solid-js 1.3.0-beta.1 → 1.3.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/dev.cjs +91 -26
- package/dist/dev.js +89 -27
- package/dist/server.cjs +62 -21
- package/dist/server.js +62 -22
- package/dist/solid.cjs +91 -26
- package/dist/solid.js +89 -27
- package/package.json +27 -15
- package/types/index.d.ts +2 -2
- package/types/reactive/signal.d.ts +22 -4
- package/types/render/component.d.ts +4 -1
- package/types/server/index.d.ts +1 -1
- package/types/server/reactive.d.ts +1 -0
- package/types/server/rendering.d.ts +6 -5
- package/web/dist/dev.cjs +13 -15
- package/web/dist/dev.js +14 -15
- package/web/dist/server.cjs +141 -159
- package/web/dist/server.js +141 -159
- package/web/dist/web.cjs +13 -15
- package/web/dist/web.js +14 -15
- package/web/types/client.d.ts +11 -2
- package/web/types/index.d.ts +2 -0
- package/web/types/server-mock.d.ts +33 -20
package/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,9 +348,10 @@ 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
|
-
if (!resolved) {
|
|
354
|
+
if (!resolved && read.loading) {
|
|
324
355
|
const ctx = useContext(SuspenseContext);
|
|
325
356
|
if (ctx) {
|
|
326
357
|
ctx.resources.set(id, read);
|
|
@@ -332,7 +363,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
332
363
|
read.loading = false;
|
|
333
364
|
function load() {
|
|
334
365
|
const ctx = sharedConfig.context;
|
|
335
|
-
if (!ctx.async) return read.loading =
|
|
366
|
+
if (!ctx.async) return read.loading = !!(typeof fn === "function" ? fn() : fn);
|
|
336
367
|
if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
|
|
337
368
|
value = ctx.resources[id].data;
|
|
338
369
|
return;
|
|
@@ -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,9 +454,9 @@ 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(),
|
|
@@ -446,26 +482,30 @@ function Suspense(props) {
|
|
|
446
482
|
}
|
|
447
483
|
const res = runSuspense();
|
|
448
484
|
if (suspenseComplete(value)) {
|
|
449
|
-
|
|
485
|
+
ctx.writeResource(id, true);
|
|
450
486
|
return res;
|
|
451
487
|
}
|
|
452
|
-
|
|
453
|
-
if (
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
}
|
|
488
|
+
onError(err => {
|
|
489
|
+
if (!done || !done(undefined, err)) throw err;
|
|
490
|
+
});
|
|
491
|
+
done = ctx.async ? ctx.registerFragment(id) : undefined;
|
|
492
|
+
if (ctx.streaming) {
|
|
493
|
+
setHydrateContext(undefined);
|
|
494
|
+
const res = {
|
|
495
|
+
t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
|
|
496
|
+
};
|
|
497
|
+
setHydrateContext(ctx);
|
|
498
|
+
return res;
|
|
499
|
+
} else if (ctx.async) {
|
|
461
500
|
return {
|
|
462
501
|
t: `<![${id}]>`
|
|
463
502
|
};
|
|
464
503
|
}
|
|
465
504
|
setHydrateContext({ ...ctx,
|
|
466
|
-
count: 0
|
|
505
|
+
count: 0,
|
|
506
|
+
id: ctx.id + "0.f"
|
|
467
507
|
});
|
|
468
|
-
return
|
|
508
|
+
return props.fallback;
|
|
469
509
|
}
|
|
470
510
|
|
|
471
511
|
exports.$PROXY = $PROXY;
|
|
@@ -492,6 +532,7 @@ exports.createRoot = createRoot;
|
|
|
492
532
|
exports.createSelector = createSelector;
|
|
493
533
|
exports.createSignal = createSignal;
|
|
494
534
|
exports.createUniqueId = createUniqueId;
|
|
535
|
+
exports.enableExternalSource = enableExternalSource;
|
|
495
536
|
exports.enableScheduling = enableScheduling;
|
|
496
537
|
exports.equalFn = equalFn;
|
|
497
538
|
exports.from = from;
|
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,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 (!resolved) {
|
|
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) return read.loading =
|
|
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;
|
|
@@ -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,9 +450,9 @@ 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(),
|
|
@@ -442,26 +478,30 @@ function Suspense(props) {
|
|
|
442
478
|
}
|
|
443
479
|
const res = runSuspense();
|
|
444
480
|
if (suspenseComplete(value)) {
|
|
445
|
-
|
|
481
|
+
ctx.writeResource(id, true);
|
|
446
482
|
return res;
|
|
447
483
|
}
|
|
448
|
-
|
|
449
|
-
if (
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}
|
|
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) {
|
|
457
496
|
return {
|
|
458
497
|
t: `<![${id}]>`
|
|
459
498
|
};
|
|
460
499
|
}
|
|
461
500
|
setHydrateContext({ ...ctx,
|
|
462
|
-
count: 0
|
|
501
|
+
count: 0,
|
|
502
|
+
id: ctx.id + "0.f"
|
|
463
503
|
});
|
|
464
|
-
return
|
|
504
|
+
return props.fallback;
|
|
465
505
|
}
|
|
466
506
|
|
|
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 };
|
|
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;
|
|
@@ -232,6 +233,9 @@ function createResource(source, fetcher, options) {
|
|
|
232
233
|
fetcher = source;
|
|
233
234
|
source = true;
|
|
234
235
|
}
|
|
236
|
+
Resources || (Resources = new Set());
|
|
237
|
+
Resources.add(load);
|
|
238
|
+
onCleanup(() => Resources.delete(load));
|
|
235
239
|
const contexts = new Set(),
|
|
236
240
|
[s, set] = createSignal((options || {}).initialValue),
|
|
237
241
|
[track, trigger] = createSignal(undefined, {
|
|
@@ -293,7 +297,7 @@ function createResource(source, fetcher, options) {
|
|
|
293
297
|
}
|
|
294
298
|
return v;
|
|
295
299
|
}
|
|
296
|
-
function load() {
|
|
300
|
+
function load(refetching = true) {
|
|
297
301
|
setError(err = undefined);
|
|
298
302
|
const lookup = dynamic ? source() : source;
|
|
299
303
|
loadedUnderTransition = Transition && Transition.running;
|
|
@@ -302,7 +306,10 @@ function createResource(source, fetcher, options) {
|
|
|
302
306
|
return;
|
|
303
307
|
}
|
|
304
308
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
305
|
-
const p = initP || untrack(() => fetcher(lookup,
|
|
309
|
+
const p = initP || untrack(() => fetcher(lookup, {
|
|
310
|
+
value: s(),
|
|
311
|
+
refetching
|
|
312
|
+
}));
|
|
306
313
|
initP = null;
|
|
307
314
|
if (typeof p !== "object" || !("then" in p)) {
|
|
308
315
|
loadEnd(pr, p);
|
|
@@ -327,12 +334,16 @@ function createResource(source, fetcher, options) {
|
|
|
327
334
|
}
|
|
328
335
|
}
|
|
329
336
|
});
|
|
330
|
-
if (dynamic) createComputed(load);else load();
|
|
337
|
+
if (dynamic) createComputed(() => load(false));else load(false);
|
|
331
338
|
return [read, {
|
|
332
339
|
refetch: load,
|
|
333
340
|
mutate: set
|
|
334
341
|
}];
|
|
335
342
|
}
|
|
343
|
+
let Resources;
|
|
344
|
+
function refetchResources(info) {
|
|
345
|
+
Resources && Resources.forEach(fn => fn(info));
|
|
346
|
+
}
|
|
336
347
|
function createDeferred(source, options) {
|
|
337
348
|
let t,
|
|
338
349
|
timeout = options ? options.timeoutMs : undefined;
|
|
@@ -503,6 +514,24 @@ let SuspenseContext;
|
|
|
503
514
|
function getSuspenseContext() {
|
|
504
515
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
505
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
|
+
}
|
|
506
535
|
function readSignal() {
|
|
507
536
|
const runningTransition = Transition && Transition.running;
|
|
508
537
|
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
@@ -630,6 +659,19 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
630
659
|
if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
|
|
631
660
|
}
|
|
632
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
|
+
}
|
|
633
675
|
return c;
|
|
634
676
|
}
|
|
635
677
|
function runTop(node) {
|
|
@@ -1063,13 +1105,19 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1063
1105
|
};
|
|
1064
1106
|
}
|
|
1065
1107
|
|
|
1108
|
+
let hydrationEnabled = false;
|
|
1109
|
+
function enableHydration() {
|
|
1110
|
+
hydrationEnabled = true;
|
|
1111
|
+
}
|
|
1066
1112
|
function createComponent(Comp, props) {
|
|
1067
|
-
if (
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
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
|
+
}
|
|
1073
1121
|
}
|
|
1074
1122
|
return untrack(() => Comp(props));
|
|
1075
1123
|
}
|
|
@@ -1158,19 +1206,20 @@ function splitProps(props, ...keys) {
|
|
|
1158
1206
|
}
|
|
1159
1207
|
function lazy(fn) {
|
|
1160
1208
|
let comp;
|
|
1209
|
+
let p;
|
|
1161
1210
|
const wrap = props => {
|
|
1162
1211
|
const ctx = sharedConfig.context;
|
|
1163
1212
|
if (ctx) {
|
|
1164
1213
|
ctx.count++;
|
|
1165
1214
|
const [s, set] = createSignal();
|
|
1166
|
-
fn().then(mod => {
|
|
1215
|
+
(p || (p = fn())).then(mod => {
|
|
1167
1216
|
setHydrateContext(ctx);
|
|
1168
1217
|
set(() => mod.default);
|
|
1169
|
-
setHydrateContext(
|
|
1218
|
+
setHydrateContext();
|
|
1170
1219
|
});
|
|
1171
1220
|
comp = s;
|
|
1172
1221
|
} else if (!comp) {
|
|
1173
|
-
const [s] = createResource(() => fn().then(mod => mod.default));
|
|
1222
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1174
1223
|
comp = s;
|
|
1175
1224
|
} else {
|
|
1176
1225
|
const c = comp();
|
|
@@ -1186,7 +1235,7 @@ function lazy(fn) {
|
|
|
1186
1235
|
return r;
|
|
1187
1236
|
}));
|
|
1188
1237
|
};
|
|
1189
|
-
wrap.preload = () =>
|
|
1238
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1190
1239
|
return wrap;
|
|
1191
1240
|
}
|
|
1192
1241
|
let counter = 0;
|
|
@@ -1246,7 +1295,11 @@ function Match(props) {
|
|
|
1246
1295
|
return props;
|
|
1247
1296
|
}
|
|
1248
1297
|
function ErrorBoundary(props) {
|
|
1249
|
-
|
|
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);
|
|
1250
1303
|
let e;
|
|
1251
1304
|
return createMemo(() => {
|
|
1252
1305
|
if ((e = errored()) != null) {
|
|
@@ -1329,8 +1382,9 @@ function Suspense(props) {
|
|
|
1329
1382
|
showContent,
|
|
1330
1383
|
showFallback,
|
|
1331
1384
|
ctx,
|
|
1332
|
-
|
|
1333
|
-
flicker
|
|
1385
|
+
p,
|
|
1386
|
+
flicker,
|
|
1387
|
+
error;
|
|
1334
1388
|
const [inFallback, setFallback] = createSignal(false),
|
|
1335
1389
|
SuspenseContext = getSuspenseContext(),
|
|
1336
1390
|
store = {
|
|
@@ -1345,21 +1399,21 @@ function Suspense(props) {
|
|
|
1345
1399
|
resolved: false
|
|
1346
1400
|
},
|
|
1347
1401
|
owner = getOwner();
|
|
1348
|
-
if (sharedConfig.context
|
|
1402
|
+
if (sharedConfig.context) {
|
|
1349
1403
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1350
|
-
|
|
1351
|
-
if (p) {
|
|
1404
|
+
p = sharedConfig.load(key);
|
|
1405
|
+
if (p && typeof p === "object") {
|
|
1352
1406
|
const [s, set] = createSignal(undefined, {
|
|
1353
1407
|
equals: false
|
|
1354
1408
|
});
|
|
1355
1409
|
flicker = s;
|
|
1356
|
-
p.then(
|
|
1410
|
+
p.then(err => {
|
|
1411
|
+
if (error = err) return set();
|
|
1357
1412
|
sharedConfig.gather(key);
|
|
1358
|
-
waitingHydration = true;
|
|
1359
1413
|
setHydrateContext(ctx);
|
|
1360
1414
|
set();
|
|
1361
|
-
setHydrateContext(
|
|
1362
|
-
|
|
1415
|
+
setHydrateContext();
|
|
1416
|
+
p = undefined;
|
|
1363
1417
|
});
|
|
1364
1418
|
}
|
|
1365
1419
|
}
|
|
@@ -1371,18 +1425,20 @@ function Suspense(props) {
|
|
|
1371
1425
|
value: store,
|
|
1372
1426
|
get children() {
|
|
1373
1427
|
return createMemo(() => {
|
|
1428
|
+
if (error) throw error;
|
|
1429
|
+
ctx = sharedConfig.context;
|
|
1374
1430
|
if (flicker) {
|
|
1375
|
-
ctx = sharedConfig.context;
|
|
1376
1431
|
flicker();
|
|
1377
1432
|
return flicker = undefined;
|
|
1378
1433
|
}
|
|
1434
|
+
if (ctx && p === undefined) setHydrateContext();
|
|
1379
1435
|
const rendered = untrack(() => props.children);
|
|
1380
1436
|
return createMemo(() => {
|
|
1381
1437
|
const inFallback = store.inFallback(),
|
|
1382
1438
|
visibleContent = showContent ? showContent() : true,
|
|
1383
1439
|
visibleFallback = showFallback ? showFallback() : true;
|
|
1384
1440
|
dispose && dispose();
|
|
1385
|
-
if ((!inFallback ||
|
|
1441
|
+
if ((!inFallback || p !== undefined) && visibleContent) {
|
|
1386
1442
|
store.resolved = true;
|
|
1387
1443
|
resumeEffects(store.effects);
|
|
1388
1444
|
return rendered;
|
|
@@ -1390,7 +1446,13 @@ function Suspense(props) {
|
|
|
1390
1446
|
if (!visibleFallback) return;
|
|
1391
1447
|
return createRoot(disposer => {
|
|
1392
1448
|
dispose = disposer;
|
|
1393
|
-
if (
|
|
1449
|
+
if (ctx) {
|
|
1450
|
+
setHydrateContext({
|
|
1451
|
+
id: ctx.id + "f",
|
|
1452
|
+
count: 0
|
|
1453
|
+
});
|
|
1454
|
+
ctx = undefined;
|
|
1455
|
+
}
|
|
1394
1456
|
return props.fallback;
|
|
1395
1457
|
}, owner);
|
|
1396
1458
|
});
|
|
@@ -1426,6 +1488,8 @@ exports.createRoot = createRoot;
|
|
|
1426
1488
|
exports.createSelector = createSelector;
|
|
1427
1489
|
exports.createSignal = createSignal;
|
|
1428
1490
|
exports.createUniqueId = createUniqueId;
|
|
1491
|
+
exports.enableExternalSource = enableExternalSource;
|
|
1492
|
+
exports.enableHydration = enableHydration;
|
|
1429
1493
|
exports.enableScheduling = enableScheduling;
|
|
1430
1494
|
exports.equalFn = equalFn;
|
|
1431
1495
|
exports.from = from;
|
|
@@ -1440,6 +1504,7 @@ exports.on = on;
|
|
|
1440
1504
|
exports.onCleanup = onCleanup;
|
|
1441
1505
|
exports.onError = onError;
|
|
1442
1506
|
exports.onMount = onMount;
|
|
1507
|
+
exports.refetchResources = refetchResources;
|
|
1443
1508
|
exports.requestCallback = requestCallback;
|
|
1444
1509
|
exports.runWithOwner = runWithOwner;
|
|
1445
1510
|
exports.sharedConfig = sharedConfig;
|