@solidjs/web 2.0.0-beta.6 → 2.0.0-beta.7
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/dist/dev.cjs +78 -37
- package/dist/dev.js +75 -38
- package/dist/server.cjs +77 -79
- package/dist/server.js +77 -79
- package/dist/web.cjs +74 -34
- package/dist/web.js +71 -35
- package/package.json +72 -30
- package/storage/package.json +8 -3
- package/storage/types/src/index.d.ts +1 -1
- 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 +46 -0
- package/storage/types-cjs/src/server-mock.d.cts +72 -0
- package/storage/types-cjs/storage/src/index.d.cts +2 -0
- package/types/client.d.ts +9 -3
- package/types/core.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/types/server.d.ts +9 -3
- package/types-cjs/client.d.cts +93 -0
- package/types-cjs/core.d.cts +3 -0
- package/types-cjs/index.d.cts +46 -0
- package/types-cjs/jsx.d.cts +1 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/server-mock.d.cts +72 -0
- package/types-cjs/server.d.cts +161 -0
package/dist/dev.cjs
CHANGED
|
@@ -6,9 +6,9 @@ var signals = require('@solidjs/signals');
|
|
|
6
6
|
const DOMWithState = {
|
|
7
7
|
INPUT: {
|
|
8
8
|
value: 1,
|
|
9
|
-
defaultValue:
|
|
9
|
+
defaultValue: 2,
|
|
10
10
|
checked: 1,
|
|
11
|
-
defaultChecked:
|
|
11
|
+
defaultChecked: 2
|
|
12
12
|
},
|
|
13
13
|
SELECT: {
|
|
14
14
|
value: 1
|
|
@@ -16,26 +16,21 @@ const DOMWithState = {
|
|
|
16
16
|
OPTION: {
|
|
17
17
|
value: 1,
|
|
18
18
|
selected: 1,
|
|
19
|
-
defaultSelected:
|
|
19
|
+
defaultSelected: 2
|
|
20
20
|
},
|
|
21
21
|
TEXTAREA: {
|
|
22
22
|
value: 1,
|
|
23
|
-
defaultValue:
|
|
23
|
+
defaultValue: 2
|
|
24
24
|
},
|
|
25
25
|
VIDEO: {
|
|
26
26
|
muted: 1,
|
|
27
|
-
defaultMuted:
|
|
27
|
+
defaultMuted: 2
|
|
28
28
|
},
|
|
29
29
|
AUDIO: {
|
|
30
30
|
muted: 1,
|
|
31
|
-
defaultMuted:
|
|
31
|
+
defaultMuted: 2
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
for (const tagName in DOMWithState) {
|
|
35
|
-
for (const propName in DOMWithState[tagName]) {
|
|
36
|
-
DOMWithState[tagName]["prop:" + propName] = 1;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
34
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
40
35
|
const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
|
|
41
36
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -54,10 +49,10 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
|
|
|
54
49
|
"webview",
|
|
55
50
|
"isindex", "listing", "multicol", "nextid", "noindex", "search"]);
|
|
56
51
|
|
|
57
|
-
const effect = (fn, effectFn
|
|
52
|
+
const effect = (fn, effectFn) => solidJs.createRenderEffect(fn, effectFn, {
|
|
58
53
|
transparent: true
|
|
59
54
|
});
|
|
60
|
-
const memo = (fn, transparent) => transparent ? fn.$r ? fn : signals.createMemo(() => fn(),
|
|
55
|
+
const memo = (fn, transparent) => transparent ? fn.$r ? fn : signals.createMemo(() => fn(), {
|
|
61
56
|
transparent: true
|
|
62
57
|
}) : solidJs.createMemo(() => fn());
|
|
63
58
|
|
|
@@ -123,16 +118,17 @@ function render$1(code, element, init, options = {}) {
|
|
|
123
118
|
if (!element) {
|
|
124
119
|
throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
|
|
125
120
|
}
|
|
121
|
+
const renderRoot = getChildRoot(element);
|
|
126
122
|
let disposer;
|
|
127
123
|
solidJs.createRoot(dispose => {
|
|
128
124
|
disposer = dispose;
|
|
129
|
-
element === document ? solidJs.flatten(code) : insert(element, code(),
|
|
125
|
+
element === document ? solidJs.flatten(code) : insert(element, code(), renderRoot.firstChild ? null : undefined, init);
|
|
130
126
|
}, {
|
|
131
127
|
id: options.renderId
|
|
132
128
|
});
|
|
133
129
|
return () => {
|
|
134
130
|
disposer();
|
|
135
|
-
|
|
131
|
+
renderRoot.textContent = "";
|
|
136
132
|
};
|
|
137
133
|
}
|
|
138
134
|
function create(html, bypassGuard, flag) {
|
|
@@ -272,10 +268,11 @@ function ref(fn, element) {
|
|
|
272
268
|
solidJs.runWithOwner(null, () => applyRef(resolved, element));
|
|
273
269
|
}
|
|
274
270
|
function insert(parent, accessor, marker, initial) {
|
|
271
|
+
const childRoot = getChildRoot(parent);
|
|
275
272
|
const multi = marker !== undefined;
|
|
276
273
|
if (multi && !initial) initial = [];
|
|
277
274
|
if (isHydrating(parent)) {
|
|
278
|
-
if (!multi && initial === undefined && parent) initial = [...
|
|
275
|
+
if (!multi && initial === undefined && parent) initial = [...childRoot.childNodes];
|
|
279
276
|
if (Array.isArray(initial)) {
|
|
280
277
|
let j = 0;
|
|
281
278
|
for (let i = 0; i < initial.length; i++) {
|
|
@@ -291,10 +288,10 @@ function insert(parent, accessor, marker, initial) {
|
|
|
291
288
|
accessor = memo(accessor, true);
|
|
292
289
|
if (multi && initial.length === 0) {
|
|
293
290
|
const placeholder = document.createTextNode("");
|
|
294
|
-
|
|
291
|
+
childRoot.insertBefore(placeholder, marker);
|
|
295
292
|
initial = [placeholder];
|
|
296
293
|
}
|
|
297
|
-
effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker)
|
|
294
|
+
effect((prev = initial) => normalize(accessor, prev, multi), (value, current = initial) => insertExpression(parent, value, current, marker));
|
|
298
295
|
}
|
|
299
296
|
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
300
297
|
const nodeName = node.nodeName;
|
|
@@ -313,8 +310,24 @@ function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
|
313
310
|
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
|
|
314
311
|
}
|
|
315
312
|
}
|
|
313
|
+
function loadModuleAssets(mapping) {
|
|
314
|
+
const hy = globalThis._$HY;
|
|
315
|
+
if (!hy) return;
|
|
316
|
+
const pending = [];
|
|
317
|
+
for (const moduleUrl in mapping) {
|
|
318
|
+
if (hy.modules[moduleUrl]) continue;
|
|
319
|
+
const entryUrl = mapping[moduleUrl];
|
|
320
|
+
if (!hy.loading[moduleUrl]) {
|
|
321
|
+
hy.loading[moduleUrl] = import(entryUrl).then(mod => {
|
|
322
|
+
hy.modules[moduleUrl] = mod;
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
pending.push(hy.loading[moduleUrl]);
|
|
326
|
+
}
|
|
327
|
+
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
328
|
+
}
|
|
316
329
|
function hydrate$1(code, element, options = {}) {
|
|
317
|
-
if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
|
|
330
|
+
if (globalThis._$HY.done) return render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
318
331
|
options.renderId ||= "";
|
|
319
332
|
if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
|
|
320
333
|
if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
|
|
@@ -323,6 +336,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
323
336
|
solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
|
|
324
337
|
solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
|
|
325
338
|
solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
|
|
339
|
+
solidJs.sharedConfig.loadModuleAssets = loadModuleAssets;
|
|
326
340
|
solidJs.sharedConfig.cleanupFragment = id => {
|
|
327
341
|
const tpl = document.getElementById("pl-" + id);
|
|
328
342
|
if (tpl) {
|
|
@@ -351,9 +365,27 @@ function hydrate$1(code, element, options = {}) {
|
|
|
351
365
|
}
|
|
352
366
|
};
|
|
353
367
|
}
|
|
368
|
+
const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
|
|
369
|
+
if (rootMapping && typeof rootMapping === "object") {
|
|
370
|
+
const p = loadModuleAssets(rootMapping);
|
|
371
|
+
if (p) {
|
|
372
|
+
gatherHydratable(element, options.renderId);
|
|
373
|
+
let disposer;
|
|
374
|
+
p.then(() => {
|
|
375
|
+
try {
|
|
376
|
+
disposer = render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
377
|
+
} finally {
|
|
378
|
+
solidJs.sharedConfig.hydrating = false;
|
|
379
|
+
}
|
|
380
|
+
}, () => {
|
|
381
|
+
solidJs.sharedConfig.hydrating = false;
|
|
382
|
+
});
|
|
383
|
+
return () => disposer && disposer();
|
|
384
|
+
}
|
|
385
|
+
}
|
|
354
386
|
try {
|
|
355
387
|
gatherHydratable(element, options.renderId);
|
|
356
|
-
return render$1(code, element, [...element.childNodes], options);
|
|
388
|
+
return render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
357
389
|
} finally {
|
|
358
390
|
solidJs.sharedConfig.hydrating = false;
|
|
359
391
|
}
|
|
@@ -402,7 +434,7 @@ function getNextMarker(start) {
|
|
|
402
434
|
return [end, current];
|
|
403
435
|
}
|
|
404
436
|
function getFirstChild(node, expectedTag) {
|
|
405
|
-
const child = node.firstChild;
|
|
437
|
+
const child = getChildRoot(node).firstChild;
|
|
406
438
|
if (isHydrating() && expectedTag && child?.localName !== expectedTag) {
|
|
407
439
|
const isMissing = !child || child.nodeType !== 1;
|
|
408
440
|
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> as first child of", node, "\n " + describeSiblings(node, child, expectedTag, isMissing));
|
|
@@ -412,20 +444,21 @@ function getFirstChild(node, expectedTag) {
|
|
|
412
444
|
function getNextSibling(node, expectedTag) {
|
|
413
445
|
const sibling = node.nextSibling;
|
|
414
446
|
if (isHydrating() && expectedTag && sibling?.localName !== expectedTag) {
|
|
415
|
-
const parent = node.
|
|
447
|
+
const parent = node.parentNode;
|
|
416
448
|
const isMissing = !sibling || sibling.nodeType !== 1;
|
|
417
449
|
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> after", node, "in", parent, "\n " + describeSiblings(parent, sibling, expectedTag, isMissing));
|
|
418
450
|
}
|
|
419
451
|
return sibling;
|
|
420
452
|
}
|
|
421
453
|
function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
|
|
454
|
+
if (!parent) return `<${expectedTag} \u2190 parent unavailable>`;
|
|
422
455
|
const children = [];
|
|
423
|
-
let child = parent.firstChild;
|
|
456
|
+
let child = getChildRoot(parent).firstChild;
|
|
424
457
|
while (child) {
|
|
425
458
|
if (child.nodeType === 1) children.push(child);
|
|
426
459
|
child = child.nextSibling;
|
|
427
460
|
}
|
|
428
|
-
const pTag = parent.localName;
|
|
461
|
+
const pTag = parent.localName || "#fragment";
|
|
429
462
|
if (isMissing) {
|
|
430
463
|
const tags = children.map(c => `<${c.localName}>`).join("");
|
|
431
464
|
return `<${pTag}>${tags}<${expectedTag} \u2190 missing></${pTag}>`;
|
|
@@ -470,6 +503,9 @@ function runHydrationEvents() {
|
|
|
470
503
|
function isHydrating(node) {
|
|
471
504
|
return solidJs.sharedConfig.hydrating && (!node || node.isConnected);
|
|
472
505
|
}
|
|
506
|
+
function getChildRoot(node) {
|
|
507
|
+
return node && node.localName === "template" ? node.content : node;
|
|
508
|
+
}
|
|
473
509
|
function toggleClassKey(node, key, value) {
|
|
474
510
|
const classNames = key.trim().split(/\s+/);
|
|
475
511
|
for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
|
|
@@ -491,7 +527,7 @@ function flattenClassList(list, result) {
|
|
|
491
527
|
function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
492
528
|
if (prop === "style") return style(node, value, prev), value;
|
|
493
529
|
if (prop === "class") return className(node, value, prev), value;
|
|
494
|
-
if (value === prev &&
|
|
530
|
+
if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
|
|
495
531
|
if (prop === "ref") {
|
|
496
532
|
if (!skipRef && value) ref(() => value, node);
|
|
497
533
|
return value;
|
|
@@ -574,21 +610,22 @@ function eventHandler(e) {
|
|
|
574
610
|
function insertExpression(parent, value, current, marker) {
|
|
575
611
|
if (isHydrating(parent)) return;
|
|
576
612
|
if (value === current) return;
|
|
613
|
+
const childRoot = getChildRoot(parent);
|
|
577
614
|
const t = typeof value,
|
|
578
615
|
multi = marker !== undefined;
|
|
579
616
|
if (t === "string" || t === "number") {
|
|
580
617
|
const tc = typeof current;
|
|
581
618
|
if (tc === "string" || tc === "number") {
|
|
582
|
-
|
|
583
|
-
} else
|
|
619
|
+
childRoot.firstChild.data = value;
|
|
620
|
+
} else childRoot.textContent = value;
|
|
584
621
|
} else if (value === undefined) {
|
|
585
622
|
cleanChildren(parent, current, marker);
|
|
586
623
|
} else if (value.nodeType) {
|
|
587
624
|
if (Array.isArray(current)) {
|
|
588
625
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
589
|
-
} else if (current === undefined || !
|
|
590
|
-
|
|
591
|
-
} else
|
|
626
|
+
} else if (current === undefined || !childRoot.firstChild) {
|
|
627
|
+
childRoot.appendChild(value);
|
|
628
|
+
} else childRoot.replaceChild(value, childRoot.firstChild);
|
|
592
629
|
} else if (Array.isArray(value)) {
|
|
593
630
|
const currentArray = current && Array.isArray(current);
|
|
594
631
|
if (value.length === 0) {
|
|
@@ -596,7 +633,7 @@ function insertExpression(parent, value, current, marker) {
|
|
|
596
633
|
} else if (currentArray) {
|
|
597
634
|
if (current.length === 0) {
|
|
598
635
|
appendNodes(parent, value, marker);
|
|
599
|
-
} else reconcileArrays(
|
|
636
|
+
} else reconcileArrays(childRoot, current, value);
|
|
600
637
|
} else {
|
|
601
638
|
current && cleanChildren(parent);
|
|
602
639
|
appendNodes(parent, value);
|
|
@@ -621,9 +658,11 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
621
658
|
return value;
|
|
622
659
|
}
|
|
623
660
|
function appendNodes(parent, array, marker = null) {
|
|
661
|
+
parent = getChildRoot(parent);
|
|
624
662
|
for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
|
|
625
663
|
}
|
|
626
664
|
function cleanChildren(parent, current, marker, replacement) {
|
|
665
|
+
parent = getChildRoot(parent);
|
|
627
666
|
if (marker === undefined) return parent.textContent = "";
|
|
628
667
|
if (current.length) {
|
|
629
668
|
let inserted = false;
|
|
@@ -680,9 +719,8 @@ function render(...args) {
|
|
|
680
719
|
}
|
|
681
720
|
const isServer = false;
|
|
682
721
|
const isDev = true;
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
|
|
722
|
+
function createElement(tagName, is = undefined) {
|
|
723
|
+
return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
|
|
686
724
|
is
|
|
687
725
|
});
|
|
688
726
|
}
|
|
@@ -738,9 +776,8 @@ function createDynamic(component, props) {
|
|
|
738
776
|
});
|
|
739
777
|
return solidJs.untrack(() => component(props));
|
|
740
778
|
case "string":
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
spread(el, props, isSvg);
|
|
779
|
+
const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, solidJs.untrack(() => props.is));
|
|
780
|
+
spread(el, props);
|
|
744
781
|
return el;
|
|
745
782
|
}
|
|
746
783
|
});
|
|
@@ -774,6 +811,10 @@ Object.defineProperty(exports, "NoHydration", {
|
|
|
774
811
|
enumerable: true,
|
|
775
812
|
get: function () { return solidJs.NoHydration; }
|
|
776
813
|
});
|
|
814
|
+
Object.defineProperty(exports, "Repeat", {
|
|
815
|
+
enumerable: true,
|
|
816
|
+
get: function () { return solidJs.Repeat; }
|
|
817
|
+
});
|
|
777
818
|
Object.defineProperty(exports, "Reveal", {
|
|
778
819
|
enumerable: true,
|
|
779
820
|
get: function () { return solidJs.Reveal; }
|
package/dist/dev.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createRenderEffect, createMemo as createMemo$1, sharedConfig, untrack, runWithOwner, flatten, createRoot, omit, $DEVCOMP, enableHydration, enforceLoadingBoundary } from 'solid-js';
|
|
2
|
-
export { Errored, For, Hydration, Loading, Match, NoHydration, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
|
|
2
|
+
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
|
|
3
3
|
import { createMemo } from '@solidjs/signals';
|
|
4
4
|
|
|
5
5
|
const DOMWithState = {
|
|
6
6
|
INPUT: {
|
|
7
7
|
value: 1,
|
|
8
|
-
defaultValue:
|
|
8
|
+
defaultValue: 2,
|
|
9
9
|
checked: 1,
|
|
10
|
-
defaultChecked:
|
|
10
|
+
defaultChecked: 2
|
|
11
11
|
},
|
|
12
12
|
SELECT: {
|
|
13
13
|
value: 1
|
|
@@ -15,26 +15,21 @@ const DOMWithState = {
|
|
|
15
15
|
OPTION: {
|
|
16
16
|
value: 1,
|
|
17
17
|
selected: 1,
|
|
18
|
-
defaultSelected:
|
|
18
|
+
defaultSelected: 2
|
|
19
19
|
},
|
|
20
20
|
TEXTAREA: {
|
|
21
21
|
value: 1,
|
|
22
|
-
defaultValue:
|
|
22
|
+
defaultValue: 2
|
|
23
23
|
},
|
|
24
24
|
VIDEO: {
|
|
25
25
|
muted: 1,
|
|
26
|
-
defaultMuted:
|
|
26
|
+
defaultMuted: 2
|
|
27
27
|
},
|
|
28
28
|
AUDIO: {
|
|
29
29
|
muted: 1,
|
|
30
|
-
defaultMuted:
|
|
30
|
+
defaultMuted: 2
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
for (const tagName in DOMWithState) {
|
|
34
|
-
for (const propName in DOMWithState[tagName]) {
|
|
35
|
-
DOMWithState[tagName]["prop:" + propName] = 1;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
33
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
39
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"]);
|
|
40
35
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -53,10 +48,10 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
|
|
|
53
48
|
"webview",
|
|
54
49
|
"isindex", "listing", "multicol", "nextid", "noindex", "search"]);
|
|
55
50
|
|
|
56
|
-
const effect = (fn, effectFn
|
|
51
|
+
const effect = (fn, effectFn) => createRenderEffect(fn, effectFn, {
|
|
57
52
|
transparent: true
|
|
58
53
|
});
|
|
59
|
-
const memo = (fn, transparent) => transparent ? fn.$r ? fn : createMemo(() => fn(),
|
|
54
|
+
const memo = (fn, transparent) => transparent ? fn.$r ? fn : createMemo(() => fn(), {
|
|
60
55
|
transparent: true
|
|
61
56
|
}) : createMemo$1(() => fn());
|
|
62
57
|
|
|
@@ -122,16 +117,17 @@ function render$1(code, element, init, options = {}) {
|
|
|
122
117
|
if (!element) {
|
|
123
118
|
throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
|
|
124
119
|
}
|
|
120
|
+
const renderRoot = getChildRoot(element);
|
|
125
121
|
let disposer;
|
|
126
122
|
createRoot(dispose => {
|
|
127
123
|
disposer = dispose;
|
|
128
|
-
element === document ? flatten(code) : insert(element, code(),
|
|
124
|
+
element === document ? flatten(code) : insert(element, code(), renderRoot.firstChild ? null : undefined, init);
|
|
129
125
|
}, {
|
|
130
126
|
id: options.renderId
|
|
131
127
|
});
|
|
132
128
|
return () => {
|
|
133
129
|
disposer();
|
|
134
|
-
|
|
130
|
+
renderRoot.textContent = "";
|
|
135
131
|
};
|
|
136
132
|
}
|
|
137
133
|
function create(html, bypassGuard, flag) {
|
|
@@ -271,10 +267,11 @@ function ref(fn, element) {
|
|
|
271
267
|
runWithOwner(null, () => applyRef(resolved, element));
|
|
272
268
|
}
|
|
273
269
|
function insert(parent, accessor, marker, initial) {
|
|
270
|
+
const childRoot = getChildRoot(parent);
|
|
274
271
|
const multi = marker !== undefined;
|
|
275
272
|
if (multi && !initial) initial = [];
|
|
276
273
|
if (isHydrating(parent)) {
|
|
277
|
-
if (!multi && initial === undefined && parent) initial = [...
|
|
274
|
+
if (!multi && initial === undefined && parent) initial = [...childRoot.childNodes];
|
|
278
275
|
if (Array.isArray(initial)) {
|
|
279
276
|
let j = 0;
|
|
280
277
|
for (let i = 0; i < initial.length; i++) {
|
|
@@ -290,10 +287,10 @@ function insert(parent, accessor, marker, initial) {
|
|
|
290
287
|
accessor = memo(accessor, true);
|
|
291
288
|
if (multi && initial.length === 0) {
|
|
292
289
|
const placeholder = document.createTextNode("");
|
|
293
|
-
|
|
290
|
+
childRoot.insertBefore(placeholder, marker);
|
|
294
291
|
initial = [placeholder];
|
|
295
292
|
}
|
|
296
|
-
effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker)
|
|
293
|
+
effect((prev = initial) => normalize(accessor, prev, multi), (value, current = initial) => insertExpression(parent, value, current, marker));
|
|
297
294
|
}
|
|
298
295
|
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
299
296
|
const nodeName = node.nodeName;
|
|
@@ -312,8 +309,24 @@ function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
|
312
309
|
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
|
|
313
310
|
}
|
|
314
311
|
}
|
|
312
|
+
function loadModuleAssets(mapping) {
|
|
313
|
+
const hy = globalThis._$HY;
|
|
314
|
+
if (!hy) return;
|
|
315
|
+
const pending = [];
|
|
316
|
+
for (const moduleUrl in mapping) {
|
|
317
|
+
if (hy.modules[moduleUrl]) continue;
|
|
318
|
+
const entryUrl = mapping[moduleUrl];
|
|
319
|
+
if (!hy.loading[moduleUrl]) {
|
|
320
|
+
hy.loading[moduleUrl] = import(entryUrl).then(mod => {
|
|
321
|
+
hy.modules[moduleUrl] = mod;
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
pending.push(hy.loading[moduleUrl]);
|
|
325
|
+
}
|
|
326
|
+
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
327
|
+
}
|
|
315
328
|
function hydrate$1(code, element, options = {}) {
|
|
316
|
-
if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
|
|
329
|
+
if (globalThis._$HY.done) return render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
317
330
|
options.renderId ||= "";
|
|
318
331
|
if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
|
|
319
332
|
if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
|
|
@@ -322,6 +335,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
322
335
|
sharedConfig.load = id => globalThis._$HY.r[id];
|
|
323
336
|
sharedConfig.has = id => id in globalThis._$HY.r;
|
|
324
337
|
sharedConfig.gather = root => gatherHydratable(element, root);
|
|
338
|
+
sharedConfig.loadModuleAssets = loadModuleAssets;
|
|
325
339
|
sharedConfig.cleanupFragment = id => {
|
|
326
340
|
const tpl = document.getElementById("pl-" + id);
|
|
327
341
|
if (tpl) {
|
|
@@ -350,9 +364,27 @@ function hydrate$1(code, element, options = {}) {
|
|
|
350
364
|
}
|
|
351
365
|
};
|
|
352
366
|
}
|
|
367
|
+
const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
|
|
368
|
+
if (rootMapping && typeof rootMapping === "object") {
|
|
369
|
+
const p = loadModuleAssets(rootMapping);
|
|
370
|
+
if (p) {
|
|
371
|
+
gatherHydratable(element, options.renderId);
|
|
372
|
+
let disposer;
|
|
373
|
+
p.then(() => {
|
|
374
|
+
try {
|
|
375
|
+
disposer = render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
376
|
+
} finally {
|
|
377
|
+
sharedConfig.hydrating = false;
|
|
378
|
+
}
|
|
379
|
+
}, () => {
|
|
380
|
+
sharedConfig.hydrating = false;
|
|
381
|
+
});
|
|
382
|
+
return () => disposer && disposer();
|
|
383
|
+
}
|
|
384
|
+
}
|
|
353
385
|
try {
|
|
354
386
|
gatherHydratable(element, options.renderId);
|
|
355
|
-
return render$1(code, element, [...element.childNodes], options);
|
|
387
|
+
return render$1(code, element, [...getChildRoot(element).childNodes], options);
|
|
356
388
|
} finally {
|
|
357
389
|
sharedConfig.hydrating = false;
|
|
358
390
|
}
|
|
@@ -401,7 +433,7 @@ function getNextMarker(start) {
|
|
|
401
433
|
return [end, current];
|
|
402
434
|
}
|
|
403
435
|
function getFirstChild(node, expectedTag) {
|
|
404
|
-
const child = node.firstChild;
|
|
436
|
+
const child = getChildRoot(node).firstChild;
|
|
405
437
|
if (isHydrating() && expectedTag && child?.localName !== expectedTag) {
|
|
406
438
|
const isMissing = !child || child.nodeType !== 1;
|
|
407
439
|
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> as first child of", node, "\n " + describeSiblings(node, child, expectedTag, isMissing));
|
|
@@ -411,20 +443,21 @@ function getFirstChild(node, expectedTag) {
|
|
|
411
443
|
function getNextSibling(node, expectedTag) {
|
|
412
444
|
const sibling = node.nextSibling;
|
|
413
445
|
if (isHydrating() && expectedTag && sibling?.localName !== expectedTag) {
|
|
414
|
-
const parent = node.
|
|
446
|
+
const parent = node.parentNode;
|
|
415
447
|
const isMissing = !sibling || sibling.nodeType !== 1;
|
|
416
448
|
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> after", node, "in", parent, "\n " + describeSiblings(parent, sibling, expectedTag, isMissing));
|
|
417
449
|
}
|
|
418
450
|
return sibling;
|
|
419
451
|
}
|
|
420
452
|
function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
|
|
453
|
+
if (!parent) return `<${expectedTag} \u2190 parent unavailable>`;
|
|
421
454
|
const children = [];
|
|
422
|
-
let child = parent.firstChild;
|
|
455
|
+
let child = getChildRoot(parent).firstChild;
|
|
423
456
|
while (child) {
|
|
424
457
|
if (child.nodeType === 1) children.push(child);
|
|
425
458
|
child = child.nextSibling;
|
|
426
459
|
}
|
|
427
|
-
const pTag = parent.localName;
|
|
460
|
+
const pTag = parent.localName || "#fragment";
|
|
428
461
|
if (isMissing) {
|
|
429
462
|
const tags = children.map(c => `<${c.localName}>`).join("");
|
|
430
463
|
return `<${pTag}>${tags}<${expectedTag} \u2190 missing></${pTag}>`;
|
|
@@ -469,6 +502,9 @@ function runHydrationEvents() {
|
|
|
469
502
|
function isHydrating(node) {
|
|
470
503
|
return sharedConfig.hydrating && (!node || node.isConnected);
|
|
471
504
|
}
|
|
505
|
+
function getChildRoot(node) {
|
|
506
|
+
return node && node.localName === "template" ? node.content : node;
|
|
507
|
+
}
|
|
472
508
|
function toggleClassKey(node, key, value) {
|
|
473
509
|
const classNames = key.trim().split(/\s+/);
|
|
474
510
|
for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
|
|
@@ -490,7 +526,7 @@ function flattenClassList(list, result) {
|
|
|
490
526
|
function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
491
527
|
if (prop === "style") return style(node, value, prev), value;
|
|
492
528
|
if (prop === "class") return className(node, value, prev), value;
|
|
493
|
-
if (value === prev &&
|
|
529
|
+
if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
|
|
494
530
|
if (prop === "ref") {
|
|
495
531
|
if (!skipRef && value) ref(() => value, node);
|
|
496
532
|
return value;
|
|
@@ -573,21 +609,22 @@ function eventHandler(e) {
|
|
|
573
609
|
function insertExpression(parent, value, current, marker) {
|
|
574
610
|
if (isHydrating(parent)) return;
|
|
575
611
|
if (value === current) return;
|
|
612
|
+
const childRoot = getChildRoot(parent);
|
|
576
613
|
const t = typeof value,
|
|
577
614
|
multi = marker !== undefined;
|
|
578
615
|
if (t === "string" || t === "number") {
|
|
579
616
|
const tc = typeof current;
|
|
580
617
|
if (tc === "string" || tc === "number") {
|
|
581
|
-
|
|
582
|
-
} else
|
|
618
|
+
childRoot.firstChild.data = value;
|
|
619
|
+
} else childRoot.textContent = value;
|
|
583
620
|
} else if (value === undefined) {
|
|
584
621
|
cleanChildren(parent, current, marker);
|
|
585
622
|
} else if (value.nodeType) {
|
|
586
623
|
if (Array.isArray(current)) {
|
|
587
624
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
588
|
-
} else if (current === undefined || !
|
|
589
|
-
|
|
590
|
-
} else
|
|
625
|
+
} else if (current === undefined || !childRoot.firstChild) {
|
|
626
|
+
childRoot.appendChild(value);
|
|
627
|
+
} else childRoot.replaceChild(value, childRoot.firstChild);
|
|
591
628
|
} else if (Array.isArray(value)) {
|
|
592
629
|
const currentArray = current && Array.isArray(current);
|
|
593
630
|
if (value.length === 0) {
|
|
@@ -595,7 +632,7 @@ function insertExpression(parent, value, current, marker) {
|
|
|
595
632
|
} else if (currentArray) {
|
|
596
633
|
if (current.length === 0) {
|
|
597
634
|
appendNodes(parent, value, marker);
|
|
598
|
-
} else reconcileArrays(
|
|
635
|
+
} else reconcileArrays(childRoot, current, value);
|
|
599
636
|
} else {
|
|
600
637
|
current && cleanChildren(parent);
|
|
601
638
|
appendNodes(parent, value);
|
|
@@ -620,9 +657,11 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
620
657
|
return value;
|
|
621
658
|
}
|
|
622
659
|
function appendNodes(parent, array, marker = null) {
|
|
660
|
+
parent = getChildRoot(parent);
|
|
623
661
|
for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
|
|
624
662
|
}
|
|
625
663
|
function cleanChildren(parent, current, marker, replacement) {
|
|
664
|
+
parent = getChildRoot(parent);
|
|
626
665
|
if (marker === undefined) return parent.textContent = "";
|
|
627
666
|
if (current.length) {
|
|
628
667
|
let inserted = false;
|
|
@@ -679,9 +718,8 @@ function render(...args) {
|
|
|
679
718
|
}
|
|
680
719
|
const isServer = false;
|
|
681
720
|
const isDev = true;
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
|
|
721
|
+
function createElement(tagName, is = undefined) {
|
|
722
|
+
return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
|
|
685
723
|
is
|
|
686
724
|
});
|
|
687
725
|
}
|
|
@@ -737,9 +775,8 @@ function createDynamic(component, props) {
|
|
|
737
775
|
});
|
|
738
776
|
return untrack(() => component(props));
|
|
739
777
|
case "string":
|
|
740
|
-
const
|
|
741
|
-
|
|
742
|
-
spread(el, props, isSvg);
|
|
778
|
+
const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
|
|
779
|
+
spread(el, props);
|
|
743
780
|
return el;
|
|
744
781
|
}
|
|
745
782
|
});
|