Repository navigation
Expand file tree
/
Copy pathvirtual-modules.d.ts
More file actions
112 lines (106 loc) · 5.3 KB
/
Copy pathvirtual-modules.d.ts
File metadata and controls
112 lines (106 loc) · 5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
declare module "virtual:solid-manifest" {
import type { DevAssetResolver, ViteManifest } from "@solidjs/vite-plugin";
/**
* In an SSR build, the parsed client manifest. In dev (and in an SSR build
* that runs before any client manifest exists), the live asset resolver.
* Either one can be passed to `renderToStream`'s `manifest` option as is;
* `if (manifest.resolve)` tells them apart.
*/
const manifest: ViteManifest | DevAssetResolver;
export default manifest;
}
// Side-effect module: importing it loads every module containing server
// functions so their registrations exist before requests are dispatched.
declare module "virtual:solid-server-function-manifest" {}
// Server-only handler (SSR builds). Importing it registers every
// server function (via the manifest above), scopes each request with
// provideRequestEvent, and configures the endpoint; mount
// `handleServerFunctionRequest` on the endpoint in your server.
declare module "virtual:solid-server-function-handler" {
import type { HandleServerFunctionOptions } from "@solidjs/web/server-functions/server";
/** The resolved endpoint path (plugin `endpoint` option joined with Vite `base`). */
export const endpoint: string;
/**
* The runtime's handler options (passed through; a custom
* `serverFunctions.runtime` can augment `HandleServerFunctionOptions` with
* its own), plus `event`.
*/
export type ServerFunctionRequestOptions = HandleServerFunctionOptions & {
/**
* Extra fields spread into the request event at creation: the public
* wrapper-to-event extension seam, same as the SSR handler's
* `handleRequest`. Conventionally `nativeEvent` carries the platform's
* raw request object (the plugin's dev middleware and a Node server
* entry pass the Node `IncomingMessage`); read it back with
* `getRequestEvent()`.
*/
event?: Record<string, unknown>;
};
export function handleServerFunctionRequest(
request: Request,
options?: ServerFunctionRequestOptions,
): Promise<Response>;
}
// Server-only start-mode request handler (the `start` option). It is the SSR
// build's entry, so a production server imports it from the built bundle
// (e.g. `./dist/server/server.js`) rather than by this id; importing the
// id directly also works from custom server code in SSR builds.
// Streams the rendered app for a web Request, scopes it with
// provideRequestEvent, resolves hashed client assets through the build
// manifest, and — when `serverFunctions` is enabled — serves the
// server-function endpoint ahead of SSR.
declare module "virtual:solid-ssr-handler" {
import type { CSPNonce } from "@solidjs/web";
import type { ServerFunctionRequestOptions } from "virtual:solid-server-function-handler";
export function handleRequest(
request: Request,
options?: {
/** Override the resolved client entry URL injected into the document. */
clientEntry?: string;
/** Extra fields merged into the `context` passed to the entry's `render`. */
context?: Record<string, unknown>;
/** Status/headers for the HTML response. */
responseInit?: ResponseInit;
/**
* Per-call CSP nonce, in `@solidjs/web`'s `CSPNonce` shape. Seeded onto
* the request event as `event.nonce` before the middleware chain runs
* (so middleware can read it) and reasserted at the page render, so it
* wins over a middleware write. It reaches every tag the render emits
* (hydration bootstrap, streamed data and swap scripts, preloads,
* styles), the injected client-entry tag, the post-flush redirect
* fallback and the `csp-nonce` meta. `null` or `''` renders without
* one. Any value outside `CSPNonce` rejects the call before the chain
* runs.
*/
nonce?: CSPNonce | null;
/**
* Per-call render mode, seeded onto the request event as
* `event.renderMode` like `nonce`, and winning over both a middleware
* write and `start.renderMode`. `'stream'` flushes the document shell
* with `<Loading>` fallbacks and streams boundary content behind it;
* `'async'` awaits the render until every boundary settled and sends
* one complete document — no fallbacks, no swap scripts, hydration
* data intact — for clients that never run JavaScript. A mid-render
* `Location` becomes a real 3xx under `'async'`.
*/
renderMode?: 'stream' | 'async';
/**
* Extra fields spread into the request event at creation — the public
* wrapper→event extension seam. Conventionally `nativeEvent` carries
* the platform's raw request object; the plugin's dev/preview
* middlewares (and, by convention, a custom Node server entry) pass
* the Node `IncomingMessage` here, so `getRequestEvent().nativeEvent`
* answers the same on every surface. Read it back anywhere inside the
* request scope with `getRequestEvent()`.
*/
event?: Record<string, unknown>;
/** Options forwarded to the server-function handler for endpoint requests. */
serverFunctions?: ServerFunctionRequestOptions;
},
): Promise<Response>;
/** Fetchable entry for runtimes and deployment integrations that use the web-standard convention. */
const handler: {
fetch(request: Request): Promise<Response>;
};
export default handler;
}