solid-js 1.9.2 → 1.9.4
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 +5 -5
- package/dist/dev.js +563 -322
- package/dist/server.cjs +50 -10
- package/dist/server.js +220 -83
- package/dist/solid.cjs +5 -5
- package/dist/solid.js +490 -280
- package/h/dist/h.js +40 -9
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/jsx-runtime/types/jsx.d.ts +93 -91
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +219 -94
- package/html/types/lit.d.ts +52 -33
- package/package.json +1 -1
- package/store/dist/dev.cjs +1 -1
- package/store/dist/dev.js +123 -43
- package/store/dist/server.js +20 -8
- package/store/dist/store.cjs +1 -1
- package/store/dist/store.js +114 -40
- package/store/types/index.d.ts +21 -7
- package/store/types/modifiers.d.ts +6 -3
- package/store/types/mutable.d.ts +5 -2
- package/store/types/server.d.ts +25 -5
- package/store/types/store.d.ts +218 -61
- package/types/index.d.ts +75 -10
- package/types/jsx.d.ts +143 -157
- package/types/reactive/array.d.ts +12 -4
- package/types/reactive/observable.d.ts +25 -17
- package/types/reactive/scheduler.d.ts +9 -6
- package/types/reactive/signal.d.ts +233 -142
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +71 -35
- package/types/render/flow.d.ts +43 -31
- package/types/render/hydration.d.ts +15 -15
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +169 -98
- package/universal/dist/dev.js +28 -12
- package/universal/dist/universal.js +28 -12
- package/universal/types/index.d.ts +3 -1
- package/universal/types/universal.d.ts +0 -1
- package/web/dist/dev.js +639 -89
- package/web/dist/server.cjs +18 -13
- package/web/dist/server.js +657 -120
- package/web/dist/web.js +627 -87
- package/web/storage/dist/storage.js +3 -3
- package/web/types/client.d.ts +1 -1
- package/web/types/core.d.ts +10 -1
- package/web/types/index.d.ts +27 -10
- package/web/types/server-mock.d.ts +47 -32
- package/web/types/server.d.ts +1 -1
- package/web/storage/types/index.js +0 -13
package/dist/server.cjs
CHANGED
|
@@ -302,6 +302,51 @@ function mutateContext(o, key, value) {
|
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
+
function escape(s, attr) {
|
|
306
|
+
const t = typeof s;
|
|
307
|
+
if (t !== "string") {
|
|
308
|
+
if (t === "function") return escape(s());
|
|
309
|
+
if (Array.isArray(s)) {
|
|
310
|
+
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
311
|
+
return s;
|
|
312
|
+
}
|
|
313
|
+
return s;
|
|
314
|
+
}
|
|
315
|
+
const delim = "<";
|
|
316
|
+
const escDelim = "<";
|
|
317
|
+
let iDelim = s.indexOf(delim);
|
|
318
|
+
let iAmp = s.indexOf("&");
|
|
319
|
+
if (iDelim < 0 && iAmp < 0) return s;
|
|
320
|
+
let left = 0,
|
|
321
|
+
out = "";
|
|
322
|
+
while (iDelim >= 0 && iAmp >= 0) {
|
|
323
|
+
if (iDelim < iAmp) {
|
|
324
|
+
if (left < iDelim) out += s.substring(left, iDelim);
|
|
325
|
+
out += escDelim;
|
|
326
|
+
left = iDelim + 1;
|
|
327
|
+
iDelim = s.indexOf(delim, left);
|
|
328
|
+
} else {
|
|
329
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
330
|
+
out += "&";
|
|
331
|
+
left = iAmp + 1;
|
|
332
|
+
iAmp = s.indexOf("&", left);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (iDelim >= 0) {
|
|
336
|
+
do {
|
|
337
|
+
if (left < iDelim) out += s.substring(left, iDelim);
|
|
338
|
+
out += escDelim;
|
|
339
|
+
left = iDelim + 1;
|
|
340
|
+
iDelim = s.indexOf(delim, left);
|
|
341
|
+
} while (iDelim >= 0);
|
|
342
|
+
} else while (iAmp >= 0) {
|
|
343
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
344
|
+
out += "&";
|
|
345
|
+
left = iAmp + 1;
|
|
346
|
+
iAmp = s.indexOf("&", left);
|
|
347
|
+
}
|
|
348
|
+
return left < s.length ? out + s.substring(left) : out;
|
|
349
|
+
}
|
|
305
350
|
function resolveSSRNode(node) {
|
|
306
351
|
const t = typeof node;
|
|
307
352
|
if (t === "string") return node;
|
|
@@ -464,19 +509,14 @@ function ErrorBoundary(props) {
|
|
|
464
509
|
if (error) return displayFallback();
|
|
465
510
|
sync = false;
|
|
466
511
|
return {
|
|
467
|
-
t: `<!--!$e${id}-->${resolveSSRNode(res)}<!--!$/e${id}-->`
|
|
512
|
+
t: `<!--!$e${id}-->${resolveSSRNode(escape(res))}<!--!$/e${id}-->`
|
|
468
513
|
};
|
|
469
514
|
}
|
|
470
515
|
const SuspenseContext = createContext();
|
|
471
516
|
let resourceContext = null;
|
|
472
517
|
function createResource(source, fetcher, options = {}) {
|
|
473
|
-
if (
|
|
474
|
-
|
|
475
|
-
options = fetcher;
|
|
476
|
-
fetcher = source;
|
|
477
|
-
source = true;
|
|
478
|
-
}
|
|
479
|
-
} else if (arguments.length === 1) {
|
|
518
|
+
if (typeof fetcher !== "function") {
|
|
519
|
+
options = fetcher || {};
|
|
480
520
|
fetcher = source;
|
|
481
521
|
source = true;
|
|
482
522
|
}
|
|
@@ -641,7 +681,7 @@ function Suspense(props) {
|
|
|
641
681
|
completed: () => {
|
|
642
682
|
const res = runSuspense();
|
|
643
683
|
if (suspenseComplete(value)) {
|
|
644
|
-
done(resolveSSRNode(res));
|
|
684
|
+
done(resolveSSRNode(escape(res)));
|
|
645
685
|
}
|
|
646
686
|
}
|
|
647
687
|
});
|
|
@@ -680,7 +720,7 @@ function Suspense(props) {
|
|
|
680
720
|
noHydrate: true
|
|
681
721
|
});
|
|
682
722
|
const res = {
|
|
683
|
-
t: `<template id="pl-${id}"></template>${resolveSSRNode(props.fallback)}<!--pl-${id}-->`
|
|
723
|
+
t: `<template id="pl-${id}"></template>${resolveSSRNode(escape(props.fallback))}<!--pl-${id}-->`
|
|
684
724
|
};
|
|
685
725
|
setHydrateContext(ctx);
|
|
686
726
|
return res;
|
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, owner && owner.owner || null);
|
|
20
|
+
handleError(e, (owner && owner.owner) || null);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
const UNOWNED = {
|
|
@@ -35,19 +35,23 @@ function createOwner() {
|
|
|
35
35
|
cleanups: null
|
|
36
36
|
};
|
|
37
37
|
if (Owner) {
|
|
38
|
-
if (!Owner.owned) Owner.owned = [o];
|
|
38
|
+
if (!Owner.owned) Owner.owned = [o];
|
|
39
|
+
else Owner.owned.push(o);
|
|
39
40
|
}
|
|
40
41
|
return o;
|
|
41
42
|
}
|
|
42
43
|
function createRoot(fn, detachedOwner) {
|
|
43
44
|
const owner = Owner,
|
|
44
45
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
45
|
-
root =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
root =
|
|
47
|
+
fn.length === 0
|
|
48
|
+
? UNOWNED
|
|
49
|
+
: {
|
|
50
|
+
context: current ? current.context : null,
|
|
51
|
+
owner: current,
|
|
52
|
+
owned: null,
|
|
53
|
+
cleanups: null
|
|
54
|
+
};
|
|
51
55
|
Owner = root;
|
|
52
56
|
let result;
|
|
53
57
|
try {
|
|
@@ -60,9 +64,12 @@ function createRoot(fn, detachedOwner) {
|
|
|
60
64
|
return result;
|
|
61
65
|
}
|
|
62
66
|
function createSignal(value, options) {
|
|
63
|
-
return [
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
return [
|
|
68
|
+
() => value,
|
|
69
|
+
v => {
|
|
70
|
+
return (value = typeof v === "function" ? v(value) : v);
|
|
71
|
+
}
|
|
72
|
+
];
|
|
66
73
|
}
|
|
67
74
|
function createComputed(fn, value) {
|
|
68
75
|
Owner = createOwner();
|
|
@@ -119,7 +126,8 @@ function on(deps, fn, options = {}) {
|
|
|
119
126
|
function onMount(fn) {}
|
|
120
127
|
function onCleanup(fn) {
|
|
121
128
|
if (Owner) {
|
|
122
|
-
if (!Owner.cleanups) Owner.cleanups = [fn];
|
|
129
|
+
if (!Owner.cleanups) Owner.cleanups = [fn];
|
|
130
|
+
else Owner.cleanups.push(fn);
|
|
123
131
|
}
|
|
124
132
|
return fn;
|
|
125
133
|
}
|
|
@@ -160,7 +168,9 @@ function createContext(defaultValue) {
|
|
|
160
168
|
};
|
|
161
169
|
}
|
|
162
170
|
function useContext(context) {
|
|
163
|
-
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
171
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
172
|
+
? Owner.context[context.id]
|
|
173
|
+
: context.defaultValue;
|
|
164
174
|
}
|
|
165
175
|
function getOwner() {
|
|
166
176
|
return Owner;
|
|
@@ -237,7 +247,8 @@ function observable(input) {
|
|
|
237
247
|
if (!(observer instanceof Object) || observer == null) {
|
|
238
248
|
throw new TypeError("Expected the observer to be an object.");
|
|
239
249
|
}
|
|
240
|
-
const handler =
|
|
250
|
+
const handler =
|
|
251
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
241
252
|
if (!handler) {
|
|
242
253
|
return {
|
|
243
254
|
unsubscribe() {}
|
|
@@ -266,7 +277,7 @@ function from(producer) {
|
|
|
266
277
|
const [s, set] = createSignal(undefined);
|
|
267
278
|
if ("subscribe" in producer) {
|
|
268
279
|
const unsub = producer.subscribe(v => set(() => v));
|
|
269
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
280
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
270
281
|
} else {
|
|
271
282
|
const clean = producer(set);
|
|
272
283
|
onCleanup(clean);
|
|
@@ -300,6 +311,52 @@ function mutateContext(o, key, value) {
|
|
|
300
311
|
}
|
|
301
312
|
}
|
|
302
313
|
|
|
314
|
+
function escape(s, attr) {
|
|
315
|
+
const t = typeof s;
|
|
316
|
+
if (t !== "string") {
|
|
317
|
+
if (t === "function") return escape(s());
|
|
318
|
+
if (Array.isArray(s)) {
|
|
319
|
+
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
320
|
+
return s;
|
|
321
|
+
}
|
|
322
|
+
return s;
|
|
323
|
+
}
|
|
324
|
+
const delim = "<";
|
|
325
|
+
const escDelim = "<";
|
|
326
|
+
let iDelim = s.indexOf(delim);
|
|
327
|
+
let iAmp = s.indexOf("&");
|
|
328
|
+
if (iDelim < 0 && iAmp < 0) return s;
|
|
329
|
+
let left = 0,
|
|
330
|
+
out = "";
|
|
331
|
+
while (iDelim >= 0 && iAmp >= 0) {
|
|
332
|
+
if (iDelim < iAmp) {
|
|
333
|
+
if (left < iDelim) out += s.substring(left, iDelim);
|
|
334
|
+
out += escDelim;
|
|
335
|
+
left = iDelim + 1;
|
|
336
|
+
iDelim = s.indexOf(delim, left);
|
|
337
|
+
} else {
|
|
338
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
339
|
+
out += "&";
|
|
340
|
+
left = iAmp + 1;
|
|
341
|
+
iAmp = s.indexOf("&", left);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (iDelim >= 0) {
|
|
345
|
+
do {
|
|
346
|
+
if (left < iDelim) out += s.substring(left, iDelim);
|
|
347
|
+
out += escDelim;
|
|
348
|
+
left = iDelim + 1;
|
|
349
|
+
iDelim = s.indexOf(delim, left);
|
|
350
|
+
} while (iDelim >= 0);
|
|
351
|
+
} else
|
|
352
|
+
while (iAmp >= 0) {
|
|
353
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
354
|
+
out += "&";
|
|
355
|
+
left = iAmp + 1;
|
|
356
|
+
iAmp = s.indexOf("&", left);
|
|
357
|
+
}
|
|
358
|
+
return left < s.length ? out + s.substring(left) : out;
|
|
359
|
+
}
|
|
303
360
|
function resolveSSRNode(node) {
|
|
304
361
|
const t = typeof node;
|
|
305
362
|
if (t === "string") return node;
|
|
@@ -309,7 +366,7 @@ function resolveSSRNode(node) {
|
|
|
309
366
|
let mapped = "";
|
|
310
367
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
311
368
|
if (typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
|
|
312
|
-
mapped += resolveSSRNode(prev = node[i]);
|
|
369
|
+
mapped += resolveSSRNode((prev = node[i]));
|
|
313
370
|
}
|
|
314
371
|
return mapped;
|
|
315
372
|
}
|
|
@@ -324,7 +381,8 @@ const sharedConfig = {
|
|
|
324
381
|
return getContextId(this.context.count);
|
|
325
382
|
},
|
|
326
383
|
getNextContextId() {
|
|
327
|
-
if (!this.context)
|
|
384
|
+
if (!this.context)
|
|
385
|
+
throw new Error(`getNextContextId cannot be used under non-hydrating context`);
|
|
328
386
|
return getContextId(this.context.count++);
|
|
329
387
|
}
|
|
330
388
|
};
|
|
@@ -337,11 +395,13 @@ function setHydrateContext(context) {
|
|
|
337
395
|
sharedConfig.context = context;
|
|
338
396
|
}
|
|
339
397
|
function nextHydrateContext() {
|
|
340
|
-
return sharedConfig.context
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
398
|
+
return sharedConfig.context
|
|
399
|
+
? {
|
|
400
|
+
...sharedConfig.context,
|
|
401
|
+
id: sharedConfig.getNextContextId(),
|
|
402
|
+
count: 0
|
|
403
|
+
}
|
|
404
|
+
: undefined;
|
|
345
405
|
}
|
|
346
406
|
function createUniqueId() {
|
|
347
407
|
return sharedConfig.getNextContextId();
|
|
@@ -416,7 +476,11 @@ function Index(props) {
|
|
|
416
476
|
}
|
|
417
477
|
function Show(props) {
|
|
418
478
|
let c;
|
|
419
|
-
return props.when
|
|
479
|
+
return props.when
|
|
480
|
+
? typeof (c = props.children) === "function"
|
|
481
|
+
? c(props.keyed ? props.when : () => props.when)
|
|
482
|
+
: c
|
|
483
|
+
: props.fallback || "";
|
|
420
484
|
}
|
|
421
485
|
function Switch(props) {
|
|
422
486
|
let conditions = props.children;
|
|
@@ -453,28 +517,26 @@ function ErrorBoundary(props) {
|
|
|
453
517
|
}
|
|
454
518
|
createMemo(() => {
|
|
455
519
|
clean = Owner;
|
|
456
|
-
return catchError(
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
520
|
+
return catchError(
|
|
521
|
+
() => (res = props.children),
|
|
522
|
+
err => {
|
|
523
|
+
error = err;
|
|
524
|
+
!sync && ctx.replace("e" + id, displayFallback);
|
|
525
|
+
sync = true;
|
|
526
|
+
}
|
|
527
|
+
);
|
|
461
528
|
});
|
|
462
529
|
if (error) return displayFallback();
|
|
463
530
|
sync = false;
|
|
464
531
|
return {
|
|
465
|
-
t: `<!--!$e${id}-->${resolveSSRNode(res)}<!--!$/e${id}-->`
|
|
532
|
+
t: `<!--!$e${id}-->${resolveSSRNode(escape(res))}<!--!$/e${id}-->`
|
|
466
533
|
};
|
|
467
534
|
}
|
|
468
535
|
const SuspenseContext = createContext();
|
|
469
536
|
let resourceContext = null;
|
|
470
537
|
function createResource(source, fetcher, options = {}) {
|
|
471
|
-
if (
|
|
472
|
-
|
|
473
|
-
options = fetcher;
|
|
474
|
-
fetcher = source;
|
|
475
|
-
source = true;
|
|
476
|
-
}
|
|
477
|
-
} else if (arguments.length === 1) {
|
|
538
|
+
if (typeof fetcher !== "function") {
|
|
539
|
+
options = fetcher || {};
|
|
478
540
|
fetcher = source;
|
|
479
541
|
source = true;
|
|
480
542
|
}
|
|
@@ -487,13 +549,17 @@ function createResource(source, fetcher, options = {}) {
|
|
|
487
549
|
if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
|
|
488
550
|
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
489
551
|
if (resource.ref) {
|
|
490
|
-
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
|
|
552
|
+
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error)
|
|
553
|
+
resource.ref[1].refetch();
|
|
491
554
|
return resource.ref;
|
|
492
555
|
}
|
|
493
556
|
}
|
|
494
557
|
const read = () => {
|
|
495
558
|
if (error) throw error;
|
|
496
|
-
const resolved =
|
|
559
|
+
const resolved =
|
|
560
|
+
options.ssrLoadFrom !== "initial" &&
|
|
561
|
+
sharedConfig.context.async &&
|
|
562
|
+
"data" in sharedConfig.context.resources[id];
|
|
497
563
|
if (!resolved && resourceContext) resourceContext.push(id);
|
|
498
564
|
if (!resolved && read.loading) {
|
|
499
565
|
const ctx = useContext(SuspenseContext);
|
|
@@ -514,7 +580,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
514
580
|
});
|
|
515
581
|
function load() {
|
|
516
582
|
const ctx = sharedConfig.context;
|
|
517
|
-
if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
|
|
583
|
+
if (!ctx.async) return (read.loading = !!(typeof source === "function" ? source() : source));
|
|
518
584
|
if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
|
|
519
585
|
value = ctx.resources[id].data;
|
|
520
586
|
return;
|
|
@@ -536,21 +602,23 @@ function createResource(source, fetcher, options = {}) {
|
|
|
536
602
|
if (p != undefined && typeof p === "object" && "then" in p) {
|
|
537
603
|
read.loading = true;
|
|
538
604
|
read.state = "pending";
|
|
539
|
-
p = p
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
605
|
+
p = p
|
|
606
|
+
.then(res => {
|
|
607
|
+
read.loading = false;
|
|
608
|
+
read.state = "ready";
|
|
609
|
+
ctx.resources[id].data = res;
|
|
610
|
+
p = null;
|
|
611
|
+
notifySuspense(contexts);
|
|
612
|
+
return res;
|
|
613
|
+
})
|
|
614
|
+
.catch(err => {
|
|
615
|
+
read.loading = false;
|
|
616
|
+
read.state = "errored";
|
|
617
|
+
read.error = error = castError(err);
|
|
618
|
+
p = null;
|
|
619
|
+
notifySuspense(contexts);
|
|
620
|
+
throw error;
|
|
621
|
+
});
|
|
554
622
|
if (ctx.serialize) ctx.serialize(id, p, options.deferStream);
|
|
555
623
|
return p;
|
|
556
624
|
}
|
|
@@ -560,17 +628,20 @@ function createResource(source, fetcher, options = {}) {
|
|
|
560
628
|
return ctx.resources[id].data;
|
|
561
629
|
}
|
|
562
630
|
if (options.ssrLoadFrom !== "initial") load();
|
|
563
|
-
return resource.ref = [
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
631
|
+
return (resource.ref = [
|
|
632
|
+
read,
|
|
633
|
+
{
|
|
634
|
+
refetch: load,
|
|
635
|
+
mutate: v => (value = v)
|
|
636
|
+
}
|
|
637
|
+
]);
|
|
567
638
|
}
|
|
568
639
|
function lazy(fn) {
|
|
569
640
|
let p;
|
|
570
641
|
let load = id => {
|
|
571
642
|
if (!p) {
|
|
572
643
|
p = fn();
|
|
573
|
-
p.then(mod => p.resolved = mod.default);
|
|
644
|
+
p.then(mod => (p.resolved = mod.default));
|
|
574
645
|
if (id) sharedConfig.context.lazy[id] = p;
|
|
575
646
|
}
|
|
576
647
|
return p;
|
|
@@ -579,7 +650,8 @@ function lazy(fn) {
|
|
|
579
650
|
const wrap = props => {
|
|
580
651
|
const id = sharedConfig.context.id;
|
|
581
652
|
let ref = sharedConfig.context.lazy[id];
|
|
582
|
-
if (ref) p = ref;
|
|
653
|
+
if (ref) p = ref;
|
|
654
|
+
else load(id);
|
|
583
655
|
if (p.resolved) return p.resolved(props);
|
|
584
656
|
const ctx = useContext(SuspenseContext);
|
|
585
657
|
const track = {
|
|
@@ -591,10 +663,12 @@ function lazy(fn) {
|
|
|
591
663
|
contexts.add(ctx);
|
|
592
664
|
}
|
|
593
665
|
if (sharedConfig.context.async) {
|
|
594
|
-
sharedConfig.context.block(
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
666
|
+
sharedConfig.context.block(
|
|
667
|
+
p.then(() => {
|
|
668
|
+
track.loading = false;
|
|
669
|
+
notifySuspense(contexts);
|
|
670
|
+
})
|
|
671
|
+
);
|
|
598
672
|
}
|
|
599
673
|
return "";
|
|
600
674
|
};
|
|
@@ -622,9 +696,12 @@ function startTransition(fn) {
|
|
|
622
696
|
fn();
|
|
623
697
|
}
|
|
624
698
|
function useTransition() {
|
|
625
|
-
return [
|
|
626
|
-
|
|
627
|
-
|
|
699
|
+
return [
|
|
700
|
+
() => false,
|
|
701
|
+
fn => {
|
|
702
|
+
fn();
|
|
703
|
+
}
|
|
704
|
+
];
|
|
628
705
|
}
|
|
629
706
|
function SuspenseList(props) {
|
|
630
707
|
return props.children;
|
|
@@ -634,15 +711,17 @@ function Suspense(props) {
|
|
|
634
711
|
const ctx = sharedConfig.context;
|
|
635
712
|
const id = sharedConfig.getContextId();
|
|
636
713
|
const o = createOwner();
|
|
637
|
-
const value =
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
714
|
+
const value =
|
|
715
|
+
ctx.suspense[id] ||
|
|
716
|
+
(ctx.suspense[id] = {
|
|
717
|
+
resources: new Map(),
|
|
718
|
+
completed: () => {
|
|
719
|
+
const res = runSuspense();
|
|
720
|
+
if (suspenseComplete(value)) {
|
|
721
|
+
done(resolveSSRNode(escape(res)));
|
|
722
|
+
}
|
|
643
723
|
}
|
|
644
|
-
}
|
|
645
|
-
});
|
|
724
|
+
});
|
|
646
725
|
function suspenseError(err) {
|
|
647
726
|
if (!done || !done(undefined, err)) {
|
|
648
727
|
runWithOwner(o.owner, () => {
|
|
@@ -656,12 +735,14 @@ function Suspense(props) {
|
|
|
656
735
|
count: 0
|
|
657
736
|
});
|
|
658
737
|
cleanNode(o);
|
|
659
|
-
return runWithOwner(o, () =>
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
738
|
+
return runWithOwner(o, () =>
|
|
739
|
+
createComponent(SuspenseContext.Provider, {
|
|
740
|
+
value,
|
|
741
|
+
get children() {
|
|
742
|
+
return catchError(() => props.children, suspenseError);
|
|
743
|
+
}
|
|
744
|
+
})
|
|
745
|
+
);
|
|
665
746
|
}
|
|
666
747
|
const res = runSuspense();
|
|
667
748
|
if (suspenseComplete(value)) {
|
|
@@ -678,7 +759,9 @@ function Suspense(props) {
|
|
|
678
759
|
noHydrate: true
|
|
679
760
|
});
|
|
680
761
|
const res = {
|
|
681
|
-
t: `<template id="pl-${id}"></template>${resolveSSRNode(
|
|
762
|
+
t: `<template id="pl-${id}"></template>${resolveSSRNode(
|
|
763
|
+
escape(props.fallback)
|
|
764
|
+
)}<!--pl-${id}-->`
|
|
682
765
|
};
|
|
683
766
|
setHydrateContext(ctx);
|
|
684
767
|
return res;
|
|
@@ -693,4 +776,58 @@ function Suspense(props) {
|
|
|
693
776
|
}, suspenseError);
|
|
694
777
|
}
|
|
695
778
|
|
|
696
|
-
export {
|
|
779
|
+
export {
|
|
780
|
+
$DEVCOMP,
|
|
781
|
+
$PROXY,
|
|
782
|
+
$TRACK,
|
|
783
|
+
DEV,
|
|
784
|
+
ErrorBoundary,
|
|
785
|
+
For,
|
|
786
|
+
Index,
|
|
787
|
+
Match,
|
|
788
|
+
Show,
|
|
789
|
+
Suspense,
|
|
790
|
+
SuspenseList,
|
|
791
|
+
Switch,
|
|
792
|
+
batch,
|
|
793
|
+
catchError,
|
|
794
|
+
children,
|
|
795
|
+
createComponent,
|
|
796
|
+
createComputed,
|
|
797
|
+
createContext,
|
|
798
|
+
createDeferred,
|
|
799
|
+
createEffect,
|
|
800
|
+
createMemo,
|
|
801
|
+
createReaction,
|
|
802
|
+
createRenderEffect,
|
|
803
|
+
createResource,
|
|
804
|
+
createRoot,
|
|
805
|
+
createSelector,
|
|
806
|
+
createSignal,
|
|
807
|
+
createUniqueId,
|
|
808
|
+
enableExternalSource,
|
|
809
|
+
enableHydration,
|
|
810
|
+
enableScheduling,
|
|
811
|
+
equalFn,
|
|
812
|
+
from,
|
|
813
|
+
getListener,
|
|
814
|
+
getOwner,
|
|
815
|
+
indexArray,
|
|
816
|
+
lazy,
|
|
817
|
+
mapArray,
|
|
818
|
+
mergeProps,
|
|
819
|
+
observable,
|
|
820
|
+
on,
|
|
821
|
+
onCleanup,
|
|
822
|
+
onError,
|
|
823
|
+
onMount,
|
|
824
|
+
requestCallback,
|
|
825
|
+
resetErrorBoundaries,
|
|
826
|
+
runWithOwner,
|
|
827
|
+
sharedConfig,
|
|
828
|
+
splitProps,
|
|
829
|
+
startTransition,
|
|
830
|
+
untrack,
|
|
831
|
+
useContext,
|
|
832
|
+
useTransition
|
|
833
|
+
};
|
package/dist/solid.cjs
CHANGED
|
@@ -257,14 +257,14 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
257
257
|
let source;
|
|
258
258
|
let fetcher;
|
|
259
259
|
let options;
|
|
260
|
-
if (
|
|
261
|
-
source = true;
|
|
262
|
-
fetcher = pSource;
|
|
263
|
-
options = pFetcher || {};
|
|
264
|
-
} else {
|
|
260
|
+
if (typeof pFetcher === "function") {
|
|
265
261
|
source = pSource;
|
|
266
262
|
fetcher = pFetcher;
|
|
267
263
|
options = pOptions || {};
|
|
264
|
+
} else {
|
|
265
|
+
source = true;
|
|
266
|
+
fetcher = pSource;
|
|
267
|
+
options = pFetcher || {};
|
|
268
268
|
}
|
|
269
269
|
let pr = null,
|
|
270
270
|
initP = NO_INIT,
|