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/dist/server.js
CHANGED
|
@@ -37,8 +37,15 @@ function createComputed(fn, value) {
|
|
|
37
37
|
owner: Owner,
|
|
38
38
|
context: null
|
|
39
39
|
};
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
try {
|
|
41
|
+
fn(value);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
const fns = lookup(Owner, ERROR);
|
|
44
|
+
if (!fns) throw err;
|
|
45
|
+
fns.forEach(f => f(err));
|
|
46
|
+
} finally {
|
|
47
|
+
Owner = Owner.owner;
|
|
48
|
+
}
|
|
42
49
|
}
|
|
43
50
|
const createRenderEffect = createComputed;
|
|
44
51
|
function createEffect(fn, value) {}
|
|
@@ -47,8 +54,16 @@ function createMemo(fn, value) {
|
|
|
47
54
|
owner: Owner,
|
|
48
55
|
context: null
|
|
49
56
|
};
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
let v;
|
|
58
|
+
try {
|
|
59
|
+
v = fn(value);
|
|
60
|
+
} catch (err) {
|
|
61
|
+
const fns = lookup(Owner, ERROR);
|
|
62
|
+
if (!fns) throw err;
|
|
63
|
+
fns.forEach(f => f(err));
|
|
64
|
+
} finally {
|
|
65
|
+
Owner = Owner.owner;
|
|
66
|
+
}
|
|
52
67
|
return () => v;
|
|
53
68
|
}
|
|
54
69
|
function createDeferred(source) {
|
|
@@ -189,6 +204,7 @@ function from(producer) {
|
|
|
189
204
|
}
|
|
190
205
|
return s;
|
|
191
206
|
}
|
|
207
|
+
function enableExternalSource(factory) {}
|
|
192
208
|
|
|
193
209
|
function resolveSSRNode(node) {
|
|
194
210
|
const t = typeof node;
|
|
@@ -286,7 +302,20 @@ function Match(props) {
|
|
|
286
302
|
return props;
|
|
287
303
|
}
|
|
288
304
|
function ErrorBoundary(props) {
|
|
289
|
-
|
|
305
|
+
let error, res;
|
|
306
|
+
const ctx = sharedConfig.context;
|
|
307
|
+
const id = ctx.id + ctx.count;
|
|
308
|
+
onError(err => error = err);
|
|
309
|
+
createMemo(() => res = props.children);
|
|
310
|
+
if (error) {
|
|
311
|
+
ctx.writeResource(id, error, true);
|
|
312
|
+
setHydrateContext({ ...ctx,
|
|
313
|
+
count: 0
|
|
314
|
+
});
|
|
315
|
+
const f = props.fallback;
|
|
316
|
+
return typeof f === "function" && f.length ? f(error, () => {}) : f;
|
|
317
|
+
}
|
|
318
|
+
return res;
|
|
290
319
|
}
|
|
291
320
|
const SuspenseContext = createContext();
|
|
292
321
|
let resourceContext = null;
|
|
@@ -306,6 +335,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
306
335
|
let resource = {};
|
|
307
336
|
let value = options.initialValue;
|
|
308
337
|
let p;
|
|
338
|
+
let error;
|
|
309
339
|
if (sharedConfig.context.async) {
|
|
310
340
|
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
311
341
|
if (resource.ref) {
|
|
@@ -314,6 +344,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
314
344
|
}
|
|
315
345
|
}
|
|
316
346
|
const read = () => {
|
|
347
|
+
if (error) throw error;
|
|
317
348
|
if (resourceContext && p) resourceContext.push(p);
|
|
318
349
|
const resolved = sharedConfig.context.async && sharedConfig.context.resources[id].data;
|
|
319
350
|
if (!resolved) {
|
|
@@ -352,6 +383,11 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
352
383
|
p = null;
|
|
353
384
|
notifySuspense(contexts);
|
|
354
385
|
return res;
|
|
386
|
+
}).catch(err => {
|
|
387
|
+
read.loading = false;
|
|
388
|
+
error = err;
|
|
389
|
+
p = null;
|
|
390
|
+
notifySuspense(contexts);
|
|
355
391
|
});
|
|
356
392
|
return;
|
|
357
393
|
}
|
|
@@ -386,7 +422,7 @@ function lazy(fn) {
|
|
|
386
422
|
});
|
|
387
423
|
return "";
|
|
388
424
|
};
|
|
389
|
-
wrap.preload = () =>
|
|
425
|
+
wrap.preload = () => p;
|
|
390
426
|
return wrap;
|
|
391
427
|
}
|
|
392
428
|
function suspenseComplete(c) {
|
|
@@ -414,13 +450,14 @@ function SuspenseList(props) {
|
|
|
414
450
|
return props.children;
|
|
415
451
|
}
|
|
416
452
|
function Suspense(props) {
|
|
453
|
+
let done;
|
|
417
454
|
const ctx = sharedConfig.context;
|
|
418
455
|
const id = ctx.id + ctx.count;
|
|
419
|
-
const done = ctx.async ? ctx.registerFragment(id) : () => {};
|
|
420
456
|
const o = Owner;
|
|
421
457
|
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
422
458
|
resources: new Map(),
|
|
423
459
|
completed: () => {
|
|
460
|
+
if (ctx.dataOnly) return done();
|
|
424
461
|
const res = runSuspense();
|
|
425
462
|
if (suspenseComplete(value)) {
|
|
426
463
|
done(resolveSSRNode(res));
|
|
@@ -441,12 +478,13 @@ function Suspense(props) {
|
|
|
441
478
|
});
|
|
442
479
|
}
|
|
443
480
|
const res = runSuspense();
|
|
444
|
-
if (suspenseComplete(value))
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
|
|
481
|
+
if (suspenseComplete(value)) return res;
|
|
482
|
+
onError(err => {
|
|
483
|
+
if (!done || !done(undefined, err)) throw err;
|
|
484
|
+
});
|
|
485
|
+
done = ctx.async ? ctx.registerFragment(id) : undefined;
|
|
486
|
+
if (ctx.streaming) {
|
|
487
|
+
if (!ctx.dataOnly) {
|
|
450
488
|
setHydrateContext(undefined);
|
|
451
489
|
const res = {
|
|
452
490
|
t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
|
|
@@ -454,6 +492,7 @@ function Suspense(props) {
|
|
|
454
492
|
setHydrateContext(ctx);
|
|
455
493
|
return res;
|
|
456
494
|
}
|
|
495
|
+
} else if (ctx.async) {
|
|
457
496
|
return {
|
|
458
497
|
t: `<![${id}]>`
|
|
459
498
|
};
|
|
@@ -464,4 +503,4 @@ function Suspense(props) {
|
|
|
464
503
|
return createComponent(() => props.fallback, {});
|
|
465
504
|
}
|
|
466
505
|
|
|
467
|
-
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
|
506
|
+
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
package/dist/solid.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;
|
|
@@ -351,7 +352,7 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
351
352
|
const subs = new Map();
|
|
352
353
|
const node = createComputation(p => {
|
|
353
354
|
const v = source();
|
|
354
|
-
for (const key of subs.keys()) if (fn(key, v)
|
|
355
|
+
for (const key of subs.keys()) if (fn(key, v) !== (p !== undefined && fn(key, p))) {
|
|
355
356
|
const l = subs.get(key);
|
|
356
357
|
for (const c of l.values()) {
|
|
357
358
|
c.state = STALE;
|
|
@@ -503,6 +504,24 @@ let SuspenseContext;
|
|
|
503
504
|
function getSuspenseContext() {
|
|
504
505
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
505
506
|
}
|
|
507
|
+
function enableExternalSource(factory) {
|
|
508
|
+
if (ExternalSourceFactory) {
|
|
509
|
+
const oldFactory = ExternalSourceFactory;
|
|
510
|
+
ExternalSourceFactory = (fn, trigger) => {
|
|
511
|
+
const oldSource = oldFactory(fn, trigger);
|
|
512
|
+
const source = factory(x => oldSource.track(x), trigger);
|
|
513
|
+
return {
|
|
514
|
+
track: x => source.track(x),
|
|
515
|
+
dispose() {
|
|
516
|
+
source.dispose();
|
|
517
|
+
oldSource.dispose();
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
};
|
|
521
|
+
} else {
|
|
522
|
+
ExternalSourceFactory = factory;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
506
525
|
function readSignal() {
|
|
507
526
|
const runningTransition = Transition && Transition.running;
|
|
508
527
|
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
@@ -630,6 +649,19 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
630
649
|
if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
|
|
631
650
|
}
|
|
632
651
|
}
|
|
652
|
+
if (ExternalSourceFactory) {
|
|
653
|
+
const [track, trigger] = createSignal(undefined, {
|
|
654
|
+
equals: false
|
|
655
|
+
});
|
|
656
|
+
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
657
|
+
onCleanup(() => ordinary.dispose());
|
|
658
|
+
const triggerInTransition = () => startTransition(trigger, () => inTransition.dispose());
|
|
659
|
+
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
660
|
+
c.fn = x => {
|
|
661
|
+
track();
|
|
662
|
+
return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
|
|
663
|
+
};
|
|
664
|
+
}
|
|
633
665
|
return c;
|
|
634
666
|
}
|
|
635
667
|
function runTop(node) {
|
|
@@ -656,7 +688,7 @@ function runTop(node) {
|
|
|
656
688
|
} else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
657
689
|
const updates = Updates;
|
|
658
690
|
Updates = null;
|
|
659
|
-
lookDownstream(node);
|
|
691
|
+
lookDownstream(node, ancestors[0]);
|
|
660
692
|
Updates = updates;
|
|
661
693
|
}
|
|
662
694
|
}
|
|
@@ -754,13 +786,15 @@ function runUserEffects(queue) {
|
|
|
754
786
|
for (i = 0; i < userLength; i++) runTop(queue[i]);
|
|
755
787
|
for (i = resume; i < queue.length; i++) runTop(queue[i]);
|
|
756
788
|
}
|
|
757
|
-
function lookDownstream(node) {
|
|
789
|
+
function lookDownstream(node, ignore) {
|
|
758
790
|
node.state = 0;
|
|
759
791
|
const runningTransition = Transition && Transition.running;
|
|
760
792
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
761
793
|
const source = node.sources[i];
|
|
762
794
|
if (source.sources) {
|
|
763
|
-
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE)
|
|
795
|
+
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
|
|
796
|
+
if (source !== ignore) runTop(source);
|
|
797
|
+
} else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source, ignore);
|
|
764
798
|
}
|
|
765
799
|
}
|
|
766
800
|
}
|
|
@@ -1061,13 +1095,19 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1061
1095
|
};
|
|
1062
1096
|
}
|
|
1063
1097
|
|
|
1098
|
+
let hydrationEnabled = false;
|
|
1099
|
+
function enableHydration() {
|
|
1100
|
+
hydrationEnabled = true;
|
|
1101
|
+
}
|
|
1064
1102
|
function createComponent(Comp, props) {
|
|
1065
|
-
if (
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1103
|
+
if (hydrationEnabled) {
|
|
1104
|
+
if (sharedConfig.context) {
|
|
1105
|
+
const c = sharedConfig.context;
|
|
1106
|
+
setHydrateContext(nextHydrateContext());
|
|
1107
|
+
const r = untrack(() => Comp(props));
|
|
1108
|
+
setHydrateContext(c);
|
|
1109
|
+
return r;
|
|
1110
|
+
}
|
|
1071
1111
|
}
|
|
1072
1112
|
return untrack(() => Comp(props));
|
|
1073
1113
|
}
|
|
@@ -1156,19 +1196,20 @@ function splitProps(props, ...keys) {
|
|
|
1156
1196
|
}
|
|
1157
1197
|
function lazy(fn) {
|
|
1158
1198
|
let comp;
|
|
1199
|
+
let p;
|
|
1159
1200
|
const wrap = props => {
|
|
1160
1201
|
const ctx = sharedConfig.context;
|
|
1161
1202
|
if (ctx) {
|
|
1162
1203
|
ctx.count++;
|
|
1163
1204
|
const [s, set] = createSignal();
|
|
1164
|
-
fn().then(mod => {
|
|
1205
|
+
(p || (p = fn())).then(mod => {
|
|
1165
1206
|
setHydrateContext(ctx);
|
|
1166
1207
|
set(() => mod.default);
|
|
1167
1208
|
setHydrateContext(undefined);
|
|
1168
1209
|
});
|
|
1169
1210
|
comp = s;
|
|
1170
1211
|
} else if (!comp) {
|
|
1171
|
-
const [s] = createResource(() => fn().then(mod => mod.default));
|
|
1212
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1172
1213
|
comp = s;
|
|
1173
1214
|
} else {
|
|
1174
1215
|
const c = comp();
|
|
@@ -1184,7 +1225,7 @@ function lazy(fn) {
|
|
|
1184
1225
|
return r;
|
|
1185
1226
|
}));
|
|
1186
1227
|
};
|
|
1187
|
-
wrap.preload = () =>
|
|
1228
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1188
1229
|
return wrap;
|
|
1189
1230
|
}
|
|
1190
1231
|
let counter = 0;
|
|
@@ -1244,7 +1285,11 @@ function Match(props) {
|
|
|
1244
1285
|
return props;
|
|
1245
1286
|
}
|
|
1246
1287
|
function ErrorBoundary(props) {
|
|
1247
|
-
|
|
1288
|
+
let err = undefined;
|
|
1289
|
+
if (sharedConfig.context && sharedConfig.load) {
|
|
1290
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1291
|
+
}
|
|
1292
|
+
const [errored, setErrored] = createSignal(err);
|
|
1248
1293
|
let e;
|
|
1249
1294
|
return createMemo(() => {
|
|
1250
1295
|
if ((e = errored()) != null) {
|
|
@@ -1328,7 +1373,8 @@ function Suspense(props) {
|
|
|
1328
1373
|
showFallback,
|
|
1329
1374
|
ctx,
|
|
1330
1375
|
waitingHydration,
|
|
1331
|
-
flicker
|
|
1376
|
+
flicker,
|
|
1377
|
+
error;
|
|
1332
1378
|
const [inFallback, setFallback] = createSignal(false),
|
|
1333
1379
|
SuspenseContext = getSuspenseContext(),
|
|
1334
1380
|
store = {
|
|
@@ -1343,7 +1389,7 @@ function Suspense(props) {
|
|
|
1343
1389
|
resolved: false
|
|
1344
1390
|
},
|
|
1345
1391
|
owner = getOwner();
|
|
1346
|
-
if (sharedConfig.context
|
|
1392
|
+
if (sharedConfig.context) {
|
|
1347
1393
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1348
1394
|
const p = sharedConfig.load(key);
|
|
1349
1395
|
if (p) {
|
|
@@ -1351,7 +1397,8 @@ function Suspense(props) {
|
|
|
1351
1397
|
equals: false
|
|
1352
1398
|
});
|
|
1353
1399
|
flicker = s;
|
|
1354
|
-
p.then(
|
|
1400
|
+
p.then(err => {
|
|
1401
|
+
if (error = err) return set();
|
|
1355
1402
|
sharedConfig.gather(key);
|
|
1356
1403
|
waitingHydration = true;
|
|
1357
1404
|
setHydrateContext(ctx);
|
|
@@ -1369,6 +1416,7 @@ function Suspense(props) {
|
|
|
1369
1416
|
value: store,
|
|
1370
1417
|
get children() {
|
|
1371
1418
|
return createMemo(() => {
|
|
1419
|
+
if (error) throw error;
|
|
1372
1420
|
if (flicker) {
|
|
1373
1421
|
ctx = sharedConfig.context;
|
|
1374
1422
|
flicker();
|
|
@@ -1424,6 +1472,8 @@ exports.createRoot = createRoot;
|
|
|
1424
1472
|
exports.createSelector = createSelector;
|
|
1425
1473
|
exports.createSignal = createSignal;
|
|
1426
1474
|
exports.createUniqueId = createUniqueId;
|
|
1475
|
+
exports.enableExternalSource = enableExternalSource;
|
|
1476
|
+
exports.enableHydration = enableHydration;
|
|
1427
1477
|
exports.enableScheduling = enableScheduling;
|
|
1428
1478
|
exports.equalFn = equalFn;
|
|
1429
1479
|
exports.from = from;
|
package/dist/solid.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;
|
|
@@ -347,7 +348,7 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
347
348
|
const subs = new Map();
|
|
348
349
|
const node = createComputation(p => {
|
|
349
350
|
const v = source();
|
|
350
|
-
for (const key of subs.keys()) if (fn(key, v)
|
|
351
|
+
for (const key of subs.keys()) if (fn(key, v) !== (p !== undefined && fn(key, p))) {
|
|
351
352
|
const l = subs.get(key);
|
|
352
353
|
for (const c of l.values()) {
|
|
353
354
|
c.state = STALE;
|
|
@@ -499,6 +500,24 @@ let SuspenseContext;
|
|
|
499
500
|
function getSuspenseContext() {
|
|
500
501
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
501
502
|
}
|
|
503
|
+
function enableExternalSource(factory) {
|
|
504
|
+
if (ExternalSourceFactory) {
|
|
505
|
+
const oldFactory = ExternalSourceFactory;
|
|
506
|
+
ExternalSourceFactory = (fn, trigger) => {
|
|
507
|
+
const oldSource = oldFactory(fn, trigger);
|
|
508
|
+
const source = factory(x => oldSource.track(x), trigger);
|
|
509
|
+
return {
|
|
510
|
+
track: x => source.track(x),
|
|
511
|
+
dispose() {
|
|
512
|
+
source.dispose();
|
|
513
|
+
oldSource.dispose();
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
};
|
|
517
|
+
} else {
|
|
518
|
+
ExternalSourceFactory = factory;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
502
521
|
function readSignal() {
|
|
503
522
|
const runningTransition = Transition && Transition.running;
|
|
504
523
|
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
@@ -626,6 +645,19 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
626
645
|
if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
|
|
627
646
|
}
|
|
628
647
|
}
|
|
648
|
+
if (ExternalSourceFactory) {
|
|
649
|
+
const [track, trigger] = createSignal(undefined, {
|
|
650
|
+
equals: false
|
|
651
|
+
});
|
|
652
|
+
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
653
|
+
onCleanup(() => ordinary.dispose());
|
|
654
|
+
const triggerInTransition = () => startTransition(trigger, () => inTransition.dispose());
|
|
655
|
+
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
656
|
+
c.fn = x => {
|
|
657
|
+
track();
|
|
658
|
+
return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
|
|
659
|
+
};
|
|
660
|
+
}
|
|
629
661
|
return c;
|
|
630
662
|
}
|
|
631
663
|
function runTop(node) {
|
|
@@ -652,7 +684,7 @@ function runTop(node) {
|
|
|
652
684
|
} else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
653
685
|
const updates = Updates;
|
|
654
686
|
Updates = null;
|
|
655
|
-
lookDownstream(node);
|
|
687
|
+
lookDownstream(node, ancestors[0]);
|
|
656
688
|
Updates = updates;
|
|
657
689
|
}
|
|
658
690
|
}
|
|
@@ -750,13 +782,15 @@ function runUserEffects(queue) {
|
|
|
750
782
|
for (i = 0; i < userLength; i++) runTop(queue[i]);
|
|
751
783
|
for (i = resume; i < queue.length; i++) runTop(queue[i]);
|
|
752
784
|
}
|
|
753
|
-
function lookDownstream(node) {
|
|
785
|
+
function lookDownstream(node, ignore) {
|
|
754
786
|
node.state = 0;
|
|
755
787
|
const runningTransition = Transition && Transition.running;
|
|
756
788
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
757
789
|
const source = node.sources[i];
|
|
758
790
|
if (source.sources) {
|
|
759
|
-
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE)
|
|
791
|
+
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
|
|
792
|
+
if (source !== ignore) runTop(source);
|
|
793
|
+
} else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source, ignore);
|
|
760
794
|
}
|
|
761
795
|
}
|
|
762
796
|
}
|
|
@@ -1057,13 +1091,19 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1057
1091
|
};
|
|
1058
1092
|
}
|
|
1059
1093
|
|
|
1094
|
+
let hydrationEnabled = false;
|
|
1095
|
+
function enableHydration() {
|
|
1096
|
+
hydrationEnabled = true;
|
|
1097
|
+
}
|
|
1060
1098
|
function createComponent(Comp, props) {
|
|
1061
|
-
if (
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1099
|
+
if (hydrationEnabled) {
|
|
1100
|
+
if (sharedConfig.context) {
|
|
1101
|
+
const c = sharedConfig.context;
|
|
1102
|
+
setHydrateContext(nextHydrateContext());
|
|
1103
|
+
const r = untrack(() => Comp(props));
|
|
1104
|
+
setHydrateContext(c);
|
|
1105
|
+
return r;
|
|
1106
|
+
}
|
|
1067
1107
|
}
|
|
1068
1108
|
return untrack(() => Comp(props));
|
|
1069
1109
|
}
|
|
@@ -1152,19 +1192,20 @@ function splitProps(props, ...keys) {
|
|
|
1152
1192
|
}
|
|
1153
1193
|
function lazy(fn) {
|
|
1154
1194
|
let comp;
|
|
1195
|
+
let p;
|
|
1155
1196
|
const wrap = props => {
|
|
1156
1197
|
const ctx = sharedConfig.context;
|
|
1157
1198
|
if (ctx) {
|
|
1158
1199
|
ctx.count++;
|
|
1159
1200
|
const [s, set] = createSignal();
|
|
1160
|
-
fn().then(mod => {
|
|
1201
|
+
(p || (p = fn())).then(mod => {
|
|
1161
1202
|
setHydrateContext(ctx);
|
|
1162
1203
|
set(() => mod.default);
|
|
1163
1204
|
setHydrateContext(undefined);
|
|
1164
1205
|
});
|
|
1165
1206
|
comp = s;
|
|
1166
1207
|
} else if (!comp) {
|
|
1167
|
-
const [s] = createResource(() => fn().then(mod => mod.default));
|
|
1208
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1168
1209
|
comp = s;
|
|
1169
1210
|
} else {
|
|
1170
1211
|
const c = comp();
|
|
@@ -1180,7 +1221,7 @@ function lazy(fn) {
|
|
|
1180
1221
|
return r;
|
|
1181
1222
|
}));
|
|
1182
1223
|
};
|
|
1183
|
-
wrap.preload = () =>
|
|
1224
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1184
1225
|
return wrap;
|
|
1185
1226
|
}
|
|
1186
1227
|
let counter = 0;
|
|
@@ -1240,7 +1281,11 @@ function Match(props) {
|
|
|
1240
1281
|
return props;
|
|
1241
1282
|
}
|
|
1242
1283
|
function ErrorBoundary(props) {
|
|
1243
|
-
|
|
1284
|
+
let err = undefined;
|
|
1285
|
+
if (sharedConfig.context && sharedConfig.load) {
|
|
1286
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1287
|
+
}
|
|
1288
|
+
const [errored, setErrored] = createSignal(err);
|
|
1244
1289
|
let e;
|
|
1245
1290
|
return createMemo(() => {
|
|
1246
1291
|
if ((e = errored()) != null) {
|
|
@@ -1324,7 +1369,8 @@ function Suspense(props) {
|
|
|
1324
1369
|
showFallback,
|
|
1325
1370
|
ctx,
|
|
1326
1371
|
waitingHydration,
|
|
1327
|
-
flicker
|
|
1372
|
+
flicker,
|
|
1373
|
+
error;
|
|
1328
1374
|
const [inFallback, setFallback] = createSignal(false),
|
|
1329
1375
|
SuspenseContext = getSuspenseContext(),
|
|
1330
1376
|
store = {
|
|
@@ -1339,7 +1385,7 @@ function Suspense(props) {
|
|
|
1339
1385
|
resolved: false
|
|
1340
1386
|
},
|
|
1341
1387
|
owner = getOwner();
|
|
1342
|
-
if (sharedConfig.context
|
|
1388
|
+
if (sharedConfig.context) {
|
|
1343
1389
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1344
1390
|
const p = sharedConfig.load(key);
|
|
1345
1391
|
if (p) {
|
|
@@ -1347,7 +1393,8 @@ function Suspense(props) {
|
|
|
1347
1393
|
equals: false
|
|
1348
1394
|
});
|
|
1349
1395
|
flicker = s;
|
|
1350
|
-
p.then(
|
|
1396
|
+
p.then(err => {
|
|
1397
|
+
if (error = err) return set();
|
|
1351
1398
|
sharedConfig.gather(key);
|
|
1352
1399
|
waitingHydration = true;
|
|
1353
1400
|
setHydrateContext(ctx);
|
|
@@ -1365,6 +1412,7 @@ function Suspense(props) {
|
|
|
1365
1412
|
value: store,
|
|
1366
1413
|
get children() {
|
|
1367
1414
|
return createMemo(() => {
|
|
1415
|
+
if (error) throw error;
|
|
1368
1416
|
if (flicker) {
|
|
1369
1417
|
ctx = sharedConfig.context;
|
|
1370
1418
|
flicker();
|
|
@@ -1395,4 +1443,4 @@ function Suspense(props) {
|
|
|
1395
1443
|
|
|
1396
1444
|
let DEV;
|
|
1397
1445
|
|
|
1398
|
-
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 };
|
|
1446
|
+
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/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-js",
|
|
3
3
|
"description": "A declarative JavaScript library for building user interfaces.",
|
|
4
|
-
"version": "1.3.0-beta.
|
|
4
|
+
"version": "1.3.0-beta.4",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"homepage": "https://
|
|
7
|
+
"homepage": "https://solidjs.com",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/solidjs/solid"
|
|
@@ -36,10 +36,6 @@
|
|
|
36
36
|
],
|
|
37
37
|
"exports": {
|
|
38
38
|
".": {
|
|
39
|
-
"development": {
|
|
40
|
-
"import": "./dist/dev.js",
|
|
41
|
-
"require": "./dist/dev.cjs"
|
|
42
|
-
},
|
|
43
39
|
"browser": {
|
|
44
40
|
"import": "./dist/solid.js",
|
|
45
41
|
"require": "./dist/solid.cjs"
|
|
@@ -48,15 +44,15 @@
|
|
|
48
44
|
"import": "./dist/server.js",
|
|
49
45
|
"require": "./dist/server.cjs"
|
|
50
46
|
},
|
|
47
|
+
"development": {
|
|
48
|
+
"import": "./dist/dev.js",
|
|
49
|
+
"require": "./dist/dev.cjs"
|
|
50
|
+
},
|
|
51
51
|
"import": "./dist/solid.js",
|
|
52
52
|
"require": "./dist/solid.cjs"
|
|
53
53
|
},
|
|
54
54
|
"./dist/*": "./dist/*",
|
|
55
55
|
"./store": {
|
|
56
|
-
"development": {
|
|
57
|
-
"import": "./store/dist/dev.js",
|
|
58
|
-
"require": "./store/dist/dev.cjs"
|
|
59
|
-
},
|
|
60
56
|
"browser": {
|
|
61
57
|
"import": "./store/dist/store.js",
|
|
62
58
|
"require": "./store/dist/store.cjs"
|
|
@@ -65,15 +61,15 @@
|
|
|
65
61
|
"import": "./store/dist/server.js",
|
|
66
62
|
"require": "./store/dist/server.cjs"
|
|
67
63
|
},
|
|
64
|
+
"development": {
|
|
65
|
+
"import": "./store/dist/dev.js",
|
|
66
|
+
"require": "./store/dist/dev.cjs"
|
|
67
|
+
},
|
|
68
68
|
"import": "./store/dist/store.js",
|
|
69
69
|
"require": "./store/dist/store.cjs"
|
|
70
70
|
},
|
|
71
71
|
"./store/dist/*": "./store/dist/*",
|
|
72
72
|
"./web": {
|
|
73
|
-
"development": {
|
|
74
|
-
"import": "./web/dist/dev.js",
|
|
75
|
-
"require": "./web/dist/dev.cjs"
|
|
76
|
-
},
|
|
77
73
|
"browser": {
|
|
78
74
|
"import": "./web/dist/web.js",
|
|
79
75
|
"require": "./web/dist/web.cjs"
|
|
@@ -82,6 +78,10 @@
|
|
|
82
78
|
"import": "./web/dist/server.js",
|
|
83
79
|
"require": "./web/dist/server.cjs"
|
|
84
80
|
},
|
|
81
|
+
"development": {
|
|
82
|
+
"import": "./web/dist/dev.js",
|
|
83
|
+
"require": "./web/dist/dev.cjs"
|
|
84
|
+
},
|
|
85
85
|
"import": "./web/dist/web.js",
|
|
86
86
|
"require": "./web/dist/web.cjs"
|
|
87
87
|
},
|
|
@@ -132,5 +132,5 @@
|
|
|
132
132
|
"compiler",
|
|
133
133
|
"performance"
|
|
134
134
|
],
|
|
135
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "c9307f020f33ff584f2d896c219e530d8ee97a9c"
|
|
136
136
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, startTransition, useTransition, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $PROXY } from "./reactive/signal";
|
|
1
|
+
export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $PROXY } from "./reactive/signal";
|
|
2
2
|
export type { Accessor, Setter, Resource, ResourceReturn, Context, ReturnTypes } from "./reactive/signal";
|
|
3
3
|
export * from "./reactive/observable";
|
|
4
4
|
export * from "./reactive/scheduler";
|
|
@@ -5,6 +5,7 @@ export declare const $PROXY: unique symbol;
|
|
|
5
5
|
export declare const NOTPENDING: {};
|
|
6
6
|
export declare var Owner: Owner | null;
|
|
7
7
|
export declare let Transition: TransitionState | null;
|
|
8
|
+
declare let ExternalSourceFactory: ExternalSourceFactory | null;
|
|
8
9
|
declare global {
|
|
9
10
|
var _$afterUpdate: () => void;
|
|
10
11
|
}
|
|
@@ -50,6 +51,11 @@ export interface TransitionState {
|
|
|
50
51
|
running: boolean;
|
|
51
52
|
cb: (() => void)[];
|
|
52
53
|
}
|
|
54
|
+
declare type ExternalSourceFactory = <Prev, Next extends Prev = Prev>(fn: EffectFunction<Prev, Next>, trigger: () => void) => ExternalSource;
|
|
55
|
+
export interface ExternalSource {
|
|
56
|
+
track: EffectFunction<any, any>;
|
|
57
|
+
dispose: () => void;
|
|
58
|
+
}
|
|
53
59
|
export declare type RootFunction<T> = (dispose: () => void) => T;
|
|
54
60
|
/**
|
|
55
61
|
* Creates a new non-tracked reactive context that doesn't auto-dispose
|
|
@@ -423,6 +429,7 @@ declare type SuspenseContext = Context<SuspenseContextType> & {
|
|
|
423
429
|
};
|
|
424
430
|
declare let SuspenseContext: SuspenseContext;
|
|
425
431
|
export declare function getSuspenseContext(): SuspenseContext;
|
|
432
|
+
export declare function enableExternalSource(factory: ExternalSourceFactory): void;
|
|
426
433
|
export declare function readSignal(this: SignalState<any> | Memo<any>): any;
|
|
427
434
|
export declare function writeSignal(node: SignalState<any> | Memo<any>, value: any, isComp?: boolean): any;
|
|
428
435
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { JSX } from "../jsx";
|
|
2
|
+
export declare function enableHydration(): void;
|
|
2
3
|
export declare type PropsWithChildren<P = {}> = P & {
|
|
3
4
|
children?: JSX.Element;
|
|
4
5
|
};
|
|
@@ -36,7 +37,9 @@ export declare function splitProps<T extends object, K1 extends keyof T, K2 exte
|
|
|
36
37
|
export declare function lazy<T extends Component<any>>(fn: () => Promise<{
|
|
37
38
|
default: T;
|
|
38
39
|
}>): T & {
|
|
39
|
-
preload: () =>
|
|
40
|
+
preload: () => Promise<{
|
|
41
|
+
default: T;
|
|
42
|
+
}>;
|
|
40
43
|
};
|
|
41
44
|
export declare function createUniqueId(): string;
|
|
42
45
|
export {};
|