solid-js 1.8.18 → 1.8.20
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 +34 -29
- package/dist/dev.js +47 -42
- package/dist/server.cjs +33 -11
- package/dist/server.js +34 -11
- package/dist/solid.cjs +34 -29
- package/dist/solid.js +44 -39
- package/package.json +3 -3
- package/types/jsx.d.ts +913 -862
- package/types/render/hydration.d.ts +2 -0
- package/types/server/rendering.d.ts +2 -0
- package/web/dist/dev.cjs +36 -21
- package/web/dist/dev.js +37 -24
- package/web/dist/server.cjs +4 -4
- package/web/dist/server.js +4 -4
- package/web/dist/web.cjs +34 -19
- package/web/dist/web.js +35 -22
|
@@ -15,6 +15,8 @@ type SharedConfig = {
|
|
|
15
15
|
done?: boolean;
|
|
16
16
|
count?: number;
|
|
17
17
|
effects?: Computation<any, any>[];
|
|
18
|
+
getContextId(): string;
|
|
19
|
+
getNextContextId(): string;
|
|
18
20
|
};
|
|
19
21
|
export declare const sharedConfig: SharedConfig;
|
|
20
22
|
export declare function setHydrateContext(context?: HydrationContext): void;
|
|
@@ -22,6 +22,8 @@ export type ComponentProps<T extends ValidComponent> = T extends Component<infer
|
|
|
22
22
|
: Record<string, unknown>;
|
|
23
23
|
type SharedConfig = {
|
|
24
24
|
context?: HydrationContext;
|
|
25
|
+
getContextId(): string;
|
|
26
|
+
getNextContextId(): string;
|
|
25
27
|
};
|
|
26
28
|
export declare const sharedConfig: SharedConfig;
|
|
27
29
|
export declare function createUniqueId(): string;
|
package/web/dist/dev.cjs
CHANGED
|
@@ -125,7 +125,7 @@ function render(code, element, init, options = {}) {
|
|
|
125
125
|
function template(html, isCE, isSVG) {
|
|
126
126
|
let node;
|
|
127
127
|
const create = () => {
|
|
128
|
-
if (
|
|
128
|
+
if (isHydrating()) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
|
|
129
129
|
const t = document.createElement("template");
|
|
130
130
|
t.innerHTML = html;
|
|
131
131
|
return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
@@ -151,19 +151,19 @@ function clearDelegatedEvents(document = window.document) {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
function setProperty(node, name, value) {
|
|
154
|
-
if (
|
|
154
|
+
if (isHydrating(node)) return;
|
|
155
155
|
node[name] = value;
|
|
156
156
|
}
|
|
157
157
|
function setAttribute(node, name, value) {
|
|
158
|
-
if (
|
|
158
|
+
if (isHydrating(node)) return;
|
|
159
159
|
if (value == null) node.removeAttribute(name);else node.setAttribute(name, value);
|
|
160
160
|
}
|
|
161
161
|
function setAttributeNS(node, namespace, name, value) {
|
|
162
|
-
if (
|
|
162
|
+
if (isHydrating(node)) return;
|
|
163
163
|
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
164
164
|
}
|
|
165
165
|
function className(node, value) {
|
|
166
|
-
if (
|
|
166
|
+
if (isHydrating(node)) return;
|
|
167
167
|
if (value == null) node.removeAttribute("class");else node.className = value;
|
|
168
168
|
}
|
|
169
169
|
function addEventListener(node, name, handler, delegate) {
|
|
@@ -222,7 +222,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
222
222
|
if (!skipChildren) {
|
|
223
223
|
solidJs.createRenderEffect(() => prevProps.children = insertExpression(node, props.children, prevProps.children));
|
|
224
224
|
}
|
|
225
|
-
solidJs.createRenderEffect(() => typeof props.ref === "function"
|
|
225
|
+
solidJs.createRenderEffect(() => typeof props.ref === "function" && use(props.ref, node));
|
|
226
226
|
solidJs.createRenderEffect(() => assign(node, props, isSVG, true, prevProps, true));
|
|
227
227
|
return prevProps;
|
|
228
228
|
}
|
|
@@ -266,21 +266,26 @@ function hydrate$1(code, element, options = {}) {
|
|
|
266
266
|
solidJs.sharedConfig.events = globalThis._$HY.events;
|
|
267
267
|
solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
|
|
268
268
|
solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
|
|
269
|
+
solidJs.sharedConfig.done = globalThis._$HY.done;
|
|
269
270
|
solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
|
|
270
271
|
solidJs.sharedConfig.registry = new Map();
|
|
271
272
|
solidJs.sharedConfig.context = {
|
|
272
273
|
id: options.renderId || "",
|
|
273
274
|
count: 0
|
|
274
275
|
};
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
276
|
+
try {
|
|
277
|
+
gatherHydratable(element, options.renderId);
|
|
278
|
+
return render(code, element, [...element.childNodes], options);
|
|
279
|
+
} finally {
|
|
280
|
+
solidJs.sharedConfig.context = null;
|
|
281
|
+
}
|
|
279
282
|
}
|
|
280
283
|
function getNextElement(template) {
|
|
281
|
-
let node,
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
let node,
|
|
285
|
+
key,
|
|
286
|
+
hydrating = isHydrating();
|
|
287
|
+
if (!hydrating || !(node = solidJs.sharedConfig.registry.get(key = getHydrationKey()))) {
|
|
288
|
+
if (hydrating) throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}`);
|
|
284
289
|
return template();
|
|
285
290
|
}
|
|
286
291
|
if (solidJs.sharedConfig.completed) solidJs.sharedConfig.completed.add(node);
|
|
@@ -295,7 +300,7 @@ function getNextMarker(start) {
|
|
|
295
300
|
let end = start,
|
|
296
301
|
count = 0,
|
|
297
302
|
current = [];
|
|
298
|
-
if (
|
|
303
|
+
if (isHydrating(start)) {
|
|
299
304
|
while (end) {
|
|
300
305
|
if (end.nodeType === 8) {
|
|
301
306
|
const v = end.nodeValue;
|
|
@@ -321,13 +326,20 @@ function runHydrationEvents() {
|
|
|
321
326
|
while (events.length) {
|
|
322
327
|
const [el, e] = events[0];
|
|
323
328
|
if (!completed.has(el)) return;
|
|
324
|
-
eventHandler(e);
|
|
325
329
|
events.shift();
|
|
330
|
+
eventHandler(e);
|
|
331
|
+
}
|
|
332
|
+
if (solidJs.sharedConfig.done) {
|
|
333
|
+
solidJs.sharedConfig.events = _$HY.events = null;
|
|
334
|
+
solidJs.sharedConfig.completed = _$HY.completed = null;
|
|
326
335
|
}
|
|
327
336
|
});
|
|
328
337
|
solidJs.sharedConfig.events.queued = true;
|
|
329
338
|
}
|
|
330
339
|
}
|
|
340
|
+
function isHydrating(node) {
|
|
341
|
+
return !!solidJs.sharedConfig.context && !solidJs.sharedConfig.done && (!node || node.isConnected);
|
|
342
|
+
}
|
|
331
343
|
function toPropertyName(name) {
|
|
332
344
|
return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
|
|
333
345
|
}
|
|
@@ -367,7 +379,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
367
379
|
if (forceProp) {
|
|
368
380
|
prop = prop.slice(5);
|
|
369
381
|
isProp = true;
|
|
370
|
-
} else if (
|
|
382
|
+
} else if (isHydrating(node)) return value;
|
|
371
383
|
if (prop === "class" || prop === "className") className(node, value);else if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[propAlias || prop] = value;
|
|
372
384
|
} else {
|
|
373
385
|
const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
|
|
@@ -376,6 +388,9 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
376
388
|
return value;
|
|
377
389
|
}
|
|
378
390
|
function eventHandler(e) {
|
|
391
|
+
if (solidJs.sharedConfig.registry && solidJs.sharedConfig.events) {
|
|
392
|
+
if (solidJs.sharedConfig.events.find(([el, ev]) => ev === e)) return;
|
|
393
|
+
}
|
|
379
394
|
const key = `$$${e.type}`;
|
|
380
395
|
let node = e.composedPath && e.composedPath()[0] || e.target;
|
|
381
396
|
if (e.target !== node) {
|
|
@@ -402,7 +417,7 @@ function eventHandler(e) {
|
|
|
402
417
|
}
|
|
403
418
|
}
|
|
404
419
|
function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
405
|
-
const hydrating =
|
|
420
|
+
const hydrating = isHydrating(parent);
|
|
406
421
|
if (hydrating) {
|
|
407
422
|
!current && (current = [...parent.childNodes]);
|
|
408
423
|
let cleaned = [];
|
|
@@ -453,9 +468,10 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
453
468
|
}
|
|
454
469
|
if (hydrating) {
|
|
455
470
|
if (!array.length) return current;
|
|
456
|
-
if (marker === undefined) return [...parent.childNodes];
|
|
471
|
+
if (marker === undefined) return current = [...parent.childNodes];
|
|
457
472
|
let node = array[0];
|
|
458
|
-
|
|
473
|
+
if (node.parentNode !== parent) return current;
|
|
474
|
+
const nodes = [node];
|
|
459
475
|
while ((node = node.nextSibling) !== marker) nodes.push(node);
|
|
460
476
|
return current = nodes;
|
|
461
477
|
}
|
|
@@ -535,8 +551,7 @@ function gatherHydratable(element, root) {
|
|
|
535
551
|
}
|
|
536
552
|
}
|
|
537
553
|
function getHydrationKey() {
|
|
538
|
-
|
|
539
|
-
return `${hydrate.id}${hydrate.count++}`;
|
|
554
|
+
return solidJs.sharedConfig.getNextContextId();
|
|
540
555
|
}
|
|
541
556
|
function NoHydration(props) {
|
|
542
557
|
return solidJs.sharedConfig.context ? undefined : props.children;
|
package/web/dist/dev.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRoot,
|
|
3
|
-
sharedConfig,
|
|
4
3
|
createRenderEffect,
|
|
5
4
|
untrack,
|
|
5
|
+
sharedConfig,
|
|
6
6
|
enableHydration,
|
|
7
7
|
getOwner,
|
|
8
8
|
createEffect,
|
|
@@ -574,7 +574,7 @@ function render(code, element, init, options = {}) {
|
|
|
574
574
|
function template(html, isCE, isSVG) {
|
|
575
575
|
let node;
|
|
576
576
|
const create = () => {
|
|
577
|
-
if (
|
|
577
|
+
if (isHydrating())
|
|
578
578
|
throw new Error(
|
|
579
579
|
"Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration."
|
|
580
580
|
);
|
|
@@ -605,21 +605,21 @@ function clearDelegatedEvents(document = window.document) {
|
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
607
|
function setProperty(node, name, value) {
|
|
608
|
-
if (
|
|
608
|
+
if (isHydrating(node)) return;
|
|
609
609
|
node[name] = value;
|
|
610
610
|
}
|
|
611
611
|
function setAttribute(node, name, value) {
|
|
612
|
-
if (
|
|
612
|
+
if (isHydrating(node)) return;
|
|
613
613
|
if (value == null) node.removeAttribute(name);
|
|
614
614
|
else node.setAttribute(name, value);
|
|
615
615
|
}
|
|
616
616
|
function setAttributeNS(node, namespace, name, value) {
|
|
617
|
-
if (
|
|
617
|
+
if (isHydrating(node)) return;
|
|
618
618
|
if (value == null) node.removeAttributeNS(namespace, name);
|
|
619
619
|
else node.setAttributeNS(namespace, name, value);
|
|
620
620
|
}
|
|
621
621
|
function className(node, value) {
|
|
622
|
-
if (
|
|
622
|
+
if (isHydrating(node)) return;
|
|
623
623
|
if (value == null) node.removeAttribute("class");
|
|
624
624
|
else node.className = value;
|
|
625
625
|
}
|
|
@@ -681,9 +681,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
681
681
|
() => (prevProps.children = insertExpression(node, props.children, prevProps.children))
|
|
682
682
|
);
|
|
683
683
|
}
|
|
684
|
-
createRenderEffect(() =>
|
|
685
|
-
typeof props.ref === "function" ? use(props.ref, node) : (props.ref = node)
|
|
686
|
-
);
|
|
684
|
+
createRenderEffect(() => typeof props.ref === "function" && use(props.ref, node));
|
|
687
685
|
createRenderEffect(() => assign(node, props, isSVG, true, prevProps, true));
|
|
688
686
|
return prevProps;
|
|
689
687
|
}
|
|
@@ -727,21 +725,26 @@ function hydrate$1(code, element, options = {}) {
|
|
|
727
725
|
sharedConfig.events = globalThis._$HY.events;
|
|
728
726
|
sharedConfig.load = id => globalThis._$HY.r[id];
|
|
729
727
|
sharedConfig.has = id => id in globalThis._$HY.r;
|
|
728
|
+
sharedConfig.done = globalThis._$HY.done;
|
|
730
729
|
sharedConfig.gather = root => gatherHydratable(element, root);
|
|
731
730
|
sharedConfig.registry = new Map();
|
|
732
731
|
sharedConfig.context = {
|
|
733
732
|
id: options.renderId || "",
|
|
734
733
|
count: 0
|
|
735
734
|
};
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
735
|
+
try {
|
|
736
|
+
gatherHydratable(element, options.renderId);
|
|
737
|
+
return render(code, element, [...element.childNodes], options);
|
|
738
|
+
} finally {
|
|
739
|
+
sharedConfig.context = null;
|
|
740
|
+
}
|
|
740
741
|
}
|
|
741
742
|
function getNextElement(template) {
|
|
742
|
-
let node,
|
|
743
|
-
|
|
744
|
-
|
|
743
|
+
let node,
|
|
744
|
+
key,
|
|
745
|
+
hydrating = isHydrating();
|
|
746
|
+
if (!hydrating || !(node = sharedConfig.registry.get((key = getHydrationKey())))) {
|
|
747
|
+
if (hydrating)
|
|
745
748
|
throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}`);
|
|
746
749
|
return template();
|
|
747
750
|
}
|
|
@@ -757,7 +760,7 @@ function getNextMarker(start) {
|
|
|
757
760
|
let end = start,
|
|
758
761
|
count = 0,
|
|
759
762
|
current = [];
|
|
760
|
-
if (
|
|
763
|
+
if (isHydrating(start)) {
|
|
761
764
|
while (end) {
|
|
762
765
|
if (end.nodeType === 8) {
|
|
763
766
|
const v = end.nodeValue;
|
|
@@ -781,13 +784,20 @@ function runHydrationEvents() {
|
|
|
781
784
|
while (events.length) {
|
|
782
785
|
const [el, e] = events[0];
|
|
783
786
|
if (!completed.has(el)) return;
|
|
784
|
-
eventHandler(e);
|
|
785
787
|
events.shift();
|
|
788
|
+
eventHandler(e);
|
|
789
|
+
}
|
|
790
|
+
if (sharedConfig.done) {
|
|
791
|
+
sharedConfig.events = _$HY.events = null;
|
|
792
|
+
sharedConfig.completed = _$HY.completed = null;
|
|
786
793
|
}
|
|
787
794
|
});
|
|
788
795
|
sharedConfig.events.queued = true;
|
|
789
796
|
}
|
|
790
797
|
}
|
|
798
|
+
function isHydrating(node) {
|
|
799
|
+
return !!sharedConfig.context && !sharedConfig.done && (!node || node.isConnected);
|
|
800
|
+
}
|
|
791
801
|
function toPropertyName(name) {
|
|
792
802
|
return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
|
|
793
803
|
}
|
|
@@ -834,7 +844,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
834
844
|
if (forceProp) {
|
|
835
845
|
prop = prop.slice(5);
|
|
836
846
|
isProp = true;
|
|
837
|
-
} else if (
|
|
847
|
+
} else if (isHydrating(node)) return value;
|
|
838
848
|
if (prop === "class" || prop === "className") className(node, value);
|
|
839
849
|
else if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;
|
|
840
850
|
else node[propAlias || prop] = value;
|
|
@@ -846,6 +856,9 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
846
856
|
return value;
|
|
847
857
|
}
|
|
848
858
|
function eventHandler(e) {
|
|
859
|
+
if (sharedConfig.registry && sharedConfig.events) {
|
|
860
|
+
if (sharedConfig.events.find(([el, ev]) => ev === e)) return;
|
|
861
|
+
}
|
|
849
862
|
const key = `$$${e.type}`;
|
|
850
863
|
let node = (e.composedPath && e.composedPath()[0]) || e.target;
|
|
851
864
|
if (e.target !== node) {
|
|
@@ -872,7 +885,7 @@ function eventHandler(e) {
|
|
|
872
885
|
}
|
|
873
886
|
}
|
|
874
887
|
function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
875
|
-
const hydrating =
|
|
888
|
+
const hydrating = isHydrating(parent);
|
|
876
889
|
if (hydrating) {
|
|
877
890
|
!current && (current = [...parent.childNodes]);
|
|
878
891
|
let cleaned = [];
|
|
@@ -924,9 +937,10 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
924
937
|
}
|
|
925
938
|
if (hydrating) {
|
|
926
939
|
if (!array.length) return current;
|
|
927
|
-
if (marker === undefined) return [...parent.childNodes];
|
|
940
|
+
if (marker === undefined) return (current = [...parent.childNodes]);
|
|
928
941
|
let node = array[0];
|
|
929
|
-
|
|
942
|
+
if (node.parentNode !== parent) return current;
|
|
943
|
+
const nodes = [node];
|
|
930
944
|
while ((node = node.nextSibling) !== marker) nodes.push(node);
|
|
931
945
|
return (current = nodes);
|
|
932
946
|
}
|
|
@@ -1016,8 +1030,7 @@ function gatherHydratable(element, root) {
|
|
|
1016
1030
|
}
|
|
1017
1031
|
}
|
|
1018
1032
|
function getHydrationKey() {
|
|
1019
|
-
|
|
1020
|
-
return `${hydrate.id}${hydrate.count++}`;
|
|
1033
|
+
return sharedConfig.getNextContextId();
|
|
1021
1034
|
}
|
|
1022
1035
|
function NoHydration(props) {
|
|
1023
1036
|
return sharedConfig.context ? undefined : props.children;
|
package/web/dist/server.cjs
CHANGED
|
@@ -400,7 +400,7 @@ function ssrAttribute(key, value, isBoolean) {
|
|
|
400
400
|
}
|
|
401
401
|
function ssrHydrationKey() {
|
|
402
402
|
const hk = getHydrationKey();
|
|
403
|
-
return hk ? ` data-hk
|
|
403
|
+
return hk ? ` data-hk=${hk}` : "";
|
|
404
404
|
}
|
|
405
405
|
function escape(s, attr) {
|
|
406
406
|
const t = typeof s;
|
|
@@ -467,7 +467,7 @@ function resolveSSRNode(node, top) {
|
|
|
467
467
|
}
|
|
468
468
|
function getHydrationKey() {
|
|
469
469
|
const hydrate = solidJs.sharedConfig.context;
|
|
470
|
-
return hydrate && !hydrate.noHydrate &&
|
|
470
|
+
return hydrate && !hydrate.noHydrate && solidJs.sharedConfig.getNextContextId();
|
|
471
471
|
}
|
|
472
472
|
function useAssets(fn) {
|
|
473
473
|
solidJs.sharedConfig.context.assets.push(() => resolveSSRNode(fn()));
|
|
@@ -482,7 +482,7 @@ function generateHydrationScript({
|
|
|
482
482
|
eventNames = ["click", "input"],
|
|
483
483
|
nonce
|
|
484
484
|
} = {}) {
|
|
485
|
-
return `<script${nonce ? ` nonce="${nonce}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('", "')}"].forEach((o=>document.addEventListener(o,(o=>{let
|
|
485
|
+
return `<script${nonce ? ` nonce="${nonce}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('", "')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
|
|
486
486
|
}
|
|
487
487
|
function Hydration(props) {
|
|
488
488
|
if (!solidJs.sharedConfig.context.noHydrate) return props.children;
|
|
@@ -490,7 +490,7 @@ function Hydration(props) {
|
|
|
490
490
|
solidJs.sharedConfig.context = {
|
|
491
491
|
...context,
|
|
492
492
|
count: 0,
|
|
493
|
-
id:
|
|
493
|
+
id: solidJs.sharedConfig.getNextContextId(),
|
|
494
494
|
noHydrate: false
|
|
495
495
|
};
|
|
496
496
|
const res = props.children;
|
package/web/dist/server.js
CHANGED
|
@@ -465,7 +465,7 @@ function ssrAttribute(key, value, isBoolean) {
|
|
|
465
465
|
}
|
|
466
466
|
function ssrHydrationKey() {
|
|
467
467
|
const hk = getHydrationKey();
|
|
468
|
-
return hk ? ` data-hk
|
|
468
|
+
return hk ? ` data-hk=${hk}` : "";
|
|
469
469
|
}
|
|
470
470
|
function escape(s, attr) {
|
|
471
471
|
const t = typeof s;
|
|
@@ -533,7 +533,7 @@ function resolveSSRNode(node, top) {
|
|
|
533
533
|
}
|
|
534
534
|
function getHydrationKey() {
|
|
535
535
|
const hydrate = sharedConfig.context;
|
|
536
|
-
return hydrate && !hydrate.noHydrate &&
|
|
536
|
+
return hydrate && !hydrate.noHydrate && sharedConfig.getNextContextId();
|
|
537
537
|
}
|
|
538
538
|
function useAssets(fn) {
|
|
539
539
|
sharedConfig.context.assets.push(() => resolveSSRNode(fn()));
|
|
@@ -549,7 +549,7 @@ function generateHydrationScript({ eventNames = ["click", "input"], nonce } = {}
|
|
|
549
549
|
nonce ? ` nonce="${nonce}"` : ""
|
|
550
550
|
}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join(
|
|
551
551
|
'", "'
|
|
552
|
-
)}"].forEach((o=>document.addEventListener(o,(o=>{let
|
|
552
|
+
)}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
|
|
553
553
|
}
|
|
554
554
|
function Hydration(props) {
|
|
555
555
|
if (!sharedConfig.context.noHydrate) return props.children;
|
|
@@ -557,7 +557,7 @@ function Hydration(props) {
|
|
|
557
557
|
sharedConfig.context = {
|
|
558
558
|
...context,
|
|
559
559
|
count: 0,
|
|
560
|
-
id:
|
|
560
|
+
id: sharedConfig.getNextContextId(),
|
|
561
561
|
noHydrate: false
|
|
562
562
|
};
|
|
563
563
|
const res = props.children;
|
package/web/dist/web.cjs
CHANGED
|
@@ -147,19 +147,19 @@ function clearDelegatedEvents(document = window.document) {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
function setProperty(node, name, value) {
|
|
150
|
-
if (
|
|
150
|
+
if (isHydrating(node)) return;
|
|
151
151
|
node[name] = value;
|
|
152
152
|
}
|
|
153
153
|
function setAttribute(node, name, value) {
|
|
154
|
-
if (
|
|
154
|
+
if (isHydrating(node)) return;
|
|
155
155
|
if (value == null) node.removeAttribute(name);else node.setAttribute(name, value);
|
|
156
156
|
}
|
|
157
157
|
function setAttributeNS(node, namespace, name, value) {
|
|
158
|
-
if (
|
|
158
|
+
if (isHydrating(node)) return;
|
|
159
159
|
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
160
160
|
}
|
|
161
161
|
function className(node, value) {
|
|
162
|
-
if (
|
|
162
|
+
if (isHydrating(node)) return;
|
|
163
163
|
if (value == null) node.removeAttribute("class");else node.className = value;
|
|
164
164
|
}
|
|
165
165
|
function addEventListener(node, name, handler, delegate) {
|
|
@@ -218,7 +218,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
218
218
|
if (!skipChildren) {
|
|
219
219
|
solidJs.createRenderEffect(() => prevProps.children = insertExpression(node, props.children, prevProps.children));
|
|
220
220
|
}
|
|
221
|
-
solidJs.createRenderEffect(() => typeof props.ref === "function"
|
|
221
|
+
solidJs.createRenderEffect(() => typeof props.ref === "function" && use(props.ref, node));
|
|
222
222
|
solidJs.createRenderEffect(() => assign(node, props, isSVG, true, prevProps, true));
|
|
223
223
|
return prevProps;
|
|
224
224
|
}
|
|
@@ -262,20 +262,25 @@ function hydrate$1(code, element, options = {}) {
|
|
|
262
262
|
solidJs.sharedConfig.events = globalThis._$HY.events;
|
|
263
263
|
solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
|
|
264
264
|
solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
|
|
265
|
+
solidJs.sharedConfig.done = globalThis._$HY.done;
|
|
265
266
|
solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
|
|
266
267
|
solidJs.sharedConfig.registry = new Map();
|
|
267
268
|
solidJs.sharedConfig.context = {
|
|
268
269
|
id: options.renderId || "",
|
|
269
270
|
count: 0
|
|
270
271
|
};
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
272
|
+
try {
|
|
273
|
+
gatherHydratable(element, options.renderId);
|
|
274
|
+
return render(code, element, [...element.childNodes], options);
|
|
275
|
+
} finally {
|
|
276
|
+
solidJs.sharedConfig.context = null;
|
|
277
|
+
}
|
|
275
278
|
}
|
|
276
279
|
function getNextElement(template) {
|
|
277
|
-
let node,
|
|
278
|
-
|
|
280
|
+
let node,
|
|
281
|
+
key,
|
|
282
|
+
hydrating = isHydrating();
|
|
283
|
+
if (!hydrating || !(node = solidJs.sharedConfig.registry.get(key = getHydrationKey()))) {
|
|
279
284
|
return template();
|
|
280
285
|
}
|
|
281
286
|
if (solidJs.sharedConfig.completed) solidJs.sharedConfig.completed.add(node);
|
|
@@ -290,7 +295,7 @@ function getNextMarker(start) {
|
|
|
290
295
|
let end = start,
|
|
291
296
|
count = 0,
|
|
292
297
|
current = [];
|
|
293
|
-
if (
|
|
298
|
+
if (isHydrating(start)) {
|
|
294
299
|
while (end) {
|
|
295
300
|
if (end.nodeType === 8) {
|
|
296
301
|
const v = end.nodeValue;
|
|
@@ -316,13 +321,20 @@ function runHydrationEvents() {
|
|
|
316
321
|
while (events.length) {
|
|
317
322
|
const [el, e] = events[0];
|
|
318
323
|
if (!completed.has(el)) return;
|
|
319
|
-
eventHandler(e);
|
|
320
324
|
events.shift();
|
|
325
|
+
eventHandler(e);
|
|
326
|
+
}
|
|
327
|
+
if (solidJs.sharedConfig.done) {
|
|
328
|
+
solidJs.sharedConfig.events = _$HY.events = null;
|
|
329
|
+
solidJs.sharedConfig.completed = _$HY.completed = null;
|
|
321
330
|
}
|
|
322
331
|
});
|
|
323
332
|
solidJs.sharedConfig.events.queued = true;
|
|
324
333
|
}
|
|
325
334
|
}
|
|
335
|
+
function isHydrating(node) {
|
|
336
|
+
return !!solidJs.sharedConfig.context && !solidJs.sharedConfig.done && (!node || node.isConnected);
|
|
337
|
+
}
|
|
326
338
|
function toPropertyName(name) {
|
|
327
339
|
return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
|
|
328
340
|
}
|
|
@@ -362,7 +374,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
362
374
|
if (forceProp) {
|
|
363
375
|
prop = prop.slice(5);
|
|
364
376
|
isProp = true;
|
|
365
|
-
} else if (
|
|
377
|
+
} else if (isHydrating(node)) return value;
|
|
366
378
|
if (prop === "class" || prop === "className") className(node, value);else if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[propAlias || prop] = value;
|
|
367
379
|
} else {
|
|
368
380
|
const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
|
|
@@ -371,6 +383,9 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
371
383
|
return value;
|
|
372
384
|
}
|
|
373
385
|
function eventHandler(e) {
|
|
386
|
+
if (solidJs.sharedConfig.registry && solidJs.sharedConfig.events) {
|
|
387
|
+
if (solidJs.sharedConfig.events.find(([el, ev]) => ev === e)) return;
|
|
388
|
+
}
|
|
374
389
|
const key = `$$${e.type}`;
|
|
375
390
|
let node = e.composedPath && e.composedPath()[0] || e.target;
|
|
376
391
|
if (e.target !== node) {
|
|
@@ -397,7 +412,7 @@ function eventHandler(e) {
|
|
|
397
412
|
}
|
|
398
413
|
}
|
|
399
414
|
function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
400
|
-
const hydrating =
|
|
415
|
+
const hydrating = isHydrating(parent);
|
|
401
416
|
if (hydrating) {
|
|
402
417
|
!current && (current = [...parent.childNodes]);
|
|
403
418
|
let cleaned = [];
|
|
@@ -448,9 +463,10 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
448
463
|
}
|
|
449
464
|
if (hydrating) {
|
|
450
465
|
if (!array.length) return current;
|
|
451
|
-
if (marker === undefined) return [...parent.childNodes];
|
|
466
|
+
if (marker === undefined) return current = [...parent.childNodes];
|
|
452
467
|
let node = array[0];
|
|
453
|
-
|
|
468
|
+
if (node.parentNode !== parent) return current;
|
|
469
|
+
const nodes = [node];
|
|
454
470
|
while ((node = node.nextSibling) !== marker) nodes.push(node);
|
|
455
471
|
return current = nodes;
|
|
456
472
|
}
|
|
@@ -530,8 +546,7 @@ function gatherHydratable(element, root) {
|
|
|
530
546
|
}
|
|
531
547
|
}
|
|
532
548
|
function getHydrationKey() {
|
|
533
|
-
|
|
534
|
-
return `${hydrate.id}${hydrate.count++}`;
|
|
549
|
+
return solidJs.sharedConfig.getNextContextId();
|
|
535
550
|
}
|
|
536
551
|
function NoHydration(props) {
|
|
537
552
|
return solidJs.sharedConfig.context ? undefined : props.children;
|