@solidjs/web 2.0.0-rc.2 → 2.0.0-rc.21
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 -1
- package/dist/server.dev.js +5165 -0
- package/dist/server.js +1876 -374
- package/dist/{server.cjs → server.observe.js} +2070 -577
- package/dist/{dev.cjs → web.dev.js} +955 -567
- package/dist/web.js +646 -350
- package/dist/{dev.js → web.observe.js} +699 -421
- package/frames/dist/assets.js +92 -0
- package/frames/dist/client.dev.js +1296 -1198
- package/frames/dist/client.js +1128 -1191
- package/frames/dist/client.observe.js +2041 -0
- package/frames/dist/regions.js +171 -0
- package/frames/dist/server.dev.js +2545 -0
- package/frames/dist/server.js +1683 -3004
- package/frames/dist/server.observe.js +2544 -0
- package/frames/dist/trace.js +45 -0
- package/frames/dist/wire.js +594 -0
- package/frames/package.json +2 -25
- package/package.json +244 -256
- package/performance-tracks/dist/performance-tracks.dev.js +679 -0
- package/performance-tracks/dist/performance-tracks.js +6 -0
- package/performance-tracks/dist/performance-tracks.observe.js +667 -0
- package/performance-tracks/package.json +7 -0
- package/performance-tracks/types/index.d.ts +69 -0
- package/serialization/decode/package.json +2 -15
- package/serialization/dist/decode.js +121 -25
- package/serialization/dist/serialization.js +282 -88
- package/serialization/package.json +2 -15
- package/serialization/types/index.d.ts +115 -153
- package/serialization/types/serializer-decode.d.ts +173 -114
- package/serialization/types/serializer.d.ts +144 -0
- package/server-functions/dist/client.dev.js +1462 -0
- package/server-functions/dist/client.js +667 -165
- package/server-functions/dist/client.observe.js +1441 -0
- package/server-functions/dist/rich-args.js +102 -1
- package/server-functions/dist/server.dev.js +2802 -299
- package/server-functions/dist/server.js +2724 -314
- package/server-functions/dist/server.observe.js +3680 -0
- package/server-functions/package.json +2 -35
- package/server-functions/rich-args/package.json +2 -15
- package/skills/server-components/SKILL.md +117 -0
- package/storage/package.json +2 -15
- package/types/client.d.ts +342 -288
- package/types/constants.d.ts +22 -0
- package/types/cookies.d.ts +32 -84
- package/types/diagnostics.d.ts +80 -0
- package/types/frames/assets-tier.d.ts +78 -0
- package/types/frames/client.d.ts +40 -1
- package/types/frames/frame-client.d.ts +443 -280
- package/types/frames/frame-container-plugin.d.ts +64 -0
- package/types/frames/frame-morph.d.ts +29 -0
- package/types/frames/frame-sink.d.ts +141 -161
- package/types/frames/frame-transport.d.ts +263 -184
- package/types/frames/regions-tier.d.ts +60 -0
- package/types/frames/serializer-decode.d.ts +241 -0
- package/types/frames/serializer.d.ts +115 -153
- package/types/frames/server.d.ts +2 -2
- package/types/frames/trace-tier.d.ts +2 -0
- package/types/frames/tree-rewrite.d.ts +39 -0
- package/types/frames/wire-tier.d.ts +169 -0
- package/types/head.d.ts +20 -0
- package/types/index.d.ts +98 -81
- package/types/index.server.d.ts +159 -0
- package/types/jsx.d.ts +49 -44
- package/types/observe.d.ts +535 -0
- package/types/reconcile.d.ts +1 -0
- package/types/render.d.ts +11 -0
- package/types/request-error-hook.d.ts +5 -0
- package/types/response.d.ts +95 -147
- package/types/serializer-decode.d.ts +173 -114
- package/types/serializer.d.ts +115 -153
- package/types/server-functions/argument-codec.d.ts +30 -0
- package/types/server-functions/client.d.ts +237 -223
- package/types/server-functions/flash.d.ts +28 -30
- package/types/server-functions/registry.d.ts +105 -0
- package/types/server-functions/rich-args.d.ts +1 -10
- package/types/server-functions/server.d.ts +538 -531
- package/types/server-functions/shared.d.ts +398 -425
- package/types/server-functions/uploads.d.ts +53 -0
- package/types/server-mock.d.ts +154 -20
- package/types/server-observe.d.ts +86 -0
- package/types/server.d.ts +601 -422
- package/types/trace.d.ts +127 -0
- package/LICENSE +0 -21
- package/dist/web.cjs +0 -2033
- package/frames/dist/client.cjs +0 -2002
- package/frames/dist/client.dev.cjs +0 -2022
- package/frames/dist/server.cjs +0 -3877
- package/serialization/dist/decode.cjs +0 -139
- package/serialization/dist/serialization.cjs +0 -261
- package/serialization/types-cjs/index.d.cts +0 -182
- package/serialization/types-cjs/package.json +0 -3
- package/serialization/types-cjs/serializer-decode.d.cts +0 -182
- package/server-functions/dist/client.cjs +0 -834
- package/server-functions/dist/rich-args.cjs +0 -11
- package/server-functions/dist/server.cjs +0 -1242
- package/server-functions/dist/server.dev.cjs +0 -1242
- package/storage/dist/storage.cjs +0 -12
- package/storage/types-cjs/index.d.cts +0 -28
- package/storage/types-cjs/package.json +0 -3
- package/types/core.d.ts +0 -9
- package/types-cjs/client.d.cts +0 -337
- package/types-cjs/cookies.d.cts +0 -93
- package/types-cjs/core.d.cts +0 -9
- package/types-cjs/frames/client.d.cts +0 -36
- package/types-cjs/frames/frame-client.d.cts +0 -356
- package/types-cjs/frames/frame-sink.d.cts +0 -194
- package/types-cjs/frames/frame-transport.d.cts +0 -222
- package/types-cjs/frames/serializer.d.cts +0 -182
- package/types-cjs/frames/server.d.cts +0 -52
- package/types-cjs/index.d.cts +0 -244
- package/types-cjs/jsx-properties.d.cts +0 -93
- package/types-cjs/jsx.d.cts +0 -4159
- package/types-cjs/package.json +0 -3
- package/types-cjs/response.d.cts +0 -174
- package/types-cjs/serializer-decode.d.cts +0 -182
- package/types-cjs/serializer.d.cts +0 -182
- package/types-cjs/server-functions/client.d.cts +0 -262
- package/types-cjs/server-functions/flash.d.cts +0 -38
- package/types-cjs/server-functions/rich-args.d.cts +0 -10
- package/types-cjs/server-functions/server.d.cts +0 -681
- package/types-cjs/server-functions/shared.d.cts +0 -523
- package/types-cjs/server-mock.d.cts +0 -286
- package/types-cjs/server.d.cts +0 -544
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seroval's node shape — the intermediate representation `serializeJSON`
|
|
3
|
+
* emits and `createJSONDeserializer` consumes. Safe to `JSON.stringify`.
|
|
4
|
+
* Declared by hand like the plugin types below (same rationale): the
|
|
5
|
+
* observable envelope — a numeric type tag, an optional reference id —
|
|
6
|
+
* with the rest owned by the codec. Real seroval nodes satisfy it; treat
|
|
7
|
+
* it as an opaque token.
|
|
8
|
+
*
|
|
9
|
+
* Integration-facing; may change (see the entry banner).
|
|
10
|
+
*/
|
|
11
|
+
export interface SerovalNode {
|
|
12
|
+
/** Node type tag (seroval-internal enum). */
|
|
13
|
+
t: number;
|
|
14
|
+
/** Reference id, when the node participates in cross-referencing. */
|
|
15
|
+
i?: number | undefined;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
/** Per-plugin bookkeeping seroval hands each plugin callback. */
|
|
19
|
+
export interface PluginData {
|
|
20
|
+
id: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The shape of a plugin's parsed payload: a map of `SerovalNode`s produced
|
|
24
|
+
* by the parse contexts, consumed by `serialize`/`deserialize`.
|
|
25
|
+
*/
|
|
26
|
+
export type PluginInfo = {
|
|
27
|
+
[key: string]: SerovalNode;
|
|
28
|
+
};
|
|
29
|
+
/** Parse context for `parse.sync`: turns child values into nodes. */
|
|
30
|
+
export interface SyncParsePluginContext {
|
|
31
|
+
parse<T>(current: T): SerovalNode;
|
|
32
|
+
}
|
|
33
|
+
/** Parse context for `parse.async`: like sync, but child parses await. */
|
|
34
|
+
export interface AsyncParsePluginContext {
|
|
35
|
+
parse<T>(current: T): Promise<SerovalNode>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Parse context for `parse.stream`: sync parsing plus the streaming
|
|
39
|
+
* lifecycle (pending-state tracking, late node emission, cleanup).
|
|
40
|
+
*/
|
|
41
|
+
export interface StreamParsePluginContext {
|
|
42
|
+
parse<T>(current: T): SerovalNode;
|
|
43
|
+
parseWithError<T>(current: T): SerovalNode | undefined;
|
|
44
|
+
isAlive(): boolean;
|
|
45
|
+
pushPendingState(): void;
|
|
46
|
+
popPendingState(): void;
|
|
47
|
+
onParse(node: SerovalNode): void;
|
|
48
|
+
onError(error: unknown): void;
|
|
49
|
+
addCleanup(callback: () => void): void;
|
|
50
|
+
}
|
|
51
|
+
/** Serialize context: renders child nodes to JS source. */
|
|
52
|
+
export interface SerializePluginContext {
|
|
53
|
+
serialize(node: SerovalNode): string;
|
|
54
|
+
}
|
|
55
|
+
/** Deserialize context: revives child nodes to runtime values. */
|
|
56
|
+
export interface DeserializePluginContext {
|
|
57
|
+
deserialize<T>(node: SerovalNode): T;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A Seroval plugin usable with the web serializers — teaches the codec how
|
|
61
|
+
* to encode/decode a custom value type (`Value` is the value it matches,
|
|
62
|
+
* `Info` its parsed payload). Supply matching plugins on both peers of a
|
|
63
|
+
* transport. Bare `SerializerPlugin` (both parameters defaulted to `any`)
|
|
64
|
+
* is the list-element type every `plugins` option accepts.
|
|
65
|
+
*
|
|
66
|
+
* Integration-facing; may change (see the entry banner).
|
|
67
|
+
*/
|
|
68
|
+
export interface SerializerPlugin<Value = any, Info extends PluginInfo = any> {
|
|
69
|
+
/** A unique string identifying the plugin — namespace it (`"app/Thing"`). */
|
|
70
|
+
tag: string;
|
|
71
|
+
/** Dependency plugins, resolved ahead of this one. */
|
|
72
|
+
extends?: SerializerPlugin[];
|
|
73
|
+
/** Whether `value` is this plugin's to encode. */
|
|
74
|
+
test(value: unknown): boolean;
|
|
75
|
+
/** Parsing modes — provide the ones the transports you target use. */
|
|
76
|
+
parse: {
|
|
77
|
+
sync?: (value: Value, ctx: SyncParsePluginContext, data: PluginData) => Info;
|
|
78
|
+
async?: (value: Value, ctx: AsyncParsePluginContext, data: PluginData) => Promise<Info>;
|
|
79
|
+
stream?: (value: Value, ctx: StreamParsePluginContext, data: PluginData) => Info;
|
|
80
|
+
};
|
|
81
|
+
/** Renders the parsed payload as JS source (script-injection form). */
|
|
82
|
+
serialize(node: Info, ctx: SerializePluginContext, data: PluginData): string;
|
|
83
|
+
/** Revives the parsed payload back into the runtime value. */
|
|
84
|
+
deserialize(node: Info, ctx: DeserializePluginContext, data: PluginData): Value;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Options shared by both halves of the JSON codec. All of them must match
|
|
88
|
+
* on the serializing and deserializing peer or payloads will not
|
|
89
|
+
* round-trip — for server functions, set them once through the
|
|
90
|
+
* client/server `codec` config option.
|
|
91
|
+
*
|
|
92
|
+
* Integration-facing; may change (see the entry banner).
|
|
93
|
+
*/
|
|
94
|
+
export interface JSONCodecOptions {
|
|
95
|
+
/** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. Must match on both peers. */
|
|
96
|
+
plugins?: SerializerPlugin[];
|
|
97
|
+
/**
|
|
98
|
+
* Seroval feature bitflags to exclude. Defaults to disabling `RegExp`
|
|
99
|
+
* (payloads may come from an untrusted peer). Must match on both peers.
|
|
100
|
+
* Outside development, the encoding side additionally strips
|
|
101
|
+
* `Error.prototype.stack` on top of any override — serialized stacks leak
|
|
102
|
+
* server paths to the client. Decoding stays permissive, so payloads from
|
|
103
|
+
* a development peer still round-trip.
|
|
104
|
+
*/
|
|
105
|
+
disabledFeatures?: number;
|
|
106
|
+
/** Maximum parse/deserialize depth. Defaults to 64. Must match on both peers. */
|
|
107
|
+
depthLimit?: number;
|
|
108
|
+
/**
|
|
109
|
+
* Whether serialized `Error`s carry their `.stack` — server file paths,
|
|
110
|
+
* internal function names, the shape of the deployment — to the peer.
|
|
111
|
+
* Defaults to `NODE_ENV === "development"`, but that signal describes the
|
|
112
|
+
* PROCESS, not the artifact: a production build running with
|
|
113
|
+
* `NODE_ENV=development` (a base image, a stray dotenv) ships stacks to
|
|
114
|
+
* the wire — including for errors marked safe with `markSafeError`, whose
|
|
115
|
+
* stacks traverse application code (#3152). Set `false` to pin production
|
|
116
|
+
* disclosure regardless of the ambient variable. Encode-side only; the
|
|
117
|
+
* decode side is always permissive, so it need not match peers.
|
|
118
|
+
*/
|
|
119
|
+
serializeErrorStacks?: boolean;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* A resident, response-scoped decode table over the keyed JSON codec: apply
|
|
123
|
+
* each frame `data` chunk with `apply`, resolve `{ $ref }` slot args with
|
|
124
|
+
* `resolve`, and `close` it when the response ends. The frames client host
|
|
125
|
+
* wires one per response (`applyData: c => table.apply(c)`,
|
|
126
|
+
* `closeData: (…) => table.close(error)`).
|
|
127
|
+
*
|
|
128
|
+
* A `{ $ref }` to a key no `apply` has delivered yet is a PENDING READ the
|
|
129
|
+
* table owns (`@internal` behaviour — the frames client is its consumer): a
|
|
130
|
+
* promise marked `s = 0`, settled by the key's `apply` and rejected by
|
|
131
|
+
* `close` — the response ended without delivering the key, so a value that
|
|
132
|
+
* never comes is an error where it is read, not a silence. Stamped `s`/`v`
|
|
133
|
+
* as it settles (`1` fulfilled, `2` rejected — the hydration serializer's
|
|
134
|
+
* marks, which a reader adopts synchronously).
|
|
135
|
+
*
|
|
136
|
+
* Integration-facing; may change (see the entry banner). This serialization
|
|
137
|
+
* entry is the single home of the data table — the frames client consumes
|
|
138
|
+
* it internally rather than re-exporting it.
|
|
139
|
+
*/
|
|
140
|
+
export interface JSONDataTable {
|
|
141
|
+
apply(chunk: {
|
|
142
|
+
key?: string;
|
|
143
|
+
node?: unknown;
|
|
144
|
+
initial?: boolean;
|
|
145
|
+
}): void;
|
|
146
|
+
/**
|
|
147
|
+
* The value under `ref`, or the table's pending read of it: a promise
|
|
148
|
+
* marked `s = 0` carrying `c`, the callbacks the table runs in the
|
|
149
|
+
* `apply` / `close` that settles it — the key delivered (whatever its
|
|
150
|
+
* value's shape: a delivered promise is adopted by the read, the
|
|
151
|
+
* callbacks do not wait for it) or the table closed.
|
|
152
|
+
*/
|
|
153
|
+
resolve<T = unknown>(ref: {
|
|
154
|
+
$ref: string;
|
|
155
|
+
}): T;
|
|
156
|
+
/**
|
|
157
|
+
* The response has ended: every pending read of a key it never
|
|
158
|
+
* delivered rejects — with `error` (the response's own) when given, with
|
|
159
|
+
* an `Error` naming the key otherwise. Idempotent.
|
|
160
|
+
*/
|
|
161
|
+
close(error?: unknown): void;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Baseline plugin set for serializing web-platform values. Shared by the
|
|
165
|
+
* hydration serializer and any consumer building its own serializer (e.g.
|
|
166
|
+
* server function transports). Plugin objects carry both their serialize
|
|
167
|
+
* and deserialize halves, so the set lives on the decode side and the
|
|
168
|
+
* encode module composes over it.
|
|
169
|
+
*/
|
|
170
|
+
export declare const DEFAULT_WEB_PLUGINS: readonly ({
|
|
171
|
+
tag: string;
|
|
172
|
+
test(value: any): boolean;
|
|
173
|
+
parse: {
|
|
174
|
+
sync(): never;
|
|
175
|
+
async(value: any, ctx: any): Promise<{
|
|
176
|
+
a: number;
|
|
177
|
+
i: any;
|
|
178
|
+
}>;
|
|
179
|
+
stream: (value: any, ctx: any) => {
|
|
180
|
+
a: number;
|
|
181
|
+
i: any;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
serialize(node: any, ctx: any): string;
|
|
185
|
+
deserialize(node: any, ctx: any): any;
|
|
186
|
+
} | import("seroval").Plugin<AbortSignal, {
|
|
187
|
+
reason?: import("seroval").SerovalNode;
|
|
188
|
+
controller?: import("seroval").SerovalNode;
|
|
189
|
+
factory?: import("seroval").SerovalNode;
|
|
190
|
+
}> | import("seroval").Plugin<CustomEvent<any>, {
|
|
191
|
+
type: import("seroval").SerovalNode;
|
|
192
|
+
options: import("seroval").SerovalNode;
|
|
193
|
+
}> | import("seroval").Plugin<DOMException, {
|
|
194
|
+
name: import("seroval").SerovalNode;
|
|
195
|
+
message: import("seroval").SerovalNode;
|
|
196
|
+
}> | import("seroval").Plugin<Event, {
|
|
197
|
+
type: import("seroval").SerovalNode;
|
|
198
|
+
options: import("seroval").SerovalNode;
|
|
199
|
+
}> | import("seroval").Plugin<FormData, {
|
|
200
|
+
factory: import("seroval").SerovalNode;
|
|
201
|
+
entries: import("seroval").SerovalNode;
|
|
202
|
+
}> | import("seroval").Plugin<Headers, {
|
|
203
|
+
value: import("seroval").SerovalNode;
|
|
204
|
+
}> | import("seroval").Plugin<ReadableStream<any>, {
|
|
205
|
+
factory: import("seroval").SerovalNode;
|
|
206
|
+
stream: import("seroval").SerovalNode;
|
|
207
|
+
}> | import("seroval").Plugin<Request, {
|
|
208
|
+
url: import("seroval").SerovalNode;
|
|
209
|
+
options: import("seroval").SerovalNode;
|
|
210
|
+
}> | import("seroval").Plugin<Response, {
|
|
211
|
+
body: import("seroval").SerovalNode;
|
|
212
|
+
options: import("seroval").SerovalNode;
|
|
213
|
+
}> | import("seroval").Plugin<URLSearchParams, {
|
|
214
|
+
value: import("seroval").SerovalNode;
|
|
215
|
+
}> | import("seroval").Plugin<URL, {
|
|
216
|
+
value: import("seroval").SerovalNode;
|
|
217
|
+
}>)[]; /**
|
|
218
|
+
* Composes custom plugins with `DEFAULT_WEB_PLUGINS`. Custom plugins come
|
|
219
|
+
* first so they can shadow a default for values both would match. Returns a
|
|
220
|
+
* fresh array; the defaults are never mutated. Useful when handing a full
|
|
221
|
+
* plugin list to another serialization layer.
|
|
222
|
+
*
|
|
223
|
+
* Integration-facing; may change (see the entry banner).
|
|
224
|
+
*/
|
|
225
|
+
export declare function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
|
|
226
|
+
export declare function resolveCodecOptions(options?: JSONCodecOptions): {
|
|
227
|
+
plugins: any;
|
|
228
|
+
disabledFeatures: number;
|
|
229
|
+
depthLimit: number;
|
|
230
|
+
serializeErrorStacks: boolean;
|
|
231
|
+
}; /**
|
|
232
|
+
* Creates the decoding counterpart of `serializeJSON`. Cross-references
|
|
233
|
+
* between chunks resolve through state shared across calls, so all chunks
|
|
234
|
+
* from one stream must go through the same deserializer instance. The first
|
|
235
|
+
* chunk's return value is the decoded source value; feeding later chunks
|
|
236
|
+
* settles the async values referenced inside it.
|
|
237
|
+
*
|
|
238
|
+
* Integration-facing; may change (see the entry banner).
|
|
239
|
+
*/
|
|
240
|
+
export declare function createJSONDeserializer(options?: JSONCodecOptions): <T>(node: SerovalNode) => T;
|
|
241
|
+
export declare function createJSONDataTable(options?: JSONCodecOptions): JSONDataTable;
|
|
@@ -1,88 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
1
|
+
import { Serializer } from "seroval";
|
|
2
|
+
import type { JSONCodecOptions, PluginInfo, SerializerPlugin, SerovalNode } from "./serializer-decode.js";
|
|
3
|
+
export { DEFAULT_WEB_PLUGINS, createJSONDataTable, createJSONDeserializer, resolveSerializerPlugins } from "./serializer-decode.js";
|
|
4
|
+
export type * from "./serializer-decode.js";
|
|
32
5
|
/**
|
|
33
|
-
*
|
|
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.
|
|
6
|
+
* Options for `createSerializer`.
|
|
38
7
|
*
|
|
39
|
-
*
|
|
8
|
+
* Integration-facing; may change (see the entry banner).
|
|
40
9
|
*/
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
10
|
+
export interface WebSerializerOptions {
|
|
11
|
+
/** Name of the global object the emitted scripts write resolved values into. */
|
|
12
|
+
globalIdentifier: string;
|
|
13
|
+
/** Cross-reference scope id, for isolating multiple streams on one page. */
|
|
14
|
+
scopeId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Seroval feature bitflags to exclude from output. Defaults to disabling
|
|
17
|
+
* post-ES2017 features (AggregateError, BigInt typed arrays). Outside
|
|
18
|
+
* development, `Error.prototype.stack` is additionally stripped on top of
|
|
19
|
+
* any override — serialized stacks leak server paths to the client.
|
|
20
|
+
*/
|
|
21
|
+
disabledFeatures?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Whether serialized `Error`s carry their `.stack`. Defaults to
|
|
24
|
+
* `NODE_ENV === "development"`; set `false` to pin production disclosure
|
|
25
|
+
* to the deployment rather than the ambient variable (#3152 — see
|
|
26
|
+
* `JSONCodecOptions.serializeErrorStacks`).
|
|
27
|
+
*/
|
|
28
|
+
serializeErrorStacks?: boolean;
|
|
29
|
+
/** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. */
|
|
30
|
+
plugins?: SerializerPlugin[];
|
|
31
|
+
/** Receives each emitted script chunk. */
|
|
32
|
+
onData: (result: string) => void;
|
|
33
|
+
onError?: (error: unknown) => void;
|
|
34
|
+
/** Fires once all async values have settled. */
|
|
35
|
+
onDone?: () => void;
|
|
36
|
+
}
|
|
45
37
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* staying readable in-process through `.value`.
|
|
51
|
-
*
|
|
52
|
-
* Application-facing (see the plugin-authoring banner above).
|
|
38
|
+
* Options for `createHydrationSerializer` — `WebSerializerOptions` minus
|
|
39
|
+
* the knobs hydration pins (`globalIdentifier`, `disabledFeatures`,
|
|
40
|
+
* `serializeErrorStacks`: its stacks follow `NODE_ENV`).
|
|
41
|
+
* @internal
|
|
53
42
|
*/
|
|
54
|
-
export
|
|
55
|
-
readonly value: V;
|
|
56
|
-
readonly replacement?: R;
|
|
57
|
-
constructor(value: V, replacement?: R);
|
|
58
|
-
}
|
|
59
|
-
|
|
43
|
+
export type HydrationSerializerOptions = Omit<WebSerializerOptions, "globalIdentifier" | "disabledFeatures" | "serializeErrorStacks">;
|
|
60
44
|
/**
|
|
61
|
-
* Options for `
|
|
45
|
+
* Options for `serializeJSON`.
|
|
62
46
|
*
|
|
63
47
|
* Integration-facing; may change (see the entry banner).
|
|
64
48
|
*/
|
|
65
|
-
export interface
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
49
|
+
export interface JSONSerializeOptions extends JSONCodecOptions {
|
|
50
|
+
/**
|
|
51
|
+
* Receives each serialized node; `initial` is true for the first chunk
|
|
52
|
+
* (the source value itself). Async values produce additional chunks as
|
|
53
|
+
* they resolve.
|
|
54
|
+
*/
|
|
55
|
+
onParse: (node: SerovalNode, initial: boolean) => void;
|
|
56
|
+
onError?: (error: unknown) => void;
|
|
57
|
+
/** Fires once all async values have settled. */
|
|
58
|
+
onDone?: () => void;
|
|
59
|
+
}
|
|
60
|
+
/** Options for `createJSONSerializer`. */
|
|
61
|
+
export interface JSONSerializerOptions extends JSONCodecOptions {
|
|
62
|
+
/**
|
|
63
|
+
* Receives each keyed record — `initial` is true for a key's first node
|
|
64
|
+
* (the written value itself); async values patch through later records
|
|
65
|
+
* under the same key. The decoding peer is `createJSONDataTable`.
|
|
66
|
+
*/
|
|
67
|
+
onData: (record: {
|
|
68
|
+
key: string;
|
|
69
|
+
node: SerovalNode;
|
|
70
|
+
initial: boolean;
|
|
71
|
+
}) => void;
|
|
72
|
+
onError?: (error: unknown) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Fires once `flush()` has been called and every pending value settled, or
|
|
75
|
+
* once `close()` runs.
|
|
76
|
+
*/
|
|
77
|
+
onDone?: () => void;
|
|
84
78
|
}
|
|
85
|
-
|
|
79
|
+
export declare const createPlugin: <Value, Info extends PluginInfo>(plugin: SerializerPlugin<Value, Info>) => SerializerPlugin<Value, Info>;
|
|
80
|
+
export interface OpaqueReference<V = unknown, R = undefined> {
|
|
81
|
+
readonly value: V;
|
|
82
|
+
readonly replacement?: R;
|
|
83
|
+
}
|
|
84
|
+
export declare const OpaqueReference: {
|
|
85
|
+
new <V, R = undefined>(value: V, replacement?: R): OpaqueReference<V, R>;
|
|
86
|
+
};
|
|
86
87
|
/**
|
|
87
88
|
* Creates a streaming Seroval serializer preconfigured with the web plugin
|
|
88
89
|
* set and the default feature policy. Emits JavaScript chunks (through
|
|
@@ -93,90 +94,51 @@ export interface WebSerializerOptions {
|
|
|
93
94
|
*
|
|
94
95
|
* Integration-facing; may change (see the entry banner).
|
|
95
96
|
*/
|
|
96
|
-
export function createSerializer(options: WebSerializerOptions): Serializer;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
*/
|
|
103
|
-
export type HydrationSerializerOptions = Omit<
|
|
104
|
-
WebSerializerOptions,
|
|
105
|
-
"globalIdentifier" | "disabledFeatures"
|
|
106
|
-
>;
|
|
107
|
-
|
|
97
|
+
export declare function createSerializer(options: WebSerializerOptions): Serializer;
|
|
98
|
+
export declare function createHydrationSerializer(options: HydrationSerializerOptions): {
|
|
99
|
+
write(key: string, value: unknown): void;
|
|
100
|
+
flush(): void;
|
|
101
|
+
close(): void;
|
|
102
|
+
};
|
|
108
103
|
/**
|
|
109
|
-
*
|
|
110
|
-
* the
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
104
|
+
* `createHydrationSerializer`'s `late`, which wraps its seroval session
|
|
105
|
+
* per write: rejects, on the client, what a write that failed to serialize
|
|
106
|
+
* midstream left pending (#4647; maintainer ruling,
|
|
107
|
+
* 2026-11-03). seroval 1.7 ends a write at its first failure without
|
|
108
|
+
* settling anything it already declared: the key's promise, a promise or
|
|
109
|
+
* async iterable nested in a value it already sent, each would stay pending
|
|
110
|
+
* forever. Every promise the write sent is rejected (its resolver is indexed
|
|
111
|
+
* right after it, `parsePromise`) and every stream it sent is thrown into,
|
|
112
|
+
* with one error naming the key; one that already settled ignores it. The
|
|
113
|
+
* failure's own text went to the error hook and is not sent. The promise is
|
|
114
|
+
* left unmarked (no `s`/`v`, which seroval's own failure call sets for
|
|
115
|
+
* synchronous adoption): the hydrating read sees it pending and takes the
|
|
116
|
+
* rejection after the claim pass, so the reading computation throws into
|
|
117
|
+
* the nearest `<Errored>`, whose fallback then replaces the server's
|
|
118
|
+
* content. Read synchronously, the fallback would be built in the claim pass
|
|
119
|
+
* against markup that is the content's.
|
|
120
|
+
*
|
|
121
|
+
* Which write a reference belongs to: seroval indexes a value into the
|
|
122
|
+
* shared `refs` as it parses it and hands the chunk that declares it to that
|
|
123
|
+
* write's `onSerialize` in the same synchronous step, so the indexes taken
|
|
124
|
+
* since the last chunk are the next chunk's, or the failed parse's when the
|
|
125
|
+
* write fails instead. Those never went out: they leave `refs`, or a later
|
|
126
|
+
* write reaching the same value (a second key on the same promise) would
|
|
127
|
+
* reference a slot the client never filled and resolve `undefined`; it
|
|
128
|
+
* parses the value again and fails on its own. seroval takes the next index
|
|
129
|
+
* from `refs.size`, so the size counts every index ever taken.
|
|
114
130
|
* @internal
|
|
115
131
|
*/
|
|
116
|
-
export function
|
|
117
|
-
|
|
118
|
-
/**
|
|
132
|
+
export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any): (key: any, value: any, callbacks: any, live: any) => any; /**
|
|
119
133
|
* Renderer primitive — returns the cross-reference bootstrap script SSR
|
|
120
134
|
* emits ahead of hydration data for a render scope. Not meant for
|
|
121
135
|
* hand-written code.
|
|
122
136
|
* @internal
|
|
123
137
|
*/
|
|
124
|
-
export function getLocalHeaderScript(id?: string): string;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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;
|
|
138
|
+
export declare function getLocalHeaderScript(id?: string): string;
|
|
139
|
+
export declare function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
|
|
140
|
+
export declare function createJSONSerializer(options: JSONSerializerOptions): {
|
|
141
|
+
write(key: string, value: unknown): void;
|
|
142
|
+
flush(): void;
|
|
143
|
+
close(): void;
|
|
182
144
|
};
|
package/types/frames/server.d.ts
CHANGED
|
@@ -48,5 +48,5 @@ export type Slot<P = {}> = (props: P & {
|
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
50
|
export declare function asyncArg<T>(value: PromiseLike<T> | AsyncIterable<T>): T;
|
|
51
|
-
export {
|
|
52
|
-
export { FRAME_STREAM_HEADER, isFrameStreamResponse } from "./frame-transport.js";
|
|
51
|
+
export { frameTransformResult, frameTransformFlightResult, frameTransformDirectResult, ServerComponentPlugin, SERVER_COMPONENT_BOOTSTRAP } from "./frame-sink.js";
|
|
52
|
+
export { FRAME_STREAM_HEADER, FRAME_HAVE_HEADER, FRAME_HAVE_BUDGET, FRAME_TIERS_HEADER, isFrameStreamResponse } from "./frame-transport.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy-on-write rewrite of a value tree, for the serialization-border walks
|
|
3
|
+
* (`toBorderForm` — every document-face serialization and every slot-arg
|
|
4
|
+
* record — and the slot-arg stand-in scrub). `visit(value, path)` is asked
|
|
5
|
+
* at every OBJECT node first (primitives pass through unasked: no visitor
|
|
6
|
+
* replaces one, and leaves are most of a payload) and answers with the
|
|
7
|
+
* node's replacement, or `DESCEND` to walk the node's leaves — which
|
|
8
|
+
* happens for a plain array or plain object only; anything else (a class
|
|
9
|
+
* instance, a `Map`, a proxy) is the app's and passes through untouched.
|
|
10
|
+
*
|
|
11
|
+
* Author values are never mutated. The walk is plain recursion, copy-on-
|
|
12
|
+
* write: an untouched subtree passes by reference, a changed one is copied
|
|
13
|
+
* along the path to the root. That is the whole cost for acyclic data of
|
|
14
|
+
* ordinary depth (measured below what `next`'s direct recursion paid, the
|
|
15
|
+
* primitive short-circuit buying more than the visitor call costs).
|
|
16
|
+
*
|
|
17
|
+
* A back-reference to an ancestor has no copy-on-write answer (the copy's
|
|
18
|
+
* back-reference would point at the original, unrewritten), and tracking
|
|
19
|
+
* ancestors at every node would tax every walk. So ancestors are tracked
|
|
20
|
+
* only from a depth ordinary payloads never reach (`TRACK`): a cycle is
|
|
21
|
+
* caught within one cycle-length past it, the pass aborts and the tree is
|
|
22
|
+
* rewritten again as a memoized clone — one copy per container, a back-
|
|
23
|
+
* reference resolving to the ancestor's copy. Only cyclic (or unusually
|
|
24
|
+
* deep) values pay. Replacements are recorded as they are produced (a trace
|
|
25
|
+
* envelope, a multicast seat, a scrubbed stand-in): a node seen again on
|
|
26
|
+
* the first pass — a cycle revisits its nodes on every level down to the
|
|
27
|
+
* catch — and every node of the clone pass answer from the record, so a
|
|
28
|
+
* visitor's side effects run once per node whichever way the walk went.
|
|
29
|
+
* Walks that replace nothing never pay the lookup. A value reachable at two
|
|
30
|
+
* paths is one node: its replacement is shared (one seat for one iterable —
|
|
31
|
+
* the identity the input had, which the serializer writes once and the
|
|
32
|
+
* client materializes once), and a shared subtree with nothing to replace
|
|
33
|
+
* is visited at each occurrence on the first pass and once on the clone
|
|
34
|
+
* pass. `path` is built (`.key`, `[i]`) only when `withPath`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const DESCEND: unique symbol;
|
|
37
|
+
type Visit = (value: object, path: string | undefined) => any;
|
|
38
|
+
export declare function rewriteTree(value: any, visit: Visit, withPath: boolean): any;
|
|
39
|
+
export {};
|