@solidjs/web 2.0.0-beta.31 → 2.0.0-beta.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -6
- package/dist/dev.cjs +285 -60
- package/dist/dev.js +267 -57
- package/dist/server.cjs +1148 -176
- package/dist/server.js +1133 -175
- package/dist/web.cjs +285 -60
- package/dist/web.js +267 -57
- package/frames/dist/client.cjs +397 -175
- package/frames/dist/client.dev.cjs +401 -175
- package/frames/dist/client.dev.js +399 -173
- package/frames/dist/client.js +395 -173
- package/frames/dist/server.cjs +1424 -277
- package/frames/dist/server.js +1426 -280
- package/package.json +69 -7
- package/serialization/decode/package.json +20 -0
- package/serialization/dist/decode.cjs +110 -0
- package/serialization/dist/decode.js +104 -0
- package/serialization/dist/serialization.cjs +106 -43
- package/serialization/dist/serialization.js +100 -44
- package/serialization/types/index.d.ts +85 -60
- package/serialization/types/serializer-decode.d.ts +182 -0
- package/serialization/types-cjs/index.d.cts +85 -60
- package/serialization/types-cjs/serializer-decode.d.cts +182 -0
- package/server-functions/dist/client.cjs +131 -98
- package/server-functions/dist/client.js +131 -99
- package/server-functions/dist/rich-args.cjs +11 -0
- package/server-functions/dist/rich-args.js +9 -0
- package/server-functions/dist/server.cjs +367 -194
- package/server-functions/dist/server.dev.cjs +1077 -0
- package/server-functions/dist/server.dev.js +1045 -0
- package/server-functions/dist/server.js +365 -195
- package/server-functions/package.json +10 -0
- package/server-functions/rich-args/package.json +20 -0
- package/storage/types/index.d.ts +1 -1
- package/storage/types-cjs/index.d.cts +1 -1
- package/types/client.d.ts +149 -6
- package/types/cookies.d.ts +93 -0
- package/types/core.d.ts +4 -2
- package/types/frames/client.d.ts +15 -1
- package/types/frames/frame-client.d.ts +63 -7
- package/types/frames/frame-sink.d.ts +26 -3
- package/types/frames/frame-transport.d.ts +40 -8
- package/types/frames/serializer.d.ts +85 -60
- package/types/frames/server.d.ts +22 -0
- package/types/index.d.ts +2 -3
- package/types/response.d.ts +45 -0
- package/types/serializer-decode.d.ts +182 -0
- package/types/serializer.d.ts +85 -60
- package/types/server-functions/client.d.ts +2 -1
- package/types/server-functions/rich-args.d.ts +10 -0
- package/types/server-functions/server.d.ts +99 -1
- package/types/server-functions/shared.d.ts +79 -1
- package/types/server-mock.d.ts +171 -59
- package/types/server.d.ts +209 -37
- package/types-cjs/client.d.cts +149 -6
- package/types-cjs/cookies.d.cts +93 -0
- package/types-cjs/core.d.cts +4 -2
- package/types-cjs/frames/client.d.cts +15 -1
- package/types-cjs/frames/frame-client.d.cts +63 -7
- package/types-cjs/frames/frame-sink.d.cts +26 -3
- package/types-cjs/frames/frame-transport.d.cts +40 -8
- package/types-cjs/frames/serializer.d.cts +85 -60
- package/types-cjs/frames/server.d.cts +22 -0
- package/types-cjs/index.d.cts +2 -3
- package/types-cjs/response.d.cts +45 -0
- package/types-cjs/serializer-decode.d.cts +182 -0
- package/types-cjs/serializer.d.cts +85 -60
- package/types-cjs/server-functions/client.d.cts +2 -1
- package/types-cjs/server-functions/rich-args.d.cts +10 -0
- package/types-cjs/server-functions/server.d.cts +99 -1
- package/types-cjs/server-functions/shared.d.cts +79 -1
- package/types-cjs/server-mock.d.cts +171 -59
- package/types-cjs/server.d.cts +209 -37
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSONCodecOptions } from "../serializer.js";
|
|
1
|
+
import { JSONCodecOptions } from "../serializer-decode.js";
|
|
2
2
|
|
|
3
3
|
export type { JSONCodecOptions };
|
|
4
4
|
|
|
@@ -18,6 +18,9 @@ export function configureServerFunctionsCodec(codec: JSONCodecOptions | undefine
|
|
|
18
18
|
* `configureServerFunctionsCodec` or the client/server `codec` option), or
|
|
19
19
|
* undefined when running on the defaults. Integrations pass this to
|
|
20
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
|
|
21
24
|
*/
|
|
22
25
|
export function getServerFunctionsCodec(): JSONCodecOptions | undefined;
|
|
23
26
|
|
|
@@ -57,6 +60,9 @@ export const ERROR_HEADER: string;
|
|
|
57
60
|
* travels percent-encoded behind a marker. `decodeErrorHeaderValue`
|
|
58
61
|
* round-trips the message exactly, astral-plane characters included (lone
|
|
59
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
|
|
60
66
|
*/
|
|
61
67
|
export function encodeErrorHeaderValue(value: string): string;
|
|
62
68
|
|
|
@@ -64,6 +70,10 @@ export function encodeErrorHeaderValue(value: string): string;
|
|
|
64
70
|
* Decodes an `ERROR_HEADER` value produced by `encodeErrorHeaderValue`:
|
|
65
71
|
* marked values are percent-decoded, everything else (including values from
|
|
66
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
|
|
67
77
|
*/
|
|
68
78
|
export function decodeErrorHeaderValue(value: string): string;
|
|
69
79
|
|
|
@@ -273,6 +283,46 @@ export function withMeta<F extends (...args: any[]) => any>(fn: F, meta: ServerF
|
|
|
273
283
|
*/
|
|
274
284
|
export const SERVER_FUNCTION_METADATA: unique symbol;
|
|
275
285
|
|
|
286
|
+
/**
|
|
287
|
+
* The transport surface integrations consume through the late-bound RPC
|
|
288
|
+
* seam (server-functions/registry.js) — filled by the transport halves when
|
|
289
|
+
* the first server function reference is created (code that only exists in
|
|
290
|
+
* a bundle when a `"use server"` function was actually compiled in), read
|
|
291
|
+
* by routers so they never import the transport/codec statically.
|
|
292
|
+
*/
|
|
293
|
+
export interface ServerFunctionRPC {
|
|
294
|
+
/**
|
|
295
|
+
* The build's `GET` declaration wrapper (client fetch transport or
|
|
296
|
+
* server in-process dispatch — see the respective entries).
|
|
297
|
+
*/
|
|
298
|
+
GET<A extends readonly any[], R>(fn: (...args: A) => R): ServerFunction<A, Awaited<R>>;
|
|
299
|
+
/**
|
|
300
|
+
* `decodeResponse` bound to the configured codec: decodes a server
|
|
301
|
+
* function response body the transport handed over whole (redirects,
|
|
302
|
+
* revalidation). Resolves undefined for empty bodies and bodies without
|
|
303
|
+
* a recognized encoding (e.g. a raw user Response).
|
|
304
|
+
*/
|
|
305
|
+
decodeResponse<T = unknown>(response: Response): Promise<T | undefined>;
|
|
306
|
+
}
|
|
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
|
+
|
|
276
326
|
/**
|
|
277
327
|
* Header carrying the body format tag (a `BodyFormat` value) —
|
|
278
328
|
* `"X-Server-Function-Format"`.
|
|
@@ -306,6 +356,11 @@ export const BodyFormat: {
|
|
|
306
356
|
readonly File: "5";
|
|
307
357
|
readonly ArrayBuffer: "6";
|
|
308
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";
|
|
309
364
|
};
|
|
310
365
|
|
|
311
366
|
/**
|
|
@@ -314,6 +369,17 @@ export const BodyFormat: {
|
|
|
314
369
|
*/
|
|
315
370
|
export type BodyFormatValue = (typeof BodyFormat)[keyof typeof BodyFormat];
|
|
316
371
|
|
|
372
|
+
/**
|
|
373
|
+
* Whether a value survives a `JSON.stringify` round trip faithfully: JSON
|
|
374
|
+
* primitives (finite numbers only), arrays, and plain objects. Anything
|
|
375
|
+
* else — Dates, Maps, typed arrays, undefined (bare or as a property),
|
|
376
|
+
* NaN, class instances, cyclic structures — needs the codec. Never throws:
|
|
377
|
+
* cycles and pathological depth answer `false`. Both peers negotiate the
|
|
378
|
+
* wire format with this guard: the client for argument lists, the server
|
|
379
|
+
* for results.
|
|
380
|
+
*/
|
|
381
|
+
export function isJSONSafe(value: unknown): boolean;
|
|
382
|
+
|
|
317
383
|
/**
|
|
318
384
|
* Picks a direct HTTP encoding (headers + BodyInit) for values that have
|
|
319
385
|
* one — strings, FormData, URLSearchParams, File, Blob, ArrayBuffer,
|
|
@@ -412,6 +478,9 @@ export function decodeResponse<T = unknown>(
|
|
|
412
478
|
* undefined for body-less responses) rides as `{ value }`. Integrations
|
|
413
479
|
* that apply response metadata themselves use this so the payload shape
|
|
414
480
|
* stays core's own.
|
|
481
|
+
*
|
|
482
|
+
* Integration plumbing; not meant for hand-written application code.
|
|
483
|
+
* @internal
|
|
415
484
|
*/
|
|
416
485
|
export function decodeResponsePayload<T = unknown, D = unknown>(
|
|
417
486
|
response: Response,
|
|
@@ -422,6 +491,9 @@ export function decodeResponsePayload<T = unknown, D = unknown>(
|
|
|
422
491
|
* Frame one payload for the server-function wire: a `;0x<len32>;` length
|
|
423
492
|
* prefix followed by the utf-8 data. Both transports (server-function
|
|
424
493
|
* responses and frame streams) share this framing.
|
|
494
|
+
*
|
|
495
|
+
* Transport wire detail; not meant for hand-written code.
|
|
496
|
+
* @internal
|
|
425
497
|
*/
|
|
426
498
|
export function createChunk(data: string): Uint8Array;
|
|
427
499
|
|
|
@@ -429,6 +501,9 @@ export function createChunk(data: string): Uint8Array;
|
|
|
429
501
|
* Incremental decoder for `createChunk` framing over a byte stream: `next()`
|
|
430
502
|
* yields one complete payload string per call (async-iterator result shape),
|
|
431
503
|
* buffering partial frames internally until their length prefix is satisfied.
|
|
504
|
+
*
|
|
505
|
+
* Transport wire detail; not meant for hand-written code.
|
|
506
|
+
* @internal
|
|
432
507
|
*/
|
|
433
508
|
export class ChunkReader {
|
|
434
509
|
constructor(stream: ReadableStream<Uint8Array>);
|
|
@@ -441,5 +516,8 @@ export class ChunkReader {
|
|
|
441
516
|
* Both peers derive it independently — the server names flight regions with
|
|
442
517
|
* it, the client routes them by it — so it must stay deterministic across
|
|
443
518
|
* realms and releases.
|
|
519
|
+
*
|
|
520
|
+
* Transport wire detail; not meant for hand-written code.
|
|
521
|
+
* @internal
|
|
444
522
|
*/
|
|
445
523
|
export function frameAddress(id: string, args?: readonly unknown[]): string;
|
package/types/server-mock.d.ts
CHANGED
|
@@ -1,7 +1,48 @@
|
|
|
1
|
+
import type { RequestEvent, RequestEventLocals, ResponseStub } from "./client.js";
|
|
2
|
+
/** Static asset manifest produced by a build (e.g. parsed Vite manifest.json). */
|
|
3
|
+
export type AssetManifest = Record<string, {
|
|
4
|
+
file: string;
|
|
5
|
+
css?: string[];
|
|
6
|
+
isEntry?: boolean;
|
|
7
|
+
imports?: string[];
|
|
8
|
+
}> & {
|
|
9
|
+
_base?: string;
|
|
10
|
+
};
|
|
11
|
+
/** Inline style content, e.g. dev CSS collected from a bundler's module graph. */
|
|
12
|
+
export type InlineStyleAsset = {
|
|
13
|
+
id: string;
|
|
14
|
+
content: string;
|
|
15
|
+
attrs?: Record<string, string>;
|
|
16
|
+
};
|
|
17
|
+
export type ResolvedAssets = {
|
|
18
|
+
js: string[];
|
|
19
|
+
css: (string | InlineStyleAsset)[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Resolver form of the manifest option — the primitive a dev server
|
|
23
|
+
* implements against its live module graph (a static manifest object is
|
|
24
|
+
* normalized into a sync resolver internally). `resolve` may return a
|
|
25
|
+
* promise (async resolvers require streaming rendering); CSS entries may be
|
|
26
|
+
* URL strings (emitted as load-gated `<link>` tags) or inline-style
|
|
27
|
+
* descriptors (emitted as `<style>` tags). A bare `resolve`-shaped function
|
|
28
|
+
* is accepted as shorthand for `{ resolve }`.
|
|
29
|
+
*/
|
|
30
|
+
export type AssetResolver = {
|
|
31
|
+
resolve(key: string): ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Synchronous fast path answering with whatever is knowable without async
|
|
34
|
+
* work (typically js URLs, omitting css). Sync consumers — e.g. a lazy
|
|
35
|
+
* component's `moduleUrl` getter used by islands — use this when `resolve`
|
|
36
|
+
* would return a promise, so adapters should provide it whenever possible.
|
|
37
|
+
*/
|
|
38
|
+
resolveSync?(key: string): ResolvedAssets | null | undefined;
|
|
39
|
+
};
|
|
40
|
+
/** Bare-function shorthand for `AssetResolver` (no sync fast path). */
|
|
41
|
+
export type AssetResolverFn = (key: string) => ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
|
|
1
42
|
/**
|
|
2
43
|
* Renders a component tree synchronously to an HTML string. Async reads inside
|
|
3
44
|
* `<Loading>` boundaries emit their `fallback` content; for full-graph
|
|
4
|
-
* resolution
|
|
45
|
+
* resolution await `renderToStream` instead.
|
|
5
46
|
*
|
|
6
47
|
* Pair the returned HTML with `hydrate()` on the client.
|
|
7
48
|
*
|
|
@@ -18,45 +59,20 @@ export declare function renderToString<T>(fn: () => T, options?: {
|
|
|
18
59
|
renderId?: string;
|
|
19
60
|
noScripts?: boolean;
|
|
20
61
|
plugins?: any[];
|
|
21
|
-
manifest?:
|
|
22
|
-
file: string;
|
|
23
|
-
css?: string[];
|
|
24
|
-
isEntry?: boolean;
|
|
25
|
-
isDynamicEntry?: boolean;
|
|
26
|
-
imports?: string[];
|
|
27
|
-
}>;
|
|
62
|
+
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
28
63
|
onError?: (err: any) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Embedded-render contract for hosts that own the document. When the
|
|
66
|
+
* render output contains no `</head>`, everything head-bound (resolved
|
|
67
|
+
* `useHead` winners, eager resources, tracked asset links, inline
|
|
68
|
+
* styles) is delivered here as one HTML string — prelude (charset/base)
|
|
69
|
+
* first — for the host to splice into its own `<head>` template, instead
|
|
70
|
+
* of being dropped. Called synchronously before `renderToString`
|
|
71
|
+
* returns; not called when the output has a `</head>` (splicing is
|
|
72
|
+
* automatic then).
|
|
73
|
+
*/
|
|
74
|
+
onHead?: (head: string) => void;
|
|
29
75
|
}): 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
|
-
*/
|
|
45
|
-
export declare function renderToStringAsync<T>(fn: () => T, options?: {
|
|
46
|
-
timeoutMs?: number;
|
|
47
|
-
nonce?: string;
|
|
48
|
-
renderId?: string;
|
|
49
|
-
noScripts?: boolean;
|
|
50
|
-
plugins?: any[];
|
|
51
|
-
manifest?: Record<string, {
|
|
52
|
-
file: string;
|
|
53
|
-
css?: string[];
|
|
54
|
-
isEntry?: boolean;
|
|
55
|
-
isDynamicEntry?: boolean;
|
|
56
|
-
imports?: string[];
|
|
57
|
-
}>;
|
|
58
|
-
onError?: (err: any) => void;
|
|
59
|
-
}): Promise<string>;
|
|
60
76
|
/**
|
|
61
77
|
* Streams an HTML response, flushing the synchronous shell first and then
|
|
62
78
|
* progressively emitting async-resolved fragments as their `<Loading>`
|
|
@@ -64,9 +80,10 @@ export declare function renderToStringAsync<T>(fn: () => T, options?: {
|
|
|
64
80
|
*
|
|
65
81
|
* Returns an object with `pipe`/`pipeTo` for piping to a Node `Writable` or
|
|
66
82
|
* a Web `WritableStream`, a lazy `readable` byte-stream view for
|
|
67
|
-
* `new Response(stream.readable)`, plus a
|
|
68
|
-
* completion
|
|
69
|
-
*
|
|
83
|
+
* `new Response(stream.readable)`, plus a thenable for awaiting full
|
|
84
|
+
* completion — `await renderToStream(...)` resolves with the settled HTML
|
|
85
|
+
* (the fully-resolved-string form of the render). `pipe`, `pipeTo`, and
|
|
86
|
+
* `readable` each consume the render — use exactly one of the three.
|
|
70
87
|
*
|
|
71
88
|
* @example
|
|
72
89
|
* ```tsx
|
|
@@ -77,6 +94,9 @@ export declare function renderToStringAsync<T>(fn: () => T, options?: {
|
|
|
77
94
|
*
|
|
78
95
|
* // Web (Workers / Deno):
|
|
79
96
|
* return new Response(renderToStream(() => <App />).readable);
|
|
97
|
+
*
|
|
98
|
+
* // Fully settled string:
|
|
99
|
+
* const html = await renderToStream(() => <App />);
|
|
80
100
|
* ```
|
|
81
101
|
*/
|
|
82
102
|
export declare function renderToStream<T>(fn: () => T, options?: {
|
|
@@ -84,13 +104,7 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
84
104
|
renderId?: string;
|
|
85
105
|
noScripts?: boolean;
|
|
86
106
|
plugins?: any[];
|
|
87
|
-
manifest?:
|
|
88
|
-
file: string;
|
|
89
|
-
css?: string[];
|
|
90
|
-
isEntry?: boolean;
|
|
91
|
-
isDynamicEntry?: boolean;
|
|
92
|
-
imports?: string[];
|
|
93
|
-
}>;
|
|
107
|
+
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
94
108
|
onCompleteShell?: (info: {
|
|
95
109
|
write: (v: string) => void;
|
|
96
110
|
}) => void;
|
|
@@ -98,8 +112,25 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
98
112
|
write: (v: string) => void;
|
|
99
113
|
}) => void;
|
|
100
114
|
onError?: (err: any) => void;
|
|
115
|
+
/**
|
|
116
|
+
* Embedded-render contract for hosts that own the document. When the
|
|
117
|
+
* shell contains no `</head>`, everything head-bound at first flush
|
|
118
|
+
* (resolved `useHead` winners, eager resources, tracked asset links,
|
|
119
|
+
* inline styles) is delivered here as one HTML string — prelude first —
|
|
120
|
+
* before the shell chunk is emitted, so the host can write its own
|
|
121
|
+
* `<head>` ahead of piping the stream. Post-shell head updates flow
|
|
122
|
+
* through the stream itself and apply in the browser. Not called when
|
|
123
|
+
* the shell has a `</head>` (splicing is automatic then).
|
|
124
|
+
*/
|
|
125
|
+
onHead?: (head: string) => void;
|
|
101
126
|
}): {
|
|
102
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Awaiting the stream resolves with the complete HTML once every boundary
|
|
129
|
+
* settles — the fully-settled-string form of the render. Render errors
|
|
130
|
+
* route through `onError` and the promise resolves with whatever HTML the
|
|
131
|
+
* render produced; it never rejects.
|
|
132
|
+
*/
|
|
133
|
+
then<TResult1 = string, TResult2 = never>(onfulfilled?: ((html: string) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
103
134
|
pipe: (writable: {
|
|
104
135
|
write: (v: string) => void;
|
|
105
136
|
end: () => void;
|
|
@@ -107,6 +138,75 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
107
138
|
pipeTo: (writable: WritableStream) => Promise<void>;
|
|
108
139
|
readonly readable: ReadableStream<Uint8Array>;
|
|
109
140
|
};
|
|
141
|
+
/**
|
|
142
|
+
* Fetch-style middleware: receives the `Request` and a `next` continuation
|
|
143
|
+
* (pass a `Request` to substitute it downstream) and returns the `Response`.
|
|
144
|
+
* Composed with `composeMiddleware`; runs inside the request-event scope, so
|
|
145
|
+
* `getRequestEvent()` works exactly as in application code.
|
|
146
|
+
*/
|
|
147
|
+
export type FetchMiddleware = (request: Request, next: (request?: Request) => Promise<Response>) => Response | Promise<Response>;
|
|
148
|
+
/**
|
|
149
|
+
* Creates a fresh, uncommitted {@link ResponseStub}. Server-only.
|
|
150
|
+
*/
|
|
151
|
+
export declare function createResponseStub(): ResponseStub;
|
|
152
|
+
/**
|
|
153
|
+
* Builds the canonical request event — a web-standard `Request`, a `locals`
|
|
154
|
+
* bag, and a stub-backed `response` head — for `provideRequestEvent`.
|
|
155
|
+
* Server-only: on the client the request event belongs to the server that
|
|
156
|
+
* rendered the page.
|
|
157
|
+
*/
|
|
158
|
+
export declare function createRequestEvent<T extends object = {}>(request: Request, init?: T): {
|
|
159
|
+
request: Request;
|
|
160
|
+
locals: RequestEventLocals;
|
|
161
|
+
response: ResponseStub;
|
|
162
|
+
} & T;
|
|
163
|
+
/**
|
|
164
|
+
* The HTTP status a redirect should use: the stub's own status when it is a
|
|
165
|
+
* redirect status (301/302/303/307/308), 302 otherwise. Server-only.
|
|
166
|
+
*/
|
|
167
|
+
export declare function getExpectedRedirectStatus(response: ResponseStub): number;
|
|
168
|
+
/**
|
|
169
|
+
* Derives the outgoing `Response` for an SSR render result, running the
|
|
170
|
+
* response-head lifecycle against `event.response`: the stub commits at
|
|
171
|
+
* shell flush, a pre-flush `Location` becomes a real redirect
|
|
172
|
+
* (`getExpectedRedirectStatus`), and a post-flush one appends the
|
|
173
|
+
* nonce-aware `<script>window.location=...</script>` fallback. String
|
|
174
|
+
* results return a `Response` synchronously; stream results resolve at
|
|
175
|
+
* shell flush. Server-only.
|
|
176
|
+
*/
|
|
177
|
+
export declare function createSSRResponse(result: string, event: RequestEvent | undefined, options?: {
|
|
178
|
+
responseInit?: ResponseInit;
|
|
179
|
+
nonce?: string;
|
|
180
|
+
transformChunk?: (chunk: string) => string;
|
|
181
|
+
}): Response;
|
|
182
|
+
export declare function createSSRResponse(result: {
|
|
183
|
+
pipe(writable: {
|
|
184
|
+
write: (v: string) => void;
|
|
185
|
+
end: () => void;
|
|
186
|
+
}): void;
|
|
187
|
+
}, event: RequestEvent | undefined, options?: {
|
|
188
|
+
responseInit?: ResponseInit;
|
|
189
|
+
nonce?: string;
|
|
190
|
+
transformChunk?: (chunk: string) => string;
|
|
191
|
+
}): Promise<Response>;
|
|
192
|
+
/**
|
|
193
|
+
* Handler-lifecycle plumbing — the exit for a `Response` that did not go
|
|
194
|
+
* through `createSSRResponse` (a middleware early return, an API result):
|
|
195
|
+
* folds the request event's response stub onto it (cookies append
|
|
196
|
+
* entry-by-entry, other headers gap-fill, status never) and commits the
|
|
197
|
+
* stub. Already-committed stubs pass the response through untouched, so
|
|
198
|
+
* handlers apply it unconditionally after their middleware chain unwinds.
|
|
199
|
+
* `event` defaults to the ambient `getRequestEvent()`. Application
|
|
200
|
+
* middleware never calls this. Server-only.
|
|
201
|
+
*/
|
|
202
|
+
export declare function commitEventResponse(response: Response, event?: RequestEvent): Response;
|
|
203
|
+
/**
|
|
204
|
+
* Composes fetch-style middleware — `(request, next) => Response` — into a
|
|
205
|
+
* single function of the same shape. Nothing reaches the wire until the
|
|
206
|
+
* outermost middleware returns, so headers on the returned `Response` stay
|
|
207
|
+
* mutable through the whole unwind, streamed bodies included. Server-only.
|
|
208
|
+
*/
|
|
209
|
+
export declare function composeMiddleware(middlewares: FetchMiddleware[]): (request: Request, next: (request?: Request) => Response | Promise<Response>) => Promise<Response>;
|
|
110
210
|
/**
|
|
111
211
|
* Compiler primitive — emitted by JSX-DOM-Expressions for tagged-template
|
|
112
212
|
* SSR output. Not meant for hand-written code.
|
|
@@ -124,27 +224,39 @@ export declare function ssrElement(name: string, props: any, children: any, need
|
|
|
124
224
|
t: string;
|
|
125
225
|
};
|
|
126
226
|
/**
|
|
127
|
-
* Compiler primitive — serializes a
|
|
128
|
-
* meant for hand-written code.
|
|
227
|
+
* Compiler primitive — serializes a class value (string, object map, or
|
|
228
|
+
* array) for SSR output. Not meant for hand-written code.
|
|
129
229
|
* @internal
|
|
130
230
|
*/
|
|
131
|
-
export declare function
|
|
231
|
+
export declare function ssrClassName(value: string | {
|
|
132
232
|
[k: string]: boolean;
|
|
133
|
-
}): string;
|
|
233
|
+
} | Array<any>): string;
|
|
134
234
|
/**
|
|
135
|
-
* Compiler primitive — serializes a style
|
|
235
|
+
* Compiler primitive — serializes a style value for SSR output. Not meant
|
|
136
236
|
* for hand-written code.
|
|
137
237
|
* @internal
|
|
138
238
|
*/
|
|
139
|
-
export declare function ssrStyle(value: {
|
|
239
|
+
export declare function ssrStyle(value: string | {
|
|
140
240
|
[k: string]: string;
|
|
141
241
|
}): string;
|
|
142
242
|
/**
|
|
143
|
-
* Compiler primitive — serializes
|
|
243
|
+
* Compiler primitive — serializes one style property for SSR output. Not
|
|
244
|
+
* meant for hand-written code.
|
|
245
|
+
* @internal
|
|
246
|
+
*/
|
|
247
|
+
export declare function ssrStyleProperty(name: string, value: any): string;
|
|
248
|
+
/**
|
|
249
|
+
* Compiler primitive — serializes an attribute for SSR output. Not meant
|
|
250
|
+
* for hand-written code.
|
|
251
|
+
* @internal
|
|
252
|
+
*/
|
|
253
|
+
export declare function ssrAttribute(key: string, value: any): string;
|
|
254
|
+
/**
|
|
255
|
+
* Compiler primitive — wraps a template-group closure for SSR output. Not
|
|
144
256
|
* meant for hand-written code.
|
|
145
257
|
* @internal
|
|
146
258
|
*/
|
|
147
|
-
export declare function
|
|
259
|
+
export declare function ssrGroup<T extends () => any[]>(fn: T, n: number): T;
|
|
148
260
|
/**
|
|
149
261
|
* Compiler primitive — generates the hydration-key attribute for SSR
|
|
150
262
|
* output. Not meant for hand-written code.
|
|
@@ -156,10 +268,10 @@ export declare function ssrHydrationKey(): string;
|
|
|
156
268
|
* Not meant for hand-written code.
|
|
157
269
|
* @internal
|
|
158
270
|
*/
|
|
159
|
-
export declare function resolveSSRNode(node: any):
|
|
271
|
+
export declare function resolveSSRNode(node: any, result?: any, top?: boolean): any;
|
|
160
272
|
/**
|
|
161
273
|
* Escapes a string for safe inclusion in HTML output. Used by the SSR
|
|
162
274
|
* runtime; not generally part of user code.
|
|
163
275
|
* @internal
|
|
164
276
|
*/
|
|
165
|
-
export declare function escape(
|
|
277
|
+
export declare function escape(s: any, attr?: boolean): any;
|