@solidjs/web 2.0.0-experimental.9 → 2.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -4
- package/dist/dev.cjs +1585 -225
- package/dist/dev.js +1510 -201
- package/dist/server.cjs +2642 -264
- package/dist/server.js +2542 -217
- package/dist/web.cjs +1523 -218
- package/dist/web.js +1448 -194
- package/frames/dist/client.cjs +1916 -0
- package/frames/dist/client.dev.cjs +1933 -0
- package/frames/dist/client.dev.js +1921 -0
- package/frames/dist/client.js +1904 -0
- package/frames/dist/server.cjs +3667 -0
- package/frames/dist/server.js +3654 -0
- package/frames/package.json +30 -0
- package/package.json +349 -37
- package/serialization/decode/package.json +20 -0
- package/serialization/dist/decode.cjs +110 -0
- package/serialization/dist/decode.js +104 -0
- package/serialization/dist/serialization.cjs +232 -0
- package/serialization/dist/serialization.js +215 -0
- package/serialization/package.json +20 -0
- package/serialization/types/index.d.ts +182 -0
- package/serialization/types/serializer-decode.d.ts +182 -0
- package/serialization/types-cjs/index.d.cts +182 -0
- package/serialization/types-cjs/package.json +3 -0
- package/serialization/types-cjs/serializer-decode.d.cts +182 -0
- package/server-functions/dist/client.cjs +646 -0
- package/server-functions/dist/client.js +617 -0
- package/server-functions/dist/rich-args.cjs +11 -0
- package/server-functions/dist/rich-args.js +9 -0
- package/server-functions/dist/server.cjs +1077 -0
- package/server-functions/dist/server.dev.cjs +1077 -0
- package/server-functions/dist/server.dev.js +1045 -0
- package/server-functions/dist/server.js +1045 -0
- package/server-functions/package.json +40 -0
- package/server-functions/rich-args/package.json +20 -0
- package/storage/package.json +8 -3
- package/storage/types/index.d.ts +26 -0
- package/storage/types-cjs/index.d.cts +28 -0
- package/storage/types-cjs/package.json +3 -0
- package/types/client.d.ts +290 -27
- package/types/cookies.d.ts +93 -0
- package/types/core.d.ts +6 -2
- package/types/frames/client.d.ts +36 -0
- package/types/frames/frame-client.d.ts +338 -0
- package/types/frames/frame-sink.d.ts +194 -0
- package/types/frames/frame-transport.d.ts +222 -0
- package/types/frames/serializer.d.ts +182 -0
- package/types/frames/server.d.ts +52 -0
- package/types/index.d.ts +209 -24
- package/types/jsx-properties.d.ts +93 -0
- package/types/jsx.d.ts +4150 -1
- package/types/response.d.ts +174 -0
- package/types/serializer-decode.d.ts +182 -0
- package/types/serializer.d.ts +182 -0
- package/types/server-functions/client.d.ts +201 -0
- package/types/server-functions/flash.d.ts +38 -0
- package/types/server-functions/rich-args.d.ts +10 -0
- package/types/server-functions/server.d.ts +588 -0
- package/types/server-functions/shared.d.ts +523 -0
- package/types/server-mock.d.ts +249 -12
- package/types/server.d.ts +424 -51
- package/types-cjs/client.d.cts +337 -0
- package/types-cjs/cookies.d.cts +93 -0
- package/types-cjs/core.d.cts +6 -0
- package/types-cjs/frames/client.d.cts +36 -0
- package/types-cjs/frames/frame-client.d.cts +338 -0
- package/types-cjs/frames/frame-sink.d.cts +194 -0
- package/types-cjs/frames/frame-transport.d.cts +222 -0
- package/types-cjs/frames/serializer.d.cts +182 -0
- package/types-cjs/frames/server.d.cts +52 -0
- package/types-cjs/index.d.cts +230 -0
- package/types-cjs/jsx-properties.d.cts +93 -0
- package/types-cjs/jsx.d.cts +4150 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/response.d.cts +174 -0
- package/types-cjs/serializer-decode.d.cts +182 -0
- package/types-cjs/serializer.d.cts +182 -0
- package/types-cjs/server-functions/client.d.cts +201 -0
- package/types-cjs/server-functions/flash.d.cts +38 -0
- package/types-cjs/server-functions/rich-args.d.cts +10 -0
- package/types-cjs/server-functions/server.d.cts +588 -0
- package/types-cjs/server-functions/shared.d.cts +523 -0
- package/types-cjs/server-mock.d.cts +277 -0
- package/types-cjs/server.d.cts +523 -0
package/dist/dev.js
CHANGED
|
@@ -1,33 +1,91 @@
|
|
|
1
|
-
import { createMemo,
|
|
2
|
-
export {
|
|
1
|
+
import { createRenderEffect, createMemo, runWithOwner, sharedConfig, untrack, flatten, createRoot, merge, createComponent, omit, createOwner, createSignal, $DEVCOMP, onCleanup, enableHydration, enforceLoadingBoundary, flush, getOwner, createEffect } from 'solid-js';
|
|
2
|
+
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const DOMWithState = {
|
|
5
|
+
INPUT: {
|
|
6
|
+
value: 1,
|
|
7
|
+
defaultValue: 2,
|
|
8
|
+
checked: 1,
|
|
9
|
+
defaultChecked: 2
|
|
10
|
+
},
|
|
11
|
+
SELECT: {
|
|
12
|
+
value: 1
|
|
13
|
+
},
|
|
14
|
+
OPTION: {
|
|
15
|
+
value: 1,
|
|
16
|
+
selected: 1,
|
|
17
|
+
defaultSelected: 2
|
|
18
|
+
},
|
|
19
|
+
TEXTAREA: {
|
|
20
|
+
value: 1,
|
|
21
|
+
defaultValue: 2
|
|
22
|
+
},
|
|
23
|
+
VIDEO: {
|
|
24
|
+
muted: 1,
|
|
25
|
+
defaultMuted: 2
|
|
26
|
+
},
|
|
27
|
+
AUDIO: {
|
|
28
|
+
muted: 1,
|
|
29
|
+
defaultMuted: 2
|
|
30
|
+
}
|
|
31
|
+
};
|
|
6
32
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
33
|
+
const $$SLOT = /*#__PURE__*/Symbol("slot");
|
|
34
|
+
const $$HOST = /*#__PURE__*/Symbol("host");
|
|
7
35
|
const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
|
|
8
36
|
const SVGElements = /*#__PURE__*/new Set([
|
|
9
37
|
"altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
|
|
10
38
|
"set", "stop",
|
|
11
39
|
"svg", "switch", "symbol", "text", "textPath",
|
|
12
40
|
"tref", "tspan", "use", "view", "vkern"]);
|
|
13
|
-
const
|
|
41
|
+
const MathMLElements = /*#__PURE__*/new Set(["annotation", "annotation-xml", "maction", "math", "menclose", "merror", "mfenced", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"]);
|
|
42
|
+
const Namespaces = {
|
|
43
|
+
svg: "http://www.w3.org/2000/svg",
|
|
44
|
+
mathml: "http://www.w3.org/1998/Math/MathML",
|
|
14
45
|
xlink: "http://www.w3.org/1999/xlink",
|
|
15
46
|
xml: "http://www.w3.org/XML/1998/namespace"
|
|
16
47
|
};
|
|
17
|
-
const
|
|
18
|
-
"
|
|
19
|
-
"isindex
|
|
48
|
+
const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
49
|
+
const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
|
|
50
|
+
const DOMElements = /*#__PURE__*/new Set(/*#__PURE__*/"a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,isindex,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,math,menu,menuitem,meta,meter,multicol,nav,nextid,nobr,noembed,noframes,noindex,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,portal,pre,progress,q,rb,rp,rt,rtc,ruby,s,samp,script,search,section,select,shadow,slot,small,source,spacer,span,strike,strong,style,sub,summary,sup,svg,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,webview,xmp".split(","));
|
|
20
51
|
|
|
21
|
-
const
|
|
52
|
+
const transparentOptions = {
|
|
53
|
+
transparent: true,
|
|
54
|
+
sync: true
|
|
55
|
+
};
|
|
56
|
+
const syncOptions = {
|
|
57
|
+
sync: true
|
|
58
|
+
};
|
|
59
|
+
const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, options ? {
|
|
60
|
+
sync: true,
|
|
61
|
+
...options,
|
|
62
|
+
transparent: !options.scope
|
|
63
|
+
} : transparentOptions);
|
|
64
|
+
const memo = fn => createMemo(() => fn(), syncOptions);
|
|
65
|
+
const assetGates = new WeakMap();
|
|
66
|
+
const waitAsset = promise => {
|
|
67
|
+
let gate = assetGates.get(promise);
|
|
68
|
+
if (!gate) {
|
|
69
|
+
runWithOwner(null, () => {
|
|
70
|
+
gate = createMemo(() => promise);
|
|
71
|
+
});
|
|
72
|
+
assetGates.set(promise, gate);
|
|
73
|
+
}
|
|
74
|
+
gate();
|
|
75
|
+
};
|
|
22
76
|
|
|
23
|
-
function reconcileArrays(parentNode, a, b) {
|
|
77
|
+
function reconcileArrays(parentNode, a, b, marker) {
|
|
24
78
|
let bLength = b.length,
|
|
25
79
|
aEnd = a.length,
|
|
26
80
|
bEnd = bLength,
|
|
27
81
|
aStart = 0,
|
|
28
82
|
bStart = 0,
|
|
29
|
-
|
|
30
|
-
|
|
83
|
+
tail = a[aEnd - 1],
|
|
84
|
+
tailTag = tail[$$SLOT],
|
|
85
|
+
after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
|
|
86
|
+
map = null,
|
|
87
|
+
anchor,
|
|
88
|
+
anchorTag;
|
|
31
89
|
while (aStart < aEnd || bStart < bEnd) {
|
|
32
90
|
if (a[aStart] === b[bStart]) {
|
|
33
91
|
aStart++;
|
|
@@ -39,18 +97,43 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
39
97
|
bEnd--;
|
|
40
98
|
}
|
|
41
99
|
if (aEnd === aStart) {
|
|
42
|
-
|
|
43
|
-
|
|
100
|
+
let node;
|
|
101
|
+
if (bEnd < bLength) {
|
|
102
|
+
if (bStart) {
|
|
103
|
+
const prev = b[bStart - 1];
|
|
104
|
+
const prevTag = prev[$$SLOT];
|
|
105
|
+
node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
|
|
106
|
+
} else node = b[bEnd - bStart];
|
|
107
|
+
} else node = after;
|
|
108
|
+
while (bStart < bEnd) {
|
|
109
|
+
const n = b[bStart++];
|
|
110
|
+
parentNode.insertBefore(n, node);
|
|
111
|
+
if (marker) n[$$SLOT] = marker;
|
|
112
|
+
}
|
|
44
113
|
} else if (bEnd === bStart) {
|
|
45
114
|
while (aStart < aEnd) {
|
|
46
|
-
|
|
47
|
-
|
|
115
|
+
const n = a[aStart++];
|
|
116
|
+
if (!map || !map.has(n)) {
|
|
117
|
+
const tag = n[$$SLOT];
|
|
118
|
+
if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
} else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
|
|
122
|
+
if (marker) {
|
|
123
|
+
do {
|
|
124
|
+
const n = a[--aEnd];
|
|
125
|
+
parentNode.insertBefore(n, anchor);
|
|
126
|
+
n[$$SLOT] = marker;
|
|
127
|
+
bStart++;
|
|
128
|
+
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
129
|
+
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
130
|
+
} else {
|
|
131
|
+
do {
|
|
132
|
+
parentNode.insertBefore(a[--aEnd], anchor);
|
|
133
|
+
bStart++;
|
|
134
|
+
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
135
|
+
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
48
136
|
}
|
|
49
|
-
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
50
|
-
const node = a[--aEnd].nextSibling;
|
|
51
|
-
parentNode.insertBefore(b[bStart++], a[aStart++].nextSibling);
|
|
52
|
-
parentNode.insertBefore(b[--bEnd], node);
|
|
53
|
-
a[aEnd] = b[bEnd];
|
|
54
137
|
} else {
|
|
55
138
|
if (!map) {
|
|
56
139
|
map = new Map();
|
|
@@ -68,78 +151,338 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
68
151
|
sequence++;
|
|
69
152
|
}
|
|
70
153
|
if (sequence > index - bStart) {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
154
|
+
const head = a[aStart];
|
|
155
|
+
const headTag = head[$$SLOT];
|
|
156
|
+
const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
|
|
157
|
+
while (bStart < index) {
|
|
158
|
+
const n = b[bStart++];
|
|
159
|
+
parentNode.insertBefore(n, node);
|
|
160
|
+
if (marker) n[$$SLOT] = marker;
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
const oldNode = a[aStart++];
|
|
164
|
+
const newNode = b[bStart++];
|
|
165
|
+
const oldTag = oldNode[$$SLOT];
|
|
166
|
+
if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
|
|
167
|
+
parentNode.replaceChild(newNode, oldNode);
|
|
168
|
+
} else {
|
|
169
|
+
parentNode.insertBefore(newNode, after);
|
|
170
|
+
}
|
|
171
|
+
if (marker) newNode[$$SLOT] = marker;
|
|
172
|
+
}
|
|
74
173
|
} else aStart++;
|
|
75
|
-
} else
|
|
174
|
+
} else {
|
|
175
|
+
const n = a[aStart++];
|
|
176
|
+
const nTag = n[$$SLOT];
|
|
177
|
+
if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
|
|
178
|
+
}
|
|
76
179
|
}
|
|
77
180
|
}
|
|
78
181
|
}
|
|
79
182
|
|
|
80
|
-
const
|
|
81
|
-
|
|
183
|
+
const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
|
|
184
|
+
const HEAD_ATTR_NAME = /^[a-zA-Z_][a-zA-Z0-9_:.-]*$/;
|
|
185
|
+
const RESOURCE_LINK_RELS = new Set(["preload", "modulepreload", "prefetch", "preconnect", "dns-prefetch", "stylesheet"]);
|
|
186
|
+
const RESOURCE_QUALIFIERS = ["as", "crossorigin", "type", "media", "imagesrcset", "imagesizes"];
|
|
187
|
+
const STYLESHEET_FETCH_META = new Set(["crossorigin", "integrity", "referrerpolicy", "fetchpriority"]);
|
|
188
|
+
function evalHeadValue(v) {
|
|
189
|
+
return typeof v === "function" ? v() : v;
|
|
190
|
+
}
|
|
191
|
+
function evalHeadProps(props, presets) {
|
|
192
|
+
const out = {};
|
|
193
|
+
for (const name in props) out[name] = presets && name in presets ? presets[name] : evalHeadValue(props[name]);
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
196
|
+
function classifyHeadTag(desc) {
|
|
197
|
+
const tag = desc.tag;
|
|
198
|
+
if (tag === "link") {
|
|
199
|
+
const rel = evalHeadValue(desc.props && desc.props.rel);
|
|
200
|
+
return {
|
|
201
|
+
resource: RESOURCE_LINK_RELS.has(rel),
|
|
202
|
+
rel
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
if (tag === "style") return {
|
|
206
|
+
resource: !!(desc.props && "href" in desc.props)
|
|
207
|
+
};
|
|
208
|
+
if (tag === "script") return {
|
|
209
|
+
resource: !!(desc.props && "src" in desc.props)
|
|
210
|
+
};
|
|
211
|
+
return {
|
|
212
|
+
resource: false
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function resourceIdentity(tag, props) {
|
|
216
|
+
let id = "res:" + tag + ":" + (props.rel || "") + ":" + (props.href || props.src || "");
|
|
217
|
+
for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
|
|
218
|
+
const q = RESOURCE_QUALIFIERS[i];
|
|
219
|
+
if (props[q] != null) id += ":" + q + "=" + props[q];
|
|
220
|
+
}
|
|
221
|
+
return id;
|
|
222
|
+
}
|
|
223
|
+
function replaceableIdentity(tag, props, key, unique) {
|
|
224
|
+
if (tag === "title") return "title";
|
|
225
|
+
if (tag === "base") return "base";
|
|
226
|
+
if (tag === "meta" && props.charset != null) return "charset";
|
|
227
|
+
if (key != null) return tag + ":key:" + key;
|
|
228
|
+
if (tag === "meta") {
|
|
229
|
+
for (const ns of ["name", "property", "http-equiv"]) if (props[ns] != null) return "meta:" + ns + ":" + props[ns] + (props.media != null ? ":media=" + props.media : "");
|
|
230
|
+
return unique;
|
|
231
|
+
}
|
|
232
|
+
if (tag === "link") {
|
|
233
|
+
const rel = props.rel || "";
|
|
234
|
+
if (rel === "icon" || rel === "apple-touch-icon") return "link:" + rel + (props.sizes != null ? ":sizes=" + props.sizes : "") + (props.type != null ? ":type=" + props.type : "");
|
|
235
|
+
return "link:" + rel + ":" + (props.href || "");
|
|
236
|
+
}
|
|
237
|
+
return unique;
|
|
238
|
+
}
|
|
239
|
+
function resolveHead(groups) {
|
|
240
|
+
const winners = new Map();
|
|
241
|
+
const sorted = groups.slice().sort((a, b) => a.seq - b.seq);
|
|
242
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
243
|
+
const group = sorted[i];
|
|
244
|
+
const byIdentity = new Map();
|
|
245
|
+
for (let j = 0; j < group.tags.length; j++) {
|
|
246
|
+
const t = group.tags[j];
|
|
247
|
+
let list = byIdentity.get(t.identity);
|
|
248
|
+
if (!list) byIdentity.set(t.identity, list = []);
|
|
249
|
+
list.push(t);
|
|
250
|
+
}
|
|
251
|
+
for (const [identity, tags] of byIdentity) {
|
|
252
|
+
if (identity === "title") {
|
|
253
|
+
if (tags.length > 1) console.warn("Multiple <title> tags in one head group; the last one wins.");
|
|
254
|
+
winners.set(identity, {
|
|
255
|
+
seq: group.seq,
|
|
256
|
+
tags: [tags[tags.length - 1]]
|
|
257
|
+
});
|
|
258
|
+
} else {
|
|
259
|
+
winners.set(identity, {
|
|
260
|
+
seq: group.seq,
|
|
261
|
+
tags
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return winners;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function parseCookieHeader(header) {
|
|
270
|
+
const cookies = {};
|
|
271
|
+
if (!header) return cookies;
|
|
272
|
+
for (const part of header.split(";")) {
|
|
273
|
+
const eq = part.indexOf("=");
|
|
274
|
+
if (eq < 0) continue;
|
|
275
|
+
const name = decodeSafe(part.slice(0, eq).trim());
|
|
276
|
+
let value = part.slice(eq + 1).trim();
|
|
277
|
+
if (value.length > 1 && value[0] === '"' && value[value.length - 1] === '"') {
|
|
278
|
+
value = value.slice(1, -1);
|
|
279
|
+
}
|
|
280
|
+
cookies[name] = decodeSafe(value);
|
|
281
|
+
}
|
|
282
|
+
return cookies;
|
|
283
|
+
}
|
|
284
|
+
function decodeSafe(text) {
|
|
285
|
+
try {
|
|
286
|
+
return decodeURIComponent(text);
|
|
287
|
+
} catch {
|
|
288
|
+
return text;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function serializeCookie(name, value, options = {}) {
|
|
292
|
+
let cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
|
|
293
|
+
cookie += `; Path=${options.path === undefined ? "/" : options.path}`;
|
|
294
|
+
if (options.domain) cookie += `; Domain=${options.domain}`;
|
|
295
|
+
if (options.maxAge !== undefined) cookie += `; Max-Age=${Math.trunc(options.maxAge)}`;
|
|
296
|
+
if (options.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
|
|
297
|
+
if (options.httpOnly) cookie += "; HttpOnly";
|
|
298
|
+
if (options.secure) cookie += "; Secure";
|
|
299
|
+
if (options.sameSite) {
|
|
300
|
+
const sameSite = options.sameSite.toLowerCase();
|
|
301
|
+
cookie += `; SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`;
|
|
302
|
+
}
|
|
303
|
+
return cookie;
|
|
304
|
+
}
|
|
305
|
+
const FLASH_COOKIE = "flash";
|
|
306
|
+
const FLASH_MATCHER = new RegExp(`(?:^|;\\s*)${FLASH_COOKIE}=([^;]+)`);
|
|
307
|
+
function hasFlashCookie(cookieHeader) {
|
|
308
|
+
return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
|
|
309
|
+
}
|
|
310
|
+
function clearFlashCookie() {
|
|
311
|
+
return `${FLASH_COOKIE}=; Max-Age=0; Path=/`;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const SERVER_FUNCTION_METADATA = Symbol.for("solid.ServerFunctionMetadata");
|
|
315
|
+
function getServerFunctionMetadata(fn) {
|
|
316
|
+
if (typeof fn !== "function") return undefined;
|
|
317
|
+
return fn[SERVER_FUNCTION_METADATA] || undefined;
|
|
318
|
+
}
|
|
319
|
+
function isServerFunction(fn) {
|
|
320
|
+
return typeof fn === "function" && !!fn[SERVER_FUNCTION_METADATA];
|
|
321
|
+
}
|
|
322
|
+
const SERVER_FUNCTION_RPC = Symbol.for("solid.ServerFunctionRPC");
|
|
323
|
+
function getServerFunctionRPC() {
|
|
324
|
+
return globalThis[SERVER_FUNCTION_RPC];
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const $$EVENT_OWNER = "_$DX_EVENT_OWNER";
|
|
328
|
+
const INNER_OWNED = {};
|
|
329
|
+
const delegatedEvents = new Set();
|
|
330
|
+
const delegatedContainers = new Map();
|
|
331
|
+
function render$1(code, element, init, options = {}) {
|
|
82
332
|
if (!element) {
|
|
83
333
|
throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
|
|
84
334
|
}
|
|
85
335
|
let disposer;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
336
|
+
registerDelegatedRoot(element);
|
|
337
|
+
try {
|
|
338
|
+
createRoot(dispose => {
|
|
339
|
+
disposer = dispose;
|
|
340
|
+
if (element === document) {
|
|
341
|
+
const tree = code();
|
|
342
|
+
effect(() => flatten(tree), () => {});
|
|
343
|
+
} else {
|
|
344
|
+
const tree = code();
|
|
345
|
+
insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
|
|
346
|
+
}
|
|
347
|
+
}, {
|
|
348
|
+
id: options.renderId
|
|
349
|
+
});
|
|
350
|
+
} catch (err) {
|
|
351
|
+
if (disposer) disposer();
|
|
352
|
+
unregisterDelegatedRoot(element);
|
|
353
|
+
throw err;
|
|
354
|
+
}
|
|
92
355
|
return () => {
|
|
93
356
|
disposer();
|
|
357
|
+
unregisterDelegatedRoot(element);
|
|
94
358
|
element.textContent = "";
|
|
95
359
|
};
|
|
96
360
|
}
|
|
97
|
-
function
|
|
361
|
+
function create(html, bypassGuard, flag) {
|
|
362
|
+
if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
|
|
363
|
+
const t = document.createElement("template");
|
|
364
|
+
t.innerHTML = html;
|
|
365
|
+
return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
366
|
+
}
|
|
367
|
+
function template(html, flag) {
|
|
98
368
|
let node;
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
t.innerHTML = html;
|
|
103
|
-
return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
|
|
104
|
-
};
|
|
105
|
-
return isImportNode ? () => untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
|
|
369
|
+
const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
|
|
370
|
+
fn._html = flag === 2 ? html.replace(/^<[^>]+>/, "") : html;
|
|
371
|
+
return fn;
|
|
106
372
|
}
|
|
107
|
-
function delegateEvents(eventNames
|
|
108
|
-
const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
|
|
373
|
+
function delegateEvents(eventNames) {
|
|
109
374
|
for (let i = 0, l = eventNames.length; i < l; i++) {
|
|
110
375
|
const name = eventNames[i];
|
|
111
|
-
if (!
|
|
112
|
-
|
|
113
|
-
|
|
376
|
+
if (!delegatedEvents.has(name)) {
|
|
377
|
+
delegatedEvents.add(name);
|
|
378
|
+
delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
|
|
114
379
|
}
|
|
115
380
|
}
|
|
116
381
|
}
|
|
117
|
-
function
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
382
|
+
function registerDelegatedRoot(root) {
|
|
383
|
+
const state = registerDelegatedContainer(root, root);
|
|
384
|
+
if (state) state.roots = (state.roots || 0) + 1;
|
|
385
|
+
}
|
|
386
|
+
function unregisterDelegatedRoot(root) {
|
|
387
|
+
const state = delegatedContainers.get(root);
|
|
388
|
+
if (state) state.roots > 1 ? state.roots-- : delete state.roots;
|
|
389
|
+
unregisterDelegatedContainer(root, root);
|
|
390
|
+
}
|
|
391
|
+
function registerDelegatedContainer(container, owner = container) {
|
|
392
|
+
if (!container || !owner) return;
|
|
393
|
+
let state = delegatedContainers.get(container);
|
|
394
|
+
if (!state) delegatedContainers.set(container, state = {
|
|
395
|
+
owners: new Map(),
|
|
396
|
+
handlers: new Map()
|
|
397
|
+
});
|
|
398
|
+
state.owners.set(owner, (state.owners.get(owner) || 0) + 1);
|
|
399
|
+
delegatedEvents.forEach(name => attachDelegatedEvent(name, container, state));
|
|
400
|
+
return state;
|
|
401
|
+
}
|
|
402
|
+
function unregisterDelegatedContainer(container, owner = container) {
|
|
403
|
+
const state = delegatedContainers.get(container);
|
|
404
|
+
if (!state) return;
|
|
405
|
+
const count = state.owners.get(owner);
|
|
406
|
+
if (count > 1) state.owners.set(owner, count - 1);else state.owners.delete(owner);
|
|
407
|
+
if (state.owners.size) return;
|
|
408
|
+
state.handlers.forEach((handler, name) => container.removeEventListener(name, handler));
|
|
409
|
+
delegatedContainers.delete(container);
|
|
410
|
+
}
|
|
411
|
+
function attachDelegatedEvent(name, container, state) {
|
|
412
|
+
if (state.handlers.has(name)) return;
|
|
413
|
+
const handler = e => eventHandler(e, container, state);
|
|
414
|
+
state.handlers.set(name, handler);
|
|
415
|
+
container.addEventListener(name, handler);
|
|
416
|
+
}
|
|
417
|
+
function getDelegatedRoot(node) {
|
|
418
|
+
while (node) {
|
|
419
|
+
if (delegatedContainers.get(node)?.roots) return node;
|
|
420
|
+
node = node._$host || node.parentNode || node.host;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
function findOwner(target, state) {
|
|
424
|
+
let node = target;
|
|
425
|
+
let distance = 0;
|
|
426
|
+
while (node) {
|
|
427
|
+
if (state.owners.has(node)) return {
|
|
428
|
+
owner: node,
|
|
429
|
+
distance
|
|
430
|
+
};
|
|
431
|
+
distance++;
|
|
432
|
+
node = node._$host || node.parentNode || node.host;
|
|
121
433
|
}
|
|
122
434
|
}
|
|
123
435
|
function setProperty(node, name, value) {
|
|
124
436
|
if (isHydrating(node)) return;
|
|
125
437
|
node[name] = value;
|
|
126
438
|
}
|
|
439
|
+
let claimHandlers = null;
|
|
440
|
+
const CLAIM_SEAM = Symbol.for("dom-expressions.element-claims");
|
|
441
|
+
function registerElementClaim(handler) {
|
|
442
|
+
(claimHandlers || (claimHandlers = globalThis[CLAIM_SEAM] = [])).push(handler);
|
|
443
|
+
return () => {
|
|
444
|
+
const index = claimHandlers.indexOf(handler);
|
|
445
|
+
index > -1 && claimHandlers.splice(index, 1);
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
const CLAIMED_ELEMENTS = "a[href], form[action]";
|
|
449
|
+
function claimElementTree(root) {
|
|
450
|
+
const handlers = globalThis[CLAIM_SEAM];
|
|
451
|
+
if (handlers === undefined || handlers.length === 0) return root;
|
|
452
|
+
const isElement = root.nodeType === 1;
|
|
453
|
+
if (!isElement && root.nodeType !== 11) return root;
|
|
454
|
+
if (isElement && root.matches(CLAIMED_ELEMENTS)) {
|
|
455
|
+
for (let i = 0; i < handlers.length; i++) handlers[i](root);
|
|
456
|
+
}
|
|
457
|
+
const found = root.querySelectorAll(CLAIMED_ELEMENTS);
|
|
458
|
+
for (let i = 0; i < found.length; i++) {
|
|
459
|
+
for (let j = 0; j < handlers.length; j++) handlers[j](found[i]);
|
|
460
|
+
}
|
|
461
|
+
return root;
|
|
462
|
+
}
|
|
463
|
+
function claimElement(node) {
|
|
464
|
+
if (claimHandlers !== null) {
|
|
465
|
+
for (let i = 0; i < claimHandlers.length; i++) claimHandlers[i](node);
|
|
466
|
+
}
|
|
467
|
+
return node;
|
|
468
|
+
}
|
|
127
469
|
function setAttribute(node, name, value) {
|
|
128
470
|
if (isHydrating(node)) return;
|
|
129
471
|
if (value == null || value === false) node.removeAttribute(name);else node.setAttribute(name, value === true ? "" : value);
|
|
472
|
+
if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
|
|
130
473
|
}
|
|
131
474
|
function setAttributeNS(node, namespace, name, value) {
|
|
132
475
|
if (isHydrating(node)) return;
|
|
133
|
-
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
476
|
+
if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
134
477
|
}
|
|
135
|
-
function className(node, value,
|
|
478
|
+
function className(node, value, prev) {
|
|
136
479
|
if (isHydrating(node)) return;
|
|
137
480
|
if (value == null || value === false) {
|
|
138
481
|
prev && node.removeAttribute("class");
|
|
139
482
|
return;
|
|
140
483
|
}
|
|
141
484
|
if (typeof value === "string") {
|
|
142
|
-
value !== prev &&
|
|
485
|
+
value !== prev && node.setAttribute("class", value);
|
|
143
486
|
return;
|
|
144
487
|
}
|
|
145
488
|
if (typeof prev === "string") {
|
|
@@ -153,16 +496,16 @@ function className(node, value, isSVG, prev) {
|
|
|
153
496
|
for (i = 0, len = prevKeys.length; i < len; i++) {
|
|
154
497
|
const key = prevKeys[i];
|
|
155
498
|
if (!key || key === "undefined" || value[key]) continue;
|
|
156
|
-
|
|
499
|
+
node.classList.remove(key);
|
|
157
500
|
}
|
|
158
501
|
for (i = 0, len = classKeys.length; i < len; i++) {
|
|
159
502
|
const key = classKeys[i],
|
|
160
503
|
classValue = !!value[key];
|
|
161
504
|
if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue;
|
|
162
|
-
|
|
505
|
+
node.classList.add(key);
|
|
163
506
|
}
|
|
164
507
|
}
|
|
165
|
-
function
|
|
508
|
+
function addEvent(node, name, handler, delegate) {
|
|
166
509
|
if (delegate) {
|
|
167
510
|
if (Array.isArray(handler)) {
|
|
168
511
|
node[`$$${name}`] = handler[0];
|
|
@@ -175,42 +518,60 @@ function addEventListener(node, name, handler, delegate) {
|
|
|
175
518
|
}
|
|
176
519
|
function style(node, value, prev) {
|
|
177
520
|
if (!value) {
|
|
178
|
-
prev
|
|
521
|
+
if (prev || node._$styles) {
|
|
522
|
+
setAttribute(node, "style");
|
|
523
|
+
node._$styles = undefined;
|
|
524
|
+
}
|
|
179
525
|
return;
|
|
180
526
|
}
|
|
181
527
|
const nodeStyle = node.style;
|
|
182
|
-
if (typeof value === "string")
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
528
|
+
if (typeof value === "string") {
|
|
529
|
+
node._$styles = undefined;
|
|
530
|
+
return nodeStyle.cssText = value;
|
|
531
|
+
}
|
|
532
|
+
if (typeof prev === "string") {
|
|
533
|
+
nodeStyle.cssText = "";
|
|
534
|
+
prev = undefined;
|
|
535
|
+
}
|
|
536
|
+
let applied = node._$styles;
|
|
537
|
+
if (!applied) {
|
|
538
|
+
applied = node._$styles = prev ? {
|
|
539
|
+
...prev
|
|
540
|
+
} : {};
|
|
541
|
+
}
|
|
186
542
|
let v, s;
|
|
543
|
+
for (s in applied) {
|
|
544
|
+
if (value[s] == null) {
|
|
545
|
+
nodeStyle.removeProperty(s);
|
|
546
|
+
delete applied[s];
|
|
547
|
+
}
|
|
548
|
+
}
|
|
187
549
|
for (s in value) {
|
|
188
550
|
v = value[s];
|
|
189
|
-
if (v !==
|
|
190
|
-
|
|
551
|
+
if (v != null && v !== applied[s]) {
|
|
552
|
+
nodeStyle.setProperty(s, v);
|
|
553
|
+
applied[s] = v;
|
|
554
|
+
}
|
|
191
555
|
}
|
|
192
|
-
for (s in prev) value[s] == null && nodeStyle.removeProperty(s);
|
|
193
556
|
}
|
|
194
557
|
function setStyleProperty(node, name, value) {
|
|
195
558
|
value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
|
|
196
559
|
}
|
|
197
|
-
function spread(node, props = {},
|
|
560
|
+
function spread(node, props = {}, skipChildren) {
|
|
198
561
|
const prevProps = {};
|
|
199
|
-
if (!skipChildren)
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
createRenderEffect(() => typeof props.ref === "function" && use(props.ref, node), () => {});
|
|
206
|
-
createRenderEffect(() => {
|
|
562
|
+
if (!skipChildren) insert(node, () => props.children);
|
|
563
|
+
effect(() => {
|
|
564
|
+
const r = props.ref;
|
|
565
|
+
(typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
|
|
566
|
+
}, () => {});
|
|
567
|
+
effect(() => {
|
|
207
568
|
const newProps = {};
|
|
208
569
|
for (const prop in props) {
|
|
209
570
|
if (prop === "children" || prop === "ref") continue;
|
|
210
571
|
newProps[prop] = props[prop];
|
|
211
572
|
}
|
|
212
573
|
return newProps;
|
|
213
|
-
}, props => assign(node, props,
|
|
574
|
+
}, props => assign(node, props, true, prevProps, true));
|
|
214
575
|
return prevProps;
|
|
215
576
|
}
|
|
216
577
|
function dynamicProperty(props, key) {
|
|
@@ -223,48 +584,628 @@ function dynamicProperty(props, key) {
|
|
|
223
584
|
});
|
|
224
585
|
return props;
|
|
225
586
|
}
|
|
226
|
-
function
|
|
227
|
-
|
|
587
|
+
function applyRef(r, element) {
|
|
588
|
+
Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
|
|
589
|
+
}
|
|
590
|
+
function ref(fn, element) {
|
|
591
|
+
const resolved = untrack(fn);
|
|
592
|
+
runWithOwner(null, () => applyRef(resolved, element));
|
|
593
|
+
}
|
|
594
|
+
function scope(fn) {
|
|
595
|
+
fn.$s = true;
|
|
596
|
+
return fn;
|
|
597
|
+
}
|
|
598
|
+
const SCOPE_OPTIONS = {
|
|
599
|
+
scope: true
|
|
600
|
+
};
|
|
601
|
+
let hydrationRt = null;
|
|
602
|
+
function installHydrationRuntime() {
|
|
603
|
+
hydrationRt = {
|
|
604
|
+
claimInitial(parent, multi, initial) {
|
|
605
|
+
if (isHydrating(parent)) {
|
|
606
|
+
if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
|
|
607
|
+
if (Array.isArray(initial)) stripTextSeparators(initial);
|
|
608
|
+
}
|
|
609
|
+
return initial;
|
|
610
|
+
},
|
|
611
|
+
reclaimRegion(current, parent, marker) {
|
|
612
|
+
if (!sharedConfig.hydrating || !current || !parent.isConnected) return current;
|
|
613
|
+
const first = Array.isArray(current) ? current[0] : current;
|
|
614
|
+
if (!first || !first.nodeType || first.isConnected) return current;
|
|
615
|
+
let nodes;
|
|
616
|
+
if (marker) {
|
|
617
|
+
nodes = [];
|
|
618
|
+
let node = marker.previousSibling,
|
|
619
|
+
depth = 0;
|
|
620
|
+
while (node) {
|
|
621
|
+
if (node.nodeType === 8) {
|
|
622
|
+
const v = node.nodeValue;
|
|
623
|
+
if (v === "/") depth++;else if (v === "$") {
|
|
624
|
+
if (depth === 0) break;
|
|
625
|
+
depth--;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
nodes.unshift(node);
|
|
629
|
+
node = node.previousSibling;
|
|
630
|
+
}
|
|
631
|
+
} else nodes = [...parent.childNodes];
|
|
632
|
+
return stripTextSeparators(nodes);
|
|
633
|
+
},
|
|
634
|
+
dedupEvent(e) {
|
|
635
|
+
return !!(sharedConfig.registry && sharedConfig.events && sharedConfig.events.find(([el, ev]) => ev === e));
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
function stripTextSeparators(nodes) {
|
|
640
|
+
let j = 0;
|
|
641
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
642
|
+
const node = nodes[i],
|
|
643
|
+
t = node.nodeType;
|
|
644
|
+
if (t === 8) {
|
|
645
|
+
const v = node.nodeValue;
|
|
646
|
+
if (v === "!$") {
|
|
647
|
+
node.remove();
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
650
|
+
if (v.startsWith("pl-")) continue;
|
|
651
|
+
} else if (t === 1 && node.localName === "template" && node.id.startsWith("pl-")) continue;
|
|
652
|
+
nodes[j++] = node;
|
|
653
|
+
}
|
|
654
|
+
nodes.length = j;
|
|
655
|
+
return nodes;
|
|
228
656
|
}
|
|
229
|
-
function insert(parent, accessor, marker, initial) {
|
|
657
|
+
function insert(parent, accessor, marker, initial, options) {
|
|
230
658
|
const multi = marker !== undefined;
|
|
659
|
+
const host = options && options.host;
|
|
231
660
|
if (multi && !initial) initial = [];
|
|
661
|
+
if (hydrationRt !== null) initial = hydrationRt.claimInitial(parent, multi, initial);
|
|
232
662
|
if (typeof accessor !== "function") {
|
|
233
663
|
accessor = normalize(accessor, initial, multi, true);
|
|
234
|
-
if (typeof accessor !== "function")
|
|
664
|
+
if (typeof accessor !== "function") {
|
|
665
|
+
insertExpression(parent, accessor, initial, marker);
|
|
666
|
+
host && tagHost(accessor, host);
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
if (multi && initial.length === 0) {
|
|
671
|
+
const placeholder = document.createTextNode("");
|
|
672
|
+
parent.insertBefore(placeholder, marker);
|
|
673
|
+
initial = [placeholder];
|
|
235
674
|
}
|
|
236
|
-
|
|
675
|
+
let current = initial;
|
|
676
|
+
effect(prev => {
|
|
677
|
+
if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
|
|
678
|
+
const value = normalize(accessor(), current, multi, true);
|
|
679
|
+
if (typeof value !== "function") return value;
|
|
680
|
+
effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
|
|
681
|
+
current = insertExpression(parent, inner, current, marker);
|
|
682
|
+
host && tagHost(current, host);
|
|
683
|
+
}, prev !== undefined && !(options && options.schedule) ? {
|
|
684
|
+
...options,
|
|
685
|
+
schedule: true
|
|
686
|
+
} : options);
|
|
687
|
+
return INNER_OWNED;
|
|
688
|
+
}, value => {
|
|
689
|
+
if (value === INNER_OWNED) return;
|
|
690
|
+
current = insertExpression(parent, value, current, marker);
|
|
691
|
+
host && tagHost(current, host);
|
|
692
|
+
},
|
|
693
|
+
accessor.$s ? options ? {
|
|
694
|
+
...options,
|
|
695
|
+
scope: true
|
|
696
|
+
} : SCOPE_OPTIONS : options);
|
|
237
697
|
}
|
|
238
|
-
function assign(node, props,
|
|
698
|
+
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
699
|
+
const nodeName = node.nodeName;
|
|
239
700
|
props || (props = {});
|
|
240
701
|
for (const prop in prevProps) {
|
|
241
702
|
if (!(prop in props)) {
|
|
242
703
|
if (prop === "children") continue;
|
|
243
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop],
|
|
704
|
+
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
|
|
244
705
|
}
|
|
245
706
|
}
|
|
246
707
|
for (const prop in props) {
|
|
247
708
|
if (prop === "children") {
|
|
248
|
-
if (!skipChildren) insertExpression(node, props.children);
|
|
709
|
+
if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
|
|
249
710
|
continue;
|
|
250
711
|
}
|
|
251
|
-
|
|
252
|
-
|
|
712
|
+
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
const ASSET_REMOVAL_GRACE = 100;
|
|
716
|
+
const assetRegistry = new Map();
|
|
717
|
+
function assetEntryKey(descriptor) {
|
|
718
|
+
if (descriptor.policy === "exclusive") return "x|" + descriptor.key;
|
|
719
|
+
return descriptor.type === "inline-style" ? "i|" + descriptor.id : descriptor.type + "|" + descriptor.href;
|
|
720
|
+
}
|
|
721
|
+
function findAssetElement(selector, attr, value) {
|
|
722
|
+
const nodes = document.querySelectorAll(selector);
|
|
723
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
724
|
+
if (nodes[i].getAttribute(attr) === value) return nodes[i];
|
|
725
|
+
}
|
|
726
|
+
return null;
|
|
727
|
+
}
|
|
728
|
+
function setAssetAttrs(el, attrs) {
|
|
729
|
+
for (const name in attrs) el.setAttribute(name, attrs[name]);
|
|
730
|
+
}
|
|
731
|
+
function mountAssetElement(descriptor) {
|
|
732
|
+
let el;
|
|
733
|
+
if (descriptor.type === "inline-style") {
|
|
734
|
+
el = findAssetElement("style[data-asset]", "data-asset", descriptor.id);
|
|
735
|
+
if (!el) {
|
|
736
|
+
el = document.createElement("style");
|
|
737
|
+
el.setAttribute("data-asset", descriptor.id);
|
|
738
|
+
el.textContent = descriptor.content || "";
|
|
739
|
+
}
|
|
740
|
+
} else {
|
|
741
|
+
const rel = descriptor.type === "module" ? "modulepreload" : "stylesheet";
|
|
742
|
+
el = findAssetElement(`link[rel="${rel}"]`, "href", descriptor.href);
|
|
743
|
+
if (!el) {
|
|
744
|
+
el = document.createElement("link");
|
|
745
|
+
el.rel = rel;
|
|
746
|
+
el.href = descriptor.href;
|
|
747
|
+
}
|
|
253
748
|
}
|
|
749
|
+
if (descriptor.attrs) setAssetAttrs(el, descriptor.attrs);
|
|
750
|
+
if (!el.isConnected) document.head.appendChild(el);
|
|
751
|
+
return el;
|
|
752
|
+
}
|
|
753
|
+
const assetLoadSettled = /*#__PURE__*/Promise.resolve();
|
|
754
|
+
function trackAssetLoad(entry, adopted) {
|
|
755
|
+
if (entry.loadPromise) return;
|
|
756
|
+
const el = entry.element;
|
|
757
|
+
let settled = el.sheet != null;
|
|
758
|
+
if (!settled && adopted && typeof performance !== "undefined" && performance.getEntriesByName) {
|
|
759
|
+
settled = performance.getEntriesByName(el.href).length > 0;
|
|
760
|
+
}
|
|
761
|
+
if (settled) {
|
|
762
|
+
entry.loadState = "loaded";
|
|
763
|
+
entry.loadPromise = assetLoadSettled;
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
entry.loadState = "pending";
|
|
767
|
+
entry.loadPromise = new Promise(resolve => {
|
|
768
|
+
const settle = state => {
|
|
769
|
+
entry.loadState = state;
|
|
770
|
+
resolve();
|
|
771
|
+
};
|
|
772
|
+
el.addEventListener("load", () => settle("loaded"), {
|
|
773
|
+
once: true
|
|
774
|
+
});
|
|
775
|
+
el.addEventListener("error", () => settle("errored"), {
|
|
776
|
+
once: true
|
|
777
|
+
});
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
function warmAsset(descriptor) {
|
|
781
|
+
if (descriptor.policy === "exclusive" || descriptor.type === "inline-style") return;
|
|
782
|
+
const key = assetEntryKey(descriptor);
|
|
783
|
+
let entry = assetRegistry.get(key);
|
|
784
|
+
if (!entry) {
|
|
785
|
+
entry = {
|
|
786
|
+
count: 0,
|
|
787
|
+
element: null,
|
|
788
|
+
timer: null
|
|
789
|
+
};
|
|
790
|
+
assetRegistry.set(key, entry);
|
|
791
|
+
}
|
|
792
|
+
let adopted = true;
|
|
793
|
+
if (!entry.element || !entry.element.isConnected) {
|
|
794
|
+
const rel = descriptor.type === "module" ? "modulepreload" : "stylesheet";
|
|
795
|
+
let el = findAssetElement(`link[rel="${rel}"]`, "href", descriptor.href);
|
|
796
|
+
if (!el && descriptor.type === "style") {
|
|
797
|
+
el = findAssetElement('link[rel="preload"][as="style"]', "href", descriptor.href);
|
|
798
|
+
}
|
|
799
|
+
if (!el) {
|
|
800
|
+
adopted = false;
|
|
801
|
+
el = document.createElement("link");
|
|
802
|
+
if (descriptor.type === "style") {
|
|
803
|
+
el.setAttribute("rel", "preload");
|
|
804
|
+
el.setAttribute("as", "style");
|
|
805
|
+
} else {
|
|
806
|
+
el.setAttribute("rel", "modulepreload");
|
|
807
|
+
}
|
|
808
|
+
el.setAttribute("href", descriptor.href);
|
|
809
|
+
if (!document.body) el.setAttribute("blocking", "render");
|
|
810
|
+
}
|
|
811
|
+
if (descriptor.attrs) setAssetAttrs(el, descriptor.attrs);
|
|
812
|
+
if (!el.isConnected) document.head.appendChild(el);
|
|
813
|
+
entry.element = el;
|
|
814
|
+
entry.loadState = undefined;
|
|
815
|
+
entry.loadPromise = undefined;
|
|
816
|
+
}
|
|
817
|
+
if (descriptor.type === "style") trackAssetLoad(entry, adopted);
|
|
818
|
+
return entry;
|
|
819
|
+
}
|
|
820
|
+
function acquireAsset(descriptor) {
|
|
821
|
+
const key = assetEntryKey(descriptor);
|
|
822
|
+
let entry = assetRegistry.get(key);
|
|
823
|
+
if (descriptor.policy === "exclusive") {
|
|
824
|
+
if (!entry) {
|
|
825
|
+
entry = {
|
|
826
|
+
original: descriptor.get(),
|
|
827
|
+
set: descriptor.set,
|
|
828
|
+
writers: []
|
|
829
|
+
};
|
|
830
|
+
assetRegistry.set(key, entry);
|
|
831
|
+
}
|
|
832
|
+
const writer = {
|
|
833
|
+
value: descriptor.value
|
|
834
|
+
};
|
|
835
|
+
entry.writers.push(writer);
|
|
836
|
+
entry.set(writer.value);
|
|
837
|
+
let released = false;
|
|
838
|
+
return () => {
|
|
839
|
+
if (released) return;
|
|
840
|
+
released = true;
|
|
841
|
+
const index = entry.writers.indexOf(writer);
|
|
842
|
+
const wasTop = index === entry.writers.length - 1;
|
|
843
|
+
entry.writers.splice(index, 1);
|
|
844
|
+
if (!wasTop) return;
|
|
845
|
+
if (entry.writers.length) {
|
|
846
|
+
entry.set(entry.writers[entry.writers.length - 1].value);
|
|
847
|
+
} else {
|
|
848
|
+
entry.set(entry.original);
|
|
849
|
+
assetRegistry.delete(key);
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
if (!entry) {
|
|
854
|
+
entry = {
|
|
855
|
+
count: 0,
|
|
856
|
+
element: null,
|
|
857
|
+
timer: null
|
|
858
|
+
};
|
|
859
|
+
assetRegistry.set(key, entry);
|
|
860
|
+
}
|
|
861
|
+
if (entry.timer) {
|
|
862
|
+
clearTimeout(entry.timer);
|
|
863
|
+
entry.timer = null;
|
|
864
|
+
}
|
|
865
|
+
entry.count++;
|
|
866
|
+
if (!entry.element || !entry.element.isConnected) {
|
|
867
|
+
entry.element = mountAssetElement(descriptor);
|
|
868
|
+
} else if (descriptor.type === "style" && entry.element.getAttribute("rel") === "preload") {
|
|
869
|
+
entry.element.removeAttribute("as");
|
|
870
|
+
entry.element.setAttribute("rel", "stylesheet");
|
|
871
|
+
}
|
|
872
|
+
let released = false;
|
|
873
|
+
return () => {
|
|
874
|
+
if (released) return;
|
|
875
|
+
released = true;
|
|
876
|
+
if (--entry.count > 0) return;
|
|
877
|
+
entry.timer = setTimeout(() => {
|
|
878
|
+
assetRegistry.delete(key);
|
|
879
|
+
entry.element && entry.element.remove();
|
|
880
|
+
}, ASSET_REMOVAL_GRACE);
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
let headRegistrations = null;
|
|
884
|
+
let headSeq = 0;
|
|
885
|
+
let headUid = 0;
|
|
886
|
+
let headOwned = null;
|
|
887
|
+
let headApplied = null;
|
|
888
|
+
let headFallbackTitle = null;
|
|
889
|
+
let headScheduled = false;
|
|
890
|
+
const headMountedResources = new Set();
|
|
891
|
+
function initHeadRegistry() {
|
|
892
|
+
if (headRegistrations) return;
|
|
893
|
+
headRegistrations = [];
|
|
894
|
+
headOwned = new Map();
|
|
895
|
+
headApplied = new Map();
|
|
896
|
+
const t = document.querySelector("title");
|
|
897
|
+
headFallbackTitle = t && !t.hasAttribute("data-dh") ? t.textContent : null;
|
|
898
|
+
if (globalThis._$HY) globalThis._$HY.h = applyServerHeadOps;
|
|
899
|
+
}
|
|
900
|
+
function applyServerHeadOps(ops) {
|
|
901
|
+
for (let i = 0; i < ops.length; i++) {
|
|
902
|
+
const op = ops[i];
|
|
903
|
+
const identity = op[0] === "t" ? "title" : op[1];
|
|
904
|
+
if (headOwned.has(identity)) continue;
|
|
905
|
+
if (op[0] === "t") setHeadTitle(op[1]);else if (op[0] === "r") {
|
|
906
|
+
const els = headMarkedElements(identity);
|
|
907
|
+
for (let j = 0; j < els.length; j++) els[j].remove();
|
|
908
|
+
} else {
|
|
909
|
+
const el = document.createElement(op[2]);
|
|
910
|
+
for (const name in op[3]) el.setAttribute(name, op[3][name]);
|
|
911
|
+
if (op[4] != null) el.textContent = op[4];
|
|
912
|
+
el.setAttribute("data-dh", identity);
|
|
913
|
+
document.head.appendChild(el);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
function headMarkedElements(identity) {
|
|
918
|
+
const nodes = document.head.querySelectorAll("[data-dh]");
|
|
919
|
+
const out = [];
|
|
920
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
921
|
+
if (nodes[i].getAttribute("data-dh") === identity) out.push(nodes[i]);
|
|
922
|
+
}
|
|
923
|
+
return out;
|
|
924
|
+
}
|
|
925
|
+
function setHeadTitle(text) {
|
|
926
|
+
let el = document.querySelector("title");
|
|
927
|
+
if (!el) {
|
|
928
|
+
el = document.createElement("title");
|
|
929
|
+
document.head.appendChild(el);
|
|
930
|
+
}
|
|
931
|
+
el.textContent = text;
|
|
932
|
+
el.setAttribute("data-dh", "title");
|
|
933
|
+
return el;
|
|
934
|
+
}
|
|
935
|
+
function scheduleHeadApply() {
|
|
936
|
+
if (headScheduled) return;
|
|
937
|
+
headScheduled = true;
|
|
938
|
+
queueMicrotask(flushHeadRegistry);
|
|
939
|
+
}
|
|
940
|
+
function flushHeadRegistry() {
|
|
941
|
+
if (sharedConfig.hydrating) {
|
|
942
|
+
setTimeout(flushHeadRegistry, 0);
|
|
943
|
+
return;
|
|
944
|
+
}
|
|
945
|
+
headScheduled = false;
|
|
946
|
+
const winners = resolveHead(headRegistrations);
|
|
947
|
+
for (const [identity, els] of headOwned) {
|
|
948
|
+
if (winners.has(identity)) continue;
|
|
949
|
+
headOwned.delete(identity);
|
|
950
|
+
headApplied.delete(identity);
|
|
951
|
+
if (identity === "title") {
|
|
952
|
+
if (headFallbackTitle != null) setHeadTitle(headFallbackTitle).removeAttribute("data-dh");
|
|
953
|
+
} else {
|
|
954
|
+
for (let i = 0; i < els.length; i++) els[i].remove();
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
for (const [identity, winner] of winners) {
|
|
958
|
+
let sig = "";
|
|
959
|
+
for (let i = 0; i < winner.tags.length; i++) sig += winner.tags[i].tag + JSON.stringify(winner.tags[i].props) + "|";
|
|
960
|
+
if (headApplied.get(identity) === sig) continue;
|
|
961
|
+
headApplied.set(identity, sig);
|
|
962
|
+
if (identity === "base" || identity === "charset") {
|
|
963
|
+
console.warn(`useHead: <${winner.tags[0].tag}> (${identity}) is shell-only and ignored on the client`);
|
|
964
|
+
continue;
|
|
965
|
+
}
|
|
966
|
+
if (identity === "title") {
|
|
967
|
+
const children = winner.tags[0].props.children;
|
|
968
|
+
setHeadTitle(children == null ? "" : String(children));
|
|
969
|
+
headOwned.set(identity, []);
|
|
970
|
+
continue;
|
|
971
|
+
}
|
|
972
|
+
const existing = headMarkedElements(identity);
|
|
973
|
+
const els = [];
|
|
974
|
+
for (let i = 0; i < winner.tags.length; i++) {
|
|
975
|
+
els.push(renderHeadElement(winner.tags[i], identity, existing));
|
|
976
|
+
}
|
|
977
|
+
for (let i = 0; i < existing.length; i++) {
|
|
978
|
+
if (els.indexOf(existing[i]) === -1) existing[i].remove();
|
|
979
|
+
}
|
|
980
|
+
headOwned.set(identity, els);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
function createHeadElement(tag, props) {
|
|
984
|
+
const el = document.createElement(tag);
|
|
985
|
+
for (const name in props) {
|
|
986
|
+
if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
|
|
987
|
+
if (!HEAD_ATTR_NAME.test(name)) {
|
|
988
|
+
console.warn(`useHead: ignoring invalid attribute name "${name}"`);
|
|
989
|
+
continue;
|
|
990
|
+
}
|
|
991
|
+
const v = props[name];
|
|
992
|
+
if (v == null || v === false) continue;
|
|
993
|
+
el.setAttribute(name, v === true ? "" : String(v));
|
|
994
|
+
}
|
|
995
|
+
if (props.children != null) el.textContent = String(props.children);
|
|
996
|
+
return el;
|
|
997
|
+
}
|
|
998
|
+
function renderHeadElement(t, identity, existing) {
|
|
999
|
+
for (let i = 0; i < existing.length; i++) {
|
|
1000
|
+
if (headElementMatches(existing[i], t)) return existing.splice(i, 1)[0];
|
|
1001
|
+
}
|
|
1002
|
+
const el = createHeadElement(t.tag, t.props);
|
|
1003
|
+
el.setAttribute("data-dh", identity);
|
|
1004
|
+
document.head.appendChild(el);
|
|
1005
|
+
return el;
|
|
1006
|
+
}
|
|
1007
|
+
function headElementMatches(el, t) {
|
|
1008
|
+
if (el.tagName.toLowerCase() !== t.tag) return false;
|
|
1009
|
+
for (const name in t.props) {
|
|
1010
|
+
if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
|
|
1011
|
+
if (!HEAD_ATTR_NAME.test(name)) continue;
|
|
1012
|
+
const v = t.props[name];
|
|
1013
|
+
if (v == null || v === false) {
|
|
1014
|
+
if (el.hasAttribute(name)) return false;
|
|
1015
|
+
} else if (el.getAttribute(name) !== (v === true ? "" : String(v))) return false;
|
|
1016
|
+
}
|
|
1017
|
+
const children = t.props.children;
|
|
1018
|
+
return (children == null ? "" : String(children)) === el.textContent;
|
|
1019
|
+
}
|
|
1020
|
+
function mountHeadResource(tag, props) {
|
|
1021
|
+
const identity = resourceIdentity(tag, props);
|
|
1022
|
+
if (headMountedResources.has(identity)) return;
|
|
1023
|
+
headMountedResources.add(identity);
|
|
1024
|
+
const url = props.href || props.src;
|
|
1025
|
+
let el = null;
|
|
1026
|
+
if (url != null) {
|
|
1027
|
+
if (tag === "link") el = findAssetElement(`link[rel="${props.rel}"]`, "href", url);else if (tag === "script") el = findAssetElement("script[src]", "src", url);else el = findAssetElement("style[href]", "href", url);
|
|
1028
|
+
}
|
|
1029
|
+
if (!el) document.head.appendChild(createHeadElement(tag, props));
|
|
1030
|
+
}
|
|
1031
|
+
function gateHeadResource(props) {
|
|
1032
|
+
const descriptor = {
|
|
1033
|
+
type: props.rel === "stylesheet" ? "style" : "module",
|
|
1034
|
+
href: props.href
|
|
1035
|
+
};
|
|
1036
|
+
let gateable = props.rel === "stylesheet" && props.href != null;
|
|
1037
|
+
let attrs = null;
|
|
1038
|
+
for (const name in props) {
|
|
1039
|
+
if (name === "rel" || name === "href") continue;
|
|
1040
|
+
if (!STYLESHEET_FETCH_META.has(name)) gateable = false;
|
|
1041
|
+
if (!HEAD_ATTR_NAME.test(name)) continue;
|
|
1042
|
+
const v = props[name];
|
|
1043
|
+
if (v == null || v === false) continue;
|
|
1044
|
+
(attrs || (attrs = {}))[name] = v === true ? "" : String(v);
|
|
1045
|
+
}
|
|
1046
|
+
if (attrs) descriptor.attrs = attrs;
|
|
1047
|
+
effect(() => {
|
|
1048
|
+
const entry = warmAsset(descriptor);
|
|
1049
|
+
if (gateable && entry.loadState === "pending" && typeof waitAsset === "function") waitAsset(entry.loadPromise);
|
|
1050
|
+
}, () => acquireAsset(descriptor));
|
|
1051
|
+
}
|
|
1052
|
+
function useHead(tags) {
|
|
1053
|
+
initHeadRegistry();
|
|
1054
|
+
const reg = {
|
|
1055
|
+
seq: -1,
|
|
1056
|
+
tags: null
|
|
1057
|
+
};
|
|
1058
|
+
const uid = ++headUid;
|
|
1059
|
+
effect(() => {
|
|
1060
|
+
let list = typeof tags === "function" ? tags() : tags;
|
|
1061
|
+
if (!Array.isArray(list)) list = [list];
|
|
1062
|
+
const replaceable = [];
|
|
1063
|
+
const resources = [];
|
|
1064
|
+
for (let i = 0; i < list.length; i++) {
|
|
1065
|
+
const desc = list[i];
|
|
1066
|
+
if (!desc || !HEAD_ELIGIBLE_TAGS.has(desc.tag)) {
|
|
1067
|
+
console.warn(`useHead: ignoring non-head tag`, desc);
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
const cls = classifyHeadTag(desc);
|
|
1071
|
+
const props = evalHeadProps(desc.props || {}, cls.rel !== undefined ? {
|
|
1072
|
+
rel: cls.rel
|
|
1073
|
+
} : undefined);
|
|
1074
|
+
if (cls.resource) {
|
|
1075
|
+
if (desc.tag === "link" && (props.rel === "stylesheet" || props.rel === "modulepreload")) {
|
|
1076
|
+
gateHeadResource(props);
|
|
1077
|
+
} else if (desc.tag === "link") {
|
|
1078
|
+
mountHeadResource(desc.tag, props);
|
|
1079
|
+
} else {
|
|
1080
|
+
resources.push({
|
|
1081
|
+
tag: desc.tag,
|
|
1082
|
+
props
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
} else {
|
|
1086
|
+
const key = evalHeadValue(desc.key);
|
|
1087
|
+
replaceable.push({
|
|
1088
|
+
tag: desc.tag,
|
|
1089
|
+
props,
|
|
1090
|
+
identity: replaceableIdentity(desc.tag, props, key, "u:c" + uid + ":" + i)
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
return {
|
|
1095
|
+
replaceable,
|
|
1096
|
+
resources
|
|
1097
|
+
};
|
|
1098
|
+
}, evaluated => {
|
|
1099
|
+
for (let i = 0; i < evaluated.resources.length; i++) {
|
|
1100
|
+
mountHeadResource(evaluated.resources[i].tag, evaluated.resources[i].props);
|
|
1101
|
+
}
|
|
1102
|
+
reg.tags = evaluated.replaceable;
|
|
1103
|
+
if (reg.seq < 0) reg.seq = ++headSeq;
|
|
1104
|
+
if (headRegistrations.indexOf(reg) === -1) headRegistrations.push(reg);
|
|
1105
|
+
scheduleHeadApply();
|
|
1106
|
+
return () => {
|
|
1107
|
+
const idx = headRegistrations.indexOf(reg);
|
|
1108
|
+
if (idx > -1) headRegistrations.splice(idx, 1);
|
|
1109
|
+
scheduleHeadApply();
|
|
1110
|
+
};
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
function loadModuleAssets(mapping) {
|
|
1114
|
+
const hy = globalThis._$HY;
|
|
1115
|
+
if (!hy) return;
|
|
1116
|
+
const pending = [];
|
|
1117
|
+
for (const key in mapping) {
|
|
1118
|
+
if (hy.modules[key]) continue;
|
|
1119
|
+
const entryUrl = mapping[key];
|
|
1120
|
+
if (!hy.loading[key]) {
|
|
1121
|
+
hy.loading[key] = import(entryUrl).then(mod => {
|
|
1122
|
+
hy.modules[key] = mod;
|
|
1123
|
+
}, err => {
|
|
1124
|
+
delete hy.loading[key];
|
|
1125
|
+
throw err;
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
pending.push(hy.loading[key]);
|
|
1129
|
+
}
|
|
1130
|
+
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
254
1131
|
}
|
|
255
1132
|
function hydrate$1(code, element, options = {}) {
|
|
256
|
-
|
|
1133
|
+
installHydrationRuntime();
|
|
1134
|
+
if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
|
|
257
1135
|
options.renderId ||= "";
|
|
1136
|
+
if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
|
|
1137
|
+
if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
|
|
258
1138
|
sharedConfig.completed = globalThis._$HY.completed;
|
|
259
1139
|
sharedConfig.events = globalThis._$HY.events;
|
|
260
1140
|
sharedConfig.load = id => globalThis._$HY.r[id];
|
|
261
1141
|
sharedConfig.has = id => id in globalThis._$HY.r;
|
|
262
1142
|
sharedConfig.gather = root => gatherHydratable(element, root);
|
|
1143
|
+
sharedConfig.loadModuleAssets = loadModuleAssets;
|
|
1144
|
+
sharedConfig.cleanupFragment = id => {
|
|
1145
|
+
const tpl = document.getElementById("pl-" + id);
|
|
1146
|
+
if (tpl) {
|
|
1147
|
+
let node = tpl.nextSibling;
|
|
1148
|
+
while (node) {
|
|
1149
|
+
const next = node.nextSibling;
|
|
1150
|
+
if (node.nodeType === 8 && node.nodeValue === "pl-" + id) {
|
|
1151
|
+
node.remove();
|
|
1152
|
+
break;
|
|
1153
|
+
}
|
|
1154
|
+
node.remove();
|
|
1155
|
+
node = next;
|
|
1156
|
+
}
|
|
1157
|
+
tpl.remove();
|
|
1158
|
+
}
|
|
1159
|
+
};
|
|
263
1160
|
sharedConfig.registry = new Map();
|
|
1161
|
+
if (!sharedConfig.boundaryScopes) sharedConfig.boundaryScopes = new Map();
|
|
1162
|
+
sharedConfig.captureBoundaryScope = id => {
|
|
1163
|
+
if (sharedConfig.registry) sharedConfig.boundaryScopes.set(id, {
|
|
1164
|
+
registry: sharedConfig.registry,
|
|
1165
|
+
gather: sharedConfig.gather
|
|
1166
|
+
});
|
|
1167
|
+
};
|
|
264
1168
|
sharedConfig.hydrating = true;
|
|
1169
|
+
{
|
|
1170
|
+
sharedConfig.verifyHydration = () => {
|
|
1171
|
+
if (sharedConfig.registry && sharedConfig.registry.size) {
|
|
1172
|
+
const orphaned = [...sharedConfig.registry.values()].filter(node => node.isConnected);
|
|
1173
|
+
sharedConfig.registry.clear();
|
|
1174
|
+
if (!orphaned.length) return;
|
|
1175
|
+
console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
|
|
1176
|
+
}
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
const hyr = globalThis._$HY.r;
|
|
1180
|
+
const rootMapping = hyr && (hyr[options.renderId + "_assets"] || hyr["_assets"]);
|
|
1181
|
+
if (rootMapping && typeof rootMapping === "object") {
|
|
1182
|
+
const p = loadModuleAssets(rootMapping);
|
|
1183
|
+
if (p) {
|
|
1184
|
+
gatherHydratable(element, options.renderId);
|
|
1185
|
+
const registry = sharedConfig.registry;
|
|
1186
|
+
const gather = sharedConfig.gather;
|
|
1187
|
+
let disposer;
|
|
1188
|
+
p.then(() => {
|
|
1189
|
+
sharedConfig.registry = registry;
|
|
1190
|
+
sharedConfig.gather = gather;
|
|
1191
|
+
sharedConfig.hydrating = true;
|
|
1192
|
+
try {
|
|
1193
|
+
disposer = render$1(code, element, [...element.childNodes], options);
|
|
1194
|
+
} finally {
|
|
1195
|
+
sharedConfig.hydrating = false;
|
|
1196
|
+
}
|
|
1197
|
+
}, err => {
|
|
1198
|
+
console.error("Hydration module preload failed, falling back to client render:", err);
|
|
1199
|
+
sharedConfig.hydrating = false;
|
|
1200
|
+
sharedConfig.registry = undefined;
|
|
1201
|
+
disposer = render$1(code, element, [...element.childNodes], options);
|
|
1202
|
+
});
|
|
1203
|
+
return () => disposer && disposer();
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
265
1206
|
try {
|
|
266
1207
|
gatherHydratable(element, options.renderId);
|
|
267
|
-
return render(code, element, [...element.childNodes], options);
|
|
1208
|
+
return render$1(code, element, [...element.childNodes], options);
|
|
268
1209
|
} finally {
|
|
269
1210
|
sharedConfig.hydrating = false;
|
|
270
1211
|
}
|
|
@@ -274,11 +1215,16 @@ function getNextElement(template) {
|
|
|
274
1215
|
key,
|
|
275
1216
|
hydrating = isHydrating();
|
|
276
1217
|
if (!hydrating || !(node = sharedConfig.registry.get(key = getHydrationKey()))) {
|
|
277
|
-
if (
|
|
278
|
-
|
|
279
|
-
|
|
1218
|
+
if (!template) {
|
|
1219
|
+
throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}`);
|
|
1220
|
+
}
|
|
1221
|
+
return template(true);
|
|
1222
|
+
}
|
|
1223
|
+
if (template && template._html) {
|
|
1224
|
+
const expected = template._html.match(/^<(\w+)/)?.[1];
|
|
1225
|
+
if (expected && node.localName !== expected) {
|
|
1226
|
+
console.warn(`Hydration tag mismatch for key "${key}": expected <${expected}> but found`, node);
|
|
280
1227
|
}
|
|
281
|
-
return template();
|
|
282
1228
|
}
|
|
283
1229
|
if (sharedConfig.completed) sharedConfig.completed.add(node);
|
|
284
1230
|
sharedConfig.registry.delete(key);
|
|
@@ -307,6 +1253,50 @@ function getNextMarker(start) {
|
|
|
307
1253
|
}
|
|
308
1254
|
return [end, current];
|
|
309
1255
|
}
|
|
1256
|
+
function getFirstChild(node, expectedTag) {
|
|
1257
|
+
const child = node.firstChild;
|
|
1258
|
+
if (isHydrating() && expectedTag && child?.localName !== expectedTag) {
|
|
1259
|
+
const isMissing = !child || child.nodeType !== 1;
|
|
1260
|
+
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> as first child of", node, "\n " + describeSiblings(node, child, expectedTag, isMissing));
|
|
1261
|
+
}
|
|
1262
|
+
return child;
|
|
1263
|
+
}
|
|
1264
|
+
function getNextSibling(node, expectedTag) {
|
|
1265
|
+
const sibling = node.nextSibling;
|
|
1266
|
+
if (isHydrating() && expectedTag && sibling?.localName !== expectedTag) {
|
|
1267
|
+
const parent = node.parentNode;
|
|
1268
|
+
const isMissing = !sibling || sibling.nodeType !== 1;
|
|
1269
|
+
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> after", node, "in", parent, "\n " + describeSiblings(parent, sibling, expectedTag, isMissing));
|
|
1270
|
+
}
|
|
1271
|
+
return sibling;
|
|
1272
|
+
}
|
|
1273
|
+
function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
|
|
1274
|
+
if (!parent) return `<${expectedTag} \u2190 parent unavailable>`;
|
|
1275
|
+
const children = [];
|
|
1276
|
+
let child = parent.firstChild;
|
|
1277
|
+
while (child) {
|
|
1278
|
+
if (child.nodeType === 1) children.push(child);
|
|
1279
|
+
child = child.nextSibling;
|
|
1280
|
+
}
|
|
1281
|
+
const pTag = parent.localName || "#fragment";
|
|
1282
|
+
if (isMissing) {
|
|
1283
|
+
const tags = children.map(c => `<${c.localName}>`).join("");
|
|
1284
|
+
return `<${pTag}>${tags}<${expectedTag} \u2190 missing></${pTag}>`;
|
|
1285
|
+
}
|
|
1286
|
+
const idx = children.indexOf(mismatchChild);
|
|
1287
|
+
let start = 0,
|
|
1288
|
+
end = children.length;
|
|
1289
|
+
let prefix = "",
|
|
1290
|
+
suffix = "";
|
|
1291
|
+
if (children.length > 6) {
|
|
1292
|
+
start = Math.max(0, idx - 2);
|
|
1293
|
+
end = Math.min(children.length, idx + 3);
|
|
1294
|
+
if (start > 0) prefix = "...";
|
|
1295
|
+
if (end < children.length) suffix = "...";
|
|
1296
|
+
}
|
|
1297
|
+
const tags = children.slice(start, end).map(c => c === mismatchChild ? `<${c.localName} \u2190 expected ${expectedTag}>` : `<${c.localName}>`).join("");
|
|
1298
|
+
return `<${pTag}>${prefix}${tags}${suffix}</${pTag}>`;
|
|
1299
|
+
}
|
|
310
1300
|
function runHydrationEvents() {
|
|
311
1301
|
if (sharedConfig.events && !sharedConfig.events.queued) {
|
|
312
1302
|
queueMicrotask(() => {
|
|
@@ -320,7 +1310,32 @@ function runHydrationEvents() {
|
|
|
320
1310
|
const [el, e] = events[0];
|
|
321
1311
|
if (!completed.has(el)) return;
|
|
322
1312
|
events.shift();
|
|
323
|
-
|
|
1313
|
+
let matchContainer, matchState, matchDistance, matches;
|
|
1314
|
+
for (const [container, state] of delegatedContainers) {
|
|
1315
|
+
if (!state.handlers.has(e.type)) continue;
|
|
1316
|
+
const entry = findOwner(e.target, state);
|
|
1317
|
+
if (!entry) continue;
|
|
1318
|
+
if (matchContainer) {
|
|
1319
|
+
if (!matches) matches = [{
|
|
1320
|
+
container: matchContainer,
|
|
1321
|
+
state: matchState,
|
|
1322
|
+
distance: matchDistance
|
|
1323
|
+
}];
|
|
1324
|
+
matches.push({
|
|
1325
|
+
container,
|
|
1326
|
+
state,
|
|
1327
|
+
distance: entry.distance
|
|
1328
|
+
});
|
|
1329
|
+
} else {
|
|
1330
|
+
matchContainer = container;
|
|
1331
|
+
matchState = state;
|
|
1332
|
+
matchDistance = entry.distance;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
if (matches) {
|
|
1336
|
+
matches.sort((a, b) => a.distance - b.distance);
|
|
1337
|
+
for (let i = 0; i < matches.length; i++) eventHandler(e, matches[i].container, matches[i].state);
|
|
1338
|
+
} else if (matchContainer) eventHandler(e, matchContainer, matchState);
|
|
324
1339
|
}
|
|
325
1340
|
if (sharedConfig.done) {
|
|
326
1341
|
sharedConfig.events = _$HY.events = null;
|
|
@@ -331,16 +1346,31 @@ function runHydrationEvents() {
|
|
|
331
1346
|
}
|
|
332
1347
|
}
|
|
333
1348
|
function isHydrating(node) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
1349
|
+
if (!sharedConfig.hydrating) return false;
|
|
1350
|
+
if (!node || node.isConnected) return true;
|
|
1351
|
+
const roots = sharedConfig.claimRoots;
|
|
1352
|
+
if (roots) {
|
|
1353
|
+
for (let i = 0; i < roots.length; i++) {
|
|
1354
|
+
if (roots[i].contains(node)) return true;
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
return false;
|
|
339
1358
|
}
|
|
340
1359
|
function classListToObject(classList) {
|
|
341
1360
|
if (Array.isArray(classList)) {
|
|
342
1361
|
const result = {};
|
|
343
1362
|
flattenClassList(classList, result);
|
|
1363
|
+
classList = result;
|
|
1364
|
+
}
|
|
1365
|
+
if (classList && typeof classList === "object") {
|
|
1366
|
+
const result = {},
|
|
1367
|
+
keys = Object.keys(classList);
|
|
1368
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
1369
|
+
const key = keys[i];
|
|
1370
|
+
if (!classList[key]) continue;
|
|
1371
|
+
const classNames = key.trim().split(/\s+/);
|
|
1372
|
+
for (let j = 0, nameLen = classNames.length; j < nameLen; j++) classNames[j] && (result[classNames[j]] = true);
|
|
1373
|
+
}
|
|
344
1374
|
return result;
|
|
345
1375
|
}
|
|
346
1376
|
return classList;
|
|
@@ -351,18 +1381,16 @@ function flattenClassList(list, result) {
|
|
|
351
1381
|
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);else if (item || item === 0) result[item] = true;
|
|
352
1382
|
}
|
|
353
1383
|
}
|
|
354
|
-
function assignProp(node, prop, value, prev,
|
|
355
|
-
let forceProp;
|
|
1384
|
+
function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
356
1385
|
if (prop === "style") return style(node, value, prev), value;
|
|
357
|
-
if (prop === "class") return className(node, value,
|
|
358
|
-
if (value === prev) return prev;
|
|
1386
|
+
if (prop === "class") return className(node, value, prev), value;
|
|
1387
|
+
if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
|
|
359
1388
|
if (prop === "ref") {
|
|
360
|
-
if (!skipRef) value
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
} else if (prop.slice(0, 2) === "on") {
|
|
1389
|
+
if (!skipRef && value) ref(() => value, node);
|
|
1390
|
+
return value;
|
|
1391
|
+
}
|
|
1392
|
+
const hasNamespace = prop.indexOf(":") > -1;
|
|
1393
|
+
if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
366
1394
|
const name = prop.slice(2).toLowerCase();
|
|
367
1395
|
const delegate = DelegatedEvents.has(name);
|
|
368
1396
|
if (!delegate && prev) {
|
|
@@ -370,26 +1398,34 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
370
1398
|
node.removeEventListener(name, h);
|
|
371
1399
|
}
|
|
372
1400
|
if (delegate || value) {
|
|
373
|
-
|
|
1401
|
+
addEvent(node, name, value, delegate);
|
|
374
1402
|
delegate && delegateEvents([name]);
|
|
375
1403
|
}
|
|
376
|
-
} else if (
|
|
377
|
-
if (
|
|
378
|
-
if (prop === "value" &&
|
|
1404
|
+
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
1405
|
+
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
1406
|
+
if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else if ((prop === "value" || prop === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA"))
|
|
1407
|
+
node[prop] = value ?? "";else node[prop] = value;
|
|
379
1408
|
} else {
|
|
380
|
-
const ns =
|
|
1409
|
+
const ns = hasNamespace && Namespaces[prop.split(":")[0]];
|
|
381
1410
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
382
1411
|
}
|
|
383
1412
|
return value;
|
|
384
1413
|
}
|
|
385
|
-
function eventHandler(e) {
|
|
386
|
-
if (
|
|
387
|
-
|
|
1414
|
+
function eventHandler(e, container, state) {
|
|
1415
|
+
if (hydrationRt !== null && hydrationRt.dedupEvent(e)) return;
|
|
1416
|
+
const prev = e[$$EVENT_OWNER];
|
|
1417
|
+
let resumeNode;
|
|
1418
|
+
if (prev) {
|
|
1419
|
+
if (prev === true || prev === container || !container.contains(prev)) return;
|
|
1420
|
+
resumeNode = prev;
|
|
388
1421
|
}
|
|
389
|
-
|
|
1422
|
+
const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
|
|
1423
|
+
if (state && !owner) return;
|
|
1424
|
+
e[$$EVENT_OWNER] = owner || true;
|
|
1425
|
+
let node = resumeNode || e.target;
|
|
390
1426
|
const key = `$$${e.type}`;
|
|
391
1427
|
const oriTarget = e.target;
|
|
392
|
-
const
|
|
1428
|
+
const boundary = owner || container || e.currentTarget;
|
|
393
1429
|
const retarget = value => Object.defineProperty(e, "target", {
|
|
394
1430
|
configurable: true,
|
|
395
1431
|
value
|
|
@@ -405,52 +1441,72 @@ function eventHandler(e) {
|
|
|
405
1441
|
return true;
|
|
406
1442
|
};
|
|
407
1443
|
const walkUpTree = () => {
|
|
408
|
-
while (handleNode()
|
|
1444
|
+
while (handleNode()) {
|
|
1445
|
+
if (node === boundary || node.parentNode === boundary) break;
|
|
1446
|
+
node = node._$host || node.parentNode || node.host;
|
|
1447
|
+
}
|
|
409
1448
|
};
|
|
410
1449
|
Object.defineProperty(e, "currentTarget", {
|
|
411
1450
|
configurable: true,
|
|
412
1451
|
get() {
|
|
413
|
-
return node || document;
|
|
1452
|
+
return node || boundary || document;
|
|
414
1453
|
}
|
|
415
1454
|
});
|
|
416
|
-
if (
|
|
417
|
-
|
|
1455
|
+
if (resumeNode) {
|
|
1456
|
+
if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
|
|
1457
|
+
if (node && node !== boundary) walkUpTree();
|
|
1458
|
+
} else if (e.composedPath) {
|
|
418
1459
|
const path = e.composedPath();
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
1460
|
+
if (path.length) {
|
|
1461
|
+
retarget(path[0]);
|
|
1462
|
+
for (let i = 0; i < path.length; i++) {
|
|
1463
|
+
node = path[i];
|
|
1464
|
+
if (!handleNode()) break;
|
|
1465
|
+
if (node._$host) {
|
|
1466
|
+
node = node._$host;
|
|
1467
|
+
walkUpTree();
|
|
1468
|
+
break;
|
|
1469
|
+
}
|
|
1470
|
+
if (node === boundary || node.parentNode === boundary) {
|
|
1471
|
+
break;
|
|
1472
|
+
}
|
|
430
1473
|
}
|
|
431
|
-
}
|
|
1474
|
+
} else walkUpTree();
|
|
432
1475
|
}
|
|
433
1476
|
else walkUpTree();
|
|
434
1477
|
retarget(oriTarget);
|
|
435
1478
|
}
|
|
436
1479
|
function insertExpression(parent, value, current, marker) {
|
|
437
|
-
if (isHydrating(parent))
|
|
438
|
-
|
|
1480
|
+
if (hydrationRt !== null && isHydrating(parent)) {
|
|
1481
|
+
if (value && value !== current) for (const n of Array.isArray(value) ? value : [value]) if (n && n.nodeType && !isHydrating(n)) return current;
|
|
1482
|
+
return value;
|
|
1483
|
+
}
|
|
1484
|
+
if (value === current) return value;
|
|
439
1485
|
const t = typeof value,
|
|
440
1486
|
multi = marker !== undefined;
|
|
441
1487
|
if (t === "string" || t === "number") {
|
|
442
1488
|
const tc = typeof current;
|
|
443
1489
|
if (tc === "string" || tc === "number") {
|
|
444
1490
|
parent.firstChild.data = value;
|
|
445
|
-
} else
|
|
1491
|
+
} else {
|
|
1492
|
+
if (ownsAllChildren(parent, current)) parent.textContent = value;else {
|
|
1493
|
+
removeOwnedChildren(parent, current);
|
|
1494
|
+
parent.insertBefore(document.createTextNode(value), parent.firstChild);
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
446
1497
|
} else if (value === undefined) {
|
|
447
1498
|
cleanChildren(parent, current, marker);
|
|
448
1499
|
} else if (value.nodeType) {
|
|
449
1500
|
if (Array.isArray(current)) {
|
|
450
1501
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
451
|
-
} else if (current
|
|
1502
|
+
} else if (current && current.nodeType) {
|
|
1503
|
+
current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
|
|
1504
|
+
} else if (current && parent.firstChild) {
|
|
1505
|
+
parent.replaceChild(value, parent.firstChild);
|
|
1506
|
+
} else {
|
|
452
1507
|
parent.appendChild(value);
|
|
453
|
-
}
|
|
1508
|
+
}
|
|
1509
|
+
if (marker) value[$$SLOT] = marker;
|
|
454
1510
|
} else if (Array.isArray(value)) {
|
|
455
1511
|
const currentArray = current && Array.isArray(current);
|
|
456
1512
|
if (value.length === 0) {
|
|
@@ -458,12 +1514,13 @@ function insertExpression(parent, value, current, marker) {
|
|
|
458
1514
|
} else if (currentArray) {
|
|
459
1515
|
if (current.length === 0) {
|
|
460
1516
|
appendNodes(parent, value, marker);
|
|
461
|
-
} else reconcileArrays(parent, current, value);
|
|
1517
|
+
} else reconcileArrays(parent, current, value, marker);
|
|
462
1518
|
} else {
|
|
463
|
-
current && cleanChildren(parent);
|
|
1519
|
+
current && cleanChildren(parent, current);
|
|
464
1520
|
appendNodes(parent, value);
|
|
465
1521
|
}
|
|
466
1522
|
} else console.warn(`Unrecognized value. Skipped inserting`, value);
|
|
1523
|
+
return value;
|
|
467
1524
|
}
|
|
468
1525
|
function normalize(value, current, multi, doNotUnwrap) {
|
|
469
1526
|
value = flatten(value, {
|
|
@@ -477,44 +1534,87 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
477
1534
|
const item = value[i],
|
|
478
1535
|
prev = current && current[i],
|
|
479
1536
|
t = typeof item;
|
|
480
|
-
if (t === "string" || t === "number") value[i] = prev && prev.nodeType === 3 && prev.data === item ? prev : document.createTextNode(item);
|
|
1537
|
+
if (t === "string" || t === "number") value[i] = prev && prev.nodeType === 3 && (sharedConfig.hydrating || prev.data === "" + item) ? prev : document.createTextNode(item);
|
|
481
1538
|
}
|
|
482
1539
|
}
|
|
483
1540
|
return value;
|
|
484
1541
|
}
|
|
1542
|
+
function tagHost(value, host) {
|
|
1543
|
+
if (Array.isArray(value)) {
|
|
1544
|
+
for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
|
|
1545
|
+
} else if (value && value.nodeType && value[$$HOST] !== host) {
|
|
1546
|
+
value[$$HOST] = host;
|
|
1547
|
+
Object.defineProperty(value, "_$host", {
|
|
1548
|
+
get: host,
|
|
1549
|
+
configurable: true
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
485
1553
|
function appendNodes(parent, array, marker = null) {
|
|
486
|
-
for (let i = 0, len = array.length; i < len; i++)
|
|
1554
|
+
for (let i = 0, len = array.length; i < len; i++) {
|
|
1555
|
+
const n = array[i];
|
|
1556
|
+
parent.insertBefore(n, marker);
|
|
1557
|
+
if (marker) n[$$SLOT] = marker;
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
function ownsAllChildren(parent, current) {
|
|
1561
|
+
if (current == null) return true;
|
|
1562
|
+
if (Array.isArray(current)) {
|
|
1563
|
+
return current.length ? parent.firstChild === current[0] && parent.lastChild === current[current.length - 1] : parent.firstChild === null;
|
|
1564
|
+
}
|
|
1565
|
+
if (current === "") return parent.firstChild === null;
|
|
1566
|
+
if (current.nodeType) return parent.firstChild === current && parent.lastChild === current;
|
|
1567
|
+
const first = parent.firstChild;
|
|
1568
|
+
return first !== null && first.nodeType === 3 && parent.lastChild === first;
|
|
1569
|
+
}
|
|
1570
|
+
function removeOwnedChildren(parent, current) {
|
|
1571
|
+
if (Array.isArray(current)) {
|
|
1572
|
+
for (let i = 0; i < current.length; i++) {
|
|
1573
|
+
const el = current[i];
|
|
1574
|
+
if (el.parentNode === parent) el.remove();
|
|
1575
|
+
}
|
|
1576
|
+
} else if (current.nodeType) {
|
|
1577
|
+
if (current.parentNode === parent) current.remove();
|
|
1578
|
+
} else {
|
|
1579
|
+
const first = parent.firstChild;
|
|
1580
|
+
if (first && first.nodeType === 3) first.remove();
|
|
1581
|
+
}
|
|
487
1582
|
}
|
|
488
1583
|
function cleanChildren(parent, current, marker, replacement) {
|
|
489
|
-
if (marker === undefined)
|
|
1584
|
+
if (marker === undefined) {
|
|
1585
|
+
if (ownsAllChildren(parent, current)) return parent.textContent = "";
|
|
1586
|
+
return removeOwnedChildren(parent, current);
|
|
1587
|
+
}
|
|
490
1588
|
if (current.length) {
|
|
491
1589
|
let inserted = false;
|
|
492
1590
|
for (let i = current.length - 1; i >= 0; i--) {
|
|
493
1591
|
const el = current[i];
|
|
494
1592
|
if (replacement !== el) {
|
|
495
|
-
const
|
|
496
|
-
|
|
1593
|
+
const tag = el[$$SLOT];
|
|
1594
|
+
const owns = el.parentNode === parent && (!tag || tag === marker);
|
|
1595
|
+
if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
|
|
497
1596
|
} else inserted = true;
|
|
498
1597
|
}
|
|
499
1598
|
} else if (replacement) parent.insertBefore(replacement, marker);
|
|
1599
|
+
if (replacement && marker) replacement[$$SLOT] = marker;
|
|
500
1600
|
}
|
|
501
1601
|
function gatherHydratable(element, root) {
|
|
502
1602
|
const templates = element.querySelectorAll(`*[_hk]`);
|
|
503
1603
|
for (let i = 0; i < templates.length; i++) {
|
|
504
1604
|
const node = templates[i];
|
|
505
1605
|
const key = node.getAttribute("_hk");
|
|
506
|
-
if (
|
|
1606
|
+
if (root) {
|
|
1607
|
+
if (!key.startsWith(root)) continue;
|
|
1608
|
+
} else {
|
|
1609
|
+
const frame = node.closest("[data-fid]");
|
|
1610
|
+
if (frame && frame !== element && element.contains(frame)) continue;
|
|
1611
|
+
}
|
|
1612
|
+
if (!sharedConfig.registry.has(key)) sharedConfig.registry.set(key, node);
|
|
507
1613
|
}
|
|
508
1614
|
}
|
|
509
1615
|
function getHydrationKey() {
|
|
510
1616
|
return sharedConfig.getNextContextId();
|
|
511
1617
|
}
|
|
512
|
-
function NoHydration(props) {
|
|
513
|
-
return sharedConfig.hydrating ? undefined : props.children;
|
|
514
|
-
}
|
|
515
|
-
function Hydration(props) {
|
|
516
|
-
return props.children;
|
|
517
|
-
}
|
|
518
1618
|
const voidFn = () => undefined;
|
|
519
1619
|
const RequestContext = Symbol();
|
|
520
1620
|
|
|
@@ -525,91 +1625,300 @@ function throwInBrowser(func) {
|
|
|
525
1625
|
function renderToString(fn, options) {
|
|
526
1626
|
throwInBrowser(renderToString);
|
|
527
1627
|
}
|
|
528
|
-
function renderToStringAsync(fn, options) {
|
|
529
|
-
throwInBrowser(renderToStringAsync);
|
|
530
|
-
}
|
|
531
1628
|
function renderToStream(fn, options) {
|
|
532
1629
|
throwInBrowser(renderToStream);
|
|
533
1630
|
}
|
|
1631
|
+
function createResponseStub() {
|
|
1632
|
+
throwInBrowser(createResponseStub);
|
|
1633
|
+
}
|
|
1634
|
+
function createRequestEvent(request, init) {
|
|
1635
|
+
throwInBrowser(createRequestEvent);
|
|
1636
|
+
}
|
|
1637
|
+
function getExpectedRedirectStatus(response) {
|
|
1638
|
+
throwInBrowser(getExpectedRedirectStatus);
|
|
1639
|
+
}
|
|
1640
|
+
function createSSRResponse() {
|
|
1641
|
+
throwInBrowser(createSSRResponse);
|
|
1642
|
+
}
|
|
1643
|
+
function commitEventResponse(response, event) {
|
|
1644
|
+
throwInBrowser(commitEventResponse);
|
|
1645
|
+
}
|
|
1646
|
+
function composeMiddleware(middlewares) {
|
|
1647
|
+
throwInBrowser(composeMiddleware);
|
|
1648
|
+
}
|
|
534
1649
|
function ssr(template, ...nodes) {}
|
|
535
1650
|
function ssrElement(name, props, children, needsId) {}
|
|
536
|
-
function
|
|
1651
|
+
function ssrClassName(value) {}
|
|
537
1652
|
function ssrStyle(value) {}
|
|
1653
|
+
function ssrStyleProperty(name, value) {}
|
|
538
1654
|
function ssrAttribute(key, value) {}
|
|
1655
|
+
function ssrGroup(fn, n) {}
|
|
539
1656
|
function ssrHydrationKey() {}
|
|
540
|
-
function resolveSSRNode(node) {}
|
|
541
|
-
function escape(
|
|
1657
|
+
function resolveSSRNode(node, result, top) {}
|
|
1658
|
+
function escape(s, attr) {}
|
|
1659
|
+
|
|
1660
|
+
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
1661
|
+
// PURE-annotated factory (same convention as solid's MockPromise): the brand
|
|
1662
|
+
const ResponseEnvelope = /* @__PURE__ */(() => {
|
|
1663
|
+
class ResponseEnvelope {
|
|
1664
|
+
constructor(response, value) {
|
|
1665
|
+
this.response = response;
|
|
1666
|
+
this.value = value;
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
ResponseEnvelope.prototype[ENVELOPE] = true;
|
|
1670
|
+
return ResponseEnvelope;
|
|
1671
|
+
})();
|
|
1672
|
+
function isResponseEnvelope(value) {
|
|
1673
|
+
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
1674
|
+
}
|
|
1675
|
+
const HREF = Symbol.for("solid.Href");
|
|
1676
|
+
function isHref(value) {
|
|
1677
|
+
return !!(value && (typeof value === "object" || typeof value === "function") && value[HREF]);
|
|
1678
|
+
}
|
|
1679
|
+
const SAFE_ERROR = Symbol.for("solid.SafeError");
|
|
1680
|
+
function markSafeError(error) {
|
|
1681
|
+
if (error && (typeof error === "object" || typeof error === "function")) {
|
|
1682
|
+
Object.defineProperty(error, SAFE_ERROR, {
|
|
1683
|
+
value: true,
|
|
1684
|
+
enumerable: false,
|
|
1685
|
+
configurable: true
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1688
|
+
return error;
|
|
1689
|
+
}
|
|
1690
|
+
function isSafeError(value) {
|
|
1691
|
+
return !!(value && (typeof value === "object" || typeof value === "function") && value[SAFE_ERROR]);
|
|
1692
|
+
}
|
|
1693
|
+
const REVALIDATE_HEADER = "X-Revalidate";
|
|
1694
|
+
function initWithRevalidate(init) {
|
|
1695
|
+
const {
|
|
1696
|
+
revalidate,
|
|
1697
|
+
...responseInit
|
|
1698
|
+
} = init;
|
|
1699
|
+
let headers;
|
|
1700
|
+
if (responseInit.headers && responseInit.headers.getSetCookie) {
|
|
1701
|
+
headers = new Headers();
|
|
1702
|
+
responseInit.headers.forEach((value, key) => {
|
|
1703
|
+
if (key !== "set-cookie") headers.append(key, value);
|
|
1704
|
+
});
|
|
1705
|
+
for (const cookie of responseInit.headers.getSetCookie()) {
|
|
1706
|
+
headers.append("Set-Cookie", cookie);
|
|
1707
|
+
}
|
|
1708
|
+
} else {
|
|
1709
|
+
headers = new Headers(responseInit.headers);
|
|
1710
|
+
}
|
|
1711
|
+
revalidate !== undefined && headers.set(REVALIDATE_HEADER, revalidate.toString());
|
|
1712
|
+
return {
|
|
1713
|
+
responseInit,
|
|
1714
|
+
headers
|
|
1715
|
+
};
|
|
1716
|
+
}
|
|
1717
|
+
function redirect(url, init = 302) {
|
|
1718
|
+
if (typeof url !== "string" && !isHref(url)) {
|
|
1719
|
+
throw new TypeError("redirect() expects a string URL or an Href-branded value (Symbol.for('solid.Href')).");
|
|
1720
|
+
}
|
|
1721
|
+
const {
|
|
1722
|
+
responseInit,
|
|
1723
|
+
headers
|
|
1724
|
+
} = initWithRevalidate(typeof init === "number" ? {
|
|
1725
|
+
status: init
|
|
1726
|
+
} : init);
|
|
1727
|
+
if (responseInit.status === undefined) {
|
|
1728
|
+
responseInit.status = 302;
|
|
1729
|
+
}
|
|
1730
|
+
headers.set("Location", String(url));
|
|
1731
|
+
return new Response(null, {
|
|
1732
|
+
...responseInit,
|
|
1733
|
+
headers
|
|
1734
|
+
});
|
|
1735
|
+
}
|
|
1736
|
+
function reload(init = {}) {
|
|
1737
|
+
const {
|
|
1738
|
+
responseInit,
|
|
1739
|
+
headers
|
|
1740
|
+
} = initWithRevalidate(init);
|
|
1741
|
+
return new Response(null, {
|
|
1742
|
+
...responseInit,
|
|
1743
|
+
headers
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1746
|
+
function respond(value, init = {}) {
|
|
1747
|
+
const {
|
|
1748
|
+
responseInit,
|
|
1749
|
+
headers
|
|
1750
|
+
} = initWithRevalidate(init);
|
|
1751
|
+
headers.set("Content-Type", "application/json");
|
|
1752
|
+
return new ResponseEnvelope(new Response(JSON.stringify(value), {
|
|
1753
|
+
...responseInit,
|
|
1754
|
+
headers
|
|
1755
|
+
}), value);
|
|
1756
|
+
}
|
|
542
1757
|
|
|
1758
|
+
const mergeProps = merge;
|
|
543
1759
|
const isServer = false;
|
|
544
1760
|
const isDev = true;
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
1761
|
+
function render(code, element, init, options = {}) {
|
|
1762
|
+
enforceLoadingBoundary(true);
|
|
1763
|
+
try {
|
|
1764
|
+
const dispose = render$1(code, element, init, {
|
|
1765
|
+
...options,
|
|
1766
|
+
insertOptions: {
|
|
1767
|
+
schedule: true
|
|
1768
|
+
}
|
|
1769
|
+
});
|
|
1770
|
+
flush();
|
|
1771
|
+
return dispose;
|
|
1772
|
+
} finally {
|
|
1773
|
+
enforceLoadingBoundary(false);
|
|
1774
|
+
}
|
|
550
1775
|
}
|
|
551
1776
|
const hydrate = (...args) => {
|
|
552
1777
|
enableHydration();
|
|
553
1778
|
return hydrate$1(...args);
|
|
554
1779
|
};
|
|
555
1780
|
function Portal(props) {
|
|
1781
|
+
return runWithOwner(createOwner(), () => portalImpl(props));
|
|
1782
|
+
}
|
|
1783
|
+
function portalImpl(props) {
|
|
556
1784
|
const treeMarker = document.createTextNode(""),
|
|
557
1785
|
startMarker = document.createTextNode(""),
|
|
558
1786
|
endMarker = document.createTextNode(""),
|
|
559
|
-
mount = () =>
|
|
560
|
-
|
|
561
|
-
|
|
1787
|
+
mount = () => props.mount || document.body,
|
|
1788
|
+
content = createMemo(() => [startMarker, props.children], {
|
|
1789
|
+
ssrSource: "client",
|
|
1790
|
+
loadingValue: undefined
|
|
1791
|
+
});
|
|
1792
|
+
createRenderEffect(
|
|
1793
|
+
() => [mount(), content(), getOwner()], ([, c, owner]) => {
|
|
1794
|
+
const m = untrack(mount);
|
|
562
1795
|
m.appendChild(endMarker);
|
|
563
|
-
|
|
1796
|
+
const dispose = runWithOwner(owner, () => createRoot(d => {
|
|
1797
|
+
insert(m, c, endMarker, undefined, {
|
|
1798
|
+
host: () => treeMarker.parentNode
|
|
1799
|
+
});
|
|
1800
|
+
return d;
|
|
1801
|
+
}));
|
|
564
1802
|
return () => {
|
|
1803
|
+
dispose();
|
|
565
1804
|
let c = startMarker;
|
|
566
|
-
while (c
|
|
1805
|
+
while (c) {
|
|
567
1806
|
const n = c.nextSibling;
|
|
568
1807
|
m.removeChild(c);
|
|
1808
|
+
if (c === endMarker) break;
|
|
569
1809
|
c = n;
|
|
570
1810
|
}
|
|
571
1811
|
};
|
|
1812
|
+
},
|
|
1813
|
+
{
|
|
1814
|
+
schedule: true,
|
|
1815
|
+
ssrSource: "client"
|
|
1816
|
+
});
|
|
1817
|
+
createEffect(mount, () => {
|
|
1818
|
+
const m = untrack(mount);
|
|
1819
|
+
const ownerRoot = getDelegatedRoot(treeMarker);
|
|
1820
|
+
if (!ownerRoot || ownerRoot.contains(m)) return;
|
|
1821
|
+
registerDelegatedContainer(m, ownerRoot);
|
|
1822
|
+
return () => unregisterDelegatedContainer(m, ownerRoot);
|
|
1823
|
+
}, {
|
|
1824
|
+
ssrSource: "client"
|
|
1825
|
+
});
|
|
1826
|
+
if (sharedConfig.hydrating) return createMemo(() => treeMarker, {
|
|
1827
|
+
ssrSource: "client",
|
|
1828
|
+
loadingValue: undefined
|
|
572
1829
|
});
|
|
573
1830
|
return treeMarker;
|
|
574
1831
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
if (prop === "appendChild" || prop === "insertBefore") {
|
|
579
|
-
return (...args) => {
|
|
580
|
-
Object.defineProperty(args[0], "_$host", {
|
|
581
|
-
get: () => marker.parentNode,
|
|
582
|
-
configurable: true
|
|
583
|
-
});
|
|
584
|
-
target[prop](...args);
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
const value = Reflect.get(target, prop);
|
|
588
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
589
|
-
}
|
|
590
|
-
});
|
|
1832
|
+
const COMPONENT_BINDING = Symbol.for("dom-expressions.component-binding");
|
|
1833
|
+
function bindingOf(value) {
|
|
1834
|
+
return value !== null && (typeof value === "function" || typeof value === "object") && value[COMPONENT_BINDING] || undefined;
|
|
591
1835
|
}
|
|
592
|
-
function
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
const el = sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, untrack(() => props.is));
|
|
605
|
-
spread(el, props, isSvg);
|
|
606
|
-
return el;
|
|
1836
|
+
function dynamic(source) {
|
|
1837
|
+
let latest = 0;
|
|
1838
|
+
const sites = new Set();
|
|
1839
|
+
let deliveredAddress;
|
|
1840
|
+
const resolveBinding = (next, prev) => {
|
|
1841
|
+
const binding = bindingOf(next);
|
|
1842
|
+
if (!binding) return next;
|
|
1843
|
+
deliveredAddress = binding.address;
|
|
1844
|
+
const prevBinding = bindingOf(prev);
|
|
1845
|
+
if (prevBinding && prevBinding.component === binding.component) {
|
|
1846
|
+
for (const deliver of sites) deliver(binding.address);
|
|
1847
|
+
return prev;
|
|
607
1848
|
}
|
|
1849
|
+
return next;
|
|
1850
|
+
};
|
|
1851
|
+
const cached = createMemo(prev => {
|
|
1852
|
+
const next = source();
|
|
1853
|
+
if (!next || typeof next.then !== "function") return resolveBinding(next, prev);
|
|
1854
|
+
const token = ++latest;
|
|
1855
|
+
return {
|
|
1856
|
+
then: (onFulfilled, onRejected) => next.then(resolved => onFulfilled(token === latest ? resolveBinding(resolved, prev) : resolved), onRejected)
|
|
1857
|
+
};
|
|
1858
|
+
}, {
|
|
1859
|
+
lazy: true
|
|
608
1860
|
});
|
|
1861
|
+
return props => {
|
|
1862
|
+
return createMemo(() => {
|
|
1863
|
+
const component = cached();
|
|
1864
|
+
switch (typeof component) {
|
|
1865
|
+
case "function":
|
|
1866
|
+
{
|
|
1867
|
+
Object.assign(component, {
|
|
1868
|
+
[$DEVCOMP]: true
|
|
1869
|
+
});
|
|
1870
|
+
const binding = bindingOf(component);
|
|
1871
|
+
if (binding) {
|
|
1872
|
+
const [address, setAddress] = createSignal(deliveredAddress ?? binding.address);
|
|
1873
|
+
sites.add(setAddress);
|
|
1874
|
+
onCleanup(() => sites.delete(setAddress));
|
|
1875
|
+
return untrack(() => binding.component(props, address));
|
|
1876
|
+
}
|
|
1877
|
+
return untrack(() => component(props));
|
|
1878
|
+
}
|
|
1879
|
+
case "string":
|
|
1880
|
+
const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
|
|
1881
|
+
spread(el, props);
|
|
1882
|
+
return el;
|
|
1883
|
+
}
|
|
1884
|
+
});
|
|
1885
|
+
};
|
|
609
1886
|
}
|
|
610
1887
|
function Dynamic(props) {
|
|
611
|
-
const
|
|
612
|
-
return
|
|
1888
|
+
const Comp = dynamic(() => props.component);
|
|
1889
|
+
return createComponent(Comp, omit(props, "component"));
|
|
1890
|
+
}
|
|
1891
|
+
function createElement(tagName, is = undefined) {
|
|
1892
|
+
return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
|
|
1893
|
+
is
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
function loadClientOnly(fn, setComp) {
|
|
1897
|
+
fn().then(m => setComp(() => m.default));
|
|
1898
|
+
}
|
|
1899
|
+
function clientOnly(fn, options = {},
|
|
1900
|
+
_moduleUrl) {
|
|
1901
|
+
const [comp, setComp] = createSignal();
|
|
1902
|
+
let started = !options.lazy;
|
|
1903
|
+
started && loadClientOnly(fn, setComp);
|
|
1904
|
+
return props => {
|
|
1905
|
+
let Comp;
|
|
1906
|
+
let m;
|
|
1907
|
+
const rest = omit(props, "fallback");
|
|
1908
|
+
if (!started) {
|
|
1909
|
+
started = true;
|
|
1910
|
+
loadClientOnly(fn, setComp);
|
|
1911
|
+
}
|
|
1912
|
+
if ((Comp = untrack(comp)) && !sharedConfig.hydrating) return Comp(rest);
|
|
1913
|
+
const [mounted, setMounted] = createSignal(!sharedConfig.hydrating);
|
|
1914
|
+
const gate = createMemo(() => (Comp = comp(), m = mounted(), untrack(() => Comp && m ? Comp(rest) : props.fallback)));
|
|
1915
|
+
const onHydrationEnd = sharedConfig.onHydrationEnd;
|
|
1916
|
+
const release = () => setMounted(true);
|
|
1917
|
+
onHydrationEnd ? onHydrationEnd(release) : queueMicrotask(release);
|
|
1918
|
+
return gate;
|
|
1919
|
+
};
|
|
613
1920
|
}
|
|
1921
|
+
function httpStatus(_code, _text) {}
|
|
1922
|
+
function httpHeader(_name, _value, _options) {}
|
|
614
1923
|
|
|
615
|
-
export {
|
|
1924
|
+
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, hasFlashCookie, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, mergeProps, parseCookieHeader, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, warmAsset };
|