solid-js 1.7.10 → 1.7.11
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 +296 -529
- package/dist/server.js +74 -168
- package/dist/solid.cjs +1 -1
- package/dist/solid.js +254 -456
- package/h/dist/h.js +8 -34
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +8 -11
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +94 -216
- package/html/types/lit.d.ts +31 -45
- package/package.json +1 -1
- package/store/dist/dev.js +42 -114
- package/store/dist/server.js +8 -19
- package/store/dist/store.js +39 -105
- 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 +9 -72
- 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 +140 -226
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +31 -62
- package/types/render/flow.d.ts +31 -43
- package/types/render/hydration.d.ts +12 -12
- package/types/server/index.d.ts +2 -56
- package/types/server/reactive.d.ts +40 -67
- package/types/server/rendering.d.ts +95 -171
- 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 +79 -610
- package/web/dist/server.js +78 -177
- package/web/dist/web.js +79 -610
- 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;
|
|
@@ -239,8 +229,7 @@ function observable(input) {
|
|
|
239
229
|
if (!(observer instanceof Object) || observer == null) {
|
|
240
230
|
throw new TypeError("Expected the observer to be an object.");
|
|
241
231
|
}
|
|
242
|
-
const handler =
|
|
243
|
-
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
232
|
+
const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
244
233
|
if (!handler) {
|
|
245
234
|
return {
|
|
246
235
|
unsubscribe() {}
|
|
@@ -269,7 +258,7 @@ function from(producer) {
|
|
|
269
258
|
const [s, set] = createSignal(undefined);
|
|
270
259
|
if ("subscribe" in producer) {
|
|
271
260
|
const unsub = producer.subscribe(v => set(() => v));
|
|
272
|
-
onCleanup(() =>
|
|
261
|
+
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
273
262
|
} else {
|
|
274
263
|
const clean = producer(set);
|
|
275
264
|
onCleanup(clean);
|
|
@@ -321,13 +310,11 @@ function setHydrateContext(context) {
|
|
|
321
310
|
sharedConfig.context = context;
|
|
322
311
|
}
|
|
323
312
|
function nextHydrateContext() {
|
|
324
|
-
return sharedConfig.context
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
: undefined;
|
|
313
|
+
return sharedConfig.context ? {
|
|
314
|
+
...sharedConfig.context,
|
|
315
|
+
id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
|
|
316
|
+
count: 0
|
|
317
|
+
} : undefined;
|
|
331
318
|
}
|
|
332
319
|
function createUniqueId() {
|
|
333
320
|
const ctx = sharedConfig.context;
|
|
@@ -403,11 +390,7 @@ function Index(props) {
|
|
|
403
390
|
}
|
|
404
391
|
function Show(props) {
|
|
405
392
|
let c;
|
|
406
|
-
return props.when
|
|
407
|
-
? typeof (c = props.children) === "function"
|
|
408
|
-
? c(props.keyed ? props.when : () => props.when)
|
|
409
|
-
: c
|
|
410
|
-
: props.fallback || "";
|
|
393
|
+
return props.when ? typeof (c = props.children) === "function" ? c(props.keyed ? props.when : () => props.when) : c : props.fallback || "";
|
|
411
394
|
}
|
|
412
395
|
function Switch(props) {
|
|
413
396
|
let conditions = props.children;
|
|
@@ -444,14 +427,11 @@ function ErrorBoundary(props) {
|
|
|
444
427
|
}
|
|
445
428
|
createMemo(() => {
|
|
446
429
|
clean = Owner;
|
|
447
|
-
return catchError(
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
sync = true;
|
|
453
|
-
}
|
|
454
|
-
);
|
|
430
|
+
return catchError(() => res = props.children, err => {
|
|
431
|
+
error = err;
|
|
432
|
+
!sync && ctx.replace("e" + id, displayFallback);
|
|
433
|
+
sync = true;
|
|
434
|
+
});
|
|
455
435
|
});
|
|
456
436
|
if (error) return displayFallback();
|
|
457
437
|
sync = false;
|
|
@@ -481,18 +461,14 @@ function createResource(source, fetcher, options = {}) {
|
|
|
481
461
|
if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
|
|
482
462
|
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
483
463
|
if (resource.ref) {
|
|
484
|
-
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
|
|
485
|
-
resource.ref[1].refetch();
|
|
464
|
+
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
|
|
486
465
|
return resource.ref;
|
|
487
466
|
}
|
|
488
467
|
}
|
|
489
468
|
const read = () => {
|
|
490
469
|
if (error) throw error;
|
|
491
470
|
if (resourceContext && p) resourceContext.push(p);
|
|
492
|
-
const resolved =
|
|
493
|
-
options.ssrLoadFrom !== "initial" &&
|
|
494
|
-
sharedConfig.context.async &&
|
|
495
|
-
"data" in sharedConfig.context.resources[id];
|
|
471
|
+
const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
|
|
496
472
|
if (!resolved && read.loading) {
|
|
497
473
|
const ctx = useContext(SuspenseContext);
|
|
498
474
|
if (ctx) {
|
|
@@ -512,7 +488,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
512
488
|
});
|
|
513
489
|
function load() {
|
|
514
490
|
const ctx = sharedConfig.context;
|
|
515
|
-
if (!ctx.async) return
|
|
491
|
+
if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
|
|
516
492
|
if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
|
|
517
493
|
value = ctx.resources[id].data;
|
|
518
494
|
return;
|
|
@@ -520,11 +496,9 @@ function createResource(source, fetcher, options = {}) {
|
|
|
520
496
|
resourceContext = [];
|
|
521
497
|
const lookup = typeof source === "function" ? source() : source;
|
|
522
498
|
if (resourceContext.length) {
|
|
523
|
-
p = Promise.all(resourceContext).then(() =>
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
})
|
|
527
|
-
);
|
|
499
|
+
p = Promise.all(resourceContext).then(() => fetcher(source(), {
|
|
500
|
+
value
|
|
501
|
+
}));
|
|
528
502
|
}
|
|
529
503
|
resourceContext = null;
|
|
530
504
|
if (!p) {
|
|
@@ -537,22 +511,20 @@ function createResource(source, fetcher, options = {}) {
|
|
|
537
511
|
read.loading = true;
|
|
538
512
|
read.state = "pending";
|
|
539
513
|
if (ctx.writeResource) ctx.writeResource(id, p, undefined, options.deferStream);
|
|
540
|
-
return p
|
|
541
|
-
.
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
.
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
notifySuspense(contexts);
|
|
555
|
-
});
|
|
514
|
+
return p.then(res => {
|
|
515
|
+
read.loading = false;
|
|
516
|
+
read.state = "ready";
|
|
517
|
+
ctx.resources[id].data = res;
|
|
518
|
+
p = null;
|
|
519
|
+
notifySuspense(contexts);
|
|
520
|
+
return res;
|
|
521
|
+
}).catch(err => {
|
|
522
|
+
read.loading = false;
|
|
523
|
+
read.state = "errored";
|
|
524
|
+
read.error = error = castError(err);
|
|
525
|
+
p = null;
|
|
526
|
+
notifySuspense(contexts);
|
|
527
|
+
});
|
|
556
528
|
}
|
|
557
529
|
ctx.resources[id].data = p;
|
|
558
530
|
if (ctx.writeResource) ctx.writeResource(id, p);
|
|
@@ -560,20 +532,17 @@ function createResource(source, fetcher, options = {}) {
|
|
|
560
532
|
return ctx.resources[id].data;
|
|
561
533
|
}
|
|
562
534
|
if (options.ssrLoadFrom !== "initial") load();
|
|
563
|
-
return
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
mutate: v => (value = v)
|
|
568
|
-
}
|
|
569
|
-
]);
|
|
535
|
+
return resource.ref = [read, {
|
|
536
|
+
refetch: load,
|
|
537
|
+
mutate: v => value = v
|
|
538
|
+
}];
|
|
570
539
|
}
|
|
571
540
|
function lazy(fn) {
|
|
572
541
|
let p;
|
|
573
542
|
let load = id => {
|
|
574
543
|
if (!p) {
|
|
575
544
|
p = fn();
|
|
576
|
-
p.then(mod =>
|
|
545
|
+
p.then(mod => p.resolved = mod.default);
|
|
577
546
|
if (id) sharedConfig.context.lazy[id] = p;
|
|
578
547
|
}
|
|
579
548
|
return p;
|
|
@@ -582,8 +551,7 @@ function lazy(fn) {
|
|
|
582
551
|
const wrap = props => {
|
|
583
552
|
const id = sharedConfig.context.id.slice(0, -1);
|
|
584
553
|
let ref = sharedConfig.context.lazy[id];
|
|
585
|
-
if (ref) p = ref;
|
|
586
|
-
else load(id);
|
|
554
|
+
if (ref) p = ref;else load(id);
|
|
587
555
|
if (p.resolved) return p.resolved(props);
|
|
588
556
|
const ctx = useContext(SuspenseContext);
|
|
589
557
|
const track = {
|
|
@@ -595,12 +563,10 @@ function lazy(fn) {
|
|
|
595
563
|
contexts.add(ctx);
|
|
596
564
|
}
|
|
597
565
|
if (sharedConfig.context.async) {
|
|
598
|
-
sharedConfig.context.block(
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
})
|
|
603
|
-
);
|
|
566
|
+
sharedConfig.context.block(p.then(() => {
|
|
567
|
+
track.loading = false;
|
|
568
|
+
notifySuspense(contexts);
|
|
569
|
+
}));
|
|
604
570
|
}
|
|
605
571
|
return "";
|
|
606
572
|
};
|
|
@@ -628,12 +594,9 @@ function startTransition(fn) {
|
|
|
628
594
|
fn();
|
|
629
595
|
}
|
|
630
596
|
function useTransition() {
|
|
631
|
-
return [
|
|
632
|
-
()
|
|
633
|
-
|
|
634
|
-
fn();
|
|
635
|
-
}
|
|
636
|
-
];
|
|
597
|
+
return [() => false, fn => {
|
|
598
|
+
fn();
|
|
599
|
+
}];
|
|
637
600
|
}
|
|
638
601
|
function SuspenseList(props) {
|
|
639
602
|
return props.children;
|
|
@@ -643,17 +606,15 @@ function Suspense(props) {
|
|
|
643
606
|
const ctx = sharedConfig.context;
|
|
644
607
|
const id = ctx.id + ctx.count;
|
|
645
608
|
const o = createOwner();
|
|
646
|
-
const value =
|
|
647
|
-
|
|
648
|
-
(
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
if (suspenseComplete(value)) {
|
|
653
|
-
done(resolveSSRNode(res));
|
|
654
|
-
}
|
|
609
|
+
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
610
|
+
resources: new Map(),
|
|
611
|
+
completed: () => {
|
|
612
|
+
const res = runSuspense();
|
|
613
|
+
if (suspenseComplete(value)) {
|
|
614
|
+
done(resolveSSRNode(res));
|
|
655
615
|
}
|
|
656
|
-
}
|
|
616
|
+
}
|
|
617
|
+
});
|
|
657
618
|
function suspenseError(err) {
|
|
658
619
|
if (!done || !done(undefined, err)) {
|
|
659
620
|
runWithOwner(o.owner, () => {
|
|
@@ -667,14 +628,12 @@ function Suspense(props) {
|
|
|
667
628
|
count: 0
|
|
668
629
|
});
|
|
669
630
|
cleanNode(o);
|
|
670
|
-
return runWithOwner(o, () =>
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
})
|
|
677
|
-
);
|
|
631
|
+
return runWithOwner(o, () => createComponent(SuspenseContext.Provider, {
|
|
632
|
+
value,
|
|
633
|
+
get children() {
|
|
634
|
+
return catchError(() => props.children, suspenseError);
|
|
635
|
+
}
|
|
636
|
+
}));
|
|
678
637
|
}
|
|
679
638
|
const res = runSuspense();
|
|
680
639
|
if (suspenseComplete(value)) return res;
|
|
@@ -703,57 +662,4 @@ function Suspense(props) {
|
|
|
703
662
|
}, suspenseError);
|
|
704
663
|
}
|
|
705
664
|
|
|
706
|
-
export {
|
|
707
|
-
$DEVCOMP,
|
|
708
|
-
$PROXY,
|
|
709
|
-
$TRACK,
|
|
710
|
-
DEV,
|
|
711
|
-
ErrorBoundary,
|
|
712
|
-
For,
|
|
713
|
-
Index,
|
|
714
|
-
Match,
|
|
715
|
-
Show,
|
|
716
|
-
Suspense,
|
|
717
|
-
SuspenseList,
|
|
718
|
-
Switch,
|
|
719
|
-
batch,
|
|
720
|
-
catchError,
|
|
721
|
-
children,
|
|
722
|
-
createComponent,
|
|
723
|
-
createComputed,
|
|
724
|
-
createContext,
|
|
725
|
-
createDeferred,
|
|
726
|
-
createEffect,
|
|
727
|
-
createMemo,
|
|
728
|
-
createReaction,
|
|
729
|
-
createRenderEffect,
|
|
730
|
-
createResource,
|
|
731
|
-
createRoot,
|
|
732
|
-
createSelector,
|
|
733
|
-
createSignal,
|
|
734
|
-
createUniqueId,
|
|
735
|
-
enableExternalSource,
|
|
736
|
-
enableHydration,
|
|
737
|
-
enableScheduling,
|
|
738
|
-
equalFn,
|
|
739
|
-
from,
|
|
740
|
-
getListener,
|
|
741
|
-
getOwner,
|
|
742
|
-
lazy,
|
|
743
|
-
mapArray,
|
|
744
|
-
mergeProps,
|
|
745
|
-
observable,
|
|
746
|
-
on,
|
|
747
|
-
onCleanup,
|
|
748
|
-
onError,
|
|
749
|
-
onMount,
|
|
750
|
-
requestCallback,
|
|
751
|
-
resetErrorBoundaries,
|
|
752
|
-
runWithOwner,
|
|
753
|
-
sharedConfig,
|
|
754
|
-
splitProps,
|
|
755
|
-
startTransition,
|
|
756
|
-
untrack,
|
|
757
|
-
useContext,
|
|
758
|
-
useTransition
|
|
759
|
-
};
|
|
665
|
+
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, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
package/dist/solid.cjs
CHANGED
|
@@ -545,7 +545,7 @@ function children(fn) {
|
|
|
545
545
|
}
|
|
546
546
|
let SuspenseContext;
|
|
547
547
|
function getSuspenseContext() {
|
|
548
|
-
return SuspenseContext || (SuspenseContext = createContext(
|
|
548
|
+
return SuspenseContext || (SuspenseContext = createContext());
|
|
549
549
|
}
|
|
550
550
|
function enableExternalSource(factory) {
|
|
551
551
|
if (ExternalSourceFactory) {
|