@solidjs/web 2.0.0-rc.1 → 2.0.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.dev.js +4472 -0
- package/dist/server.js +1301 -251
- package/dist/{server.cjs → server.observe.js} +1501 -452
- package/dist/{dev.cjs → web.dev.js} +699 -360
- package/dist/web.js +454 -139
- package/dist/{dev.js → web.observe.js} +505 -211
- package/frames/dist/client.dev.js +463 -71
- package/frames/dist/client.js +363 -70
- package/frames/dist/{client.dev.cjs → client.observe.js} +486 -133
- package/frames/dist/server.dev.js +1713 -0
- package/frames/dist/server.js +552 -2583
- package/frames/dist/server.observe.js +1713 -0
- package/frames/package.json +2 -25
- package/package.json +214 -255
- package/performance-tracks/dist/performance-tracks.dev.js +678 -0
- package/performance-tracks/dist/performance-tracks.js +6 -0
- package/performance-tracks/dist/performance-tracks.observe.js +666 -0
- package/performance-tracks/package.json +7 -0
- package/performance-tracks/types/index.d.ts +67 -0
- package/serialization/decode/package.json +2 -15
- package/serialization/dist/decode.js +92 -15
- package/serialization/dist/serialization.js +103 -23
- package/serialization/package.json +2 -15
- package/serialization/types/index.d.ts +76 -157
- package/serialization/types/serializer-decode.d.ts +149 -112
- package/serialization/types/serializer.d.ts +101 -0
- package/server-functions/dist/client.dev.js +1364 -0
- package/server-functions/dist/client.js +611 -97
- package/server-functions/dist/client.observe.js +1343 -0
- package/server-functions/dist/server.dev.js +2138 -202
- package/server-functions/dist/server.js +2042 -199
- package/server-functions/dist/server.observe.js +3043 -0
- package/server-functions/package.json +2 -35
- package/server-functions/rich-args/package.json +2 -15
- package/storage/package.json +2 -15
- package/types/client.d.ts +193 -288
- package/types/constants.d.ts +20 -0
- package/types/cookies.d.ts +32 -84
- package/types/diagnostics.d.ts +56 -0
- package/types/frames/client.d.ts +1 -1
- package/types/frames/frame-client.d.ts +323 -259
- package/types/frames/frame-container-plugin.d.ts +72 -0
- package/types/frames/frame-sink.d.ts +101 -158
- package/types/frames/frame-transport.d.ts +192 -190
- package/types/frames/serializer-decode.d.ts +219 -0
- package/types/frames/serializer.d.ts +76 -157
- package/types/frames/server.d.ts +1 -1
- package/types/head.d.ts +19 -0
- package/types/index.d.ts +52 -80
- package/types/index.server.d.ts +174 -0
- package/types/jsx.d.ts +33 -35
- package/types/observe.d.ts +358 -0
- package/types/reconcile.d.ts +1 -0
- package/types/render.d.ts +9 -0
- package/types/response.d.ts +75 -150
- package/types/serializer-decode.d.ts +149 -112
- package/types/serializer.d.ts +76 -157
- package/types/server-functions/client.d.ts +192 -194
- package/types/server-functions/flash.d.ts +28 -30
- package/types/server-functions/registry.d.ts +102 -0
- package/types/server-functions/rich-args.d.ts +1 -10
- package/types/server-functions/server.d.ts +511 -475
- package/types/server-functions/shared.d.ts +366 -425
- package/types/server-mock.d.ts +110 -13
- package/types/server-observe.d.ts +77 -0
- package/types/server.d.ts +425 -425
- package/types/trace.d.ts +127 -0
- package/LICENSE +0 -21
- package/dist/web.cjs +0 -2008
- package/frames/dist/client.cjs +0 -1916
- package/frames/dist/server.cjs +0 -3756
- package/serialization/dist/decode.cjs +0 -122
- package/serialization/dist/serialization.cjs +0 -244
- 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 -793
- package/server-functions/dist/rich-args.cjs +0 -11
- package/server-functions/dist/server.cjs +0 -1171
- package/server-functions/dist/server.dev.cjs +0 -1171
- 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 -6
- package/types-cjs/client.d.cts +0 -337
- package/types-cjs/cookies.d.cts +0 -93
- package/types-cjs/core.d.cts +0 -6
- package/types-cjs/frames/client.d.cts +0 -36
- package/types-cjs/frames/frame-client.d.cts +0 -338
- 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 -231
- 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 -616
- package/types-cjs/server-functions/shared.d.cts +0 -523
- package/types-cjs/server-mock.d.cts +0 -277
- package/types-cjs/server.d.cts +0 -523
package/types/server.d.ts
CHANGED
|
@@ -1,155 +1,119 @@
|
|
|
1
|
+
import { sharedConfig, getOwner, createComponent, untrack, merge as mergeProps } from "solid-js";
|
|
2
|
+
import { ssrScope as scope } from "solid-js/internal";
|
|
3
|
+
import type { ServerErrorSite } from "solid-js/internal";
|
|
4
|
+
import { effect, memo } from "./render.js";
|
|
5
|
+
import { type TraceContext } from "./trace.js";
|
|
6
|
+
export { parseCookieHeader, serializeCookie } from "./cookies.js";
|
|
7
|
+
export { clearFlashCookie, hasFlashCookie } from "./cookies.js";
|
|
8
|
+
export { getServerFunctionMetadata, getServerFunctionRPC, isServerFunction } from "./server-functions/registry.js";
|
|
1
9
|
import { JSX } from "./jsx.js";
|
|
2
10
|
import { SerializerPlugin } from "./serializer-decode.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
type PreloadLinkAttributes = {
|
|
12
|
+
type?: string;
|
|
13
|
+
crossorigin?: JSX.HTMLCrossorigin;
|
|
14
|
+
integrity?: string;
|
|
15
|
+
referrerpolicy?: JSX.HTMLReferrerPolicy;
|
|
16
|
+
fetchpriority?: JSX.HTMLFetchPriority;
|
|
17
|
+
media?: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* An explicit `<link rel="preload">` emitted by the SSR asset pipeline.
|
|
21
|
+
*
|
|
22
|
+
* `as` is the HTML Standard's set of preload destinations exactly — anything
|
|
23
|
+
* else translates to null and the browser does nothing with the link.
|
|
24
|
+
*
|
|
25
|
+
* `imagesrcset` candidates must already be resolved by the integration: they
|
|
26
|
+
* are carried verbatim (a relative candidate resolves against the DOCUMENT
|
|
27
|
+
* URL, not the manifest base). Pair it with `imagesizes` whenever a candidate
|
|
28
|
+
* uses a width descriptor, which the spec requires — without it the source
|
|
29
|
+
* size falls back to `100vw` and the preload can miss the image the `<img>`
|
|
30
|
+
* selects. Omitting `href` is the spec's own recommendation for the source-set
|
|
31
|
+
* form: it would only serve browsers without `imagesrcset` support, and there
|
|
32
|
+
* it would likely preload the wrong candidate.
|
|
33
|
+
*/
|
|
34
|
+
export type PreloadLink = PreloadLinkAttributes & ({
|
|
35
|
+
href: string;
|
|
36
|
+
as: Exclude<JSX.HTMLPreloadAs, "image">;
|
|
37
|
+
imagesrcset?: never;
|
|
38
|
+
imagesizes?: never;
|
|
39
|
+
} | {
|
|
40
|
+
href: string;
|
|
41
|
+
as: "image";
|
|
42
|
+
imagesrcset?: string;
|
|
43
|
+
imagesizes?: string;
|
|
44
|
+
} | {
|
|
45
|
+
href?: never;
|
|
46
|
+
as: "image";
|
|
47
|
+
imagesrcset: string;
|
|
48
|
+
imagesizes?: string;
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Static asset graph consumed by the SSR pipeline. This is Solid's own
|
|
52
|
+
* contract — a parsed Vite client manifest satisfies it structurally
|
|
53
|
+
* (unknown fields pass through untyped), but any bundler integration can
|
|
54
|
+
* produce it. Only these fields are ever read: `preloads` is Solid's
|
|
55
|
+
* extension slot for explicit typed links the integration selects.
|
|
56
|
+
*/
|
|
57
|
+
export type AssetManifest = Record<string, {
|
|
58
|
+
file: string;
|
|
59
|
+
css?: string[];
|
|
60
|
+
isEntry?: boolean;
|
|
61
|
+
imports?: string[];
|
|
62
|
+
preloads?: PreloadLink[];
|
|
63
|
+
}> & {
|
|
64
|
+
_base?: string;
|
|
65
|
+
};
|
|
21
66
|
/** Inline style content, e.g. dev CSS collected from a bundler's module graph. */
|
|
22
67
|
export type InlineStyleAsset = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
68
|
+
id: string;
|
|
69
|
+
content: string;
|
|
70
|
+
attrs?: Record<string, string>;
|
|
26
71
|
};
|
|
27
|
-
|
|
28
72
|
export type ResolvedAssets = {
|
|
29
|
-
|
|
30
|
-
|
|
73
|
+
js: string[];
|
|
74
|
+
css: (string | InlineStyleAsset)[];
|
|
75
|
+
preloads?: PreloadLink[];
|
|
31
76
|
};
|
|
32
|
-
|
|
33
77
|
/**
|
|
34
78
|
* Resolver form of the manifest option — the primitive a dev server
|
|
35
79
|
* implements against its live module graph (a static manifest object is
|
|
36
80
|
* normalized into a sync resolver internally). `resolve` may return a
|
|
37
81
|
* promise (async resolvers require streaming rendering); CSS entries may be
|
|
38
82
|
* URL strings (emitted as load-gated `<link>` tags) or inline-style
|
|
39
|
-
* descriptors (emitted as `<style>` tags)
|
|
40
|
-
*
|
|
83
|
+
* descriptors (emitted as `<style>` tags), and `preloads` carries explicit
|
|
84
|
+
* preload links selected by the integration. A bare `resolve`-shaped
|
|
85
|
+
* function is accepted as shorthand for `{ resolve }`.
|
|
41
86
|
*/
|
|
42
87
|
export type AssetResolver = {
|
|
43
|
-
|
|
44
|
-
key: string
|
|
45
|
-
): ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
|
|
46
|
-
/**
|
|
47
|
-
* Synchronous fast path answering with whatever is knowable without async
|
|
48
|
-
* work (typically js URLs, omitting css). Sync consumers — e.g. a lazy
|
|
49
|
-
* component's `moduleUrl` getter used by islands — use this when `resolve`
|
|
50
|
-
* would return a promise, so adapters should provide it whenever possible.
|
|
51
|
-
*/
|
|
52
|
-
resolveSync?(key: string): ResolvedAssets | null | undefined;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/** 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
|
-
|
|
60
|
-
export function renderToString<T>(
|
|
61
|
-
fn: () => T,
|
|
62
|
-
options?: {
|
|
63
|
-
nonce?: string;
|
|
64
|
-
renderId?: string;
|
|
65
|
-
noScripts?: boolean;
|
|
66
|
-
plugins?: SerializerPlugin[];
|
|
67
|
-
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
68
|
-
onError?: (err: any) => void;
|
|
88
|
+
resolve(key: string): ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
|
|
69
89
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* `
|
|
73
|
-
*
|
|
74
|
-
* first — for the host to splice into its own `<head>` template, instead
|
|
75
|
-
* of being dropped. Called synchronously before `renderToString`
|
|
76
|
-
* returns; not called when the output has a `</head>` (splicing is
|
|
77
|
-
* automatic then).
|
|
90
|
+
* Synchronous fast path answering with whatever is knowable without async
|
|
91
|
+
* work (typically js URLs, omitting css). Sync consumers — e.g. a lazy
|
|
92
|
+
* component's `moduleUrl` getter used by islands — use this when `resolve`
|
|
93
|
+
* would return a promise, so adapters should provide it whenever possible.
|
|
78
94
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
)
|
|
82
|
-
export
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
* through the stream itself and apply in the browser. Not called when
|
|
101
|
-
* the shell has a `</head>` (splicing is automatic then).
|
|
102
|
-
*/
|
|
103
|
-
onHead?: (head: string) => void;
|
|
104
|
-
}
|
|
105
|
-
): {
|
|
106
|
-
/**
|
|
107
|
-
* Awaiting the stream resolves with the complete HTML once every boundary
|
|
108
|
-
* settles — the fully-settled-string form of the render (`const html =
|
|
109
|
-
* await renderToStream(...)`). Render errors route through `onError` and
|
|
110
|
-
* the promise resolves with whatever HTML the render produced; it never
|
|
111
|
-
* rejects.
|
|
112
|
-
*/
|
|
113
|
-
then<TResult1 = string, TResult2 = never>(
|
|
114
|
-
onfulfilled?: ((html: string) => TResult1 | PromiseLike<TResult1>) | null,
|
|
115
|
-
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null
|
|
116
|
-
): Promise<TResult1 | TResult2>;
|
|
117
|
-
pipe: (writable: { write: (v: string) => void; end: () => void }) => void;
|
|
118
|
-
pipeTo: (writable: WritableStream) => Promise<void>;
|
|
119
|
-
/**
|
|
120
|
-
* Lazy `ReadableStream<Uint8Array>` view of the render — hand it straight
|
|
121
|
-
* to `new Response(stream.readable)`. First access starts the render
|
|
122
|
-
* piping through an internal `TransformStream` (chunks are UTF-8 encoded
|
|
123
|
-
* bytes, the same as `pipeTo` writes) and the stream is cached, so
|
|
124
|
-
* repeated access returns the same instance. Like `pipe`/`pipeTo`, this
|
|
125
|
-
* consumes the render: use exactly one of the three — mixing distinct
|
|
126
|
-
* consumers (`readable` after `pipe`/`pipeTo`, or vice versa) throws an
|
|
127
|
-
* error naming the conflict.
|
|
128
|
-
*/
|
|
129
|
-
readonly readable: ReadableStream<Uint8Array>;
|
|
95
|
+
resolveSync?(key: string): ResolvedAssets | null | undefined;
|
|
96
|
+
};
|
|
97
|
+
/** Bare-function shorthand for `AssetResolver` (no sync fast path). */
|
|
98
|
+
export type AssetResolverFn = (key: string) => ResolvedAssets | null | undefined | Promise<ResolvedAssets | null | undefined>;
|
|
99
|
+
/**
|
|
100
|
+
* CSP nonce for the tags a server render emits. A string applies to both
|
|
101
|
+
* nonce-aware destinations. A `{ script, style }` pair routes each tag to
|
|
102
|
+
* the directive governing its fetch (`script-src-elem` / `style-src-elem`,
|
|
103
|
+
* falling back to `script-src` / `style-src` then `default-src`). Both
|
|
104
|
+
* keys are required; `false` leaves that destination un-nonced. Worker
|
|
105
|
+
* destinations take the script nonce, which only applies when their own
|
|
106
|
+
* fallback reaches `script-src`. A nonce on a `useHead` tag's own props
|
|
107
|
+
* always wins.
|
|
108
|
+
*
|
|
109
|
+
* Only `renderToString` / `renderToStream` take this shape. Surfaces that
|
|
110
|
+
* emit one script (`HydrationScript`, `generateHydrationScript`,
|
|
111
|
+
* `createSSRResponse`) take a string — project with `scriptNonce`.
|
|
112
|
+
*/
|
|
113
|
+
export type CSPNonce = string | {
|
|
114
|
+
script: string | false;
|
|
115
|
+
style: string | false;
|
|
130
116
|
};
|
|
131
|
-
|
|
132
|
-
export function HydrationScript(props: { nonce?: string; eventNames?: string[] }): JSX.Element;
|
|
133
|
-
export function ssr(template: string[] | string, ...nodes: any[]): { t: string };
|
|
134
|
-
export function ssrElement(
|
|
135
|
-
name: string,
|
|
136
|
-
props: any,
|
|
137
|
-
children: any,
|
|
138
|
-
needsId: boolean
|
|
139
|
-
): { t: string };
|
|
140
|
-
export function ssrClassName(value: string | { [k: string]: boolean } | Array<any>): string;
|
|
141
|
-
export function ssrStyle(value: string | { [k: string]: string }): string;
|
|
142
|
-
export function ssrStyleProperty(name: string, value: any): string;
|
|
143
|
-
export function ssrAttribute(key: string, value: any): string;
|
|
144
|
-
export function ssrGroup<T extends () => any[]>(fn: T, n: number): T;
|
|
145
|
-
export function scope<T>(fn: () => T): () => unknown;
|
|
146
|
-
export function ssrHydrationKey(): string;
|
|
147
|
-
export function resolveSSRNode(node: any, result?: any, top?: boolean): any;
|
|
148
|
-
export function escape(s: any, attr?: boolean): any;
|
|
149
|
-
export function applyRef(
|
|
150
|
-
r: ((element: any) => void) | ((element: any) => void)[],
|
|
151
|
-
element: any
|
|
152
|
-
): void;
|
|
153
117
|
/**
|
|
154
118
|
* A head tag descriptor. Props values may be getters (evaluated lazily on
|
|
155
119
|
* the server — at the owning flush boundary — and reactively on the client);
|
|
@@ -166,39 +130,10 @@ export function applyRef(
|
|
|
166
130
|
* docs/head-management-rfc.md.
|
|
167
131
|
*/
|
|
168
132
|
export type HeadTag = {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
133
|
+
tag: "title" | "meta" | "link" | "style" | "script" | "base";
|
|
134
|
+
props: Record<string, any>;
|
|
135
|
+
key?: string | (() => string);
|
|
172
136
|
};
|
|
173
|
-
/**
|
|
174
|
-
* Registers head tags with the render's head registry. An array is a group —
|
|
175
|
-
* one replacement set; a single tag is a group of one; a function is a
|
|
176
|
-
* reactive group whose membership resolves at the owning flush boundary
|
|
177
|
-
* (resource tags inside it emit at that flush rather than eagerly).
|
|
178
|
-
* Replaceable tags (title/meta/canonical/…) resolve by last-committed group
|
|
179
|
-
* and stream as patches with their suspense boundary's reveal; resource tags
|
|
180
|
-
* (preload and friends, stylesheets, `script[src]`) emit eagerly and dedupe
|
|
181
|
-
* by identity. See docs/head-management-rfc.md.
|
|
182
|
-
*/
|
|
183
|
-
export function useHead(tag: HeadTag | HeadTag[] | (() => HeadTag | HeadTag[])): void;
|
|
184
|
-
export function getHydrationKey(): string | undefined;
|
|
185
|
-
export function effect<T>(fn: (prev?: T) => T, effect: (value: T, prev?: T) => void): void;
|
|
186
|
-
export function memo<T>(fn: () => T, equal: boolean): () => T;
|
|
187
|
-
export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
|
|
188
|
-
export function mergeProps(...sources: unknown[]): unknown;
|
|
189
|
-
export function getOwner(): unknown;
|
|
190
|
-
export function generateHydrationScript(options?: {
|
|
191
|
-
nonce?: string;
|
|
192
|
-
eventNames?: string[];
|
|
193
|
-
}): string;
|
|
194
|
-
/**
|
|
195
|
-
* Registered symbol (`Symbol.for("solid.RequestContext")`) naming the
|
|
196
|
-
* global slot where `provideRequestEvent` parks the AsyncLocalStorage that
|
|
197
|
-
* scopes request events. Integration plumbing — application code reads the
|
|
198
|
-
* event through `getRequestEvent()` instead.
|
|
199
|
-
* @internal
|
|
200
|
-
*/
|
|
201
|
-
export declare const RequestContext: unique symbol;
|
|
202
137
|
/**
|
|
203
138
|
* The mutable response head an integration's handler exposes on the request
|
|
204
139
|
* event as `event.response`: status/statusText/headers it will apply when
|
|
@@ -214,22 +149,21 @@ export declare const RequestContext: unique symbol;
|
|
|
214
149
|
* and reads it when folding single-flight cookies, but never requires it.
|
|
215
150
|
*/
|
|
216
151
|
export interface ResponseStub {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
152
|
+
status?: number;
|
|
153
|
+
statusText?: string;
|
|
154
|
+
headers: Headers;
|
|
155
|
+
/**
|
|
156
|
+
* Set once the response head has been derived/sent from this stub —
|
|
157
|
+
* status and headers can no longer change. Flip it through
|
|
158
|
+
* `commitResponseStub`, which also instruments the stub's `headers` so
|
|
159
|
+
* a post-commit write fails loudly (dev build throws, production
|
|
160
|
+
* reports + no-ops) instead of silently missing the wire. `status`/
|
|
161
|
+
* `statusText` stay plain fields: consumers that write response
|
|
162
|
+
* metadata during render (e.g. JSX response components) must still
|
|
163
|
+
* treat later status writes and cleanup-time retractions as no-ops.
|
|
164
|
+
*/
|
|
165
|
+
committed?: boolean;
|
|
231
166
|
}
|
|
232
|
-
|
|
233
167
|
/**
|
|
234
168
|
* The type of `RequestEvent.locals` — a module-augmentable interface so
|
|
235
169
|
* applications can type the state their middleware hangs on the event.
|
|
@@ -251,9 +185,8 @@ export interface ResponseStub {
|
|
|
251
185
|
* `locals` would break every untyped write that works today).
|
|
252
186
|
*/
|
|
253
187
|
export interface RequestEventLocals {
|
|
254
|
-
|
|
188
|
+
[key: string | number | symbol]: any;
|
|
255
189
|
}
|
|
256
|
-
|
|
257
190
|
/**
|
|
258
191
|
* The per-request context available on the server: the incoming `Request`
|
|
259
192
|
* and a `locals` bag integrations and middleware can hang state on (typed
|
|
@@ -262,262 +195,329 @@ export interface RequestEventLocals {
|
|
|
262
195
|
* `ResponseStub`).
|
|
263
196
|
*/
|
|
264
197
|
export interface RequestEvent {
|
|
265
|
-
|
|
266
|
-
|
|
198
|
+
request: Request;
|
|
199
|
+
locals: RequestEventLocals;
|
|
267
200
|
}
|
|
268
|
-
/**
|
|
269
|
-
* The current request event, when called on the server inside a request
|
|
270
|
-
* scope (established by `provideRequestEvent` from `@solidjs/web/storage`
|
|
271
|
-
* or by the framework). Undefined on the client and outside a request.
|
|
272
|
-
* Read it above `await` boundaries in partially-polyfilled environments.
|
|
273
|
-
*/
|
|
274
|
-
export function getRequestEvent(): RequestEvent | undefined;
|
|
275
|
-
|
|
276
|
-
/** A fresh, uncommitted response head. */
|
|
277
|
-
export function createResponseStub(): ResponseStub;
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* The canonical request event for HTTP handlers: the incoming `Request`, a
|
|
281
|
-
* `locals` bag, and a `response` head stub the render writes to. `init`
|
|
282
|
-
* spreads over the defaults so frameworks can extend the shape.
|
|
283
|
-
*/
|
|
284
|
-
export function createRequestEvent<T extends object = {}>(
|
|
285
|
-
request: Request,
|
|
286
|
-
init?: T
|
|
287
|
-
): RequestEvent & { response: ResponseStub } & T;
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* The status an outgoing redirect should use for a response head carrying
|
|
291
|
-
* a `Location`: the stub's own status when it is a redirect status, 302
|
|
292
|
-
* otherwise.
|
|
293
|
-
*/
|
|
294
|
-
export function getExpectedRedirectStatus(response: ResponseStub): number;
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Flips a response stub to `committed` — the moment its head freezes on
|
|
298
|
-
* the wire — and instruments the stub's `headers` mutating methods
|
|
299
|
-
* (`set`/`append`/`delete`, patched in place; the `Headers` identity and
|
|
300
|
-
* reads are untouched) so a post-commit write fails loudly instead of
|
|
301
|
-
* silently missing the wire: it throws in the dev build and reports +
|
|
302
|
-
* no-ops otherwise. Every head materialization path commits through here
|
|
303
|
-
* (`createSSRResponse`, the server-function handler's commit seam);
|
|
304
|
-
* integrations deriving their own heads should too.
|
|
305
|
-
*
|
|
306
|
-
* `allowLateLocation` is the stream path's documented exception: a
|
|
307
|
-
* `Location` set after the shell flushed is still honored client-side
|
|
308
|
-
* (stream completion appends a `window.location` script), so that one
|
|
309
|
-
* write stays permitted there.
|
|
310
|
-
*/
|
|
311
|
-
export function commitResponseStub(
|
|
312
|
-
stub: ResponseStub,
|
|
313
|
-
options?: { allowLateLocation?: boolean }
|
|
314
|
-
): ResponseStub;
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Handler-lifecycle plumbing — a response's exit through the request
|
|
318
|
-
* event's response-stub lifecycle: page results leave through
|
|
319
|
-
* `createSSRResponse`, any other `Response` (a middleware early return, an
|
|
320
|
-
* API result) leaves through `commitEventResponse`; application middleware
|
|
321
|
-
* never calls this. Folds the event's stub onto the outgoing response —
|
|
322
|
-
* `Set-Cookie` appends entry-by-entry alongside the response's own, other
|
|
323
|
-
* stub headers fill gaps only (never the wire-protocol family the handlers
|
|
324
|
-
* own, never `Content-Type`/`Content-Length` on a bodiless response), the
|
|
325
|
-
* status is never taken from the stub — then commits the stub
|
|
326
|
-
* (`commitResponseStub`: post-commit writes fail loudly). Responses with
|
|
327
|
-
* immutable headers are rebuilt around merged copies.
|
|
328
|
-
*
|
|
329
|
-
* Idempotent at handler edges: an already-committed stub passes the
|
|
330
|
-
* response through untouched, so a handler may apply this unconditionally
|
|
331
|
-
* after its middleware chain unwinds — page responses from
|
|
332
|
-
* `createSSRResponse` come back committed and do not double-fold.
|
|
333
|
-
*
|
|
334
|
-
* `event` defaults to the ambient `getRequestEvent()`.
|
|
335
|
-
*/
|
|
336
|
-
export function commitEventResponse(response: Response, event?: RequestEvent): Response;
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* The cookie codec (the platform-gap primitives — see cookies.d.ts): ALL
|
|
340
|
-
* of core's cookie surface. The blessed patterns are
|
|
341
|
-
* `parseCookieHeader(event.request.headers.get("cookie"))` for reads and
|
|
342
|
-
* `event.response.headers.append("set-cookie", serializeCookie(name,
|
|
343
|
-
* value, options))` for writes.
|
|
344
|
-
*/
|
|
345
|
-
export { parseCookieHeader, serializeCookie } from "./cookies.js";
|
|
346
201
|
export type { CookieOptions } from "./cookies.js";
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* The flash cookie's isomorphic half and the codec-free server-function
|
|
350
|
-
* layer (reference detection + the late-bound RPC seam) — mirrors of the
|
|
351
|
-
* client entry's exports, so integration code reading them stays
|
|
352
|
-
* universal. Declared through server-functions/shared.d.ts, the
|
|
353
|
-
* declaration home published-types layouts ship.
|
|
354
|
-
*/
|
|
355
|
-
export {
|
|
356
|
-
clearFlashCookie,
|
|
357
|
-
getServerFunctionMetadata,
|
|
358
|
-
getServerFunctionRPC,
|
|
359
|
-
hasFlashCookie,
|
|
360
|
-
isServerFunction
|
|
361
|
-
} from "./server-functions/shared.js";
|
|
362
|
-
export type {
|
|
363
|
-
ServerFunction,
|
|
364
|
-
ServerFunctionMetadata,
|
|
365
|
-
ServerFunctionRPC
|
|
366
|
-
} from "./server-functions/shared.js";
|
|
367
|
-
|
|
202
|
+
export type { ServerFunction, ServerFunctionMetadata, ServerFunctionRPC } from "./server-functions/shared.js";
|
|
368
203
|
export interface SSRResponseOptions {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
204
|
+
/** Base head; the stub's status/headers win over it. */
|
|
205
|
+
responseInit?: ResponseInit;
|
|
206
|
+
/** Nonce carried by the post-flush `<script>` redirect fallback. */
|
|
207
|
+
nonce?: string;
|
|
208
|
+
/** Rewrites each outgoing HTML chunk (entry script injection, ...). */
|
|
209
|
+
transformChunk?: (chunk: string) => string;
|
|
375
210
|
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Derives the outgoing `Response` for an SSR render result, running the
|
|
379
|
-
* response-head lifecycle against `event.response`: commit at shell flush,
|
|
380
|
-
* pre-flush `Location` becomes a real redirect, post-flush `Location`
|
|
381
|
-
* appends a client-side script redirect before the stream closes.
|
|
382
|
-
* Synchronous for string results; resolves at shell flush for stream
|
|
383
|
-
* results.
|
|
384
|
-
*/
|
|
385
|
-
export function createSSRResponse(
|
|
386
|
-
result: string,
|
|
387
|
-
event: RequestEvent | undefined,
|
|
388
|
-
options?: SSRResponseOptions
|
|
389
|
-
): Response;
|
|
390
|
-
export function createSSRResponse(
|
|
391
|
-
result: { pipe(writable: { write: (v: string) => void; end: () => void }): void },
|
|
392
|
-
event: RequestEvent | undefined,
|
|
393
|
-
options?: SSRResponseOptions
|
|
394
|
-
): Promise<Response>;
|
|
395
|
-
|
|
396
211
|
/**
|
|
397
212
|
* Fetch-style middleware: return a `Response` to answer the request, or
|
|
398
213
|
* call `next()` (optionally with a substitute `Request`) to advance the
|
|
399
214
|
* chain and observe/replace the eventual response.
|
|
400
215
|
*/
|
|
401
|
-
export type FetchMiddleware = (
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
216
|
+
export type FetchMiddleware = (request: Request, next: (request?: Request) => Promise<Response>) => Response | Promise<Response>;
|
|
217
|
+
export { createComponent, effect, memo, untrack, mergeProps, scope, getOwner };
|
|
218
|
+
export { sharedConfig };
|
|
219
|
+
export { DOMWithState, ChildProperties, DOMElements, SVGElements, MathMLElements, VoidElements, RawTextElements, Namespaces, DelegatedEvents } from "./constants.js";
|
|
220
|
+
export declare function scriptNonce(nonce?: CSPNonce): string | undefined;
|
|
221
|
+
export declare function styleNonce(nonce?: CSPNonce): string | undefined;
|
|
222
|
+
export declare function useHead(tag: HeadTag | HeadTag[] | (() => HeadTag | HeadTag[])): void;
|
|
223
|
+
export declare function renderToString<T>(fn: () => T, options?: {
|
|
224
|
+
nonce?: CSPNonce;
|
|
225
|
+
renderId?: string;
|
|
226
|
+
noScripts?: boolean;
|
|
227
|
+
plugins?: SerializerPlugin[];
|
|
228
|
+
manifest?: AssetManifest | AssetResolver | AssetResolverFn;
|
|
229
|
+
/**
|
|
230
|
+
* This render's server error hook, ahead of `configureServerErrors`'
|
|
231
|
+
* (see `ServerErrorHook`): every failure the render handles — an
|
|
232
|
+
* `<Errored>` fallback (`handling: "fallback"`), a hydration value that
|
|
233
|
+
* would not serialize (`"serialize"`) — once per error, with where it
|
|
234
|
+
* was met. A one-argument listener still works; it 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, with where it was met. A one-argument listener still
|
|
268
|
+
* works; it hears them all — filter on `context.handling` for the
|
|
269
|
+
* request-failing ones alone. Without a hook (here or ambient) a
|
|
270
|
+
* failure that fails the request goes to `console.error`.
|
|
271
|
+
*/
|
|
272
|
+
onError?: ServerErrorHook;
|
|
273
|
+
/**
|
|
274
|
+
* Embedded-render contract for hosts that own the document. When the
|
|
275
|
+
* shell contains no `</head>`, everything head-bound at first flush
|
|
276
|
+
* (resolved `useHead` winners, eager resources, tracked asset links,
|
|
277
|
+
* inline styles) is delivered here as one HTML string — prelude first —
|
|
278
|
+
* before the shell chunk is emitted, so the host can write its own
|
|
279
|
+
* `<head>` ahead of piping the stream. Post-shell head updates flow
|
|
280
|
+
* through the stream itself and apply in the browser. Not called when
|
|
281
|
+
* the shell has a `</head>` (splicing is automatic then).
|
|
282
|
+
*/
|
|
283
|
+
onHead?: (head: string) => void;
|
|
284
|
+
/**
|
|
285
|
+
* The request's lifecycle. Aborting tears the render down exactly as a
|
|
286
|
+
* client disconnect does (`SSR_STREAM_ABANDONED`, `data.reason:
|
|
287
|
+
* "signal"`): in-flight reactive work is disposed, every async source
|
|
288
|
+
* still being pulled is returned, and nothing more reaches the sink. For
|
|
289
|
+
* the host whose transport cannot report a dead consumer through the
|
|
290
|
+
* sink or the readable view — a frame stream whose emission never
|
|
291
|
+
* touches the document writable, a platform whose response body is
|
|
292
|
+
* consumed by a proxy — this is the one teardown handle; pass
|
|
293
|
+
* `request.signal`. Idempotent with the sink and consumer paths: whichever
|
|
294
|
+
* fires first tears down, the rest are no-ops.
|
|
295
|
+
*/
|
|
296
|
+
signal?: AbortSignal;
|
|
297
|
+
}): {
|
|
298
|
+
/**
|
|
299
|
+
* Awaiting the stream resolves with the complete HTML once every boundary
|
|
300
|
+
* settles — the fully-settled-string form of the render (`const html =
|
|
301
|
+
* await renderToStream(...)`). Render errors route through `onError` and
|
|
302
|
+
* the promise resolves with whatever HTML the render produced; it never
|
|
303
|
+
* rejects.
|
|
304
|
+
*
|
|
305
|
+
* Completion is this path's head-freeze point: the request event's
|
|
306
|
+
* `response` head (the request scope the render was started in) is
|
|
307
|
+
* committed right before the render's final dispose, so
|
|
308
|
+
* `httpStatus`/`httpHeader` declarations still live at completion survive
|
|
309
|
+
* into `createSSRResponse(html, event)` — which sees the already-committed
|
|
310
|
+
* stub and passes it through. The piped forms freeze at shell flush
|
|
311
|
+
* instead.
|
|
312
|
+
*/
|
|
313
|
+
then<TResult1 = string, TResult2 = never>(onfulfilled?: ((html: string) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
314
|
+
pipe: (writable: {
|
|
315
|
+
write: (v: string) => void;
|
|
316
|
+
end: () => void;
|
|
317
|
+
}) => void;
|
|
318
|
+
pipeTo: (writable: WritableStream) => Promise<void>;
|
|
319
|
+
/**
|
|
320
|
+
* Lazy `ReadableStream<Uint8Array>` view of the render — hand it straight
|
|
321
|
+
* to `new Response(stream.readable)`. First access starts the render
|
|
322
|
+
* piping through an internal `TransformStream` (chunks are UTF-8 encoded
|
|
323
|
+
* bytes, the same as `pipeTo` writes) and the stream is cached, so
|
|
324
|
+
* repeated access returns the same instance. Like `pipe`/`pipeTo`, this
|
|
325
|
+
* consumes the render: use exactly one of the three — mixing distinct
|
|
326
|
+
* consumers (`readable` after `pipe`/`pipeTo`, or vice versa) throws an
|
|
327
|
+
* error naming the conflict.
|
|
328
|
+
*/
|
|
329
|
+
readonly readable: ReadableStream<Uint8Array>;
|
|
330
|
+
};
|
|
331
|
+
export declare function HydrationScript(props: {
|
|
332
|
+
nonce?: string;
|
|
333
|
+
eventNames?: string[];
|
|
334
|
+
}): JSX.Element;
|
|
335
|
+
export declare function ssrGroup<T extends () => any[]>(fn: T, n: number): T;
|
|
336
|
+
/**
|
|
337
|
+
* The live-hole engine for one frame response. Constructed by the frame
|
|
338
|
+
* renderer (frame-sink) and published on the render context; `ssr()` and
|
|
339
|
+
* `resolveSSRNode` route content holes through `content()` while it is
|
|
340
|
+
* present. Bindings live in the sink's DR-2 ledger — same commit-driven
|
|
341
|
+
* sweeps, same equality gating, same end-of-response latch as watched slot
|
|
342
|
+
* args.
|
|
343
|
+
*
|
|
344
|
+
* Every state transition is commit-driven: the engine never chains its own
|
|
345
|
+
* promises, so it cannot amplify commits or starve the event loop — a
|
|
346
|
+
* pending re-evaluation simply waits for the next commit (async settles
|
|
347
|
+
* commit through the render core, and the response's end-latch sweep is
|
|
348
|
+
* always the last one).
|
|
349
|
+
*/
|
|
350
|
+
export declare function createLiveHoles(sink: any, scoped: any): {
|
|
351
|
+
suppressed: number;
|
|
352
|
+
sweeping: boolean;
|
|
353
|
+
parent: any;
|
|
354
|
+
recordStamp: number;
|
|
355
|
+
gateHit: boolean;
|
|
356
|
+
/**
|
|
357
|
+
* Intercept a thunk content hole: resolve it, and — when the evaluation
|
|
358
|
+
* proves re-runnable — mint an id, wrap the output in its marker pair,
|
|
359
|
+
* and open the ledger binding. Returns a string (sync resolve), a
|
|
360
|
+
* marker-wrapped `{ t, h, p }` template (NotReady escalation — markers
|
|
361
|
+
* ride the template so the retry's splice lands inside them), an
|
|
362
|
+
* UNMARKED string/template (latched: slot positions, impure
|
|
363
|
+
* evaluations), or null when interception is off for this evaluation.
|
|
364
|
+
*/
|
|
365
|
+
content(hole: any): any;
|
|
366
|
+
/** The shared id counter — `ssr()` mints an attr address at injection
|
|
367
|
+
* time, before its capture completes. */
|
|
368
|
+
mint(): number;
|
|
369
|
+
/** Whether interception may arm at the current evaluation point —
|
|
370
|
+
* `ssr()` asks before opening an attr capture (the `data-lha`
|
|
371
|
+
* injection must not touch out-of-scope bytes; content holes are
|
|
372
|
+
* gated inside `content()` itself). */
|
|
373
|
+
active(): boolean;
|
|
374
|
+
/**
|
|
375
|
+
* Register an element's attr-hole capture (built by `ssr()`'s in-tag
|
|
376
|
+
* scan): the tag's attribute area as alternating static strings and
|
|
377
|
+
* re-runnable parts (`{ f }` thunks, `{ g, i }` group positions). Sweeps
|
|
378
|
+
* rebuild the text, equality-gate against the baseline, and ship
|
|
379
|
+
* changes as an element-keyed `attr` chunk. Names that vanish between
|
|
380
|
+
* rebuilds ride an explicit `removed` list where the server holds the
|
|
381
|
+
* previous text; the client also matches the element to the whole
|
|
382
|
+
* text (the morph's rule), so a resume's re-emission — previous text
|
|
383
|
+
* known only as a digest, no list — removes them too.
|
|
384
|
+
*/
|
|
385
|
+
attr(cap: any): void;
|
|
386
|
+
};
|
|
387
|
+
export declare function ssr(template: string[] | string, ...nodes: any[]): {
|
|
388
|
+
t: string;
|
|
389
|
+
};
|
|
390
|
+
export declare function ssrClassName(value: string | {
|
|
391
|
+
[k: string]: boolean;
|
|
392
|
+
} | Array<any>): string;
|
|
393
|
+
export declare function ssrStyle(value: string | {
|
|
394
|
+
[k: string]: string;
|
|
395
|
+
}): string;
|
|
396
|
+
export declare function ssrStyleProperty(name: string, value: any): string;
|
|
397
|
+
export declare function ssrElement(name: string, props: any | any[] | (() => any | any[]), children: any, needsId: boolean, skip?: (key: string) => boolean, attrs?: string | (() => string)): {
|
|
398
|
+
t: string;
|
|
399
|
+
};
|
|
400
|
+
export declare function ssrElementAttribute(key: string, value: any): string;
|
|
401
|
+
export declare function ssrAttribute(key: string, value: any): string;
|
|
402
|
+
export declare function ssrHydrationKey(): string;
|
|
403
|
+
export declare const CLAIM_PROP: unique symbol;
|
|
404
|
+
export declare const CLAIMS_STREAM = 1;
|
|
405
|
+
export declare const CLAIMS_DOCUMENT = 2;
|
|
406
|
+
export declare function ssrClaim(map: any): string;
|
|
407
|
+
export declare function ssrSelectValues(): void;
|
|
408
|
+
export declare function resolveSSRSelectValues(html: any): any;
|
|
409
|
+
export declare function escape(s: any, attr?: boolean): any;
|
|
410
|
+
export declare function getHydrationKey(): string | undefined;
|
|
411
|
+
export declare function applyRef(r: ((element: any) => void) | ((element: any) => void)[], element: any): void;
|
|
412
|
+
export declare function generateHydrationScript(options?: {
|
|
413
|
+
nonce?: string;
|
|
414
|
+
eventNames?: string[];
|
|
415
|
+
}): string;
|
|
416
|
+
export declare function resolveSSRNode(node: any, result?: any, top?: boolean, nested?: boolean): any;
|
|
417
|
+
export declare const RequestContext: unique symbol; /**
|
|
418
|
+
* Where a server-side failure was met, as the server error hook hears it.
|
|
419
|
+
*
|
|
420
|
+
* `kind: "render"` — `fallback`: an `<Errored>` rendered its fallback;
|
|
421
|
+
* `client`: a `<Loading>` fragment rejected and the client re-renders the
|
|
422
|
+
* subtree; `failed`: nothing contained it and the request fails;
|
|
423
|
+
* `serialize`: a hydration value would not serialize and the render went on
|
|
424
|
+
* without it (a render that passed `onError`). `kind: "server-function"` — `thrown`:
|
|
425
|
+
* the body threw; `channel`: a rejection or throw escaping through the
|
|
426
|
+
* result graph (a promise, an iterable, a stream) with the head already
|
|
427
|
+
* committed. `boundary` is the hydration id the boundary records and
|
|
428
|
+
* findings use; `ownerPath` is where the error was THROWN — the component
|
|
429
|
+
* labels root-first up the owner chain it escaped, when the compiler emitted
|
|
430
|
+
* them — and `boundaryPath` where it was MET, the same labels up the
|
|
431
|
+
* boundary's chain (what broke, and what the user saw); `functionId`/`direct`
|
|
432
|
+
* name the server function and whether it was an in-process call during
|
|
433
|
+
* SSR; `event` the request, when the failure happened inside one.
|
|
434
|
+
*/
|
|
435
|
+
export interface ServerErrorContext extends Omit<ServerErrorSite, "event"> {
|
|
436
|
+
event?: RequestEvent;
|
|
437
|
+
}
|
|
406
438
|
/**
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
439
|
+
* The server error hook (see `configureServerErrors`): every failure the
|
|
440
|
+
* server runtime handles or fails on, once per error object, with where it
|
|
441
|
+
* was met. Return the value the client should receive in place of the error
|
|
442
|
+
* — rendered into the fallback, serialized for hydration, sent as the RPC
|
|
443
|
+
* error — or nothing for the default policy (a generic `Error` outside the
|
|
444
|
+
* dev build, the error itself in it; `markSafeError` still passes through).
|
|
445
|
+
* A returned value is taken as intended client-facing content and is not
|
|
446
|
+
* sanitized again. Ignored for `handling: "failed"`, which has no wire.
|
|
447
|
+
*
|
|
448
|
+
* One road a mapping does not reach: a rejected async source's serialized
|
|
449
|
+
* rejection is encoded the moment the source rejects, ahead of the boundary
|
|
450
|
+
* that meets the failure, and carries the default policy's value there. The
|
|
451
|
+
* hydrating client renders from the boundary's record, which carries the
|
|
452
|
+
* mapping; no tick is added to the error path to make the two agree.
|
|
411
453
|
*/
|
|
412
|
-
export
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
) => Promise<Response>;
|
|
418
|
-
|
|
419
|
-
export function untrack<T>(fn: () => T): T;
|
|
420
|
-
|
|
421
|
-
// client-only APIs
|
|
422
|
-
|
|
423
|
-
/** @deprecated not supported on the server side */
|
|
424
|
-
export function style(
|
|
425
|
-
node: Element,
|
|
426
|
-
value: { [k: string]: string },
|
|
427
|
-
prev?: { [k: string]: string }
|
|
428
|
-
): void;
|
|
429
|
-
|
|
430
|
-
/** @deprecated not supported on the server side */
|
|
431
|
-
export function insert<T>(
|
|
432
|
-
parent: MountableElement,
|
|
433
|
-
accessor: (() => T) | T,
|
|
434
|
-
marker?: Node | null,
|
|
435
|
-
init?: JSX.Element
|
|
436
|
-
): JSX.Element;
|
|
437
|
-
|
|
438
|
-
/** @deprecated not supported on the server side */
|
|
439
|
-
export function spread<T>(node: Element, accessor: T, skipChildren?: Boolean): void;
|
|
440
|
-
|
|
441
|
-
/** @deprecated not supported on the server side */
|
|
442
|
-
export function delegateEvents(eventNames: string[]): void;
|
|
443
|
-
/** @deprecated not supported on the server side */
|
|
444
|
-
export function registerDelegatedRoot(root: MountableElement): void;
|
|
445
|
-
/** @deprecated not supported on the server side */
|
|
446
|
-
export function unregisterDelegatedRoot(root: MountableElement): void;
|
|
447
|
-
/** @deprecated not supported on the server side */
|
|
448
|
-
export function registerDelegatedContainer(
|
|
449
|
-
container: MountableElement,
|
|
450
|
-
owner?: MountableElement
|
|
451
|
-
): void;
|
|
452
|
-
/** @deprecated not supported on the server side */
|
|
453
|
-
export function unregisterDelegatedContainer(
|
|
454
|
-
container: MountableElement,
|
|
455
|
-
owner?: MountableElement
|
|
456
|
-
): void;
|
|
457
|
-
/** @deprecated not supported on the server side */
|
|
458
|
-
export function getDelegatedRoot(node: MountableElement): MountableElement | undefined;
|
|
459
|
-
/** @deprecated not supported on the server side */
|
|
460
|
-
export function dynamicProperty(props: unknown, key: string): unknown;
|
|
461
|
-
/** @deprecated not supported on the server side */
|
|
462
|
-
export function setAttribute(node: Element, name: string, value: string): void;
|
|
463
|
-
/** @deprecated not supported on the server side */
|
|
464
|
-
export function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
|
|
465
|
-
|
|
454
|
+
export type ServerErrorHook = (error: unknown, context: ServerErrorContext) => unknown | void;
|
|
455
|
+
export interface ServerErrorsConfig {
|
|
456
|
+
/** The hook, or `undefined` to clear it. */
|
|
457
|
+
onError?: ServerErrorHook;
|
|
458
|
+
}
|
|
466
459
|
/**
|
|
467
|
-
*
|
|
468
|
-
*
|
|
460
|
+
* Registers the ambient server error hook — the one call a server
|
|
461
|
+
* `init()` makes to see every failure the runtime handles in production:
|
|
462
|
+
* an `<Errored>` fallback rendered, a `<Loading>` fragment rejected, a
|
|
463
|
+
* server-function throw (HTTP dispatch or an in-process call during SSR),
|
|
464
|
+
* the failure that fails a request. Called once per error object, at first
|
|
465
|
+
* sight, wherever the runtime met it; its return, when given, is the wire
|
|
466
|
+
* value (see `ServerErrorHook`). A per-request hook — `renderToStream`'s
|
|
467
|
+
* `onError`, the server-function handler's — overrides it for that
|
|
468
|
+
* request. Registered on `globalThis` under a registered symbol, so a
|
|
469
|
+
* bundled server build and an instrumented `--import`ed module share it.
|
|
470
|
+
*
|
|
471
|
+
* ```ts
|
|
472
|
+
* configureServerErrors({
|
|
473
|
+
* onError: (error, { kind, handling, boundary, functionId }) => {
|
|
474
|
+
* Sentry.captureException(error, {
|
|
475
|
+
* mechanism: { type: `solid.${kind}.${handling}`, handled: handling !== "failed" }
|
|
476
|
+
* });
|
|
477
|
+
* }
|
|
478
|
+
* });
|
|
479
|
+
* ```
|
|
469
480
|
*/
|
|
470
|
-
export function
|
|
471
|
-
/** Server no-op: returns `node` unchanged. Claims never fire during SSR. */
|
|
472
|
-
export function claimElement<T extends Element>(node: T): T;
|
|
473
|
-
/** Server no-op: returns `root` unchanged. Claims never fire during SSR. */
|
|
474
|
-
export function claimElementTree<T extends Node>(root: T): T;
|
|
475
|
-
|
|
476
|
-
/** @deprecated not supported on the server side */
|
|
477
|
-
export function addEvent(node: Element, name: string, handler: () => void, delegate: boolean): void;
|
|
478
|
-
|
|
479
|
-
/** @deprecated not supported on the server side */
|
|
480
|
-
export function render(code: () => JSX.Element, element: MountableElement): () => void;
|
|
481
|
+
export declare function configureServerErrors(config: ServerErrorsConfig): void;
|
|
481
482
|
/**
|
|
482
|
-
*
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
* - `2` — the template html is wrapped; the outer tag is stripped at clone time.
|
|
483
|
+
* The current request event, when called on the server inside a request
|
|
484
|
+
* scope (established by `provideRequestEvent` from `@solidjs/web/storage`
|
|
485
|
+
* or by the framework). Undefined on the client and outside a request.
|
|
486
|
+
* Read it above `await` boundaries in partially-polyfilled environments.
|
|
487
487
|
*/
|
|
488
|
-
export function
|
|
489
|
-
/** @deprecated not supported on the server side */
|
|
490
|
-
export function setProperty(node: Element, name: string, value: any): void;
|
|
491
|
-
/** @deprecated not supported on the server side */
|
|
492
|
-
export function className(node: Element, value: string): void;
|
|
493
|
-
/** @deprecated not supported on the server side */
|
|
494
|
-
export function assign(node: Element, props: any, skipChildren?: Boolean): void;
|
|
495
|
-
|
|
496
|
-
/** @deprecated not supported on the server side */
|
|
497
|
-
export function hydrate(
|
|
498
|
-
fn: () => JSX.Element,
|
|
499
|
-
node: MountableElement,
|
|
500
|
-
options?: { renderId?: string; owner?: unknown }
|
|
501
|
-
): () => void;
|
|
502
|
-
|
|
503
|
-
/** @deprecated not supported on the server side */
|
|
504
|
-
export function getNextElement(template?: () => Element): Element;
|
|
505
|
-
/** @deprecated not supported on the server side */
|
|
506
|
-
export function getNextMatch(start: Node, elementName: string): Element;
|
|
507
|
-
/** @deprecated not supported on the server side */
|
|
508
|
-
export function getNextMarker(start: Node): [Node, Array<Node>];
|
|
509
|
-
/** @deprecated not supported on the server side */
|
|
510
|
-
export function runHydrationEvents(): void;
|
|
511
|
-
/** @deprecated not supported on the server side */
|
|
512
|
-
export function ref(
|
|
513
|
-
fn: () => ((element: Element) => void) | ((element: Element) => void)[],
|
|
514
|
-
element: Element
|
|
515
|
-
): void;
|
|
516
|
-
/** @deprecated not supported on the server side */
|
|
517
|
-
export function setStyleProperty(node: Element, name: string, value: any): void;
|
|
488
|
+
export declare function getRequestEvent(): RequestEvent | undefined;
|
|
518
489
|
/**
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
490
|
+
* The trace the current request belongs to — continued from the incoming
|
|
491
|
+
* W3C `traceparent` when there was one, originated by the runtime
|
|
492
|
+
* otherwise; in observe/dev builds, merged with the installed provider's
|
|
493
|
+
* answer (`OBSERVE.server.trace`). Same object for every read within the
|
|
494
|
+
* request, direct server-function calls included. For a render outside a
|
|
495
|
+
* request scope, the render's own trace. `undefined` outside both, and on
|
|
496
|
+
* the client. Forward it downstream from a server function with
|
|
497
|
+
* `getTraceContext()?.entries.traceparent`.
|
|
522
498
|
*/
|
|
523
|
-
export function
|
|
499
|
+
export declare function getTraceContext(): TraceContext | undefined;
|
|
500
|
+
/** A fresh, uncommitted response head. */
|
|
501
|
+
export declare function createResponseStub(): ResponseStub;
|
|
502
|
+
export declare function createRequestEvent<T extends object = {}>(request: Request, init?: T): RequestEvent & {
|
|
503
|
+
response: ResponseStub;
|
|
504
|
+
} & T;
|
|
505
|
+
export declare function commitResponseStub(stub: ResponseStub, options?: {
|
|
506
|
+
allowLateLocation?: boolean;
|
|
507
|
+
event?: RequestEvent;
|
|
508
|
+
}): ResponseStub;
|
|
509
|
+
export declare function getExpectedRedirectStatus(response: ResponseStub): number;
|
|
510
|
+
export declare function commitEventResponse(response: Response, event?: RequestEvent): Response;
|
|
511
|
+
export declare function createSSRResponse(result: string, event: RequestEvent | undefined, options?: SSRResponseOptions): Response;
|
|
512
|
+
export declare function createSSRResponse(result: {
|
|
513
|
+
pipe(writable: {
|
|
514
|
+
write: (v: string) => void;
|
|
515
|
+
end: () => void;
|
|
516
|
+
}): void;
|
|
517
|
+
}, event: RequestEvent | undefined, options?: SSRResponseOptions): Promise<Response>;
|
|
518
|
+
export declare function composeMiddleware(middlewares: FetchMiddleware[]): (request: Request, next: (request?: Request) => Response | Promise<Response>) => Promise<Response>;
|
|
519
|
+
export declare function registerElementClaim(handler: (element: Element) => void): () => void;
|
|
520
|
+
export declare function claimElement<T extends Element>(node: T): T;
|
|
521
|
+
export declare function claimElementTree<T extends Node>(root: T): T;
|
|
522
|
+
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 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 };
|
|
523
|
+
declare function notSup(): void;
|