@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
|
@@ -1,94 +1,6 @@
|
|
|
1
|
+
export { LIVE_SOURCE, SERVER_FUNCTION_METADATA, getServerFunctionMetadata, getServerFunctionRPC, isServerFunction, provideServerFunctionRPC, withMeta } from "./registry.cjs";
|
|
2
|
+
export { FLASH_COOKIE, clearFlashCookie, hasFlashCookie, matchFlashCookie } from "../cookies.cjs";
|
|
1
3
|
import { JSONCodecOptions } from "../serializer-decode.cjs";
|
|
2
|
-
|
|
3
|
-
export type { JSONCodecOptions };
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Configures the codec options for the server function wire format (extra
|
|
7
|
-
* Seroval plugins, feature policy, depth limit). Both peers must configure
|
|
8
|
-
* identical options or payloads will not round-trip. Usually called
|
|
9
|
-
* indirectly through `configureServerFunctionsClient` /
|
|
10
|
-
* `configureServerFunctionsServer` (their `codec` option writes through to
|
|
11
|
-
* here); call it directly only from universal code configuring both sides
|
|
12
|
-
* at once.
|
|
13
|
-
*/
|
|
14
|
-
export function configureServerFunctionsCodec(codec: JSONCodecOptions | undefined): void;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The currently configured codec options (set through
|
|
18
|
-
* `configureServerFunctionsCodec` or the client/server `codec` option), or
|
|
19
|
-
* undefined when running on the defaults. Integrations pass this to
|
|
20
|
-
* lower-level codec helpers so custom plugins configured by the app apply.
|
|
21
|
-
*
|
|
22
|
-
* Integration plumbing; not meant for hand-written application code.
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
export function getServerFunctionsCodec(): JSONCodecOptions | undefined;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Request header carrying the server function id (`"X-Server-Function-Id"`).
|
|
29
|
-
* Integrations can read it to identify which function a request targets;
|
|
30
|
-
* the id also arrives as the `id` query parameter for GET calls and no-JS
|
|
31
|
-
* form posts.
|
|
32
|
-
*/
|
|
33
|
-
export const FUNCTION_HEADER: string;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Request header carrying a per-call instance id
|
|
37
|
-
* (`"X-Server-Function-Instance"`). Its presence tells the server the call
|
|
38
|
-
* came through the client runtime — its absence marks a no-JS form post or
|
|
39
|
-
* direct HTTP call, which receive plain responses instead of codec-encoded
|
|
40
|
-
* ones.
|
|
41
|
-
*/
|
|
42
|
-
export const INSTANCE_HEADER: string;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Response header marking a thrown server-function error
|
|
46
|
-
* (`"X-Server-Function-Error"`). The client transport rejects with the
|
|
47
|
-
* decoded body when it is present (unless redirect/revalidation metadata
|
|
48
|
-
* marks the response as control flow). The value carries the error's
|
|
49
|
-
* message — `"true"` for thrown control-flow responses and non-Error
|
|
50
|
-
* values — encoded with `encodeErrorHeaderValue`, so integrations reading
|
|
51
|
-
* it must pass it through `decodeErrorHeaderValue`.
|
|
52
|
-
*/
|
|
53
|
-
export const ERROR_HEADER: string;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Encodes an error message for the `ERROR_HEADER` value. HTTP header values
|
|
57
|
-
* are latin1 ByteStrings — `Headers.set` throws on code points above U+00FF
|
|
58
|
-
* — so plain printable-latin1 messages ride verbatim (ASCII stays
|
|
59
|
-
* byte-identical on the wire) and everything else (CJK, emoji, controls)
|
|
60
|
-
* travels percent-encoded behind a marker. `decodeErrorHeaderValue`
|
|
61
|
-
* round-trips the message exactly, astral-plane characters included (lone
|
|
62
|
-
* surrogates are replaced with U+FFFD — they cannot survive UTF-8 anyway).
|
|
63
|
-
*
|
|
64
|
-
* Transport wire detail; not meant for hand-written code.
|
|
65
|
-
* @internal
|
|
66
|
-
*/
|
|
67
|
-
export function encodeErrorHeaderValue(value: string): string;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Decodes an `ERROR_HEADER` value produced by `encodeErrorHeaderValue`:
|
|
71
|
-
* marked values are percent-decoded, everything else (including values from
|
|
72
|
-
* peers that never encode) passes through untouched.
|
|
73
|
-
*
|
|
74
|
-
* Integration plumbing for readers of `ERROR_HEADER`; not meant for
|
|
75
|
-
* hand-written application code.
|
|
76
|
-
* @internal
|
|
77
|
-
*/
|
|
78
|
-
export function decodeErrorHeaderValue(value: string): string;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Header driving the single-flight protocol on both legs
|
|
82
|
-
* (`"X-Single-Flight"`). On the request it opts the call into data
|
|
83
|
-
* collection — the transport sends it automatically on non-GET calls while
|
|
84
|
-
* a flight-data consumer is subscribed (subscribing IS the opt-in). On the
|
|
85
|
-
* response it marks a body carrying the standardized `SingleFlightPayload`.
|
|
86
|
-
* How the data is produced (a data-only render, running route preloads,
|
|
87
|
-
* anything else) and what it means is entirely the integration's business —
|
|
88
|
-
* the protocol only standardizes the wire shape and the delivery.
|
|
89
|
-
*/
|
|
90
|
-
export const SINGLE_FLIGHT_HEADER: string;
|
|
91
|
-
|
|
92
4
|
/**
|
|
93
5
|
* The standardized body of a single-flight response (a response tagged with
|
|
94
6
|
* `SINGLE_FLIGHT_HEADER`): the function's return `value` plus the
|
|
@@ -99,12 +11,11 @@ export const SINGLE_FLIGHT_HEADER: string;
|
|
|
99
11
|
* `data`, which can be any codec-serializable value.
|
|
100
12
|
*/
|
|
101
13
|
export interface SingleFlightPayload<T = unknown, D = unknown> {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
14
|
+
/** The server function's return (or thrown) value. */
|
|
15
|
+
value: T;
|
|
16
|
+
/** The integration-produced data payload. */
|
|
17
|
+
data: D;
|
|
106
18
|
}
|
|
107
|
-
|
|
108
19
|
/**
|
|
109
20
|
* Envelope context delivered alongside single-flight data: the transport
|
|
110
21
|
* response, whose headers carry the integration metadata (`Location` for
|
|
@@ -112,96 +23,28 @@ export interface SingleFlightPayload<T = unknown, D = unknown> {
|
|
|
112
23
|
* consumed — read `data` and `value` from the delivery, not from here.
|
|
113
24
|
*/
|
|
114
25
|
export interface FlightDataContext {
|
|
115
|
-
|
|
116
|
-
|
|
26
|
+
/** The HTTP response the data arrived on (metadata only). */
|
|
27
|
+
response: Response;
|
|
117
28
|
}
|
|
118
|
-
|
|
119
29
|
/**
|
|
120
30
|
* Consumer receiving single-flight data on the client: `data` is the
|
|
121
31
|
* integration-produced payload (opaque to the protocol), `context` carries
|
|
122
32
|
* the envelope metadata. Async consumers are awaited before the function
|
|
123
33
|
* value is returned to the caller, so caches are seeded first.
|
|
124
34
|
*/
|
|
125
|
-
export type FlightDataConsumer<D = unknown> = (
|
|
126
|
-
data: D,
|
|
127
|
-
context: FlightDataContext
|
|
128
|
-
) => void | Promise<void>;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Registers the consumer the client transport delivers single-flight data
|
|
132
|
-
* to. Subscribing is the single-flight opt-in: while a consumer is
|
|
133
|
-
* registered the transport sends the request-leg `SINGLE_FLIGHT_HEADER` on
|
|
134
|
-
* non-GET calls (GET reads stay plain and cacheable), asking the server's
|
|
135
|
-
* collection hook to fold data into the response. When a single-flight
|
|
136
|
-
* response arrives, the transport decodes the standardized
|
|
137
|
-
* `{ value, data }` payload, delivers `data` (with the response as
|
|
138
|
-
* envelope context — redirect location, revalidation keys), and returns
|
|
139
|
-
* `value` to the caller as if the call were plain. What to do with the
|
|
140
|
-
* data (seed caches, navigate, ...) is entirely the consumer's business.
|
|
141
|
-
* One active consumer at a time — a later registration replaces the
|
|
142
|
-
* current one; returns an unsubscribe function. With no consumer
|
|
143
|
-
* registered, no header is sent and the server does no collection work;
|
|
144
|
-
* responses an integration opted in manually still pass through to the
|
|
145
|
-
* caller whole, exactly like other integration responses.
|
|
146
|
-
*/
|
|
147
|
-
export function subscribeFlightData<D = unknown>(consumer: FlightDataConsumer<D>): () => void;
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Name of the cookie carrying the outcome of a call made without the client
|
|
151
|
-
* runtime (`"flash"`). A no-JS form post has no way to receive a value —
|
|
152
|
-
* the browser follows the redirect and renders the next page — so the
|
|
153
|
-
* handler stashes the outcome here for the render after it to pick up,
|
|
154
|
-
* which is how a form submitted without JavaScript still shows its result.
|
|
155
|
-
*
|
|
156
|
-
* The name, detection and clearing are isomorphic (integrations read the
|
|
157
|
-
* cookie from code that also ships to the browser); the codec that fills it
|
|
158
|
-
* is server-only and lives behind the server entry.
|
|
159
|
-
*/
|
|
160
|
-
export const FLASH_COOKIE: string;
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Whether a Cookie header carries a flash cookie, readable or not. Cheap
|
|
164
|
-
* enough to call on every render so the clear can be queued before the
|
|
165
|
-
* response headers flush.
|
|
166
|
-
*/
|
|
167
|
-
export function hasFlashCookie(cookieHeader: string | null): boolean;
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* The `Set-Cookie` value clearing the flash cookie. The outcome is
|
|
171
|
-
* one-shot: append this as soon as the cookie is detected, whether or not
|
|
172
|
-
* it decodes, so a stale outcome cannot resurface on a later request.
|
|
173
|
-
*/
|
|
174
|
-
export function clearFlashCookie(): string;
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* The raw encoded flash payload out of a Cookie header, if present — the
|
|
178
|
-
* codec's own accessor.
|
|
179
|
-
*
|
|
180
|
-
* @internal
|
|
181
|
-
*/
|
|
182
|
-
export function matchFlashCookie(cookieHeader: string | null): string | undefined;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* The currently registered single-flight consumer.
|
|
186
|
-
*
|
|
187
|
-
* Transport building block; not meant for hand-written code.
|
|
188
|
-
* @internal
|
|
189
|
-
*/
|
|
190
|
-
export function getFlightDataConsumer(): FlightDataConsumer | undefined;
|
|
191
|
-
|
|
35
|
+
export type FlightDataConsumer<D = unknown> = (data: D, context: FlightDataContext) => void | Promise<void>;
|
|
192
36
|
/**
|
|
193
37
|
* The public contract of a server function reference — what a `"use
|
|
194
38
|
* server"` import is at runtime on either side: an async callable plus its
|
|
195
39
|
* build-stable identity.
|
|
196
40
|
*/
|
|
197
41
|
export interface ServerFunction<A extends readonly any[] = any[], T = any> {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
42
|
+
(...args: A): Promise<T>;
|
|
43
|
+
/** The build-stable function id (stable across the client and server builds). */
|
|
44
|
+
readonly id: string;
|
|
45
|
+
/** URL invoking this function directly over HTTP (form `action`s, raw fetches). */
|
|
46
|
+
readonly url: string;
|
|
203
47
|
}
|
|
204
|
-
|
|
205
48
|
/**
|
|
206
49
|
* Declaration-static metadata attached to a server function reference
|
|
207
50
|
* through declaration wrappers (`GET`, `withMeta`). Read it with
|
|
@@ -211,78 +54,19 @@ export interface ServerFunction<A extends readonly any[] = any[], T = any> {
|
|
|
211
54
|
* over earlier ones.
|
|
212
55
|
*/
|
|
213
56
|
export interface ServerFunctionMetadata {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
57
|
+
/** The declared HTTP method. Undeclared references call over POST. */
|
|
58
|
+
readonly method?: "GET" | "POST";
|
|
59
|
+
/**
|
|
60
|
+
* A human-readable label for the function, seeded by development builds
|
|
61
|
+
* from the compiled function's source name (dev tooling — inspectors,
|
|
62
|
+
* logs). Dev-only: production builds emit no name. Not unique and not an
|
|
63
|
+
* identity key — use `id` for identity. Seeded as a default: an explicit
|
|
64
|
+
* `withMeta` write wins.
|
|
65
|
+
*/
|
|
66
|
+
readonly name?: string;
|
|
67
|
+
/** User-declared transport metadata attached with `withMeta`. */
|
|
68
|
+
readonly [key: string]: unknown;
|
|
226
69
|
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Reads a server function reference's declaration metadata — e.g.
|
|
230
|
-
* `getServerFunctionMetadata(fn)?.method === "GET"` detects a `GET(fn)`
|
|
231
|
-
* declaration. Returns undefined when `fn` is not a server function
|
|
232
|
-
* reference; plain references carry an empty metadata object. Works on
|
|
233
|
-
* client proxies and server-side references alike, across duplicated
|
|
234
|
-
* module instances (registered-symbol brand).
|
|
235
|
-
*/
|
|
236
|
-
export function getServerFunctionMetadata(fn: unknown): ServerFunctionMetadata | undefined;
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Whether `fn` is a server function reference (a client proxy or a
|
|
240
|
-
* server-side registered callable). Detection is structural — a
|
|
241
|
-
* registered-symbol metadata brand — so it holds across duplicated module
|
|
242
|
-
* instances and both sides of the directive boundary.
|
|
243
|
-
*/
|
|
244
|
-
export function isServerFunction(fn: unknown): fn is ServerFunction;
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Attaches user-declared transport metadata to a server function reference
|
|
248
|
-
* (client proxy or server-registered callable) and returns the reference.
|
|
249
|
-
* Writes ride the same channel `GET` uses: later writes shallow-merge over
|
|
250
|
-
* earlier ones, and `getServerFunctionMetadata(fn)` reads the merged bag —
|
|
251
|
-
* so `withMeta` composes with `GET` in either order
|
|
252
|
-
* (`GET(withMeta(fn, meta))` ≡ `withMeta(GET(fn), meta)`).
|
|
253
|
-
*
|
|
254
|
-
* The pattern is declare-on-function, react-in-hook: metadata declared
|
|
255
|
-
* here reaches `prepareRequest` as `context.meta`, letting session-dynamic
|
|
256
|
-
* transport policy key on declarations instead of comparing function ids:
|
|
257
|
-
*
|
|
258
|
-
* ```ts
|
|
259
|
-
* export const chargeCard = withMeta(async (amount: number) => {
|
|
260
|
-
* "use server";
|
|
261
|
-
* // ...
|
|
262
|
-
* }, { requiresAuth: true });
|
|
263
|
-
*
|
|
264
|
-
* configureServerFunctionsClient({
|
|
265
|
-
* prepareRequest(init, { meta }) {
|
|
266
|
-
* if (meta?.requiresAuth) {
|
|
267
|
-
* return {
|
|
268
|
-
* ...init,
|
|
269
|
-
* headers: { ...init.headers, Authorization: `Bearer ${session.token()}` }
|
|
270
|
-
* };
|
|
271
|
-
* }
|
|
272
|
-
* return init;
|
|
273
|
-
* }
|
|
274
|
-
* });
|
|
275
|
-
* ```
|
|
276
|
-
*/
|
|
277
|
-
export function withMeta<F extends (...args: any[]) => any>(fn: F, meta: ServerFunctionMetadata): F;
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* The registered symbol branding server function references with their
|
|
281
|
-
* declaration metadata. Use the typed accessors instead.
|
|
282
|
-
* @internal
|
|
283
|
-
*/
|
|
284
|
-
export const SERVER_FUNCTION_METADATA: unique symbol;
|
|
285
|
-
|
|
286
70
|
/**
|
|
287
71
|
* The transport surface integrations consume through the late-bound RPC
|
|
288
72
|
* seam (server-functions/registry.js) — filled by the transport halves when
|
|
@@ -291,123 +75,89 @@ export const SERVER_FUNCTION_METADATA: unique symbol;
|
|
|
291
75
|
* by routers so they never import the transport/codec statically.
|
|
292
76
|
*/
|
|
293
77
|
export interface ServerFunctionRPC {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
78
|
+
/**
|
|
79
|
+
* The build's `GET` declaration wrapper (client fetch transport or
|
|
80
|
+
* server in-process dispatch — see the respective entries).
|
|
81
|
+
*/
|
|
82
|
+
GET<A extends readonly any[], R>(fn: (...args: A) => R): ServerFunction<A, Awaited<R>>;
|
|
83
|
+
/**
|
|
84
|
+
* `decodeResponse` bound to the configured codec: decodes a server
|
|
85
|
+
* function response body the transport handed over whole (redirects,
|
|
86
|
+
* revalidation). Resolves undefined for empty bodies and bodies without
|
|
87
|
+
* a recognized encoding (e.g. a raw user Response).
|
|
88
|
+
*/
|
|
89
|
+
decodeResponse<T = unknown>(response: Response): Promise<T | undefined>;
|
|
306
90
|
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Fills the RPC seam. Called by the transport halves when the first server
|
|
310
|
-
* function reference is created; first write wins.
|
|
311
|
-
* @internal
|
|
312
|
-
*/
|
|
313
|
-
export function provideServerFunctionRPC(rpc: ServerFunctionRPC): void;
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* The registered RPC surface, or undefined when no server function exists
|
|
317
|
-
* in this build's graph. Integration plumbing (routers): gate every use of
|
|
318
|
-
* the transport/codec behind this read instead of importing it — an app
|
|
319
|
-
* with no server functions then ships none of it, while a reference in the
|
|
320
|
-
* bundle guarantees the seam is filled before integration code can hold
|
|
321
|
-
* that reference (compiled output creates references at module scope).
|
|
322
|
-
* @internal
|
|
323
|
-
*/
|
|
324
|
-
export function getServerFunctionRPC(): ServerFunctionRPC | undefined;
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Header carrying the body format tag (a `BodyFormat` value) —
|
|
328
|
-
* `"X-Server-Function-Format"`.
|
|
329
|
-
*
|
|
330
|
-
* Transport wire detail; not meant for hand-written code.
|
|
331
|
-
* @internal
|
|
332
|
-
*/
|
|
333
|
-
export const BODY_FORMAT_HEADER: string;
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* FormData key used when a lone File is sent as the argument.
|
|
337
|
-
*
|
|
338
|
-
* Transport wire detail; not meant for hand-written code.
|
|
339
|
-
* @internal
|
|
340
|
-
*/
|
|
341
|
-
export const FILE_FORM_KEY: string;
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Wire tags naming how a request/response body was encoded, carried in
|
|
345
|
-
* `BODY_FORMAT_HEADER`.
|
|
346
|
-
*
|
|
347
|
-
* Transport wire detail; not meant for hand-written code.
|
|
348
|
-
* @internal
|
|
349
|
-
*/
|
|
350
|
-
export const BodyFormat: {
|
|
351
|
-
readonly Serialized: "0";
|
|
352
|
-
readonly String: "1";
|
|
353
|
-
readonly FormData: "2";
|
|
354
|
-
readonly URLSearchParams: "3";
|
|
355
|
-
readonly Blob: "4";
|
|
356
|
-
readonly File: "5";
|
|
357
|
-
readonly ArrayBuffer: "6";
|
|
358
|
-
readonly Uint8Array: "7";
|
|
359
|
-
/**
|
|
360
|
-
* Plain `JSON.stringify` — the fast path for JSON-safe payloads on both
|
|
361
|
-
* legs: argument lists on the request, results on the response.
|
|
362
|
-
*/
|
|
363
|
-
readonly Json: "8";
|
|
364
|
-
};
|
|
365
|
-
|
|
366
91
|
/**
|
|
367
92
|
* Transport wire detail; not meant for hand-written code.
|
|
368
93
|
* @internal
|
|
369
94
|
*/
|
|
370
95
|
export type BodyFormatValue = (typeof BodyFormat)[keyof typeof BodyFormat];
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
*
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
*/
|
|
392
|
-
export
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
96
|
+
export declare function configureServerFunctionsCodec(codec: JSONCodecOptions | undefined): void;
|
|
97
|
+
export declare function getServerFunctionsCodec(): JSONCodecOptions | undefined;
|
|
98
|
+
export declare function subscribeFlightData<D = unknown>(consumer: FlightDataConsumer<D>): () => void;
|
|
99
|
+
export declare function getFlightDataConsumer(): FlightDataConsumer | undefined;
|
|
100
|
+
export declare function frameAddress(id: string, args?: readonly unknown[]): string;
|
|
101
|
+
/** Header carrying the server function id. */
|
|
102
|
+
export declare const FUNCTION_HEADER = "X-Server-Function-Id";
|
|
103
|
+
/**
|
|
104
|
+
* Response header marking a thrown server-function error. The value is the
|
|
105
|
+
* error's message (the structured error itself travels in the body); `"true"`
|
|
106
|
+
* for thrown control-flow responses and non-Error values.
|
|
107
|
+
*/
|
|
108
|
+
export declare const ERROR_HEADER = "X-Server-Function-Error";
|
|
109
|
+
export declare function encodeErrorHeaderValue(value: string): string;
|
|
110
|
+
export declare function decodeErrorHeaderValue(value: string): string;
|
|
111
|
+
/**
|
|
112
|
+
* Header carrying a per-call instance id. Its presence tells the server a
|
|
113
|
+
* scripted client is on the other end (vs. a no-JS form post).
|
|
114
|
+
*/
|
|
115
|
+
export declare const INSTANCE_HEADER = "X-Server-Function-Instance";
|
|
116
|
+
/** Header carrying the body format tag (a `BodyFormat` value). */
|
|
117
|
+
export declare const BODY_FORMAT_HEADER = "X-Server-Function-Format";
|
|
118
|
+
/**
|
|
119
|
+
* Header driving the single-flight protocol on both legs: on the request it
|
|
120
|
+
* opts the call into flight-data collection (the integration sends it on
|
|
121
|
+
* calls whose response should fold in data), on the response it marks a
|
|
122
|
+
* body carrying the standardized `{ value, data }` payload. How the data
|
|
123
|
+
* is produced (and what it means) is entirely the integration's business —
|
|
124
|
+
* core only owns the wire shape and the delivery.
|
|
125
|
+
*/
|
|
126
|
+
export declare const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
|
|
127
|
+
/** FormData key used when a lone File is sent as the argument. */
|
|
128
|
+
export declare const FILE_FORM_KEY = "__server_function_file__";
|
|
129
|
+
export declare const BodyFormat: {
|
|
130
|
+
Serialized: string;
|
|
131
|
+
String: string;
|
|
132
|
+
FormData: string;
|
|
133
|
+
URLSearchParams: string;
|
|
134
|
+
Blob: string;
|
|
135
|
+
File: string;
|
|
136
|
+
ArrayBuffer: string;
|
|
137
|
+
Uint8Array: string;
|
|
138
|
+
/**
|
|
139
|
+
* Plain `JSON.stringify` — the fast path for JSON-safe payloads on both
|
|
140
|
+
* legs: argument lists on the request, results (single-flight envelopes
|
|
141
|
+
* included) on the response.
|
|
142
|
+
*/
|
|
143
|
+
Json: string;
|
|
144
|
+
};
|
|
145
|
+
export declare function isJSONSafe(value: unknown): boolean;
|
|
146
|
+
export declare function getHeadersAndBody(body: unknown): {
|
|
147
|
+
headers?: Record<string, string>;
|
|
148
|
+
body: BodyInit;
|
|
149
|
+
} | undefined;
|
|
150
|
+
export declare function extractBody(source: Request | Response, codecOptions?: JSONCodecOptions): Promise<unknown>;
|
|
151
|
+
export declare function createChunk(data: string): Uint8Array;
|
|
152
|
+
export declare class ChunkReader {
|
|
153
|
+
constructor(stream: any);
|
|
154
|
+
readChunk(): Promise<void>;
|
|
155
|
+
next(): Promise<{
|
|
156
|
+
done: boolean;
|
|
157
|
+
value: string;
|
|
158
|
+
}>;
|
|
159
|
+
drain(interpret: any): Promise<void>;
|
|
160
|
+
} /**
|
|
411
161
|
* Serializes a value as a stream of length-prefixed SerovalNode chunks.
|
|
412
162
|
* Async values (promises, streams) keep the stream open until they settle,
|
|
413
163
|
* so one connection carries incremental results. Codec options must match
|
|
@@ -416,108 +166,12 @@ export function extractBody(
|
|
|
416
166
|
* Transport building block; not meant for hand-written code.
|
|
417
167
|
* @internal
|
|
418
168
|
*/
|
|
419
|
-
export function serializeStream(
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
):
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
* @internal
|
|
429
|
-
*/
|
|
430
|
-
export function serializeString(value: unknown, codecOptions?: JSONCodecOptions): Promise<string>;
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* Decodes a framed chunk stream from a Request/Response body. Resolves with
|
|
434
|
-
* the first chunk's value (the source value); later chunks settle the async
|
|
435
|
-
* values referenced inside it as they arrive.
|
|
436
|
-
*
|
|
437
|
-
* Transport building block; use `decodeResponse` from integration code.
|
|
438
|
-
* @internal
|
|
439
|
-
*/
|
|
440
|
-
export function deserializeStream<T = unknown>(
|
|
441
|
-
source: Request | Response,
|
|
442
|
-
codecOptions?: JSONCodecOptions
|
|
443
|
-
): Promise<T>;
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* `deserializeStream` for an already-buffered string.
|
|
447
|
-
*
|
|
448
|
-
* Transport building block; not meant for hand-written code.
|
|
449
|
-
* @internal
|
|
450
|
-
*/
|
|
451
|
-
export function deserializeString<T = unknown>(
|
|
452
|
-
text: string,
|
|
453
|
-
codecOptions?: JSONCodecOptions
|
|
454
|
-
): Promise<T>;
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* Decodes a server function response body using the configured codec. This
|
|
458
|
-
* is the integration-facing decoder: routers call it on responses the
|
|
459
|
-
* transport hands over whole — redirects, revalidation, single-flight
|
|
460
|
-
* payloads — to recover the structured value inside. Resolves undefined for
|
|
461
|
-
* empty bodies and bodies without a recognized encoding (e.g. a raw user
|
|
462
|
-
* Response). Renderer- and platform-neutral: safe to use from universal
|
|
463
|
-
* code.
|
|
464
|
-
*
|
|
465
|
-
* @param response the transport response; its body is read from a clone,
|
|
466
|
-
* so the original stays readable
|
|
467
|
-
* @param codecOptions overrides the configured codec for this call
|
|
468
|
-
*/
|
|
469
|
-
export function decodeResponse<T = unknown>(
|
|
470
|
-
response: Response,
|
|
471
|
-
codecOptions?: JSONCodecOptions
|
|
472
|
-
): Promise<T | undefined>;
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* `decodeResponse` plus the single-flight envelope split: when the response
|
|
476
|
-
* carries the single-flight header the decoded `{ value, data }` payload is
|
|
477
|
-
* unwrapped into `{ value, flightData }`; otherwise the decoded body (or
|
|
478
|
-
* undefined for body-less responses) rides as `{ value }`. Integrations
|
|
479
|
-
* that apply response metadata themselves use this so the payload shape
|
|
480
|
-
* stays core's own.
|
|
481
|
-
*
|
|
482
|
-
* Integration plumbing; not meant for hand-written application code.
|
|
483
|
-
* @internal
|
|
484
|
-
*/
|
|
485
|
-
export function decodeResponsePayload<T = unknown, D = unknown>(
|
|
486
|
-
response: Response,
|
|
487
|
-
codecOptions?: JSONCodecOptions
|
|
488
|
-
): Promise<{ value: T | undefined; flightData?: D }>;
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* Frame one payload for the server-function wire: a `;0x<len32>;` length
|
|
492
|
-
* prefix followed by the utf-8 data. Both transports (server-function
|
|
493
|
-
* responses and frame streams) share this framing.
|
|
494
|
-
*
|
|
495
|
-
* Transport wire detail; not meant for hand-written code.
|
|
496
|
-
* @internal
|
|
497
|
-
*/
|
|
498
|
-
export function createChunk(data: string): Uint8Array;
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* Incremental decoder for `createChunk` framing over a byte stream: `next()`
|
|
502
|
-
* yields one complete payload string per call (async-iterator result shape),
|
|
503
|
-
* buffering partial frames internally until their length prefix is satisfied.
|
|
504
|
-
*
|
|
505
|
-
* Transport wire detail; not meant for hand-written code.
|
|
506
|
-
* @internal
|
|
507
|
-
*/
|
|
508
|
-
export class ChunkReader {
|
|
509
|
-
constructor(stream: ReadableStream<Uint8Array>);
|
|
510
|
-
next(): Promise<{ done: boolean; value: string | undefined }>;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
* The intrinsic wire address of a server-component call: the function id,
|
|
515
|
-
* suffixed with a realm-stable hash of the arguments when there are any.
|
|
516
|
-
* Both peers derive it independently — the server names flight regions with
|
|
517
|
-
* it, the client routes them by it — so it must stay deterministic across
|
|
518
|
-
* realms and releases.
|
|
519
|
-
*
|
|
520
|
-
* Transport wire detail; not meant for hand-written code.
|
|
521
|
-
* @internal
|
|
522
|
-
*/
|
|
523
|
-
export function frameAddress(id: string, args?: readonly unknown[]): string;
|
|
169
|
+
export declare function serializeStream(value: unknown, codecOptions?: JSONCodecOptions): ReadableStream<Uint8Array>;
|
|
170
|
+
export declare function serializeString(value: unknown, codecOptions?: JSONCodecOptions): Promise<string>;
|
|
171
|
+
export declare function deserializeStream<T = unknown>(source: Request | Response, codecOptions?: JSONCodecOptions): Promise<T>;
|
|
172
|
+
export declare function deserializeString<T = unknown>(text: string, codecOptions?: JSONCodecOptions): Promise<T>;
|
|
173
|
+
export declare function decodeResponse<T = unknown>(response: Response, codecOptions?: JSONCodecOptions): Promise<T | undefined>;
|
|
174
|
+
export declare function decodeResponsePayload<T = unknown, D = unknown>(response: Response, codecOptions?: JSONCodecOptions): Promise<{
|
|
175
|
+
value: T | undefined;
|
|
176
|
+
flightData?: D;
|
|
177
|
+
}>;
|
|
@@ -217,7 +217,7 @@ export declare function commitEventResponse(response: Response, event?: RequestE
|
|
|
217
217
|
*/
|
|
218
218
|
export declare function composeMiddleware(middlewares: FetchMiddleware[]): (request: Request, next: (request?: Request) => Response | Promise<Response>) => Promise<Response>;
|
|
219
219
|
/**
|
|
220
|
-
* Compiler primitive — emitted by JSX
|
|
220
|
+
* Compiler primitive — emitted by Solid's JSX compiler for tagged-template
|
|
221
221
|
* SSR output. Not meant for hand-written code.
|
|
222
222
|
* @internal
|
|
223
223
|
*/
|
|
@@ -225,7 +225,7 @@ export declare function ssr(template: string[] | string, ...nodes: any[]): {
|
|
|
225
225
|
t: string;
|
|
226
226
|
};
|
|
227
227
|
/**
|
|
228
|
-
* Compiler primitive — emitted by JSX
|
|
228
|
+
* Compiler primitive — emitted by Solid's JSX compiler for SSR element
|
|
229
229
|
* output. Not meant for hand-written code.
|
|
230
230
|
* @internal
|
|
231
231
|
*/
|