solid-js 1.5.0-beta.1 → 1.5.0-beta.4
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 +161 -145
- package/dist/dev.js +161 -145
- package/dist/server.cjs +76 -42
- package/dist/server.js +76 -42
- package/dist/solid.cjs +161 -145
- package/dist/solid.js +161 -145
- package/h/jsx-runtime/types/jsx.d.ts +3 -1
- package/package.json +81 -21
- package/store/types/index.d.ts +4 -4
- package/store/types/mutable.d.ts +1 -1
- package/store/types/server.d.ts +1 -1
- package/store/types/store.d.ts +2 -2
- package/types/index.d.ts +8 -8
- package/types/jsx.d.ts +4 -2
- package/types/reactive/array.d.ts +1 -1
- package/types/reactive/observable.d.ts +1 -1
- package/types/reactive/signal.d.ts +51 -36
- package/types/render/Suspense.d.ts +1 -1
- package/types/render/component.d.ts +1 -1
- package/types/render/flow.d.ts +20 -3
- package/types/render/index.d.ts +4 -4
- package/types/server/index.d.ts +3 -3
- package/types/server/reactive.d.ts +6 -3
- package/types/server/rendering.d.ts +16 -7
- package/universal/dist/dev.cjs +4 -1
- package/universal/dist/dev.js +5 -2
- package/universal/dist/universal.cjs +4 -1
- package/universal/dist/universal.js +5 -2
- package/universal/types/index.d.ts +1 -1
- package/web/dist/dev.cjs +13 -7
- package/web/dist/dev.js +8 -6
- package/web/dist/server.cjs +324 -246
- package/web/dist/server.js +322 -247
- package/web/dist/web.cjs +13 -7
- package/web/dist/web.js +8 -6
- package/web/types/client.d.ts +4 -1
- package/web/types/core.d.ts +2 -2
- package/web/types/index.d.ts +3 -3
- package/web/types/jsx.d.ts +1 -1
- package/web/types/server-mock.d.ts +4 -1
- package/web/types/server.d.ts +2 -0
package/dist/dev.js
CHANGED
|
@@ -149,7 +149,6 @@ let Transition = null;
|
|
|
149
149
|
let Scheduler = null;
|
|
150
150
|
let ExternalSourceFactory = null;
|
|
151
151
|
let Listener = null;
|
|
152
|
-
let Pending = null;
|
|
153
152
|
let Updates = null;
|
|
154
153
|
let Effects = null;
|
|
155
154
|
let ExecCount = 0;
|
|
@@ -166,7 +165,7 @@ function createRoot(fn, detachedOwner) {
|
|
|
166
165
|
},
|
|
167
166
|
updateFn = unowned ? () => fn(() => {
|
|
168
167
|
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
169
|
-
}) : () => fn(() => cleanNode(root));
|
|
168
|
+
}) : () => fn(() => untrack(() => cleanNode(root)));
|
|
170
169
|
{
|
|
171
170
|
if (owner) root.name = `${owner.name}-r${rootCount++}`;
|
|
172
171
|
globalThis._$afterCreateRoot && globalThis._$afterCreateRoot(root);
|
|
@@ -239,18 +238,19 @@ function createMemo(fn, value, options) {
|
|
|
239
238
|
} else updateComputation(c);
|
|
240
239
|
return readSignal.bind(c);
|
|
241
240
|
}
|
|
242
|
-
function createResource(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
source = true;
|
|
248
|
-
}
|
|
249
|
-
} else if (arguments.length === 1) {
|
|
250
|
-
fetcher = source;
|
|
241
|
+
function createResource(pSource, pFetcher, pOptions) {
|
|
242
|
+
let source;
|
|
243
|
+
let fetcher;
|
|
244
|
+
let options;
|
|
245
|
+
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
251
246
|
source = true;
|
|
247
|
+
fetcher = pSource;
|
|
248
|
+
options = pFetcher || {};
|
|
249
|
+
} else {
|
|
250
|
+
source = pSource;
|
|
251
|
+
fetcher = pFetcher;
|
|
252
|
+
options = pOptions || {};
|
|
252
253
|
}
|
|
253
|
-
options || (options = {});
|
|
254
254
|
let err = undefined,
|
|
255
255
|
pr = null,
|
|
256
256
|
initP = NO_INIT,
|
|
@@ -268,7 +268,7 @@ function createResource(source, fetcher, options) {
|
|
|
268
268
|
if (sharedConfig.context) {
|
|
269
269
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
270
270
|
let v;
|
|
271
|
-
if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
271
|
+
if (options.useInitialValue) initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
272
272
|
}
|
|
273
273
|
function loadEnd(p, v, success, key) {
|
|
274
274
|
if (pr === p) {
|
|
@@ -296,8 +296,8 @@ function createResource(source, fetcher, options) {
|
|
|
296
296
|
function completeLoad(v, success) {
|
|
297
297
|
!success && (err = castError(v));
|
|
298
298
|
runUpdates(() => {
|
|
299
|
-
setValue(() =>
|
|
300
|
-
setState(success ? "ready" : "
|
|
299
|
+
setValue(() => v);
|
|
300
|
+
setState(success ? "ready" : "errored");
|
|
301
301
|
for (const c of contexts.keys()) c.decrement();
|
|
302
302
|
contexts.clear();
|
|
303
303
|
}, false);
|
|
@@ -320,7 +320,7 @@ function createResource(source, fetcher, options) {
|
|
|
320
320
|
return v;
|
|
321
321
|
}
|
|
322
322
|
function load(refetching = true) {
|
|
323
|
-
if (refetching && scheduled) return;
|
|
323
|
+
if (refetching !== false && scheduled) return;
|
|
324
324
|
scheduled = false;
|
|
325
325
|
err = undefined;
|
|
326
326
|
const lookup = dynamic ? dynamic() : source;
|
|
@@ -348,10 +348,11 @@ function createResource(source, fetcher, options) {
|
|
|
348
348
|
return p.then(v => loadEnd(p, v, true, lookup), e => loadEnd(p, e, false));
|
|
349
349
|
}
|
|
350
350
|
Object.defineProperties(read, {
|
|
351
|
+
value: {
|
|
352
|
+
get: () => value()
|
|
353
|
+
},
|
|
351
354
|
state: {
|
|
352
|
-
get()
|
|
353
|
-
return state();
|
|
354
|
-
}
|
|
355
|
+
get: () => state()
|
|
355
356
|
},
|
|
356
357
|
loading: {
|
|
357
358
|
get() {
|
|
@@ -361,13 +362,13 @@ function createResource(source, fetcher, options) {
|
|
|
361
362
|
},
|
|
362
363
|
error: {
|
|
363
364
|
get() {
|
|
364
|
-
return state() === "
|
|
365
|
+
return state() === "errored" ? err : undefined;
|
|
365
366
|
}
|
|
366
367
|
},
|
|
367
368
|
latest: {
|
|
368
369
|
get() {
|
|
369
370
|
if (!resolved) return read();
|
|
370
|
-
if (state() === "
|
|
371
|
+
if (state() === "errored") throw err;
|
|
371
372
|
return value();
|
|
372
373
|
}
|
|
373
374
|
}
|
|
@@ -396,9 +397,8 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
396
397
|
const subs = new Map();
|
|
397
398
|
const node = createComputation(p => {
|
|
398
399
|
const v = source();
|
|
399
|
-
for (const key of subs.
|
|
400
|
-
const
|
|
401
|
-
for (const c of l.values()) {
|
|
400
|
+
for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
|
|
401
|
+
for (const c of val.values()) {
|
|
402
402
|
c.state = STALE;
|
|
403
403
|
if (c.pure) Updates.push(c);else Effects.push(c);
|
|
404
404
|
}
|
|
@@ -407,8 +407,8 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
407
407
|
}, undefined, true, STALE, options );
|
|
408
408
|
updateComputation(node);
|
|
409
409
|
return key => {
|
|
410
|
-
|
|
411
|
-
if (listener
|
|
410
|
+
const listener = Listener;
|
|
411
|
+
if (listener) {
|
|
412
412
|
let l;
|
|
413
413
|
if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
|
|
414
414
|
onCleanup(() => {
|
|
@@ -420,18 +420,7 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
420
420
|
};
|
|
421
421
|
}
|
|
422
422
|
function batch(fn) {
|
|
423
|
-
|
|
424
|
-
let result;
|
|
425
|
-
const q = Pending = [];
|
|
426
|
-
try {
|
|
427
|
-
result = fn();
|
|
428
|
-
} finally {
|
|
429
|
-
Pending = null;
|
|
430
|
-
}
|
|
431
|
-
runUpdates(() => {
|
|
432
|
-
for (let i = 0; i < q.length; i += 1) notifySignal(q[i]);
|
|
433
|
-
}, false);
|
|
434
|
-
return result;
|
|
423
|
+
return runUpdates(fn, false);
|
|
435
424
|
}
|
|
436
425
|
function untrack(fn) {
|
|
437
426
|
let result,
|
|
@@ -592,7 +581,12 @@ function useContext(context) {
|
|
|
592
581
|
}
|
|
593
582
|
function children(fn) {
|
|
594
583
|
const children = createMemo(fn);
|
|
595
|
-
|
|
584
|
+
const memo = createMemo(() => resolveChildren(children()));
|
|
585
|
+
memo.toArray = () => {
|
|
586
|
+
const c = memo();
|
|
587
|
+
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
588
|
+
};
|
|
589
|
+
return memo;
|
|
596
590
|
}
|
|
597
591
|
let SuspenseContext;
|
|
598
592
|
function getSuspenseContext() {
|
|
@@ -619,10 +613,12 @@ function enableExternalSource(factory) {
|
|
|
619
613
|
function readSignal() {
|
|
620
614
|
const runningTransition = Transition && Transition.running;
|
|
621
615
|
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
616
|
+
if (!runningTransition && this.state === STALE || runningTransition && this.tState === STALE) updateComputation(this);else {
|
|
617
|
+
const updates = Updates;
|
|
618
|
+
Updates = null;
|
|
619
|
+
runUpdates(() => lookUpstream(this), false);
|
|
620
|
+
Updates = updates;
|
|
621
|
+
}
|
|
626
622
|
}
|
|
627
623
|
if (Listener) {
|
|
628
624
|
const sSlot = this.observers ? this.observers.length : 0;
|
|
@@ -655,30 +651,27 @@ function writeSignal(node, value, isComp) {
|
|
|
655
651
|
}
|
|
656
652
|
if (!TransitionRunning) node.value = value;
|
|
657
653
|
} else node.value = value;
|
|
658
|
-
if (
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
|
|
670
|
-
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
671
|
-
if (o.observers) markDownstream(o);
|
|
654
|
+
if (node.observers && node.observers.length) {
|
|
655
|
+
runUpdates(() => {
|
|
656
|
+
for (let i = 0; i < node.observers.length; i += 1) {
|
|
657
|
+
const o = node.observers[i];
|
|
658
|
+
const TransitionRunning = Transition && Transition.running;
|
|
659
|
+
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
660
|
+
if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
|
|
661
|
+
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
662
|
+
if (o.observers) markDownstream(o);
|
|
663
|
+
}
|
|
664
|
+
if (TransitionRunning) o.tState = STALE;else o.state = STALE;
|
|
672
665
|
}
|
|
673
|
-
if (
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
}, false);
|
|
666
|
+
if (Updates.length > 10e5) {
|
|
667
|
+
Updates = [];
|
|
668
|
+
if ("_SOLID_DEV_") throw new Error("Potential Infinite Loop Detected.");
|
|
669
|
+
throw new Error();
|
|
670
|
+
}
|
|
671
|
+
}, false);
|
|
672
|
+
}
|
|
681
673
|
}
|
|
674
|
+
return value;
|
|
682
675
|
}
|
|
683
676
|
function updateComputation(node) {
|
|
684
677
|
if (!node.fn) return;
|
|
@@ -704,10 +697,11 @@ function runComputation(node, value, time) {
|
|
|
704
697
|
try {
|
|
705
698
|
nextValue = node.fn(value);
|
|
706
699
|
} catch (err) {
|
|
700
|
+
if (node.pure) Transition && Transition.running ? node.tState = STALE : node.state = STALE;
|
|
707
701
|
handleError(err);
|
|
708
702
|
}
|
|
709
703
|
if (!node.updatedAt || node.updatedAt <= time) {
|
|
710
|
-
if (node.updatedAt && "observers" in node) {
|
|
704
|
+
if (node.updatedAt != null && "observers" in node) {
|
|
711
705
|
writeSignal(node, nextValue, true);
|
|
712
706
|
} else if (Transition && Transition.running && node.pure) {
|
|
713
707
|
Transition.sources.add(node);
|
|
@@ -781,7 +775,7 @@ function runTop(node) {
|
|
|
781
775
|
} else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
782
776
|
const updates = Updates;
|
|
783
777
|
Updates = null;
|
|
784
|
-
lookUpstream(node, ancestors[0]);
|
|
778
|
+
runUpdates(() => lookUpstream(node, ancestors[0]), false);
|
|
785
779
|
Updates = updates;
|
|
786
780
|
}
|
|
787
781
|
}
|
|
@@ -976,7 +970,7 @@ function resolveChildren(children) {
|
|
|
976
970
|
function createProvider(id) {
|
|
977
971
|
return function provider(props) {
|
|
978
972
|
let res;
|
|
979
|
-
|
|
973
|
+
createRenderEffect(() => res = untrack(() => {
|
|
980
974
|
Owner.context = {
|
|
981
975
|
[id]: props.value
|
|
982
976
|
};
|
|
@@ -1022,7 +1016,7 @@ function observable(input) {
|
|
|
1022
1016
|
};
|
|
1023
1017
|
}
|
|
1024
1018
|
const dispose = createRoot(disposer => {
|
|
1025
|
-
|
|
1019
|
+
createEffect(() => {
|
|
1026
1020
|
const v = input();
|
|
1027
1021
|
untrack(() => handler(v));
|
|
1028
1022
|
});
|
|
@@ -1377,6 +1371,7 @@ function Index(props) {
|
|
|
1377
1371
|
}
|
|
1378
1372
|
function Show(props) {
|
|
1379
1373
|
let strictEqual = false;
|
|
1374
|
+
const keyed = props.keyed;
|
|
1380
1375
|
const condition = createMemo(() => props.when, undefined, {
|
|
1381
1376
|
equals: (a, b) => strictEqual ? a === b : !a === !b
|
|
1382
1377
|
});
|
|
@@ -1384,20 +1379,26 @@ function Show(props) {
|
|
|
1384
1379
|
const c = condition();
|
|
1385
1380
|
if (c) {
|
|
1386
1381
|
const child = props.children;
|
|
1387
|
-
|
|
1382
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1383
|
+
strictEqual = keyed || fn;
|
|
1384
|
+
return fn ? untrack(() => child(c)) : child;
|
|
1388
1385
|
}
|
|
1389
1386
|
return props.fallback;
|
|
1390
1387
|
});
|
|
1391
1388
|
}
|
|
1392
1389
|
function Switch(props) {
|
|
1393
1390
|
let strictEqual = false;
|
|
1391
|
+
let keyed = false;
|
|
1394
1392
|
const conditions = children(() => props.children),
|
|
1395
1393
|
evalConditions = createMemo(() => {
|
|
1396
1394
|
let conds = conditions();
|
|
1397
1395
|
if (!Array.isArray(conds)) conds = [conds];
|
|
1398
1396
|
for (let i = 0; i < conds.length; i++) {
|
|
1399
1397
|
const c = conds[i].when;
|
|
1400
|
-
if (c)
|
|
1398
|
+
if (c) {
|
|
1399
|
+
keyed = !!conds[i].keyed;
|
|
1400
|
+
return [i, c, conds[i]];
|
|
1401
|
+
}
|
|
1401
1402
|
}
|
|
1402
1403
|
return [-1];
|
|
1403
1404
|
}, undefined, {
|
|
@@ -1407,7 +1408,9 @@ function Switch(props) {
|
|
|
1407
1408
|
const [index, when, cond] = evalConditions();
|
|
1408
1409
|
if (index < 0) return props.fallback;
|
|
1409
1410
|
const c = cond.children;
|
|
1410
|
-
|
|
1411
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1412
|
+
strictEqual = keyed || fn;
|
|
1413
|
+
return fn ? untrack(() => c(when)) : c;
|
|
1411
1414
|
});
|
|
1412
1415
|
}
|
|
1413
1416
|
function Match(props) {
|
|
@@ -1430,81 +1433,94 @@ function ErrorBoundary(props) {
|
|
|
1430
1433
|
if (e = errored()) {
|
|
1431
1434
|
const f = props.fallback;
|
|
1432
1435
|
if ((typeof f !== "function" || f.length == 0)) console.error(e);
|
|
1433
|
-
|
|
1436
|
+
const res = typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1437
|
+
onError(setErrored);
|
|
1438
|
+
return res;
|
|
1434
1439
|
}
|
|
1435
1440
|
onError(setErrored);
|
|
1436
1441
|
return props.children;
|
|
1437
1442
|
});
|
|
1438
1443
|
}
|
|
1439
1444
|
|
|
1445
|
+
const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1440
1446
|
const SuspenseListContext = createContext();
|
|
1441
1447
|
function SuspenseList(props) {
|
|
1442
|
-
let
|
|
1448
|
+
let [wrapper, setWrapper] = createSignal(() => ({
|
|
1449
|
+
inFallback: false
|
|
1450
|
+
})),
|
|
1451
|
+
show;
|
|
1443
1452
|
const listContext = useContext(SuspenseListContext);
|
|
1453
|
+
const [registry, setRegistry] = createSignal([]);
|
|
1444
1454
|
if (listContext) {
|
|
1445
|
-
|
|
1446
|
-
suspenseSetter = setFallback;
|
|
1447
|
-
[showContent, showFallback] = listContext.register(inFallback);
|
|
1455
|
+
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1448
1456
|
}
|
|
1449
|
-
const
|
|
1450
|
-
comp = createComponent(SuspenseListContext.Provider, {
|
|
1451
|
-
value: {
|
|
1452
|
-
register: inFallback => {
|
|
1453
|
-
const [showingContent, showContent] = createSignal(false),
|
|
1454
|
-
[showingFallback, showFallback] = createSignal(false);
|
|
1455
|
-
setRegistry(registry => [...registry, {
|
|
1456
|
-
inFallback,
|
|
1457
|
-
showContent,
|
|
1458
|
-
showFallback
|
|
1459
|
-
}]);
|
|
1460
|
-
return [showingContent, showingFallback];
|
|
1461
|
-
}
|
|
1462
|
-
},
|
|
1463
|
-
get children() {
|
|
1464
|
-
return props.children;
|
|
1465
|
-
}
|
|
1466
|
-
});
|
|
1467
|
-
createComputed(() => {
|
|
1457
|
+
const resolved = createMemo(prev => {
|
|
1468
1458
|
const reveal = props.revealOrder,
|
|
1469
1459
|
tail = props.tail,
|
|
1470
|
-
|
|
1471
|
-
|
|
1460
|
+
{
|
|
1461
|
+
showContent = true,
|
|
1462
|
+
showFallback = true
|
|
1463
|
+
} = show ? show() : {},
|
|
1472
1464
|
reg = registry(),
|
|
1473
1465
|
reverse = reveal === "backwards";
|
|
1474
1466
|
if (reveal === "together") {
|
|
1475
|
-
const all = reg.every(
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
return;
|
|
1467
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1468
|
+
const res = reg.map(() => ({
|
|
1469
|
+
showContent: all && showContent,
|
|
1470
|
+
showFallback
|
|
1471
|
+
}));
|
|
1472
|
+
res.inFallback = !all;
|
|
1473
|
+
return res;
|
|
1482
1474
|
}
|
|
1483
1475
|
let stop = false;
|
|
1476
|
+
let inFallback = prev.inFallback;
|
|
1477
|
+
const res = [];
|
|
1484
1478
|
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1485
1479
|
const n = reverse ? len - i - 1 : i,
|
|
1486
|
-
s = reg[n]
|
|
1480
|
+
s = reg[n]();
|
|
1487
1481
|
if (!stop && !s) {
|
|
1488
|
-
|
|
1489
|
-
|
|
1482
|
+
res[n] = {
|
|
1483
|
+
showContent,
|
|
1484
|
+
showFallback
|
|
1485
|
+
};
|
|
1490
1486
|
} else {
|
|
1491
1487
|
const next = !stop;
|
|
1492
|
-
if (next
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1488
|
+
if (next) inFallback = true;
|
|
1489
|
+
res[n] = {
|
|
1490
|
+
showContent: next,
|
|
1491
|
+
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1492
|
+
};
|
|
1496
1493
|
stop = true;
|
|
1497
|
-
reg[n].showContent(next);
|
|
1498
1494
|
}
|
|
1499
1495
|
}
|
|
1500
|
-
if (!stop
|
|
1496
|
+
if (!stop) inFallback = false;
|
|
1497
|
+
res.inFallback = inFallback;
|
|
1498
|
+
return res;
|
|
1499
|
+
}, {
|
|
1500
|
+
inFallback: false
|
|
1501
|
+
});
|
|
1502
|
+
setWrapper(() => resolved);
|
|
1503
|
+
return createComponent(SuspenseListContext.Provider, {
|
|
1504
|
+
value: {
|
|
1505
|
+
register: inFallback => {
|
|
1506
|
+
let index;
|
|
1507
|
+
setRegistry(registry => {
|
|
1508
|
+
index = registry.length;
|
|
1509
|
+
return [...registry, inFallback];
|
|
1510
|
+
});
|
|
1511
|
+
return createMemo(() => resolved()[index], undefined, {
|
|
1512
|
+
equals: suspenseListEquals
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
},
|
|
1516
|
+
get children() {
|
|
1517
|
+
return props.children;
|
|
1518
|
+
}
|
|
1501
1519
|
});
|
|
1502
|
-
return comp;
|
|
1503
1520
|
}
|
|
1504
1521
|
function Suspense(props) {
|
|
1505
1522
|
let counter = 0,
|
|
1506
|
-
|
|
1507
|
-
showFallback,
|
|
1523
|
+
show,
|
|
1508
1524
|
ctx,
|
|
1509
1525
|
p,
|
|
1510
1526
|
flicker,
|
|
@@ -1526,29 +1542,26 @@ function Suspense(props) {
|
|
|
1526
1542
|
if (sharedConfig.context && sharedConfig.load) {
|
|
1527
1543
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1528
1544
|
let ref = sharedConfig.load(key);
|
|
1529
|
-
if (ref) {
|
|
1530
|
-
p =
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
setHydrateContext();
|
|
1546
|
-
});
|
|
1547
|
-
}
|
|
1545
|
+
if (ref && (p = ref[0]) && p !== "$$f") {
|
|
1546
|
+
if (typeof p !== "object" || !("then" in p)) p = Promise.resolve(p);
|
|
1547
|
+
const [s, set] = createSignal(undefined, {
|
|
1548
|
+
equals: false
|
|
1549
|
+
});
|
|
1550
|
+
flicker = s;
|
|
1551
|
+
p.then(err => {
|
|
1552
|
+
if (err || sharedConfig.done) {
|
|
1553
|
+
err && (error = err);
|
|
1554
|
+
return set();
|
|
1555
|
+
}
|
|
1556
|
+
sharedConfig.gather(key);
|
|
1557
|
+
setHydrateContext(ctx);
|
|
1558
|
+
set();
|
|
1559
|
+
setHydrateContext();
|
|
1560
|
+
});
|
|
1548
1561
|
}
|
|
1549
1562
|
}
|
|
1550
1563
|
const listContext = useContext(SuspenseListContext);
|
|
1551
|
-
if (listContext)
|
|
1564
|
+
if (listContext) show = listContext.register(store.inFallback);
|
|
1552
1565
|
let dispose;
|
|
1553
1566
|
onCleanup(() => dispose && dispose());
|
|
1554
1567
|
return createComponent(SuspenseContext.Provider, {
|
|
@@ -1561,20 +1574,23 @@ function Suspense(props) {
|
|
|
1561
1574
|
flicker();
|
|
1562
1575
|
return flicker = undefined;
|
|
1563
1576
|
}
|
|
1564
|
-
if (ctx &&
|
|
1577
|
+
if (ctx && p === "$$f") setHydrateContext();
|
|
1565
1578
|
const rendered = createMemo(() => props.children);
|
|
1566
|
-
return createMemo(
|
|
1579
|
+
return createMemo(prev => {
|
|
1567
1580
|
const inFallback = store.inFallback(),
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1581
|
+
{
|
|
1582
|
+
showContent = true,
|
|
1583
|
+
showFallback = true
|
|
1584
|
+
} = show ? show() : {};
|
|
1585
|
+
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1572
1586
|
store.resolved = true;
|
|
1573
|
-
|
|
1587
|
+
dispose && dispose();
|
|
1588
|
+
dispose = ctx = p = undefined;
|
|
1574
1589
|
resumeEffects(store.effects);
|
|
1575
1590
|
return rendered();
|
|
1576
1591
|
}
|
|
1577
|
-
if (!
|
|
1592
|
+
if (!showFallback) return;
|
|
1593
|
+
if (dispose) return prev;
|
|
1578
1594
|
return createRoot(disposer => {
|
|
1579
1595
|
dispose = disposer;
|
|
1580
1596
|
if (ctx) {
|