solid-js 1.3.0-beta.8 → 1.3.0-beta.9
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 -16
- package/dist/dev.js +28 -17
- package/dist/server.cjs +10 -10
- package/dist/server.js +10 -10
- package/dist/solid.cjs +28 -16
- package/dist/solid.js +28 -17
- package/package.json +2 -2
- package/types/index.d.ts +2 -2
- package/types/reactive/signal.d.ts +14 -3
- package/types/server/rendering.d.ts +0 -1
- package/web/dist/server.cjs +15 -15
- package/web/dist/server.js +15 -15
- package/web/types/server-mock.d.ts +0 -3
package/dist/dev.cjs
CHANGED
|
@@ -236,6 +236,9 @@ function createResource(source, fetcher, options) {
|
|
|
236
236
|
fetcher = source;
|
|
237
237
|
source = true;
|
|
238
238
|
}
|
|
239
|
+
Resources || (Resources = new Set());
|
|
240
|
+
Resources.add(load);
|
|
241
|
+
onCleanup(() => Resources.delete(load));
|
|
239
242
|
const contexts = new Set(),
|
|
240
243
|
[s, set] = createSignal((options || {}).initialValue),
|
|
241
244
|
[track, trigger] = createSignal(undefined, {
|
|
@@ -251,8 +254,6 @@ function createResource(source, fetcher, options) {
|
|
|
251
254
|
dynamic = typeof source === "function";
|
|
252
255
|
if (sharedConfig.context) {
|
|
253
256
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
254
|
-
({ ...sharedConfig.context
|
|
255
|
-
});
|
|
256
257
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
257
258
|
}
|
|
258
259
|
function loadEnd(p, v, e) {
|
|
@@ -299,7 +300,7 @@ function createResource(source, fetcher, options) {
|
|
|
299
300
|
}
|
|
300
301
|
return v;
|
|
301
302
|
}
|
|
302
|
-
function load() {
|
|
303
|
+
function load(refetching = true) {
|
|
303
304
|
setError(err = undefined);
|
|
304
305
|
const lookup = dynamic ? source() : source;
|
|
305
306
|
loadedUnderTransition = Transition && Transition.running;
|
|
@@ -308,7 +309,10 @@ function createResource(source, fetcher, options) {
|
|
|
308
309
|
return;
|
|
309
310
|
}
|
|
310
311
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
311
|
-
const p = initP || untrack(() => fetcher(lookup,
|
|
312
|
+
const p = initP || untrack(() => fetcher(lookup, {
|
|
313
|
+
value: s(),
|
|
314
|
+
refetching
|
|
315
|
+
}));
|
|
312
316
|
initP = null;
|
|
313
317
|
if (typeof p !== "object" || !("then" in p)) {
|
|
314
318
|
loadEnd(pr, p);
|
|
@@ -333,12 +337,16 @@ function createResource(source, fetcher, options) {
|
|
|
333
337
|
}
|
|
334
338
|
}
|
|
335
339
|
});
|
|
336
|
-
if (dynamic) createComputed(load);else load();
|
|
340
|
+
if (dynamic) createComputed(() => load(false));else load(false);
|
|
337
341
|
return [read, {
|
|
338
342
|
refetch: load,
|
|
339
343
|
mutate: set
|
|
340
344
|
}];
|
|
341
345
|
}
|
|
346
|
+
let Resources;
|
|
347
|
+
function refreshResources(info) {
|
|
348
|
+
Resources && Resources.forEach(fn => fn(info));
|
|
349
|
+
}
|
|
342
350
|
function createDeferred(source, options) {
|
|
343
351
|
let t,
|
|
344
352
|
timeout = options ? options.timeoutMs : undefined;
|
|
@@ -1450,7 +1458,7 @@ function Suspense(props) {
|
|
|
1450
1458
|
showContent,
|
|
1451
1459
|
showFallback,
|
|
1452
1460
|
ctx,
|
|
1453
|
-
|
|
1461
|
+
p,
|
|
1454
1462
|
flicker,
|
|
1455
1463
|
error;
|
|
1456
1464
|
const [inFallback, setFallback] = createSignal(false),
|
|
@@ -1469,8 +1477,8 @@ function Suspense(props) {
|
|
|
1469
1477
|
owner = getOwner();
|
|
1470
1478
|
if (sharedConfig.context) {
|
|
1471
1479
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1472
|
-
|
|
1473
|
-
if (p) {
|
|
1480
|
+
p = sharedConfig.load(key);
|
|
1481
|
+
if (p && typeof p === "object") {
|
|
1474
1482
|
const [s, set] = createSignal(undefined, {
|
|
1475
1483
|
equals: false
|
|
1476
1484
|
});
|
|
@@ -1478,11 +1486,10 @@ function Suspense(props) {
|
|
|
1478
1486
|
p.then(err => {
|
|
1479
1487
|
if (error = err) return set();
|
|
1480
1488
|
sharedConfig.gather(key);
|
|
1481
|
-
waitingHydration = true;
|
|
1482
1489
|
setHydrateContext(ctx);
|
|
1483
1490
|
set();
|
|
1484
1491
|
setHydrateContext();
|
|
1485
|
-
|
|
1492
|
+
p = undefined;
|
|
1486
1493
|
});
|
|
1487
1494
|
}
|
|
1488
1495
|
}
|
|
@@ -1495,18 +1502,19 @@ function Suspense(props) {
|
|
|
1495
1502
|
get children() {
|
|
1496
1503
|
return createMemo(() => {
|
|
1497
1504
|
if (error) throw error;
|
|
1505
|
+
ctx = sharedConfig.context;
|
|
1498
1506
|
if (flicker) {
|
|
1499
|
-
ctx = sharedConfig.context;
|
|
1500
1507
|
flicker();
|
|
1501
1508
|
return flicker = undefined;
|
|
1502
1509
|
}
|
|
1510
|
+
if (ctx && p === undefined) setHydrateContext();
|
|
1503
1511
|
const rendered = untrack(() => props.children);
|
|
1504
1512
|
return createMemo(() => {
|
|
1505
1513
|
const inFallback = store.inFallback(),
|
|
1506
1514
|
visibleContent = showContent ? showContent() : true,
|
|
1507
1515
|
visibleFallback = showFallback ? showFallback() : true;
|
|
1508
1516
|
dispose && dispose();
|
|
1509
|
-
if ((!inFallback ||
|
|
1517
|
+
if ((!inFallback || p !== undefined) && visibleContent) {
|
|
1510
1518
|
store.resolved = true;
|
|
1511
1519
|
resumeEffects(store.effects);
|
|
1512
1520
|
return rendered;
|
|
@@ -1514,10 +1522,13 @@ function Suspense(props) {
|
|
|
1514
1522
|
if (!visibleFallback) return;
|
|
1515
1523
|
return createRoot(disposer => {
|
|
1516
1524
|
dispose = disposer;
|
|
1517
|
-
if (
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1525
|
+
if (ctx) {
|
|
1526
|
+
setHydrateContext({
|
|
1527
|
+
id: ctx.id + "f",
|
|
1528
|
+
count: 0
|
|
1529
|
+
});
|
|
1530
|
+
ctx = undefined;
|
|
1531
|
+
}
|
|
1521
1532
|
return props.fallback;
|
|
1522
1533
|
}, owner);
|
|
1523
1534
|
});
|
|
@@ -1579,6 +1590,7 @@ exports.on = on;
|
|
|
1579
1590
|
exports.onCleanup = onCleanup;
|
|
1580
1591
|
exports.onError = onError;
|
|
1581
1592
|
exports.onMount = onMount;
|
|
1593
|
+
exports.refreshResources = refreshResources;
|
|
1582
1594
|
exports.requestCallback = requestCallback;
|
|
1583
1595
|
exports.runWithOwner = runWithOwner;
|
|
1584
1596
|
exports.sharedConfig = sharedConfig;
|
package/dist/dev.js
CHANGED
|
@@ -232,6 +232,9 @@ function createResource(source, fetcher, options) {
|
|
|
232
232
|
fetcher = source;
|
|
233
233
|
source = true;
|
|
234
234
|
}
|
|
235
|
+
Resources || (Resources = new Set());
|
|
236
|
+
Resources.add(load);
|
|
237
|
+
onCleanup(() => Resources.delete(load));
|
|
235
238
|
const contexts = new Set(),
|
|
236
239
|
[s, set] = createSignal((options || {}).initialValue),
|
|
237
240
|
[track, trigger] = createSignal(undefined, {
|
|
@@ -247,8 +250,6 @@ function createResource(source, fetcher, options) {
|
|
|
247
250
|
dynamic = typeof source === "function";
|
|
248
251
|
if (sharedConfig.context) {
|
|
249
252
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
250
|
-
({ ...sharedConfig.context
|
|
251
|
-
});
|
|
252
253
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
253
254
|
}
|
|
254
255
|
function loadEnd(p, v, e) {
|
|
@@ -295,7 +296,7 @@ function createResource(source, fetcher, options) {
|
|
|
295
296
|
}
|
|
296
297
|
return v;
|
|
297
298
|
}
|
|
298
|
-
function load() {
|
|
299
|
+
function load(refetching = true) {
|
|
299
300
|
setError(err = undefined);
|
|
300
301
|
const lookup = dynamic ? source() : source;
|
|
301
302
|
loadedUnderTransition = Transition && Transition.running;
|
|
@@ -304,7 +305,10 @@ function createResource(source, fetcher, options) {
|
|
|
304
305
|
return;
|
|
305
306
|
}
|
|
306
307
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
307
|
-
const p = initP || untrack(() => fetcher(lookup,
|
|
308
|
+
const p = initP || untrack(() => fetcher(lookup, {
|
|
309
|
+
value: s(),
|
|
310
|
+
refetching
|
|
311
|
+
}));
|
|
308
312
|
initP = null;
|
|
309
313
|
if (typeof p !== "object" || !("then" in p)) {
|
|
310
314
|
loadEnd(pr, p);
|
|
@@ -329,12 +333,16 @@ function createResource(source, fetcher, options) {
|
|
|
329
333
|
}
|
|
330
334
|
}
|
|
331
335
|
});
|
|
332
|
-
if (dynamic) createComputed(load);else load();
|
|
336
|
+
if (dynamic) createComputed(() => load(false));else load(false);
|
|
333
337
|
return [read, {
|
|
334
338
|
refetch: load,
|
|
335
339
|
mutate: set
|
|
336
340
|
}];
|
|
337
341
|
}
|
|
342
|
+
let Resources;
|
|
343
|
+
function refreshResources(info) {
|
|
344
|
+
Resources && Resources.forEach(fn => fn(info));
|
|
345
|
+
}
|
|
338
346
|
function createDeferred(source, options) {
|
|
339
347
|
let t,
|
|
340
348
|
timeout = options ? options.timeoutMs : undefined;
|
|
@@ -1446,7 +1454,7 @@ function Suspense(props) {
|
|
|
1446
1454
|
showContent,
|
|
1447
1455
|
showFallback,
|
|
1448
1456
|
ctx,
|
|
1449
|
-
|
|
1457
|
+
p,
|
|
1450
1458
|
flicker,
|
|
1451
1459
|
error;
|
|
1452
1460
|
const [inFallback, setFallback] = createSignal(false),
|
|
@@ -1465,8 +1473,8 @@ function Suspense(props) {
|
|
|
1465
1473
|
owner = getOwner();
|
|
1466
1474
|
if (sharedConfig.context) {
|
|
1467
1475
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1468
|
-
|
|
1469
|
-
if (p) {
|
|
1476
|
+
p = sharedConfig.load(key);
|
|
1477
|
+
if (p && typeof p === "object") {
|
|
1470
1478
|
const [s, set] = createSignal(undefined, {
|
|
1471
1479
|
equals: false
|
|
1472
1480
|
});
|
|
@@ -1474,11 +1482,10 @@ function Suspense(props) {
|
|
|
1474
1482
|
p.then(err => {
|
|
1475
1483
|
if (error = err) return set();
|
|
1476
1484
|
sharedConfig.gather(key);
|
|
1477
|
-
waitingHydration = true;
|
|
1478
1485
|
setHydrateContext(ctx);
|
|
1479
1486
|
set();
|
|
1480
1487
|
setHydrateContext();
|
|
1481
|
-
|
|
1488
|
+
p = undefined;
|
|
1482
1489
|
});
|
|
1483
1490
|
}
|
|
1484
1491
|
}
|
|
@@ -1491,18 +1498,19 @@ function Suspense(props) {
|
|
|
1491
1498
|
get children() {
|
|
1492
1499
|
return createMemo(() => {
|
|
1493
1500
|
if (error) throw error;
|
|
1501
|
+
ctx = sharedConfig.context;
|
|
1494
1502
|
if (flicker) {
|
|
1495
|
-
ctx = sharedConfig.context;
|
|
1496
1503
|
flicker();
|
|
1497
1504
|
return flicker = undefined;
|
|
1498
1505
|
}
|
|
1506
|
+
if (ctx && p === undefined) setHydrateContext();
|
|
1499
1507
|
const rendered = untrack(() => props.children);
|
|
1500
1508
|
return createMemo(() => {
|
|
1501
1509
|
const inFallback = store.inFallback(),
|
|
1502
1510
|
visibleContent = showContent ? showContent() : true,
|
|
1503
1511
|
visibleFallback = showFallback ? showFallback() : true;
|
|
1504
1512
|
dispose && dispose();
|
|
1505
|
-
if ((!inFallback ||
|
|
1513
|
+
if ((!inFallback || p !== undefined) && visibleContent) {
|
|
1506
1514
|
store.resolved = true;
|
|
1507
1515
|
resumeEffects(store.effects);
|
|
1508
1516
|
return rendered;
|
|
@@ -1510,10 +1518,13 @@ function Suspense(props) {
|
|
|
1510
1518
|
if (!visibleFallback) return;
|
|
1511
1519
|
return createRoot(disposer => {
|
|
1512
1520
|
dispose = disposer;
|
|
1513
|
-
if (
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1521
|
+
if (ctx) {
|
|
1522
|
+
setHydrateContext({
|
|
1523
|
+
id: ctx.id + "f",
|
|
1524
|
+
count: 0
|
|
1525
|
+
});
|
|
1526
|
+
ctx = undefined;
|
|
1527
|
+
}
|
|
1517
1528
|
return props.fallback;
|
|
1518
1529
|
}, owner);
|
|
1519
1530
|
});
|
|
@@ -1535,4 +1546,4 @@ if (globalThis) {
|
|
|
1535
1546
|
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
1536
1547
|
}
|
|
1537
1548
|
|
|
1538
|
-
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
|
1549
|
+
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, refreshResources, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
package/dist/server.cjs
CHANGED
|
@@ -461,7 +461,6 @@ function Suspense(props) {
|
|
|
461
461
|
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
462
462
|
resources: new Map(),
|
|
463
463
|
completed: () => {
|
|
464
|
-
if (ctx.dataOnly) return done();
|
|
465
464
|
const res = runSuspense();
|
|
466
465
|
if (suspenseComplete(value)) {
|
|
467
466
|
done(resolveSSRNode(res));
|
|
@@ -482,20 +481,21 @@ function Suspense(props) {
|
|
|
482
481
|
});
|
|
483
482
|
}
|
|
484
483
|
const res = runSuspense();
|
|
485
|
-
if (suspenseComplete(value))
|
|
484
|
+
if (suspenseComplete(value)) {
|
|
485
|
+
ctx.writeResource(id, true);
|
|
486
|
+
return res;
|
|
487
|
+
}
|
|
486
488
|
onError(err => {
|
|
487
489
|
if (!done || !done(undefined, err)) throw err;
|
|
488
490
|
});
|
|
489
491
|
done = ctx.async ? ctx.registerFragment(id) : undefined;
|
|
490
492
|
if (ctx.streaming) {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
return res;
|
|
498
|
-
}
|
|
493
|
+
setHydrateContext(undefined);
|
|
494
|
+
const res = {
|
|
495
|
+
t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
|
|
496
|
+
};
|
|
497
|
+
setHydrateContext(ctx);
|
|
498
|
+
return res;
|
|
499
499
|
} else if (ctx.async) {
|
|
500
500
|
return {
|
|
501
501
|
t: `<![${id}]>`
|
package/dist/server.js
CHANGED
|
@@ -457,7 +457,6 @@ function Suspense(props) {
|
|
|
457
457
|
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
458
458
|
resources: new Map(),
|
|
459
459
|
completed: () => {
|
|
460
|
-
if (ctx.dataOnly) return done();
|
|
461
460
|
const res = runSuspense();
|
|
462
461
|
if (suspenseComplete(value)) {
|
|
463
462
|
done(resolveSSRNode(res));
|
|
@@ -478,20 +477,21 @@ function Suspense(props) {
|
|
|
478
477
|
});
|
|
479
478
|
}
|
|
480
479
|
const res = runSuspense();
|
|
481
|
-
if (suspenseComplete(value))
|
|
480
|
+
if (suspenseComplete(value)) {
|
|
481
|
+
ctx.writeResource(id, true);
|
|
482
|
+
return res;
|
|
483
|
+
}
|
|
482
484
|
onError(err => {
|
|
483
485
|
if (!done || !done(undefined, err)) throw err;
|
|
484
486
|
});
|
|
485
487
|
done = ctx.async ? ctx.registerFragment(id) : undefined;
|
|
486
488
|
if (ctx.streaming) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
return res;
|
|
494
|
-
}
|
|
489
|
+
setHydrateContext(undefined);
|
|
490
|
+
const res = {
|
|
491
|
+
t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
|
|
492
|
+
};
|
|
493
|
+
setHydrateContext(ctx);
|
|
494
|
+
return res;
|
|
495
495
|
} else if (ctx.async) {
|
|
496
496
|
return {
|
|
497
497
|
t: `<![${id}]>`
|
package/dist/solid.cjs
CHANGED
|
@@ -233,6 +233,9 @@ function createResource(source, fetcher, options) {
|
|
|
233
233
|
fetcher = source;
|
|
234
234
|
source = true;
|
|
235
235
|
}
|
|
236
|
+
Resources || (Resources = new Set());
|
|
237
|
+
Resources.add(load);
|
|
238
|
+
onCleanup(() => Resources.delete(load));
|
|
236
239
|
const contexts = new Set(),
|
|
237
240
|
[s, set] = createSignal((options || {}).initialValue),
|
|
238
241
|
[track, trigger] = createSignal(undefined, {
|
|
@@ -248,8 +251,6 @@ function createResource(source, fetcher, options) {
|
|
|
248
251
|
dynamic = typeof source === "function";
|
|
249
252
|
if (sharedConfig.context) {
|
|
250
253
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
251
|
-
({ ...sharedConfig.context
|
|
252
|
-
});
|
|
253
254
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
254
255
|
}
|
|
255
256
|
function loadEnd(p, v, e) {
|
|
@@ -296,7 +297,7 @@ function createResource(source, fetcher, options) {
|
|
|
296
297
|
}
|
|
297
298
|
return v;
|
|
298
299
|
}
|
|
299
|
-
function load() {
|
|
300
|
+
function load(refetching = true) {
|
|
300
301
|
setError(err = undefined);
|
|
301
302
|
const lookup = dynamic ? source() : source;
|
|
302
303
|
loadedUnderTransition = Transition && Transition.running;
|
|
@@ -305,7 +306,10 @@ function createResource(source, fetcher, options) {
|
|
|
305
306
|
return;
|
|
306
307
|
}
|
|
307
308
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
308
|
-
const p = initP || untrack(() => fetcher(lookup,
|
|
309
|
+
const p = initP || untrack(() => fetcher(lookup, {
|
|
310
|
+
value: s(),
|
|
311
|
+
refetching
|
|
312
|
+
}));
|
|
309
313
|
initP = null;
|
|
310
314
|
if (typeof p !== "object" || !("then" in p)) {
|
|
311
315
|
loadEnd(pr, p);
|
|
@@ -330,12 +334,16 @@ function createResource(source, fetcher, options) {
|
|
|
330
334
|
}
|
|
331
335
|
}
|
|
332
336
|
});
|
|
333
|
-
if (dynamic) createComputed(load);else load();
|
|
337
|
+
if (dynamic) createComputed(() => load(false));else load(false);
|
|
334
338
|
return [read, {
|
|
335
339
|
refetch: load,
|
|
336
340
|
mutate: set
|
|
337
341
|
}];
|
|
338
342
|
}
|
|
343
|
+
let Resources;
|
|
344
|
+
function refreshResources(info) {
|
|
345
|
+
Resources && Resources.forEach(fn => fn(info));
|
|
346
|
+
}
|
|
339
347
|
function createDeferred(source, options) {
|
|
340
348
|
let t,
|
|
341
349
|
timeout = options ? options.timeoutMs : undefined;
|
|
@@ -1374,7 +1382,7 @@ function Suspense(props) {
|
|
|
1374
1382
|
showContent,
|
|
1375
1383
|
showFallback,
|
|
1376
1384
|
ctx,
|
|
1377
|
-
|
|
1385
|
+
p,
|
|
1378
1386
|
flicker,
|
|
1379
1387
|
error;
|
|
1380
1388
|
const [inFallback, setFallback] = createSignal(false),
|
|
@@ -1393,8 +1401,8 @@ function Suspense(props) {
|
|
|
1393
1401
|
owner = getOwner();
|
|
1394
1402
|
if (sharedConfig.context) {
|
|
1395
1403
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1396
|
-
|
|
1397
|
-
if (p) {
|
|
1404
|
+
p = sharedConfig.load(key);
|
|
1405
|
+
if (p && typeof p === "object") {
|
|
1398
1406
|
const [s, set] = createSignal(undefined, {
|
|
1399
1407
|
equals: false
|
|
1400
1408
|
});
|
|
@@ -1402,11 +1410,10 @@ function Suspense(props) {
|
|
|
1402
1410
|
p.then(err => {
|
|
1403
1411
|
if (error = err) return set();
|
|
1404
1412
|
sharedConfig.gather(key);
|
|
1405
|
-
waitingHydration = true;
|
|
1406
1413
|
setHydrateContext(ctx);
|
|
1407
1414
|
set();
|
|
1408
1415
|
setHydrateContext();
|
|
1409
|
-
|
|
1416
|
+
p = undefined;
|
|
1410
1417
|
});
|
|
1411
1418
|
}
|
|
1412
1419
|
}
|
|
@@ -1419,18 +1426,19 @@ function Suspense(props) {
|
|
|
1419
1426
|
get children() {
|
|
1420
1427
|
return createMemo(() => {
|
|
1421
1428
|
if (error) throw error;
|
|
1429
|
+
ctx = sharedConfig.context;
|
|
1422
1430
|
if (flicker) {
|
|
1423
|
-
ctx = sharedConfig.context;
|
|
1424
1431
|
flicker();
|
|
1425
1432
|
return flicker = undefined;
|
|
1426
1433
|
}
|
|
1434
|
+
if (ctx && p === undefined) setHydrateContext();
|
|
1427
1435
|
const rendered = untrack(() => props.children);
|
|
1428
1436
|
return createMemo(() => {
|
|
1429
1437
|
const inFallback = store.inFallback(),
|
|
1430
1438
|
visibleContent = showContent ? showContent() : true,
|
|
1431
1439
|
visibleFallback = showFallback ? showFallback() : true;
|
|
1432
1440
|
dispose && dispose();
|
|
1433
|
-
if ((!inFallback ||
|
|
1441
|
+
if ((!inFallback || p !== undefined) && visibleContent) {
|
|
1434
1442
|
store.resolved = true;
|
|
1435
1443
|
resumeEffects(store.effects);
|
|
1436
1444
|
return rendered;
|
|
@@ -1438,10 +1446,13 @@ function Suspense(props) {
|
|
|
1438
1446
|
if (!visibleFallback) return;
|
|
1439
1447
|
return createRoot(disposer => {
|
|
1440
1448
|
dispose = disposer;
|
|
1441
|
-
if (
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1449
|
+
if (ctx) {
|
|
1450
|
+
setHydrateContext({
|
|
1451
|
+
id: ctx.id + "f",
|
|
1452
|
+
count: 0
|
|
1453
|
+
});
|
|
1454
|
+
ctx = undefined;
|
|
1455
|
+
}
|
|
1445
1456
|
return props.fallback;
|
|
1446
1457
|
}, owner);
|
|
1447
1458
|
});
|
|
@@ -1493,6 +1504,7 @@ exports.on = on;
|
|
|
1493
1504
|
exports.onCleanup = onCleanup;
|
|
1494
1505
|
exports.onError = onError;
|
|
1495
1506
|
exports.onMount = onMount;
|
|
1507
|
+
exports.refreshResources = refreshResources;
|
|
1496
1508
|
exports.requestCallback = requestCallback;
|
|
1497
1509
|
exports.runWithOwner = runWithOwner;
|
|
1498
1510
|
exports.sharedConfig = sharedConfig;
|
package/dist/solid.js
CHANGED
|
@@ -229,6 +229,9 @@ function createResource(source, fetcher, options) {
|
|
|
229
229
|
fetcher = source;
|
|
230
230
|
source = true;
|
|
231
231
|
}
|
|
232
|
+
Resources || (Resources = new Set());
|
|
233
|
+
Resources.add(load);
|
|
234
|
+
onCleanup(() => Resources.delete(load));
|
|
232
235
|
const contexts = new Set(),
|
|
233
236
|
[s, set] = createSignal((options || {}).initialValue),
|
|
234
237
|
[track, trigger] = createSignal(undefined, {
|
|
@@ -244,8 +247,6 @@ function createResource(source, fetcher, options) {
|
|
|
244
247
|
dynamic = typeof source === "function";
|
|
245
248
|
if (sharedConfig.context) {
|
|
246
249
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
247
|
-
({ ...sharedConfig.context
|
|
248
|
-
});
|
|
249
250
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
250
251
|
}
|
|
251
252
|
function loadEnd(p, v, e) {
|
|
@@ -292,7 +293,7 @@ function createResource(source, fetcher, options) {
|
|
|
292
293
|
}
|
|
293
294
|
return v;
|
|
294
295
|
}
|
|
295
|
-
function load() {
|
|
296
|
+
function load(refetching = true) {
|
|
296
297
|
setError(err = undefined);
|
|
297
298
|
const lookup = dynamic ? source() : source;
|
|
298
299
|
loadedUnderTransition = Transition && Transition.running;
|
|
@@ -301,7 +302,10 @@ function createResource(source, fetcher, options) {
|
|
|
301
302
|
return;
|
|
302
303
|
}
|
|
303
304
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
304
|
-
const p = initP || untrack(() => fetcher(lookup,
|
|
305
|
+
const p = initP || untrack(() => fetcher(lookup, {
|
|
306
|
+
value: s(),
|
|
307
|
+
refetching
|
|
308
|
+
}));
|
|
305
309
|
initP = null;
|
|
306
310
|
if (typeof p !== "object" || !("then" in p)) {
|
|
307
311
|
loadEnd(pr, p);
|
|
@@ -326,12 +330,16 @@ function createResource(source, fetcher, options) {
|
|
|
326
330
|
}
|
|
327
331
|
}
|
|
328
332
|
});
|
|
329
|
-
if (dynamic) createComputed(load);else load();
|
|
333
|
+
if (dynamic) createComputed(() => load(false));else load(false);
|
|
330
334
|
return [read, {
|
|
331
335
|
refetch: load,
|
|
332
336
|
mutate: set
|
|
333
337
|
}];
|
|
334
338
|
}
|
|
339
|
+
let Resources;
|
|
340
|
+
function refreshResources(info) {
|
|
341
|
+
Resources && Resources.forEach(fn => fn(info));
|
|
342
|
+
}
|
|
335
343
|
function createDeferred(source, options) {
|
|
336
344
|
let t,
|
|
337
345
|
timeout = options ? options.timeoutMs : undefined;
|
|
@@ -1370,7 +1378,7 @@ function Suspense(props) {
|
|
|
1370
1378
|
showContent,
|
|
1371
1379
|
showFallback,
|
|
1372
1380
|
ctx,
|
|
1373
|
-
|
|
1381
|
+
p,
|
|
1374
1382
|
flicker,
|
|
1375
1383
|
error;
|
|
1376
1384
|
const [inFallback, setFallback] = createSignal(false),
|
|
@@ -1389,8 +1397,8 @@ function Suspense(props) {
|
|
|
1389
1397
|
owner = getOwner();
|
|
1390
1398
|
if (sharedConfig.context) {
|
|
1391
1399
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1392
|
-
|
|
1393
|
-
if (p) {
|
|
1400
|
+
p = sharedConfig.load(key);
|
|
1401
|
+
if (p && typeof p === "object") {
|
|
1394
1402
|
const [s, set] = createSignal(undefined, {
|
|
1395
1403
|
equals: false
|
|
1396
1404
|
});
|
|
@@ -1398,11 +1406,10 @@ function Suspense(props) {
|
|
|
1398
1406
|
p.then(err => {
|
|
1399
1407
|
if (error = err) return set();
|
|
1400
1408
|
sharedConfig.gather(key);
|
|
1401
|
-
waitingHydration = true;
|
|
1402
1409
|
setHydrateContext(ctx);
|
|
1403
1410
|
set();
|
|
1404
1411
|
setHydrateContext();
|
|
1405
|
-
|
|
1412
|
+
p = undefined;
|
|
1406
1413
|
});
|
|
1407
1414
|
}
|
|
1408
1415
|
}
|
|
@@ -1415,18 +1422,19 @@ function Suspense(props) {
|
|
|
1415
1422
|
get children() {
|
|
1416
1423
|
return createMemo(() => {
|
|
1417
1424
|
if (error) throw error;
|
|
1425
|
+
ctx = sharedConfig.context;
|
|
1418
1426
|
if (flicker) {
|
|
1419
|
-
ctx = sharedConfig.context;
|
|
1420
1427
|
flicker();
|
|
1421
1428
|
return flicker = undefined;
|
|
1422
1429
|
}
|
|
1430
|
+
if (ctx && p === undefined) setHydrateContext();
|
|
1423
1431
|
const rendered = untrack(() => props.children);
|
|
1424
1432
|
return createMemo(() => {
|
|
1425
1433
|
const inFallback = store.inFallback(),
|
|
1426
1434
|
visibleContent = showContent ? showContent() : true,
|
|
1427
1435
|
visibleFallback = showFallback ? showFallback() : true;
|
|
1428
1436
|
dispose && dispose();
|
|
1429
|
-
if ((!inFallback ||
|
|
1437
|
+
if ((!inFallback || p !== undefined) && visibleContent) {
|
|
1430
1438
|
store.resolved = true;
|
|
1431
1439
|
resumeEffects(store.effects);
|
|
1432
1440
|
return rendered;
|
|
@@ -1434,10 +1442,13 @@ function Suspense(props) {
|
|
|
1434
1442
|
if (!visibleFallback) return;
|
|
1435
1443
|
return createRoot(disposer => {
|
|
1436
1444
|
dispose = disposer;
|
|
1437
|
-
if (
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1445
|
+
if (ctx) {
|
|
1446
|
+
setHydrateContext({
|
|
1447
|
+
id: ctx.id + "f",
|
|
1448
|
+
count: 0
|
|
1449
|
+
});
|
|
1450
|
+
ctx = undefined;
|
|
1451
|
+
}
|
|
1441
1452
|
return props.fallback;
|
|
1442
1453
|
}, owner);
|
|
1443
1454
|
});
|
|
@@ -1448,4 +1459,4 @@ function Suspense(props) {
|
|
|
1448
1459
|
|
|
1449
1460
|
let DEV;
|
|
1450
1461
|
|
|
1451
|
-
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
|
1462
|
+
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, refreshResources, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-js",
|
|
3
3
|
"description": "A declarative JavaScript library for building user interfaces.",
|
|
4
|
-
"version": "1.3.0-beta.
|
|
4
|
+
"version": "1.3.0-beta.9",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -144,5 +144,5 @@
|
|
|
144
144
|
"compiler",
|
|
145
145
|
"performance"
|
|
146
146
|
],
|
|
147
|
-
"gitHead": "
|
|
147
|
+
"gitHead": "058e842f24e8ef67121296774a526edbb1f7b5ad"
|
|
148
148
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $PROXY } from "./reactive/signal";
|
|
2
|
-
export type { Accessor, Setter, Resource, ResourceReturn, Context, ReturnTypes } from "./reactive/signal";
|
|
1
|
+
export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition, refreshResources, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $PROXY } from "./reactive/signal";
|
|
2
|
+
export type { Accessor, Setter, Resource, ResourceReturn, ResourceFetcher, ResourceFetcherInfo, Context, ReturnTypes } from "./reactive/signal";
|
|
3
3
|
export * from "./reactive/observable";
|
|
4
4
|
export * from "./reactive/scheduler";
|
|
5
5
|
export * from "./reactive/array";
|
|
@@ -185,11 +185,15 @@ export interface Resource<T> extends Accessor<T> {
|
|
|
185
185
|
}
|
|
186
186
|
export declare type ResourceActions<T> = {
|
|
187
187
|
mutate: Setter<T>;
|
|
188
|
-
refetch: () => void;
|
|
188
|
+
refetch: (info?: unknown) => void;
|
|
189
189
|
};
|
|
190
190
|
export declare type ResourceReturn<T> = [Resource<T>, ResourceActions<T>];
|
|
191
191
|
export declare type ResourceSource<S> = S | false | null | (() => S | false | null);
|
|
192
|
-
export declare type ResourceFetcher<S, T> = (k: S,
|
|
192
|
+
export declare type ResourceFetcher<S, T> = (k: S, info: ResourceFetcherInfo<T>) => T | Promise<T>;
|
|
193
|
+
export declare type ResourceFetcherInfo<T> = {
|
|
194
|
+
value: T | undefined;
|
|
195
|
+
refetching?: unknown;
|
|
196
|
+
};
|
|
193
197
|
export declare type ResourceOptions<T> = T extends undefined ? {
|
|
194
198
|
initialValue?: T;
|
|
195
199
|
name?: string;
|
|
@@ -207,7 +211,7 @@ export declare type ResourceOptions<T> = T extends undefined ? {
|
|
|
207
211
|
* ```typescript
|
|
208
212
|
* const fetcher: ResourceFetcher<S, T, > = (
|
|
209
213
|
* sourceOutput: ReturnValue<typeof source>,
|
|
210
|
-
*
|
|
214
|
+
* info: ResourceFetcherInfo<T>
|
|
211
215
|
* ) => T | Promise<T>;
|
|
212
216
|
* ```
|
|
213
217
|
* @param options - an optional object with the initialValue and the name (for debugging purposes)
|
|
@@ -226,6 +230,7 @@ export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S,
|
|
|
226
230
|
export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
227
231
|
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
|
|
228
232
|
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
233
|
+
export declare function refreshResources(info?: unknown): void;
|
|
229
234
|
export interface DeferredOptions<T> {
|
|
230
235
|
equals?: false | ((prev: T, next: T) => boolean);
|
|
231
236
|
name?: string;
|
|
@@ -348,6 +353,12 @@ export declare function getListener(): Computation<any, any> | null;
|
|
|
348
353
|
export declare function getOwner(): Owner | null;
|
|
349
354
|
export declare function runWithOwner(o: Owner, fn: () => any): any;
|
|
350
355
|
export declare function enableScheduling(scheduler?: typeof requestCallback): void;
|
|
356
|
+
/**
|
|
357
|
+
* ```typescript
|
|
358
|
+
* export function startTransition(fn: () => void, cb?: () => void) => void
|
|
359
|
+
*
|
|
360
|
+
* @description https://www.solidjs.com/docs/latest/api#usetransition
|
|
361
|
+
*/
|
|
351
362
|
export declare function startTransition(fn: () => void, cb?: () => void): void;
|
|
352
363
|
export declare type Transition = [Accessor<boolean>, (fn: () => void, cb?: () => void) => void];
|
|
353
364
|
/**
|
package/web/dist/server.cjs
CHANGED
|
@@ -243,7 +243,8 @@ function renderToString(code, options = {}) {
|
|
|
243
243
|
assets: [],
|
|
244
244
|
nonce: options.nonce,
|
|
245
245
|
writeResource(id, p, error) {
|
|
246
|
-
if (error) scripts += `_$HY.set("${id}", ${serializeError(p)});`;
|
|
246
|
+
if (error) return scripts += `_$HY.set("${id}", ${serializeError(p)});`;
|
|
247
|
+
scripts += `_$HY.set("${id}", ${devalue(p)});`;
|
|
247
248
|
}
|
|
248
249
|
};
|
|
249
250
|
let html = injectAssets(solidJs.sharedConfig.context.assets, resolveSSRNode(escape(code())));
|
|
@@ -251,6 +252,7 @@ function renderToString(code, options = {}) {
|
|
|
251
252
|
return html;
|
|
252
253
|
}
|
|
253
254
|
function renderToStringAsync(code, options = {}) {
|
|
255
|
+
let scripts = "";
|
|
254
256
|
const {
|
|
255
257
|
nonce,
|
|
256
258
|
renderId,
|
|
@@ -263,12 +265,12 @@ function renderToStringAsync(code, options = {}) {
|
|
|
263
265
|
suspense: {},
|
|
264
266
|
assets: [],
|
|
265
267
|
async: true,
|
|
266
|
-
nonce
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
268
|
+
nonce,
|
|
269
|
+
writeResource(id, p, error) {
|
|
270
|
+
if (error) return scripts += `_$HY.set("${id}", ${serializeError(p)});`;
|
|
271
|
+
if (typeof p !== "object" || !("then" in p)) return scripts += `_$HY.set("${id}", ${devalue(p)});`;
|
|
272
|
+
p.then(d => scripts += `_$HY.set("${id}", ${devalue(d)});`).catch(() => scripts += `_$HY.set("${id}", null);`);
|
|
273
|
+
}
|
|
272
274
|
};
|
|
273
275
|
const timeout = new Promise((_, reject) => setTimeout(() => reject("renderToString timed out"), timeoutMs));
|
|
274
276
|
function asyncWrap(fn) {
|
|
@@ -284,6 +286,7 @@ function renderToStringAsync(code, options = {}) {
|
|
|
284
286
|
cache[key] = value;
|
|
285
287
|
registry.delete(key);
|
|
286
288
|
if (error) return scripts += `_$HY.set("${key}", Promise.resolve(${serializeError(error)}));`;
|
|
289
|
+
scripts += `_$HY.set("${key}", true);`;
|
|
287
290
|
if (!registry.size) Promise.resolve().then(() => {
|
|
288
291
|
let source = resolveSSRNode(rendered);
|
|
289
292
|
let final = "";
|
|
@@ -310,7 +313,6 @@ function renderToStream(code, options = {}) {
|
|
|
310
313
|
nonce,
|
|
311
314
|
onCompleteShell,
|
|
312
315
|
onCompleteAll,
|
|
313
|
-
dataOnly,
|
|
314
316
|
renderId
|
|
315
317
|
} = options;
|
|
316
318
|
const tmp = [];
|
|
@@ -344,7 +346,6 @@ function renderToStream(code, options = {}) {
|
|
|
344
346
|
count: 0,
|
|
345
347
|
async: true,
|
|
346
348
|
streaming: true,
|
|
347
|
-
dataOnly,
|
|
348
349
|
resources: {},
|
|
349
350
|
suspense: {},
|
|
350
351
|
assets: [],
|
|
@@ -355,6 +356,7 @@ function renderToStream(code, options = {}) {
|
|
|
355
356
|
scheduled = true;
|
|
356
357
|
}
|
|
357
358
|
if (error) return tasks.push(`_$HY.set("${id}", ${serializeError(p)})`);
|
|
359
|
+
if (typeof p !== "object" || !("then" in p)) return tasks.push(`_$HY.set("${id}", ${devalue(p)})`);
|
|
358
360
|
tasks.push(`_$HY.init("${id}")`);
|
|
359
361
|
p.then(d => {
|
|
360
362
|
!completed && buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HY.set("${id}", ${devalue(d)})</script>`);
|
|
@@ -364,13 +366,11 @@ function renderToStream(code, options = {}) {
|
|
|
364
366
|
},
|
|
365
367
|
registerFragment(key) {
|
|
366
368
|
registry.set(key, []);
|
|
367
|
-
if (!
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
scheduled = true;
|
|
371
|
-
}
|
|
372
|
-
tasks.push(`_$HY.init("${key}")`);
|
|
369
|
+
if (!scheduled) {
|
|
370
|
+
Promise.resolve().then(writeInitialScript);
|
|
371
|
+
scheduled = true;
|
|
373
372
|
}
|
|
373
|
+
tasks.push(`_$HY.init("${key}")`);
|
|
374
374
|
return (value, error) => {
|
|
375
375
|
const keys = registry.get(key);
|
|
376
376
|
registry.delete(key);
|
package/web/dist/server.js
CHANGED
|
@@ -240,7 +240,8 @@ function renderToString(code, options = {}) {
|
|
|
240
240
|
assets: [],
|
|
241
241
|
nonce: options.nonce,
|
|
242
242
|
writeResource(id, p, error) {
|
|
243
|
-
if (error) scripts += `_$HY.set("${id}", ${serializeError(p)});`;
|
|
243
|
+
if (error) return scripts += `_$HY.set("${id}", ${serializeError(p)});`;
|
|
244
|
+
scripts += `_$HY.set("${id}", ${devalue(p)});`;
|
|
244
245
|
}
|
|
245
246
|
};
|
|
246
247
|
let html = injectAssets(sharedConfig.context.assets, resolveSSRNode(escape(code())));
|
|
@@ -248,6 +249,7 @@ function renderToString(code, options = {}) {
|
|
|
248
249
|
return html;
|
|
249
250
|
}
|
|
250
251
|
function renderToStringAsync(code, options = {}) {
|
|
252
|
+
let scripts = "";
|
|
251
253
|
const {
|
|
252
254
|
nonce,
|
|
253
255
|
renderId,
|
|
@@ -260,12 +262,12 @@ function renderToStringAsync(code, options = {}) {
|
|
|
260
262
|
suspense: {},
|
|
261
263
|
assets: [],
|
|
262
264
|
async: true,
|
|
263
|
-
nonce
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
265
|
+
nonce,
|
|
266
|
+
writeResource(id, p, error) {
|
|
267
|
+
if (error) return scripts += `_$HY.set("${id}", ${serializeError(p)});`;
|
|
268
|
+
if (typeof p !== "object" || !("then" in p)) return scripts += `_$HY.set("${id}", ${devalue(p)});`;
|
|
269
|
+
p.then(d => scripts += `_$HY.set("${id}", ${devalue(d)});`).catch(() => scripts += `_$HY.set("${id}", null);`);
|
|
270
|
+
}
|
|
269
271
|
};
|
|
270
272
|
const timeout = new Promise((_, reject) => setTimeout(() => reject("renderToString timed out"), timeoutMs));
|
|
271
273
|
function asyncWrap(fn) {
|
|
@@ -281,6 +283,7 @@ function renderToStringAsync(code, options = {}) {
|
|
|
281
283
|
cache[key] = value;
|
|
282
284
|
registry.delete(key);
|
|
283
285
|
if (error) return scripts += `_$HY.set("${key}", Promise.resolve(${serializeError(error)}));`;
|
|
286
|
+
scripts += `_$HY.set("${key}", true);`;
|
|
284
287
|
if (!registry.size) Promise.resolve().then(() => {
|
|
285
288
|
let source = resolveSSRNode(rendered);
|
|
286
289
|
let final = "";
|
|
@@ -307,7 +310,6 @@ function renderToStream(code, options = {}) {
|
|
|
307
310
|
nonce,
|
|
308
311
|
onCompleteShell,
|
|
309
312
|
onCompleteAll,
|
|
310
|
-
dataOnly,
|
|
311
313
|
renderId
|
|
312
314
|
} = options;
|
|
313
315
|
const tmp = [];
|
|
@@ -341,7 +343,6 @@ function renderToStream(code, options = {}) {
|
|
|
341
343
|
count: 0,
|
|
342
344
|
async: true,
|
|
343
345
|
streaming: true,
|
|
344
|
-
dataOnly,
|
|
345
346
|
resources: {},
|
|
346
347
|
suspense: {},
|
|
347
348
|
assets: [],
|
|
@@ -352,6 +353,7 @@ function renderToStream(code, options = {}) {
|
|
|
352
353
|
scheduled = true;
|
|
353
354
|
}
|
|
354
355
|
if (error) return tasks.push(`_$HY.set("${id}", ${serializeError(p)})`);
|
|
356
|
+
if (typeof p !== "object" || !("then" in p)) return tasks.push(`_$HY.set("${id}", ${devalue(p)})`);
|
|
355
357
|
tasks.push(`_$HY.init("${id}")`);
|
|
356
358
|
p.then(d => {
|
|
357
359
|
!completed && buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HY.set("${id}", ${devalue(d)})</script>`);
|
|
@@ -361,13 +363,11 @@ function renderToStream(code, options = {}) {
|
|
|
361
363
|
},
|
|
362
364
|
registerFragment(key) {
|
|
363
365
|
registry.set(key, []);
|
|
364
|
-
if (!
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
scheduled = true;
|
|
368
|
-
}
|
|
369
|
-
tasks.push(`_$HY.init("${key}")`);
|
|
366
|
+
if (!scheduled) {
|
|
367
|
+
Promise.resolve().then(writeInitialScript);
|
|
368
|
+
scheduled = true;
|
|
370
369
|
}
|
|
370
|
+
tasks.push(`_$HY.init("${key}")`);
|
|
371
371
|
return (value, error) => {
|
|
372
372
|
const keys = registry.get(key);
|
|
373
373
|
registry.delete(key);
|
|
@@ -9,7 +9,6 @@ export declare function renderToStringAsync<T>(fn: () => T, options?: {
|
|
|
9
9
|
}): Promise<string>;
|
|
10
10
|
export declare function renderToStream<T>(fn: () => T, options?: {
|
|
11
11
|
nonce?: string;
|
|
12
|
-
dataOnly?: boolean;
|
|
13
12
|
renderId?: string;
|
|
14
13
|
onCompleteShell?: () => void;
|
|
15
14
|
onCompleteAll?: () => void;
|
|
@@ -42,7 +41,6 @@ export declare type LegacyResults = {
|
|
|
42
41
|
*/
|
|
43
42
|
export declare function pipeToWritable<T>(fn: () => T, writable: WritableStream, options?: {
|
|
44
43
|
nonce?: string;
|
|
45
|
-
dataOnly?: boolean;
|
|
46
44
|
onReady?: (res: LegacyResults) => void;
|
|
47
45
|
onCompleteAll?: () => void;
|
|
48
46
|
}): void;
|
|
@@ -53,7 +51,6 @@ export declare function pipeToNodeWritable<T>(fn: () => T, writable: {
|
|
|
53
51
|
write: (v: string) => void;
|
|
54
52
|
}, options?: {
|
|
55
53
|
nonce?: string;
|
|
56
|
-
dataOnly?: boolean;
|
|
57
54
|
onReady?: (res: LegacyResults) => void;
|
|
58
55
|
onCompleteAll?: () => void;
|
|
59
56
|
}): void;
|