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 CHANGED
@@ -169,7 +169,7 @@ function createRoot(fn, detachedOwner) {
169
169
  },
170
170
  updateFn = unowned ? () => fn(() => {
171
171
  throw new Error("Dispose method must be an explicit argument to createRoot function");
172
- }) : () => fn(() => cleanNode(root));
172
+ }) : () => fn(() => untrack(() => cleanNode(root)));
173
173
  {
174
174
  if (owner) root.name = `${owner.name}-r${rootCount++}`;
175
175
  globalThis._$afterCreateRoot && globalThis._$afterCreateRoot(root);
@@ -264,7 +264,7 @@ function createResource(pSource, pFetcher, pOptions) {
264
264
  resolved = ("initialValue" in options),
265
265
  dynamic = typeof source === "function" && createMemo(source);
266
266
  const contexts = new Set(),
267
- [value, setValue] = options.store ? options.store(options.initialValue) : createSignal(options.initialValue),
267
+ [value, setValue] = (options.storage || createSignal)(options.initialValue),
268
268
  [track, trigger] = createSignal(undefined, {
269
269
  equals: false
270
270
  }),
@@ -272,7 +272,7 @@ function createResource(pSource, pFetcher, pOptions) {
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.ssrValue === "initial") 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) {
@@ -301,7 +301,7 @@ function createResource(pSource, pFetcher, pOptions) {
301
301
  !success && (err = castError(v));
302
302
  runUpdates(() => {
303
303
  setValue(() => v);
304
- setState(success ? "ready" : "error");
304
+ setState(success ? "ready" : "errored");
305
305
  for (const c of contexts.keys()) c.decrement();
306
306
  contexts.clear();
307
307
  }, false);
@@ -353,9 +353,7 @@ function createResource(pSource, pFetcher, pOptions) {
353
353
  }
354
354
  Object.defineProperties(read, {
355
355
  state: {
356
- get() {
357
- return state();
358
- }
356
+ get: () => state()
359
357
  },
360
358
  loading: {
361
359
  get() {
@@ -365,13 +363,13 @@ function createResource(pSource, pFetcher, pOptions) {
365
363
  },
366
364
  error: {
367
365
  get() {
368
- return state() === "error" ? err : undefined;
366
+ return state() === "errored" ? err : undefined;
369
367
  }
370
368
  },
371
369
  latest: {
372
370
  get() {
373
371
  if (!resolved) return read();
374
- if (state() === "error") throw err;
372
+ if (state() === "errored") throw err;
375
373
  return value();
376
374
  }
377
375
  }
@@ -400,9 +398,8 @@ function createSelector(source, fn = equalFn, options) {
400
398
  const subs = new Map();
401
399
  const node = createComputation(p => {
402
400
  const v = source();
403
- for (const key of subs.keys()) if (fn(key, v) !== fn(key, p)) {
404
- const l = subs.get(key);
405
- for (const c of l.values()) {
401
+ for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
402
+ for (const c of val.values()) {
406
403
  c.state = STALE;
407
404
  if (c.pure) Updates.push(c);else Effects.push(c);
408
405
  }
@@ -411,8 +408,8 @@ function createSelector(source, fn = equalFn, options) {
411
408
  }, undefined, true, STALE, options );
412
409
  updateComputation(node);
413
410
  return key => {
414
- let listener;
415
- if (listener = Listener) {
411
+ const listener = Listener;
412
+ if (listener) {
416
413
  let l;
417
414
  if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
418
415
  onCleanup(() => {
@@ -585,7 +582,12 @@ function useContext(context) {
585
582
  }
586
583
  function children(fn) {
587
584
  const children = createMemo(fn);
588
- return createMemo(() => resolveChildren(children()));
585
+ const memo = createMemo(() => resolveChildren(children()));
586
+ memo.toArray = () => {
587
+ const c = memo();
588
+ return Array.isArray(c) ? c : c != null ? [c] : [];
589
+ };
590
+ return memo;
589
591
  }
590
592
  let SuspenseContext;
591
593
  function getSuspenseContext() {
@@ -700,7 +702,7 @@ function runComputation(node, value, time) {
700
702
  handleError(err);
701
703
  }
702
704
  if (!node.updatedAt || node.updatedAt <= time) {
703
- if (node.updatedAt && "observers" in node) {
705
+ if (node.updatedAt != null && "observers" in node) {
704
706
  writeSignal(node, nextValue, true);
705
707
  } else if (Transition && Transition.running && node.pure) {
706
708
  Transition.sources.add(node);
@@ -969,7 +971,7 @@ function resolveChildren(children) {
969
971
  function createProvider(id) {
970
972
  return function provider(props) {
971
973
  let res;
972
- createComputed(() => res = untrack(() => {
974
+ createRenderEffect(() => res = untrack(() => {
973
975
  Owner.context = {
974
976
  [id]: props.value
975
977
  };
@@ -1370,6 +1372,7 @@ function Index(props) {
1370
1372
  }
1371
1373
  function Show(props) {
1372
1374
  let strictEqual = false;
1375
+ const keyed = props.keyed;
1373
1376
  const condition = createMemo(() => props.when, undefined, {
1374
1377
  equals: (a, b) => strictEqual ? a === b : !a === !b
1375
1378
  });
@@ -1377,20 +1380,26 @@ function Show(props) {
1377
1380
  const c = condition();
1378
1381
  if (c) {
1379
1382
  const child = props.children;
1380
- return (strictEqual = typeof child === "function" && child.length > 0) ? untrack(() => child(c)) : child;
1383
+ const fn = typeof child === "function" && child.length > 0;
1384
+ strictEqual = keyed || fn;
1385
+ return fn ? untrack(() => child(c)) : child;
1381
1386
  }
1382
1387
  return props.fallback;
1383
1388
  });
1384
1389
  }
1385
1390
  function Switch(props) {
1386
1391
  let strictEqual = false;
1392
+ let keyed = false;
1387
1393
  const conditions = children(() => props.children),
1388
1394
  evalConditions = createMemo(() => {
1389
1395
  let conds = conditions();
1390
1396
  if (!Array.isArray(conds)) conds = [conds];
1391
1397
  for (let i = 0; i < conds.length; i++) {
1392
1398
  const c = conds[i].when;
1393
- if (c) return [i, c, conds[i]];
1399
+ if (c) {
1400
+ keyed = !!conds[i].keyed;
1401
+ return [i, c, conds[i]];
1402
+ }
1394
1403
  }
1395
1404
  return [-1];
1396
1405
  }, undefined, {
@@ -1400,7 +1409,9 @@ function Switch(props) {
1400
1409
  const [index, when, cond] = evalConditions();
1401
1410
  if (index < 0) return props.fallback;
1402
1411
  const c = cond.children;
1403
- return (strictEqual = typeof c === "function" && c.length > 0) ? untrack(() => c(when)) : c;
1412
+ const fn = typeof c === "function" && c.length > 0;
1413
+ strictEqual = keyed || fn;
1414
+ return fn ? untrack(() => c(when)) : c;
1404
1415
  });
1405
1416
  }
1406
1417
  function Match(props) {
@@ -1432,74 +1443,85 @@ function ErrorBoundary(props) {
1432
1443
  });
1433
1444
  }
1434
1445
 
1446
+ const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFallback === b.showFallback;
1435
1447
  const SuspenseListContext = createContext();
1436
1448
  function SuspenseList(props) {
1437
- let suspenseSetter, showContent, showFallback;
1449
+ let [wrapper, setWrapper] = createSignal(() => ({
1450
+ inFallback: false
1451
+ })),
1452
+ show;
1438
1453
  const listContext = useContext(SuspenseListContext);
1454
+ const [registry, setRegistry] = createSignal([]);
1439
1455
  if (listContext) {
1440
- const [inFallback, setFallback] = createSignal(false);
1441
- suspenseSetter = setFallback;
1442
- [showContent, showFallback] = listContext.register(inFallback);
1456
+ show = listContext.register(createMemo(() => wrapper()().inFallback));
1443
1457
  }
1444
- const [registry, setRegistry] = createSignal([]),
1445
- comp = createComponent(SuspenseListContext.Provider, {
1446
- value: {
1447
- register: inFallback => {
1448
- const [showingContent, showContent] = createSignal(false),
1449
- [showingFallback, showFallback] = createSignal(false);
1450
- setRegistry(registry => [...registry, {
1451
- inFallback,
1452
- showContent,
1453
- showFallback
1454
- }]);
1455
- return [showingContent, showingFallback];
1456
- }
1457
- },
1458
- get children() {
1459
- return props.children;
1460
- }
1461
- });
1462
- createComputed(() => {
1458
+ const resolved = createMemo(prev => {
1463
1459
  const reveal = props.revealOrder,
1464
1460
  tail = props.tail,
1465
- visibleContent = showContent ? showContent() : true,
1466
- visibleFallback = showFallback ? showFallback() : true,
1461
+ {
1462
+ showContent = true,
1463
+ showFallback = true
1464
+ } = show ? show() : {},
1467
1465
  reg = registry(),
1468
1466
  reverse = reveal === "backwards";
1469
1467
  if (reveal === "together") {
1470
- const all = reg.every(i => !i.inFallback());
1471
- suspenseSetter && suspenseSetter(!all);
1472
- reg.forEach(i => {
1473
- i.showContent(all && visibleContent);
1474
- i.showFallback(visibleFallback);
1475
- });
1476
- return;
1468
+ const all = reg.every(inFallback => !inFallback());
1469
+ const res = reg.map(() => ({
1470
+ showContent: all && showContent,
1471
+ showFallback
1472
+ }));
1473
+ res.inFallback = !all;
1474
+ return res;
1477
1475
  }
1478
1476
  let stop = false;
1477
+ let inFallback = prev.inFallback;
1478
+ const res = [];
1479
1479
  for (let i = 0, len = reg.length; i < len; i++) {
1480
1480
  const n = reverse ? len - i - 1 : i,
1481
- s = reg[n].inFallback();
1481
+ s = reg[n]();
1482
1482
  if (!stop && !s) {
1483
- reg[n].showContent(visibleContent);
1484
- reg[n].showFallback(visibleFallback);
1483
+ res[n] = {
1484
+ showContent,
1485
+ showFallback
1486
+ };
1485
1487
  } else {
1486
1488
  const next = !stop;
1487
- if (next && suspenseSetter) suspenseSetter(true);
1488
- if (!tail || next && tail === "collapsed") {
1489
- reg[n].showFallback(visibleFallback);
1490
- } else reg[n].showFallback(false);
1489
+ if (next) inFallback = true;
1490
+ res[n] = {
1491
+ showContent: next,
1492
+ showFallback: !tail || next && tail === "collapsed" ? showFallback : false
1493
+ };
1491
1494
  stop = true;
1492
- reg[n].showContent(next);
1493
1495
  }
1494
1496
  }
1495
- if (!stop && suspenseSetter) suspenseSetter(false);
1497
+ if (!stop) inFallback = false;
1498
+ res.inFallback = inFallback;
1499
+ return res;
1500
+ }, {
1501
+ inFallback: false
1502
+ });
1503
+ setWrapper(() => resolved);
1504
+ return createComponent(SuspenseListContext.Provider, {
1505
+ value: {
1506
+ register: inFallback => {
1507
+ let index;
1508
+ setRegistry(registry => {
1509
+ index = registry.length;
1510
+ return [...registry, inFallback];
1511
+ });
1512
+ return createMemo(() => resolved()[index], undefined, {
1513
+ equals: suspenseListEquals
1514
+ });
1515
+ }
1516
+ },
1517
+ get children() {
1518
+ return props.children;
1519
+ }
1496
1520
  });
1497
- return comp;
1498
1521
  }
1499
1522
  function Suspense(props) {
1500
1523
  let counter = 0,
1501
- showContent,
1502
- showFallback,
1524
+ show,
1503
1525
  ctx,
1504
1526
  p,
1505
1527
  flicker,
@@ -1540,7 +1562,7 @@ function Suspense(props) {
1540
1562
  }
1541
1563
  }
1542
1564
  const listContext = useContext(SuspenseListContext);
1543
- if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
1565
+ if (listContext) show = listContext.register(store.inFallback);
1544
1566
  let dispose;
1545
1567
  onCleanup(() => dispose && dispose());
1546
1568
  return createComponent(SuspenseContext.Provider, {
@@ -1555,18 +1577,21 @@ function Suspense(props) {
1555
1577
  }
1556
1578
  if (ctx && p === "$$f") setHydrateContext();
1557
1579
  const rendered = createMemo(() => props.children);
1558
- return createMemo(() => {
1580
+ return createMemo(prev => {
1559
1581
  const inFallback = store.inFallback(),
1560
- visibleContent = showContent ? showContent() : true,
1561
- visibleFallback = showFallback ? showFallback() : true;
1562
- dispose && dispose();
1563
- if ((!inFallback || p && p !== "$$f") && visibleContent) {
1582
+ {
1583
+ showContent = true,
1584
+ showFallback = true
1585
+ } = show ? show() : {};
1586
+ if ((!inFallback || p && p !== "$$f") && showContent) {
1564
1587
  store.resolved = true;
1565
- ctx = p = undefined;
1588
+ dispose && dispose();
1589
+ dispose = ctx = p = undefined;
1566
1590
  resumeEffects(store.effects);
1567
1591
  return rendered();
1568
1592
  }
1569
- if (!visibleFallback) return;
1593
+ if (!showFallback) return;
1594
+ if (dispose) return prev;
1570
1595
  return createRoot(disposer => {
1571
1596
  dispose = disposer;
1572
1597
  if (ctx) {
package/dist/dev.js CHANGED
@@ -165,7 +165,7 @@ function createRoot(fn, detachedOwner) {
165
165
  },
166
166
  updateFn = unowned ? () => fn(() => {
167
167
  throw new Error("Dispose method must be an explicit argument to createRoot function");
168
- }) : () => fn(() => cleanNode(root));
168
+ }) : () => fn(() => untrack(() => cleanNode(root)));
169
169
  {
170
170
  if (owner) root.name = `${owner.name}-r${rootCount++}`;
171
171
  globalThis._$afterCreateRoot && globalThis._$afterCreateRoot(root);
@@ -260,7 +260,7 @@ function createResource(pSource, pFetcher, pOptions) {
260
260
  resolved = ("initialValue" in options),
261
261
  dynamic = typeof source === "function" && createMemo(source);
262
262
  const contexts = new Set(),
263
- [value, setValue] = options.store ? options.store(options.initialValue) : createSignal(options.initialValue),
263
+ [value, setValue] = (options.storage || createSignal)(options.initialValue),
264
264
  [track, trigger] = createSignal(undefined, {
265
265
  equals: false
266
266
  }),
@@ -268,7 +268,7 @@ function createResource(pSource, pFetcher, pOptions) {
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.ssrValue === "initial") 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) {
@@ -297,7 +297,7 @@ function createResource(pSource, pFetcher, pOptions) {
297
297
  !success && (err = castError(v));
298
298
  runUpdates(() => {
299
299
  setValue(() => v);
300
- setState(success ? "ready" : "error");
300
+ setState(success ? "ready" : "errored");
301
301
  for (const c of contexts.keys()) c.decrement();
302
302
  contexts.clear();
303
303
  }, false);
@@ -349,9 +349,7 @@ function createResource(pSource, pFetcher, pOptions) {
349
349
  }
350
350
  Object.defineProperties(read, {
351
351
  state: {
352
- get() {
353
- return state();
354
- }
352
+ get: () => state()
355
353
  },
356
354
  loading: {
357
355
  get() {
@@ -361,13 +359,13 @@ function createResource(pSource, pFetcher, pOptions) {
361
359
  },
362
360
  error: {
363
361
  get() {
364
- return state() === "error" ? err : undefined;
362
+ return state() === "errored" ? err : undefined;
365
363
  }
366
364
  },
367
365
  latest: {
368
366
  get() {
369
367
  if (!resolved) return read();
370
- if (state() === "error") throw err;
368
+ if (state() === "errored") throw err;
371
369
  return value();
372
370
  }
373
371
  }
@@ -396,9 +394,8 @@ function createSelector(source, fn = equalFn, options) {
396
394
  const subs = new Map();
397
395
  const node = createComputation(p => {
398
396
  const v = source();
399
- for (const key of subs.keys()) if (fn(key, v) !== fn(key, p)) {
400
- const l = subs.get(key);
401
- for (const c of l.values()) {
397
+ for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
398
+ for (const c of val.values()) {
402
399
  c.state = STALE;
403
400
  if (c.pure) Updates.push(c);else Effects.push(c);
404
401
  }
@@ -407,8 +404,8 @@ function createSelector(source, fn = equalFn, options) {
407
404
  }, undefined, true, STALE, options );
408
405
  updateComputation(node);
409
406
  return key => {
410
- let listener;
411
- if (listener = Listener) {
407
+ const listener = Listener;
408
+ if (listener) {
412
409
  let l;
413
410
  if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
414
411
  onCleanup(() => {
@@ -581,7 +578,12 @@ function useContext(context) {
581
578
  }
582
579
  function children(fn) {
583
580
  const children = createMemo(fn);
584
- return createMemo(() => resolveChildren(children()));
581
+ const memo = createMemo(() => resolveChildren(children()));
582
+ memo.toArray = () => {
583
+ const c = memo();
584
+ return Array.isArray(c) ? c : c != null ? [c] : [];
585
+ };
586
+ return memo;
585
587
  }
586
588
  let SuspenseContext;
587
589
  function getSuspenseContext() {
@@ -696,7 +698,7 @@ function runComputation(node, value, time) {
696
698
  handleError(err);
697
699
  }
698
700
  if (!node.updatedAt || node.updatedAt <= time) {
699
- if (node.updatedAt && "observers" in node) {
701
+ if (node.updatedAt != null && "observers" in node) {
700
702
  writeSignal(node, nextValue, true);
701
703
  } else if (Transition && Transition.running && node.pure) {
702
704
  Transition.sources.add(node);
@@ -965,7 +967,7 @@ function resolveChildren(children) {
965
967
  function createProvider(id) {
966
968
  return function provider(props) {
967
969
  let res;
968
- createComputed(() => res = untrack(() => {
970
+ createRenderEffect(() => res = untrack(() => {
969
971
  Owner.context = {
970
972
  [id]: props.value
971
973
  };
@@ -1366,6 +1368,7 @@ function Index(props) {
1366
1368
  }
1367
1369
  function Show(props) {
1368
1370
  let strictEqual = false;
1371
+ const keyed = props.keyed;
1369
1372
  const condition = createMemo(() => props.when, undefined, {
1370
1373
  equals: (a, b) => strictEqual ? a === b : !a === !b
1371
1374
  });
@@ -1373,20 +1376,26 @@ function Show(props) {
1373
1376
  const c = condition();
1374
1377
  if (c) {
1375
1378
  const child = props.children;
1376
- return (strictEqual = typeof child === "function" && child.length > 0) ? untrack(() => child(c)) : child;
1379
+ const fn = typeof child === "function" && child.length > 0;
1380
+ strictEqual = keyed || fn;
1381
+ return fn ? untrack(() => child(c)) : child;
1377
1382
  }
1378
1383
  return props.fallback;
1379
1384
  });
1380
1385
  }
1381
1386
  function Switch(props) {
1382
1387
  let strictEqual = false;
1388
+ let keyed = false;
1383
1389
  const conditions = children(() => props.children),
1384
1390
  evalConditions = createMemo(() => {
1385
1391
  let conds = conditions();
1386
1392
  if (!Array.isArray(conds)) conds = [conds];
1387
1393
  for (let i = 0; i < conds.length; i++) {
1388
1394
  const c = conds[i].when;
1389
- if (c) return [i, c, conds[i]];
1395
+ if (c) {
1396
+ keyed = !!conds[i].keyed;
1397
+ return [i, c, conds[i]];
1398
+ }
1390
1399
  }
1391
1400
  return [-1];
1392
1401
  }, undefined, {
@@ -1396,7 +1405,9 @@ function Switch(props) {
1396
1405
  const [index, when, cond] = evalConditions();
1397
1406
  if (index < 0) return props.fallback;
1398
1407
  const c = cond.children;
1399
- return (strictEqual = typeof c === "function" && c.length > 0) ? untrack(() => c(when)) : c;
1408
+ const fn = typeof c === "function" && c.length > 0;
1409
+ strictEqual = keyed || fn;
1410
+ return fn ? untrack(() => c(when)) : c;
1400
1411
  });
1401
1412
  }
1402
1413
  function Match(props) {
@@ -1428,74 +1439,85 @@ function ErrorBoundary(props) {
1428
1439
  });
1429
1440
  }
1430
1441
 
1442
+ const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFallback === b.showFallback;
1431
1443
  const SuspenseListContext = createContext();
1432
1444
  function SuspenseList(props) {
1433
- let suspenseSetter, showContent, showFallback;
1445
+ let [wrapper, setWrapper] = createSignal(() => ({
1446
+ inFallback: false
1447
+ })),
1448
+ show;
1434
1449
  const listContext = useContext(SuspenseListContext);
1450
+ const [registry, setRegistry] = createSignal([]);
1435
1451
  if (listContext) {
1436
- const [inFallback, setFallback] = createSignal(false);
1437
- suspenseSetter = setFallback;
1438
- [showContent, showFallback] = listContext.register(inFallback);
1452
+ show = listContext.register(createMemo(() => wrapper()().inFallback));
1439
1453
  }
1440
- const [registry, setRegistry] = createSignal([]),
1441
- comp = createComponent(SuspenseListContext.Provider, {
1442
- value: {
1443
- register: inFallback => {
1444
- const [showingContent, showContent] = createSignal(false),
1445
- [showingFallback, showFallback] = createSignal(false);
1446
- setRegistry(registry => [...registry, {
1447
- inFallback,
1448
- showContent,
1449
- showFallback
1450
- }]);
1451
- return [showingContent, showingFallback];
1452
- }
1453
- },
1454
- get children() {
1455
- return props.children;
1456
- }
1457
- });
1458
- createComputed(() => {
1454
+ const resolved = createMemo(prev => {
1459
1455
  const reveal = props.revealOrder,
1460
1456
  tail = props.tail,
1461
- visibleContent = showContent ? showContent() : true,
1462
- visibleFallback = showFallback ? showFallback() : true,
1457
+ {
1458
+ showContent = true,
1459
+ showFallback = true
1460
+ } = show ? show() : {},
1463
1461
  reg = registry(),
1464
1462
  reverse = reveal === "backwards";
1465
1463
  if (reveal === "together") {
1466
- const all = reg.every(i => !i.inFallback());
1467
- suspenseSetter && suspenseSetter(!all);
1468
- reg.forEach(i => {
1469
- i.showContent(all && visibleContent);
1470
- i.showFallback(visibleFallback);
1471
- });
1472
- return;
1464
+ const all = reg.every(inFallback => !inFallback());
1465
+ const res = reg.map(() => ({
1466
+ showContent: all && showContent,
1467
+ showFallback
1468
+ }));
1469
+ res.inFallback = !all;
1470
+ return res;
1473
1471
  }
1474
1472
  let stop = false;
1473
+ let inFallback = prev.inFallback;
1474
+ const res = [];
1475
1475
  for (let i = 0, len = reg.length; i < len; i++) {
1476
1476
  const n = reverse ? len - i - 1 : i,
1477
- s = reg[n].inFallback();
1477
+ s = reg[n]();
1478
1478
  if (!stop && !s) {
1479
- reg[n].showContent(visibleContent);
1480
- reg[n].showFallback(visibleFallback);
1479
+ res[n] = {
1480
+ showContent,
1481
+ showFallback
1482
+ };
1481
1483
  } else {
1482
1484
  const next = !stop;
1483
- if (next && suspenseSetter) suspenseSetter(true);
1484
- if (!tail || next && tail === "collapsed") {
1485
- reg[n].showFallback(visibleFallback);
1486
- } else reg[n].showFallback(false);
1485
+ if (next) inFallback = true;
1486
+ res[n] = {
1487
+ showContent: next,
1488
+ showFallback: !tail || next && tail === "collapsed" ? showFallback : false
1489
+ };
1487
1490
  stop = true;
1488
- reg[n].showContent(next);
1489
1491
  }
1490
1492
  }
1491
- if (!stop && suspenseSetter) suspenseSetter(false);
1493
+ if (!stop) inFallback = false;
1494
+ res.inFallback = inFallback;
1495
+ return res;
1496
+ }, {
1497
+ inFallback: false
1498
+ });
1499
+ setWrapper(() => resolved);
1500
+ return createComponent(SuspenseListContext.Provider, {
1501
+ value: {
1502
+ register: inFallback => {
1503
+ let index;
1504
+ setRegistry(registry => {
1505
+ index = registry.length;
1506
+ return [...registry, inFallback];
1507
+ });
1508
+ return createMemo(() => resolved()[index], undefined, {
1509
+ equals: suspenseListEquals
1510
+ });
1511
+ }
1512
+ },
1513
+ get children() {
1514
+ return props.children;
1515
+ }
1492
1516
  });
1493
- return comp;
1494
1517
  }
1495
1518
  function Suspense(props) {
1496
1519
  let counter = 0,
1497
- showContent,
1498
- showFallback,
1520
+ show,
1499
1521
  ctx,
1500
1522
  p,
1501
1523
  flicker,
@@ -1536,7 +1558,7 @@ function Suspense(props) {
1536
1558
  }
1537
1559
  }
1538
1560
  const listContext = useContext(SuspenseListContext);
1539
- if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
1561
+ if (listContext) show = listContext.register(store.inFallback);
1540
1562
  let dispose;
1541
1563
  onCleanup(() => dispose && dispose());
1542
1564
  return createComponent(SuspenseContext.Provider, {
@@ -1551,18 +1573,21 @@ function Suspense(props) {
1551
1573
  }
1552
1574
  if (ctx && p === "$$f") setHydrateContext();
1553
1575
  const rendered = createMemo(() => props.children);
1554
- return createMemo(() => {
1576
+ return createMemo(prev => {
1555
1577
  const inFallback = store.inFallback(),
1556
- visibleContent = showContent ? showContent() : true,
1557
- visibleFallback = showFallback ? showFallback() : true;
1558
- dispose && dispose();
1559
- if ((!inFallback || p && p !== "$$f") && visibleContent) {
1578
+ {
1579
+ showContent = true,
1580
+ showFallback = true
1581
+ } = show ? show() : {};
1582
+ if ((!inFallback || p && p !== "$$f") && showContent) {
1560
1583
  store.resolved = true;
1561
- ctx = p = undefined;
1584
+ dispose && dispose();
1585
+ dispose = ctx = p = undefined;
1562
1586
  resumeEffects(store.effects);
1563
1587
  return rendered();
1564
1588
  }
1565
- if (!visibleFallback) return;
1589
+ if (!showFallback) return;
1590
+ if (dispose) return prev;
1566
1591
  return createRoot(disposer => {
1567
1592
  dispose = disposer;
1568
1593
  if (ctx) {