@solidjs/web 2.0.0-beta.31 → 2.0.0-beta.33

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 (73) hide show
  1. package/README.md +1 -6
  2. package/dist/dev.cjs +285 -60
  3. package/dist/dev.js +267 -57
  4. package/dist/server.cjs +1148 -176
  5. package/dist/server.js +1133 -175
  6. package/dist/web.cjs +285 -60
  7. package/dist/web.js +267 -57
  8. package/frames/dist/client.cjs +397 -175
  9. package/frames/dist/client.dev.cjs +401 -175
  10. package/frames/dist/client.dev.js +399 -173
  11. package/frames/dist/client.js +395 -173
  12. package/frames/dist/server.cjs +1424 -277
  13. package/frames/dist/server.js +1426 -280
  14. package/package.json +69 -7
  15. package/serialization/decode/package.json +20 -0
  16. package/serialization/dist/decode.cjs +110 -0
  17. package/serialization/dist/decode.js +104 -0
  18. package/serialization/dist/serialization.cjs +106 -43
  19. package/serialization/dist/serialization.js +100 -44
  20. package/serialization/types/index.d.ts +85 -60
  21. package/serialization/types/serializer-decode.d.ts +182 -0
  22. package/serialization/types-cjs/index.d.cts +85 -60
  23. package/serialization/types-cjs/serializer-decode.d.cts +182 -0
  24. package/server-functions/dist/client.cjs +131 -98
  25. package/server-functions/dist/client.js +131 -99
  26. package/server-functions/dist/rich-args.cjs +11 -0
  27. package/server-functions/dist/rich-args.js +9 -0
  28. package/server-functions/dist/server.cjs +367 -194
  29. package/server-functions/dist/server.dev.cjs +1077 -0
  30. package/server-functions/dist/server.dev.js +1045 -0
  31. package/server-functions/dist/server.js +365 -195
  32. package/server-functions/package.json +10 -0
  33. package/server-functions/rich-args/package.json +20 -0
  34. package/storage/types/index.d.ts +1 -1
  35. package/storage/types-cjs/index.d.cts +1 -1
  36. package/types/client.d.ts +149 -6
  37. package/types/cookies.d.ts +93 -0
  38. package/types/core.d.ts +4 -2
  39. package/types/frames/client.d.ts +15 -1
  40. package/types/frames/frame-client.d.ts +63 -7
  41. package/types/frames/frame-sink.d.ts +26 -3
  42. package/types/frames/frame-transport.d.ts +40 -8
  43. package/types/frames/serializer.d.ts +85 -60
  44. package/types/frames/server.d.ts +22 -0
  45. package/types/index.d.ts +2 -3
  46. package/types/response.d.ts +45 -0
  47. package/types/serializer-decode.d.ts +182 -0
  48. package/types/serializer.d.ts +85 -60
  49. package/types/server-functions/client.d.ts +2 -1
  50. package/types/server-functions/rich-args.d.ts +10 -0
  51. package/types/server-functions/server.d.ts +99 -1
  52. package/types/server-functions/shared.d.ts +79 -1
  53. package/types/server-mock.d.ts +171 -59
  54. package/types/server.d.ts +209 -37
  55. package/types-cjs/client.d.cts +149 -6
  56. package/types-cjs/cookies.d.cts +93 -0
  57. package/types-cjs/core.d.cts +4 -2
  58. package/types-cjs/frames/client.d.cts +15 -1
  59. package/types-cjs/frames/frame-client.d.cts +63 -7
  60. package/types-cjs/frames/frame-sink.d.cts +26 -3
  61. package/types-cjs/frames/frame-transport.d.cts +40 -8
  62. package/types-cjs/frames/serializer.d.cts +85 -60
  63. package/types-cjs/frames/server.d.cts +22 -0
  64. package/types-cjs/index.d.cts +2 -3
  65. package/types-cjs/response.d.cts +45 -0
  66. package/types-cjs/serializer-decode.d.cts +182 -0
  67. package/types-cjs/serializer.d.cts +85 -60
  68. package/types-cjs/server-functions/client.d.cts +2 -1
  69. package/types-cjs/server-functions/rich-args.d.cts +10 -0
  70. package/types-cjs/server-functions/server.d.cts +99 -1
  71. package/types-cjs/server-functions/shared.d.cts +79 -1
  72. package/types-cjs/server-mock.d.cts +171 -59
  73. package/types-cjs/server.d.cts +209 -37
@@ -0,0 +1,93 @@
1
+ // Cookie wire format: the platform-gap primitives, and ALL of core's
2
+ // cookie surface — core owns the exchange (the request's headers in, the
3
+ // response stub's headers out) and the codec, nothing ambient. Blessed
4
+ // patterns:
5
+ //
6
+ // parseCookieHeader(event.request.headers.get("cookie"))
7
+ // event.response.headers.append("set-cookie", serializeCookie(name, value, options))
8
+ //
9
+ // Dependency-free and isomorphic (exported from both entries — real
10
+ // implementation, never a stub); integrity/confidentiality layers
11
+ // (sessions) belong to the caller, on top of these primitives.
12
+
13
+ /**
14
+ * Attributes for a `Set-Cookie` header, mirroring RFC 6265. `path`
15
+ * defaults to `/`; nothing else is defaulted.
16
+ */
17
+ export interface CookieOptions {
18
+ /** Cookie `Path` attribute. Defaults to `/`. */
19
+ path?: string;
20
+ /** Cookie `Domain` attribute. Emitted only when provided. */
21
+ domain?: string;
22
+ /** Cookie `Max-Age` attribute, in seconds (truncated to an integer). */
23
+ maxAge?: number;
24
+ /** Cookie `Expires` attribute. */
25
+ expires?: Date;
26
+ /** Emit the `HttpOnly` attribute. */
27
+ httpOnly?: boolean;
28
+ /** Emit the `Secure` attribute. */
29
+ secure?: boolean;
30
+ /** Cookie `SameSite` attribute, any case. */
31
+ sameSite?: "lax" | "strict" | "none" | "Lax" | "Strict" | "None";
32
+ }
33
+
34
+ /**
35
+ * Parses a `Cookie` request header into a name → value map. Names and
36
+ * values are `decodeURIComponent`-decoded (falling back to the raw text
37
+ * when decoding throws); a quoted value keeps its content. `null`/empty
38
+ * input parses to an empty map.
39
+ *
40
+ * The read half of the platform gap — the blessed request-cookie read is
41
+ * `parseCookieHeader(event.request.headers.get("cookie"))`.
42
+ */
43
+ export function parseCookieHeader(header: string | null | undefined): Record<string, string>;
44
+
45
+ /**
46
+ * Serializes a cookie to a `Set-Cookie` header value. The name and value
47
+ * are `encodeURIComponent`-encoded (the parser decodes symmetrically);
48
+ * `path` defaults to `/` and every other attribute is emitted exactly
49
+ * when the caller asked for it.
50
+ *
51
+ * The write half of the platform gap — the blessed response-cookie write
52
+ * is `event.response.headers.append("set-cookie", serializeCookie(name,
53
+ * value, options))`, which every head materialization path carries to the
54
+ * wire entry-by-entry.
55
+ */
56
+ export function serializeCookie(name: string, value: string, options?: CookieOptions): string;
57
+
58
+ /**
59
+ * Name of the cookie carrying the outcome of a server function call made
60
+ * without the client runtime (`"flash"`). A no-JS form post has no way to
61
+ * receive a value — the browser follows the redirect and renders the next
62
+ * page — so the handler stashes the outcome here for the render after it
63
+ * to pick up, which is how a form submitted without JavaScript still shows
64
+ * its result.
65
+ *
66
+ * The name, detection and clearing are cookie utilities and isomorphic
67
+ * (integrations read the cookie from code that also ships to the browser);
68
+ * the codec that fills and decodes it is server-only and lives behind the
69
+ * server-functions server entry.
70
+ */
71
+ export const FLASH_COOKIE: string;
72
+
73
+ /**
74
+ * Whether a Cookie header carries a flash cookie, readable or not. Cheap
75
+ * enough to call on every render so the clear can be queued before the
76
+ * response headers flush.
77
+ */
78
+ export function hasFlashCookie(cookieHeader: string | null): boolean;
79
+
80
+ /**
81
+ * The `Set-Cookie` value clearing the flash cookie. The outcome is
82
+ * one-shot: append this as soon as the cookie is detected, whether or not
83
+ * it decodes, so a stale outcome cannot resurface on a later request.
84
+ */
85
+ export function clearFlashCookie(): string;
86
+
87
+ /**
88
+ * The raw encoded flash payload out of a Cookie header, if present — the
89
+ * codec's own accessor.
90
+ *
91
+ * @internal
92
+ */
93
+ export function matchFlashCookie(cookieHeader: string | null): string | undefined;
@@ -1,4 +1,6 @@
1
- export { getOwner, runWithOwner, createComponent, createRoot as root, sharedConfig, untrack, merge as mergeProps, flatten, ssrHandleError, ssrScope, NoHydration, Hydration, runInServerComponentScope } from "solid-js";
2
- export declare const effect: (fn: any, effectFn: any, options: any) => void;
1
+ export { getOwner, runWithOwner, createComponent, createRoot as root, sharedConfig, untrack, merge as mergeProps, flatten, ssrHandleError, ssrScope, NoHydration, Hydration, runInServerComponentScope, creationStamp, inServerComponentScope } from "solid-js";
2
+ export declare const effect: (fn: any, effectFn: any, options?: any) => void;
3
3
  export declare const memo: (fn: any) => import("solid-js").SourceAccessor<any>;
4
4
  export declare const runWithHydrationScope: (id: any, fn: any) => unknown;
5
+ export declare const ssrAsyncValue: (value: any) => import("solid-js").SourceAccessor<any>;
6
+ export declare const waitAsset: (promise: any) => void;
@@ -1,7 +1,20 @@
1
1
  export { createFrame, createFrameHost, createFrameElement, FRAME_APPLIED_EVENT } from "./frame-client.cjs";
2
2
  export { FRAME_STREAM_HEADER, applyFrameResponse, isFrameStreamResponse, createServerComponentHandler } from "./frame-transport.cjs";
3
- export { createJSONDataTable } from "./serializer.cjs";
4
3
  export type { Slot } from "./server.cjs";
4
+ /**
5
+ * Client-condition twin of the server face's `asyncArg` (DR-2 value tier):
6
+ * the identity that types an async value crossing the slot border as its
7
+ * settled value. Server component modules are authored in universal code and
8
+ * may resolve under the browser condition at typecheck/bundle time — the
9
+ * call never runs here (the `"use server"` body executes server-side), but
10
+ * the symbol must exist.
11
+ */
12
+ export declare function asyncArg<T>(value: PromiseLike<T> | AsyncIterable<T>): T;
13
+ /**
14
+ * The app-wide shared frame host (created lazily): one chunk router with
15
+ * per-response codec data tables.
16
+ * @experimental
17
+ */
5
18
  export declare function getFrameHost(): any;
6
19
  /**
7
20
  * Installs the server-component transport policy on the server-function
@@ -18,5 +31,6 @@ export declare function getFrameHost(): any;
18
31
  * Call once in the client entry (an explicit call — the package is
19
32
  * `sideEffects: false`, so a bare import would be tree-shaken away);
20
33
  * call again to rebind to a custom host.
34
+ * @experimental
21
35
  */
22
36
  export declare function installServerComponents(host?: any): void;
@@ -6,9 +6,17 @@
6
6
  * inside the boundary are preserved across server updates — the
7
7
  * version is a stale-guard only ("policy A"): newer content morphs in
8
8
  * place, and teardown is `dispose()`, never a version bump.
9
+ *
10
+ * EXPERIMENTAL — the frames/server-components surface ships as an
11
+ * experimental preview, excluded from the 2.0 stability guarantee: API
12
+ * shapes and the wire format may change between prereleases (RFC 11).
13
+ * Every export in this module is `@experimental`.
9
14
  */
10
15
 
11
- /** One transport chunk of a frame stream, addressed by frame `id`. */
16
+ /**
17
+ * One transport chunk of a frame stream, addressed by frame `id`.
18
+ * @experimental
19
+ */
12
20
  export type FrameChunk =
13
21
  | { type: "start"; id: string; version: number }
14
22
  | { type: "html"; id: string; version: number; html: string }
@@ -48,6 +56,7 @@ export type FrameChunk =
48
56
  * Maps a wire chunk onto resident-store record writes. `data` chunks map to
49
57
  * no records — they are response-scoped and the host applies them through
50
58
  * its data hook.
59
+ * @experimental
51
60
  */
52
61
  export function chunkToRecords(chunk: FrameChunk): Record<string, unknown>;
53
62
 
@@ -55,13 +64,17 @@ export function chunkToRecords(chunk: FrameChunk): Record<string, unknown>;
55
64
  * One store write applied to a frame: `r` maps record keys to values
56
65
  * (`chunkToRecords` produces these from wire chunks) and `version` is the
57
66
  * stream stamp — an older version than the frame's current one is ignored.
67
+ * @experimental
58
68
  */
59
69
  export interface FrameWrite {
60
70
  version: number;
61
71
  r: Record<string, unknown>;
62
72
  }
63
73
 
64
- /** Context passed to a slot callback. */
74
+ /**
75
+ * Context passed to a slot callback.
76
+ * @experimental
77
+ */
65
78
  export interface SlotContext {
66
79
  /**
67
80
  * True only for the hydration-attach invocation of an adopted
@@ -117,9 +130,11 @@ export interface SlotContext {
117
130
  * resolved args (primitives literal, `{$ref}` data resolved through the
118
131
  * host, `{$frame}` regions as marker-range fragments). Return nodes to fill
119
132
  * the range, or `undefined` to claim `ctx.existing` untouched.
133
+ * @experimental
120
134
  */
121
135
  export type Slot = (props: Record<string, unknown>, ctx: SlotContext) => Node | Node[] | undefined;
122
136
 
137
+ /** @experimental */
123
138
  export interface Frame {
124
139
  /** Merge a write into the store and flush (morph/reveal/slot sync). */
125
140
  apply(write: FrameWrite): void;
@@ -159,6 +174,7 @@ export interface Frame {
159
174
  * An id may have several frames (the same server component mounted more
160
175
  * than once): chunks fan out to all of them, and a frame registering after
161
176
  * delivery is seeded from a sibling's store.
177
+ * @experimental
162
178
  */
163
179
  export interface FrameHost {
164
180
  register(id: string, frame: Frame): void;
@@ -170,6 +186,10 @@ export interface FrameHost {
170
186
  serialize(value: unknown): { $ref: string };
171
187
  /** `frameId` is the resolving frame's id — route to its stream's table. */
172
188
  resolve(ref: { $ref: string }, frameId?: string): unknown;
189
+ /** See FrameHostOptions.revive. */
190
+ revive?(value: unknown): unknown;
191
+ /** See FrameHostOptions.isContainer. */
192
+ isContainer?(value: unknown): boolean;
173
193
  }
174
194
 
175
195
  /**
@@ -180,10 +200,14 @@ export interface FrameHost {
180
200
  * boundary (nested region frames dispatch too); use it to re-apply
181
201
  * client-owned decorations on server-owned markup (router affordance
182
202
  * reflection, e.g. `aria-current`) without a MutationObserver.
203
+ * @experimental
183
204
  */
184
205
  export const FRAME_APPLIED_EVENT: "frame:applied";
185
206
 
186
- /** Options for `createFrameHost`. */
207
+ /**
208
+ * Options for `createFrameHost`.
209
+ * @experimental
210
+ */
187
211
  export interface FrameHostOptions {
188
212
  /**
189
213
  * Backs `{$ref}` slot args (typically a codec data table's `resolve`).
@@ -199,11 +223,37 @@ export interface FrameHostOptions {
199
223
  * `applyData: c => table.apply(c)` (see `createJSONDataTable`).
200
224
  */
201
225
  applyData?(chunk: Extract<FrameChunk, { type: "data" }>): void;
226
+ /**
227
+ * A lazily-loaded deserializer's load, awaited by the transport before it
228
+ * delivers a `data` chunk — `applyData`/`resolve` can assume the codec is
229
+ * resident once data has arrived. Keeps codec weight out of the eager
230
+ * client graph for responses that never carry serialized data.
231
+ */
232
+ prepareData?(): Promise<unknown>;
233
+ /**
234
+ * Revive protocol markers inside LITERAL slot args (values that are
235
+ * neither `{$ref}` nor `{$frame}`) at arg-resolution time. Document-face
236
+ * container traces ride this way — inline in the record, revived by the
237
+ * integration (`reviveContainerTraces`) into live local containers.
238
+ */
239
+ revive?(value: unknown): unknown;
240
+ /**
241
+ * Whether a resolved arg value is a LIVE CONTAINER (a materialized trace —
242
+ * see `isMaterializedContainer`). The record-dedupe compare must know: a
243
+ * pending container's property reads throw not-ready, so async probes and
244
+ * serialization compares would detonate it. Containers compare by
245
+ * identity only.
246
+ */
247
+ isContainer?(value: unknown): boolean;
202
248
  }
203
249
 
250
+ /** @experimental */
204
251
  export function createFrameHost(options?: FrameHostOptions): FrameHost;
205
252
 
206
- /** Options for `createFrame` / `createFrameElement`. */
253
+ /**
254
+ * Options for `createFrame` / `createFrameElement`.
255
+ * @experimental
256
+ */
207
257
  export interface FrameOptions {
208
258
  /** Register with this host under `id`, receiving routed/buffered chunks. */
209
259
  host?: FrameHost;
@@ -217,7 +267,7 @@ export interface FrameOptions {
217
267
  */
218
268
  adopt?: boolean;
219
269
  /** Called after each apply flush (tests/telemetry). */
220
- onApply?(info: { version: number; reason: "materialize" | "morph" | "reveal" }): void;
270
+ onApply?(info: { version: number; reason: "materialize" | "morph" | "reveal" | "error" }): void;
221
271
  /**
222
272
  * Wraps element-claim sweeps (`a[href]`/`form[action]` in materialized
223
273
  * server content — and only those) so claim consumers register their
@@ -259,12 +309,17 @@ export interface FrameOptions {
259
309
  * so the first apply morphs against it and slots sync immediately (hydration
260
310
  * attach), claiming their server-rendered DOM — a document boot needs no
261
311
  * chunk.
312
+ * @experimental
262
313
  */
263
314
  export function createFrame(boundary: Element, options?: FrameOptions): Frame;
264
315
 
265
- /** The default boundary/region element tag and its id attribute — the DOM
266
- * contract the producer emits at t=0 and the consumer creates/adopts. */
316
+ /**
317
+ * The default boundary/region element tag and its id attribute — the DOM
318
+ * contract the producer emits at t=0 and the consumer creates/adopts.
319
+ * @experimental
320
+ */
267
321
  export const FRAME_TAG: "dx-frame";
322
+ /** @experimental */
268
323
  export const FRAME_ID_ATTR: "data-fid";
269
324
 
270
325
  /**
@@ -274,6 +329,7 @@ export const FRAME_ID_ATTR: "data-fid";
274
329
  * returned `element` in any position — single, array, or fragment — with no
275
330
  * special-casing. One frame per element; lifecycle belongs to the creator via
276
331
  * `dispose()` (register it with your owner's cleanup).
332
+ * @experimental
277
333
  */
278
334
  export function createFrameElement(options: FrameOptions): {
279
335
  readonly element: Element;
@@ -1,6 +1,13 @@
1
+ // EXPERIMENTAL — the frames/server-components surface ships as an
2
+ // experimental preview, excluded from the 2.0 stability guarantee: API
3
+ // shapes and the wire format may change between prereleases (RFC 11).
4
+ // Every export in this module is @experimental.
1
5
  import { FrameChunk } from "./frame-client.cjs";
2
6
 
3
- /** Addresses a frame stream: the boundary id and this response's version. */
7
+ /**
8
+ * Addresses a frame stream: the boundary id and this response's version.
9
+ * @experimental
10
+ */
4
11
  export interface FrameAddress {
5
12
  id: string;
6
13
  version: number;
@@ -12,13 +19,17 @@ export interface FrameAddress {
12
19
  * method emits transport-agnostic chunks; `emit` is the envelope boundary.
13
20
  * @internal Compiler/renderer wiring — use `renderToFrameStream` or
14
21
  * `renderServerComponent` instead.
22
+ * @experimental
15
23
  */
16
24
  export function createFrameSink(
17
25
  emit: (chunk: FrameChunk) => void,
18
26
  frame: FrameAddress
19
27
  ): Record<string, (...args: any[]) => void>;
20
28
 
21
- /** Options shared by the frame producers. */
29
+ /**
30
+ * Options shared by the frame producers.
31
+ * @experimental
32
+ */
22
33
  export interface FrameStreamOptions {
23
34
  /** Boundary address; defaults to `{ id: "", version: 1 }`. */
24
35
  frame?: { id?: string; version?: number };
@@ -26,7 +37,10 @@ export interface FrameStreamOptions {
26
37
  [key: string]: unknown;
27
38
  }
28
39
 
29
- /** A produced frame stream: pipe chunks, or await the collected array. */
40
+ /**
41
+ * A produced frame stream: pipe chunks, or await the collected array.
42
+ * @experimental
43
+ */
30
44
  export interface FrameStream extends PromiseLike<FrameChunk[]> {
31
45
  pipe(writable: { write(chunk: FrameChunk): void; end?(): void }): void;
32
46
  }
@@ -37,6 +51,7 @@ export interface FrameStream extends PromiseLike<FrameChunk[]> {
37
51
  * by a chunk envelope (`start` up front, `complete` at stream end). Data
38
52
  * records default to the keyed JSON codec (decode with
39
53
  * `createJSONDataTable`).
54
+ * @experimental
40
55
  */
41
56
  export function renderToFrameStream(code: () => unknown, options?: FrameStreamOptions): FrameStream;
42
57
 
@@ -57,6 +72,7 @@ export function renderToFrameStream(code: () => unknown, options?: FrameStreamOp
57
72
  *
58
73
  * The props a *client* passes never reach the server — server inputs are the
59
74
  * function's arguments.
75
+ * @experimental
60
76
  */
61
77
  export function renderServerComponent(
62
78
  component: (props: Record<string, any>) => unknown,
@@ -70,6 +86,7 @@ export function renderServerComponent(
70
86
  * the live render context, so it must only be used during the frame's
71
87
  * render.
72
88
  * @internal Exposed for framework bindings composing their own producers.
89
+ * @experimental
73
90
  */
74
91
  export function createSlotProps(
75
92
  sink: ReturnType<typeof createFrameSink>,
@@ -82,6 +99,7 @@ export function createSlotProps(
82
99
  * the client and `X-Content-Raw` so the server-function handler forwards it
83
100
  * untouched. `init` (headers/status, e.g. from a `respond()` envelope)
84
101
  * merges in; the frame tags win on conflict.
102
+ * @experimental
85
103
  */
86
104
  export function serverComponentResponse(
87
105
  component: (props: Record<string, any>) => unknown,
@@ -103,6 +121,7 @@ export function serverComponentResponse(
103
121
  * provideEvent
104
122
  * });
105
123
  * ```
124
+ * @experimental
106
125
  */
107
126
  export function frameTransformResult(event: unknown, result: unknown): unknown;
108
127
 
@@ -115,6 +134,7 @@ export function frameTransformResult(event: unknown, result: unknown): unknown;
115
134
  * positions (the one hydration-time exception), wrapped in the same marker
116
135
  * dialect the chunk producer emits so the adopting client binds slots and
117
136
  * regions onto the server-rendered ranges.
137
+ * @experimental
118
138
  */
119
139
  export function createDocumentSlotProps(
120
140
  clientProps: Record<string, unknown>,
@@ -128,6 +148,7 @@ export function createDocumentSlotProps(
128
148
  * as an inline-renderable server component (frame markers + document
129
149
  * slot props), branded with its function id and the call's wire address.
130
150
  * Non-function results pass through.
151
+ * @experimental
131
152
  */
132
153
  export function frameTransformDirectResult<T>(
133
154
  value: T,
@@ -143,6 +164,7 @@ export function frameTransformDirectResult<T>(
143
164
  * component entries serialized as flight references. Returns `undefined`
144
165
  * when nothing invalidated is markup (the response stays the plain
145
166
  * single-flight envelope).
167
+ * @experimental
146
168
  */
147
169
  export function frameTransformFlightResult(
148
170
  event: unknown,
@@ -167,5 +189,6 @@ export {
167
189
  * self-bootstraps the registry. Kept for integrations still installing it
168
190
  * document-wide; the client upgrades the registry via
169
191
  * `installServerComponents()`.
192
+ * @experimental
170
193
  */
171
194
  export const SERVER_COMPONENT_BOOTSTRAP: string;
@@ -1,5 +1,9 @@
1
+ // EXPERIMENTAL — the frames/server-components surface ships as an
2
+ // experimental preview, excluded from the 2.0 stability guarantee: API
3
+ // shapes and the wire format may change between prereleases (RFC 11).
4
+ // Every export in this module is @experimental.
1
5
  import { FrameChunk, FrameHost } from "./frame-client.cjs";
2
- import { JSONCodecOptions } from "./serializer.cjs";
6
+ import { JSONCodecOptions } from "./serializer-decode.cjs";
3
7
 
4
8
  // Structural mirror of server-functions/shared.js's FlightDataConsumer:
5
9
  // this file may only reference siblings that ship with it when integrations
@@ -11,13 +15,20 @@ type FlightConsumer = (data: unknown, context: { response: Response }) => void |
11
15
  * Header tagging a Response as a frame stream; its value is the producing
12
16
  * frame's id. Frame-owned wire contract — deliberately not a server-function
13
17
  * `BodyFormat` entry, since the body is frame chunks, not a serialized value.
18
+ * @experimental
14
19
  */
15
20
  export const FRAME_STREAM_HEADER: "X-Frame-Stream";
16
21
 
17
- /** Whether a fetch Response carries a frame stream. */
22
+ /**
23
+ * Whether a fetch Response carries a frame stream.
24
+ * @experimental
25
+ */
18
26
  export function isFrameStreamResponse(response: Response): boolean;
19
27
 
20
- /** Options for `applyFrameResponse`. */
28
+ /**
29
+ * Options for `applyFrameResponse`.
30
+ * @experimental
31
+ */
21
32
  export interface ApplyFrameResponseOptions {
22
33
  /**
23
34
  * Remap the producer's root frame id onto a local one — the id your
@@ -57,6 +68,7 @@ export interface ApplyFrameResponseOptions {
57
68
  * await applyFrameResponse(response, host, { as: "story-pane" });
58
69
  * }
59
70
  * ```
71
+ * @experimental
60
72
  */
61
73
  export function applyFrameResponse(
62
74
  response: Response,
@@ -64,13 +76,22 @@ export function applyFrameResponse(
64
76
  options?: ApplyFrameResponseOptions
65
77
  ): Promise<string>;
66
78
 
67
- /** Brands an inline-rendered server component with its function id. */
79
+ /**
80
+ * Brands an inline-rendered server component with its function id.
81
+ * @experimental
82
+ */
68
83
  export const SERVER_COMPONENT: unique symbol;
69
84
 
70
- /** The unwrapped server component behind an inline-render wrap. */
85
+ /**
86
+ * The unwrapped server component behind an inline-render wrap.
87
+ * @experimental
88
+ */
71
89
  export const SERVER_COMPONENT_SOURCE: unique symbol;
72
90
 
73
- /** The call's wire address (`frameAddress`), for regions to be emitted under. */
91
+ /**
92
+ * The call's wire address (`frameAddress`), for regions to be emitted under.
93
+ * @experimental
94
+ */
74
95
  export const SERVER_COMPONENT_ADDRESS: unique symbol;
75
96
 
76
97
  /**
@@ -81,10 +102,14 @@ export const SERVER_COMPONENT_ADDRESS: unique symbol;
81
102
  * instance, new binding" — keep the mounted instance and deliver the new
82
103
  * address into it; a different function swaps normally. `Symbol.for`, so
83
104
  * frameworks can honor it without importing this module.
105
+ * @experimental
84
106
  */
85
107
  export const COMPONENT_BINDING: unique symbol;
86
108
 
87
- /** The value under `COMPONENT_BINDING` on a transport-resolved binding. */
109
+ /**
110
+ * The value under `COMPONENT_BINDING` on a transport-resolved binding.
111
+ * @experimental
112
+ */
88
113
  export interface ComponentBinding<C = unknown> {
89
114
  /** The per-function mount component (the equals-gate identity). */
90
115
  component: C;
@@ -98,6 +123,7 @@ export interface ComponentBinding<C = unknown> {
98
123
  * placeholder in the hydration serializer, a live-registry lookup by call
99
124
  * address in the JSON codec (single-flight envelopes) — its markup never
100
125
  * rides as data.
126
+ * @experimental
101
127
  */
102
128
  export const ServerComponentPlugin: unknown;
103
129
 
@@ -108,6 +134,7 @@ export const ServerComponentPlugin: unknown;
108
134
  * on a script's first reference, a bare read after). Loaded document-SSR
109
135
  * modules install this (see frame-sink); client bundles never carry the
110
136
  * bootstrap text.
137
+ * @experimental
111
138
  */
112
139
  export function setServerComponentBootstrap(resolve: (ctx: unknown) => string): void;
113
140
 
@@ -115,10 +142,14 @@ export function setServerComponentBootstrap(resolve: (ctx: unknown) => string):
115
142
  * The codec options for a single-flight envelope: `codec` plus
116
143
  * `ServerComponentPlugin` (deduped by tag). Injected by the protocol on both
117
144
  * legs; exported for integrations composing their own flight carriers.
145
+ * @experimental
118
146
  */
119
147
  export function flightCodec(codec?: JSONCodecOptions): JSONCodecOptions;
120
148
 
121
- /** Options for `createServerComponentHandler`. */
149
+ /**
150
+ * Options for `createServerComponentHandler`.
151
+ * @experimental
152
+ */
122
153
  export interface ServerComponentHandlerOptions<C = unknown> {
123
154
  host: FrameHost;
124
155
  /**
@@ -170,6 +201,7 @@ export interface ServerComponentHandlerOptions<C = unknown> {
170
201
  * per-args entries — while mounts are per-SITE, rendering the per-function
171
202
  * component and following delivered addresses. An address nothing is bound
172
203
  * to warms its store (preload isolation is the default, not a rule).
204
+ * @experimental
173
205
  */
174
206
  export function createServerComponentHandler<C>(options: ServerComponentHandlerOptions<C>): {
175
207
  intercept?(info: { id: string; meta: unknown; args: unknown[] }): unknown;