solid-js 1.2.5 → 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 +137 -46
- package/dist/dev.js +135 -46
- package/dist/server.cjs +70 -60
- package/dist/server.js +70 -60
- package/dist/solid.cjs +137 -46
- package/dist/solid.js +135 -46
- package/package.json +27 -15
- package/types/index.d.ts +2 -3
- package/types/reactive/signal.d.ts +98 -82
- package/types/render/component.d.ts +4 -1
- package/types/render/hydration.d.ts +3 -2
- package/types/server/index.d.ts +2 -2
- package/types/server/reactive.d.ts +2 -2
- package/types/server/rendering.d.ts +7 -5
- package/web/dist/dev.cjs +32 -24
- package/web/dist/dev.js +33 -23
- package/web/dist/server.cjs +219 -135
- package/web/dist/server.js +220 -137
- package/web/dist/web.cjs +32 -24
- package/web/dist/web.js +33 -23
- package/web/types/client.d.ts +11 -3
- package/web/types/core.d.ts +2 -2
- package/web/types/index.d.ts +2 -0
- package/web/types/server-mock.d.ts +33 -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;
|
|
@@ -215,7 +231,7 @@ function createUniqueId() {
|
|
|
215
231
|
return `${ctx.id}${ctx.count++}`;
|
|
216
232
|
}
|
|
217
233
|
function createComponent(Comp, props) {
|
|
218
|
-
if (sharedConfig.context) {
|
|
234
|
+
if (sharedConfig.context && !sharedConfig.context.noHydrate) {
|
|
219
235
|
const c = sharedConfig.context;
|
|
220
236
|
setHydrateContext(nextHydrateContext());
|
|
221
237
|
const r = Comp(props);
|
|
@@ -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,9 +344,10 @@ 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
|
-
if (
|
|
350
|
+
if (!resolved && read.loading) {
|
|
320
351
|
const ctx = useContext(SuspenseContext);
|
|
321
352
|
if (ctx) {
|
|
322
353
|
ctx.resources.set(id, read);
|
|
@@ -328,7 +359,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
328
359
|
read.loading = false;
|
|
329
360
|
function load() {
|
|
330
361
|
const ctx = sharedConfig.context;
|
|
331
|
-
if (!ctx.async
|
|
362
|
+
if (!ctx.async) return read.loading = !!(typeof fn === "function" ? fn() : fn);
|
|
332
363
|
if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
|
|
333
364
|
value = ctx.resources[id].data;
|
|
334
365
|
return;
|
|
@@ -345,21 +376,18 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
345
376
|
}
|
|
346
377
|
read.loading = true;
|
|
347
378
|
if ("then" in p) {
|
|
348
|
-
if (ctx.writeResource)
|
|
349
|
-
ctx.writeResource(id, p);
|
|
350
|
-
p.then(v => {
|
|
351
|
-
value = v;
|
|
352
|
-
read.loading = false;
|
|
353
|
-
p = null;
|
|
354
|
-
});
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
379
|
+
if (ctx.writeResource) ctx.writeResource(id, p);
|
|
357
380
|
p.then(res => {
|
|
358
381
|
read.loading = false;
|
|
359
382
|
ctx.resources[id].data = res;
|
|
360
383
|
p = null;
|
|
361
384
|
notifySuspense(contexts);
|
|
362
385
|
return res;
|
|
386
|
+
}).catch(err => {
|
|
387
|
+
read.loading = false;
|
|
388
|
+
error = err;
|
|
389
|
+
p = null;
|
|
390
|
+
notifySuspense(contexts);
|
|
363
391
|
});
|
|
364
392
|
return;
|
|
365
393
|
}
|
|
@@ -388,13 +416,13 @@ function lazy(fn) {
|
|
|
388
416
|
ctx.resources.set(id, track);
|
|
389
417
|
contexts.add(ctx);
|
|
390
418
|
}
|
|
391
|
-
p.then(() => {
|
|
419
|
+
if (sharedConfig.context.async) p.then(() => {
|
|
392
420
|
track.loading = false;
|
|
393
421
|
notifySuspense(contexts);
|
|
394
422
|
});
|
|
395
423
|
return "";
|
|
396
424
|
};
|
|
397
|
-
wrap.preload = () =>
|
|
425
|
+
wrap.preload = () => p;
|
|
398
426
|
return wrap;
|
|
399
427
|
}
|
|
400
428
|
function suspenseComplete(c) {
|
|
@@ -421,15 +449,10 @@ function useTransition() {
|
|
|
421
449
|
function SuspenseList(props) {
|
|
422
450
|
return props.children;
|
|
423
451
|
}
|
|
424
|
-
const SUSPENSE_GLOBAL = Symbol("suspense-global");
|
|
425
452
|
function Suspense(props) {
|
|
453
|
+
let done;
|
|
426
454
|
const ctx = sharedConfig.context;
|
|
427
|
-
if (!ctx.async) return createComponent(() => {
|
|
428
|
-
props.children;
|
|
429
|
-
return props.fallback;
|
|
430
|
-
}, {});
|
|
431
455
|
const id = ctx.id + ctx.count;
|
|
432
|
-
const done = ctx.async ? lookup(Owner, SUSPENSE_GLOBAL)(id) : () => {};
|
|
433
456
|
const o = Owner;
|
|
434
457
|
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
435
458
|
resources: new Map(),
|
|
@@ -455,43 +478,30 @@ function Suspense(props) {
|
|
|
455
478
|
}
|
|
456
479
|
const res = runSuspense();
|
|
457
480
|
if (suspenseComplete(value)) {
|
|
458
|
-
|
|
481
|
+
ctx.writeResource(id, true);
|
|
459
482
|
return res;
|
|
460
483
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
if (value) cache[key] = value;
|
|
481
|
-
registry.delete(key);
|
|
482
|
-
if (!registry.size) Promise.resolve().then(() => {
|
|
483
|
-
let source = resolveSSRNode(res());
|
|
484
|
-
let final = "";
|
|
485
|
-
let match;
|
|
486
|
-
while (match = source.match(SUSPENSE_REPLACE)) {
|
|
487
|
-
final += source.substring(0, match.index);
|
|
488
|
-
source = cache[match[1]] + source.substring(match.index + match[0].length);
|
|
489
|
-
}
|
|
490
|
-
resolve(final + source);
|
|
491
|
-
});
|
|
492
|
-
};
|
|
493
|
-
}
|
|
484
|
+
onError(err => {
|
|
485
|
+
if (!done || !done(undefined, err)) throw err;
|
|
486
|
+
});
|
|
487
|
+
done = ctx.async ? ctx.registerFragment(id) : undefined;
|
|
488
|
+
if (ctx.streaming) {
|
|
489
|
+
setHydrateContext(undefined);
|
|
490
|
+
const res = {
|
|
491
|
+
t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
|
|
492
|
+
};
|
|
493
|
+
setHydrateContext(ctx);
|
|
494
|
+
return res;
|
|
495
|
+
} else if (ctx.async) {
|
|
496
|
+
return {
|
|
497
|
+
t: `<![${id}]>`
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
setHydrateContext({ ...ctx,
|
|
501
|
+
count: 0,
|
|
502
|
+
id: ctx.id + "0.f"
|
|
494
503
|
});
|
|
504
|
+
return props.fallback;
|
|
495
505
|
}
|
|
496
506
|
|
|
497
|
-
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch,
|
|
507
|
+
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;
|
|
@@ -184,12 +185,13 @@ function createSignal(value, options) {
|
|
|
184
185
|
pending: NOTPENDING,
|
|
185
186
|
comparator: options.equals || undefined
|
|
186
187
|
};
|
|
187
|
-
|
|
188
|
+
const setter = value => {
|
|
188
189
|
if (typeof value === "function") {
|
|
189
190
|
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);
|
|
190
191
|
}
|
|
191
192
|
return writeSignal(s, value);
|
|
192
|
-
}
|
|
193
|
+
};
|
|
194
|
+
return [readSignal.bind(s), setter];
|
|
193
195
|
}
|
|
194
196
|
function createComputed(fn, value, options) {
|
|
195
197
|
const c = createComputation(fn, value, true, STALE);
|
|
@@ -231,6 +233,9 @@ function createResource(source, fetcher, options) {
|
|
|
231
233
|
fetcher = source;
|
|
232
234
|
source = true;
|
|
233
235
|
}
|
|
236
|
+
Resources || (Resources = new Set());
|
|
237
|
+
Resources.add(load);
|
|
238
|
+
onCleanup(() => Resources.delete(load));
|
|
234
239
|
const contexts = new Set(),
|
|
235
240
|
[s, set] = createSignal((options || {}).initialValue),
|
|
236
241
|
[track, trigger] = createSignal(undefined, {
|
|
@@ -246,12 +251,7 @@ function createResource(source, fetcher, options) {
|
|
|
246
251
|
dynamic = typeof source === "function";
|
|
247
252
|
if (sharedConfig.context) {
|
|
248
253
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
249
|
-
if (sharedConfig.
|
|
250
|
-
initP = sharedConfig.context.loadResource(id);
|
|
251
|
-
} else if (sharedConfig.resources && id && id in sharedConfig.resources) {
|
|
252
|
-
initP = sharedConfig.resources[id];
|
|
253
|
-
delete sharedConfig.resources[id];
|
|
254
|
-
}
|
|
254
|
+
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
255
255
|
}
|
|
256
256
|
function loadEnd(p, v, e) {
|
|
257
257
|
if (pr === p) {
|
|
@@ -297,7 +297,7 @@ function createResource(source, fetcher, options) {
|
|
|
297
297
|
}
|
|
298
298
|
return v;
|
|
299
299
|
}
|
|
300
|
-
function load() {
|
|
300
|
+
function load(refetching = true) {
|
|
301
301
|
setError(err = undefined);
|
|
302
302
|
const lookup = dynamic ? source() : source;
|
|
303
303
|
loadedUnderTransition = Transition && Transition.running;
|
|
@@ -306,7 +306,10 @@ function createResource(source, fetcher, options) {
|
|
|
306
306
|
return;
|
|
307
307
|
}
|
|
308
308
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
309
|
-
const p = initP || untrack(() => fetcher(lookup,
|
|
309
|
+
const p = initP || untrack(() => fetcher(lookup, {
|
|
310
|
+
value: s(),
|
|
311
|
+
refetching
|
|
312
|
+
}));
|
|
310
313
|
initP = null;
|
|
311
314
|
if (typeof p !== "object" || !("then" in p)) {
|
|
312
315
|
loadEnd(pr, p);
|
|
@@ -331,12 +334,16 @@ function createResource(source, fetcher, options) {
|
|
|
331
334
|
}
|
|
332
335
|
}
|
|
333
336
|
});
|
|
334
|
-
if (dynamic) createComputed(load);else load();
|
|
337
|
+
if (dynamic) createComputed(() => load(false));else load(false);
|
|
335
338
|
return [read, {
|
|
336
339
|
refetch: load,
|
|
337
340
|
mutate: set
|
|
338
341
|
}];
|
|
339
342
|
}
|
|
343
|
+
let Resources;
|
|
344
|
+
function refetchResources(info) {
|
|
345
|
+
Resources && Resources.forEach(fn => fn(info));
|
|
346
|
+
}
|
|
340
347
|
function createDeferred(source, options) {
|
|
341
348
|
let t,
|
|
342
349
|
timeout = options ? options.timeoutMs : undefined;
|
|
@@ -355,7 +362,7 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
355
362
|
const subs = new Map();
|
|
356
363
|
const node = createComputation(p => {
|
|
357
364
|
const v = source();
|
|
358
|
-
for (const key of subs.keys()) if (fn(key, v)
|
|
365
|
+
for (const key of subs.keys()) if (fn(key, v) !== (p !== undefined && fn(key, p))) {
|
|
359
366
|
const l = subs.get(key);
|
|
360
367
|
for (const c of l.values()) {
|
|
361
368
|
c.state = STALE;
|
|
@@ -406,7 +413,8 @@ function untrack(fn) {
|
|
|
406
413
|
Listener = listener;
|
|
407
414
|
return result;
|
|
408
415
|
}
|
|
409
|
-
function on(deps, fn,
|
|
416
|
+
function on(deps, fn,
|
|
417
|
+
options) {
|
|
410
418
|
const isArray = Array.isArray(deps);
|
|
411
419
|
let prevInput;
|
|
412
420
|
let defer = options && options.defer;
|
|
@@ -506,6 +514,24 @@ let SuspenseContext;
|
|
|
506
514
|
function getSuspenseContext() {
|
|
507
515
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
508
516
|
}
|
|
517
|
+
function enableExternalSource(factory) {
|
|
518
|
+
if (ExternalSourceFactory) {
|
|
519
|
+
const oldFactory = ExternalSourceFactory;
|
|
520
|
+
ExternalSourceFactory = (fn, trigger) => {
|
|
521
|
+
const oldSource = oldFactory(fn, trigger);
|
|
522
|
+
const source = factory(x => oldSource.track(x), trigger);
|
|
523
|
+
return {
|
|
524
|
+
track: x => source.track(x),
|
|
525
|
+
dispose() {
|
|
526
|
+
source.dispose();
|
|
527
|
+
oldSource.dispose();
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
};
|
|
531
|
+
} else {
|
|
532
|
+
ExternalSourceFactory = factory;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
509
535
|
function readSignal() {
|
|
510
536
|
const runningTransition = Transition && Transition.running;
|
|
511
537
|
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
@@ -633,6 +659,19 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
633
659
|
if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
|
|
634
660
|
}
|
|
635
661
|
}
|
|
662
|
+
if (ExternalSourceFactory) {
|
|
663
|
+
const [track, trigger] = createSignal(undefined, {
|
|
664
|
+
equals: false
|
|
665
|
+
});
|
|
666
|
+
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
667
|
+
onCleanup(() => ordinary.dispose());
|
|
668
|
+
const triggerInTransition = () => startTransition(trigger, () => inTransition.dispose());
|
|
669
|
+
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
670
|
+
c.fn = x => {
|
|
671
|
+
track();
|
|
672
|
+
return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
|
|
673
|
+
};
|
|
674
|
+
}
|
|
636
675
|
return c;
|
|
637
676
|
}
|
|
638
677
|
function runTop(node) {
|
|
@@ -659,7 +698,7 @@ function runTop(node) {
|
|
|
659
698
|
} else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
|
|
660
699
|
const updates = Updates;
|
|
661
700
|
Updates = null;
|
|
662
|
-
lookDownstream(node);
|
|
701
|
+
lookDownstream(node, ancestors[0]);
|
|
663
702
|
Updates = updates;
|
|
664
703
|
}
|
|
665
704
|
}
|
|
@@ -757,13 +796,15 @@ function runUserEffects(queue) {
|
|
|
757
796
|
for (i = 0; i < userLength; i++) runTop(queue[i]);
|
|
758
797
|
for (i = resume; i < queue.length; i++) runTop(queue[i]);
|
|
759
798
|
}
|
|
760
|
-
function lookDownstream(node) {
|
|
799
|
+
function lookDownstream(node, ignore) {
|
|
761
800
|
node.state = 0;
|
|
762
801
|
const runningTransition = Transition && Transition.running;
|
|
763
802
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
764
803
|
const source = node.sources[i];
|
|
765
804
|
if (source.sources) {
|
|
766
|
-
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE)
|
|
805
|
+
if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
|
|
806
|
+
if (source !== ignore) runTop(source);
|
|
807
|
+
} else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source, ignore);
|
|
767
808
|
}
|
|
768
809
|
}
|
|
769
810
|
}
|
|
@@ -1064,13 +1105,19 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1064
1105
|
};
|
|
1065
1106
|
}
|
|
1066
1107
|
|
|
1108
|
+
let hydrationEnabled = false;
|
|
1109
|
+
function enableHydration() {
|
|
1110
|
+
hydrationEnabled = true;
|
|
1111
|
+
}
|
|
1067
1112
|
function createComponent(Comp, props) {
|
|
1068
|
-
if (
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1113
|
+
if (hydrationEnabled) {
|
|
1114
|
+
if (sharedConfig.context) {
|
|
1115
|
+
const c = sharedConfig.context;
|
|
1116
|
+
setHydrateContext(nextHydrateContext());
|
|
1117
|
+
const r = untrack(() => Comp(props));
|
|
1118
|
+
setHydrateContext(c);
|
|
1119
|
+
return r;
|
|
1120
|
+
}
|
|
1074
1121
|
}
|
|
1075
1122
|
return untrack(() => Comp(props));
|
|
1076
1123
|
}
|
|
@@ -1159,19 +1206,20 @@ function splitProps(props, ...keys) {
|
|
|
1159
1206
|
}
|
|
1160
1207
|
function lazy(fn) {
|
|
1161
1208
|
let comp;
|
|
1209
|
+
let p;
|
|
1162
1210
|
const wrap = props => {
|
|
1163
1211
|
const ctx = sharedConfig.context;
|
|
1164
|
-
if (ctx
|
|
1212
|
+
if (ctx) {
|
|
1165
1213
|
ctx.count++;
|
|
1166
1214
|
const [s, set] = createSignal();
|
|
1167
|
-
fn().then(mod => {
|
|
1215
|
+
(p || (p = fn())).then(mod => {
|
|
1168
1216
|
setHydrateContext(ctx);
|
|
1169
1217
|
set(() => mod.default);
|
|
1170
|
-
setHydrateContext(
|
|
1218
|
+
setHydrateContext();
|
|
1171
1219
|
});
|
|
1172
1220
|
comp = s;
|
|
1173
1221
|
} else if (!comp) {
|
|
1174
|
-
const [s] = createResource(() => fn().then(mod => mod.default));
|
|
1222
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1175
1223
|
comp = s;
|
|
1176
1224
|
} else {
|
|
1177
1225
|
const c = comp();
|
|
@@ -1187,7 +1235,7 @@ function lazy(fn) {
|
|
|
1187
1235
|
return r;
|
|
1188
1236
|
}));
|
|
1189
1237
|
};
|
|
1190
|
-
wrap.preload = () =>
|
|
1238
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1191
1239
|
return wrap;
|
|
1192
1240
|
}
|
|
1193
1241
|
let counter = 0;
|
|
@@ -1234,7 +1282,7 @@ function Switch(props) {
|
|
|
1234
1282
|
}
|
|
1235
1283
|
return [-1];
|
|
1236
1284
|
}, undefined, {
|
|
1237
|
-
equals: (a, b) => a
|
|
1285
|
+
equals: (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
|
|
1238
1286
|
});
|
|
1239
1287
|
return createMemo(() => {
|
|
1240
1288
|
const [index, when, cond] = evalConditions();
|
|
@@ -1247,7 +1295,11 @@ function Match(props) {
|
|
|
1247
1295
|
return props;
|
|
1248
1296
|
}
|
|
1249
1297
|
function ErrorBoundary(props) {
|
|
1250
|
-
|
|
1298
|
+
let err = undefined;
|
|
1299
|
+
if (sharedConfig.context && sharedConfig.load) {
|
|
1300
|
+
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1301
|
+
}
|
|
1302
|
+
const [errored, setErrored] = createSignal(err);
|
|
1251
1303
|
let e;
|
|
1252
1304
|
return createMemo(() => {
|
|
1253
1305
|
if ((e = errored()) != null) {
|
|
@@ -1328,7 +1380,11 @@ function SuspenseList(props) {
|
|
|
1328
1380
|
function Suspense(props) {
|
|
1329
1381
|
let counter = 0,
|
|
1330
1382
|
showContent,
|
|
1331
|
-
showFallback
|
|
1383
|
+
showFallback,
|
|
1384
|
+
ctx,
|
|
1385
|
+
p,
|
|
1386
|
+
flicker,
|
|
1387
|
+
error;
|
|
1332
1388
|
const [inFallback, setFallback] = createSignal(false),
|
|
1333
1389
|
SuspenseContext = getSuspenseContext(),
|
|
1334
1390
|
store = {
|
|
@@ -1343,6 +1399,24 @@ function Suspense(props) {
|
|
|
1343
1399
|
resolved: false
|
|
1344
1400
|
},
|
|
1345
1401
|
owner = getOwner();
|
|
1402
|
+
if (sharedConfig.context) {
|
|
1403
|
+
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1404
|
+
p = sharedConfig.load(key);
|
|
1405
|
+
if (p && typeof p === "object") {
|
|
1406
|
+
const [s, set] = createSignal(undefined, {
|
|
1407
|
+
equals: false
|
|
1408
|
+
});
|
|
1409
|
+
flicker = s;
|
|
1410
|
+
p.then(err => {
|
|
1411
|
+
if (error = err) return set();
|
|
1412
|
+
sharedConfig.gather(key);
|
|
1413
|
+
setHydrateContext(ctx);
|
|
1414
|
+
set();
|
|
1415
|
+
setHydrateContext();
|
|
1416
|
+
p = undefined;
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1346
1420
|
const listContext = useContext(SuspenseListContext);
|
|
1347
1421
|
if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
|
|
1348
1422
|
let dispose;
|
|
@@ -1350,28 +1424,43 @@ function Suspense(props) {
|
|
|
1350
1424
|
return createComponent(SuspenseContext.Provider, {
|
|
1351
1425
|
value: store,
|
|
1352
1426
|
get children() {
|
|
1353
|
-
const rendered = untrack(() => props.children);
|
|
1354
1427
|
return createMemo(() => {
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
store.resolved = true;
|
|
1361
|
-
resumeEffects(store.effects);
|
|
1362
|
-
return rendered;
|
|
1428
|
+
if (error) throw error;
|
|
1429
|
+
ctx = sharedConfig.context;
|
|
1430
|
+
if (flicker) {
|
|
1431
|
+
flicker();
|
|
1432
|
+
return flicker = undefined;
|
|
1363
1433
|
}
|
|
1364
|
-
if (
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1434
|
+
if (ctx && p === undefined) setHydrateContext();
|
|
1435
|
+
const rendered = untrack(() => props.children);
|
|
1436
|
+
return createMemo(() => {
|
|
1437
|
+
const inFallback = store.inFallback(),
|
|
1438
|
+
visibleContent = showContent ? showContent() : true,
|
|
1439
|
+
visibleFallback = showFallback ? showFallback() : true;
|
|
1440
|
+
dispose && dispose();
|
|
1441
|
+
if ((!inFallback || p !== undefined) && visibleContent) {
|
|
1442
|
+
store.resolved = true;
|
|
1443
|
+
resumeEffects(store.effects);
|
|
1444
|
+
return rendered;
|
|
1445
|
+
}
|
|
1446
|
+
if (!visibleFallback) return;
|
|
1447
|
+
return createRoot(disposer => {
|
|
1448
|
+
dispose = disposer;
|
|
1449
|
+
if (ctx) {
|
|
1450
|
+
setHydrateContext({
|
|
1451
|
+
id: ctx.id + "f",
|
|
1452
|
+
count: 0
|
|
1453
|
+
});
|
|
1454
|
+
ctx = undefined;
|
|
1455
|
+
}
|
|
1456
|
+
return props.fallback;
|
|
1457
|
+
}, owner);
|
|
1458
|
+
});
|
|
1369
1459
|
});
|
|
1370
1460
|
}
|
|
1371
1461
|
});
|
|
1372
1462
|
}
|
|
1373
1463
|
|
|
1374
|
-
function awaitSuspense() {}
|
|
1375
1464
|
let DEV;
|
|
1376
1465
|
|
|
1377
1466
|
exports.$PROXY = $PROXY;
|
|
@@ -1384,7 +1473,6 @@ exports.Show = Show;
|
|
|
1384
1473
|
exports.Suspense = Suspense;
|
|
1385
1474
|
exports.SuspenseList = SuspenseList;
|
|
1386
1475
|
exports.Switch = Switch;
|
|
1387
|
-
exports.awaitSuspense = awaitSuspense;
|
|
1388
1476
|
exports.batch = batch;
|
|
1389
1477
|
exports.cancelCallback = cancelCallback;
|
|
1390
1478
|
exports.children = children;
|
|
@@ -1400,6 +1488,8 @@ exports.createRoot = createRoot;
|
|
|
1400
1488
|
exports.createSelector = createSelector;
|
|
1401
1489
|
exports.createSignal = createSignal;
|
|
1402
1490
|
exports.createUniqueId = createUniqueId;
|
|
1491
|
+
exports.enableExternalSource = enableExternalSource;
|
|
1492
|
+
exports.enableHydration = enableHydration;
|
|
1403
1493
|
exports.enableScheduling = enableScheduling;
|
|
1404
1494
|
exports.equalFn = equalFn;
|
|
1405
1495
|
exports.from = from;
|
|
@@ -1414,6 +1504,7 @@ exports.on = on;
|
|
|
1414
1504
|
exports.onCleanup = onCleanup;
|
|
1415
1505
|
exports.onError = onError;
|
|
1416
1506
|
exports.onMount = onMount;
|
|
1507
|
+
exports.refetchResources = refetchResources;
|
|
1417
1508
|
exports.requestCallback = requestCallback;
|
|
1418
1509
|
exports.runWithOwner = runWithOwner;
|
|
1419
1510
|
exports.sharedConfig = sharedConfig;
|