solid-js 1.5.0-beta.2 → 1.5.0-beta.5
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 +97 -72
- package/dist/dev.js +97 -72
- package/dist/server.cjs +14 -5
- package/dist/server.js +14 -5
- package/dist/solid.cjs +97 -72
- package/dist/solid.js +97 -72
- package/h/jsx-runtime/types/jsx.d.ts +1 -1
- package/package.json +5 -1
- package/store/types/store.d.ts +2 -2
- package/types/index.d.ts +1 -1
- package/types/jsx.d.ts +2 -2
- package/types/reactive/signal.d.ts +10 -6
- package/types/render/flow.d.ts +18 -1
- package/types/server/reactive.d.ts +5 -1
- package/types/server/rendering.d.ts +10 -4
- 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/web/dist/dev.cjs +13 -7
- package/web/dist/dev.js +8 -6
- package/web/dist/server.cjs +288 -221
- package/web/dist/server.js +286 -222
- package/web/dist/web.cjs +13 -7
- package/web/dist/web.js +8 -6
- package/web/types/client.d.ts +3 -0
- package/web/types/server-mock.d.ts +4 -1
- package/web/types/server.d.ts +2 -0
- package/jsx-runtime.d.ts +0 -1
package/dist/server.cjs
CHANGED
|
@@ -144,7 +144,12 @@ function getOwner() {
|
|
|
144
144
|
return Owner;
|
|
145
145
|
}
|
|
146
146
|
function children(fn) {
|
|
147
|
-
|
|
147
|
+
const memo = createMemo(() => resolveChildren(fn()));
|
|
148
|
+
memo.toArray = () => {
|
|
149
|
+
const c = memo();
|
|
150
|
+
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
151
|
+
};
|
|
152
|
+
return memo;
|
|
148
153
|
}
|
|
149
154
|
function runWithOwner(o, fn) {
|
|
150
155
|
const prev = Owner;
|
|
@@ -391,10 +396,10 @@ function createResource(source, fetcher, options = {}) {
|
|
|
391
396
|
const contexts = new Set();
|
|
392
397
|
const id = sharedConfig.context.id + sharedConfig.context.count++;
|
|
393
398
|
let resource = {};
|
|
394
|
-
let value = options.initialValue;
|
|
399
|
+
let value = options.storage ? options.storage(options.initialValue)[0]() : options.initialValue;
|
|
395
400
|
let p;
|
|
396
401
|
let error;
|
|
397
|
-
if (sharedConfig.context.async) {
|
|
402
|
+
if (sharedConfig.context.async && options.ssrValue !== "initial") {
|
|
398
403
|
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
399
404
|
if (resource.ref) {
|
|
400
405
|
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
|
|
@@ -404,7 +409,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
404
409
|
const read = () => {
|
|
405
410
|
if (error) throw error;
|
|
406
411
|
if (resourceContext && p) resourceContext.push(p);
|
|
407
|
-
const resolved = sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
|
|
412
|
+
const resolved = options.ssrValue !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
|
|
408
413
|
if (!resolved && read.loading) {
|
|
409
414
|
const ctx = useContext(SuspenseContext);
|
|
410
415
|
if (ctx) {
|
|
@@ -416,6 +421,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
416
421
|
};
|
|
417
422
|
read.loading = false;
|
|
418
423
|
read.error = undefined;
|
|
424
|
+
read.state = "initialValue" in options ? "resolved" : "unresolved";
|
|
419
425
|
Object.defineProperty(read, "latest", {
|
|
420
426
|
get() {
|
|
421
427
|
return read();
|
|
@@ -444,15 +450,18 @@ function createResource(source, fetcher, options = {}) {
|
|
|
444
450
|
}
|
|
445
451
|
if (p != undefined && typeof p === "object" && "then" in p) {
|
|
446
452
|
read.loading = true;
|
|
453
|
+
read.state = "pending";
|
|
447
454
|
if (ctx.writeResource) ctx.writeResource(id, p, undefined, options.deferStream);
|
|
448
455
|
return p.then(res => {
|
|
449
456
|
read.loading = false;
|
|
457
|
+
read.state = "resolved";
|
|
450
458
|
ctx.resources[id].data = res;
|
|
451
459
|
p = null;
|
|
452
460
|
notifySuspense(contexts);
|
|
453
461
|
return res;
|
|
454
462
|
}).catch(err => {
|
|
455
463
|
read.loading = false;
|
|
464
|
+
read.state = "errored";
|
|
456
465
|
read.error = error = castError(err);
|
|
457
466
|
p = null;
|
|
458
467
|
notifySuspense(contexts);
|
|
@@ -463,7 +472,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
463
472
|
p = null;
|
|
464
473
|
return ctx.resources[id].data;
|
|
465
474
|
}
|
|
466
|
-
load();
|
|
475
|
+
if (options.ssrValue !== "initial") load();
|
|
467
476
|
return resource.ref = [read, {
|
|
468
477
|
refetch: load,
|
|
469
478
|
mutate: v => value = v
|
package/dist/server.js
CHANGED
|
@@ -140,7 +140,12 @@ function getOwner() {
|
|
|
140
140
|
return Owner;
|
|
141
141
|
}
|
|
142
142
|
function children(fn) {
|
|
143
|
-
|
|
143
|
+
const memo = createMemo(() => resolveChildren(fn()));
|
|
144
|
+
memo.toArray = () => {
|
|
145
|
+
const c = memo();
|
|
146
|
+
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
147
|
+
};
|
|
148
|
+
return memo;
|
|
144
149
|
}
|
|
145
150
|
function runWithOwner(o, fn) {
|
|
146
151
|
const prev = Owner;
|
|
@@ -387,10 +392,10 @@ function createResource(source, fetcher, options = {}) {
|
|
|
387
392
|
const contexts = new Set();
|
|
388
393
|
const id = sharedConfig.context.id + sharedConfig.context.count++;
|
|
389
394
|
let resource = {};
|
|
390
|
-
let value = options.initialValue;
|
|
395
|
+
let value = options.storage ? options.storage(options.initialValue)[0]() : options.initialValue;
|
|
391
396
|
let p;
|
|
392
397
|
let error;
|
|
393
|
-
if (sharedConfig.context.async) {
|
|
398
|
+
if (sharedConfig.context.async && options.ssrValue !== "initial") {
|
|
394
399
|
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
395
400
|
if (resource.ref) {
|
|
396
401
|
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
|
|
@@ -400,7 +405,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
400
405
|
const read = () => {
|
|
401
406
|
if (error) throw error;
|
|
402
407
|
if (resourceContext && p) resourceContext.push(p);
|
|
403
|
-
const resolved = sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
|
|
408
|
+
const resolved = options.ssrValue !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
|
|
404
409
|
if (!resolved && read.loading) {
|
|
405
410
|
const ctx = useContext(SuspenseContext);
|
|
406
411
|
if (ctx) {
|
|
@@ -412,6 +417,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
412
417
|
};
|
|
413
418
|
read.loading = false;
|
|
414
419
|
read.error = undefined;
|
|
420
|
+
read.state = "initialValue" in options ? "resolved" : "unresolved";
|
|
415
421
|
Object.defineProperty(read, "latest", {
|
|
416
422
|
get() {
|
|
417
423
|
return read();
|
|
@@ -440,15 +446,18 @@ function createResource(source, fetcher, options = {}) {
|
|
|
440
446
|
}
|
|
441
447
|
if (p != undefined && typeof p === "object" && "then" in p) {
|
|
442
448
|
read.loading = true;
|
|
449
|
+
read.state = "pending";
|
|
443
450
|
if (ctx.writeResource) ctx.writeResource(id, p, undefined, options.deferStream);
|
|
444
451
|
return p.then(res => {
|
|
445
452
|
read.loading = false;
|
|
453
|
+
read.state = "resolved";
|
|
446
454
|
ctx.resources[id].data = res;
|
|
447
455
|
p = null;
|
|
448
456
|
notifySuspense(contexts);
|
|
449
457
|
return res;
|
|
450
458
|
}).catch(err => {
|
|
451
459
|
read.loading = false;
|
|
460
|
+
read.state = "errored";
|
|
452
461
|
read.error = error = castError(err);
|
|
453
462
|
p = null;
|
|
454
463
|
notifySuspense(contexts);
|
|
@@ -459,7 +468,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
459
468
|
p = null;
|
|
460
469
|
return ctx.resources[id].data;
|
|
461
470
|
}
|
|
462
|
-
load();
|
|
471
|
+
if (options.ssrValue !== "initial") load();
|
|
463
472
|
return resource.ref = [read, {
|
|
464
473
|
refetch: load,
|
|
465
474
|
mutate: v => value = v
|
package/dist/solid.cjs
CHANGED
|
@@ -166,7 +166,7 @@ function createRoot(fn, detachedOwner) {
|
|
|
166
166
|
context: null,
|
|
167
167
|
owner: detachedOwner || owner
|
|
168
168
|
},
|
|
169
|
-
updateFn = unowned ? fn : () => fn(() => cleanNode(root));
|
|
169
|
+
updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
|
|
170
170
|
Owner = root;
|
|
171
171
|
Listener = null;
|
|
172
172
|
try {
|
|
@@ -256,7 +256,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
256
256
|
resolved = ("initialValue" in options),
|
|
257
257
|
dynamic = typeof source === "function" && createMemo(source);
|
|
258
258
|
const contexts = new Set(),
|
|
259
|
-
[value, setValue] =
|
|
259
|
+
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
260
260
|
[track, trigger] = createSignal(undefined, {
|
|
261
261
|
equals: false
|
|
262
262
|
}),
|
|
@@ -264,7 +264,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
264
264
|
if (sharedConfig.context) {
|
|
265
265
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
266
266
|
let v;
|
|
267
|
-
if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
267
|
+
if (options.ssrValue === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
268
268
|
}
|
|
269
269
|
function loadEnd(p, v, success, key) {
|
|
270
270
|
if (pr === p) {
|
|
@@ -293,7 +293,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
293
293
|
!success && (err = castError(v));
|
|
294
294
|
runUpdates(() => {
|
|
295
295
|
setValue(() => v);
|
|
296
|
-
setState(success ? "ready" : "
|
|
296
|
+
setState(success ? "ready" : "errored");
|
|
297
297
|
for (const c of contexts.keys()) c.decrement();
|
|
298
298
|
contexts.clear();
|
|
299
299
|
}, false);
|
|
@@ -345,9 +345,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
345
345
|
}
|
|
346
346
|
Object.defineProperties(read, {
|
|
347
347
|
state: {
|
|
348
|
-
get()
|
|
349
|
-
return state();
|
|
350
|
-
}
|
|
348
|
+
get: () => state()
|
|
351
349
|
},
|
|
352
350
|
loading: {
|
|
353
351
|
get() {
|
|
@@ -357,13 +355,13 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
357
355
|
},
|
|
358
356
|
error: {
|
|
359
357
|
get() {
|
|
360
|
-
return state() === "
|
|
358
|
+
return state() === "errored" ? err : undefined;
|
|
361
359
|
}
|
|
362
360
|
},
|
|
363
361
|
latest: {
|
|
364
362
|
get() {
|
|
365
363
|
if (!resolved) return read();
|
|
366
|
-
if (state() === "
|
|
364
|
+
if (state() === "errored") throw err;
|
|
367
365
|
return value();
|
|
368
366
|
}
|
|
369
367
|
}
|
|
@@ -392,9 +390,8 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
392
390
|
const subs = new Map();
|
|
393
391
|
const node = createComputation(p => {
|
|
394
392
|
const v = source();
|
|
395
|
-
for (const key of subs.
|
|
396
|
-
const
|
|
397
|
-
for (const c of l.values()) {
|
|
393
|
+
for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
|
|
394
|
+
for (const c of val.values()) {
|
|
398
395
|
c.state = STALE;
|
|
399
396
|
if (c.pure) Updates.push(c);else Effects.push(c);
|
|
400
397
|
}
|
|
@@ -403,8 +400,8 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
403
400
|
}, undefined, true, STALE);
|
|
404
401
|
updateComputation(node);
|
|
405
402
|
return key => {
|
|
406
|
-
|
|
407
|
-
if (listener
|
|
403
|
+
const listener = Listener;
|
|
404
|
+
if (listener) {
|
|
408
405
|
let l;
|
|
409
406
|
if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
|
|
410
407
|
onCleanup(() => {
|
|
@@ -525,7 +522,12 @@ function useContext(context) {
|
|
|
525
522
|
}
|
|
526
523
|
function children(fn) {
|
|
527
524
|
const children = createMemo(fn);
|
|
528
|
-
|
|
525
|
+
const memo = createMemo(() => resolveChildren(children()));
|
|
526
|
+
memo.toArray = () => {
|
|
527
|
+
const c = memo();
|
|
528
|
+
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
529
|
+
};
|
|
530
|
+
return memo;
|
|
529
531
|
}
|
|
530
532
|
let SuspenseContext;
|
|
531
533
|
function getSuspenseContext() {
|
|
@@ -640,7 +642,7 @@ function runComputation(node, value, time) {
|
|
|
640
642
|
handleError(err);
|
|
641
643
|
}
|
|
642
644
|
if (!node.updatedAt || node.updatedAt <= time) {
|
|
643
|
-
if (node.updatedAt && "observers" in node) {
|
|
645
|
+
if (node.updatedAt != null && "observers" in node) {
|
|
644
646
|
writeSignal(node, nextValue, true);
|
|
645
647
|
} else if (Transition && Transition.running && node.pure) {
|
|
646
648
|
Transition.sources.add(node);
|
|
@@ -907,7 +909,7 @@ function resolveChildren(children) {
|
|
|
907
909
|
function createProvider(id) {
|
|
908
910
|
return function provider(props) {
|
|
909
911
|
let res;
|
|
910
|
-
|
|
912
|
+
createRenderEffect(() => res = untrack(() => {
|
|
911
913
|
Owner.context = {
|
|
912
914
|
[id]: props.value
|
|
913
915
|
};
|
|
@@ -1282,6 +1284,7 @@ function Index(props) {
|
|
|
1282
1284
|
}
|
|
1283
1285
|
function Show(props) {
|
|
1284
1286
|
let strictEqual = false;
|
|
1287
|
+
const keyed = props.keyed;
|
|
1285
1288
|
const condition = createMemo(() => props.when, undefined, {
|
|
1286
1289
|
equals: (a, b) => strictEqual ? a === b : !a === !b
|
|
1287
1290
|
});
|
|
@@ -1289,20 +1292,26 @@ function Show(props) {
|
|
|
1289
1292
|
const c = condition();
|
|
1290
1293
|
if (c) {
|
|
1291
1294
|
const child = props.children;
|
|
1292
|
-
|
|
1295
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1296
|
+
strictEqual = keyed || fn;
|
|
1297
|
+
return fn ? untrack(() => child(c)) : child;
|
|
1293
1298
|
}
|
|
1294
1299
|
return props.fallback;
|
|
1295
1300
|
});
|
|
1296
1301
|
}
|
|
1297
1302
|
function Switch(props) {
|
|
1298
1303
|
let strictEqual = false;
|
|
1304
|
+
let keyed = false;
|
|
1299
1305
|
const conditions = children(() => props.children),
|
|
1300
1306
|
evalConditions = createMemo(() => {
|
|
1301
1307
|
let conds = conditions();
|
|
1302
1308
|
if (!Array.isArray(conds)) conds = [conds];
|
|
1303
1309
|
for (let i = 0; i < conds.length; i++) {
|
|
1304
1310
|
const c = conds[i].when;
|
|
1305
|
-
if (c)
|
|
1311
|
+
if (c) {
|
|
1312
|
+
keyed = !!conds[i].keyed;
|
|
1313
|
+
return [i, c, conds[i]];
|
|
1314
|
+
}
|
|
1306
1315
|
}
|
|
1307
1316
|
return [-1];
|
|
1308
1317
|
}, undefined, {
|
|
@@ -1312,7 +1321,9 @@ function Switch(props) {
|
|
|
1312
1321
|
const [index, when, cond] = evalConditions();
|
|
1313
1322
|
if (index < 0) return props.fallback;
|
|
1314
1323
|
const c = cond.children;
|
|
1315
|
-
|
|
1324
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1325
|
+
strictEqual = keyed || fn;
|
|
1326
|
+
return fn ? untrack(() => c(when)) : c;
|
|
1316
1327
|
});
|
|
1317
1328
|
}
|
|
1318
1329
|
function Match(props) {
|
|
@@ -1343,74 +1354,85 @@ function ErrorBoundary(props) {
|
|
|
1343
1354
|
});
|
|
1344
1355
|
}
|
|
1345
1356
|
|
|
1357
|
+
const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1346
1358
|
const SuspenseListContext = createContext();
|
|
1347
1359
|
function SuspenseList(props) {
|
|
1348
|
-
let
|
|
1360
|
+
let [wrapper, setWrapper] = createSignal(() => ({
|
|
1361
|
+
inFallback: false
|
|
1362
|
+
})),
|
|
1363
|
+
show;
|
|
1349
1364
|
const listContext = useContext(SuspenseListContext);
|
|
1365
|
+
const [registry, setRegistry] = createSignal([]);
|
|
1350
1366
|
if (listContext) {
|
|
1351
|
-
|
|
1352
|
-
suspenseSetter = setFallback;
|
|
1353
|
-
[showContent, showFallback] = listContext.register(inFallback);
|
|
1367
|
+
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1354
1368
|
}
|
|
1355
|
-
const
|
|
1356
|
-
comp = createComponent(SuspenseListContext.Provider, {
|
|
1357
|
-
value: {
|
|
1358
|
-
register: inFallback => {
|
|
1359
|
-
const [showingContent, showContent] = createSignal(false),
|
|
1360
|
-
[showingFallback, showFallback] = createSignal(false);
|
|
1361
|
-
setRegistry(registry => [...registry, {
|
|
1362
|
-
inFallback,
|
|
1363
|
-
showContent,
|
|
1364
|
-
showFallback
|
|
1365
|
-
}]);
|
|
1366
|
-
return [showingContent, showingFallback];
|
|
1367
|
-
}
|
|
1368
|
-
},
|
|
1369
|
-
get children() {
|
|
1370
|
-
return props.children;
|
|
1371
|
-
}
|
|
1372
|
-
});
|
|
1373
|
-
createComputed(() => {
|
|
1369
|
+
const resolved = createMemo(prev => {
|
|
1374
1370
|
const reveal = props.revealOrder,
|
|
1375
1371
|
tail = props.tail,
|
|
1376
|
-
|
|
1377
|
-
|
|
1372
|
+
{
|
|
1373
|
+
showContent = true,
|
|
1374
|
+
showFallback = true
|
|
1375
|
+
} = show ? show() : {},
|
|
1378
1376
|
reg = registry(),
|
|
1379
1377
|
reverse = reveal === "backwards";
|
|
1380
1378
|
if (reveal === "together") {
|
|
1381
|
-
const all = reg.every(
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
return;
|
|
1379
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1380
|
+
const res = reg.map(() => ({
|
|
1381
|
+
showContent: all && showContent,
|
|
1382
|
+
showFallback
|
|
1383
|
+
}));
|
|
1384
|
+
res.inFallback = !all;
|
|
1385
|
+
return res;
|
|
1388
1386
|
}
|
|
1389
1387
|
let stop = false;
|
|
1388
|
+
let inFallback = prev.inFallback;
|
|
1389
|
+
const res = [];
|
|
1390
1390
|
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1391
1391
|
const n = reverse ? len - i - 1 : i,
|
|
1392
|
-
s = reg[n]
|
|
1392
|
+
s = reg[n]();
|
|
1393
1393
|
if (!stop && !s) {
|
|
1394
|
-
|
|
1395
|
-
|
|
1394
|
+
res[n] = {
|
|
1395
|
+
showContent,
|
|
1396
|
+
showFallback
|
|
1397
|
+
};
|
|
1396
1398
|
} else {
|
|
1397
1399
|
const next = !stop;
|
|
1398
|
-
if (next
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1400
|
+
if (next) inFallback = true;
|
|
1401
|
+
res[n] = {
|
|
1402
|
+
showContent: next,
|
|
1403
|
+
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1404
|
+
};
|
|
1402
1405
|
stop = true;
|
|
1403
|
-
reg[n].showContent(next);
|
|
1404
1406
|
}
|
|
1405
1407
|
}
|
|
1406
|
-
if (!stop
|
|
1408
|
+
if (!stop) inFallback = false;
|
|
1409
|
+
res.inFallback = inFallback;
|
|
1410
|
+
return res;
|
|
1411
|
+
}, {
|
|
1412
|
+
inFallback: false
|
|
1413
|
+
});
|
|
1414
|
+
setWrapper(() => resolved);
|
|
1415
|
+
return createComponent(SuspenseListContext.Provider, {
|
|
1416
|
+
value: {
|
|
1417
|
+
register: inFallback => {
|
|
1418
|
+
let index;
|
|
1419
|
+
setRegistry(registry => {
|
|
1420
|
+
index = registry.length;
|
|
1421
|
+
return [...registry, inFallback];
|
|
1422
|
+
});
|
|
1423
|
+
return createMemo(() => resolved()[index], undefined, {
|
|
1424
|
+
equals: suspenseListEquals
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
},
|
|
1428
|
+
get children() {
|
|
1429
|
+
return props.children;
|
|
1430
|
+
}
|
|
1407
1431
|
});
|
|
1408
|
-
return comp;
|
|
1409
1432
|
}
|
|
1410
1433
|
function Suspense(props) {
|
|
1411
1434
|
let counter = 0,
|
|
1412
|
-
|
|
1413
|
-
showFallback,
|
|
1435
|
+
show,
|
|
1414
1436
|
ctx,
|
|
1415
1437
|
p,
|
|
1416
1438
|
flicker,
|
|
@@ -1451,7 +1473,7 @@ function Suspense(props) {
|
|
|
1451
1473
|
}
|
|
1452
1474
|
}
|
|
1453
1475
|
const listContext = useContext(SuspenseListContext);
|
|
1454
|
-
if (listContext)
|
|
1476
|
+
if (listContext) show = listContext.register(store.inFallback);
|
|
1455
1477
|
let dispose;
|
|
1456
1478
|
onCleanup(() => dispose && dispose());
|
|
1457
1479
|
return createComponent(SuspenseContext.Provider, {
|
|
@@ -1466,18 +1488,21 @@ function Suspense(props) {
|
|
|
1466
1488
|
}
|
|
1467
1489
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1468
1490
|
const rendered = createMemo(() => props.children);
|
|
1469
|
-
return createMemo(
|
|
1491
|
+
return createMemo(prev => {
|
|
1470
1492
|
const inFallback = store.inFallback(),
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1493
|
+
{
|
|
1494
|
+
showContent = true,
|
|
1495
|
+
showFallback = true
|
|
1496
|
+
} = show ? show() : {};
|
|
1497
|
+
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1475
1498
|
store.resolved = true;
|
|
1476
|
-
|
|
1499
|
+
dispose && dispose();
|
|
1500
|
+
dispose = ctx = p = undefined;
|
|
1477
1501
|
resumeEffects(store.effects);
|
|
1478
1502
|
return rendered();
|
|
1479
1503
|
}
|
|
1480
|
-
if (!
|
|
1504
|
+
if (!showFallback) return;
|
|
1505
|
+
if (dispose) return prev;
|
|
1481
1506
|
return createRoot(disposer => {
|
|
1482
1507
|
dispose = disposer;
|
|
1483
1508
|
if (ctx) {
|