solid-js 1.9.2 → 1.9.3
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.js +559 -318
- package/dist/server.js +168 -74
- package/dist/solid.js +486 -276
- package/h/dist/h.js +40 -9
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/jsx-runtime/types/jsx.d.ts +93 -91
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +219 -94
- package/html/types/lit.d.ts +52 -33
- package/package.json +1 -1
- package/store/dist/dev.js +123 -43
- package/store/dist/server.js +20 -8
- package/store/dist/store.js +114 -40
- package/store/types/index.d.ts +21 -7
- package/store/types/modifiers.d.ts +6 -3
- package/store/types/mutable.d.ts +5 -2
- package/store/types/server.d.ts +25 -5
- package/store/types/store.d.ts +218 -61
- package/types/index.d.ts +75 -10
- package/types/jsx.d.ts +143 -157
- package/types/reactive/array.d.ts +12 -4
- package/types/reactive/observable.d.ts +25 -17
- package/types/reactive/scheduler.d.ts +9 -6
- package/types/reactive/signal.d.ts +233 -142
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +71 -35
- package/types/render/flow.d.ts +43 -31
- package/types/render/hydration.d.ts +15 -15
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +169 -98
- package/universal/dist/dev.js +28 -12
- package/universal/dist/universal.js +28 -12
- package/universal/types/index.d.ts +3 -1
- package/universal/types/universal.d.ts +0 -1
- package/web/dist/dev.js +639 -89
- package/web/dist/server.cjs +13 -10
- package/web/dist/server.js +653 -118
- package/web/dist/web.js +627 -87
- package/web/storage/dist/storage.js +3 -3
- package/web/types/client.d.ts +1 -1
- package/web/types/core.d.ts +10 -1
- package/web/types/index.d.ts +27 -10
- package/web/types/server-mock.d.ts +47 -32
- package/web/types/server.d.ts +1 -1
package/dist/server.js
CHANGED
|
@@ -17,7 +17,7 @@ function handleError(err, owner = Owner) {
|
|
|
17
17
|
try {
|
|
18
18
|
for (const f of fns) f(error);
|
|
19
19
|
} catch (e) {
|
|
20
|
-
handleError(e, owner && owner.owner || null);
|
|
20
|
+
handleError(e, (owner && owner.owner) || null);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
const UNOWNED = {
|
|
@@ -35,19 +35,23 @@ function createOwner() {
|
|
|
35
35
|
cleanups: null
|
|
36
36
|
};
|
|
37
37
|
if (Owner) {
|
|
38
|
-
if (!Owner.owned) Owner.owned = [o];
|
|
38
|
+
if (!Owner.owned) Owner.owned = [o];
|
|
39
|
+
else Owner.owned.push(o);
|
|
39
40
|
}
|
|
40
41
|
return o;
|
|
41
42
|
}
|
|
42
43
|
function createRoot(fn, detachedOwner) {
|
|
43
44
|
const owner = Owner,
|
|
44
45
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
45
|
-
root =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
root =
|
|
47
|
+
fn.length === 0
|
|
48
|
+
? UNOWNED
|
|
49
|
+
: {
|
|
50
|
+
context: current ? current.context : null,
|
|
51
|
+
owner: current,
|
|
52
|
+
owned: null,
|
|
53
|
+
cleanups: null
|
|
54
|
+
};
|
|
51
55
|
Owner = root;
|
|
52
56
|
let result;
|
|
53
57
|
try {
|
|
@@ -60,9 +64,12 @@ function createRoot(fn, detachedOwner) {
|
|
|
60
64
|
return result;
|
|
61
65
|
}
|
|
62
66
|
function createSignal(value, options) {
|
|
63
|
-
return [
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
return [
|
|
68
|
+
() => value,
|
|
69
|
+
v => {
|
|
70
|
+
return (value = typeof v === "function" ? v(value) : v);
|
|
71
|
+
}
|
|
72
|
+
];
|
|
66
73
|
}
|
|
67
74
|
function createComputed(fn, value) {
|
|
68
75
|
Owner = createOwner();
|
|
@@ -119,7 +126,8 @@ function on(deps, fn, options = {}) {
|
|
|
119
126
|
function onMount(fn) {}
|
|
120
127
|
function onCleanup(fn) {
|
|
121
128
|
if (Owner) {
|
|
122
|
-
if (!Owner.cleanups) Owner.cleanups = [fn];
|
|
129
|
+
if (!Owner.cleanups) Owner.cleanups = [fn];
|
|
130
|
+
else Owner.cleanups.push(fn);
|
|
123
131
|
}
|
|
124
132
|
return fn;
|
|
125
133
|
}
|
|
@@ -160,7 +168,9 @@ function createContext(defaultValue) {
|
|
|
160
168
|
};
|
|
161
169
|
}
|
|
162
170
|
function useContext(context) {
|
|
163
|
-
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
171
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
172
|
+
? Owner.context[context.id]
|
|
173
|
+
: context.defaultValue;
|
|
164
174
|
}
|
|
165
175
|
function getOwner() {
|
|
166
176
|
return Owner;
|
|
@@ -237,7 +247,8 @@ function observable(input) {
|
|
|
237
247
|
if (!(observer instanceof Object) || observer == null) {
|
|
238
248
|
throw new TypeError("Expected the observer to be an object.");
|
|
239
249
|
}
|
|
240
|
-
const handler =
|
|
250
|
+
const handler =
|
|
251
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
241
252
|
if (!handler) {
|
|
242
253
|
return {
|
|
243
254
|
unsubscribe() {}
|
|
@@ -266,7 +277,7 @@ function from(producer) {
|
|
|
266
277
|
const [s, set] = createSignal(undefined);
|
|
267
278
|
if ("subscribe" in producer) {
|
|
268
279
|
const unsub = producer.subscribe(v => set(() => v));
|
|
269
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
280
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
270
281
|
} else {
|
|
271
282
|
const clean = producer(set);
|
|
272
283
|
onCleanup(clean);
|
|
@@ -309,7 +320,7 @@ function resolveSSRNode(node) {
|
|
|
309
320
|
let mapped = "";
|
|
310
321
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
311
322
|
if (typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
|
|
312
|
-
mapped += resolveSSRNode(prev = node[i]);
|
|
323
|
+
mapped += resolveSSRNode((prev = node[i]));
|
|
313
324
|
}
|
|
314
325
|
return mapped;
|
|
315
326
|
}
|
|
@@ -324,7 +335,8 @@ const sharedConfig = {
|
|
|
324
335
|
return getContextId(this.context.count);
|
|
325
336
|
},
|
|
326
337
|
getNextContextId() {
|
|
327
|
-
if (!this.context)
|
|
338
|
+
if (!this.context)
|
|
339
|
+
throw new Error(`getNextContextId cannot be used under non-hydrating context`);
|
|
328
340
|
return getContextId(this.context.count++);
|
|
329
341
|
}
|
|
330
342
|
};
|
|
@@ -337,11 +349,13 @@ function setHydrateContext(context) {
|
|
|
337
349
|
sharedConfig.context = context;
|
|
338
350
|
}
|
|
339
351
|
function nextHydrateContext() {
|
|
340
|
-
return sharedConfig.context
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
352
|
+
return sharedConfig.context
|
|
353
|
+
? {
|
|
354
|
+
...sharedConfig.context,
|
|
355
|
+
id: sharedConfig.getNextContextId(),
|
|
356
|
+
count: 0
|
|
357
|
+
}
|
|
358
|
+
: undefined;
|
|
345
359
|
}
|
|
346
360
|
function createUniqueId() {
|
|
347
361
|
return sharedConfig.getNextContextId();
|
|
@@ -416,7 +430,11 @@ function Index(props) {
|
|
|
416
430
|
}
|
|
417
431
|
function Show(props) {
|
|
418
432
|
let c;
|
|
419
|
-
return props.when
|
|
433
|
+
return props.when
|
|
434
|
+
? typeof (c = props.children) === "function"
|
|
435
|
+
? c(props.keyed ? props.when : () => props.when)
|
|
436
|
+
: c
|
|
437
|
+
: props.fallback || "";
|
|
420
438
|
}
|
|
421
439
|
function Switch(props) {
|
|
422
440
|
let conditions = props.children;
|
|
@@ -453,11 +471,14 @@ function ErrorBoundary(props) {
|
|
|
453
471
|
}
|
|
454
472
|
createMemo(() => {
|
|
455
473
|
clean = Owner;
|
|
456
|
-
return catchError(
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
474
|
+
return catchError(
|
|
475
|
+
() => (res = props.children),
|
|
476
|
+
err => {
|
|
477
|
+
error = err;
|
|
478
|
+
!sync && ctx.replace("e" + id, displayFallback);
|
|
479
|
+
sync = true;
|
|
480
|
+
}
|
|
481
|
+
);
|
|
461
482
|
});
|
|
462
483
|
if (error) return displayFallback();
|
|
463
484
|
sync = false;
|
|
@@ -487,13 +508,17 @@ function createResource(source, fetcher, options = {}) {
|
|
|
487
508
|
if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
|
|
488
509
|
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
489
510
|
if (resource.ref) {
|
|
490
|
-
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
|
|
511
|
+
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
|
|
512
|
+
resource.ref[1].refetch();
|
|
491
513
|
return resource.ref;
|
|
492
514
|
}
|
|
493
515
|
}
|
|
494
516
|
const read = () => {
|
|
495
517
|
if (error) throw error;
|
|
496
|
-
const resolved =
|
|
518
|
+
const resolved =
|
|
519
|
+
options.ssrLoadFrom !== "initial" &&
|
|
520
|
+
sharedConfig.context.async &&
|
|
521
|
+
"data" in sharedConfig.context.resources[id];
|
|
497
522
|
if (!resolved && resourceContext) resourceContext.push(id);
|
|
498
523
|
if (!resolved && read.loading) {
|
|
499
524
|
const ctx = useContext(SuspenseContext);
|
|
@@ -514,7 +539,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
514
539
|
});
|
|
515
540
|
function load() {
|
|
516
541
|
const ctx = sharedConfig.context;
|
|
517
|
-
if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
|
|
542
|
+
if (!ctx.async) return (read.loading = !!(typeof source === "function" ? source() : source));
|
|
518
543
|
if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
|
|
519
544
|
value = ctx.resources[id].data;
|
|
520
545
|
return;
|
|
@@ -536,21 +561,23 @@ function createResource(source, fetcher, options = {}) {
|
|
|
536
561
|
if (p != undefined && typeof p === "object" && "then" in p) {
|
|
537
562
|
read.loading = true;
|
|
538
563
|
read.state = "pending";
|
|
539
|
-
p = p
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
564
|
+
p = p
|
|
565
|
+
.then(res => {
|
|
566
|
+
read.loading = false;
|
|
567
|
+
read.state = "ready";
|
|
568
|
+
ctx.resources[id].data = res;
|
|
569
|
+
p = null;
|
|
570
|
+
notifySuspense(contexts);
|
|
571
|
+
return res;
|
|
572
|
+
})
|
|
573
|
+
.catch(err => {
|
|
574
|
+
read.loading = false;
|
|
575
|
+
read.state = "errored";
|
|
576
|
+
read.error = error = castError(err);
|
|
577
|
+
p = null;
|
|
578
|
+
notifySuspense(contexts);
|
|
579
|
+
throw error;
|
|
580
|
+
});
|
|
554
581
|
if (ctx.serialize) ctx.serialize(id, p, options.deferStream);
|
|
555
582
|
return p;
|
|
556
583
|
}
|
|
@@ -560,17 +587,20 @@ function createResource(source, fetcher, options = {}) {
|
|
|
560
587
|
return ctx.resources[id].data;
|
|
561
588
|
}
|
|
562
589
|
if (options.ssrLoadFrom !== "initial") load();
|
|
563
|
-
return resource.ref = [
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
590
|
+
return (resource.ref = [
|
|
591
|
+
read,
|
|
592
|
+
{
|
|
593
|
+
refetch: load,
|
|
594
|
+
mutate: v => (value = v)
|
|
595
|
+
}
|
|
596
|
+
]);
|
|
567
597
|
}
|
|
568
598
|
function lazy(fn) {
|
|
569
599
|
let p;
|
|
570
600
|
let load = id => {
|
|
571
601
|
if (!p) {
|
|
572
602
|
p = fn();
|
|
573
|
-
p.then(mod => p.resolved = mod.default);
|
|
603
|
+
p.then(mod => (p.resolved = mod.default));
|
|
574
604
|
if (id) sharedConfig.context.lazy[id] = p;
|
|
575
605
|
}
|
|
576
606
|
return p;
|
|
@@ -579,7 +609,8 @@ function lazy(fn) {
|
|
|
579
609
|
const wrap = props => {
|
|
580
610
|
const id = sharedConfig.context.id;
|
|
581
611
|
let ref = sharedConfig.context.lazy[id];
|
|
582
|
-
if (ref) p = ref;
|
|
612
|
+
if (ref) p = ref;
|
|
613
|
+
else load(id);
|
|
583
614
|
if (p.resolved) return p.resolved(props);
|
|
584
615
|
const ctx = useContext(SuspenseContext);
|
|
585
616
|
const track = {
|
|
@@ -591,10 +622,12 @@ function lazy(fn) {
|
|
|
591
622
|
contexts.add(ctx);
|
|
592
623
|
}
|
|
593
624
|
if (sharedConfig.context.async) {
|
|
594
|
-
sharedConfig.context.block(
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
625
|
+
sharedConfig.context.block(
|
|
626
|
+
p.then(() => {
|
|
627
|
+
track.loading = false;
|
|
628
|
+
notifySuspense(contexts);
|
|
629
|
+
})
|
|
630
|
+
);
|
|
598
631
|
}
|
|
599
632
|
return "";
|
|
600
633
|
};
|
|
@@ -622,9 +655,12 @@ function startTransition(fn) {
|
|
|
622
655
|
fn();
|
|
623
656
|
}
|
|
624
657
|
function useTransition() {
|
|
625
|
-
return [
|
|
626
|
-
|
|
627
|
-
|
|
658
|
+
return [
|
|
659
|
+
() => false,
|
|
660
|
+
fn => {
|
|
661
|
+
fn();
|
|
662
|
+
}
|
|
663
|
+
];
|
|
628
664
|
}
|
|
629
665
|
function SuspenseList(props) {
|
|
630
666
|
return props.children;
|
|
@@ -634,15 +670,17 @@ function Suspense(props) {
|
|
|
634
670
|
const ctx = sharedConfig.context;
|
|
635
671
|
const id = sharedConfig.getContextId();
|
|
636
672
|
const o = createOwner();
|
|
637
|
-
const value =
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
673
|
+
const value =
|
|
674
|
+
ctx.suspense[id] ||
|
|
675
|
+
(ctx.suspense[id] = {
|
|
676
|
+
resources: new Map(),
|
|
677
|
+
completed: () => {
|
|
678
|
+
const res = runSuspense();
|
|
679
|
+
if (suspenseComplete(value)) {
|
|
680
|
+
done(resolveSSRNode(res));
|
|
681
|
+
}
|
|
643
682
|
}
|
|
644
|
-
}
|
|
645
|
-
});
|
|
683
|
+
});
|
|
646
684
|
function suspenseError(err) {
|
|
647
685
|
if (!done || !done(undefined, err)) {
|
|
648
686
|
runWithOwner(o.owner, () => {
|
|
@@ -656,12 +694,14 @@ function Suspense(props) {
|
|
|
656
694
|
count: 0
|
|
657
695
|
});
|
|
658
696
|
cleanNode(o);
|
|
659
|
-
return runWithOwner(o, () =>
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
697
|
+
return runWithOwner(o, () =>
|
|
698
|
+
createComponent(SuspenseContext.Provider, {
|
|
699
|
+
value,
|
|
700
|
+
get children() {
|
|
701
|
+
return catchError(() => props.children, suspenseError);
|
|
702
|
+
}
|
|
703
|
+
})
|
|
704
|
+
);
|
|
665
705
|
}
|
|
666
706
|
const res = runSuspense();
|
|
667
707
|
if (suspenseComplete(value)) {
|
|
@@ -693,4 +733,58 @@ function Suspense(props) {
|
|
|
693
733
|
}, suspenseError);
|
|
694
734
|
}
|
|
695
735
|
|
|
696
|
-
export {
|
|
736
|
+
export {
|
|
737
|
+
$DEVCOMP,
|
|
738
|
+
$PROXY,
|
|
739
|
+
$TRACK,
|
|
740
|
+
DEV,
|
|
741
|
+
ErrorBoundary,
|
|
742
|
+
For,
|
|
743
|
+
Index,
|
|
744
|
+
Match,
|
|
745
|
+
Show,
|
|
746
|
+
Suspense,
|
|
747
|
+
SuspenseList,
|
|
748
|
+
Switch,
|
|
749
|
+
batch,
|
|
750
|
+
catchError,
|
|
751
|
+
children,
|
|
752
|
+
createComponent,
|
|
753
|
+
createComputed,
|
|
754
|
+
createContext,
|
|
755
|
+
createDeferred,
|
|
756
|
+
createEffect,
|
|
757
|
+
createMemo,
|
|
758
|
+
createReaction,
|
|
759
|
+
createRenderEffect,
|
|
760
|
+
createResource,
|
|
761
|
+
createRoot,
|
|
762
|
+
createSelector,
|
|
763
|
+
createSignal,
|
|
764
|
+
createUniqueId,
|
|
765
|
+
enableExternalSource,
|
|
766
|
+
enableHydration,
|
|
767
|
+
enableScheduling,
|
|
768
|
+
equalFn,
|
|
769
|
+
from,
|
|
770
|
+
getListener,
|
|
771
|
+
getOwner,
|
|
772
|
+
indexArray,
|
|
773
|
+
lazy,
|
|
774
|
+
mapArray,
|
|
775
|
+
mergeProps,
|
|
776
|
+
observable,
|
|
777
|
+
on,
|
|
778
|
+
onCleanup,
|
|
779
|
+
onError,
|
|
780
|
+
onMount,
|
|
781
|
+
requestCallback,
|
|
782
|
+
resetErrorBoundaries,
|
|
783
|
+
runWithOwner,
|
|
784
|
+
sharedConfig,
|
|
785
|
+
splitProps,
|
|
786
|
+
startTransition,
|
|
787
|
+
untrack,
|
|
788
|
+
useContext,
|
|
789
|
+
useTransition
|
|
790
|
+
};
|