solid-js 1.2.5 → 1.3.0-beta.0
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 +52 -28
- package/dist/dev.js +53 -28
- package/dist/server.cjs +20 -51
- package/dist/server.js +21 -51
- package/dist/solid.cjs +52 -28
- package/dist/solid.js +53 -28
- package/package.json +2 -2
- package/types/index.d.ts +0 -1
- package/types/reactive/signal.d.ts +76 -78
- package/types/render/hydration.d.ts +3 -2
- package/types/server/index.d.ts +1 -1
- package/types/server/reactive.d.ts +1 -2
- package/types/server/rendering.d.ts +2 -1
- package/web/dist/dev.cjs +26 -16
- package/web/dist/dev.js +27 -16
- package/web/dist/server.cjs +205 -99
- package/web/dist/server.js +206 -101
- package/web/dist/web.cjs +26 -16
- package/web/dist/web.js +27 -16
- package/web/types/client.d.ts +0 -1
- package/web/types/core.d.ts +2 -2
package/dist/dev.cjs
CHANGED
|
@@ -187,12 +187,13 @@ function createSignal(value, options) {
|
|
|
187
187
|
comparator: options.equals || undefined
|
|
188
188
|
};
|
|
189
189
|
if (!options.internal) s.name = registerGraph(options.name || hashValue(value), s);
|
|
190
|
-
|
|
190
|
+
const setter = value => {
|
|
191
191
|
if (typeof value === "function") {
|
|
192
192
|
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.pending !== NOTPENDING ? s.pending : s.tValue);else value = value(s.pending !== NOTPENDING ? s.pending : s.value);
|
|
193
193
|
}
|
|
194
194
|
return writeSignal(s, value);
|
|
195
|
-
}
|
|
195
|
+
};
|
|
196
|
+
return [readSignal.bind(s), setter];
|
|
196
197
|
}
|
|
197
198
|
function createComputed(fn, value, options) {
|
|
198
199
|
const c = createComputation(fn, value, true, STALE, options );
|
|
@@ -249,12 +250,7 @@ function createResource(source, fetcher, options) {
|
|
|
249
250
|
dynamic = typeof source === "function";
|
|
250
251
|
if (sharedConfig.context) {
|
|
251
252
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
252
|
-
if (sharedConfig.
|
|
253
|
-
initP = sharedConfig.context.loadResource(id);
|
|
254
|
-
} else if (sharedConfig.resources && id && id in sharedConfig.resources) {
|
|
255
|
-
initP = sharedConfig.resources[id];
|
|
256
|
-
delete sharedConfig.resources[id];
|
|
257
|
-
}
|
|
253
|
+
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
258
254
|
}
|
|
259
255
|
function loadEnd(p, v, e) {
|
|
260
256
|
if (pr === p) {
|
|
@@ -409,7 +405,8 @@ function untrack(fn) {
|
|
|
409
405
|
Listener = listener;
|
|
410
406
|
return result;
|
|
411
407
|
}
|
|
412
|
-
function on(deps, fn,
|
|
408
|
+
function on(deps, fn,
|
|
409
|
+
options) {
|
|
413
410
|
const isArray = Array.isArray(deps);
|
|
414
411
|
let prevInput;
|
|
415
412
|
let defer = options && options.defer;
|
|
@@ -1237,7 +1234,7 @@ function lazy(fn) {
|
|
|
1237
1234
|
let comp;
|
|
1238
1235
|
const wrap = props => {
|
|
1239
1236
|
const ctx = sharedConfig.context;
|
|
1240
|
-
if (ctx
|
|
1237
|
+
if (ctx) {
|
|
1241
1238
|
ctx.count++;
|
|
1242
1239
|
const [s, set] = createSignal();
|
|
1243
1240
|
fn().then(mod => {
|
|
@@ -1310,7 +1307,7 @@ function Switch(props) {
|
|
|
1310
1307
|
}
|
|
1311
1308
|
return [-1];
|
|
1312
1309
|
}, undefined, {
|
|
1313
|
-
equals: (a, b) => a
|
|
1310
|
+
equals: (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
|
|
1314
1311
|
});
|
|
1315
1312
|
return createMemo(() => {
|
|
1316
1313
|
const [index, when, cond] = evalConditions();
|
|
@@ -1404,7 +1401,10 @@ function SuspenseList(props) {
|
|
|
1404
1401
|
function Suspense(props) {
|
|
1405
1402
|
let counter = 0,
|
|
1406
1403
|
showContent,
|
|
1407
|
-
showFallback
|
|
1404
|
+
showFallback,
|
|
1405
|
+
ctx,
|
|
1406
|
+
waitingHydration,
|
|
1407
|
+
flicker;
|
|
1408
1408
|
const [inFallback, setFallback] = createSignal(false),
|
|
1409
1409
|
SuspenseContext = getSuspenseContext(),
|
|
1410
1410
|
store = {
|
|
@@ -1419,6 +1419,24 @@ function Suspense(props) {
|
|
|
1419
1419
|
resolved: false
|
|
1420
1420
|
},
|
|
1421
1421
|
owner = getOwner();
|
|
1422
|
+
if (sharedConfig.context && sharedConfig.load) {
|
|
1423
|
+
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1424
|
+
const p = sharedConfig.load(key);
|
|
1425
|
+
if (p) {
|
|
1426
|
+
const [s, set] = createSignal(undefined, {
|
|
1427
|
+
equals: false
|
|
1428
|
+
});
|
|
1429
|
+
flicker = s;
|
|
1430
|
+
p.then(() => {
|
|
1431
|
+
sharedConfig.gather(key);
|
|
1432
|
+
waitingHydration = true;
|
|
1433
|
+
setHydrateContext(ctx);
|
|
1434
|
+
set();
|
|
1435
|
+
setHydrateContext(undefined);
|
|
1436
|
+
waitingHydration = false;
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1422
1440
|
const listContext = useContext(SuspenseListContext);
|
|
1423
1441
|
if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
|
|
1424
1442
|
let dispose;
|
|
@@ -1426,28 +1444,35 @@ function Suspense(props) {
|
|
|
1426
1444
|
return createComponent(SuspenseContext.Provider, {
|
|
1427
1445
|
value: store,
|
|
1428
1446
|
get children() {
|
|
1429
|
-
const rendered = untrack(() => props.children);
|
|
1430
1447
|
return createMemo(() => {
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
if (!inFallback && visibleContent) {
|
|
1436
|
-
store.resolved = true;
|
|
1437
|
-
resumeEffects(store.effects);
|
|
1438
|
-
return rendered;
|
|
1448
|
+
if (flicker) {
|
|
1449
|
+
ctx = sharedConfig.context;
|
|
1450
|
+
flicker();
|
|
1451
|
+
return flicker = undefined;
|
|
1439
1452
|
}
|
|
1440
|
-
|
|
1441
|
-
return
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1453
|
+
const rendered = untrack(() => props.children);
|
|
1454
|
+
return createMemo(() => {
|
|
1455
|
+
const inFallback = store.inFallback(),
|
|
1456
|
+
visibleContent = showContent ? showContent() : true,
|
|
1457
|
+
visibleFallback = showFallback ? showFallback() : true;
|
|
1458
|
+
dispose && dispose();
|
|
1459
|
+
if ((!inFallback || waitingHydration) && visibleContent) {
|
|
1460
|
+
store.resolved = true;
|
|
1461
|
+
resumeEffects(store.effects);
|
|
1462
|
+
return rendered;
|
|
1463
|
+
}
|
|
1464
|
+
if (!visibleFallback) return;
|
|
1465
|
+
return createRoot(disposer => {
|
|
1466
|
+
dispose = disposer;
|
|
1467
|
+
if (sharedConfig.context) sharedConfig.context.count = 0;
|
|
1468
|
+
return props.fallback;
|
|
1469
|
+
}, owner);
|
|
1470
|
+
});
|
|
1445
1471
|
});
|
|
1446
1472
|
}
|
|
1447
1473
|
});
|
|
1448
1474
|
}
|
|
1449
1475
|
|
|
1450
|
-
function awaitSuspense() {}
|
|
1451
1476
|
exports.DEV = void 0;
|
|
1452
1477
|
{
|
|
1453
1478
|
exports.DEV = {
|
|
@@ -1470,7 +1495,6 @@ exports.Show = Show;
|
|
|
1470
1495
|
exports.Suspense = Suspense;
|
|
1471
1496
|
exports.SuspenseList = SuspenseList;
|
|
1472
1497
|
exports.Switch = Switch;
|
|
1473
|
-
exports.awaitSuspense = awaitSuspense;
|
|
1474
1498
|
exports.batch = batch;
|
|
1475
1499
|
exports.cancelCallback = cancelCallback;
|
|
1476
1500
|
exports.children = children;
|
package/dist/dev.js
CHANGED
|
@@ -183,12 +183,13 @@ function createSignal(value, options) {
|
|
|
183
183
|
comparator: options.equals || undefined
|
|
184
184
|
};
|
|
185
185
|
if (!options.internal) s.name = registerGraph(options.name || hashValue(value), s);
|
|
186
|
-
|
|
186
|
+
const setter = value => {
|
|
187
187
|
if (typeof value === "function") {
|
|
188
188
|
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.pending !== NOTPENDING ? s.pending : s.tValue);else value = value(s.pending !== NOTPENDING ? s.pending : s.value);
|
|
189
189
|
}
|
|
190
190
|
return writeSignal(s, value);
|
|
191
|
-
}
|
|
191
|
+
};
|
|
192
|
+
return [readSignal.bind(s), setter];
|
|
192
193
|
}
|
|
193
194
|
function createComputed(fn, value, options) {
|
|
194
195
|
const c = createComputation(fn, value, true, STALE, options );
|
|
@@ -245,12 +246,7 @@ function createResource(source, fetcher, options) {
|
|
|
245
246
|
dynamic = typeof source === "function";
|
|
246
247
|
if (sharedConfig.context) {
|
|
247
248
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
248
|
-
if (sharedConfig.
|
|
249
|
-
initP = sharedConfig.context.loadResource(id);
|
|
250
|
-
} else if (sharedConfig.resources && id && id in sharedConfig.resources) {
|
|
251
|
-
initP = sharedConfig.resources[id];
|
|
252
|
-
delete sharedConfig.resources[id];
|
|
253
|
-
}
|
|
249
|
+
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
254
250
|
}
|
|
255
251
|
function loadEnd(p, v, e) {
|
|
256
252
|
if (pr === p) {
|
|
@@ -405,7 +401,8 @@ function untrack(fn) {
|
|
|
405
401
|
Listener = listener;
|
|
406
402
|
return result;
|
|
407
403
|
}
|
|
408
|
-
function on(deps, fn,
|
|
404
|
+
function on(deps, fn,
|
|
405
|
+
options) {
|
|
409
406
|
const isArray = Array.isArray(deps);
|
|
410
407
|
let prevInput;
|
|
411
408
|
let defer = options && options.defer;
|
|
@@ -1233,7 +1230,7 @@ function lazy(fn) {
|
|
|
1233
1230
|
let comp;
|
|
1234
1231
|
const wrap = props => {
|
|
1235
1232
|
const ctx = sharedConfig.context;
|
|
1236
|
-
if (ctx
|
|
1233
|
+
if (ctx) {
|
|
1237
1234
|
ctx.count++;
|
|
1238
1235
|
const [s, set] = createSignal();
|
|
1239
1236
|
fn().then(mod => {
|
|
@@ -1306,7 +1303,7 @@ function Switch(props) {
|
|
|
1306
1303
|
}
|
|
1307
1304
|
return [-1];
|
|
1308
1305
|
}, undefined, {
|
|
1309
|
-
equals: (a, b) => a
|
|
1306
|
+
equals: (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
|
|
1310
1307
|
});
|
|
1311
1308
|
return createMemo(() => {
|
|
1312
1309
|
const [index, when, cond] = evalConditions();
|
|
@@ -1400,7 +1397,10 @@ function SuspenseList(props) {
|
|
|
1400
1397
|
function Suspense(props) {
|
|
1401
1398
|
let counter = 0,
|
|
1402
1399
|
showContent,
|
|
1403
|
-
showFallback
|
|
1400
|
+
showFallback,
|
|
1401
|
+
ctx,
|
|
1402
|
+
waitingHydration,
|
|
1403
|
+
flicker;
|
|
1404
1404
|
const [inFallback, setFallback] = createSignal(false),
|
|
1405
1405
|
SuspenseContext = getSuspenseContext(),
|
|
1406
1406
|
store = {
|
|
@@ -1415,6 +1415,24 @@ function Suspense(props) {
|
|
|
1415
1415
|
resolved: false
|
|
1416
1416
|
},
|
|
1417
1417
|
owner = getOwner();
|
|
1418
|
+
if (sharedConfig.context && sharedConfig.load) {
|
|
1419
|
+
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1420
|
+
const p = sharedConfig.load(key);
|
|
1421
|
+
if (p) {
|
|
1422
|
+
const [s, set] = createSignal(undefined, {
|
|
1423
|
+
equals: false
|
|
1424
|
+
});
|
|
1425
|
+
flicker = s;
|
|
1426
|
+
p.then(() => {
|
|
1427
|
+
sharedConfig.gather(key);
|
|
1428
|
+
waitingHydration = true;
|
|
1429
|
+
setHydrateContext(ctx);
|
|
1430
|
+
set();
|
|
1431
|
+
setHydrateContext(undefined);
|
|
1432
|
+
waitingHydration = false;
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1418
1436
|
const listContext = useContext(SuspenseListContext);
|
|
1419
1437
|
if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
|
|
1420
1438
|
let dispose;
|
|
@@ -1422,28 +1440,35 @@ function Suspense(props) {
|
|
|
1422
1440
|
return createComponent(SuspenseContext.Provider, {
|
|
1423
1441
|
value: store,
|
|
1424
1442
|
get children() {
|
|
1425
|
-
const rendered = untrack(() => props.children);
|
|
1426
1443
|
return createMemo(() => {
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
if (!inFallback && visibleContent) {
|
|
1432
|
-
store.resolved = true;
|
|
1433
|
-
resumeEffects(store.effects);
|
|
1434
|
-
return rendered;
|
|
1444
|
+
if (flicker) {
|
|
1445
|
+
ctx = sharedConfig.context;
|
|
1446
|
+
flicker();
|
|
1447
|
+
return flicker = undefined;
|
|
1435
1448
|
}
|
|
1436
|
-
|
|
1437
|
-
return
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1449
|
+
const rendered = untrack(() => props.children);
|
|
1450
|
+
return createMemo(() => {
|
|
1451
|
+
const inFallback = store.inFallback(),
|
|
1452
|
+
visibleContent = showContent ? showContent() : true,
|
|
1453
|
+
visibleFallback = showFallback ? showFallback() : true;
|
|
1454
|
+
dispose && dispose();
|
|
1455
|
+
if ((!inFallback || waitingHydration) && visibleContent) {
|
|
1456
|
+
store.resolved = true;
|
|
1457
|
+
resumeEffects(store.effects);
|
|
1458
|
+
return rendered;
|
|
1459
|
+
}
|
|
1460
|
+
if (!visibleFallback) return;
|
|
1461
|
+
return createRoot(disposer => {
|
|
1462
|
+
dispose = disposer;
|
|
1463
|
+
if (sharedConfig.context) sharedConfig.context.count = 0;
|
|
1464
|
+
return props.fallback;
|
|
1465
|
+
}, owner);
|
|
1466
|
+
});
|
|
1441
1467
|
});
|
|
1442
1468
|
}
|
|
1443
1469
|
});
|
|
1444
1470
|
}
|
|
1445
1471
|
|
|
1446
|
-
function awaitSuspense() {}
|
|
1447
1472
|
let DEV;
|
|
1448
1473
|
{
|
|
1449
1474
|
DEV = {
|
|
@@ -1457,4 +1482,4 @@ if (globalThis) {
|
|
|
1457
1482
|
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
1458
1483
|
}
|
|
1459
1484
|
|
|
1460
|
-
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch,
|
|
1485
|
+
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, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
package/dist/server.cjs
CHANGED
|
@@ -219,7 +219,7 @@ function createUniqueId() {
|
|
|
219
219
|
return `${ctx.id}${ctx.count++}`;
|
|
220
220
|
}
|
|
221
221
|
function createComponent(Comp, props) {
|
|
222
|
-
if (sharedConfig.context) {
|
|
222
|
+
if (sharedConfig.context && !sharedConfig.context.noHydrate) {
|
|
223
223
|
const c = sharedConfig.context;
|
|
224
224
|
setHydrateContext(nextHydrateContext());
|
|
225
225
|
const r = Comp(props);
|
|
@@ -320,7 +320,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
320
320
|
const read = () => {
|
|
321
321
|
if (resourceContext && p) resourceContext.push(p);
|
|
322
322
|
const resolved = sharedConfig.context.async && sharedConfig.context.resources[id].data;
|
|
323
|
-
if (
|
|
323
|
+
if (!resolved) {
|
|
324
324
|
const ctx = useContext(SuspenseContext);
|
|
325
325
|
if (ctx) {
|
|
326
326
|
ctx.resources.set(id, read);
|
|
@@ -332,7 +332,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
332
332
|
read.loading = false;
|
|
333
333
|
function load() {
|
|
334
334
|
const ctx = sharedConfig.context;
|
|
335
|
-
if (!ctx.async
|
|
335
|
+
if (!ctx.async) return read.loading = true;
|
|
336
336
|
if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
|
|
337
337
|
value = ctx.resources[id].data;
|
|
338
338
|
return;
|
|
@@ -349,15 +349,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
349
349
|
}
|
|
350
350
|
read.loading = true;
|
|
351
351
|
if ("then" in p) {
|
|
352
|
-
if (ctx.writeResource)
|
|
353
|
-
ctx.writeResource(id, p);
|
|
354
|
-
p.then(v => {
|
|
355
|
-
value = v;
|
|
356
|
-
read.loading = false;
|
|
357
|
-
p = null;
|
|
358
|
-
});
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
352
|
+
if (ctx.writeResource) ctx.writeResource(id, p);
|
|
361
353
|
p.then(res => {
|
|
362
354
|
read.loading = false;
|
|
363
355
|
ctx.resources[id].data = res;
|
|
@@ -392,7 +384,7 @@ function lazy(fn) {
|
|
|
392
384
|
ctx.resources.set(id, track);
|
|
393
385
|
contexts.add(ctx);
|
|
394
386
|
}
|
|
395
|
-
p.then(() => {
|
|
387
|
+
if (sharedConfig.context.async) p.then(() => {
|
|
396
388
|
track.loading = false;
|
|
397
389
|
notifySuspense(contexts);
|
|
398
390
|
});
|
|
@@ -425,15 +417,10 @@ function useTransition() {
|
|
|
425
417
|
function SuspenseList(props) {
|
|
426
418
|
return props.children;
|
|
427
419
|
}
|
|
428
|
-
const SUSPENSE_GLOBAL = Symbol("suspense-global");
|
|
429
420
|
function Suspense(props) {
|
|
430
421
|
const ctx = sharedConfig.context;
|
|
431
|
-
if (!ctx.async) return createComponent(() => {
|
|
432
|
-
props.children;
|
|
433
|
-
return props.fallback;
|
|
434
|
-
}, {});
|
|
435
422
|
const id = ctx.id + ctx.count;
|
|
436
|
-
const done = ctx.async ?
|
|
423
|
+
const done = ctx.async ? ctx.registerFragment(id) : () => {};
|
|
437
424
|
const o = Owner;
|
|
438
425
|
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
439
426
|
resources: new Map(),
|
|
@@ -462,40 +449,23 @@ function Suspense(props) {
|
|
|
462
449
|
done();
|
|
463
450
|
return res;
|
|
464
451
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
function awaitSuspense(fn) {
|
|
471
|
-
return new Promise(resolve => {
|
|
472
|
-
const registry = new Set();
|
|
473
|
-
const cache = Object.create(null);
|
|
474
|
-
const res = createMemo(() => {
|
|
475
|
-
Owner.context = {
|
|
476
|
-
[SUSPENSE_GLOBAL]: getCallback
|
|
477
|
-
};
|
|
478
|
-
return fn();
|
|
479
|
-
});
|
|
480
|
-
if (!registry.size) resolve(res());
|
|
481
|
-
function getCallback(key) {
|
|
482
|
-
registry.add(key);
|
|
483
|
-
return value => {
|
|
484
|
-
if (value) cache[key] = value;
|
|
485
|
-
registry.delete(key);
|
|
486
|
-
if (!registry.size) Promise.resolve().then(() => {
|
|
487
|
-
let source = resolveSSRNode(res());
|
|
488
|
-
let final = "";
|
|
489
|
-
let match;
|
|
490
|
-
while (match = source.match(SUSPENSE_REPLACE)) {
|
|
491
|
-
final += source.substring(0, match.index);
|
|
492
|
-
source = cache[match[1]] + source.substring(match.index + match[0].length);
|
|
493
|
-
}
|
|
494
|
-
resolve(final + source);
|
|
495
|
-
});
|
|
452
|
+
if (sharedConfig.context.async) {
|
|
453
|
+
if (sharedConfig.context.streaming) {
|
|
454
|
+
setHydrateContext(undefined);
|
|
455
|
+
const res = {
|
|
456
|
+
t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
|
|
496
457
|
};
|
|
458
|
+
setHydrateContext(ctx);
|
|
459
|
+
return res;
|
|
497
460
|
}
|
|
461
|
+
return {
|
|
462
|
+
t: `<![${id}]>`
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
setHydrateContext({ ...ctx,
|
|
466
|
+
count: 0
|
|
498
467
|
});
|
|
468
|
+
return createComponent(() => props.fallback, {});
|
|
499
469
|
}
|
|
500
470
|
|
|
501
471
|
exports.$PROXY = $PROXY;
|
|
@@ -508,7 +478,6 @@ exports.Show = Show;
|
|
|
508
478
|
exports.Suspense = Suspense;
|
|
509
479
|
exports.SuspenseList = SuspenseList;
|
|
510
480
|
exports.Switch = Switch;
|
|
511
|
-
exports.awaitSuspense = awaitSuspense;
|
|
512
481
|
exports.batch = batch;
|
|
513
482
|
exports.children = children;
|
|
514
483
|
exports.createComponent = createComponent;
|
package/dist/server.js
CHANGED
|
@@ -215,7 +215,7 @@ function createUniqueId() {
|
|
|
215
215
|
return `${ctx.id}${ctx.count++}`;
|
|
216
216
|
}
|
|
217
217
|
function createComponent(Comp, props) {
|
|
218
|
-
if (sharedConfig.context) {
|
|
218
|
+
if (sharedConfig.context && !sharedConfig.context.noHydrate) {
|
|
219
219
|
const c = sharedConfig.context;
|
|
220
220
|
setHydrateContext(nextHydrateContext());
|
|
221
221
|
const r = Comp(props);
|
|
@@ -316,7 +316,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
316
316
|
const read = () => {
|
|
317
317
|
if (resourceContext && p) resourceContext.push(p);
|
|
318
318
|
const resolved = sharedConfig.context.async && sharedConfig.context.resources[id].data;
|
|
319
|
-
if (
|
|
319
|
+
if (!resolved) {
|
|
320
320
|
const ctx = useContext(SuspenseContext);
|
|
321
321
|
if (ctx) {
|
|
322
322
|
ctx.resources.set(id, read);
|
|
@@ -328,7 +328,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
328
328
|
read.loading = false;
|
|
329
329
|
function load() {
|
|
330
330
|
const ctx = sharedConfig.context;
|
|
331
|
-
if (!ctx.async
|
|
331
|
+
if (!ctx.async) return read.loading = true;
|
|
332
332
|
if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
|
|
333
333
|
value = ctx.resources[id].data;
|
|
334
334
|
return;
|
|
@@ -345,15 +345,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
345
345
|
}
|
|
346
346
|
read.loading = true;
|
|
347
347
|
if ("then" in p) {
|
|
348
|
-
if (ctx.writeResource)
|
|
349
|
-
ctx.writeResource(id, p);
|
|
350
|
-
p.then(v => {
|
|
351
|
-
value = v;
|
|
352
|
-
read.loading = false;
|
|
353
|
-
p = null;
|
|
354
|
-
});
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
348
|
+
if (ctx.writeResource) ctx.writeResource(id, p);
|
|
357
349
|
p.then(res => {
|
|
358
350
|
read.loading = false;
|
|
359
351
|
ctx.resources[id].data = res;
|
|
@@ -388,7 +380,7 @@ function lazy(fn) {
|
|
|
388
380
|
ctx.resources.set(id, track);
|
|
389
381
|
contexts.add(ctx);
|
|
390
382
|
}
|
|
391
|
-
p.then(() => {
|
|
383
|
+
if (sharedConfig.context.async) p.then(() => {
|
|
392
384
|
track.loading = false;
|
|
393
385
|
notifySuspense(contexts);
|
|
394
386
|
});
|
|
@@ -421,15 +413,10 @@ function useTransition() {
|
|
|
421
413
|
function SuspenseList(props) {
|
|
422
414
|
return props.children;
|
|
423
415
|
}
|
|
424
|
-
const SUSPENSE_GLOBAL = Symbol("suspense-global");
|
|
425
416
|
function Suspense(props) {
|
|
426
417
|
const ctx = sharedConfig.context;
|
|
427
|
-
if (!ctx.async) return createComponent(() => {
|
|
428
|
-
props.children;
|
|
429
|
-
return props.fallback;
|
|
430
|
-
}, {});
|
|
431
418
|
const id = ctx.id + ctx.count;
|
|
432
|
-
const done = ctx.async ?
|
|
419
|
+
const done = ctx.async ? ctx.registerFragment(id) : () => {};
|
|
433
420
|
const o = Owner;
|
|
434
421
|
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
435
422
|
resources: new Map(),
|
|
@@ -458,40 +445,23 @@ function Suspense(props) {
|
|
|
458
445
|
done();
|
|
459
446
|
return res;
|
|
460
447
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
function awaitSuspense(fn) {
|
|
467
|
-
return new Promise(resolve => {
|
|
468
|
-
const registry = new Set();
|
|
469
|
-
const cache = Object.create(null);
|
|
470
|
-
const res = createMemo(() => {
|
|
471
|
-
Owner.context = {
|
|
472
|
-
[SUSPENSE_GLOBAL]: getCallback
|
|
473
|
-
};
|
|
474
|
-
return fn();
|
|
475
|
-
});
|
|
476
|
-
if (!registry.size) resolve(res());
|
|
477
|
-
function getCallback(key) {
|
|
478
|
-
registry.add(key);
|
|
479
|
-
return value => {
|
|
480
|
-
if (value) cache[key] = value;
|
|
481
|
-
registry.delete(key);
|
|
482
|
-
if (!registry.size) Promise.resolve().then(() => {
|
|
483
|
-
let source = resolveSSRNode(res());
|
|
484
|
-
let final = "";
|
|
485
|
-
let match;
|
|
486
|
-
while (match = source.match(SUSPENSE_REPLACE)) {
|
|
487
|
-
final += source.substring(0, match.index);
|
|
488
|
-
source = cache[match[1]] + source.substring(match.index + match[0].length);
|
|
489
|
-
}
|
|
490
|
-
resolve(final + source);
|
|
491
|
-
});
|
|
448
|
+
if (sharedConfig.context.async) {
|
|
449
|
+
if (sharedConfig.context.streaming) {
|
|
450
|
+
setHydrateContext(undefined);
|
|
451
|
+
const res = {
|
|
452
|
+
t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
|
|
492
453
|
};
|
|
454
|
+
setHydrateContext(ctx);
|
|
455
|
+
return res;
|
|
493
456
|
}
|
|
457
|
+
return {
|
|
458
|
+
t: `<![${id}]>`
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
setHydrateContext({ ...ctx,
|
|
462
|
+
count: 0
|
|
494
463
|
});
|
|
464
|
+
return createComponent(() => props.fallback, {});
|
|
495
465
|
}
|
|
496
466
|
|
|
497
|
-
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch,
|
|
467
|
+
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|