@solidjs/web 2.0.0-rc.20 → 2.0.0-rc.21
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/server.dev.js +163 -63
- package/dist/server.js +163 -63
- package/dist/server.observe.js +163 -63
- package/dist/web.dev.js +17 -24
- package/dist/web.js +17 -24
- package/dist/web.observe.js +17 -24
- package/frames/dist/server.dev.js +2 -6
- package/frames/dist/server.js +2 -6
- package/frames/dist/server.observe.js +2 -6
- package/package.json +2 -2
- package/serialization/dist/serialization.js +51 -11
- package/serialization/types/index.d.ts +35 -0
- package/serialization/types/serializer.d.ts +35 -0
- package/server-functions/dist/rich-args.js +27 -9
- package/server-functions/dist/server.dev.js +122 -36
- package/server-functions/dist/server.js +122 -36
- package/server-functions/dist/server.observe.js +122 -36
- package/types/frames/serializer.d.ts +35 -0
- package/types/serializer.d.ts +35 -0
- package/types/server-functions/client.d.ts +0 -1
- package/types/server-functions/server.d.ts +0 -1
- package/types/server-functions/uploads.d.ts +3 -0
- package/types/server-mock.d.ts +35 -8
- package/types/server.d.ts +45 -15
|
@@ -1331,7 +1331,19 @@ function createUploadDeserializer(form) {
|
|
|
1331
1331
|
if (typeof index !== "number" || !Number.isSafeInteger(index) || index < 0) refuse();
|
|
1332
1332
|
const part = form.get(UPLOAD_FILE_PART + index);
|
|
1333
1333
|
if (!isBlob(part)) refuse();
|
|
1334
|
-
return part;
|
|
1334
|
+
if (node.t === undefined) return part;
|
|
1335
|
+
const type = ctx.deserialize(node.t);
|
|
1336
|
+
if (typeof type !== "string") refuse();
|
|
1337
|
+
if (node.n === undefined) return new Blob([part], {
|
|
1338
|
+
type
|
|
1339
|
+
});
|
|
1340
|
+
const name = ctx.deserialize(node.n);
|
|
1341
|
+
const lastModified = node.l === undefined ? undefined : ctx.deserialize(node.l);
|
|
1342
|
+
if (typeof name !== "string" || typeof lastModified !== "number") refuse();
|
|
1343
|
+
return new File([part], name, {
|
|
1344
|
+
type,
|
|
1345
|
+
lastModified
|
|
1346
|
+
});
|
|
1335
1347
|
}
|
|
1336
1348
|
};
|
|
1337
1349
|
}
|
|
@@ -1429,59 +1441,124 @@ function scopeDeferredResult(value, scope) {
|
|
|
1429
1441
|
return scopeDeferredContents(value, scope);
|
|
1430
1442
|
}
|
|
1431
1443
|
class ScopeFrame {
|
|
1432
|
-
constructor(value, prototype, keys,
|
|
1444
|
+
constructor(value, prototype, keys, i, first) {
|
|
1433
1445
|
this.value = value;
|
|
1434
1446
|
this.prototype = prototype;
|
|
1435
1447
|
this.next = null;
|
|
1436
1448
|
this.keys = keys;
|
|
1437
|
-
this.
|
|
1438
|
-
this.
|
|
1449
|
+
this.i = i;
|
|
1450
|
+
this.first = first;
|
|
1451
|
+
this.descriptors = null;
|
|
1452
|
+
this.snapshotted = false;
|
|
1439
1453
|
this.changed = false;
|
|
1440
1454
|
}
|
|
1441
1455
|
}
|
|
1442
1456
|
function frameShell(frame) {
|
|
1443
|
-
return frame.next ??= frame.keys ? Object.create(frame.prototype, frame.descriptors) : frame.value.slice();
|
|
1457
|
+
return frame.next ??= frame.keys ? Object.create(frame.prototype, frame.descriptors ?? Object.getOwnPropertyDescriptors(frame.value)) : frame.value.slice();
|
|
1458
|
+
}
|
|
1459
|
+
function writableValue(descriptor) {
|
|
1460
|
+
return descriptor !== undefined && "value" in descriptor && descriptor.writable === true ? descriptor.value : undefined;
|
|
1461
|
+
}
|
|
1462
|
+
function carrierSlot(frame, key) {
|
|
1463
|
+
return writableValue(frame.descriptors ? frame.descriptors[key] : Object.getOwnPropertyDescriptor(frame.value, key));
|
|
1464
|
+
}
|
|
1465
|
+
function snapshotFrames(stack) {
|
|
1466
|
+
for (let k = stack.length - 1; k >= 0 && !stack[k].snapshotted; k--) {
|
|
1467
|
+
const frame = stack[k];
|
|
1468
|
+
frame.snapshotted = true;
|
|
1469
|
+
if (frame.keys) frame.descriptors = Object.getOwnPropertyDescriptors(frame.value);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
function isLeaf(value) {
|
|
1473
|
+
return value === null || typeof value !== "object" && typeof value !== "function";
|
|
1474
|
+
}
|
|
1475
|
+
function sharedPrototypesInert() {
|
|
1476
|
+
const {
|
|
1477
|
+
toStringTag,
|
|
1478
|
+
asyncIterator,
|
|
1479
|
+
iterator,
|
|
1480
|
+
hasInstance
|
|
1481
|
+
} = Symbol;
|
|
1482
|
+
return !(Object.hasOwn(Promise, hasInstance) || typeof ReadableStream !== "undefined" && Object.hasOwn(ReadableStream, hasInstance) || Object.hasOwn(Object.prototype, toStringTag) || Object.hasOwn(Object.prototype, asyncIterator) || Object.hasOwn(Object.prototype, iterator) || Object.hasOwn(Array.prototype, toStringTag) || Object.hasOwn(Array.prototype, asyncIterator));
|
|
1483
|
+
}
|
|
1484
|
+
function isInertCarrier(value, prototype, isArray) {
|
|
1485
|
+
const {
|
|
1486
|
+
toStringTag,
|
|
1487
|
+
asyncIterator,
|
|
1488
|
+
iterator
|
|
1489
|
+
} = Symbol;
|
|
1490
|
+
return (isArray ? prototype === Array.prototype : prototype === Object.prototype || prototype === null) && !Object.hasOwn(value, toStringTag) && !Object.hasOwn(value, asyncIterator) && (isArray || !Object.hasOwn(value, iterator)) && typeof value[asyncIterator] !== "function" && (isArray || typeof value[iterator] !== "function");
|
|
1444
1491
|
}
|
|
1445
1492
|
function enterScopeCarrier(value, state) {
|
|
1446
|
-
if (value
|
|
1447
|
-
|
|
1493
|
+
if (isLeaf(value)) return value;
|
|
1494
|
+
const seen = state.seen.get(value);
|
|
1495
|
+
if (seen !== undefined) {
|
|
1448
1496
|
state.cyclic.add(value);
|
|
1449
|
-
const seen = state.seen.get(value);
|
|
1450
1497
|
return seen instanceof ScopeFrame ? frameShell(seen) : seen;
|
|
1451
1498
|
}
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1499
|
+
let isArray = false;
|
|
1500
|
+
let prototype;
|
|
1501
|
+
if (typeof value === "object") {
|
|
1502
|
+
isArray = Array.isArray(value);
|
|
1503
|
+
prototype = Object.getPrototypeOf(value);
|
|
1456
1504
|
}
|
|
1457
|
-
if (
|
|
1458
|
-
|
|
1505
|
+
if (!state.inert || prototype === undefined || !isInertCarrier(value, prototype, isArray)) {
|
|
1506
|
+
snapshotFrames(state.stack);
|
|
1507
|
+
const bound = bindDeferredBody(value, state.scope);
|
|
1508
|
+
if (bound !== value) {
|
|
1509
|
+
state.seen.set(value, bound);
|
|
1510
|
+
return bound;
|
|
1511
|
+
}
|
|
1512
|
+
if (typeof value !== "object") return value;
|
|
1513
|
+
}
|
|
1514
|
+
if (isArray) {
|
|
1459
1515
|
if (Object.isFrozen(value)) {
|
|
1460
1516
|
state.seen.set(value, value);
|
|
1461
1517
|
return value;
|
|
1462
1518
|
}
|
|
1463
|
-
|
|
1519
|
+
let i = 0;
|
|
1520
|
+
let first;
|
|
1521
|
+
while (i < value.length && isLeaf(first = value[i])) i++;
|
|
1522
|
+
if (i === value.length) {
|
|
1523
|
+
state.seen.set(value, value);
|
|
1524
|
+
return value;
|
|
1525
|
+
}
|
|
1526
|
+
const frame = new ScopeFrame(value, null, null, i, first);
|
|
1464
1527
|
state.seen.set(value, frame);
|
|
1465
1528
|
return frame;
|
|
1466
1529
|
}
|
|
1467
|
-
|
|
1468
|
-
|
|
1530
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
1531
|
+
state.seen.set(value, value);
|
|
1532
|
+
return value;
|
|
1533
|
+
}
|
|
1534
|
+
const keys = Object.keys(value);
|
|
1535
|
+
let i = 0;
|
|
1536
|
+
let first;
|
|
1537
|
+
while (i < keys.length && isLeaf(first = writableValue(Object.getOwnPropertyDescriptor(value, keys[i])))) i++;
|
|
1538
|
+
if (i === keys.length) {
|
|
1539
|
+
state.seen.set(value, value);
|
|
1540
|
+
return value;
|
|
1541
|
+
}
|
|
1542
|
+
if (Object.isFrozen(value)) {
|
|
1469
1543
|
state.seen.set(value, value);
|
|
1470
1544
|
return value;
|
|
1471
1545
|
}
|
|
1472
|
-
const frame = new ScopeFrame(value, prototype,
|
|
1546
|
+
const frame = new ScopeFrame(value, prototype, keys, i, first);
|
|
1473
1547
|
state.seen.set(value, frame);
|
|
1474
1548
|
return frame;
|
|
1475
1549
|
}
|
|
1476
1550
|
function scopeDeferredContents(root, scope) {
|
|
1551
|
+
const stack = [];
|
|
1477
1552
|
const state = {
|
|
1478
1553
|
seen: new Map(),
|
|
1479
1554
|
cyclic: new Set(),
|
|
1480
|
-
scope
|
|
1555
|
+
scope,
|
|
1556
|
+
inert: sharedPrototypesInert(),
|
|
1557
|
+
stack
|
|
1481
1558
|
};
|
|
1482
1559
|
const entered = enterScopeCarrier(root, state);
|
|
1483
1560
|
if (!(entered instanceof ScopeFrame)) return entered;
|
|
1484
|
-
|
|
1561
|
+
stack.push(entered);
|
|
1485
1562
|
let delivered = NOTHING;
|
|
1486
1563
|
for (;;) {
|
|
1487
1564
|
const top = stack[stack.length - 1];
|
|
@@ -1490,17 +1567,11 @@ function scopeDeferredContents(root, scope) {
|
|
|
1490
1567
|
while (top.i < length) {
|
|
1491
1568
|
const i = top.i;
|
|
1492
1569
|
let original;
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
writable = "value" in descriptor && descriptor.writable === true;
|
|
1497
|
-
original = writable ? descriptor.value : undefined;
|
|
1570
|
+
if (top.first !== NOTHING) {
|
|
1571
|
+
original = top.first;
|
|
1572
|
+
top.first = NOTHING;
|
|
1498
1573
|
} else {
|
|
1499
|
-
original = top.value[i];
|
|
1500
|
-
}
|
|
1501
|
-
if (!writable) {
|
|
1502
|
-
top.i++;
|
|
1503
|
-
continue;
|
|
1574
|
+
original = top.keys ? carrierSlot(top, top.keys[i]) : top.value[i];
|
|
1504
1575
|
}
|
|
1505
1576
|
let bound;
|
|
1506
1577
|
if (delivered !== NOTHING) {
|
|
@@ -1537,7 +1608,7 @@ function scopeDeferredContents(root, scope) {
|
|
|
1537
1608
|
}
|
|
1538
1609
|
}
|
|
1539
1610
|
function bindDeferredBody(value, scope) {
|
|
1540
|
-
if (value
|
|
1611
|
+
if (isLeaf(value)) return value;
|
|
1541
1612
|
const promised = scope(() => nativePromise(value));
|
|
1542
1613
|
if (promised) {
|
|
1543
1614
|
return promised.then(result => scope(() => scopeDeferredResult(result, scope)));
|
|
@@ -1806,8 +1877,8 @@ function broadcast(fn) {
|
|
|
1806
1877
|
BROADCASTS.add(fn.id);
|
|
1807
1878
|
return ref;
|
|
1808
1879
|
}
|
|
1809
|
-
function encodedArguments(request, argsEncoding, argumentBytes) {
|
|
1810
|
-
if (request.method !== "POST") return argsEncoding ||
|
|
1880
|
+
function encodedArguments(request, url, argsEncoding, argumentBytes) {
|
|
1881
|
+
if (request.method !== "POST") return argsEncoding || url.search;
|
|
1811
1882
|
if (!argumentBytes) return undefined;
|
|
1812
1883
|
return (request.headers.get("content-type") || "") + "\0" + (argsEncoding || "") + "\0" + new TextDecoder("latin1").decode(argumentBytes);
|
|
1813
1884
|
}
|
|
@@ -3338,7 +3409,7 @@ async function handleServerFunctionRequest(request, options = {}) {
|
|
|
3338
3409
|
id: functionId,
|
|
3339
3410
|
live: !!live,
|
|
3340
3411
|
broadcast: shared || undefined,
|
|
3341
|
-
shareKey: shared ? encodedArguments(request, argsEncoding, argumentBytes) : undefined
|
|
3412
|
+
shareKey: shared ? encodedArguments(request, url, argsEncoding, argumentBytes) : undefined
|
|
3342
3413
|
});
|
|
3343
3414
|
const run = () => serverFunction(...parsed);
|
|
3344
3415
|
return observeInvocation({
|
|
@@ -3408,7 +3479,8 @@ async function handleServerFunctionRequest(request, options = {}) {
|
|
|
3408
3479
|
}
|
|
3409
3480
|
if (!scripted) {
|
|
3410
3481
|
if (handleNoJS) {
|
|
3411
|
-
|
|
3482
|
+
const outcome = result == null && metadata !== undefined ? metadata : result;
|
|
3483
|
+
return withEnvelopeCookies(await handleNoJS(outcome, request, parsed), outcome, metadata);
|
|
3412
3484
|
}
|
|
3413
3485
|
if (result instanceof Response) return result;
|
|
3414
3486
|
return encodeResult(result, headers, status, codec, request.signal, scope);
|
|
@@ -3491,7 +3563,10 @@ async function handleServerFunctionRequest(request, options = {}) {
|
|
|
3491
3563
|
}
|
|
3492
3564
|
headers.set(ERROR_HEADER, "true");
|
|
3493
3565
|
if (!scripted) {
|
|
3494
|
-
if (handleNoJS)
|
|
3566
|
+
if (handleNoJS) {
|
|
3567
|
+
const outcome = x ?? metadata;
|
|
3568
|
+
return withEnvelopeCookies(await handleNoJS(outcome, request, parsed, true), outcome, metadata);
|
|
3569
|
+
}
|
|
3495
3570
|
if (x instanceof Response) return x;
|
|
3496
3571
|
}
|
|
3497
3572
|
if (scripted && status === 304) warnScripted304(functionId);
|
|
@@ -3548,6 +3623,17 @@ function withholdTrace(event) {
|
|
|
3548
3623
|
if (event.response && event.response.committed) return;
|
|
3549
3624
|
traceForEvent(event).emit = false;
|
|
3550
3625
|
}
|
|
3626
|
+
function withEnvelopeCookies(response, outcome, metadata) {
|
|
3627
|
+
if (outcome === metadata || !metadata || !metadata.headers || !(response instanceof Response)) {
|
|
3628
|
+
return response;
|
|
3629
|
+
}
|
|
3630
|
+
const cookies = metadata.headers.getSetCookie ? metadata.headers.getSetCookie() : [];
|
|
3631
|
+
if (!cookies.length) return response;
|
|
3632
|
+
const owned = ownResponse(response);
|
|
3633
|
+
if (owned === response) return response;
|
|
3634
|
+
for (const cookie of cookies) owned.headers.append("Set-Cookie", cookie);
|
|
3635
|
+
return owned;
|
|
3636
|
+
}
|
|
3551
3637
|
function ownResponse(response) {
|
|
3552
3638
|
try {
|
|
3553
3639
|
return new Response(response.body, response);
|
|
@@ -100,6 +100,41 @@ export declare function createHydrationSerializer(options: HydrationSerializerOp
|
|
|
100
100
|
flush(): void;
|
|
101
101
|
close(): void;
|
|
102
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* `createHydrationSerializer`'s `late`, which wraps its seroval session
|
|
105
|
+
* per write: rejects, on the client, what a write that failed to serialize
|
|
106
|
+
* midstream left pending (#4647; maintainer ruling,
|
|
107
|
+
* 2026-11-03). seroval 1.7 ends a write at its first failure without
|
|
108
|
+
* settling anything it already declared: the key's promise, a promise or
|
|
109
|
+
* async iterable nested in a value it already sent, each would stay pending
|
|
110
|
+
* forever. Every promise the write sent is rejected (its resolver is indexed
|
|
111
|
+
* right after it, `parsePromise`) and every stream it sent is thrown into,
|
|
112
|
+
* with one error naming the key; one that already settled ignores it. The
|
|
113
|
+
* failure's own text went to the error hook and is not sent. The promise is
|
|
114
|
+
* left unmarked (no `s`/`v`, which seroval's own failure call sets for
|
|
115
|
+
* synchronous adoption): the hydrating read sees it pending and takes the
|
|
116
|
+
* rejection after the claim pass, so the reading computation throws into
|
|
117
|
+
* the nearest `<Errored>`, whose fallback then replaces the server's
|
|
118
|
+
* content. Read synchronously, the fallback would be built in the claim pass
|
|
119
|
+
* against markup that is the content's.
|
|
120
|
+
*
|
|
121
|
+
* Which write a reference belongs to: seroval indexes a value into the
|
|
122
|
+
* shared `refs` as it parses it and hands the chunk that declares it to that
|
|
123
|
+
* write's `onSerialize` in the same synchronous step, so the indexes taken
|
|
124
|
+
* since the last chunk are the next chunk's, or the failed parse's when the
|
|
125
|
+
* write fails instead. Those never went out: they leave `refs`, or a later
|
|
126
|
+
* write reaching the same value (a second key on the same promise) would
|
|
127
|
+
* reference a slot the client never filled and resolve `undefined`; it
|
|
128
|
+
* parses the value again and fails on its own. seroval takes the next index
|
|
129
|
+
* from `refs.size`, so the size counts every index ever taken.
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any): (key: any, value: any, callbacks: any, live: any) => any; /**
|
|
133
|
+
* Renderer primitive — returns the cross-reference bootstrap script SSR
|
|
134
|
+
* emits ahead of hydration data for a render scope. Not meant for
|
|
135
|
+
* hand-written code.
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
103
138
|
export declare function getLocalHeaderScript(id?: string): string;
|
|
104
139
|
export declare function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
|
|
105
140
|
export declare function createJSONSerializer(options: JSONSerializerOptions): {
|
package/types/serializer.d.ts
CHANGED
|
@@ -100,6 +100,41 @@ export declare function createHydrationSerializer(options: HydrationSerializerOp
|
|
|
100
100
|
flush(): void;
|
|
101
101
|
close(): void;
|
|
102
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* `createHydrationSerializer`'s `late`, which wraps its seroval session
|
|
105
|
+
* per write: rejects, on the client, what a write that failed to serialize
|
|
106
|
+
* midstream left pending (#4647; maintainer ruling,
|
|
107
|
+
* 2026-11-03). seroval 1.7 ends a write at its first failure without
|
|
108
|
+
* settling anything it already declared: the key's promise, a promise or
|
|
109
|
+
* async iterable nested in a value it already sent, each would stay pending
|
|
110
|
+
* forever. Every promise the write sent is rejected (its resolver is indexed
|
|
111
|
+
* right after it, `parsePromise`) and every stream it sent is thrown into,
|
|
112
|
+
* with one error naming the key; one that already settled ignores it. The
|
|
113
|
+
* failure's own text went to the error hook and is not sent. The promise is
|
|
114
|
+
* left unmarked (no `s`/`v`, which seroval's own failure call sets for
|
|
115
|
+
* synchronous adoption): the hydrating read sees it pending and takes the
|
|
116
|
+
* rejection after the claim pass, so the reading computation throws into
|
|
117
|
+
* the nearest `<Errored>`, whose fallback then replaces the server's
|
|
118
|
+
* content. Read synchronously, the fallback would be built in the claim pass
|
|
119
|
+
* against markup that is the content's.
|
|
120
|
+
*
|
|
121
|
+
* Which write a reference belongs to: seroval indexes a value into the
|
|
122
|
+
* shared `refs` as it parses it and hands the chunk that declares it to that
|
|
123
|
+
* write's `onSerialize` in the same synchronous step, so the indexes taken
|
|
124
|
+
* since the last chunk are the next chunk's, or the failed parse's when the
|
|
125
|
+
* write fails instead. Those never went out: they leave `refs`, or a later
|
|
126
|
+
* write reaching the same value (a second key on the same promise) would
|
|
127
|
+
* reference a slot the client never filled and resolve `undefined`; it
|
|
128
|
+
* parses the value again and fails on its own. seroval takes the next index
|
|
129
|
+
* from `refs.size`, so the size counts every index ever taken.
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any): (key: any, value: any, callbacks: any, live: any) => any; /**
|
|
133
|
+
* Renderer primitive — returns the cross-reference bootstrap script SSR
|
|
134
|
+
* emits ahead of hydration data for a render scope. Not meant for
|
|
135
|
+
* hand-written code.
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
103
138
|
export declare function getLocalHeaderScript(id?: string): string;
|
|
104
139
|
export declare function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
|
|
105
140
|
export declare function createJSONSerializer(options: JSONSerializerOptions): {
|
|
@@ -256,7 +256,6 @@ export interface LiveServerFunction<A extends readonly any[] = any[], R = any> {
|
|
|
256
256
|
/**
|
|
257
257
|
* Declares a live server function whose answer is the same for every
|
|
258
258
|
* viewer: on the client exactly `live(fn)` — the sharing is the server's.
|
|
259
|
-
* @experimental
|
|
260
259
|
*/
|
|
261
260
|
export declare function broadcast<A extends readonly any[], R>(fn: (...args: A) => R): LiveServerFunction<A, Awaited<R>>;
|
|
262
261
|
/**
|
|
@@ -546,7 +546,6 @@ export declare function live<A extends readonly any[], R>(fn: (...args: A) => R)
|
|
|
546
546
|
* data source (see sharedSourceResponse). The outer body still runs per
|
|
547
547
|
* call — a gate (auth, redirects) — but what it returns is the shared
|
|
548
548
|
* answer's to render.
|
|
549
|
-
* @experimental
|
|
550
549
|
*/
|
|
551
550
|
export declare function broadcast<A extends readonly any[], R>(fn: (...args: A) => R): ServerFunction<A, LiveSource<Awaited<R>>>;
|
|
552
551
|
export declare function getServerFunctionInvocation(): ServerFunctionInvocation | undefined;
|
|
@@ -16,12 +16,15 @@ export declare function createUploadSerializer(files: any): {
|
|
|
16
16
|
parse: {
|
|
17
17
|
sync: (value: any, ctx: any) => {
|
|
18
18
|
i: any;
|
|
19
|
+
t: any;
|
|
19
20
|
};
|
|
20
21
|
async: (value: any, ctx: any) => Promise<{
|
|
21
22
|
i: any;
|
|
23
|
+
t: any;
|
|
22
24
|
}>;
|
|
23
25
|
stream: (value: any, ctx: any) => {
|
|
24
26
|
i: any;
|
|
27
|
+
t: any;
|
|
25
28
|
};
|
|
26
29
|
};
|
|
27
30
|
serialize: (node: any, ctx: any) => any;
|
package/types/server-mock.d.ts
CHANGED
|
@@ -71,14 +71,21 @@ export type PreloadLink = PreloadLinkAttributes & ({
|
|
|
71
71
|
* (unknown fields pass through untyped), but any bundler integration can
|
|
72
72
|
* produce it. Only these fields are ever read: `preloads` is Solid's
|
|
73
73
|
* extension slot for explicit typed links the integration selects.
|
|
74
|
+
*
|
|
75
|
+
* Keys are module ids, except `_`-prefixed metadata strings: `_base` (the
|
|
76
|
+
* public base joined with every `file`), plus any an integration stamps,
|
|
77
|
+
* such as the vite plugin's `_entry`. The index signature carries both
|
|
78
|
+
* (solidjs/solid#4502), so a read by key is an entry only once narrowed,
|
|
79
|
+
* e.g. `typeof entry === "object"`.
|
|
74
80
|
*/
|
|
75
|
-
export type AssetManifest =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
export type AssetManifest = {
|
|
82
|
+
[key: string]: {
|
|
83
|
+
file: string;
|
|
84
|
+
css?: string[];
|
|
85
|
+
isEntry?: boolean;
|
|
86
|
+
imports?: string[];
|
|
87
|
+
preloads?: PreloadLink[];
|
|
88
|
+
} | string | undefined;
|
|
82
89
|
_base?: string;
|
|
83
90
|
};
|
|
84
91
|
/** Inline style content, e.g. dev CSS collected from a bundler's module graph. */
|
|
@@ -144,6 +151,13 @@ export declare function renderToString<T>(fn: () => T, options?: {
|
|
|
144
151
|
noScripts?: boolean;
|
|
145
152
|
plugins?: any[];
|
|
146
153
|
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
154
|
+
/**
|
|
155
|
+
* Server modulepreload hints for modules outside the entry's static import
|
|
156
|
+
* closure (lazy and route chunks) carry `fetchpriority="low"` so they do not
|
|
157
|
+
* compete with the modules hydration waits on. `false` emits them at default
|
|
158
|
+
* priority.
|
|
159
|
+
*/
|
|
160
|
+
lowPriorityPreloads?: boolean;
|
|
147
161
|
/** This render's server error hook, ahead of `configureServerErrors`' (see the server entry). */
|
|
148
162
|
onError?: ServerErrorHook;
|
|
149
163
|
/**
|
|
@@ -190,6 +204,13 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
190
204
|
noScripts?: boolean;
|
|
191
205
|
plugins?: any[];
|
|
192
206
|
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
207
|
+
/**
|
|
208
|
+
* Server modulepreload hints for modules outside the entry's static import
|
|
209
|
+
* closure (lazy and route chunks) carry `fetchpriority="low"` so they do not
|
|
210
|
+
* compete with the modules hydration waits on. `false` emits them at default
|
|
211
|
+
* priority.
|
|
212
|
+
*/
|
|
213
|
+
lowPriorityPreloads?: boolean;
|
|
193
214
|
onCompleteShell?: (info: {
|
|
194
215
|
write: (v: string) => void;
|
|
195
216
|
}) => void;
|
|
@@ -215,6 +236,12 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
215
236
|
* "signal"`); the one teardown handle for a host whose transport cannot
|
|
216
237
|
* report a dead consumer through the sink or the readable view — pass
|
|
217
238
|
* `request.signal`.
|
|
239
|
+
* Awaiting the render rejects with `signal.reason` when this signal aborts;
|
|
240
|
+
* the streaming forms stop writing and end cleanly — a close, not an
|
|
241
|
+
* error, since bytes are already out: `pipe` ends its sink, `pipeTo`
|
|
242
|
+
* closes its writable (after the writes already handed to it) and
|
|
243
|
+
* resolves, and `readable` closes. `onError` and `onCompleteAll` are not
|
|
244
|
+
* called (#4646).
|
|
218
245
|
*/
|
|
219
246
|
signal?: AbortSignal;
|
|
220
247
|
}): {
|
|
@@ -222,7 +249,7 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
222
249
|
* Awaiting the stream resolves with the complete HTML once every boundary
|
|
223
250
|
* settles — the fully-settled-string form of the render. Render errors
|
|
224
251
|
* route through `onError` and the promise resolves with whatever HTML the
|
|
225
|
-
* render produced
|
|
252
|
+
* render produced. Signal cancellation rejects with `signal.reason`.
|
|
226
253
|
*/
|
|
227
254
|
then<TResult1 = string, TResult2 = never>(onfulfilled?: ((html: string) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
228
255
|
pipe: (writable: {
|
package/types/server.d.ts
CHANGED
|
@@ -54,14 +54,21 @@ export type PreloadLink = PreloadLinkAttributes & ({
|
|
|
54
54
|
* (unknown fields pass through untyped), but any bundler integration can
|
|
55
55
|
* produce it. Only these fields are ever read: `preloads` is Solid's
|
|
56
56
|
* extension slot for explicit typed links the integration selects.
|
|
57
|
+
*
|
|
58
|
+
* Keys are module ids, except `_`-prefixed metadata strings: `_base` (the
|
|
59
|
+
* public base joined with every `file`), plus any an integration stamps,
|
|
60
|
+
* such as the vite plugin's `_entry`. The index signature carries both
|
|
61
|
+
* (solidjs/solid#4502), so a read by key is an entry only once narrowed,
|
|
62
|
+
* e.g. `typeof entry === "object"`.
|
|
57
63
|
*/
|
|
58
|
-
export type AssetManifest =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
export type AssetManifest = {
|
|
65
|
+
[key: string]: {
|
|
66
|
+
file: string;
|
|
67
|
+
css?: string[];
|
|
68
|
+
isEntry?: boolean;
|
|
69
|
+
imports?: string[];
|
|
70
|
+
preloads?: PreloadLink[];
|
|
71
|
+
} | string | undefined;
|
|
65
72
|
_base?: string;
|
|
66
73
|
};
|
|
67
74
|
/** Inline style content, e.g. dev CSS collected from a bundler's module graph. */
|
|
@@ -224,6 +231,13 @@ export declare function renderToString<T>(fn: () => T, options?: {
|
|
|
224
231
|
noScripts?: boolean;
|
|
225
232
|
plugins?: SerializerPlugin[];
|
|
226
233
|
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
234
|
+
/**
|
|
235
|
+
* Server modulepreload hints for modules outside the entry's static import
|
|
236
|
+
* closure (lazy and route chunks) carry `fetchpriority="low"` so they do not
|
|
237
|
+
* compete with the modules hydration waits on. `false` emits them at default
|
|
238
|
+
* priority.
|
|
239
|
+
*/
|
|
240
|
+
lowPriorityPreloads?: boolean;
|
|
227
241
|
/**
|
|
228
242
|
* This render's server error hook, ahead of `configureServerErrors`'
|
|
229
243
|
* (see `ServerErrorHook`): every failure the render handles — an
|
|
@@ -252,6 +266,13 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
252
266
|
noScripts?: boolean;
|
|
253
267
|
plugins?: SerializerPlugin[];
|
|
254
268
|
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
269
|
+
/**
|
|
270
|
+
* Server modulepreload hints for modules outside the entry's static import
|
|
271
|
+
* closure (lazy and route chunks) carry `fetchpriority="low"` so they do not
|
|
272
|
+
* compete with the modules hydration waits on. `false` emits them at default
|
|
273
|
+
* priority.
|
|
274
|
+
*/
|
|
275
|
+
lowPriorityPreloads?: boolean;
|
|
255
276
|
onCompleteShell?: (info: {
|
|
256
277
|
write: (v: string) => void;
|
|
257
278
|
}) => void;
|
|
@@ -263,7 +284,10 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
263
284
|
* (see `ServerErrorHook`): every failure the render handles — an
|
|
264
285
|
* `<Errored>` fallback (`handling: "fallback"`), a rejected fragment
|
|
265
286
|
* (`"client"`), a hydration value that would not serialize
|
|
266
|
-
* (`"serialize"
|
|
287
|
+
* (`"serialize"`: an async value that fails before the first flush
|
|
288
|
+
* also fails the render, with no `onCompleteAll`; after it, its key
|
|
289
|
+
* rejects on the client — #4647) — and the one that fails the request
|
|
290
|
+
* (`"failed"`),
|
|
267
291
|
* once per error per kind per request (per render outside one), with
|
|
268
292
|
* where it was met. A one-argument listener still
|
|
269
293
|
* works; it hears them all — filter on `context.handling` for the
|
|
@@ -286,13 +310,19 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
286
310
|
* The request's lifecycle. Aborting tears the render down exactly as a
|
|
287
311
|
* client disconnect does (`SSR_STREAM_ABANDONED`, `data.reason:
|
|
288
312
|
* "signal"`): in-flight reactive work is disposed, every async source
|
|
289
|
-
* still being pulled is returned, and nothing more
|
|
290
|
-
* the host whose transport cannot report a dead consumer
|
|
291
|
-
* sink or the readable view — a frame stream whose emission
|
|
292
|
-
* touches the document writable, a platform whose response body
|
|
293
|
-
* consumed by a proxy — this is the one teardown handle; pass
|
|
313
|
+
* still being pulled is returned, and nothing more is written to the
|
|
314
|
+
* sink. For the host whose transport cannot report a dead consumer
|
|
315
|
+
* through the sink or the readable view — a frame stream whose emission
|
|
316
|
+
* never touches the document writable, a platform whose response body
|
|
317
|
+
* is consumed by a proxy — this is the one teardown handle; pass
|
|
294
318
|
* `request.signal`. Idempotent with the sink and consumer paths: whichever
|
|
295
319
|
* fires first tears down, the rest are no-ops.
|
|
320
|
+
* Awaiting the render rejects with `signal.reason` when this signal aborts;
|
|
321
|
+
* the streaming forms stop writing and end cleanly — a close, not an
|
|
322
|
+
* error, since bytes are already out: `pipe` ends its sink, `pipeTo`
|
|
323
|
+
* closes its writable (after the writes already handed to it) and
|
|
324
|
+
* resolves, and `readable` closes. `onError` and `onCompleteAll` are not
|
|
325
|
+
* called (#4646).
|
|
296
326
|
*/
|
|
297
327
|
signal?: AbortSignal;
|
|
298
328
|
}): {
|
|
@@ -300,8 +330,8 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
300
330
|
* Awaiting the stream resolves with the complete HTML once every boundary
|
|
301
331
|
* settles — the fully-settled-string form of the render (`const html =
|
|
302
332
|
* await renderToStream(...)`). Render errors route through `onError` and
|
|
303
|
-
* the promise resolves with whatever HTML the render produced
|
|
304
|
-
* rejects.
|
|
333
|
+
* the promise resolves with whatever HTML the render produced. Signal
|
|
334
|
+
* cancellation rejects with `signal.reason`.
|
|
305
335
|
*
|
|
306
336
|
* Completion is this path's head-freeze point: the request event's
|
|
307
337
|
* `response` head (the request scope the render was started in) is
|