@solidjs/web 2.0.0-experimental.8 → 2.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +22 -4
  2. package/dist/dev.cjs +1585 -225
  3. package/dist/dev.js +1510 -201
  4. package/dist/server.cjs +2642 -264
  5. package/dist/server.js +2542 -217
  6. package/dist/web.cjs +1523 -218
  7. package/dist/web.js +1448 -194
  8. package/frames/dist/client.cjs +1916 -0
  9. package/frames/dist/client.dev.cjs +1933 -0
  10. package/frames/dist/client.dev.js +1921 -0
  11. package/frames/dist/client.js +1904 -0
  12. package/frames/dist/server.cjs +3667 -0
  13. package/frames/dist/server.js +3654 -0
  14. package/frames/package.json +30 -0
  15. package/package.json +349 -37
  16. package/serialization/decode/package.json +20 -0
  17. package/serialization/dist/decode.cjs +110 -0
  18. package/serialization/dist/decode.js +104 -0
  19. package/serialization/dist/serialization.cjs +232 -0
  20. package/serialization/dist/serialization.js +215 -0
  21. package/serialization/package.json +20 -0
  22. package/serialization/types/index.d.ts +182 -0
  23. package/serialization/types/serializer-decode.d.ts +182 -0
  24. package/serialization/types-cjs/index.d.cts +182 -0
  25. package/serialization/types-cjs/package.json +3 -0
  26. package/serialization/types-cjs/serializer-decode.d.cts +182 -0
  27. package/server-functions/dist/client.cjs +646 -0
  28. package/server-functions/dist/client.js +617 -0
  29. package/server-functions/dist/rich-args.cjs +11 -0
  30. package/server-functions/dist/rich-args.js +9 -0
  31. package/server-functions/dist/server.cjs +1077 -0
  32. package/server-functions/dist/server.dev.cjs +1077 -0
  33. package/server-functions/dist/server.dev.js +1045 -0
  34. package/server-functions/dist/server.js +1045 -0
  35. package/server-functions/package.json +40 -0
  36. package/server-functions/rich-args/package.json +20 -0
  37. package/storage/package.json +8 -3
  38. package/storage/types/index.d.ts +26 -0
  39. package/storage/types-cjs/index.d.cts +28 -0
  40. package/storage/types-cjs/package.json +3 -0
  41. package/types/client.d.ts +290 -27
  42. package/types/cookies.d.ts +93 -0
  43. package/types/core.d.ts +6 -2
  44. package/types/frames/client.d.ts +36 -0
  45. package/types/frames/frame-client.d.ts +338 -0
  46. package/types/frames/frame-sink.d.ts +194 -0
  47. package/types/frames/frame-transport.d.ts +222 -0
  48. package/types/frames/serializer.d.ts +182 -0
  49. package/types/frames/server.d.ts +52 -0
  50. package/types/index.d.ts +209 -24
  51. package/types/jsx-properties.d.ts +93 -0
  52. package/types/jsx.d.ts +4150 -1
  53. package/types/response.d.ts +174 -0
  54. package/types/serializer-decode.d.ts +182 -0
  55. package/types/serializer.d.ts +182 -0
  56. package/types/server-functions/client.d.ts +201 -0
  57. package/types/server-functions/flash.d.ts +38 -0
  58. package/types/server-functions/rich-args.d.ts +10 -0
  59. package/types/server-functions/server.d.ts +588 -0
  60. package/types/server-functions/shared.d.ts +523 -0
  61. package/types/server-mock.d.ts +249 -12
  62. package/types/server.d.ts +424 -51
  63. package/types-cjs/client.d.cts +337 -0
  64. package/types-cjs/cookies.d.cts +93 -0
  65. package/types-cjs/core.d.cts +6 -0
  66. package/types-cjs/frames/client.d.cts +36 -0
  67. package/types-cjs/frames/frame-client.d.cts +338 -0
  68. package/types-cjs/frames/frame-sink.d.cts +194 -0
  69. package/types-cjs/frames/frame-transport.d.cts +222 -0
  70. package/types-cjs/frames/serializer.d.cts +182 -0
  71. package/types-cjs/frames/server.d.cts +52 -0
  72. package/types-cjs/index.d.cts +230 -0
  73. package/types-cjs/jsx-properties.d.cts +93 -0
  74. package/types-cjs/jsx.d.cts +4150 -0
  75. package/types-cjs/package.json +3 -0
  76. package/types-cjs/response.d.cts +174 -0
  77. package/types-cjs/serializer-decode.d.cts +182 -0
  78. package/types-cjs/serializer.d.cts +182 -0
  79. package/types-cjs/server-functions/client.d.cts +201 -0
  80. package/types-cjs/server-functions/flash.d.cts +38 -0
  81. package/types-cjs/server-functions/rich-args.d.cts +10 -0
  82. package/types-cjs/server-functions/server.d.cts +588 -0
  83. package/types-cjs/server-functions/shared.d.cts +523 -0
  84. package/types-cjs/server-mock.d.cts +277 -0
  85. package/types-cjs/server.d.cts +523 -0
@@ -0,0 +1,523 @@
1
+ import { JSONCodecOptions } from "../serializer-decode.cjs";
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
+ /**
93
+ * The standardized body of a single-flight response (a response tagged with
94
+ * `SINGLE_FLIGHT_HEADER`): the function's return `value` plus the
95
+ * integration-produced `data` payload, folded into one round trip by the
96
+ * HTTP handler. Integrations decoding passthrough responses themselves (no
97
+ * registered consumer) see this shape from `decodeResponse`. The top level
98
+ * is reserved for the protocol — integration payload lives entirely under
99
+ * `data`, which can be any codec-serializable value.
100
+ */
101
+ 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;
106
+ }
107
+
108
+ /**
109
+ * 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.
113
+ */
114
+ export interface FlightDataContext {
115
+ /** The HTTP response the data arrived on (metadata only). */
116
+ response: Response;
117
+ }
118
+
119
+ /**
120
+ * Consumer receiving single-flight data on the client: `data` is the
121
+ * 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
189
+ */
190
+ export function getFlightDataConsumer(): FlightDataConsumer | undefined;
191
+
192
+ /**
193
+ * The public contract of a server function reference — what a `"use
194
+ * server"` import is at runtime on either side: an async callable plus its
195
+ * build-stable identity.
196
+ */
197
+ 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;
203
+ }
204
+
205
+ /**
206
+ * Declaration-static metadata attached to a server function reference
207
+ * through declaration wrappers (`GET`, `withMeta`). Read it with
208
+ * `getServerFunctionMetadata`; routers and integrations detect capability
209
+ * from here instead of property sniffing, and `prepareRequest` receives it
210
+ * as `context.meta`. Write through `withMeta` — later writes shallow-merge
211
+ * over earlier ones.
212
+ */
213
+ 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;
226
+ }
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
+ /**
287
+ * The transport surface integrations consume through the late-bound RPC
288
+ * seam (server-functions/registry.js) — filled by the transport halves when
289
+ * the first server function reference is created (code that only exists in
290
+ * a bundle when a `"use server"` function was actually compiled in), read
291
+ * by routers so they never import the transport/codec statically.
292
+ */
293
+ 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>;
306
+ }
307
+
308
+ /**
309
+ * Fills the RPC seam. Called by the transport halves when the first server
310
+ * function reference is created; first write wins.
311
+ * @internal
312
+ */
313
+ export function provideServerFunctionRPC(rpc: ServerFunctionRPC): void;
314
+
315
+ /**
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).
322
+ * @internal
323
+ */
324
+ export function getServerFunctionRPC(): ServerFunctionRPC | undefined;
325
+
326
+ /**
327
+ * Header carrying the body format tag (a `BodyFormat` value) —
328
+ * `"X-Server-Function-Format"`.
329
+ *
330
+ * Transport wire detail; not meant for hand-written code.
331
+ * @internal
332
+ */
333
+ export const BODY_FORMAT_HEADER: string;
334
+
335
+ /**
336
+ * FormData key used when a lone File is sent as the argument.
337
+ *
338
+ * Transport wire detail; not meant for hand-written code.
339
+ * @internal
340
+ */
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.
348
+ * @internal
349
+ */
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
+
366
+ /**
367
+ * Transport wire detail; not meant for hand-written code.
368
+ * @internal
369
+ */
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.
380
+ */
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.
390
+ * @internal
391
+ */
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.
403
+ * @internal
404
+ */
405
+ export function extractBody(
406
+ source: Request | Response,
407
+ codecOptions?: JSONCodecOptions
408
+ ): Promise<unknown>;
409
+
410
+ /**
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
418
+ */
419
+ export function serializeStream(
420
+ value: unknown,
421
+ codecOptions?: JSONCodecOptions
422
+ ): ReadableStream<Uint8Array>;
423
+
424
+ /**
425
+ * `serializeStream` drained to a string (async values fully awaited).
426
+ *
427
+ * Transport building block; not meant for hand-written code.
428
+ * @internal
429
+ */
430
+ export function serializeString(value: unknown, codecOptions?: JSONCodecOptions): Promise<string>;
431
+
432
+ /**
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.
436
+ *
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
+
445
+ /**
446
+ * `deserializeStream` for an already-buffered string.
447
+ *
448
+ * Transport building block; not meant for hand-written code.
449
+ * @internal
450
+ */
451
+ export function deserializeString<T = unknown>(
452
+ text: string,
453
+ codecOptions?: JSONCodecOptions
454
+ ): Promise<T>;
455
+
456
+ /**
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
468
+ */
469
+ export function decodeResponse<T = unknown>(
470
+ response: Response,
471
+ codecOptions?: JSONCodecOptions
472
+ ): Promise<T | undefined>;
473
+
474
+ /**
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.
483
+ * @internal
484
+ */
485
+ export function decodeResponsePayload<T = unknown, D = unknown>(
486
+ response: Response,
487
+ codecOptions?: JSONCodecOptions
488
+ ): Promise<{ value: T | undefined; flightData?: D }>;
489
+
490
+ /**
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.
494
+ *
495
+ * Transport wire detail; not meant for hand-written code.
496
+ * @internal
497
+ */
498
+ export function createChunk(data: string): Uint8Array;
499
+
500
+ /**
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.
504
+ *
505
+ * Transport wire detail; not meant for hand-written code.
506
+ * @internal
507
+ */
508
+ export class ChunkReader {
509
+ constructor(stream: ReadableStream<Uint8Array>);
510
+ next(): Promise<{ done: boolean; value: string | undefined }>;
511
+ }
512
+
513
+ /**
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
+ *
520
+ * Transport wire detail; not meant for hand-written code.
521
+ * @internal
522
+ */
523
+ export function frameAddress(id: string, args?: readonly unknown[]): string;