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.cjs
CHANGED
|
@@ -153,7 +153,6 @@ let Transition = null;
|
|
|
153
153
|
let Scheduler = null;
|
|
154
154
|
let ExternalSourceFactory = null;
|
|
155
155
|
let Listener = null;
|
|
156
|
-
let Pending = null;
|
|
157
156
|
let Updates = null;
|
|
158
157
|
let Effects = null;
|
|
159
158
|
let ExecCount = 0;
|
|
@@ -170,7 +169,7 @@ function createRoot(fn, detachedOwner) {
|
|
|
170
169
|
},
|
|
171
170
|
updateFn = unowned ? () => fn(() => {
|
|
172
171
|
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
173
|
-
}) : () => fn(() => cleanNode(root));
|
|
172
|
+
}) : () => fn(() => untrack(() => cleanNode(root)));
|
|
174
173
|
{
|
|
175
174
|
if (owner) root.name = `${owner.name}-r${rootCount++}`;
|
|
176
175
|
globalThis._$afterCreateRoot && globalThis._$afterCreateRoot(root);
|
|
@@ -243,18 +242,19 @@ function createMemo(fn, value, options) {
|
|
|
243
242
|
} else updateComputation(c);
|
|
244
243
|
return readSignal.bind(c);
|
|
245
244
|
}
|
|
246
|
-
function createResource(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
source = true;
|
|
252
|
-
}
|
|
253
|
-
} else if (arguments.length === 1) {
|
|
254
|
-
fetcher = source;
|
|
245
|
+
function createResource(pSource, pFetcher, pOptions) {
|
|
246
|
+
let source;
|
|
247
|
+
let fetcher;
|
|
248
|
+
let options;
|
|
249
|
+
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
255
250
|
source = true;
|
|
251
|
+
fetcher = pSource;
|
|
252
|
+
options = pFetcher || {};
|
|
253
|
+
} else {
|
|
254
|
+
source = pSource;
|
|
255
|
+
fetcher = pFetcher;
|
|
256
|
+
options = pOptions || {};
|
|
256
257
|
}
|
|
257
|
-
options || (options = {});
|
|
258
258
|
let err = undefined,
|
|
259
259
|
pr = null,
|
|
260
260
|
initP = NO_INIT,
|
|
@@ -272,7 +272,7 @@ function createResource(source, fetcher, options) {
|
|
|
272
272
|
if (sharedConfig.context) {
|
|
273
273
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
274
274
|
let v;
|
|
275
|
-
if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
275
|
+
if (options.useInitialValue) initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
276
276
|
}
|
|
277
277
|
function loadEnd(p, v, success, key) {
|
|
278
278
|
if (pr === p) {
|
|
@@ -300,8 +300,8 @@ function createResource(source, fetcher, options) {
|
|
|
300
300
|
function completeLoad(v, success) {
|
|
301
301
|
!success && (err = castError(v));
|
|
302
302
|
runUpdates(() => {
|
|
303
|
-
setValue(() =>
|
|
304
|
-
setState(success ? "ready" : "
|
|
303
|
+
setValue(() => v);
|
|
304
|
+
setState(success ? "ready" : "errored");
|
|
305
305
|
for (const c of contexts.keys()) c.decrement();
|
|
306
306
|
contexts.clear();
|
|
307
307
|
}, false);
|
|
@@ -324,7 +324,7 @@ function createResource(source, fetcher, options) {
|
|
|
324
324
|
return v;
|
|
325
325
|
}
|
|
326
326
|
function load(refetching = true) {
|
|
327
|
-
if (refetching && scheduled) return;
|
|
327
|
+
if (refetching !== false && scheduled) return;
|
|
328
328
|
scheduled = false;
|
|
329
329
|
err = undefined;
|
|
330
330
|
const lookup = dynamic ? dynamic() : source;
|
|
@@ -352,10 +352,11 @@ function createResource(source, fetcher, options) {
|
|
|
352
352
|
return p.then(v => loadEnd(p, v, true, lookup), e => loadEnd(p, e, false));
|
|
353
353
|
}
|
|
354
354
|
Object.defineProperties(read, {
|
|
355
|
+
value: {
|
|
356
|
+
get: () => value()
|
|
357
|
+
},
|
|
355
358
|
state: {
|
|
356
|
-
get()
|
|
357
|
-
return state();
|
|
358
|
-
}
|
|
359
|
+
get: () => state()
|
|
359
360
|
},
|
|
360
361
|
loading: {
|
|
361
362
|
get() {
|
|
@@ -365,13 +366,13 @@ function createResource(source, fetcher, options) {
|
|
|
365
366
|
},
|
|
366
367
|
error: {
|
|
367
368
|
get() {
|
|
368
|
-
return state() === "
|
|
369
|
+
return state() === "errored" ? err : undefined;
|
|
369
370
|
}
|
|
370
371
|
},
|
|
371
372
|
latest: {
|
|
372
373
|
get() {
|
|
373
374
|
if (!resolved) return read();
|
|
374
|
-
if (state() === "
|
|
375
|
+
if (state() === "errored") throw err;
|
|
375
376
|
return value();
|
|
376
377
|
}
|
|
377
378
|
}
|
|
@@ -400,9 +401,8 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
400
401
|
const subs = new Map();
|
|
401
402
|
const node = createComputation(p => {
|
|
402
403
|
const v = source();
|
|
403
|
-
for (const key of subs.
|
|
404
|
-
const
|
|
405
|
-
for (const c of l.values()) {
|
|
404
|
+
for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
|
|
405
|
+
for (const c of val.values()) {
|
|
406
406
|
c.state = STALE;
|
|
407
407
|
if (c.pure) Updates.push(c);else Effects.push(c);
|
|
408
408
|
}
|
|
@@ -411,8 +411,8 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
411
411
|
}, undefined, true, STALE, options );
|
|
412
412
|
updateComputation(node);
|
|
413
413
|
return key => {
|
|
414
|
-
|
|
415
|
-
if (listener
|
|
414
|
+
const listener = Listener;
|
|
415
|
+
if (listener) {
|
|
416
416
|
let l;
|
|
417
417
|
if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
|
|
418
418
|
onCleanup(() => {
|
|
@@ -424,18 +424,7 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
424
424
|
};
|
|
425
425
|
}
|
|
426
426
|
function batch(fn) {
|
|
427
|
-
|
|
428
|
-
let result;
|
|
429
|
-
const q = Pending = [];
|
|
430
|
-
try {
|
|
431
|
-
result = fn();
|
|
432
|
-
} finally {
|
|
433
|
-
Pending = null;
|
|
434
|
-
}
|
|
435
|
-
runUpdates(() => {
|
|
436
|
-
for (let i = 0; i < q.length; i += 1) notifySignal(q[i]);
|
|
437
|
-
}, false);
|
|
438
|
-
return result;
|
|
427
|
+
return runUpdates(fn, false);
|
|
439
428
|
}
|
|
440
429
|
function untrack(fn) {
|
|
441
430
|
let result,
|
|
@@ -596,7 +585,12 @@ function useContext(context) {
|
|
|
596
585
|
}
|
|
597
586
|
function children(fn) {
|
|
598
587
|
const children = createMemo(fn);
|
|
599
|
-
|
|
588
|
+
const memo = createMemo(() => resolveChildren(children()));
|
|
589
|
+
memo.toArray = () => {
|
|
590
|
+
const c = memo();
|
|
591
|
+
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
592
|
+
};
|
|
593
|
+
return memo;
|
|
600
594
|
}
|
|
601
595
|
let SuspenseContext;
|
|
602
596
|
function getSuspenseContext() {
|
|
@@ -623,10 +617,12 @@ function enableExternalSource(factory) {
|
|
|
623
617
|
function readSignal() {
|
|
624
618
|
const runningTransition = Transition && Transition.running;
|
|
625
619
|
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
620
|
+
if (!runningTransition && this.state === STALE || runningTransition && this.tState === STALE) updateComputation(this);else {
|
|
621
|
+
const updates = Updates;
|
|
622
|
+
Updates = null;
|
|
623
|
+
runUpdates(() => lookUpstream(this), false);
|
|
624
|
+
Updates = updates;
|
|
625
|
+
}
|
|
630
626
|
}
|
|
631
627
|
if (Listener) {
|
|
632
628
|
const sSlot = this.observers ? this.observers.length : 0;
|
|
@@ -659,30 +655,27 @@ function writeSignal(node, value, isComp) {
|
|
|
659
655
|
}
|
|
660
656
|
if (!TransitionRunning) node.value = value;
|
|
661
657
|
} else node.value = value;
|
|
662
|
-
if (
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
|
|
674
|
-
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
675
|
-
if (o.observers) markDownstream(o);
|
|
658
|
+
if (node.observers && node.observers.length) {
|
|
659
|
+
runUpdates(() => {
|
|
660
|
+
for (let i = 0; i < node.observers.length; i += 1) {
|
|
661
|
+
const o = node.observers[i];
|
|
662
|
+
const TransitionRunning = Transition && Transition.running;
|
|
663
|
+
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
664
|
+
if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
|
|
665
|
+
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
666
|
+
if (o.observers) markDownstream(o);
|
|
667
|
+
}
|
|
668
|
+
if (TransitionRunning) o.tState = STALE;else o.state = STALE;
|
|
676
669
|
}
|
|
677
|
-
if (
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
}, false);
|
|
670
|
+
if (Updates.length > 10e5) {
|
|
671
|
+
Updates = [];
|
|
672
|
+
if ("_SOLID_DEV_") throw new Error("Potential Infinite Loop Detected.");
|
|
673
|
+
throw new Error();
|
|
674
|
+
}
|
|
675
|
+
}, false);
|
|
676
|
+
}
|
|
685
677
|
}
|
|
678
|
+
return value;
|
|
686
679
|
}
|
|
687
680
|
function updateComputation(node) {
|
|
688
681
|
if (!node.fn) return;
|
|
@@ -708,10 +701,11 @@ function runComputation(node, value, time) {
|
|
|
708
701
|
try {
|
|
709
702
|
nextValue = node.fn(value);
|
|
710
703
|
} catch (err) {
|
|
704
|
+
if (node.pure) Transition && Transition.running ? node.tState = STALE : node.state = STALE;
|
|
711
705
|
handleError(err);
|
|
712
706
|
}
|
|
713
707
|
if (!node.updatedAt || node.updatedAt <= time) {
|
|
714
|
-
if (node.updatedAt && "observers" in node) {
|
|
708
|
+
if (node.updatedAt != null && "observers" in node) {
|
|
715
709
|
writeSignal(node, nextValue, true);
|
|
716
710
|
} else if (Transition && Transition.running && node.pure) {
|
|
717
711
|
Transition.sources.add(node);
|
|
@@ -785,7 +779,7 @@ function runTop(node) {
|
|
|
785
779
|
} else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
786
780
|
const updates = Updates;
|
|
787
781
|
Updates = null;
|
|
788
|
-
lookUpstream(node, ancestors[0]);
|
|
782
|
+
runUpdates(() => lookUpstream(node, ancestors[0]), false);
|
|
789
783
|
Updates = updates;
|
|
790
784
|
}
|
|
791
785
|
}
|
|
@@ -980,7 +974,7 @@ function resolveChildren(children) {
|
|
|
980
974
|
function createProvider(id) {
|
|
981
975
|
return function provider(props) {
|
|
982
976
|
let res;
|
|
983
|
-
|
|
977
|
+
createRenderEffect(() => res = untrack(() => {
|
|
984
978
|
Owner.context = {
|
|
985
979
|
[id]: props.value
|
|
986
980
|
};
|
|
@@ -1026,7 +1020,7 @@ function observable(input) {
|
|
|
1026
1020
|
};
|
|
1027
1021
|
}
|
|
1028
1022
|
const dispose = createRoot(disposer => {
|
|
1029
|
-
|
|
1023
|
+
createEffect(() => {
|
|
1030
1024
|
const v = input();
|
|
1031
1025
|
untrack(() => handler(v));
|
|
1032
1026
|
});
|
|
@@ -1381,6 +1375,7 @@ function Index(props) {
|
|
|
1381
1375
|
}
|
|
1382
1376
|
function Show(props) {
|
|
1383
1377
|
let strictEqual = false;
|
|
1378
|
+
const keyed = props.keyed;
|
|
1384
1379
|
const condition = createMemo(() => props.when, undefined, {
|
|
1385
1380
|
equals: (a, b) => strictEqual ? a === b : !a === !b
|
|
1386
1381
|
});
|
|
@@ -1388,20 +1383,26 @@ function Show(props) {
|
|
|
1388
1383
|
const c = condition();
|
|
1389
1384
|
if (c) {
|
|
1390
1385
|
const child = props.children;
|
|
1391
|
-
|
|
1386
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1387
|
+
strictEqual = keyed || fn;
|
|
1388
|
+
return fn ? untrack(() => child(c)) : child;
|
|
1392
1389
|
}
|
|
1393
1390
|
return props.fallback;
|
|
1394
1391
|
});
|
|
1395
1392
|
}
|
|
1396
1393
|
function Switch(props) {
|
|
1397
1394
|
let strictEqual = false;
|
|
1395
|
+
let keyed = false;
|
|
1398
1396
|
const conditions = children(() => props.children),
|
|
1399
1397
|
evalConditions = createMemo(() => {
|
|
1400
1398
|
let conds = conditions();
|
|
1401
1399
|
if (!Array.isArray(conds)) conds = [conds];
|
|
1402
1400
|
for (let i = 0; i < conds.length; i++) {
|
|
1403
1401
|
const c = conds[i].when;
|
|
1404
|
-
if (c)
|
|
1402
|
+
if (c) {
|
|
1403
|
+
keyed = !!conds[i].keyed;
|
|
1404
|
+
return [i, c, conds[i]];
|
|
1405
|
+
}
|
|
1405
1406
|
}
|
|
1406
1407
|
return [-1];
|
|
1407
1408
|
}, undefined, {
|
|
@@ -1411,7 +1412,9 @@ function Switch(props) {
|
|
|
1411
1412
|
const [index, when, cond] = evalConditions();
|
|
1412
1413
|
if (index < 0) return props.fallback;
|
|
1413
1414
|
const c = cond.children;
|
|
1414
|
-
|
|
1415
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1416
|
+
strictEqual = keyed || fn;
|
|
1417
|
+
return fn ? untrack(() => c(when)) : c;
|
|
1415
1418
|
});
|
|
1416
1419
|
}
|
|
1417
1420
|
function Match(props) {
|
|
@@ -1434,81 +1437,94 @@ function ErrorBoundary(props) {
|
|
|
1434
1437
|
if (e = errored()) {
|
|
1435
1438
|
const f = props.fallback;
|
|
1436
1439
|
if ((typeof f !== "function" || f.length == 0)) console.error(e);
|
|
1437
|
-
|
|
1440
|
+
const res = typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1441
|
+
onError(setErrored);
|
|
1442
|
+
return res;
|
|
1438
1443
|
}
|
|
1439
1444
|
onError(setErrored);
|
|
1440
1445
|
return props.children;
|
|
1441
1446
|
});
|
|
1442
1447
|
}
|
|
1443
1448
|
|
|
1449
|
+
const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1444
1450
|
const SuspenseListContext = createContext();
|
|
1445
1451
|
function SuspenseList(props) {
|
|
1446
|
-
let
|
|
1452
|
+
let [wrapper, setWrapper] = createSignal(() => ({
|
|
1453
|
+
inFallback: false
|
|
1454
|
+
})),
|
|
1455
|
+
show;
|
|
1447
1456
|
const listContext = useContext(SuspenseListContext);
|
|
1457
|
+
const [registry, setRegistry] = createSignal([]);
|
|
1448
1458
|
if (listContext) {
|
|
1449
|
-
|
|
1450
|
-
suspenseSetter = setFallback;
|
|
1451
|
-
[showContent, showFallback] = listContext.register(inFallback);
|
|
1459
|
+
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1452
1460
|
}
|
|
1453
|
-
const
|
|
1454
|
-
comp = createComponent(SuspenseListContext.Provider, {
|
|
1455
|
-
value: {
|
|
1456
|
-
register: inFallback => {
|
|
1457
|
-
const [showingContent, showContent] = createSignal(false),
|
|
1458
|
-
[showingFallback, showFallback] = createSignal(false);
|
|
1459
|
-
setRegistry(registry => [...registry, {
|
|
1460
|
-
inFallback,
|
|
1461
|
-
showContent,
|
|
1462
|
-
showFallback
|
|
1463
|
-
}]);
|
|
1464
|
-
return [showingContent, showingFallback];
|
|
1465
|
-
}
|
|
1466
|
-
},
|
|
1467
|
-
get children() {
|
|
1468
|
-
return props.children;
|
|
1469
|
-
}
|
|
1470
|
-
});
|
|
1471
|
-
createComputed(() => {
|
|
1461
|
+
const resolved = createMemo(prev => {
|
|
1472
1462
|
const reveal = props.revealOrder,
|
|
1473
1463
|
tail = props.tail,
|
|
1474
|
-
|
|
1475
|
-
|
|
1464
|
+
{
|
|
1465
|
+
showContent = true,
|
|
1466
|
+
showFallback = true
|
|
1467
|
+
} = show ? show() : {},
|
|
1476
1468
|
reg = registry(),
|
|
1477
1469
|
reverse = reveal === "backwards";
|
|
1478
1470
|
if (reveal === "together") {
|
|
1479
|
-
const all = reg.every(
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
return;
|
|
1471
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1472
|
+
const res = reg.map(() => ({
|
|
1473
|
+
showContent: all && showContent,
|
|
1474
|
+
showFallback
|
|
1475
|
+
}));
|
|
1476
|
+
res.inFallback = !all;
|
|
1477
|
+
return res;
|
|
1486
1478
|
}
|
|
1487
1479
|
let stop = false;
|
|
1480
|
+
let inFallback = prev.inFallback;
|
|
1481
|
+
const res = [];
|
|
1488
1482
|
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1489
1483
|
const n = reverse ? len - i - 1 : i,
|
|
1490
|
-
s = reg[n]
|
|
1484
|
+
s = reg[n]();
|
|
1491
1485
|
if (!stop && !s) {
|
|
1492
|
-
|
|
1493
|
-
|
|
1486
|
+
res[n] = {
|
|
1487
|
+
showContent,
|
|
1488
|
+
showFallback
|
|
1489
|
+
};
|
|
1494
1490
|
} else {
|
|
1495
1491
|
const next = !stop;
|
|
1496
|
-
if (next
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1492
|
+
if (next) inFallback = true;
|
|
1493
|
+
res[n] = {
|
|
1494
|
+
showContent: next,
|
|
1495
|
+
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1496
|
+
};
|
|
1500
1497
|
stop = true;
|
|
1501
|
-
reg[n].showContent(next);
|
|
1502
1498
|
}
|
|
1503
1499
|
}
|
|
1504
|
-
if (!stop
|
|
1500
|
+
if (!stop) inFallback = false;
|
|
1501
|
+
res.inFallback = inFallback;
|
|
1502
|
+
return res;
|
|
1503
|
+
}, {
|
|
1504
|
+
inFallback: false
|
|
1505
|
+
});
|
|
1506
|
+
setWrapper(() => resolved);
|
|
1507
|
+
return createComponent(SuspenseListContext.Provider, {
|
|
1508
|
+
value: {
|
|
1509
|
+
register: inFallback => {
|
|
1510
|
+
let index;
|
|
1511
|
+
setRegistry(registry => {
|
|
1512
|
+
index = registry.length;
|
|
1513
|
+
return [...registry, inFallback];
|
|
1514
|
+
});
|
|
1515
|
+
return createMemo(() => resolved()[index], undefined, {
|
|
1516
|
+
equals: suspenseListEquals
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
},
|
|
1520
|
+
get children() {
|
|
1521
|
+
return props.children;
|
|
1522
|
+
}
|
|
1505
1523
|
});
|
|
1506
|
-
return comp;
|
|
1507
1524
|
}
|
|
1508
1525
|
function Suspense(props) {
|
|
1509
1526
|
let counter = 0,
|
|
1510
|
-
|
|
1511
|
-
showFallback,
|
|
1527
|
+
show,
|
|
1512
1528
|
ctx,
|
|
1513
1529
|
p,
|
|
1514
1530
|
flicker,
|
|
@@ -1530,29 +1546,26 @@ function Suspense(props) {
|
|
|
1530
1546
|
if (sharedConfig.context && sharedConfig.load) {
|
|
1531
1547
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1532
1548
|
let ref = sharedConfig.load(key);
|
|
1533
|
-
if (ref) {
|
|
1534
|
-
p =
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
setHydrateContext();
|
|
1550
|
-
});
|
|
1551
|
-
}
|
|
1549
|
+
if (ref && (p = ref[0]) && p !== "$$f") {
|
|
1550
|
+
if (typeof p !== "object" || !("then" in p)) p = Promise.resolve(p);
|
|
1551
|
+
const [s, set] = createSignal(undefined, {
|
|
1552
|
+
equals: false
|
|
1553
|
+
});
|
|
1554
|
+
flicker = s;
|
|
1555
|
+
p.then(err => {
|
|
1556
|
+
if (err || sharedConfig.done) {
|
|
1557
|
+
err && (error = err);
|
|
1558
|
+
return set();
|
|
1559
|
+
}
|
|
1560
|
+
sharedConfig.gather(key);
|
|
1561
|
+
setHydrateContext(ctx);
|
|
1562
|
+
set();
|
|
1563
|
+
setHydrateContext();
|
|
1564
|
+
});
|
|
1552
1565
|
}
|
|
1553
1566
|
}
|
|
1554
1567
|
const listContext = useContext(SuspenseListContext);
|
|
1555
|
-
if (listContext)
|
|
1568
|
+
if (listContext) show = listContext.register(store.inFallback);
|
|
1556
1569
|
let dispose;
|
|
1557
1570
|
onCleanup(() => dispose && dispose());
|
|
1558
1571
|
return createComponent(SuspenseContext.Provider, {
|
|
@@ -1565,20 +1578,23 @@ function Suspense(props) {
|
|
|
1565
1578
|
flicker();
|
|
1566
1579
|
return flicker = undefined;
|
|
1567
1580
|
}
|
|
1568
|
-
if (ctx &&
|
|
1581
|
+
if (ctx && p === "$$f") setHydrateContext();
|
|
1569
1582
|
const rendered = createMemo(() => props.children);
|
|
1570
|
-
return createMemo(
|
|
1583
|
+
return createMemo(prev => {
|
|
1571
1584
|
const inFallback = store.inFallback(),
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1585
|
+
{
|
|
1586
|
+
showContent = true,
|
|
1587
|
+
showFallback = true
|
|
1588
|
+
} = show ? show() : {};
|
|
1589
|
+
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1576
1590
|
store.resolved = true;
|
|
1577
|
-
|
|
1591
|
+
dispose && dispose();
|
|
1592
|
+
dispose = ctx = p = undefined;
|
|
1578
1593
|
resumeEffects(store.effects);
|
|
1579
1594
|
return rendered();
|
|
1580
1595
|
}
|
|
1581
|
-
if (!
|
|
1596
|
+
if (!showFallback) return;
|
|
1597
|
+
if (dispose) return prev;
|
|
1582
1598
|
return createRoot(disposer => {
|
|
1583
1599
|
dispose = disposer;
|
|
1584
1600
|
if (ctx) {
|