@solidjs/web 2.0.0-rc.4 → 2.0.0-rc.5
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 -7
- package/dist/dev.js +51 -8
- package/dist/server.cjs +162 -35
- package/dist/server.js +161 -36
- package/dist/web.cjs +32 -7
- package/dist/web.js +31 -8
- package/frames/dist/client.cjs +41 -8
- package/frames/dist/client.dev.cjs +41 -8
- package/frames/dist/client.dev.js +41 -8
- package/frames/dist/client.js +41 -8
- package/frames/dist/server.cjs +432 -44
- package/frames/dist/server.js +432 -44
- package/package.json +2 -2
- package/serialization/dist/decode.cjs +4 -2
- package/serialization/dist/decode.js +4 -2
- package/serialization/dist/serialization.cjs +12 -8
- package/serialization/dist/serialization.js +12 -8
- package/serialization/types/index.d.ts +7 -0
- package/serialization/types/serializer-decode.d.ts +14 -1
- package/serialization/types/serializer.d.ts +7 -0
- package/serialization/types-cjs/index.d.cts +7 -0
- package/serialization/types-cjs/serializer-decode.d.cts +14 -1
- package/serialization/types-cjs/serializer.d.cts +7 -0
- package/server-functions/dist/client.cjs +150 -33
- package/server-functions/dist/client.js +147 -34
- package/server-functions/dist/server.cjs +731 -118
- package/server-functions/dist/server.dev.cjs +751 -118
- package/server-functions/dist/server.dev.js +747 -119
- package/server-functions/dist/server.js +727 -119
- package/types/cookies.d.ts +6 -14
- package/types/frames/frame-client.d.ts +4 -0
- package/types/frames/serializer-decode.d.ts +14 -1
- package/types/frames/serializer.d.ts +7 -0
- package/types/jsx.d.ts +11 -16
- package/types/response.d.ts +11 -0
- package/types/serializer-decode.d.ts +14 -1
- package/types/serializer.d.ts +7 -0
- package/types/server-functions/client.d.ts +22 -2
- package/types/server-functions/flash.d.ts +9 -0
- package/types/server-functions/server.d.ts +58 -9
- package/types/server-functions/shared.d.ts +77 -14
- package/types/server-mock.d.ts +17 -2
- package/types/server.d.ts +16 -2
- package/types-cjs/cookies.d.cts +6 -14
- package/types-cjs/frames/frame-client.d.cts +4 -0
- package/types-cjs/frames/serializer-decode.d.cts +14 -1
- package/types-cjs/frames/serializer.d.cts +7 -0
- package/types-cjs/jsx.d.cts +11 -16
- package/types-cjs/response.d.cts +11 -0
- package/types-cjs/serializer-decode.d.cts +14 -1
- package/types-cjs/serializer.d.cts +7 -0
- package/types-cjs/server-functions/client.d.cts +22 -2
- package/types-cjs/server-functions/flash.d.cts +9 -0
- package/types-cjs/server-functions/server.d.cts +58 -9
- package/types-cjs/server-functions/shared.d.cts +77 -14
- package/types-cjs/server-mock.d.cts +17 -2
- package/types-cjs/server.d.cts +16 -2
package/types-cjs/cookies.d.cts
CHANGED
|
@@ -13,6 +13,12 @@ export interface CookieOptions {
|
|
|
13
13
|
secure?: boolean;
|
|
14
14
|
/** Cookie `SameSite` attribute, any case. */
|
|
15
15
|
sameSite?: "lax" | "strict" | "none" | "Lax" | "Strict" | "None";
|
|
16
|
+
/**
|
|
17
|
+
* Emit the `Partitioned` attribute (CHIPS): a third-party cookie keyed to
|
|
18
|
+
* the top-level site it was set under — the only third-party cookie that
|
|
19
|
+
* keeps working as browsers finish removing the rest. Requires `secure`.
|
|
20
|
+
*/
|
|
21
|
+
partitioned?: boolean;
|
|
16
22
|
}
|
|
17
23
|
/**
|
|
18
24
|
* Parses a `Cookie` request header into a name → value map. Names and
|
|
@@ -25,20 +31,6 @@ export interface CookieOptions {
|
|
|
25
31
|
* `parseCookieHeader(event.request.headers.get("cookie"))`.
|
|
26
32
|
*/
|
|
27
33
|
export declare function parseCookieHeader(header: string | null | undefined): Record<string, string>;
|
|
28
|
-
/**
|
|
29
|
-
* Serializes a cookie to a `Set-Cookie` header value. The name and value
|
|
30
|
-
* are `encodeURIComponent`-encoded (the parser decodes symmetrically);
|
|
31
|
-
* `path` defaults to `/` — the only defaulted attribute — and every other
|
|
32
|
-
* attribute is emitted exactly when the caller asked for it: `domain`,
|
|
33
|
-
* `maxAge` (seconds, truncated to an integer), `expires` (a `Date`),
|
|
34
|
-
* `httpOnly`, `secure`, `sameSite` (`"lax" | "strict" | "none"`, any
|
|
35
|
-
* case).
|
|
36
|
-
*
|
|
37
|
-
* The write half of the platform gap — the blessed response-cookie write
|
|
38
|
-
* is `event.response.headers.append("set-cookie", serializeCookie(name,
|
|
39
|
-
* value, options))`, which every head materialization path carries to the
|
|
40
|
-
* wire entry-by-entry.
|
|
41
|
-
*/
|
|
42
34
|
export declare function serializeCookie(name: string, value: string, options?: CookieOptions): string;
|
|
43
35
|
export declare const FLASH_COOKIE = "flash";
|
|
44
36
|
/** Whether a Cookie header carries a flash cookie (readable or not). */
|
|
@@ -105,6 +105,18 @@ export interface JSONCodecOptions {
|
|
|
105
105
|
disabledFeatures?: number;
|
|
106
106
|
/** Maximum parse/deserialize depth. Defaults to 64. Must match on both peers. */
|
|
107
107
|
depthLimit?: number;
|
|
108
|
+
/**
|
|
109
|
+
* Whether serialized `Error`s carry their `.stack` — server file paths,
|
|
110
|
+
* internal function names, the shape of the deployment — to the peer.
|
|
111
|
+
* Defaults to `NODE_ENV === "development"`, but that signal describes the
|
|
112
|
+
* PROCESS, not the artifact: a production build running with
|
|
113
|
+
* `NODE_ENV=development` (a base image, a stray dotenv) ships stacks to
|
|
114
|
+
* the wire — including for errors marked safe with `markSafeError`, whose
|
|
115
|
+
* stacks traverse application code (#3152). Set `false` to pin production
|
|
116
|
+
* disclosure regardless of the ambient variable. Encode-side only; the
|
|
117
|
+
* decode side is always permissive, so it need not match peers.
|
|
118
|
+
*/
|
|
119
|
+
serializeErrorStacks?: boolean;
|
|
108
120
|
}
|
|
109
121
|
/**
|
|
110
122
|
* A resident, response-scoped decode table over the keyed JSON codec: apply
|
|
@@ -142,10 +154,11 @@ export declare const DEFAULT_WEB_PLUGINS: any; /**
|
|
|
142
154
|
* Integration-facing; may change (see the entry banner).
|
|
143
155
|
*/
|
|
144
156
|
export declare function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
|
|
145
|
-
export declare function resolveCodecOptions({ plugins, disabledFeatures, depthLimit }?: JSONCodecOptions): {
|
|
157
|
+
export declare function resolveCodecOptions({ plugins, disabledFeatures, depthLimit, serializeErrorStacks }?: JSONCodecOptions): {
|
|
146
158
|
plugins: SerializerPlugin<any, any>[];
|
|
147
159
|
disabledFeatures: any;
|
|
148
160
|
depthLimit: number;
|
|
161
|
+
serializeErrorStacks: boolean;
|
|
149
162
|
}; /**
|
|
150
163
|
* Creates the decoding counterpart of `serializeJSON`. Cross-references
|
|
151
164
|
* between chunks resolve through state shared across calls, so all chunks
|
|
@@ -19,6 +19,13 @@ export interface WebSerializerOptions {
|
|
|
19
19
|
* any override — serialized stacks leak server paths to the client.
|
|
20
20
|
*/
|
|
21
21
|
disabledFeatures?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Whether serialized `Error`s carry their `.stack`. Defaults to
|
|
24
|
+
* `NODE_ENV === "development"`; set `false` to pin production disclosure
|
|
25
|
+
* to the deployment rather than the ambient variable (#3152 — see
|
|
26
|
+
* `JSONCodecOptions.serializeErrorStacks`).
|
|
27
|
+
*/
|
|
28
|
+
serializeErrorStacks?: boolean;
|
|
22
29
|
/** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. */
|
|
23
30
|
plugins?: SerializerPlugin[];
|
|
24
31
|
/** Receives each emitted script chunk. */
|
package/types-cjs/jsx.d.cts
CHANGED
|
@@ -1080,6 +1080,7 @@ export namespace JSX {
|
|
|
1080
1080
|
type HTMLFormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
|
|
1081
1081
|
type HTMLFormMethod = "post" | "get" | "dialog";
|
|
1082
1082
|
type HTMLCrossorigin = "anonymous" | "use-credentials" | EnumeratedAcceptsEmpty;
|
|
1083
|
+
type HTMLFetchPriority = "high" | "low" | "auto";
|
|
1083
1084
|
type HTMLReferrerPolicy =
|
|
1084
1085
|
| "no-referrer"
|
|
1085
1086
|
| "no-referrer-when-downgrade"
|
|
@@ -1105,19 +1106,8 @@ export namespace JSX {
|
|
|
1105
1106
|
| "allow-top-navigation"
|
|
1106
1107
|
| "allow-top-navigation-by-user-activation"
|
|
1107
1108
|
| "allow-top-navigation-to-custom-protocols";
|
|
1108
|
-
type
|
|
1109
|
-
|
|
1110
|
-
| "document"
|
|
1111
|
-
| "embed"
|
|
1112
|
-
| "fetch"
|
|
1113
|
-
| "font"
|
|
1114
|
-
| "image"
|
|
1115
|
-
| "object"
|
|
1116
|
-
| "script"
|
|
1117
|
-
| "style"
|
|
1118
|
-
| "track"
|
|
1119
|
-
| "video"
|
|
1120
|
-
| "worker";
|
|
1109
|
+
type HTMLPreloadAs = "fetch" | "font" | "image" | "script" | "style" | "track";
|
|
1110
|
+
type HTMLLinkAs = HTMLPreloadAs | "audio" | "document" | "embed" | "object" | "video" | "worker";
|
|
1121
1111
|
|
|
1122
1112
|
interface AnchorHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
1123
1113
|
download?: string | EnumeratedAcceptsEmpty | RemoveAttribute;
|
|
@@ -1367,7 +1357,7 @@ export namespace JSX {
|
|
|
1367
1357
|
browsingtopics?: string | RemoveAttribute;
|
|
1368
1358
|
crossorigin?: HTMLCrossorigin | RemoveAttribute;
|
|
1369
1359
|
decoding?: "sync" | "async" | "auto" | RemoveAttribute;
|
|
1370
|
-
fetchpriority?:
|
|
1360
|
+
fetchpriority?: HTMLFetchPriority | RemoveAttribute;
|
|
1371
1361
|
height?: number | string | RemoveAttribute;
|
|
1372
1362
|
ismap?: BooleanAttribute | RemoveAttribute;
|
|
1373
1363
|
loading?: "eager" | "lazy" | RemoveAttribute;
|
|
@@ -1522,7 +1512,7 @@ export namespace JSX {
|
|
|
1522
1512
|
color?: string | RemoveAttribute;
|
|
1523
1513
|
crossorigin?: HTMLCrossorigin | RemoveAttribute;
|
|
1524
1514
|
disabled?: BooleanAttribute | RemoveAttribute;
|
|
1525
|
-
fetchpriority?:
|
|
1515
|
+
fetchpriority?: HTMLFetchPriority | RemoveAttribute;
|
|
1526
1516
|
href?: string | RemoveAttribute;
|
|
1527
1517
|
hreflang?: string | RemoveAttribute;
|
|
1528
1518
|
imagesizes?: string | RemoveAttribute;
|
|
@@ -1713,7 +1703,7 @@ export namespace JSX {
|
|
|
1713
1703
|
blocking?: "render" | RemoveAttribute;
|
|
1714
1704
|
crossorigin?: HTMLCrossorigin | RemoveAttribute;
|
|
1715
1705
|
defer?: BooleanAttribute | RemoveAttribute;
|
|
1716
|
-
fetchpriority?:
|
|
1706
|
+
fetchpriority?: HTMLFetchPriority | RemoveAttribute;
|
|
1717
1707
|
for?: string | RemoveAttribute;
|
|
1718
1708
|
integrity?: string | RemoveAttribute;
|
|
1719
1709
|
nomodule?: BooleanAttribute | RemoveAttribute;
|
|
@@ -3500,6 +3490,11 @@ export namespace JSX {
|
|
|
3500
3490
|
* @url https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement
|
|
3501
3491
|
*/
|
|
3502
3492
|
select: SelectHTMLAttributes<HTMLSelectElement> & Properties<HTMLSelectElement>;
|
|
3493
|
+
/**
|
|
3494
|
+
* @url https://developer.mozilla.org/en-US/docs/Web/HTML/Element/selectedcontent
|
|
3495
|
+
* @url https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectedContentElement
|
|
3496
|
+
*/
|
|
3497
|
+
selectedcontent: HTMLAttributes<HTMLElement> & Properties<HTMLElement>;
|
|
3503
3498
|
/**
|
|
3504
3499
|
* @url https://developer.mozilla.org/en-US/docs/Web/HTML/Element/slot
|
|
3505
3500
|
* @url https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement
|
package/types-cjs/response.d.cts
CHANGED
|
@@ -50,6 +50,8 @@ export declare const REVALIDATE_HEADER = "X-Revalidate";
|
|
|
50
50
|
export interface ResponseHelperInit extends ResponseInit {
|
|
51
51
|
revalidate?: string | string[];
|
|
52
52
|
}
|
|
53
|
+
/** @internal */
|
|
54
|
+
export declare const RESPONSE_HEADER_VALUE_LIMIT = 4096;
|
|
53
55
|
/**
|
|
54
56
|
* Response redirecting to `url` (default 302). `revalidate` names the
|
|
55
57
|
* cache keys the mutation invalidated.
|
|
@@ -60,6 +62,15 @@ export declare function redirect(url: string | Href, init?: number | ResponseHel
|
|
|
60
62
|
* them when omitted).
|
|
61
63
|
*/
|
|
62
64
|
export declare function reload(init?: ResponseHelperInit): Response;
|
|
65
|
+
/**
|
|
66
|
+
* Statuses HTTP forbids a body on — the `Response` constructor enforces it
|
|
67
|
+
* by throwing on ANY body, `JSON.stringify(undefined)`'s `"undefined"`
|
|
68
|
+
* included. Shared with the server-function encoder, which answers void
|
|
69
|
+
* results on these statuses with a real null-body response and reports
|
|
70
|
+
* value-carrying ones as authoring errors (#3095).
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
export declare const NULL_BODY_STATUSES: ReadonlySet<number>;
|
|
63
74
|
/**
|
|
64
75
|
* A value paired with response metadata (status, headers, `revalidate`) —
|
|
65
76
|
* for the things a naked return can't express. Progressive enhancement
|
|
@@ -105,6 +105,18 @@ export interface JSONCodecOptions {
|
|
|
105
105
|
disabledFeatures?: number;
|
|
106
106
|
/** Maximum parse/deserialize depth. Defaults to 64. Must match on both peers. */
|
|
107
107
|
depthLimit?: number;
|
|
108
|
+
/**
|
|
109
|
+
* Whether serialized `Error`s carry their `.stack` — server file paths,
|
|
110
|
+
* internal function names, the shape of the deployment — to the peer.
|
|
111
|
+
* Defaults to `NODE_ENV === "development"`, but that signal describes the
|
|
112
|
+
* PROCESS, not the artifact: a production build running with
|
|
113
|
+
* `NODE_ENV=development` (a base image, a stray dotenv) ships stacks to
|
|
114
|
+
* the wire — including for errors marked safe with `markSafeError`, whose
|
|
115
|
+
* stacks traverse application code (#3152). Set `false` to pin production
|
|
116
|
+
* disclosure regardless of the ambient variable. Encode-side only; the
|
|
117
|
+
* decode side is always permissive, so it need not match peers.
|
|
118
|
+
*/
|
|
119
|
+
serializeErrorStacks?: boolean;
|
|
108
120
|
}
|
|
109
121
|
/**
|
|
110
122
|
* A resident, response-scoped decode table over the keyed JSON codec: apply
|
|
@@ -142,10 +154,11 @@ export declare const DEFAULT_WEB_PLUGINS: any; /**
|
|
|
142
154
|
* Integration-facing; may change (see the entry banner).
|
|
143
155
|
*/
|
|
144
156
|
export declare function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
|
|
145
|
-
export declare function resolveCodecOptions({ plugins, disabledFeatures, depthLimit }?: JSONCodecOptions): {
|
|
157
|
+
export declare function resolveCodecOptions({ plugins, disabledFeatures, depthLimit, serializeErrorStacks }?: JSONCodecOptions): {
|
|
146
158
|
plugins: SerializerPlugin<any, any>[];
|
|
147
159
|
disabledFeatures: any;
|
|
148
160
|
depthLimit: number;
|
|
161
|
+
serializeErrorStacks: boolean;
|
|
149
162
|
}; /**
|
|
150
163
|
* Creates the decoding counterpart of `serializeJSON`. Cross-references
|
|
151
164
|
* between chunks resolve through state shared across calls, so all chunks
|
|
@@ -19,6 +19,13 @@ export interface WebSerializerOptions {
|
|
|
19
19
|
* any override — serialized stacks leak server paths to the client.
|
|
20
20
|
*/
|
|
21
21
|
disabledFeatures?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Whether serialized `Error`s carry their `.stack`. Defaults to
|
|
24
|
+
* `NODE_ENV === "development"`; set `false` to pin production disclosure
|
|
25
|
+
* to the deployment rather than the ambient variable (#3152 — see
|
|
26
|
+
* `JSONCodecOptions.serializeErrorStacks`).
|
|
27
|
+
*/
|
|
28
|
+
serializeErrorStacks?: boolean;
|
|
22
29
|
/** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. */
|
|
23
30
|
plugins?: SerializerPlugin[];
|
|
24
31
|
/** Receives each emitted script chunk. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ServerFunction, ServerFunctionMetadata } from "./shared.cjs";
|
|
2
|
+
export { ChunkReader, ERROR_HEADER, FLASH_COOKIE, INSTANCE_HEADER, REDIRECT_HEADER, SERVER_FUNCTION_INVOKE, SINGLE_FLIGHT_HEADER, UNKNOWN_HEADER, clearFlashCookie, createChunk, decodeErrorHeaderValue, decodeRedirectHeaderValue, decodeResponse, decodeResponsePayload, deserializeStream, encodeErrorHeaderValue, frameAddress, getFlightDataConsumer, getFlightDataSourceIds, getServerFunctionMetadata, getServerFunctionsCodec, hasFlashCookie, invoke, isServerFunction, serializeString, subscribeFlightData, withMeta } from "./shared.cjs";
|
|
2
3
|
export { REVALIDATE_HEADER } from "../response.cjs";
|
|
3
4
|
import { JSONCodecOptions } from "../serializer-decode.cjs";
|
|
4
5
|
export type { FlightDataConsumer, FlightDataContext, InvokeOptions, ServerFunction, ServerFunctionInvoker, ServerFunctionMetadata, SingleFlightPayload } from "./shared.cjs";
|
|
@@ -159,6 +160,25 @@ export declare function parseServerFunctionUrl(url: string): string | null;
|
|
|
159
160
|
export declare function configureServerFunctionsClient(config?: ServerFunctionsClientConfig): void;
|
|
160
161
|
export declare function createServerReference(id: string, name?: string, base?: string): ServerFunction;
|
|
161
162
|
export declare function GET<A extends readonly any[], R>(fn: (...args: A) => R): ServerFunction<A, Awaited<R>>;
|
|
162
|
-
export
|
|
163
|
+
export interface LiveServerFunction<A extends readonly any[] = any[], R = any> {
|
|
164
|
+
(...args: A): LiveSource<R>;
|
|
165
|
+
/** The build-stable function id (stable across the client and server builds). */
|
|
166
|
+
readonly id: string;
|
|
167
|
+
/** URL invoking this function directly over HTTP. */
|
|
168
|
+
readonly url: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Declares a value-shaped live source: a server function returning an async
|
|
172
|
+
* iterable whose yields are successive VALUES of one logical query, with the
|
|
173
|
+
* contract that the source re-yields current state on every invocation.
|
|
174
|
+
* Calls to the returned reference produce an iterable that survives the
|
|
175
|
+
* connection — post-connect deaths re-invoke with exponential backoff
|
|
176
|
+
* (reset per healthy value, woken early by connectivity returning),
|
|
177
|
+
* first-connect failures reject like a normal call, and `break` aborts the
|
|
178
|
+
* in-flight request. Live calls are reads and never opt into single-flight
|
|
179
|
+
* enveloping. Wire state, if wanted, rides the returned iterable's
|
|
180
|
+
* `onstatus` hook. Compose with `GET` inside-out: `live(GET(fn))`.
|
|
181
|
+
*/
|
|
182
|
+
export declare function live<A extends readonly any[], R>(fn: (...args: A) => R): LiveServerFunction<A, Awaited<R>>;
|
|
163
183
|
export declare function registerServerReference(): never;
|
|
164
184
|
export declare function getServerFunctionInvocation(): ServerFunctionInvocation | undefined;
|
|
@@ -13,6 +13,15 @@ export interface FlashSubmission {
|
|
|
13
13
|
result?: any;
|
|
14
14
|
/** The thrown value, when the call threw. */
|
|
15
15
|
error?: any;
|
|
16
|
+
/**
|
|
17
|
+
* Set when the outcome was too large for the cookie's 4 KB ceiling and
|
|
18
|
+
* was degraded to fit (#3137): the input echo is dropped, and `result` /
|
|
19
|
+
* `error` may carry a bounded prefix — or the bare outcome flag `true` —
|
|
20
|
+
* rather than the full value. The submission still says what happened
|
|
21
|
+
* and where; integrations should render it as "succeeded (result too
|
|
22
|
+
* large to display)" rather than replaying the value.
|
|
23
|
+
*/
|
|
24
|
+
truncated?: boolean;
|
|
16
25
|
}
|
|
17
26
|
export declare function encodeFlashCookie(url: string, result: any, input: any[], thrown?: boolean): string;
|
|
18
27
|
export declare function decodeFlashCookie(cookieHeader: string | null): FlashSubmission | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { ERROR_HEADER, FLASH_COOKIE, INSTANCE_HEADER, SERVER_FUNCTION_INVOKE, SINGLE_FLIGHT_HEADER, clearFlashCookie, decodeErrorHeaderValue, decodeResponse, decodeResponsePayload, encodeErrorHeaderValue, getServerFunctionMetadata, hasFlashCookie, invoke, isServerFunction, subscribeFlightData, withMeta } from "./shared.cjs";
|
|
1
|
+
export { ERROR_HEADER, FLASH_COOKIE, INSTANCE_HEADER, REDIRECT_HEADER, SERVER_FUNCTION_INVOKE, SINGLE_FLIGHT_HEADER, UNKNOWN_HEADER, clearFlashCookie, decodeErrorHeaderValue, decodeRedirectHeaderValue, decodeResponse, decodeResponsePayload, encodeErrorHeaderValue, getServerFunctionMetadata, hasFlashCookie, invoke, isServerFunction, subscribeFlightData, withMeta } from "./shared.cjs";
|
|
2
2
|
export { decodeFlashCookie, encodeFlashCookie } from "./flash.cjs";
|
|
3
3
|
import { ResponseEnvelope } from "../response.cjs";
|
|
4
4
|
import { JSONCodecOptions } from "../serializer-decode.cjs";
|
|
5
5
|
import { RequestEvent } from "../server.cjs";
|
|
6
|
+
import type { ServerFunction, ServerFunctionMetadata } from "./shared.cjs";
|
|
6
7
|
export type { FlightDataConsumer, FlightDataContext, InvokeOptions, ServerFunction, ServerFunctionInvoker, ServerFunctionMetadata, SingleFlightPayload } from "./shared.cjs";
|
|
7
8
|
export type { FlashSubmission } from "./flash.cjs";
|
|
8
9
|
/**
|
|
@@ -130,6 +131,18 @@ export interface ServerFunctionCSRFOptions {
|
|
|
130
131
|
* @default false
|
|
131
132
|
*/
|
|
132
133
|
allowRequestsWithoutOriginCheck?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Applies the origin gate to GET-declared reads as well. By default the
|
|
136
|
+
* gate is skipped for declared reads: same-origin policy already keeps a
|
|
137
|
+
* cross-site caller from READING the response, and the gate's `Vary`
|
|
138
|
+
* fragments (or, on CDNs that ignore Vary, poisons) the shared-cache
|
|
139
|
+
* entries the `GET` helper exists to enable (#3071). The premise that
|
|
140
|
+
* skip rests on is `GET()`'s safety contract — declared reads are safe
|
|
141
|
+
* to EXECUTE from any origin (#3114). A deployment that does not rely
|
|
142
|
+
* on shared caches can enable this to gate its reads too.
|
|
143
|
+
* @default false
|
|
144
|
+
*/
|
|
145
|
+
protectDeclaredReads?: boolean;
|
|
133
146
|
}
|
|
134
147
|
/** Options for `configureServerFunctionsServer`. */
|
|
135
148
|
export interface ServerFunctionsServerConfig {
|
|
@@ -150,10 +163,13 @@ export interface ServerFunctionsServerConfig {
|
|
|
150
163
|
*/
|
|
151
164
|
wrapInvocation?: WrapInvocationHook;
|
|
152
165
|
/**
|
|
153
|
-
* The single-flight hook: produces the data payload folded into
|
|
166
|
+
* The unnamed single-flight hook: produces the data payload folded into
|
|
154
167
|
* responses of calls that opted in (see `CollectFlightDataHook`).
|
|
155
168
|
* Registered once by the integration that owns data production (a
|
|
156
|
-
* router); per-handler `collectFlightData` options override it.
|
|
169
|
+
* router); per-handler `collectFlightData` options override it. Other
|
|
170
|
+
* integrations contribute additively through
|
|
171
|
+
* `registerFlightDataSource(id, hook)` instead of competing for this
|
|
172
|
+
* slot.
|
|
157
173
|
*/
|
|
158
174
|
collectFlightData?: CollectFlightDataHook;
|
|
159
175
|
/**
|
|
@@ -228,6 +244,24 @@ export interface ServerFunctionsServerConfig {
|
|
|
228
244
|
* `decodeResponse` sees them too.
|
|
229
245
|
*/
|
|
230
246
|
codec?: JSONCodecOptions;
|
|
247
|
+
/**
|
|
248
|
+
* Upper bound, in bytes, on a call's argument payload — the POST body,
|
|
249
|
+
* or the `?args=` query encoding. The payload is buffered and decoded
|
|
250
|
+
* before dispatch, so its cost is paid before application code can
|
|
251
|
+
* decline it; the bound is enforced up front and a request over it is
|
|
252
|
+
* refused with `413` before any decoding (#3115). Raise it for functions
|
|
253
|
+
* that accept large uploads, or set `Infinity` to remove the bound.
|
|
254
|
+
* @default 1_048_576 (1 MiB)
|
|
255
|
+
*/
|
|
256
|
+
bodySizeLimit?: number;
|
|
257
|
+
/**
|
|
258
|
+
* Upper bound on the number of arguments a call may carry. The decoded
|
|
259
|
+
* argument array is spread into the function call, so an unbounded list
|
|
260
|
+
* forces a range error out of any function regardless of what it does;
|
|
261
|
+
* past the bound the request is refused with `400` (#3115).
|
|
262
|
+
* @default 1000
|
|
263
|
+
*/
|
|
264
|
+
maxArguments?: number;
|
|
231
265
|
}
|
|
232
266
|
/**
|
|
233
267
|
* A registered server function: its build-stable id paired with the
|
|
@@ -347,6 +381,16 @@ export interface HandleServerFunctionOptions {
|
|
|
347
381
|
csrf?: boolean | ServerFunctionCSRFOptions;
|
|
348
382
|
/** Overrides the configured codec options for this handler. */
|
|
349
383
|
codec?: JSONCodecOptions;
|
|
384
|
+
/**
|
|
385
|
+
* Overrides the configured argument payload bound for this handler (see
|
|
386
|
+
* `ServerFunctionsServerConfig.bodySizeLimit`).
|
|
387
|
+
*/
|
|
388
|
+
bodySizeLimit?: number;
|
|
389
|
+
/**
|
|
390
|
+
* Overrides the configured argument count bound for this handler (see
|
|
391
|
+
* `ServerFunctionsServerConfig.maxArguments`).
|
|
392
|
+
*/
|
|
393
|
+
maxArguments?: number;
|
|
350
394
|
}
|
|
351
395
|
export interface ServerFunctionRequestCall {
|
|
352
396
|
type: "request";
|
|
@@ -366,6 +410,7 @@ export interface ServerFunctionResponseCall {
|
|
|
366
410
|
}
|
|
367
411
|
export type ServerFunctionCall = ServerFunctionRequestCall | ServerFunctionResponseCall;
|
|
368
412
|
export declare function configureServerFunctionsServer(config?: ServerFunctionsServerConfig): void;
|
|
413
|
+
export declare function registerFlightDataSource(source: string, hook: CollectFlightDataHook): () => void;
|
|
369
414
|
export declare function registerServerFunction<T extends any[], R>(id: string, callback: (...args: T) => R): (...args: T) => R;
|
|
370
415
|
export declare function getServerFunction<T extends any[], R>(id: string): (...args: T) => R;
|
|
371
416
|
export declare function registerServerReference<T extends any[], R>(id: string, fn: (...args: T) => R, name?: string): ServerFunctionReference<T, R>;
|
|
@@ -376,6 +421,8 @@ export declare function getServerFunctionInvocation(): ServerFunctionInvocation
|
|
|
376
421
|
export declare function getEventServerFunctionInvocation(event: RequestEvent | undefined): ServerFunctionInvocation | undefined;
|
|
377
422
|
export declare function foldSetCookies(headers: Headers, setCookies: readonly string[]): Headers;
|
|
378
423
|
export declare function createNoJSHandler(options?: NoJSHandlerOptions): (result: unknown, request: Request, args: unknown[], thrown?: boolean) => Response;
|
|
424
|
+
/** @internal */
|
|
425
|
+
export declare function guardFailures(value: any, state: any): any;
|
|
379
426
|
/**
|
|
380
427
|
* The response-side codec stream: `serializeStream` (shared.js) hardened
|
|
381
428
|
* with request-lifetime teardown. Server-only on purpose — the shared half
|
|
@@ -384,12 +431,14 @@ export declare function createNoJSHandler(options?: NoJSHandlerOptions): (result
|
|
|
384
431
|
* An abort of `signal` (the platform fires request.signal when the caller's
|
|
385
432
|
* fetch aborts or the tab goes away) or the consumer cancelling the
|
|
386
433
|
* ReadableStream (how platforms surface a dropped connection to the body)
|
|
387
|
-
* stops pending serialization and tears down
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
* the codec
|
|
434
|
+
* stops pending serialization and tears down EVERY async-iterable or
|
|
435
|
+
* ReadableStream source in the result graph, nested ones included (#3125) —
|
|
436
|
+
* each producer's `iterator.return()` / `reader.cancel()` runs, so
|
|
437
|
+
* generator `finally` blocks execute instead of the server pumping streams
|
|
438
|
+
* nobody is reading. The wiring rides guardFailures' walk: it already wraps
|
|
439
|
+
* every channel before the codec sees the value, so the demand gate and the
|
|
440
|
+
* teardown registry are threaded through its state (`{ items: rows() }` —
|
|
441
|
+
* a cursor beside a total — gets the same two guarantees as `return rows()`).
|
|
393
442
|
*/
|
|
394
443
|
export declare function serializeResponseStream(value: any, codecOptions: any, signal: any): ReadableStream<any>;
|
|
395
444
|
/** Message a sanitized (production) server error carries on the wire. */
|
|
@@ -8,19 +8,22 @@ import { JSONCodecOptions } from "../serializer-decode.cjs";
|
|
|
8
8
|
* HTTP handler. Integrations decoding passthrough responses themselves (no
|
|
9
9
|
* registered consumer) see this shape from `decodeResponse`. The top level
|
|
10
10
|
* is reserved for the protocol — integration payload lives entirely under
|
|
11
|
-
* `data`,
|
|
11
|
+
* `data`, the envelope keyed by source id (the unnamed registration's
|
|
12
|
+
* slice rides under the reserved id "true"); each slice can be any
|
|
13
|
+
* codec-serializable value.
|
|
12
14
|
*/
|
|
13
15
|
export interface SingleFlightPayload<T = unknown, D = unknown> {
|
|
14
16
|
/** The server function's return (or thrown) value. */
|
|
15
17
|
value: T;
|
|
16
|
-
/** The integration-produced data payload. */
|
|
18
|
+
/** The integration-produced data payload, keyed by source id. */
|
|
17
19
|
data: D;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* Envelope context delivered alongside single-flight data: the transport
|
|
21
|
-
* response, whose headers carry the integration metadata (
|
|
22
|
-
* redirect-with-data, `X-Revalidate` keys) and status. The
|
|
23
|
-
* consumed — read `data` and `value` from the delivery,
|
|
23
|
+
* response, whose headers carry the integration metadata (the redirect
|
|
24
|
+
* carrier for redirect-with-data, `X-Revalidate` keys) and status. The
|
|
25
|
+
* body is already consumed — read `data` and `value` from the delivery,
|
|
26
|
+
* not from here.
|
|
24
27
|
*/
|
|
25
28
|
export interface FlightDataContext {
|
|
26
29
|
/** The HTTP response the data arrived on (metadata only). */
|
|
@@ -131,11 +134,27 @@ export interface ServerFunctionRPC {
|
|
|
131
134
|
export type BodyFormatValue = (typeof BodyFormat)[keyof typeof BodyFormat];
|
|
132
135
|
export declare function configureServerFunctionsCodec(codec: JSONCodecOptions | undefined): void;
|
|
133
136
|
export declare function getServerFunctionsCodec(): JSONCodecOptions | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* Validates a flight data source id (both registration halves share the
|
|
139
|
+
* rule): ids travel the `SINGLE_FLIGHT_HEADER` as a comma-separated list,
|
|
140
|
+
* so they cannot be empty or contain commas, and "true" is reserved for
|
|
141
|
+
* the unnamed registration.
|
|
142
|
+
*
|
|
143
|
+
* Transport building block; not meant for hand-written code.
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
146
|
+
export declare function assertFlightSource(source: string): void;
|
|
134
147
|
export declare function subscribeFlightData<D = unknown>(consumer: FlightDataConsumer<D>): () => void;
|
|
135
|
-
export declare function
|
|
148
|
+
export declare function subscribeFlightData<D = unknown>(source: string, consumer: FlightDataConsumer<D>): () => void;
|
|
149
|
+
export declare function getFlightDataConsumer(source?: string): FlightDataConsumer | undefined;
|
|
150
|
+
export declare function getFlightDataSourceIds(): string[];
|
|
136
151
|
export declare function frameAddress(id: string, args?: readonly unknown[]): string;
|
|
137
152
|
export declare function serverFunctionAddress(endpoint: string, id: string): string;
|
|
138
|
-
export declare function
|
|
153
|
+
export declare function serverFunctionDataAddress(endpoint: string, id: string): string;
|
|
154
|
+
export declare function parseServerFunctionAddress(pathname: string, endpoint: string): {
|
|
155
|
+
id: string;
|
|
156
|
+
data: boolean;
|
|
157
|
+
} | null;
|
|
139
158
|
/**
|
|
140
159
|
* Response header marking a thrown server-function error. The value is the
|
|
141
160
|
* error's message (the structured error itself travels in the body); `"true"`
|
|
@@ -151,6 +170,51 @@ export declare function decodeErrorHeaderValue(value: string): string;
|
|
|
151
170
|
export declare const INSTANCE_HEADER = "X-Server-Function-Instance";
|
|
152
171
|
/** Header carrying the body format tag (a `BodyFormat` value). */
|
|
153
172
|
export declare const BODY_FORMAT_HEADER = "X-Server-Function-Format";
|
|
173
|
+
/**
|
|
174
|
+
* Header labelling the unknown-id 404: the address was well-formed but its
|
|
175
|
+
* id is not registered in the deployment that answered (#3110). This is the
|
|
176
|
+
* ordinary shape of version skew — a tab holding the previous build's ids
|
|
177
|
+
* across a deploy — and the label is what lets an integration recover
|
|
178
|
+
* (e.g. reload the document) instead of surfacing a generic failed call.
|
|
179
|
+
* Nothing distinguishes it otherwise: a CDN 404 and a skew 404 look alike.
|
|
180
|
+
*/
|
|
181
|
+
export declare const UNKNOWN_HEADER = "X-Server-Function-Unknown";
|
|
182
|
+
/**
|
|
183
|
+
* Header carrying a redirect to scripted callers. fetch FOLLOWS redirect
|
|
184
|
+
* statuses before the transport can read them, so a scripted answer masks
|
|
185
|
+
* the 3xx to 200 and this header carries what the mask erases: the author's
|
|
186
|
+
* status and the target RESOLVED against the request url — exactly the
|
|
187
|
+
* meaning HTTP assigns the `Location` a form post would have received.
|
|
188
|
+
* Value: `<status> <absolute-url>`, decode with `decodeRedirectHeaderValue`.
|
|
189
|
+
*
|
|
190
|
+
* Carrying the resolved absolute form is the point (#3102, #3107): the
|
|
191
|
+
* reader never guesses navigation strategy from how the author spelled the
|
|
192
|
+
* target — `redirect("/")` and `redirect(new URL("/", url).href)` arrive
|
|
193
|
+
* identical by construction, and same-origin vs cross-origin is a real URL
|
|
194
|
+
* comparison, not a `startsWith("http")` coin toss. `Location` itself never
|
|
195
|
+
* rides a masked answer: on a 200 it has no HTTP meaning, and it collided
|
|
196
|
+
* with authored Locations on statuses that forward (a 201's created-at is
|
|
197
|
+
* data, not navigation).
|
|
198
|
+
*/
|
|
199
|
+
export declare const REDIRECT_HEADER = "X-Server-Function-Redirect";
|
|
200
|
+
/**
|
|
201
|
+
* Decodes a `REDIRECT_HEADER` value into the author's status and the
|
|
202
|
+
* resolved absolute target. Integration plumbing for readers of the header
|
|
203
|
+
* (routers); the wire format is the runtime's own, not a contract to parse
|
|
204
|
+
* by hand.
|
|
205
|
+
*
|
|
206
|
+
* The documented output — a resolved ABSOLUTE http(s) target and a redirect
|
|
207
|
+
* status — is enforced, not assumed (#3175): the absoluteness used to be a
|
|
208
|
+
* property of the server having resolved it, and a hostile or buggy peer
|
|
209
|
+
* could ride a `javascript:` target straight into the `location.href =
|
|
210
|
+
* decoded.url` an integration reasonably writes. A value that does not
|
|
211
|
+
* parse as an absolute http(s) url, or whose status is not one the runtime
|
|
212
|
+
* masks, decodes to `undefined` — the same answer a missing header gives.
|
|
213
|
+
*/
|
|
214
|
+
export declare function decodeRedirectHeaderValue(value: string | null | undefined): {
|
|
215
|
+
status: number;
|
|
216
|
+
url: string;
|
|
217
|
+
} | undefined;
|
|
154
218
|
/**
|
|
155
219
|
* Header driving the single-flight protocol on both legs: on the request it
|
|
156
220
|
* opts the call into flight-data collection (the integration sends it on
|
|
@@ -200,15 +264,14 @@ export declare class ChunkReader {
|
|
|
200
264
|
value: string;
|
|
201
265
|
}>;
|
|
202
266
|
drain(interpret: any): Promise<void>;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
* Transport building block; not meant for hand-written code.
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Encodes a terminal error-trailer frame payload. The value is expected to
|
|
270
|
+
* be already sanitized by the caller; only `name` and `message` travel.
|
|
271
|
+
* Transport wire detail; not meant for hand-written code.
|
|
210
272
|
* @internal
|
|
211
273
|
*/
|
|
274
|
+
export declare function encodeErrorTrailer(error: unknown): string;
|
|
212
275
|
export declare function serializeStream(value: unknown, codecOptions?: JSONCodecOptions): ReadableStream<Uint8Array>;
|
|
213
276
|
export declare function serializeString(value: unknown, codecOptions?: JSONCodecOptions): Promise<string>;
|
|
214
277
|
export declare function deserializeStream<T = unknown>(source: Request | Response, codecOptions?: JSONCodecOptions): Promise<T>;
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import type { RequestEvent, RequestEventLocals, ResponseStub } from "./client.cjs";
|
|
2
|
+
import type { JSX } from "./jsx.cjs";
|
|
3
|
+
/** An explicit `<link rel="preload">` emitted by the SSR asset pipeline. */
|
|
4
|
+
export type PreloadLink = {
|
|
5
|
+
href: string;
|
|
6
|
+
as: JSX.HTMLPreloadAs;
|
|
7
|
+
type?: string;
|
|
8
|
+
crossorigin?: JSX.HTMLCrossorigin;
|
|
9
|
+
integrity?: string;
|
|
10
|
+
referrerpolicy?: JSX.HTMLReferrerPolicy;
|
|
11
|
+
fetchpriority?: JSX.HTMLFetchPriority;
|
|
12
|
+
media?: string;
|
|
13
|
+
};
|
|
2
14
|
/** Static asset manifest produced by a build (e.g. parsed Vite manifest.json). */
|
|
3
15
|
export type AssetManifest = Record<string, {
|
|
4
16
|
file: string;
|
|
5
17
|
css?: string[];
|
|
6
18
|
isEntry?: boolean;
|
|
7
19
|
imports?: string[];
|
|
20
|
+
preloads?: PreloadLink[];
|
|
8
21
|
}> & {
|
|
9
22
|
_base?: string;
|
|
10
23
|
};
|
|
@@ -17,6 +30,7 @@ export type InlineStyleAsset = {
|
|
|
17
30
|
export type ResolvedAssets = {
|
|
18
31
|
js: string[];
|
|
19
32
|
css: (string | InlineStyleAsset)[];
|
|
33
|
+
preloads?: PreloadLink[];
|
|
20
34
|
};
|
|
21
35
|
/**
|
|
22
36
|
* Resolver form of the manifest option — the primitive a dev server
|
|
@@ -24,8 +38,9 @@ export type ResolvedAssets = {
|
|
|
24
38
|
* normalized into a sync resolver internally). `resolve` may return a
|
|
25
39
|
* promise (async resolvers require streaming rendering); CSS entries may be
|
|
26
40
|
* URL strings (emitted as load-gated `<link>` tags) or inline-style
|
|
27
|
-
* descriptors (emitted as `<style>` tags)
|
|
28
|
-
*
|
|
41
|
+
* descriptors (emitted as `<style>` tags), and `preloads` carries explicit
|
|
42
|
+
* preload links selected by the integration. A bare `resolve`-shaped
|
|
43
|
+
* function is accepted as shorthand for `{ resolve }`.
|
|
29
44
|
*/
|
|
30
45
|
export type AssetResolver = {
|
|
31
46
|
resolve(key: string): ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
|
package/types-cjs/server.d.cts
CHANGED
|
@@ -5,12 +5,24 @@ export { clearFlashCookie, hasFlashCookie } from "./cookies.cjs";
|
|
|
5
5
|
export { getServerFunctionMetadata, getServerFunctionRPC, isServerFunction } from "./server-functions/registry.cjs";
|
|
6
6
|
import { JSX } from "./jsx.cjs";
|
|
7
7
|
import { SerializerPlugin } from "./serializer-decode.cjs";
|
|
8
|
+
/** An explicit `<link rel="preload">` emitted by the SSR asset pipeline. */
|
|
9
|
+
export type PreloadLink = {
|
|
10
|
+
href: string;
|
|
11
|
+
as: JSX.HTMLPreloadAs;
|
|
12
|
+
type?: string;
|
|
13
|
+
crossorigin?: JSX.HTMLCrossorigin;
|
|
14
|
+
integrity?: string;
|
|
15
|
+
referrerpolicy?: JSX.HTMLReferrerPolicy;
|
|
16
|
+
fetchpriority?: JSX.HTMLFetchPriority;
|
|
17
|
+
media?: string;
|
|
18
|
+
};
|
|
8
19
|
/** Static asset manifest produced by a build (e.g. parsed Vite manifest.json). */
|
|
9
20
|
export type AssetManifest = Record<string, {
|
|
10
21
|
file: string;
|
|
11
22
|
css?: string[];
|
|
12
23
|
isEntry?: boolean;
|
|
13
24
|
imports?: string[];
|
|
25
|
+
preloads?: PreloadLink[];
|
|
14
26
|
}> & {
|
|
15
27
|
_base?: string;
|
|
16
28
|
};
|
|
@@ -23,6 +35,7 @@ export type InlineStyleAsset = {
|
|
|
23
35
|
export type ResolvedAssets = {
|
|
24
36
|
js: string[];
|
|
25
37
|
css: (string | InlineStyleAsset)[];
|
|
38
|
+
preloads?: PreloadLink[];
|
|
26
39
|
};
|
|
27
40
|
/**
|
|
28
41
|
* Resolver form of the manifest option — the primitive a dev server
|
|
@@ -30,8 +43,9 @@ export type ResolvedAssets = {
|
|
|
30
43
|
* normalized into a sync resolver internally). `resolve` may return a
|
|
31
44
|
* promise (async resolvers require streaming rendering); CSS entries may be
|
|
32
45
|
* URL strings (emitted as load-gated `<link>` tags) or inline-style
|
|
33
|
-
* descriptors (emitted as `<style>` tags)
|
|
34
|
-
*
|
|
46
|
+
* descriptors (emitted as `<style>` tags), and `preloads` carries explicit
|
|
47
|
+
* preload links selected by the integration. A bare `resolve`-shaped
|
|
48
|
+
* function is accepted as shorthand for `{ resolve }`.
|
|
35
49
|
*/
|
|
36
50
|
export type AssetResolver = {
|
|
37
51
|
resolve(key: string): ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
|