@solidjs/web 2.0.0-beta.11 → 2.0.0-beta.13
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 +16 -28
- package/dist/dev.js +16 -28
- package/dist/server.cjs +48 -5
- package/dist/server.js +48 -5
- package/dist/web.cjs +15 -27
- package/dist/web.js +15 -27
- package/package.json +3 -3
- package/types/jsx.d.ts +9 -241
- package/types-cjs/jsx.d.cts +9 -241
package/dist/dev.cjs
CHANGED
|
@@ -129,7 +129,6 @@ function render$1(code, element, init, options = {}) {
|
|
|
129
129
|
if (!element) {
|
|
130
130
|
throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
|
|
131
131
|
}
|
|
132
|
-
const renderRoot = getChildRoot(element);
|
|
133
132
|
let disposer;
|
|
134
133
|
solidJs.createRoot(dispose => {
|
|
135
134
|
disposer = dispose;
|
|
@@ -138,14 +137,14 @@ function render$1(code, element, init, options = {}) {
|
|
|
138
137
|
effect(() => solidJs.flatten(tree), () => {});
|
|
139
138
|
} else {
|
|
140
139
|
const tree = code();
|
|
141
|
-
insert(element, () => tree,
|
|
140
|
+
insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
|
|
142
141
|
}
|
|
143
142
|
}, {
|
|
144
143
|
id: options.renderId
|
|
145
144
|
});
|
|
146
145
|
return () => {
|
|
147
146
|
disposer();
|
|
148
|
-
|
|
147
|
+
element.textContent = "";
|
|
149
148
|
};
|
|
150
149
|
}
|
|
151
150
|
function create(html, bypassGuard, flag) {
|
|
@@ -284,11 +283,10 @@ function ref(fn, element) {
|
|
|
284
283
|
solidJs.runWithOwner(null, () => applyRef(resolved, element));
|
|
285
284
|
}
|
|
286
285
|
function insert(parent, accessor, marker, initial, options) {
|
|
287
|
-
const childRoot = getChildRoot(parent);
|
|
288
286
|
const multi = marker !== undefined;
|
|
289
287
|
if (multi && !initial) initial = [];
|
|
290
288
|
if (isHydrating(parent)) {
|
|
291
|
-
if (!multi && initial === undefined && parent) initial = [...
|
|
289
|
+
if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
|
|
292
290
|
if (Array.isArray(initial)) {
|
|
293
291
|
let j = 0;
|
|
294
292
|
for (let i = 0; i < initial.length; i++) {
|
|
@@ -303,7 +301,7 @@ function insert(parent, accessor, marker, initial, options) {
|
|
|
303
301
|
}
|
|
304
302
|
if (multi && initial.length === 0) {
|
|
305
303
|
const placeholder = document.createTextNode("");
|
|
306
|
-
|
|
304
|
+
parent.insertBefore(placeholder, marker);
|
|
307
305
|
initial = [placeholder];
|
|
308
306
|
}
|
|
309
307
|
let current = initial;
|
|
@@ -358,7 +356,7 @@ function loadModuleAssets(mapping) {
|
|
|
358
356
|
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
359
357
|
}
|
|
360
358
|
function hydrate$1(code, element, options = {}) {
|
|
361
|
-
if (globalThis._$HY.done) return render$1(code, element, [...
|
|
359
|
+
if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
|
|
362
360
|
options.renderId ||= "";
|
|
363
361
|
if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
|
|
364
362
|
if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
|
|
@@ -404,7 +402,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
404
402
|
let disposer;
|
|
405
403
|
p.then(() => {
|
|
406
404
|
try {
|
|
407
|
-
disposer = render$1(code, element, [...
|
|
405
|
+
disposer = render$1(code, element, [...element.childNodes], options);
|
|
408
406
|
} finally {
|
|
409
407
|
solidJs.sharedConfig.hydrating = false;
|
|
410
408
|
}
|
|
@@ -416,7 +414,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
416
414
|
}
|
|
417
415
|
try {
|
|
418
416
|
gatherHydratable(element, options.renderId);
|
|
419
|
-
return render$1(code, element, [...
|
|
417
|
+
return render$1(code, element, [...element.childNodes], options);
|
|
420
418
|
} finally {
|
|
421
419
|
solidJs.sharedConfig.hydrating = false;
|
|
422
420
|
}
|
|
@@ -465,7 +463,7 @@ function getNextMarker(start) {
|
|
|
465
463
|
return [end, current];
|
|
466
464
|
}
|
|
467
465
|
function getFirstChild(node, expectedTag) {
|
|
468
|
-
const child =
|
|
466
|
+
const child = node.firstChild;
|
|
469
467
|
if (isHydrating() && expectedTag && child?.localName !== expectedTag) {
|
|
470
468
|
const isMissing = !child || child.nodeType !== 1;
|
|
471
469
|
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> as first child of", node, "\n " + describeSiblings(node, child, expectedTag, isMissing));
|
|
@@ -484,7 +482,7 @@ function getNextSibling(node, expectedTag) {
|
|
|
484
482
|
function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
|
|
485
483
|
if (!parent) return `<${expectedTag} \u2190 parent unavailable>`;
|
|
486
484
|
const children = [];
|
|
487
|
-
let child =
|
|
485
|
+
let child = parent.firstChild;
|
|
488
486
|
while (child) {
|
|
489
487
|
if (child.nodeType === 1) children.push(child);
|
|
490
488
|
child = child.nextSibling;
|
|
@@ -534,9 +532,6 @@ function runHydrationEvents() {
|
|
|
534
532
|
function isHydrating(node) {
|
|
535
533
|
return solidJs.sharedConfig.hydrating && (!node || node.isConnected);
|
|
536
534
|
}
|
|
537
|
-
function getChildRoot(node) {
|
|
538
|
-
return node && node.localName === "template" ? node.content : node;
|
|
539
|
-
}
|
|
540
535
|
function classListToObject(classList) {
|
|
541
536
|
if (Array.isArray(classList)) {
|
|
542
537
|
const result = {};
|
|
@@ -571,11 +566,7 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
571
566
|
return value;
|
|
572
567
|
}
|
|
573
568
|
const hasNamespace = prop.indexOf(":") > -1;
|
|
574
|
-
if (hasNamespace && prop.slice(0,
|
|
575
|
-
const e = prop.slice(3);
|
|
576
|
-
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
577
|
-
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
578
|
-
} else if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
569
|
+
if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
579
570
|
const name = prop.slice(2).toLowerCase();
|
|
580
571
|
const delegate = DelegatedEvents.has(name);
|
|
581
572
|
if (!delegate && prev) {
|
|
@@ -648,22 +639,21 @@ function eventHandler(e) {
|
|
|
648
639
|
function insertExpression(parent, value, current, marker) {
|
|
649
640
|
if (isHydrating(parent)) return;
|
|
650
641
|
if (value === current) return;
|
|
651
|
-
const childRoot = getChildRoot(parent);
|
|
652
642
|
const t = typeof value,
|
|
653
643
|
multi = marker !== undefined;
|
|
654
644
|
if (t === "string" || t === "number") {
|
|
655
645
|
const tc = typeof current;
|
|
656
646
|
if (tc === "string" || tc === "number") {
|
|
657
|
-
|
|
658
|
-
} else
|
|
647
|
+
parent.firstChild.data = value;
|
|
648
|
+
} else parent.textContent = value;
|
|
659
649
|
} else if (value === undefined) {
|
|
660
650
|
cleanChildren(parent, current, marker);
|
|
661
651
|
} else if (value.nodeType) {
|
|
662
652
|
if (Array.isArray(current)) {
|
|
663
653
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
664
|
-
} else if (current === undefined || !
|
|
665
|
-
|
|
666
|
-
} else
|
|
654
|
+
} else if (current === undefined || !parent.firstChild) {
|
|
655
|
+
parent.appendChild(value);
|
|
656
|
+
} else parent.replaceChild(value, parent.firstChild);
|
|
667
657
|
} else if (Array.isArray(value)) {
|
|
668
658
|
const currentArray = current && Array.isArray(current);
|
|
669
659
|
if (value.length === 0) {
|
|
@@ -671,7 +661,7 @@ function insertExpression(parent, value, current, marker) {
|
|
|
671
661
|
} else if (currentArray) {
|
|
672
662
|
if (current.length === 0) {
|
|
673
663
|
appendNodes(parent, value, marker);
|
|
674
|
-
} else reconcileArrays(
|
|
664
|
+
} else reconcileArrays(parent, current, value);
|
|
675
665
|
} else {
|
|
676
666
|
current && cleanChildren(parent);
|
|
677
667
|
appendNodes(parent, value);
|
|
@@ -696,11 +686,9 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
696
686
|
return value;
|
|
697
687
|
}
|
|
698
688
|
function appendNodes(parent, array, marker = null) {
|
|
699
|
-
parent = getChildRoot(parent);
|
|
700
689
|
for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
|
|
701
690
|
}
|
|
702
691
|
function cleanChildren(parent, current, marker, replacement) {
|
|
703
|
-
parent = getChildRoot(parent);
|
|
704
692
|
if (marker === undefined) return parent.textContent = "";
|
|
705
693
|
if (current.length) {
|
|
706
694
|
let inserted = false;
|
package/dist/dev.js
CHANGED
|
@@ -128,7 +128,6 @@ function render$1(code, element, init, options = {}) {
|
|
|
128
128
|
if (!element) {
|
|
129
129
|
throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
|
|
130
130
|
}
|
|
131
|
-
const renderRoot = getChildRoot(element);
|
|
132
131
|
let disposer;
|
|
133
132
|
createRoot(dispose => {
|
|
134
133
|
disposer = dispose;
|
|
@@ -137,14 +136,14 @@ function render$1(code, element, init, options = {}) {
|
|
|
137
136
|
effect(() => flatten(tree), () => {});
|
|
138
137
|
} else {
|
|
139
138
|
const tree = code();
|
|
140
|
-
insert(element, () => tree,
|
|
139
|
+
insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
|
|
141
140
|
}
|
|
142
141
|
}, {
|
|
143
142
|
id: options.renderId
|
|
144
143
|
});
|
|
145
144
|
return () => {
|
|
146
145
|
disposer();
|
|
147
|
-
|
|
146
|
+
element.textContent = "";
|
|
148
147
|
};
|
|
149
148
|
}
|
|
150
149
|
function create(html, bypassGuard, flag) {
|
|
@@ -283,11 +282,10 @@ function ref(fn, element) {
|
|
|
283
282
|
runWithOwner(null, () => applyRef(resolved, element));
|
|
284
283
|
}
|
|
285
284
|
function insert(parent, accessor, marker, initial, options) {
|
|
286
|
-
const childRoot = getChildRoot(parent);
|
|
287
285
|
const multi = marker !== undefined;
|
|
288
286
|
if (multi && !initial) initial = [];
|
|
289
287
|
if (isHydrating(parent)) {
|
|
290
|
-
if (!multi && initial === undefined && parent) initial = [...
|
|
288
|
+
if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
|
|
291
289
|
if (Array.isArray(initial)) {
|
|
292
290
|
let j = 0;
|
|
293
291
|
for (let i = 0; i < initial.length; i++) {
|
|
@@ -302,7 +300,7 @@ function insert(parent, accessor, marker, initial, options) {
|
|
|
302
300
|
}
|
|
303
301
|
if (multi && initial.length === 0) {
|
|
304
302
|
const placeholder = document.createTextNode("");
|
|
305
|
-
|
|
303
|
+
parent.insertBefore(placeholder, marker);
|
|
306
304
|
initial = [placeholder];
|
|
307
305
|
}
|
|
308
306
|
let current = initial;
|
|
@@ -357,7 +355,7 @@ function loadModuleAssets(mapping) {
|
|
|
357
355
|
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
358
356
|
}
|
|
359
357
|
function hydrate$1(code, element, options = {}) {
|
|
360
|
-
if (globalThis._$HY.done) return render$1(code, element, [...
|
|
358
|
+
if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
|
|
361
359
|
options.renderId ||= "";
|
|
362
360
|
if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
|
|
363
361
|
if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
|
|
@@ -403,7 +401,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
403
401
|
let disposer;
|
|
404
402
|
p.then(() => {
|
|
405
403
|
try {
|
|
406
|
-
disposer = render$1(code, element, [...
|
|
404
|
+
disposer = render$1(code, element, [...element.childNodes], options);
|
|
407
405
|
} finally {
|
|
408
406
|
sharedConfig.hydrating = false;
|
|
409
407
|
}
|
|
@@ -415,7 +413,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
415
413
|
}
|
|
416
414
|
try {
|
|
417
415
|
gatherHydratable(element, options.renderId);
|
|
418
|
-
return render$1(code, element, [...
|
|
416
|
+
return render$1(code, element, [...element.childNodes], options);
|
|
419
417
|
} finally {
|
|
420
418
|
sharedConfig.hydrating = false;
|
|
421
419
|
}
|
|
@@ -464,7 +462,7 @@ function getNextMarker(start) {
|
|
|
464
462
|
return [end, current];
|
|
465
463
|
}
|
|
466
464
|
function getFirstChild(node, expectedTag) {
|
|
467
|
-
const child =
|
|
465
|
+
const child = node.firstChild;
|
|
468
466
|
if (isHydrating() && expectedTag && child?.localName !== expectedTag) {
|
|
469
467
|
const isMissing = !child || child.nodeType !== 1;
|
|
470
468
|
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> as first child of", node, "\n " + describeSiblings(node, child, expectedTag, isMissing));
|
|
@@ -483,7 +481,7 @@ function getNextSibling(node, expectedTag) {
|
|
|
483
481
|
function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
|
|
484
482
|
if (!parent) return `<${expectedTag} \u2190 parent unavailable>`;
|
|
485
483
|
const children = [];
|
|
486
|
-
let child =
|
|
484
|
+
let child = parent.firstChild;
|
|
487
485
|
while (child) {
|
|
488
486
|
if (child.nodeType === 1) children.push(child);
|
|
489
487
|
child = child.nextSibling;
|
|
@@ -533,9 +531,6 @@ function runHydrationEvents() {
|
|
|
533
531
|
function isHydrating(node) {
|
|
534
532
|
return sharedConfig.hydrating && (!node || node.isConnected);
|
|
535
533
|
}
|
|
536
|
-
function getChildRoot(node) {
|
|
537
|
-
return node && node.localName === "template" ? node.content : node;
|
|
538
|
-
}
|
|
539
534
|
function classListToObject(classList) {
|
|
540
535
|
if (Array.isArray(classList)) {
|
|
541
536
|
const result = {};
|
|
@@ -570,11 +565,7 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
570
565
|
return value;
|
|
571
566
|
}
|
|
572
567
|
const hasNamespace = prop.indexOf(":") > -1;
|
|
573
|
-
if (hasNamespace && prop.slice(0,
|
|
574
|
-
const e = prop.slice(3);
|
|
575
|
-
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
576
|
-
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
577
|
-
} else if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
568
|
+
if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
578
569
|
const name = prop.slice(2).toLowerCase();
|
|
579
570
|
const delegate = DelegatedEvents.has(name);
|
|
580
571
|
if (!delegate && prev) {
|
|
@@ -647,22 +638,21 @@ function eventHandler(e) {
|
|
|
647
638
|
function insertExpression(parent, value, current, marker) {
|
|
648
639
|
if (isHydrating(parent)) return;
|
|
649
640
|
if (value === current) return;
|
|
650
|
-
const childRoot = getChildRoot(parent);
|
|
651
641
|
const t = typeof value,
|
|
652
642
|
multi = marker !== undefined;
|
|
653
643
|
if (t === "string" || t === "number") {
|
|
654
644
|
const tc = typeof current;
|
|
655
645
|
if (tc === "string" || tc === "number") {
|
|
656
|
-
|
|
657
|
-
} else
|
|
646
|
+
parent.firstChild.data = value;
|
|
647
|
+
} else parent.textContent = value;
|
|
658
648
|
} else if (value === undefined) {
|
|
659
649
|
cleanChildren(parent, current, marker);
|
|
660
650
|
} else if (value.nodeType) {
|
|
661
651
|
if (Array.isArray(current)) {
|
|
662
652
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
663
|
-
} else if (current === undefined || !
|
|
664
|
-
|
|
665
|
-
} else
|
|
653
|
+
} else if (current === undefined || !parent.firstChild) {
|
|
654
|
+
parent.appendChild(value);
|
|
655
|
+
} else parent.replaceChild(value, parent.firstChild);
|
|
666
656
|
} else if (Array.isArray(value)) {
|
|
667
657
|
const currentArray = current && Array.isArray(current);
|
|
668
658
|
if (value.length === 0) {
|
|
@@ -670,7 +660,7 @@ function insertExpression(parent, value, current, marker) {
|
|
|
670
660
|
} else if (currentArray) {
|
|
671
661
|
if (current.length === 0) {
|
|
672
662
|
appendNodes(parent, value, marker);
|
|
673
|
-
} else reconcileArrays(
|
|
663
|
+
} else reconcileArrays(parent, current, value);
|
|
674
664
|
} else {
|
|
675
665
|
current && cleanChildren(parent);
|
|
676
666
|
appendNodes(parent, value);
|
|
@@ -695,11 +685,9 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
695
685
|
return value;
|
|
696
686
|
}
|
|
697
687
|
function appendNodes(parent, array, marker = null) {
|
|
698
|
-
parent = getChildRoot(parent);
|
|
699
688
|
for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
|
|
700
689
|
}
|
|
701
690
|
function cleanChildren(parent, current, marker, replacement) {
|
|
702
|
-
parent = getChildRoot(parent);
|
|
703
691
|
if (marker === undefined) return parent.textContent = "";
|
|
704
692
|
if (current.length) {
|
|
705
693
|
let inserted = false;
|
package/dist/server.cjs
CHANGED
|
@@ -617,6 +617,19 @@ function ssrFirstGroupHit(hole) {
|
|
|
617
617
|
return buildAsyncWrap(err, hole);
|
|
618
618
|
}
|
|
619
619
|
}
|
|
620
|
+
function tryResolveFunctionHole(hole) {
|
|
621
|
+
let value;
|
|
622
|
+
try {
|
|
623
|
+
value = hole();
|
|
624
|
+
} catch (err) {
|
|
625
|
+
return buildAsyncWrap(err, hole) || "";
|
|
626
|
+
}
|
|
627
|
+
const t = typeof value;
|
|
628
|
+
if (t === "string") return value;
|
|
629
|
+
if (t === "number") return "" + value;
|
|
630
|
+
if (value == null || t === "boolean") return "";
|
|
631
|
+
return tryResolveString(value);
|
|
632
|
+
}
|
|
620
633
|
function mergeTemplateInto(result, node) {
|
|
621
634
|
result.t[result.t.length - 1] += node.t[0];
|
|
622
635
|
if (node.t.length > 1) {
|
|
@@ -625,6 +638,13 @@ function mergeTemplateInto(result, node) {
|
|
|
625
638
|
result.p.push(...node.p);
|
|
626
639
|
}
|
|
627
640
|
}
|
|
641
|
+
function appendResolvedNode(result, node) {
|
|
642
|
+
if (node.fn !== undefined) {
|
|
643
|
+
result.h.push(node.fn);
|
|
644
|
+
result.p.push(node.p);
|
|
645
|
+
result.t.push("");
|
|
646
|
+
} else if (node.merge !== undefined) mergeTemplateInto(result, node.merge);else resolveSSRNode(node.bail, result);
|
|
647
|
+
}
|
|
628
648
|
let _lastGroupFn = null;
|
|
629
649
|
let _lastGroupArr = null;
|
|
630
650
|
let _lastGroupErr = null;
|
|
@@ -715,6 +735,17 @@ function ssr(t) {
|
|
|
715
735
|
}
|
|
716
736
|
} else if (result !== null) {
|
|
717
737
|
resolveSSRNode(hole, result);
|
|
738
|
+
} else if (ht === "function") {
|
|
739
|
+
const r = tryResolveFunctionHole(hole);
|
|
740
|
+
if (typeof r === "string") s += r;else {
|
|
741
|
+
result = {
|
|
742
|
+
t: [s],
|
|
743
|
+
h: [],
|
|
744
|
+
p: []
|
|
745
|
+
};
|
|
746
|
+
s = "";
|
|
747
|
+
appendResolvedNode(result, r);
|
|
748
|
+
}
|
|
718
749
|
} else {
|
|
719
750
|
const r = tryResolveString(hole);
|
|
720
751
|
if (typeof r === "string") {
|
|
@@ -726,11 +757,7 @@ function ssr(t) {
|
|
|
726
757
|
p: []
|
|
727
758
|
};
|
|
728
759
|
s = "";
|
|
729
|
-
|
|
730
|
-
result.h.push(r.fn);
|
|
731
|
-
result.p.push(r.p);
|
|
732
|
-
result.t.push("");
|
|
733
|
-
} else if (r.merge !== undefined) mergeTemplateInto(result, r.merge);else resolveSSRNode(r.bail, result);
|
|
760
|
+
appendResolvedNode(result, r);
|
|
734
761
|
}
|
|
735
762
|
}
|
|
736
763
|
const next = t[i];
|
|
@@ -820,6 +847,8 @@ function escape(s, attr) {
|
|
|
820
847
|
const t = typeof s;
|
|
821
848
|
if (t !== "string") {
|
|
822
849
|
if (!attr && Array.isArray(s)) {
|
|
850
|
+
const joined = tryJoinPlainSSRArray(s);
|
|
851
|
+
if (joined !== undefined) return joined;
|
|
823
852
|
s = s.slice();
|
|
824
853
|
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
825
854
|
return s;
|
|
@@ -872,6 +901,18 @@ function escapeSlow(s, attr, start) {
|
|
|
872
901
|
}
|
|
873
902
|
return left < s.length ? out + s.substring(left) : out;
|
|
874
903
|
}
|
|
904
|
+
function tryJoinPlainSSRArray(nodes) {
|
|
905
|
+
if (nodes.length === 0) return undefined;
|
|
906
|
+
let out = "";
|
|
907
|
+
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
908
|
+
const node = nodes[i];
|
|
909
|
+
if (node == null || typeof node !== "object" || node.h || typeof node.t !== "string") {
|
|
910
|
+
return undefined;
|
|
911
|
+
}
|
|
912
|
+
out += node.t;
|
|
913
|
+
}
|
|
914
|
+
return out;
|
|
915
|
+
}
|
|
875
916
|
function mergeProps(...sources) {
|
|
876
917
|
const target = {};
|
|
877
918
|
for (let i = 0; i < sources.length; i++) {
|
|
@@ -1020,6 +1061,8 @@ function tryResolveString(node) {
|
|
|
1020
1061
|
if (node == null || t === "boolean") return "";
|
|
1021
1062
|
if (t === "object") {
|
|
1022
1063
|
if (Array.isArray(node)) {
|
|
1064
|
+
const joined = tryJoinPlainSSRArray(node);
|
|
1065
|
+
if (joined !== undefined) return joined;
|
|
1023
1066
|
let s = "";
|
|
1024
1067
|
let prevNonObj = false;
|
|
1025
1068
|
for (let i = 0, len = node.length; i < len; i++) {
|
package/dist/server.js
CHANGED
|
@@ -616,6 +616,19 @@ function ssrFirstGroupHit(hole) {
|
|
|
616
616
|
return buildAsyncWrap(err, hole);
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
|
+
function tryResolveFunctionHole(hole) {
|
|
620
|
+
let value;
|
|
621
|
+
try {
|
|
622
|
+
value = hole();
|
|
623
|
+
} catch (err) {
|
|
624
|
+
return buildAsyncWrap(err, hole) || "";
|
|
625
|
+
}
|
|
626
|
+
const t = typeof value;
|
|
627
|
+
if (t === "string") return value;
|
|
628
|
+
if (t === "number") return "" + value;
|
|
629
|
+
if (value == null || t === "boolean") return "";
|
|
630
|
+
return tryResolveString(value);
|
|
631
|
+
}
|
|
619
632
|
function mergeTemplateInto(result, node) {
|
|
620
633
|
result.t[result.t.length - 1] += node.t[0];
|
|
621
634
|
if (node.t.length > 1) {
|
|
@@ -624,6 +637,13 @@ function mergeTemplateInto(result, node) {
|
|
|
624
637
|
result.p.push(...node.p);
|
|
625
638
|
}
|
|
626
639
|
}
|
|
640
|
+
function appendResolvedNode(result, node) {
|
|
641
|
+
if (node.fn !== undefined) {
|
|
642
|
+
result.h.push(node.fn);
|
|
643
|
+
result.p.push(node.p);
|
|
644
|
+
result.t.push("");
|
|
645
|
+
} else if (node.merge !== undefined) mergeTemplateInto(result, node.merge);else resolveSSRNode(node.bail, result);
|
|
646
|
+
}
|
|
627
647
|
let _lastGroupFn = null;
|
|
628
648
|
let _lastGroupArr = null;
|
|
629
649
|
let _lastGroupErr = null;
|
|
@@ -714,6 +734,17 @@ function ssr(t) {
|
|
|
714
734
|
}
|
|
715
735
|
} else if (result !== null) {
|
|
716
736
|
resolveSSRNode(hole, result);
|
|
737
|
+
} else if (ht === "function") {
|
|
738
|
+
const r = tryResolveFunctionHole(hole);
|
|
739
|
+
if (typeof r === "string") s += r;else {
|
|
740
|
+
result = {
|
|
741
|
+
t: [s],
|
|
742
|
+
h: [],
|
|
743
|
+
p: []
|
|
744
|
+
};
|
|
745
|
+
s = "";
|
|
746
|
+
appendResolvedNode(result, r);
|
|
747
|
+
}
|
|
717
748
|
} else {
|
|
718
749
|
const r = tryResolveString(hole);
|
|
719
750
|
if (typeof r === "string") {
|
|
@@ -725,11 +756,7 @@ function ssr(t) {
|
|
|
725
756
|
p: []
|
|
726
757
|
};
|
|
727
758
|
s = "";
|
|
728
|
-
|
|
729
|
-
result.h.push(r.fn);
|
|
730
|
-
result.p.push(r.p);
|
|
731
|
-
result.t.push("");
|
|
732
|
-
} else if (r.merge !== undefined) mergeTemplateInto(result, r.merge);else resolveSSRNode(r.bail, result);
|
|
759
|
+
appendResolvedNode(result, r);
|
|
733
760
|
}
|
|
734
761
|
}
|
|
735
762
|
const next = t[i];
|
|
@@ -819,6 +846,8 @@ function escape(s, attr) {
|
|
|
819
846
|
const t = typeof s;
|
|
820
847
|
if (t !== "string") {
|
|
821
848
|
if (!attr && Array.isArray(s)) {
|
|
849
|
+
const joined = tryJoinPlainSSRArray(s);
|
|
850
|
+
if (joined !== undefined) return joined;
|
|
822
851
|
s = s.slice();
|
|
823
852
|
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
824
853
|
return s;
|
|
@@ -871,6 +900,18 @@ function escapeSlow(s, attr, start) {
|
|
|
871
900
|
}
|
|
872
901
|
return left < s.length ? out + s.substring(left) : out;
|
|
873
902
|
}
|
|
903
|
+
function tryJoinPlainSSRArray(nodes) {
|
|
904
|
+
if (nodes.length === 0) return undefined;
|
|
905
|
+
let out = "";
|
|
906
|
+
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
907
|
+
const node = nodes[i];
|
|
908
|
+
if (node == null || typeof node !== "object" || node.h || typeof node.t !== "string") {
|
|
909
|
+
return undefined;
|
|
910
|
+
}
|
|
911
|
+
out += node.t;
|
|
912
|
+
}
|
|
913
|
+
return out;
|
|
914
|
+
}
|
|
874
915
|
function mergeProps(...sources) {
|
|
875
916
|
const target = {};
|
|
876
917
|
for (let i = 0; i < sources.length; i++) {
|
|
@@ -1019,6 +1060,8 @@ function tryResolveString(node) {
|
|
|
1019
1060
|
if (node == null || t === "boolean") return "";
|
|
1020
1061
|
if (t === "object") {
|
|
1021
1062
|
if (Array.isArray(node)) {
|
|
1063
|
+
const joined = tryJoinPlainSSRArray(node);
|
|
1064
|
+
if (joined !== undefined) return joined;
|
|
1022
1065
|
let s = "";
|
|
1023
1066
|
let prevNonObj = false;
|
|
1024
1067
|
for (let i = 0, len = node.length; i < len; i++) {
|
package/dist/web.cjs
CHANGED
|
@@ -126,7 +126,6 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
126
126
|
const $$EVENTS = "_$DX_DELEGATE";
|
|
127
127
|
const INNER_OWNED = {};
|
|
128
128
|
function render$1(code, element, init, options = {}) {
|
|
129
|
-
const renderRoot = getChildRoot(element);
|
|
130
129
|
let disposer;
|
|
131
130
|
solidJs.createRoot(dispose => {
|
|
132
131
|
disposer = dispose;
|
|
@@ -135,14 +134,14 @@ function render$1(code, element, init, options = {}) {
|
|
|
135
134
|
effect(() => solidJs.flatten(tree), () => {});
|
|
136
135
|
} else {
|
|
137
136
|
const tree = code();
|
|
138
|
-
insert(element, () => tree,
|
|
137
|
+
insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
|
|
139
138
|
}
|
|
140
139
|
}, {
|
|
141
140
|
id: options.renderId
|
|
142
141
|
});
|
|
143
142
|
return () => {
|
|
144
143
|
disposer();
|
|
145
|
-
|
|
144
|
+
element.textContent = "";
|
|
146
145
|
};
|
|
147
146
|
}
|
|
148
147
|
function create(html, bypassGuard, flag) {
|
|
@@ -279,11 +278,10 @@ function ref(fn, element) {
|
|
|
279
278
|
solidJs.runWithOwner(null, () => applyRef(resolved, element));
|
|
280
279
|
}
|
|
281
280
|
function insert(parent, accessor, marker, initial, options) {
|
|
282
|
-
const childRoot = getChildRoot(parent);
|
|
283
281
|
const multi = marker !== undefined;
|
|
284
282
|
if (multi && !initial) initial = [];
|
|
285
283
|
if (isHydrating(parent)) {
|
|
286
|
-
if (!multi && initial === undefined && parent) initial = [...
|
|
284
|
+
if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
|
|
287
285
|
if (Array.isArray(initial)) {
|
|
288
286
|
let j = 0;
|
|
289
287
|
for (let i = 0; i < initial.length; i++) {
|
|
@@ -298,7 +296,7 @@ function insert(parent, accessor, marker, initial, options) {
|
|
|
298
296
|
}
|
|
299
297
|
if (multi && initial.length === 0) {
|
|
300
298
|
const placeholder = document.createTextNode("");
|
|
301
|
-
|
|
299
|
+
parent.insertBefore(placeholder, marker);
|
|
302
300
|
initial = [placeholder];
|
|
303
301
|
}
|
|
304
302
|
let current = initial;
|
|
@@ -353,7 +351,7 @@ function loadModuleAssets(mapping) {
|
|
|
353
351
|
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
354
352
|
}
|
|
355
353
|
function hydrate$1(code, element, options = {}) {
|
|
356
|
-
if (globalThis._$HY.done) return render$1(code, element, [...
|
|
354
|
+
if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
|
|
357
355
|
options.renderId ||= "";
|
|
358
356
|
if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
|
|
359
357
|
if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
|
|
@@ -389,7 +387,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
389
387
|
let disposer;
|
|
390
388
|
p.then(() => {
|
|
391
389
|
try {
|
|
392
|
-
disposer = render$1(code, element, [...
|
|
390
|
+
disposer = render$1(code, element, [...element.childNodes], options);
|
|
393
391
|
} finally {
|
|
394
392
|
solidJs.sharedConfig.hydrating = false;
|
|
395
393
|
}
|
|
@@ -401,7 +399,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
401
399
|
}
|
|
402
400
|
try {
|
|
403
401
|
gatherHydratable(element, options.renderId);
|
|
404
|
-
return render$1(code, element, [...
|
|
402
|
+
return render$1(code, element, [...element.childNodes], options);
|
|
405
403
|
} finally {
|
|
406
404
|
solidJs.sharedConfig.hydrating = false;
|
|
407
405
|
}
|
|
@@ -444,7 +442,7 @@ function getNextMarker(start) {
|
|
|
444
442
|
return [end, current];
|
|
445
443
|
}
|
|
446
444
|
function getFirstChild(node, expectedTag) {
|
|
447
|
-
const child =
|
|
445
|
+
const child = node.firstChild;
|
|
448
446
|
return child;
|
|
449
447
|
}
|
|
450
448
|
function getNextSibling(node, expectedTag) {
|
|
@@ -477,9 +475,6 @@ function runHydrationEvents() {
|
|
|
477
475
|
function isHydrating(node) {
|
|
478
476
|
return solidJs.sharedConfig.hydrating && (!node || node.isConnected);
|
|
479
477
|
}
|
|
480
|
-
function getChildRoot(node) {
|
|
481
|
-
return node && node.localName === "template" ? node.content : node;
|
|
482
|
-
}
|
|
483
478
|
function classListToObject(classList) {
|
|
484
479
|
if (Array.isArray(classList)) {
|
|
485
480
|
const result = {};
|
|
@@ -514,11 +509,7 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
514
509
|
return value;
|
|
515
510
|
}
|
|
516
511
|
const hasNamespace = prop.indexOf(":") > -1;
|
|
517
|
-
if (hasNamespace && prop.slice(0,
|
|
518
|
-
const e = prop.slice(3);
|
|
519
|
-
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
520
|
-
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
521
|
-
} else if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
512
|
+
if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
522
513
|
const name = prop.slice(2).toLowerCase();
|
|
523
514
|
const delegate = DelegatedEvents.has(name);
|
|
524
515
|
if (!delegate && prev) {
|
|
@@ -591,22 +582,21 @@ function eventHandler(e) {
|
|
|
591
582
|
function insertExpression(parent, value, current, marker) {
|
|
592
583
|
if (isHydrating(parent)) return;
|
|
593
584
|
if (value === current) return;
|
|
594
|
-
const childRoot = getChildRoot(parent);
|
|
595
585
|
const t = typeof value,
|
|
596
586
|
multi = marker !== undefined;
|
|
597
587
|
if (t === "string" || t === "number") {
|
|
598
588
|
const tc = typeof current;
|
|
599
589
|
if (tc === "string" || tc === "number") {
|
|
600
|
-
|
|
601
|
-
} else
|
|
590
|
+
parent.firstChild.data = value;
|
|
591
|
+
} else parent.textContent = value;
|
|
602
592
|
} else if (value === undefined) {
|
|
603
593
|
cleanChildren(parent, current, marker);
|
|
604
594
|
} else if (value.nodeType) {
|
|
605
595
|
if (Array.isArray(current)) {
|
|
606
596
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
607
|
-
} else if (current === undefined || !
|
|
608
|
-
|
|
609
|
-
} else
|
|
597
|
+
} else if (current === undefined || !parent.firstChild) {
|
|
598
|
+
parent.appendChild(value);
|
|
599
|
+
} else parent.replaceChild(value, parent.firstChild);
|
|
610
600
|
} else if (Array.isArray(value)) {
|
|
611
601
|
const currentArray = current && Array.isArray(current);
|
|
612
602
|
if (value.length === 0) {
|
|
@@ -614,7 +604,7 @@ function insertExpression(parent, value, current, marker) {
|
|
|
614
604
|
} else if (currentArray) {
|
|
615
605
|
if (current.length === 0) {
|
|
616
606
|
appendNodes(parent, value, marker);
|
|
617
|
-
} else reconcileArrays(
|
|
607
|
+
} else reconcileArrays(parent, current, value);
|
|
618
608
|
} else {
|
|
619
609
|
current && cleanChildren(parent);
|
|
620
610
|
appendNodes(parent, value);
|
|
@@ -639,11 +629,9 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
639
629
|
return value;
|
|
640
630
|
}
|
|
641
631
|
function appendNodes(parent, array, marker = null) {
|
|
642
|
-
parent = getChildRoot(parent);
|
|
643
632
|
for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
|
|
644
633
|
}
|
|
645
634
|
function cleanChildren(parent, current, marker, replacement) {
|
|
646
|
-
parent = getChildRoot(parent);
|
|
647
635
|
if (marker === undefined) return parent.textContent = "";
|
|
648
636
|
if (current.length) {
|
|
649
637
|
let inserted = false;
|