This commit is contained in:
@@ -271,6 +271,7 @@ function to_style(value, styles) {
|
||||
}
|
||||
const BLOCK_OPEN = `<!--${HYDRATION_START}-->`;
|
||||
const BLOCK_CLOSE = `<!--${HYDRATION_END}-->`;
|
||||
const EMPTY_COMMENT = `<!---->`;
|
||||
let controller = null;
|
||||
function abort() {
|
||||
controller?.abort(STALE_REACTION);
|
||||
@@ -444,10 +445,10 @@ class Renderer {
|
||||
* @param {(renderer: Renderer) => void} fn
|
||||
*/
|
||||
head(fn) {
|
||||
const head = new Renderer(this.global, this);
|
||||
head.type = "head";
|
||||
this.#out.push(head);
|
||||
head.child(fn);
|
||||
const head2 = new Renderer(this.global, this);
|
||||
head2.type = "head";
|
||||
this.#out.push(head2);
|
||||
head2.child(fn);
|
||||
}
|
||||
/**
|
||||
* @param {Array<Promise<void>>} blockers
|
||||
@@ -581,7 +582,7 @@ class Renderer {
|
||||
*/
|
||||
option(attrs, body, css_hash, classes, styles, flags, is_rich) {
|
||||
this.#out.push(`<option${attributes(attrs, css_hash, classes, styles, flags)}`);
|
||||
const close = (renderer, value, { head, body: body2 }) => {
|
||||
const close = (renderer, value, { head: head2, body: body2 }) => {
|
||||
if (has_own_property.call(attrs, "value")) {
|
||||
value = attrs.value;
|
||||
}
|
||||
@@ -589,8 +590,8 @@ class Renderer {
|
||||
renderer.#out.push(' selected=""');
|
||||
}
|
||||
renderer.#out.push(`>${body2}${is_rich ? "<!>" : ""}</option>`);
|
||||
if (head) {
|
||||
renderer.head((child) => child.push(head));
|
||||
if (head2) {
|
||||
renderer.head((child) => child.push(head2));
|
||||
}
|
||||
};
|
||||
if (typeof body === "function") {
|
||||
@@ -615,8 +616,8 @@ class Renderer {
|
||||
*/
|
||||
title(fn) {
|
||||
const path = this.get_path();
|
||||
const close = (head) => {
|
||||
this.global.set_title(head, path);
|
||||
const close = (head2) => {
|
||||
this.global.set_title(head2, path);
|
||||
};
|
||||
this.child((renderer) => {
|
||||
const r = new Renderer(renderer.global, renderer);
|
||||
@@ -901,13 +902,13 @@ class Renderer {
|
||||
for (const cleanup of renderer.#collect_on_destroy()) {
|
||||
cleanup();
|
||||
}
|
||||
let head = content.head + renderer.global.get_title();
|
||||
let head2 = content.head + renderer.global.get_title();
|
||||
let body = content.body;
|
||||
for (const { hash, code } of renderer.global.css) {
|
||||
head += `<style id="${hash}">${code}</style>`;
|
||||
head2 += `<style id="${hash}">${code}</style>`;
|
||||
}
|
||||
return {
|
||||
head,
|
||||
head: head2,
|
||||
body,
|
||||
hashes: {
|
||||
script: renderer.global.csp.script_hashes
|
||||
@@ -1011,6 +1012,13 @@ function render(component, options = {}) {
|
||||
options
|
||||
);
|
||||
}
|
||||
function head(hash, renderer, fn) {
|
||||
renderer.head((renderer2) => {
|
||||
renderer2.push(`<!--${hash}-->`);
|
||||
renderer2.child(fn);
|
||||
renderer2.push(EMPTY_COMMENT);
|
||||
});
|
||||
}
|
||||
function attributes(attrs, css_hash, classes, styles, flags = 0) {
|
||||
if (styles) {
|
||||
attrs.style = to_style(attrs.style, styles);
|
||||
@@ -1062,6 +1070,9 @@ function spread_props(props) {
|
||||
}
|
||||
return merged_props;
|
||||
}
|
||||
function stringify(value) {
|
||||
return typeof value === "string" ? value : value == null ? "" : value + "";
|
||||
}
|
||||
function bind_props(props_parent, props_now) {
|
||||
for (const key of Object.keys(props_now)) {
|
||||
const initial_value = props_parent[key];
|
||||
@@ -1071,6 +1082,12 @@ function bind_props(props_parent, props_now) {
|
||||
}
|
||||
}
|
||||
}
|
||||
function ensure_array_like(array_like_or_iterator) {
|
||||
if (array_like_or_iterator) {
|
||||
return array_like_or_iterator.length !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
function once(get_value) {
|
||||
let value = (
|
||||
/** @type {V} */
|
||||
@@ -1100,67 +1117,70 @@ function derived(fn) {
|
||||
};
|
||||
}
|
||||
export {
|
||||
is_array as $,
|
||||
array_prototype as $,
|
||||
ATTACHMENT_KEY as A,
|
||||
BOUNDARY_EFFECT as B,
|
||||
COMMENT_NODE as C,
|
||||
DIRTY as D,
|
||||
ERROR_VALUE as E,
|
||||
ROOT_EFFECT as F,
|
||||
RENDER_EFFECT as G,
|
||||
BLOCK_EFFECT as F,
|
||||
deferred as G,
|
||||
HYDRATION_ERROR as H,
|
||||
INERT as I,
|
||||
MANAGED_EFFECT as J,
|
||||
HEAD_EFFECT as K,
|
||||
DESTROYED as L,
|
||||
BRANCH_EFFECT as J,
|
||||
ROOT_EFFECT as K,
|
||||
RENDER_EFFECT as L,
|
||||
MAYBE_DIRTY as M,
|
||||
ASYNC as N,
|
||||
includes as O,
|
||||
EFFECT_TRANSPARENT as P,
|
||||
EFFECT_PRESERVED as Q,
|
||||
MANAGED_EFFECT as N,
|
||||
HEAD_EFFECT as O,
|
||||
DESTROYED as P,
|
||||
ASYNC as Q,
|
||||
REACTION_RAN as R,
|
||||
STALE_REACTION as S,
|
||||
EAGER_EFFECT as T,
|
||||
includes as S,
|
||||
EFFECT_TRANSPARENT as T,
|
||||
UNINITIALIZED as U,
|
||||
STATE_SYMBOL as V,
|
||||
EFFECT_PRESERVED as V,
|
||||
WAS_MARKED as W,
|
||||
object_prototype as X,
|
||||
array_prototype as Y,
|
||||
get_descriptor as Z,
|
||||
get_prototype_of as _,
|
||||
STALE_REACTION as X,
|
||||
EAGER_EFFECT as Y,
|
||||
STATE_SYMBOL as Z,
|
||||
object_prototype as _,
|
||||
getAllContexts as a,
|
||||
is_extensible as a0,
|
||||
USER_EFFECT as a1,
|
||||
REACTION_IS_UPDATING as a2,
|
||||
index_of as a3,
|
||||
define_property as a4,
|
||||
array_from as a5,
|
||||
is_passive_event as a6,
|
||||
LEGACY_PROPS as a7,
|
||||
render as a8,
|
||||
get_descriptor as a0,
|
||||
get_prototype_of as a1,
|
||||
is_array as a2,
|
||||
is_extensible as a3,
|
||||
USER_EFFECT as a4,
|
||||
REACTION_IS_UPDATING as a5,
|
||||
index_of as a6,
|
||||
define_property as a7,
|
||||
array_from as a8,
|
||||
is_passive_event as a9,
|
||||
LEGACY_PROPS as aa,
|
||||
render as ab,
|
||||
attributes as b,
|
||||
bind_props as c,
|
||||
derived as d,
|
||||
spread_props as e,
|
||||
escape_html as f,
|
||||
head as f,
|
||||
getContext as g,
|
||||
hasContext as h,
|
||||
attr as i,
|
||||
clsx as j,
|
||||
HYDRATION_END as k,
|
||||
escape_html as i,
|
||||
ensure_array_like as j,
|
||||
attr as k,
|
||||
lifecycle_function_unavailable as l,
|
||||
HYDRATION_START as m,
|
||||
stringify as m,
|
||||
noop as n,
|
||||
HYDRATION_START_ELSE as o,
|
||||
clsx as o,
|
||||
props_id as p,
|
||||
run_all as q,
|
||||
HYDRATION_END as q,
|
||||
run as r,
|
||||
setContext as s,
|
||||
EFFECT as t,
|
||||
CONNECTED as u,
|
||||
CLEAN as v,
|
||||
DERIVED as w,
|
||||
BLOCK_EFFECT as x,
|
||||
deferred as y,
|
||||
BRANCH_EFFECT as z
|
||||
HYDRATION_START as t,
|
||||
HYDRATION_START_ELSE as u,
|
||||
run_all as v,
|
||||
EFFECT as w,
|
||||
CONNECTED as x,
|
||||
CLEAN as y,
|
||||
DERIVED as z
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user