@solidjs/web 2.0.0-beta.0 → 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 +238 -107
- package/dist/dev.js +218 -101
- package/dist/server.cjs +196 -105
- package/dist/server.js +182 -103
- package/dist/web.cjs +224 -98
- package/dist/web.js +204 -92
- 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 -17
- 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 -16
- 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/README.md
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @solidjs/web
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Solid 2.0's web platform runtime — DOM rendering, hydration, server-side rendering, and the web-only control-flow components (`Portal`, `Dynamic`).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> **Solid 2.0 (experimental beta).** In 1.x this package was the `solid-js/web` subpath; in 2.0 it's a separate `@solidjs/web` package.
|
|
6
|
+
>
|
|
7
|
+
> See [`solid-js`'s CHEATSHEET](https://github.com/solidjs/solid/blob/next/packages/solid/CHEATSHEET.md) and [MIGRATION guide](https://github.com/solidjs/solid/blob/next/documentation/solid-2.0/MIGRATION.md) for the 2.0 surface.
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
## Entry points
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
// Browser / hydration
|
|
13
|
+
import { render, hydrate, Portal, Dynamic, dynamic } from "@solidjs/web";
|
|
14
|
+
|
|
15
|
+
// Server (SSR)
|
|
16
|
+
import {
|
|
17
|
+
renderToString,
|
|
18
|
+
renderToStringAsync,
|
|
19
|
+
renderToStream,
|
|
20
|
+
isServer
|
|
21
|
+
} from "@solidjs/web";
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The control-flow components from `solid-js` (`For`, `Show`, `Switch`/`Match`, `Loading`, `Errored`, `Repeat`, `Reveal`) are also re-exported from `@solidjs/web` for convenience.
|
|
25
|
+
|
|
26
|
+
## More
|
|
27
|
+
|
|
28
|
+
- [Documentation](https://docs.solidjs.com)
|
|
29
|
+
- [Cheatsheet (2.0 public API)](https://github.com/solidjs/solid/blob/next/packages/solid/CHEATSHEET.md)
|
|
30
|
+
- [Migration guide (1.x → 2.0)](https://github.com/solidjs/solid/blob/next/documentation/solid-2.0/MIGRATION.md)
|
package/dist/dev.cjs
CHANGED
|
@@ -2,8 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
var solidJs = require('solid-js');
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const DOMWithState = {
|
|
6
|
+
INPUT: {
|
|
7
|
+
value: 1,
|
|
8
|
+
defaultValue: 2,
|
|
9
|
+
checked: 1,
|
|
10
|
+
defaultChecked: 2
|
|
11
|
+
},
|
|
12
|
+
SELECT: {
|
|
13
|
+
value: 1
|
|
14
|
+
},
|
|
15
|
+
OPTION: {
|
|
16
|
+
value: 1,
|
|
17
|
+
selected: 1,
|
|
18
|
+
defaultSelected: 2
|
|
19
|
+
},
|
|
20
|
+
TEXTAREA: {
|
|
21
|
+
value: 1,
|
|
22
|
+
defaultValue: 2
|
|
23
|
+
},
|
|
24
|
+
VIDEO: {
|
|
25
|
+
muted: 1,
|
|
26
|
+
defaultMuted: 2
|
|
27
|
+
},
|
|
28
|
+
AUDIO: {
|
|
29
|
+
muted: 1,
|
|
30
|
+
defaultMuted: 2
|
|
31
|
+
}
|
|
32
|
+
};
|
|
7
33
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
8
34
|
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"]);
|
|
9
35
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -11,17 +37,26 @@ const SVGElements = /*#__PURE__*/new Set([
|
|
|
11
37
|
"set", "stop",
|
|
12
38
|
"svg", "switch", "symbol", "text", "textPath",
|
|
13
39
|
"tref", "tspan", "use", "view", "vkern"]);
|
|
14
|
-
const
|
|
40
|
+
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"]);
|
|
41
|
+
const Namespaces = {
|
|
42
|
+
svg: "http://www.w3.org/2000/svg",
|
|
43
|
+
mathml: "http://www.w3.org/1998/Math/MathML",
|
|
15
44
|
xlink: "http://www.w3.org/1999/xlink",
|
|
16
45
|
xml: "http://www.w3.org/XML/1998/namespace"
|
|
17
46
|
};
|
|
47
|
+
const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
48
|
+
const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
|
|
18
49
|
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",
|
|
19
50
|
"webview",
|
|
20
51
|
"isindex", "listing", "multicol", "nextid", "noindex", "search"]);
|
|
21
52
|
|
|
22
|
-
const
|
|
53
|
+
const transparentOptions = {
|
|
23
54
|
transparent: true
|
|
24
|
-
}
|
|
55
|
+
};
|
|
56
|
+
const effect = (fn, effectFn, options) => solidJs.createRenderEffect(fn, effectFn, options ? {
|
|
57
|
+
transparent: true,
|
|
58
|
+
...options
|
|
59
|
+
} : transparentOptions);
|
|
25
60
|
const memo = fn => solidJs.createMemo(() => fn());
|
|
26
61
|
|
|
27
62
|
function reconcileArrays(parentNode, a, b) {
|
|
@@ -82,32 +117,40 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
82
117
|
}
|
|
83
118
|
|
|
84
119
|
const $$EVENTS = "_$DX_DELEGATE";
|
|
85
|
-
|
|
120
|
+
const INNER_OWNED = {};
|
|
121
|
+
function render$1(code, element, init, options = {}) {
|
|
86
122
|
if (!element) {
|
|
87
123
|
throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
|
|
88
124
|
}
|
|
125
|
+
const renderRoot = getChildRoot(element);
|
|
89
126
|
let disposer;
|
|
90
127
|
solidJs.createRoot(dispose => {
|
|
91
128
|
disposer = dispose;
|
|
92
|
-
element === document
|
|
129
|
+
if (element === document) {
|
|
130
|
+
const tree = code();
|
|
131
|
+
effect(() => solidJs.flatten(tree), () => {});
|
|
132
|
+
} else {
|
|
133
|
+
const tree = code();
|
|
134
|
+
insert(element, () => tree, renderRoot.firstChild ? null : undefined, init, options.insertOptions);
|
|
135
|
+
}
|
|
93
136
|
}, {
|
|
94
137
|
id: options.renderId
|
|
95
138
|
});
|
|
96
139
|
return () => {
|
|
97
140
|
disposer();
|
|
98
|
-
|
|
141
|
+
renderRoot.textContent = "";
|
|
99
142
|
};
|
|
100
143
|
}
|
|
101
|
-
function
|
|
144
|
+
function create(html, bypassGuard, flag) {
|
|
145
|
+
if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
|
|
146
|
+
const t = document.createElement("template");
|
|
147
|
+
t.innerHTML = html;
|
|
148
|
+
return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
149
|
+
}
|
|
150
|
+
function template(html, flag) {
|
|
102
151
|
let node;
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
|
|
106
|
-
t.innerHTML = html;
|
|
107
|
-
return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
|
|
108
|
-
};
|
|
109
|
-
const fn = isImportNode ? bypassGuard => solidJs.untrack(() => document.importNode(node || (node = create(bypassGuard)), true)) : bypassGuard => (node || (node = create(bypassGuard))).cloneNode(true);
|
|
110
|
-
fn._html = html;
|
|
152
|
+
const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
|
|
153
|
+
fn._html = flag === 2 ? html.replace(/^<[^>]+>/, "") : html;
|
|
111
154
|
return fn;
|
|
112
155
|
}
|
|
113
156
|
function delegateEvents(eventNames, document = window.document) {
|
|
@@ -136,16 +179,16 @@ function setAttribute(node, name, value) {
|
|
|
136
179
|
}
|
|
137
180
|
function setAttributeNS(node, namespace, name, value) {
|
|
138
181
|
if (isHydrating(node)) return;
|
|
139
|
-
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
182
|
+
if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
140
183
|
}
|
|
141
|
-
function className(node, value,
|
|
184
|
+
function className(node, value, prev) {
|
|
142
185
|
if (isHydrating(node)) return;
|
|
143
186
|
if (value == null || value === false) {
|
|
144
187
|
prev && node.removeAttribute("class");
|
|
145
188
|
return;
|
|
146
189
|
}
|
|
147
190
|
if (typeof value === "string") {
|
|
148
|
-
value !== prev &&
|
|
191
|
+
value !== prev && node.setAttribute("class", value);
|
|
149
192
|
return;
|
|
150
193
|
}
|
|
151
194
|
if (typeof prev === "string") {
|
|
@@ -188,7 +231,6 @@ function style(node, value, prev) {
|
|
|
188
231
|
if (typeof value === "string") return nodeStyle.cssText = value;
|
|
189
232
|
typeof prev === "string" && (nodeStyle.cssText = prev = undefined);
|
|
190
233
|
prev || (prev = {});
|
|
191
|
-
value || (value = {});
|
|
192
234
|
let v, s;
|
|
193
235
|
for (s in value) {
|
|
194
236
|
v = value[s];
|
|
@@ -200,14 +242,9 @@ function style(node, value, prev) {
|
|
|
200
242
|
function setStyleProperty(node, name, value) {
|
|
201
243
|
value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
|
|
202
244
|
}
|
|
203
|
-
function spread(node, props = {},
|
|
245
|
+
function spread(node, props = {}, skipChildren) {
|
|
204
246
|
const prevProps = {};
|
|
205
|
-
if (!skipChildren)
|
|
206
|
-
effect(() => normalize(props.children, prevProps.children), value => {
|
|
207
|
-
insertExpression(node, value, prevProps.children);
|
|
208
|
-
prevProps.children = value;
|
|
209
|
-
});
|
|
210
|
-
}
|
|
247
|
+
if (!skipChildren) insert(node, () => props.children);
|
|
211
248
|
effect(() => {
|
|
212
249
|
const r = props.ref;
|
|
213
250
|
(typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
|
|
@@ -219,7 +256,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
219
256
|
newProps[prop] = props[prop];
|
|
220
257
|
}
|
|
221
258
|
return newProps;
|
|
222
|
-
}, props => assign(node, props,
|
|
259
|
+
}, props => assign(node, props, true, prevProps, true));
|
|
223
260
|
return prevProps;
|
|
224
261
|
}
|
|
225
262
|
function dynamicProperty(props, key) {
|
|
@@ -239,41 +276,79 @@ function ref(fn, element) {
|
|
|
239
276
|
const resolved = solidJs.untrack(fn);
|
|
240
277
|
solidJs.runWithOwner(null, () => applyRef(resolved, element));
|
|
241
278
|
}
|
|
242
|
-
function insert(parent, accessor, marker, initial) {
|
|
279
|
+
function insert(parent, accessor, marker, initial, options) {
|
|
280
|
+
const childRoot = getChildRoot(parent);
|
|
243
281
|
const multi = marker !== undefined;
|
|
244
282
|
if (multi && !initial) initial = [];
|
|
245
|
-
if (isHydrating(parent)
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
283
|
+
if (isHydrating(parent)) {
|
|
284
|
+
if (!multi && initial === undefined && parent) initial = [...childRoot.childNodes];
|
|
285
|
+
if (Array.isArray(initial)) {
|
|
286
|
+
let j = 0;
|
|
287
|
+
for (let i = 0; i < initial.length; i++) {
|
|
288
|
+
if (initial[i].nodeType === 8 && initial[i].nodeValue === "!$") initial[i].remove();else initial[j++] = initial[i];
|
|
289
|
+
}
|
|
290
|
+
initial.length = j;
|
|
249
291
|
}
|
|
250
|
-
initial.length = j;
|
|
251
292
|
}
|
|
252
293
|
if (typeof accessor !== "function") {
|
|
253
294
|
accessor = normalize(accessor, initial, multi, true);
|
|
254
295
|
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
255
296
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
297
|
+
if (multi && initial.length === 0) {
|
|
298
|
+
const placeholder = document.createTextNode("");
|
|
299
|
+
childRoot.insertBefore(placeholder, marker);
|
|
300
|
+
initial = [placeholder];
|
|
301
|
+
}
|
|
302
|
+
let current = initial;
|
|
303
|
+
effect(() => {
|
|
304
|
+
const value = normalize(accessor(), current, multi, true);
|
|
305
|
+
if (typeof value !== "function") return value;
|
|
306
|
+
effect(() => normalize(value, current, multi), inner => {
|
|
307
|
+
insertExpression(parent, inner, current, marker);
|
|
308
|
+
current = inner;
|
|
309
|
+
}, options);
|
|
310
|
+
return INNER_OWNED;
|
|
311
|
+
}, value => {
|
|
312
|
+
if (value === INNER_OWNED) return;
|
|
313
|
+
insertExpression(parent, value, current, marker);
|
|
314
|
+
current = value;
|
|
315
|
+
}, options);
|
|
316
|
+
}
|
|
317
|
+
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
318
|
+
const nodeName = node.nodeName;
|
|
259
319
|
props || (props = {});
|
|
260
320
|
for (const prop in prevProps) {
|
|
261
321
|
if (!(prop in props)) {
|
|
262
322
|
if (prop === "children") continue;
|
|
263
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop],
|
|
323
|
+
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
|
|
264
324
|
}
|
|
265
325
|
}
|
|
266
326
|
for (const prop in props) {
|
|
267
327
|
if (prop === "children") {
|
|
268
|
-
if (!skipChildren) insertExpression(node, props.children);
|
|
328
|
+
if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
|
|
269
329
|
continue;
|
|
270
330
|
}
|
|
271
|
-
|
|
272
|
-
|
|
331
|
+
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function loadModuleAssets(mapping) {
|
|
335
|
+
const hy = globalThis._$HY;
|
|
336
|
+
if (!hy) return;
|
|
337
|
+
const pending = [];
|
|
338
|
+
for (const moduleUrl in mapping) {
|
|
339
|
+
if (hy.modules[moduleUrl]) continue;
|
|
340
|
+
const entryUrl = mapping[moduleUrl];
|
|
341
|
+
if (!hy.loading[moduleUrl]) {
|
|
342
|
+
hy.loading[moduleUrl] = import(entryUrl).then(mod => {
|
|
343
|
+
hy.modules[moduleUrl] = mod;
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
pending.push(hy.loading[moduleUrl]);
|
|
273
347
|
}
|
|
348
|
+
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
274
349
|
}
|
|
275
350
|
function hydrate$1(code, element, options = {}) {
|
|
276
|
-
if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
|
|
351
|
+
if (globalThis._$HY.done) return render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
277
352
|
options.renderId ||= "";
|
|
278
353
|
if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
|
|
279
354
|
if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
|
|
@@ -282,6 +357,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
282
357
|
solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
|
|
283
358
|
solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
|
|
284
359
|
solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
|
|
360
|
+
solidJs.sharedConfig.loadModuleAssets = loadModuleAssets;
|
|
285
361
|
solidJs.sharedConfig.cleanupFragment = id => {
|
|
286
362
|
const tpl = document.getElementById("pl-" + id);
|
|
287
363
|
if (tpl) {
|
|
@@ -303,14 +379,34 @@ function hydrate$1(code, element, options = {}) {
|
|
|
303
379
|
{
|
|
304
380
|
solidJs.sharedConfig.verifyHydration = () => {
|
|
305
381
|
if (solidJs.sharedConfig.registry && solidJs.sharedConfig.registry.size) {
|
|
306
|
-
const orphaned = [...solidJs.sharedConfig.registry.values()];
|
|
382
|
+
const orphaned = [...solidJs.sharedConfig.registry.values()].filter(node => node.isConnected);
|
|
383
|
+
solidJs.sharedConfig.registry.clear();
|
|
384
|
+
if (!orphaned.length) return;
|
|
307
385
|
console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
|
|
308
386
|
}
|
|
309
387
|
};
|
|
310
388
|
}
|
|
389
|
+
const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
|
|
390
|
+
if (rootMapping && typeof rootMapping === "object") {
|
|
391
|
+
const p = loadModuleAssets(rootMapping);
|
|
392
|
+
if (p) {
|
|
393
|
+
gatherHydratable(element, options.renderId);
|
|
394
|
+
let disposer;
|
|
395
|
+
p.then(() => {
|
|
396
|
+
try {
|
|
397
|
+
disposer = render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
398
|
+
} finally {
|
|
399
|
+
solidJs.sharedConfig.hydrating = false;
|
|
400
|
+
}
|
|
401
|
+
}, () => {
|
|
402
|
+
solidJs.sharedConfig.hydrating = false;
|
|
403
|
+
});
|
|
404
|
+
return () => disposer && disposer();
|
|
405
|
+
}
|
|
406
|
+
}
|
|
311
407
|
try {
|
|
312
408
|
gatherHydratable(element, options.renderId);
|
|
313
|
-
return render(code, element, [...element.childNodes], options);
|
|
409
|
+
return render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
314
410
|
} finally {
|
|
315
411
|
solidJs.sharedConfig.hydrating = false;
|
|
316
412
|
}
|
|
@@ -359,7 +455,7 @@ function getNextMarker(start) {
|
|
|
359
455
|
return [end, current];
|
|
360
456
|
}
|
|
361
457
|
function getFirstChild(node, expectedTag) {
|
|
362
|
-
const child = node.firstChild;
|
|
458
|
+
const child = getChildRoot(node).firstChild;
|
|
363
459
|
if (isHydrating() && expectedTag && child?.localName !== expectedTag) {
|
|
364
460
|
const isMissing = !child || child.nodeType !== 1;
|
|
365
461
|
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> as first child of", node, "\n " + describeSiblings(node, child, expectedTag, isMissing));
|
|
@@ -369,20 +465,21 @@ function getFirstChild(node, expectedTag) {
|
|
|
369
465
|
function getNextSibling(node, expectedTag) {
|
|
370
466
|
const sibling = node.nextSibling;
|
|
371
467
|
if (isHydrating() && expectedTag && sibling?.localName !== expectedTag) {
|
|
372
|
-
const parent = node.
|
|
468
|
+
const parent = node.parentNode;
|
|
373
469
|
const isMissing = !sibling || sibling.nodeType !== 1;
|
|
374
470
|
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> after", node, "in", parent, "\n " + describeSiblings(parent, sibling, expectedTag, isMissing));
|
|
375
471
|
}
|
|
376
472
|
return sibling;
|
|
377
473
|
}
|
|
378
474
|
function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
|
|
475
|
+
if (!parent) return `<${expectedTag} \u2190 parent unavailable>`;
|
|
379
476
|
const children = [];
|
|
380
|
-
let child = parent.firstChild;
|
|
477
|
+
let child = getChildRoot(parent).firstChild;
|
|
381
478
|
while (child) {
|
|
382
479
|
if (child.nodeType === 1) children.push(child);
|
|
383
480
|
child = child.nextSibling;
|
|
384
481
|
}
|
|
385
|
-
const pTag = parent.localName;
|
|
482
|
+
const pTag = parent.localName || "#fragment";
|
|
386
483
|
if (isMissing) {
|
|
387
484
|
const tags = children.map(c => `<${c.localName}>`).join("");
|
|
388
485
|
return `<${pTag}>${tags}<${expectedTag} \u2190 missing></${pTag}>`;
|
|
@@ -427,6 +524,9 @@ function runHydrationEvents() {
|
|
|
427
524
|
function isHydrating(node) {
|
|
428
525
|
return solidJs.sharedConfig.hydrating && (!node || node.isConnected);
|
|
429
526
|
}
|
|
527
|
+
function getChildRoot(node) {
|
|
528
|
+
return node && node.localName === "template" ? node.content : node;
|
|
529
|
+
}
|
|
430
530
|
function toggleClassKey(node, key, value) {
|
|
431
531
|
const classNames = key.trim().split(/\s+/);
|
|
432
532
|
for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
|
|
@@ -445,18 +545,20 @@ function flattenClassList(list, result) {
|
|
|
445
545
|
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;
|
|
446
546
|
}
|
|
447
547
|
}
|
|
448
|
-
function assignProp(node, prop, value, prev,
|
|
449
|
-
let forceProp;
|
|
548
|
+
function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
450
549
|
if (prop === "style") return style(node, value, prev), value;
|
|
451
|
-
if (prop === "class") return className(node, value,
|
|
452
|
-
if (value === prev) return prev;
|
|
550
|
+
if (prop === "class") return className(node, value, prev), value;
|
|
551
|
+
if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
|
|
453
552
|
if (prop === "ref") {
|
|
454
553
|
if (!skipRef && value) ref(() => value, node);
|
|
455
|
-
|
|
554
|
+
return value;
|
|
555
|
+
}
|
|
556
|
+
const hasNamespace = prop.indexOf(":") > -1;
|
|
557
|
+
if (hasNamespace && prop.slice(0, 3) === "on:") {
|
|
456
558
|
const e = prop.slice(3);
|
|
457
559
|
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
458
560
|
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
459
|
-
} else if (prop.slice(0, 2) === "on") {
|
|
561
|
+
} else if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
460
562
|
const name = prop.slice(2).toLowerCase();
|
|
461
563
|
const delegate = DelegatedEvents.has(name);
|
|
462
564
|
if (!delegate && prev) {
|
|
@@ -467,11 +569,11 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
467
569
|
addEventListener(node, name, value, delegate);
|
|
468
570
|
delegate && delegateEvents([name]);
|
|
469
571
|
}
|
|
470
|
-
} else if (
|
|
471
|
-
if (
|
|
472
|
-
if (prop === "value" &&
|
|
572
|
+
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
573
|
+
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
574
|
+
if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
|
|
473
575
|
} else {
|
|
474
|
-
const ns =
|
|
576
|
+
const ns = hasNamespace && Namespaces[prop.split(":")[0]];
|
|
475
577
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
476
578
|
}
|
|
477
579
|
return value;
|
|
@@ -529,21 +631,22 @@ function eventHandler(e) {
|
|
|
529
631
|
function insertExpression(parent, value, current, marker) {
|
|
530
632
|
if (isHydrating(parent)) return;
|
|
531
633
|
if (value === current) return;
|
|
634
|
+
const childRoot = getChildRoot(parent);
|
|
532
635
|
const t = typeof value,
|
|
533
636
|
multi = marker !== undefined;
|
|
534
637
|
if (t === "string" || t === "number") {
|
|
535
638
|
const tc = typeof current;
|
|
536
639
|
if (tc === "string" || tc === "number") {
|
|
537
|
-
|
|
538
|
-
} else
|
|
640
|
+
childRoot.firstChild.data = value;
|
|
641
|
+
} else childRoot.textContent = value;
|
|
539
642
|
} else if (value === undefined) {
|
|
540
643
|
cleanChildren(parent, current, marker);
|
|
541
644
|
} else if (value.nodeType) {
|
|
542
645
|
if (Array.isArray(current)) {
|
|
543
646
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
544
|
-
} else if (current === undefined || !
|
|
545
|
-
|
|
546
|
-
} else
|
|
647
|
+
} else if (current === undefined || !childRoot.firstChild) {
|
|
648
|
+
childRoot.appendChild(value);
|
|
649
|
+
} else childRoot.replaceChild(value, childRoot.firstChild);
|
|
547
650
|
} else if (Array.isArray(value)) {
|
|
548
651
|
const currentArray = current && Array.isArray(current);
|
|
549
652
|
if (value.length === 0) {
|
|
@@ -551,7 +654,7 @@ function insertExpression(parent, value, current, marker) {
|
|
|
551
654
|
} else if (currentArray) {
|
|
552
655
|
if (current.length === 0) {
|
|
553
656
|
appendNodes(parent, value, marker);
|
|
554
|
-
} else reconcileArrays(
|
|
657
|
+
} else reconcileArrays(childRoot, current, value);
|
|
555
658
|
} else {
|
|
556
659
|
current && cleanChildren(parent);
|
|
557
660
|
appendNodes(parent, value);
|
|
@@ -576,9 +679,11 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
576
679
|
return value;
|
|
577
680
|
}
|
|
578
681
|
function appendNodes(parent, array, marker = null) {
|
|
682
|
+
parent = getChildRoot(parent);
|
|
579
683
|
for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
|
|
580
684
|
}
|
|
581
685
|
function cleanChildren(parent, current, marker, replacement) {
|
|
686
|
+
parent = getChildRoot(parent);
|
|
582
687
|
if (marker === undefined) return parent.textContent = "";
|
|
583
688
|
if (current.length) {
|
|
584
689
|
let inserted = false;
|
|
@@ -602,12 +707,6 @@ function gatherHydratable(element, root) {
|
|
|
602
707
|
function getHydrationKey() {
|
|
603
708
|
return solidJs.sharedConfig.getNextContextId();
|
|
604
709
|
}
|
|
605
|
-
function NoHydration(props) {
|
|
606
|
-
return solidJs.sharedConfig.hydrating ? undefined : props.children;
|
|
607
|
-
}
|
|
608
|
-
function Hydration(props) {
|
|
609
|
-
return props.children;
|
|
610
|
-
}
|
|
611
710
|
const voidFn = () => undefined;
|
|
612
711
|
const RequestContext = Symbol();
|
|
613
712
|
|
|
@@ -633,13 +732,23 @@ function ssrHydrationKey() {}
|
|
|
633
732
|
function resolveSSRNode(node) {}
|
|
634
733
|
function escape(html) {}
|
|
635
734
|
|
|
735
|
+
const mergeProps = solidJs.merge;
|
|
636
736
|
const isServer = false;
|
|
637
737
|
const isDev = true;
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
738
|
+
function render(code, element, init, options = {}) {
|
|
739
|
+
solidJs.enforceLoadingBoundary(true);
|
|
740
|
+
try {
|
|
741
|
+
const dispose = render$1(code, element, init, {
|
|
742
|
+
...options,
|
|
743
|
+
insertOptions: {
|
|
744
|
+
schedule: true
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
solidJs.flush();
|
|
748
|
+
return dispose;
|
|
749
|
+
} finally {
|
|
750
|
+
solidJs.enforceLoadingBoundary(false);
|
|
751
|
+
}
|
|
643
752
|
}
|
|
644
753
|
const hydrate = (...args) => {
|
|
645
754
|
solidJs.enableHydration();
|
|
@@ -665,6 +774,36 @@ function Portal(props) {
|
|
|
665
774
|
});
|
|
666
775
|
return treeMarker;
|
|
667
776
|
}
|
|
777
|
+
function dynamic(source) {
|
|
778
|
+
const cached = solidJs.createMemo(source, {
|
|
779
|
+
lazy: true
|
|
780
|
+
});
|
|
781
|
+
return props => {
|
|
782
|
+
return solidJs.createMemo(() => {
|
|
783
|
+
const component = cached();
|
|
784
|
+
switch (typeof component) {
|
|
785
|
+
case "function":
|
|
786
|
+
Object.assign(component, {
|
|
787
|
+
[solidJs.$DEVCOMP]: true
|
|
788
|
+
});
|
|
789
|
+
return solidJs.untrack(() => component(props));
|
|
790
|
+
case "string":
|
|
791
|
+
const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, solidJs.untrack(() => props.is));
|
|
792
|
+
spread(el, props);
|
|
793
|
+
return el;
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
function Dynamic(props) {
|
|
799
|
+
const Comp = dynamic(() => props.component);
|
|
800
|
+
return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
|
|
801
|
+
}
|
|
802
|
+
function createElement(tagName, is = undefined) {
|
|
803
|
+
return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
|
|
804
|
+
is
|
|
805
|
+
});
|
|
806
|
+
}
|
|
668
807
|
function createElementProxy(el, marker) {
|
|
669
808
|
return new Proxy(el, {
|
|
670
809
|
get(target, prop) {
|
|
@@ -682,28 +821,6 @@ function createElementProxy(el, marker) {
|
|
|
682
821
|
}
|
|
683
822
|
});
|
|
684
823
|
}
|
|
685
|
-
function createDynamic(component, props) {
|
|
686
|
-
const cached = solidJs.createMemo(component);
|
|
687
|
-
return solidJs.createMemo(() => {
|
|
688
|
-
const component = cached();
|
|
689
|
-
switch (typeof component) {
|
|
690
|
-
case "function":
|
|
691
|
-
Object.assign(component, {
|
|
692
|
-
[solidJs.$DEVCOMP]: true
|
|
693
|
-
});
|
|
694
|
-
return solidJs.untrack(() => component(props));
|
|
695
|
-
case "string":
|
|
696
|
-
const isSvg = SVGElements.has(component);
|
|
697
|
-
const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, solidJs.untrack(() => props.is));
|
|
698
|
-
spread(el, props, isSvg);
|
|
699
|
-
return el;
|
|
700
|
-
}
|
|
701
|
-
});
|
|
702
|
-
}
|
|
703
|
-
function Dynamic(props) {
|
|
704
|
-
const others = solidJs.omit(props, "component");
|
|
705
|
-
return createDynamic(() => props.component, others);
|
|
706
|
-
}
|
|
707
824
|
|
|
708
825
|
Object.defineProperty(exports, "Errored", {
|
|
709
826
|
enumerable: true,
|
|
@@ -713,6 +830,10 @@ Object.defineProperty(exports, "For", {
|
|
|
713
830
|
enumerable: true,
|
|
714
831
|
get: function () { return solidJs.For; }
|
|
715
832
|
});
|
|
833
|
+
Object.defineProperty(exports, "Hydration", {
|
|
834
|
+
enumerable: true,
|
|
835
|
+
get: function () { return solidJs.Hydration; }
|
|
836
|
+
});
|
|
716
837
|
Object.defineProperty(exports, "Loading", {
|
|
717
838
|
enumerable: true,
|
|
718
839
|
get: function () { return solidJs.Loading; }
|
|
@@ -721,6 +842,18 @@ Object.defineProperty(exports, "Match", {
|
|
|
721
842
|
enumerable: true,
|
|
722
843
|
get: function () { return solidJs.Match; }
|
|
723
844
|
});
|
|
845
|
+
Object.defineProperty(exports, "NoHydration", {
|
|
846
|
+
enumerable: true,
|
|
847
|
+
get: function () { return solidJs.NoHydration; }
|
|
848
|
+
});
|
|
849
|
+
Object.defineProperty(exports, "Repeat", {
|
|
850
|
+
enumerable: true,
|
|
851
|
+
get: function () { return solidJs.Repeat; }
|
|
852
|
+
});
|
|
853
|
+
Object.defineProperty(exports, "Reveal", {
|
|
854
|
+
enumerable: true,
|
|
855
|
+
get: function () { return solidJs.Reveal; }
|
|
856
|
+
});
|
|
724
857
|
Object.defineProperty(exports, "Show", {
|
|
725
858
|
enumerable: true,
|
|
726
859
|
get: function () { return solidJs.Show; }
|
|
@@ -737,10 +870,6 @@ Object.defineProperty(exports, "getOwner", {
|
|
|
737
870
|
enumerable: true,
|
|
738
871
|
get: function () { return solidJs.getOwner; }
|
|
739
872
|
});
|
|
740
|
-
Object.defineProperty(exports, "mergeProps", {
|
|
741
|
-
enumerable: true,
|
|
742
|
-
get: function () { return solidJs.merge; }
|
|
743
|
-
});
|
|
744
873
|
Object.defineProperty(exports, "untrack", {
|
|
745
874
|
enumerable: true,
|
|
746
875
|
get: function () { return solidJs.untrack; }
|
|
@@ -748,23 +877,24 @@ Object.defineProperty(exports, "untrack", {
|
|
|
748
877
|
exports.Assets = voidFn;
|
|
749
878
|
exports.ChildProperties = ChildProperties;
|
|
750
879
|
exports.DOMElements = DOMElements;
|
|
880
|
+
exports.DOMWithState = DOMWithState;
|
|
751
881
|
exports.DelegatedEvents = DelegatedEvents;
|
|
752
882
|
exports.Dynamic = Dynamic;
|
|
753
|
-
exports.Hydration = Hydration;
|
|
754
883
|
exports.HydrationScript = voidFn;
|
|
755
|
-
exports.
|
|
884
|
+
exports.MathMLElements = MathMLElements;
|
|
885
|
+
exports.Namespaces = Namespaces;
|
|
756
886
|
exports.Portal = Portal;
|
|
757
|
-
exports.
|
|
887
|
+
exports.RawTextElements = RawTextElements;
|
|
758
888
|
exports.RequestContext = RequestContext;
|
|
759
889
|
exports.SVGElements = SVGElements;
|
|
760
|
-
exports.
|
|
890
|
+
exports.VoidElements = VoidElements;
|
|
761
891
|
exports.addEventListener = addEventListener;
|
|
762
892
|
exports.applyRef = applyRef;
|
|
763
893
|
exports.assign = assign;
|
|
764
894
|
exports.className = className;
|
|
765
895
|
exports.clearDelegatedEvents = clearDelegatedEvents;
|
|
766
|
-
exports.createDynamic = createDynamic;
|
|
767
896
|
exports.delegateEvents = delegateEvents;
|
|
897
|
+
exports.dynamic = dynamic;
|
|
768
898
|
exports.dynamicProperty = dynamicProperty;
|
|
769
899
|
exports.effect = effect;
|
|
770
900
|
exports.escape = escape;
|
|
@@ -782,6 +912,7 @@ exports.insert = insert;
|
|
|
782
912
|
exports.isDev = isDev;
|
|
783
913
|
exports.isServer = isServer;
|
|
784
914
|
exports.memo = memo;
|
|
915
|
+
exports.mergeProps = mergeProps;
|
|
785
916
|
exports.ref = ref;
|
|
786
917
|
exports.render = render;
|
|
787
918
|
exports.renderToStream = renderToStream;
|