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

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 +1224 -205
  3. package/dist/dev.js +1188 -199
  4. package/dist/server.cjs +1429 -234
  5. package/dist/server.js +1391 -231
  6. package/dist/web.cjs +1207 -195
  7. package/dist/web.js +1171 -189
  8. package/frames/dist/client.cjs +1694 -0
  9. package/frames/dist/client.dev.cjs +1707 -0
  10. package/frames/dist/client.dev.js +1695 -0
  11. package/frames/dist/client.js +1682 -0
  12. package/frames/dist/server.cjs +2520 -0
  13. package/frames/dist/server.js +2508 -0
  14. package/frames/package.json +30 -0
  15. package/package.json +285 -37
  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 +127 -21
  32. package/types/core.d.ts +4 -3
  33. package/types/frames/client.d.ts +22 -0
  34. package/types/frames/frame-client.d.ts +282 -0
  35. package/types/frames/frame-sink.d.ts +171 -0
  36. package/types/frames/frame-transport.d.ts +190 -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 +223 -28
  50. package/types-cjs/client.d.cts +194 -0
  51. package/types-cjs/core.d.cts +4 -0
  52. package/types-cjs/frames/client.d.cts +22 -0
  53. package/types-cjs/frames/frame-client.d.cts +282 -0
  54. package/types-cjs/frames/frame-sink.d.cts +171 -0
  55. package/types-cjs/frames/frame-transport.d.cts +190 -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 +351 -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,171 @@
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
+ * Statement form of the `self._$SC` placeholder-registry bootstrap
165
+ * (idempotent — first definition wins). No longer required in the document
166
+ * shell: each hydration script's first serialized server-component reference
167
+ * self-bootstraps the registry. Kept for integrations still installing it
168
+ * document-wide; the client upgrades the registry via
169
+ * `installServerComponents()`.
170
+ */
171
+ export const SERVER_COMPONENT_BOOTSTRAP: string;
@@ -0,0 +1,190 @@
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
+ * Receives the payload text of each `outcome` chunk — the response-scoped
41
+ * single-flight envelope, the caller's result rather than anything the
42
+ * host renders.
43
+ */
44
+ onOutcome?(payload: string): void;
45
+ }
46
+
47
+ /**
48
+ * Reads a frame-stream Response to completion, applying every chunk to
49
+ * `host`. Chunks are length-prefixed JSON over the server-function wire
50
+ * framing. Resolves with the id the chunks were applied under once the
51
+ * stream ends; rejects on a malformed or errored stream.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const response = await getStory(id); // frame-tagged server function result
56
+ * if (isFrameStreamResponse(response)) {
57
+ * await applyFrameResponse(response, host, { as: "story-pane" });
58
+ * }
59
+ * ```
60
+ */
61
+ export function applyFrameResponse(
62
+ response: Response,
63
+ host: FrameHost,
64
+ options?: ApplyFrameResponseOptions
65
+ ): Promise<string>;
66
+
67
+ /** Brands an inline-rendered server component with its function id. */
68
+ export const SERVER_COMPONENT: unique symbol;
69
+
70
+ /** The unwrapped server component behind an inline-render wrap. */
71
+ export const SERVER_COMPONENT_SOURCE: unique symbol;
72
+
73
+ /** The call's wire address (`frameAddress`), for regions to be emitted under. */
74
+ export const SERVER_COMPONENT_ADDRESS: unique symbol;
75
+
76
+ /**
77
+ * The binding brand on values the transport resolves: `{ component, address }`
78
+ * — the identity split (DR-1). `component` is the mount identity, one per
79
+ * server function; `address` names the call's content store. An equals-gated
80
+ * reader compares `component` across resolutions: same function means "same
81
+ * instance, new binding" — keep the mounted instance and deliver the new
82
+ * address into it; a different function swaps normally. `Symbol.for`, so
83
+ * frameworks can honor it without importing this module.
84
+ */
85
+ export const COMPONENT_BINDING: unique symbol;
86
+
87
+ /** The value under `COMPONENT_BINDING` on a transport-resolved binding. */
88
+ export interface ComponentBinding<C = unknown> {
89
+ /** The per-function mount component (the equals-gate identity). */
90
+ component: C;
91
+ /** The call's intrinsic (function, arguments) address — its store's key. */
92
+ address: string;
93
+ }
94
+
95
+ /**
96
+ * Seroval plugin for a server component crossing a serialization boundary:
97
+ * a branded component serializes as a REFERENCE — a per-function document
98
+ * placeholder in the hydration serializer, a live-registry lookup by call
99
+ * address in the JSON codec (single-flight envelopes) — its markup never
100
+ * rides as data.
101
+ */
102
+ export const ServerComponentPlugin: unknown;
103
+
104
+ /**
105
+ * Installs the hydration-serializer registry prefix: given the emitted
106
+ * script's serializer context, returns the expression the next serialized
107
+ * reference reads the `_$SC` registry through (the self-bootstrapping form
108
+ * on a script's first reference, a bare read after). Loaded document-SSR
109
+ * modules install this (see frame-sink); client bundles never carry the
110
+ * bootstrap text.
111
+ */
112
+ export function setServerComponentBootstrap(resolve: (ctx: unknown) => string): void;
113
+
114
+ /**
115
+ * The codec options for a single-flight envelope: `codec` plus
116
+ * `ServerComponentPlugin` (deduped by tag). Injected by the protocol on both
117
+ * legs; exported for integrations composing their own flight carriers.
118
+ */
119
+ export function flightCodec(codec?: JSONCodecOptions): JSONCodecOptions;
120
+
121
+ /** Options for `createServerComponentHandler`. */
122
+ export interface ServerComponentHandlerOptions<C = unknown> {
123
+ host: FrameHost;
124
+ /**
125
+ * Builds the framework's mount component for a server FUNCTION. Invoked
126
+ * once per function and cached — this is the equals-gate identity every
127
+ * call of the function resolves through. The component is CALLED (by the
128
+ * binding wrapper or a gated reader), receiving its current address as a
129
+ * second argument (`() => string`); it should (re-)bind its frame's pull
130
+ * to that address's store. Multi-mount fans out per site.
131
+ */
132
+ component(fnId: string): C;
133
+ /**
134
+ * A new response is about to stream into an address: 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?(address: string, version: number, response: Response): void;
139
+ /**
140
+ * Answer a call SYNCHRONOUSLY before any request is made (t = 0 local
141
+ * answers — e.g. a boundary the document already carries). Returning a
142
+ * non-undefined value resolves the call with it; a hydrating consumer
143
+ * never observes a pending beat.
144
+ */
145
+ intercept?(info: { id: string; meta: unknown; args: unknown[] }): C | undefined;
146
+ /**
147
+ * Reads the registered single-flight consumer at delivery time. The
148
+ * consumer is module state in the server-function client's SHARED
149
+ * instance; pass a getter reading that instance when your bundling gives
150
+ * this module a private copy. Defaults to the local copy's reader.
151
+ */
152
+ consumer?(): FlightConsumer | undefined;
153
+ /**
154
+ * Reads the configured codec options at decode time — same instance-
155
+ * identity contract as `consumer`. Defaults to the local copy's reader.
156
+ */
157
+ codec?(): JSONCodecOptions | undefined;
158
+ }
159
+
160
+ /**
161
+ * The client mirror of `frameTransformResult`, shaped for the server-function
162
+ * client's `responseHandler` seam: frame-stream responses resolve the call
163
+ * with a **binding** — a callable wrapper branded `COMPONENT_BINDING` — so
164
+ * an equals-gated consumer (Solid's `dynamic`) never remounts across
165
+ * refetches or argument changes; the response streams into the address's
166
+ * resident store as the only observable effect.
167
+ *
168
+ * The identity split (DR-1): stores are keyed per-ADDRESS — the call's
169
+ * intrinsic (function, arguments) name, one-to-one with a query cache's
170
+ * per-args entries — while mounts are per-SITE, rendering the per-function
171
+ * component and following delivered addresses. An address nothing is bound
172
+ * to warms its store (preload isolation is the default, not a rule).
173
+ */
174
+ export function createServerComponentHandler<C>(options: ServerComponentHandlerOptions<C>): {
175
+ intercept?(info: { id: string; meta: unknown; args: unknown[] }): unknown;
176
+ handle(
177
+ response: Response,
178
+ ctx: { id: string; meta: unknown; args: unknown[]; context: unknown }
179
+ ): unknown;
180
+ /**
181
+ * Declares that the document is showing a call: hydration-data references
182
+ * carry their call's address (`_$SC.r(id, address)`) but never travel
183
+ * through the transport, so the integration forwards those records here.
184
+ * Mints the call's binding (a post-load refetch then resolves a value
185
+ * whose component matches what the document mounted) and brands the
186
+ * per-function component so cache-seeded readers deliver instead of
187
+ * remounting when their site later switches calls.
188
+ */
189
+ showing(address: string, functionId: string): void;
190
+ };
@@ -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";