@solidjs/web 2.0.0-beta.30 → 2.0.0-beta.32
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 +1 -6
- package/dist/dev.cjs +284 -82
- package/dist/dev.js +271 -79
- package/dist/server.cjs +555 -135
- package/dist/server.js +544 -132
- package/dist/web.cjs +281 -79
- package/dist/web.js +268 -76
- package/frames/dist/client.cjs +413 -360
- package/frames/dist/client.dev.cjs +413 -360
- package/frames/dist/client.dev.js +414 -361
- package/frames/dist/client.js +414 -361
- package/frames/dist/server.cjs +604 -199
- package/frames/dist/server.js +605 -201
- package/package.json +56 -6
- package/serialization/dist/serialization.cjs +8 -0
- package/serialization/dist/serialization.js +1 -0
- package/serialization/types/index.d.ts +173 -6
- package/serialization/types-cjs/index.d.cts +173 -6
- package/server-functions/dist/client.cjs +46 -9
- package/server-functions/dist/client.js +47 -11
- package/server-functions/dist/rich-args.cjs +11 -0
- package/server-functions/dist/rich-args.js +9 -0
- package/server-functions/dist/server.cjs +275 -126
- package/server-functions/dist/server.dev.cjs +1053 -0
- package/server-functions/dist/server.dev.js +1021 -0
- package/server-functions/dist/server.js +273 -127
- package/server-functions/package.json +10 -0
- package/server-functions/rich-args/package.json +20 -0
- package/storage/types/index.d.ts +1 -1
- package/storage/types-cjs/index.d.cts +1 -1
- package/types/client.d.ts +134 -11
- package/types/core.d.ts +3 -1
- package/types/frames/client.d.ts +24 -8
- package/types/frames/frame-client.d.ts +49 -7
- package/types/frames/frame-sink.d.ts +32 -6
- package/types/frames/frame-transport.d.ts +88 -62
- package/types/frames/serializer.d.ts +173 -6
- package/types/frames/server.d.ts +22 -0
- package/types/index.d.ts +2 -3
- package/types/jsx.d.ts +3 -3
- package/types/response.d.ts +45 -0
- package/types/serializer.d.ts +173 -6
- package/types/server-functions/client.d.ts +1 -0
- package/types/server-functions/rich-args.d.ts +10 -0
- package/types/server-functions/server.d.ts +98 -0
- package/types/server-functions/shared.d.ts +22 -0
- package/types/server-mock.d.ts +171 -59
- package/types/server.d.ts +196 -42
- package/types-cjs/client.d.cts +134 -11
- package/types-cjs/core.d.cts +3 -1
- package/types-cjs/frames/client.d.cts +24 -8
- package/types-cjs/frames/frame-client.d.cts +49 -7
- package/types-cjs/frames/frame-sink.d.cts +32 -6
- package/types-cjs/frames/frame-transport.d.cts +88 -62
- package/types-cjs/frames/serializer.d.cts +173 -6
- package/types-cjs/frames/server.d.cts +22 -0
- package/types-cjs/index.d.cts +2 -3
- package/types-cjs/jsx.d.cts +3 -3
- package/types-cjs/response.d.cts +45 -0
- package/types-cjs/serializer.d.cts +173 -6
- package/types-cjs/server-functions/client.d.cts +1 -0
- package/types-cjs/server-functions/rich-args.d.cts +10 -0
- package/types-cjs/server-functions/server.d.cts +98 -0
- package/types-cjs/server-functions/shared.d.cts +22 -0
- package/types-cjs/server-mock.d.cts +171 -59
- package/types-cjs/server.d.cts +196 -42
|
@@ -1,3 +1,7 @@
|
|
|
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
6
|
import { JSONCodecOptions } from "./serializer.cjs";
|
|
3
7
|
|
|
@@ -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
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Whether a fetch Response carries a frame stream.
|
|
24
|
+
* @experimental
|
|
25
|
+
*/
|
|
18
26
|
export function isFrameStreamResponse(response: Response): boolean;
|
|
19
27
|
|
|
20
|
-
/**
|
|
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
|
|
@@ -36,12 +47,6 @@ export interface ApplyFrameResponseOptions {
|
|
|
36
47
|
* response.
|
|
37
48
|
*/
|
|
38
49
|
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
50
|
/**
|
|
46
51
|
* Receives the payload text of each `outcome` chunk — the response-scoped
|
|
47
52
|
* single-flight envelope, the caller's result rather than anything the
|
|
@@ -63,6 +68,7 @@ export interface ApplyFrameResponseOptions {
|
|
|
63
68
|
* await applyFrameResponse(response, host, { as: "story-pane" });
|
|
64
69
|
* }
|
|
65
70
|
* ```
|
|
71
|
+
* @experimental
|
|
66
72
|
*/
|
|
67
73
|
export function applyFrameResponse(
|
|
68
74
|
response: Response,
|
|
@@ -70,39 +76,45 @@ export function applyFrameResponse(
|
|
|
70
76
|
options?: ApplyFrameResponseOptions
|
|
71
77
|
): Promise<string>;
|
|
72
78
|
|
|
73
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Brands an inline-rendered server component with its function id.
|
|
81
|
+
* @experimental
|
|
82
|
+
*/
|
|
74
83
|
export const SERVER_COMPONENT: unique symbol;
|
|
75
84
|
|
|
76
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* The unwrapped server component behind an inline-render wrap.
|
|
87
|
+
* @experimental
|
|
88
|
+
*/
|
|
77
89
|
export const SERVER_COMPONENT_SOURCE: unique symbol;
|
|
78
90
|
|
|
79
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* The call's wire address (`frameAddress`), for regions to be emitted under.
|
|
93
|
+
* @experimental
|
|
94
|
+
*/
|
|
80
95
|
export const SERVER_COMPONENT_ADDRESS: unique symbol;
|
|
81
96
|
|
|
82
97
|
/**
|
|
83
|
-
* The
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* honor it without importing this module.
|
|
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
|
|
90
106
|
*/
|
|
91
|
-
export const
|
|
107
|
+
export const COMPONENT_BINDING: unique symbol;
|
|
92
108
|
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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;
|
|
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;
|
|
106
118
|
}
|
|
107
119
|
|
|
108
120
|
/**
|
|
@@ -111,38 +123,50 @@ export interface ComponentHandoff {
|
|
|
111
123
|
* placeholder in the hydration serializer, a live-registry lookup by call
|
|
112
124
|
* address in the JSON codec (single-flight envelopes) — its markup never
|
|
113
125
|
* rides as data.
|
|
126
|
+
* @experimental
|
|
114
127
|
*/
|
|
115
128
|
export const ServerComponentPlugin: unknown;
|
|
116
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
|
+
|
|
117
141
|
/**
|
|
118
142
|
* The codec options for a single-flight envelope: `codec` plus
|
|
119
143
|
* `ServerComponentPlugin` (deduped by tag). Injected by the protocol on both
|
|
120
144
|
* legs; exported for integrations composing their own flight carriers.
|
|
145
|
+
* @experimental
|
|
121
146
|
*/
|
|
122
147
|
export function flightCodec(codec?: JSONCodecOptions): JSONCodecOptions;
|
|
123
148
|
|
|
124
|
-
/**
|
|
149
|
+
/**
|
|
150
|
+
* Options for `createServerComponentHandler`.
|
|
151
|
+
* @experimental
|
|
152
|
+
*/
|
|
125
153
|
export interface ServerComponentHandlerOptions<C = unknown> {
|
|
126
154
|
host: FrameHost;
|
|
127
155
|
/**
|
|
128
|
-
* Builds the framework's
|
|
129
|
-
* per
|
|
130
|
-
*
|
|
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.
|
|
131
162
|
*/
|
|
132
|
-
component(
|
|
163
|
+
component(fnId: string): C;
|
|
133
164
|
/**
|
|
134
|
-
* A new response is about to stream into
|
|
165
|
+
* A new response is about to stream into an address: rotate
|
|
135
166
|
* response-scoped state (codec data tables) here. `version` is the
|
|
136
167
|
* client-owned stream counter the chunks will be stamped with.
|
|
137
168
|
*/
|
|
138
|
-
onStream?(
|
|
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;
|
|
169
|
+
onStream?(address: string, version: number, response: Response): void;
|
|
146
170
|
/**
|
|
147
171
|
* Answer a call SYNCHRONOUSLY before any request is made (t = 0 local
|
|
148
172
|
* answers — e.g. a boundary the document already carries). Returning a
|
|
@@ -167,30 +191,32 @@ export interface ServerComponentHandlerOptions<C = unknown> {
|
|
|
167
191
|
/**
|
|
168
192
|
* The client mirror of `frameTransformResult`, shaped for the server-function
|
|
169
193
|
* client's `responseHandler` seam: frame-stream responses resolve the call
|
|
170
|
-
* with a **
|
|
171
|
-
* (Solid's `dynamic`) never remounts across
|
|
172
|
-
*
|
|
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.
|
|
173
198
|
*
|
|
174
|
-
*
|
|
175
|
-
* intrinsic (function, arguments)
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
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
|
|
179
205
|
*/
|
|
180
206
|
export function createServerComponentHandler<C>(options: ServerComponentHandlerOptions<C>): {
|
|
181
|
-
intercept?(info: { id: string; meta: unknown; args: unknown[] }):
|
|
207
|
+
intercept?(info: { id: string; meta: unknown; args: unknown[] }): unknown;
|
|
182
208
|
handle(
|
|
183
209
|
response: Response,
|
|
184
210
|
ctx: { id: string; meta: unknown; args: unknown[]; context: unknown }
|
|
185
|
-
):
|
|
211
|
+
): unknown;
|
|
186
212
|
/**
|
|
187
213
|
* Declares that the document is showing a call: hydration-data references
|
|
188
214
|
* carry their call's address (`_$SC.r(id, address)`) but never travel
|
|
189
|
-
* through the transport, so the integration forwards those records here
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
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.
|
|
194
220
|
*/
|
|
195
|
-
showing(address: string, functionId: string
|
|
221
|
+
showing(address: string, functionId: string): void;
|
|
196
222
|
};
|
|
@@ -1,23 +1,142 @@
|
|
|
1
|
-
|
|
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 { Serializer, SerovalNode } from "seroval";
|
|
2
9
|
|
|
3
10
|
/**
|
|
4
11
|
* Seroval's node shape — the intermediate representation `serializeJSON`
|
|
5
12
|
* emits and `createJSONDeserializer` consumes. Safe to `JSON.stringify`.
|
|
13
|
+
*
|
|
14
|
+
* Integration-facing; may change (see the entry banner).
|
|
6
15
|
*/
|
|
7
16
|
export type { SerovalNode };
|
|
8
17
|
|
|
18
|
+
// ---- Plugin authoring ----
|
|
19
|
+
//
|
|
20
|
+
// Unlike the rest of this entry, plugin authoring is APPLICATION-FACING —
|
|
21
|
+
// it is the supported way to feed the serializers' `plugins` options and
|
|
22
|
+
// the server-function entries' `codec.plugins`. The values re-export
|
|
23
|
+
// seroval's own (`createPlugin`, `OpaqueReference` — see serializer.js);
|
|
24
|
+
// the TYPES are declared here by hand, like everything else in this file,
|
|
25
|
+
// because seroval's published d.ts use extensionless ESM-relative imports
|
|
26
|
+
// that `moduleResolution: "nodenext"` cannot follow — a bare type
|
|
27
|
+
// re-export would silently degrade the whole authoring surface to `any`
|
|
28
|
+
// under skipLibCheck. The declarations mirror seroval ~1.5 exactly; the
|
|
29
|
+
// `~` pin is what makes mirroring safe.
|
|
30
|
+
|
|
31
|
+
/** Per-plugin bookkeeping seroval hands each plugin callback. */
|
|
32
|
+
export interface PluginData {
|
|
33
|
+
id: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The shape of a plugin's parsed payload: a map of `SerovalNode`s produced
|
|
38
|
+
* by the parse contexts, consumed by `serialize`/`deserialize`.
|
|
39
|
+
*/
|
|
40
|
+
export type PluginInfo = { [key: string]: SerovalNode };
|
|
41
|
+
|
|
42
|
+
/** Parse context for `parse.sync`: turns child values into nodes. */
|
|
43
|
+
export interface SyncParsePluginContext {
|
|
44
|
+
parse<T>(current: T): SerovalNode;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Parse context for `parse.async`: like sync, but child parses await. */
|
|
48
|
+
export interface AsyncParsePluginContext {
|
|
49
|
+
parse<T>(current: T): Promise<SerovalNode>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Parse context for `parse.stream`: sync parsing plus the streaming
|
|
54
|
+
* lifecycle (pending-state tracking, late node emission, cleanup).
|
|
55
|
+
*/
|
|
56
|
+
export interface StreamParsePluginContext {
|
|
57
|
+
parse<T>(current: T): SerovalNode;
|
|
58
|
+
parseWithError<T>(current: T): SerovalNode | undefined;
|
|
59
|
+
isAlive(): boolean;
|
|
60
|
+
pushPendingState(): void;
|
|
61
|
+
popPendingState(): void;
|
|
62
|
+
onParse(node: SerovalNode): void;
|
|
63
|
+
onError(error: unknown): void;
|
|
64
|
+
addCleanup(callback: () => void): void;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Serialize context: renders child nodes to JS source. */
|
|
68
|
+
export interface SerializePluginContext {
|
|
69
|
+
serialize(node: SerovalNode): string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Deserialize context: revives child nodes to runtime values. */
|
|
73
|
+
export interface DeserializePluginContext {
|
|
74
|
+
deserialize<T>(node: SerovalNode): T;
|
|
75
|
+
}
|
|
76
|
+
|
|
9
77
|
/**
|
|
10
78
|
* A Seroval plugin usable with the web serializers — teaches the codec how
|
|
11
|
-
* to encode/decode a custom value type
|
|
12
|
-
* peers of a
|
|
79
|
+
* to encode/decode a custom value type (`Value` is the value it matches,
|
|
80
|
+
* `Info` its parsed payload). Supply matching plugins on both peers of a
|
|
81
|
+
* transport. Bare `SerializerPlugin` (both parameters defaulted to `any`)
|
|
82
|
+
* is the list-element type every `plugins` option accepts.
|
|
83
|
+
*
|
|
84
|
+
* Integration-facing; may change (see the entry banner).
|
|
13
85
|
*/
|
|
14
|
-
export
|
|
86
|
+
export interface SerializerPlugin<Value = any, Info extends PluginInfo = any> {
|
|
87
|
+
/** A unique string identifying the plugin — namespace it (`"app/Thing"`). */
|
|
88
|
+
tag: string;
|
|
89
|
+
/** Dependency plugins, resolved ahead of this one. */
|
|
90
|
+
extends?: SerializerPlugin[];
|
|
91
|
+
/** Whether `value` is this plugin's to encode. */
|
|
92
|
+
test(value: unknown): boolean;
|
|
93
|
+
/** Parsing modes — provide the ones the transports you target use. */
|
|
94
|
+
parse: {
|
|
95
|
+
sync?: (value: Value, ctx: SyncParsePluginContext, data: PluginData) => Info;
|
|
96
|
+
async?: (value: Value, ctx: AsyncParsePluginContext, data: PluginData) => Promise<Info>;
|
|
97
|
+
stream?: (value: Value, ctx: StreamParsePluginContext, data: PluginData) => Info;
|
|
98
|
+
};
|
|
99
|
+
/** Renders the parsed payload as JS source (script-injection form). */
|
|
100
|
+
serialize(node: Info, ctx: SerializePluginContext, data: PluginData): string;
|
|
101
|
+
/** Revives the parsed payload back into the runtime value. */
|
|
102
|
+
deserialize(node: Info, ctx: DeserializePluginContext, data: PluginData): Value;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Builds a `SerializerPlugin` — seroval's `createPlugin`, re-exported so
|
|
107
|
+
* plugin authors stay on the exact seroval instance/version the runtime
|
|
108
|
+
* serializes with. Import it from HERE, not from your own `seroval`
|
|
109
|
+
* dependency: a plugin built against a different copy/version would not
|
|
110
|
+
* fail the build — it would emit nodes the other peer can't interpret.
|
|
111
|
+
*
|
|
112
|
+
* Application-facing (see the plugin-authoring banner above).
|
|
113
|
+
*/
|
|
114
|
+
export function createPlugin<Value, Info extends PluginInfo>(
|
|
115
|
+
plugin: SerializerPlugin<Value, Info>
|
|
116
|
+
): SerializerPlugin<Value, Info>;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Seroval's `OpaqueReference`, re-exported from the runtime's own instance
|
|
120
|
+
* (an `OpaqueReference` from another seroval copy fails the serializer's
|
|
121
|
+
* instanceof check and serializes as a plain value): wraps a value so it
|
|
122
|
+
* crosses the wire as its `replacement` (default `undefined`) while
|
|
123
|
+
* staying readable in-process through `.value`.
|
|
124
|
+
*
|
|
125
|
+
* Application-facing (see the plugin-authoring banner above).
|
|
126
|
+
*/
|
|
127
|
+
export class OpaqueReference<V, R = undefined> {
|
|
128
|
+
readonly value: V;
|
|
129
|
+
readonly replacement?: R;
|
|
130
|
+
constructor(value: V, replacement?: R);
|
|
131
|
+
}
|
|
15
132
|
|
|
16
133
|
/**
|
|
17
134
|
* Baseline plugin set for serializing web-platform values (AbortSignal,
|
|
18
135
|
* Event, FormData, Headers, ReadableStream, Request, Response, URL, ...).
|
|
19
136
|
* Applied by every serializer in this module; custom plugins compose ahead
|
|
20
137
|
* of it via `resolveSerializerPlugins`.
|
|
138
|
+
*
|
|
139
|
+
* Integration-facing; may change (see the entry banner).
|
|
21
140
|
*/
|
|
22
141
|
export const DEFAULT_WEB_PLUGINS: readonly SerializerPlugin[];
|
|
23
142
|
|
|
@@ -26,10 +145,16 @@ export const DEFAULT_WEB_PLUGINS: readonly SerializerPlugin[];
|
|
|
26
145
|
* first so they can shadow a default for values both would match. Returns a
|
|
27
146
|
* fresh array; the defaults are never mutated. Useful when handing a full
|
|
28
147
|
* plugin list to another serialization layer.
|
|
148
|
+
*
|
|
149
|
+
* Integration-facing; may change (see the entry banner).
|
|
29
150
|
*/
|
|
30
151
|
export function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
|
|
31
152
|
|
|
32
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* Options for `createSerializer`.
|
|
155
|
+
*
|
|
156
|
+
* Integration-facing; may change (see the entry banner).
|
|
157
|
+
*/
|
|
33
158
|
export interface WebSerializerOptions {
|
|
34
159
|
/** Name of the global object the emitted scripts write resolved values into. */
|
|
35
160
|
globalIdentifier: string;
|
|
@@ -58,6 +183,8 @@ export interface WebSerializerOptions {
|
|
|
58
183
|
* evaluated — the script-injection form of serialization renderers build
|
|
59
184
|
* on. For a JSON-based wire codec (no eval on the receiving side), use
|
|
60
185
|
* `serializeJSON` / `createJSONDeserializer` instead.
|
|
186
|
+
*
|
|
187
|
+
* Integration-facing; may change (see the entry banner).
|
|
61
188
|
*/
|
|
62
189
|
export function createSerializer(options: WebSerializerOptions): Serializer;
|
|
63
190
|
|
|
@@ -96,6 +223,8 @@ export function getLocalHeaderScript(id?: string): string;
|
|
|
96
223
|
* on the serializing and deserializing peer or payloads will not
|
|
97
224
|
* round-trip — for server functions, set them once through the
|
|
98
225
|
* client/server `codec` config option.
|
|
226
|
+
*
|
|
227
|
+
* Integration-facing; may change (see the entry banner).
|
|
99
228
|
*/
|
|
100
229
|
export interface JSONCodecOptions {
|
|
101
230
|
/** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. Must match on both peers. */
|
|
@@ -113,7 +242,11 @@ export interface JSONCodecOptions {
|
|
|
113
242
|
depthLimit?: number;
|
|
114
243
|
}
|
|
115
244
|
|
|
116
|
-
/**
|
|
245
|
+
/**
|
|
246
|
+
* Options for `serializeJSON`.
|
|
247
|
+
*
|
|
248
|
+
* Integration-facing; may change (see the entry banner).
|
|
249
|
+
*/
|
|
117
250
|
export interface JSONSerializeOptions extends JSONCodecOptions {
|
|
118
251
|
/**
|
|
119
252
|
* Receives each serialized node; `initial` is true for the first chunk
|
|
@@ -132,6 +265,8 @@ export interface JSONSerializeOptions extends JSONCodecOptions {
|
|
|
132
265
|
* the deserializing peer needs no script evaluation, so CSP-safe). Wire
|
|
133
266
|
* framing of the nodes is the transport's concern. Returns a cancel
|
|
134
267
|
* function that aborts pending async serialization.
|
|
268
|
+
*
|
|
269
|
+
* Integration-facing; may change (see the entry banner).
|
|
135
270
|
*/
|
|
136
271
|
export function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
|
|
137
272
|
|
|
@@ -141,14 +276,46 @@ export function serializeJSON(value: unknown, options: JSONSerializeOptions): ()
|
|
|
141
276
|
* from one stream must go through the same deserializer instance. The first
|
|
142
277
|
* chunk's return value is the decoded source value; feeding later chunks
|
|
143
278
|
* settles the async values referenced inside it.
|
|
279
|
+
*
|
|
280
|
+
* Integration-facing; may change (see the entry banner).
|
|
144
281
|
*/
|
|
145
282
|
export function createJSONDeserializer(options?: JSONCodecOptions): <T>(node: SerovalNode) => T;
|
|
146
283
|
|
|
284
|
+
/** Options for `createJSONSerializer`. */
|
|
285
|
+
export interface JSONSerializerOptions extends JSONCodecOptions {
|
|
286
|
+
/**
|
|
287
|
+
* Receives each keyed record — `initial` is true for a key's first node
|
|
288
|
+
* (the written value itself); async values patch through later records
|
|
289
|
+
* under the same key. The decoding peer is `createJSONDataTable`.
|
|
290
|
+
*/
|
|
291
|
+
onData: (record: { key: string; node: SerovalNode; initial: boolean }) => void;
|
|
292
|
+
onError?: (error: unknown) => void;
|
|
293
|
+
/** Fires once `flush()` has been called and every pending value settled. */
|
|
294
|
+
onDone?: () => void;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* The keyed, streaming encoder of the eval-free JSON codec — the render
|
|
299
|
+
* stream's data serializer (frames default to it). Each `write(key, value)`
|
|
300
|
+
* shares one reference space, so cross-record identity holds; `flush()`
|
|
301
|
+
* marks the write set complete (writes after it are dropped, mirroring the
|
|
302
|
+
* hydration serializer); `close()` aborts pending async serialization.
|
|
303
|
+
*/
|
|
304
|
+
export function createJSONSerializer(options: JSONSerializerOptions): {
|
|
305
|
+
write(key: string, value: unknown): void;
|
|
306
|
+
flush(): void;
|
|
307
|
+
close(): void;
|
|
308
|
+
};
|
|
309
|
+
|
|
147
310
|
/**
|
|
148
311
|
* A resident, response-scoped decode table over the keyed JSON codec: apply
|
|
149
312
|
* each frame `data` chunk with `apply`, resolve `{ $ref }` slot args with
|
|
150
313
|
* `resolve`. The frames client host wires one per response
|
|
151
314
|
* (`applyData: c => table.apply(c)`).
|
|
315
|
+
*
|
|
316
|
+
* Integration-facing; may change (see the entry banner). This serialization
|
|
317
|
+
* entry is the single home of the data table — the frames client consumes
|
|
318
|
+
* it internally rather than re-exporting it.
|
|
152
319
|
*/
|
|
153
320
|
export interface JSONDataTable {
|
|
154
321
|
apply(chunk: { key?: string; node?: unknown; initial?: boolean }): void;
|
|
@@ -22,9 +22,31 @@ import type { Element as SolidElement } from "solid-js";
|
|
|
22
22
|
* re-creates everything. It is occurrence identity, not client data: it is
|
|
23
23
|
* stripped before the client component sees its props. Positional identity is
|
|
24
24
|
* the right default; `$key` matters when a live list reorders.
|
|
25
|
+
* @experimental
|
|
25
26
|
*/
|
|
26
27
|
export type Slot<P = {}> = (props: P & {
|
|
27
28
|
$key?: string | number;
|
|
28
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;
|
|
29
51
|
export { renderToFrameStream, renderServerComponent, serverComponentResponse, frameTransformResult, frameTransformFlightResult, createFrameSink, frameTransformDirectResult, ServerComponentPlugin, SERVER_COMPONENT_BOOTSTRAP } from "./frame-sink.cjs";
|
|
30
52
|
export { FRAME_STREAM_HEADER, isFrameStreamResponse } from "./frame-transport.cjs";
|
package/types-cjs/index.d.cts
CHANGED
|
@@ -96,9 +96,8 @@ export declare function render(code: () => JSX.Element, element: MountableElemen
|
|
|
96
96
|
* and reactive bindings without reconstructing the DOM. Returns a `dispose`
|
|
97
97
|
* function that tears down reactive scopes (DOM nodes are left in place).
|
|
98
98
|
*
|
|
99
|
-
* Use this when the page HTML was produced by `renderToString
|
|
100
|
-
* `
|
|
101
|
-
* `render` instead.
|
|
99
|
+
* Use this when the page HTML was produced by `renderToString` or
|
|
100
|
+
* `renderToStream`. For client-only apps, use `render` instead.
|
|
102
101
|
*
|
|
103
102
|
* Pass `options.renderId` to hydrate one of multiple roots emitted by a
|
|
104
103
|
* server render that used the same id.
|
package/types-cjs/jsx.d.cts
CHANGED
|
@@ -240,13 +240,13 @@ export namespace JSX {
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
type RefCallback<T> = (el: T) => void;
|
|
243
|
-
type Ref<T> = T | RefCallback<T> | Ref<T>[];
|
|
243
|
+
type Ref<T> = T | RefCallback<T> | undefined | Ref<T>[];
|
|
244
244
|
|
|
245
245
|
interface IntrinsicAttributes {
|
|
246
|
-
ref?: Ref<unknown
|
|
246
|
+
ref?: Ref<unknown>;
|
|
247
247
|
}
|
|
248
248
|
interface CustomAttributes<T> {
|
|
249
|
-
ref?: Ref<T
|
|
249
|
+
ref?: Ref<T>;
|
|
250
250
|
children?: Element | undefined;
|
|
251
251
|
$ServerOnly?: boolean | undefined;
|
|
252
252
|
}
|
package/types-cjs/response.d.cts
CHANGED
|
@@ -49,6 +49,51 @@ export interface Href {
|
|
|
49
49
|
*/
|
|
50
50
|
export function isHref(value: unknown): value is Href;
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Registered-symbol brand (`Symbol.for("solid.SafeError")`) marking a thrown
|
|
54
|
+
* value as safe to serialize to the client verbatim. Declared `unique
|
|
55
|
+
* symbol` type-side; the runtime value is the registered symbol, so
|
|
56
|
+
* separately bundled copies agree on identity.
|
|
57
|
+
*/
|
|
58
|
+
export declare const SAFE_ERROR: unique symbol;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Marks `error` as safe to serialize to the client verbatim, opting it out
|
|
62
|
+
* of the server-function handler's production error sanitization.
|
|
63
|
+
*
|
|
64
|
+
* By default a plain `Error` thrown from a server function is sanitized to a
|
|
65
|
+
* generic `Error` outside the dev build (the `development` export condition
|
|
66
|
+
* selects the full-fidelity copy; every other resolution sanitizes):
|
|
67
|
+
* its `message`, `stack`, and own-properties are dropped so a driver/ORM
|
|
68
|
+
* error can't leak a failing query or connection string over the wire.
|
|
69
|
+
* Dev builds keep full fidelity. This is the escape hatch for errors whose
|
|
70
|
+
* content is *intentional* client-facing information — brand them and their
|
|
71
|
+
* message/properties travel intact in every environment.
|
|
72
|
+
*
|
|
73
|
+
* The brand is a non-enumerable, symbol-keyed property, so it never itself
|
|
74
|
+
* serializes as an own-property. Sets the brand and returns the same value.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* import { markSafeError } from "@solidjs/web";
|
|
79
|
+
*
|
|
80
|
+
* async function transfer(amount: number) {
|
|
81
|
+
* "use server";
|
|
82
|
+
* if (amount > balance) {
|
|
83
|
+
* // The user must see this message; opt out of sanitization.
|
|
84
|
+
* throw markSafeError(new Error("Insufficient funds"));
|
|
85
|
+
* }
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export function markSafeError<E>(error: E): E;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Whether `value` is branded safe to serialize (via `markSafeError`).
|
|
93
|
+
* Registered-symbol check, correct across duplicated module instances.
|
|
94
|
+
*/
|
|
95
|
+
export function isSafeError(value: unknown): value is Error;
|
|
96
|
+
|
|
52
97
|
/**
|
|
53
98
|
* Response header naming the cache keys a mutation invalidated
|
|
54
99
|
* (`"X-Revalidate"`), comma separated. The response helpers below set it
|