@solidjs/web 2.0.0-beta.1 → 2.0.0-beta.10
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 +27 -4
- package/dist/dev.cjs +223 -95
- package/dist/dev.js +211 -91
- package/dist/server.cjs +184 -79
- package/dist/server.js +178 -79
- package/dist/web.cjs +209 -86
- package/dist/web.js +197 -82
- package/package.json +98 -33
- package/storage/package.json +8 -3
- package/storage/types/src/index.d.ts +147 -21
- package/storage/types/src/jsx.d.ts +29 -0
- package/storage/types/src/server-mock.d.ts +89 -0
- package/storage/types-cjs/index.d.cts +2 -0
- package/storage/types-cjs/package.json +3 -0
- package/storage/types-cjs/src/client.d.cts +1 -0
- package/storage/types-cjs/src/index.d.cts +171 -0
- package/storage/types-cjs/src/jsx.d.cts +29 -0
- package/storage/types-cjs/src/server-mock.d.cts +161 -0
- package/storage/types-cjs/storage/src/index.d.cts +2 -0
- package/types/client.d.ts +31 -15
- package/types/core.d.ts +1 -1
- package/types/index.d.ts +147 -21
- package/types/jsx-properties.d.ts +92 -0
- package/types/jsx.d.ts +4321 -1
- package/types/server-mock.d.ts +89 -0
- package/types/server.d.ts +35 -17
- package/types-cjs/client.d.cts +104 -0
- package/types-cjs/core.d.cts +3 -0
- package/types-cjs/index.d.cts +171 -0
- package/types-cjs/jsx-properties.d.cts +92 -0
- package/types-cjs/jsx.d.cts +4321 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/server-mock.d.cts +161 -0
- package/types-cjs/server.d.cts +174 -0
package/dist/dev.js
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, createRoot,
|
|
2
|
-
export { Errored, For, Hydration, Loading, Match, NoHydration, Show, Switch, createComponent, getOwner,
|
|
1
|
+
import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, $DEVCOMP, enableHydration, enforceLoadingBoundary, flush } 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"]);
|
|
7
33
|
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
34
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -10,17 +36,26 @@ const SVGElements = /*#__PURE__*/new Set([
|
|
|
10
36
|
"set", "stop",
|
|
11
37
|
"svg", "switch", "symbol", "text", "textPath",
|
|
12
38
|
"tref", "tspan", "use", "view", "vkern"]);
|
|
13
|
-
const
|
|
39
|
+
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"]);
|
|
40
|
+
const Namespaces = {
|
|
41
|
+
svg: "http://www.w3.org/2000/svg",
|
|
42
|
+
mathml: "http://www.w3.org/1998/Math/MathML",
|
|
14
43
|
xlink: "http://www.w3.org/1999/xlink",
|
|
15
44
|
xml: "http://www.w3.org/XML/1998/namespace"
|
|
16
45
|
};
|
|
46
|
+
const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
47
|
+
const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
|
|
17
48
|
const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "main", "nav", "section", "body", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "param", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "menu", "summary", "details", "slot", "template", "acronym", "applet", "basefont", "bgsound", "big", "blink", "center", "content", "dir", "font", "frame", "frameset", "hgroup", "image", "keygen", "marquee", "menuitem", "nobr", "noembed", "noframes", "plaintext", "rb", "rtc", "shadow", "spacer", "strike", "tt", "xmp", "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", "head", "header", "hgroup", "hr", "html", "i", "iframe", "image", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "marquee", "menu", "menuitem", "meta", "meter", "nav", "nobr", "noembed", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "plaintext", "portal", "pre", "progress", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr", "xmp", "input", "h1", "h2", "h3", "h4", "h5", "h6",
|
|
18
49
|
"webview",
|
|
19
50
|
"isindex", "listing", "multicol", "nextid", "noindex", "search"]);
|
|
20
51
|
|
|
21
|
-
const
|
|
52
|
+
const transparentOptions = {
|
|
22
53
|
transparent: true
|
|
23
|
-
}
|
|
54
|
+
};
|
|
55
|
+
const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, options ? {
|
|
56
|
+
transparent: true,
|
|
57
|
+
...options
|
|
58
|
+
} : transparentOptions);
|
|
24
59
|
const memo = fn => createMemo(() => fn());
|
|
25
60
|
|
|
26
61
|
function reconcileArrays(parentNode, a, b) {
|
|
@@ -81,32 +116,40 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
81
116
|
}
|
|
82
117
|
|
|
83
118
|
const $$EVENTS = "_$DX_DELEGATE";
|
|
84
|
-
|
|
119
|
+
const INNER_OWNED = {};
|
|
120
|
+
function render$1(code, element, init, options = {}) {
|
|
85
121
|
if (!element) {
|
|
86
122
|
throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
|
|
87
123
|
}
|
|
124
|
+
const renderRoot = getChildRoot(element);
|
|
88
125
|
let disposer;
|
|
89
126
|
createRoot(dispose => {
|
|
90
127
|
disposer = dispose;
|
|
91
|
-
element === document
|
|
128
|
+
if (element === document) {
|
|
129
|
+
const tree = code();
|
|
130
|
+
effect(() => flatten(tree), () => {});
|
|
131
|
+
} else {
|
|
132
|
+
const tree = code();
|
|
133
|
+
insert(element, () => tree, renderRoot.firstChild ? null : undefined, init, options.insertOptions);
|
|
134
|
+
}
|
|
92
135
|
}, {
|
|
93
136
|
id: options.renderId
|
|
94
137
|
});
|
|
95
138
|
return () => {
|
|
96
139
|
disposer();
|
|
97
|
-
|
|
140
|
+
renderRoot.textContent = "";
|
|
98
141
|
};
|
|
99
142
|
}
|
|
100
|
-
function
|
|
143
|
+
function create(html, bypassGuard, flag) {
|
|
144
|
+
if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
|
|
145
|
+
const t = document.createElement("template");
|
|
146
|
+
t.innerHTML = html;
|
|
147
|
+
return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
148
|
+
}
|
|
149
|
+
function template(html, flag) {
|
|
101
150
|
let node;
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
|
|
105
|
-
t.innerHTML = html;
|
|
106
|
-
return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
|
|
107
|
-
};
|
|
108
|
-
const fn = isImportNode ? bypassGuard => untrack(() => document.importNode(node || (node = create(bypassGuard)), true)) : bypassGuard => (node || (node = create(bypassGuard))).cloneNode(true);
|
|
109
|
-
fn._html = html;
|
|
151
|
+
const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
|
|
152
|
+
fn._html = flag === 2 ? html.replace(/^<[^>]+>/, "") : html;
|
|
110
153
|
return fn;
|
|
111
154
|
}
|
|
112
155
|
function delegateEvents(eventNames, document = window.document) {
|
|
@@ -135,16 +178,16 @@ function setAttribute(node, name, value) {
|
|
|
135
178
|
}
|
|
136
179
|
function setAttributeNS(node, namespace, name, value) {
|
|
137
180
|
if (isHydrating(node)) return;
|
|
138
|
-
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
181
|
+
if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
139
182
|
}
|
|
140
|
-
function className(node, value,
|
|
183
|
+
function className(node, value, prev) {
|
|
141
184
|
if (isHydrating(node)) return;
|
|
142
185
|
if (value == null || value === false) {
|
|
143
186
|
prev && node.removeAttribute("class");
|
|
144
187
|
return;
|
|
145
188
|
}
|
|
146
189
|
if (typeof value === "string") {
|
|
147
|
-
value !== prev &&
|
|
190
|
+
value !== prev && node.setAttribute("class", value);
|
|
148
191
|
return;
|
|
149
192
|
}
|
|
150
193
|
if (typeof prev === "string") {
|
|
@@ -187,7 +230,6 @@ function style(node, value, prev) {
|
|
|
187
230
|
if (typeof value === "string") return nodeStyle.cssText = value;
|
|
188
231
|
typeof prev === "string" && (nodeStyle.cssText = prev = undefined);
|
|
189
232
|
prev || (prev = {});
|
|
190
|
-
value || (value = {});
|
|
191
233
|
let v, s;
|
|
192
234
|
for (s in value) {
|
|
193
235
|
v = value[s];
|
|
@@ -199,14 +241,9 @@ function style(node, value, prev) {
|
|
|
199
241
|
function setStyleProperty(node, name, value) {
|
|
200
242
|
value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
|
|
201
243
|
}
|
|
202
|
-
function spread(node, props = {},
|
|
244
|
+
function spread(node, props = {}, skipChildren) {
|
|
203
245
|
const prevProps = {};
|
|
204
|
-
if (!skipChildren)
|
|
205
|
-
effect(() => normalize(props.children, prevProps.children), value => {
|
|
206
|
-
insertExpression(node, value, prevProps.children);
|
|
207
|
-
prevProps.children = value;
|
|
208
|
-
});
|
|
209
|
-
}
|
|
246
|
+
if (!skipChildren) insert(node, () => props.children);
|
|
210
247
|
effect(() => {
|
|
211
248
|
const r = props.ref;
|
|
212
249
|
(typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
|
|
@@ -218,7 +255,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
218
255
|
newProps[prop] = props[prop];
|
|
219
256
|
}
|
|
220
257
|
return newProps;
|
|
221
|
-
}, props => assign(node, props,
|
|
258
|
+
}, props => assign(node, props, true, prevProps, true));
|
|
222
259
|
return prevProps;
|
|
223
260
|
}
|
|
224
261
|
function dynamicProperty(props, key) {
|
|
@@ -238,11 +275,12 @@ function ref(fn, element) {
|
|
|
238
275
|
const resolved = untrack(fn);
|
|
239
276
|
runWithOwner(null, () => applyRef(resolved, element));
|
|
240
277
|
}
|
|
241
|
-
function insert(parent, accessor, marker, initial) {
|
|
278
|
+
function insert(parent, accessor, marker, initial, options) {
|
|
279
|
+
const childRoot = getChildRoot(parent);
|
|
242
280
|
const multi = marker !== undefined;
|
|
243
281
|
if (multi && !initial) initial = [];
|
|
244
282
|
if (isHydrating(parent)) {
|
|
245
|
-
if (!multi && initial === undefined && parent) initial = [...
|
|
283
|
+
if (!multi && initial === undefined && parent) initial = [...childRoot.childNodes];
|
|
246
284
|
if (Array.isArray(initial)) {
|
|
247
285
|
let j = 0;
|
|
248
286
|
for (let i = 0; i < initial.length; i++) {
|
|
@@ -255,27 +293,61 @@ function insert(parent, accessor, marker, initial) {
|
|
|
255
293
|
accessor = normalize(accessor, initial, multi, true);
|
|
256
294
|
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
257
295
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
296
|
+
if (multi && initial.length === 0) {
|
|
297
|
+
const placeholder = document.createTextNode("");
|
|
298
|
+
childRoot.insertBefore(placeholder, marker);
|
|
299
|
+
initial = [placeholder];
|
|
300
|
+
}
|
|
301
|
+
let current = initial;
|
|
302
|
+
effect(() => {
|
|
303
|
+
const value = normalize(accessor(), current, multi, true);
|
|
304
|
+
if (typeof value !== "function") return value;
|
|
305
|
+
effect(() => normalize(value, current, multi), inner => {
|
|
306
|
+
insertExpression(parent, inner, current, marker);
|
|
307
|
+
current = inner;
|
|
308
|
+
}, options);
|
|
309
|
+
return INNER_OWNED;
|
|
310
|
+
}, value => {
|
|
311
|
+
if (value === INNER_OWNED) return;
|
|
312
|
+
insertExpression(parent, value, current, marker);
|
|
313
|
+
current = value;
|
|
314
|
+
}, options);
|
|
315
|
+
}
|
|
316
|
+
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
317
|
+
const nodeName = node.nodeName;
|
|
261
318
|
props || (props = {});
|
|
262
319
|
for (const prop in prevProps) {
|
|
263
320
|
if (!(prop in props)) {
|
|
264
321
|
if (prop === "children") continue;
|
|
265
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop],
|
|
322
|
+
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
|
|
266
323
|
}
|
|
267
324
|
}
|
|
268
325
|
for (const prop in props) {
|
|
269
326
|
if (prop === "children") {
|
|
270
|
-
if (!skipChildren) insertExpression(node, props.children);
|
|
327
|
+
if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
|
|
271
328
|
continue;
|
|
272
329
|
}
|
|
273
|
-
|
|
274
|
-
|
|
330
|
+
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
function loadModuleAssets(mapping) {
|
|
334
|
+
const hy = globalThis._$HY;
|
|
335
|
+
if (!hy) return;
|
|
336
|
+
const pending = [];
|
|
337
|
+
for (const moduleUrl in mapping) {
|
|
338
|
+
if (hy.modules[moduleUrl]) continue;
|
|
339
|
+
const entryUrl = mapping[moduleUrl];
|
|
340
|
+
if (!hy.loading[moduleUrl]) {
|
|
341
|
+
hy.loading[moduleUrl] = import(entryUrl).then(mod => {
|
|
342
|
+
hy.modules[moduleUrl] = mod;
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
pending.push(hy.loading[moduleUrl]);
|
|
275
346
|
}
|
|
347
|
+
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
276
348
|
}
|
|
277
349
|
function hydrate$1(code, element, options = {}) {
|
|
278
|
-
if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
|
|
350
|
+
if (globalThis._$HY.done) return render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
279
351
|
options.renderId ||= "";
|
|
280
352
|
if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
|
|
281
353
|
if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
|
|
@@ -284,6 +356,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
284
356
|
sharedConfig.load = id => globalThis._$HY.r[id];
|
|
285
357
|
sharedConfig.has = id => id in globalThis._$HY.r;
|
|
286
358
|
sharedConfig.gather = root => gatherHydratable(element, root);
|
|
359
|
+
sharedConfig.loadModuleAssets = loadModuleAssets;
|
|
287
360
|
sharedConfig.cleanupFragment = id => {
|
|
288
361
|
const tpl = document.getElementById("pl-" + id);
|
|
289
362
|
if (tpl) {
|
|
@@ -305,14 +378,34 @@ function hydrate$1(code, element, options = {}) {
|
|
|
305
378
|
{
|
|
306
379
|
sharedConfig.verifyHydration = () => {
|
|
307
380
|
if (sharedConfig.registry && sharedConfig.registry.size) {
|
|
308
|
-
const orphaned = [...sharedConfig.registry.values()];
|
|
381
|
+
const orphaned = [...sharedConfig.registry.values()].filter(node => node.isConnected);
|
|
382
|
+
sharedConfig.registry.clear();
|
|
383
|
+
if (!orphaned.length) return;
|
|
309
384
|
console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
|
|
310
385
|
}
|
|
311
386
|
};
|
|
312
387
|
}
|
|
388
|
+
const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
|
|
389
|
+
if (rootMapping && typeof rootMapping === "object") {
|
|
390
|
+
const p = loadModuleAssets(rootMapping);
|
|
391
|
+
if (p) {
|
|
392
|
+
gatherHydratable(element, options.renderId);
|
|
393
|
+
let disposer;
|
|
394
|
+
p.then(() => {
|
|
395
|
+
try {
|
|
396
|
+
disposer = render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
397
|
+
} finally {
|
|
398
|
+
sharedConfig.hydrating = false;
|
|
399
|
+
}
|
|
400
|
+
}, () => {
|
|
401
|
+
sharedConfig.hydrating = false;
|
|
402
|
+
});
|
|
403
|
+
return () => disposer && disposer();
|
|
404
|
+
}
|
|
405
|
+
}
|
|
313
406
|
try {
|
|
314
407
|
gatherHydratable(element, options.renderId);
|
|
315
|
-
return render(code, element, [...element.childNodes], options);
|
|
408
|
+
return render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
316
409
|
} finally {
|
|
317
410
|
sharedConfig.hydrating = false;
|
|
318
411
|
}
|
|
@@ -361,7 +454,7 @@ function getNextMarker(start) {
|
|
|
361
454
|
return [end, current];
|
|
362
455
|
}
|
|
363
456
|
function getFirstChild(node, expectedTag) {
|
|
364
|
-
const child = node.firstChild;
|
|
457
|
+
const child = getChildRoot(node).firstChild;
|
|
365
458
|
if (isHydrating() && expectedTag && child?.localName !== expectedTag) {
|
|
366
459
|
const isMissing = !child || child.nodeType !== 1;
|
|
367
460
|
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> as first child of", node, "\n " + describeSiblings(node, child, expectedTag, isMissing));
|
|
@@ -371,20 +464,21 @@ function getFirstChild(node, expectedTag) {
|
|
|
371
464
|
function getNextSibling(node, expectedTag) {
|
|
372
465
|
const sibling = node.nextSibling;
|
|
373
466
|
if (isHydrating() && expectedTag && sibling?.localName !== expectedTag) {
|
|
374
|
-
const parent = node.
|
|
467
|
+
const parent = node.parentNode;
|
|
375
468
|
const isMissing = !sibling || sibling.nodeType !== 1;
|
|
376
469
|
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> after", node, "in", parent, "\n " + describeSiblings(parent, sibling, expectedTag, isMissing));
|
|
377
470
|
}
|
|
378
471
|
return sibling;
|
|
379
472
|
}
|
|
380
473
|
function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
|
|
474
|
+
if (!parent) return `<${expectedTag} \u2190 parent unavailable>`;
|
|
381
475
|
const children = [];
|
|
382
|
-
let child = parent.firstChild;
|
|
476
|
+
let child = getChildRoot(parent).firstChild;
|
|
383
477
|
while (child) {
|
|
384
478
|
if (child.nodeType === 1) children.push(child);
|
|
385
479
|
child = child.nextSibling;
|
|
386
480
|
}
|
|
387
|
-
const pTag = parent.localName;
|
|
481
|
+
const pTag = parent.localName || "#fragment";
|
|
388
482
|
if (isMissing) {
|
|
389
483
|
const tags = children.map(c => `<${c.localName}>`).join("");
|
|
390
484
|
return `<${pTag}>${tags}<${expectedTag} \u2190 missing></${pTag}>`;
|
|
@@ -429,6 +523,9 @@ function runHydrationEvents() {
|
|
|
429
523
|
function isHydrating(node) {
|
|
430
524
|
return sharedConfig.hydrating && (!node || node.isConnected);
|
|
431
525
|
}
|
|
526
|
+
function getChildRoot(node) {
|
|
527
|
+
return node && node.localName === "template" ? node.content : node;
|
|
528
|
+
}
|
|
432
529
|
function toggleClassKey(node, key, value) {
|
|
433
530
|
const classNames = key.trim().split(/\s+/);
|
|
434
531
|
for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
|
|
@@ -447,18 +544,20 @@ function flattenClassList(list, result) {
|
|
|
447
544
|
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;
|
|
448
545
|
}
|
|
449
546
|
}
|
|
450
|
-
function assignProp(node, prop, value, prev,
|
|
451
|
-
let forceProp;
|
|
547
|
+
function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
452
548
|
if (prop === "style") return style(node, value, prev), value;
|
|
453
|
-
if (prop === "class") return className(node, value,
|
|
454
|
-
if (value === prev) return prev;
|
|
549
|
+
if (prop === "class") return className(node, value, prev), value;
|
|
550
|
+
if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
|
|
455
551
|
if (prop === "ref") {
|
|
456
552
|
if (!skipRef && value) ref(() => value, node);
|
|
457
|
-
|
|
553
|
+
return value;
|
|
554
|
+
}
|
|
555
|
+
const hasNamespace = prop.indexOf(":") > -1;
|
|
556
|
+
if (hasNamespace && prop.slice(0, 3) === "on:") {
|
|
458
557
|
const e = prop.slice(3);
|
|
459
558
|
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
460
559
|
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
461
|
-
} else if (prop.slice(0, 2) === "on") {
|
|
560
|
+
} else if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
462
561
|
const name = prop.slice(2).toLowerCase();
|
|
463
562
|
const delegate = DelegatedEvents.has(name);
|
|
464
563
|
if (!delegate && prev) {
|
|
@@ -469,11 +568,11 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
469
568
|
addEventListener(node, name, value, delegate);
|
|
470
569
|
delegate && delegateEvents([name]);
|
|
471
570
|
}
|
|
472
|
-
} else if (
|
|
473
|
-
if (
|
|
474
|
-
if (prop === "value" &&
|
|
571
|
+
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
572
|
+
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
573
|
+
if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
|
|
475
574
|
} else {
|
|
476
|
-
const ns =
|
|
575
|
+
const ns = hasNamespace && Namespaces[prop.split(":")[0]];
|
|
477
576
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
478
577
|
}
|
|
479
578
|
return value;
|
|
@@ -531,21 +630,22 @@ function eventHandler(e) {
|
|
|
531
630
|
function insertExpression(parent, value, current, marker) {
|
|
532
631
|
if (isHydrating(parent)) return;
|
|
533
632
|
if (value === current) return;
|
|
633
|
+
const childRoot = getChildRoot(parent);
|
|
534
634
|
const t = typeof value,
|
|
535
635
|
multi = marker !== undefined;
|
|
536
636
|
if (t === "string" || t === "number") {
|
|
537
637
|
const tc = typeof current;
|
|
538
638
|
if (tc === "string" || tc === "number") {
|
|
539
|
-
|
|
540
|
-
} else
|
|
639
|
+
childRoot.firstChild.data = value;
|
|
640
|
+
} else childRoot.textContent = value;
|
|
541
641
|
} else if (value === undefined) {
|
|
542
642
|
cleanChildren(parent, current, marker);
|
|
543
643
|
} else if (value.nodeType) {
|
|
544
644
|
if (Array.isArray(current)) {
|
|
545
645
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
546
|
-
} else if (current === undefined || !
|
|
547
|
-
|
|
548
|
-
} else
|
|
646
|
+
} else if (current === undefined || !childRoot.firstChild) {
|
|
647
|
+
childRoot.appendChild(value);
|
|
648
|
+
} else childRoot.replaceChild(value, childRoot.firstChild);
|
|
549
649
|
} else if (Array.isArray(value)) {
|
|
550
650
|
const currentArray = current && Array.isArray(current);
|
|
551
651
|
if (value.length === 0) {
|
|
@@ -553,7 +653,7 @@ function insertExpression(parent, value, current, marker) {
|
|
|
553
653
|
} else if (currentArray) {
|
|
554
654
|
if (current.length === 0) {
|
|
555
655
|
appendNodes(parent, value, marker);
|
|
556
|
-
} else reconcileArrays(
|
|
656
|
+
} else reconcileArrays(childRoot, current, value);
|
|
557
657
|
} else {
|
|
558
658
|
current && cleanChildren(parent);
|
|
559
659
|
appendNodes(parent, value);
|
|
@@ -578,9 +678,11 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
578
678
|
return value;
|
|
579
679
|
}
|
|
580
680
|
function appendNodes(parent, array, marker = null) {
|
|
681
|
+
parent = getChildRoot(parent);
|
|
581
682
|
for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
|
|
582
683
|
}
|
|
583
684
|
function cleanChildren(parent, current, marker, replacement) {
|
|
685
|
+
parent = getChildRoot(parent);
|
|
584
686
|
if (marker === undefined) return parent.textContent = "";
|
|
585
687
|
if (current.length) {
|
|
586
688
|
let inserted = false;
|
|
@@ -629,13 +731,23 @@ function ssrHydrationKey() {}
|
|
|
629
731
|
function resolveSSRNode(node) {}
|
|
630
732
|
function escape(html) {}
|
|
631
733
|
|
|
734
|
+
const mergeProps = merge;
|
|
632
735
|
const isServer = false;
|
|
633
736
|
const isDev = true;
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
737
|
+
function render(code, element, init, options = {}) {
|
|
738
|
+
enforceLoadingBoundary(true);
|
|
739
|
+
try {
|
|
740
|
+
const dispose = render$1(code, element, init, {
|
|
741
|
+
...options,
|
|
742
|
+
insertOptions: {
|
|
743
|
+
schedule: true
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
flush();
|
|
747
|
+
return dispose;
|
|
748
|
+
} finally {
|
|
749
|
+
enforceLoadingBoundary(false);
|
|
750
|
+
}
|
|
639
751
|
}
|
|
640
752
|
const hydrate = (...args) => {
|
|
641
753
|
enableHydration();
|
|
@@ -661,6 +773,36 @@ function Portal(props) {
|
|
|
661
773
|
});
|
|
662
774
|
return treeMarker;
|
|
663
775
|
}
|
|
776
|
+
function dynamic(source) {
|
|
777
|
+
const cached = createMemo(source, {
|
|
778
|
+
lazy: true
|
|
779
|
+
});
|
|
780
|
+
return props => {
|
|
781
|
+
return createMemo(() => {
|
|
782
|
+
const component = cached();
|
|
783
|
+
switch (typeof component) {
|
|
784
|
+
case "function":
|
|
785
|
+
Object.assign(component, {
|
|
786
|
+
[$DEVCOMP]: true
|
|
787
|
+
});
|
|
788
|
+
return untrack(() => component(props));
|
|
789
|
+
case "string":
|
|
790
|
+
const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
|
|
791
|
+
spread(el, props);
|
|
792
|
+
return el;
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
function Dynamic(props) {
|
|
798
|
+
const Comp = dynamic(() => props.component);
|
|
799
|
+
return createComponent(Comp, omit(props, "component"));
|
|
800
|
+
}
|
|
801
|
+
function createElement(tagName, is = undefined) {
|
|
802
|
+
return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
|
|
803
|
+
is
|
|
804
|
+
});
|
|
805
|
+
}
|
|
664
806
|
function createElementProxy(el, marker) {
|
|
665
807
|
return new Proxy(el, {
|
|
666
808
|
get(target, prop) {
|
|
@@ -678,27 +820,5 @@ function createElementProxy(el, marker) {
|
|
|
678
820
|
}
|
|
679
821
|
});
|
|
680
822
|
}
|
|
681
|
-
function createDynamic(component, props) {
|
|
682
|
-
const cached = createMemo(component);
|
|
683
|
-
return createMemo(() => {
|
|
684
|
-
const component = cached();
|
|
685
|
-
switch (typeof component) {
|
|
686
|
-
case "function":
|
|
687
|
-
Object.assign(component, {
|
|
688
|
-
[$DEVCOMP]: true
|
|
689
|
-
});
|
|
690
|
-
return untrack(() => component(props));
|
|
691
|
-
case "string":
|
|
692
|
-
const isSvg = SVGElements.has(component);
|
|
693
|
-
const el = sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, untrack(() => props.is));
|
|
694
|
-
spread(el, props, isSvg);
|
|
695
|
-
return el;
|
|
696
|
-
}
|
|
697
|
-
});
|
|
698
|
-
}
|
|
699
|
-
function Dynamic(props) {
|
|
700
|
-
const others = omit(props, "component");
|
|
701
|
-
return createDynamic(() => props.component, others);
|
|
702
|
-
}
|
|
703
823
|
|
|
704
|
-
export { voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, voidFn as HydrationScript, Portal,
|
|
824
|
+
export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, addEventListener, applyRef, assign, className, clearDelegatedEvents, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, mergeProps, ref, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, voidFn as useAssets };
|