solid-js 1.8.18 → 1.8.19
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/dist/dev.cjs +28 -23
- package/dist/dev.js +344 -580
- package/dist/server.cjs +33 -11
- package/dist/server.js +105 -176
- package/dist/solid.cjs +28 -23
- package/dist/solid.js +302 -507
- package/h/dist/h.js +9 -38
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +8 -11
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +94 -216
- package/html/types/lit.d.ts +33 -47
- package/package.json +3 -3
- package/store/dist/dev.js +43 -122
- package/store/dist/server.js +8 -19
- package/store/dist/store.js +40 -113
- package/store/types/index.d.ts +7 -21
- package/store/types/modifiers.d.ts +3 -6
- package/store/types/mutable.d.ts +2 -5
- package/store/types/server.d.ts +4 -12
- package/store/types/store.d.ts +61 -218
- package/types/index.d.ts +10 -75
- package/types/reactive/array.d.ts +4 -12
- package/types/reactive/observable.d.ts +17 -25
- package/types/reactive/scheduler.d.ts +6 -9
- package/types/reactive/signal.d.ts +142 -233
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +33 -64
- package/types/render/flow.d.ts +31 -43
- package/types/render/hydration.d.ts +15 -13
- package/types/server/index.d.ts +2 -57
- package/types/server/reactive.d.ts +42 -73
- package/types/server/rendering.d.ts +98 -167
- package/universal/dist/dev.js +12 -28
- package/universal/dist/universal.js +12 -28
- package/universal/types/index.d.ts +1 -3
- package/universal/types/universal.d.ts +1 -0
- package/web/dist/dev.cjs +2 -3
- package/web/dist/dev.js +84 -629
- package/web/dist/server.cjs +3 -3
- package/web/dist/server.js +99 -213
- package/web/dist/web.cjs +2 -3
- package/web/dist/web.js +82 -620
- package/web/storage/dist/storage.js +3 -3
- package/web/types/client.d.ts +2 -2
- package/web/types/core.d.ts +1 -10
- package/web/types/index.d.ts +10 -27
- package/web/types/server-mock.d.ts +32 -47
package/dist/server.cjs
CHANGED
|
@@ -319,21 +319,34 @@ function resolveSSRNode(node) {
|
|
|
319
319
|
if (t === "function") return resolveSSRNode(node());
|
|
320
320
|
return String(node);
|
|
321
321
|
}
|
|
322
|
-
const sharedConfig = {
|
|
322
|
+
const sharedConfig = {
|
|
323
|
+
context: undefined,
|
|
324
|
+
getContextId() {
|
|
325
|
+
if (!this.context) throw new Error(`getContextId cannot be used under non-hydrating context`);
|
|
326
|
+
return getContextId(this.context.count);
|
|
327
|
+
},
|
|
328
|
+
getNextContextId() {
|
|
329
|
+
if (!this.context) throw new Error(`getNextContextId cannot be used under non-hydrating context`);
|
|
330
|
+
return getContextId(this.context.count++);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
function getContextId(count) {
|
|
334
|
+
const num = String(count),
|
|
335
|
+
len = num.length - 1;
|
|
336
|
+
return sharedConfig.context.id + (len ? String.fromCharCode(96 + len) : "") + num;
|
|
337
|
+
}
|
|
323
338
|
function setHydrateContext(context) {
|
|
324
339
|
sharedConfig.context = context;
|
|
325
340
|
}
|
|
326
341
|
function nextHydrateContext() {
|
|
327
342
|
return sharedConfig.context ? {
|
|
328
343
|
...sharedConfig.context,
|
|
329
|
-
id:
|
|
344
|
+
id: sharedConfig.getNextContextId(),
|
|
330
345
|
count: 0
|
|
331
346
|
} : undefined;
|
|
332
347
|
}
|
|
333
348
|
function createUniqueId() {
|
|
334
|
-
|
|
335
|
-
if (!ctx) throw new Error(`createUniqueId cannot be used under non-hydrating context`);
|
|
336
|
-
return `${ctx.id}${ctx.count++}`;
|
|
349
|
+
return sharedConfig.getNextContextId();
|
|
337
350
|
}
|
|
338
351
|
function createComponent(Comp, props) {
|
|
339
352
|
if (sharedConfig.context && !sharedConfig.context.noHydrate) {
|
|
@@ -429,7 +442,7 @@ function ErrorBoundary(props) {
|
|
|
429
442
|
clean,
|
|
430
443
|
sync = true;
|
|
431
444
|
const ctx = sharedConfig.context;
|
|
432
|
-
const id =
|
|
445
|
+
const id = sharedConfig.getContextId();
|
|
433
446
|
function displayFallback() {
|
|
434
447
|
cleanNode(clean);
|
|
435
448
|
ctx.serialize(id, error);
|
|
@@ -455,6 +468,7 @@ function ErrorBoundary(props) {
|
|
|
455
468
|
};
|
|
456
469
|
}
|
|
457
470
|
const SuspenseContext = createContext();
|
|
471
|
+
let resourceContext = null;
|
|
458
472
|
function createResource(source, fetcher, options = {}) {
|
|
459
473
|
if (arguments.length === 2) {
|
|
460
474
|
if (typeof fetcher === "object") {
|
|
@@ -467,7 +481,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
467
481
|
source = true;
|
|
468
482
|
}
|
|
469
483
|
const contexts = new Set();
|
|
470
|
-
const id = sharedConfig.
|
|
484
|
+
const id = sharedConfig.getNextContextId();
|
|
471
485
|
let resource = {};
|
|
472
486
|
let value = options.storage ? options.storage(options.initialValue)[0]() : options.initialValue;
|
|
473
487
|
let p;
|
|
@@ -482,6 +496,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
482
496
|
const read = () => {
|
|
483
497
|
if (error) throw error;
|
|
484
498
|
const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
|
|
499
|
+
if (!resolved && resourceContext) resourceContext.push(id);
|
|
485
500
|
if (!resolved && read.loading) {
|
|
486
501
|
const ctx = useContext(SuspenseContext);
|
|
487
502
|
if (ctx) {
|
|
@@ -506,7 +521,14 @@ function createResource(source, fetcher, options = {}) {
|
|
|
506
521
|
value = ctx.resources[id].data;
|
|
507
522
|
return;
|
|
508
523
|
}
|
|
509
|
-
|
|
524
|
+
let lookup;
|
|
525
|
+
try {
|
|
526
|
+
resourceContext = [];
|
|
527
|
+
lookup = typeof source === "function" ? source() : source;
|
|
528
|
+
if (resourceContext.length) return;
|
|
529
|
+
} finally {
|
|
530
|
+
resourceContext = null;
|
|
531
|
+
}
|
|
510
532
|
if (!p) {
|
|
511
533
|
if (lookup == null || lookup === false) return;
|
|
512
534
|
p = fetcher(lookup, {
|
|
@@ -612,7 +634,7 @@ function SuspenseList(props) {
|
|
|
612
634
|
function Suspense(props) {
|
|
613
635
|
let done;
|
|
614
636
|
const ctx = sharedConfig.context;
|
|
615
|
-
const id =
|
|
637
|
+
const id = sharedConfig.getContextId();
|
|
616
638
|
const o = createOwner();
|
|
617
639
|
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
618
640
|
resources: new Map(),
|
|
@@ -654,7 +676,7 @@ function Suspense(props) {
|
|
|
654
676
|
setHydrateContext({
|
|
655
677
|
...ctx,
|
|
656
678
|
count: 0,
|
|
657
|
-
id: ctx.id + "
|
|
679
|
+
id: ctx.id + "0F",
|
|
658
680
|
noHydrate: true
|
|
659
681
|
});
|
|
660
682
|
const res = {
|
|
@@ -666,7 +688,7 @@ function Suspense(props) {
|
|
|
666
688
|
setHydrateContext({
|
|
667
689
|
...ctx,
|
|
668
690
|
count: 0,
|
|
669
|
-
id: ctx.id + "
|
|
691
|
+
id: ctx.id + "0F"
|
|
670
692
|
});
|
|
671
693
|
ctx.serialize(id, "$$f");
|
|
672
694
|
return props.fallback;
|
package/dist/server.js
CHANGED
|
@@ -17,7 +17,7 @@ function handleError(err, owner = Owner) {
|
|
|
17
17
|
try {
|
|
18
18
|
for (const f of fns) f(error);
|
|
19
19
|
} catch (e) {
|
|
20
|
-
handleError(e,
|
|
20
|
+
handleError(e, owner && owner.owner || null);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
const UNOWNED = {
|
|
@@ -35,23 +35,19 @@ function createOwner() {
|
|
|
35
35
|
cleanups: null
|
|
36
36
|
};
|
|
37
37
|
if (Owner) {
|
|
38
|
-
if (!Owner.owned) Owner.owned = [o];
|
|
39
|
-
else Owner.owned.push(o);
|
|
38
|
+
if (!Owner.owned) Owner.owned = [o];else Owner.owned.push(o);
|
|
40
39
|
}
|
|
41
40
|
return o;
|
|
42
41
|
}
|
|
43
42
|
function createRoot(fn, detachedOwner) {
|
|
44
43
|
const owner = Owner,
|
|
45
44
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
46
|
-
root =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
owned: null,
|
|
53
|
-
cleanups: null
|
|
54
|
-
};
|
|
45
|
+
root = fn.length === 0 ? UNOWNED : {
|
|
46
|
+
context: current ? current.context : null,
|
|
47
|
+
owner: current,
|
|
48
|
+
owned: null,
|
|
49
|
+
cleanups: null
|
|
50
|
+
};
|
|
55
51
|
Owner = root;
|
|
56
52
|
let result;
|
|
57
53
|
try {
|
|
@@ -64,12 +60,9 @@ function createRoot(fn, detachedOwner) {
|
|
|
64
60
|
return result;
|
|
65
61
|
}
|
|
66
62
|
function createSignal(value, options) {
|
|
67
|
-
return [
|
|
68
|
-
()
|
|
69
|
-
|
|
70
|
-
return (value = typeof v === "function" ? v(value) : v);
|
|
71
|
-
}
|
|
72
|
-
];
|
|
63
|
+
return [() => value, v => {
|
|
64
|
+
return value = typeof v === "function" ? v(value) : v;
|
|
65
|
+
}];
|
|
73
66
|
}
|
|
74
67
|
function createComputed(fn, value) {
|
|
75
68
|
Owner = createOwner();
|
|
@@ -126,8 +119,7 @@ function on(deps, fn, options = {}) {
|
|
|
126
119
|
function onMount(fn) {}
|
|
127
120
|
function onCleanup(fn) {
|
|
128
121
|
if (Owner) {
|
|
129
|
-
if (!Owner.cleanups) Owner.cleanups = [fn];
|
|
130
|
-
else Owner.cleanups.push(fn);
|
|
122
|
+
if (!Owner.cleanups) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
|
|
131
123
|
}
|
|
132
124
|
return fn;
|
|
133
125
|
}
|
|
@@ -168,9 +160,7 @@ function createContext(defaultValue) {
|
|
|
168
160
|
};
|
|
169
161
|
}
|
|
170
162
|
function useContext(context) {
|
|
171
|
-
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
172
|
-
? Owner.context[context.id]
|
|
173
|
-
: context.defaultValue;
|
|
163
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined ? Owner.context[context.id] : context.defaultValue;
|
|
174
164
|
}
|
|
175
165
|
function getOwner() {
|
|
176
166
|
return Owner;
|
|
@@ -247,8 +237,7 @@ function observable(input) {
|
|
|
247
237
|
if (!(observer instanceof Object) || observer == null) {
|
|
248
238
|
throw new TypeError("Expected the observer to be an object.");
|
|
249
239
|
}
|
|
250
|
-
const handler =
|
|
251
|
-
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
240
|
+
const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
252
241
|
if (!handler) {
|
|
253
242
|
return {
|
|
254
243
|
unsubscribe() {}
|
|
@@ -277,7 +266,7 @@ function from(producer) {
|
|
|
277
266
|
const [s, set] = createSignal(undefined);
|
|
278
267
|
if ("subscribe" in producer) {
|
|
279
268
|
const unsub = producer.subscribe(v => set(() => v));
|
|
280
|
-
onCleanup(() =>
|
|
269
|
+
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
281
270
|
} else {
|
|
282
271
|
const clean = producer(set);
|
|
283
272
|
onCleanup(clean);
|
|
@@ -320,7 +309,7 @@ function resolveSSRNode(node) {
|
|
|
320
309
|
let mapped = "";
|
|
321
310
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
322
311
|
if (typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
|
|
323
|
-
mapped += resolveSSRNode(
|
|
312
|
+
mapped += resolveSSRNode(prev = node[i]);
|
|
324
313
|
}
|
|
325
314
|
return mapped;
|
|
326
315
|
}
|
|
@@ -328,23 +317,34 @@ function resolveSSRNode(node) {
|
|
|
328
317
|
if (t === "function") return resolveSSRNode(node());
|
|
329
318
|
return String(node);
|
|
330
319
|
}
|
|
331
|
-
const sharedConfig = {
|
|
320
|
+
const sharedConfig = {
|
|
321
|
+
context: undefined,
|
|
322
|
+
getContextId() {
|
|
323
|
+
if (!this.context) throw new Error(`getContextId cannot be used under non-hydrating context`);
|
|
324
|
+
return getContextId(this.context.count);
|
|
325
|
+
},
|
|
326
|
+
getNextContextId() {
|
|
327
|
+
if (!this.context) throw new Error(`getNextContextId cannot be used under non-hydrating context`);
|
|
328
|
+
return getContextId(this.context.count++);
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
function getContextId(count) {
|
|
332
|
+
const num = String(count),
|
|
333
|
+
len = num.length - 1;
|
|
334
|
+
return sharedConfig.context.id + (len ? String.fromCharCode(96 + len) : "") + num;
|
|
335
|
+
}
|
|
332
336
|
function setHydrateContext(context) {
|
|
333
337
|
sharedConfig.context = context;
|
|
334
338
|
}
|
|
335
339
|
function nextHydrateContext() {
|
|
336
|
-
return sharedConfig.context
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
342
|
-
: undefined;
|
|
340
|
+
return sharedConfig.context ? {
|
|
341
|
+
...sharedConfig.context,
|
|
342
|
+
id: sharedConfig.getNextContextId(),
|
|
343
|
+
count: 0
|
|
344
|
+
} : undefined;
|
|
343
345
|
}
|
|
344
346
|
function createUniqueId() {
|
|
345
|
-
|
|
346
|
-
if (!ctx) throw new Error(`createUniqueId cannot be used under non-hydrating context`);
|
|
347
|
-
return `${ctx.id}${ctx.count++}`;
|
|
347
|
+
return sharedConfig.getNextContextId();
|
|
348
348
|
}
|
|
349
349
|
function createComponent(Comp, props) {
|
|
350
350
|
if (sharedConfig.context && !sharedConfig.context.noHydrate) {
|
|
@@ -416,11 +416,7 @@ function Index(props) {
|
|
|
416
416
|
}
|
|
417
417
|
function Show(props) {
|
|
418
418
|
let c;
|
|
419
|
-
return props.when
|
|
420
|
-
? typeof (c = props.children) === "function"
|
|
421
|
-
? c(props.keyed ? props.when : () => props.when)
|
|
422
|
-
: c
|
|
423
|
-
: props.fallback || "";
|
|
419
|
+
return props.when ? typeof (c = props.children) === "function" ? c(props.keyed ? props.when : () => props.when) : c : props.fallback || "";
|
|
424
420
|
}
|
|
425
421
|
function Switch(props) {
|
|
426
422
|
let conditions = props.children;
|
|
@@ -444,7 +440,7 @@ function ErrorBoundary(props) {
|
|
|
444
440
|
clean,
|
|
445
441
|
sync = true;
|
|
446
442
|
const ctx = sharedConfig.context;
|
|
447
|
-
const id =
|
|
443
|
+
const id = sharedConfig.getContextId();
|
|
448
444
|
function displayFallback() {
|
|
449
445
|
cleanNode(clean);
|
|
450
446
|
ctx.serialize(id, error);
|
|
@@ -457,14 +453,11 @@ function ErrorBoundary(props) {
|
|
|
457
453
|
}
|
|
458
454
|
createMemo(() => {
|
|
459
455
|
clean = Owner;
|
|
460
|
-
return catchError(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
sync = true;
|
|
466
|
-
}
|
|
467
|
-
);
|
|
456
|
+
return catchError(() => res = props.children, err => {
|
|
457
|
+
error = err;
|
|
458
|
+
!sync && ctx.replace("e" + id, displayFallback);
|
|
459
|
+
sync = true;
|
|
460
|
+
});
|
|
468
461
|
});
|
|
469
462
|
if (error) return displayFallback();
|
|
470
463
|
sync = false;
|
|
@@ -473,6 +466,7 @@ function ErrorBoundary(props) {
|
|
|
473
466
|
};
|
|
474
467
|
}
|
|
475
468
|
const SuspenseContext = createContext();
|
|
469
|
+
let resourceContext = null;
|
|
476
470
|
function createResource(source, fetcher, options = {}) {
|
|
477
471
|
if (arguments.length === 2) {
|
|
478
472
|
if (typeof fetcher === "object") {
|
|
@@ -485,7 +479,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
485
479
|
source = true;
|
|
486
480
|
}
|
|
487
481
|
const contexts = new Set();
|
|
488
|
-
const id = sharedConfig.
|
|
482
|
+
const id = sharedConfig.getNextContextId();
|
|
489
483
|
let resource = {};
|
|
490
484
|
let value = options.storage ? options.storage(options.initialValue)[0]() : options.initialValue;
|
|
491
485
|
let p;
|
|
@@ -493,17 +487,14 @@ function createResource(source, fetcher, options = {}) {
|
|
|
493
487
|
if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
|
|
494
488
|
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
495
489
|
if (resource.ref) {
|
|
496
|
-
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
|
|
497
|
-
resource.ref[1].refetch();
|
|
490
|
+
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
|
|
498
491
|
return resource.ref;
|
|
499
492
|
}
|
|
500
493
|
}
|
|
501
494
|
const read = () => {
|
|
502
495
|
if (error) throw error;
|
|
503
|
-
const resolved =
|
|
504
|
-
|
|
505
|
-
sharedConfig.context.async &&
|
|
506
|
-
"data" in sharedConfig.context.resources[id];
|
|
496
|
+
const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
|
|
497
|
+
if (!resolved && resourceContext) resourceContext.push(id);
|
|
507
498
|
if (!resolved && read.loading) {
|
|
508
499
|
const ctx = useContext(SuspenseContext);
|
|
509
500
|
if (ctx) {
|
|
@@ -523,12 +514,19 @@ function createResource(source, fetcher, options = {}) {
|
|
|
523
514
|
});
|
|
524
515
|
function load() {
|
|
525
516
|
const ctx = sharedConfig.context;
|
|
526
|
-
if (!ctx.async) return
|
|
517
|
+
if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
|
|
527
518
|
if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
|
|
528
519
|
value = ctx.resources[id].data;
|
|
529
520
|
return;
|
|
530
521
|
}
|
|
531
|
-
|
|
522
|
+
let lookup;
|
|
523
|
+
try {
|
|
524
|
+
resourceContext = [];
|
|
525
|
+
lookup = typeof source === "function" ? source() : source;
|
|
526
|
+
if (resourceContext.length) return;
|
|
527
|
+
} finally {
|
|
528
|
+
resourceContext = null;
|
|
529
|
+
}
|
|
532
530
|
if (!p) {
|
|
533
531
|
if (lookup == null || lookup === false) return;
|
|
534
532
|
p = fetcher(lookup, {
|
|
@@ -538,23 +536,21 @@ function createResource(source, fetcher, options = {}) {
|
|
|
538
536
|
if (p != undefined && typeof p === "object" && "then" in p) {
|
|
539
537
|
read.loading = true;
|
|
540
538
|
read.state = "pending";
|
|
541
|
-
p = p
|
|
542
|
-
.
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
.
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
throw error;
|
|
557
|
-
});
|
|
539
|
+
p = p.then(res => {
|
|
540
|
+
read.loading = false;
|
|
541
|
+
read.state = "ready";
|
|
542
|
+
ctx.resources[id].data = res;
|
|
543
|
+
p = null;
|
|
544
|
+
notifySuspense(contexts);
|
|
545
|
+
return res;
|
|
546
|
+
}).catch(err => {
|
|
547
|
+
read.loading = false;
|
|
548
|
+
read.state = "errored";
|
|
549
|
+
read.error = error = castError(err);
|
|
550
|
+
p = null;
|
|
551
|
+
notifySuspense(contexts);
|
|
552
|
+
throw error;
|
|
553
|
+
});
|
|
558
554
|
if (ctx.serialize) ctx.serialize(id, p, options.deferStream);
|
|
559
555
|
return p;
|
|
560
556
|
}
|
|
@@ -564,20 +560,17 @@ function createResource(source, fetcher, options = {}) {
|
|
|
564
560
|
return ctx.resources[id].data;
|
|
565
561
|
}
|
|
566
562
|
if (options.ssrLoadFrom !== "initial") load();
|
|
567
|
-
return
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
mutate: v => (value = v)
|
|
572
|
-
}
|
|
573
|
-
]);
|
|
563
|
+
return resource.ref = [read, {
|
|
564
|
+
refetch: load,
|
|
565
|
+
mutate: v => value = v
|
|
566
|
+
}];
|
|
574
567
|
}
|
|
575
568
|
function lazy(fn) {
|
|
576
569
|
let p;
|
|
577
570
|
let load = id => {
|
|
578
571
|
if (!p) {
|
|
579
572
|
p = fn();
|
|
580
|
-
p.then(mod =>
|
|
573
|
+
p.then(mod => p.resolved = mod.default);
|
|
581
574
|
if (id) sharedConfig.context.lazy[id] = p;
|
|
582
575
|
}
|
|
583
576
|
return p;
|
|
@@ -586,8 +579,7 @@ function lazy(fn) {
|
|
|
586
579
|
const wrap = props => {
|
|
587
580
|
const id = sharedConfig.context.id.slice(0, -1);
|
|
588
581
|
let ref = sharedConfig.context.lazy[id];
|
|
589
|
-
if (ref) p = ref;
|
|
590
|
-
else load(id);
|
|
582
|
+
if (ref) p = ref;else load(id);
|
|
591
583
|
if (p.resolved) return p.resolved(props);
|
|
592
584
|
const ctx = useContext(SuspenseContext);
|
|
593
585
|
const track = {
|
|
@@ -599,12 +591,10 @@ function lazy(fn) {
|
|
|
599
591
|
contexts.add(ctx);
|
|
600
592
|
}
|
|
601
593
|
if (sharedConfig.context.async) {
|
|
602
|
-
sharedConfig.context.block(
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
})
|
|
607
|
-
);
|
|
594
|
+
sharedConfig.context.block(p.then(() => {
|
|
595
|
+
track.loading = false;
|
|
596
|
+
notifySuspense(contexts);
|
|
597
|
+
}));
|
|
608
598
|
}
|
|
609
599
|
return "";
|
|
610
600
|
};
|
|
@@ -632,12 +622,9 @@ function startTransition(fn) {
|
|
|
632
622
|
fn();
|
|
633
623
|
}
|
|
634
624
|
function useTransition() {
|
|
635
|
-
return [
|
|
636
|
-
()
|
|
637
|
-
|
|
638
|
-
fn();
|
|
639
|
-
}
|
|
640
|
-
];
|
|
625
|
+
return [() => false, fn => {
|
|
626
|
+
fn();
|
|
627
|
+
}];
|
|
641
628
|
}
|
|
642
629
|
function SuspenseList(props) {
|
|
643
630
|
return props.children;
|
|
@@ -645,19 +632,17 @@ function SuspenseList(props) {
|
|
|
645
632
|
function Suspense(props) {
|
|
646
633
|
let done;
|
|
647
634
|
const ctx = sharedConfig.context;
|
|
648
|
-
const id =
|
|
635
|
+
const id = sharedConfig.getContextId();
|
|
649
636
|
const o = createOwner();
|
|
650
|
-
const value =
|
|
651
|
-
|
|
652
|
-
(
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
if (suspenseComplete(value)) {
|
|
657
|
-
done(resolveSSRNode(res));
|
|
658
|
-
}
|
|
637
|
+
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
638
|
+
resources: new Map(),
|
|
639
|
+
completed: () => {
|
|
640
|
+
const res = runSuspense();
|
|
641
|
+
if (suspenseComplete(value)) {
|
|
642
|
+
done(resolveSSRNode(res));
|
|
659
643
|
}
|
|
660
|
-
}
|
|
644
|
+
}
|
|
645
|
+
});
|
|
661
646
|
function suspenseError(err) {
|
|
662
647
|
if (!done || !done(undefined, err)) {
|
|
663
648
|
runWithOwner(o.owner, () => {
|
|
@@ -671,14 +656,12 @@ function Suspense(props) {
|
|
|
671
656
|
count: 0
|
|
672
657
|
});
|
|
673
658
|
cleanNode(o);
|
|
674
|
-
return runWithOwner(o, () =>
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
})
|
|
681
|
-
);
|
|
659
|
+
return runWithOwner(o, () => createComponent(SuspenseContext.Provider, {
|
|
660
|
+
value,
|
|
661
|
+
get children() {
|
|
662
|
+
return catchError(() => props.children, suspenseError);
|
|
663
|
+
}
|
|
664
|
+
}));
|
|
682
665
|
}
|
|
683
666
|
const res = runSuspense();
|
|
684
667
|
if (suspenseComplete(value)) {
|
|
@@ -691,7 +674,7 @@ function Suspense(props) {
|
|
|
691
674
|
setHydrateContext({
|
|
692
675
|
...ctx,
|
|
693
676
|
count: 0,
|
|
694
|
-
id: ctx.id + "
|
|
677
|
+
id: ctx.id + "0F",
|
|
695
678
|
noHydrate: true
|
|
696
679
|
});
|
|
697
680
|
const res = {
|
|
@@ -703,65 +686,11 @@ function Suspense(props) {
|
|
|
703
686
|
setHydrateContext({
|
|
704
687
|
...ctx,
|
|
705
688
|
count: 0,
|
|
706
|
-
id: ctx.id + "
|
|
689
|
+
id: ctx.id + "0F"
|
|
707
690
|
});
|
|
708
691
|
ctx.serialize(id, "$$f");
|
|
709
692
|
return props.fallback;
|
|
710
693
|
}, suspenseError);
|
|
711
694
|
}
|
|
712
695
|
|
|
713
|
-
export {
|
|
714
|
-
$DEVCOMP,
|
|
715
|
-
$PROXY,
|
|
716
|
-
$TRACK,
|
|
717
|
-
DEV,
|
|
718
|
-
ErrorBoundary,
|
|
719
|
-
For,
|
|
720
|
-
Index,
|
|
721
|
-
Match,
|
|
722
|
-
Show,
|
|
723
|
-
Suspense,
|
|
724
|
-
SuspenseList,
|
|
725
|
-
Switch,
|
|
726
|
-
batch,
|
|
727
|
-
catchError,
|
|
728
|
-
children,
|
|
729
|
-
createComponent,
|
|
730
|
-
createComputed,
|
|
731
|
-
createContext,
|
|
732
|
-
createDeferred,
|
|
733
|
-
createEffect,
|
|
734
|
-
createMemo,
|
|
735
|
-
createReaction,
|
|
736
|
-
createRenderEffect,
|
|
737
|
-
createResource,
|
|
738
|
-
createRoot,
|
|
739
|
-
createSelector,
|
|
740
|
-
createSignal,
|
|
741
|
-
createUniqueId,
|
|
742
|
-
enableExternalSource,
|
|
743
|
-
enableHydration,
|
|
744
|
-
enableScheduling,
|
|
745
|
-
equalFn,
|
|
746
|
-
from,
|
|
747
|
-
getListener,
|
|
748
|
-
getOwner,
|
|
749
|
-
indexArray,
|
|
750
|
-
lazy,
|
|
751
|
-
mapArray,
|
|
752
|
-
mergeProps,
|
|
753
|
-
observable,
|
|
754
|
-
on,
|
|
755
|
-
onCleanup,
|
|
756
|
-
onError,
|
|
757
|
-
onMount,
|
|
758
|
-
requestCallback,
|
|
759
|
-
resetErrorBoundaries,
|
|
760
|
-
runWithOwner,
|
|
761
|
-
sharedConfig,
|
|
762
|
-
splitProps,
|
|
763
|
-
startTransition,
|
|
764
|
-
untrack,
|
|
765
|
-
useContext,
|
|
766
|
-
useTransition
|
|
767
|
-
};
|
|
696
|
+
export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, catchError, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|