@solidjs/web 2.0.0-rc.2 → 2.0.0-rc.20
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 -1
- package/dist/server.dev.js +5065 -0
- package/dist/server.js +1757 -355
- package/dist/{server.cjs → server.observe.js} +1951 -558
- package/dist/{dev.cjs → web.dev.js} +945 -550
- package/dist/web.js +635 -332
- package/dist/{dev.js → web.observe.js} +688 -403
- package/frames/dist/assets.js +92 -0
- package/frames/dist/client.dev.js +1296 -1198
- package/frames/dist/client.js +1128 -1191
- package/frames/dist/client.observe.js +2041 -0
- package/frames/dist/regions.js +171 -0
- package/frames/dist/server.dev.js +2549 -0
- package/frames/dist/server.js +1688 -3005
- package/frames/dist/server.observe.js +2548 -0
- package/frames/dist/trace.js +45 -0
- package/frames/dist/wire.js +594 -0
- package/frames/package.json +2 -25
- package/package.json +244 -256
- package/performance-tracks/dist/performance-tracks.dev.js +679 -0
- package/performance-tracks/dist/performance-tracks.js +6 -0
- package/performance-tracks/dist/performance-tracks.observe.js +667 -0
- package/performance-tracks/package.json +7 -0
- package/performance-tracks/types/index.d.ts +69 -0
- package/serialization/decode/package.json +2 -15
- package/serialization/dist/decode.js +121 -25
- package/serialization/dist/serialization.js +242 -88
- package/serialization/package.json +2 -15
- package/serialization/types/index.d.ts +85 -158
- package/serialization/types/serializer-decode.d.ts +173 -114
- package/serialization/types/serializer.d.ts +109 -0
- package/server-functions/dist/client.dev.js +1462 -0
- package/server-functions/dist/client.js +667 -165
- package/server-functions/dist/client.observe.js +1441 -0
- package/server-functions/dist/rich-args.js +84 -1
- package/server-functions/dist/server.dev.js +2714 -297
- package/server-functions/dist/server.js +2595 -271
- package/server-functions/dist/server.observe.js +3594 -0
- package/server-functions/package.json +2 -35
- package/server-functions/rich-args/package.json +2 -15
- package/skills/server-components/SKILL.md +117 -0
- package/storage/package.json +2 -15
- package/types/client.d.ts +342 -288
- package/types/constants.d.ts +22 -0
- package/types/cookies.d.ts +32 -84
- package/types/diagnostics.d.ts +80 -0
- package/types/frames/assets-tier.d.ts +78 -0
- package/types/frames/client.d.ts +40 -1
- package/types/frames/frame-client.d.ts +443 -280
- package/types/frames/frame-container-plugin.d.ts +64 -0
- package/types/frames/frame-morph.d.ts +29 -0
- package/types/frames/frame-sink.d.ts +141 -161
- package/types/frames/frame-transport.d.ts +263 -184
- package/types/frames/regions-tier.d.ts +60 -0
- package/types/frames/serializer-decode.d.ts +241 -0
- package/types/frames/serializer.d.ts +85 -158
- package/types/frames/server.d.ts +2 -2
- package/types/frames/trace-tier.d.ts +2 -0
- package/types/frames/tree-rewrite.d.ts +39 -0
- package/types/frames/wire-tier.d.ts +169 -0
- package/types/head.d.ts +20 -0
- package/types/index.d.ts +98 -81
- package/types/index.server.d.ts +159 -0
- package/types/jsx.d.ts +49 -44
- package/types/observe.d.ts +535 -0
- package/types/reconcile.d.ts +1 -0
- package/types/render.d.ts +11 -0
- package/types/request-error-hook.d.ts +5 -0
- package/types/response.d.ts +95 -147
- package/types/serializer-decode.d.ts +173 -114
- package/types/serializer.d.ts +85 -158
- package/types/server-functions/argument-codec.d.ts +30 -0
- package/types/server-functions/client.d.ts +238 -223
- package/types/server-functions/flash.d.ts +28 -30
- package/types/server-functions/registry.d.ts +105 -0
- package/types/server-functions/rich-args.d.ts +1 -10
- package/types/server-functions/server.d.ts +539 -531
- package/types/server-functions/shared.d.ts +398 -425
- package/types/server-functions/uploads.d.ts +50 -0
- package/types/server-mock.d.ts +120 -13
- package/types/server-observe.d.ts +86 -0
- package/types/server.d.ts +571 -422
- package/types/trace.d.ts +127 -0
- package/LICENSE +0 -21
- package/dist/web.cjs +0 -2033
- package/frames/dist/client.cjs +0 -2002
- package/frames/dist/client.dev.cjs +0 -2022
- package/frames/dist/server.cjs +0 -3877
- package/serialization/dist/decode.cjs +0 -139
- package/serialization/dist/serialization.cjs +0 -261
- package/serialization/types-cjs/index.d.cts +0 -182
- package/serialization/types-cjs/package.json +0 -3
- package/serialization/types-cjs/serializer-decode.d.cts +0 -182
- package/server-functions/dist/client.cjs +0 -834
- package/server-functions/dist/rich-args.cjs +0 -11
- package/server-functions/dist/server.cjs +0 -1242
- package/server-functions/dist/server.dev.cjs +0 -1242
- package/storage/dist/storage.cjs +0 -12
- package/storage/types-cjs/index.d.cts +0 -28
- package/storage/types-cjs/package.json +0 -3
- package/types/core.d.ts +0 -9
- package/types-cjs/client.d.cts +0 -337
- package/types-cjs/cookies.d.cts +0 -93
- package/types-cjs/core.d.cts +0 -9
- package/types-cjs/frames/client.d.cts +0 -36
- package/types-cjs/frames/frame-client.d.cts +0 -356
- package/types-cjs/frames/frame-sink.d.cts +0 -194
- package/types-cjs/frames/frame-transport.d.cts +0 -222
- package/types-cjs/frames/serializer.d.cts +0 -182
- package/types-cjs/frames/server.d.cts +0 -52
- package/types-cjs/index.d.cts +0 -244
- package/types-cjs/jsx-properties.d.cts +0 -93
- package/types-cjs/jsx.d.cts +0 -4159
- package/types-cjs/package.json +0 -3
- package/types-cjs/response.d.cts +0 -174
- package/types-cjs/serializer-decode.d.cts +0 -182
- package/types-cjs/serializer.d.cts +0 -182
- package/types-cjs/server-functions/client.d.cts +0 -262
- package/types-cjs/server-functions/flash.d.cts +0 -38
- package/types-cjs/server-functions/rich-args.d.cts +0 -10
- package/types-cjs/server-functions/server.d.cts +0 -681
- package/types-cjs/server-functions/shared.d.cts +0 -523
- package/types-cjs/server-mock.d.cts +0 -286
- package/types-cjs/server.d.cts +0 -544
package/types/server.d.ts
CHANGED
|
@@ -1,62 +1,102 @@
|
|
|
1
|
+
import { getOwner, createComponent, untrack, merge as mergeProps } from "solid-js";
|
|
2
|
+
import { ssrScope as scope } from "solid-js/internal";
|
|
3
|
+
import type { Owner } from "solid-js";
|
|
4
|
+
import type { ServerErrorSite } from "solid-js/internal";
|
|
5
|
+
import { effect, memo } from "./render.js";
|
|
6
|
+
import { type TraceContext } from "./trace.js";
|
|
7
|
+
export { parseCookieHeader, serializeCookie } from "./cookies.js";
|
|
8
|
+
export { clearFlashCookie, hasFlashCookie } from "./cookies.js";
|
|
9
|
+
export { getServerFunctionMetadata, getServerFunctionRPC, isServerFunction } from "./server-functions/registry.js";
|
|
1
10
|
import { JSX } from "./jsx.js";
|
|
2
11
|
import { SerializerPlugin } from "./serializer-decode.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
type PreloadLinkAttributes = {
|
|
13
|
+
type?: string;
|
|
14
|
+
crossorigin?: JSX.HTMLCrossorigin;
|
|
15
|
+
integrity?: string;
|
|
16
|
+
referrerpolicy?: JSX.HTMLReferrerPolicy;
|
|
17
|
+
fetchpriority?: JSX.HTMLFetchPriority;
|
|
18
|
+
media?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* An explicit `<link rel="preload">` emitted by the SSR asset pipeline.
|
|
22
|
+
*
|
|
23
|
+
* `as` is the HTML Standard's set of preload destinations exactly — anything
|
|
24
|
+
* else translates to null and the browser does nothing with the link.
|
|
25
|
+
*
|
|
26
|
+
* `imagesrcset` candidates must already be resolved by the integration: they
|
|
27
|
+
* are carried verbatim (a relative candidate resolves against the DOCUMENT
|
|
28
|
+
* URL, not the manifest base). Pair it with `imagesizes` whenever a candidate
|
|
29
|
+
* uses a width descriptor, which the spec requires — without it the source
|
|
30
|
+
* size falls back to `100vw` and the preload can miss the image the `<img>`
|
|
31
|
+
* selects. Omitting `href` is the spec's own recommendation for the source-set
|
|
32
|
+
* form: it would only serve browsers without `imagesrcset` support, and there
|
|
33
|
+
* it would likely preload the wrong candidate.
|
|
34
|
+
*/
|
|
35
|
+
export type PreloadLink = PreloadLinkAttributes & ({
|
|
36
|
+
href: string;
|
|
37
|
+
as: Exclude<JSX.HTMLPreloadAs, "image">;
|
|
38
|
+
imagesrcset?: never;
|
|
39
|
+
imagesizes?: never;
|
|
40
|
+
} | {
|
|
41
|
+
href: string;
|
|
42
|
+
as: "image";
|
|
43
|
+
imagesrcset?: string;
|
|
44
|
+
imagesizes?: string;
|
|
45
|
+
} | {
|
|
46
|
+
href?: never;
|
|
47
|
+
as: "image";
|
|
48
|
+
imagesrcset: string;
|
|
49
|
+
imagesizes?: string;
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Static asset graph consumed by the SSR pipeline. This is Solid's own
|
|
53
|
+
* contract — a parsed Vite client manifest satisfies it structurally
|
|
54
|
+
* (unknown fields pass through untyped), but any bundler integration can
|
|
55
|
+
* produce it. Only these fields are ever read: `preloads` is Solid's
|
|
56
|
+
* extension slot for explicit typed links the integration selects.
|
|
57
|
+
*/
|
|
58
|
+
export type AssetManifest = Record<string, {
|
|
59
|
+
file: string;
|
|
60
|
+
css?: string[];
|
|
61
|
+
isEntry?: boolean;
|
|
62
|
+
imports?: string[];
|
|
63
|
+
preloads?: PreloadLink[];
|
|
64
|
+
}> & {
|
|
65
|
+
_base?: string;
|
|
66
|
+
};
|
|
21
67
|
/** Inline style content, e.g. dev CSS collected from a bundler's module graph. */
|
|
22
68
|
export type InlineStyleAsset = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
69
|
+
id: string;
|
|
70
|
+
content: string;
|
|
71
|
+
attrs?: Record<string, string>;
|
|
26
72
|
};
|
|
27
|
-
|
|
28
73
|
export type ResolvedAssets = {
|
|
29
|
-
|
|
30
|
-
|
|
74
|
+
js: string[];
|
|
75
|
+
css: (string | InlineStyleAsset)[];
|
|
76
|
+
preloads?: PreloadLink[];
|
|
31
77
|
};
|
|
32
|
-
|
|
33
78
|
/**
|
|
34
79
|
* Resolver form of the manifest option — the primitive a dev server
|
|
35
80
|
* implements against its live module graph (a static manifest object is
|
|
36
81
|
* normalized into a sync resolver internally). `resolve` may return a
|
|
37
82
|
* promise (async resolvers require streaming rendering); CSS entries may be
|
|
38
83
|
* URL strings (emitted as load-gated `<link>` tags) or inline-style
|
|
39
|
-
* descriptors (emitted as `<style>` tags)
|
|
40
|
-
*
|
|
84
|
+
* descriptors (emitted as `<style>` tags), and `preloads` carries explicit
|
|
85
|
+
* preload links selected by the integration. A bare `resolve`-shaped
|
|
86
|
+
* function is accepted as shorthand for `{ resolve }`.
|
|
41
87
|
*/
|
|
42
88
|
export type AssetResolver = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*/
|
|
52
|
-
resolveSync?(key: string): ResolvedAssets | null | undefined;
|
|
89
|
+
resolve(key: string): ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
|
|
90
|
+
/**
|
|
91
|
+
* Synchronous fast path answering with whatever is knowable without async
|
|
92
|
+
* work (typically js URLs, omitting css). Sync consumers — e.g. a lazy
|
|
93
|
+
* component's `moduleUrl` getter used by islands — use this when `resolve`
|
|
94
|
+
* would return a promise, so adapters should provide it whenever possible.
|
|
95
|
+
*/
|
|
96
|
+
resolveSync?(key: string): ResolvedAssets | null | undefined;
|
|
53
97
|
};
|
|
54
|
-
|
|
55
98
|
/** Bare-function shorthand for `AssetResolver` (no sync fast path). */
|
|
56
|
-
export type AssetResolverFn = (
|
|
57
|
-
key: string
|
|
58
|
-
) => ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
|
|
59
|
-
|
|
99
|
+
export type AssetResolverFn = (key: string) => ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
|
|
60
100
|
/**
|
|
61
101
|
* CSP nonce for the tags a server render emits. A string applies to both
|
|
62
102
|
* nonce-aware destinations. A `{ script, style }` pair routes each tag to
|
|
@@ -67,110 +107,14 @@ export type AssetResolverFn = (
|
|
|
67
107
|
* fallback reaches `script-src`. A nonce on a `useHead` tag's own props
|
|
68
108
|
* always wins.
|
|
69
109
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
110
|
+
* Surfaces that emit one script (`HydrationScript`,
|
|
111
|
+
* `generateHydrationScript`, `createSSRResponse`) take either shape and use
|
|
112
|
+
* its script half.
|
|
73
113
|
*/
|
|
74
|
-
export type CSPNonce = string | {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
export function scriptNonce(nonce?: CSPNonce): string | undefined;
|
|
78
|
-
/** The style-destination half of a render `nonce`. */
|
|
79
|
-
export function styleNonce(nonce?: CSPNonce): string | undefined;
|
|
80
|
-
|
|
81
|
-
export function renderToString<T>(
|
|
82
|
-
fn: () => T,
|
|
83
|
-
options?: {
|
|
84
|
-
nonce?: CSPNonce;
|
|
85
|
-
renderId?: string;
|
|
86
|
-
noScripts?: boolean;
|
|
87
|
-
plugins?: SerializerPlugin[];
|
|
88
|
-
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
89
|
-
onError?: (err: any) => void;
|
|
90
|
-
/**
|
|
91
|
-
* Embedded-render contract for hosts that own the document. When the
|
|
92
|
-
* render output contains no `</head>`, everything head-bound (resolved
|
|
93
|
-
* `useHead` winners, eager resources, tracked asset links, inline
|
|
94
|
-
* styles) is delivered here as one HTML string — prelude (charset/base)
|
|
95
|
-
* first — for the host to splice into its own `<head>` template, instead
|
|
96
|
-
* of being dropped. Called synchronously before `renderToString`
|
|
97
|
-
* returns; not called when the output has a `</head>` (splicing is
|
|
98
|
-
* automatic then).
|
|
99
|
-
*/
|
|
100
|
-
onHead?: (head: string) => void;
|
|
101
|
-
}
|
|
102
|
-
): string;
|
|
103
|
-
export function renderToStream<T>(
|
|
104
|
-
fn: () => T,
|
|
105
|
-
options?: {
|
|
106
|
-
nonce?: CSPNonce;
|
|
107
|
-
renderId?: string;
|
|
108
|
-
noScripts?: boolean;
|
|
109
|
-
plugins?: SerializerPlugin[];
|
|
110
|
-
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
111
|
-
onCompleteShell?: (info: { write: (v: string) => void }) => void;
|
|
112
|
-
onCompleteAll?: (info: { write: (v: string) => void }) => void;
|
|
113
|
-
onError?: (err: any) => void;
|
|
114
|
-
/**
|
|
115
|
-
* Embedded-render contract for hosts that own the document. When the
|
|
116
|
-
* shell contains no `</head>`, everything head-bound at first flush
|
|
117
|
-
* (resolved `useHead` winners, eager resources, tracked asset links,
|
|
118
|
-
* inline styles) is delivered here as one HTML string — prelude first —
|
|
119
|
-
* before the shell chunk is emitted, so the host can write its own
|
|
120
|
-
* `<head>` ahead of piping the stream. Post-shell head updates flow
|
|
121
|
-
* through the stream itself and apply in the browser. Not called when
|
|
122
|
-
* the shell has a `</head>` (splicing is automatic then).
|
|
123
|
-
*/
|
|
124
|
-
onHead?: (head: string) => void;
|
|
125
|
-
}
|
|
126
|
-
): {
|
|
127
|
-
/**
|
|
128
|
-
* Awaiting the stream resolves with the complete HTML once every boundary
|
|
129
|
-
* settles — the fully-settled-string form of the render (`const html =
|
|
130
|
-
* await renderToStream(...)`). Render errors route through `onError` and
|
|
131
|
-
* the promise resolves with whatever HTML the render produced; it never
|
|
132
|
-
* rejects.
|
|
133
|
-
*/
|
|
134
|
-
then<TResult1 = string, TResult2 = never>(
|
|
135
|
-
onfulfilled?: ((html: string) => TResult1 | PromiseLike<TResult1>) | null,
|
|
136
|
-
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null
|
|
137
|
-
): Promise<TResult1 | TResult2>;
|
|
138
|
-
pipe: (writable: { write: (v: string) => void; end: () => void }) => void;
|
|
139
|
-
pipeTo: (writable: WritableStream) => Promise<void>;
|
|
140
|
-
/**
|
|
141
|
-
* Lazy `ReadableStream<Uint8Array>` view of the render — hand it straight
|
|
142
|
-
* to `new Response(stream.readable)`. First access starts the render
|
|
143
|
-
* piping through an internal `TransformStream` (chunks are UTF-8 encoded
|
|
144
|
-
* bytes, the same as `pipeTo` writes) and the stream is cached, so
|
|
145
|
-
* repeated access returns the same instance. Like `pipe`/`pipeTo`, this
|
|
146
|
-
* consumes the render: use exactly one of the three — mixing distinct
|
|
147
|
-
* consumers (`readable` after `pipe`/`pipeTo`, or vice versa) throws an
|
|
148
|
-
* error naming the conflict.
|
|
149
|
-
*/
|
|
150
|
-
readonly readable: ReadableStream<Uint8Array>;
|
|
114
|
+
export type CSPNonce = string | {
|
|
115
|
+
script: string | false;
|
|
116
|
+
style: string | false;
|
|
151
117
|
};
|
|
152
|
-
|
|
153
|
-
export function HydrationScript(props: { nonce?: string; eventNames?: string[] }): JSX.Element;
|
|
154
|
-
export function ssr(template: string[] | string, ...nodes: any[]): { t: string };
|
|
155
|
-
export function ssrElement(
|
|
156
|
-
name: string,
|
|
157
|
-
props: any,
|
|
158
|
-
children: any,
|
|
159
|
-
needsId: boolean
|
|
160
|
-
): { t: string };
|
|
161
|
-
export function ssrClassName(value: string | { [k: string]: boolean } | Array<any>): string;
|
|
162
|
-
export function ssrStyle(value: string | { [k: string]: string }): string;
|
|
163
|
-
export function ssrStyleProperty(name: string, value: any): string;
|
|
164
|
-
export function ssrAttribute(key: string, value: any): string;
|
|
165
|
-
export function ssrGroup<T extends () => any[]>(fn: T, n: number): T;
|
|
166
|
-
export function scope<T>(fn: () => T): () => unknown;
|
|
167
|
-
export function ssrHydrationKey(): string;
|
|
168
|
-
export function resolveSSRNode(node: any, result?: any, top?: boolean): any;
|
|
169
|
-
export function escape(s: any, attr?: boolean): any;
|
|
170
|
-
export function applyRef(
|
|
171
|
-
r: ((element: any) => void) | ((element: any) => void)[],
|
|
172
|
-
element: any
|
|
173
|
-
): void;
|
|
174
118
|
/**
|
|
175
119
|
* A head tag descriptor. Props values may be getters (evaluated lazily on
|
|
176
120
|
* the server — at the owning flush boundary — and reactively on the client);
|
|
@@ -187,39 +131,10 @@ export function applyRef(
|
|
|
187
131
|
* docs/head-management-rfc.md.
|
|
188
132
|
*/
|
|
189
133
|
export type HeadTag = {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
134
|
+
tag: "title" | "meta" | "link" | "style" | "script" | "base";
|
|
135
|
+
props: Record<string, any>;
|
|
136
|
+
key?: string | (() => string);
|
|
193
137
|
};
|
|
194
|
-
/**
|
|
195
|
-
* Registers head tags with the render's head registry. An array is a group —
|
|
196
|
-
* one replacement set; a single tag is a group of one; a function is a
|
|
197
|
-
* reactive group whose membership resolves at the owning flush boundary
|
|
198
|
-
* (resource tags inside it emit at that flush rather than eagerly).
|
|
199
|
-
* Replaceable tags (title/meta/canonical/…) resolve by last-committed group
|
|
200
|
-
* and stream as patches with their suspense boundary's reveal; resource tags
|
|
201
|
-
* (preload and friends, stylesheets, `script[src]`) emit eagerly and dedupe
|
|
202
|
-
* by identity. See docs/head-management-rfc.md.
|
|
203
|
-
*/
|
|
204
|
-
export function useHead(tag: HeadTag | HeadTag[] | (() => HeadTag | HeadTag[])): void;
|
|
205
|
-
export function getHydrationKey(): string | undefined;
|
|
206
|
-
export function effect<T>(fn: (prev?: T) => T, effect: (value: T, prev?: T) => void): void;
|
|
207
|
-
export function memo<T>(fn: () => T, equal: boolean): () => T;
|
|
208
|
-
export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
|
|
209
|
-
export function mergeProps(...sources: unknown[]): unknown;
|
|
210
|
-
export function getOwner(): unknown;
|
|
211
|
-
export function generateHydrationScript(options?: {
|
|
212
|
-
nonce?: string;
|
|
213
|
-
eventNames?: string[];
|
|
214
|
-
}): string;
|
|
215
|
-
/**
|
|
216
|
-
* Registered symbol (`Symbol.for("solid.RequestContext")`) naming the
|
|
217
|
-
* global slot where `provideRequestEvent` parks the AsyncLocalStorage that
|
|
218
|
-
* scopes request events. Integration plumbing — application code reads the
|
|
219
|
-
* event through `getRequestEvent()` instead.
|
|
220
|
-
* @internal
|
|
221
|
-
*/
|
|
222
|
-
export declare const RequestContext: unique symbol;
|
|
223
138
|
/**
|
|
224
139
|
* The mutable response head an integration's handler exposes on the request
|
|
225
140
|
* event as `event.response`: status/statusText/headers it will apply when
|
|
@@ -235,22 +150,21 @@ export declare const RequestContext: unique symbol;
|
|
|
235
150
|
* and reads it when folding single-flight cookies, but never requires it.
|
|
236
151
|
*/
|
|
237
152
|
export interface ResponseStub {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
153
|
+
status?: number;
|
|
154
|
+
statusText?: string;
|
|
155
|
+
headers: Headers;
|
|
156
|
+
/**
|
|
157
|
+
* Set once the response head has been derived/sent from this stub —
|
|
158
|
+
* status and headers can no longer change. Flip it through
|
|
159
|
+
* `commitResponseStub`, which also instruments the stub's `headers` so
|
|
160
|
+
* a post-commit write fails loudly (dev build throws, production
|
|
161
|
+
* reports + no-ops) instead of silently missing the wire. `status`/
|
|
162
|
+
* `statusText` stay plain fields: consumers that write response
|
|
163
|
+
* metadata during render (e.g. JSX response components) must still
|
|
164
|
+
* treat later status writes and cleanup-time retractions as no-ops.
|
|
165
|
+
*/
|
|
166
|
+
committed?: boolean;
|
|
252
167
|
}
|
|
253
|
-
|
|
254
168
|
/**
|
|
255
169
|
* The type of `RequestEvent.locals` — a module-augmentable interface so
|
|
256
170
|
* applications can type the state their middleware hangs on the event.
|
|
@@ -272,9 +186,8 @@ export interface ResponseStub {
|
|
|
272
186
|
* `locals` would break every untyped write that works today).
|
|
273
187
|
*/
|
|
274
188
|
export interface RequestEventLocals {
|
|
275
|
-
|
|
189
|
+
[key: string | number | symbol]: any;
|
|
276
190
|
}
|
|
277
|
-
|
|
278
191
|
/**
|
|
279
192
|
* The per-request context available on the server: the incoming `Request`
|
|
280
193
|
* and a `locals` bag integrations and middleware can hang state on (typed
|
|
@@ -283,262 +196,498 @@ export interface RequestEventLocals {
|
|
|
283
196
|
* `ResponseStub`).
|
|
284
197
|
*/
|
|
285
198
|
export interface RequestEvent {
|
|
286
|
-
|
|
287
|
-
|
|
199
|
+
request: Request;
|
|
200
|
+
locals: RequestEventLocals;
|
|
201
|
+
}
|
|
202
|
+
export type { CookieOptions } from "./cookies.js";
|
|
203
|
+
export type { ServerFunction, ServerFunctionMetadata, ServerFunctionRPC } from "./server-functions/shared.js";
|
|
204
|
+
export interface SSRResponseOptions {
|
|
205
|
+
/** Base head; the stub's status/headers win over it. */
|
|
206
|
+
responseInit?: ResponseInit;
|
|
207
|
+
/** Nonce carried by the post-flush `<script>` redirect fallback (its script half). */
|
|
208
|
+
nonce?: CSPNonce;
|
|
209
|
+
/** Rewrites each outgoing HTML chunk (entry script injection, ...). */
|
|
210
|
+
transformChunk?: (chunk: string) => string;
|
|
288
211
|
}
|
|
289
212
|
/**
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
* Read it above `await` boundaries in partially-polyfilled environments.
|
|
213
|
+
* Fetch-style middleware: return a `Response` to answer the request, or
|
|
214
|
+
* call `next()` (optionally with a substitute `Request`) to advance the
|
|
215
|
+
* chain and observe/replace the eventual response.
|
|
294
216
|
*/
|
|
295
|
-
export
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
export function
|
|
299
|
-
|
|
217
|
+
export type FetchMiddleware = (request: Request, next: (request?: Request) => Promise<Response>) => Response | Promise<Response>;
|
|
218
|
+
export { createComponent, effect, memo, untrack, mergeProps, scope, getOwner };
|
|
219
|
+
export { DOMWithState, ChildProperties, DOMElements, SVGElements, MathMLElements, VoidElements, RawTextElements, Namespaces, DelegatedEvents } from "./constants.js";
|
|
220
|
+
export declare function useHead(tag: HeadTag | HeadTag[] | (() => HeadTag | HeadTag[])): void;
|
|
221
|
+
export declare function renderToString<T>(fn: () => T, options?: {
|
|
222
|
+
nonce?: CSPNonce;
|
|
223
|
+
renderId?: string;
|
|
224
|
+
noScripts?: boolean;
|
|
225
|
+
plugins?: SerializerPlugin[];
|
|
226
|
+
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
227
|
+
/**
|
|
228
|
+
* This render's server error hook, ahead of `configureServerErrors`'
|
|
229
|
+
* (see `ServerErrorHook`): every failure the render handles — an
|
|
230
|
+
* `<Errored>` fallback (`handling: "fallback"`), a hydration value that
|
|
231
|
+
* would not serialize (`"serialize"`) — and the throw that fails it
|
|
232
|
+
* (`"failed"`, heard before it is rethrown to the caller), once per
|
|
233
|
+
* error, with where it was met. A one-argument listener still works; it
|
|
234
|
+
* hears them all.
|
|
235
|
+
*/
|
|
236
|
+
onError?: ServerErrorHook;
|
|
237
|
+
/**
|
|
238
|
+
* Embedded-render contract for hosts that own the document. When the
|
|
239
|
+
* render output contains no `</head>`, everything head-bound (resolved
|
|
240
|
+
* `useHead` winners, eager resources, tracked asset links, inline
|
|
241
|
+
* styles) is delivered here as one HTML string — prelude (charset/base)
|
|
242
|
+
* first — for the host to splice into its own `<head>` template, instead
|
|
243
|
+
* of being dropped. Called synchronously before `renderToString`
|
|
244
|
+
* returns; not called when the output has a `</head>` (splicing is
|
|
245
|
+
* automatic then).
|
|
246
|
+
*/
|
|
247
|
+
onHead?: (head: string) => void;
|
|
248
|
+
}): string;
|
|
249
|
+
export declare function renderToStream<T>(fn: () => T, options?: {
|
|
250
|
+
nonce?: CSPNonce;
|
|
251
|
+
renderId?: string;
|
|
252
|
+
noScripts?: boolean;
|
|
253
|
+
plugins?: SerializerPlugin[];
|
|
254
|
+
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
255
|
+
onCompleteShell?: (info: {
|
|
256
|
+
write: (v: string) => void;
|
|
257
|
+
}) => void;
|
|
258
|
+
onCompleteAll?: (info: {
|
|
259
|
+
write: (v: string) => void;
|
|
260
|
+
}) => void;
|
|
261
|
+
/**
|
|
262
|
+
* This render's server error hook, ahead of `configureServerErrors`'
|
|
263
|
+
* (see `ServerErrorHook`): every failure the render handles — an
|
|
264
|
+
* `<Errored>` fallback (`handling: "fallback"`), a rejected fragment
|
|
265
|
+
* (`"client"`), a hydration value that would not serialize
|
|
266
|
+
* (`"serialize"`) — and the one that fails the request (`"failed"`),
|
|
267
|
+
* once per error per kind per request (per render outside one), with
|
|
268
|
+
* where it was met. A one-argument listener still
|
|
269
|
+
* works; it hears them all — filter on `context.handling` for the
|
|
270
|
+
* request-failing ones alone. Without a hook (here or ambient) a
|
|
271
|
+
* failure that fails the request goes to `console.error`.
|
|
272
|
+
*/
|
|
273
|
+
onError?: ServerErrorHook;
|
|
274
|
+
/**
|
|
275
|
+
* Embedded-render contract for hosts that own the document. When the
|
|
276
|
+
* shell contains no `</head>`, everything head-bound at first flush
|
|
277
|
+
* (resolved `useHead` winners, eager resources, tracked asset links,
|
|
278
|
+
* inline styles) is delivered here as one HTML string — prelude first —
|
|
279
|
+
* before the shell chunk is emitted, so the host can write its own
|
|
280
|
+
* `<head>` ahead of piping the stream. Post-shell head updates flow
|
|
281
|
+
* through the stream itself and apply in the browser. Not called when
|
|
282
|
+
* the shell has a `</head>` (splicing is automatic then).
|
|
283
|
+
*/
|
|
284
|
+
onHead?: (head: string) => void;
|
|
285
|
+
/**
|
|
286
|
+
* The request's lifecycle. Aborting tears the render down exactly as a
|
|
287
|
+
* client disconnect does (`SSR_STREAM_ABANDONED`, `data.reason:
|
|
288
|
+
* "signal"`): in-flight reactive work is disposed, every async source
|
|
289
|
+
* still being pulled is returned, and nothing more reaches the sink. For
|
|
290
|
+
* the host whose transport cannot report a dead consumer through the
|
|
291
|
+
* sink or the readable view — a frame stream whose emission never
|
|
292
|
+
* touches the document writable, a platform whose response body is
|
|
293
|
+
* consumed by a proxy — this is the one teardown handle; pass
|
|
294
|
+
* `request.signal`. Idempotent with the sink and consumer paths: whichever
|
|
295
|
+
* fires first tears down, the rest are no-ops.
|
|
296
|
+
*/
|
|
297
|
+
signal?: AbortSignal;
|
|
298
|
+
}): {
|
|
299
|
+
/**
|
|
300
|
+
* Awaiting the stream resolves with the complete HTML once every boundary
|
|
301
|
+
* settles — the fully-settled-string form of the render (`const html =
|
|
302
|
+
* await renderToStream(...)`). Render errors route through `onError` and
|
|
303
|
+
* the promise resolves with whatever HTML the render produced; it never
|
|
304
|
+
* rejects.
|
|
305
|
+
*
|
|
306
|
+
* Completion is this path's head-freeze point: the request event's
|
|
307
|
+
* `response` head (the request scope the render was started in) is
|
|
308
|
+
* committed right before the render's final dispose, so
|
|
309
|
+
* `httpStatus`/`httpHeader` declarations still live at completion survive
|
|
310
|
+
* into `createSSRResponse(html, event)` — which sees the already-committed
|
|
311
|
+
* stub and passes it through. The piped forms freeze at shell flush
|
|
312
|
+
* instead.
|
|
313
|
+
*/
|
|
314
|
+
then<TResult1 = string, TResult2 = never>(onfulfilled?: ((html: string) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
315
|
+
pipe: (writable: {
|
|
316
|
+
write: (v: string) => void;
|
|
317
|
+
end: () => void;
|
|
318
|
+
}) => void;
|
|
319
|
+
pipeTo: (writable: WritableStream) => Promise<void>;
|
|
320
|
+
/**
|
|
321
|
+
* Lazy `ReadableStream<Uint8Array>` view of the render — hand it straight
|
|
322
|
+
* to `new Response(stream.readable)`. First access starts the render
|
|
323
|
+
* piping through an internal `TransformStream` (chunks are UTF-8 encoded
|
|
324
|
+
* bytes, the same as `pipeTo` writes) and the stream is cached, so
|
|
325
|
+
* repeated access returns the same instance. Like `pipe`/`pipeTo`, this
|
|
326
|
+
* consumes the render: use exactly one of the three — mixing distinct
|
|
327
|
+
* consumers (`readable` after `pipe`/`pipeTo`, or vice versa) throws an
|
|
328
|
+
* error naming the conflict.
|
|
329
|
+
*/
|
|
330
|
+
readonly readable: ReadableStream<Uint8Array>;
|
|
331
|
+
};
|
|
332
|
+
export declare function HydrationScript(props: {
|
|
333
|
+
nonce?: CSPNonce;
|
|
334
|
+
eventNames?: string[];
|
|
335
|
+
}): JSX.Element;
|
|
336
|
+
export declare function ssrGroup<T extends () => any[]>(fn: T, n: number): T;
|
|
300
337
|
/**
|
|
301
|
-
* The
|
|
302
|
-
*
|
|
303
|
-
*
|
|
338
|
+
* The live-hole engine for one frame response. Constructed by the frame
|
|
339
|
+
* renderer (frame-sink) and published on the render context; `ssr()` and
|
|
340
|
+
* `resolveSSRNode` route content holes through `content()` while it is
|
|
341
|
+
* present. Bindings live in the sink's DR-2 ledger — same commit-driven
|
|
342
|
+
* sweeps, same equality gating, same end-of-response latch as watched slot
|
|
343
|
+
* args.
|
|
344
|
+
*
|
|
345
|
+
* Every state transition is commit-driven: the engine never chains its own
|
|
346
|
+
* promises, so it cannot amplify commits or starve the event loop — a
|
|
347
|
+
* pending re-evaluation simply waits for the next commit (async settles
|
|
348
|
+
* commit through the render core, and the response's end-latch sweep is
|
|
349
|
+
* always the last one).
|
|
304
350
|
*/
|
|
305
|
-
export function
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
351
|
+
export declare function createLiveHoles(sink: any, scoped: any, settled: any, errorScope: any): {
|
|
352
|
+
suppressed: number;
|
|
353
|
+
sweeping: boolean;
|
|
354
|
+
parent: any;
|
|
355
|
+
gateHit: boolean;
|
|
356
|
+
sweptOwners: boolean;
|
|
357
|
+
scope: any;
|
|
358
|
+
visit: any;
|
|
359
|
+
dry: boolean;
|
|
360
|
+
/**
|
|
361
|
+
* The id of a positional slot call: at render time (and on a retry,
|
|
362
|
+
* which renders) the render-positional id the proxy minted, `given`,
|
|
363
|
+
* kept for the call's position; on a sweep, the id that position had —
|
|
364
|
+
* or, for a position no render reached, `prop#~<scope>.<n>` (the `~`
|
|
365
|
+
* keeps it apart from render ids and `$key` ids, whose alphabet has
|
|
366
|
+
* none). Outside every hole, `given` as it is.
|
|
367
|
+
*/
|
|
368
|
+
slotId(prop: any, given: any): any;
|
|
369
|
+
/** A slot occurrence reached by the evaluation in progress; `forget` runs
|
|
370
|
+
* once a re-evaluation of its hole no longer reaches it. */
|
|
371
|
+
seen(id: any, forget: any): void;
|
|
372
|
+
/**
|
|
373
|
+
* Enter a nested hole's scope on the path that resolves it unminted (a
|
|
374
|
+
* sweep's interior, a suppressed window): the same scope a first render
|
|
375
|
+
* gives it inside `content()`. Returns the scope to restore, or
|
|
376
|
+
* undefined when none was entered.
|
|
377
|
+
*/
|
|
378
|
+
nest(hole: any): any;
|
|
379
|
+
/**
|
|
380
|
+
* Intercept a thunk content hole: resolve it, and — when the evaluation
|
|
381
|
+
* proves re-runnable — mint an id, wrap the output in its marker pair,
|
|
382
|
+
* and open the ledger binding. Returns a string (sync resolve), a
|
|
383
|
+
* marker-wrapped `{ t, h, p }` template (NotReady escalation — markers
|
|
384
|
+
* ride the template so the retry's splice lands inside them), an
|
|
385
|
+
* UNMARKED string/template (latched: slot positions, impure
|
|
386
|
+
* evaluations), or null when interception is off for this evaluation.
|
|
387
|
+
*/
|
|
388
|
+
content(hole: any): any;
|
|
389
|
+
/** The shared id counter — `ssr()` mints an attr address at injection
|
|
390
|
+
* time, before its capture completes. */
|
|
391
|
+
mint(): number;
|
|
392
|
+
/** Whether interception may arm at the current evaluation point —
|
|
393
|
+
* `ssr()` asks before opening an attr capture (the `data-lha`
|
|
394
|
+
* injection must not touch out-of-scope bytes, nor address an element
|
|
395
|
+
* nothing can change; content holes are gated inside `content()`
|
|
396
|
+
* itself). */
|
|
397
|
+
active(): boolean;
|
|
398
|
+
/**
|
|
399
|
+
* Register an element's attr-hole capture (built by `ssr()`'s in-tag
|
|
400
|
+
* scan): the tag's attribute area as alternating static strings and
|
|
401
|
+
* re-runnable parts (`{ f }` thunks, `{ g, i }` group positions). Sweeps
|
|
402
|
+
* rebuild the text, equality-gate against the baseline, and ship
|
|
403
|
+
* changes as an element-keyed `attr` chunk. Names that vanish between
|
|
404
|
+
* rebuilds ride an explicit `removed` list where the server holds the
|
|
405
|
+
* previous text; the client also matches the element to the whole
|
|
406
|
+
* text (the morph's rule), so a resume's re-emission — previous text
|
|
407
|
+
* known only as a digest, no list — removes them too.
|
|
408
|
+
*/
|
|
409
|
+
attr(cap: any): void;
|
|
410
|
+
};
|
|
411
|
+
export declare function ssr(template: string[] | string, ...nodes: any[]): {
|
|
412
|
+
t: string;
|
|
413
|
+
};
|
|
414
|
+
export declare function ssrClassName(value: string | {
|
|
415
|
+
[k: string]: boolean;
|
|
416
|
+
} | Array<any>): string;
|
|
417
|
+
export declare function ssrStyle(value: string | {
|
|
418
|
+
[k: string]: string;
|
|
419
|
+
}): string;
|
|
420
|
+
export declare function ssrStyleProperty(name: string, value: any): string;
|
|
421
|
+
export declare function ssrStyleProperties(...entries: any[]): string;
|
|
422
|
+
export declare function ssrElement(name: string, props: any | any[] | (() => any | any[]), children: any, needsId: boolean, skip?: (key: string) => boolean, attrs?: string | (() => string)): {
|
|
423
|
+
t: string;
|
|
424
|
+
};
|
|
425
|
+
export declare function ssrElementAttribute(key: string, value: any): string;
|
|
426
|
+
export declare function ssrAttribute(key: string, value: any): string;
|
|
427
|
+
export declare function ssrHydrationKey(): string;
|
|
310
428
|
/**
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
429
|
+
* A render's link handler (`setLinkClaim`): given an anchor's link-relevant
|
|
430
|
+
* attributes — `href`, and `target` / `rel` / `download` / `link` /
|
|
431
|
+
* `aria-current` when present, raw values as written — returns the extra
|
|
432
|
+
* attribute markup for the anchor, each attribute with its leading space
|
|
433
|
+
* (`" data-active"`, `' data-active aria-current="page"'`), or `""`.
|
|
434
|
+
* Synchronous and pure; the markup is the handler's own and is written
|
|
435
|
+
* verbatim.
|
|
436
|
+
* @internal
|
|
314
437
|
*/
|
|
315
|
-
export
|
|
316
|
-
|
|
438
|
+
export type LinkClaimHandler = (attrs: Readonly<Record<string, unknown>>) => string;
|
|
317
439
|
/**
|
|
318
|
-
*
|
|
319
|
-
* the
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
|
|
325
|
-
|
|
440
|
+
* Compiler-emitted hole after a candidate anchor's attributes in SSR output:
|
|
441
|
+
* the render's link handler's markup for the anchor (`setLinkClaim`), or
|
|
442
|
+
* `""` when the render has no handler. An author-written `aria-current`
|
|
443
|
+
* wins — the handler is not consulted for that anchor. Not for hand-written
|
|
444
|
+
* code.
|
|
445
|
+
* @internal
|
|
446
|
+
*/
|
|
447
|
+
export declare function ssrLinkClaim(attrs: Readonly<Record<string, unknown>>): string;
|
|
448
|
+
export declare function ssrSelectValues(): void;
|
|
449
|
+
export declare function resolveSSRSelectValues(html: any): any;
|
|
450
|
+
export declare function escape(s: any, attr?: boolean): any;
|
|
451
|
+
export declare function getHydrationKey(): string | undefined;
|
|
452
|
+
export declare function applyRef(r: ((element: any) => void) | ((element: any) => void)[], element: any): void;
|
|
453
|
+
export declare function generateHydrationScript(options?: {
|
|
454
|
+
nonce?: CSPNonce;
|
|
455
|
+
eventNames?: string[];
|
|
456
|
+
}): string;
|
|
457
|
+
export declare function resolveSSRNode(node: any, result?: any, top?: boolean, nested?: boolean): any;
|
|
458
|
+
export declare const RequestContext: unique symbol; /**
|
|
459
|
+
* Where a server-side failure was met, as the server error hook hears it.
|
|
326
460
|
*
|
|
327
|
-
* `
|
|
328
|
-
* `
|
|
329
|
-
*
|
|
330
|
-
*
|
|
461
|
+
* `kind: "render"` — `fallback`: an `<Errored>` rendered its fallback;
|
|
462
|
+
* `client`: a `<Loading>` fragment rejected and the client re-renders the
|
|
463
|
+
* subtree; `failed`: nothing contained it and the request fails — including
|
|
464
|
+
* a synchronous throw out of `renderToString` or `renderToStream`'s first
|
|
465
|
+
* pass, reported before it reaches the caller;
|
|
466
|
+
* `serialize`: a hydration value would not serialize and the render went on
|
|
467
|
+
* without it (a render that passed `onError`). `kind: "server-function"` — `thrown`:
|
|
468
|
+
* the body threw; `channel`: a rejection or throw escaping through the
|
|
469
|
+
* result graph (a promise, an iterable, a stream) with the head already
|
|
470
|
+
* committed. `kind: "request"` (always `failed`): a failure that fails the
|
|
471
|
+
* request outside any render or server function the runtime reports — a
|
|
472
|
+
* middleware throw the framework's request handler catches (see
|
|
473
|
+
* `reportRequestFailure`). `boundary` is the hydration id the boundary records and
|
|
474
|
+
* findings use; `ownerPath` is where the error was THROWN — the component
|
|
475
|
+
* labels root-first up the owner chain it escaped, when the compiler emitted
|
|
476
|
+
* them — and `boundaryPath` where it was MET, the same labels up the
|
|
477
|
+
* boundary's chain (what broke, and what the user saw); `functionId`/`direct`
|
|
478
|
+
* name the server function and whether it was an in-process call during
|
|
479
|
+
* SSR; `event` the request, when the failure happened inside one.
|
|
331
480
|
*/
|
|
332
|
-
export
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
): ResponseStub;
|
|
336
|
-
|
|
481
|
+
export interface ServerErrorContext extends Omit<ServerErrorSite, "event"> {
|
|
482
|
+
event?: RequestEvent;
|
|
483
|
+
}
|
|
337
484
|
/**
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
485
|
+
* The server error hook (see `configureServerErrors`): every failure the
|
|
486
|
+
* server runtime handles or fails on, once per error object per `kind` per
|
|
487
|
+
* request (per render when no request is in scope — never once per
|
|
488
|
+
* process: an error object one request met and another meets again is
|
|
489
|
+
* heard by both), with where it was met. A direct server-function call that
|
|
490
|
+
* throws during SSR and the `<Errored>` that contains it are heard as both:
|
|
491
|
+
* `server-function` (the call failed), then `render` (the render fell back),
|
|
492
|
+
* so `kind: "render"` alone answers whether a render failed. Return the value the client should receive in
|
|
493
|
+
* place of the error — rendered into the fallback, serialized for
|
|
494
|
+
* hydration, sent as the RPC error — or nothing for the default policy (a
|
|
495
|
+
* generic `Error` outside the dev build, the error itself in it;
|
|
496
|
+
* `markSafeError` still passes through).
|
|
497
|
+
* A returned value is taken as intended client-facing content and is not
|
|
498
|
+
* sanitized again. Ignored for `handling: "failed"`, which has no wire, and
|
|
499
|
+
* once an earlier kind's sight gave one: every road carries the first.
|
|
349
500
|
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
501
|
+
* One road a mapping does not reach: a rejected async source's serialized
|
|
502
|
+
* rejection is encoded the moment the source rejects, ahead of the boundary
|
|
503
|
+
* that meets the failure, and carries the default policy's value there. The
|
|
504
|
+
* hydrating client renders from the boundary's record, which carries the
|
|
505
|
+
* mapping; no tick is added to the error path to make the two agree.
|
|
506
|
+
*/
|
|
507
|
+
export type ServerErrorHook = (error: unknown, context: ServerErrorContext) => unknown | void;
|
|
508
|
+
export interface ServerErrorsConfig {
|
|
509
|
+
/** The hook, or `undefined` to clear it. */
|
|
510
|
+
onError?: ServerErrorHook;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Registers the ambient server error hook — the one call a server
|
|
514
|
+
* `init()` makes to see every failure the runtime handles in production:
|
|
515
|
+
* an `<Errored>` fallback rendered, a `<Loading>` fragment rejected, a
|
|
516
|
+
* server-function throw (HTTP dispatch or an in-process call during SSR),
|
|
517
|
+
* the failure that fails a request. Called once per error object per kind
|
|
518
|
+
* per request (per render outside one), at first sight, wherever the runtime
|
|
519
|
+
* met it; its return, when given, is the wire value (see
|
|
520
|
+
* `ServerErrorHook`). A per-request hook — `renderToStream`'s
|
|
521
|
+
* `onError`, the server-function handler's — overrides it for that
|
|
522
|
+
* request. Registered on `globalThis` under a registered symbol, so a
|
|
523
|
+
* bundled server build and an instrumented `--import`ed module share it.
|
|
354
524
|
*
|
|
355
|
-
*
|
|
525
|
+
* ```ts
|
|
526
|
+
* configureServerErrors({
|
|
527
|
+
* onError: (error, { kind, handling, boundary, functionId }) => {
|
|
528
|
+
* Sentry.captureException(error, {
|
|
529
|
+
* mechanism: { type: `solid.${kind}.${handling}`, handled: handling !== "failed" }
|
|
530
|
+
* });
|
|
531
|
+
* }
|
|
532
|
+
* });
|
|
533
|
+
* ```
|
|
356
534
|
*/
|
|
357
|
-
export function
|
|
358
|
-
|
|
535
|
+
export declare function configureServerErrors(config: ServerErrorsConfig): void;
|
|
359
536
|
/**
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
* `
|
|
364
|
-
*
|
|
537
|
+
* Reports a failure that fails a request outside any render or server
|
|
538
|
+
* function the runtime reports, such as a throw a framework's request
|
|
539
|
+
* handler catches from its middleware. The ambient server error hook hears
|
|
540
|
+
* it as `{ kind: "request", handling: "failed", event }`, once per error
|
|
541
|
+
* object per request, and its return is ignored, as for every `handling:
|
|
542
|
+
* "failed"`. A render failure is the render's: a synchronous throw out of
|
|
543
|
+
* `renderToString` or `renderToStream` was already heard as `kind:
|
|
544
|
+
* "render"` before the caller caught it, so reporting it here adds nothing.
|
|
545
|
+
* With no hook registered the failure goes to `console.error`, as a render
|
|
546
|
+
* that fails before its shell does. There is no per-request hook at this
|
|
547
|
+
* layer.
|
|
365
548
|
*/
|
|
366
|
-
export
|
|
367
|
-
export type { CookieOptions } from "./cookies.js";
|
|
368
|
-
|
|
549
|
+
export declare function reportRequestFailure(error: unknown, event: RequestEvent): void;
|
|
369
550
|
/**
|
|
370
|
-
* The
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
* declaration home published-types layouts ship.
|
|
551
|
+
* The current request event, when called on the server inside a request
|
|
552
|
+
* scope (established by `provideRequestEvent` from `@solidjs/web/storage`
|
|
553
|
+
* or by the framework). Undefined on the client and outside a request.
|
|
554
|
+
* Read it above `await` boundaries in partially-polyfilled environments.
|
|
375
555
|
*/
|
|
376
|
-
export
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
556
|
+
export declare function getRequestEvent(): RequestEvent | undefined;
|
|
557
|
+
/** A render's keyed server-to-client value channel (`getHydrationWriter`). */
|
|
558
|
+
export interface HydrationWriter {
|
|
559
|
+
/**
|
|
560
|
+
* Whether the render takes promises and async iterables (`renderToStream`).
|
|
561
|
+
* `renderToString` takes synchronous values only; `write` throws on an
|
|
562
|
+
* async one.
|
|
563
|
+
*/
|
|
564
|
+
readonly async: boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Serializes `value` for the client under `key`, readable there with
|
|
567
|
+
* `takeHydrationValue(key)`. Returns `false` without writing when `key` was
|
|
568
|
+
* already written by this render (the first write wins) or the render no
|
|
569
|
+
* longer takes values (a finished `renderToString`, a completed stream).
|
|
570
|
+
* `deferStream` holds the shell until a promise settles. Prefix keys with
|
|
571
|
+
* the library's own namespace (`"sq:"`); Solid's own entries are keyed by
|
|
572
|
+
* hydration id.
|
|
573
|
+
*/
|
|
574
|
+
write(key: string, value: unknown, options?: {
|
|
575
|
+
deferStream?: boolean;
|
|
576
|
+
}): boolean;
|
|
396
577
|
}
|
|
397
|
-
|
|
578
|
+
/** A keyed value taken from the hydration registry (`takeHydrationValue`). */
|
|
579
|
+
export type HydrationValue<T = unknown> = {
|
|
580
|
+
status: "resolved";
|
|
581
|
+
value: T;
|
|
582
|
+
} | {
|
|
583
|
+
status: "rejected";
|
|
584
|
+
error: unknown;
|
|
585
|
+
} | {
|
|
586
|
+
status: "pending";
|
|
587
|
+
promise: Promise<T>;
|
|
588
|
+
};
|
|
398
589
|
/**
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
590
|
+
* The keyed server-to-client value channel of the render the caller belongs
|
|
591
|
+
* to — found through the caller's owner, else (no owner) through the request
|
|
592
|
+
* scope when exactly one render is open for that request. `undefined`
|
|
593
|
+
* outside any render and on the client. Never another request's render.
|
|
594
|
+
*
|
|
595
|
+
* Capture it where the render is known (component setup) to write from IO
|
|
596
|
+
* later. A write is not gated on `<NoHydration>`: read `isHydratable()` where
|
|
597
|
+
* the value is produced to decide. Read the value on the client with
|
|
598
|
+
* `takeHydrationValue(key)`.
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* ```ts
|
|
602
|
+
* const writer = getHydrationWriter();
|
|
603
|
+
* if (writer && isHydratable()) writer.write("sq:" + hash, data);
|
|
604
|
+
* ```
|
|
405
605
|
*/
|
|
406
|
-
export function
|
|
407
|
-
result: string,
|
|
408
|
-
event: RequestEvent | undefined,
|
|
409
|
-
options?: SSRResponseOptions
|
|
410
|
-
): Response;
|
|
411
|
-
export function createSSRResponse(
|
|
412
|
-
result: { pipe(writable: { write: (v: string) => void; end: () => void }): void },
|
|
413
|
-
event: RequestEvent | undefined,
|
|
414
|
-
options?: SSRResponseOptions
|
|
415
|
-
): Promise<Response>;
|
|
416
|
-
|
|
606
|
+
export declare function getHydrationWriter(): HydrationWriter | undefined;
|
|
417
607
|
/**
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
*
|
|
608
|
+
* Sets the link handler of the render the caller belongs to — found through
|
|
609
|
+
* the caller's owner (component setup), else through the request scope when
|
|
610
|
+
* exactly one render is open for it — so every candidate anchor rendered
|
|
611
|
+
* from here on carries the handler's markup (`aria-current="page"`,
|
|
612
|
+
* `data-active`) in the server HTML. Returns `false` outside any render.
|
|
613
|
+
*
|
|
614
|
+
* Scoped to the render: concurrent renders never share a handler, and it is
|
|
615
|
+
* gone with the render. Set once per render, typically from a router's
|
|
616
|
+
* server render with its request's location; `undefined` clears it. Anchors
|
|
617
|
+
* serialized BEFORE the call (a document shell above the router) are not
|
|
618
|
+
* marked. Server components inline in the document render under the page's
|
|
619
|
+
* handler; a server component's own frame stream has none unless its render
|
|
620
|
+
* sets one.
|
|
621
|
+
*
|
|
622
|
+
* The first call with a handler writes the `links` hydration record once for
|
|
623
|
+
* the response (`hasServerLinkState()` on the client), the signal that the
|
|
624
|
+
* anchors' link state is the server's and can be trusted at hydration.
|
|
625
|
+
*
|
|
626
|
+
* @example
|
|
627
|
+
* ```ts
|
|
628
|
+
* // in <Router>'s server render
|
|
629
|
+
* setLinkClaim(attrs => matchLink(attrs, location) ? ' data-active aria-current="page"' : "");
|
|
630
|
+
* ```
|
|
631
|
+
* @internal
|
|
421
632
|
*/
|
|
422
|
-
export
|
|
423
|
-
request: Request,
|
|
424
|
-
next: (request?: Request) => Promise<Response>
|
|
425
|
-
) => Response | Promise<Response>;
|
|
426
|
-
|
|
633
|
+
export declare function setLinkClaim(handler: LinkClaimHandler | undefined): boolean;
|
|
427
634
|
/**
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
* `getRequestEvent()` works exactly as in application code.
|
|
635
|
+
* Server: `false`. The client reads the `links` hydration record a render
|
|
636
|
+
* with a link handler wrote (`setLinkClaim`); see the client entry.
|
|
637
|
+
* @internal
|
|
432
638
|
*/
|
|
433
|
-
export function
|
|
434
|
-
|
|
435
|
-
):
|
|
436
|
-
request: Request,
|
|
437
|
-
next: (request?: Request) => Response | Promise<Response>
|
|
438
|
-
) => Promise<Response>;
|
|
439
|
-
|
|
440
|
-
export function untrack<T>(fn: () => T): T;
|
|
441
|
-
|
|
442
|
-
// client-only APIs
|
|
443
|
-
|
|
444
|
-
/** @deprecated not supported on the server side */
|
|
445
|
-
export function style(
|
|
446
|
-
node: Element,
|
|
447
|
-
value: { [k: string]: string },
|
|
448
|
-
prev?: { [k: string]: string }
|
|
449
|
-
): void;
|
|
450
|
-
|
|
451
|
-
/** @deprecated not supported on the server side */
|
|
452
|
-
export function insert<T>(
|
|
453
|
-
parent: MountableElement,
|
|
454
|
-
accessor: (() => T) | T,
|
|
455
|
-
marker?: Node | null,
|
|
456
|
-
init?: JSX.Element
|
|
457
|
-
): JSX.Element;
|
|
458
|
-
|
|
459
|
-
/** @deprecated not supported on the server side */
|
|
460
|
-
export function spread<T>(node: Element, accessor: T, skipChildren?: Boolean): void;
|
|
461
|
-
|
|
462
|
-
/** @deprecated not supported on the server side */
|
|
463
|
-
export function delegateEvents(eventNames: string[]): void;
|
|
464
|
-
/** @deprecated not supported on the server side */
|
|
465
|
-
export function registerDelegatedRoot(root: MountableElement): void;
|
|
466
|
-
/** @deprecated not supported on the server side */
|
|
467
|
-
export function unregisterDelegatedRoot(root: MountableElement): void;
|
|
468
|
-
/** @deprecated not supported on the server side */
|
|
469
|
-
export function registerDelegatedContainer(
|
|
470
|
-
container: MountableElement,
|
|
471
|
-
owner?: MountableElement
|
|
472
|
-
): void;
|
|
473
|
-
/** @deprecated not supported on the server side */
|
|
474
|
-
export function unregisterDelegatedContainer(
|
|
475
|
-
container: MountableElement,
|
|
476
|
-
owner?: MountableElement
|
|
477
|
-
): void;
|
|
478
|
-
/** @deprecated not supported on the server side */
|
|
479
|
-
export function getDelegatedRoot(node: MountableElement): MountableElement | undefined;
|
|
480
|
-
/** @deprecated not supported on the server side */
|
|
481
|
-
export function dynamicProperty(props: unknown, key: string): unknown;
|
|
482
|
-
/** @deprecated not supported on the server side */
|
|
483
|
-
export function setAttribute(node: Element, name: string, value: string): void;
|
|
484
|
-
/** @deprecated not supported on the server side */
|
|
485
|
-
export function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
|
|
486
|
-
|
|
639
|
+
export declare function hasServerLinkState(): boolean;
|
|
640
|
+
/** Server stub — the registry is the client's. See the client entry. */
|
|
641
|
+
export declare function takeHydrationValue<T = unknown>(_key: string): HydrationValue<T> | undefined;
|
|
487
642
|
/**
|
|
488
|
-
*
|
|
489
|
-
*
|
|
643
|
+
* The trace the current request belongs to — continued from the incoming
|
|
644
|
+
* W3C `traceparent` when there was one, originated by the runtime
|
|
645
|
+
* otherwise; in observe/dev builds, merged with the installed provider's
|
|
646
|
+
* answer (`OBSERVE.server.trace`). Same object for every read within the
|
|
647
|
+
* request, direct server-function calls included. For a render outside a
|
|
648
|
+
* request scope, the render's own trace, read within it (under its owner).
|
|
649
|
+
* `undefined` outside both, and on the client. Forward it downstream from a
|
|
650
|
+
* server function with `getTraceContext()?.entries.traceparent`.
|
|
490
651
|
*/
|
|
491
|
-
export function
|
|
492
|
-
/**
|
|
493
|
-
export function
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
export function
|
|
652
|
+
export declare function getTraceContext(): TraceContext | undefined;
|
|
653
|
+
/** A fresh, uncommitted response head. */
|
|
654
|
+
export declare function createResponseStub(): ResponseStub;
|
|
655
|
+
export declare function createRequestEvent<T extends object = {}>(request: Request, init?: T): RequestEvent & {
|
|
656
|
+
response: ResponseStub;
|
|
657
|
+
} & T;
|
|
658
|
+
export declare function commitResponseStub(stub: ResponseStub, options?: {
|
|
659
|
+
allowLateLocation?: boolean;
|
|
660
|
+
event?: RequestEvent;
|
|
661
|
+
}): ResponseStub;
|
|
662
|
+
export declare function getExpectedRedirectStatus(response: ResponseStub): number;
|
|
663
|
+
export declare function commitEventResponse(response: Response, event?: RequestEvent): Response;
|
|
664
|
+
export declare function createSSRResponse(result: string, event: RequestEvent | undefined, options?: SSRResponseOptions): Response;
|
|
665
|
+
export declare function createSSRResponse(result: {
|
|
666
|
+
pipe(writable: {
|
|
667
|
+
write: (v: string) => void;
|
|
668
|
+
end: () => void;
|
|
669
|
+
}): void;
|
|
670
|
+
}, event: RequestEvent | undefined, options?: SSRResponseOptions): Promise<Response>;
|
|
671
|
+
export declare function composeMiddleware(middlewares: FetchMiddleware[]): (request: Request, next: (request?: Request) => Response | Promise<Response>) => Promise<Response>;
|
|
502
672
|
/**
|
|
503
|
-
*
|
|
504
|
-
* @
|
|
505
|
-
* - `undefined` — clone the template as-is (uses `cloneNode`).
|
|
506
|
-
* - `1` — use `document.importNode` instead of `cloneNode`.
|
|
507
|
-
* - `2` — the template html is wrapped; the outer tag is stripped at clone time.
|
|
673
|
+
* Options for `registerElementClaim` (see the client entry); inert on the server.
|
|
674
|
+
* @internal
|
|
508
675
|
*/
|
|
509
|
-
export
|
|
510
|
-
/**
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
fn: () => JSX.Element,
|
|
520
|
-
node: MountableElement,
|
|
521
|
-
options?: { renderId?: string; owner?: unknown }
|
|
522
|
-
): () => void;
|
|
523
|
-
|
|
524
|
-
/** @deprecated not supported on the server side */
|
|
525
|
-
export function getNextElement(template?: () => Element): Element;
|
|
526
|
-
/** @deprecated not supported on the server side */
|
|
527
|
-
export function getNextMatch(start: Node, elementName: string): Element;
|
|
528
|
-
/** @deprecated not supported on the server side */
|
|
529
|
-
export function getNextMarker(start: Node): [Node, Array<Node>];
|
|
530
|
-
/** @deprecated not supported on the server side */
|
|
531
|
-
export function runHydrationEvents(): void;
|
|
532
|
-
/** @deprecated not supported on the server side */
|
|
533
|
-
export function ref(
|
|
534
|
-
fn: () => ((element: Element) => void) | ((element: Element) => void)[],
|
|
535
|
-
element: Element
|
|
536
|
-
): void;
|
|
537
|
-
/** @deprecated not supported on the server side */
|
|
538
|
-
export function setStyleProperty(node: Element, name: string, value: any): void;
|
|
539
|
-
/**
|
|
540
|
-
* @internal See client.d.ts — head-management RFC policy: ambient CSS is
|
|
541
|
-
* unmanaged; the head registry owns directly-mounted stylesheet lifecycle.
|
|
542
|
-
* @deprecated not supported on the server side — register assets through the render context instead
|
|
676
|
+
export type ElementClaimOptions = {
|
|
677
|
+
/**
|
|
678
|
+
* Attribute names whose compiler-owned writes re-claim an already claimed
|
|
679
|
+
* element, as plain names (`href` covers `prop:href` and `xlink:href`).
|
|
680
|
+
* Defaults to `["href", "action"]`.
|
|
681
|
+
*/
|
|
682
|
+
attributes?: readonly string[];
|
|
683
|
+
}; /**
|
|
684
|
+
* Server no-op: element claims are a client-only concern, but consumers may
|
|
685
|
+
* register isomorphically. Returns a no-op unregister function.
|
|
543
686
|
*/
|
|
544
|
-
export function
|
|
687
|
+
export declare function registerElementClaim(handler: (element: Element) => void, options?: ElementClaimOptions): () => void;
|
|
688
|
+
export declare function claimElement<T extends Element>(node: T, owner?: Owner | null): T;
|
|
689
|
+
export declare function claimElementTree<T extends Node>(root: T): T;
|
|
690
|
+
/** Server: `fn()`. No event is dispatched during SSR, so there is no interaction to join. */
|
|
691
|
+
export declare function dispatchAsInteraction<T>(_e: Event, fn: () => T): T;
|
|
692
|
+
export { notSup as style, notSup as insert, notSup as spread, notSup as delegateEvents, notSup as registerDelegatedRoot, notSup as unregisterDelegatedRoot, notSup as registerDelegatedContainer, notSup as unregisterDelegatedContainer, notSup as getDelegatedRoot, notSup as dynamicProperty, notSup as setAttribute, notSup as setAttributeNS, notSup as addEvent, notSup as render, notSup as template, notSup as setProperty, notSup as setStatefulProperty, notSup as className, notSup as assign, notSup as hydrate, notSup as getNextElement, notSup as getNextMatch, notSup as getNextMarker, notSup as runHydrationEvents, notSup as ref, notSup as setStyleProperty, notSup as readShallow, notSup as acquireAsset };
|
|
693
|
+
declare function notSup(): void;
|