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/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] =
|
|
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" : "
|
|
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() === "
|
|
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() === "
|
|
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.
|
|
404
|
-
const
|
|
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
|
-
|
|
415
|
-
if (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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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)
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
1441
|
-
suspenseSetter = setFallback;
|
|
1442
|
-
[showContent, showFallback] = listContext.register(inFallback);
|
|
1456
|
+
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1443
1457
|
}
|
|
1444
|
-
const
|
|
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
|
-
|
|
1466
|
-
|
|
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(
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
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]
|
|
1481
|
+
s = reg[n]();
|
|
1482
1482
|
if (!stop && !s) {
|
|
1483
|
-
|
|
1484
|
-
|
|
1483
|
+
res[n] = {
|
|
1484
|
+
showContent,
|
|
1485
|
+
showFallback
|
|
1486
|
+
};
|
|
1485
1487
|
} else {
|
|
1486
1488
|
const next = !stop;
|
|
1487
|
-
if (next
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
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
|
|
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
|
-
|
|
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)
|
|
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
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1582
|
+
{
|
|
1583
|
+
showContent = true,
|
|
1584
|
+
showFallback = true
|
|
1585
|
+
} = show ? show() : {};
|
|
1586
|
+
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1564
1587
|
store.resolved = true;
|
|
1565
|
-
|
|
1588
|
+
dispose && dispose();
|
|
1589
|
+
dispose = ctx = p = undefined;
|
|
1566
1590
|
resumeEffects(store.effects);
|
|
1567
1591
|
return rendered();
|
|
1568
1592
|
}
|
|
1569
|
-
if (!
|
|
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] =
|
|
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" : "
|
|
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() === "
|
|
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() === "
|
|
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.
|
|
400
|
-
const
|
|
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
|
-
|
|
411
|
-
if (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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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)
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
1437
|
-
suspenseSetter = setFallback;
|
|
1438
|
-
[showContent, showFallback] = listContext.register(inFallback);
|
|
1452
|
+
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1439
1453
|
}
|
|
1440
|
-
const
|
|
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
|
-
|
|
1462
|
-
|
|
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(
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
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]
|
|
1477
|
+
s = reg[n]();
|
|
1478
1478
|
if (!stop && !s) {
|
|
1479
|
-
|
|
1480
|
-
|
|
1479
|
+
res[n] = {
|
|
1480
|
+
showContent,
|
|
1481
|
+
showFallback
|
|
1482
|
+
};
|
|
1481
1483
|
} else {
|
|
1482
1484
|
const next = !stop;
|
|
1483
|
-
if (next
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
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
|
|
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
|
-
|
|
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)
|
|
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
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1578
|
+
{
|
|
1579
|
+
showContent = true,
|
|
1580
|
+
showFallback = true
|
|
1581
|
+
} = show ? show() : {};
|
|
1582
|
+
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1560
1583
|
store.resolved = true;
|
|
1561
|
-
|
|
1584
|
+
dispose && dispose();
|
|
1585
|
+
dispose = ctx = p = undefined;
|
|
1562
1586
|
resumeEffects(store.effects);
|
|
1563
1587
|
return rendered();
|
|
1564
1588
|
}
|
|
1565
|
-
if (!
|
|
1589
|
+
if (!showFallback) return;
|
|
1590
|
+
if (dispose) return prev;
|
|
1566
1591
|
return createRoot(disposer => {
|
|
1567
1592
|
dispose = disposer;
|
|
1568
1593
|
if (ctx) {
|