solid-js 1.9.3 → 1.9.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/LICENSE +1 -1
- package/dist/dev.cjs +59 -45
- package/dist/dev.js +67 -53
- package/dist/server.cjs +50 -10
- package/dist/server.js +53 -10
- package/dist/solid.cjs +40 -37
- package/dist/solid.js +51 -44
- package/h/jsx-runtime/types/jsx.d.ts +30 -2
- package/html/dist/html.cjs +3 -3
- package/html/dist/html.js +3 -3
- package/package.json +1 -1
- package/store/dist/dev.cjs +1 -1
- package/store/dist/dev.js +1 -1
- package/store/dist/store.cjs +1 -1
- package/store/dist/store.js +1 -1
- package/store/types/store.d.ts +1 -0
- package/types/index.d.ts +3 -0
- package/types/jsx.d.ts +34 -2
- 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/web/dist/dev.cjs +13 -9
- package/web/dist/dev.js +16 -10
- package/web/dist/server.cjs +15 -9
- package/web/dist/server.js +21 -12
- package/web/dist/web.cjs +13 -9
- package/web/dist/web.js +14 -8
- package/web/types/index.d.ts +16 -0
- package/web/storage/types/index.js +0 -13
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") {
|
|
@@ -275,14 +281,14 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
275
281
|
let source;
|
|
276
282
|
let fetcher;
|
|
277
283
|
let options;
|
|
278
|
-
if (
|
|
279
|
-
source = true;
|
|
280
|
-
fetcher = pSource;
|
|
281
|
-
options = pFetcher || {};
|
|
282
|
-
} else {
|
|
284
|
+
if (typeof pFetcher === "function") {
|
|
283
285
|
source = pSource;
|
|
284
286
|
fetcher = pFetcher;
|
|
285
287
|
options = pOptions || {};
|
|
288
|
+
} else {
|
|
289
|
+
source = true;
|
|
290
|
+
fetcher = pSource;
|
|
291
|
+
options = pFetcher || {};
|
|
286
292
|
}
|
|
287
293
|
let pr = null,
|
|
288
294
|
initP = NO_INIT,
|
|
@@ -578,9 +584,11 @@ function devComponent(Comp, props) {
|
|
|
578
584
|
return c.tValue !== undefined ? c.tValue : c.value;
|
|
579
585
|
}
|
|
580
586
|
function registerGraph(value) {
|
|
581
|
-
if (
|
|
582
|
-
|
|
583
|
-
|
|
587
|
+
if (Owner) {
|
|
588
|
+
if (Owner.sourceMap) Owner.sourceMap.push(value);else Owner.sourceMap = [value];
|
|
589
|
+
value.graph = Owner;
|
|
590
|
+
}
|
|
591
|
+
if (DevHooks.afterRegisterGraph) DevHooks.afterRegisterGraph(value);
|
|
584
592
|
}
|
|
585
593
|
function createContext(defaultValue, options) {
|
|
586
594
|
const id = Symbol("context");
|
|
@@ -691,7 +699,7 @@ function writeSignal(node, value, isComp) {
|
|
|
691
699
|
}
|
|
692
700
|
if (Updates.length > 10e5) {
|
|
693
701
|
Updates = [];
|
|
694
|
-
if (
|
|
702
|
+
if (IS_DEV) throw new Error("Potential Infinite Loop Detected.");
|
|
695
703
|
throw new Error();
|
|
696
704
|
}
|
|
697
705
|
}, false);
|
|
@@ -1097,8 +1105,8 @@ function observable(input) {
|
|
|
1097
1105
|
}
|
|
1098
1106
|
};
|
|
1099
1107
|
}
|
|
1100
|
-
function from(producer) {
|
|
1101
|
-
const [s, set] = createSignal(
|
|
1108
|
+
function from(producer, initalValue = undefined) {
|
|
1109
|
+
const [s, set] = createSignal(initalValue, {
|
|
1102
1110
|
equals: false
|
|
1103
1111
|
});
|
|
1104
1112
|
if ("subscribe" in producer) {
|
|
@@ -1462,7 +1470,7 @@ function lazy(fn) {
|
|
|
1462
1470
|
}
|
|
1463
1471
|
let Comp;
|
|
1464
1472
|
return createMemo(() => (Comp = comp()) ? untrack(() => {
|
|
1465
|
-
if (
|
|
1473
|
+
if (IS_DEV) Object.assign(Comp, {
|
|
1466
1474
|
[$DEVCOMP]: true
|
|
1467
1475
|
});
|
|
1468
1476
|
if (!ctx || sharedConfig.done) return Comp(props);
|
|
@@ -1501,8 +1509,11 @@ function Index(props) {
|
|
|
1501
1509
|
}
|
|
1502
1510
|
function Show(props) {
|
|
1503
1511
|
const keyed = props.keyed;
|
|
1504
|
-
const
|
|
1505
|
-
|
|
1512
|
+
const conditionValue = createMemo(() => props.when, undefined, {
|
|
1513
|
+
name: "condition value"
|
|
1514
|
+
} );
|
|
1515
|
+
const condition = keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
1516
|
+
equals: (a, b) => !a === !b,
|
|
1506
1517
|
name: "condition"
|
|
1507
1518
|
} );
|
|
1508
1519
|
return createMemo(() => {
|
|
@@ -1512,7 +1523,7 @@ function Show(props) {
|
|
|
1512
1523
|
const fn = typeof child === "function" && child.length > 0;
|
|
1513
1524
|
return fn ? untrack(() => child(keyed ? c : () => {
|
|
1514
1525
|
if (!untrack(condition)) throw narrowedError("Show");
|
|
1515
|
-
return
|
|
1526
|
+
return conditionValue();
|
|
1516
1527
|
})) : child;
|
|
1517
1528
|
}
|
|
1518
1529
|
return props.fallback;
|
|
@@ -1521,35 +1532,38 @@ function Show(props) {
|
|
|
1521
1532
|
} );
|
|
1522
1533
|
}
|
|
1523
1534
|
function Switch(props) {
|
|
1524
|
-
|
|
1525
|
-
const
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
}
|
|
1535
|
+
const chs = children(() => props.children);
|
|
1536
|
+
const switchFunc = createMemo(() => {
|
|
1537
|
+
const ch = chs();
|
|
1538
|
+
const mps = Array.isArray(ch) ? ch : [ch];
|
|
1539
|
+
let func = () => undefined;
|
|
1540
|
+
for (let i = 0; i < mps.length; i++) {
|
|
1541
|
+
const index = i;
|
|
1542
|
+
const mp = mps[i];
|
|
1543
|
+
const prevFunc = func;
|
|
1544
|
+
const conditionValue = createMemo(() => prevFunc() ? undefined : mp.when, undefined, {
|
|
1545
|
+
name: "condition value"
|
|
1546
|
+
} );
|
|
1547
|
+
const condition = mp.keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
1548
|
+
equals: (a, b) => !a === !b,
|
|
1549
|
+
name: "condition"
|
|
1550
|
+
} );
|
|
1551
|
+
func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
|
|
1552
|
+
}
|
|
1553
|
+
return func;
|
|
1554
|
+
});
|
|
1542
1555
|
return createMemo(() => {
|
|
1543
|
-
const
|
|
1544
|
-
if (
|
|
1545
|
-
const
|
|
1546
|
-
const
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1556
|
+
const sel = switchFunc()();
|
|
1557
|
+
if (!sel) return props.fallback;
|
|
1558
|
+
const [index, conditionValue, mp] = sel;
|
|
1559
|
+
const child = mp.children;
|
|
1560
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1561
|
+
return fn ? untrack(() => child(mp.keyed ? conditionValue() : () => {
|
|
1562
|
+
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
1563
|
+
return conditionValue();
|
|
1564
|
+
})) : child;
|
|
1551
1565
|
}, undefined, {
|
|
1552
|
-
name: "
|
|
1566
|
+
name: "eval conditions"
|
|
1553
1567
|
} );
|
|
1554
1568
|
}
|
|
1555
1569
|
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") {
|
|
@@ -289,14 +295,14 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
289
295
|
let source;
|
|
290
296
|
let fetcher;
|
|
291
297
|
let options;
|
|
292
|
-
if (
|
|
293
|
-
source = true;
|
|
294
|
-
fetcher = pSource;
|
|
295
|
-
options = pFetcher || {};
|
|
296
|
-
} else {
|
|
298
|
+
if (typeof pFetcher === "function") {
|
|
297
299
|
source = pSource;
|
|
298
300
|
fetcher = pFetcher;
|
|
299
301
|
options = pOptions || {};
|
|
302
|
+
} else {
|
|
303
|
+
source = true;
|
|
304
|
+
fetcher = pSource;
|
|
305
|
+
options = pFetcher || {};
|
|
300
306
|
}
|
|
301
307
|
let pr = null,
|
|
302
308
|
initP = NO_INIT,
|
|
@@ -648,10 +654,12 @@ function devComponent(Comp, props) {
|
|
|
648
654
|
return c.tValue !== undefined ? c.tValue : c.value;
|
|
649
655
|
}
|
|
650
656
|
function registerGraph(value) {
|
|
651
|
-
if (
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
657
|
+
if (Owner) {
|
|
658
|
+
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
659
|
+
else Owner.sourceMap = [value];
|
|
660
|
+
value.graph = Owner;
|
|
661
|
+
}
|
|
662
|
+
if (DevHooks.afterRegisterGraph) DevHooks.afterRegisterGraph(value);
|
|
655
663
|
}
|
|
656
664
|
function createContext(defaultValue, options) {
|
|
657
665
|
const id = Symbol("context");
|
|
@@ -765,7 +773,7 @@ function writeSignal(node, value, isComp) {
|
|
|
765
773
|
}
|
|
766
774
|
if (Updates.length > 10e5) {
|
|
767
775
|
Updates = [];
|
|
768
|
-
if (
|
|
776
|
+
if (IS_DEV) throw new Error("Potential Infinite Loop Detected.");
|
|
769
777
|
throw new Error();
|
|
770
778
|
}
|
|
771
779
|
}, false);
|
|
@@ -1198,8 +1206,8 @@ function observable(input) {
|
|
|
1198
1206
|
}
|
|
1199
1207
|
};
|
|
1200
1208
|
}
|
|
1201
|
-
function from(producer) {
|
|
1202
|
-
const [s, set] = createSignal(
|
|
1209
|
+
function from(producer, initalValue = undefined) {
|
|
1210
|
+
const [s, set] = createSignal(initalValue, {
|
|
1203
1211
|
equals: false
|
|
1204
1212
|
});
|
|
1205
1213
|
if ("subscribe" in producer) {
|
|
@@ -1595,7 +1603,7 @@ function lazy(fn) {
|
|
|
1595
1603
|
return createMemo(() =>
|
|
1596
1604
|
(Comp = comp())
|
|
1597
1605
|
? untrack(() => {
|
|
1598
|
-
if (
|
|
1606
|
+
if (IS_DEV)
|
|
1599
1607
|
Object.assign(Comp, {
|
|
1600
1608
|
[$DEVCOMP]: true
|
|
1601
1609
|
});
|
|
@@ -1646,10 +1654,15 @@ function Index(props) {
|
|
|
1646
1654
|
}
|
|
1647
1655
|
function Show(props) {
|
|
1648
1656
|
const keyed = props.keyed;
|
|
1649
|
-
const
|
|
1650
|
-
|
|
1651
|
-
name: "condition"
|
|
1657
|
+
const conditionValue = createMemo(() => props.when, undefined, {
|
|
1658
|
+
name: "condition value"
|
|
1652
1659
|
});
|
|
1660
|
+
const condition = keyed
|
|
1661
|
+
? conditionValue
|
|
1662
|
+
: createMemo(conditionValue, undefined, {
|
|
1663
|
+
equals: (a, b) => !a === !b,
|
|
1664
|
+
name: "condition"
|
|
1665
|
+
});
|
|
1653
1666
|
return createMemo(
|
|
1654
1667
|
() => {
|
|
1655
1668
|
const c = condition();
|
|
@@ -1663,7 +1676,7 @@ function Show(props) {
|
|
|
1663
1676
|
? c
|
|
1664
1677
|
: () => {
|
|
1665
1678
|
if (!untrack(condition)) throw narrowedError("Show");
|
|
1666
|
-
return
|
|
1679
|
+
return conditionValue();
|
|
1667
1680
|
}
|
|
1668
1681
|
)
|
|
1669
1682
|
)
|
|
@@ -1678,50 +1691,51 @@ function Show(props) {
|
|
|
1678
1691
|
);
|
|
1679
1692
|
}
|
|
1680
1693
|
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
|
-
|
|
1694
|
+
const chs = children(() => props.children);
|
|
1695
|
+
const switchFunc = createMemo(() => {
|
|
1696
|
+
const ch = chs();
|
|
1697
|
+
const mps = Array.isArray(ch) ? ch : [ch];
|
|
1698
|
+
let func = () => undefined;
|
|
1699
|
+
for (let i = 0; i < mps.length; i++) {
|
|
1700
|
+
const index = i;
|
|
1701
|
+
const mp = mps[i];
|
|
1702
|
+
const prevFunc = func;
|
|
1703
|
+
const conditionValue = createMemo(() => (prevFunc() ? undefined : mp.when), undefined, {
|
|
1704
|
+
name: "condition value"
|
|
1705
|
+
});
|
|
1706
|
+
const condition = mp.keyed
|
|
1707
|
+
? conditionValue
|
|
1708
|
+
: createMemo(conditionValue, undefined, {
|
|
1709
|
+
equals: (a, b) => !a === !b,
|
|
1710
|
+
name: "condition"
|
|
1711
|
+
});
|
|
1712
|
+
func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
|
|
1713
|
+
}
|
|
1714
|
+
return func;
|
|
1715
|
+
});
|
|
1703
1716
|
return createMemo(
|
|
1704
1717
|
() => {
|
|
1705
|
-
const
|
|
1706
|
-
if (
|
|
1707
|
-
const
|
|
1708
|
-
const
|
|
1718
|
+
const sel = switchFunc()();
|
|
1719
|
+
if (!sel) return props.fallback;
|
|
1720
|
+
const [index, conditionValue, mp] = sel;
|
|
1721
|
+
const child = mp.children;
|
|
1722
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1709
1723
|
return fn
|
|
1710
1724
|
? untrack(() =>
|
|
1711
|
-
|
|
1712
|
-
keyed
|
|
1713
|
-
?
|
|
1725
|
+
child(
|
|
1726
|
+
mp.keyed
|
|
1727
|
+
? conditionValue()
|
|
1714
1728
|
: () => {
|
|
1715
|
-
if (untrack(
|
|
1716
|
-
return
|
|
1729
|
+
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
1730
|
+
return conditionValue();
|
|
1717
1731
|
}
|
|
1718
1732
|
)
|
|
1719
1733
|
)
|
|
1720
|
-
:
|
|
1734
|
+
: child;
|
|
1721
1735
|
},
|
|
1722
1736
|
undefined,
|
|
1723
1737
|
{
|
|
1724
|
-
name: "
|
|
1738
|
+
name: "eval conditions"
|
|
1725
1739
|
}
|
|
1726
1740
|
);
|
|
1727
1741
|
}
|
package/dist/server.cjs
CHANGED
|
@@ -302,6 +302,51 @@ function mutateContext(o, key, value) {
|
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
+
function escape(s, attr) {
|
|
306
|
+
const t = typeof s;
|
|
307
|
+
if (t !== "string") {
|
|
308
|
+
if (t === "function") return escape(s());
|
|
309
|
+
if (Array.isArray(s)) {
|
|
310
|
+
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
311
|
+
return s;
|
|
312
|
+
}
|
|
313
|
+
return s;
|
|
314
|
+
}
|
|
315
|
+
const delim = "<";
|
|
316
|
+
const escDelim = "<";
|
|
317
|
+
let iDelim = s.indexOf(delim);
|
|
318
|
+
let iAmp = s.indexOf("&");
|
|
319
|
+
if (iDelim < 0 && iAmp < 0) return s;
|
|
320
|
+
let left = 0,
|
|
321
|
+
out = "";
|
|
322
|
+
while (iDelim >= 0 && iAmp >= 0) {
|
|
323
|
+
if (iDelim < iAmp) {
|
|
324
|
+
if (left < iDelim) out += s.substring(left, iDelim);
|
|
325
|
+
out += escDelim;
|
|
326
|
+
left = iDelim + 1;
|
|
327
|
+
iDelim = s.indexOf(delim, left);
|
|
328
|
+
} else {
|
|
329
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
330
|
+
out += "&";
|
|
331
|
+
left = iAmp + 1;
|
|
332
|
+
iAmp = s.indexOf("&", left);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (iDelim >= 0) {
|
|
336
|
+
do {
|
|
337
|
+
if (left < iDelim) out += s.substring(left, iDelim);
|
|
338
|
+
out += escDelim;
|
|
339
|
+
left = iDelim + 1;
|
|
340
|
+
iDelim = s.indexOf(delim, left);
|
|
341
|
+
} while (iDelim >= 0);
|
|
342
|
+
} else while (iAmp >= 0) {
|
|
343
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
344
|
+
out += "&";
|
|
345
|
+
left = iAmp + 1;
|
|
346
|
+
iAmp = s.indexOf("&", left);
|
|
347
|
+
}
|
|
348
|
+
return left < s.length ? out + s.substring(left) : out;
|
|
349
|
+
}
|
|
305
350
|
function resolveSSRNode(node) {
|
|
306
351
|
const t = typeof node;
|
|
307
352
|
if (t === "string") return node;
|
|
@@ -464,19 +509,14 @@ function ErrorBoundary(props) {
|
|
|
464
509
|
if (error) return displayFallback();
|
|
465
510
|
sync = false;
|
|
466
511
|
return {
|
|
467
|
-
t: `<!--!$e${id}-->${resolveSSRNode(res)}<!--!$/e${id}-->`
|
|
512
|
+
t: `<!--!$e${id}-->${resolveSSRNode(escape(res))}<!--!$/e${id}-->`
|
|
468
513
|
};
|
|
469
514
|
}
|
|
470
515
|
const SuspenseContext = createContext();
|
|
471
516
|
let resourceContext = null;
|
|
472
517
|
function createResource(source, fetcher, options = {}) {
|
|
473
|
-
if (
|
|
474
|
-
|
|
475
|
-
options = fetcher;
|
|
476
|
-
fetcher = source;
|
|
477
|
-
source = true;
|
|
478
|
-
}
|
|
479
|
-
} else if (arguments.length === 1) {
|
|
518
|
+
if (typeof fetcher !== "function") {
|
|
519
|
+
options = fetcher || {};
|
|
480
520
|
fetcher = source;
|
|
481
521
|
source = true;
|
|
482
522
|
}
|
|
@@ -641,7 +681,7 @@ function Suspense(props) {
|
|
|
641
681
|
completed: () => {
|
|
642
682
|
const res = runSuspense();
|
|
643
683
|
if (suspenseComplete(value)) {
|
|
644
|
-
done(resolveSSRNode(res));
|
|
684
|
+
done(resolveSSRNode(escape(res)));
|
|
645
685
|
}
|
|
646
686
|
}
|
|
647
687
|
});
|
|
@@ -680,7 +720,7 @@ function Suspense(props) {
|
|
|
680
720
|
noHydrate: true
|
|
681
721
|
});
|
|
682
722
|
const res = {
|
|
683
|
-
t: `<template id="pl-${id}"></template>${resolveSSRNode(props.fallback)}<!--pl-${id}-->`
|
|
723
|
+
t: `<template id="pl-${id}"></template>${resolveSSRNode(escape(props.fallback))}<!--pl-${id}-->`
|
|
684
724
|
};
|
|
685
725
|
setHydrateContext(ctx);
|
|
686
726
|
return res;
|
package/dist/server.js
CHANGED
|
@@ -311,6 +311,52 @@ function mutateContext(o, key, value) {
|
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
+
function escape(s, attr) {
|
|
315
|
+
const t = typeof s;
|
|
316
|
+
if (t !== "string") {
|
|
317
|
+
if (t === "function") return escape(s());
|
|
318
|
+
if (Array.isArray(s)) {
|
|
319
|
+
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
320
|
+
return s;
|
|
321
|
+
}
|
|
322
|
+
return s;
|
|
323
|
+
}
|
|
324
|
+
const delim = "<";
|
|
325
|
+
const escDelim = "<";
|
|
326
|
+
let iDelim = s.indexOf(delim);
|
|
327
|
+
let iAmp = s.indexOf("&");
|
|
328
|
+
if (iDelim < 0 && iAmp < 0) return s;
|
|
329
|
+
let left = 0,
|
|
330
|
+
out = "";
|
|
331
|
+
while (iDelim >= 0 && iAmp >= 0) {
|
|
332
|
+
if (iDelim < iAmp) {
|
|
333
|
+
if (left < iDelim) out += s.substring(left, iDelim);
|
|
334
|
+
out += escDelim;
|
|
335
|
+
left = iDelim + 1;
|
|
336
|
+
iDelim = s.indexOf(delim, left);
|
|
337
|
+
} else {
|
|
338
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
339
|
+
out += "&";
|
|
340
|
+
left = iAmp + 1;
|
|
341
|
+
iAmp = s.indexOf("&", left);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (iDelim >= 0) {
|
|
345
|
+
do {
|
|
346
|
+
if (left < iDelim) out += s.substring(left, iDelim);
|
|
347
|
+
out += escDelim;
|
|
348
|
+
left = iDelim + 1;
|
|
349
|
+
iDelim = s.indexOf(delim, left);
|
|
350
|
+
} while (iDelim >= 0);
|
|
351
|
+
} else
|
|
352
|
+
while (iAmp >= 0) {
|
|
353
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
354
|
+
out += "&";
|
|
355
|
+
left = iAmp + 1;
|
|
356
|
+
iAmp = s.indexOf("&", left);
|
|
357
|
+
}
|
|
358
|
+
return left < s.length ? out + s.substring(left) : out;
|
|
359
|
+
}
|
|
314
360
|
function resolveSSRNode(node) {
|
|
315
361
|
const t = typeof node;
|
|
316
362
|
if (t === "string") return node;
|
|
@@ -483,19 +529,14 @@ function ErrorBoundary(props) {
|
|
|
483
529
|
if (error) return displayFallback();
|
|
484
530
|
sync = false;
|
|
485
531
|
return {
|
|
486
|
-
t: `<!--!$e${id}-->${resolveSSRNode(res)}<!--!$/e${id}-->`
|
|
532
|
+
t: `<!--!$e${id}-->${resolveSSRNode(escape(res))}<!--!$/e${id}-->`
|
|
487
533
|
};
|
|
488
534
|
}
|
|
489
535
|
const SuspenseContext = createContext();
|
|
490
536
|
let resourceContext = null;
|
|
491
537
|
function createResource(source, fetcher, options = {}) {
|
|
492
|
-
if (
|
|
493
|
-
|
|
494
|
-
options = fetcher;
|
|
495
|
-
fetcher = source;
|
|
496
|
-
source = true;
|
|
497
|
-
}
|
|
498
|
-
} else if (arguments.length === 1) {
|
|
538
|
+
if (typeof fetcher !== "function") {
|
|
539
|
+
options = fetcher || {};
|
|
499
540
|
fetcher = source;
|
|
500
541
|
source = true;
|
|
501
542
|
}
|
|
@@ -677,7 +718,7 @@ function Suspense(props) {
|
|
|
677
718
|
completed: () => {
|
|
678
719
|
const res = runSuspense();
|
|
679
720
|
if (suspenseComplete(value)) {
|
|
680
|
-
done(resolveSSRNode(res));
|
|
721
|
+
done(resolveSSRNode(escape(res)));
|
|
681
722
|
}
|
|
682
723
|
}
|
|
683
724
|
});
|
|
@@ -718,7 +759,9 @@ function Suspense(props) {
|
|
|
718
759
|
noHydrate: true
|
|
719
760
|
});
|
|
720
761
|
const res = {
|
|
721
|
-
t: `<template id="pl-${id}"></template>${resolveSSRNode(
|
|
762
|
+
t: `<template id="pl-${id}"></template>${resolveSSRNode(
|
|
763
|
+
escape(props.fallback)
|
|
764
|
+
)}<!--pl-${id}-->`
|
|
722
765
|
};
|
|
723
766
|
setHydrateContext(ctx);
|
|
724
767
|
return res;
|