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