@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/web.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,27 +124,35 @@ 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 = {}) {
|
|
129
|
+
const renderRoot = getChildRoot(element);
|
|
86
130
|
let disposer;
|
|
87
131
|
solidJs.createRoot(dispose => {
|
|
88
132
|
disposer = dispose;
|
|
89
|
-
element === document
|
|
133
|
+
if (element === document) {
|
|
134
|
+
const tree = code();
|
|
135
|
+
effect(() => solidJs.flatten(tree), () => {});
|
|
136
|
+
} else {
|
|
137
|
+
const tree = code();
|
|
138
|
+
insert(element, () => tree, renderRoot.firstChild ? null : undefined, init, options.insertOptions);
|
|
139
|
+
}
|
|
90
140
|
}, {
|
|
91
141
|
id: options.renderId
|
|
92
142
|
});
|
|
93
143
|
return () => {
|
|
94
144
|
disposer();
|
|
95
|
-
|
|
145
|
+
renderRoot.textContent = "";
|
|
96
146
|
};
|
|
97
147
|
}
|
|
98
|
-
function
|
|
148
|
+
function create(html, bypassGuard, flag) {
|
|
149
|
+
const t = document.createElement("template");
|
|
150
|
+
t.innerHTML = html;
|
|
151
|
+
return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
152
|
+
}
|
|
153
|
+
function template(html, flag) {
|
|
99
154
|
let node;
|
|
100
|
-
const
|
|
101
|
-
const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
|
|
102
|
-
t.innerHTML = html;
|
|
103
|
-
return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
|
|
104
|
-
};
|
|
105
|
-
const fn = isImportNode ? bypassGuard => solidJs.untrack(() => document.importNode(node || (node = create()), true)) : bypassGuard => (node || (node = create())).cloneNode(true);
|
|
155
|
+
const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
|
|
106
156
|
return fn;
|
|
107
157
|
}
|
|
108
158
|
function delegateEvents(eventNames, document = window.document) {
|
|
@@ -131,16 +181,16 @@ function setAttribute(node, name, value) {
|
|
|
131
181
|
}
|
|
132
182
|
function setAttributeNS(node, namespace, name, value) {
|
|
133
183
|
if (isHydrating(node)) return;
|
|
134
|
-
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
184
|
+
if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
135
185
|
}
|
|
136
|
-
function className(node, value,
|
|
186
|
+
function className(node, value, prev) {
|
|
137
187
|
if (isHydrating(node)) return;
|
|
138
188
|
if (value == null || value === false) {
|
|
139
189
|
prev && node.removeAttribute("class");
|
|
140
190
|
return;
|
|
141
191
|
}
|
|
142
192
|
if (typeof value === "string") {
|
|
143
|
-
value !== prev &&
|
|
193
|
+
value !== prev && node.setAttribute("class", value);
|
|
144
194
|
return;
|
|
145
195
|
}
|
|
146
196
|
if (typeof prev === "string") {
|
|
@@ -154,13 +204,13 @@ function className(node, value, isSVG, prev) {
|
|
|
154
204
|
for (i = 0, len = prevKeys.length; i < len; i++) {
|
|
155
205
|
const key = prevKeys[i];
|
|
156
206
|
if (!key || key === "undefined" || value[key]) continue;
|
|
157
|
-
|
|
207
|
+
node.classList.remove(key);
|
|
158
208
|
}
|
|
159
209
|
for (i = 0, len = classKeys.length; i < len; i++) {
|
|
160
210
|
const key = classKeys[i],
|
|
161
211
|
classValue = !!value[key];
|
|
162
212
|
if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue;
|
|
163
|
-
|
|
213
|
+
node.classList.add(key);
|
|
164
214
|
}
|
|
165
215
|
}
|
|
166
216
|
function addEventListener(node, name, handler, delegate) {
|
|
@@ -183,7 +233,6 @@ function style(node, value, prev) {
|
|
|
183
233
|
if (typeof value === "string") return nodeStyle.cssText = value;
|
|
184
234
|
typeof prev === "string" && (nodeStyle.cssText = prev = undefined);
|
|
185
235
|
prev || (prev = {});
|
|
186
|
-
value || (value = {});
|
|
187
236
|
let v, s;
|
|
188
237
|
for (s in value) {
|
|
189
238
|
v = value[s];
|
|
@@ -195,14 +244,9 @@ function style(node, value, prev) {
|
|
|
195
244
|
function setStyleProperty(node, name, value) {
|
|
196
245
|
value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
|
|
197
246
|
}
|
|
198
|
-
function spread(node, props = {},
|
|
247
|
+
function spread(node, props = {}, skipChildren) {
|
|
199
248
|
const prevProps = {};
|
|
200
|
-
if (!skipChildren)
|
|
201
|
-
effect(() => normalize(props.children, prevProps.children), value => {
|
|
202
|
-
insertExpression(node, value, prevProps.children);
|
|
203
|
-
prevProps.children = value;
|
|
204
|
-
});
|
|
205
|
-
}
|
|
249
|
+
if (!skipChildren) insert(node, () => props.children);
|
|
206
250
|
effect(() => {
|
|
207
251
|
const r = props.ref;
|
|
208
252
|
(typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
|
|
@@ -214,7 +258,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
214
258
|
newProps[prop] = props[prop];
|
|
215
259
|
}
|
|
216
260
|
return newProps;
|
|
217
|
-
}, props => assign(node, props,
|
|
261
|
+
}, props => assign(node, props, true, prevProps, true));
|
|
218
262
|
return prevProps;
|
|
219
263
|
}
|
|
220
264
|
function dynamicProperty(props, key) {
|
|
@@ -234,11 +278,12 @@ function ref(fn, element) {
|
|
|
234
278
|
const resolved = solidJs.untrack(fn);
|
|
235
279
|
solidJs.runWithOwner(null, () => applyRef(resolved, element));
|
|
236
280
|
}
|
|
237
|
-
function insert(parent, accessor, marker, initial) {
|
|
281
|
+
function insert(parent, accessor, marker, initial, options) {
|
|
282
|
+
const childRoot = getChildRoot(parent);
|
|
238
283
|
const multi = marker !== undefined;
|
|
239
284
|
if (multi && !initial) initial = [];
|
|
240
285
|
if (isHydrating(parent)) {
|
|
241
|
-
if (!multi && initial === undefined && parent) initial = [...
|
|
286
|
+
if (!multi && initial === undefined && parent) initial = [...childRoot.childNodes];
|
|
242
287
|
if (Array.isArray(initial)) {
|
|
243
288
|
let j = 0;
|
|
244
289
|
for (let i = 0; i < initial.length; i++) {
|
|
@@ -251,27 +296,64 @@ function insert(parent, accessor, marker, initial) {
|
|
|
251
296
|
accessor = normalize(accessor, initial, multi, true);
|
|
252
297
|
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
253
298
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
299
|
+
if (multi && initial.length === 0) {
|
|
300
|
+
const placeholder = document.createTextNode("");
|
|
301
|
+
childRoot.insertBefore(placeholder, marker);
|
|
302
|
+
initial = [placeholder];
|
|
303
|
+
}
|
|
304
|
+
let current = initial;
|
|
305
|
+
effect(prev => {
|
|
306
|
+
const value = normalize(accessor(), current, multi, true);
|
|
307
|
+
if (typeof value !== "function") return value;
|
|
308
|
+
effect(() => normalize(value, current, multi), inner => {
|
|
309
|
+
insertExpression(parent, inner, current, marker);
|
|
310
|
+
current = inner;
|
|
311
|
+
}, prev !== undefined && !(options && options.schedule) ? {
|
|
312
|
+
...options,
|
|
313
|
+
schedule: true
|
|
314
|
+
} : options);
|
|
315
|
+
return INNER_OWNED;
|
|
316
|
+
}, value => {
|
|
317
|
+
if (value === INNER_OWNED) return;
|
|
318
|
+
insertExpression(parent, value, current, marker);
|
|
319
|
+
current = value;
|
|
320
|
+
}, options);
|
|
321
|
+
}
|
|
322
|
+
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
323
|
+
const nodeName = node.nodeName;
|
|
257
324
|
props || (props = {});
|
|
258
325
|
for (const prop in prevProps) {
|
|
259
326
|
if (!(prop in props)) {
|
|
260
327
|
if (prop === "children") continue;
|
|
261
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop],
|
|
328
|
+
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
|
|
262
329
|
}
|
|
263
330
|
}
|
|
264
331
|
for (const prop in props) {
|
|
265
332
|
if (prop === "children") {
|
|
266
|
-
if (!skipChildren) insertExpression(node, props.children);
|
|
333
|
+
if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
|
|
267
334
|
continue;
|
|
268
335
|
}
|
|
269
|
-
|
|
270
|
-
|
|
336
|
+
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
function loadModuleAssets(mapping) {
|
|
340
|
+
const hy = globalThis._$HY;
|
|
341
|
+
if (!hy) return;
|
|
342
|
+
const pending = [];
|
|
343
|
+
for (const moduleUrl in mapping) {
|
|
344
|
+
if (hy.modules[moduleUrl]) continue;
|
|
345
|
+
const entryUrl = mapping[moduleUrl];
|
|
346
|
+
if (!hy.loading[moduleUrl]) {
|
|
347
|
+
hy.loading[moduleUrl] = import(entryUrl).then(mod => {
|
|
348
|
+
hy.modules[moduleUrl] = mod;
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
pending.push(hy.loading[moduleUrl]);
|
|
271
352
|
}
|
|
353
|
+
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
272
354
|
}
|
|
273
355
|
function hydrate$1(code, element, options = {}) {
|
|
274
|
-
if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
|
|
356
|
+
if (globalThis._$HY.done) return render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
275
357
|
options.renderId ||= "";
|
|
276
358
|
if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
|
|
277
359
|
if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
|
|
@@ -280,6 +362,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
280
362
|
solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
|
|
281
363
|
solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
|
|
282
364
|
solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
|
|
365
|
+
solidJs.sharedConfig.loadModuleAssets = loadModuleAssets;
|
|
283
366
|
solidJs.sharedConfig.cleanupFragment = id => {
|
|
284
367
|
const tpl = document.getElementById("pl-" + id);
|
|
285
368
|
if (tpl) {
|
|
@@ -298,9 +381,27 @@ function hydrate$1(code, element, options = {}) {
|
|
|
298
381
|
};
|
|
299
382
|
solidJs.sharedConfig.registry = new Map();
|
|
300
383
|
solidJs.sharedConfig.hydrating = true;
|
|
384
|
+
const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
|
|
385
|
+
if (rootMapping && typeof rootMapping === "object") {
|
|
386
|
+
const p = loadModuleAssets(rootMapping);
|
|
387
|
+
if (p) {
|
|
388
|
+
gatherHydratable(element, options.renderId);
|
|
389
|
+
let disposer;
|
|
390
|
+
p.then(() => {
|
|
391
|
+
try {
|
|
392
|
+
disposer = render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
393
|
+
} finally {
|
|
394
|
+
solidJs.sharedConfig.hydrating = false;
|
|
395
|
+
}
|
|
396
|
+
}, () => {
|
|
397
|
+
solidJs.sharedConfig.hydrating = false;
|
|
398
|
+
});
|
|
399
|
+
return () => disposer && disposer();
|
|
400
|
+
}
|
|
401
|
+
}
|
|
301
402
|
try {
|
|
302
403
|
gatherHydratable(element, options.renderId);
|
|
303
|
-
return render(code, element, [...element.childNodes], options);
|
|
404
|
+
return render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
304
405
|
} finally {
|
|
305
406
|
solidJs.sharedConfig.hydrating = false;
|
|
306
407
|
}
|
|
@@ -343,7 +444,7 @@ function getNextMarker(start) {
|
|
|
343
444
|
return [end, current];
|
|
344
445
|
}
|
|
345
446
|
function getFirstChild(node, expectedTag) {
|
|
346
|
-
const child = node.firstChild;
|
|
447
|
+
const child = getChildRoot(node).firstChild;
|
|
347
448
|
return child;
|
|
348
449
|
}
|
|
349
450
|
function getNextSibling(node, expectedTag) {
|
|
@@ -376,14 +477,24 @@ function runHydrationEvents() {
|
|
|
376
477
|
function isHydrating(node) {
|
|
377
478
|
return solidJs.sharedConfig.hydrating && (!node || node.isConnected);
|
|
378
479
|
}
|
|
379
|
-
function
|
|
380
|
-
|
|
381
|
-
for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
|
|
480
|
+
function getChildRoot(node) {
|
|
481
|
+
return node && node.localName === "template" ? node.content : node;
|
|
382
482
|
}
|
|
383
483
|
function classListToObject(classList) {
|
|
384
484
|
if (Array.isArray(classList)) {
|
|
385
485
|
const result = {};
|
|
386
486
|
flattenClassList(classList, result);
|
|
487
|
+
classList = result;
|
|
488
|
+
}
|
|
489
|
+
if (classList && typeof classList === "object") {
|
|
490
|
+
const result = {},
|
|
491
|
+
keys = Object.keys(classList);
|
|
492
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
493
|
+
const key = keys[i];
|
|
494
|
+
if (!classList[key]) continue;
|
|
495
|
+
const classNames = key.trim().split(/\s+/);
|
|
496
|
+
for (let j = 0, nameLen = classNames.length; j < nameLen; j++) classNames[j] && (result[classNames[j]] = true);
|
|
497
|
+
}
|
|
387
498
|
return result;
|
|
388
499
|
}
|
|
389
500
|
return classList;
|
|
@@ -394,18 +505,20 @@ function flattenClassList(list, result) {
|
|
|
394
505
|
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;
|
|
395
506
|
}
|
|
396
507
|
}
|
|
397
|
-
function assignProp(node, prop, value, prev,
|
|
398
|
-
let forceProp;
|
|
508
|
+
function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
399
509
|
if (prop === "style") return style(node, value, prev), value;
|
|
400
|
-
if (prop === "class") return className(node, value,
|
|
401
|
-
if (value === prev) return prev;
|
|
510
|
+
if (prop === "class") return className(node, value, prev), value;
|
|
511
|
+
if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
|
|
402
512
|
if (prop === "ref") {
|
|
403
513
|
if (!skipRef && value) ref(() => value, node);
|
|
404
|
-
|
|
514
|
+
return value;
|
|
515
|
+
}
|
|
516
|
+
const hasNamespace = prop.indexOf(":") > -1;
|
|
517
|
+
if (hasNamespace && prop.slice(0, 3) === "on:") {
|
|
405
518
|
const e = prop.slice(3);
|
|
406
519
|
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
407
520
|
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
408
|
-
} else if (prop.slice(0, 2) === "on") {
|
|
521
|
+
} else if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
409
522
|
const name = prop.slice(2).toLowerCase();
|
|
410
523
|
const delegate = DelegatedEvents.has(name);
|
|
411
524
|
if (!delegate && prev) {
|
|
@@ -416,11 +529,11 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
416
529
|
addEventListener(node, name, value, delegate);
|
|
417
530
|
delegate && delegateEvents([name]);
|
|
418
531
|
}
|
|
419
|
-
} else if (
|
|
420
|
-
if (
|
|
421
|
-
if (prop === "value" &&
|
|
532
|
+
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
533
|
+
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
534
|
+
if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
|
|
422
535
|
} else {
|
|
423
|
-
const ns =
|
|
536
|
+
const ns = hasNamespace && Namespaces[prop.split(":")[0]];
|
|
424
537
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
425
538
|
}
|
|
426
539
|
return value;
|
|
@@ -478,21 +591,22 @@ function eventHandler(e) {
|
|
|
478
591
|
function insertExpression(parent, value, current, marker) {
|
|
479
592
|
if (isHydrating(parent)) return;
|
|
480
593
|
if (value === current) return;
|
|
594
|
+
const childRoot = getChildRoot(parent);
|
|
481
595
|
const t = typeof value,
|
|
482
596
|
multi = marker !== undefined;
|
|
483
597
|
if (t === "string" || t === "number") {
|
|
484
598
|
const tc = typeof current;
|
|
485
599
|
if (tc === "string" || tc === "number") {
|
|
486
|
-
|
|
487
|
-
} else
|
|
600
|
+
childRoot.firstChild.data = value;
|
|
601
|
+
} else childRoot.textContent = value;
|
|
488
602
|
} else if (value === undefined) {
|
|
489
603
|
cleanChildren(parent, current, marker);
|
|
490
604
|
} else if (value.nodeType) {
|
|
491
605
|
if (Array.isArray(current)) {
|
|
492
606
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
493
|
-
} else if (current === undefined || !
|
|
494
|
-
|
|
495
|
-
} else
|
|
607
|
+
} else if (current === undefined || !childRoot.firstChild) {
|
|
608
|
+
childRoot.appendChild(value);
|
|
609
|
+
} else childRoot.replaceChild(value, childRoot.firstChild);
|
|
496
610
|
} else if (Array.isArray(value)) {
|
|
497
611
|
const currentArray = current && Array.isArray(current);
|
|
498
612
|
if (value.length === 0) {
|
|
@@ -500,7 +614,7 @@ function insertExpression(parent, value, current, marker) {
|
|
|
500
614
|
} else if (currentArray) {
|
|
501
615
|
if (current.length === 0) {
|
|
502
616
|
appendNodes(parent, value, marker);
|
|
503
|
-
} else reconcileArrays(
|
|
617
|
+
} else reconcileArrays(childRoot, current, value);
|
|
504
618
|
} else {
|
|
505
619
|
current && cleanChildren(parent);
|
|
506
620
|
appendNodes(parent, value);
|
|
@@ -525,9 +639,11 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
525
639
|
return value;
|
|
526
640
|
}
|
|
527
641
|
function appendNodes(parent, array, marker = null) {
|
|
642
|
+
parent = getChildRoot(parent);
|
|
528
643
|
for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
|
|
529
644
|
}
|
|
530
645
|
function cleanChildren(parent, current, marker, replacement) {
|
|
646
|
+
parent = getChildRoot(parent);
|
|
531
647
|
if (marker === undefined) return parent.textContent = "";
|
|
532
648
|
if (current.length) {
|
|
533
649
|
let inserted = false;
|
|
@@ -576,13 +692,21 @@ function ssrHydrationKey() {}
|
|
|
576
692
|
function resolveSSRNode(node) {}
|
|
577
693
|
function escape(html) {}
|
|
578
694
|
|
|
695
|
+
const mergeProps = solidJs.merge;
|
|
579
696
|
const isServer = false;
|
|
580
697
|
const isDev = false;
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
698
|
+
function render(code, element, init, options = {}) {
|
|
699
|
+
try {
|
|
700
|
+
const dispose = render$1(code, element, init, {
|
|
701
|
+
...options,
|
|
702
|
+
insertOptions: {
|
|
703
|
+
schedule: true
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
solidJs.flush();
|
|
707
|
+
return dispose;
|
|
708
|
+
} finally {
|
|
709
|
+
}
|
|
586
710
|
}
|
|
587
711
|
const hydrate = (...args) => {
|
|
588
712
|
solidJs.enableHydration();
|
|
@@ -608,6 +732,33 @@ function Portal(props) {
|
|
|
608
732
|
});
|
|
609
733
|
return treeMarker;
|
|
610
734
|
}
|
|
735
|
+
function dynamic(source) {
|
|
736
|
+
const cached = solidJs.createMemo(source, {
|
|
737
|
+
lazy: true
|
|
738
|
+
});
|
|
739
|
+
return props => {
|
|
740
|
+
return solidJs.createMemo(() => {
|
|
741
|
+
const component = cached();
|
|
742
|
+
switch (typeof component) {
|
|
743
|
+
case "function":
|
|
744
|
+
return solidJs.untrack(() => component(props));
|
|
745
|
+
case "string":
|
|
746
|
+
const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, solidJs.untrack(() => props.is));
|
|
747
|
+
spread(el, props);
|
|
748
|
+
return el;
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
function Dynamic(props) {
|
|
754
|
+
const Comp = dynamic(() => props.component);
|
|
755
|
+
return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
|
|
756
|
+
}
|
|
757
|
+
function createElement(tagName, is = undefined) {
|
|
758
|
+
return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
|
|
759
|
+
is
|
|
760
|
+
});
|
|
761
|
+
}
|
|
611
762
|
function createElementProxy(el, marker) {
|
|
612
763
|
return new Proxy(el, {
|
|
613
764
|
get(target, prop) {
|
|
@@ -625,25 +776,6 @@ function createElementProxy(el, marker) {
|
|
|
625
776
|
}
|
|
626
777
|
});
|
|
627
778
|
}
|
|
628
|
-
function createDynamic(component, props) {
|
|
629
|
-
const cached = solidJs.createMemo(component);
|
|
630
|
-
return solidJs.createMemo(() => {
|
|
631
|
-
const component = cached();
|
|
632
|
-
switch (typeof component) {
|
|
633
|
-
case "function":
|
|
634
|
-
return solidJs.untrack(() => component(props));
|
|
635
|
-
case "string":
|
|
636
|
-
const isSvg = SVGElements.has(component);
|
|
637
|
-
const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, solidJs.untrack(() => props.is));
|
|
638
|
-
spread(el, props, isSvg);
|
|
639
|
-
return el;
|
|
640
|
-
}
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
function Dynamic(props) {
|
|
644
|
-
const others = solidJs.omit(props, "component");
|
|
645
|
-
return createDynamic(() => props.component, others);
|
|
646
|
-
}
|
|
647
779
|
|
|
648
780
|
Object.defineProperty(exports, "Errored", {
|
|
649
781
|
enumerable: true,
|
|
@@ -669,6 +801,14 @@ Object.defineProperty(exports, "NoHydration", {
|
|
|
669
801
|
enumerable: true,
|
|
670
802
|
get: function () { return solidJs.NoHydration; }
|
|
671
803
|
});
|
|
804
|
+
Object.defineProperty(exports, "Repeat", {
|
|
805
|
+
enumerable: true,
|
|
806
|
+
get: function () { return solidJs.Repeat; }
|
|
807
|
+
});
|
|
808
|
+
Object.defineProperty(exports, "Reveal", {
|
|
809
|
+
enumerable: true,
|
|
810
|
+
get: function () { return solidJs.Reveal; }
|
|
811
|
+
});
|
|
672
812
|
Object.defineProperty(exports, "Show", {
|
|
673
813
|
enumerable: true,
|
|
674
814
|
get: function () { return solidJs.Show; }
|
|
@@ -685,10 +825,6 @@ Object.defineProperty(exports, "getOwner", {
|
|
|
685
825
|
enumerable: true,
|
|
686
826
|
get: function () { return solidJs.getOwner; }
|
|
687
827
|
});
|
|
688
|
-
Object.defineProperty(exports, "mergeProps", {
|
|
689
|
-
enumerable: true,
|
|
690
|
-
get: function () { return solidJs.merge; }
|
|
691
|
-
});
|
|
692
828
|
Object.defineProperty(exports, "untrack", {
|
|
693
829
|
enumerable: true,
|
|
694
830
|
get: function () { return solidJs.untrack; }
|
|
@@ -696,21 +832,24 @@ Object.defineProperty(exports, "untrack", {
|
|
|
696
832
|
exports.Assets = voidFn;
|
|
697
833
|
exports.ChildProperties = ChildProperties;
|
|
698
834
|
exports.DOMElements = DOMElements;
|
|
835
|
+
exports.DOMWithState = DOMWithState;
|
|
699
836
|
exports.DelegatedEvents = DelegatedEvents;
|
|
700
837
|
exports.Dynamic = Dynamic;
|
|
701
838
|
exports.HydrationScript = voidFn;
|
|
839
|
+
exports.MathMLElements = MathMLElements;
|
|
840
|
+
exports.Namespaces = Namespaces;
|
|
702
841
|
exports.Portal = Portal;
|
|
703
|
-
exports.
|
|
842
|
+
exports.RawTextElements = RawTextElements;
|
|
704
843
|
exports.RequestContext = RequestContext;
|
|
705
844
|
exports.SVGElements = SVGElements;
|
|
706
|
-
exports.
|
|
845
|
+
exports.VoidElements = VoidElements;
|
|
707
846
|
exports.addEventListener = addEventListener;
|
|
708
847
|
exports.applyRef = applyRef;
|
|
709
848
|
exports.assign = assign;
|
|
710
849
|
exports.className = className;
|
|
711
850
|
exports.clearDelegatedEvents = clearDelegatedEvents;
|
|
712
|
-
exports.createDynamic = createDynamic;
|
|
713
851
|
exports.delegateEvents = delegateEvents;
|
|
852
|
+
exports.dynamic = dynamic;
|
|
714
853
|
exports.dynamicProperty = dynamicProperty;
|
|
715
854
|
exports.effect = effect;
|
|
716
855
|
exports.escape = escape;
|
|
@@ -728,6 +867,7 @@ exports.insert = insert;
|
|
|
728
867
|
exports.isDev = isDev;
|
|
729
868
|
exports.isServer = isServer;
|
|
730
869
|
exports.memo = memo;
|
|
870
|
+
exports.mergeProps = mergeProps;
|
|
731
871
|
exports.ref = ref;
|
|
732
872
|
exports.render = render;
|
|
733
873
|
exports.renderToStream = renderToStream;
|