solid-js 1.3.0-beta.1 → 1.3.0-beta.10
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/README.md +3 -1
- package/dist/dev.cjs +91 -26
- package/dist/dev.js +89 -27
- package/dist/server.cjs +62 -21
- package/dist/server.js +62 -22
- package/dist/solid.cjs +91 -26
- package/dist/solid.js +89 -27
- package/package.json +27 -15
- package/types/index.d.ts +2 -2
- package/types/reactive/signal.d.ts +22 -4
- package/types/render/component.d.ts +4 -1
- package/types/server/index.d.ts +1 -1
- package/types/server/reactive.d.ts +1 -0
- package/types/server/rendering.d.ts +6 -5
- package/web/dist/dev.cjs +13 -15
- package/web/dist/dev.js +14 -15
- package/web/dist/server.cjs +141 -159
- package/web/dist/server.js +141 -159
- package/web/dist/web.cjs +13 -15
- package/web/dist/web.js +14 -15
- package/web/types/client.d.ts +11 -2
- package/web/types/index.d.ts +2 -0
- package/web/types/server-mock.d.ts +33 -20
package/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
<p>
|
|
2
|
+
<img width="100%" src="https://raw.githubusercontent.com/solidjs/solid/master/banner.png" alt="SolidJS">
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
5
|
[](https://github.com/solidjs/solid/actions/workflows/main-ci.yml)
|
|
4
6
|
[](https://coveralls.io/github/solidjs/solid?branch=main)
|
package/dist/dev.cjs
CHANGED
|
@@ -149,6 +149,7 @@ const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
|
149
149
|
var Owner = null;
|
|
150
150
|
let Transition = null;
|
|
151
151
|
let Scheduler = null;
|
|
152
|
+
let ExternalSourceFactory = null;
|
|
152
153
|
let Listener = null;
|
|
153
154
|
let Pending = null;
|
|
154
155
|
let Updates = null;
|
|
@@ -235,6 +236,9 @@ function createResource(source, fetcher, options) {
|
|
|
235
236
|
fetcher = source;
|
|
236
237
|
source = true;
|
|
237
238
|
}
|
|
239
|
+
Resources || (Resources = new Set());
|
|
240
|
+
Resources.add(load);
|
|
241
|
+
onCleanup(() => Resources.delete(load));
|
|
238
242
|
const contexts = new Set(),
|
|
239
243
|
[s, set] = createSignal((options || {}).initialValue),
|
|
240
244
|
[track, trigger] = createSignal(undefined, {
|
|
@@ -296,7 +300,7 @@ function createResource(source, fetcher, options) {
|
|
|
296
300
|
}
|
|
297
301
|
return v;
|
|
298
302
|
}
|
|
299
|
-
function load() {
|
|
303
|
+
function load(refetching = true) {
|
|
300
304
|
setError(err = undefined);
|
|
301
305
|
const lookup = dynamic ? source() : source;
|
|
302
306
|
loadedUnderTransition = Transition && Transition.running;
|
|
@@ -305,7 +309,10 @@ function createResource(source, fetcher, options) {
|
|
|
305
309
|
return;
|
|
306
310
|
}
|
|
307
311
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
308
|
-
const p = initP || untrack(() => fetcher(lookup,
|
|
312
|
+
const p = initP || untrack(() => fetcher(lookup, {
|
|
313
|
+
value: s(),
|
|
314
|
+
refetching
|
|
315
|
+
}));
|
|
309
316
|
initP = null;
|
|
310
317
|
if (typeof p !== "object" || !("then" in p)) {
|
|
311
318
|
loadEnd(pr, p);
|
|
@@ -330,12 +337,16 @@ function createResource(source, fetcher, options) {
|
|
|
330
337
|
}
|
|
331
338
|
}
|
|
332
339
|
});
|
|
333
|
-
if (dynamic) createComputed(load);else load();
|
|
340
|
+
if (dynamic) createComputed(() => load(false));else load(false);
|
|
334
341
|
return [read, {
|
|
335
342
|
refetch: load,
|
|
336
343
|
mutate: set
|
|
337
344
|
}];
|
|
338
345
|
}
|
|
346
|
+
let Resources;
|
|
347
|
+
function refetchResources(info) {
|
|
348
|
+
Resources && Resources.forEach(fn => fn(info));
|
|
349
|
+
}
|
|
339
350
|
function createDeferred(source, options) {
|
|
340
351
|
let t,
|
|
341
352
|
timeout = options ? options.timeoutMs : undefined;
|
|
@@ -554,6 +565,24 @@ let SuspenseContext;
|
|
|
554
565
|
function getSuspenseContext() {
|
|
555
566
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
556
567
|
}
|
|
568
|
+
function enableExternalSource(factory) {
|
|
569
|
+
if (ExternalSourceFactory) {
|
|
570
|
+
const oldFactory = ExternalSourceFactory;
|
|
571
|
+
ExternalSourceFactory = (fn, trigger) => {
|
|
572
|
+
const oldSource = oldFactory(fn, trigger);
|
|
573
|
+
const source = factory(x => oldSource.track(x), trigger);
|
|
574
|
+
return {
|
|
575
|
+
track: x => source.track(x),
|
|
576
|
+
dispose() {
|
|
577
|
+
source.dispose();
|
|
578
|
+
oldSource.dispose();
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
};
|
|
582
|
+
} else {
|
|
583
|
+
ExternalSourceFactory = factory;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
557
586
|
function readSignal() {
|
|
558
587
|
const runningTransition = Transition && Transition.running;
|
|
559
588
|
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
@@ -682,6 +711,19 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
682
711
|
}
|
|
683
712
|
c.name = options && options.name || `${Owner.name || "c"}-${(Owner.owned || Owner.tOwned).length}`;
|
|
684
713
|
}
|
|
714
|
+
if (ExternalSourceFactory) {
|
|
715
|
+
const [track, trigger] = createSignal(undefined, {
|
|
716
|
+
equals: false
|
|
717
|
+
});
|
|
718
|
+
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
719
|
+
onCleanup(() => ordinary.dispose());
|
|
720
|
+
const triggerInTransition = () => startTransition(trigger, () => inTransition.dispose());
|
|
721
|
+
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
722
|
+
c.fn = x => {
|
|
723
|
+
track();
|
|
724
|
+
return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
|
|
725
|
+
};
|
|
726
|
+
}
|
|
685
727
|
return c;
|
|
686
728
|
}
|
|
687
729
|
function runTop(node) {
|
|
@@ -1139,13 +1181,19 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1139
1181
|
};
|
|
1140
1182
|
}
|
|
1141
1183
|
|
|
1184
|
+
let hydrationEnabled = false;
|
|
1185
|
+
function enableHydration() {
|
|
1186
|
+
hydrationEnabled = true;
|
|
1187
|
+
}
|
|
1142
1188
|
function createComponent(Comp, props) {
|
|
1143
|
-
if (
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1189
|
+
if (hydrationEnabled) {
|
|
1190
|
+
if (sharedConfig.context) {
|
|
1191
|
+
const c = sharedConfig.context;
|
|
1192
|
+
setHydrateContext(nextHydrateContext());
|
|
1193
|
+
const r = devComponent(Comp, props) ;
|
|
1194
|
+
setHydrateContext(c);
|
|
1195
|
+
return r;
|
|
1196
|
+
}
|
|
1149
1197
|
}
|
|
1150
1198
|
return devComponent(Comp, props);
|
|
1151
1199
|
}
|
|
@@ -1234,19 +1282,20 @@ function splitProps(props, ...keys) {
|
|
|
1234
1282
|
}
|
|
1235
1283
|
function lazy(fn) {
|
|
1236
1284
|
let comp;
|
|
1285
|
+
let p;
|
|
1237
1286
|
const wrap = props => {
|
|
1238
1287
|
const ctx = sharedConfig.context;
|
|
1239
1288
|
if (ctx) {
|
|
1240
1289
|
ctx.count++;
|
|
1241
1290
|
const [s, set] = createSignal();
|
|
1242
|
-
fn().then(mod => {
|
|
1291
|
+
(p || (p = fn())).then(mod => {
|
|
1243
1292
|
setHydrateContext(ctx);
|
|
1244
1293
|
set(() => mod.default);
|
|
1245
|
-
setHydrateContext(
|
|
1294
|
+
setHydrateContext();
|
|
1246
1295
|
});
|
|
1247
1296
|
comp = s;
|
|
1248
1297
|
} else if (!comp) {
|
|
1249
|
-
const [s] = createResource(() => fn().then(mod => mod.default));
|
|
1298
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1250
1299
|
comp = s;
|
|
1251
1300
|
} else {
|
|
1252
1301
|
const c = comp();
|
|
@@ -1262,7 +1311,7 @@ function lazy(fn) {
|
|
|
1262
1311
|
return r;
|
|
1263
1312
|
}));
|
|
1264
1313
|
};
|
|
1265
|
-
wrap.preload = () =>
|
|
1314
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1266
1315
|
return wrap;
|
|
1267
1316
|
}
|
|
1268
1317
|
let counter = 0;
|
|
@@ -1322,7 +1371,11 @@ function Match(props) {
|
|
|
1322
1371
|
return props;
|
|
1323
1372
|
}
|
|
1324
1373
|
function ErrorBoundary(props) {
|
|
1325
|
-
|
|
1374
|
+
let err = undefined;
|
|
1375
|
+
if (sharedConfig.context && sharedConfig.load) {
|
|
1376
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1377
|
+
}
|
|
1378
|
+
const [errored, setErrored] = createSignal(err);
|
|
1326
1379
|
let e;
|
|
1327
1380
|
return createMemo(() => {
|
|
1328
1381
|
if ((e = errored()) != null) {
|
|
@@ -1405,8 +1458,9 @@ function Suspense(props) {
|
|
|
1405
1458
|
showContent,
|
|
1406
1459
|
showFallback,
|
|
1407
1460
|
ctx,
|
|
1408
|
-
|
|
1409
|
-
flicker
|
|
1461
|
+
p,
|
|
1462
|
+
flicker,
|
|
1463
|
+
error;
|
|
1410
1464
|
const [inFallback, setFallback] = createSignal(false),
|
|
1411
1465
|
SuspenseContext = getSuspenseContext(),
|
|
1412
1466
|
store = {
|
|
@@ -1421,21 +1475,21 @@ function Suspense(props) {
|
|
|
1421
1475
|
resolved: false
|
|
1422
1476
|
},
|
|
1423
1477
|
owner = getOwner();
|
|
1424
|
-
if (sharedConfig.context
|
|
1478
|
+
if (sharedConfig.context) {
|
|
1425
1479
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1426
|
-
|
|
1427
|
-
if (p) {
|
|
1480
|
+
p = sharedConfig.load(key);
|
|
1481
|
+
if (p && typeof p === "object") {
|
|
1428
1482
|
const [s, set] = createSignal(undefined, {
|
|
1429
1483
|
equals: false
|
|
1430
1484
|
});
|
|
1431
1485
|
flicker = s;
|
|
1432
|
-
p.then(
|
|
1486
|
+
p.then(err => {
|
|
1487
|
+
if (error = err) return set();
|
|
1433
1488
|
sharedConfig.gather(key);
|
|
1434
|
-
waitingHydration = true;
|
|
1435
1489
|
setHydrateContext(ctx);
|
|
1436
1490
|
set();
|
|
1437
|
-
setHydrateContext(
|
|
1438
|
-
|
|
1491
|
+
setHydrateContext();
|
|
1492
|
+
p = undefined;
|
|
1439
1493
|
});
|
|
1440
1494
|
}
|
|
1441
1495
|
}
|
|
@@ -1447,18 +1501,20 @@ function Suspense(props) {
|
|
|
1447
1501
|
value: store,
|
|
1448
1502
|
get children() {
|
|
1449
1503
|
return createMemo(() => {
|
|
1504
|
+
if (error) throw error;
|
|
1505
|
+
ctx = sharedConfig.context;
|
|
1450
1506
|
if (flicker) {
|
|
1451
|
-
ctx = sharedConfig.context;
|
|
1452
1507
|
flicker();
|
|
1453
1508
|
return flicker = undefined;
|
|
1454
1509
|
}
|
|
1510
|
+
if (ctx && p === undefined) setHydrateContext();
|
|
1455
1511
|
const rendered = untrack(() => props.children);
|
|
1456
1512
|
return createMemo(() => {
|
|
1457
1513
|
const inFallback = store.inFallback(),
|
|
1458
1514
|
visibleContent = showContent ? showContent() : true,
|
|
1459
1515
|
visibleFallback = showFallback ? showFallback() : true;
|
|
1460
1516
|
dispose && dispose();
|
|
1461
|
-
if ((!inFallback ||
|
|
1517
|
+
if ((!inFallback || p !== undefined) && visibleContent) {
|
|
1462
1518
|
store.resolved = true;
|
|
1463
1519
|
resumeEffects(store.effects);
|
|
1464
1520
|
return rendered;
|
|
@@ -1466,7 +1522,13 @@ function Suspense(props) {
|
|
|
1466
1522
|
if (!visibleFallback) return;
|
|
1467
1523
|
return createRoot(disposer => {
|
|
1468
1524
|
dispose = disposer;
|
|
1469
|
-
if (
|
|
1525
|
+
if (ctx) {
|
|
1526
|
+
setHydrateContext({
|
|
1527
|
+
id: ctx.id + "f",
|
|
1528
|
+
count: 0
|
|
1529
|
+
});
|
|
1530
|
+
ctx = undefined;
|
|
1531
|
+
}
|
|
1470
1532
|
return props.fallback;
|
|
1471
1533
|
}, owner);
|
|
1472
1534
|
});
|
|
@@ -1512,6 +1574,8 @@ exports.createRoot = createRoot;
|
|
|
1512
1574
|
exports.createSelector = createSelector;
|
|
1513
1575
|
exports.createSignal = createSignal;
|
|
1514
1576
|
exports.createUniqueId = createUniqueId;
|
|
1577
|
+
exports.enableExternalSource = enableExternalSource;
|
|
1578
|
+
exports.enableHydration = enableHydration;
|
|
1515
1579
|
exports.enableScheduling = enableScheduling;
|
|
1516
1580
|
exports.equalFn = equalFn;
|
|
1517
1581
|
exports.from = from;
|
|
@@ -1526,6 +1590,7 @@ exports.on = on;
|
|
|
1526
1590
|
exports.onCleanup = onCleanup;
|
|
1527
1591
|
exports.onError = onError;
|
|
1528
1592
|
exports.onMount = onMount;
|
|
1593
|
+
exports.refetchResources = refetchResources;
|
|
1529
1594
|
exports.requestCallback = requestCallback;
|
|
1530
1595
|
exports.runWithOwner = runWithOwner;
|
|
1531
1596
|
exports.sharedConfig = sharedConfig;
|
package/dist/dev.js
CHANGED
|
@@ -145,6 +145,7 @@ const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
|
145
145
|
var Owner = null;
|
|
146
146
|
let Transition = null;
|
|
147
147
|
let Scheduler = null;
|
|
148
|
+
let ExternalSourceFactory = null;
|
|
148
149
|
let Listener = null;
|
|
149
150
|
let Pending = null;
|
|
150
151
|
let Updates = null;
|
|
@@ -231,6 +232,9 @@ function createResource(source, fetcher, options) {
|
|
|
231
232
|
fetcher = source;
|
|
232
233
|
source = true;
|
|
233
234
|
}
|
|
235
|
+
Resources || (Resources = new Set());
|
|
236
|
+
Resources.add(load);
|
|
237
|
+
onCleanup(() => Resources.delete(load));
|
|
234
238
|
const contexts = new Set(),
|
|
235
239
|
[s, set] = createSignal((options || {}).initialValue),
|
|
236
240
|
[track, trigger] = createSignal(undefined, {
|
|
@@ -292,7 +296,7 @@ function createResource(source, fetcher, options) {
|
|
|
292
296
|
}
|
|
293
297
|
return v;
|
|
294
298
|
}
|
|
295
|
-
function load() {
|
|
299
|
+
function load(refetching = true) {
|
|
296
300
|
setError(err = undefined);
|
|
297
301
|
const lookup = dynamic ? source() : source;
|
|
298
302
|
loadedUnderTransition = Transition && Transition.running;
|
|
@@ -301,7 +305,10 @@ function createResource(source, fetcher, options) {
|
|
|
301
305
|
return;
|
|
302
306
|
}
|
|
303
307
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
304
|
-
const p = initP || untrack(() => fetcher(lookup,
|
|
308
|
+
const p = initP || untrack(() => fetcher(lookup, {
|
|
309
|
+
value: s(),
|
|
310
|
+
refetching
|
|
311
|
+
}));
|
|
305
312
|
initP = null;
|
|
306
313
|
if (typeof p !== "object" || !("then" in p)) {
|
|
307
314
|
loadEnd(pr, p);
|
|
@@ -326,12 +333,16 @@ function createResource(source, fetcher, options) {
|
|
|
326
333
|
}
|
|
327
334
|
}
|
|
328
335
|
});
|
|
329
|
-
if (dynamic) createComputed(load);else load();
|
|
336
|
+
if (dynamic) createComputed(() => load(false));else load(false);
|
|
330
337
|
return [read, {
|
|
331
338
|
refetch: load,
|
|
332
339
|
mutate: set
|
|
333
340
|
}];
|
|
334
341
|
}
|
|
342
|
+
let Resources;
|
|
343
|
+
function refetchResources(info) {
|
|
344
|
+
Resources && Resources.forEach(fn => fn(info));
|
|
345
|
+
}
|
|
335
346
|
function createDeferred(source, options) {
|
|
336
347
|
let t,
|
|
337
348
|
timeout = options ? options.timeoutMs : undefined;
|
|
@@ -550,6 +561,24 @@ let SuspenseContext;
|
|
|
550
561
|
function getSuspenseContext() {
|
|
551
562
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
552
563
|
}
|
|
564
|
+
function enableExternalSource(factory) {
|
|
565
|
+
if (ExternalSourceFactory) {
|
|
566
|
+
const oldFactory = ExternalSourceFactory;
|
|
567
|
+
ExternalSourceFactory = (fn, trigger) => {
|
|
568
|
+
const oldSource = oldFactory(fn, trigger);
|
|
569
|
+
const source = factory(x => oldSource.track(x), trigger);
|
|
570
|
+
return {
|
|
571
|
+
track: x => source.track(x),
|
|
572
|
+
dispose() {
|
|
573
|
+
source.dispose();
|
|
574
|
+
oldSource.dispose();
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
};
|
|
578
|
+
} else {
|
|
579
|
+
ExternalSourceFactory = factory;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
553
582
|
function readSignal() {
|
|
554
583
|
const runningTransition = Transition && Transition.running;
|
|
555
584
|
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
@@ -678,6 +707,19 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
678
707
|
}
|
|
679
708
|
c.name = options && options.name || `${Owner.name || "c"}-${(Owner.owned || Owner.tOwned).length}`;
|
|
680
709
|
}
|
|
710
|
+
if (ExternalSourceFactory) {
|
|
711
|
+
const [track, trigger] = createSignal(undefined, {
|
|
712
|
+
equals: false
|
|
713
|
+
});
|
|
714
|
+
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
715
|
+
onCleanup(() => ordinary.dispose());
|
|
716
|
+
const triggerInTransition = () => startTransition(trigger, () => inTransition.dispose());
|
|
717
|
+
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
718
|
+
c.fn = x => {
|
|
719
|
+
track();
|
|
720
|
+
return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
|
|
721
|
+
};
|
|
722
|
+
}
|
|
681
723
|
return c;
|
|
682
724
|
}
|
|
683
725
|
function runTop(node) {
|
|
@@ -1135,13 +1177,19 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1135
1177
|
};
|
|
1136
1178
|
}
|
|
1137
1179
|
|
|
1180
|
+
let hydrationEnabled = false;
|
|
1181
|
+
function enableHydration() {
|
|
1182
|
+
hydrationEnabled = true;
|
|
1183
|
+
}
|
|
1138
1184
|
function createComponent(Comp, props) {
|
|
1139
|
-
if (
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1185
|
+
if (hydrationEnabled) {
|
|
1186
|
+
if (sharedConfig.context) {
|
|
1187
|
+
const c = sharedConfig.context;
|
|
1188
|
+
setHydrateContext(nextHydrateContext());
|
|
1189
|
+
const r = devComponent(Comp, props) ;
|
|
1190
|
+
setHydrateContext(c);
|
|
1191
|
+
return r;
|
|
1192
|
+
}
|
|
1145
1193
|
}
|
|
1146
1194
|
return devComponent(Comp, props);
|
|
1147
1195
|
}
|
|
@@ -1230,19 +1278,20 @@ function splitProps(props, ...keys) {
|
|
|
1230
1278
|
}
|
|
1231
1279
|
function lazy(fn) {
|
|
1232
1280
|
let comp;
|
|
1281
|
+
let p;
|
|
1233
1282
|
const wrap = props => {
|
|
1234
1283
|
const ctx = sharedConfig.context;
|
|
1235
1284
|
if (ctx) {
|
|
1236
1285
|
ctx.count++;
|
|
1237
1286
|
const [s, set] = createSignal();
|
|
1238
|
-
fn().then(mod => {
|
|
1287
|
+
(p || (p = fn())).then(mod => {
|
|
1239
1288
|
setHydrateContext(ctx);
|
|
1240
1289
|
set(() => mod.default);
|
|
1241
|
-
setHydrateContext(
|
|
1290
|
+
setHydrateContext();
|
|
1242
1291
|
});
|
|
1243
1292
|
comp = s;
|
|
1244
1293
|
} else if (!comp) {
|
|
1245
|
-
const [s] = createResource(() => fn().then(mod => mod.default));
|
|
1294
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1246
1295
|
comp = s;
|
|
1247
1296
|
} else {
|
|
1248
1297
|
const c = comp();
|
|
@@ -1258,7 +1307,7 @@ function lazy(fn) {
|
|
|
1258
1307
|
return r;
|
|
1259
1308
|
}));
|
|
1260
1309
|
};
|
|
1261
|
-
wrap.preload = () =>
|
|
1310
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1262
1311
|
return wrap;
|
|
1263
1312
|
}
|
|
1264
1313
|
let counter = 0;
|
|
@@ -1318,7 +1367,11 @@ function Match(props) {
|
|
|
1318
1367
|
return props;
|
|
1319
1368
|
}
|
|
1320
1369
|
function ErrorBoundary(props) {
|
|
1321
|
-
|
|
1370
|
+
let err = undefined;
|
|
1371
|
+
if (sharedConfig.context && sharedConfig.load) {
|
|
1372
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1373
|
+
}
|
|
1374
|
+
const [errored, setErrored] = createSignal(err);
|
|
1322
1375
|
let e;
|
|
1323
1376
|
return createMemo(() => {
|
|
1324
1377
|
if ((e = errored()) != null) {
|
|
@@ -1401,8 +1454,9 @@ function Suspense(props) {
|
|
|
1401
1454
|
showContent,
|
|
1402
1455
|
showFallback,
|
|
1403
1456
|
ctx,
|
|
1404
|
-
|
|
1405
|
-
flicker
|
|
1457
|
+
p,
|
|
1458
|
+
flicker,
|
|
1459
|
+
error;
|
|
1406
1460
|
const [inFallback, setFallback] = createSignal(false),
|
|
1407
1461
|
SuspenseContext = getSuspenseContext(),
|
|
1408
1462
|
store = {
|
|
@@ -1417,21 +1471,21 @@ function Suspense(props) {
|
|
|
1417
1471
|
resolved: false
|
|
1418
1472
|
},
|
|
1419
1473
|
owner = getOwner();
|
|
1420
|
-
if (sharedConfig.context
|
|
1474
|
+
if (sharedConfig.context) {
|
|
1421
1475
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1422
|
-
|
|
1423
|
-
if (p) {
|
|
1476
|
+
p = sharedConfig.load(key);
|
|
1477
|
+
if (p && typeof p === "object") {
|
|
1424
1478
|
const [s, set] = createSignal(undefined, {
|
|
1425
1479
|
equals: false
|
|
1426
1480
|
});
|
|
1427
1481
|
flicker = s;
|
|
1428
|
-
p.then(
|
|
1482
|
+
p.then(err => {
|
|
1483
|
+
if (error = err) return set();
|
|
1429
1484
|
sharedConfig.gather(key);
|
|
1430
|
-
waitingHydration = true;
|
|
1431
1485
|
setHydrateContext(ctx);
|
|
1432
1486
|
set();
|
|
1433
|
-
setHydrateContext(
|
|
1434
|
-
|
|
1487
|
+
setHydrateContext();
|
|
1488
|
+
p = undefined;
|
|
1435
1489
|
});
|
|
1436
1490
|
}
|
|
1437
1491
|
}
|
|
@@ -1443,18 +1497,20 @@ function Suspense(props) {
|
|
|
1443
1497
|
value: store,
|
|
1444
1498
|
get children() {
|
|
1445
1499
|
return createMemo(() => {
|
|
1500
|
+
if (error) throw error;
|
|
1501
|
+
ctx = sharedConfig.context;
|
|
1446
1502
|
if (flicker) {
|
|
1447
|
-
ctx = sharedConfig.context;
|
|
1448
1503
|
flicker();
|
|
1449
1504
|
return flicker = undefined;
|
|
1450
1505
|
}
|
|
1506
|
+
if (ctx && p === undefined) setHydrateContext();
|
|
1451
1507
|
const rendered = untrack(() => props.children);
|
|
1452
1508
|
return createMemo(() => {
|
|
1453
1509
|
const inFallback = store.inFallback(),
|
|
1454
1510
|
visibleContent = showContent ? showContent() : true,
|
|
1455
1511
|
visibleFallback = showFallback ? showFallback() : true;
|
|
1456
1512
|
dispose && dispose();
|
|
1457
|
-
if ((!inFallback ||
|
|
1513
|
+
if ((!inFallback || p !== undefined) && visibleContent) {
|
|
1458
1514
|
store.resolved = true;
|
|
1459
1515
|
resumeEffects(store.effects);
|
|
1460
1516
|
return rendered;
|
|
@@ -1462,7 +1518,13 @@ function Suspense(props) {
|
|
|
1462
1518
|
if (!visibleFallback) return;
|
|
1463
1519
|
return createRoot(disposer => {
|
|
1464
1520
|
dispose = disposer;
|
|
1465
|
-
if (
|
|
1521
|
+
if (ctx) {
|
|
1522
|
+
setHydrateContext({
|
|
1523
|
+
id: ctx.id + "f",
|
|
1524
|
+
count: 0
|
|
1525
|
+
});
|
|
1526
|
+
ctx = undefined;
|
|
1527
|
+
}
|
|
1466
1528
|
return props.fallback;
|
|
1467
1529
|
}, owner);
|
|
1468
1530
|
});
|
|
@@ -1484,4 +1546,4 @@ if (globalThis) {
|
|
|
1484
1546
|
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
1485
1547
|
}
|
|
1486
1548
|
|
|
1487
|
-
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
|
1549
|
+
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, refetchResources, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|