solid-js 1.7.0-beta.0 → 1.7.0-beta.2
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/LICENSE +1 -1
- package/dist/dev.cjs +35 -15
- package/dist/dev.js +35 -16
- package/dist/server.cjs +88 -69
- package/dist/server.js +88 -69
- package/dist/solid.cjs +31 -12
- package/dist/solid.js +31 -13
- package/h/jsx-runtime/types/jsx.d.ts +3 -0
- package/html/dist/html.cjs +14 -10
- package/html/dist/html.js +15 -11
- package/html/types/lit.d.ts +1 -1
- package/package.json +3 -2
- package/store/dist/dev.cjs +2 -5
- package/store/dist/dev.js +2 -5
- package/store/dist/store.cjs +2 -5
- package/store/dist/store.js +2 -5
- package/types/index.d.ts +1 -1
- package/types/jsx.d.ts +4 -0
- package/types/reactive/array.d.ts +23 -0
- package/types/reactive/signal.d.ts +36 -1
- package/types/render/flow.d.ts +15 -13
- package/types/server/reactive.d.ts +8 -4
- package/types/server/rendering.d.ts +7 -3
- package/web/dist/dev.cjs +88 -55
- package/web/dist/dev.js +88 -56
- package/web/dist/server.cjs +40 -283
- package/web/dist/server.js +41 -285
- package/web/dist/web.cjs +94 -55
- package/web/dist/web.js +94 -56
- package/web/types/client.d.ts +2 -2
- package/web/types/index.d.ts +2 -1
package/LICENSE
CHANGED
package/dist/dev.cjs
CHANGED
|
@@ -461,6 +461,20 @@ function onCleanup(fn) {
|
|
|
461
461
|
if (Owner === null) console.warn("cleanups created outside a `createRoot` or `render` will never be run");else if (Owner.cleanups === null) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
|
|
462
462
|
return fn;
|
|
463
463
|
}
|
|
464
|
+
function catchError(fn, handler) {
|
|
465
|
+
ERROR || (ERROR = Symbol("error"));
|
|
466
|
+
Owner = createComputation(undefined, undefined, true);
|
|
467
|
+
Owner.context = {
|
|
468
|
+
[ERROR]: [handler]
|
|
469
|
+
};
|
|
470
|
+
try {
|
|
471
|
+
return fn();
|
|
472
|
+
} catch (err) {
|
|
473
|
+
handleError(err);
|
|
474
|
+
} finally {
|
|
475
|
+
Owner = Owner.owner;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
464
478
|
function onError(fn) {
|
|
465
479
|
ERROR || (ERROR = Symbol("error"));
|
|
466
480
|
if (Owner === null) console.warn("error handlers created outside a `createRoot` or `render` will never be run");else if (Owner.context === null) Owner.context = {
|
|
@@ -535,7 +549,8 @@ function devComponent(Comp, props) {
|
|
|
535
549
|
c.props = props;
|
|
536
550
|
c.observers = null;
|
|
537
551
|
c.observerSlots = null;
|
|
538
|
-
c.
|
|
552
|
+
c.name = Comp.name;
|
|
553
|
+
c.component = Comp;
|
|
539
554
|
updateComputation(c);
|
|
540
555
|
return c.tValue !== undefined ? c.tValue : c.value;
|
|
541
556
|
}
|
|
@@ -644,7 +659,7 @@ function writeSignal(node, value, isComp) {
|
|
|
644
659
|
}
|
|
645
660
|
if (Updates.length > 10e5) {
|
|
646
661
|
Updates = [];
|
|
647
|
-
if (
|
|
662
|
+
if (true) throw new Error("Potential Infinite Loop Detected.");
|
|
648
663
|
throw new Error();
|
|
649
664
|
}
|
|
650
665
|
}, false);
|
|
@@ -689,7 +704,8 @@ function runComputation(node, value, time) {
|
|
|
689
704
|
node.owned = null;
|
|
690
705
|
}
|
|
691
706
|
}
|
|
692
|
-
|
|
707
|
+
node.updatedAt = time + 1;
|
|
708
|
+
return handleError(err);
|
|
693
709
|
}
|
|
694
710
|
if (!node.updatedAt || node.updatedAt <= time) {
|
|
695
711
|
if (node.updatedAt != null && "observers" in node) {
|
|
@@ -870,7 +886,7 @@ function lookUpstream(node, ignore) {
|
|
|
870
886
|
const source = node.sources[i];
|
|
871
887
|
if (source.sources) {
|
|
872
888
|
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
|
|
873
|
-
if (source !== ignore) runTop(source);
|
|
889
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
|
|
874
890
|
} else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookUpstream(source, ignore);
|
|
875
891
|
}
|
|
876
892
|
}
|
|
@@ -906,16 +922,16 @@ function cleanNode(node) {
|
|
|
906
922
|
}
|
|
907
923
|
if (Transition && Transition.running && node.pure) {
|
|
908
924
|
if (node.tOwned) {
|
|
909
|
-
for (i =
|
|
925
|
+
for (i = node.tOwned.length - 1; i >= 0; i--) cleanNode(node.tOwned[i]);
|
|
910
926
|
delete node.tOwned;
|
|
911
927
|
}
|
|
912
928
|
reset(node, true);
|
|
913
929
|
} else if (node.owned) {
|
|
914
|
-
for (i =
|
|
930
|
+
for (i = node.owned.length - 1; i >= 0; i--) cleanNode(node.owned[i]);
|
|
915
931
|
node.owned = null;
|
|
916
932
|
}
|
|
917
933
|
if (node.cleanups) {
|
|
918
|
-
for (i =
|
|
934
|
+
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
919
935
|
node.cleanups = null;
|
|
920
936
|
}
|
|
921
937
|
if (Transition && Transition.running) node.tState = 0;else node.state = 0;
|
|
@@ -1360,7 +1376,7 @@ function lazy(fn) {
|
|
|
1360
1376
|
}
|
|
1361
1377
|
let Comp;
|
|
1362
1378
|
return createMemo(() => (Comp = comp()) && untrack(() => {
|
|
1363
|
-
if (
|
|
1379
|
+
if (true) Object.assign(Comp, {
|
|
1364
1380
|
[$DEVCOMP]: true
|
|
1365
1381
|
});
|
|
1366
1382
|
if (!ctx) return Comp(props);
|
|
@@ -1407,7 +1423,10 @@ function Show(props) {
|
|
|
1407
1423
|
if (c) {
|
|
1408
1424
|
const child = props.children;
|
|
1409
1425
|
const fn = typeof child === "function" && child.length > 0;
|
|
1410
|
-
return fn ? untrack(() => child(keyed ? c : () =>
|
|
1426
|
+
return fn ? untrack(() => child(keyed ? c : () => {
|
|
1427
|
+
if (true && !untrack(condition)) console.warn("Accessing stale value from Show.");
|
|
1428
|
+
return props.when;
|
|
1429
|
+
})) : child;
|
|
1411
1430
|
}
|
|
1412
1431
|
return props.fallback;
|
|
1413
1432
|
}, undefined, {
|
|
@@ -1438,7 +1457,10 @@ function Switch(props) {
|
|
|
1438
1457
|
if (index < 0) return props.fallback;
|
|
1439
1458
|
const c = cond.children;
|
|
1440
1459
|
const fn = typeof c === "function" && c.length > 0;
|
|
1441
|
-
return fn ? untrack(() => c(keyed ? when : () =>
|
|
1460
|
+
return fn ? untrack(() => c(keyed ? when : () => {
|
|
1461
|
+
if (true && untrack(evalConditions)[0] !== index) console.warn("Accessing stale value from Match.");
|
|
1462
|
+
return cond.when;
|
|
1463
|
+
})) : c;
|
|
1442
1464
|
}, undefined, {
|
|
1443
1465
|
name: "value"
|
|
1444
1466
|
} );
|
|
@@ -1465,12 +1487,9 @@ function ErrorBoundary(props) {
|
|
|
1465
1487
|
if (e = errored()) {
|
|
1466
1488
|
const f = props.fallback;
|
|
1467
1489
|
if ((typeof f !== "function" || f.length == 0)) console.error(e);
|
|
1468
|
-
|
|
1469
|
-
onError(setErrored);
|
|
1470
|
-
return res;
|
|
1490
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1471
1491
|
}
|
|
1472
|
-
|
|
1473
|
-
return props.children;
|
|
1492
|
+
return catchError(() => props.children, setErrored);
|
|
1474
1493
|
}, undefined, {
|
|
1475
1494
|
name: "value"
|
|
1476
1495
|
} );
|
|
@@ -1665,6 +1684,7 @@ exports.SuspenseList = SuspenseList;
|
|
|
1665
1684
|
exports.Switch = Switch;
|
|
1666
1685
|
exports.batch = batch;
|
|
1667
1686
|
exports.cancelCallback = cancelCallback;
|
|
1687
|
+
exports.catchError = catchError;
|
|
1668
1688
|
exports.children = children;
|
|
1669
1689
|
exports.createComponent = createComponent;
|
|
1670
1690
|
exports.createComputed = createComputed;
|
package/dist/dev.js
CHANGED
|
@@ -459,6 +459,20 @@ function onCleanup(fn) {
|
|
|
459
459
|
if (Owner === null) console.warn("cleanups created outside a `createRoot` or `render` will never be run");else if (Owner.cleanups === null) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
|
|
460
460
|
return fn;
|
|
461
461
|
}
|
|
462
|
+
function catchError(fn, handler) {
|
|
463
|
+
ERROR || (ERROR = Symbol("error"));
|
|
464
|
+
Owner = createComputation(undefined, undefined, true);
|
|
465
|
+
Owner.context = {
|
|
466
|
+
[ERROR]: [handler]
|
|
467
|
+
};
|
|
468
|
+
try {
|
|
469
|
+
return fn();
|
|
470
|
+
} catch (err) {
|
|
471
|
+
handleError(err);
|
|
472
|
+
} finally {
|
|
473
|
+
Owner = Owner.owner;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
462
476
|
function onError(fn) {
|
|
463
477
|
ERROR || (ERROR = Symbol("error"));
|
|
464
478
|
if (Owner === null) console.warn("error handlers created outside a `createRoot` or `render` will never be run");else if (Owner.context === null) Owner.context = {
|
|
@@ -533,7 +547,8 @@ function devComponent(Comp, props) {
|
|
|
533
547
|
c.props = props;
|
|
534
548
|
c.observers = null;
|
|
535
549
|
c.observerSlots = null;
|
|
536
|
-
c.
|
|
550
|
+
c.name = Comp.name;
|
|
551
|
+
c.component = Comp;
|
|
537
552
|
updateComputation(c);
|
|
538
553
|
return c.tValue !== undefined ? c.tValue : c.value;
|
|
539
554
|
}
|
|
@@ -642,7 +657,7 @@ function writeSignal(node, value, isComp) {
|
|
|
642
657
|
}
|
|
643
658
|
if (Updates.length > 10e5) {
|
|
644
659
|
Updates = [];
|
|
645
|
-
if (
|
|
660
|
+
if (true) throw new Error("Potential Infinite Loop Detected.");
|
|
646
661
|
throw new Error();
|
|
647
662
|
}
|
|
648
663
|
}, false);
|
|
@@ -687,7 +702,8 @@ function runComputation(node, value, time) {
|
|
|
687
702
|
node.owned = null;
|
|
688
703
|
}
|
|
689
704
|
}
|
|
690
|
-
|
|
705
|
+
node.updatedAt = time + 1;
|
|
706
|
+
return handleError(err);
|
|
691
707
|
}
|
|
692
708
|
if (!node.updatedAt || node.updatedAt <= time) {
|
|
693
709
|
if (node.updatedAt != null && "observers" in node) {
|
|
@@ -868,7 +884,7 @@ function lookUpstream(node, ignore) {
|
|
|
868
884
|
const source = node.sources[i];
|
|
869
885
|
if (source.sources) {
|
|
870
886
|
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
|
|
871
|
-
if (source !== ignore) runTop(source);
|
|
887
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
|
|
872
888
|
} else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookUpstream(source, ignore);
|
|
873
889
|
}
|
|
874
890
|
}
|
|
@@ -904,16 +920,16 @@ function cleanNode(node) {
|
|
|
904
920
|
}
|
|
905
921
|
if (Transition && Transition.running && node.pure) {
|
|
906
922
|
if (node.tOwned) {
|
|
907
|
-
for (i =
|
|
923
|
+
for (i = node.tOwned.length - 1; i >= 0; i--) cleanNode(node.tOwned[i]);
|
|
908
924
|
delete node.tOwned;
|
|
909
925
|
}
|
|
910
926
|
reset(node, true);
|
|
911
927
|
} else if (node.owned) {
|
|
912
|
-
for (i =
|
|
928
|
+
for (i = node.owned.length - 1; i >= 0; i--) cleanNode(node.owned[i]);
|
|
913
929
|
node.owned = null;
|
|
914
930
|
}
|
|
915
931
|
if (node.cleanups) {
|
|
916
|
-
for (i =
|
|
932
|
+
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
917
933
|
node.cleanups = null;
|
|
918
934
|
}
|
|
919
935
|
if (Transition && Transition.running) node.tState = 0;else node.state = 0;
|
|
@@ -1358,7 +1374,7 @@ function lazy(fn) {
|
|
|
1358
1374
|
}
|
|
1359
1375
|
let Comp;
|
|
1360
1376
|
return createMemo(() => (Comp = comp()) && untrack(() => {
|
|
1361
|
-
if (
|
|
1377
|
+
if (true) Object.assign(Comp, {
|
|
1362
1378
|
[$DEVCOMP]: true
|
|
1363
1379
|
});
|
|
1364
1380
|
if (!ctx) return Comp(props);
|
|
@@ -1405,7 +1421,10 @@ function Show(props) {
|
|
|
1405
1421
|
if (c) {
|
|
1406
1422
|
const child = props.children;
|
|
1407
1423
|
const fn = typeof child === "function" && child.length > 0;
|
|
1408
|
-
return fn ? untrack(() => child(keyed ? c : () =>
|
|
1424
|
+
return fn ? untrack(() => child(keyed ? c : () => {
|
|
1425
|
+
if (true && !untrack(condition)) console.warn("Accessing stale value from Show.");
|
|
1426
|
+
return props.when;
|
|
1427
|
+
})) : child;
|
|
1409
1428
|
}
|
|
1410
1429
|
return props.fallback;
|
|
1411
1430
|
}, undefined, {
|
|
@@ -1436,7 +1455,10 @@ function Switch(props) {
|
|
|
1436
1455
|
if (index < 0) return props.fallback;
|
|
1437
1456
|
const c = cond.children;
|
|
1438
1457
|
const fn = typeof c === "function" && c.length > 0;
|
|
1439
|
-
return fn ? untrack(() => c(keyed ? when : () =>
|
|
1458
|
+
return fn ? untrack(() => c(keyed ? when : () => {
|
|
1459
|
+
if (true && untrack(evalConditions)[0] !== index) console.warn("Accessing stale value from Match.");
|
|
1460
|
+
return cond.when;
|
|
1461
|
+
})) : c;
|
|
1440
1462
|
}, undefined, {
|
|
1441
1463
|
name: "value"
|
|
1442
1464
|
} );
|
|
@@ -1463,12 +1485,9 @@ function ErrorBoundary(props) {
|
|
|
1463
1485
|
if (e = errored()) {
|
|
1464
1486
|
const f = props.fallback;
|
|
1465
1487
|
if ((typeof f !== "function" || f.length == 0)) console.error(e);
|
|
1466
|
-
|
|
1467
|
-
onError(setErrored);
|
|
1468
|
-
return res;
|
|
1488
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1469
1489
|
}
|
|
1470
|
-
|
|
1471
|
-
return props.children;
|
|
1490
|
+
return catchError(() => props.children, setErrored);
|
|
1472
1491
|
}, undefined, {
|
|
1473
1492
|
name: "value"
|
|
1474
1493
|
} );
|
|
@@ -1650,4 +1669,4 @@ if (globalThis) {
|
|
|
1650
1669
|
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
1651
1670
|
}
|
|
1652
1671
|
|
|
1653
|
-
export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, 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 };
|
|
1672
|
+
export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, 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/server.cjs
CHANGED
|
@@ -6,7 +6,6 @@ const $TRACK = Symbol("solid-track");
|
|
|
6
6
|
const $DEVCOMP = Symbol("solid-dev-component");
|
|
7
7
|
const DEV = undefined;
|
|
8
8
|
const ERROR = Symbol("error");
|
|
9
|
-
const BRANCH = Symbol("branch");
|
|
10
9
|
function castError(err) {
|
|
11
10
|
if (err instanceof Error) return err;
|
|
12
11
|
return new Error(typeof err === "string" ? err : "Unknown error", {
|
|
@@ -21,19 +20,35 @@ function handleError(err) {
|
|
|
21
20
|
}
|
|
22
21
|
const UNOWNED = {
|
|
23
22
|
context: null,
|
|
24
|
-
owner: null
|
|
23
|
+
owner: null,
|
|
24
|
+
owned: null,
|
|
25
|
+
cleanups: null
|
|
25
26
|
};
|
|
26
27
|
let Owner = null;
|
|
28
|
+
function createOwner() {
|
|
29
|
+
const o = {
|
|
30
|
+
owner: Owner,
|
|
31
|
+
context: null,
|
|
32
|
+
owned: null,
|
|
33
|
+
cleanups: null
|
|
34
|
+
};
|
|
35
|
+
if (Owner) {
|
|
36
|
+
if (!Owner.owned) Owner.owned = [o];else Owner.owned.push(o);
|
|
37
|
+
}
|
|
38
|
+
return o;
|
|
39
|
+
}
|
|
27
40
|
function createRoot(fn, detachedOwner) {
|
|
28
41
|
const owner = Owner,
|
|
29
42
|
root = fn.length === 0 ? UNOWNED : {
|
|
30
43
|
context: null,
|
|
31
|
-
owner: detachedOwner === undefined ? owner : detachedOwner
|
|
44
|
+
owner: detachedOwner === undefined ? owner : detachedOwner,
|
|
45
|
+
owned: null,
|
|
46
|
+
cleanups: null
|
|
32
47
|
};
|
|
33
48
|
Owner = root;
|
|
34
49
|
let result;
|
|
35
50
|
try {
|
|
36
|
-
result = fn(() => {});
|
|
51
|
+
result = fn(fn.length === 0 ? () => {} : () => cleanNode(root));
|
|
37
52
|
} catch (err) {
|
|
38
53
|
handleError(err);
|
|
39
54
|
} finally {
|
|
@@ -47,10 +62,7 @@ function createSignal(value, options) {
|
|
|
47
62
|
}];
|
|
48
63
|
}
|
|
49
64
|
function createComputed(fn, value) {
|
|
50
|
-
Owner =
|
|
51
|
-
owner: Owner,
|
|
52
|
-
context: null
|
|
53
|
-
};
|
|
65
|
+
Owner = createOwner();
|
|
54
66
|
try {
|
|
55
67
|
fn(value);
|
|
56
68
|
} catch (err) {
|
|
@@ -67,10 +79,7 @@ function createReaction(fn) {
|
|
|
67
79
|
};
|
|
68
80
|
}
|
|
69
81
|
function createMemo(fn, value) {
|
|
70
|
-
Owner =
|
|
71
|
-
owner: Owner,
|
|
72
|
-
context: null
|
|
73
|
-
};
|
|
82
|
+
Owner = createOwner();
|
|
74
83
|
let v;
|
|
75
84
|
try {
|
|
76
85
|
v = fn(value);
|
|
@@ -106,16 +115,36 @@ function on(deps, fn, options = {}) {
|
|
|
106
115
|
}
|
|
107
116
|
function onMount(fn) {}
|
|
108
117
|
function onCleanup(fn) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (!node.cleanups) node.cleanups = [fn];else node.cleanups.push(fn);
|
|
118
|
+
if (Owner) {
|
|
119
|
+
if (!Owner.cleanups) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
|
|
112
120
|
}
|
|
113
121
|
return fn;
|
|
114
122
|
}
|
|
115
123
|
function cleanNode(node) {
|
|
124
|
+
if (node.owned) {
|
|
125
|
+
for (let i = 0; i < node.owned.length; i++) cleanNode(node.owned[i]);
|
|
126
|
+
node.owned = null;
|
|
127
|
+
}
|
|
116
128
|
if (node.cleanups) {
|
|
117
129
|
for (let i = 0; i < node.cleanups.length; i++) node.cleanups[i]();
|
|
118
|
-
node.cleanups =
|
|
130
|
+
node.cleanups = null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function catchError(fn, handler) {
|
|
134
|
+
Owner = {
|
|
135
|
+
owner: Owner,
|
|
136
|
+
context: {
|
|
137
|
+
[ERROR]: [handler]
|
|
138
|
+
},
|
|
139
|
+
owned: null,
|
|
140
|
+
cleanups: null
|
|
141
|
+
};
|
|
142
|
+
try {
|
|
143
|
+
return fn();
|
|
144
|
+
} catch (err) {
|
|
145
|
+
handleError(err);
|
|
146
|
+
} finally {
|
|
147
|
+
Owner = Owner.owner;
|
|
119
148
|
}
|
|
120
149
|
}
|
|
121
150
|
function onError(fn) {
|
|
@@ -345,7 +374,7 @@ function Index(props) {
|
|
|
345
374
|
}
|
|
346
375
|
function Show(props) {
|
|
347
376
|
let c;
|
|
348
|
-
return props.when ? typeof (c = props.children) === "function" ? c(props.when) : c : props.fallback || "";
|
|
377
|
+
return props.when ? typeof (c = props.children) === "function" ? c(props.keyed ? props.when : () => props.when) : c : props.fallback || "";
|
|
349
378
|
}
|
|
350
379
|
function Switch(props) {
|
|
351
380
|
let conditions = props.children;
|
|
@@ -354,7 +383,7 @@ function Switch(props) {
|
|
|
354
383
|
const w = conditions[i].when;
|
|
355
384
|
if (w) {
|
|
356
385
|
const c = conditions[i].children;
|
|
357
|
-
return typeof c === "function" ? c(w) : c;
|
|
386
|
+
return typeof c === "function" ? c(conditions[i].keyed ? w : () => w) : c;
|
|
358
387
|
}
|
|
359
388
|
}
|
|
360
389
|
return props.fallback || "";
|
|
@@ -380,17 +409,13 @@ function ErrorBoundary(props) {
|
|
|
380
409
|
const f = props.fallback;
|
|
381
410
|
return typeof f === "function" && f.length ? f(error, () => {}) : f;
|
|
382
411
|
}
|
|
383
|
-
onError(err => {
|
|
384
|
-
error = err;
|
|
385
|
-
!sync && ctx.replace("e" + id, displayFallback);
|
|
386
|
-
sync = true;
|
|
387
|
-
});
|
|
388
|
-
onCleanup(() => cleanNode(clean));
|
|
389
412
|
createMemo(() => {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
413
|
+
clean = Owner;
|
|
414
|
+
return catchError(() => res = props.children, err => {
|
|
415
|
+
error = err;
|
|
416
|
+
!sync && ctx.replace("e" + id, displayFallback);
|
|
417
|
+
sync = true;
|
|
418
|
+
});
|
|
394
419
|
});
|
|
395
420
|
if (error) return displayFallback();
|
|
396
421
|
sync = false;
|
|
@@ -439,7 +464,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
439
464
|
};
|
|
440
465
|
read.loading = false;
|
|
441
466
|
read.error = undefined;
|
|
442
|
-
read.state = "initialValue" in options ? "
|
|
467
|
+
read.state = "initialValue" in options ? "ready" : "unresolved";
|
|
443
468
|
Object.defineProperty(read, "latest", {
|
|
444
469
|
get() {
|
|
445
470
|
return read();
|
|
@@ -472,7 +497,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
472
497
|
if (ctx.writeResource) ctx.writeResource(id, p, undefined, options.deferStream);
|
|
473
498
|
return p.then(res => {
|
|
474
499
|
read.loading = false;
|
|
475
|
-
read.state = "
|
|
500
|
+
read.state = "ready";
|
|
476
501
|
ctx.resources[id].data = res;
|
|
477
502
|
p = null;
|
|
478
503
|
notifySuspense(contexts);
|
|
@@ -562,15 +587,9 @@ function SuspenseList(props) {
|
|
|
562
587
|
}
|
|
563
588
|
function Suspense(props) {
|
|
564
589
|
let done;
|
|
565
|
-
let clean;
|
|
566
590
|
const ctx = sharedConfig.context;
|
|
567
591
|
const id = ctx.id + ctx.count;
|
|
568
|
-
const o =
|
|
569
|
-
if (o) {
|
|
570
|
-
if (o.context) o.context[BRANCH] = clean = {};else o.context = {
|
|
571
|
-
[BRANCH]: clean = {}
|
|
572
|
-
};
|
|
573
|
-
}
|
|
592
|
+
const o = createOwner();
|
|
574
593
|
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
575
594
|
resources: new Map(),
|
|
576
595
|
completed: () => {
|
|
@@ -580,51 +599,51 @@ function Suspense(props) {
|
|
|
580
599
|
}
|
|
581
600
|
}
|
|
582
601
|
});
|
|
602
|
+
function suspenseError(err) {
|
|
603
|
+
if (!done || !done(undefined, err)) {
|
|
604
|
+
if (o) runWithOwner(o.owner, () => {
|
|
605
|
+
throw err;
|
|
606
|
+
});else throw err;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
583
609
|
function runSuspense() {
|
|
584
610
|
setHydrateContext({
|
|
585
611
|
...ctx,
|
|
586
612
|
count: 0
|
|
587
613
|
});
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
});
|
|
596
|
-
});
|
|
614
|
+
o && cleanNode(o);
|
|
615
|
+
return runWithOwner(o, () => createComponent(SuspenseContext.Provider, {
|
|
616
|
+
value,
|
|
617
|
+
get children() {
|
|
618
|
+
return catchError(() => props.children, suspenseError);
|
|
619
|
+
}
|
|
620
|
+
}));
|
|
597
621
|
}
|
|
598
622
|
const res = runSuspense();
|
|
599
623
|
if (suspenseComplete(value)) return res;
|
|
600
|
-
onError(err => {
|
|
601
|
-
if (!done || !done(undefined, err)) {
|
|
602
|
-
if (o) runWithOwner(o.owner, () => {
|
|
603
|
-
throw err;
|
|
604
|
-
});else throw err;
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
624
|
done = ctx.async ? ctx.registerFragment(id) : undefined;
|
|
608
|
-
|
|
625
|
+
return catchError(() => {
|
|
626
|
+
if (ctx.async) {
|
|
627
|
+
setHydrateContext({
|
|
628
|
+
...ctx,
|
|
629
|
+
count: 0,
|
|
630
|
+
id: ctx.id + "0-f",
|
|
631
|
+
noHydrate: true
|
|
632
|
+
});
|
|
633
|
+
const res = {
|
|
634
|
+
t: `<template id="pl-${id}"></template>${resolveSSRNode(props.fallback)}<!pl-${id}>`
|
|
635
|
+
};
|
|
636
|
+
setHydrateContext(ctx);
|
|
637
|
+
return res;
|
|
638
|
+
}
|
|
609
639
|
setHydrateContext({
|
|
610
640
|
...ctx,
|
|
611
641
|
count: 0,
|
|
612
|
-
id: ctx.id + "0
|
|
613
|
-
noHydrate: true
|
|
642
|
+
id: ctx.id + "0-f"
|
|
614
643
|
});
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
setHydrateContext(ctx);
|
|
619
|
-
return res;
|
|
620
|
-
}
|
|
621
|
-
setHydrateContext({
|
|
622
|
-
...ctx,
|
|
623
|
-
count: 0,
|
|
624
|
-
id: ctx.id + "0.f"
|
|
625
|
-
});
|
|
626
|
-
ctx.writeResource(id, "$$f");
|
|
627
|
-
return props.fallback;
|
|
644
|
+
ctx.writeResource(id, "$$f");
|
|
645
|
+
return props.fallback;
|
|
646
|
+
}, suspenseError);
|
|
628
647
|
}
|
|
629
648
|
|
|
630
649
|
exports.$DEVCOMP = $DEVCOMP;
|