solid-js 1.7.9 → 1.7.11
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 +36 -20
- package/dist/dev.js +326 -548
- package/dist/server.cjs +38 -23
- package/dist/server.js +108 -192
- package/dist/solid.cjs +36 -20
- package/dist/solid.js +284 -475
- package/h/dist/h.js +8 -34
- 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 +31 -45
- package/package.json +1 -1
- package/store/dist/dev.cjs +4 -3
- package/store/dist/dev.js +46 -117
- package/store/dist/server.js +8 -19
- package/store/dist/store.cjs +4 -3
- package/store/dist/store.js +43 -108
- 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 -215
- package/types/index.d.ts +9 -69
- 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 +150 -236
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +31 -62
- package/types/render/flow.d.ts +31 -43
- package/types/render/hydration.d.ts +12 -12
- package/types/server/index.d.ts +2 -55
- package/types/server/reactive.d.ts +44 -72
- package/types/server/rendering.d.ts +95 -171
- 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.js +79 -610
- package/web/dist/server.cjs +5 -1
- package/web/dist/server.js +82 -177
- package/web/dist/web.js +79 -610
- 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/web/types/server.d.ts +1 -1
package/dist/server.cjs
CHANGED
|
@@ -13,7 +13,7 @@ function castError(err) {
|
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
function handleError(err, owner = Owner) {
|
|
16
|
-
const fns =
|
|
16
|
+
const fns = owner && owner.context && owner.context[ERROR];
|
|
17
17
|
const error = castError(err);
|
|
18
18
|
if (!fns) throw error;
|
|
19
19
|
try {
|
|
@@ -32,7 +32,7 @@ let Owner = null;
|
|
|
32
32
|
function createOwner() {
|
|
33
33
|
const o = {
|
|
34
34
|
owner: Owner,
|
|
35
|
-
context: null,
|
|
35
|
+
context: Owner ? Owner.context : null,
|
|
36
36
|
owned: null,
|
|
37
37
|
cleanups: null
|
|
38
38
|
};
|
|
@@ -43,9 +43,10 @@ function createOwner() {
|
|
|
43
43
|
}
|
|
44
44
|
function createRoot(fn, detachedOwner) {
|
|
45
45
|
const owner = Owner,
|
|
46
|
+
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
46
47
|
root = fn.length === 0 ? UNOWNED : {
|
|
47
|
-
context: null,
|
|
48
|
-
owner:
|
|
48
|
+
context: current ? current.context : null,
|
|
49
|
+
owner: current,
|
|
49
50
|
owned: null,
|
|
50
51
|
cleanups: null
|
|
51
52
|
};
|
|
@@ -135,14 +136,12 @@ function cleanNode(node) {
|
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
function catchError(fn, handler) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
context
|
|
141
|
-
|
|
142
|
-
},
|
|
143
|
-
owned: null,
|
|
144
|
-
cleanups: null
|
|
139
|
+
const owner = createOwner();
|
|
140
|
+
owner.context = {
|
|
141
|
+
...owner.context,
|
|
142
|
+
[ERROR]: [handler]
|
|
145
143
|
};
|
|
144
|
+
Owner = owner;
|
|
146
145
|
try {
|
|
147
146
|
return fn();
|
|
148
147
|
} catch (err) {
|
|
@@ -151,13 +150,6 @@ function catchError(fn, handler) {
|
|
|
151
150
|
Owner = Owner.owner;
|
|
152
151
|
}
|
|
153
152
|
}
|
|
154
|
-
function onError(fn) {
|
|
155
|
-
if (Owner) {
|
|
156
|
-
if (Owner.context === null) Owner.context = {
|
|
157
|
-
[ERROR]: [fn]
|
|
158
|
-
};else if (!Owner.context[ERROR]) Owner.context[ERROR] = [fn];else Owner.context[ERROR].push(fn);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
153
|
function getListener() {
|
|
162
154
|
return null;
|
|
163
155
|
}
|
|
@@ -170,8 +162,7 @@ function createContext(defaultValue) {
|
|
|
170
162
|
};
|
|
171
163
|
}
|
|
172
164
|
function useContext(context) {
|
|
173
|
-
|
|
174
|
-
return (ctx = lookup(Owner, context.id)) !== undefined ? ctx : context.defaultValue;
|
|
165
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined ? Owner.context[context.id] : context.defaultValue;
|
|
175
166
|
}
|
|
176
167
|
function getOwner() {
|
|
177
168
|
return Owner;
|
|
@@ -195,9 +186,6 @@ function runWithOwner(o, fn) {
|
|
|
195
186
|
Owner = prev;
|
|
196
187
|
}
|
|
197
188
|
}
|
|
198
|
-
function lookup(owner, key) {
|
|
199
|
-
return owner ? owner.context && owner.context[key] !== undefined ? owner.context[key] : lookup(owner.owner, key) : undefined;
|
|
200
|
-
}
|
|
201
189
|
function resolveChildren(children) {
|
|
202
190
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
203
191
|
if (Array.isArray(children)) {
|
|
@@ -214,6 +202,7 @@ function createProvider(id) {
|
|
|
214
202
|
return function provider(props) {
|
|
215
203
|
return createMemo(() => {
|
|
216
204
|
Owner.context = {
|
|
205
|
+
...Owner.context,
|
|
217
206
|
[id]: props.value
|
|
218
207
|
};
|
|
219
208
|
return children(() => props.children);
|
|
@@ -279,6 +268,31 @@ function from(producer) {
|
|
|
279
268
|
return s;
|
|
280
269
|
}
|
|
281
270
|
function enableExternalSource(factory) {}
|
|
271
|
+
function onError(fn) {
|
|
272
|
+
if (Owner) {
|
|
273
|
+
if (Owner.context === null || !Owner.context[ERROR]) {
|
|
274
|
+
Owner.context = {
|
|
275
|
+
...Owner.context,
|
|
276
|
+
[ERROR]: [fn]
|
|
277
|
+
};
|
|
278
|
+
mutateContext(Owner, ERROR, [fn]);
|
|
279
|
+
} else Owner.context[ERROR].push(fn);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function mutateContext(o, key, value) {
|
|
283
|
+
if (o.owned) {
|
|
284
|
+
for (let i = 0; i < o.owned.length; i++) {
|
|
285
|
+
if (o.owned[i].context === o.context) mutateContext(o.owned[i], key, value);
|
|
286
|
+
if (!o.owned[i].context) {
|
|
287
|
+
o.owned[i].context = o.context;
|
|
288
|
+
mutateContext(o.owned[i], key, value);
|
|
289
|
+
} else if (!o.owned[i].context[key]) {
|
|
290
|
+
o.owned[i].context[key] = value;
|
|
291
|
+
mutateContext(o.owned[i], key, value);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
282
296
|
|
|
283
297
|
function resolveSSRNode(node) {
|
|
284
298
|
const t = typeof node;
|
|
@@ -663,6 +677,7 @@ exports.Suspense = Suspense;
|
|
|
663
677
|
exports.SuspenseList = SuspenseList;
|
|
664
678
|
exports.Switch = Switch;
|
|
665
679
|
exports.batch = batch;
|
|
680
|
+
exports.catchError = catchError;
|
|
666
681
|
exports.children = children;
|
|
667
682
|
exports.createComponent = createComponent;
|
|
668
683
|
exports.createComputed = createComputed;
|
package/dist/server.js
CHANGED
|
@@ -11,13 +11,13 @@ function castError(err) {
|
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
function handleError(err, owner = Owner) {
|
|
14
|
-
const fns =
|
|
14
|
+
const fns = owner && owner.context && owner.context[ERROR];
|
|
15
15
|
const error = castError(err);
|
|
16
16
|
if (!fns) throw error;
|
|
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 = {
|
|
@@ -30,27 +30,24 @@ let Owner = null;
|
|
|
30
30
|
function createOwner() {
|
|
31
31
|
const o = {
|
|
32
32
|
owner: Owner,
|
|
33
|
-
context: null,
|
|
33
|
+
context: Owner ? Owner.context : null,
|
|
34
34
|
owned: null,
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
cleanups: null
|
|
53
|
-
};
|
|
44
|
+
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
45
|
+
root = fn.length === 0 ? UNOWNED : {
|
|
46
|
+
context: current ? current.context : null,
|
|
47
|
+
owner: current,
|
|
48
|
+
owned: null,
|
|
49
|
+
cleanups: null
|
|
50
|
+
};
|
|
54
51
|
Owner = root;
|
|
55
52
|
let result;
|
|
56
53
|
try {
|
|
@@ -63,12 +60,9 @@ function createRoot(fn, detachedOwner) {
|
|
|
63
60
|
return result;
|
|
64
61
|
}
|
|
65
62
|
function createSignal(value, options) {
|
|
66
|
-
return [
|
|
67
|
-
()
|
|
68
|
-
|
|
69
|
-
return (value = typeof v === "function" ? v(value) : v);
|
|
70
|
-
}
|
|
71
|
-
];
|
|
63
|
+
return [() => value, v => {
|
|
64
|
+
return value = typeof v === "function" ? v(value) : v;
|
|
65
|
+
}];
|
|
72
66
|
}
|
|
73
67
|
function createComputed(fn, value) {
|
|
74
68
|
Owner = createOwner();
|
|
@@ -125,8 +119,7 @@ function on(deps, fn, options = {}) {
|
|
|
125
119
|
function onMount(fn) {}
|
|
126
120
|
function onCleanup(fn) {
|
|
127
121
|
if (Owner) {
|
|
128
|
-
if (!Owner.cleanups) Owner.cleanups = [fn];
|
|
129
|
-
else Owner.cleanups.push(fn);
|
|
122
|
+
if (!Owner.cleanups) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
|
|
130
123
|
}
|
|
131
124
|
return fn;
|
|
132
125
|
}
|
|
@@ -141,14 +134,12 @@ function cleanNode(node) {
|
|
|
141
134
|
}
|
|
142
135
|
}
|
|
143
136
|
function catchError(fn, handler) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
context
|
|
147
|
-
|
|
148
|
-
},
|
|
149
|
-
owned: null,
|
|
150
|
-
cleanups: null
|
|
137
|
+
const owner = createOwner();
|
|
138
|
+
owner.context = {
|
|
139
|
+
...owner.context,
|
|
140
|
+
[ERROR]: [handler]
|
|
151
141
|
};
|
|
142
|
+
Owner = owner;
|
|
152
143
|
try {
|
|
153
144
|
return fn();
|
|
154
145
|
} catch (err) {
|
|
@@ -157,16 +148,6 @@ function catchError(fn, handler) {
|
|
|
157
148
|
Owner = Owner.owner;
|
|
158
149
|
}
|
|
159
150
|
}
|
|
160
|
-
function onError(fn) {
|
|
161
|
-
if (Owner) {
|
|
162
|
-
if (Owner.context === null)
|
|
163
|
-
Owner.context = {
|
|
164
|
-
[ERROR]: [fn]
|
|
165
|
-
};
|
|
166
|
-
else if (!Owner.context[ERROR]) Owner.context[ERROR] = [fn];
|
|
167
|
-
else Owner.context[ERROR].push(fn);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
151
|
function getListener() {
|
|
171
152
|
return null;
|
|
172
153
|
}
|
|
@@ -179,8 +160,7 @@ function createContext(defaultValue) {
|
|
|
179
160
|
};
|
|
180
161
|
}
|
|
181
162
|
function useContext(context) {
|
|
182
|
-
|
|
183
|
-
return (ctx = lookup(Owner, context.id)) !== undefined ? ctx : context.defaultValue;
|
|
163
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined ? Owner.context[context.id] : context.defaultValue;
|
|
184
164
|
}
|
|
185
165
|
function getOwner() {
|
|
186
166
|
return Owner;
|
|
@@ -204,13 +184,6 @@ function runWithOwner(o, fn) {
|
|
|
204
184
|
Owner = prev;
|
|
205
185
|
}
|
|
206
186
|
}
|
|
207
|
-
function lookup(owner, key) {
|
|
208
|
-
return owner
|
|
209
|
-
? owner.context && owner.context[key] !== undefined
|
|
210
|
-
? owner.context[key]
|
|
211
|
-
: lookup(owner.owner, key)
|
|
212
|
-
: undefined;
|
|
213
|
-
}
|
|
214
187
|
function resolveChildren(children) {
|
|
215
188
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
216
189
|
if (Array.isArray(children)) {
|
|
@@ -227,6 +200,7 @@ function createProvider(id) {
|
|
|
227
200
|
return function provider(props) {
|
|
228
201
|
return createMemo(() => {
|
|
229
202
|
Owner.context = {
|
|
203
|
+
...Owner.context,
|
|
230
204
|
[id]: props.value
|
|
231
205
|
};
|
|
232
206
|
return children(() => props.children);
|
|
@@ -255,8 +229,7 @@ function observable(input) {
|
|
|
255
229
|
if (!(observer instanceof Object) || observer == null) {
|
|
256
230
|
throw new TypeError("Expected the observer to be an object.");
|
|
257
231
|
}
|
|
258
|
-
const handler =
|
|
259
|
-
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
232
|
+
const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
260
233
|
if (!handler) {
|
|
261
234
|
return {
|
|
262
235
|
unsubscribe() {}
|
|
@@ -285,7 +258,7 @@ function from(producer) {
|
|
|
285
258
|
const [s, set] = createSignal(undefined);
|
|
286
259
|
if ("subscribe" in producer) {
|
|
287
260
|
const unsub = producer.subscribe(v => set(() => v));
|
|
288
|
-
onCleanup(() =>
|
|
261
|
+
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
289
262
|
} else {
|
|
290
263
|
const clean = producer(set);
|
|
291
264
|
onCleanup(clean);
|
|
@@ -293,6 +266,31 @@ function from(producer) {
|
|
|
293
266
|
return s;
|
|
294
267
|
}
|
|
295
268
|
function enableExternalSource(factory) {}
|
|
269
|
+
function onError(fn) {
|
|
270
|
+
if (Owner) {
|
|
271
|
+
if (Owner.context === null || !Owner.context[ERROR]) {
|
|
272
|
+
Owner.context = {
|
|
273
|
+
...Owner.context,
|
|
274
|
+
[ERROR]: [fn]
|
|
275
|
+
};
|
|
276
|
+
mutateContext(Owner, ERROR, [fn]);
|
|
277
|
+
} else Owner.context[ERROR].push(fn);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function mutateContext(o, key, value) {
|
|
281
|
+
if (o.owned) {
|
|
282
|
+
for (let i = 0; i < o.owned.length; i++) {
|
|
283
|
+
if (o.owned[i].context === o.context) mutateContext(o.owned[i], key, value);
|
|
284
|
+
if (!o.owned[i].context) {
|
|
285
|
+
o.owned[i].context = o.context;
|
|
286
|
+
mutateContext(o.owned[i], key, value);
|
|
287
|
+
} else if (!o.owned[i].context[key]) {
|
|
288
|
+
o.owned[i].context[key] = value;
|
|
289
|
+
mutateContext(o.owned[i], key, value);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
296
294
|
|
|
297
295
|
function resolveSSRNode(node) {
|
|
298
296
|
const t = typeof node;
|
|
@@ -312,13 +310,11 @@ function setHydrateContext(context) {
|
|
|
312
310
|
sharedConfig.context = context;
|
|
313
311
|
}
|
|
314
312
|
function nextHydrateContext() {
|
|
315
|
-
return sharedConfig.context
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
: undefined;
|
|
313
|
+
return sharedConfig.context ? {
|
|
314
|
+
...sharedConfig.context,
|
|
315
|
+
id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`,
|
|
316
|
+
count: 0
|
|
317
|
+
} : undefined;
|
|
322
318
|
}
|
|
323
319
|
function createUniqueId() {
|
|
324
320
|
const ctx = sharedConfig.context;
|
|
@@ -394,11 +390,7 @@ function Index(props) {
|
|
|
394
390
|
}
|
|
395
391
|
function Show(props) {
|
|
396
392
|
let c;
|
|
397
|
-
return props.when
|
|
398
|
-
? typeof (c = props.children) === "function"
|
|
399
|
-
? c(props.keyed ? props.when : () => props.when)
|
|
400
|
-
: c
|
|
401
|
-
: props.fallback || "";
|
|
393
|
+
return props.when ? typeof (c = props.children) === "function" ? c(props.keyed ? props.when : () => props.when) : c : props.fallback || "";
|
|
402
394
|
}
|
|
403
395
|
function Switch(props) {
|
|
404
396
|
let conditions = props.children;
|
|
@@ -435,14 +427,11 @@ function ErrorBoundary(props) {
|
|
|
435
427
|
}
|
|
436
428
|
createMemo(() => {
|
|
437
429
|
clean = Owner;
|
|
438
|
-
return catchError(
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
sync = true;
|
|
444
|
-
}
|
|
445
|
-
);
|
|
430
|
+
return catchError(() => res = props.children, err => {
|
|
431
|
+
error = err;
|
|
432
|
+
!sync && ctx.replace("e" + id, displayFallback);
|
|
433
|
+
sync = true;
|
|
434
|
+
});
|
|
446
435
|
});
|
|
447
436
|
if (error) return displayFallback();
|
|
448
437
|
sync = false;
|
|
@@ -472,18 +461,14 @@ function createResource(source, fetcher, options = {}) {
|
|
|
472
461
|
if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
|
|
473
462
|
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
474
463
|
if (resource.ref) {
|
|
475
|
-
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
|
|
476
|
-
resource.ref[1].refetch();
|
|
464
|
+
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
|
|
477
465
|
return resource.ref;
|
|
478
466
|
}
|
|
479
467
|
}
|
|
480
468
|
const read = () => {
|
|
481
469
|
if (error) throw error;
|
|
482
470
|
if (resourceContext && p) resourceContext.push(p);
|
|
483
|
-
const resolved =
|
|
484
|
-
options.ssrLoadFrom !== "initial" &&
|
|
485
|
-
sharedConfig.context.async &&
|
|
486
|
-
"data" in sharedConfig.context.resources[id];
|
|
471
|
+
const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
|
|
487
472
|
if (!resolved && read.loading) {
|
|
488
473
|
const ctx = useContext(SuspenseContext);
|
|
489
474
|
if (ctx) {
|
|
@@ -503,7 +488,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
503
488
|
});
|
|
504
489
|
function load() {
|
|
505
490
|
const ctx = sharedConfig.context;
|
|
506
|
-
if (!ctx.async) return
|
|
491
|
+
if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
|
|
507
492
|
if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
|
|
508
493
|
value = ctx.resources[id].data;
|
|
509
494
|
return;
|
|
@@ -511,11 +496,9 @@ function createResource(source, fetcher, options = {}) {
|
|
|
511
496
|
resourceContext = [];
|
|
512
497
|
const lookup = typeof source === "function" ? source() : source;
|
|
513
498
|
if (resourceContext.length) {
|
|
514
|
-
p = Promise.all(resourceContext).then(() =>
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
})
|
|
518
|
-
);
|
|
499
|
+
p = Promise.all(resourceContext).then(() => fetcher(source(), {
|
|
500
|
+
value
|
|
501
|
+
}));
|
|
519
502
|
}
|
|
520
503
|
resourceContext = null;
|
|
521
504
|
if (!p) {
|
|
@@ -528,22 +511,20 @@ function createResource(source, fetcher, options = {}) {
|
|
|
528
511
|
read.loading = true;
|
|
529
512
|
read.state = "pending";
|
|
530
513
|
if (ctx.writeResource) ctx.writeResource(id, p, undefined, options.deferStream);
|
|
531
|
-
return p
|
|
532
|
-
.
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
.
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
notifySuspense(contexts);
|
|
546
|
-
});
|
|
514
|
+
return p.then(res => {
|
|
515
|
+
read.loading = false;
|
|
516
|
+
read.state = "ready";
|
|
517
|
+
ctx.resources[id].data = res;
|
|
518
|
+
p = null;
|
|
519
|
+
notifySuspense(contexts);
|
|
520
|
+
return res;
|
|
521
|
+
}).catch(err => {
|
|
522
|
+
read.loading = false;
|
|
523
|
+
read.state = "errored";
|
|
524
|
+
read.error = error = castError(err);
|
|
525
|
+
p = null;
|
|
526
|
+
notifySuspense(contexts);
|
|
527
|
+
});
|
|
547
528
|
}
|
|
548
529
|
ctx.resources[id].data = p;
|
|
549
530
|
if (ctx.writeResource) ctx.writeResource(id, p);
|
|
@@ -551,20 +532,17 @@ function createResource(source, fetcher, options = {}) {
|
|
|
551
532
|
return ctx.resources[id].data;
|
|
552
533
|
}
|
|
553
534
|
if (options.ssrLoadFrom !== "initial") load();
|
|
554
|
-
return
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
mutate: v => (value = v)
|
|
559
|
-
}
|
|
560
|
-
]);
|
|
535
|
+
return resource.ref = [read, {
|
|
536
|
+
refetch: load,
|
|
537
|
+
mutate: v => value = v
|
|
538
|
+
}];
|
|
561
539
|
}
|
|
562
540
|
function lazy(fn) {
|
|
563
541
|
let p;
|
|
564
542
|
let load = id => {
|
|
565
543
|
if (!p) {
|
|
566
544
|
p = fn();
|
|
567
|
-
p.then(mod =>
|
|
545
|
+
p.then(mod => p.resolved = mod.default);
|
|
568
546
|
if (id) sharedConfig.context.lazy[id] = p;
|
|
569
547
|
}
|
|
570
548
|
return p;
|
|
@@ -573,8 +551,7 @@ function lazy(fn) {
|
|
|
573
551
|
const wrap = props => {
|
|
574
552
|
const id = sharedConfig.context.id.slice(0, -1);
|
|
575
553
|
let ref = sharedConfig.context.lazy[id];
|
|
576
|
-
if (ref) p = ref;
|
|
577
|
-
else load(id);
|
|
554
|
+
if (ref) p = ref;else load(id);
|
|
578
555
|
if (p.resolved) return p.resolved(props);
|
|
579
556
|
const ctx = useContext(SuspenseContext);
|
|
580
557
|
const track = {
|
|
@@ -586,12 +563,10 @@ function lazy(fn) {
|
|
|
586
563
|
contexts.add(ctx);
|
|
587
564
|
}
|
|
588
565
|
if (sharedConfig.context.async) {
|
|
589
|
-
sharedConfig.context.block(
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
})
|
|
594
|
-
);
|
|
566
|
+
sharedConfig.context.block(p.then(() => {
|
|
567
|
+
track.loading = false;
|
|
568
|
+
notifySuspense(contexts);
|
|
569
|
+
}));
|
|
595
570
|
}
|
|
596
571
|
return "";
|
|
597
572
|
};
|
|
@@ -619,12 +594,9 @@ function startTransition(fn) {
|
|
|
619
594
|
fn();
|
|
620
595
|
}
|
|
621
596
|
function useTransition() {
|
|
622
|
-
return [
|
|
623
|
-
()
|
|
624
|
-
|
|
625
|
-
fn();
|
|
626
|
-
}
|
|
627
|
-
];
|
|
597
|
+
return [() => false, fn => {
|
|
598
|
+
fn();
|
|
599
|
+
}];
|
|
628
600
|
}
|
|
629
601
|
function SuspenseList(props) {
|
|
630
602
|
return props.children;
|
|
@@ -634,17 +606,15 @@ function Suspense(props) {
|
|
|
634
606
|
const ctx = sharedConfig.context;
|
|
635
607
|
const id = ctx.id + ctx.count;
|
|
636
608
|
const o = createOwner();
|
|
637
|
-
const value =
|
|
638
|
-
|
|
639
|
-
(
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
if (suspenseComplete(value)) {
|
|
644
|
-
done(resolveSSRNode(res));
|
|
645
|
-
}
|
|
609
|
+
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
610
|
+
resources: new Map(),
|
|
611
|
+
completed: () => {
|
|
612
|
+
const res = runSuspense();
|
|
613
|
+
if (suspenseComplete(value)) {
|
|
614
|
+
done(resolveSSRNode(res));
|
|
646
615
|
}
|
|
647
|
-
}
|
|
616
|
+
}
|
|
617
|
+
});
|
|
648
618
|
function suspenseError(err) {
|
|
649
619
|
if (!done || !done(undefined, err)) {
|
|
650
620
|
runWithOwner(o.owner, () => {
|
|
@@ -658,14 +628,12 @@ function Suspense(props) {
|
|
|
658
628
|
count: 0
|
|
659
629
|
});
|
|
660
630
|
cleanNode(o);
|
|
661
|
-
return runWithOwner(o, () =>
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
})
|
|
668
|
-
);
|
|
631
|
+
return runWithOwner(o, () => createComponent(SuspenseContext.Provider, {
|
|
632
|
+
value,
|
|
633
|
+
get children() {
|
|
634
|
+
return catchError(() => props.children, suspenseError);
|
|
635
|
+
}
|
|
636
|
+
}));
|
|
669
637
|
}
|
|
670
638
|
const res = runSuspense();
|
|
671
639
|
if (suspenseComplete(value)) return res;
|
|
@@ -694,56 +662,4 @@ function Suspense(props) {
|
|
|
694
662
|
}, suspenseError);
|
|
695
663
|
}
|
|
696
664
|
|
|
697
|
-
export {
|
|
698
|
-
$DEVCOMP,
|
|
699
|
-
$PROXY,
|
|
700
|
-
$TRACK,
|
|
701
|
-
DEV,
|
|
702
|
-
ErrorBoundary,
|
|
703
|
-
For,
|
|
704
|
-
Index,
|
|
705
|
-
Match,
|
|
706
|
-
Show,
|
|
707
|
-
Suspense,
|
|
708
|
-
SuspenseList,
|
|
709
|
-
Switch,
|
|
710
|
-
batch,
|
|
711
|
-
children,
|
|
712
|
-
createComponent,
|
|
713
|
-
createComputed,
|
|
714
|
-
createContext,
|
|
715
|
-
createDeferred,
|
|
716
|
-
createEffect,
|
|
717
|
-
createMemo,
|
|
718
|
-
createReaction,
|
|
719
|
-
createRenderEffect,
|
|
720
|
-
createResource,
|
|
721
|
-
createRoot,
|
|
722
|
-
createSelector,
|
|
723
|
-
createSignal,
|
|
724
|
-
createUniqueId,
|
|
725
|
-
enableExternalSource,
|
|
726
|
-
enableHydration,
|
|
727
|
-
enableScheduling,
|
|
728
|
-
equalFn,
|
|
729
|
-
from,
|
|
730
|
-
getListener,
|
|
731
|
-
getOwner,
|
|
732
|
-
lazy,
|
|
733
|
-
mapArray,
|
|
734
|
-
mergeProps,
|
|
735
|
-
observable,
|
|
736
|
-
on,
|
|
737
|
-
onCleanup,
|
|
738
|
-
onError,
|
|
739
|
-
onMount,
|
|
740
|
-
requestCallback,
|
|
741
|
-
resetErrorBoundaries,
|
|
742
|
-
runWithOwner,
|
|
743
|
-
sharedConfig,
|
|
744
|
-
splitProps,
|
|
745
|
-
startTransition,
|
|
746
|
-
untrack,
|
|
747
|
-
useContext,
|
|
748
|
-
useTransition
|
|
749
|
-
};
|
|
665
|
+
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, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|