@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.
- package/README.md +22 -4
- package/dist/dev.cjs +1585 -225
- package/dist/dev.js +1510 -201
- package/dist/server.cjs +2642 -264
- package/dist/server.js +2542 -217
- package/dist/web.cjs +1523 -218
- package/dist/web.js +1448 -194
- package/frames/dist/client.cjs +1916 -0
- package/frames/dist/client.dev.cjs +1933 -0
- package/frames/dist/client.dev.js +1921 -0
- package/frames/dist/client.js +1904 -0
- package/frames/dist/server.cjs +3667 -0
- package/frames/dist/server.js +3654 -0
- package/frames/package.json +30 -0
- package/package.json +349 -37
- package/serialization/decode/package.json +20 -0
- package/serialization/dist/decode.cjs +110 -0
- package/serialization/dist/decode.js +104 -0
- package/serialization/dist/serialization.cjs +232 -0
- package/serialization/dist/serialization.js +215 -0
- package/serialization/package.json +20 -0
- package/serialization/types/index.d.ts +182 -0
- package/serialization/types/serializer-decode.d.ts +182 -0
- package/serialization/types-cjs/index.d.cts +182 -0
- package/serialization/types-cjs/package.json +3 -0
- package/serialization/types-cjs/serializer-decode.d.cts +182 -0
- package/server-functions/dist/client.cjs +646 -0
- package/server-functions/dist/client.js +617 -0
- package/server-functions/dist/rich-args.cjs +11 -0
- package/server-functions/dist/rich-args.js +9 -0
- package/server-functions/dist/server.cjs +1077 -0
- package/server-functions/dist/server.dev.cjs +1077 -0
- package/server-functions/dist/server.dev.js +1045 -0
- package/server-functions/dist/server.js +1045 -0
- package/server-functions/package.json +40 -0
- package/server-functions/rich-args/package.json +20 -0
- package/storage/package.json +8 -3
- package/storage/types/index.d.ts +26 -0
- package/storage/types-cjs/index.d.cts +28 -0
- package/storage/types-cjs/package.json +3 -0
- package/types/client.d.ts +290 -27
- package/types/cookies.d.ts +93 -0
- package/types/core.d.ts +6 -2
- package/types/frames/client.d.ts +36 -0
- package/types/frames/frame-client.d.ts +338 -0
- package/types/frames/frame-sink.d.ts +194 -0
- package/types/frames/frame-transport.d.ts +222 -0
- package/types/frames/serializer.d.ts +182 -0
- package/types/frames/server.d.ts +52 -0
- package/types/index.d.ts +209 -24
- package/types/jsx-properties.d.ts +93 -0
- package/types/jsx.d.ts +4150 -1
- package/types/response.d.ts +174 -0
- package/types/serializer-decode.d.ts +182 -0
- package/types/serializer.d.ts +182 -0
- package/types/server-functions/client.d.ts +201 -0
- package/types/server-functions/flash.d.ts +38 -0
- package/types/server-functions/rich-args.d.ts +10 -0
- package/types/server-functions/server.d.ts +588 -0
- package/types/server-functions/shared.d.ts +523 -0
- package/types/server-mock.d.ts +249 -12
- package/types/server.d.ts +424 -51
- package/types-cjs/client.d.cts +337 -0
- package/types-cjs/cookies.d.cts +93 -0
- package/types-cjs/core.d.cts +6 -0
- package/types-cjs/frames/client.d.cts +36 -0
- package/types-cjs/frames/frame-client.d.cts +338 -0
- package/types-cjs/frames/frame-sink.d.cts +194 -0
- package/types-cjs/frames/frame-transport.d.cts +222 -0
- package/types-cjs/frames/serializer.d.cts +182 -0
- package/types-cjs/frames/server.d.cts +52 -0
- package/types-cjs/index.d.cts +230 -0
- package/types-cjs/jsx-properties.d.cts +93 -0
- package/types-cjs/jsx.d.cts +4150 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/response.d.cts +174 -0
- package/types-cjs/serializer-decode.d.cts +182 -0
- package/types-cjs/serializer.d.cts +182 -0
- package/types-cjs/server-functions/client.d.cts +201 -0
- package/types-cjs/server-functions/flash.d.cts +38 -0
- package/types-cjs/server-functions/rich-args.d.cts +10 -0
- package/types-cjs/server-functions/server.d.cts +588 -0
- package/types-cjs/server-functions/shared.d.cts +523 -0
- package/types-cjs/server-mock.d.cts +277 -0
- package/types-cjs/server.d.cts +523 -0
|
@@ -0,0 +1,222 @@
|
|
|
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.
|
|
5
|
+
import { FrameChunk, FrameHost } from "./frame-client.js";
|
|
6
|
+
import { JSONCodecOptions } from "./serializer-decode.js";
|
|
7
|
+
|
|
8
|
+
// Structural mirror of server-functions/shared.js's FlightDataConsumer:
|
|
9
|
+
// this file may only reference siblings that ship with it when integrations
|
|
10
|
+
// copy the frames declaration set (solid-web's types build), and the
|
|
11
|
+
// server-functions declarations are copied to a different root.
|
|
12
|
+
type FlightConsumer = (data: unknown, context: { response: Response }) => void | Promise<void>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Header tagging a Response as a frame stream; its value is the producing
|
|
16
|
+
* frame's id. Frame-owned wire contract — deliberately not a server-function
|
|
17
|
+
* `BodyFormat` entry, since the body is frame chunks, not a serialized value.
|
|
18
|
+
* @experimental
|
|
19
|
+
*/
|
|
20
|
+
export const FRAME_STREAM_HEADER: "X-Frame-Stream";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Whether a fetch Response carries a frame stream.
|
|
24
|
+
* @experimental
|
|
25
|
+
*/
|
|
26
|
+
export function isFrameStreamResponse(response: Response): boolean;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Options for `applyFrameResponse`.
|
|
30
|
+
* @experimental
|
|
31
|
+
*/
|
|
32
|
+
export interface ApplyFrameResponseOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Remap the producer's root frame id onto a local one — the id your
|
|
35
|
+
* insertable/frame registered under — so navigations to the same boundary
|
|
36
|
+
* reuse the same frame regardless of what the server called it. Boundary
|
|
37
|
+
* identity belongs to the client.
|
|
38
|
+
*/
|
|
39
|
+
as?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Restamp every chunk of the response with this version (one response IS
|
|
42
|
+
* one version). Versions belong to the client too: the producer cannot
|
|
43
|
+
* know how many streams a boundary has consumed, so pass the Nth-response
|
|
44
|
+
* counter to make policy A's stale-guard real across navigations. A
|
|
45
|
+
* single-flight response addresses several boundaries, each with its own
|
|
46
|
+
* history — pass a function and it is called once per frame in the
|
|
47
|
+
* response.
|
|
48
|
+
*/
|
|
49
|
+
version?: number | ((frameId: string) => number);
|
|
50
|
+
/**
|
|
51
|
+
* Receives the payload text of each `outcome` chunk — the response-scoped
|
|
52
|
+
* single-flight envelope, the caller's result rather than anything the
|
|
53
|
+
* host renders.
|
|
54
|
+
*/
|
|
55
|
+
onOutcome?(payload: string): void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Reads a frame-stream Response to completion, applying every chunk to
|
|
60
|
+
* `host`. Chunks are length-prefixed JSON over the server-function wire
|
|
61
|
+
* framing. Resolves with the id the chunks were applied under once the
|
|
62
|
+
* stream ends; rejects on a malformed or errored stream.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const response = await getStory(id); // frame-tagged server function result
|
|
67
|
+
* if (isFrameStreamResponse(response)) {
|
|
68
|
+
* await applyFrameResponse(response, host, { as: "story-pane" });
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
* @experimental
|
|
72
|
+
*/
|
|
73
|
+
export function applyFrameResponse(
|
|
74
|
+
response: Response,
|
|
75
|
+
host: FrameHost,
|
|
76
|
+
options?: ApplyFrameResponseOptions
|
|
77
|
+
): Promise<string>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Brands an inline-rendered server component with its function id.
|
|
81
|
+
* @experimental
|
|
82
|
+
*/
|
|
83
|
+
export const SERVER_COMPONENT: unique symbol;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The unwrapped server component behind an inline-render wrap.
|
|
87
|
+
* @experimental
|
|
88
|
+
*/
|
|
89
|
+
export const SERVER_COMPONENT_SOURCE: unique symbol;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The call's wire address (`frameAddress`), for regions to be emitted under.
|
|
93
|
+
* @experimental
|
|
94
|
+
*/
|
|
95
|
+
export const SERVER_COMPONENT_ADDRESS: unique symbol;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The binding brand on values the transport resolves: `{ component, address }`
|
|
99
|
+
* — the identity split (DR-1). `component` is the mount identity, one per
|
|
100
|
+
* server function; `address` names the call's content store. An equals-gated
|
|
101
|
+
* reader compares `component` across resolutions: same function means "same
|
|
102
|
+
* instance, new binding" — keep the mounted instance and deliver the new
|
|
103
|
+
* address into it; a different function swaps normally. `Symbol.for`, so
|
|
104
|
+
* frameworks can honor it without importing this module.
|
|
105
|
+
* @experimental
|
|
106
|
+
*/
|
|
107
|
+
export const COMPONENT_BINDING: unique symbol;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The value under `COMPONENT_BINDING` on a transport-resolved binding.
|
|
111
|
+
* @experimental
|
|
112
|
+
*/
|
|
113
|
+
export interface ComponentBinding<C = unknown> {
|
|
114
|
+
/** The per-function mount component (the equals-gate identity). */
|
|
115
|
+
component: C;
|
|
116
|
+
/** The call's intrinsic (function, arguments) address — its store's key. */
|
|
117
|
+
address: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Seroval plugin for a server component crossing a serialization boundary:
|
|
122
|
+
* a branded component serializes as a REFERENCE — a per-function document
|
|
123
|
+
* placeholder in the hydration serializer, a live-registry lookup by call
|
|
124
|
+
* address in the JSON codec (single-flight envelopes) — its markup never
|
|
125
|
+
* rides as data.
|
|
126
|
+
* @experimental
|
|
127
|
+
*/
|
|
128
|
+
export const ServerComponentPlugin: unknown;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Installs the hydration-serializer registry prefix: given the emitted
|
|
132
|
+
* script's serializer context, returns the expression the next serialized
|
|
133
|
+
* reference reads the `_$SC` registry through (the self-bootstrapping form
|
|
134
|
+
* on a script's first reference, a bare read after). Loaded document-SSR
|
|
135
|
+
* modules install this (see frame-sink); client bundles never carry the
|
|
136
|
+
* bootstrap text.
|
|
137
|
+
* @experimental
|
|
138
|
+
*/
|
|
139
|
+
export function setServerComponentBootstrap(resolve: (ctx: unknown) => string): void;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The codec options for a single-flight envelope: `codec` plus
|
|
143
|
+
* `ServerComponentPlugin` (deduped by tag). Injected by the protocol on both
|
|
144
|
+
* legs; exported for integrations composing their own flight carriers.
|
|
145
|
+
* @experimental
|
|
146
|
+
*/
|
|
147
|
+
export function flightCodec(codec?: JSONCodecOptions): JSONCodecOptions;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Options for `createServerComponentHandler`.
|
|
151
|
+
* @experimental
|
|
152
|
+
*/
|
|
153
|
+
export interface ServerComponentHandlerOptions<C = unknown> {
|
|
154
|
+
host: FrameHost;
|
|
155
|
+
/**
|
|
156
|
+
* Builds the framework's mount component for a server FUNCTION. Invoked
|
|
157
|
+
* once per function and cached — this is the equals-gate identity every
|
|
158
|
+
* call of the function resolves through. The component is CALLED (by the
|
|
159
|
+
* binding wrapper or a gated reader), receiving its current address as a
|
|
160
|
+
* second argument (`() => string`); it should (re-)bind its frame's pull
|
|
161
|
+
* to that address's store. Multi-mount fans out per site.
|
|
162
|
+
*/
|
|
163
|
+
component(fnId: string): C;
|
|
164
|
+
/**
|
|
165
|
+
* A new response is about to stream into an address: rotate
|
|
166
|
+
* response-scoped state (codec data tables) here. `version` is the
|
|
167
|
+
* client-owned stream counter the chunks will be stamped with.
|
|
168
|
+
*/
|
|
169
|
+
onStream?(address: string, version: number, response: Response): void;
|
|
170
|
+
/**
|
|
171
|
+
* Answer a call SYNCHRONOUSLY before any request is made (t = 0 local
|
|
172
|
+
* answers — e.g. a boundary the document already carries). Returning a
|
|
173
|
+
* non-undefined value resolves the call with it; a hydrating consumer
|
|
174
|
+
* never observes a pending beat.
|
|
175
|
+
*/
|
|
176
|
+
intercept?(info: { id: string; meta: unknown; args: unknown[] }): C | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* Reads the registered single-flight consumer at delivery time. The
|
|
179
|
+
* consumer is module state in the server-function client's SHARED
|
|
180
|
+
* instance; pass a getter reading that instance when your bundling gives
|
|
181
|
+
* this module a private copy. Defaults to the local copy's reader.
|
|
182
|
+
*/
|
|
183
|
+
consumer?(): FlightConsumer | undefined;
|
|
184
|
+
/**
|
|
185
|
+
* Reads the configured codec options at decode time — same instance-
|
|
186
|
+
* identity contract as `consumer`. Defaults to the local copy's reader.
|
|
187
|
+
*/
|
|
188
|
+
codec?(): JSONCodecOptions | undefined;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The client mirror of `frameTransformResult`, shaped for the server-function
|
|
193
|
+
* client's `responseHandler` seam: frame-stream responses resolve the call
|
|
194
|
+
* with a **binding** — a callable wrapper branded `COMPONENT_BINDING` — so
|
|
195
|
+
* an equals-gated consumer (Solid's `dynamic`) never remounts across
|
|
196
|
+
* refetches or argument changes; the response streams into the address's
|
|
197
|
+
* resident store as the only observable effect.
|
|
198
|
+
*
|
|
199
|
+
* The identity split (DR-1): stores are keyed per-ADDRESS — the call's
|
|
200
|
+
* intrinsic (function, arguments) name, one-to-one with a query cache's
|
|
201
|
+
* per-args entries — while mounts are per-SITE, rendering the per-function
|
|
202
|
+
* component and following delivered addresses. An address nothing is bound
|
|
203
|
+
* to warms its store (preload isolation is the default, not a rule).
|
|
204
|
+
* @experimental
|
|
205
|
+
*/
|
|
206
|
+
export function createServerComponentHandler<C>(options: ServerComponentHandlerOptions<C>): {
|
|
207
|
+
intercept?(info: { id: string; meta: unknown; args: unknown[] }): unknown;
|
|
208
|
+
handle(
|
|
209
|
+
response: Response,
|
|
210
|
+
ctx: { id: string; meta: unknown; args: unknown[]; context: unknown }
|
|
211
|
+
): unknown;
|
|
212
|
+
/**
|
|
213
|
+
* Declares that the document is showing a call: hydration-data references
|
|
214
|
+
* carry their call's address (`_$SC.r(id, address)`) but never travel
|
|
215
|
+
* through the transport, so the integration forwards those records here.
|
|
216
|
+
* Mints the call's binding (a post-load refetch then resolves a value
|
|
217
|
+
* whose component matches what the document mounted) and brands the
|
|
218
|
+
* per-function component so cache-seeded readers deliver instead of
|
|
219
|
+
* remounting when their site later switches calls.
|
|
220
|
+
*/
|
|
221
|
+
showing(address: string, functionId: string): void;
|
|
222
|
+
};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// Serialization surface (published as `@solidjs/web/serialization`): the
|
|
2
|
+
// runtime's Seroval machinery, exposed for the runtime's own entries and
|
|
3
|
+
// for integrations building transports on the same codec. This is
|
|
4
|
+
// INTEGRATION-FACING plumbing, not application API — it is exempt from the
|
|
5
|
+
// 2.0 stability guarantee and may change between releases. Application and
|
|
6
|
+
// router code should configure `codec` on the server-function entries
|
|
7
|
+
// instead of importing from here.
|
|
8
|
+
import type { Serializer } from "seroval";
|
|
9
|
+
import {
|
|
10
|
+
JSONCodecOptions,
|
|
11
|
+
PluginInfo,
|
|
12
|
+
SerializerPlugin,
|
|
13
|
+
SerovalNode
|
|
14
|
+
} from "./serializer-decode.js";
|
|
15
|
+
|
|
16
|
+
// The decode half — `SerovalNode`, the plugin TYPES, `DEFAULT_WEB_PLUGINS`,
|
|
17
|
+
// `resolveSerializerPlugins`, `JSONCodecOptions`, `createJSONDeserializer`,
|
|
18
|
+
// `createJSONDataTable` — is declared in serializer-decode.d.ts (published
|
|
19
|
+
// as `@solidjs/web/serialization/decode`, the module lazy client consumers
|
|
20
|
+
// load) and re-exported here so this remains the full surface.
|
|
21
|
+
export * from "./serializer-decode.js";
|
|
22
|
+
|
|
23
|
+
// ---- Plugin authoring ----
|
|
24
|
+
//
|
|
25
|
+
// Unlike the rest of this entry, plugin authoring is APPLICATION-FACING —
|
|
26
|
+
// it is the supported way to feed the serializers' `plugins` options and
|
|
27
|
+
// the server-function entries' `codec.plugins`. The values re-export
|
|
28
|
+
// seroval's own (`createPlugin`, `OpaqueReference` — see serializer.js);
|
|
29
|
+
// the plugin TYPES live in serializer-decode.d.ts (hand-declared there —
|
|
30
|
+
// see its banner for why).
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Builds a `SerializerPlugin` — seroval's `createPlugin`, re-exported so
|
|
34
|
+
* plugin authors stay on the exact seroval instance/version the runtime
|
|
35
|
+
* serializes with. Import it from HERE, not from your own `seroval`
|
|
36
|
+
* dependency: a plugin built against a different copy/version would not
|
|
37
|
+
* fail the build — it would emit nodes the other peer can't interpret.
|
|
38
|
+
*
|
|
39
|
+
* Application-facing (see the plugin-authoring banner above).
|
|
40
|
+
*/
|
|
41
|
+
export function createPlugin<Value, Info extends PluginInfo>(
|
|
42
|
+
plugin: SerializerPlugin<Value, Info>
|
|
43
|
+
): SerializerPlugin<Value, Info>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Seroval's `OpaqueReference`, re-exported from the runtime's own instance
|
|
47
|
+
* (an `OpaqueReference` from another seroval copy fails the serializer's
|
|
48
|
+
* instanceof check and serializes as a plain value): wraps a value so it
|
|
49
|
+
* crosses the wire as its `replacement` (default `undefined`) while
|
|
50
|
+
* staying readable in-process through `.value`.
|
|
51
|
+
*
|
|
52
|
+
* Application-facing (see the plugin-authoring banner above).
|
|
53
|
+
*/
|
|
54
|
+
export class OpaqueReference<V, R = undefined> {
|
|
55
|
+
readonly value: V;
|
|
56
|
+
readonly replacement?: R;
|
|
57
|
+
constructor(value: V, replacement?: R);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Options for `createSerializer`.
|
|
62
|
+
*
|
|
63
|
+
* Integration-facing; may change (see the entry banner).
|
|
64
|
+
*/
|
|
65
|
+
export interface WebSerializerOptions {
|
|
66
|
+
/** Name of the global object the emitted scripts write resolved values into. */
|
|
67
|
+
globalIdentifier: string;
|
|
68
|
+
/** Cross-reference scope id, for isolating multiple streams on one page. */
|
|
69
|
+
scopeId?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Seroval feature bitflags to exclude from output. Defaults to disabling
|
|
72
|
+
* post-ES2017 features (AggregateError, BigInt typed arrays). Outside
|
|
73
|
+
* development, `Error.prototype.stack` is additionally stripped on top of
|
|
74
|
+
* any override — serialized stacks leak server paths to the client.
|
|
75
|
+
*/
|
|
76
|
+
disabledFeatures?: number;
|
|
77
|
+
/** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. */
|
|
78
|
+
plugins?: SerializerPlugin[];
|
|
79
|
+
/** Receives each emitted script chunk. */
|
|
80
|
+
onData: (result: string) => void;
|
|
81
|
+
onError?: (error: unknown) => void;
|
|
82
|
+
/** Fires once all async values have settled. */
|
|
83
|
+
onDone?: () => void;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Creates a streaming Seroval serializer preconfigured with the web plugin
|
|
88
|
+
* set and the default feature policy. Emits JavaScript chunks (through
|
|
89
|
+
* `onData`) that reconstruct the values under `globalIdentifier` when
|
|
90
|
+
* evaluated — the script-injection form of serialization renderers build
|
|
91
|
+
* on. For a JSON-based wire codec (no eval on the receiving side), use
|
|
92
|
+
* `serializeJSON` / `createJSONDeserializer` instead.
|
|
93
|
+
*
|
|
94
|
+
* Integration-facing; may change (see the entry banner).
|
|
95
|
+
*/
|
|
96
|
+
export function createSerializer(options: WebSerializerOptions): Serializer;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Options for `createHydrationSerializer` — `WebSerializerOptions` minus
|
|
100
|
+
* the knobs hydration pins (`globalIdentifier`, `disabledFeatures`).
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
export type HydrationSerializerOptions = Omit<
|
|
104
|
+
WebSerializerOptions,
|
|
105
|
+
"globalIdentifier" | "disabledFeatures"
|
|
106
|
+
>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Renderer primitive — the serializer SSR uses for hydration output. Pins
|
|
110
|
+
* the hydration global (`_$HY.r`) and feature policy; only the wiring
|
|
111
|
+
* options (callbacks, scope, extra plugins) are configurable. Not meant
|
|
112
|
+
* for hand-written code — custom serialization should use
|
|
113
|
+
* `createSerializer` or the JSON codec.
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
export function createHydrationSerializer(options: HydrationSerializerOptions): Serializer;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Renderer primitive — returns the cross-reference bootstrap script SSR
|
|
120
|
+
* emits ahead of hydration data for a render scope. Not meant for
|
|
121
|
+
* hand-written code.
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
124
|
+
export function getLocalHeaderScript(id?: string): string;
|
|
125
|
+
|
|
126
|
+
// ---- JSON codec (server function transports) ----
|
|
127
|
+
// (`JSONCodecOptions` and the decode half are declared in
|
|
128
|
+
// serializer-decode.d.ts and re-exported above.)
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Options for `serializeJSON`.
|
|
132
|
+
*
|
|
133
|
+
* Integration-facing; may change (see the entry banner).
|
|
134
|
+
*/
|
|
135
|
+
export interface JSONSerializeOptions extends JSONCodecOptions {
|
|
136
|
+
/**
|
|
137
|
+
* Receives each serialized node; `initial` is true for the first chunk
|
|
138
|
+
* (the source value itself). Async values produce additional chunks as
|
|
139
|
+
* they resolve.
|
|
140
|
+
*/
|
|
141
|
+
onParse: (node: SerovalNode, initial: boolean) => void;
|
|
142
|
+
onError?: (error: unknown) => void;
|
|
143
|
+
/** Fires once all async values have settled. */
|
|
144
|
+
onDone?: () => void;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Serializes `value` as SerovalNode chunks delivered through `onParse` —
|
|
149
|
+
* the encoding half of the eval-free JSON codec (RPC-style transports;
|
|
150
|
+
* the deserializing peer needs no script evaluation, so CSP-safe). Wire
|
|
151
|
+
* framing of the nodes is the transport's concern. Returns a cancel
|
|
152
|
+
* function that aborts pending async serialization.
|
|
153
|
+
*
|
|
154
|
+
* Integration-facing; may change (see the entry banner).
|
|
155
|
+
*/
|
|
156
|
+
export function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
|
|
157
|
+
|
|
158
|
+
/** Options for `createJSONSerializer`. */
|
|
159
|
+
export interface JSONSerializerOptions extends JSONCodecOptions {
|
|
160
|
+
/**
|
|
161
|
+
* Receives each keyed record — `initial` is true for a key's first node
|
|
162
|
+
* (the written value itself); async values patch through later records
|
|
163
|
+
* under the same key. The decoding peer is `createJSONDataTable`.
|
|
164
|
+
*/
|
|
165
|
+
onData: (record: { key: string; node: SerovalNode; initial: boolean }) => void;
|
|
166
|
+
onError?: (error: unknown) => void;
|
|
167
|
+
/** Fires once `flush()` has been called and every pending value settled. */
|
|
168
|
+
onDone?: () => void;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The keyed, streaming encoder of the eval-free JSON codec — the render
|
|
173
|
+
* stream's data serializer (frames default to it). Each `write(key, value)`
|
|
174
|
+
* shares one reference space, so cross-record identity holds; `flush()`
|
|
175
|
+
* marks the write set complete (writes after it are dropped, mirroring the
|
|
176
|
+
* hydration serializer); `close()` aborts pending async serialization.
|
|
177
|
+
*/
|
|
178
|
+
export function createJSONSerializer(options: JSONSerializerOptions): {
|
|
179
|
+
write(key: string, value: unknown): void;
|
|
180
|
+
flush(): void;
|
|
181
|
+
close(): void;
|
|
182
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
* @experimental
|
|
26
|
+
*/
|
|
27
|
+
export type Slot<P = {}> = (props: P & {
|
|
28
|
+
$key?: string | number;
|
|
29
|
+
}) => SolidElement;
|
|
30
|
+
/**
|
|
31
|
+
* Types an async value crossing the slot border (DR-2, value tier). What you
|
|
32
|
+
* pass is what ships — the promise / async iterable itself rides the data
|
|
33
|
+
* channel — but the client's prop READ settles: it suspends into the covering
|
|
34
|
+
* boundary until first arrival (a promise's resolution, an iterable's first
|
|
35
|
+
* yield), then reads as the settled value, updating per yield for iterables.
|
|
36
|
+
*
|
|
37
|
+
* `asyncArg` is the type-level statement of that contract: identity at
|
|
38
|
+
* runtime, settled type at the border, so `Slot<P>` keeps the fill's props
|
|
39
|
+
* truthful to what its reads actually return.
|
|
40
|
+
*
|
|
41
|
+
* Slots render as JSX — the compiler wraps each prop in a getter so the read
|
|
42
|
+
* defers to the slot border, where the runtime owns it. A call form
|
|
43
|
+
* (`props.status({ … })`) evaluates its args eagerly in the component body —
|
|
44
|
+
* a top-level read, an error in most cases.
|
|
45
|
+
*
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <props.status progress={asyncArg(gen.progress)} stats={asyncArg(gen.stats)} />
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function asyncArg<T>(value: PromiseLike<T> | AsyncIterable<T>): T;
|
|
51
|
+
export { renderToFrameStream, renderServerComponent, serverComponentResponse, frameTransformResult, frameTransformFlightResult, createFrameSink, frameTransformDirectResult, ServerComponentPlugin, SERVER_COMPONENT_BOOTSTRAP } from "./frame-sink.js";
|
|
52
|
+
export { FRAME_STREAM_HEADER, isFrameStreamResponse } from "./frame-transport.js";
|