@solidjs/web 2.0.0-beta.3 → 2.0.0-beta.30

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 +27 -4
  2. package/dist/dev.cjs +1211 -205
  3. package/dist/dev.js +1175 -199
  4. package/dist/server.cjs +1342 -234
  5. package/dist/server.js +1304 -231
  6. package/dist/web.cjs +1195 -196
  7. package/dist/web.js +1159 -190
  8. package/frames/dist/client.cjs +1746 -0
  9. package/frames/dist/client.dev.cjs +1759 -0
  10. package/frames/dist/client.dev.js +1747 -0
  11. package/frames/dist/client.js +1734 -0
  12. package/frames/dist/server.cjs +2426 -0
  13. package/frames/dist/server.js +2414 -0
  14. package/frames/package.json +30 -0
  15. package/package.json +287 -38
  16. package/serialization/dist/serialization.cjs +169 -0
  17. package/serialization/dist/serialization.js +159 -0
  18. package/serialization/package.json +20 -0
  19. package/serialization/types/index.d.ts +157 -0
  20. package/serialization/types-cjs/index.d.cts +157 -0
  21. package/serialization/types-cjs/package.json +3 -0
  22. package/server-functions/dist/client.cjs +613 -0
  23. package/server-functions/dist/client.js +585 -0
  24. package/server-functions/dist/server.cjs +904 -0
  25. package/server-functions/dist/server.js +875 -0
  26. package/server-functions/package.json +30 -0
  27. package/storage/package.json +8 -3
  28. package/storage/types/index.d.ts +26 -0
  29. package/storage/types-cjs/index.d.cts +28 -0
  30. package/storage/types-cjs/package.json +3 -0
  31. package/types/client.d.ts +125 -21
  32. package/types/core.d.ts +4 -3
  33. package/types/frames/client.d.ts +20 -0
  34. package/types/frames/frame-client.d.ts +270 -0
  35. package/types/frames/frame-sink.d.ts +168 -0
  36. package/types/frames/frame-transport.d.ts +196 -0
  37. package/types/frames/serializer.d.ts +157 -0
  38. package/types/frames/server.d.ts +30 -0
  39. package/types/index.d.ts +211 -26
  40. package/types/jsx-properties.d.ts +93 -0
  41. package/types/jsx.d.ts +4150 -1
  42. package/types/response.d.ts +129 -0
  43. package/types/serializer.d.ts +157 -0
  44. package/types/server-functions/client.d.ts +200 -0
  45. package/types/server-functions/flash.d.ts +38 -0
  46. package/types/server-functions/server.d.ts +490 -0
  47. package/types/server-functions/shared.d.ts +445 -0
  48. package/types/server-mock.d.ts +93 -0
  49. package/types/server.d.ts +221 -28
  50. package/types-cjs/client.d.cts +192 -0
  51. package/types-cjs/core.d.cts +4 -0
  52. package/types-cjs/frames/client.d.cts +20 -0
  53. package/types-cjs/frames/frame-client.d.cts +270 -0
  54. package/types-cjs/frames/frame-sink.d.cts +168 -0
  55. package/types-cjs/frames/frame-transport.d.cts +196 -0
  56. package/types-cjs/frames/serializer.d.cts +157 -0
  57. package/types-cjs/frames/server.d.cts +30 -0
  58. package/types-cjs/index.d.cts +231 -0
  59. package/types-cjs/jsx-properties.d.cts +93 -0
  60. package/types-cjs/jsx.d.cts +4150 -0
  61. package/types-cjs/package.json +3 -0
  62. package/types-cjs/response.d.cts +129 -0
  63. package/types-cjs/serializer.d.cts +157 -0
  64. package/types-cjs/server-functions/client.d.cts +200 -0
  65. package/types-cjs/server-functions/flash.d.cts +38 -0
  66. package/types-cjs/server-functions/server.d.cts +490 -0
  67. package/types-cjs/server-functions/shared.d.cts +445 -0
  68. package/types-cjs/server-mock.d.cts +165 -0
  69. package/types-cjs/server.d.cts +349 -0
  70. package/storage/types/src/client.d.ts +0 -1
  71. package/storage/types/src/index.d.ts +0 -46
  72. package/storage/types/src/server-mock.d.ts +0 -72
  73. package/storage/types/storage/src/index.d.ts +0 -2
@@ -0,0 +1,168 @@
1
+ import { FrameChunk } from "./frame-client.js";
2
+
3
+ /** Addresses a frame stream: the boundary id and this response's version. */
4
+ export interface FrameAddress {
5
+ id: string;
6
+ version: number;
7
+ }
8
+
9
+ /**
10
+ * The emission surface `renderToStream` routes through when producing a
11
+ * frame stream instead of a document (see the `sink` render option). Each
12
+ * method emits transport-agnostic chunks; `emit` is the envelope boundary.
13
+ * @internal Compiler/renderer wiring — use `renderToFrameStream` or
14
+ * `renderServerComponent` instead.
15
+ */
16
+ export function createFrameSink(
17
+ emit: (chunk: FrameChunk) => void,
18
+ frame: FrameAddress
19
+ ): Record<string, (...args: any[]) => void>;
20
+
21
+ /** Options shared by the frame producers. */
22
+ export interface FrameStreamOptions {
23
+ /** Boundary address; defaults to `{ id: "", version: 1 }`. */
24
+ frame?: { id?: string; version?: number };
25
+ /** Remaining `renderToStream` options (plugins, onError, manifest, ...). */
26
+ [key: string]: unknown;
27
+ }
28
+
29
+ /** A produced frame stream: pipe chunks, or await the collected array. */
30
+ export interface FrameStream extends PromiseLike<FrameChunk[]> {
31
+ pipe(writable: { write(chunk: FrameChunk): void; end?(): void }): void;
32
+ }
33
+
34
+ /**
35
+ * Render to a FrameChunk stream: the same render core as `renderToStream`
36
+ * with emission swapped to the frame sink and the document writable replaced
37
+ * by a chunk envelope (`start` up front, `complete` at stream end). Data
38
+ * records default to the keyed JSON codec (decode with
39
+ * `createJSONDataTable`).
40
+ */
41
+ export function renderToFrameStream(code: () => unknown, options?: FrameStreamOptions): FrameStream;
42
+
43
+ /**
44
+ * Render a **server component** — a `props => JSX` function, typically
45
+ * returned from a server function — to a FrameChunk stream. `props` is a
46
+ * slot-props proxy, not data:
47
+ *
48
+ * - reading a prop as a child emits a marker range the client fills;
49
+ * - calling a prop as a render function emits a `slot` chunk for a fresh
50
+ * occurrence (a primitive `$key` arg names it, so client state follows the
51
+ * entity across responses — the slot-level analogue of For's `keyed`
52
+ * function; positional otherwise, which is the right default for most
53
+ * flows);
54
+ * - primitive args ride the chunk; server JSX args stream as nested regions
55
+ * (`{$frame}` — html once, never data); other values serialize as `{$ref}`
56
+ * data records with referential dedupe.
57
+ *
58
+ * The props a *client* passes never reach the server — server inputs are the
59
+ * function's arguments.
60
+ */
61
+ export function renderServerComponent(
62
+ component: (props: Record<string, any>) => unknown,
63
+ options?: FrameStreamOptions
64
+ ): FrameStream;
65
+
66
+ /**
67
+ * The slot props proxy used by `renderServerComponent`. Every key
68
+ * virtually exists (`in` is always true — a prop is a position the client
69
+ * may fill), enumeration is empty by design, and serialization goes through
70
+ * the live render context, so it must only be used during the frame's
71
+ * render.
72
+ * @internal Exposed for framework bindings composing their own producers.
73
+ */
74
+ export function createSlotProps(
75
+ sink: ReturnType<typeof createFrameSink>,
76
+ frame: FrameAddress
77
+ ): Record<string, any>;
78
+
79
+ /**
80
+ * A server component as an HTTP Response: the chunk stream framed with the
81
+ * server-function wire convention, tagged `X-Frame-Stream: <frame id>` for
82
+ * the client and `X-Content-Raw` so the server-function handler forwards it
83
+ * untouched. `init` (headers/status, e.g. from a `respond()` envelope)
84
+ * merges in; the frame tags win on conflict.
85
+ */
86
+ export function serverComponentResponse(
87
+ component: (props: Record<string, any>) => unknown,
88
+ options?: FrameStreamOptions,
89
+ init?: { headers?: HeadersInit; status?: number }
90
+ ): Response;
91
+
92
+ /**
93
+ * The server-component convention as a `transformResult` policy for
94
+ * `handleServerFunctionRequest`: a function result — or a `respond()`
95
+ * envelope whose value is a function — becomes a frame-stream Response,
96
+ * with the frame id defaulting to the server function's id so repeat calls
97
+ * target the same client boundary. Everything else passes through.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * handleServerFunctionRequest(request, {
102
+ * transformResult: frameTransformResult,
103
+ * provideEvent
104
+ * });
105
+ * ```
106
+ */
107
+ export function frameTransformResult(event: unknown, result: unknown): unknown;
108
+
109
+ // === Document SSR (t = 0) ===
110
+
111
+ /**
112
+ * Document-mode slot props — the t = 0 counterpart of
113
+ * `createSlotProps`: the server component renders INLINE in the
114
+ * document and the client's real props render server-side inside its
115
+ * positions (the one hydration-time exception), wrapped in the same marker
116
+ * dialect the chunk producer emits so the adopting client binds slots and
117
+ * regions onto the server-rendered ranges.
118
+ */
119
+ export function createDocumentSlotProps(
120
+ clientProps: Record<string, unknown>,
121
+ frameId: string
122
+ ): Record<string, unknown>;
123
+
124
+ /**
125
+ * The in-process mirror of `frameTransformResult` for DOCUMENT SSR: install
126
+ * as `configureServerFunctionsServer({ transformDirectResult })` and a
127
+ * direct (same-process) server-function result that is a function comes back
128
+ * as an inline-renderable server component (frame markers + document
129
+ * slot props), branded with its function id and the call's wire address.
130
+ * Non-function results pass through.
131
+ */
132
+ export function frameTransformDirectResult<T>(
133
+ value: T,
134
+ options: { id: string; args?: unknown[] }
135
+ ): T;
136
+
137
+ /**
138
+ * The frame half of single-flight, as a `transformFlightResult` policy for
139
+ * `handleServerFunctionRequest`: when part of what a mutation invalidated is
140
+ * markup (a component-valued flight-data entry), the frame stream carries
141
+ * the whole payload — each component's content as a region addressed by its
142
+ * call, the `{ value, data }` envelope as `outcome` chunks with the
143
+ * component entries serialized as flight references. Returns `undefined`
144
+ * when nothing invalidated is markup (the response stays the plain
145
+ * single-flight envelope).
146
+ */
147
+ export function frameTransformFlightResult(
148
+ event: unknown,
149
+ outcome: { value: unknown; data: unknown },
150
+ context?: unknown
151
+ ): Promise<Response | undefined>;
152
+
153
+ // The brands and the codec plugin live with the transport (client bundles
154
+ // resolve flight references against the live registry); re-exported here for
155
+ // server integrations importing the document-SSR surface.
156
+ export {
157
+ SERVER_COMPONENT,
158
+ SERVER_COMPONENT_ADDRESS,
159
+ SERVER_COMPONENT_SOURCE,
160
+ ServerComponentPlugin
161
+ } from "./frame-transport.js";
162
+
163
+ /**
164
+ * Inline bootstrap for the document shell: installs the `self._$SC`
165
+ * placeholder registry the hydration references resolve through; the client
166
+ * upgrades it via `installServerComponents()`.
167
+ */
168
+ export const SERVER_COMPONENT_BOOTSTRAP: string;
@@ -0,0 +1,196 @@
1
+ import { FrameChunk, FrameHost } from "./frame-client.js";
2
+ import { JSONCodecOptions } from "./serializer.js";
3
+
4
+ // Structural mirror of server-functions/shared.js's FlightDataConsumer:
5
+ // this file may only reference siblings that ship with it when integrations
6
+ // copy the frames declaration set (solid-web's types build), and the
7
+ // server-functions declarations are copied to a different root.
8
+ type FlightConsumer = (data: unknown, context: { response: Response }) => void | Promise<void>;
9
+
10
+ /**
11
+ * Header tagging a Response as a frame stream; its value is the producing
12
+ * frame's id. Frame-owned wire contract — deliberately not a server-function
13
+ * `BodyFormat` entry, since the body is frame chunks, not a serialized value.
14
+ */
15
+ export const FRAME_STREAM_HEADER: "X-Frame-Stream";
16
+
17
+ /** Whether a fetch Response carries a frame stream. */
18
+ export function isFrameStreamResponse(response: Response): boolean;
19
+
20
+ /** Options for `applyFrameResponse`. */
21
+ export interface ApplyFrameResponseOptions {
22
+ /**
23
+ * Remap the producer's root frame id onto a local one — the id your
24
+ * insertable/frame registered under — so navigations to the same boundary
25
+ * reuse the same frame regardless of what the server called it. Boundary
26
+ * identity belongs to the client.
27
+ */
28
+ as?: string;
29
+ /**
30
+ * Restamp every chunk of the response with this version (one response IS
31
+ * one version). Versions belong to the client too: the producer cannot
32
+ * know how many streams a boundary has consumed, so pass the Nth-response
33
+ * counter to make policy A's stale-guard real across navigations. A
34
+ * single-flight response addresses several boundaries, each with its own
35
+ * history — pass a function and it is called once per frame in the
36
+ * response.
37
+ */
38
+ version?: number | ((frameId: string) => number);
39
+ /**
40
+ * Remap any frame id other than the response's own root onto a local one
41
+ * — how a consumer resolves the addresses a single-flight response uses
42
+ * for the regions it refreshed.
43
+ */
44
+ route?(id: string): string;
45
+ /**
46
+ * Receives the payload text of each `outcome` chunk — the response-scoped
47
+ * single-flight envelope, the caller's result rather than anything the
48
+ * host renders.
49
+ */
50
+ onOutcome?(payload: string): void;
51
+ }
52
+
53
+ /**
54
+ * Reads a frame-stream Response to completion, applying every chunk to
55
+ * `host`. Chunks are length-prefixed JSON over the server-function wire
56
+ * framing. Resolves with the id the chunks were applied under once the
57
+ * stream ends; rejects on a malformed or errored stream.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const response = await getStory(id); // frame-tagged server function result
62
+ * if (isFrameStreamResponse(response)) {
63
+ * await applyFrameResponse(response, host, { as: "story-pane" });
64
+ * }
65
+ * ```
66
+ */
67
+ export function applyFrameResponse(
68
+ response: Response,
69
+ host: FrameHost,
70
+ options?: ApplyFrameResponseOptions
71
+ ): Promise<string>;
72
+
73
+ /** Brands an inline-rendered server component with its function id. */
74
+ export const SERVER_COMPONENT: unique symbol;
75
+
76
+ /** The unwrapped server component behind an inline-render wrap. */
77
+ export const SERVER_COMPONENT_SOURCE: unique symbol;
78
+
79
+ /** The call's wire address (`frameAddress`), for regions to be emitted under. */
80
+ export const SERVER_COMPONENT_ADDRESS: unique symbol;
81
+
82
+ /**
83
+ * The handoff contract on components the transport resolves: `{ fnId,
84
+ * frameId, take(prev) }`. A reader whose source resolved a NEW component
85
+ * while a previous one is mounted offers the old one — `take` rebinds the
86
+ * live mount when both are boundaries of the same function (the element and
87
+ * its slot state stay; the incoming stream morphs it), and the reader keeps
88
+ * its previous value instead of remounting. `Symbol.for`, so frameworks can
89
+ * honor it without importing this module.
90
+ */
91
+ export const COMPONENT_HANDOFF: unique symbol;
92
+
93
+ /** The value under `COMPONENT_HANDOFF` on a transport-resolved component. */
94
+ export interface ComponentHandoff {
95
+ /** The server function id both peers derive the boundary's calls from. */
96
+ fnId: string;
97
+ /** The frame id this component's fresh mounts register under. */
98
+ frameId: string;
99
+ /**
100
+ * Offer `prev` (the reader's current value) to this component. Returns
101
+ * true when the reader should KEEP prev — the mounted frame was rebound
102
+ * to this component's id (or already showed it); false means swap
103
+ * normally (different function, unbranded prev, or nothing mounted).
104
+ */
105
+ take(prev: unknown): boolean;
106
+ }
107
+
108
+ /**
109
+ * Seroval plugin for a server component crossing a serialization boundary:
110
+ * a branded component serializes as a REFERENCE — a per-function document
111
+ * placeholder in the hydration serializer, a live-registry lookup by call
112
+ * address in the JSON codec (single-flight envelopes) — its markup never
113
+ * rides as data.
114
+ */
115
+ export const ServerComponentPlugin: unknown;
116
+
117
+ /**
118
+ * The codec options for a single-flight envelope: `codec` plus
119
+ * `ServerComponentPlugin` (deduped by tag). Injected by the protocol on both
120
+ * legs; exported for integrations composing their own flight carriers.
121
+ */
122
+ export function flightCodec(codec?: JSONCodecOptions): JSONCodecOptions;
123
+
124
+ /** Options for `createServerComponentHandler`. */
125
+ export interface ServerComponentHandlerOptions<C = unknown> {
126
+ host: FrameHost;
127
+ /**
128
+ * Builds the framework's mountable component for a boundary. Invoked once
129
+ * per boundary and cached; every mount of the returned component is its
130
+ * own frame instance under the boundary id (multi-mount fans out).
131
+ */
132
+ component(frameId: string): C;
133
+ /**
134
+ * A new response is about to stream into a boundary: rotate
135
+ * response-scoped state (codec data tables) here. `version` is the
136
+ * client-owned stream counter the chunks will be stamped with.
137
+ */
138
+ onStream?(frameId: string, version: number, response: Response): void;
139
+ /**
140
+ * Document-SSR adoption: given a boundary id the page already carries
141
+ * (server-rendered between `frame:<id>` markers), return the component
142
+ * that adopts that range — or `undefined` to stream normally. Consulted
143
+ * once per boundary, before any fetch.
144
+ */
145
+ documentComponent?(frameId: string): C | undefined;
146
+ /**
147
+ * Answer a call SYNCHRONOUSLY before any request is made (t = 0 local
148
+ * answers — e.g. a boundary the document already carries). Returning a
149
+ * non-undefined value resolves the call with it; a hydrating consumer
150
+ * never observes a pending beat.
151
+ */
152
+ intercept?(info: { id: string; meta: unknown; args: unknown[] }): C | undefined;
153
+ /**
154
+ * Reads the registered single-flight consumer at delivery time. The
155
+ * consumer is module state in the server-function client's SHARED
156
+ * instance; pass a getter reading that instance when your bundling gives
157
+ * this module a private copy. Defaults to the local copy's reader.
158
+ */
159
+ consumer?(): FlightConsumer | undefined;
160
+ /**
161
+ * Reads the configured codec options at decode time — same instance-
162
+ * identity contract as `consumer`. Defaults to the local copy's reader.
163
+ */
164
+ codec?(): JSONCodecOptions | undefined;
165
+ }
166
+
167
+ /**
168
+ * The client mirror of `frameTransformResult`, shaped for the server-function
169
+ * client's `responseHandler` seam: frame-stream responses resolve the call
170
+ * with a **stable component** instead of data, so an equals-gated consumer
171
+ * (Solid's `dynamic`) never remounts across refetches — the response streams
172
+ * into the boundary underneath as the only observable effect.
173
+ *
174
+ * Boundary identity is derived, never declared: every call keys by its
175
+ * intrinsic (function, arguments) address — the query cache's per-args rule,
176
+ * so cached components and boundaries stay one-to-one. Same-args calls
177
+ * resolve the identical component and morph in place; an args switch swaps
178
+ * boundaries, re-materialized from the host's retained state.
179
+ */
180
+ export function createServerComponentHandler<C>(options: ServerComponentHandlerOptions<C>): {
181
+ intercept?(info: { id: string; meta: unknown; args: unknown[] }): C | undefined;
182
+ handle(
183
+ response: Response,
184
+ ctx: { id: string; meta: unknown; args: unknown[]; context: unknown }
185
+ ): C | undefined;
186
+ /**
187
+ * Declares that the document is showing a call: hydration-data references
188
+ * carry their call's address (`_$SC.r(id, address)`) but never travel
189
+ * through the transport, so the integration forwards those records here —
190
+ * they are how a post-load call for the same (function, arguments) finds
191
+ * its way back to the adopted boundary. `component` must be the exact
192
+ * reference the integration's cache holds for the call (the per-function
193
+ * placeholder), or readers' equals-gates fail into remounts.
194
+ */
195
+ showing(address: string, functionId: string, component: C): void;
196
+ };
@@ -0,0 +1,157 @@
1
+ import { Plugin, Serializer, SerovalNode } from "seroval";
2
+
3
+ /**
4
+ * Seroval's node shape — the intermediate representation `serializeJSON`
5
+ * emits and `createJSONDeserializer` consumes. Safe to `JSON.stringify`.
6
+ */
7
+ export type { SerovalNode };
8
+
9
+ /**
10
+ * A Seroval plugin usable with the web serializers — teaches the codec how
11
+ * to encode/decode a custom value type. Supply matching plugins on both
12
+ * peers of a transport.
13
+ */
14
+ export type SerializerPlugin = Plugin<any, any>;
15
+
16
+ /**
17
+ * Baseline plugin set for serializing web-platform values (AbortSignal,
18
+ * Event, FormData, Headers, ReadableStream, Request, Response, URL, ...).
19
+ * Applied by every serializer in this module; custom plugins compose ahead
20
+ * of it via `resolveSerializerPlugins`.
21
+ */
22
+ export const DEFAULT_WEB_PLUGINS: readonly SerializerPlugin[];
23
+
24
+ /**
25
+ * Composes custom plugins with `DEFAULT_WEB_PLUGINS`. Custom plugins come
26
+ * first so they can shadow a default for values both would match. Returns a
27
+ * fresh array; the defaults are never mutated. Useful when handing a full
28
+ * plugin list to another serialization layer.
29
+ */
30
+ export function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
31
+
32
+ /** Options for `createSerializer`. */
33
+ export interface WebSerializerOptions {
34
+ /** Name of the global object the emitted scripts write resolved values into. */
35
+ globalIdentifier: string;
36
+ /** Cross-reference scope id, for isolating multiple streams on one page. */
37
+ scopeId?: string;
38
+ /**
39
+ * Seroval feature bitflags to exclude from output. Defaults to disabling
40
+ * post-ES2017 features (AggregateError, BigInt typed arrays). Outside
41
+ * development, `Error.prototype.stack` is additionally stripped on top of
42
+ * any override — serialized stacks leak server paths to the client.
43
+ */
44
+ disabledFeatures?: number;
45
+ /** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. */
46
+ plugins?: SerializerPlugin[];
47
+ /** Receives each emitted script chunk. */
48
+ onData: (result: string) => void;
49
+ onError?: (error: unknown) => void;
50
+ /** Fires once all async values have settled. */
51
+ onDone?: () => void;
52
+ }
53
+
54
+ /**
55
+ * Creates a streaming Seroval serializer preconfigured with the web plugin
56
+ * set and the default feature policy. Emits JavaScript chunks (through
57
+ * `onData`) that reconstruct the values under `globalIdentifier` when
58
+ * evaluated — the script-injection form of serialization renderers build
59
+ * on. For a JSON-based wire codec (no eval on the receiving side), use
60
+ * `serializeJSON` / `createJSONDeserializer` instead.
61
+ */
62
+ export function createSerializer(options: WebSerializerOptions): Serializer;
63
+
64
+ /**
65
+ * Options for `createHydrationSerializer` — `WebSerializerOptions` minus
66
+ * the knobs hydration pins (`globalIdentifier`, `disabledFeatures`).
67
+ * @internal
68
+ */
69
+ export type HydrationSerializerOptions = Omit<
70
+ WebSerializerOptions,
71
+ "globalIdentifier" | "disabledFeatures"
72
+ >;
73
+
74
+ /**
75
+ * Renderer primitive — the serializer SSR uses for hydration output. Pins
76
+ * the hydration global (`_$HY.r`) and feature policy; only the wiring
77
+ * options (callbacks, scope, extra plugins) are configurable. Not meant
78
+ * for hand-written code — custom serialization should use
79
+ * `createSerializer` or the JSON codec.
80
+ * @internal
81
+ */
82
+ export function createHydrationSerializer(options: HydrationSerializerOptions): Serializer;
83
+
84
+ /**
85
+ * Renderer primitive — returns the cross-reference bootstrap script SSR
86
+ * emits ahead of hydration data for a render scope. Not meant for
87
+ * hand-written code.
88
+ * @internal
89
+ */
90
+ export function getLocalHeaderScript(id?: string): string;
91
+
92
+ // ---- JSON codec (server function transports) ----
93
+
94
+ /**
95
+ * Options shared by both halves of the JSON codec. All of them must match
96
+ * on the serializing and deserializing peer or payloads will not
97
+ * round-trip — for server functions, set them once through the
98
+ * client/server `codec` config option.
99
+ */
100
+ export interface JSONCodecOptions {
101
+ /** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. Must match on both peers. */
102
+ plugins?: SerializerPlugin[];
103
+ /**
104
+ * Seroval feature bitflags to exclude. Defaults to disabling `RegExp`
105
+ * (payloads may come from an untrusted peer). Must match on both peers.
106
+ * Outside development, the encoding side additionally strips
107
+ * `Error.prototype.stack` on top of any override — serialized stacks leak
108
+ * server paths to the client. Decoding stays permissive, so payloads from
109
+ * a development peer still round-trip.
110
+ */
111
+ disabledFeatures?: number;
112
+ /** Maximum parse/deserialize depth. Defaults to 64. Must match on both peers. */
113
+ depthLimit?: number;
114
+ }
115
+
116
+ /** Options for `serializeJSON`. */
117
+ export interface JSONSerializeOptions extends JSONCodecOptions {
118
+ /**
119
+ * Receives each serialized node; `initial` is true for the first chunk
120
+ * (the source value itself). Async values produce additional chunks as
121
+ * they resolve.
122
+ */
123
+ onParse: (node: SerovalNode, initial: boolean) => void;
124
+ onError?: (error: unknown) => void;
125
+ /** Fires once all async values have settled. */
126
+ onDone?: () => void;
127
+ }
128
+
129
+ /**
130
+ * Serializes `value` as SerovalNode chunks delivered through `onParse` —
131
+ * the encoding half of the eval-free JSON codec (RPC-style transports;
132
+ * the deserializing peer needs no script evaluation, so CSP-safe). Wire
133
+ * framing of the nodes is the transport's concern. Returns a cancel
134
+ * function that aborts pending async serialization.
135
+ */
136
+ export function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
137
+
138
+ /**
139
+ * Creates the decoding counterpart of `serializeJSON`. Cross-references
140
+ * between chunks resolve through state shared across calls, so all chunks
141
+ * from one stream must go through the same deserializer instance. The first
142
+ * chunk's return value is the decoded source value; feeding later chunks
143
+ * settles the async values referenced inside it.
144
+ */
145
+ export function createJSONDeserializer(options?: JSONCodecOptions): <T>(node: SerovalNode) => T;
146
+
147
+ /**
148
+ * A resident, response-scoped decode table over the keyed JSON codec: apply
149
+ * each frame `data` chunk with `apply`, resolve `{ $ref }` slot args with
150
+ * `resolve`. The frames client host wires one per response
151
+ * (`applyData: c => table.apply(c)`).
152
+ */
153
+ export interface JSONDataTable {
154
+ apply(chunk: { key?: string; node?: unknown; initial?: boolean }): void;
155
+ resolve<T = unknown>(ref: { $ref: string }): T;
156
+ }
157
+ export function createJSONDataTable(options?: JSONCodecOptions): JSONDataTable;
@@ -0,0 +1,30 @@
1
+ import type { Element as SolidElement } from "solid-js";
2
+ /**
3
+ * A client position in a server component: a prop the server renders (as JSX
4
+ * or by calling it) where client-owned markup belongs. `P` is the client
5
+ * component's own props, so a server component can reference the client
6
+ * component's type directly instead of restating it.
7
+ *
8
+ * Arguments are classified by VALUE, not by name — any prop may carry any of
9
+ * these:
10
+ *
11
+ * - primitives ride the chunk;
12
+ * - server JSX streams as a nested region (html once, never data);
13
+ * - anything else serializes as a data record.
14
+ *
15
+ * Async server JSX in an argument needs its own boundary: the region is
16
+ * emitted as one finished string, so a bare async read has no fallback to
17
+ * show and no fragment to reveal into.
18
+ *
19
+ * `$key` names the occurrence so client state follows an entity across
20
+ * responses rather than being positional — the slot-level analogue of `For`'s
21
+ * `keyed`, for when references can't carry identity because every response
22
+ * re-creates everything. It is occurrence identity, not client data: it is
23
+ * stripped before the client component sees its props. Positional identity is
24
+ * the right default; `$key` matters when a live list reorders.
25
+ */
26
+ export type Slot<P = {}> = (props: P & {
27
+ $key?: string | number;
28
+ }) => SolidElement;
29
+ export { renderToFrameStream, renderServerComponent, serverComponentResponse, frameTransformResult, frameTransformFlightResult, createFrameSink, frameTransformDirectResult, ServerComponentPlugin, SERVER_COMPONENT_BOOTSTRAP } from "./frame-sink.js";
30
+ export { FRAME_STREAM_HEADER, isFrameStreamResponse } from "./frame-transport.js";