@solidjs/web 2.0.0-beta.3 → 2.0.0-beta.30
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 +27 -4
- package/dist/dev.cjs +1211 -205
- package/dist/dev.js +1175 -199
- package/dist/server.cjs +1342 -234
- package/dist/server.js +1304 -231
- package/dist/web.cjs +1195 -196
- package/dist/web.js +1159 -190
- package/frames/dist/client.cjs +1746 -0
- package/frames/dist/client.dev.cjs +1759 -0
- package/frames/dist/client.dev.js +1747 -0
- package/frames/dist/client.js +1734 -0
- package/frames/dist/server.cjs +2426 -0
- package/frames/dist/server.js +2414 -0
- package/frames/package.json +30 -0
- package/package.json +287 -38
- package/serialization/dist/serialization.cjs +169 -0
- package/serialization/dist/serialization.js +159 -0
- package/serialization/package.json +20 -0
- package/serialization/types/index.d.ts +157 -0
- package/serialization/types-cjs/index.d.cts +157 -0
- package/serialization/types-cjs/package.json +3 -0
- package/server-functions/dist/client.cjs +613 -0
- package/server-functions/dist/client.js +585 -0
- package/server-functions/dist/server.cjs +904 -0
- package/server-functions/dist/server.js +875 -0
- package/server-functions/package.json +30 -0
- package/storage/package.json +8 -3
- package/storage/types/index.d.ts +26 -0
- package/storage/types-cjs/index.d.cts +28 -0
- package/storage/types-cjs/package.json +3 -0
- package/types/client.d.ts +125 -21
- package/types/core.d.ts +4 -3
- package/types/frames/client.d.ts +20 -0
- package/types/frames/frame-client.d.ts +270 -0
- package/types/frames/frame-sink.d.ts +168 -0
- package/types/frames/frame-transport.d.ts +196 -0
- package/types/frames/serializer.d.ts +157 -0
- package/types/frames/server.d.ts +30 -0
- package/types/index.d.ts +211 -26
- package/types/jsx-properties.d.ts +93 -0
- package/types/jsx.d.ts +4150 -1
- package/types/response.d.ts +129 -0
- package/types/serializer.d.ts +157 -0
- package/types/server-functions/client.d.ts +200 -0
- package/types/server-functions/flash.d.ts +38 -0
- package/types/server-functions/server.d.ts +490 -0
- package/types/server-functions/shared.d.ts +445 -0
- package/types/server-mock.d.ts +93 -0
- package/types/server.d.ts +221 -28
- package/types-cjs/client.d.cts +192 -0
- package/types-cjs/core.d.cts +4 -0
- package/types-cjs/frames/client.d.cts +20 -0
- package/types-cjs/frames/frame-client.d.cts +270 -0
- package/types-cjs/frames/frame-sink.d.cts +168 -0
- package/types-cjs/frames/frame-transport.d.cts +196 -0
- package/types-cjs/frames/serializer.d.cts +157 -0
- package/types-cjs/frames/server.d.cts +30 -0
- package/types-cjs/index.d.cts +231 -0
- package/types-cjs/jsx-properties.d.cts +93 -0
- package/types-cjs/jsx.d.cts +4150 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/response.d.cts +129 -0
- package/types-cjs/serializer.d.cts +157 -0
- package/types-cjs/server-functions/client.d.cts +200 -0
- package/types-cjs/server-functions/flash.d.cts +38 -0
- package/types-cjs/server-functions/server.d.cts +490 -0
- package/types-cjs/server-functions/shared.d.cts +445 -0
- package/types-cjs/server-mock.d.cts +165 -0
- package/types-cjs/server.d.cts +349 -0
- package/storage/types/src/client.d.ts +0 -1
- package/storage/types/src/index.d.ts +0 -46
- package/storage/types/src/server-mock.d.ts +0 -72
- package/storage/types/storage/src/index.d.ts +0 -2
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { JSONCodecOptions } from "../serializer.js";
|
|
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
|
+
export function getServerFunctionsCodec(): JSONCodecOptions | undefined;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Request header carrying the server function id (`"X-Server-Function-Id"`).
|
|
26
|
+
* Integrations can read it to identify which function a request targets;
|
|
27
|
+
* the id also arrives as the `id` query parameter for GET calls and no-JS
|
|
28
|
+
* form posts.
|
|
29
|
+
*/
|
|
30
|
+
export const FUNCTION_HEADER: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Request header carrying a per-call instance id
|
|
34
|
+
* (`"X-Server-Function-Instance"`). Its presence tells the server the call
|
|
35
|
+
* came through the client runtime — its absence marks a no-JS form post or
|
|
36
|
+
* direct HTTP call, which receive plain responses instead of codec-encoded
|
|
37
|
+
* ones.
|
|
38
|
+
*/
|
|
39
|
+
export const INSTANCE_HEADER: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Response header marking a thrown server-function error
|
|
43
|
+
* (`"X-Server-Function-Error"`). The client transport rejects with the
|
|
44
|
+
* decoded body when it is present (unless redirect/revalidation metadata
|
|
45
|
+
* marks the response as control flow). The value carries the error's
|
|
46
|
+
* message — `"true"` for thrown control-flow responses and non-Error
|
|
47
|
+
* values — encoded with `encodeErrorHeaderValue`, so integrations reading
|
|
48
|
+
* it must pass it through `decodeErrorHeaderValue`.
|
|
49
|
+
*/
|
|
50
|
+
export const ERROR_HEADER: string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Encodes an error message for the `ERROR_HEADER` value. HTTP header values
|
|
54
|
+
* are latin1 ByteStrings — `Headers.set` throws on code points above U+00FF
|
|
55
|
+
* — so plain printable-latin1 messages ride verbatim (ASCII stays
|
|
56
|
+
* byte-identical on the wire) and everything else (CJK, emoji, controls)
|
|
57
|
+
* travels percent-encoded behind a marker. `decodeErrorHeaderValue`
|
|
58
|
+
* round-trips the message exactly, astral-plane characters included (lone
|
|
59
|
+
* surrogates are replaced with U+FFFD — they cannot survive UTF-8 anyway).
|
|
60
|
+
*/
|
|
61
|
+
export function encodeErrorHeaderValue(value: string): string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Decodes an `ERROR_HEADER` value produced by `encodeErrorHeaderValue`:
|
|
65
|
+
* marked values are percent-decoded, everything else (including values from
|
|
66
|
+
* peers that never encode) passes through untouched.
|
|
67
|
+
*/
|
|
68
|
+
export function decodeErrorHeaderValue(value: string): string;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Header driving the single-flight protocol on both legs
|
|
72
|
+
* (`"X-Single-Flight"`). On the request it opts the call into data
|
|
73
|
+
* collection — the transport sends it automatically on non-GET calls while
|
|
74
|
+
* a flight-data consumer is subscribed (subscribing IS the opt-in). On the
|
|
75
|
+
* response it marks a body carrying the standardized `SingleFlightPayload`.
|
|
76
|
+
* How the data is produced (a data-only render, running route preloads,
|
|
77
|
+
* anything else) and what it means is entirely the integration's business —
|
|
78
|
+
* the protocol only standardizes the wire shape and the delivery.
|
|
79
|
+
*/
|
|
80
|
+
export const SINGLE_FLIGHT_HEADER: string;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The standardized body of a single-flight response (a response tagged with
|
|
84
|
+
* `SINGLE_FLIGHT_HEADER`): the function's return `value` plus the
|
|
85
|
+
* integration-produced `data` payload, folded into one round trip by the
|
|
86
|
+
* HTTP handler. Integrations decoding passthrough responses themselves (no
|
|
87
|
+
* registered consumer) see this shape from `decodeResponse`. The top level
|
|
88
|
+
* is reserved for the protocol — integration payload lives entirely under
|
|
89
|
+
* `data`, which can be any codec-serializable value.
|
|
90
|
+
*/
|
|
91
|
+
export interface SingleFlightPayload<T = unknown, D = unknown> {
|
|
92
|
+
/** The server function's return (or thrown) value. */
|
|
93
|
+
value: T;
|
|
94
|
+
/** The integration-produced data payload. */
|
|
95
|
+
data: D;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Envelope context delivered alongside single-flight data: the transport
|
|
100
|
+
* response, whose headers carry the integration metadata (`Location` for
|
|
101
|
+
* redirect-with-data, `X-Revalidate` keys) and status. The body is already
|
|
102
|
+
* consumed — read `data` and `value` from the delivery, not from here.
|
|
103
|
+
*/
|
|
104
|
+
export interface FlightDataContext {
|
|
105
|
+
/** The HTTP response the data arrived on (metadata only). */
|
|
106
|
+
response: Response;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Consumer receiving single-flight data on the client: `data` is the
|
|
111
|
+
* integration-produced payload (opaque to the protocol), `context` carries
|
|
112
|
+
* the envelope metadata. Async consumers are awaited before the function
|
|
113
|
+
* value is returned to the caller, so caches are seeded first.
|
|
114
|
+
*/
|
|
115
|
+
export type FlightDataConsumer<D = unknown> = (
|
|
116
|
+
data: D,
|
|
117
|
+
context: FlightDataContext
|
|
118
|
+
) => void | Promise<void>;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Registers the consumer the client transport delivers single-flight data
|
|
122
|
+
* to. Subscribing is the single-flight opt-in: while a consumer is
|
|
123
|
+
* registered the transport sends the request-leg `SINGLE_FLIGHT_HEADER` on
|
|
124
|
+
* non-GET calls (GET reads stay plain and cacheable), asking the server's
|
|
125
|
+
* collection hook to fold data into the response. When a single-flight
|
|
126
|
+
* response arrives, the transport decodes the standardized
|
|
127
|
+
* `{ value, data }` payload, delivers `data` (with the response as
|
|
128
|
+
* envelope context — redirect location, revalidation keys), and returns
|
|
129
|
+
* `value` to the caller as if the call were plain. What to do with the
|
|
130
|
+
* data (seed caches, navigate, ...) is entirely the consumer's business.
|
|
131
|
+
* One active consumer at a time — a later registration replaces the
|
|
132
|
+
* current one; returns an unsubscribe function. With no consumer
|
|
133
|
+
* registered, no header is sent and the server does no collection work;
|
|
134
|
+
* responses an integration opted in manually still pass through to the
|
|
135
|
+
* caller whole, exactly like other integration responses.
|
|
136
|
+
*/
|
|
137
|
+
export function subscribeFlightData<D = unknown>(consumer: FlightDataConsumer<D>): () => void;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Name of the cookie carrying the outcome of a call made without the client
|
|
141
|
+
* runtime (`"flash"`). A no-JS form post has no way to receive a value —
|
|
142
|
+
* the browser follows the redirect and renders the next page — so the
|
|
143
|
+
* handler stashes the outcome here for the render after it to pick up,
|
|
144
|
+
* which is how a form submitted without JavaScript still shows its result.
|
|
145
|
+
*
|
|
146
|
+
* The name, detection and clearing are isomorphic (integrations read the
|
|
147
|
+
* cookie from code that also ships to the browser); the codec that fills it
|
|
148
|
+
* is server-only and lives behind the server entry.
|
|
149
|
+
*/
|
|
150
|
+
export const FLASH_COOKIE: string;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Whether a Cookie header carries a flash cookie, readable or not. Cheap
|
|
154
|
+
* enough to call on every render so the clear can be queued before the
|
|
155
|
+
* response headers flush.
|
|
156
|
+
*/
|
|
157
|
+
export function hasFlashCookie(cookieHeader: string | null): boolean;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The `Set-Cookie` value clearing the flash cookie. The outcome is
|
|
161
|
+
* one-shot: append this as soon as the cookie is detected, whether or not
|
|
162
|
+
* it decodes, so a stale outcome cannot resurface on a later request.
|
|
163
|
+
*/
|
|
164
|
+
export function clearFlashCookie(): string;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The raw encoded flash payload out of a Cookie header, if present — the
|
|
168
|
+
* codec's own accessor.
|
|
169
|
+
*
|
|
170
|
+
* @internal
|
|
171
|
+
*/
|
|
172
|
+
export function matchFlashCookie(cookieHeader: string | null): string | undefined;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* The currently registered single-flight consumer.
|
|
176
|
+
*
|
|
177
|
+
* Transport building block; not meant for hand-written code.
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
export function getFlightDataConsumer(): FlightDataConsumer | undefined;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* The public contract of a server function reference — what a `"use
|
|
184
|
+
* server"` import is at runtime on either side: an async callable plus its
|
|
185
|
+
* build-stable identity.
|
|
186
|
+
*/
|
|
187
|
+
export interface ServerFunction<A extends readonly any[] = any[], T = any> {
|
|
188
|
+
(...args: A): Promise<T>;
|
|
189
|
+
/** The build-stable function id (stable across the client and server builds). */
|
|
190
|
+
readonly id: string;
|
|
191
|
+
/** URL invoking this function directly over HTTP (form `action`s, raw fetches). */
|
|
192
|
+
readonly url: string;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Declaration-static metadata attached to a server function reference
|
|
197
|
+
* through declaration wrappers (`GET`, `withMeta`). Read it with
|
|
198
|
+
* `getServerFunctionMetadata`; routers and integrations detect capability
|
|
199
|
+
* from here instead of property sniffing, and `prepareRequest` receives it
|
|
200
|
+
* as `context.meta`. Write through `withMeta` — later writes shallow-merge
|
|
201
|
+
* over earlier ones.
|
|
202
|
+
*/
|
|
203
|
+
export interface ServerFunctionMetadata {
|
|
204
|
+
/** The declared HTTP method. Undeclared references call over POST. */
|
|
205
|
+
readonly method?: "GET" | "POST";
|
|
206
|
+
/**
|
|
207
|
+
* A human-readable label for the function, seeded by development builds
|
|
208
|
+
* from the compiled function's source name (dev tooling — inspectors,
|
|
209
|
+
* logs). Dev-only: production builds emit no name. Not unique and not an
|
|
210
|
+
* identity key — use `id` for identity. Seeded as a default: an explicit
|
|
211
|
+
* `withMeta` write wins.
|
|
212
|
+
*/
|
|
213
|
+
readonly name?: string;
|
|
214
|
+
/** User-declared transport metadata attached with `withMeta`. */
|
|
215
|
+
readonly [key: string]: unknown;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Reads a server function reference's declaration metadata — e.g.
|
|
220
|
+
* `getServerFunctionMetadata(fn)?.method === "GET"` detects a `GET(fn)`
|
|
221
|
+
* declaration. Returns undefined when `fn` is not a server function
|
|
222
|
+
* reference; plain references carry an empty metadata object. Works on
|
|
223
|
+
* client proxies and server-side references alike, across duplicated
|
|
224
|
+
* module instances (registered-symbol brand).
|
|
225
|
+
*/
|
|
226
|
+
export function getServerFunctionMetadata(fn: unknown): ServerFunctionMetadata | undefined;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Whether `fn` is a server function reference (a client proxy or a
|
|
230
|
+
* server-side registered callable). Detection is structural — a
|
|
231
|
+
* registered-symbol metadata brand — so it holds across duplicated module
|
|
232
|
+
* instances and both sides of the directive boundary.
|
|
233
|
+
*/
|
|
234
|
+
export function isServerFunction(fn: unknown): fn is ServerFunction;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Attaches user-declared transport metadata to a server function reference
|
|
238
|
+
* (client proxy or server-registered callable) and returns the reference.
|
|
239
|
+
* Writes ride the same channel `GET` uses: later writes shallow-merge over
|
|
240
|
+
* earlier ones, and `getServerFunctionMetadata(fn)` reads the merged bag —
|
|
241
|
+
* so `withMeta` composes with `GET` in either order
|
|
242
|
+
* (`GET(withMeta(fn, meta))` ≡ `withMeta(GET(fn), meta)`).
|
|
243
|
+
*
|
|
244
|
+
* The pattern is declare-on-function, react-in-hook: metadata declared
|
|
245
|
+
* here reaches `prepareRequest` as `context.meta`, letting session-dynamic
|
|
246
|
+
* transport policy key on declarations instead of comparing function ids:
|
|
247
|
+
*
|
|
248
|
+
* ```ts
|
|
249
|
+
* export const chargeCard = withMeta(async (amount: number) => {
|
|
250
|
+
* "use server";
|
|
251
|
+
* // ...
|
|
252
|
+
* }, { requiresAuth: true });
|
|
253
|
+
*
|
|
254
|
+
* configureServerFunctionsClient({
|
|
255
|
+
* prepareRequest(init, { meta }) {
|
|
256
|
+
* if (meta?.requiresAuth) {
|
|
257
|
+
* return {
|
|
258
|
+
* ...init,
|
|
259
|
+
* headers: { ...init.headers, Authorization: `Bearer ${session.token()}` }
|
|
260
|
+
* };
|
|
261
|
+
* }
|
|
262
|
+
* return init;
|
|
263
|
+
* }
|
|
264
|
+
* });
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
export function withMeta<F extends (...args: any[]) => any>(fn: F, meta: ServerFunctionMetadata): F;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* The registered symbol branding server function references with their
|
|
271
|
+
* declaration metadata. Use the typed accessors instead.
|
|
272
|
+
* @internal
|
|
273
|
+
*/
|
|
274
|
+
export const SERVER_FUNCTION_METADATA: unique symbol;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Header carrying the body format tag (a `BodyFormat` value) —
|
|
278
|
+
* `"X-Server-Function-Format"`.
|
|
279
|
+
*
|
|
280
|
+
* Transport wire detail; not meant for hand-written code.
|
|
281
|
+
* @internal
|
|
282
|
+
*/
|
|
283
|
+
export const BODY_FORMAT_HEADER: string;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* FormData key used when a lone File is sent as the argument.
|
|
287
|
+
*
|
|
288
|
+
* Transport wire detail; not meant for hand-written code.
|
|
289
|
+
* @internal
|
|
290
|
+
*/
|
|
291
|
+
export const FILE_FORM_KEY: string;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Wire tags naming how a request/response body was encoded, carried in
|
|
295
|
+
* `BODY_FORMAT_HEADER`.
|
|
296
|
+
*
|
|
297
|
+
* Transport wire detail; not meant for hand-written code.
|
|
298
|
+
* @internal
|
|
299
|
+
*/
|
|
300
|
+
export const BodyFormat: {
|
|
301
|
+
readonly Serialized: "0";
|
|
302
|
+
readonly String: "1";
|
|
303
|
+
readonly FormData: "2";
|
|
304
|
+
readonly URLSearchParams: "3";
|
|
305
|
+
readonly Blob: "4";
|
|
306
|
+
readonly File: "5";
|
|
307
|
+
readonly ArrayBuffer: "6";
|
|
308
|
+
readonly Uint8Array: "7";
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Transport wire detail; not meant for hand-written code.
|
|
313
|
+
* @internal
|
|
314
|
+
*/
|
|
315
|
+
export type BodyFormatValue = (typeof BodyFormat)[keyof typeof BodyFormat];
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Picks a direct HTTP encoding (headers + BodyInit) for values that have
|
|
319
|
+
* one — strings, FormData, URLSearchParams, File, Blob, ArrayBuffer,
|
|
320
|
+
* Uint8Array. Returns undefined when the value needs the serializer.
|
|
321
|
+
*
|
|
322
|
+
* Transport building block used by the fetch transport and the HTTP
|
|
323
|
+
* handler; not meant for hand-written code.
|
|
324
|
+
* @internal
|
|
325
|
+
*/
|
|
326
|
+
export function getHeadersAndBody(
|
|
327
|
+
body: unknown
|
|
328
|
+
): { headers?: Record<string, string>; body: BodyInit } | undefined;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Decodes a Request/Response body according to its `BODY_FORMAT_HEADER`
|
|
332
|
+
* tag (falling back to content-type sniffing for form posts that never saw
|
|
333
|
+
* the client runtime). The inverse of `getHeadersAndBody` + the serialized
|
|
334
|
+
* stream. Resolves undefined for bodies without a recognized encoding.
|
|
335
|
+
*
|
|
336
|
+
* Transport building block; use `decodeResponse` from integration code.
|
|
337
|
+
* @internal
|
|
338
|
+
*/
|
|
339
|
+
export function extractBody(
|
|
340
|
+
source: Request | Response,
|
|
341
|
+
codecOptions?: JSONCodecOptions
|
|
342
|
+
): Promise<unknown>;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Serializes a value as a stream of length-prefixed SerovalNode chunks.
|
|
346
|
+
* Async values (promises, streams) keep the stream open until they settle,
|
|
347
|
+
* so one connection carries incremental results. Codec options must match
|
|
348
|
+
* the deserializing peer.
|
|
349
|
+
*
|
|
350
|
+
* Transport building block; not meant for hand-written code.
|
|
351
|
+
* @internal
|
|
352
|
+
*/
|
|
353
|
+
export function serializeStream(
|
|
354
|
+
value: unknown,
|
|
355
|
+
codecOptions?: JSONCodecOptions
|
|
356
|
+
): ReadableStream<Uint8Array>;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* `serializeStream` drained to a string (async values fully awaited).
|
|
360
|
+
*
|
|
361
|
+
* Transport building block; not meant for hand-written code.
|
|
362
|
+
* @internal
|
|
363
|
+
*/
|
|
364
|
+
export function serializeString(value: unknown, codecOptions?: JSONCodecOptions): Promise<string>;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Decodes a framed chunk stream from a Request/Response body. Resolves with
|
|
368
|
+
* the first chunk's value (the source value); later chunks settle the async
|
|
369
|
+
* values referenced inside it as they arrive.
|
|
370
|
+
*
|
|
371
|
+
* Transport building block; use `decodeResponse` from integration code.
|
|
372
|
+
* @internal
|
|
373
|
+
*/
|
|
374
|
+
export function deserializeStream<T = unknown>(
|
|
375
|
+
source: Request | Response,
|
|
376
|
+
codecOptions?: JSONCodecOptions
|
|
377
|
+
): Promise<T>;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* `deserializeStream` for an already-buffered string.
|
|
381
|
+
*
|
|
382
|
+
* Transport building block; not meant for hand-written code.
|
|
383
|
+
* @internal
|
|
384
|
+
*/
|
|
385
|
+
export function deserializeString<T = unknown>(
|
|
386
|
+
text: string,
|
|
387
|
+
codecOptions?: JSONCodecOptions
|
|
388
|
+
): Promise<T>;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Decodes a server function response body using the configured codec. This
|
|
392
|
+
* is the integration-facing decoder: routers call it on responses the
|
|
393
|
+
* transport hands over whole — redirects, revalidation, single-flight
|
|
394
|
+
* payloads — to recover the structured value inside. Resolves undefined for
|
|
395
|
+
* empty bodies and bodies without a recognized encoding (e.g. a raw user
|
|
396
|
+
* Response). Renderer- and platform-neutral: safe to use from universal
|
|
397
|
+
* code.
|
|
398
|
+
*
|
|
399
|
+
* @param response the transport response; its body is read from a clone,
|
|
400
|
+
* so the original stays readable
|
|
401
|
+
* @param codecOptions overrides the configured codec for this call
|
|
402
|
+
*/
|
|
403
|
+
export function decodeResponse<T = unknown>(
|
|
404
|
+
response: Response,
|
|
405
|
+
codecOptions?: JSONCodecOptions
|
|
406
|
+
): Promise<T | undefined>;
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* `decodeResponse` plus the single-flight envelope split: when the response
|
|
410
|
+
* carries the single-flight header the decoded `{ value, data }` payload is
|
|
411
|
+
* unwrapped into `{ value, flightData }`; otherwise the decoded body (or
|
|
412
|
+
* undefined for body-less responses) rides as `{ value }`. Integrations
|
|
413
|
+
* that apply response metadata themselves use this so the payload shape
|
|
414
|
+
* stays core's own.
|
|
415
|
+
*/
|
|
416
|
+
export function decodeResponsePayload<T = unknown, D = unknown>(
|
|
417
|
+
response: Response,
|
|
418
|
+
codecOptions?: JSONCodecOptions
|
|
419
|
+
): Promise<{ value: T | undefined; flightData?: D }>;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Frame one payload for the server-function wire: a `;0x<len32>;` length
|
|
423
|
+
* prefix followed by the utf-8 data. Both transports (server-function
|
|
424
|
+
* responses and frame streams) share this framing.
|
|
425
|
+
*/
|
|
426
|
+
export function createChunk(data: string): Uint8Array;
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Incremental decoder for `createChunk` framing over a byte stream: `next()`
|
|
430
|
+
* yields one complete payload string per call (async-iterator result shape),
|
|
431
|
+
* buffering partial frames internally until their length prefix is satisfied.
|
|
432
|
+
*/
|
|
433
|
+
export class ChunkReader {
|
|
434
|
+
constructor(stream: ReadableStream<Uint8Array>);
|
|
435
|
+
next(): Promise<{ done: boolean; value: string | undefined }>;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* The intrinsic wire address of a server-component call: the function id,
|
|
440
|
+
* suffixed with a realm-stable hash of the arguments when there are any.
|
|
441
|
+
* Both peers derive it independently — the server names flight regions with
|
|
442
|
+
* it, the client routes them by it — so it must stay deterministic across
|
|
443
|
+
* realms and releases.
|
|
444
|
+
*/
|
|
445
|
+
export function frameAddress(id: string, args?: readonly unknown[]): string;
|
package/types/server-mock.d.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders a component tree synchronously to an HTML string. Async reads inside
|
|
3
|
+
* `<Loading>` boundaries emit their `fallback` content; for full-graph
|
|
4
|
+
* resolution use `renderToStringAsync` instead.
|
|
5
|
+
*
|
|
6
|
+
* Pair the returned HTML with `hydrate()` on the client.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* import { renderToString } from "@solidjs/web";
|
|
11
|
+
*
|
|
12
|
+
* const html = renderToString(() => <App />);
|
|
13
|
+
* res.send(`<!doctype html><html><body><div id="root">${html}</div></body></html>`);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
1
16
|
export declare function renderToString<T>(fn: () => T, options?: {
|
|
2
17
|
nonce?: string;
|
|
3
18
|
renderId?: string;
|
|
@@ -12,6 +27,21 @@ export declare function renderToString<T>(fn: () => T, options?: {
|
|
|
12
27
|
}>;
|
|
13
28
|
onError?: (err: any) => void;
|
|
14
29
|
}): string;
|
|
30
|
+
/**
|
|
31
|
+
* Renders a component tree to an HTML string and awaits all async reads in the
|
|
32
|
+
* subtree before resolving. The returned HTML reflects the fully-settled state
|
|
33
|
+
* — no `<Loading>` fallbacks appear in the output.
|
|
34
|
+
*
|
|
35
|
+
* Use this when you want a complete page in one round-trip. For incremental
|
|
36
|
+
* streaming with progressive boundary resolution, use `renderToStream`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* import { renderToStringAsync } from "@solidjs/web";
|
|
41
|
+
*
|
|
42
|
+
* const html = await renderToStringAsync(() => <App />);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
15
45
|
export declare function renderToStringAsync<T>(fn: () => T, options?: {
|
|
16
46
|
timeoutMs?: number;
|
|
17
47
|
nonce?: string;
|
|
@@ -27,6 +57,28 @@ export declare function renderToStringAsync<T>(fn: () => T, options?: {
|
|
|
27
57
|
}>;
|
|
28
58
|
onError?: (err: any) => void;
|
|
29
59
|
}): Promise<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Streams an HTML response, flushing the synchronous shell first and then
|
|
62
|
+
* progressively emitting async-resolved fragments as their `<Loading>`
|
|
63
|
+
* boundaries settle. Good for time-to-first-byte sensitive pages.
|
|
64
|
+
*
|
|
65
|
+
* Returns an object with `pipe`/`pipeTo` for piping to a Node `Writable` or
|
|
66
|
+
* a Web `WritableStream`, a lazy `readable` byte-stream view for
|
|
67
|
+
* `new Response(stream.readable)`, plus a `then` for awaiting full
|
|
68
|
+
* completion. `pipe`, `pipeTo`, and `readable` each consume the render —
|
|
69
|
+
* use exactly one of the three.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```tsx
|
|
73
|
+
* import { renderToStream } from "@solidjs/web";
|
|
74
|
+
*
|
|
75
|
+
* // Node:
|
|
76
|
+
* renderToStream(() => <App />).pipe(res);
|
|
77
|
+
*
|
|
78
|
+
* // Web (Workers / Deno):
|
|
79
|
+
* return new Response(renderToStream(() => <App />).readable);
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
30
82
|
export declare function renderToStream<T>(fn: () => T, options?: {
|
|
31
83
|
nonce?: string;
|
|
32
84
|
renderId?: string;
|
|
@@ -53,20 +105,61 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
53
105
|
end: () => void;
|
|
54
106
|
}) => void;
|
|
55
107
|
pipeTo: (writable: WritableStream) => Promise<void>;
|
|
108
|
+
readonly readable: ReadableStream<Uint8Array>;
|
|
56
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* Compiler primitive — emitted by JSX-DOM-Expressions for tagged-template
|
|
112
|
+
* SSR output. Not meant for hand-written code.
|
|
113
|
+
* @internal
|
|
114
|
+
*/
|
|
57
115
|
export declare function ssr(template: string[] | string, ...nodes: any[]): {
|
|
58
116
|
t: string;
|
|
59
117
|
};
|
|
118
|
+
/**
|
|
119
|
+
* Compiler primitive — emitted by JSX-DOM-Expressions for SSR element
|
|
120
|
+
* output. Not meant for hand-written code.
|
|
121
|
+
* @internal
|
|
122
|
+
*/
|
|
60
123
|
export declare function ssrElement(name: string, props: any, children: any, needsId: boolean): {
|
|
61
124
|
t: string;
|
|
62
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* Compiler primitive — serializes a classList object for SSR output. Not
|
|
128
|
+
* meant for hand-written code.
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
63
131
|
export declare function ssrClassList(value: {
|
|
64
132
|
[k: string]: boolean;
|
|
65
133
|
}): string;
|
|
134
|
+
/**
|
|
135
|
+
* Compiler primitive — serializes a style object for SSR output. Not meant
|
|
136
|
+
* for hand-written code.
|
|
137
|
+
* @internal
|
|
138
|
+
*/
|
|
66
139
|
export declare function ssrStyle(value: {
|
|
67
140
|
[k: string]: string;
|
|
68
141
|
}): string;
|
|
142
|
+
/**
|
|
143
|
+
* Compiler primitive — serializes a boolean attribute for SSR output. Not
|
|
144
|
+
* meant for hand-written code.
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
69
147
|
export declare function ssrAttribute(key: string, value: boolean): string;
|
|
148
|
+
/**
|
|
149
|
+
* Compiler primitive — generates the hydration-key attribute for SSR
|
|
150
|
+
* output. Not meant for hand-written code.
|
|
151
|
+
* @internal
|
|
152
|
+
*/
|
|
70
153
|
export declare function ssrHydrationKey(): string;
|
|
154
|
+
/**
|
|
155
|
+
* Compiler primitive — collapses an SSR-shaped node into its HTML string.
|
|
156
|
+
* Not meant for hand-written code.
|
|
157
|
+
* @internal
|
|
158
|
+
*/
|
|
71
159
|
export declare function resolveSSRNode(node: any): string;
|
|
160
|
+
/**
|
|
161
|
+
* Escapes a string for safe inclusion in HTML output. Used by the SSR
|
|
162
|
+
* runtime; not generally part of user code.
|
|
163
|
+
* @internal
|
|
164
|
+
*/
|
|
72
165
|
export declare function escape(html: string): string;
|