solid-js 1.9.4 → 1.9.6
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/LICENSE +1 -1
- package/dist/dev.cjs +57 -42
- package/dist/dev.js +65 -50
- package/dist/solid.cjs +38 -34
- package/dist/solid.js +49 -41
- package/h/jsx-runtime/types/jsx.d.ts +2975 -1021
- package/html/dist/html.cjs +5 -5
- package/html/dist/html.js +5 -5
- package/package.json +1 -1
- package/store/types/store.d.ts +1 -0
- package/types/index.d.ts +3 -0
- package/types/jsx.d.ts +2126 -281
- package/types/reactive/observable.d.ts +11 -11
- package/types/reactive/signal.d.ts +4 -0
- package/types/server/reactive.d.ts +6 -1
- package/universal/dist/dev.cjs +3 -1
- package/universal/dist/dev.js +4 -2
- package/universal/dist/universal.cjs +3 -1
- package/universal/dist/universal.js +4 -2
- package/web/dist/dev.cjs +21 -14
- package/web/dist/dev.js +25 -12
- package/web/dist/server.cjs +18 -11
- package/web/dist/server.js +22 -8
- package/web/dist/web.cjs +21 -14
- package/web/dist/web.js +23 -10
- package/web/types/core.d.ts +1 -1
- package/web/types/index.d.ts +16 -0
package/LICENSE
CHANGED
package/dist/dev.cjs
CHANGED
|
@@ -144,6 +144,7 @@ function nextHydrateContext() {
|
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
const IS_DEV = true;
|
|
147
148
|
const equalFn = (a, b) => a === b;
|
|
148
149
|
const $PROXY = Symbol("solid-proxy");
|
|
149
150
|
const SUPPORTS_PROXY = typeof Proxy === "function";
|
|
@@ -174,7 +175,8 @@ let ExecCount = 0;
|
|
|
174
175
|
const DevHooks = {
|
|
175
176
|
afterUpdate: null,
|
|
176
177
|
afterCreateOwner: null,
|
|
177
|
-
afterCreateSignal: null
|
|
178
|
+
afterCreateSignal: null,
|
|
179
|
+
afterRegisterGraph: null
|
|
178
180
|
};
|
|
179
181
|
function createRoot(fn, detachedOwner) {
|
|
180
182
|
const listener = Listener,
|
|
@@ -215,8 +217,12 @@ function createSignal(value, options) {
|
|
|
215
217
|
};
|
|
216
218
|
{
|
|
217
219
|
if (options.name) s.name = options.name;
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
+
if (options.internal) {
|
|
221
|
+
s.internal = true;
|
|
222
|
+
} else {
|
|
223
|
+
registerGraph(s);
|
|
224
|
+
if (DevHooks.afterCreateSignal) DevHooks.afterCreateSignal(s);
|
|
225
|
+
}
|
|
220
226
|
}
|
|
221
227
|
const setter = value => {
|
|
222
228
|
if (typeof value === "function") {
|
|
@@ -401,9 +407,10 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
401
407
|
}
|
|
402
408
|
}
|
|
403
409
|
});
|
|
404
|
-
|
|
410
|
+
let owner = Owner;
|
|
411
|
+
if (dynamic) createComputed(() => (owner = Owner, load(false)));else load(false);
|
|
405
412
|
return [read, {
|
|
406
|
-
refetch: load,
|
|
413
|
+
refetch: info => runWithOwner(owner, () => load(info)),
|
|
407
414
|
mutate: setValue
|
|
408
415
|
}];
|
|
409
416
|
}
|
|
@@ -578,9 +585,11 @@ function devComponent(Comp, props) {
|
|
|
578
585
|
return c.tValue !== undefined ? c.tValue : c.value;
|
|
579
586
|
}
|
|
580
587
|
function registerGraph(value) {
|
|
581
|
-
if (
|
|
582
|
-
|
|
583
|
-
|
|
588
|
+
if (Owner) {
|
|
589
|
+
if (Owner.sourceMap) Owner.sourceMap.push(value);else Owner.sourceMap = [value];
|
|
590
|
+
value.graph = Owner;
|
|
591
|
+
}
|
|
592
|
+
if (DevHooks.afterRegisterGraph) DevHooks.afterRegisterGraph(value);
|
|
584
593
|
}
|
|
585
594
|
function createContext(defaultValue, options) {
|
|
586
595
|
const id = Symbol("context");
|
|
@@ -691,7 +700,7 @@ function writeSignal(node, value, isComp) {
|
|
|
691
700
|
}
|
|
692
701
|
if (Updates.length > 10e5) {
|
|
693
702
|
Updates = [];
|
|
694
|
-
if (
|
|
703
|
+
if (IS_DEV) throw new Error("Potential Infinite Loop Detected.");
|
|
695
704
|
throw new Error();
|
|
696
705
|
}
|
|
697
706
|
}, false);
|
|
@@ -1097,8 +1106,8 @@ function observable(input) {
|
|
|
1097
1106
|
}
|
|
1098
1107
|
};
|
|
1099
1108
|
}
|
|
1100
|
-
function from(producer) {
|
|
1101
|
-
const [s, set] = createSignal(
|
|
1109
|
+
function from(producer, initalValue = undefined) {
|
|
1110
|
+
const [s, set] = createSignal(initalValue, {
|
|
1102
1111
|
equals: false
|
|
1103
1112
|
});
|
|
1104
1113
|
if ("subscribe" in producer) {
|
|
@@ -1462,7 +1471,7 @@ function lazy(fn) {
|
|
|
1462
1471
|
}
|
|
1463
1472
|
let Comp;
|
|
1464
1473
|
return createMemo(() => (Comp = comp()) ? untrack(() => {
|
|
1465
|
-
if (
|
|
1474
|
+
if (IS_DEV) Object.assign(Comp, {
|
|
1466
1475
|
[$DEVCOMP]: true
|
|
1467
1476
|
});
|
|
1468
1477
|
if (!ctx || sharedConfig.done) return Comp(props);
|
|
@@ -1501,8 +1510,11 @@ function Index(props) {
|
|
|
1501
1510
|
}
|
|
1502
1511
|
function Show(props) {
|
|
1503
1512
|
const keyed = props.keyed;
|
|
1504
|
-
const
|
|
1505
|
-
|
|
1513
|
+
const conditionValue = createMemo(() => props.when, undefined, {
|
|
1514
|
+
name: "condition value"
|
|
1515
|
+
} );
|
|
1516
|
+
const condition = keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
1517
|
+
equals: (a, b) => !a === !b,
|
|
1506
1518
|
name: "condition"
|
|
1507
1519
|
} );
|
|
1508
1520
|
return createMemo(() => {
|
|
@@ -1512,7 +1524,7 @@ function Show(props) {
|
|
|
1512
1524
|
const fn = typeof child === "function" && child.length > 0;
|
|
1513
1525
|
return fn ? untrack(() => child(keyed ? c : () => {
|
|
1514
1526
|
if (!untrack(condition)) throw narrowedError("Show");
|
|
1515
|
-
return
|
|
1527
|
+
return conditionValue();
|
|
1516
1528
|
})) : child;
|
|
1517
1529
|
}
|
|
1518
1530
|
return props.fallback;
|
|
@@ -1521,35 +1533,38 @@ function Show(props) {
|
|
|
1521
1533
|
} );
|
|
1522
1534
|
}
|
|
1523
1535
|
function Switch(props) {
|
|
1524
|
-
|
|
1525
|
-
const
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
}
|
|
1536
|
+
const chs = children(() => props.children);
|
|
1537
|
+
const switchFunc = createMemo(() => {
|
|
1538
|
+
const ch = chs();
|
|
1539
|
+
const mps = Array.isArray(ch) ? ch : [ch];
|
|
1540
|
+
let func = () => undefined;
|
|
1541
|
+
for (let i = 0; i < mps.length; i++) {
|
|
1542
|
+
const index = i;
|
|
1543
|
+
const mp = mps[i];
|
|
1544
|
+
const prevFunc = func;
|
|
1545
|
+
const conditionValue = createMemo(() => prevFunc() ? undefined : mp.when, undefined, {
|
|
1546
|
+
name: "condition value"
|
|
1547
|
+
} );
|
|
1548
|
+
const condition = mp.keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
1549
|
+
equals: (a, b) => !a === !b,
|
|
1550
|
+
name: "condition"
|
|
1551
|
+
} );
|
|
1552
|
+
func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
|
|
1553
|
+
}
|
|
1554
|
+
return func;
|
|
1555
|
+
});
|
|
1542
1556
|
return createMemo(() => {
|
|
1543
|
-
const
|
|
1544
|
-
if (
|
|
1545
|
-
const
|
|
1546
|
-
const
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1557
|
+
const sel = switchFunc()();
|
|
1558
|
+
if (!sel) return props.fallback;
|
|
1559
|
+
const [index, conditionValue, mp] = sel;
|
|
1560
|
+
const child = mp.children;
|
|
1561
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1562
|
+
return fn ? untrack(() => child(mp.keyed ? conditionValue() : () => {
|
|
1563
|
+
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
1564
|
+
return conditionValue();
|
|
1565
|
+
})) : child;
|
|
1551
1566
|
}, undefined, {
|
|
1552
|
-
name: "
|
|
1567
|
+
name: "eval conditions"
|
|
1553
1568
|
} );
|
|
1554
1569
|
}
|
|
1555
1570
|
function Match(props) {
|
package/dist/dev.js
CHANGED
|
@@ -144,6 +144,7 @@ function nextHydrateContext() {
|
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
const IS_DEV = true;
|
|
147
148
|
const equalFn = (a, b) => a === b;
|
|
148
149
|
const $PROXY = Symbol("solid-proxy");
|
|
149
150
|
const SUPPORTS_PROXY = typeof Proxy === "function";
|
|
@@ -174,7 +175,8 @@ let ExecCount = 0;
|
|
|
174
175
|
const DevHooks = {
|
|
175
176
|
afterUpdate: null,
|
|
176
177
|
afterCreateOwner: null,
|
|
177
|
-
afterCreateSignal: null
|
|
178
|
+
afterCreateSignal: null,
|
|
179
|
+
afterRegisterGraph: null
|
|
178
180
|
};
|
|
179
181
|
function createRoot(fn, detachedOwner) {
|
|
180
182
|
const listener = Listener,
|
|
@@ -220,8 +222,12 @@ function createSignal(value, options) {
|
|
|
220
222
|
};
|
|
221
223
|
{
|
|
222
224
|
if (options.name) s.name = options.name;
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
+
if (options.internal) {
|
|
226
|
+
s.internal = true;
|
|
227
|
+
} else {
|
|
228
|
+
registerGraph(s);
|
|
229
|
+
if (DevHooks.afterCreateSignal) DevHooks.afterCreateSignal(s);
|
|
230
|
+
}
|
|
225
231
|
}
|
|
226
232
|
const setter = value => {
|
|
227
233
|
if (typeof value === "function") {
|
|
@@ -429,12 +435,13 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
429
435
|
}
|
|
430
436
|
}
|
|
431
437
|
});
|
|
432
|
-
|
|
438
|
+
let owner = Owner;
|
|
439
|
+
if (dynamic) createComputed(() => ((owner = Owner), load(false)));
|
|
433
440
|
else load(false);
|
|
434
441
|
return [
|
|
435
442
|
read,
|
|
436
443
|
{
|
|
437
|
-
refetch: load,
|
|
444
|
+
refetch: info => runWithOwner(owner, () => load(info)),
|
|
438
445
|
mutate: setValue
|
|
439
446
|
}
|
|
440
447
|
];
|
|
@@ -648,10 +655,12 @@ function devComponent(Comp, props) {
|
|
|
648
655
|
return c.tValue !== undefined ? c.tValue : c.value;
|
|
649
656
|
}
|
|
650
657
|
function registerGraph(value) {
|
|
651
|
-
if (
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
658
|
+
if (Owner) {
|
|
659
|
+
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
660
|
+
else Owner.sourceMap = [value];
|
|
661
|
+
value.graph = Owner;
|
|
662
|
+
}
|
|
663
|
+
if (DevHooks.afterRegisterGraph) DevHooks.afterRegisterGraph(value);
|
|
655
664
|
}
|
|
656
665
|
function createContext(defaultValue, options) {
|
|
657
666
|
const id = Symbol("context");
|
|
@@ -765,7 +774,7 @@ function writeSignal(node, value, isComp) {
|
|
|
765
774
|
}
|
|
766
775
|
if (Updates.length > 10e5) {
|
|
767
776
|
Updates = [];
|
|
768
|
-
if (
|
|
777
|
+
if (IS_DEV) throw new Error("Potential Infinite Loop Detected.");
|
|
769
778
|
throw new Error();
|
|
770
779
|
}
|
|
771
780
|
}, false);
|
|
@@ -1198,8 +1207,8 @@ function observable(input) {
|
|
|
1198
1207
|
}
|
|
1199
1208
|
};
|
|
1200
1209
|
}
|
|
1201
|
-
function from(producer) {
|
|
1202
|
-
const [s, set] = createSignal(
|
|
1210
|
+
function from(producer, initalValue = undefined) {
|
|
1211
|
+
const [s, set] = createSignal(initalValue, {
|
|
1203
1212
|
equals: false
|
|
1204
1213
|
});
|
|
1205
1214
|
if ("subscribe" in producer) {
|
|
@@ -1595,7 +1604,7 @@ function lazy(fn) {
|
|
|
1595
1604
|
return createMemo(() =>
|
|
1596
1605
|
(Comp = comp())
|
|
1597
1606
|
? untrack(() => {
|
|
1598
|
-
if (
|
|
1607
|
+
if (IS_DEV)
|
|
1599
1608
|
Object.assign(Comp, {
|
|
1600
1609
|
[$DEVCOMP]: true
|
|
1601
1610
|
});
|
|
@@ -1646,10 +1655,15 @@ function Index(props) {
|
|
|
1646
1655
|
}
|
|
1647
1656
|
function Show(props) {
|
|
1648
1657
|
const keyed = props.keyed;
|
|
1649
|
-
const
|
|
1650
|
-
|
|
1651
|
-
name: "condition"
|
|
1658
|
+
const conditionValue = createMemo(() => props.when, undefined, {
|
|
1659
|
+
name: "condition value"
|
|
1652
1660
|
});
|
|
1661
|
+
const condition = keyed
|
|
1662
|
+
? conditionValue
|
|
1663
|
+
: createMemo(conditionValue, undefined, {
|
|
1664
|
+
equals: (a, b) => !a === !b,
|
|
1665
|
+
name: "condition"
|
|
1666
|
+
});
|
|
1653
1667
|
return createMemo(
|
|
1654
1668
|
() => {
|
|
1655
1669
|
const c = condition();
|
|
@@ -1663,7 +1677,7 @@ function Show(props) {
|
|
|
1663
1677
|
? c
|
|
1664
1678
|
: () => {
|
|
1665
1679
|
if (!untrack(condition)) throw narrowedError("Show");
|
|
1666
|
-
return
|
|
1680
|
+
return conditionValue();
|
|
1667
1681
|
}
|
|
1668
1682
|
)
|
|
1669
1683
|
)
|
|
@@ -1678,50 +1692,51 @@ function Show(props) {
|
|
|
1678
1692
|
);
|
|
1679
1693
|
}
|
|
1680
1694
|
function Switch(props) {
|
|
1681
|
-
|
|
1682
|
-
const
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1695
|
+
const chs = children(() => props.children);
|
|
1696
|
+
const switchFunc = createMemo(() => {
|
|
1697
|
+
const ch = chs();
|
|
1698
|
+
const mps = Array.isArray(ch) ? ch : [ch];
|
|
1699
|
+
let func = () => undefined;
|
|
1700
|
+
for (let i = 0; i < mps.length; i++) {
|
|
1701
|
+
const index = i;
|
|
1702
|
+
const mp = mps[i];
|
|
1703
|
+
const prevFunc = func;
|
|
1704
|
+
const conditionValue = createMemo(() => (prevFunc() ? undefined : mp.when), undefined, {
|
|
1705
|
+
name: "condition value"
|
|
1706
|
+
});
|
|
1707
|
+
const condition = mp.keyed
|
|
1708
|
+
? conditionValue
|
|
1709
|
+
: createMemo(conditionValue, undefined, {
|
|
1710
|
+
equals: (a, b) => !a === !b,
|
|
1711
|
+
name: "condition"
|
|
1712
|
+
});
|
|
1713
|
+
func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
|
|
1714
|
+
}
|
|
1715
|
+
return func;
|
|
1716
|
+
});
|
|
1703
1717
|
return createMemo(
|
|
1704
1718
|
() => {
|
|
1705
|
-
const
|
|
1706
|
-
if (
|
|
1707
|
-
const
|
|
1708
|
-
const
|
|
1719
|
+
const sel = switchFunc()();
|
|
1720
|
+
if (!sel) return props.fallback;
|
|
1721
|
+
const [index, conditionValue, mp] = sel;
|
|
1722
|
+
const child = mp.children;
|
|
1723
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1709
1724
|
return fn
|
|
1710
1725
|
? untrack(() =>
|
|
1711
|
-
|
|
1712
|
-
keyed
|
|
1713
|
-
?
|
|
1726
|
+
child(
|
|
1727
|
+
mp.keyed
|
|
1728
|
+
? conditionValue()
|
|
1714
1729
|
: () => {
|
|
1715
|
-
if (untrack(
|
|
1716
|
-
return
|
|
1730
|
+
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
1731
|
+
return conditionValue();
|
|
1717
1732
|
}
|
|
1718
1733
|
)
|
|
1719
1734
|
)
|
|
1720
|
-
:
|
|
1735
|
+
: child;
|
|
1721
1736
|
},
|
|
1722
1737
|
undefined,
|
|
1723
1738
|
{
|
|
1724
|
-
name: "
|
|
1739
|
+
name: "eval conditions"
|
|
1725
1740
|
}
|
|
1726
1741
|
);
|
|
1727
1742
|
}
|
package/dist/solid.cjs
CHANGED
|
@@ -144,6 +144,7 @@ function nextHydrateContext() {
|
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
const IS_DEV = false;
|
|
147
148
|
const equalFn = (a, b) => a === b;
|
|
148
149
|
const $PROXY = Symbol("solid-proxy");
|
|
149
150
|
const SUPPORTS_PROXY = typeof Proxy === "function";
|
|
@@ -383,9 +384,10 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
383
384
|
}
|
|
384
385
|
}
|
|
385
386
|
});
|
|
386
|
-
|
|
387
|
+
let owner = Owner;
|
|
388
|
+
if (dynamic) createComputed(() => (owner = Owner, load(false)));else load(false);
|
|
387
389
|
return [read, {
|
|
388
|
-
refetch: load,
|
|
390
|
+
refetch: info => runWithOwner(owner, () => load(info)),
|
|
389
391
|
mutate: setValue
|
|
390
392
|
}];
|
|
391
393
|
}
|
|
@@ -651,7 +653,7 @@ function writeSignal(node, value, isComp) {
|
|
|
651
653
|
}
|
|
652
654
|
if (Updates.length > 10e5) {
|
|
653
655
|
Updates = [];
|
|
654
|
-
if (
|
|
656
|
+
if (IS_DEV) ;
|
|
655
657
|
throw new Error();
|
|
656
658
|
}
|
|
657
659
|
}, false);
|
|
@@ -1054,8 +1056,8 @@ function observable(input) {
|
|
|
1054
1056
|
}
|
|
1055
1057
|
};
|
|
1056
1058
|
}
|
|
1057
|
-
function from(producer) {
|
|
1058
|
-
const [s, set] = createSignal(
|
|
1059
|
+
function from(producer, initalValue = undefined) {
|
|
1060
|
+
const [s, set] = createSignal(initalValue, {
|
|
1059
1061
|
equals: false
|
|
1060
1062
|
});
|
|
1061
1063
|
if ("subscribe" in producer) {
|
|
@@ -1415,7 +1417,7 @@ function lazy(fn) {
|
|
|
1415
1417
|
}
|
|
1416
1418
|
let Comp;
|
|
1417
1419
|
return createMemo(() => (Comp = comp()) ? untrack(() => {
|
|
1418
|
-
if (
|
|
1420
|
+
if (IS_DEV) ;
|
|
1419
1421
|
if (!ctx || sharedConfig.done) return Comp(props);
|
|
1420
1422
|
const c = sharedConfig.context;
|
|
1421
1423
|
setHydrateContext(ctx);
|
|
@@ -1448,8 +1450,9 @@ function Index(props) {
|
|
|
1448
1450
|
}
|
|
1449
1451
|
function Show(props) {
|
|
1450
1452
|
const keyed = props.keyed;
|
|
1451
|
-
const
|
|
1452
|
-
|
|
1453
|
+
const conditionValue = createMemo(() => props.when, undefined, undefined);
|
|
1454
|
+
const condition = keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
1455
|
+
equals: (a, b) => !a === !b
|
|
1453
1456
|
});
|
|
1454
1457
|
return createMemo(() => {
|
|
1455
1458
|
const c = condition();
|
|
@@ -1458,39 +1461,40 @@ function Show(props) {
|
|
|
1458
1461
|
const fn = typeof child === "function" && child.length > 0;
|
|
1459
1462
|
return fn ? untrack(() => child(keyed ? c : () => {
|
|
1460
1463
|
if (!untrack(condition)) throw narrowedError("Show");
|
|
1461
|
-
return
|
|
1464
|
+
return conditionValue();
|
|
1462
1465
|
})) : child;
|
|
1463
1466
|
}
|
|
1464
1467
|
return props.fallback;
|
|
1465
1468
|
}, undefined, undefined);
|
|
1466
1469
|
}
|
|
1467
1470
|
function Switch(props) {
|
|
1468
|
-
|
|
1469
|
-
const
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
|
|
1471
|
+
const chs = children(() => props.children);
|
|
1472
|
+
const switchFunc = createMemo(() => {
|
|
1473
|
+
const ch = chs();
|
|
1474
|
+
const mps = Array.isArray(ch) ? ch : [ch];
|
|
1475
|
+
let func = () => undefined;
|
|
1476
|
+
for (let i = 0; i < mps.length; i++) {
|
|
1477
|
+
const index = i;
|
|
1478
|
+
const mp = mps[i];
|
|
1479
|
+
const prevFunc = func;
|
|
1480
|
+
const conditionValue = createMemo(() => prevFunc() ? undefined : mp.when, undefined, undefined);
|
|
1481
|
+
const condition = mp.keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
1482
|
+
equals: (a, b) => !a === !b
|
|
1483
|
+
});
|
|
1484
|
+
func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
|
|
1485
|
+
}
|
|
1486
|
+
return func;
|
|
1487
|
+
});
|
|
1485
1488
|
return createMemo(() => {
|
|
1486
|
-
const
|
|
1487
|
-
if (
|
|
1488
|
-
const
|
|
1489
|
-
const
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1489
|
+
const sel = switchFunc()();
|
|
1490
|
+
if (!sel) return props.fallback;
|
|
1491
|
+
const [index, conditionValue, mp] = sel;
|
|
1492
|
+
const child = mp.children;
|
|
1493
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1494
|
+
return fn ? untrack(() => child(mp.keyed ? conditionValue() : () => {
|
|
1495
|
+
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
1496
|
+
return conditionValue();
|
|
1497
|
+
})) : child;
|
|
1494
1498
|
}, undefined, undefined);
|
|
1495
1499
|
}
|
|
1496
1500
|
function Match(props) {
|