solid-js 1.7.8 → 1.7.9
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 +534 -296
- package/dist/server.js +175 -77
- package/dist/solid.js +461 -254
- package/h/dist/h.cjs +2 -2
- package/h/dist/h.js +36 -10
- 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 +3 -0
- package/h/types/hyperscript.d.ts +11 -11
- package/h/types/index.d.ts +3 -2
- package/html/dist/html.cjs +2 -2
- package/html/dist/html.js +218 -96
- package/html/types/index.d.ts +3 -2
- package/html/types/lit.d.ts +45 -31
- package/package.json +1 -1
- package/store/dist/dev.cjs +34 -32
- package/store/dist/dev.js +141 -67
- package/store/dist/server.js +19 -8
- package/store/dist/store.cjs +34 -32
- package/store/dist/store.js +132 -64
- 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 +217 -63
- package/types/index.d.ts +69 -9
- package/types/jsx.d.ts +3 -0
- 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 +227 -136
- 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 +12 -12
- package/types/server/index.d.ts +55 -2
- package/types/server/reactive.d.ts +67 -40
- package/types/server/rendering.d.ts +171 -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 +610 -79
- package/web/dist/server.js +176 -77
- package/web/dist/web.js +610 -79
- 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,18 +35,22 @@ 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
|
-
root =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
root =
|
|
46
|
+
fn.length === 0
|
|
47
|
+
? UNOWNED
|
|
48
|
+
: {
|
|
49
|
+
context: null,
|
|
50
|
+
owner: detachedOwner === undefined ? owner : detachedOwner,
|
|
51
|
+
owned: null,
|
|
52
|
+
cleanups: null
|
|
53
|
+
};
|
|
50
54
|
Owner = root;
|
|
51
55
|
let result;
|
|
52
56
|
try {
|
|
@@ -59,9 +63,12 @@ function createRoot(fn, detachedOwner) {
|
|
|
59
63
|
return result;
|
|
60
64
|
}
|
|
61
65
|
function createSignal(value, options) {
|
|
62
|
-
return [
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
return [
|
|
67
|
+
() => value,
|
|
68
|
+
v => {
|
|
69
|
+
return (value = typeof v === "function" ? v(value) : v);
|
|
70
|
+
}
|
|
71
|
+
];
|
|
65
72
|
}
|
|
66
73
|
function createComputed(fn, value) {
|
|
67
74
|
Owner = createOwner();
|
|
@@ -118,7 +125,8 @@ function on(deps, fn, options = {}) {
|
|
|
118
125
|
function onMount(fn) {}
|
|
119
126
|
function onCleanup(fn) {
|
|
120
127
|
if (Owner) {
|
|
121
|
-
if (!Owner.cleanups) Owner.cleanups = [fn];
|
|
128
|
+
if (!Owner.cleanups) Owner.cleanups = [fn];
|
|
129
|
+
else Owner.cleanups.push(fn);
|
|
122
130
|
}
|
|
123
131
|
return fn;
|
|
124
132
|
}
|
|
@@ -151,9 +159,12 @@ function catchError(fn, handler) {
|
|
|
151
159
|
}
|
|
152
160
|
function onError(fn) {
|
|
153
161
|
if (Owner) {
|
|
154
|
-
if (Owner.context === null)
|
|
155
|
-
|
|
156
|
-
|
|
162
|
+
if (Owner.context === null)
|
|
163
|
+
Owner.context = {
|
|
164
|
+
[ERROR]: [fn]
|
|
165
|
+
};
|
|
166
|
+
else if (!Owner.context[ERROR]) Owner.context[ERROR] = [fn];
|
|
167
|
+
else Owner.context[ERROR].push(fn);
|
|
157
168
|
}
|
|
158
169
|
}
|
|
159
170
|
function getListener() {
|
|
@@ -194,7 +205,11 @@ function runWithOwner(o, fn) {
|
|
|
194
205
|
}
|
|
195
206
|
}
|
|
196
207
|
function lookup(owner, key) {
|
|
197
|
-
return owner
|
|
208
|
+
return owner
|
|
209
|
+
? owner.context && owner.context[key] !== undefined
|
|
210
|
+
? owner.context[key]
|
|
211
|
+
: lookup(owner.owner, key)
|
|
212
|
+
: undefined;
|
|
198
213
|
}
|
|
199
214
|
function resolveChildren(children) {
|
|
200
215
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -240,7 +255,8 @@ function observable(input) {
|
|
|
240
255
|
if (!(observer instanceof Object) || observer == null) {
|
|
241
256
|
throw new TypeError("Expected the observer to be an object.");
|
|
242
257
|
}
|
|
243
|
-
const handler =
|
|
258
|
+
const handler =
|
|
259
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
244
260
|
if (!handler) {
|
|
245
261
|
return {
|
|
246
262
|
unsubscribe() {}
|
|
@@ -269,7 +285,7 @@ function from(producer) {
|
|
|
269
285
|
const [s, set] = createSignal(undefined);
|
|
270
286
|
if ("subscribe" in producer) {
|
|
271
287
|
const unsub = producer.subscribe(v => set(() => v));
|
|
272
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
288
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
273
289
|
} else {
|
|
274
290
|
const clean = producer(set);
|
|
275
291
|
onCleanup(clean);
|
|
@@ -296,11 +312,13 @@ function setHydrateContext(context) {
|
|
|
296
312
|
sharedConfig.context = context;
|
|
297
313
|
}
|
|
298
314
|
function nextHydrateContext() {
|
|
299
|
-
return sharedConfig.context
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
315
|
+
return sharedConfig.context
|
|
316
|
+
? {
|
|
317
|
+
...sharedConfig.context,
|
|
318
|
+
id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
|
|
319
|
+
count: 0
|
|
320
|
+
}
|
|
321
|
+
: undefined;
|
|
304
322
|
}
|
|
305
323
|
function createUniqueId() {
|
|
306
324
|
const ctx = sharedConfig.context;
|
|
@@ -376,7 +394,11 @@ function Index(props) {
|
|
|
376
394
|
}
|
|
377
395
|
function Show(props) {
|
|
378
396
|
let c;
|
|
379
|
-
return props.when
|
|
397
|
+
return props.when
|
|
398
|
+
? typeof (c = props.children) === "function"
|
|
399
|
+
? c(props.keyed ? props.when : () => props.when)
|
|
400
|
+
: c
|
|
401
|
+
: props.fallback || "";
|
|
380
402
|
}
|
|
381
403
|
function Switch(props) {
|
|
382
404
|
let conditions = props.children;
|
|
@@ -413,11 +435,14 @@ function ErrorBoundary(props) {
|
|
|
413
435
|
}
|
|
414
436
|
createMemo(() => {
|
|
415
437
|
clean = Owner;
|
|
416
|
-
return catchError(
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
438
|
+
return catchError(
|
|
439
|
+
() => (res = props.children),
|
|
440
|
+
err => {
|
|
441
|
+
error = err;
|
|
442
|
+
!sync && ctx.replace("e" + id, displayFallback);
|
|
443
|
+
sync = true;
|
|
444
|
+
}
|
|
445
|
+
);
|
|
421
446
|
});
|
|
422
447
|
if (error) return displayFallback();
|
|
423
448
|
sync = false;
|
|
@@ -447,14 +472,18 @@ function createResource(source, fetcher, options = {}) {
|
|
|
447
472
|
if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
|
|
448
473
|
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
449
474
|
if (resource.ref) {
|
|
450
|
-
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
|
|
475
|
+
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
|
|
476
|
+
resource.ref[1].refetch();
|
|
451
477
|
return resource.ref;
|
|
452
478
|
}
|
|
453
479
|
}
|
|
454
480
|
const read = () => {
|
|
455
481
|
if (error) throw error;
|
|
456
482
|
if (resourceContext && p) resourceContext.push(p);
|
|
457
|
-
const resolved =
|
|
483
|
+
const resolved =
|
|
484
|
+
options.ssrLoadFrom !== "initial" &&
|
|
485
|
+
sharedConfig.context.async &&
|
|
486
|
+
"data" in sharedConfig.context.resources[id];
|
|
458
487
|
if (!resolved && read.loading) {
|
|
459
488
|
const ctx = useContext(SuspenseContext);
|
|
460
489
|
if (ctx) {
|
|
@@ -474,7 +503,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
474
503
|
});
|
|
475
504
|
function load() {
|
|
476
505
|
const ctx = sharedConfig.context;
|
|
477
|
-
if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
|
|
506
|
+
if (!ctx.async) return (read.loading = !!(typeof source === "function" ? source() : source));
|
|
478
507
|
if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
|
|
479
508
|
value = ctx.resources[id].data;
|
|
480
509
|
return;
|
|
@@ -482,9 +511,11 @@ function createResource(source, fetcher, options = {}) {
|
|
|
482
511
|
resourceContext = [];
|
|
483
512
|
const lookup = typeof source === "function" ? source() : source;
|
|
484
513
|
if (resourceContext.length) {
|
|
485
|
-
p = Promise.all(resourceContext).then(() =>
|
|
486
|
-
|
|
487
|
-
|
|
514
|
+
p = Promise.all(resourceContext).then(() =>
|
|
515
|
+
fetcher(source(), {
|
|
516
|
+
value
|
|
517
|
+
})
|
|
518
|
+
);
|
|
488
519
|
}
|
|
489
520
|
resourceContext = null;
|
|
490
521
|
if (!p) {
|
|
@@ -497,20 +528,22 @@ function createResource(source, fetcher, options = {}) {
|
|
|
497
528
|
read.loading = true;
|
|
498
529
|
read.state = "pending";
|
|
499
530
|
if (ctx.writeResource) ctx.writeResource(id, p, undefined, options.deferStream);
|
|
500
|
-
return p
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
531
|
+
return p
|
|
532
|
+
.then(res => {
|
|
533
|
+
read.loading = false;
|
|
534
|
+
read.state = "ready";
|
|
535
|
+
ctx.resources[id].data = res;
|
|
536
|
+
p = null;
|
|
537
|
+
notifySuspense(contexts);
|
|
538
|
+
return res;
|
|
539
|
+
})
|
|
540
|
+
.catch(err => {
|
|
541
|
+
read.loading = false;
|
|
542
|
+
read.state = "errored";
|
|
543
|
+
read.error = error = castError(err);
|
|
544
|
+
p = null;
|
|
545
|
+
notifySuspense(contexts);
|
|
546
|
+
});
|
|
514
547
|
}
|
|
515
548
|
ctx.resources[id].data = p;
|
|
516
549
|
if (ctx.writeResource) ctx.writeResource(id, p);
|
|
@@ -518,17 +551,20 @@ function createResource(source, fetcher, options = {}) {
|
|
|
518
551
|
return ctx.resources[id].data;
|
|
519
552
|
}
|
|
520
553
|
if (options.ssrLoadFrom !== "initial") load();
|
|
521
|
-
return resource.ref = [
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
554
|
+
return (resource.ref = [
|
|
555
|
+
read,
|
|
556
|
+
{
|
|
557
|
+
refetch: load,
|
|
558
|
+
mutate: v => (value = v)
|
|
559
|
+
}
|
|
560
|
+
]);
|
|
525
561
|
}
|
|
526
562
|
function lazy(fn) {
|
|
527
563
|
let p;
|
|
528
564
|
let load = id => {
|
|
529
565
|
if (!p) {
|
|
530
566
|
p = fn();
|
|
531
|
-
p.then(mod => p.resolved = mod.default);
|
|
567
|
+
p.then(mod => (p.resolved = mod.default));
|
|
532
568
|
if (id) sharedConfig.context.lazy[id] = p;
|
|
533
569
|
}
|
|
534
570
|
return p;
|
|
@@ -537,7 +573,8 @@ function lazy(fn) {
|
|
|
537
573
|
const wrap = props => {
|
|
538
574
|
const id = sharedConfig.context.id.slice(0, -1);
|
|
539
575
|
let ref = sharedConfig.context.lazy[id];
|
|
540
|
-
if (ref) p = ref;
|
|
576
|
+
if (ref) p = ref;
|
|
577
|
+
else load(id);
|
|
541
578
|
if (p.resolved) return p.resolved(props);
|
|
542
579
|
const ctx = useContext(SuspenseContext);
|
|
543
580
|
const track = {
|
|
@@ -549,10 +586,12 @@ function lazy(fn) {
|
|
|
549
586
|
contexts.add(ctx);
|
|
550
587
|
}
|
|
551
588
|
if (sharedConfig.context.async) {
|
|
552
|
-
sharedConfig.context.block(
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
589
|
+
sharedConfig.context.block(
|
|
590
|
+
p.then(() => {
|
|
591
|
+
track.loading = false;
|
|
592
|
+
notifySuspense(contexts);
|
|
593
|
+
})
|
|
594
|
+
);
|
|
556
595
|
}
|
|
557
596
|
return "";
|
|
558
597
|
};
|
|
@@ -580,9 +619,12 @@ function startTransition(fn) {
|
|
|
580
619
|
fn();
|
|
581
620
|
}
|
|
582
621
|
function useTransition() {
|
|
583
|
-
return [
|
|
584
|
-
|
|
585
|
-
|
|
622
|
+
return [
|
|
623
|
+
() => false,
|
|
624
|
+
fn => {
|
|
625
|
+
fn();
|
|
626
|
+
}
|
|
627
|
+
];
|
|
586
628
|
}
|
|
587
629
|
function SuspenseList(props) {
|
|
588
630
|
return props.children;
|
|
@@ -592,15 +634,17 @@ function Suspense(props) {
|
|
|
592
634
|
const ctx = sharedConfig.context;
|
|
593
635
|
const id = ctx.id + ctx.count;
|
|
594
636
|
const o = createOwner();
|
|
595
|
-
const value =
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
637
|
+
const value =
|
|
638
|
+
ctx.suspense[id] ||
|
|
639
|
+
(ctx.suspense[id] = {
|
|
640
|
+
resources: new Map(),
|
|
641
|
+
completed: () => {
|
|
642
|
+
const res = runSuspense();
|
|
643
|
+
if (suspenseComplete(value)) {
|
|
644
|
+
done(resolveSSRNode(res));
|
|
645
|
+
}
|
|
601
646
|
}
|
|
602
|
-
}
|
|
603
|
-
});
|
|
647
|
+
});
|
|
604
648
|
function suspenseError(err) {
|
|
605
649
|
if (!done || !done(undefined, err)) {
|
|
606
650
|
runWithOwner(o.owner, () => {
|
|
@@ -614,12 +658,14 @@ function Suspense(props) {
|
|
|
614
658
|
count: 0
|
|
615
659
|
});
|
|
616
660
|
cleanNode(o);
|
|
617
|
-
return runWithOwner(o, () =>
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
661
|
+
return runWithOwner(o, () =>
|
|
662
|
+
createComponent(SuspenseContext.Provider, {
|
|
663
|
+
value,
|
|
664
|
+
get children() {
|
|
665
|
+
return catchError(() => props.children, suspenseError);
|
|
666
|
+
}
|
|
667
|
+
})
|
|
668
|
+
);
|
|
623
669
|
}
|
|
624
670
|
const res = runSuspense();
|
|
625
671
|
if (suspenseComplete(value)) return res;
|
|
@@ -648,4 +694,56 @@ function Suspense(props) {
|
|
|
648
694
|
}, suspenseError);
|
|
649
695
|
}
|
|
650
696
|
|
|
651
|
-
export {
|
|
697
|
+
export {
|
|
698
|
+
$DEVCOMP,
|
|
699
|
+
$PROXY,
|
|
700
|
+
$TRACK,
|
|
701
|
+
DEV,
|
|
702
|
+
ErrorBoundary,
|
|
703
|
+
For,
|
|
704
|
+
Index,
|
|
705
|
+
Match,
|
|
706
|
+
Show,
|
|
707
|
+
Suspense,
|
|
708
|
+
SuspenseList,
|
|
709
|
+
Switch,
|
|
710
|
+
batch,
|
|
711
|
+
children,
|
|
712
|
+
createComponent,
|
|
713
|
+
createComputed,
|
|
714
|
+
createContext,
|
|
715
|
+
createDeferred,
|
|
716
|
+
createEffect,
|
|
717
|
+
createMemo,
|
|
718
|
+
createReaction,
|
|
719
|
+
createRenderEffect,
|
|
720
|
+
createResource,
|
|
721
|
+
createRoot,
|
|
722
|
+
createSelector,
|
|
723
|
+
createSignal,
|
|
724
|
+
createUniqueId,
|
|
725
|
+
enableExternalSource,
|
|
726
|
+
enableHydration,
|
|
727
|
+
enableScheduling,
|
|
728
|
+
equalFn,
|
|
729
|
+
from,
|
|
730
|
+
getListener,
|
|
731
|
+
getOwner,
|
|
732
|
+
lazy,
|
|
733
|
+
mapArray,
|
|
734
|
+
mergeProps,
|
|
735
|
+
observable,
|
|
736
|
+
on,
|
|
737
|
+
onCleanup,
|
|
738
|
+
onError,
|
|
739
|
+
onMount,
|
|
740
|
+
requestCallback,
|
|
741
|
+
resetErrorBoundaries,
|
|
742
|
+
runWithOwner,
|
|
743
|
+
sharedConfig,
|
|
744
|
+
splitProps,
|
|
745
|
+
startTransition,
|
|
746
|
+
untrack,
|
|
747
|
+
useContext,
|
|
748
|
+
useTransition
|
|
749
|
+
};
|