@solidjs/web 2.0.0-beta.18 → 2.0.0-beta.19
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 +112 -36
- package/dist/dev.js +107 -37
- package/dist/server.cjs +68 -4
- package/dist/server.js +64 -5
- package/dist/web.cjs +112 -36
- package/dist/web.js +107 -37
- package/package.json +81 -7
- package/serialization/types/index.d.ts +52 -10
- package/serialization/types-cjs/index.d.cts +52 -10
- package/server-functions/dist/client.cjs +370 -0
- package/server-functions/dist/client.js +363 -0
- package/server-functions/dist/server.cjs +542 -0
- package/server-functions/dist/server.js +531 -0
- package/server-functions/package.json +30 -0
- package/storage/types/index.d.ts +26 -0
- package/storage/types-cjs/index.d.cts +26 -0
- package/types/index.d.ts +1 -0
- package/types/response.d.ts +93 -0
- package/types/serializer.d.ts +52 -10
- package/types/server-functions/client.d.ts +63 -0
- package/types/server-functions/server.d.ts +188 -0
- package/types/server-functions/shared.d.ts +171 -0
- package/types/server.d.ts +18 -0
- package/types-cjs/index.d.cts +1 -0
- package/types-cjs/response.d.cts +93 -0
- package/types-cjs/serializer.d.cts +52 -10
- package/types-cjs/server-functions/client.d.cts +63 -0
- package/types-cjs/server-functions/server.d.cts +188 -0
- package/types-cjs/server-functions/shared.d.cts +171 -0
- package/types-cjs/server.d.cts +18 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/web",
|
|
3
3
|
"description": "Solid's web runtime: client rendering, hydration, SSR, and DOM-specific control flow (Portal, Dynamic).",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.19",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"main": "./dist/server.cjs",
|
|
17
17
|
"module": "./dist/server.js",
|
|
18
|
-
"unpkg": "./dist/web.
|
|
18
|
+
"unpkg": "./dist/web.js",
|
|
19
|
+
"jsdelivr": "./dist/web.js",
|
|
19
20
|
"types": "./types/index.d.ts",
|
|
20
21
|
"type": "module",
|
|
21
22
|
"sideEffects": false,
|
|
@@ -31,7 +32,9 @@
|
|
|
31
32
|
"serialization/dist",
|
|
32
33
|
"serialization/types",
|
|
33
34
|
"serialization/types-cjs",
|
|
34
|
-
"serialization/package.json"
|
|
35
|
+
"serialization/package.json",
|
|
36
|
+
"server-functions/dist",
|
|
37
|
+
"server-functions/package.json"
|
|
35
38
|
],
|
|
36
39
|
"exports": {
|
|
37
40
|
".": {
|
|
@@ -144,6 +147,76 @@
|
|
|
144
147
|
"default": "./serialization/dist/serialization.cjs"
|
|
145
148
|
}
|
|
146
149
|
},
|
|
150
|
+
"./server-functions": {
|
|
151
|
+
"worker": {
|
|
152
|
+
"import": {
|
|
153
|
+
"types": "./types/server-functions/server.d.ts",
|
|
154
|
+
"default": "./server-functions/dist/server.js"
|
|
155
|
+
},
|
|
156
|
+
"require": {
|
|
157
|
+
"types": "./types-cjs/server-functions/server.d.cts",
|
|
158
|
+
"default": "./server-functions/dist/server.cjs"
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
"browser": {
|
|
162
|
+
"import": {
|
|
163
|
+
"types": "./types/server-functions/client.d.ts",
|
|
164
|
+
"default": "./server-functions/dist/client.js"
|
|
165
|
+
},
|
|
166
|
+
"require": {
|
|
167
|
+
"types": "./types-cjs/server-functions/client.d.cts",
|
|
168
|
+
"default": "./server-functions/dist/client.cjs"
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
"deno": {
|
|
172
|
+
"import": {
|
|
173
|
+
"types": "./types/server-functions/server.d.ts",
|
|
174
|
+
"default": "./server-functions/dist/server.js"
|
|
175
|
+
},
|
|
176
|
+
"require": {
|
|
177
|
+
"types": "./types-cjs/server-functions/server.d.cts",
|
|
178
|
+
"default": "./server-functions/dist/server.cjs"
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"node": {
|
|
182
|
+
"import": {
|
|
183
|
+
"types": "./types/server-functions/server.d.ts",
|
|
184
|
+
"default": "./server-functions/dist/server.js"
|
|
185
|
+
},
|
|
186
|
+
"require": {
|
|
187
|
+
"types": "./types-cjs/server-functions/server.d.cts",
|
|
188
|
+
"default": "./server-functions/dist/server.cjs"
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"import": {
|
|
192
|
+
"types": "./types/server-functions/client.d.ts",
|
|
193
|
+
"default": "./server-functions/dist/client.js"
|
|
194
|
+
},
|
|
195
|
+
"require": {
|
|
196
|
+
"types": "./types-cjs/server-functions/client.d.cts",
|
|
197
|
+
"default": "./server-functions/dist/client.cjs"
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
"./server-functions/server": {
|
|
201
|
+
"import": {
|
|
202
|
+
"types": "./types/server-functions/server.d.ts",
|
|
203
|
+
"default": "./server-functions/dist/server.js"
|
|
204
|
+
},
|
|
205
|
+
"require": {
|
|
206
|
+
"types": "./types-cjs/server-functions/server.d.cts",
|
|
207
|
+
"default": "./server-functions/dist/server.cjs"
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"./server-functions/client": {
|
|
211
|
+
"import": {
|
|
212
|
+
"types": "./types/server-functions/client.d.ts",
|
|
213
|
+
"default": "./server-functions/dist/client.js"
|
|
214
|
+
},
|
|
215
|
+
"require": {
|
|
216
|
+
"types": "./types-cjs/server-functions/client.d.cts",
|
|
217
|
+
"default": "./server-functions/dist/client.cjs"
|
|
218
|
+
}
|
|
219
|
+
},
|
|
147
220
|
"./types/*": "./types/*"
|
|
148
221
|
},
|
|
149
222
|
"dependencies": {
|
|
@@ -151,23 +224,24 @@
|
|
|
151
224
|
"seroval-plugins": "~1.5.4"
|
|
152
225
|
},
|
|
153
226
|
"peerDependencies": {
|
|
154
|
-
"solid-js": "^2.0.0-beta.
|
|
227
|
+
"solid-js": "^2.0.0-beta.19"
|
|
155
228
|
},
|
|
156
229
|
"devDependencies": {
|
|
157
|
-
"solid-js": "2.0.0-beta.
|
|
230
|
+
"solid-js": "2.0.0-beta.19"
|
|
158
231
|
},
|
|
159
232
|
"scripts": {
|
|
160
233
|
"build": "npm-run-all -nl build:clean types:copy-jsx build:js",
|
|
161
234
|
"build:clean": "rimraf dist/",
|
|
162
235
|
"build:js": "rollup -c",
|
|
163
236
|
"link": "symlink-dir . node_modules/@solidjs/web",
|
|
164
|
-
"types": "npm-run-all -nl types:clean types:copy-jsx types:web types:copy-web types:web-storage types:copy-serialization types:cjs",
|
|
237
|
+
"types": "npm-run-all -nl types:clean types:copy-jsx types:web types:copy-web types:web-storage types:copy-serialization types:copy-server-functions types:cjs",
|
|
165
238
|
"types:clean": "rimraf types/ types-cjs/ storage/types/ storage/types-cjs/ serialization/types/ serialization/types-cjs/",
|
|
166
239
|
"types:copy-jsx": "ncp ../../node_modules/@dom-expressions/runtime/src/jsx.d.ts ./src/jsx.d.ts && ncp ../../node_modules/@dom-expressions/runtime/src/jsx-properties.d.ts ./src/jsx-properties.d.ts && dom-expressions-jsx-types --input ./src/jsx.d.ts --element \"SolidElement | Node | ArrayElement\" --import 'import type { Element as SolidElement } from \"solid-js\";'",
|
|
167
240
|
"types:web": "tsc --project ./tsconfig.build.json",
|
|
168
|
-
"types:copy-web": "ncp ../../node_modules/@dom-expressions/runtime/src/client.d.ts ./types/client.d.ts && ncp ../../node_modules/@dom-expressions/runtime/src/server.d.ts ./types/server.d.ts && ncp ../../node_modules/@dom-expressions/runtime/src/serializer.d.ts ./types/serializer.d.ts && ncp ./src/jsx.d.ts ./types/jsx.d.ts && ncp ./src/jsx-properties.d.ts ./types/jsx-properties.d.ts",
|
|
241
|
+
"types:copy-web": "ncp ../../node_modules/@dom-expressions/runtime/src/client.d.ts ./types/client.d.ts && ncp ../../node_modules/@dom-expressions/runtime/src/server.d.ts ./types/server.d.ts && ncp ../../node_modules/@dom-expressions/runtime/src/serializer.d.ts ./types/serializer.d.ts && ncp ../../node_modules/@dom-expressions/runtime/src/response.d.ts ./types/response.d.ts && ncp ./src/jsx.d.ts ./types/jsx.d.ts && ncp ./src/jsx-properties.d.ts ./types/jsx-properties.d.ts",
|
|
169
242
|
"types:web-storage": "tsc --project ./storage/tsconfig.build.json",
|
|
170
243
|
"types:copy-serialization": "node -e \"fs.mkdirSync('./serialization/types', { recursive: true }); fs.copyFileSync('../../node_modules/@dom-expressions/runtime/src/serializer.d.ts', './serialization/types/index.d.ts');\"",
|
|
244
|
+
"types:copy-server-functions": "node -e \"fs.mkdirSync('./types/server-functions', { recursive: true }); for (const f of ['shared', 'client', 'server']) fs.copyFileSync('../../node_modules/@dom-expressions/runtime/src/server-functions/' + f + '.d.ts', './types/server-functions/' + f + '.d.ts');\"",
|
|
171
245
|
"types:cjs": "node ../../scripts/sync-dual-types.mjs ./types ./types-cjs ./storage/types ./storage/types-cjs ./serialization/types ./serialization/types-cjs",
|
|
172
246
|
"test": "vitest run && vitest run --config vite.config.server.mjs && vitest run --config vite.config.hydrate.mjs",
|
|
173
247
|
"test:server": "vitest run --config vite.config.server.mjs",
|
|
@@ -1,26 +1,39 @@
|
|
|
1
1
|
import { Plugin, Serializer, SerovalNode } from "seroval";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Seroval's node shape — the intermediate representation `serializeJSON`
|
|
5
|
+
* emits and `createJSONDeserializer` consumes. Safe to `JSON.stringify`.
|
|
6
|
+
*/
|
|
3
7
|
export type { SerovalNode };
|
|
4
8
|
|
|
5
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* A Seroval plugin usable with the web serializers — teaches the codec how
|
|
11
|
+
* to encode/decode a custom value type. Supply matching plugins on both
|
|
12
|
+
* peers of a transport.
|
|
13
|
+
*/
|
|
6
14
|
export type SerializerPlugin = Plugin<any, any>;
|
|
7
15
|
|
|
8
16
|
/**
|
|
9
17
|
* Baseline plugin set for serializing web-platform values (AbortSignal,
|
|
10
18
|
* Event, FormData, Headers, ReadableStream, Request, Response, URL, ...).
|
|
19
|
+
* Applied by every serializer in this module; custom plugins compose ahead
|
|
20
|
+
* of it via `resolveSerializerPlugins`.
|
|
11
21
|
*/
|
|
12
22
|
export const DEFAULT_WEB_PLUGINS: readonly SerializerPlugin[];
|
|
13
23
|
|
|
14
24
|
/**
|
|
15
25
|
* Composes custom plugins with `DEFAULT_WEB_PLUGINS`. Custom plugins come
|
|
16
26
|
* first so they can shadow a default for values both would match. Returns a
|
|
17
|
-
* fresh array; the defaults are never mutated.
|
|
27
|
+
* fresh array; the defaults are never mutated. Useful when handing a full
|
|
28
|
+
* plugin list to another serialization layer.
|
|
18
29
|
*/
|
|
19
30
|
export function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
|
|
20
31
|
|
|
32
|
+
/** Options for `createSerializer`. */
|
|
21
33
|
export interface WebSerializerOptions {
|
|
22
34
|
/** Name of the global object the emitted scripts write resolved values into. */
|
|
23
35
|
globalIdentifier: string;
|
|
36
|
+
/** Cross-reference scope id, for isolating multiple streams on one page. */
|
|
24
37
|
scopeId?: string;
|
|
25
38
|
/**
|
|
26
39
|
* Seroval feature bitflags to exclude from output. Defaults to disabling
|
|
@@ -29,34 +42,59 @@ export interface WebSerializerOptions {
|
|
|
29
42
|
disabledFeatures?: number;
|
|
30
43
|
/** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. */
|
|
31
44
|
plugins?: SerializerPlugin[];
|
|
45
|
+
/** Receives each emitted script chunk. */
|
|
32
46
|
onData: (result: string) => void;
|
|
33
47
|
onError?: (error: unknown) => void;
|
|
48
|
+
/** Fires once all async values have settled. */
|
|
34
49
|
onDone?: () => void;
|
|
35
50
|
}
|
|
36
51
|
|
|
37
52
|
/**
|
|
38
53
|
* Creates a streaming Seroval serializer preconfigured with the web plugin
|
|
39
|
-
* set and the default feature policy.
|
|
54
|
+
* set and the default feature policy. Emits JavaScript chunks (through
|
|
55
|
+
* `onData`) that reconstruct the values under `globalIdentifier` when
|
|
56
|
+
* evaluated — the script-injection form of serialization renderers build
|
|
57
|
+
* on. For a JSON-based wire codec (no eval on the receiving side), use
|
|
58
|
+
* `serializeJSON` / `createJSONDeserializer` instead.
|
|
40
59
|
*/
|
|
41
60
|
export function createSerializer(options: WebSerializerOptions): Serializer;
|
|
42
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Options for `createHydrationSerializer` — `WebSerializerOptions` minus
|
|
64
|
+
* the knobs hydration pins (`globalIdentifier`, `disabledFeatures`).
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
43
67
|
export type HydrationSerializerOptions = Omit<
|
|
44
68
|
WebSerializerOptions,
|
|
45
69
|
"globalIdentifier" | "disabledFeatures"
|
|
46
70
|
>;
|
|
47
71
|
|
|
48
72
|
/**
|
|
49
|
-
*
|
|
50
|
-
* and feature policy
|
|
51
|
-
* plugins) are configurable.
|
|
73
|
+
* Renderer primitive — the serializer SSR uses for hydration output. Pins
|
|
74
|
+
* the hydration global (`_$HY.r`) and feature policy; only the wiring
|
|
75
|
+
* options (callbacks, scope, extra plugins) are configurable. Not meant
|
|
76
|
+
* for hand-written code — custom serialization should use
|
|
77
|
+
* `createSerializer` or the JSON codec.
|
|
78
|
+
* @internal
|
|
52
79
|
*/
|
|
53
80
|
export function createHydrationSerializer(options: HydrationSerializerOptions): Serializer;
|
|
54
81
|
|
|
55
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* Renderer primitive — returns the cross-reference bootstrap script SSR
|
|
84
|
+
* emits ahead of hydration data for a render scope. Not meant for
|
|
85
|
+
* hand-written code.
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
56
88
|
export function getLocalHeaderScript(id?: string): string;
|
|
57
89
|
|
|
58
90
|
// ---- JSON codec (server function transports) ----
|
|
59
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Options shared by both halves of the JSON codec. All of them must match
|
|
94
|
+
* on the serializing and deserializing peer or payloads will not
|
|
95
|
+
* round-trip — for server functions, set them once through the
|
|
96
|
+
* client/server `codec` config option.
|
|
97
|
+
*/
|
|
60
98
|
export interface JSONCodecOptions {
|
|
61
99
|
/** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. Must match on both peers. */
|
|
62
100
|
plugins?: SerializerPlugin[];
|
|
@@ -69,6 +107,7 @@ export interface JSONCodecOptions {
|
|
|
69
107
|
depthLimit?: number;
|
|
70
108
|
}
|
|
71
109
|
|
|
110
|
+
/** Options for `serializeJSON`. */
|
|
72
111
|
export interface JSONSerializeOptions extends JSONCodecOptions {
|
|
73
112
|
/**
|
|
74
113
|
* Receives each serialized node; `initial` is true for the first chunk
|
|
@@ -82,8 +121,10 @@ export interface JSONSerializeOptions extends JSONCodecOptions {
|
|
|
82
121
|
}
|
|
83
122
|
|
|
84
123
|
/**
|
|
85
|
-
* Serializes `value` as SerovalNode chunks delivered through `onParse
|
|
86
|
-
*
|
|
124
|
+
* Serializes `value` as SerovalNode chunks delivered through `onParse` —
|
|
125
|
+
* the encoding half of the eval-free JSON codec (RPC-style transports;
|
|
126
|
+
* the deserializing peer needs no script evaluation, so CSP-safe). Wire
|
|
127
|
+
* framing of the nodes is the transport's concern. Returns a cancel
|
|
87
128
|
* function that aborts pending async serialization.
|
|
88
129
|
*/
|
|
89
130
|
export function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
|
|
@@ -92,6 +133,7 @@ export function serializeJSON(value: unknown, options: JSONSerializeOptions): ()
|
|
|
92
133
|
* Creates the decoding counterpart of `serializeJSON`. Cross-references
|
|
93
134
|
* between chunks resolve through state shared across calls, so all chunks
|
|
94
135
|
* from one stream must go through the same deserializer instance. The first
|
|
95
|
-
* chunk's return value is the decoded source value
|
|
136
|
+
* chunk's return value is the decoded source value; feeding later chunks
|
|
137
|
+
* settles the async values referenced inside it.
|
|
96
138
|
*/
|
|
97
139
|
export function createJSONDeserializer(options?: JSONCodecOptions): <T>(node: SerovalNode) => T;
|
|
@@ -1,26 +1,39 @@
|
|
|
1
1
|
import { Plugin, Serializer, SerovalNode } from "seroval";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Seroval's node shape — the intermediate representation `serializeJSON`
|
|
5
|
+
* emits and `createJSONDeserializer` consumes. Safe to `JSON.stringify`.
|
|
6
|
+
*/
|
|
3
7
|
export type { SerovalNode };
|
|
4
8
|
|
|
5
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* A Seroval plugin usable with the web serializers — teaches the codec how
|
|
11
|
+
* to encode/decode a custom value type. Supply matching plugins on both
|
|
12
|
+
* peers of a transport.
|
|
13
|
+
*/
|
|
6
14
|
export type SerializerPlugin = Plugin<any, any>;
|
|
7
15
|
|
|
8
16
|
/**
|
|
9
17
|
* Baseline plugin set for serializing web-platform values (AbortSignal,
|
|
10
18
|
* Event, FormData, Headers, ReadableStream, Request, Response, URL, ...).
|
|
19
|
+
* Applied by every serializer in this module; custom plugins compose ahead
|
|
20
|
+
* of it via `resolveSerializerPlugins`.
|
|
11
21
|
*/
|
|
12
22
|
export const DEFAULT_WEB_PLUGINS: readonly SerializerPlugin[];
|
|
13
23
|
|
|
14
24
|
/**
|
|
15
25
|
* Composes custom plugins with `DEFAULT_WEB_PLUGINS`. Custom plugins come
|
|
16
26
|
* first so they can shadow a default for values both would match. Returns a
|
|
17
|
-
* fresh array; the defaults are never mutated.
|
|
27
|
+
* fresh array; the defaults are never mutated. Useful when handing a full
|
|
28
|
+
* plugin list to another serialization layer.
|
|
18
29
|
*/
|
|
19
30
|
export function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
|
|
20
31
|
|
|
32
|
+
/** Options for `createSerializer`. */
|
|
21
33
|
export interface WebSerializerOptions {
|
|
22
34
|
/** Name of the global object the emitted scripts write resolved values into. */
|
|
23
35
|
globalIdentifier: string;
|
|
36
|
+
/** Cross-reference scope id, for isolating multiple streams on one page. */
|
|
24
37
|
scopeId?: string;
|
|
25
38
|
/**
|
|
26
39
|
* Seroval feature bitflags to exclude from output. Defaults to disabling
|
|
@@ -29,34 +42,59 @@ export interface WebSerializerOptions {
|
|
|
29
42
|
disabledFeatures?: number;
|
|
30
43
|
/** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. */
|
|
31
44
|
plugins?: SerializerPlugin[];
|
|
45
|
+
/** Receives each emitted script chunk. */
|
|
32
46
|
onData: (result: string) => void;
|
|
33
47
|
onError?: (error: unknown) => void;
|
|
48
|
+
/** Fires once all async values have settled. */
|
|
34
49
|
onDone?: () => void;
|
|
35
50
|
}
|
|
36
51
|
|
|
37
52
|
/**
|
|
38
53
|
* Creates a streaming Seroval serializer preconfigured with the web plugin
|
|
39
|
-
* set and the default feature policy.
|
|
54
|
+
* set and the default feature policy. Emits JavaScript chunks (through
|
|
55
|
+
* `onData`) that reconstruct the values under `globalIdentifier` when
|
|
56
|
+
* evaluated — the script-injection form of serialization renderers build
|
|
57
|
+
* on. For a JSON-based wire codec (no eval on the receiving side), use
|
|
58
|
+
* `serializeJSON` / `createJSONDeserializer` instead.
|
|
40
59
|
*/
|
|
41
60
|
export function createSerializer(options: WebSerializerOptions): Serializer;
|
|
42
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Options for `createHydrationSerializer` — `WebSerializerOptions` minus
|
|
64
|
+
* the knobs hydration pins (`globalIdentifier`, `disabledFeatures`).
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
43
67
|
export type HydrationSerializerOptions = Omit<
|
|
44
68
|
WebSerializerOptions,
|
|
45
69
|
"globalIdentifier" | "disabledFeatures"
|
|
46
70
|
>;
|
|
47
71
|
|
|
48
72
|
/**
|
|
49
|
-
*
|
|
50
|
-
* and feature policy
|
|
51
|
-
* plugins) are configurable.
|
|
73
|
+
* Renderer primitive — the serializer SSR uses for hydration output. Pins
|
|
74
|
+
* the hydration global (`_$HY.r`) and feature policy; only the wiring
|
|
75
|
+
* options (callbacks, scope, extra plugins) are configurable. Not meant
|
|
76
|
+
* for hand-written code — custom serialization should use
|
|
77
|
+
* `createSerializer` or the JSON codec.
|
|
78
|
+
* @internal
|
|
52
79
|
*/
|
|
53
80
|
export function createHydrationSerializer(options: HydrationSerializerOptions): Serializer;
|
|
54
81
|
|
|
55
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* Renderer primitive — returns the cross-reference bootstrap script SSR
|
|
84
|
+
* emits ahead of hydration data for a render scope. Not meant for
|
|
85
|
+
* hand-written code.
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
56
88
|
export function getLocalHeaderScript(id?: string): string;
|
|
57
89
|
|
|
58
90
|
// ---- JSON codec (server function transports) ----
|
|
59
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Options shared by both halves of the JSON codec. All of them must match
|
|
94
|
+
* on the serializing and deserializing peer or payloads will not
|
|
95
|
+
* round-trip — for server functions, set them once through the
|
|
96
|
+
* client/server `codec` config option.
|
|
97
|
+
*/
|
|
60
98
|
export interface JSONCodecOptions {
|
|
61
99
|
/** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. Must match on both peers. */
|
|
62
100
|
plugins?: SerializerPlugin[];
|
|
@@ -69,6 +107,7 @@ export interface JSONCodecOptions {
|
|
|
69
107
|
depthLimit?: number;
|
|
70
108
|
}
|
|
71
109
|
|
|
110
|
+
/** Options for `serializeJSON`. */
|
|
72
111
|
export interface JSONSerializeOptions extends JSONCodecOptions {
|
|
73
112
|
/**
|
|
74
113
|
* Receives each serialized node; `initial` is true for the first chunk
|
|
@@ -82,8 +121,10 @@ export interface JSONSerializeOptions extends JSONCodecOptions {
|
|
|
82
121
|
}
|
|
83
122
|
|
|
84
123
|
/**
|
|
85
|
-
* Serializes `value` as SerovalNode chunks delivered through `onParse
|
|
86
|
-
*
|
|
124
|
+
* Serializes `value` as SerovalNode chunks delivered through `onParse` —
|
|
125
|
+
* the encoding half of the eval-free JSON codec (RPC-style transports;
|
|
126
|
+
* the deserializing peer needs no script evaluation, so CSP-safe). Wire
|
|
127
|
+
* framing of the nodes is the transport's concern. Returns a cancel
|
|
87
128
|
* function that aborts pending async serialization.
|
|
88
129
|
*/
|
|
89
130
|
export function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
|
|
@@ -92,6 +133,7 @@ export function serializeJSON(value: unknown, options: JSONSerializeOptions): ()
|
|
|
92
133
|
* Creates the decoding counterpart of `serializeJSON`. Cross-references
|
|
93
134
|
* between chunks resolve through state shared across calls, so all chunks
|
|
94
135
|
* from one stream must go through the same deserializer instance. The first
|
|
95
|
-
* chunk's return value is the decoded source value
|
|
136
|
+
* chunk's return value is the decoded source value; feeding later chunks
|
|
137
|
+
* settles the async values referenced inside it.
|
|
96
138
|
*/
|
|
97
139
|
export function createJSONDeserializer(options?: JSONCodecOptions): <T>(node: SerovalNode) => T;
|