solid-js 1.8.17 → 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/README.md +223 -223
- package/dist/dev.cjs +29 -24
- package/dist/dev.js +344 -580
- package/dist/server.cjs +31 -18
- package/dist/server.js +103 -185
- package/dist/solid.cjs +29 -24
- package/dist/solid.js +302 -507
- package/h/dist/h.cjs +12 -1
- package/h/dist/h.js +19 -34
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +8 -11
- package/h/jsx-runtime/types/jsx.d.ts +5 -0
- 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 +62 -219
- package/types/index.d.ts +10 -75
- package/types/jsx.d.ts +5 -0
- package/types/reactive/array.d.ts +6 -14
- package/types/reactive/observable.d.ts +18 -26
- package/types/reactive/scheduler.d.ts +6 -9
- package/types/reactive/signal.d.ts +164 -255
- package/types/render/Suspense.d.ts +7 -7
- package/types/render/component.d.ts +33 -64
- package/types/render/flow.d.ts +37 -49
- 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 +99 -168
- 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 +6 -4
- package/web/dist/dev.js +88 -630
- package/web/dist/server.cjs +6 -6
- package/web/dist/server.js +102 -216
- package/web/dist/web.cjs +6 -4
- package/web/dist/web.js +86 -621
- 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 +12 -29
- 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);
|
|
@@ -468,7 +481,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
468
481
|
source = true;
|
|
469
482
|
}
|
|
470
483
|
const contexts = new Set();
|
|
471
|
-
const id = sharedConfig.
|
|
484
|
+
const id = sharedConfig.getNextContextId();
|
|
472
485
|
let resource = {};
|
|
473
486
|
let value = options.storage ? options.storage(options.initialValue)[0]() : options.initialValue;
|
|
474
487
|
let p;
|
|
@@ -482,8 +495,8 @@ function createResource(source, fetcher, options = {}) {
|
|
|
482
495
|
}
|
|
483
496
|
const read = () => {
|
|
484
497
|
if (error) throw error;
|
|
485
|
-
if (resourceContext && p) resourceContext.push(p);
|
|
486
498
|
const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
|
|
499
|
+
if (!resolved && resourceContext) resourceContext.push(id);
|
|
487
500
|
if (!resolved && read.loading) {
|
|
488
501
|
const ctx = useContext(SuspenseContext);
|
|
489
502
|
if (ctx) {
|
|
@@ -508,14 +521,14 @@ function createResource(source, fetcher, options = {}) {
|
|
|
508
521
|
value = ctx.resources[id].data;
|
|
509
522
|
return;
|
|
510
523
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
524
|
+
let lookup;
|
|
525
|
+
try {
|
|
526
|
+
resourceContext = [];
|
|
527
|
+
lookup = typeof source === "function" ? source() : source;
|
|
528
|
+
if (resourceContext.length) return;
|
|
529
|
+
} finally {
|
|
530
|
+
resourceContext = null;
|
|
517
531
|
}
|
|
518
|
-
resourceContext = null;
|
|
519
532
|
if (!p) {
|
|
520
533
|
if (lookup == null || lookup === false) return;
|
|
521
534
|
p = fetcher(lookup, {
|
|
@@ -621,7 +634,7 @@ function SuspenseList(props) {
|
|
|
621
634
|
function Suspense(props) {
|
|
622
635
|
let done;
|
|
623
636
|
const ctx = sharedConfig.context;
|
|
624
|
-
const id =
|
|
637
|
+
const id = sharedConfig.getContextId();
|
|
625
638
|
const o = createOwner();
|
|
626
639
|
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
627
640
|
resources: new Map(),
|
|
@@ -663,7 +676,7 @@ function Suspense(props) {
|
|
|
663
676
|
setHydrateContext({
|
|
664
677
|
...ctx,
|
|
665
678
|
count: 0,
|
|
666
|
-
id: ctx.id + "
|
|
679
|
+
id: ctx.id + "0F",
|
|
667
680
|
noHydrate: true
|
|
668
681
|
});
|
|
669
682
|
const res = {
|
|
@@ -675,7 +688,7 @@ function Suspense(props) {
|
|
|
675
688
|
setHydrateContext({
|
|
676
689
|
...ctx,
|
|
677
690
|
count: 0,
|
|
678
|
-
id: ctx.id + "
|
|
691
|
+
id: ctx.id + "0F"
|
|
679
692
|
});
|
|
680
693
|
ctx.serialize(id, "$$f");
|
|
681
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;
|
|
@@ -486,7 +479,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
486
479
|
source = true;
|
|
487
480
|
}
|
|
488
481
|
const contexts = new Set();
|
|
489
|
-
const id = sharedConfig.
|
|
482
|
+
const id = sharedConfig.getNextContextId();
|
|
490
483
|
let resource = {};
|
|
491
484
|
let value = options.storage ? options.storage(options.initialValue)[0]() : options.initialValue;
|
|
492
485
|
let p;
|
|
@@ -494,18 +487,14 @@ function createResource(source, fetcher, options = {}) {
|
|
|
494
487
|
if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
|
|
495
488
|
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
496
489
|
if (resource.ref) {
|
|
497
|
-
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
|
|
498
|
-
resource.ref[1].refetch();
|
|
490
|
+
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
|
|
499
491
|
return resource.ref;
|
|
500
492
|
}
|
|
501
493
|
}
|
|
502
494
|
const read = () => {
|
|
503
495
|
if (error) throw error;
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
options.ssrLoadFrom !== "initial" &&
|
|
507
|
-
sharedConfig.context.async &&
|
|
508
|
-
"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);
|
|
509
498
|
if (!resolved && read.loading) {
|
|
510
499
|
const ctx = useContext(SuspenseContext);
|
|
511
500
|
if (ctx) {
|
|
@@ -525,21 +514,19 @@ function createResource(source, fetcher, options = {}) {
|
|
|
525
514
|
});
|
|
526
515
|
function load() {
|
|
527
516
|
const ctx = sharedConfig.context;
|
|
528
|
-
if (!ctx.async) return
|
|
517
|
+
if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
|
|
529
518
|
if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
|
|
530
519
|
value = ctx.resources[id].data;
|
|
531
520
|
return;
|
|
532
521
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
);
|
|
522
|
+
let lookup;
|
|
523
|
+
try {
|
|
524
|
+
resourceContext = [];
|
|
525
|
+
lookup = typeof source === "function" ? source() : source;
|
|
526
|
+
if (resourceContext.length) return;
|
|
527
|
+
} finally {
|
|
528
|
+
resourceContext = null;
|
|
541
529
|
}
|
|
542
|
-
resourceContext = null;
|
|
543
530
|
if (!p) {
|
|
544
531
|
if (lookup == null || lookup === false) return;
|
|
545
532
|
p = fetcher(lookup, {
|
|
@@ -549,23 +536,21 @@ function createResource(source, fetcher, options = {}) {
|
|
|
549
536
|
if (p != undefined && typeof p === "object" && "then" in p) {
|
|
550
537
|
read.loading = true;
|
|
551
538
|
read.state = "pending";
|
|
552
|
-
p = p
|
|
553
|
-
.
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
.
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
throw error;
|
|
568
|
-
});
|
|
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
|
+
});
|
|
569
554
|
if (ctx.serialize) ctx.serialize(id, p, options.deferStream);
|
|
570
555
|
return p;
|
|
571
556
|
}
|
|
@@ -575,20 +560,17 @@ function createResource(source, fetcher, options = {}) {
|
|
|
575
560
|
return ctx.resources[id].data;
|
|
576
561
|
}
|
|
577
562
|
if (options.ssrLoadFrom !== "initial") load();
|
|
578
|
-
return
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
mutate: v => (value = v)
|
|
583
|
-
}
|
|
584
|
-
]);
|
|
563
|
+
return resource.ref = [read, {
|
|
564
|
+
refetch: load,
|
|
565
|
+
mutate: v => value = v
|
|
566
|
+
}];
|
|
585
567
|
}
|
|
586
568
|
function lazy(fn) {
|
|
587
569
|
let p;
|
|
588
570
|
let load = id => {
|
|
589
571
|
if (!p) {
|
|
590
572
|
p = fn();
|
|
591
|
-
p.then(mod =>
|
|
573
|
+
p.then(mod => p.resolved = mod.default);
|
|
592
574
|
if (id) sharedConfig.context.lazy[id] = p;
|
|
593
575
|
}
|
|
594
576
|
return p;
|
|
@@ -597,8 +579,7 @@ function lazy(fn) {
|
|
|
597
579
|
const wrap = props => {
|
|
598
580
|
const id = sharedConfig.context.id.slice(0, -1);
|
|
599
581
|
let ref = sharedConfig.context.lazy[id];
|
|
600
|
-
if (ref) p = ref;
|
|
601
|
-
else load(id);
|
|
582
|
+
if (ref) p = ref;else load(id);
|
|
602
583
|
if (p.resolved) return p.resolved(props);
|
|
603
584
|
const ctx = useContext(SuspenseContext);
|
|
604
585
|
const track = {
|
|
@@ -610,12 +591,10 @@ function lazy(fn) {
|
|
|
610
591
|
contexts.add(ctx);
|
|
611
592
|
}
|
|
612
593
|
if (sharedConfig.context.async) {
|
|
613
|
-
sharedConfig.context.block(
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
})
|
|
618
|
-
);
|
|
594
|
+
sharedConfig.context.block(p.then(() => {
|
|
595
|
+
track.loading = false;
|
|
596
|
+
notifySuspense(contexts);
|
|
597
|
+
}));
|
|
619
598
|
}
|
|
620
599
|
return "";
|
|
621
600
|
};
|
|
@@ -643,12 +622,9 @@ function startTransition(fn) {
|
|
|
643
622
|
fn();
|
|
644
623
|
}
|
|
645
624
|
function useTransition() {
|
|
646
|
-
return [
|
|
647
|
-
()
|
|
648
|
-
|
|
649
|
-
fn();
|
|
650
|
-
}
|
|
651
|
-
];
|
|
625
|
+
return [() => false, fn => {
|
|
626
|
+
fn();
|
|
627
|
+
}];
|
|
652
628
|
}
|
|
653
629
|
function SuspenseList(props) {
|
|
654
630
|
return props.children;
|
|
@@ -656,19 +632,17 @@ function SuspenseList(props) {
|
|
|
656
632
|
function Suspense(props) {
|
|
657
633
|
let done;
|
|
658
634
|
const ctx = sharedConfig.context;
|
|
659
|
-
const id =
|
|
635
|
+
const id = sharedConfig.getContextId();
|
|
660
636
|
const o = createOwner();
|
|
661
|
-
const value =
|
|
662
|
-
|
|
663
|
-
(
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
if (suspenseComplete(value)) {
|
|
668
|
-
done(resolveSSRNode(res));
|
|
669
|
-
}
|
|
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));
|
|
670
643
|
}
|
|
671
|
-
}
|
|
644
|
+
}
|
|
645
|
+
});
|
|
672
646
|
function suspenseError(err) {
|
|
673
647
|
if (!done || !done(undefined, err)) {
|
|
674
648
|
runWithOwner(o.owner, () => {
|
|
@@ -682,14 +656,12 @@ function Suspense(props) {
|
|
|
682
656
|
count: 0
|
|
683
657
|
});
|
|
684
658
|
cleanNode(o);
|
|
685
|
-
return runWithOwner(o, () =>
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
})
|
|
692
|
-
);
|
|
659
|
+
return runWithOwner(o, () => createComponent(SuspenseContext.Provider, {
|
|
660
|
+
value,
|
|
661
|
+
get children() {
|
|
662
|
+
return catchError(() => props.children, suspenseError);
|
|
663
|
+
}
|
|
664
|
+
}));
|
|
693
665
|
}
|
|
694
666
|
const res = runSuspense();
|
|
695
667
|
if (suspenseComplete(value)) {
|
|
@@ -702,7 +674,7 @@ function Suspense(props) {
|
|
|
702
674
|
setHydrateContext({
|
|
703
675
|
...ctx,
|
|
704
676
|
count: 0,
|
|
705
|
-
id: ctx.id + "
|
|
677
|
+
id: ctx.id + "0F",
|
|
706
678
|
noHydrate: true
|
|
707
679
|
});
|
|
708
680
|
const res = {
|
|
@@ -714,65 +686,11 @@ function Suspense(props) {
|
|
|
714
686
|
setHydrateContext({
|
|
715
687
|
...ctx,
|
|
716
688
|
count: 0,
|
|
717
|
-
id: ctx.id + "
|
|
689
|
+
id: ctx.id + "0F"
|
|
718
690
|
});
|
|
719
691
|
ctx.serialize(id, "$$f");
|
|
720
692
|
return props.fallback;
|
|
721
693
|
}, suspenseError);
|
|
722
694
|
}
|
|
723
695
|
|
|
724
|
-
export {
|
|
725
|
-
$DEVCOMP,
|
|
726
|
-
$PROXY,
|
|
727
|
-
$TRACK,
|
|
728
|
-
DEV,
|
|
729
|
-
ErrorBoundary,
|
|
730
|
-
For,
|
|
731
|
-
Index,
|
|
732
|
-
Match,
|
|
733
|
-
Show,
|
|
734
|
-
Suspense,
|
|
735
|
-
SuspenseList,
|
|
736
|
-
Switch,
|
|
737
|
-
batch,
|
|
738
|
-
catchError,
|
|
739
|
-
children,
|
|
740
|
-
createComponent,
|
|
741
|
-
createComputed,
|
|
742
|
-
createContext,
|
|
743
|
-
createDeferred,
|
|
744
|
-
createEffect,
|
|
745
|
-
createMemo,
|
|
746
|
-
createReaction,
|
|
747
|
-
createRenderEffect,
|
|
748
|
-
createResource,
|
|
749
|
-
createRoot,
|
|
750
|
-
createSelector,
|
|
751
|
-
createSignal,
|
|
752
|
-
createUniqueId,
|
|
753
|
-
enableExternalSource,
|
|
754
|
-
enableHydration,
|
|
755
|
-
enableScheduling,
|
|
756
|
-
equalFn,
|
|
757
|
-
from,
|
|
758
|
-
getListener,
|
|
759
|
-
getOwner,
|
|
760
|
-
indexArray,
|
|
761
|
-
lazy,
|
|
762
|
-
mapArray,
|
|
763
|
-
mergeProps,
|
|
764
|
-
observable,
|
|
765
|
-
on,
|
|
766
|
-
onCleanup,
|
|
767
|
-
onError,
|
|
768
|
-
onMount,
|
|
769
|
-
requestCallback,
|
|
770
|
-
resetErrorBoundaries,
|
|
771
|
-
runWithOwner,
|
|
772
|
-
sharedConfig,
|
|
773
|
-
splitProps,
|
|
774
|
-
startTransition,
|
|
775
|
-
untrack,
|
|
776
|
-
useContext,
|
|
777
|
-
useTransition
|
|
778
|
-
};
|
|
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 };
|