@solidjs/web 2.0.0-rc.2 → 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.
Files changed (124) hide show
  1. package/README.md +1 -1
  2. package/dist/server.dev.js +5165 -0
  3. package/dist/server.js +1876 -374
  4. package/dist/{server.cjs → server.observe.js} +2070 -577
  5. package/dist/{dev.cjs → web.dev.js} +955 -567
  6. package/dist/web.js +646 -350
  7. package/dist/{dev.js → web.observe.js} +699 -421
  8. package/frames/dist/assets.js +92 -0
  9. package/frames/dist/client.dev.js +1296 -1198
  10. package/frames/dist/client.js +1128 -1191
  11. package/frames/dist/client.observe.js +2041 -0
  12. package/frames/dist/regions.js +171 -0
  13. package/frames/dist/server.dev.js +2545 -0
  14. package/frames/dist/server.js +1683 -3004
  15. package/frames/dist/server.observe.js +2544 -0
  16. package/frames/dist/trace.js +45 -0
  17. package/frames/dist/wire.js +594 -0
  18. package/frames/package.json +2 -25
  19. package/package.json +244 -256
  20. package/performance-tracks/dist/performance-tracks.dev.js +679 -0
  21. package/performance-tracks/dist/performance-tracks.js +6 -0
  22. package/performance-tracks/dist/performance-tracks.observe.js +667 -0
  23. package/performance-tracks/package.json +7 -0
  24. package/performance-tracks/types/index.d.ts +69 -0
  25. package/serialization/decode/package.json +2 -15
  26. package/serialization/dist/decode.js +121 -25
  27. package/serialization/dist/serialization.js +282 -88
  28. package/serialization/package.json +2 -15
  29. package/serialization/types/index.d.ts +115 -153
  30. package/serialization/types/serializer-decode.d.ts +173 -114
  31. package/serialization/types/serializer.d.ts +144 -0
  32. package/server-functions/dist/client.dev.js +1462 -0
  33. package/server-functions/dist/client.js +667 -165
  34. package/server-functions/dist/client.observe.js +1441 -0
  35. package/server-functions/dist/rich-args.js +102 -1
  36. package/server-functions/dist/server.dev.js +2802 -299
  37. package/server-functions/dist/server.js +2724 -314
  38. package/server-functions/dist/server.observe.js +3680 -0
  39. package/server-functions/package.json +2 -35
  40. package/server-functions/rich-args/package.json +2 -15
  41. package/skills/server-components/SKILL.md +117 -0
  42. package/storage/package.json +2 -15
  43. package/types/client.d.ts +342 -288
  44. package/types/constants.d.ts +22 -0
  45. package/types/cookies.d.ts +32 -84
  46. package/types/diagnostics.d.ts +80 -0
  47. package/types/frames/assets-tier.d.ts +78 -0
  48. package/types/frames/client.d.ts +40 -1
  49. package/types/frames/frame-client.d.ts +443 -280
  50. package/types/frames/frame-container-plugin.d.ts +64 -0
  51. package/types/frames/frame-morph.d.ts +29 -0
  52. package/types/frames/frame-sink.d.ts +141 -161
  53. package/types/frames/frame-transport.d.ts +263 -184
  54. package/types/frames/regions-tier.d.ts +60 -0
  55. package/types/frames/serializer-decode.d.ts +241 -0
  56. package/types/frames/serializer.d.ts +115 -153
  57. package/types/frames/server.d.ts +2 -2
  58. package/types/frames/trace-tier.d.ts +2 -0
  59. package/types/frames/tree-rewrite.d.ts +39 -0
  60. package/types/frames/wire-tier.d.ts +169 -0
  61. package/types/head.d.ts +20 -0
  62. package/types/index.d.ts +98 -81
  63. package/types/index.server.d.ts +159 -0
  64. package/types/jsx.d.ts +49 -44
  65. package/types/observe.d.ts +535 -0
  66. package/types/reconcile.d.ts +1 -0
  67. package/types/render.d.ts +11 -0
  68. package/types/request-error-hook.d.ts +5 -0
  69. package/types/response.d.ts +95 -147
  70. package/types/serializer-decode.d.ts +173 -114
  71. package/types/serializer.d.ts +115 -153
  72. package/types/server-functions/argument-codec.d.ts +30 -0
  73. package/types/server-functions/client.d.ts +237 -223
  74. package/types/server-functions/flash.d.ts +28 -30
  75. package/types/server-functions/registry.d.ts +105 -0
  76. package/types/server-functions/rich-args.d.ts +1 -10
  77. package/types/server-functions/server.d.ts +538 -531
  78. package/types/server-functions/shared.d.ts +398 -425
  79. package/types/server-functions/uploads.d.ts +53 -0
  80. package/types/server-mock.d.ts +154 -20
  81. package/types/server-observe.d.ts +86 -0
  82. package/types/server.d.ts +601 -422
  83. package/types/trace.d.ts +127 -0
  84. package/LICENSE +0 -21
  85. package/dist/web.cjs +0 -2033
  86. package/frames/dist/client.cjs +0 -2002
  87. package/frames/dist/client.dev.cjs +0 -2022
  88. package/frames/dist/server.cjs +0 -3877
  89. package/serialization/dist/decode.cjs +0 -139
  90. package/serialization/dist/serialization.cjs +0 -261
  91. package/serialization/types-cjs/index.d.cts +0 -182
  92. package/serialization/types-cjs/package.json +0 -3
  93. package/serialization/types-cjs/serializer-decode.d.cts +0 -182
  94. package/server-functions/dist/client.cjs +0 -834
  95. package/server-functions/dist/rich-args.cjs +0 -11
  96. package/server-functions/dist/server.cjs +0 -1242
  97. package/server-functions/dist/server.dev.cjs +0 -1242
  98. package/storage/dist/storage.cjs +0 -12
  99. package/storage/types-cjs/index.d.cts +0 -28
  100. package/storage/types-cjs/package.json +0 -3
  101. package/types/core.d.ts +0 -9
  102. package/types-cjs/client.d.cts +0 -337
  103. package/types-cjs/cookies.d.cts +0 -93
  104. package/types-cjs/core.d.cts +0 -9
  105. package/types-cjs/frames/client.d.cts +0 -36
  106. package/types-cjs/frames/frame-client.d.cts +0 -356
  107. package/types-cjs/frames/frame-sink.d.cts +0 -194
  108. package/types-cjs/frames/frame-transport.d.cts +0 -222
  109. package/types-cjs/frames/serializer.d.cts +0 -182
  110. package/types-cjs/frames/server.d.cts +0 -52
  111. package/types-cjs/index.d.cts +0 -244
  112. package/types-cjs/jsx-properties.d.cts +0 -93
  113. package/types-cjs/jsx.d.cts +0 -4159
  114. package/types-cjs/package.json +0 -3
  115. package/types-cjs/response.d.cts +0 -174
  116. package/types-cjs/serializer-decode.d.cts +0 -182
  117. package/types-cjs/serializer.d.cts +0 -182
  118. package/types-cjs/server-functions/client.d.cts +0 -262
  119. package/types-cjs/server-functions/flash.d.cts +0 -38
  120. package/types-cjs/server-functions/rich-args.d.cts +0 -10
  121. package/types-cjs/server-functions/server.d.cts +0 -681
  122. package/types-cjs/server-functions/shared.d.cts +0 -523
  123. package/types-cjs/server-mock.d.cts +0 -286
  124. package/types-cjs/server.d.cts +0 -544
@@ -1,94 +1,6 @@
1
+ export { LIVE_LOCAL, LIVE_RESUME_FROM, LIVE_SOURCE, SERVER_FUNCTION_INVOKE, SERVER_FUNCTION_METADATA, getServerFunctionMetadata, getServerFunctionRPC, invoke, isServerFunction, provideServerFunctionRPC, withMeta } from "./registry.js";
2
+ export { FLASH_COOKIE, clearFlashCookie, hasFlashCookie, matchFlashCookie } from "../cookies.js";
1
3
  import { JSONCodecOptions } from "../serializer-decode.js";
2
-
3
- export type { JSONCodecOptions };
4
-
5
- /**
6
- * Configures the codec options for the server function wire format (extra
7
- * Seroval plugins, feature policy, depth limit). Both peers must configure
8
- * identical options or payloads will not round-trip. Usually called
9
- * indirectly through `configureServerFunctionsClient` /
10
- * `configureServerFunctionsServer` (their `codec` option writes through to
11
- * here); call it directly only from universal code configuring both sides
12
- * at once.
13
- */
14
- export function configureServerFunctionsCodec(codec: JSONCodecOptions | undefined): void;
15
-
16
- /**
17
- * The currently configured codec options (set through
18
- * `configureServerFunctionsCodec` or the client/server `codec` option), or
19
- * undefined when running on the defaults. Integrations pass this to
20
- * lower-level codec helpers so custom plugins configured by the app apply.
21
- *
22
- * Integration plumbing; not meant for hand-written application code.
23
- * @internal
24
- */
25
- export function getServerFunctionsCodec(): JSONCodecOptions | undefined;
26
-
27
- /**
28
- * Request header carrying the server function id (`"X-Server-Function-Id"`).
29
- * Integrations can read it to identify which function a request targets;
30
- * the id also arrives as the `id` query parameter for GET calls and no-JS
31
- * form posts.
32
- */
33
- export const FUNCTION_HEADER: string;
34
-
35
- /**
36
- * Request header carrying a per-call instance id
37
- * (`"X-Server-Function-Instance"`). Its presence tells the server the call
38
- * came through the client runtime — its absence marks a no-JS form post or
39
- * direct HTTP call, which receive plain responses instead of codec-encoded
40
- * ones.
41
- */
42
- export const INSTANCE_HEADER: string;
43
-
44
- /**
45
- * Response header marking a thrown server-function error
46
- * (`"X-Server-Function-Error"`). The client transport rejects with the
47
- * decoded body when it is present (unless redirect/revalidation metadata
48
- * marks the response as control flow). The value carries the error's
49
- * message — `"true"` for thrown control-flow responses and non-Error
50
- * values — encoded with `encodeErrorHeaderValue`, so integrations reading
51
- * it must pass it through `decodeErrorHeaderValue`.
52
- */
53
- export const ERROR_HEADER: string;
54
-
55
- /**
56
- * Encodes an error message for the `ERROR_HEADER` value. HTTP header values
57
- * are latin1 ByteStrings — `Headers.set` throws on code points above U+00FF
58
- * — so plain printable-latin1 messages ride verbatim (ASCII stays
59
- * byte-identical on the wire) and everything else (CJK, emoji, controls)
60
- * travels percent-encoded behind a marker. `decodeErrorHeaderValue`
61
- * round-trips the message exactly, astral-plane characters included (lone
62
- * surrogates are replaced with U+FFFD — they cannot survive UTF-8 anyway).
63
- *
64
- * Transport wire detail; not meant for hand-written code.
65
- * @internal
66
- */
67
- export function encodeErrorHeaderValue(value: string): string;
68
-
69
- /**
70
- * Decodes an `ERROR_HEADER` value produced by `encodeErrorHeaderValue`:
71
- * marked values are percent-decoded, everything else (including values from
72
- * peers that never encode) passes through untouched.
73
- *
74
- * Integration plumbing for readers of `ERROR_HEADER`; not meant for
75
- * hand-written application code.
76
- * @internal
77
- */
78
- export function decodeErrorHeaderValue(value: string): string;
79
-
80
- /**
81
- * Header driving the single-flight protocol on both legs
82
- * (`"X-Single-Flight"`). On the request it opts the call into data
83
- * collection — the transport sends it automatically on non-GET calls while
84
- * a flight-data consumer is subscribed (subscribing IS the opt-in). On the
85
- * response it marks a body carrying the standardized `SingleFlightPayload`.
86
- * How the data is produced (a data-only render, running route preloads,
87
- * anything else) and what it means is entirely the integration's business —
88
- * the protocol only standardizes the wire shape and the delivery.
89
- */
90
- export const SINGLE_FLIGHT_HEADER: string;
91
-
92
4
  /**
93
5
  * The standardized body of a single-flight response (a response tagged with
94
6
  * `SINGLE_FLIGHT_HEADER`): the function's return `value` plus the
@@ -96,112 +8,90 @@ export const SINGLE_FLIGHT_HEADER: string;
96
8
  * HTTP handler. Integrations decoding passthrough responses themselves (no
97
9
  * registered consumer) see this shape from `decodeResponse`. The top level
98
10
  * is reserved for the protocol — integration payload lives entirely under
99
- * `data`, which can be any codec-serializable value.
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.
100
14
  */
101
15
  export interface SingleFlightPayload<T = unknown, D = unknown> {
102
- /** The server function's return (or thrown) value. */
103
- value: T;
104
- /** The integration-produced data payload. */
105
- data: D;
16
+ /** The server function's return (or thrown) value. */
17
+ value: T;
18
+ /** The integration-produced data payload, keyed by source id. */
19
+ data: D;
106
20
  }
107
-
108
21
  /**
109
22
  * Envelope context delivered alongside single-flight data: the transport
110
- * response, whose headers carry the integration metadata (`Location` for
111
- * redirect-with-data, `X-Revalidate` keys) and status. The body is already
112
- * consumed — read `data` and `value` from the delivery, not from here.
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.
113
27
  */
114
28
  export interface FlightDataContext {
115
- /** The HTTP response the data arrived on (metadata only). */
116
- response: Response;
29
+ /** The HTTP response the data arrived on (metadata only). */
30
+ response: Response;
117
31
  }
118
-
119
32
  /**
120
33
  * Consumer receiving single-flight data on the client: `data` is the
121
34
  * integration-produced payload (opaque to the protocol), `context` carries
122
- * the envelope metadata. Async consumers are awaited before the function
123
- * value is returned to the caller, so caches are seeded first.
124
- */
125
- export type FlightDataConsumer<D = unknown> = (
126
- data: D,
127
- context: FlightDataContext
128
- ) => void | Promise<void>;
129
-
130
- /**
131
- * Registers the consumer the client transport delivers single-flight data
132
- * to. Subscribing is the single-flight opt-in: while a consumer is
133
- * registered the transport sends the request-leg `SINGLE_FLIGHT_HEADER` on
134
- * non-GET calls (GET reads stay plain and cacheable), asking the server's
135
- * collection hook to fold data into the response. When a single-flight
136
- * response arrives, the transport decodes the standardized
137
- * `{ value, data }` payload, delivers `data` (with the response as
138
- * envelope context — redirect location, revalidation keys), and returns
139
- * `value` to the caller as if the call were plain. What to do with the
140
- * data (seed caches, navigate, ...) is entirely the consumer's business.
141
- * One active consumer at a time — a later registration replaces the
142
- * current one; returns an unsubscribe function. With no consumer
143
- * registered, no header is sent and the server does no collection work;
144
- * responses an integration opted in manually still pass through to the
145
- * caller whole, exactly like other integration responses.
146
- */
147
- export function subscribeFlightData<D = unknown>(consumer: FlightDataConsumer<D>): () => void;
148
-
149
- /**
150
- * Name of the cookie carrying the outcome of a call made without the client
151
- * runtime (`"flash"`). A no-JS form post has no way to receive a value —
152
- * the browser follows the redirect and renders the next page — so the
153
- * handler stashes the outcome here for the render after it to pick up,
154
- * which is how a form submitted without JavaScript still shows its result.
155
- *
156
- * The name, detection and clearing are isomorphic (integrations read the
157
- * cookie from code that also ships to the browser); the codec that fills it
158
- * is server-only and lives behind the server entry.
159
- */
160
- export const FLASH_COOKIE: string;
161
-
162
- /**
163
- * Whether a Cookie header carries a flash cookie, readable or not. Cheap
164
- * enough to call on every render so the clear can be queued before the
165
- * response headers flush.
166
- */
167
- export function hasFlashCookie(cookieHeader: string | null): boolean;
168
-
169
- /**
170
- * The `Set-Cookie` value clearing the flash cookie. The outcome is
171
- * one-shot: append this as soon as the cookie is detected, whether or not
172
- * it decodes, so a stale outcome cannot resurface on a later request.
173
- */
174
- export function clearFlashCookie(): string;
175
-
176
- /**
177
- * The raw encoded flash payload out of a Cookie header, if present — the
178
- * codec's own accessor.
179
- *
180
- * @internal
181
- */
182
- export function matchFlashCookie(cookieHeader: string | null): string | undefined;
183
-
184
- /**
185
- * The currently registered single-flight consumer.
186
- *
187
- * Transport building block; not meant for hand-written code.
188
- * @internal
35
+ * the envelope metadata. `data` is `undefined` when the response carried
36
+ * integration metadata (a redirect, revalidation keys) but the server
37
+ * folded no slice for this source — the consumer still runs, to apply the
38
+ * metadata. Async consumers are awaited before the function value is
39
+ * returned to the caller, so caches are seeded first.
189
40
  */
190
- export function getFlightDataConsumer(): FlightDataConsumer | undefined;
191
-
41
+ export type FlightDataConsumer<D = unknown> = (data: D | undefined, context: FlightDataContext) => void | Promise<void>;
192
42
  /**
193
43
  * The public contract of a server function reference — what a `"use
194
44
  * server"` import is at runtime on either side: an async callable plus its
195
45
  * build-stable identity.
196
46
  */
197
47
  export interface ServerFunction<A extends readonly any[] = any[], T = any> {
198
- (...args: A): Promise<T>;
199
- /** The build-stable function id (stable across the client and server builds). */
200
- readonly id: string;
201
- /** URL invoking this function directly over HTTP (form `action`s, raw fetches). */
202
- readonly url: string;
48
+ (...args: A): Promise<T>;
49
+ /** The build-stable function id (stable across the client and server builds). */
50
+ readonly id: string;
51
+ /**
52
+ * The plain-HTTP address of this function — what a `<form action>` posts
53
+ * to without the runtime (the integration behind `action={fn}` reads it).
54
+ * Not where the reference's own call goes: that is `serverFunctionUrl(fn,
55
+ * ...args)`, for a `GET()` reference — the url to preload or fetch.
56
+ */
57
+ readonly url: string;
58
+ }
59
+ /**
60
+ * Per-call, invocation-scoped options for `invoke` — things that vary
61
+ * between calls of the SAME function and cannot be declared (`GET`,
62
+ * `withMeta`) or configured (`prepareRequest`). On the server the call is
63
+ * in-process: `signal` still rejects the caller, the transport hints are
64
+ * no-ops (they describe a wire that does not exist).
65
+ */
66
+ export interface InvokeOptions {
67
+ /**
68
+ * The call's lifecycle. Aborting rejects the call with the signal's
69
+ * reason and cancels the request (firing `request.signal` server-side);
70
+ * a live source's iteration ends across reconnects. When provided, the
71
+ * signal owns the wire — timeouts compose through it
72
+ * (`AbortSignal.timeout`, `AbortSignal.any`).
73
+ */
74
+ signal?: AbortSignal;
75
+ /**
76
+ * Lets the request outlive the page — fire-and-forget calls during
77
+ * unload (`pagehide`). Maps to fetch's `keepalive`, body-size caps
78
+ * included.
79
+ */
80
+ keepalive?: boolean;
81
+ /** Fetch priority hint — speculative prefetch vs. interaction fetch. */
82
+ priority?: "high" | "low" | "auto";
203
83
  }
204
-
84
+ /**
85
+ * A reference's invocation channel, carried under `SERVER_FUNCTION_INVOKE`:
86
+ * applies one call with per-call options. Declaration wrappers (`GET`,
87
+ * `live`) forward it mechanically — they keep the call mapping 1:1. A
88
+ * wrapper that shares calls (a deduping cache, a multicast channel) opts
89
+ * in deliberately, deciding first what a caller's abort means for shared
90
+ * work — or declines, leaving `invoke` to answer with a directed error.
91
+ * Options arrive already validated — `invoke` admits only
92
+ * invocation-scoped keys.
93
+ */
94
+ export type ServerFunctionInvoker<A extends readonly any[] = any[], R = any> = (args: A, options?: InvokeOptions) => R;
205
95
  /**
206
96
  * Declaration-static metadata attached to a server function reference
207
97
  * through declaration wrappers (`GET`, `withMeta`). Read it with
@@ -211,78 +101,38 @@ export interface ServerFunction<A extends readonly any[] = any[], T = any> {
211
101
  * over earlier ones.
212
102
  */
213
103
  export interface ServerFunctionMetadata {
214
- /** The declared HTTP method. Undeclared references call over POST. */
215
- readonly method?: "GET" | "POST";
216
- /**
217
- * A human-readable label for the function, seeded by development builds
218
- * from the compiled function's source name (dev tooling — inspectors,
219
- * logs). Dev-only: production builds emit no name. Not unique and not an
220
- * identity key — use `id` for identity. Seeded as a default: an explicit
221
- * `withMeta` write wins.
222
- */
223
- readonly name?: string;
224
- /** User-declared transport metadata attached with `withMeta`. */
225
- readonly [key: string]: unknown;
104
+ /** The declared HTTP method. Undeclared references call over POST. */
105
+ readonly method?: "GET" | "POST";
106
+ /**
107
+ * A human-readable label for the function, seeded by development builds
108
+ * from the compiled function's source name (dev tooling — inspectors,
109
+ * logs). Dev-only: production builds emit no name. Not unique and not an
110
+ * identity key — use `id` for identity. Seeded as a default: an explicit
111
+ * `withMeta` write wins.
112
+ */
113
+ readonly name?: string;
114
+ /**
115
+ * This function's own send, client side: the transport calls it instead
116
+ * of the configured `fetch` for every request the function makes, with
117
+ * the configured send (the app's `fetch`, or the global) as `next`. For
118
+ * an integration that answers a declared function's calls itself — a
119
+ * prerendered build's static artifacts, a cache — while the app's
120
+ * transport `fetch` stays the app's: pass on what you don't answer
121
+ * through `next`. The contract is `fetch`'s (see
122
+ * `ServerFunctionsClientConfig.fetch`); hydration adopts a
123
+ * server-rendered read only if the send reaches the global `fetch` in the
124
+ * same tick.
125
+ *
126
+ * ```ts
127
+ * withMeta(getPosts, {
128
+ * fetch: (address, init, next) => cached(address) ?? next(address, init)
129
+ * });
130
+ * ```
131
+ */
132
+ readonly fetch?: (address: string, init: RequestInit, next: (address: string, init: RequestInit) => Response | Promise<Response>) => Response | Promise<Response>;
133
+ /** User-declared transport metadata attached with `withMeta`. */
134
+ readonly [key: string]: unknown;
226
135
  }
227
-
228
- /**
229
- * Reads a server function reference's declaration metadata — e.g.
230
- * `getServerFunctionMetadata(fn)?.method === "GET"` detects a `GET(fn)`
231
- * declaration. Returns undefined when `fn` is not a server function
232
- * reference; plain references carry an empty metadata object. Works on
233
- * client proxies and server-side references alike, across duplicated
234
- * module instances (registered-symbol brand).
235
- */
236
- export function getServerFunctionMetadata(fn: unknown): ServerFunctionMetadata | undefined;
237
-
238
- /**
239
- * Whether `fn` is a server function reference (a client proxy or a
240
- * server-side registered callable). Detection is structural — a
241
- * registered-symbol metadata brand — so it holds across duplicated module
242
- * instances and both sides of the directive boundary.
243
- */
244
- export function isServerFunction(fn: unknown): fn is ServerFunction;
245
-
246
- /**
247
- * Attaches user-declared transport metadata to a server function reference
248
- * (client proxy or server-registered callable) and returns the reference.
249
- * Writes ride the same channel `GET` uses: later writes shallow-merge over
250
- * earlier ones, and `getServerFunctionMetadata(fn)` reads the merged bag —
251
- * so `withMeta` composes with `GET` in either order
252
- * (`GET(withMeta(fn, meta))` ≡ `withMeta(GET(fn), meta)`).
253
- *
254
- * The pattern is declare-on-function, react-in-hook: metadata declared
255
- * here reaches `prepareRequest` as `context.meta`, letting session-dynamic
256
- * transport policy key on declarations instead of comparing function ids:
257
- *
258
- * ```ts
259
- * export const chargeCard = withMeta(async (amount: number) => {
260
- * "use server";
261
- * // ...
262
- * }, { requiresAuth: true });
263
- *
264
- * configureServerFunctionsClient({
265
- * prepareRequest(init, { meta }) {
266
- * if (meta?.requiresAuth) {
267
- * return {
268
- * ...init,
269
- * headers: { ...init.headers, Authorization: `Bearer ${session.token()}` }
270
- * };
271
- * }
272
- * return init;
273
- * }
274
- * });
275
- * ```
276
- */
277
- export function withMeta<F extends (...args: any[]) => any>(fn: F, meta: ServerFunctionMetadata): F;
278
-
279
- /**
280
- * The registered symbol branding server function references with their
281
- * declaration metadata. Use the typed accessors instead.
282
- * @internal
283
- */
284
- export const SERVER_FUNCTION_METADATA: unique symbol;
285
-
286
136
  /**
287
137
  * The transport surface integrations consume through the late-bound RPC
288
138
  * seam (server-functions/registry.js) — filled by the transport halves when
@@ -291,233 +141,356 @@ export const SERVER_FUNCTION_METADATA: unique symbol;
291
141
  * by routers so they never import the transport/codec statically.
292
142
  */
293
143
  export interface ServerFunctionRPC {
294
- /**
295
- * The build's `GET` declaration wrapper (client fetch transport or
296
- * server in-process dispatch — see the respective entries).
297
- */
298
- GET<A extends readonly any[], R>(fn: (...args: A) => R): ServerFunction<A, Awaited<R>>;
299
- /**
300
- * `decodeResponse` bound to the configured codec: decodes a server
301
- * function response body the transport handed over whole (redirects,
302
- * revalidation). Resolves undefined for empty bodies and bodies without
303
- * a recognized encoding (e.g. a raw user Response).
304
- */
305
- decodeResponse<T = unknown>(response: Response): Promise<T | undefined>;
144
+ /**
145
+ * The build's `GET` declaration wrapper (client fetch transport or
146
+ * server in-process dispatch — see the respective entries).
147
+ */
148
+ GET<A extends readonly any[], R>(fn: (...args: A) => R): ServerFunction<A, Awaited<R>>;
149
+ /**
150
+ * `decodeResponse` bound to the configured codec: decodes a server
151
+ * function response body the transport handed over whole (redirects,
152
+ * revalidation). Resolves undefined for empty bodies and bodies without
153
+ * a recognized encoding (e.g. a raw user Response).
154
+ */
155
+ decodeResponse<T = unknown>(response: Response): Promise<T | undefined>;
306
156
  }
307
-
308
157
  /**
309
- * Fills the RPC seam. Called by the transport halves when the first server
310
- * function reference is created; first write wins.
158
+ * Transport wire detail; not meant for hand-written code.
311
159
  * @internal
312
160
  */
313
- export function provideServerFunctionRPC(rpc: ServerFunctionRPC): void;
314
-
161
+ export type BodyFormatValue = (typeof BodyFormat)[keyof typeof BodyFormat];
162
+ export declare function configureServerFunctionsCodec(codec: JSONCodecOptions | undefined): void;
163
+ export declare function getServerFunctionsCodec(): JSONCodecOptions | undefined;
315
164
  /**
316
- * The registered RPC surface, or undefined when no server function exists
317
- * in this build's graph. Integration plumbing (routers): gate every use of
318
- * the transport/codec behind this read instead of importing it — an app
319
- * with no server functions then ships none of it, while a reference in the
320
- * bundle guarantees the seam is filled before integration code can hold
321
- * that reference (compiled output creates references at module scope).
165
+ * Validates a flight data source id (both registration halves share the
166
+ * rule): ids travel the `SINGLE_FLIGHT_HEADER` as a comma-separated list,
167
+ * so they cannot be empty or contain commas, and "true" is reserved for
168
+ * the unnamed registration.
169
+ *
170
+ * Transport building block; not meant for hand-written code.
322
171
  * @internal
323
172
  */
324
- export function getServerFunctionRPC(): ServerFunctionRPC | undefined;
325
-
173
+ export declare function assertFlightSource(source: string): void;
174
+ export declare function subscribeFlightData<D = unknown>(consumer: FlightDataConsumer<D>): () => void;
175
+ export declare function subscribeFlightData<D = unknown>(source: string, consumer: FlightDataConsumer<D>): () => void;
176
+ export declare function getFlightDataConsumer(source?: string): FlightDataConsumer | undefined;
177
+ export declare function getFlightDataSourceIds(): string[];
326
178
  /**
327
- * Header carrying the body format tag (a `BodyFormat` value) —
328
- * `"X-Server-Function-Format"`.
179
+ * Whether a mutation response carries integration metadata — the redirect
180
+ * carrier or `X-Revalidate` keys. Metadata is envelope-level (it describes
181
+ * what the mutation did to every cache on the page), so a response carrying
182
+ * it is delivered to every registered flight consumer, folded or not.
329
183
  *
330
- * Transport wire detail; not meant for hand-written code.
184
+ * Transport building block; not meant for hand-written code.
331
185
  * @internal
332
186
  */
333
- export const BODY_FORMAT_HEADER: string;
334
-
187
+ export declare function hasFlightMetadata(response: Response): boolean;
335
188
  /**
336
- * FormData key used when a lone File is sent as the argument.
189
+ * Delivers a decoded single-flight envelope's `data` to the registered
190
+ * consumers — THE delivery path, shared by every transport that can carry
191
+ * the envelope (the plain server-function client and the frames client's
192
+ * flight application), so a mutation reads identically whichever body
193
+ * shape it arrived in.
337
194
  *
338
- * Transport wire detail; not meant for hand-written code.
195
+ * `data` is the keyed envelope, `{ [source]: slice }` (the unnamed
196
+ * registration's slice under the reserved id "true"); `response` is the
197
+ * envelope context, whose `SINGLE_FLIGHT_HEADER` names the folded sources.
198
+ * Each registered consumer receives its own slice, in registration order,
199
+ * awaited sequentially so caches are seeded before the caller sees the
200
+ * value. Pending entries in the slices (values the collector folded while
201
+ * still in flight, streamed after the response head) are settled before
202
+ * any consumer runs. A consumer whose source was not folded is skipped —
203
+ * unless the response carries integration metadata, in which case it runs
204
+ * with `data` `undefined` to apply the metadata. Consumers are looked up
205
+ * per delivery: an awaited consumer may unsubscribe another (a provider
206
+ * tearing down under a navigation).
207
+ *
208
+ * Transport building block; not meant for hand-written code.
339
209
  * @internal
340
210
  */
341
- export const FILE_FORM_KEY: string;
342
-
343
- /**
344
- * Wire tags naming how a request/response body was encoded, carried in
345
- * `BODY_FORMAT_HEADER`.
346
- *
347
- * Transport wire detail; not meant for hand-written code.
211
+ export declare function deliverFlightData(response: Response, data: unknown): Promise<void>;
212
+ export declare function frameAddress(id: string, args?: readonly unknown[]): string;
213
+ export declare function serverFunctionAddress(endpoint: string, id: string): string;
214
+ export declare function serverFunctionDataAddress(endpoint: string, id: string): string;
215
+ export declare function serverFunctionLiveAddress(endpoint: string, id: string): string;
216
+ export declare function parseServerFunctionAddress(pathname: string, endpoint: string): {
217
+ id: string;
218
+ data: boolean;
219
+ live: boolean;
220
+ } | null;
221
+ /**
222
+ * The longest url a `GET()` call goes out as. Longer, the call dispatches
223
+ * over POST instead — a cache miss rather than a 414 from whichever proxy in
224
+ * the chain draws the line first — so no url describes it (`serverFunctionUrl`
225
+ * refuses to render one).
348
226
  * @internal
349
227
  */
350
- export const BodyFormat: {
351
- readonly Serialized: "0";
352
- readonly String: "1";
353
- readonly FormData: "2";
354
- readonly URLSearchParams: "3";
355
- readonly Blob: "4";
356
- readonly File: "5";
357
- readonly ArrayBuffer: "6";
358
- readonly Uint8Array: "7";
359
- /**
360
- * Plain `JSON.stringify` — the fast path for JSON-safe payloads on both
361
- * legs: argument lists on the request, results on the response.
362
- */
363
- readonly Json: "8";
364
- };
365
-
228
+ export declare const MAX_GET_URL_LENGTH = 2000;
366
229
  /**
367
- * Transport wire detail; not meant for hand-written code.
230
+ * Body of both entries' `serverFunctionActionUrl`: the plain-HTTP address of
231
+ * a function, `<endpoint>/<id>[?args=...]`.
368
232
  * @internal
369
233
  */
370
- export type BodyFormatValue = (typeof BodyFormat)[keyof typeof BodyFormat];
371
-
372
- /**
373
- * Whether a value survives a `JSON.stringify` round trip faithfully: JSON
374
- * primitives (finite numbers only), arrays, and plain objects. Anything
375
- * else — Dates, Maps, typed arrays, undefined (bare or as a property),
376
- * NaN, class instances, cyclic structures — needs the codec. Never throws:
377
- * cycles and pathological depth answer `false`. Both peers negotiate the
378
- * wire format with this guard: the client for argument lists, the server
379
- * for results.
234
+ export declare function serverFunctionActionUrlFor(endpoint: string, target: ServerFunction | string, boundArgs: readonly unknown[]): string;
235
+ /**
236
+ * Body of both entries' `serverFunctionUrl`: the url a `GET()` reference's
237
+ * own call requests — `<endpoint>/data/<id>[?args=...]`, or for a live
238
+ * reference `<endpoint>/live/<id>[?args=...]` — built the way the transport
239
+ * builds it (JSON arguments in `args`; see `GET`'s client half) so a fetch
240
+ * of it is the call. For a live reference that call is a standing event
241
+ * stream: the url is for fetching by hand (`curl -N`), not for a preload
242
+ * or prefetch, which would open a stream nothing reads. Refuses — rather
243
+ * than answering with an address nothing would request — when the
244
+ * reference is not a declared read (the default transport POSTs, and a
245
+ * POST is not described by its url), when the arguments need the codec
246
+ * (the transport encodes those asynchronously, and a url rendered as a
247
+ * value cannot wait), and when the url would be long enough for the call
248
+ * to fall back to POST.
249
+ * @internal
380
250
  */
381
- export function isJSONSafe(value: unknown): boolean;
382
-
383
- /**
384
- * Picks a direct HTTP encoding (headers + BodyInit) for values that have
385
- * one — strings, FormData, URLSearchParams, File, Blob, ArrayBuffer,
386
- * Uint8Array. Returns undefined when the value needs the serializer.
387
- *
388
- * Transport building block used by the fetch transport and the HTTP
389
- * handler; not meant for hand-written code.
251
+ export declare function serverFunctionUrlFor(endpoint: string, fn: ServerFunction, args: readonly unknown[]): string;
252
+ /**
253
+ * Response header marking a thrown server-function error. The value is the
254
+ * error's message (the structured error itself travels in the body); `"true"`
255
+ * for thrown control-flow responses and non-Error values.
256
+ */
257
+ export declare const ERROR_HEADER = "X-Server-Function-Error";
258
+ export declare function encodeErrorHeaderValue(value: string): string;
259
+ export declare function decodeErrorHeaderValue(value: string): string;
260
+ /** Header carrying the body format tag (a `BodyFormat` value). */
261
+ export declare const BODY_FORMAT_HEADER = "X-Server-Function-Format";
262
+ /**
263
+ * The position a `live` loop reconnects from, on the request to a live
264
+ * address — the header `EventSource` sends for the same purpose, so a cursor
265
+ * source written against either reader reads one name. Its value is the
266
+ * `id:` of the last event the loop received: a cursor the source named, or
267
+ * the runtime's digest of a value-shaped yield (see `positionDigest`), which
268
+ * lets the server skip re-sending a first emission the client already
269
+ * holds. Rides only on the live address, which is `no-store` and never
270
+ * preloaded — a position must never become an argument, where it would
271
+ * change a read's url identity.
390
272
  * @internal
391
273
  */
392
- export function getHeadersAndBody(
393
- body: unknown
394
- ): { headers?: Record<string, string>; body: BodyInit } | undefined;
395
-
396
- /**
397
- * Decodes a Request/Response body according to its `BODY_FORMAT_HEADER`
398
- * tag (falling back to content-type sniffing for form posts that never saw
399
- * the client runtime). The inverse of `getHeadersAndBody` + the serialized
400
- * stream. Resolves undefined for bodies without a recognized encoding.
401
- *
402
- * Transport building block; use `decodeResponse` from integration code.
274
+ export declare const LAST_EVENT_ID_HEADER = "Last-Event-ID";
275
+ /**
276
+ * Per-iteration slot the `live` loop threads through its invoke options
277
+ * (never a public option; process-local symbol): the reader records each
278
+ * event's `id:` in `position`, the next connect sends it back as
279
+ * `Last-Event-ID`, and the loop asks the reference for the LIVE address
280
+ * when this is present. `open` builds the event-stream reader — installed
281
+ * by `live()` itself, so a client that never imports `live` carries no
282
+ * event-stream parser (the `provideRPC` pattern). `connection` is the slot
283
+ * for the connection being made: the decoder sets `connection.ended`, a
284
+ * promise for the body's end carrying how many deferreds were still open
285
+ * (the lifetime signal — death or completion), the error the body ended
286
+ * with, and the sweep the loop may run over the open ones.
403
287
  * @internal
404
288
  */
405
- export function extractBody(
406
- source: Request | Response,
407
- codecOptions?: JSONCodecOptions
408
- ): Promise<unknown>;
409
-
289
+ export declare const LIVE_WIRE: unique symbol;
410
290
  /**
411
- * Serializes a value as a stream of length-prefixed SerovalNode chunks.
412
- * Async values (promises, streams) keep the stream open until they settle,
413
- * so one connection carries incremental results. Codec options must match
414
- * the deserializing peer.
415
- *
416
- * Transport building block; not meant for hand-written code.
417
- * @internal
291
+ * Header labelling the unknown-id 404: the address was well-formed but its
292
+ * id is not registered in the deployment that answered (#3110). This is the
293
+ * ordinary shape of version skew — a tab holding the previous build's ids
294
+ * across a deploy — and the label is what lets an integration recover
295
+ * (e.g. reload the document) instead of surfacing a generic failed call.
296
+ * Nothing distinguishes it otherwise: a CDN 404 and a skew 404 look alike.
418
297
  */
419
- export function serializeStream(
420
- value: unknown,
421
- codecOptions?: JSONCodecOptions
422
- ): ReadableStream<Uint8Array>;
423
-
298
+ export declare const UNKNOWN_HEADER = "X-Server-Function-Unknown";
424
299
  /**
425
- * `serializeStream` drained to a string (async values fully awaited).
426
- *
427
- * Transport building block; not meant for hand-written code.
428
- * @internal
300
+ * Header carrying a build id. The build integration adds it to calls
301
+ * through `prepareRequest`; the client runtime never sends it. A server
302
+ * configured with another `buildId` answers `409` with its own id under the
303
+ * same header and the `UNKNOWN_HEADER` label, and does not run the function.
304
+ * This catches the skew the unknown-id 404 cannot: a function whose id
305
+ * survived the deploy but whose arguments or result changed shape.
429
306
  */
430
- export function serializeString(value: unknown, codecOptions?: JSONCodecOptions): Promise<string>;
431
-
307
+ export declare const BUILD_HEADER = "X-Server-Function-Build";
432
308
  /**
433
- * Decodes a framed chunk stream from a Request/Response body. Resolves with
434
- * the first chunk's value (the source value); later chunks settle the async
435
- * values referenced inside it as they arrive.
309
+ * Header carrying a redirect to scripted callers. fetch FOLLOWS redirect
310
+ * statuses before the transport can read them, so a scripted answer masks
311
+ * the 3xx to 200 and this header carries what the mask erases: the author's
312
+ * status and the target RESOLVED against the request url — exactly the
313
+ * meaning HTTP assigns the `Location` a form post would have received.
314
+ * Value: `<status> <absolute-url>`, decode with `decodeRedirectHeaderValue`.
436
315
  *
437
- * Transport building block; use `decodeResponse` from integration code.
438
- * @internal
439
- */
440
- export function deserializeStream<T = unknown>(
441
- source: Request | Response,
442
- codecOptions?: JSONCodecOptions
443
- ): Promise<T>;
444
-
316
+ * Carrying the resolved absolute form is the point (#3102, #3107): the
317
+ * reader never guesses navigation strategy from how the author spelled the
318
+ * target — `redirect("/")` and `redirect(new URL("/", url).href)` arrive
319
+ * identical by construction, and same-origin vs cross-origin is a real URL
320
+ * comparison, not a `startsWith("http")` coin toss. `Location` itself never
321
+ * rides a masked answer: on a 200 it has no HTTP meaning, and it collided
322
+ * with authored Locations on statuses that forward (a 201's created-at is
323
+ * data, not navigation).
324
+ */
325
+ export declare const REDIRECT_HEADER = "X-Server-Function-Redirect";
326
+ /**
327
+ * Decodes a `REDIRECT_HEADER` value into the author's status and the
328
+ * resolved absolute target. Integration plumbing for readers of the header
329
+ * (routers); the wire format is the runtime's own, not a contract to parse
330
+ * by hand.
331
+ *
332
+ * The documented output — a resolved ABSOLUTE http(s) target and a redirect
333
+ * status — is enforced, not assumed (#3175): the absoluteness used to be a
334
+ * property of the server having resolved it, and a hostile or buggy peer
335
+ * could ride a `javascript:` target straight into the `location.href =
336
+ * decoded.url` an integration reasonably writes. A value that does not
337
+ * parse as an absolute http(s) url, or whose status is not one the runtime
338
+ * masks, decodes to `undefined` — the same answer a missing header gives.
339
+ */
340
+ export declare function decodeRedirectHeaderValue(value: string | null | undefined): {
341
+ status: number;
342
+ url: string;
343
+ } | undefined;
344
+ /**
345
+ * Header driving the single-flight protocol on both legs: on the request it
346
+ * opts the call into flight-data collection (the integration sends it on
347
+ * calls whose response should fold in data), on the response it marks a
348
+ * body carrying the standardized `{ value, data }` payload. How the data
349
+ * is produced (and what it means) is entirely the integration's business —
350
+ * core only owns the wire shape and the delivery.
351
+ */
352
+ export declare const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
353
+ /** FormData key used when a lone File is sent as the argument. */
354
+ export declare const FILE_FORM_KEY = "__server_function_file__";
355
+ export declare const BodyFormat: {
356
+ Serialized: string;
357
+ String: string;
358
+ FormData: string;
359
+ URLSearchParams: string;
360
+ Blob: string;
361
+ File: string;
362
+ ArrayBuffer: string;
363
+ Uint8Array: string;
364
+ /**
365
+ * Plain `JSON.stringify` — the fast path for JSON-safe payloads on both
366
+ * legs: argument lists on the request, results (single-flight envelopes
367
+ * included) on the response.
368
+ */
369
+ Json: string;
370
+ /**
371
+ * No body at all — a function that returned nothing. It marks the response
372
+ * as one the runtime encoded, which separates a void result with a status
373
+ * on it from a refusal answered by something else. Decoding falls through
374
+ * to `undefined`, which is what a peer predating the tag reads too.
375
+ */
376
+ Void: string;
377
+ };
378
+ export declare function isJSONSafe(value: unknown): boolean;
379
+ export declare function getHeadersAndBody(body: unknown): {
380
+ headers?: Record<string, string>;
381
+ body: BodyInit;
382
+ } | undefined;
383
+ export declare function extractBody(source: Request | Response, codecOptions?: JSONCodecOptions, wire?: unknown): Promise<unknown>;
384
+ export declare function createChunk(data: string): Uint8Array;
385
+ export declare class ChunkReader {
386
+ constructor(stream: any);
387
+ /** Reads once into the buffer; answers whether the reader was cancelled. */
388
+ readChunk(): Promise<any>;
389
+ next(): Promise<{
390
+ done: boolean;
391
+ value: any;
392
+ }>;
393
+ drain(interpret: any): Promise<void>;
394
+ /** End the read: the body is cancelled through the lock this reader
395
+ * holds, and a pending `next()` resolves done, even partway through a
396
+ * frame. */
397
+ cancel(reason: any): any;
398
+ }
445
399
  /**
446
- * `deserializeStream` for an already-buffered string.
400
+ * Frame one payload as a server-sent event — the framing a live address
401
+ * answers in. The same codec payloads `createChunk` frames ride one per
402
+ * event so buffering middleboxes, trained on `text/event-stream`, pass them
403
+ * through unbuffered; `id` (when given) rides as the event's `id:` field,
404
+ * which is what a reconnecting loop echoes back as `Last-Event-ID`.
447
405
  *
448
- * Transport building block; not meant for hand-written code.
406
+ * Payloads are `JSON.stringify` output and so carry no raw CR/LF, but the
407
+ * split is done regardless: a payload IS one `data:` line per line, and
408
+ * the reader joins them back with `\n`, so the framing is correct for any
409
+ * string rather than for the strings it happens to see.
410
+ *
411
+ * Transport wire detail; not meant for hand-written code.
449
412
  * @internal
450
413
  */
451
- export function deserializeString<T = unknown>(
452
- text: string,
453
- codecOptions?: JSONCodecOptions
454
- ): Promise<T>;
455
-
414
+ export declare function createEventChunk(data: string, id?: string): Uint8Array;
456
415
  /**
457
- * Decodes a server function response body using the configured codec. This
458
- * is the integration-facing decoder: routers call it on responses the
459
- * transport hands over whole — redirects, revalidation, single-flight
460
- * payloads — to recover the structured value inside. Resolves undefined for
461
- * empty bodies and bodies without a recognized encoding (e.g. a raw user
462
- * Response). Renderer- and platform-neutral: safe to use from universal
463
- * code.
464
- *
465
- * @param response the transport response; its body is read from a clone,
466
- * so the original stays readable
467
- * @param codecOptions overrides the configured codec for this call
416
+ * The heartbeat a live response writes while idle: an event-stream comment,
417
+ * invisible to the reader, that keeps proxies with idle timeouts from
418
+ * closing a connection that is merely waiting.
419
+ * @internal
468
420
  */
469
- export function decodeResponse<T = unknown>(
470
- response: Response,
471
- codecOptions?: JSONCodecOptions
472
- ): Promise<T | undefined>;
473
-
421
+ export declare const EVENT_STREAM_HEARTBEAT: Uint8Array<ArrayBuffer>;
474
422
  /**
475
- * `decodeResponse` plus the single-flight envelope split: when the response
476
- * carries the single-flight header the decoded `{ value, data }` payload is
477
- * unwrapped into `{ value, flightData }`; otherwise the decoded body (or
478
- * undefined for body-less responses) rides as `{ value }`. Integrations
479
- * that apply response metadata themselves use this so the payload shape
480
- * stays core's own.
481
- *
482
- * Integration plumbing; not meant for hand-written application code.
423
+ * Whether a Request/Response body is framed as an event stream (by content
424
+ * type — the framing a live address answers in).
483
425
  * @internal
484
426
  */
485
- export function decodeResponsePayload<T = unknown, D = unknown>(
486
- response: Response,
487
- codecOptions?: JSONCodecOptions
488
- ): Promise<{ value: T | undefined; flightData?: D }>;
489
-
427
+ export declare function isEventStream(source: Request | Response): boolean;
490
428
  /**
491
- * Frame one payload for the server-function wire: a `;0x<len32>;` length
492
- * prefix followed by the utf-8 data. Both transports (server-function
493
- * responses and frame streams) share this framing.
429
+ * The reader for what `createEventChunk` writes — `ChunkReader`'s
430
+ * counterpart for the event-stream framing, same `next()`/`drain()` shape
431
+ * so `deserializeStream` runs unchanged over either. Only `data:` and `id:`
432
+ * are read; `event:`, `retry:` and unknown fields are ignored (the
433
+ * transport carries one kind of event and owns its own backoff), comments
434
+ * are heartbeats. An event dispatches on its blank line; an event the body
435
+ * ends inside is discarded, as the spec says, and the drain's end-of-body
436
+ * sweep fails whatever it left open.
437
+ *
438
+ * Each dispatched event's `id:` is recorded on `wire.position` — the value
439
+ * the loop sends as `Last-Event-ID` on its next connect.
494
440
  *
495
441
  * Transport wire detail; not meant for hand-written code.
496
442
  * @internal
497
443
  */
498
- export function createChunk(data: string): Uint8Array;
499
-
444
+ export declare class EventStreamReader {
445
+ constructor(stream: any, wire: any);
446
+ read(): Promise<void>;
447
+ takeLine(): any;
448
+ next(): Promise<{
449
+ done: boolean;
450
+ value: any;
451
+ }>;
452
+ drain(interpret: any): Promise<void>;
453
+ /** End the read (see `ChunkReader.cancel`). */
454
+ cancel(reason: any): any;
455
+ }
500
456
  /**
501
- * Incremental decoder for `createChunk` framing over a byte stream: `next()`
502
- * yields one complete payload string per call (async-iterator result shape),
503
- * buffering partial frames internally until their length prefix is satisfied.
457
+ * The runtime's position for a value-shaped yield: a digest of the value's
458
+ * JSON form, carried as the event's `id:` and echoed back on reconnect so
459
+ * the server can skip re-sending a first emission the client already holds
460
+ * (the data-tier analog of a frame's hole digest). Over `JSON.stringify` of
461
+ * the VALUE, not over the codec record that carries it — a record's
462
+ * reference ids depend on what the stream sent before it, so the same value
463
+ * encodes differently on a fresh connection. `undefined` for a yield that
464
+ * is not JSON-safe: such a yield carries no id and is never skipped.
504
465
  *
505
- * Transport wire detail; not meant for hand-written code.
466
+ * FNV-1a in two 32-bit lanes (a second seed, not a 64-bit arithmetic that
467
+ * JavaScript lacks) → 16 hex characters. Not a security boundary: an equal
468
+ * digest only elides a re-send the client would have discarded as equal.
506
469
  * @internal
507
470
  */
508
- export class ChunkReader {
509
- constructor(stream: ReadableStream<Uint8Array>);
510
- next(): Promise<{ done: boolean; value: string | undefined }>;
511
- }
512
-
471
+ export declare function positionDigest(value: unknown): string | undefined;
513
472
  /**
514
- * The intrinsic wire address of a server-component call: the function id,
515
- * suffixed with a realm-stable hash of the arguments when there are any.
516
- * Both peers derive it independently — the server names flight regions with
517
- * it, the client routes them by it — so it must stay deterministic across
518
- * realms and releases.
519
- *
473
+ * The digest behind `positionDigest`, over a string as-is: the frame tier's
474
+ * hole/fragment digest (RFC 11 §9.5, Hole hashes) — minted by the server
475
+ * over the html it emits, stored by the client per hole, echoed back on a
476
+ * resume as the have-list. Same lanes, same width, same non-goal (a
477
+ * collision elides a re-send, nothing more).
478
+ * @internal
479
+ */
480
+ export declare function textDigest(text: string): string;
481
+ /**
482
+ * Encodes a terminal error-trailer frame payload. The value is expected to
483
+ * be already sanitized by the caller; only `name` and `message` travel.
520
484
  * Transport wire detail; not meant for hand-written code.
521
485
  * @internal
522
486
  */
523
- export function frameAddress(id: string, args?: readonly unknown[]): string;
487
+ export declare function encodeErrorTrailer(error: unknown): string;
488
+ export declare function serializeStream(value: unknown, codecOptions?: JSONCodecOptions): ReadableStream<Uint8Array>;
489
+ export declare function serializeString(value: unknown, codecOptions?: JSONCodecOptions): Promise<string>;
490
+ export declare function deserializeStream<T = unknown>(source: Request | Response, codecOptions?: JSONCodecOptions, wire?: unknown): Promise<T>;
491
+ export declare function deserializeString<T = unknown>(text: string, codecOptions?: JSONCodecOptions): Promise<T>;
492
+ export declare function decodeResponse<T = unknown>(response: Response, codecOptions?: JSONCodecOptions): Promise<T | undefined>;
493
+ export declare function decodeResponsePayload<T = unknown, D = unknown>(response: Response, codecOptions?: JSONCodecOptions): Promise<{
494
+ value: T | undefined;
495
+ flightData?: D;
496
+ }>;