solid-js 1.8.2 → 1.8.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.cjs +1 -1
- package/dist/dev.js +534 -299
- package/dist/server.js +170 -75
- package/dist/solid.cjs +1 -1
- package/dist/solid.js +461 -257
- package/h/dist/h.js +34 -8
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +216 -94
- package/html/types/lit.d.ts +45 -31
- package/package.json +1 -1
- package/store/dist/dev.js +114 -42
- package/store/dist/server.js +19 -8
- package/store/dist/store.js +105 -39
- 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 +12 -4
- package/store/types/store.d.ts +218 -61
- package/types/index.d.ts +72 -9
- 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 +228 -140
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +62 -31
- package/types/render/flow.d.ts +43 -31
- package/types/render/hydration.d.ts +13 -13
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +166 -95
- 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 +617 -81
- package/web/dist/server.js +175 -92
- package/web/dist/web.js +611 -80
- package/web/types/client.d.ts +2 -2
- 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/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);
|
|
@@ -318,11 +329,13 @@ function setHydrateContext(context) {
|
|
|
318
329
|
sharedConfig.context = context;
|
|
319
330
|
}
|
|
320
331
|
function nextHydrateContext() {
|
|
321
|
-
return sharedConfig.context
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
332
|
+
return sharedConfig.context
|
|
333
|
+
? {
|
|
334
|
+
...sharedConfig.context,
|
|
335
|
+
id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
|
|
336
|
+
count: 0
|
|
337
|
+
}
|
|
338
|
+
: undefined;
|
|
326
339
|
}
|
|
327
340
|
function createUniqueId() {
|
|
328
341
|
const ctx = sharedConfig.context;
|
|
@@ -399,7 +412,11 @@ function Index(props) {
|
|
|
399
412
|
}
|
|
400
413
|
function Show(props) {
|
|
401
414
|
let c;
|
|
402
|
-
return props.when
|
|
415
|
+
return props.when
|
|
416
|
+
? typeof (c = props.children) === "function"
|
|
417
|
+
? c(props.keyed ? props.when : () => props.when)
|
|
418
|
+
: c
|
|
419
|
+
: props.fallback || "";
|
|
403
420
|
}
|
|
404
421
|
function Switch(props) {
|
|
405
422
|
let conditions = props.children;
|
|
@@ -436,11 +453,14 @@ function ErrorBoundary(props) {
|
|
|
436
453
|
}
|
|
437
454
|
createMemo(() => {
|
|
438
455
|
clean = Owner;
|
|
439
|
-
return catchError(
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
456
|
+
return catchError(
|
|
457
|
+
() => (res = props.children),
|
|
458
|
+
err => {
|
|
459
|
+
error = err;
|
|
460
|
+
!sync && ctx.replace("e" + id, displayFallback);
|
|
461
|
+
sync = true;
|
|
462
|
+
}
|
|
463
|
+
);
|
|
444
464
|
});
|
|
445
465
|
if (error) return displayFallback();
|
|
446
466
|
sync = false;
|
|
@@ -470,14 +490,18 @@ function createResource(source, fetcher, options = {}) {
|
|
|
470
490
|
if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
|
|
471
491
|
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
472
492
|
if (resource.ref) {
|
|
473
|
-
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
|
|
493
|
+
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
|
|
494
|
+
resource.ref[1].refetch();
|
|
474
495
|
return resource.ref;
|
|
475
496
|
}
|
|
476
497
|
}
|
|
477
498
|
const read = () => {
|
|
478
499
|
if (error) throw error;
|
|
479
500
|
if (resourceContext && p) resourceContext.push(p);
|
|
480
|
-
const resolved =
|
|
501
|
+
const resolved =
|
|
502
|
+
options.ssrLoadFrom !== "initial" &&
|
|
503
|
+
sharedConfig.context.async &&
|
|
504
|
+
"data" in sharedConfig.context.resources[id];
|
|
481
505
|
if (!resolved && read.loading) {
|
|
482
506
|
const ctx = useContext(SuspenseContext);
|
|
483
507
|
if (ctx) {
|
|
@@ -497,7 +521,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
497
521
|
});
|
|
498
522
|
function load() {
|
|
499
523
|
const ctx = sharedConfig.context;
|
|
500
|
-
if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
|
|
524
|
+
if (!ctx.async) return (read.loading = !!(typeof source === "function" ? source() : source));
|
|
501
525
|
if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
|
|
502
526
|
value = ctx.resources[id].data;
|
|
503
527
|
return;
|
|
@@ -505,9 +529,11 @@ function createResource(source, fetcher, options = {}) {
|
|
|
505
529
|
resourceContext = [];
|
|
506
530
|
const lookup = typeof source === "function" ? source() : source;
|
|
507
531
|
if (resourceContext.length) {
|
|
508
|
-
p = Promise.all(resourceContext).then(() =>
|
|
509
|
-
|
|
510
|
-
|
|
532
|
+
p = Promise.all(resourceContext).then(() =>
|
|
533
|
+
fetcher(source(), {
|
|
534
|
+
value
|
|
535
|
+
})
|
|
536
|
+
);
|
|
511
537
|
}
|
|
512
538
|
resourceContext = null;
|
|
513
539
|
if (!p) {
|
|
@@ -519,21 +545,23 @@ function createResource(source, fetcher, options = {}) {
|
|
|
519
545
|
if (p != undefined && typeof p === "object" && "then" in p) {
|
|
520
546
|
read.loading = true;
|
|
521
547
|
read.state = "pending";
|
|
522
|
-
p = p
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
548
|
+
p = p
|
|
549
|
+
.then(res => {
|
|
550
|
+
read.loading = false;
|
|
551
|
+
read.state = "ready";
|
|
552
|
+
ctx.resources[id].data = res;
|
|
553
|
+
p = null;
|
|
554
|
+
notifySuspense(contexts);
|
|
555
|
+
return res;
|
|
556
|
+
})
|
|
557
|
+
.catch(err => {
|
|
558
|
+
read.loading = false;
|
|
559
|
+
read.state = "errored";
|
|
560
|
+
read.error = error = castError(err);
|
|
561
|
+
p = null;
|
|
562
|
+
notifySuspense(contexts);
|
|
563
|
+
throw error;
|
|
564
|
+
});
|
|
537
565
|
if (ctx.serialize) ctx.serialize(id, p, options.deferStream);
|
|
538
566
|
return p;
|
|
539
567
|
}
|
|
@@ -543,17 +571,20 @@ function createResource(source, fetcher, options = {}) {
|
|
|
543
571
|
return ctx.resources[id].data;
|
|
544
572
|
}
|
|
545
573
|
if (options.ssrLoadFrom !== "initial") load();
|
|
546
|
-
return resource.ref = [
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
574
|
+
return (resource.ref = [
|
|
575
|
+
read,
|
|
576
|
+
{
|
|
577
|
+
refetch: load,
|
|
578
|
+
mutate: v => (value = v)
|
|
579
|
+
}
|
|
580
|
+
]);
|
|
550
581
|
}
|
|
551
582
|
function lazy(fn) {
|
|
552
583
|
let p;
|
|
553
584
|
let load = id => {
|
|
554
585
|
if (!p) {
|
|
555
586
|
p = fn();
|
|
556
|
-
p.then(mod => p.resolved = mod.default);
|
|
587
|
+
p.then(mod => (p.resolved = mod.default));
|
|
557
588
|
if (id) sharedConfig.context.lazy[id] = p;
|
|
558
589
|
}
|
|
559
590
|
return p;
|
|
@@ -562,7 +593,8 @@ function lazy(fn) {
|
|
|
562
593
|
const wrap = props => {
|
|
563
594
|
const id = sharedConfig.context.id.slice(0, -1);
|
|
564
595
|
let ref = sharedConfig.context.lazy[id];
|
|
565
|
-
if (ref) p = ref;
|
|
596
|
+
if (ref) p = ref;
|
|
597
|
+
else load(id);
|
|
566
598
|
if (p.resolved) return p.resolved(props);
|
|
567
599
|
const ctx = useContext(SuspenseContext);
|
|
568
600
|
const track = {
|
|
@@ -574,10 +606,12 @@ function lazy(fn) {
|
|
|
574
606
|
contexts.add(ctx);
|
|
575
607
|
}
|
|
576
608
|
if (sharedConfig.context.async) {
|
|
577
|
-
sharedConfig.context.block(
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
609
|
+
sharedConfig.context.block(
|
|
610
|
+
p.then(() => {
|
|
611
|
+
track.loading = false;
|
|
612
|
+
notifySuspense(contexts);
|
|
613
|
+
})
|
|
614
|
+
);
|
|
581
615
|
}
|
|
582
616
|
return "";
|
|
583
617
|
};
|
|
@@ -605,9 +639,12 @@ function startTransition(fn) {
|
|
|
605
639
|
fn();
|
|
606
640
|
}
|
|
607
641
|
function useTransition() {
|
|
608
|
-
return [
|
|
609
|
-
|
|
610
|
-
|
|
642
|
+
return [
|
|
643
|
+
() => false,
|
|
644
|
+
fn => {
|
|
645
|
+
fn();
|
|
646
|
+
}
|
|
647
|
+
];
|
|
611
648
|
}
|
|
612
649
|
function SuspenseList(props) {
|
|
613
650
|
return props.children;
|
|
@@ -617,15 +654,17 @@ function Suspense(props) {
|
|
|
617
654
|
const ctx = sharedConfig.context;
|
|
618
655
|
const id = ctx.id + ctx.count;
|
|
619
656
|
const o = createOwner();
|
|
620
|
-
const value =
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
657
|
+
const value =
|
|
658
|
+
ctx.suspense[id] ||
|
|
659
|
+
(ctx.suspense[id] = {
|
|
660
|
+
resources: new Map(),
|
|
661
|
+
completed: () => {
|
|
662
|
+
const res = runSuspense();
|
|
663
|
+
if (suspenseComplete(value)) {
|
|
664
|
+
done(resolveSSRNode(res));
|
|
665
|
+
}
|
|
626
666
|
}
|
|
627
|
-
}
|
|
628
|
-
});
|
|
667
|
+
});
|
|
629
668
|
function suspenseError(err) {
|
|
630
669
|
if (!done || !done(undefined, err)) {
|
|
631
670
|
runWithOwner(o.owner, () => {
|
|
@@ -639,12 +678,14 @@ function Suspense(props) {
|
|
|
639
678
|
count: 0
|
|
640
679
|
});
|
|
641
680
|
cleanNode(o);
|
|
642
|
-
return runWithOwner(o, () =>
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
681
|
+
return runWithOwner(o, () =>
|
|
682
|
+
createComponent(SuspenseContext.Provider, {
|
|
683
|
+
value,
|
|
684
|
+
get children() {
|
|
685
|
+
return catchError(() => props.children, suspenseError);
|
|
686
|
+
}
|
|
687
|
+
})
|
|
688
|
+
);
|
|
648
689
|
}
|
|
649
690
|
const res = runSuspense();
|
|
650
691
|
if (suspenseComplete(value)) {
|
|
@@ -676,4 +717,58 @@ function Suspense(props) {
|
|
|
676
717
|
}, suspenseError);
|
|
677
718
|
}
|
|
678
719
|
|
|
679
|
-
export {
|
|
720
|
+
export {
|
|
721
|
+
$DEVCOMP,
|
|
722
|
+
$PROXY,
|
|
723
|
+
$TRACK,
|
|
724
|
+
DEV,
|
|
725
|
+
ErrorBoundary,
|
|
726
|
+
For,
|
|
727
|
+
Index,
|
|
728
|
+
Match,
|
|
729
|
+
Show,
|
|
730
|
+
Suspense,
|
|
731
|
+
SuspenseList,
|
|
732
|
+
Switch,
|
|
733
|
+
batch,
|
|
734
|
+
catchError,
|
|
735
|
+
children,
|
|
736
|
+
createComponent,
|
|
737
|
+
createComputed,
|
|
738
|
+
createContext,
|
|
739
|
+
createDeferred,
|
|
740
|
+
createEffect,
|
|
741
|
+
createMemo,
|
|
742
|
+
createReaction,
|
|
743
|
+
createRenderEffect,
|
|
744
|
+
createResource,
|
|
745
|
+
createRoot,
|
|
746
|
+
createSelector,
|
|
747
|
+
createSignal,
|
|
748
|
+
createUniqueId,
|
|
749
|
+
enableExternalSource,
|
|
750
|
+
enableHydration,
|
|
751
|
+
enableScheduling,
|
|
752
|
+
equalFn,
|
|
753
|
+
from,
|
|
754
|
+
getListener,
|
|
755
|
+
getOwner,
|
|
756
|
+
indexArray,
|
|
757
|
+
lazy,
|
|
758
|
+
mapArray,
|
|
759
|
+
mergeProps,
|
|
760
|
+
observable,
|
|
761
|
+
on,
|
|
762
|
+
onCleanup,
|
|
763
|
+
onError,
|
|
764
|
+
onMount,
|
|
765
|
+
requestCallback,
|
|
766
|
+
resetErrorBoundaries,
|
|
767
|
+
runWithOwner,
|
|
768
|
+
sharedConfig,
|
|
769
|
+
splitProps,
|
|
770
|
+
startTransition,
|
|
771
|
+
untrack,
|
|
772
|
+
useContext,
|
|
773
|
+
useTransition
|
|
774
|
+
};
|
package/dist/solid.cjs
CHANGED
|
@@ -1602,7 +1602,7 @@ function Suspense(props) {
|
|
|
1602
1602
|
if (sharedConfig.context && sharedConfig.load) {
|
|
1603
1603
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1604
1604
|
let ref = sharedConfig.load(key);
|
|
1605
|
-
if (ref && (typeof ref !== "object" ||
|
|
1605
|
+
if (ref && (typeof ref !== "object" || ref.status !== 'success')) p = ref;
|
|
1606
1606
|
if (p && p !== "$$f") {
|
|
1607
1607
|
const [s, set] = createSignal(undefined, {
|
|
1608
1608
|
equals: false
|