@solidjs/web 2.0.0-rc.2 → 2.0.0-rc.3
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/dist/dev.cjs +86 -61
- package/dist/dev.js +81 -60
- package/dist/server.cjs +34 -17
- package/dist/server.js +35 -19
- package/dist/web.cjs +83 -59
- package/dist/web.js +78 -58
- package/frames/dist/client.cjs +8 -8
- package/frames/dist/client.dev.cjs +8 -8
- package/frames/dist/client.dev.js +8 -8
- package/frames/dist/client.js +8 -8
- package/frames/dist/server.cjs +28 -18
- package/frames/dist/server.js +29 -19
- package/package.json +20 -22
- package/serialization/dist/decode.cjs +3 -3
- package/serialization/dist/decode.js +3 -3
- package/serialization/dist/serialization.cjs +7 -11
- package/serialization/dist/serialization.js +7 -6
- package/serialization/types/index.d.ts +69 -157
- package/serialization/types/serializer-decode.d.ts +89 -112
- package/serialization/types/serializer.d.ts +94 -0
- package/serialization/types-cjs/index.d.cts +69 -157
- package/serialization/types-cjs/serializer-decode.d.cts +89 -112
- package/serialization/types-cjs/serializer.d.cts +94 -0
- package/types/client.d.ts +150 -290
- package/types/constants.d.ts +18 -0
- package/types/cookies.d.ts +31 -75
- package/types/frames/frame-client.d.ts +287 -277
- package/types/frames/frame-container-plugin.d.ts +71 -0
- package/types/frames/frame-sink.d.ts +58 -160
- package/types/frames/frame-transport.d.ts +161 -194
- package/types/frames/serializer-decode.d.ts +159 -0
- package/types/frames/serializer.d.ts +69 -157
- package/types/head.d.ts +16 -0
- package/types/index.d.ts +0 -65
- package/types/index.server.d.ts +125 -0
- package/types/jsx.d.ts +5 -13
- package/types/reconcile.d.ts +1 -0
- package/types/render.d.ts +4 -0
- package/types/response.d.ts +41 -153
- package/types/serializer-decode.d.ts +89 -112
- package/types/serializer.d.ts +69 -157
- package/types/server-functions/client.d.ts +93 -222
- package/types/server-functions/flash.d.ts +10 -30
- package/types/server-functions/registry.d.ts +63 -0
- package/types/server-functions/rich-args.d.ts +1 -10
- package/types/server-functions/server.d.ts +292 -574
- package/types/server-functions/shared.d.ts +112 -458
- package/types/server-mock.d.ts +2 -2
- package/types/server.d.ts +242 -434
- package/types-cjs/client.d.cts +150 -290
- package/types-cjs/constants.d.cts +18 -0
- package/types-cjs/cookies.d.cts +31 -75
- package/types-cjs/frames/frame-client.d.cts +287 -277
- package/types-cjs/frames/frame-container-plugin.d.cts +71 -0
- package/types-cjs/frames/frame-sink.d.cts +58 -160
- package/types-cjs/frames/frame-transport.d.cts +161 -194
- package/types-cjs/frames/serializer-decode.d.cts +159 -0
- package/types-cjs/frames/serializer.d.cts +69 -157
- package/types-cjs/head.d.cts +16 -0
- package/types-cjs/index.d.cts +0 -65
- package/types-cjs/index.server.d.cts +125 -0
- package/types-cjs/jsx.d.cts +5 -13
- package/types-cjs/reconcile.d.cts +1 -0
- package/types-cjs/render.d.cts +4 -0
- package/types-cjs/response.d.cts +41 -153
- package/types-cjs/serializer-decode.d.cts +89 -112
- package/types-cjs/serializer.d.cts +69 -157
- package/types-cjs/server-functions/client.d.cts +93 -222
- package/types-cjs/server-functions/flash.d.cts +10 -30
- package/types-cjs/server-functions/registry.d.cts +63 -0
- package/types-cjs/server-functions/rich-args.d.cts +1 -10
- package/types-cjs/server-functions/server.d.cts +292 -574
- package/types-cjs/server-functions/shared.d.cts +112 -458
- package/types-cjs/server-mock.d.cts +2 -2
- package/types-cjs/server.d.cts +242 -434
- package/LICENSE +0 -21
- package/types/core.d.ts +0 -9
- package/types-cjs/core.d.cts +0 -9
package/types/response.d.ts
CHANGED
|
@@ -1,174 +1,62 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Envelope pairing HTTP metadata
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
constructor(response: Response | undefined, value: T);
|
|
12
|
-
/** The HTTP metadata: status and headers to forward (body ignored by integrations). */
|
|
13
|
-
response: Response | undefined;
|
|
14
|
-
/** The structured value the caller receives. */
|
|
15
|
-
value: T;
|
|
2
|
+
* Envelope pairing HTTP metadata with a value. Produced by `respond()` and
|
|
3
|
+
* by server-function `transformResult` implementations (e.g. single-flight
|
|
4
|
+
* payloads); the HTTP handler forwards `response`'s headers and
|
|
5
|
+
* (non-redirect) status and encodes `value` as the body through the codec,
|
|
6
|
+
* while client-only integrations read `value` directly — no reparse.
|
|
7
|
+
*/
|
|
8
|
+
export interface ResponseEnvelope<T = unknown> {
|
|
9
|
+
response: Response | undefined;
|
|
10
|
+
value: T;
|
|
16
11
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* this over `instanceof`.
|
|
23
|
-
*/
|
|
24
|
-
export function isResponseEnvelope(value: unknown): value is ResponseEnvelope;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Registered-symbol brand (`Symbol.for("solid.Href")`) marking URL-bearing
|
|
28
|
-
* values. Declared `unique symbol` type-side; the runtime value is the
|
|
29
|
-
* registered symbol, so separately bundled copies agree on identity.
|
|
30
|
-
*/
|
|
12
|
+
export declare const ResponseEnvelope: {
|
|
13
|
+
new <T>(response: Response | undefined, value: T): ResponseEnvelope<T>;
|
|
14
|
+
};
|
|
15
|
+
/** Whether `value` is a `ResponseEnvelope` (robust across module copies). */
|
|
16
|
+
export declare function isResponseEnvelope(value: unknown): value is ResponseEnvelope;
|
|
31
17
|
export declare const HREF: unique symbol;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* A URL-bearing value: coerces to its URL via `toString()` and carries the
|
|
35
|
-
* `HREF` registered-symbol brand. Integrations mint these (e.g. a router's
|
|
36
|
-
* typed path objects answer the brand from their proxy) and URL-accepting
|
|
37
|
-
* APIs like `redirect()` accept them alongside plain strings. The brand is
|
|
38
|
-
* what makes the type meaningful — every object has `toString()`.
|
|
39
|
-
*/
|
|
40
18
|
export interface Href {
|
|
41
|
-
|
|
42
|
-
|
|
19
|
+
[HREF]: true;
|
|
20
|
+
toString(): string;
|
|
43
21
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* Whether `value` is an `Href`-branded URL-bearing value. Registered-symbol
|
|
47
|
-
* check, so it stays correct across duplicated module instances — same
|
|
48
|
-
* rationale as `isResponseEnvelope`.
|
|
49
|
-
*/
|
|
50
|
-
export function isHref(value: unknown): value is Href;
|
|
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
|
-
*/
|
|
22
|
+
/** Whether `value` is an `Href`-branded URL-bearing value. */
|
|
23
|
+
export declare function isHref(value: unknown): value is Href;
|
|
58
24
|
export declare const SAFE_ERROR: unique symbol;
|
|
59
|
-
|
|
60
25
|
/**
|
|
61
26
|
* Marks `error` as safe to serialize to the client verbatim, opting it out
|
|
62
|
-
* of
|
|
63
|
-
*
|
|
64
|
-
*
|
|
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.
|
|
27
|
+
* of production error sanitization (see `handleServerFunctionRequest`). Use
|
|
28
|
+
* for errors whose message/properties are intentional client-facing content.
|
|
29
|
+
* Returns the same value for convenient `throw markSafeError(new Error(...))`.
|
|
94
30
|
*/
|
|
95
|
-
export function
|
|
96
|
-
|
|
31
|
+
export declare function markSafeError<E>(error: E): E;
|
|
32
|
+
/** Whether `value` is branded safe to serialize (robust across module copies). */
|
|
33
|
+
export declare function isSafeError(value: unknown): value is Error;
|
|
97
34
|
/**
|
|
98
|
-
* Response header naming the cache keys a mutation invalidated
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* Core never inspects the keys, so how they are matched (prefixes, exact
|
|
103
|
-
* names, namespaces) is the integration's business.
|
|
35
|
+
* Response header naming the cache keys a mutation invalidated, comma
|
|
36
|
+
* separated. Set by the helpers below and read by the client transport and
|
|
37
|
+
* by integrations; core never inspects the keys, so how they are matched
|
|
38
|
+
* (prefixes, exact names, namespaces) is the integration's business.
|
|
104
39
|
*/
|
|
105
|
-
export const REVALIDATE_HEADER
|
|
106
|
-
|
|
40
|
+
export declare const REVALIDATE_HEADER = "X-Revalidate";
|
|
107
41
|
/** `ResponseInit` accepted by the response helpers, plus `revalidate`. */
|
|
108
42
|
export interface ResponseHelperInit extends ResponseInit {
|
|
109
|
-
|
|
110
|
-
* Cache keys the mutation invalidated, carried in the `X-Revalidate`
|
|
111
|
-
* header. Opaque to the protocol — the integration's keyed cache (e.g.
|
|
112
|
-
* the router's `query` cache) assigns them meaning.
|
|
113
|
-
*/
|
|
114
|
-
revalidate?: string | string[];
|
|
43
|
+
revalidate?: string | string[];
|
|
115
44
|
}
|
|
116
|
-
|
|
117
45
|
/**
|
|
118
|
-
* Response redirecting to `url` (default
|
|
119
|
-
*
|
|
120
|
-
* client integration to follow — or return it from a client-side action,
|
|
121
|
-
* where the integration interprets it in memory. Same object, same
|
|
122
|
-
* meaning, both sides.
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```ts
|
|
126
|
-
* import { redirect } from "@solidjs/web";
|
|
127
|
-
*
|
|
128
|
-
* async function login(form: FormData) {
|
|
129
|
-
* "use server";
|
|
130
|
-
* // ...
|
|
131
|
-
* return redirect("/dashboard", { revalidate: "session" });
|
|
132
|
-
* }
|
|
133
|
-
* ```
|
|
46
|
+
* Response redirecting to `url` (default 302). `revalidate` names the
|
|
47
|
+
* cache keys the mutation invalidated.
|
|
134
48
|
*/
|
|
135
|
-
export function redirect(url: string | Href, init?: number | ResponseHelperInit): Response;
|
|
136
|
-
|
|
49
|
+
export declare function redirect(url: string | Href, init?: number | ResponseHelperInit): Response;
|
|
137
50
|
/**
|
|
138
|
-
* Empty response requesting revalidation of the named cache keys
|
|
139
|
-
* them when omitted.
|
|
140
|
-
* "refetch your data".
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* ```ts
|
|
144
|
-
* import { reload } from "@solidjs/web";
|
|
145
|
-
*
|
|
146
|
-
* async function addTodo(title: string) {
|
|
147
|
-
* "use server";
|
|
148
|
-
* await db.insert(title);
|
|
149
|
-
* return reload({ revalidate: "todos" });
|
|
150
|
-
* }
|
|
151
|
-
* ```
|
|
51
|
+
* Empty response requesting revalidation of the named cache keys (all of
|
|
52
|
+
* them when omitted).
|
|
152
53
|
*/
|
|
153
|
-
export function reload(init?: ResponseHelperInit): Response;
|
|
154
|
-
|
|
54
|
+
export declare function reload(init?: ResponseHelperInit): Response;
|
|
155
55
|
/**
|
|
156
56
|
* A value paired with response metadata (status, headers, `revalidate`) —
|
|
157
|
-
* for the things a naked return can't express.
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* posts, direct HTTP) get real JSON.
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* ```ts
|
|
165
|
-
* import { respond } from "@solidjs/web";
|
|
166
|
-
*
|
|
167
|
-
* async function createItem(input: Item) {
|
|
168
|
-
* "use server";
|
|
169
|
-
* const item = await db.create(input);
|
|
170
|
-
* return respond(item, { status: 201, revalidate: "items" });
|
|
171
|
-
* }
|
|
172
|
-
* ```
|
|
57
|
+
* for the things a naked return can't express. Progressive enhancement
|
|
58
|
+
* stays invisible: the carried response holds a plain JSON body so
|
|
59
|
+
* consumers without the client runtime (no-JS form posts, direct HTTP)
|
|
60
|
+
* get real JSON, while integrations read `value` — no reparse.
|
|
173
61
|
*/
|
|
174
|
-
export function respond<T>(value: T, init?: ResponseHelperInit): ResponseEnvelope<T>;
|
|
62
|
+
export declare function respond<T>(value: T, init?: ResponseHelperInit): ResponseEnvelope<T>;
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
// The DECODE half of the serialization surface (published as
|
|
2
|
-
// `@solidjs/web/serialization/decode`): what reading a serialized payload
|
|
3
|
-
// needs — `fromCrossJSON`-backed deserializers and the shared plugin set —
|
|
4
|
-
// with none of the encode machinery. Lazy client consumers (the frames
|
|
5
|
-
// data tables, `deserializeStream`) load this module so the encode half
|
|
6
|
-
// never ships to a browser that only reads. The full serializer.d.ts
|
|
7
|
-
// re-exports everything here; see its banner for the stability contract
|
|
8
|
-
// (integration-facing, exempt from the 2.0 stability guarantee).
|
|
9
|
-
// ---- Plugin types ----
|
|
10
|
-
//
|
|
11
|
-
// Declared here by hand (seroval's published d.ts use extensionless
|
|
12
|
-
// ESM-relative imports that `moduleResolution: "nodenext"` cannot follow —
|
|
13
|
-
// a bare type re-export would silently degrade the surface to `any` under
|
|
14
|
-
// skipLibCheck, and an import would make every entry whose types reach
|
|
15
|
-
// this module — the MAIN client entry included, via the server-function
|
|
16
|
-
// seam's `JSONCodecOptions` — unimportable from a strict Node16 CJS
|
|
17
|
-
// consumer). The declarations mirror seroval ~1.5 exactly; the `~` pin is
|
|
18
|
-
// what makes mirroring safe. Plugin AUTHORING (`createPlugin`,
|
|
19
|
-
// `OpaqueReference`) lives on the full serialization entry.
|
|
20
|
-
|
|
21
1
|
/**
|
|
22
2
|
* Seroval's node shape — the intermediate representation `serializeJSON`
|
|
23
3
|
* emits and `createJSONDeserializer` consumes. Safe to `JSON.stringify`.
|
|
@@ -29,59 +9,53 @@
|
|
|
29
9
|
* Integration-facing; may change (see the entry banner).
|
|
30
10
|
*/
|
|
31
11
|
export interface SerovalNode {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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;
|
|
37
17
|
}
|
|
38
|
-
|
|
39
18
|
/** Per-plugin bookkeeping seroval hands each plugin callback. */
|
|
40
19
|
export interface PluginData {
|
|
41
|
-
|
|
20
|
+
id: number;
|
|
42
21
|
}
|
|
43
|
-
|
|
44
22
|
/**
|
|
45
23
|
* The shape of a plugin's parsed payload: a map of `SerovalNode`s produced
|
|
46
24
|
* by the parse contexts, consumed by `serialize`/`deserialize`.
|
|
47
25
|
*/
|
|
48
|
-
export type PluginInfo = {
|
|
49
|
-
|
|
26
|
+
export type PluginInfo = {
|
|
27
|
+
[key: string]: SerovalNode;
|
|
28
|
+
};
|
|
50
29
|
/** Parse context for `parse.sync`: turns child values into nodes. */
|
|
51
30
|
export interface SyncParsePluginContext {
|
|
52
|
-
|
|
31
|
+
parse<T>(current: T): SerovalNode;
|
|
53
32
|
}
|
|
54
|
-
|
|
55
33
|
/** Parse context for `parse.async`: like sync, but child parses await. */
|
|
56
34
|
export interface AsyncParsePluginContext {
|
|
57
|
-
|
|
35
|
+
parse<T>(current: T): Promise<SerovalNode>;
|
|
58
36
|
}
|
|
59
|
-
|
|
60
37
|
/**
|
|
61
38
|
* Parse context for `parse.stream`: sync parsing plus the streaming
|
|
62
39
|
* lifecycle (pending-state tracking, late node emission, cleanup).
|
|
63
40
|
*/
|
|
64
41
|
export interface StreamParsePluginContext {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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;
|
|
73
50
|
}
|
|
74
|
-
|
|
75
51
|
/** Serialize context: renders child nodes to JS source. */
|
|
76
52
|
export interface SerializePluginContext {
|
|
77
|
-
|
|
53
|
+
serialize(node: SerovalNode): string;
|
|
78
54
|
}
|
|
79
|
-
|
|
80
55
|
/** Deserialize context: revives child nodes to runtime values. */
|
|
81
56
|
export interface DeserializePluginContext {
|
|
82
|
-
|
|
57
|
+
deserialize<T>(node: SerovalNode): T;
|
|
83
58
|
}
|
|
84
|
-
|
|
85
59
|
/**
|
|
86
60
|
* A Seroval plugin usable with the web serializers — teaches the codec how
|
|
87
61
|
* to encode/decode a custom value type (`Value` is the value it matches,
|
|
@@ -92,44 +66,23 @@ export interface DeserializePluginContext {
|
|
|
92
66
|
* Integration-facing; may change (see the entry banner).
|
|
93
67
|
*/
|
|
94
68
|
export interface SerializerPlugin<Value = any, Info extends PluginInfo = any> {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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;
|
|
111
85
|
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Baseline plugin set for serializing web-platform values (AbortSignal,
|
|
115
|
-
* Event, FormData, Headers, ReadableStream, Request, Response, URL, ...).
|
|
116
|
-
* Applied by every serializer in this module; custom plugins compose ahead
|
|
117
|
-
* of it via `resolveSerializerPlugins`.
|
|
118
|
-
*
|
|
119
|
-
* Integration-facing; may change (see the entry banner).
|
|
120
|
-
*/
|
|
121
|
-
export const DEFAULT_WEB_PLUGINS: readonly SerializerPlugin[];
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Composes custom plugins with `DEFAULT_WEB_PLUGINS`. Custom plugins come
|
|
125
|
-
* first so they can shadow a default for values both would match. Returns a
|
|
126
|
-
* fresh array; the defaults are never mutated. Useful when handing a full
|
|
127
|
-
* plugin list to another serialization layer.
|
|
128
|
-
*
|
|
129
|
-
* Integration-facing; may change (see the entry banner).
|
|
130
|
-
*/
|
|
131
|
-
export function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
|
|
132
|
-
|
|
133
86
|
/**
|
|
134
87
|
* Options shared by both halves of the JSON codec. All of them must match
|
|
135
88
|
* on the serializing and deserializing peer or payloads will not
|
|
@@ -139,32 +92,20 @@ export function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): Se
|
|
|
139
92
|
* Integration-facing; may change (see the entry banner).
|
|
140
93
|
*/
|
|
141
94
|
export interface JSONCodecOptions {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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;
|
|
155
108
|
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Creates the decoding counterpart of `serializeJSON`. Cross-references
|
|
159
|
-
* between chunks resolve through state shared across calls, so all chunks
|
|
160
|
-
* from one stream must go through the same deserializer instance. The first
|
|
161
|
-
* chunk's return value is the decoded source value; feeding later chunks
|
|
162
|
-
* settles the async values referenced inside it.
|
|
163
|
-
*
|
|
164
|
-
* Integration-facing; may change (see the entry banner).
|
|
165
|
-
*/
|
|
166
|
-
export function createJSONDeserializer(options?: JSONCodecOptions): <T>(node: SerovalNode) => T;
|
|
167
|
-
|
|
168
109
|
/**
|
|
169
110
|
* A resident, response-scoped decode table over the keyed JSON codec: apply
|
|
170
111
|
* each frame `data` chunk with `apply`, resolve `{ $ref }` slot args with
|
|
@@ -176,7 +117,43 @@ export function createJSONDeserializer(options?: JSONCodecOptions): <T>(node: Se
|
|
|
176
117
|
* it internally rather than re-exporting it.
|
|
177
118
|
*/
|
|
178
119
|
export interface JSONDataTable {
|
|
179
|
-
|
|
180
|
-
|
|
120
|
+
apply(chunk: {
|
|
121
|
+
key?: string;
|
|
122
|
+
node?: unknown;
|
|
123
|
+
initial?: boolean;
|
|
124
|
+
}): void;
|
|
125
|
+
resolve<T = unknown>(ref: {
|
|
126
|
+
$ref: string;
|
|
127
|
+
}): T;
|
|
181
128
|
}
|
|
182
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Baseline plugin set for serializing web-platform values. Shared by the
|
|
131
|
+
* hydration serializer and any consumer building its own serializer (e.g.
|
|
132
|
+
* server function transports). Plugin objects carry both their serialize
|
|
133
|
+
* and deserialize halves, so the set lives on the decode side and the
|
|
134
|
+
* encode module composes over it.
|
|
135
|
+
*/
|
|
136
|
+
export declare const DEFAULT_WEB_PLUGINS: any; /**
|
|
137
|
+
* Composes custom plugins with `DEFAULT_WEB_PLUGINS`. Custom plugins come
|
|
138
|
+
* first so they can shadow a default for values both would match. Returns a
|
|
139
|
+
* fresh array; the defaults are never mutated. Useful when handing a full
|
|
140
|
+
* plugin list to another serialization layer.
|
|
141
|
+
*
|
|
142
|
+
* Integration-facing; may change (see the entry banner).
|
|
143
|
+
*/
|
|
144
|
+
export declare function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
|
|
145
|
+
export declare function resolveCodecOptions({ plugins, disabledFeatures, depthLimit }?: JSONCodecOptions): {
|
|
146
|
+
plugins: SerializerPlugin<any, any>[];
|
|
147
|
+
disabledFeatures: any;
|
|
148
|
+
depthLimit: number;
|
|
149
|
+
}; /**
|
|
150
|
+
* Creates the decoding counterpart of `serializeJSON`. Cross-references
|
|
151
|
+
* between chunks resolve through state shared across calls, so all chunks
|
|
152
|
+
* from one stream must go through the same deserializer instance. The first
|
|
153
|
+
* chunk's return value is the decoded source value; feeding later chunks
|
|
154
|
+
* settles the async values referenced inside it.
|
|
155
|
+
*
|
|
156
|
+
* Integration-facing; may change (see the entry banner).
|
|
157
|
+
*/
|
|
158
|
+
export declare function createJSONDeserializer(options?: JSONCodecOptions): <T>(node: SerovalNode) => T;
|
|
159
|
+
export declare function createJSONDataTable(options?: JSONCodecOptions): JSONDataTable;
|