solid-js 1.3.0-beta.0 → 1.3.0-beta.4
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 +67 -17
- package/dist/dev.js +66 -18
- package/dist/server.cjs +53 -13
- package/dist/server.js +53 -14
- package/dist/solid.cjs +67 -17
- package/dist/solid.js +66 -18
- package/package.json +15 -15
- package/types/index.d.ts +1 -1
- package/types/reactive/signal.d.ts +7 -0
- 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 +12 -15
- package/web/dist/dev.js +13 -15
- package/web/dist/server.cjs +139 -162
- package/web/dist/server.js +139 -162
- package/web/dist/web.cjs +12 -15
- package/web/dist/web.js +13 -15
- package/web/types/client.d.ts +11 -2
- package/web/types/index.d.ts +2 -0
- package/web/types/server-mock.d.ts +36 -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;
|
|
@@ -354,7 +355,7 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
354
355
|
const subs = new Map();
|
|
355
356
|
const node = createComputation(p => {
|
|
356
357
|
const v = source();
|
|
357
|
-
for (const key of subs.keys()) if (fn(key, v)
|
|
358
|
+
for (const key of subs.keys()) if (fn(key, v) !== (p !== undefined && fn(key, p))) {
|
|
358
359
|
const l = subs.get(key);
|
|
359
360
|
for (const c of l.values()) {
|
|
360
361
|
c.state = STALE;
|
|
@@ -554,6 +555,24 @@ let SuspenseContext;
|
|
|
554
555
|
function getSuspenseContext() {
|
|
555
556
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
556
557
|
}
|
|
558
|
+
function enableExternalSource(factory) {
|
|
559
|
+
if (ExternalSourceFactory) {
|
|
560
|
+
const oldFactory = ExternalSourceFactory;
|
|
561
|
+
ExternalSourceFactory = (fn, trigger) => {
|
|
562
|
+
const oldSource = oldFactory(fn, trigger);
|
|
563
|
+
const source = factory(x => oldSource.track(x), trigger);
|
|
564
|
+
return {
|
|
565
|
+
track: x => source.track(x),
|
|
566
|
+
dispose() {
|
|
567
|
+
source.dispose();
|
|
568
|
+
oldSource.dispose();
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
};
|
|
572
|
+
} else {
|
|
573
|
+
ExternalSourceFactory = factory;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
557
576
|
function readSignal() {
|
|
558
577
|
const runningTransition = Transition && Transition.running;
|
|
559
578
|
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
@@ -682,6 +701,19 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
682
701
|
}
|
|
683
702
|
c.name = options && options.name || `${Owner.name || "c"}-${(Owner.owned || Owner.tOwned).length}`;
|
|
684
703
|
}
|
|
704
|
+
if (ExternalSourceFactory) {
|
|
705
|
+
const [track, trigger] = createSignal(undefined, {
|
|
706
|
+
equals: false
|
|
707
|
+
});
|
|
708
|
+
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
709
|
+
onCleanup(() => ordinary.dispose());
|
|
710
|
+
const triggerInTransition = () => startTransition(trigger, () => inTransition.dispose());
|
|
711
|
+
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
712
|
+
c.fn = x => {
|
|
713
|
+
track();
|
|
714
|
+
return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
|
|
715
|
+
};
|
|
716
|
+
}
|
|
685
717
|
return c;
|
|
686
718
|
}
|
|
687
719
|
function runTop(node) {
|
|
@@ -708,7 +740,7 @@ function runTop(node) {
|
|
|
708
740
|
} else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
709
741
|
const updates = Updates;
|
|
710
742
|
Updates = null;
|
|
711
|
-
lookDownstream(node);
|
|
743
|
+
lookDownstream(node, ancestors[0]);
|
|
712
744
|
Updates = updates;
|
|
713
745
|
}
|
|
714
746
|
}
|
|
@@ -807,13 +839,15 @@ function runUserEffects(queue) {
|
|
|
807
839
|
for (i = 0; i < userLength; i++) runTop(queue[i]);
|
|
808
840
|
for (i = resume; i < queue.length; i++) runTop(queue[i]);
|
|
809
841
|
}
|
|
810
|
-
function lookDownstream(node) {
|
|
842
|
+
function lookDownstream(node, ignore) {
|
|
811
843
|
node.state = 0;
|
|
812
844
|
const runningTransition = Transition && Transition.running;
|
|
813
845
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
814
846
|
const source = node.sources[i];
|
|
815
847
|
if (source.sources) {
|
|
816
|
-
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE)
|
|
848
|
+
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
|
|
849
|
+
if (source !== ignore) runTop(source);
|
|
850
|
+
} else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source, ignore);
|
|
817
851
|
}
|
|
818
852
|
}
|
|
819
853
|
}
|
|
@@ -1137,13 +1171,19 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1137
1171
|
};
|
|
1138
1172
|
}
|
|
1139
1173
|
|
|
1174
|
+
let hydrationEnabled = false;
|
|
1175
|
+
function enableHydration() {
|
|
1176
|
+
hydrationEnabled = true;
|
|
1177
|
+
}
|
|
1140
1178
|
function createComponent(Comp, props) {
|
|
1141
|
-
if (
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1179
|
+
if (hydrationEnabled) {
|
|
1180
|
+
if (sharedConfig.context) {
|
|
1181
|
+
const c = sharedConfig.context;
|
|
1182
|
+
setHydrateContext(nextHydrateContext());
|
|
1183
|
+
const r = devComponent(Comp, props) ;
|
|
1184
|
+
setHydrateContext(c);
|
|
1185
|
+
return r;
|
|
1186
|
+
}
|
|
1147
1187
|
}
|
|
1148
1188
|
return devComponent(Comp, props);
|
|
1149
1189
|
}
|
|
@@ -1232,19 +1272,20 @@ function splitProps(props, ...keys) {
|
|
|
1232
1272
|
}
|
|
1233
1273
|
function lazy(fn) {
|
|
1234
1274
|
let comp;
|
|
1275
|
+
let p;
|
|
1235
1276
|
const wrap = props => {
|
|
1236
1277
|
const ctx = sharedConfig.context;
|
|
1237
1278
|
if (ctx) {
|
|
1238
1279
|
ctx.count++;
|
|
1239
1280
|
const [s, set] = createSignal();
|
|
1240
|
-
fn().then(mod => {
|
|
1281
|
+
(p || (p = fn())).then(mod => {
|
|
1241
1282
|
setHydrateContext(ctx);
|
|
1242
1283
|
set(() => mod.default);
|
|
1243
1284
|
setHydrateContext(undefined);
|
|
1244
1285
|
});
|
|
1245
1286
|
comp = s;
|
|
1246
1287
|
} else if (!comp) {
|
|
1247
|
-
const [s] = createResource(() => fn().then(mod => mod.default));
|
|
1288
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1248
1289
|
comp = s;
|
|
1249
1290
|
} else {
|
|
1250
1291
|
const c = comp();
|
|
@@ -1260,7 +1301,7 @@ function lazy(fn) {
|
|
|
1260
1301
|
return r;
|
|
1261
1302
|
}));
|
|
1262
1303
|
};
|
|
1263
|
-
wrap.preload = () =>
|
|
1304
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1264
1305
|
return wrap;
|
|
1265
1306
|
}
|
|
1266
1307
|
let counter = 0;
|
|
@@ -1320,7 +1361,11 @@ function Match(props) {
|
|
|
1320
1361
|
return props;
|
|
1321
1362
|
}
|
|
1322
1363
|
function ErrorBoundary(props) {
|
|
1323
|
-
|
|
1364
|
+
let err = undefined;
|
|
1365
|
+
if (sharedConfig.context && sharedConfig.load) {
|
|
1366
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1367
|
+
}
|
|
1368
|
+
const [errored, setErrored] = createSignal(err);
|
|
1324
1369
|
let e;
|
|
1325
1370
|
return createMemo(() => {
|
|
1326
1371
|
if ((e = errored()) != null) {
|
|
@@ -1404,7 +1449,8 @@ function Suspense(props) {
|
|
|
1404
1449
|
showFallback,
|
|
1405
1450
|
ctx,
|
|
1406
1451
|
waitingHydration,
|
|
1407
|
-
flicker
|
|
1452
|
+
flicker,
|
|
1453
|
+
error;
|
|
1408
1454
|
const [inFallback, setFallback] = createSignal(false),
|
|
1409
1455
|
SuspenseContext = getSuspenseContext(),
|
|
1410
1456
|
store = {
|
|
@@ -1419,7 +1465,7 @@ function Suspense(props) {
|
|
|
1419
1465
|
resolved: false
|
|
1420
1466
|
},
|
|
1421
1467
|
owner = getOwner();
|
|
1422
|
-
if (sharedConfig.context
|
|
1468
|
+
if (sharedConfig.context) {
|
|
1423
1469
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1424
1470
|
const p = sharedConfig.load(key);
|
|
1425
1471
|
if (p) {
|
|
@@ -1427,7 +1473,8 @@ function Suspense(props) {
|
|
|
1427
1473
|
equals: false
|
|
1428
1474
|
});
|
|
1429
1475
|
flicker = s;
|
|
1430
|
-
p.then(
|
|
1476
|
+
p.then(err => {
|
|
1477
|
+
if (error = err) return set();
|
|
1431
1478
|
sharedConfig.gather(key);
|
|
1432
1479
|
waitingHydration = true;
|
|
1433
1480
|
setHydrateContext(ctx);
|
|
@@ -1445,6 +1492,7 @@ function Suspense(props) {
|
|
|
1445
1492
|
value: store,
|
|
1446
1493
|
get children() {
|
|
1447
1494
|
return createMemo(() => {
|
|
1495
|
+
if (error) throw error;
|
|
1448
1496
|
if (flicker) {
|
|
1449
1497
|
ctx = sharedConfig.context;
|
|
1450
1498
|
flicker();
|
|
@@ -1510,6 +1558,8 @@ exports.createRoot = createRoot;
|
|
|
1510
1558
|
exports.createSelector = createSelector;
|
|
1511
1559
|
exports.createSignal = createSignal;
|
|
1512
1560
|
exports.createUniqueId = createUniqueId;
|
|
1561
|
+
exports.enableExternalSource = enableExternalSource;
|
|
1562
|
+
exports.enableHydration = enableHydration;
|
|
1513
1563
|
exports.enableScheduling = enableScheduling;
|
|
1514
1564
|
exports.equalFn = equalFn;
|
|
1515
1565
|
exports.from = from;
|
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;
|
|
@@ -350,7 +351,7 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
350
351
|
const subs = new Map();
|
|
351
352
|
const node = createComputation(p => {
|
|
352
353
|
const v = source();
|
|
353
|
-
for (const key of subs.keys()) if (fn(key, v)
|
|
354
|
+
for (const key of subs.keys()) if (fn(key, v) !== (p !== undefined && fn(key, p))) {
|
|
354
355
|
const l = subs.get(key);
|
|
355
356
|
for (const c of l.values()) {
|
|
356
357
|
c.state = STALE;
|
|
@@ -550,6 +551,24 @@ let SuspenseContext;
|
|
|
550
551
|
function getSuspenseContext() {
|
|
551
552
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
552
553
|
}
|
|
554
|
+
function enableExternalSource(factory) {
|
|
555
|
+
if (ExternalSourceFactory) {
|
|
556
|
+
const oldFactory = ExternalSourceFactory;
|
|
557
|
+
ExternalSourceFactory = (fn, trigger) => {
|
|
558
|
+
const oldSource = oldFactory(fn, trigger);
|
|
559
|
+
const source = factory(x => oldSource.track(x), trigger);
|
|
560
|
+
return {
|
|
561
|
+
track: x => source.track(x),
|
|
562
|
+
dispose() {
|
|
563
|
+
source.dispose();
|
|
564
|
+
oldSource.dispose();
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
};
|
|
568
|
+
} else {
|
|
569
|
+
ExternalSourceFactory = factory;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
553
572
|
function readSignal() {
|
|
554
573
|
const runningTransition = Transition && Transition.running;
|
|
555
574
|
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
@@ -678,6 +697,19 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
678
697
|
}
|
|
679
698
|
c.name = options && options.name || `${Owner.name || "c"}-${(Owner.owned || Owner.tOwned).length}`;
|
|
680
699
|
}
|
|
700
|
+
if (ExternalSourceFactory) {
|
|
701
|
+
const [track, trigger] = createSignal(undefined, {
|
|
702
|
+
equals: false
|
|
703
|
+
});
|
|
704
|
+
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
705
|
+
onCleanup(() => ordinary.dispose());
|
|
706
|
+
const triggerInTransition = () => startTransition(trigger, () => inTransition.dispose());
|
|
707
|
+
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
708
|
+
c.fn = x => {
|
|
709
|
+
track();
|
|
710
|
+
return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
|
|
711
|
+
};
|
|
712
|
+
}
|
|
681
713
|
return c;
|
|
682
714
|
}
|
|
683
715
|
function runTop(node) {
|
|
@@ -704,7 +736,7 @@ function runTop(node) {
|
|
|
704
736
|
} else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
705
737
|
const updates = Updates;
|
|
706
738
|
Updates = null;
|
|
707
|
-
lookDownstream(node);
|
|
739
|
+
lookDownstream(node, ancestors[0]);
|
|
708
740
|
Updates = updates;
|
|
709
741
|
}
|
|
710
742
|
}
|
|
@@ -803,13 +835,15 @@ function runUserEffects(queue) {
|
|
|
803
835
|
for (i = 0; i < userLength; i++) runTop(queue[i]);
|
|
804
836
|
for (i = resume; i < queue.length; i++) runTop(queue[i]);
|
|
805
837
|
}
|
|
806
|
-
function lookDownstream(node) {
|
|
838
|
+
function lookDownstream(node, ignore) {
|
|
807
839
|
node.state = 0;
|
|
808
840
|
const runningTransition = Transition && Transition.running;
|
|
809
841
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
810
842
|
const source = node.sources[i];
|
|
811
843
|
if (source.sources) {
|
|
812
|
-
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE)
|
|
844
|
+
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
|
|
845
|
+
if (source !== ignore) runTop(source);
|
|
846
|
+
} else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source, ignore);
|
|
813
847
|
}
|
|
814
848
|
}
|
|
815
849
|
}
|
|
@@ -1133,13 +1167,19 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1133
1167
|
};
|
|
1134
1168
|
}
|
|
1135
1169
|
|
|
1170
|
+
let hydrationEnabled = false;
|
|
1171
|
+
function enableHydration() {
|
|
1172
|
+
hydrationEnabled = true;
|
|
1173
|
+
}
|
|
1136
1174
|
function createComponent(Comp, props) {
|
|
1137
|
-
if (
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1175
|
+
if (hydrationEnabled) {
|
|
1176
|
+
if (sharedConfig.context) {
|
|
1177
|
+
const c = sharedConfig.context;
|
|
1178
|
+
setHydrateContext(nextHydrateContext());
|
|
1179
|
+
const r = devComponent(Comp, props) ;
|
|
1180
|
+
setHydrateContext(c);
|
|
1181
|
+
return r;
|
|
1182
|
+
}
|
|
1143
1183
|
}
|
|
1144
1184
|
return devComponent(Comp, props);
|
|
1145
1185
|
}
|
|
@@ -1228,19 +1268,20 @@ function splitProps(props, ...keys) {
|
|
|
1228
1268
|
}
|
|
1229
1269
|
function lazy(fn) {
|
|
1230
1270
|
let comp;
|
|
1271
|
+
let p;
|
|
1231
1272
|
const wrap = props => {
|
|
1232
1273
|
const ctx = sharedConfig.context;
|
|
1233
1274
|
if (ctx) {
|
|
1234
1275
|
ctx.count++;
|
|
1235
1276
|
const [s, set] = createSignal();
|
|
1236
|
-
fn().then(mod => {
|
|
1277
|
+
(p || (p = fn())).then(mod => {
|
|
1237
1278
|
setHydrateContext(ctx);
|
|
1238
1279
|
set(() => mod.default);
|
|
1239
1280
|
setHydrateContext(undefined);
|
|
1240
1281
|
});
|
|
1241
1282
|
comp = s;
|
|
1242
1283
|
} else if (!comp) {
|
|
1243
|
-
const [s] = createResource(() => fn().then(mod => mod.default));
|
|
1284
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1244
1285
|
comp = s;
|
|
1245
1286
|
} else {
|
|
1246
1287
|
const c = comp();
|
|
@@ -1256,7 +1297,7 @@ function lazy(fn) {
|
|
|
1256
1297
|
return r;
|
|
1257
1298
|
}));
|
|
1258
1299
|
};
|
|
1259
|
-
wrap.preload = () =>
|
|
1300
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1260
1301
|
return wrap;
|
|
1261
1302
|
}
|
|
1262
1303
|
let counter = 0;
|
|
@@ -1316,7 +1357,11 @@ function Match(props) {
|
|
|
1316
1357
|
return props;
|
|
1317
1358
|
}
|
|
1318
1359
|
function ErrorBoundary(props) {
|
|
1319
|
-
|
|
1360
|
+
let err = undefined;
|
|
1361
|
+
if (sharedConfig.context && sharedConfig.load) {
|
|
1362
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1363
|
+
}
|
|
1364
|
+
const [errored, setErrored] = createSignal(err);
|
|
1320
1365
|
let e;
|
|
1321
1366
|
return createMemo(() => {
|
|
1322
1367
|
if ((e = errored()) != null) {
|
|
@@ -1400,7 +1445,8 @@ function Suspense(props) {
|
|
|
1400
1445
|
showFallback,
|
|
1401
1446
|
ctx,
|
|
1402
1447
|
waitingHydration,
|
|
1403
|
-
flicker
|
|
1448
|
+
flicker,
|
|
1449
|
+
error;
|
|
1404
1450
|
const [inFallback, setFallback] = createSignal(false),
|
|
1405
1451
|
SuspenseContext = getSuspenseContext(),
|
|
1406
1452
|
store = {
|
|
@@ -1415,7 +1461,7 @@ function Suspense(props) {
|
|
|
1415
1461
|
resolved: false
|
|
1416
1462
|
},
|
|
1417
1463
|
owner = getOwner();
|
|
1418
|
-
if (sharedConfig.context
|
|
1464
|
+
if (sharedConfig.context) {
|
|
1419
1465
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1420
1466
|
const p = sharedConfig.load(key);
|
|
1421
1467
|
if (p) {
|
|
@@ -1423,7 +1469,8 @@ function Suspense(props) {
|
|
|
1423
1469
|
equals: false
|
|
1424
1470
|
});
|
|
1425
1471
|
flicker = s;
|
|
1426
|
-
p.then(
|
|
1472
|
+
p.then(err => {
|
|
1473
|
+
if (error = err) return set();
|
|
1427
1474
|
sharedConfig.gather(key);
|
|
1428
1475
|
waitingHydration = true;
|
|
1429
1476
|
setHydrateContext(ctx);
|
|
@@ -1441,6 +1488,7 @@ function Suspense(props) {
|
|
|
1441
1488
|
value: store,
|
|
1442
1489
|
get children() {
|
|
1443
1490
|
return createMemo(() => {
|
|
1491
|
+
if (error) throw error;
|
|
1444
1492
|
if (flicker) {
|
|
1445
1493
|
ctx = sharedConfig.context;
|
|
1446
1494
|
flicker();
|
|
@@ -1482,4 +1530,4 @@ if (globalThis) {
|
|
|
1482
1530
|
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
1483
1531
|
}
|
|
1484
1532
|
|
|
1485
|
-
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 };
|
|
1533
|
+
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, 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) {
|
|
@@ -193,6 +208,7 @@ function from(producer) {
|
|
|
193
208
|
}
|
|
194
209
|
return s;
|
|
195
210
|
}
|
|
211
|
+
function enableExternalSource(factory) {}
|
|
196
212
|
|
|
197
213
|
function resolveSSRNode(node) {
|
|
198
214
|
const t = typeof node;
|
|
@@ -290,7 +306,20 @@ function Match(props) {
|
|
|
290
306
|
return props;
|
|
291
307
|
}
|
|
292
308
|
function ErrorBoundary(props) {
|
|
293
|
-
|
|
309
|
+
let error, res;
|
|
310
|
+
const ctx = sharedConfig.context;
|
|
311
|
+
const id = ctx.id + ctx.count;
|
|
312
|
+
onError(err => error = err);
|
|
313
|
+
createMemo(() => res = props.children);
|
|
314
|
+
if (error) {
|
|
315
|
+
ctx.writeResource(id, error, true);
|
|
316
|
+
setHydrateContext({ ...ctx,
|
|
317
|
+
count: 0
|
|
318
|
+
});
|
|
319
|
+
const f = props.fallback;
|
|
320
|
+
return typeof f === "function" && f.length ? f(error, () => {}) : f;
|
|
321
|
+
}
|
|
322
|
+
return res;
|
|
294
323
|
}
|
|
295
324
|
const SuspenseContext = createContext();
|
|
296
325
|
let resourceContext = null;
|
|
@@ -310,6 +339,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
310
339
|
let resource = {};
|
|
311
340
|
let value = options.initialValue;
|
|
312
341
|
let p;
|
|
342
|
+
let error;
|
|
313
343
|
if (sharedConfig.context.async) {
|
|
314
344
|
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
315
345
|
if (resource.ref) {
|
|
@@ -318,6 +348,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
318
348
|
}
|
|
319
349
|
}
|
|
320
350
|
const read = () => {
|
|
351
|
+
if (error) throw error;
|
|
321
352
|
if (resourceContext && p) resourceContext.push(p);
|
|
322
353
|
const resolved = sharedConfig.context.async && sharedConfig.context.resources[id].data;
|
|
323
354
|
if (!resolved) {
|
|
@@ -356,6 +387,11 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
356
387
|
p = null;
|
|
357
388
|
notifySuspense(contexts);
|
|
358
389
|
return res;
|
|
390
|
+
}).catch(err => {
|
|
391
|
+
read.loading = false;
|
|
392
|
+
error = err;
|
|
393
|
+
p = null;
|
|
394
|
+
notifySuspense(contexts);
|
|
359
395
|
});
|
|
360
396
|
return;
|
|
361
397
|
}
|
|
@@ -390,7 +426,7 @@ function lazy(fn) {
|
|
|
390
426
|
});
|
|
391
427
|
return "";
|
|
392
428
|
};
|
|
393
|
-
wrap.preload = () =>
|
|
429
|
+
wrap.preload = () => p;
|
|
394
430
|
return wrap;
|
|
395
431
|
}
|
|
396
432
|
function suspenseComplete(c) {
|
|
@@ -418,13 +454,14 @@ function SuspenseList(props) {
|
|
|
418
454
|
return props.children;
|
|
419
455
|
}
|
|
420
456
|
function Suspense(props) {
|
|
457
|
+
let done;
|
|
421
458
|
const ctx = sharedConfig.context;
|
|
422
459
|
const id = ctx.id + ctx.count;
|
|
423
|
-
const done = ctx.async ? ctx.registerFragment(id) : () => {};
|
|
424
460
|
const o = Owner;
|
|
425
461
|
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
426
462
|
resources: new Map(),
|
|
427
463
|
completed: () => {
|
|
464
|
+
if (ctx.dataOnly) return done();
|
|
428
465
|
const res = runSuspense();
|
|
429
466
|
if (suspenseComplete(value)) {
|
|
430
467
|
done(resolveSSRNode(res));
|
|
@@ -445,12 +482,13 @@ function Suspense(props) {
|
|
|
445
482
|
});
|
|
446
483
|
}
|
|
447
484
|
const res = runSuspense();
|
|
448
|
-
if (suspenseComplete(value))
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
|
|
485
|
+
if (suspenseComplete(value)) return res;
|
|
486
|
+
onError(err => {
|
|
487
|
+
if (!done || !done(undefined, err)) throw err;
|
|
488
|
+
});
|
|
489
|
+
done = ctx.async ? ctx.registerFragment(id) : undefined;
|
|
490
|
+
if (ctx.streaming) {
|
|
491
|
+
if (!ctx.dataOnly) {
|
|
454
492
|
setHydrateContext(undefined);
|
|
455
493
|
const res = {
|
|
456
494
|
t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
|
|
@@ -458,6 +496,7 @@ function Suspense(props) {
|
|
|
458
496
|
setHydrateContext(ctx);
|
|
459
497
|
return res;
|
|
460
498
|
}
|
|
499
|
+
} else if (ctx.async) {
|
|
461
500
|
return {
|
|
462
501
|
t: `<![${id}]>`
|
|
463
502
|
};
|
|
@@ -492,6 +531,7 @@ exports.createRoot = createRoot;
|
|
|
492
531
|
exports.createSelector = createSelector;
|
|
493
532
|
exports.createSignal = createSignal;
|
|
494
533
|
exports.createUniqueId = createUniqueId;
|
|
534
|
+
exports.enableExternalSource = enableExternalSource;
|
|
495
535
|
exports.enableScheduling = enableScheduling;
|
|
496
536
|
exports.equalFn = equalFn;
|
|
497
537
|
exports.from = from;
|