solid-js 1.2.6 → 1.3.0-beta.3
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 +66 -33
- package/dist/dev.js +67 -33
- package/dist/server.cjs +67 -60
- package/dist/server.js +68 -60
- package/dist/solid.cjs +66 -33
- package/dist/solid.js +67 -33
- package/package.json +3 -3
- package/types/index.d.ts +0 -1
- package/types/reactive/signal.d.ts +76 -78
- package/types/render/hydration.d.ts +3 -2
- package/types/server/index.d.ts +1 -1
- package/types/server/reactive.d.ts +1 -2
- package/types/server/rendering.d.ts +7 -5
- package/web/dist/dev.cjs +21 -16
- package/web/dist/dev.js +22 -16
- package/web/dist/server.cjs +251 -104
- package/web/dist/server.js +252 -106
- package/web/dist/web.cjs +21 -16
- package/web/dist/web.js +22 -16
- package/web/types/client.d.ts +0 -1
- package/web/types/core.d.ts +2 -2
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
|
@@ -187,12 +187,13 @@ function createSignal(value, options) {
|
|
|
187
187
|
comparator: options.equals || undefined
|
|
188
188
|
};
|
|
189
189
|
if (!options.internal) s.name = registerGraph(options.name || hashValue(value), s);
|
|
190
|
-
|
|
190
|
+
const setter = value => {
|
|
191
191
|
if (typeof value === "function") {
|
|
192
192
|
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.pending !== NOTPENDING ? s.pending : s.tValue);else value = value(s.pending !== NOTPENDING ? s.pending : s.value);
|
|
193
193
|
}
|
|
194
194
|
return writeSignal(s, value);
|
|
195
|
-
}
|
|
195
|
+
};
|
|
196
|
+
return [readSignal.bind(s), setter];
|
|
196
197
|
}
|
|
197
198
|
function createComputed(fn, value, options) {
|
|
198
199
|
const c = createComputation(fn, value, true, STALE, options );
|
|
@@ -249,12 +250,7 @@ function createResource(source, fetcher, options) {
|
|
|
249
250
|
dynamic = typeof source === "function";
|
|
250
251
|
if (sharedConfig.context) {
|
|
251
252
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
252
|
-
if (sharedConfig.
|
|
253
|
-
initP = sharedConfig.context.loadResource(id);
|
|
254
|
-
} else if (sharedConfig.resources && id && id in sharedConfig.resources) {
|
|
255
|
-
initP = sharedConfig.resources[id];
|
|
256
|
-
delete sharedConfig.resources[id];
|
|
257
|
-
}
|
|
253
|
+
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
258
254
|
}
|
|
259
255
|
function loadEnd(p, v, e) {
|
|
260
256
|
if (pr === p) {
|
|
@@ -358,7 +354,7 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
358
354
|
const subs = new Map();
|
|
359
355
|
const node = createComputation(p => {
|
|
360
356
|
const v = source();
|
|
361
|
-
for (const key of subs.keys()) if (fn(key, v)
|
|
357
|
+
for (const key of subs.keys()) if (fn(key, v) !== (p !== undefined && fn(key, p))) {
|
|
362
358
|
const l = subs.get(key);
|
|
363
359
|
for (const c of l.values()) {
|
|
364
360
|
c.state = STALE;
|
|
@@ -409,7 +405,8 @@ function untrack(fn) {
|
|
|
409
405
|
Listener = listener;
|
|
410
406
|
return result;
|
|
411
407
|
}
|
|
412
|
-
function on(deps, fn,
|
|
408
|
+
function on(deps, fn,
|
|
409
|
+
options) {
|
|
413
410
|
const isArray = Array.isArray(deps);
|
|
414
411
|
let prevInput;
|
|
415
412
|
let defer = options && options.defer;
|
|
@@ -711,7 +708,7 @@ function runTop(node) {
|
|
|
711
708
|
} else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
712
709
|
const updates = Updates;
|
|
713
710
|
Updates = null;
|
|
714
|
-
lookDownstream(node);
|
|
711
|
+
lookDownstream(node, ancestors[0]);
|
|
715
712
|
Updates = updates;
|
|
716
713
|
}
|
|
717
714
|
}
|
|
@@ -810,13 +807,15 @@ function runUserEffects(queue) {
|
|
|
810
807
|
for (i = 0; i < userLength; i++) runTop(queue[i]);
|
|
811
808
|
for (i = resume; i < queue.length; i++) runTop(queue[i]);
|
|
812
809
|
}
|
|
813
|
-
function lookDownstream(node) {
|
|
810
|
+
function lookDownstream(node, ignore) {
|
|
814
811
|
node.state = 0;
|
|
815
812
|
const runningTransition = Transition && Transition.running;
|
|
816
813
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
817
814
|
const source = node.sources[i];
|
|
818
815
|
if (source.sources) {
|
|
819
|
-
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE)
|
|
816
|
+
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
|
|
817
|
+
if (source !== ignore) runTop(source);
|
|
818
|
+
} else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source, ignore);
|
|
820
819
|
}
|
|
821
820
|
}
|
|
822
821
|
}
|
|
@@ -1237,7 +1236,7 @@ function lazy(fn) {
|
|
|
1237
1236
|
let comp;
|
|
1238
1237
|
const wrap = props => {
|
|
1239
1238
|
const ctx = sharedConfig.context;
|
|
1240
|
-
if (ctx
|
|
1239
|
+
if (ctx) {
|
|
1241
1240
|
ctx.count++;
|
|
1242
1241
|
const [s, set] = createSignal();
|
|
1243
1242
|
fn().then(mod => {
|
|
@@ -1310,7 +1309,7 @@ function Switch(props) {
|
|
|
1310
1309
|
}
|
|
1311
1310
|
return [-1];
|
|
1312
1311
|
}, undefined, {
|
|
1313
|
-
equals: (a, b) => a
|
|
1312
|
+
equals: (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
|
|
1314
1313
|
});
|
|
1315
1314
|
return createMemo(() => {
|
|
1316
1315
|
const [index, when, cond] = evalConditions();
|
|
@@ -1323,7 +1322,11 @@ function Match(props) {
|
|
|
1323
1322
|
return props;
|
|
1324
1323
|
}
|
|
1325
1324
|
function ErrorBoundary(props) {
|
|
1326
|
-
|
|
1325
|
+
let err = undefined;
|
|
1326
|
+
if (sharedConfig.context && sharedConfig.load) {
|
|
1327
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1328
|
+
}
|
|
1329
|
+
const [errored, setErrored] = createSignal(err);
|
|
1327
1330
|
let e;
|
|
1328
1331
|
return createMemo(() => {
|
|
1329
1332
|
if ((e = errored()) != null) {
|
|
@@ -1404,7 +1407,11 @@ function SuspenseList(props) {
|
|
|
1404
1407
|
function Suspense(props) {
|
|
1405
1408
|
let counter = 0,
|
|
1406
1409
|
showContent,
|
|
1407
|
-
showFallback
|
|
1410
|
+
showFallback,
|
|
1411
|
+
ctx,
|
|
1412
|
+
waitingHydration,
|
|
1413
|
+
flicker,
|
|
1414
|
+
error;
|
|
1408
1415
|
const [inFallback, setFallback] = createSignal(false),
|
|
1409
1416
|
SuspenseContext = getSuspenseContext(),
|
|
1410
1417
|
store = {
|
|
@@ -1419,6 +1426,25 @@ function Suspense(props) {
|
|
|
1419
1426
|
resolved: false
|
|
1420
1427
|
},
|
|
1421
1428
|
owner = getOwner();
|
|
1429
|
+
if (sharedConfig.context) {
|
|
1430
|
+
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1431
|
+
const p = sharedConfig.load(key);
|
|
1432
|
+
if (p) {
|
|
1433
|
+
const [s, set] = createSignal(undefined, {
|
|
1434
|
+
equals: false
|
|
1435
|
+
});
|
|
1436
|
+
flicker = s;
|
|
1437
|
+
p.then(err => {
|
|
1438
|
+
if (error = err) return set();
|
|
1439
|
+
sharedConfig.gather(key);
|
|
1440
|
+
waitingHydration = true;
|
|
1441
|
+
setHydrateContext(ctx);
|
|
1442
|
+
set();
|
|
1443
|
+
setHydrateContext(undefined);
|
|
1444
|
+
waitingHydration = false;
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1422
1448
|
const listContext = useContext(SuspenseListContext);
|
|
1423
1449
|
if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
|
|
1424
1450
|
let dispose;
|
|
@@ -1426,28 +1452,36 @@ function Suspense(props) {
|
|
|
1426
1452
|
return createComponent(SuspenseContext.Provider, {
|
|
1427
1453
|
value: store,
|
|
1428
1454
|
get children() {
|
|
1429
|
-
const rendered = untrack(() => props.children);
|
|
1430
1455
|
return createMemo(() => {
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
store.resolved = true;
|
|
1437
|
-
resumeEffects(store.effects);
|
|
1438
|
-
return rendered;
|
|
1456
|
+
if (error) throw error;
|
|
1457
|
+
if (flicker) {
|
|
1458
|
+
ctx = sharedConfig.context;
|
|
1459
|
+
flicker();
|
|
1460
|
+
return flicker = undefined;
|
|
1439
1461
|
}
|
|
1440
|
-
|
|
1441
|
-
return
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1462
|
+
const rendered = untrack(() => props.children);
|
|
1463
|
+
return createMemo(() => {
|
|
1464
|
+
const inFallback = store.inFallback(),
|
|
1465
|
+
visibleContent = showContent ? showContent() : true,
|
|
1466
|
+
visibleFallback = showFallback ? showFallback() : true;
|
|
1467
|
+
dispose && dispose();
|
|
1468
|
+
if ((!inFallback || waitingHydration) && visibleContent) {
|
|
1469
|
+
store.resolved = true;
|
|
1470
|
+
resumeEffects(store.effects);
|
|
1471
|
+
return rendered;
|
|
1472
|
+
}
|
|
1473
|
+
if (!visibleFallback) return;
|
|
1474
|
+
return createRoot(disposer => {
|
|
1475
|
+
dispose = disposer;
|
|
1476
|
+
if (sharedConfig.context) sharedConfig.context.count = 0;
|
|
1477
|
+
return props.fallback;
|
|
1478
|
+
}, owner);
|
|
1479
|
+
});
|
|
1445
1480
|
});
|
|
1446
1481
|
}
|
|
1447
1482
|
});
|
|
1448
1483
|
}
|
|
1449
1484
|
|
|
1450
|
-
function awaitSuspense() {}
|
|
1451
1485
|
exports.DEV = void 0;
|
|
1452
1486
|
{
|
|
1453
1487
|
exports.DEV = {
|
|
@@ -1470,7 +1504,6 @@ exports.Show = Show;
|
|
|
1470
1504
|
exports.Suspense = Suspense;
|
|
1471
1505
|
exports.SuspenseList = SuspenseList;
|
|
1472
1506
|
exports.Switch = Switch;
|
|
1473
|
-
exports.awaitSuspense = awaitSuspense;
|
|
1474
1507
|
exports.batch = batch;
|
|
1475
1508
|
exports.cancelCallback = cancelCallback;
|
|
1476
1509
|
exports.children = children;
|
package/dist/dev.js
CHANGED
|
@@ -183,12 +183,13 @@ function createSignal(value, options) {
|
|
|
183
183
|
comparator: options.equals || undefined
|
|
184
184
|
};
|
|
185
185
|
if (!options.internal) s.name = registerGraph(options.name || hashValue(value), s);
|
|
186
|
-
|
|
186
|
+
const setter = value => {
|
|
187
187
|
if (typeof value === "function") {
|
|
188
188
|
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.pending !== NOTPENDING ? s.pending : s.tValue);else value = value(s.pending !== NOTPENDING ? s.pending : s.value);
|
|
189
189
|
}
|
|
190
190
|
return writeSignal(s, value);
|
|
191
|
-
}
|
|
191
|
+
};
|
|
192
|
+
return [readSignal.bind(s), setter];
|
|
192
193
|
}
|
|
193
194
|
function createComputed(fn, value, options) {
|
|
194
195
|
const c = createComputation(fn, value, true, STALE, options );
|
|
@@ -245,12 +246,7 @@ function createResource(source, fetcher, options) {
|
|
|
245
246
|
dynamic = typeof source === "function";
|
|
246
247
|
if (sharedConfig.context) {
|
|
247
248
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
248
|
-
if (sharedConfig.
|
|
249
|
-
initP = sharedConfig.context.loadResource(id);
|
|
250
|
-
} else if (sharedConfig.resources && id && id in sharedConfig.resources) {
|
|
251
|
-
initP = sharedConfig.resources[id];
|
|
252
|
-
delete sharedConfig.resources[id];
|
|
253
|
-
}
|
|
249
|
+
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
254
250
|
}
|
|
255
251
|
function loadEnd(p, v, e) {
|
|
256
252
|
if (pr === p) {
|
|
@@ -354,7 +350,7 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
354
350
|
const subs = new Map();
|
|
355
351
|
const node = createComputation(p => {
|
|
356
352
|
const v = source();
|
|
357
|
-
for (const key of subs.keys()) if (fn(key, v)
|
|
353
|
+
for (const key of subs.keys()) if (fn(key, v) !== (p !== undefined && fn(key, p))) {
|
|
358
354
|
const l = subs.get(key);
|
|
359
355
|
for (const c of l.values()) {
|
|
360
356
|
c.state = STALE;
|
|
@@ -405,7 +401,8 @@ function untrack(fn) {
|
|
|
405
401
|
Listener = listener;
|
|
406
402
|
return result;
|
|
407
403
|
}
|
|
408
|
-
function on(deps, fn,
|
|
404
|
+
function on(deps, fn,
|
|
405
|
+
options) {
|
|
409
406
|
const isArray = Array.isArray(deps);
|
|
410
407
|
let prevInput;
|
|
411
408
|
let defer = options && options.defer;
|
|
@@ -707,7 +704,7 @@ function runTop(node) {
|
|
|
707
704
|
} else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
708
705
|
const updates = Updates;
|
|
709
706
|
Updates = null;
|
|
710
|
-
lookDownstream(node);
|
|
707
|
+
lookDownstream(node, ancestors[0]);
|
|
711
708
|
Updates = updates;
|
|
712
709
|
}
|
|
713
710
|
}
|
|
@@ -806,13 +803,15 @@ function runUserEffects(queue) {
|
|
|
806
803
|
for (i = 0; i < userLength; i++) runTop(queue[i]);
|
|
807
804
|
for (i = resume; i < queue.length; i++) runTop(queue[i]);
|
|
808
805
|
}
|
|
809
|
-
function lookDownstream(node) {
|
|
806
|
+
function lookDownstream(node, ignore) {
|
|
810
807
|
node.state = 0;
|
|
811
808
|
const runningTransition = Transition && Transition.running;
|
|
812
809
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
813
810
|
const source = node.sources[i];
|
|
814
811
|
if (source.sources) {
|
|
815
|
-
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE)
|
|
812
|
+
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
|
|
813
|
+
if (source !== ignore) runTop(source);
|
|
814
|
+
} else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source, ignore);
|
|
816
815
|
}
|
|
817
816
|
}
|
|
818
817
|
}
|
|
@@ -1233,7 +1232,7 @@ function lazy(fn) {
|
|
|
1233
1232
|
let comp;
|
|
1234
1233
|
const wrap = props => {
|
|
1235
1234
|
const ctx = sharedConfig.context;
|
|
1236
|
-
if (ctx
|
|
1235
|
+
if (ctx) {
|
|
1237
1236
|
ctx.count++;
|
|
1238
1237
|
const [s, set] = createSignal();
|
|
1239
1238
|
fn().then(mod => {
|
|
@@ -1306,7 +1305,7 @@ function Switch(props) {
|
|
|
1306
1305
|
}
|
|
1307
1306
|
return [-1];
|
|
1308
1307
|
}, undefined, {
|
|
1309
|
-
equals: (a, b) => a
|
|
1308
|
+
equals: (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
|
|
1310
1309
|
});
|
|
1311
1310
|
return createMemo(() => {
|
|
1312
1311
|
const [index, when, cond] = evalConditions();
|
|
@@ -1319,7 +1318,11 @@ function Match(props) {
|
|
|
1319
1318
|
return props;
|
|
1320
1319
|
}
|
|
1321
1320
|
function ErrorBoundary(props) {
|
|
1322
|
-
|
|
1321
|
+
let err = undefined;
|
|
1322
|
+
if (sharedConfig.context && sharedConfig.load) {
|
|
1323
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1324
|
+
}
|
|
1325
|
+
const [errored, setErrored] = createSignal(err);
|
|
1323
1326
|
let e;
|
|
1324
1327
|
return createMemo(() => {
|
|
1325
1328
|
if ((e = errored()) != null) {
|
|
@@ -1400,7 +1403,11 @@ function SuspenseList(props) {
|
|
|
1400
1403
|
function Suspense(props) {
|
|
1401
1404
|
let counter = 0,
|
|
1402
1405
|
showContent,
|
|
1403
|
-
showFallback
|
|
1406
|
+
showFallback,
|
|
1407
|
+
ctx,
|
|
1408
|
+
waitingHydration,
|
|
1409
|
+
flicker,
|
|
1410
|
+
error;
|
|
1404
1411
|
const [inFallback, setFallback] = createSignal(false),
|
|
1405
1412
|
SuspenseContext = getSuspenseContext(),
|
|
1406
1413
|
store = {
|
|
@@ -1415,6 +1422,25 @@ function Suspense(props) {
|
|
|
1415
1422
|
resolved: false
|
|
1416
1423
|
},
|
|
1417
1424
|
owner = getOwner();
|
|
1425
|
+
if (sharedConfig.context) {
|
|
1426
|
+
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1427
|
+
const p = sharedConfig.load(key);
|
|
1428
|
+
if (p) {
|
|
1429
|
+
const [s, set] = createSignal(undefined, {
|
|
1430
|
+
equals: false
|
|
1431
|
+
});
|
|
1432
|
+
flicker = s;
|
|
1433
|
+
p.then(err => {
|
|
1434
|
+
if (error = err) return set();
|
|
1435
|
+
sharedConfig.gather(key);
|
|
1436
|
+
waitingHydration = true;
|
|
1437
|
+
setHydrateContext(ctx);
|
|
1438
|
+
set();
|
|
1439
|
+
setHydrateContext(undefined);
|
|
1440
|
+
waitingHydration = false;
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1418
1444
|
const listContext = useContext(SuspenseListContext);
|
|
1419
1445
|
if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
|
|
1420
1446
|
let dispose;
|
|
@@ -1422,28 +1448,36 @@ function Suspense(props) {
|
|
|
1422
1448
|
return createComponent(SuspenseContext.Provider, {
|
|
1423
1449
|
value: store,
|
|
1424
1450
|
get children() {
|
|
1425
|
-
const rendered = untrack(() => props.children);
|
|
1426
1451
|
return createMemo(() => {
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
store.resolved = true;
|
|
1433
|
-
resumeEffects(store.effects);
|
|
1434
|
-
return rendered;
|
|
1452
|
+
if (error) throw error;
|
|
1453
|
+
if (flicker) {
|
|
1454
|
+
ctx = sharedConfig.context;
|
|
1455
|
+
flicker();
|
|
1456
|
+
return flicker = undefined;
|
|
1435
1457
|
}
|
|
1436
|
-
|
|
1437
|
-
return
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1458
|
+
const rendered = untrack(() => props.children);
|
|
1459
|
+
return createMemo(() => {
|
|
1460
|
+
const inFallback = store.inFallback(),
|
|
1461
|
+
visibleContent = showContent ? showContent() : true,
|
|
1462
|
+
visibleFallback = showFallback ? showFallback() : true;
|
|
1463
|
+
dispose && dispose();
|
|
1464
|
+
if ((!inFallback || waitingHydration) && visibleContent) {
|
|
1465
|
+
store.resolved = true;
|
|
1466
|
+
resumeEffects(store.effects);
|
|
1467
|
+
return rendered;
|
|
1468
|
+
}
|
|
1469
|
+
if (!visibleFallback) return;
|
|
1470
|
+
return createRoot(disposer => {
|
|
1471
|
+
dispose = disposer;
|
|
1472
|
+
if (sharedConfig.context) sharedConfig.context.count = 0;
|
|
1473
|
+
return props.fallback;
|
|
1474
|
+
}, owner);
|
|
1475
|
+
});
|
|
1441
1476
|
});
|
|
1442
1477
|
}
|
|
1443
1478
|
});
|
|
1444
1479
|
}
|
|
1445
1480
|
|
|
1446
|
-
function awaitSuspense() {}
|
|
1447
1481
|
let DEV;
|
|
1448
1482
|
{
|
|
1449
1483
|
DEV = {
|
|
@@ -1457,4 +1491,4 @@ if (globalThis) {
|
|
|
1457
1491
|
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
1458
1492
|
}
|
|
1459
1493
|
|
|
1460
|
-
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch,
|
|
1494
|
+
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 };
|
package/dist/server.cjs
CHANGED
|
@@ -41,8 +41,15 @@ function createComputed(fn, value) {
|
|
|
41
41
|
owner: Owner,
|
|
42
42
|
context: null
|
|
43
43
|
};
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
try {
|
|
45
|
+
fn(value);
|
|
46
|
+
} catch (err) {
|
|
47
|
+
const fns = lookup(Owner, ERROR);
|
|
48
|
+
if (!fns) throw err;
|
|
49
|
+
fns.forEach(f => f(err));
|
|
50
|
+
} finally {
|
|
51
|
+
Owner = Owner.owner;
|
|
52
|
+
}
|
|
46
53
|
}
|
|
47
54
|
const createRenderEffect = createComputed;
|
|
48
55
|
function createEffect(fn, value) {}
|
|
@@ -51,8 +58,16 @@ function createMemo(fn, value) {
|
|
|
51
58
|
owner: Owner,
|
|
52
59
|
context: null
|
|
53
60
|
};
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
let v;
|
|
62
|
+
try {
|
|
63
|
+
v = fn(value);
|
|
64
|
+
} catch (err) {
|
|
65
|
+
const fns = lookup(Owner, ERROR);
|
|
66
|
+
if (!fns) throw err;
|
|
67
|
+
fns.forEach(f => f(err));
|
|
68
|
+
} finally {
|
|
69
|
+
Owner = Owner.owner;
|
|
70
|
+
}
|
|
56
71
|
return () => v;
|
|
57
72
|
}
|
|
58
73
|
function createDeferred(source) {
|
|
@@ -219,7 +234,7 @@ function createUniqueId() {
|
|
|
219
234
|
return `${ctx.id}${ctx.count++}`;
|
|
220
235
|
}
|
|
221
236
|
function createComponent(Comp, props) {
|
|
222
|
-
if (sharedConfig.context) {
|
|
237
|
+
if (sharedConfig.context && !sharedConfig.context.noHydrate) {
|
|
223
238
|
const c = sharedConfig.context;
|
|
224
239
|
setHydrateContext(nextHydrateContext());
|
|
225
240
|
const r = Comp(props);
|
|
@@ -290,7 +305,20 @@ function Match(props) {
|
|
|
290
305
|
return props;
|
|
291
306
|
}
|
|
292
307
|
function ErrorBoundary(props) {
|
|
293
|
-
|
|
308
|
+
let error, res;
|
|
309
|
+
const ctx = sharedConfig.context;
|
|
310
|
+
const id = ctx.id + ctx.count;
|
|
311
|
+
onError(err => error = err);
|
|
312
|
+
createMemo(() => res = props.children);
|
|
313
|
+
if (error) {
|
|
314
|
+
ctx.writeResource(id, error, true);
|
|
315
|
+
setHydrateContext({ ...ctx,
|
|
316
|
+
count: 0
|
|
317
|
+
});
|
|
318
|
+
const f = props.fallback;
|
|
319
|
+
return typeof f === "function" && f.length ? f(error, () => {}) : f;
|
|
320
|
+
}
|
|
321
|
+
return res;
|
|
294
322
|
}
|
|
295
323
|
const SuspenseContext = createContext();
|
|
296
324
|
let resourceContext = null;
|
|
@@ -310,6 +338,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
310
338
|
let resource = {};
|
|
311
339
|
let value = options.initialValue;
|
|
312
340
|
let p;
|
|
341
|
+
let error;
|
|
313
342
|
if (sharedConfig.context.async) {
|
|
314
343
|
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
315
344
|
if (resource.ref) {
|
|
@@ -318,9 +347,10 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
318
347
|
}
|
|
319
348
|
}
|
|
320
349
|
const read = () => {
|
|
350
|
+
if (error) throw error;
|
|
321
351
|
if (resourceContext && p) resourceContext.push(p);
|
|
322
352
|
const resolved = sharedConfig.context.async && sharedConfig.context.resources[id].data;
|
|
323
|
-
if (
|
|
353
|
+
if (!resolved) {
|
|
324
354
|
const ctx = useContext(SuspenseContext);
|
|
325
355
|
if (ctx) {
|
|
326
356
|
ctx.resources.set(id, read);
|
|
@@ -332,7 +362,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
332
362
|
read.loading = false;
|
|
333
363
|
function load() {
|
|
334
364
|
const ctx = sharedConfig.context;
|
|
335
|
-
if (!ctx.async
|
|
365
|
+
if (!ctx.async) return read.loading = true;
|
|
336
366
|
if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
|
|
337
367
|
value = ctx.resources[id].data;
|
|
338
368
|
return;
|
|
@@ -349,21 +379,18 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
349
379
|
}
|
|
350
380
|
read.loading = true;
|
|
351
381
|
if ("then" in p) {
|
|
352
|
-
if (ctx.writeResource)
|
|
353
|
-
ctx.writeResource(id, p);
|
|
354
|
-
p.then(v => {
|
|
355
|
-
value = v;
|
|
356
|
-
read.loading = false;
|
|
357
|
-
p = null;
|
|
358
|
-
});
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
382
|
+
if (ctx.writeResource) ctx.writeResource(id, p);
|
|
361
383
|
p.then(res => {
|
|
362
384
|
read.loading = false;
|
|
363
385
|
ctx.resources[id].data = res;
|
|
364
386
|
p = null;
|
|
365
387
|
notifySuspense(contexts);
|
|
366
388
|
return res;
|
|
389
|
+
}).catch(err => {
|
|
390
|
+
read.loading = false;
|
|
391
|
+
error = err;
|
|
392
|
+
p = null;
|
|
393
|
+
notifySuspense(contexts);
|
|
367
394
|
});
|
|
368
395
|
return;
|
|
369
396
|
}
|
|
@@ -392,7 +419,7 @@ function lazy(fn) {
|
|
|
392
419
|
ctx.resources.set(id, track);
|
|
393
420
|
contexts.add(ctx);
|
|
394
421
|
}
|
|
395
|
-
p.then(() => {
|
|
422
|
+
if (sharedConfig.context.async) p.then(() => {
|
|
396
423
|
track.loading = false;
|
|
397
424
|
notifySuspense(contexts);
|
|
398
425
|
});
|
|
@@ -425,19 +452,15 @@ function useTransition() {
|
|
|
425
452
|
function SuspenseList(props) {
|
|
426
453
|
return props.children;
|
|
427
454
|
}
|
|
428
|
-
const SUSPENSE_GLOBAL = Symbol("suspense-global");
|
|
429
455
|
function Suspense(props) {
|
|
456
|
+
let done;
|
|
430
457
|
const ctx = sharedConfig.context;
|
|
431
|
-
if (!ctx.async) return createComponent(() => {
|
|
432
|
-
props.children;
|
|
433
|
-
return props.fallback;
|
|
434
|
-
}, {});
|
|
435
458
|
const id = ctx.id + ctx.count;
|
|
436
|
-
const done = ctx.async ? lookup(Owner, SUSPENSE_GLOBAL)(id) : () => {};
|
|
437
459
|
const o = Owner;
|
|
438
460
|
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
439
461
|
resources: new Map(),
|
|
440
462
|
completed: () => {
|
|
463
|
+
if (ctx.dataOnly) return done();
|
|
441
464
|
const res = runSuspense();
|
|
442
465
|
if (suspenseComplete(value)) {
|
|
443
466
|
done(resolveSSRNode(res));
|
|
@@ -458,44 +481,29 @@ function Suspense(props) {
|
|
|
458
481
|
});
|
|
459
482
|
}
|
|
460
483
|
const res = runSuspense();
|
|
461
|
-
if (suspenseComplete(value))
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
const
|
|
470
|
-
|
|
471
|
-
return new Promise(resolve => {
|
|
472
|
-
const registry = new Set();
|
|
473
|
-
const cache = Object.create(null);
|
|
474
|
-
const res = createMemo(() => {
|
|
475
|
-
Owner.context = {
|
|
476
|
-
[SUSPENSE_GLOBAL]: getCallback
|
|
477
|
-
};
|
|
478
|
-
return fn();
|
|
479
|
-
});
|
|
480
|
-
if (!registry.size) resolve(res());
|
|
481
|
-
function getCallback(key) {
|
|
482
|
-
registry.add(key);
|
|
483
|
-
return value => {
|
|
484
|
-
if (value) cache[key] = value;
|
|
485
|
-
registry.delete(key);
|
|
486
|
-
if (!registry.size) Promise.resolve().then(() => {
|
|
487
|
-
let source = resolveSSRNode(res());
|
|
488
|
-
let final = "";
|
|
489
|
-
let match;
|
|
490
|
-
while (match = source.match(SUSPENSE_REPLACE)) {
|
|
491
|
-
final += source.substring(0, match.index);
|
|
492
|
-
source = cache[match[1]] + source.substring(match.index + match[0].length);
|
|
493
|
-
}
|
|
494
|
-
resolve(final + source);
|
|
495
|
-
});
|
|
484
|
+
if (suspenseComplete(value)) return res;
|
|
485
|
+
onError(err => {
|
|
486
|
+
if (!done || !done(undefined, err)) throw err;
|
|
487
|
+
});
|
|
488
|
+
done = ctx.async ? ctx.registerFragment(id) : undefined;
|
|
489
|
+
if (ctx.streaming) {
|
|
490
|
+
if (!ctx.dataOnly) {
|
|
491
|
+
setHydrateContext(undefined);
|
|
492
|
+
const res = {
|
|
493
|
+
t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
|
|
496
494
|
};
|
|
495
|
+
setHydrateContext(ctx);
|
|
496
|
+
return res;
|
|
497
497
|
}
|
|
498
|
+
} else if (ctx.async) {
|
|
499
|
+
return {
|
|
500
|
+
t: `<![${id}]>`
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
setHydrateContext({ ...ctx,
|
|
504
|
+
count: 0
|
|
498
505
|
});
|
|
506
|
+
return createComponent(() => props.fallback, {});
|
|
499
507
|
}
|
|
500
508
|
|
|
501
509
|
exports.$PROXY = $PROXY;
|
|
@@ -508,7 +516,6 @@ exports.Show = Show;
|
|
|
508
516
|
exports.Suspense = Suspense;
|
|
509
517
|
exports.SuspenseList = SuspenseList;
|
|
510
518
|
exports.Switch = Switch;
|
|
511
|
-
exports.awaitSuspense = awaitSuspense;
|
|
512
519
|
exports.batch = batch;
|
|
513
520
|
exports.children = children;
|
|
514
521
|
exports.createComponent = createComponent;
|