solid-js 1.6.7 → 1.6.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.cjs +140 -127
- package/dist/dev.js +140 -127
- package/dist/server.cjs +35 -40
- package/dist/server.js +35 -40
- package/dist/solid.cjs +126 -115
- package/dist/solid.js +126 -115
- package/h/dist/h.cjs +4 -4
- package/h/dist/h.js +4 -4
- package/h/types/hyperscript.d.ts +3 -3
- package/html/dist/html.cjs +34 -35
- package/html/dist/html.js +34 -35
- package/html/types/lit.d.ts +2 -2
- package/package.json +1 -1
- package/store/dist/dev.cjs +16 -16
- package/store/dist/dev.js +16 -16
- package/store/dist/server.cjs +3 -3
- package/store/dist/server.js +3 -3
- package/store/dist/store.cjs +16 -16
- package/store/dist/store.js +16 -16
- package/types/reactive/signal.d.ts +9 -8
- package/types/server/rendering.d.ts +1 -0
- package/universal/dist/dev.cjs +10 -10
- package/universal/dist/dev.js +10 -10
- package/universal/dist/universal.cjs +10 -10
- package/universal/dist/universal.js +10 -10
- package/web/dist/dev.cjs +29 -22
- package/web/dist/dev.js +29 -22
- package/web/dist/server.cjs +14 -20
- package/web/dist/server.js +14 -20
- package/web/dist/web.cjs +29 -22
- package/web/dist/web.js +29 -22
package/dist/dev.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
let taskIdCounter = 1,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
isCallbackScheduled = false,
|
|
3
|
+
isPerformingWork = false,
|
|
4
|
+
taskQueue = [],
|
|
5
|
+
currentTask = null,
|
|
6
|
+
shouldYieldToHost = null,
|
|
7
|
+
yieldInterval = 5,
|
|
8
|
+
deadline = 0,
|
|
9
|
+
maxYieldInterval = 300,
|
|
10
|
+
scheduleCallback = null,
|
|
11
|
+
scheduledCallback = null;
|
|
12
12
|
const maxSigned31BitInt = 1073741823;
|
|
13
13
|
function setupScheduler() {
|
|
14
14
|
const channel = new MessageChannel(),
|
|
15
|
-
|
|
15
|
+
port = channel.port2;
|
|
16
16
|
scheduleCallback = () => port.postMessage(null);
|
|
17
17
|
channel.port1.onmessage = () => {
|
|
18
18
|
if (scheduledCallback !== null) {
|
|
@@ -63,7 +63,7 @@ function enqueue(taskQueue, task) {
|
|
|
63
63
|
function requestCallback(fn, options) {
|
|
64
64
|
if (!scheduleCallback) setupScheduler();
|
|
65
65
|
let startTime = performance.now(),
|
|
66
|
-
|
|
66
|
+
timeout = maxSigned31BitInt;
|
|
67
67
|
if (options && options.timeout) timeout = options.timeout;
|
|
68
68
|
const newTask = {
|
|
69
69
|
id: taskIdCounter++,
|
|
@@ -119,7 +119,8 @@ function setHydrateContext(context) {
|
|
|
119
119
|
sharedConfig.context = context;
|
|
120
120
|
}
|
|
121
121
|
function nextHydrateContext() {
|
|
122
|
-
return {
|
|
122
|
+
return {
|
|
123
|
+
...sharedConfig.context,
|
|
123
124
|
id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
|
|
124
125
|
count: 0
|
|
125
126
|
};
|
|
@@ -155,22 +156,22 @@ let rootCount = 0;
|
|
|
155
156
|
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
156
157
|
function createRoot(fn, detachedOwner) {
|
|
157
158
|
const listener = Listener,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
159
|
+
owner = Owner,
|
|
160
|
+
unowned = fn.length === 0,
|
|
161
|
+
root = unowned ? {
|
|
162
|
+
owned: null,
|
|
163
|
+
cleanups: null,
|
|
164
|
+
context: null,
|
|
165
|
+
owner: null
|
|
166
|
+
} : {
|
|
167
|
+
owned: null,
|
|
168
|
+
cleanups: null,
|
|
169
|
+
context: null,
|
|
170
|
+
owner: detachedOwner || owner
|
|
171
|
+
},
|
|
172
|
+
updateFn = unowned ? () => fn(() => {
|
|
173
|
+
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
174
|
+
}) : () => fn(() => untrack(() => cleanNode(root)));
|
|
174
175
|
{
|
|
175
176
|
if (owner) root.name = `${owner.name}-r${rootCount++}`;
|
|
176
177
|
globalThis._$afterCreateRoot && globalThis._$afterCreateRoot(root);
|
|
@@ -212,7 +213,7 @@ function createRenderEffect(fn, value, options) {
|
|
|
212
213
|
function createEffect(fn, value, options) {
|
|
213
214
|
runEffects = runUserEffects;
|
|
214
215
|
const c = createComputation(fn, value, false, STALE, options ),
|
|
215
|
-
|
|
216
|
+
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
216
217
|
if (s) c.suspense = s;
|
|
217
218
|
c.user = true;
|
|
218
219
|
Effects ? Effects.push(c) : updateComputation(c);
|
|
@@ -220,10 +221,10 @@ function createEffect(fn, value, options) {
|
|
|
220
221
|
function createReaction(onInvalidate, options) {
|
|
221
222
|
let fn;
|
|
222
223
|
const c = createComputation(() => {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
fn ? fn() : untrack(onInvalidate);
|
|
225
|
+
fn = undefined;
|
|
226
|
+
}, undefined, false, 0, options ),
|
|
227
|
+
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
227
228
|
if (s) c.suspense = s;
|
|
228
229
|
c.user = true;
|
|
229
230
|
return tracking => {
|
|
@@ -257,19 +258,19 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
257
258
|
options = pOptions || {};
|
|
258
259
|
}
|
|
259
260
|
let pr = null,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
261
|
+
initP = NO_INIT,
|
|
262
|
+
id = null,
|
|
263
|
+
loadedUnderTransition = false,
|
|
264
|
+
scheduled = false,
|
|
265
|
+
resolved = ("initialValue" in options),
|
|
266
|
+
dynamic = typeof source === "function" && createMemo(source);
|
|
266
267
|
const contexts = new Set(),
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
268
|
+
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
269
|
+
[error, setError] = createSignal(undefined),
|
|
270
|
+
[track, trigger] = createSignal(undefined, {
|
|
271
|
+
equals: false
|
|
272
|
+
}),
|
|
273
|
+
[state, setState] = createSignal(resolved ? "ready" : "unresolved");
|
|
273
274
|
if (sharedConfig.context) {
|
|
274
275
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
275
276
|
let v;
|
|
@@ -305,8 +306,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
305
306
|
}
|
|
306
307
|
function read() {
|
|
307
308
|
const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
|
|
308
|
-
|
|
309
|
-
|
|
309
|
+
v = value(),
|
|
310
|
+
err = error();
|
|
310
311
|
if (err && !pr) throw err;
|
|
311
312
|
if (Listener && !Listener.user && c) {
|
|
312
313
|
createComputed(() => {
|
|
@@ -378,7 +379,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
378
379
|
}
|
|
379
380
|
function createDeferred(source, options) {
|
|
380
381
|
let t,
|
|
381
|
-
|
|
382
|
+
timeout = options ? options.timeoutMs : undefined;
|
|
382
383
|
const node = createComputation(() => {
|
|
383
384
|
if (!t || !t.fn) t = requestCallback(() => setDeferred(() => node.value), timeout !== undefined ? {
|
|
384
385
|
timeout
|
|
@@ -521,11 +522,10 @@ function devComponent(Comp, props) {
|
|
|
521
522
|
[$DEVCOMP]: true
|
|
522
523
|
});
|
|
523
524
|
return Comp(props);
|
|
524
|
-
}), undefined, true);
|
|
525
|
+
}), undefined, true, 0);
|
|
525
526
|
c.props = props;
|
|
526
527
|
c.observers = null;
|
|
527
528
|
c.observerSlots = null;
|
|
528
|
-
c.state = 0;
|
|
529
529
|
c.componentName = Comp.name;
|
|
530
530
|
updateComputation(c);
|
|
531
531
|
return c.tValue !== undefined ? c.tValue : c.value;
|
|
@@ -558,13 +558,15 @@ function registerGraph(name, value) {
|
|
|
558
558
|
Owner.sourceMap || (Owner.sourceMap = {});
|
|
559
559
|
while (Owner.sourceMap[tryName]) tryName = `${name}-${++i}`;
|
|
560
560
|
Owner.sourceMap[tryName] = value;
|
|
561
|
+
value.graph = Owner;
|
|
561
562
|
}
|
|
562
563
|
return tryName;
|
|
563
564
|
}
|
|
564
565
|
function serializeGraph(owner) {
|
|
565
566
|
owner || (owner = Owner);
|
|
566
567
|
if (!owner) return {};
|
|
567
|
-
return {
|
|
568
|
+
return {
|
|
569
|
+
...serializeValues(owner.sourceMap),
|
|
568
570
|
...(owner.owned ? serializeChildren(owner) : {})
|
|
569
571
|
};
|
|
570
572
|
}
|
|
@@ -680,8 +682,8 @@ function updateComputation(node) {
|
|
|
680
682
|
if (!node.fn) return;
|
|
681
683
|
cleanNode(node);
|
|
682
684
|
const owner = Owner,
|
|
683
|
-
|
|
684
|
-
|
|
685
|
+
listener = Listener,
|
|
686
|
+
time = ExecCount;
|
|
685
687
|
Listener = Owner = node;
|
|
686
688
|
runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
|
|
687
689
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
@@ -702,7 +704,17 @@ function runComputation(node, value, time) {
|
|
|
702
704
|
try {
|
|
703
705
|
nextValue = node.fn(value);
|
|
704
706
|
} catch (err) {
|
|
705
|
-
if (node.pure)
|
|
707
|
+
if (node.pure) {
|
|
708
|
+
if (Transition && Transition.running) {
|
|
709
|
+
node.tState = STALE;
|
|
710
|
+
node.tOwned && node.tOwned.forEach(cleanNode);
|
|
711
|
+
node.tOwned = undefined;
|
|
712
|
+
} else {
|
|
713
|
+
node.state = STALE;
|
|
714
|
+
node.owned && node.owned.forEach(cleanNode);
|
|
715
|
+
node.owned = null;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
706
718
|
handleError(err);
|
|
707
719
|
}
|
|
708
720
|
if (!node.updatedAt || node.updatedAt <= time) {
|
|
@@ -770,7 +782,7 @@ function runTop(node) {
|
|
|
770
782
|
node = ancestors[i];
|
|
771
783
|
if (runningTransition) {
|
|
772
784
|
let top = node,
|
|
773
|
-
|
|
785
|
+
prev = ancestors[i + 1];
|
|
774
786
|
while ((top = top.owner) && top !== prev) {
|
|
775
787
|
if (Transition.disposed.has(top)) return;
|
|
776
788
|
}
|
|
@@ -867,7 +879,7 @@ function scheduleQueue(queue) {
|
|
|
867
879
|
}
|
|
868
880
|
function runUserEffects(queue) {
|
|
869
881
|
let i,
|
|
870
|
-
|
|
882
|
+
userLength = 0;
|
|
871
883
|
for (i = 0; i < queue.length; i++) {
|
|
872
884
|
const e = queue[i];
|
|
873
885
|
if (!e.user) runTop(e);else queue[userLength++] = e;
|
|
@@ -903,11 +915,11 @@ function cleanNode(node) {
|
|
|
903
915
|
if (node.sources) {
|
|
904
916
|
while (node.sources.length) {
|
|
905
917
|
const source = node.sources.pop(),
|
|
906
|
-
|
|
907
|
-
|
|
918
|
+
index = node.sourceSlots.pop(),
|
|
919
|
+
obs = source.observers;
|
|
908
920
|
if (obs && obs.length) {
|
|
909
921
|
const n = obs.pop(),
|
|
910
|
-
|
|
922
|
+
s = source.observerSlots.pop();
|
|
911
923
|
if (index < obs.length) {
|
|
912
924
|
n.sourceSlots[s] = index;
|
|
913
925
|
obs[index] = n;
|
|
@@ -997,7 +1009,8 @@ function serializeChildren(root) {
|
|
|
997
1009
|
const result = {};
|
|
998
1010
|
for (let i = 0, len = root.owned.length; i < len; i++) {
|
|
999
1011
|
const node = root.owned[i];
|
|
1000
|
-
result[node.componentName ? `${node.componentName}:${node.name}` : node.name] = {
|
|
1012
|
+
result[node.componentName ? `${node.componentName}:${node.name}` : node.name] = {
|
|
1013
|
+
...serializeValues(node.sourceMap),
|
|
1001
1014
|
...(node.owned ? serializeChildren(node) : {})
|
|
1002
1015
|
};
|
|
1003
1016
|
}
|
|
@@ -1055,27 +1068,27 @@ function dispose(d) {
|
|
|
1055
1068
|
}
|
|
1056
1069
|
function mapArray(list, mapFn, options = {}) {
|
|
1057
1070
|
let items = [],
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1071
|
+
mapped = [],
|
|
1072
|
+
disposers = [],
|
|
1073
|
+
len = 0,
|
|
1074
|
+
indexes = mapFn.length > 1 ? [] : null;
|
|
1062
1075
|
onCleanup(() => dispose(disposers));
|
|
1063
1076
|
return () => {
|
|
1064
1077
|
let newItems = list() || [],
|
|
1065
|
-
|
|
1066
|
-
|
|
1078
|
+
i,
|
|
1079
|
+
j;
|
|
1067
1080
|
newItems[$TRACK];
|
|
1068
1081
|
return untrack(() => {
|
|
1069
1082
|
let newLen = newItems.length,
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1083
|
+
newIndices,
|
|
1084
|
+
newIndicesNext,
|
|
1085
|
+
temp,
|
|
1086
|
+
tempdisposers,
|
|
1087
|
+
tempIndexes,
|
|
1088
|
+
start,
|
|
1089
|
+
end,
|
|
1090
|
+
newEnd,
|
|
1091
|
+
item;
|
|
1079
1092
|
if (newLen === 0) {
|
|
1080
1093
|
if (len !== 0) {
|
|
1081
1094
|
dispose(disposers);
|
|
@@ -1160,11 +1173,11 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1160
1173
|
}
|
|
1161
1174
|
function indexArray(list, mapFn, options = {}) {
|
|
1162
1175
|
let items = [],
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1176
|
+
mapped = [],
|
|
1177
|
+
disposers = [],
|
|
1178
|
+
signals = [],
|
|
1179
|
+
len = 0,
|
|
1180
|
+
i;
|
|
1168
1181
|
onCleanup(() => dispose(disposers));
|
|
1169
1182
|
return () => {
|
|
1170
1183
|
const newItems = list() || [];
|
|
@@ -1446,21 +1459,21 @@ function Switch(props) {
|
|
|
1446
1459
|
let keyed = false;
|
|
1447
1460
|
const equals = (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1448
1461
|
const conditions = children(() => props.children),
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1462
|
+
evalConditions = createMemo(() => {
|
|
1463
|
+
let conds = conditions();
|
|
1464
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1465
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1466
|
+
const c = conds[i].when;
|
|
1467
|
+
if (c) {
|
|
1468
|
+
keyed = !!conds[i].keyed;
|
|
1469
|
+
return [i, c, conds[i]];
|
|
1470
|
+
}
|
|
1457
1471
|
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
} );
|
|
1472
|
+
return [-1];
|
|
1473
|
+
}, undefined, {
|
|
1474
|
+
equals,
|
|
1475
|
+
name: "eval conditions"
|
|
1476
|
+
} );
|
|
1464
1477
|
return createMemo(() => {
|
|
1465
1478
|
const [index, when, cond] = evalConditions();
|
|
1466
1479
|
if (index < 0) return props.fallback;
|
|
@@ -1509,9 +1522,9 @@ const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFa
|
|
|
1509
1522
|
const SuspenseListContext = createContext();
|
|
1510
1523
|
function SuspenseList(props) {
|
|
1511
1524
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1525
|
+
inFallback: false
|
|
1526
|
+
})),
|
|
1527
|
+
show;
|
|
1515
1528
|
const listContext = useContext(SuspenseListContext);
|
|
1516
1529
|
const [registry, setRegistry] = createSignal([]);
|
|
1517
1530
|
if (listContext) {
|
|
@@ -1519,13 +1532,13 @@ function SuspenseList(props) {
|
|
|
1519
1532
|
}
|
|
1520
1533
|
const resolved = createMemo(prev => {
|
|
1521
1534
|
const reveal = props.revealOrder,
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1535
|
+
tail = props.tail,
|
|
1536
|
+
{
|
|
1537
|
+
showContent = true,
|
|
1538
|
+
showFallback = true
|
|
1539
|
+
} = show ? show() : {},
|
|
1540
|
+
reg = registry(),
|
|
1541
|
+
reverse = reveal === "backwards";
|
|
1529
1542
|
if (reveal === "together") {
|
|
1530
1543
|
const all = reg.every(inFallback => !inFallback());
|
|
1531
1544
|
const res = reg.map(() => ({
|
|
@@ -1540,7 +1553,7 @@ function SuspenseList(props) {
|
|
|
1540
1553
|
const res = [];
|
|
1541
1554
|
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1542
1555
|
const n = reverse ? len - i - 1 : i,
|
|
1543
|
-
|
|
1556
|
+
s = reg[n]();
|
|
1544
1557
|
if (!stop && !s) {
|
|
1545
1558
|
res[n] = {
|
|
1546
1559
|
showContent,
|
|
@@ -1583,25 +1596,25 @@ function SuspenseList(props) {
|
|
|
1583
1596
|
}
|
|
1584
1597
|
function Suspense(props) {
|
|
1585
1598
|
let counter = 0,
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1599
|
+
show,
|
|
1600
|
+
ctx,
|
|
1601
|
+
p,
|
|
1602
|
+
flicker,
|
|
1603
|
+
error;
|
|
1591
1604
|
const [inFallback, setFallback] = createSignal(false),
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1605
|
+
SuspenseContext = getSuspenseContext(),
|
|
1606
|
+
store = {
|
|
1607
|
+
increment: () => {
|
|
1608
|
+
if (++counter === 1) setFallback(true);
|
|
1609
|
+
},
|
|
1610
|
+
decrement: () => {
|
|
1611
|
+
if (--counter === 0) setFallback(false);
|
|
1612
|
+
},
|
|
1613
|
+
inFallback,
|
|
1614
|
+
effects: [],
|
|
1615
|
+
resolved: false
|
|
1599
1616
|
},
|
|
1600
|
-
|
|
1601
|
-
effects: [],
|
|
1602
|
-
resolved: false
|
|
1603
|
-
},
|
|
1604
|
-
owner = getOwner();
|
|
1617
|
+
owner = getOwner();
|
|
1605
1618
|
if (sharedConfig.context && sharedConfig.load) {
|
|
1606
1619
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1607
1620
|
let ref = sharedConfig.load(key);
|
|
@@ -1641,10 +1654,10 @@ function Suspense(props) {
|
|
|
1641
1654
|
const rendered = createMemo(() => props.children);
|
|
1642
1655
|
return createMemo(prev => {
|
|
1643
1656
|
const inFallback = store.inFallback(),
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1657
|
+
{
|
|
1658
|
+
showContent = true,
|
|
1659
|
+
showFallback = true
|
|
1660
|
+
} = show ? show() : {};
|
|
1648
1661
|
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1649
1662
|
store.resolved = true;
|
|
1650
1663
|
dispose && dispose();
|
package/dist/server.cjs
CHANGED
|
@@ -25,10 +25,10 @@ let Owner = null;
|
|
|
25
25
|
function createRoot(fn, detachedOwner) {
|
|
26
26
|
detachedOwner && (Owner = detachedOwner);
|
|
27
27
|
const owner = Owner,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
root = fn.length === 0 ? UNOWNED : {
|
|
29
|
+
context: null,
|
|
30
|
+
owner
|
|
31
|
+
};
|
|
32
32
|
Owner = root;
|
|
33
33
|
let result;
|
|
34
34
|
try {
|
|
@@ -264,7 +264,8 @@ function setHydrateContext(context) {
|
|
|
264
264
|
sharedConfig.context = context;
|
|
265
265
|
}
|
|
266
266
|
function nextHydrateContext() {
|
|
267
|
-
return sharedConfig.context ? {
|
|
267
|
+
return sharedConfig.context ? {
|
|
268
|
+
...sharedConfig.context,
|
|
268
269
|
id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
|
|
269
270
|
count: 0
|
|
270
271
|
} : undefined;
|
|
@@ -311,23 +312,23 @@ function mergeProps(...sources) {
|
|
|
311
312
|
}
|
|
312
313
|
function splitProps(props, ...keys) {
|
|
313
314
|
const descriptors = Object.getOwnPropertyDescriptors(props),
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
315
|
+
split = k => {
|
|
316
|
+
const clone = {};
|
|
317
|
+
for (let i = 0; i < k.length; i++) {
|
|
318
|
+
const key = k[i];
|
|
319
|
+
if (descriptors[key]) {
|
|
320
|
+
Object.defineProperty(clone, key, descriptors[key]);
|
|
321
|
+
delete descriptors[key];
|
|
322
|
+
}
|
|
321
323
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
};
|
|
324
|
+
return clone;
|
|
325
|
+
};
|
|
325
326
|
return keys.map(split).concat(split(Object.keys(descriptors)));
|
|
326
327
|
}
|
|
327
328
|
function simpleMap(props, wrap) {
|
|
328
329
|
const list = props.each || [],
|
|
329
|
-
|
|
330
|
-
|
|
330
|
+
len = list.length,
|
|
331
|
+
fn = props.children;
|
|
331
332
|
if (len) {
|
|
332
333
|
let mapped = Array(len);
|
|
333
334
|
for (let i = 0; i < len; i++) mapped[i] = wrap(fn, list[i], i);
|
|
@@ -363,15 +364,16 @@ function Match(props) {
|
|
|
363
364
|
function resetErrorBoundaries() {}
|
|
364
365
|
function ErrorBoundary(props) {
|
|
365
366
|
let error,
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
367
|
+
res,
|
|
368
|
+
clean,
|
|
369
|
+
sync = true;
|
|
369
370
|
const ctx = sharedConfig.context;
|
|
370
371
|
const id = ctx.id + ctx.count;
|
|
371
372
|
function displayFallback() {
|
|
372
373
|
cleanNode(clean);
|
|
373
374
|
ctx.writeResource(id, error, true);
|
|
374
|
-
setHydrateContext({
|
|
375
|
+
setHydrateContext({
|
|
376
|
+
...ctx,
|
|
375
377
|
count: 0
|
|
376
378
|
});
|
|
377
379
|
const f = props.fallback;
|
|
@@ -494,31 +496,21 @@ function createResource(source, fetcher, options = {}) {
|
|
|
494
496
|
}];
|
|
495
497
|
}
|
|
496
498
|
function lazy(fn) {
|
|
497
|
-
let resolved;
|
|
498
499
|
let p;
|
|
499
500
|
let load = id => {
|
|
500
501
|
if (!p) {
|
|
501
|
-
if (id) {
|
|
502
|
-
let ref = sharedConfig.context.resources[id] = {
|
|
503
|
-
ref: p = fn()
|
|
504
|
-
};
|
|
505
|
-
p.then(mod => ref.data = resolved = mod.default);
|
|
506
|
-
return p;
|
|
507
|
-
}
|
|
508
502
|
p = fn();
|
|
509
|
-
p.then(mod => resolved = mod.default);
|
|
503
|
+
p.then(mod => p.resolved = mod.default);
|
|
504
|
+
if (id) sharedConfig.context.lazy[id] = p;
|
|
510
505
|
}
|
|
511
506
|
return p;
|
|
512
507
|
};
|
|
513
508
|
const contexts = new Set();
|
|
514
509
|
const wrap = props => {
|
|
515
510
|
const id = sharedConfig.context.id.slice(0, -1);
|
|
516
|
-
let ref = sharedConfig.context.
|
|
517
|
-
if (ref)
|
|
518
|
-
|
|
519
|
-
resolved = ref.data;
|
|
520
|
-
} else load(id);
|
|
521
|
-
if (resolved) return resolved(props);
|
|
511
|
+
let ref = sharedConfig.context.lazy[id];
|
|
512
|
+
if (ref) p = ref;else load(id);
|
|
513
|
+
if (p.resolved) return p.resolved(props);
|
|
522
514
|
const ctx = useContext(SuspenseContext);
|
|
523
515
|
const track = {
|
|
524
516
|
loading: true,
|
|
@@ -588,7 +580,8 @@ function Suspense(props) {
|
|
|
588
580
|
}
|
|
589
581
|
});
|
|
590
582
|
function runSuspense() {
|
|
591
|
-
setHydrateContext({
|
|
583
|
+
setHydrateContext({
|
|
584
|
+
...ctx,
|
|
592
585
|
count: 0
|
|
593
586
|
});
|
|
594
587
|
return runWithOwner(o, () => {
|
|
@@ -612,18 +605,20 @@ function Suspense(props) {
|
|
|
612
605
|
});
|
|
613
606
|
done = ctx.async ? ctx.registerFragment(id) : undefined;
|
|
614
607
|
if (ctx.async) {
|
|
615
|
-
setHydrateContext({
|
|
608
|
+
setHydrateContext({
|
|
609
|
+
...ctx,
|
|
616
610
|
count: 0,
|
|
617
611
|
id: ctx.id + "0.f",
|
|
618
612
|
noHydrate: true
|
|
619
613
|
});
|
|
620
614
|
const res = {
|
|
621
|
-
t: `<
|
|
615
|
+
t: `<template id="pl-${id}"></template>${resolveSSRNode(props.fallback)}<!pl-${id}>`
|
|
622
616
|
};
|
|
623
617
|
setHydrateContext(ctx);
|
|
624
618
|
return res;
|
|
625
619
|
}
|
|
626
|
-
setHydrateContext({
|
|
620
|
+
setHydrateContext({
|
|
621
|
+
...ctx,
|
|
627
622
|
count: 0,
|
|
628
623
|
id: ctx.id + "0.f"
|
|
629
624
|
});
|