@solidjs/web 2.0.0-beta.1 → 2.0.0-beta.11
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 +251 -106
- package/dist/dev.js +239 -102
- package/dist/server.cjs +391 -109
- package/dist/server.js +384 -105
- package/dist/web.cjs +237 -97
- package/dist/web.js +225 -93
- package/package.json +100 -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 +3 -3
- 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 +36 -18
- 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.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,18 +37,32 @@ 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
|
|
23
|
-
transparent: true
|
|
24
|
-
|
|
25
|
-
|
|
53
|
+
const transparentOptions = {
|
|
54
|
+
transparent: true,
|
|
55
|
+
sync: true
|
|
56
|
+
};
|
|
57
|
+
const syncOptions = {
|
|
58
|
+
sync: true
|
|
59
|
+
};
|
|
60
|
+
const effect = (fn, effectFn, options) => solidJs.createRenderEffect(fn, effectFn, options ? {
|
|
61
|
+
transparent: true,
|
|
62
|
+
sync: true,
|
|
63
|
+
...options
|
|
64
|
+
} : transparentOptions);
|
|
65
|
+
const memo = fn => solidJs.createMemo(() => fn(), syncOptions);
|
|
26
66
|
|
|
27
67
|
function reconcileArrays(parentNode, a, b) {
|
|
28
68
|
let bLength = b.length,
|
|
@@ -51,10 +91,12 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
51
91
|
aStart++;
|
|
52
92
|
}
|
|
53
93
|
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
94
|
+
const anchor = a[aStart];
|
|
95
|
+
do {
|
|
96
|
+
parentNode.insertBefore(a[--aEnd], anchor);
|
|
97
|
+
bStart++;
|
|
98
|
+
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
99
|
+
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
58
100
|
} else {
|
|
59
101
|
if (!map) {
|
|
60
102
|
map = new Map();
|
|
@@ -82,32 +124,40 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
82
124
|
}
|
|
83
125
|
|
|
84
126
|
const $$EVENTS = "_$DX_DELEGATE";
|
|
85
|
-
|
|
127
|
+
const INNER_OWNED = {};
|
|
128
|
+
function render$1(code, element, init, options = {}) {
|
|
86
129
|
if (!element) {
|
|
87
130
|
throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
|
|
88
131
|
}
|
|
132
|
+
const renderRoot = getChildRoot(element);
|
|
89
133
|
let disposer;
|
|
90
134
|
solidJs.createRoot(dispose => {
|
|
91
135
|
disposer = dispose;
|
|
92
|
-
element === document
|
|
136
|
+
if (element === document) {
|
|
137
|
+
const tree = code();
|
|
138
|
+
effect(() => solidJs.flatten(tree), () => {});
|
|
139
|
+
} else {
|
|
140
|
+
const tree = code();
|
|
141
|
+
insert(element, () => tree, renderRoot.firstChild ? null : undefined, init, options.insertOptions);
|
|
142
|
+
}
|
|
93
143
|
}, {
|
|
94
144
|
id: options.renderId
|
|
95
145
|
});
|
|
96
146
|
return () => {
|
|
97
147
|
disposer();
|
|
98
|
-
|
|
148
|
+
renderRoot.textContent = "";
|
|
99
149
|
};
|
|
100
150
|
}
|
|
101
|
-
function
|
|
151
|
+
function create(html, bypassGuard, flag) {
|
|
152
|
+
if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
|
|
153
|
+
const t = document.createElement("template");
|
|
154
|
+
t.innerHTML = html;
|
|
155
|
+
return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
156
|
+
}
|
|
157
|
+
function template(html, flag) {
|
|
102
158
|
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;
|
|
159
|
+
const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
|
|
160
|
+
fn._html = flag === 2 ? html.replace(/^<[^>]+>/, "") : html;
|
|
111
161
|
return fn;
|
|
112
162
|
}
|
|
113
163
|
function delegateEvents(eventNames, document = window.document) {
|
|
@@ -136,16 +186,16 @@ function setAttribute(node, name, value) {
|
|
|
136
186
|
}
|
|
137
187
|
function setAttributeNS(node, namespace, name, value) {
|
|
138
188
|
if (isHydrating(node)) return;
|
|
139
|
-
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
189
|
+
if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
140
190
|
}
|
|
141
|
-
function className(node, value,
|
|
191
|
+
function className(node, value, prev) {
|
|
142
192
|
if (isHydrating(node)) return;
|
|
143
193
|
if (value == null || value === false) {
|
|
144
194
|
prev && node.removeAttribute("class");
|
|
145
195
|
return;
|
|
146
196
|
}
|
|
147
197
|
if (typeof value === "string") {
|
|
148
|
-
value !== prev &&
|
|
198
|
+
value !== prev && node.setAttribute("class", value);
|
|
149
199
|
return;
|
|
150
200
|
}
|
|
151
201
|
if (typeof prev === "string") {
|
|
@@ -159,13 +209,13 @@ function className(node, value, isSVG, prev) {
|
|
|
159
209
|
for (i = 0, len = prevKeys.length; i < len; i++) {
|
|
160
210
|
const key = prevKeys[i];
|
|
161
211
|
if (!key || key === "undefined" || value[key]) continue;
|
|
162
|
-
|
|
212
|
+
node.classList.remove(key);
|
|
163
213
|
}
|
|
164
214
|
for (i = 0, len = classKeys.length; i < len; i++) {
|
|
165
215
|
const key = classKeys[i],
|
|
166
216
|
classValue = !!value[key];
|
|
167
217
|
if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue;
|
|
168
|
-
|
|
218
|
+
node.classList.add(key);
|
|
169
219
|
}
|
|
170
220
|
}
|
|
171
221
|
function addEventListener(node, name, handler, delegate) {
|
|
@@ -188,7 +238,6 @@ function style(node, value, prev) {
|
|
|
188
238
|
if (typeof value === "string") return nodeStyle.cssText = value;
|
|
189
239
|
typeof prev === "string" && (nodeStyle.cssText = prev = undefined);
|
|
190
240
|
prev || (prev = {});
|
|
191
|
-
value || (value = {});
|
|
192
241
|
let v, s;
|
|
193
242
|
for (s in value) {
|
|
194
243
|
v = value[s];
|
|
@@ -200,14 +249,9 @@ function style(node, value, prev) {
|
|
|
200
249
|
function setStyleProperty(node, name, value) {
|
|
201
250
|
value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
|
|
202
251
|
}
|
|
203
|
-
function spread(node, props = {},
|
|
252
|
+
function spread(node, props = {}, skipChildren) {
|
|
204
253
|
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
|
-
}
|
|
254
|
+
if (!skipChildren) insert(node, () => props.children);
|
|
211
255
|
effect(() => {
|
|
212
256
|
const r = props.ref;
|
|
213
257
|
(typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
|
|
@@ -219,7 +263,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
219
263
|
newProps[prop] = props[prop];
|
|
220
264
|
}
|
|
221
265
|
return newProps;
|
|
222
|
-
}, props => assign(node, props,
|
|
266
|
+
}, props => assign(node, props, true, prevProps, true));
|
|
223
267
|
return prevProps;
|
|
224
268
|
}
|
|
225
269
|
function dynamicProperty(props, key) {
|
|
@@ -239,11 +283,12 @@ function ref(fn, element) {
|
|
|
239
283
|
const resolved = solidJs.untrack(fn);
|
|
240
284
|
solidJs.runWithOwner(null, () => applyRef(resolved, element));
|
|
241
285
|
}
|
|
242
|
-
function insert(parent, accessor, marker, initial) {
|
|
286
|
+
function insert(parent, accessor, marker, initial, options) {
|
|
287
|
+
const childRoot = getChildRoot(parent);
|
|
243
288
|
const multi = marker !== undefined;
|
|
244
289
|
if (multi && !initial) initial = [];
|
|
245
290
|
if (isHydrating(parent)) {
|
|
246
|
-
if (!multi && initial === undefined && parent) initial = [...
|
|
291
|
+
if (!multi && initial === undefined && parent) initial = [...childRoot.childNodes];
|
|
247
292
|
if (Array.isArray(initial)) {
|
|
248
293
|
let j = 0;
|
|
249
294
|
for (let i = 0; i < initial.length; i++) {
|
|
@@ -256,27 +301,64 @@ function insert(parent, accessor, marker, initial) {
|
|
|
256
301
|
accessor = normalize(accessor, initial, multi, true);
|
|
257
302
|
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
258
303
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
304
|
+
if (multi && initial.length === 0) {
|
|
305
|
+
const placeholder = document.createTextNode("");
|
|
306
|
+
childRoot.insertBefore(placeholder, marker);
|
|
307
|
+
initial = [placeholder];
|
|
308
|
+
}
|
|
309
|
+
let current = initial;
|
|
310
|
+
effect(prev => {
|
|
311
|
+
const value = normalize(accessor(), current, multi, true);
|
|
312
|
+
if (typeof value !== "function") return value;
|
|
313
|
+
effect(() => normalize(value, current, multi), inner => {
|
|
314
|
+
insertExpression(parent, inner, current, marker);
|
|
315
|
+
current = inner;
|
|
316
|
+
}, prev !== undefined && !(options && options.schedule) ? {
|
|
317
|
+
...options,
|
|
318
|
+
schedule: true
|
|
319
|
+
} : options);
|
|
320
|
+
return INNER_OWNED;
|
|
321
|
+
}, value => {
|
|
322
|
+
if (value === INNER_OWNED) return;
|
|
323
|
+
insertExpression(parent, value, current, marker);
|
|
324
|
+
current = value;
|
|
325
|
+
}, options);
|
|
326
|
+
}
|
|
327
|
+
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
328
|
+
const nodeName = node.nodeName;
|
|
262
329
|
props || (props = {});
|
|
263
330
|
for (const prop in prevProps) {
|
|
264
331
|
if (!(prop in props)) {
|
|
265
332
|
if (prop === "children") continue;
|
|
266
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop],
|
|
333
|
+
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
|
|
267
334
|
}
|
|
268
335
|
}
|
|
269
336
|
for (const prop in props) {
|
|
270
337
|
if (prop === "children") {
|
|
271
|
-
if (!skipChildren) insertExpression(node, props.children);
|
|
338
|
+
if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
|
|
272
339
|
continue;
|
|
273
340
|
}
|
|
274
|
-
|
|
275
|
-
|
|
341
|
+
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
function loadModuleAssets(mapping) {
|
|
345
|
+
const hy = globalThis._$HY;
|
|
346
|
+
if (!hy) return;
|
|
347
|
+
const pending = [];
|
|
348
|
+
for (const moduleUrl in mapping) {
|
|
349
|
+
if (hy.modules[moduleUrl]) continue;
|
|
350
|
+
const entryUrl = mapping[moduleUrl];
|
|
351
|
+
if (!hy.loading[moduleUrl]) {
|
|
352
|
+
hy.loading[moduleUrl] = import(entryUrl).then(mod => {
|
|
353
|
+
hy.modules[moduleUrl] = mod;
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
pending.push(hy.loading[moduleUrl]);
|
|
276
357
|
}
|
|
358
|
+
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
277
359
|
}
|
|
278
360
|
function hydrate$1(code, element, options = {}) {
|
|
279
|
-
if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
|
|
361
|
+
if (globalThis._$HY.done) return render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
280
362
|
options.renderId ||= "";
|
|
281
363
|
if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
|
|
282
364
|
if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
|
|
@@ -285,6 +367,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
285
367
|
solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
|
|
286
368
|
solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
|
|
287
369
|
solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
|
|
370
|
+
solidJs.sharedConfig.loadModuleAssets = loadModuleAssets;
|
|
288
371
|
solidJs.sharedConfig.cleanupFragment = id => {
|
|
289
372
|
const tpl = document.getElementById("pl-" + id);
|
|
290
373
|
if (tpl) {
|
|
@@ -306,14 +389,34 @@ function hydrate$1(code, element, options = {}) {
|
|
|
306
389
|
{
|
|
307
390
|
solidJs.sharedConfig.verifyHydration = () => {
|
|
308
391
|
if (solidJs.sharedConfig.registry && solidJs.sharedConfig.registry.size) {
|
|
309
|
-
const orphaned = [...solidJs.sharedConfig.registry.values()];
|
|
392
|
+
const orphaned = [...solidJs.sharedConfig.registry.values()].filter(node => node.isConnected);
|
|
393
|
+
solidJs.sharedConfig.registry.clear();
|
|
394
|
+
if (!orphaned.length) return;
|
|
310
395
|
console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
|
|
311
396
|
}
|
|
312
397
|
};
|
|
313
398
|
}
|
|
399
|
+
const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
|
|
400
|
+
if (rootMapping && typeof rootMapping === "object") {
|
|
401
|
+
const p = loadModuleAssets(rootMapping);
|
|
402
|
+
if (p) {
|
|
403
|
+
gatherHydratable(element, options.renderId);
|
|
404
|
+
let disposer;
|
|
405
|
+
p.then(() => {
|
|
406
|
+
try {
|
|
407
|
+
disposer = render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
408
|
+
} finally {
|
|
409
|
+
solidJs.sharedConfig.hydrating = false;
|
|
410
|
+
}
|
|
411
|
+
}, () => {
|
|
412
|
+
solidJs.sharedConfig.hydrating = false;
|
|
413
|
+
});
|
|
414
|
+
return () => disposer && disposer();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
314
417
|
try {
|
|
315
418
|
gatherHydratable(element, options.renderId);
|
|
316
|
-
return render(code, element, [...element.childNodes], options);
|
|
419
|
+
return render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
317
420
|
} finally {
|
|
318
421
|
solidJs.sharedConfig.hydrating = false;
|
|
319
422
|
}
|
|
@@ -362,7 +465,7 @@ function getNextMarker(start) {
|
|
|
362
465
|
return [end, current];
|
|
363
466
|
}
|
|
364
467
|
function getFirstChild(node, expectedTag) {
|
|
365
|
-
const child = node.firstChild;
|
|
468
|
+
const child = getChildRoot(node).firstChild;
|
|
366
469
|
if (isHydrating() && expectedTag && child?.localName !== expectedTag) {
|
|
367
470
|
const isMissing = !child || child.nodeType !== 1;
|
|
368
471
|
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> as first child of", node, "\n " + describeSiblings(node, child, expectedTag, isMissing));
|
|
@@ -372,20 +475,21 @@ function getFirstChild(node, expectedTag) {
|
|
|
372
475
|
function getNextSibling(node, expectedTag) {
|
|
373
476
|
const sibling = node.nextSibling;
|
|
374
477
|
if (isHydrating() && expectedTag && sibling?.localName !== expectedTag) {
|
|
375
|
-
const parent = node.
|
|
478
|
+
const parent = node.parentNode;
|
|
376
479
|
const isMissing = !sibling || sibling.nodeType !== 1;
|
|
377
480
|
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> after", node, "in", parent, "\n " + describeSiblings(parent, sibling, expectedTag, isMissing));
|
|
378
481
|
}
|
|
379
482
|
return sibling;
|
|
380
483
|
}
|
|
381
484
|
function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
|
|
485
|
+
if (!parent) return `<${expectedTag} \u2190 parent unavailable>`;
|
|
382
486
|
const children = [];
|
|
383
|
-
let child = parent.firstChild;
|
|
487
|
+
let child = getChildRoot(parent).firstChild;
|
|
384
488
|
while (child) {
|
|
385
489
|
if (child.nodeType === 1) children.push(child);
|
|
386
490
|
child = child.nextSibling;
|
|
387
491
|
}
|
|
388
|
-
const pTag = parent.localName;
|
|
492
|
+
const pTag = parent.localName || "#fragment";
|
|
389
493
|
if (isMissing) {
|
|
390
494
|
const tags = children.map(c => `<${c.localName}>`).join("");
|
|
391
495
|
return `<${pTag}>${tags}<${expectedTag} \u2190 missing></${pTag}>`;
|
|
@@ -430,14 +534,24 @@ function runHydrationEvents() {
|
|
|
430
534
|
function isHydrating(node) {
|
|
431
535
|
return solidJs.sharedConfig.hydrating && (!node || node.isConnected);
|
|
432
536
|
}
|
|
433
|
-
function
|
|
434
|
-
|
|
435
|
-
for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
|
|
537
|
+
function getChildRoot(node) {
|
|
538
|
+
return node && node.localName === "template" ? node.content : node;
|
|
436
539
|
}
|
|
437
540
|
function classListToObject(classList) {
|
|
438
541
|
if (Array.isArray(classList)) {
|
|
439
542
|
const result = {};
|
|
440
543
|
flattenClassList(classList, result);
|
|
544
|
+
classList = result;
|
|
545
|
+
}
|
|
546
|
+
if (classList && typeof classList === "object") {
|
|
547
|
+
const result = {},
|
|
548
|
+
keys = Object.keys(classList);
|
|
549
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
550
|
+
const key = keys[i];
|
|
551
|
+
if (!classList[key]) continue;
|
|
552
|
+
const classNames = key.trim().split(/\s+/);
|
|
553
|
+
for (let j = 0, nameLen = classNames.length; j < nameLen; j++) classNames[j] && (result[classNames[j]] = true);
|
|
554
|
+
}
|
|
441
555
|
return result;
|
|
442
556
|
}
|
|
443
557
|
return classList;
|
|
@@ -448,18 +562,20 @@ function flattenClassList(list, result) {
|
|
|
448
562
|
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;
|
|
449
563
|
}
|
|
450
564
|
}
|
|
451
|
-
function assignProp(node, prop, value, prev,
|
|
452
|
-
let forceProp;
|
|
565
|
+
function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
453
566
|
if (prop === "style") return style(node, value, prev), value;
|
|
454
|
-
if (prop === "class") return className(node, value,
|
|
455
|
-
if (value === prev) return prev;
|
|
567
|
+
if (prop === "class") return className(node, value, prev), value;
|
|
568
|
+
if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
|
|
456
569
|
if (prop === "ref") {
|
|
457
570
|
if (!skipRef && value) ref(() => value, node);
|
|
458
|
-
|
|
571
|
+
return value;
|
|
572
|
+
}
|
|
573
|
+
const hasNamespace = prop.indexOf(":") > -1;
|
|
574
|
+
if (hasNamespace && prop.slice(0, 3) === "on:") {
|
|
459
575
|
const e = prop.slice(3);
|
|
460
576
|
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
461
577
|
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
462
|
-
} else if (prop.slice(0, 2) === "on") {
|
|
578
|
+
} else if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
463
579
|
const name = prop.slice(2).toLowerCase();
|
|
464
580
|
const delegate = DelegatedEvents.has(name);
|
|
465
581
|
if (!delegate && prev) {
|
|
@@ -470,11 +586,11 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
470
586
|
addEventListener(node, name, value, delegate);
|
|
471
587
|
delegate && delegateEvents([name]);
|
|
472
588
|
}
|
|
473
|
-
} else if (
|
|
474
|
-
if (
|
|
475
|
-
if (prop === "value" &&
|
|
589
|
+
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
590
|
+
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
591
|
+
if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
|
|
476
592
|
} else {
|
|
477
|
-
const ns =
|
|
593
|
+
const ns = hasNamespace && Namespaces[prop.split(":")[0]];
|
|
478
594
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
479
595
|
}
|
|
480
596
|
return value;
|
|
@@ -532,21 +648,22 @@ function eventHandler(e) {
|
|
|
532
648
|
function insertExpression(parent, value, current, marker) {
|
|
533
649
|
if (isHydrating(parent)) return;
|
|
534
650
|
if (value === current) return;
|
|
651
|
+
const childRoot = getChildRoot(parent);
|
|
535
652
|
const t = typeof value,
|
|
536
653
|
multi = marker !== undefined;
|
|
537
654
|
if (t === "string" || t === "number") {
|
|
538
655
|
const tc = typeof current;
|
|
539
656
|
if (tc === "string" || tc === "number") {
|
|
540
|
-
|
|
541
|
-
} else
|
|
657
|
+
childRoot.firstChild.data = value;
|
|
658
|
+
} else childRoot.textContent = value;
|
|
542
659
|
} else if (value === undefined) {
|
|
543
660
|
cleanChildren(parent, current, marker);
|
|
544
661
|
} else if (value.nodeType) {
|
|
545
662
|
if (Array.isArray(current)) {
|
|
546
663
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
547
|
-
} else if (current === undefined || !
|
|
548
|
-
|
|
549
|
-
} else
|
|
664
|
+
} else if (current === undefined || !childRoot.firstChild) {
|
|
665
|
+
childRoot.appendChild(value);
|
|
666
|
+
} else childRoot.replaceChild(value, childRoot.firstChild);
|
|
550
667
|
} else if (Array.isArray(value)) {
|
|
551
668
|
const currentArray = current && Array.isArray(current);
|
|
552
669
|
if (value.length === 0) {
|
|
@@ -554,7 +671,7 @@ function insertExpression(parent, value, current, marker) {
|
|
|
554
671
|
} else if (currentArray) {
|
|
555
672
|
if (current.length === 0) {
|
|
556
673
|
appendNodes(parent, value, marker);
|
|
557
|
-
} else reconcileArrays(
|
|
674
|
+
} else reconcileArrays(childRoot, current, value);
|
|
558
675
|
} else {
|
|
559
676
|
current && cleanChildren(parent);
|
|
560
677
|
appendNodes(parent, value);
|
|
@@ -579,9 +696,11 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
579
696
|
return value;
|
|
580
697
|
}
|
|
581
698
|
function appendNodes(parent, array, marker = null) {
|
|
699
|
+
parent = getChildRoot(parent);
|
|
582
700
|
for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
|
|
583
701
|
}
|
|
584
702
|
function cleanChildren(parent, current, marker, replacement) {
|
|
703
|
+
parent = getChildRoot(parent);
|
|
585
704
|
if (marker === undefined) return parent.textContent = "";
|
|
586
705
|
if (current.length) {
|
|
587
706
|
let inserted = false;
|
|
@@ -630,13 +749,23 @@ function ssrHydrationKey() {}
|
|
|
630
749
|
function resolveSSRNode(node) {}
|
|
631
750
|
function escape(html) {}
|
|
632
751
|
|
|
752
|
+
const mergeProps = solidJs.merge;
|
|
633
753
|
const isServer = false;
|
|
634
754
|
const isDev = true;
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
755
|
+
function render(code, element, init, options = {}) {
|
|
756
|
+
solidJs.enforceLoadingBoundary(true);
|
|
757
|
+
try {
|
|
758
|
+
const dispose = render$1(code, element, init, {
|
|
759
|
+
...options,
|
|
760
|
+
insertOptions: {
|
|
761
|
+
schedule: true
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
solidJs.flush();
|
|
765
|
+
return dispose;
|
|
766
|
+
} finally {
|
|
767
|
+
solidJs.enforceLoadingBoundary(false);
|
|
768
|
+
}
|
|
640
769
|
}
|
|
641
770
|
const hydrate = (...args) => {
|
|
642
771
|
solidJs.enableHydration();
|
|
@@ -662,6 +791,36 @@ function Portal(props) {
|
|
|
662
791
|
});
|
|
663
792
|
return treeMarker;
|
|
664
793
|
}
|
|
794
|
+
function dynamic(source) {
|
|
795
|
+
const cached = solidJs.createMemo(source, {
|
|
796
|
+
lazy: true
|
|
797
|
+
});
|
|
798
|
+
return props => {
|
|
799
|
+
return solidJs.createMemo(() => {
|
|
800
|
+
const component = cached();
|
|
801
|
+
switch (typeof component) {
|
|
802
|
+
case "function":
|
|
803
|
+
Object.assign(component, {
|
|
804
|
+
[solidJs.$DEVCOMP]: true
|
|
805
|
+
});
|
|
806
|
+
return solidJs.untrack(() => component(props));
|
|
807
|
+
case "string":
|
|
808
|
+
const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, solidJs.untrack(() => props.is));
|
|
809
|
+
spread(el, props);
|
|
810
|
+
return el;
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
function Dynamic(props) {
|
|
816
|
+
const Comp = dynamic(() => props.component);
|
|
817
|
+
return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
|
|
818
|
+
}
|
|
819
|
+
function createElement(tagName, is = undefined) {
|
|
820
|
+
return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
|
|
821
|
+
is
|
|
822
|
+
});
|
|
823
|
+
}
|
|
665
824
|
function createElementProxy(el, marker) {
|
|
666
825
|
return new Proxy(el, {
|
|
667
826
|
get(target, prop) {
|
|
@@ -679,28 +838,6 @@ function createElementProxy(el, marker) {
|
|
|
679
838
|
}
|
|
680
839
|
});
|
|
681
840
|
}
|
|
682
|
-
function createDynamic(component, props) {
|
|
683
|
-
const cached = solidJs.createMemo(component);
|
|
684
|
-
return solidJs.createMemo(() => {
|
|
685
|
-
const component = cached();
|
|
686
|
-
switch (typeof component) {
|
|
687
|
-
case "function":
|
|
688
|
-
Object.assign(component, {
|
|
689
|
-
[solidJs.$DEVCOMP]: true
|
|
690
|
-
});
|
|
691
|
-
return solidJs.untrack(() => component(props));
|
|
692
|
-
case "string":
|
|
693
|
-
const isSvg = SVGElements.has(component);
|
|
694
|
-
const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, solidJs.untrack(() => props.is));
|
|
695
|
-
spread(el, props, isSvg);
|
|
696
|
-
return el;
|
|
697
|
-
}
|
|
698
|
-
});
|
|
699
|
-
}
|
|
700
|
-
function Dynamic(props) {
|
|
701
|
-
const others = solidJs.omit(props, "component");
|
|
702
|
-
return createDynamic(() => props.component, others);
|
|
703
|
-
}
|
|
704
841
|
|
|
705
842
|
Object.defineProperty(exports, "Errored", {
|
|
706
843
|
enumerable: true,
|
|
@@ -726,6 +863,14 @@ Object.defineProperty(exports, "NoHydration", {
|
|
|
726
863
|
enumerable: true,
|
|
727
864
|
get: function () { return solidJs.NoHydration; }
|
|
728
865
|
});
|
|
866
|
+
Object.defineProperty(exports, "Repeat", {
|
|
867
|
+
enumerable: true,
|
|
868
|
+
get: function () { return solidJs.Repeat; }
|
|
869
|
+
});
|
|
870
|
+
Object.defineProperty(exports, "Reveal", {
|
|
871
|
+
enumerable: true,
|
|
872
|
+
get: function () { return solidJs.Reveal; }
|
|
873
|
+
});
|
|
729
874
|
Object.defineProperty(exports, "Show", {
|
|
730
875
|
enumerable: true,
|
|
731
876
|
get: function () { return solidJs.Show; }
|
|
@@ -742,10 +887,6 @@ Object.defineProperty(exports, "getOwner", {
|
|
|
742
887
|
enumerable: true,
|
|
743
888
|
get: function () { return solidJs.getOwner; }
|
|
744
889
|
});
|
|
745
|
-
Object.defineProperty(exports, "mergeProps", {
|
|
746
|
-
enumerable: true,
|
|
747
|
-
get: function () { return solidJs.merge; }
|
|
748
|
-
});
|
|
749
890
|
Object.defineProperty(exports, "untrack", {
|
|
750
891
|
enumerable: true,
|
|
751
892
|
get: function () { return solidJs.untrack; }
|
|
@@ -753,21 +894,24 @@ Object.defineProperty(exports, "untrack", {
|
|
|
753
894
|
exports.Assets = voidFn;
|
|
754
895
|
exports.ChildProperties = ChildProperties;
|
|
755
896
|
exports.DOMElements = DOMElements;
|
|
897
|
+
exports.DOMWithState = DOMWithState;
|
|
756
898
|
exports.DelegatedEvents = DelegatedEvents;
|
|
757
899
|
exports.Dynamic = Dynamic;
|
|
758
900
|
exports.HydrationScript = voidFn;
|
|
901
|
+
exports.MathMLElements = MathMLElements;
|
|
902
|
+
exports.Namespaces = Namespaces;
|
|
759
903
|
exports.Portal = Portal;
|
|
760
|
-
exports.
|
|
904
|
+
exports.RawTextElements = RawTextElements;
|
|
761
905
|
exports.RequestContext = RequestContext;
|
|
762
906
|
exports.SVGElements = SVGElements;
|
|
763
|
-
exports.
|
|
907
|
+
exports.VoidElements = VoidElements;
|
|
764
908
|
exports.addEventListener = addEventListener;
|
|
765
909
|
exports.applyRef = applyRef;
|
|
766
910
|
exports.assign = assign;
|
|
767
911
|
exports.className = className;
|
|
768
912
|
exports.clearDelegatedEvents = clearDelegatedEvents;
|
|
769
|
-
exports.createDynamic = createDynamic;
|
|
770
913
|
exports.delegateEvents = delegateEvents;
|
|
914
|
+
exports.dynamic = dynamic;
|
|
771
915
|
exports.dynamicProperty = dynamicProperty;
|
|
772
916
|
exports.effect = effect;
|
|
773
917
|
exports.escape = escape;
|
|
@@ -785,6 +929,7 @@ exports.insert = insert;
|
|
|
785
929
|
exports.isDev = isDev;
|
|
786
930
|
exports.isServer = isServer;
|
|
787
931
|
exports.memo = memo;
|
|
932
|
+
exports.mergeProps = mergeProps;
|
|
788
933
|
exports.ref = ref;
|
|
789
934
|
exports.render = render;
|
|
790
935
|
exports.renderToStream = renderToStream;
|