@sveltejs/kit 1.0.0-next.34 → 1.0.0-next.342

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.
Files changed (73) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +16 -0
  3. package/assets/app/navigation.js +24 -0
  4. package/assets/app/paths.js +1 -0
  5. package/assets/app/stores.js +97 -0
  6. package/assets/client/singletons.js +13 -0
  7. package/assets/client/start.js +1782 -0
  8. package/assets/components/error.svelte +18 -2
  9. package/assets/env.js +8 -0
  10. package/assets/paths.js +13 -0
  11. package/assets/server/index.js +3367 -0
  12. package/dist/chunks/cert.js +28154 -0
  13. package/dist/chunks/constants.js +663 -0
  14. package/dist/chunks/filesystem.js +110 -0
  15. package/dist/chunks/index.js +549 -0
  16. package/dist/chunks/index2.js +1385 -0
  17. package/dist/chunks/index3.js +118 -0
  18. package/dist/chunks/index4.js +183 -0
  19. package/dist/chunks/index5.js +253 -0
  20. package/dist/chunks/index6.js +15749 -0
  21. package/dist/chunks/misc.js +78 -0
  22. package/dist/chunks/multipart-parser.js +450 -0
  23. package/dist/chunks/object.js +83 -0
  24. package/dist/chunks/sync.js +858 -0
  25. package/dist/chunks/write_tsconfig.js +160 -0
  26. package/dist/cli.js +1097 -64
  27. package/dist/hooks.js +28 -0
  28. package/dist/node/polyfills.js +6514 -0
  29. package/dist/node.js +301 -0
  30. package/package.json +80 -62
  31. package/svelte-kit.js +0 -1
  32. package/types/ambient.d.ts +307 -0
  33. package/types/index.d.ts +292 -0
  34. package/types/internal.d.ts +321 -0
  35. package/types/private.d.ts +235 -0
  36. package/CHANGELOG.md +0 -362
  37. package/assets/runtime/app/navigation.js +0 -23
  38. package/assets/runtime/app/navigation.js.map +0 -1
  39. package/assets/runtime/app/paths.js +0 -2
  40. package/assets/runtime/app/paths.js.map +0 -1
  41. package/assets/runtime/app/stores.js +0 -78
  42. package/assets/runtime/app/stores.js.map +0 -1
  43. package/assets/runtime/internal/singletons.js +0 -15
  44. package/assets/runtime/internal/singletons.js.map +0 -1
  45. package/assets/runtime/internal/start.js +0 -591
  46. package/assets/runtime/internal/start.js.map +0 -1
  47. package/assets/runtime/utils-85ebcc60.js +0 -18
  48. package/assets/runtime/utils-85ebcc60.js.map +0 -1
  49. package/dist/api.js +0 -32
  50. package/dist/api.js.map +0 -1
  51. package/dist/cli.js.map +0 -1
  52. package/dist/create_app.js +0 -577
  53. package/dist/create_app.js.map +0 -1
  54. package/dist/index.js +0 -329
  55. package/dist/index.js.map +0 -1
  56. package/dist/index2.js +0 -14368
  57. package/dist/index2.js.map +0 -1
  58. package/dist/index3.js +0 -545
  59. package/dist/index3.js.map +0 -1
  60. package/dist/index4.js +0 -71
  61. package/dist/index4.js.map +0 -1
  62. package/dist/index5.js +0 -465
  63. package/dist/index5.js.map +0 -1
  64. package/dist/index6.js +0 -729
  65. package/dist/index6.js.map +0 -1
  66. package/dist/renderer.js +0 -2413
  67. package/dist/renderer.js.map +0 -1
  68. package/dist/standard.js +0 -100
  69. package/dist/standard.js.map +0 -1
  70. package/dist/utils.js +0 -57
  71. package/dist/utils.js.map +0 -1
  72. package/dist/vite.js +0 -317
  73. package/dist/vite.js.map +0 -1
@@ -0,0 +1,307 @@
1
+ /**
2
+ * It's possible to tell SvelteKit how to type objects inside your app by declaring the `App` namespace. By default, a new project will have a file called `src/app.d.ts` containing the following:
3
+ *
4
+ * ```ts
5
+ * /// <reference types="@sveltejs/kit" />
6
+ *
7
+ * declare namespace App {
8
+ * interface Locals {}
9
+ *
10
+ * interface Platform {}
11
+ *
12
+ * interface Session {}
13
+ *
14
+ * interface Stuff {}
15
+ * }
16
+ * ```
17
+ *
18
+ * By populating these interfaces, you will gain type safety when using `event.locals`, `event.platform`, `session` and `stuff`.
19
+ *
20
+ * Note that since it's an ambient declaration file, you can't use `import` statements — instead, use the `import(...)` function:
21
+ *
22
+ * ```ts
23
+ * interface Locals {
24
+ * user: import('$lib/types').User;
25
+ * }
26
+ * ```
27
+ */
28
+ declare namespace App {
29
+ /**
30
+ * The interface that defines `event.locals`, which can be accessed in [hooks](/docs/hooks) (`handle`, `handleError` and `getSession`) and [endpoints](/docs/routing#endpoints).
31
+ */
32
+ export interface Locals {}
33
+
34
+ /**
35
+ * If your adapter provides [platform-specific context](/docs/adapters#supported-environments-platform-specific-context) via `event.platform`, you can specify it here.
36
+ */
37
+ export interface Platform {}
38
+
39
+ /**
40
+ * The interface that defines `session`, both as an argument to [`load`](/docs/loading) functions and the value of the [session store](/docs/modules#$app-stores).
41
+ */
42
+ export interface Session {}
43
+
44
+ /**
45
+ * The interface that defines `stuff`, as input or output to [`load`](/docs/loading) or as the value of the `stuff` property of the [page store](/docs/modules#$app-stores).
46
+ */
47
+ export interface Stuff {}
48
+ }
49
+
50
+ /**
51
+ * ```ts
52
+ * import { browser, dev, mode, prerendering } from '$app/env';
53
+ * ```
54
+ */
55
+ declare module '$app/env' {
56
+ /**
57
+ * Whether the app is running in the browser or on the server.
58
+ */
59
+ export const browser: boolean;
60
+ /**
61
+ * `true` in development mode, `false` in production.
62
+ */
63
+ export const dev: boolean;
64
+ /**
65
+ * `true` when prerendering, `false` otherwise.
66
+ */
67
+ export const prerendering: boolean;
68
+ /**
69
+ * The Vite.js mode the app is running in. Configure in `config.kit.vite.mode`.
70
+ * Vite.js loads the dotenv file associated with the provided mode, `.env.[mode]` or `.env.[mode].local`.
71
+ * By default, `svelte-kit dev` runs with `mode=development` and `svelte-kit build` runs with `mode=production`.
72
+ */
73
+ export const mode: string;
74
+ }
75
+
76
+ /**
77
+ * ```ts
78
+ * import {
79
+ * afterNavigate,
80
+ * beforeNavigate,
81
+ * disableScrollHandling,
82
+ * goto,
83
+ * invalidate,
84
+ * prefetch,
85
+ * prefetchRoutes
86
+ * } from '$app/navigation';
87
+ * ```
88
+ */
89
+ declare module '$app/navigation' {
90
+ /**
91
+ * If called when the page is being updated following a navigation (in `onMount` or `afterNavigate` or an action, for example), this disables SvelteKit's built-in scroll handling.
92
+ * This is generally discouraged, since it breaks user expectations.
93
+ */
94
+ export function disableScrollHandling(): void;
95
+ /**
96
+ * Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `href`.
97
+ *
98
+ * @param href Where to navigate to
99
+ * @param opts.replaceState If `true`, will replace the current `history` entry rather than creating a new one with `pushState`
100
+ * @param opts.noscroll If `true`, the browser will maintain its scroll position rather than scrolling to the top of the page after navigation
101
+ * @param opts.keepfocus If `true`, the currently focused element will retain focus after navigation. Otherwise, focus will be reset to the body
102
+ * @param opts.state The state of the new/updated history entry
103
+ */
104
+ export function goto(
105
+ href: string,
106
+ opts?: { replaceState?: boolean; noscroll?: boolean; keepfocus?: boolean; state?: any }
107
+ ): Promise<void>;
108
+ /**
109
+ * Causes any `load` functions belonging to the currently active page to re-run if they `fetch` the resource in question. Returns a `Promise` that resolves when the page is subsequently updated.
110
+ * @param dependency The invalidated resource
111
+ */
112
+ export function invalidate(dependency: string | ((href: string) => boolean)): Promise<void>;
113
+ /**
114
+ * Programmatically prefetches the given page, which means
115
+ * 1. ensuring that the code for the page is loaded, and
116
+ * 2. calling the page's load function with the appropriate options.
117
+ *
118
+ * This is the same behaviour that SvelteKit triggers when the user taps or mouses over an `<a>` element with `sveltekit:prefetch`.
119
+ * If the next navigation is to `href`, the values returned from load will be used, making navigation instantaneous.
120
+ * Returns a Promise that resolves when the prefetch is complete.
121
+ *
122
+ * @param href Page to prefetch
123
+ */
124
+ export function prefetch(href: string): Promise<void>;
125
+ /**
126
+ * Programmatically prefetches the code for routes that haven't yet been fetched.
127
+ * Typically, you might call this to speed up subsequent navigation.
128
+ *
129
+ * If no argument is given, all routes will be fetched, otherwise you can specify routes by any matching pathname
130
+ * such as `/about` (to match `src/routes/about.svelte`) or `/blog/*` (to match `src/routes/blog/[slug].svelte`).
131
+ *
132
+ * Unlike prefetch, this won't call load for individual pages.
133
+ * Returns a Promise that resolves when the routes have been prefetched.
134
+ */
135
+ export function prefetchRoutes(routes?: string[]): Promise<void>;
136
+
137
+ /**
138
+ * A navigation interceptor that triggers before we navigate to a new URL (internal or external) whether by clicking a link, calling `goto`, or using the browser back/forward controls.
139
+ * This is helpful if we want to conditionally prevent a navigation from completing or lookup the upcoming url.
140
+ */
141
+ export function beforeNavigate(
142
+ fn: (navigation: { from: URL; to: URL | null; cancel: () => void }) => void
143
+ ): void;
144
+
145
+ /**
146
+ * A lifecycle function that runs when the page mounts, and also whenever SvelteKit navigates to a new URL but stays on this component.
147
+ */
148
+ export function afterNavigate(fn: (navigation: { from: URL | null; to: URL }) => void): void;
149
+ }
150
+
151
+ /**
152
+ * ```ts
153
+ * import { base, assets } from '$app/paths';
154
+ * ```
155
+ */
156
+ declare module '$app/paths' {
157
+ /**
158
+ * A string that matches [`config.kit.paths.base`](/docs/configuration#paths). It must start, but not end with `/` (e.g. `/base-path`), unless it is the empty string.
159
+ */
160
+ export const base: `/${string}`;
161
+ /**
162
+ * An absolute path that matches [`config.kit.paths.assets`](/docs/configuration#paths).
163
+ *
164
+ * > If a value for `config.kit.paths.assets` is specified, it will be replaced with `'/_svelte_kit_assets'` during [`svelte-kit dev`](/docs/cli#svelte-kit-dev) or [`svelte-kit preview`](/docs/cli#svelte-kit-preview), since the assets don't yet live at their eventual URL.
165
+ */
166
+ export const assets: `https://${string}` | `http://${string}`;
167
+ }
168
+
169
+ /**
170
+ * ```ts
171
+ * import { getStores, navigating, page, session, updated } from '$app/stores';
172
+ * ```
173
+ *
174
+ * Stores are _contextual_ — they are added to the [context](https://svelte.dev/tutorial/context-api) of your root component. This means that `session` and `page` are unique to each request on the server, rather than shared between multiple requests handled by the same server simultaneously, which is what makes it safe to include user-specific data in `session`.
175
+ *
176
+ * Because of that, you must subscribe to the stores during component initialization (which happens automatically if you reference the store value, e.g. as `$page`, in a component) before you can use them.
177
+ */
178
+ declare module '$app/stores' {
179
+ import { Readable, Writable } from 'svelte/store';
180
+ import { Navigation, Page } from '@sveltejs/kit';
181
+
182
+ /**
183
+ * A convenience function around `getContext`. Must be called during component initialization.
184
+ * Only use this if you need to defer store subscription until after the component has mounted, for some reason.
185
+ */
186
+ export function getStores(): {
187
+ navigating: typeof navigating;
188
+ page: typeof page;
189
+ session: typeof session;
190
+ updated: typeof updated;
191
+ };
192
+
193
+ /**
194
+ * A readable store whose value contains page data.
195
+ */
196
+ export const page: Readable<Page>;
197
+ /**
198
+ * A readable store.
199
+ * When navigating starts, its value is `{ from: URL, to: URL }`,
200
+ * When navigating finishes, its value reverts to `null`.
201
+ */
202
+ export const navigating: Readable<Navigation | null>;
203
+ /**
204
+ * A writable store whose initial value is whatever was returned from [`getSession`](/docs/hooks#getsession).
205
+ * It can be written to, but this will not cause changes to persist on the server — this is something you must implement yourself.
206
+ */
207
+ export const session: Writable<App.Session>;
208
+ /**
209
+ * A readable store whose initial value is `false`. If [`version.pollInterval`](/docs/configuration#version) is a non-zero value, SvelteKit will poll for new versions of the app and update the store value to `true` when it detects one. `updated.check()` will force an immediate check, regardless of polling.
210
+ */
211
+ export const updated: Readable<boolean> & { check: () => boolean };
212
+ }
213
+
214
+ /**
215
+ * ```ts
216
+ * import { build, files, prerendered, version } from '$service-worker';
217
+ * ```
218
+ *
219
+ * This module is only available to [service workers](/docs/service-workers).
220
+ */
221
+ declare module '$service-worker' {
222
+ /**
223
+ * An array of URL strings representing the files generated by Vite, suitable for caching with `cache.addAll(build)`.
224
+ */
225
+ export const build: string[];
226
+ /**
227
+ * An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.kit.files.assets`. You can customize which files are included from `static` directory using [`config.kit.serviceWorker.files`](/docs/configuration)
228
+ */
229
+ export const files: string[];
230
+ /**
231
+ * An array of pathnames corresponding to prerendered pages and endpoints.
232
+ */
233
+ export const prerendered: string[];
234
+ /**
235
+ * See [`config.kit.version`](/docs/configuration#version). It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches.
236
+ */
237
+ export const version: string;
238
+ }
239
+
240
+ declare module '@sveltejs/kit/hooks' {
241
+ import { Handle } from '@sveltejs/kit';
242
+
243
+ /**
244
+ * A helper function for sequencing multiple `handle` calls in a middleware-like manner.
245
+ *
246
+ * ```js
247
+ * /// file: src/hooks.js
248
+ * import { sequence } from '@sveltejs/kit/hooks';
249
+ *
250
+ * /** @type {import('@sveltejs/kit').Handle} *\/
251
+ * async function first({ event, resolve }) {
252
+ * console.log('first pre-processing');
253
+ * const result = await resolve(event);
254
+ * console.log('first post-processing');
255
+ * return result;
256
+ * }
257
+ *
258
+ * /** @type {import('@sveltejs/kit').Handle} *\/
259
+ * async function second({ event, resolve }) {
260
+ * console.log('second pre-processing');
261
+ * const result = await resolve(event);
262
+ * console.log('second post-processing');
263
+ * return result;
264
+ * }
265
+ *
266
+ * export const handle = sequence(first, second);
267
+ * ```
268
+ *
269
+ * The example above would print:
270
+ *
271
+ * ```
272
+ * first pre-processing
273
+ * second pre-processing
274
+ * second post-processing
275
+ * first post-processing
276
+ * ```
277
+ *
278
+ * @param handlers The chain of `handle` functions
279
+ */
280
+ export function sequence(...handlers: Handle[]): Handle;
281
+ }
282
+
283
+ /**
284
+ * A polyfill for `fetch` and its related interfaces, used by adapters for environments that don't provide a native implementation.
285
+ */
286
+ declare module '@sveltejs/kit/node/polyfills' {
287
+ /**
288
+ * Make various web APIs available as globals:
289
+ * - `crypto`
290
+ * - `fetch`
291
+ * - `Headers`
292
+ * - `Request`
293
+ * - `Response`
294
+ */
295
+ export function installPolyfills(): void;
296
+ }
297
+
298
+ /**
299
+ * Utilities used by adapters for Node-like environments.
300
+ */
301
+ declare module '@sveltejs/kit/node' {
302
+ export function getRequest(
303
+ base: string,
304
+ request: import('http').IncomingMessage
305
+ ): Promise<Request>;
306
+ export function setResponse(res: import('http').ServerResponse, response: Response): void;
307
+ }
@@ -0,0 +1,292 @@
1
+ /// <reference types="svelte" />
2
+ /// <reference types="vite/client" />
3
+
4
+ import './ambient';
5
+
6
+ import { CompileOptions } from 'svelte/types/compiler/interfaces';
7
+ import {
8
+ AdapterEntry,
9
+ BodyValidator,
10
+ CspDirectives,
11
+ JSONValue,
12
+ Logger,
13
+ MaybePromise,
14
+ Prerendered,
15
+ PrerenderOnErrorValue,
16
+ RequestOptions,
17
+ ResponseHeaders,
18
+ RouteDefinition,
19
+ TrailingSlash
20
+ } from './private';
21
+ import { SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal';
22
+
23
+ export interface Adapter {
24
+ name: string;
25
+ adapt(builder: Builder): MaybePromise<void>;
26
+ }
27
+
28
+ export interface Builder {
29
+ log: Logger;
30
+ rimraf(dir: string): void;
31
+ mkdirp(dir: string): void;
32
+
33
+ config: ValidatedConfig;
34
+ prerendered: Prerendered;
35
+
36
+ /**
37
+ * Create entry points that map to individual functions
38
+ * @param fn A function that groups a set of routes into an entry point
39
+ */
40
+ createEntries(fn: (route: RouteDefinition) => AdapterEntry): Promise<void>;
41
+
42
+ generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
43
+
44
+ getBuildDirectory(name: string): string;
45
+ getClientDirectory(): string;
46
+ getServerDirectory(): string;
47
+ getStaticDirectory(): string;
48
+
49
+ /**
50
+ * @param dest the destination folder to which files should be copied
51
+ * @returns an array of paths corresponding to the files that have been created by the copy
52
+ */
53
+ writeClient(dest: string): string[];
54
+ /**
55
+ *
56
+ * @param dest
57
+ */
58
+ writePrerendered(
59
+ dest: string,
60
+ opts?: {
61
+ fallback?: string;
62
+ }
63
+ ): string[];
64
+ /**
65
+ * @param dest the destination folder to which files should be copied
66
+ * @returns an array of paths corresponding to the files that have been created by the copy
67
+ */
68
+ writeServer(dest: string): string[];
69
+ /**
70
+ * @param dest the destination folder to which files should be copied
71
+ * @returns an array of paths corresponding to the files that have been created by the copy
72
+ */
73
+ writeStatic(dest: string): string[];
74
+ /**
75
+ * @param from the source file or folder
76
+ * @param to the destination file or folder
77
+ * @param opts.filter a function to determine whether a file or folder should be copied
78
+ * @param opts.replace a map of strings to replace
79
+ * @returns an array of paths corresponding to the files that have been created by the copy
80
+ */
81
+ copy(
82
+ from: string,
83
+ to: string,
84
+ opts?: {
85
+ filter?: (basename: string) => boolean;
86
+ replace?: Record<string, string>;
87
+ }
88
+ ): string[];
89
+ }
90
+
91
+ export interface Config {
92
+ compilerOptions?: CompileOptions;
93
+ extensions?: string[];
94
+ kit?: {
95
+ adapter?: Adapter;
96
+ alias?: Record<string, string>;
97
+ appDir?: string;
98
+ browser?: {
99
+ hydrate?: boolean;
100
+ router?: boolean;
101
+ };
102
+ csp?: {
103
+ mode?: 'hash' | 'nonce' | 'auto';
104
+ directives?: CspDirectives;
105
+ };
106
+ endpointExtensions?: string[];
107
+ files?: {
108
+ assets?: string;
109
+ hooks?: string;
110
+ lib?: string;
111
+ params?: string;
112
+ routes?: string;
113
+ serviceWorker?: string;
114
+ template?: string;
115
+ };
116
+ floc?: boolean;
117
+ inlineStyleThreshold?: number;
118
+ methodOverride?: {
119
+ parameter?: string;
120
+ allowed?: string[];
121
+ };
122
+ outDir?: string;
123
+ package?: {
124
+ dir?: string;
125
+ emitTypes?: boolean;
126
+ exports?(filepath: string): boolean;
127
+ files?(filepath: string): boolean;
128
+ };
129
+ paths?: {
130
+ assets?: string;
131
+ base?: string;
132
+ };
133
+ prerender?: {
134
+ concurrency?: number;
135
+ crawl?: boolean;
136
+ default?: boolean;
137
+ enabled?: boolean;
138
+ entries?: Array<'*' | `/${string}`>;
139
+ onError?: PrerenderOnErrorValue;
140
+ };
141
+ routes?: (filepath: string) => boolean;
142
+ serviceWorker?: {
143
+ register?: boolean;
144
+ files?: (filepath: string) => boolean;
145
+ };
146
+ trailingSlash?: TrailingSlash;
147
+ version?: {
148
+ name?: string;
149
+ pollInterval?: number;
150
+ };
151
+ vite?: import('vite').UserConfig | (() => MaybePromise<import('vite').UserConfig>);
152
+ };
153
+ preprocess?: any;
154
+ }
155
+
156
+ export interface ExternalFetch {
157
+ (req: Request): Promise<Response>;
158
+ }
159
+
160
+ export interface GetSession {
161
+ (event: RequestEvent): MaybePromise<App.Session>;
162
+ }
163
+
164
+ export interface Handle {
165
+ (input: {
166
+ event: RequestEvent;
167
+ resolve(event: RequestEvent, opts?: ResolveOptions): MaybePromise<Response>;
168
+ }): MaybePromise<Response>;
169
+ }
170
+
171
+ export interface HandleError {
172
+ (input: { error: Error & { frame?: string }; event: RequestEvent }): void;
173
+ }
174
+
175
+ /**
176
+ * The `(event: LoadEvent) => LoadOutput` `load` function exported from `<script context="module">` in a page or layout.
177
+ *
178
+ * Note that you can use [generated types](/docs/types#generated-types) instead of manually specifying the Params generic argument.
179
+ */
180
+ export interface Load<
181
+ Params extends Record<string, string> = Record<string, string>,
182
+ InputProps extends Record<string, any> = Record<string, any>,
183
+ OutputProps extends Record<string, any> = InputProps
184
+ > {
185
+ (event: LoadEvent<Params, InputProps>): MaybePromise<LoadOutput<OutputProps>>;
186
+ }
187
+
188
+ export interface LoadEvent<
189
+ Params extends Record<string, string> = Record<string, string>,
190
+ Props extends Record<string, any> = Record<string, any>
191
+ > {
192
+ fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
193
+ params: Params;
194
+ props: Props;
195
+ routeId: string | null;
196
+ session: App.Session;
197
+ stuff: Partial<App.Stuff>;
198
+ url: URL;
199
+ status: number | null;
200
+ error: Error | null;
201
+ }
202
+
203
+ export interface LoadOutput<Props extends Record<string, any> = Record<string, any>> {
204
+ status?: number;
205
+ error?: string | Error;
206
+ redirect?: string;
207
+ props?: Props;
208
+ stuff?: Partial<App.Stuff>;
209
+ cache?: LoadOutputCache;
210
+ dependencies?: string[];
211
+ }
212
+
213
+ export interface LoadOutputCache {
214
+ maxage: number;
215
+ private?: boolean;
216
+ }
217
+
218
+ export interface Navigation {
219
+ from: URL;
220
+ to: URL;
221
+ }
222
+
223
+ export interface Page<Params extends Record<string, string> = Record<string, string>> {
224
+ url: URL;
225
+ params: Params;
226
+ routeId: string | null;
227
+ stuff: App.Stuff;
228
+ status: number;
229
+ error: Error | null;
230
+ }
231
+
232
+ export interface ParamMatcher {
233
+ (param: string): boolean;
234
+ }
235
+
236
+ export interface RequestEvent<Params extends Record<string, string> = Record<string, string>> {
237
+ clientAddress: string;
238
+ locals: App.Locals;
239
+ params: Params;
240
+ platform: Readonly<App.Platform>;
241
+ request: Request;
242
+ routeId: string | null;
243
+ url: URL;
244
+ }
245
+
246
+ /**
247
+ * A `(event: RequestEvent) => RequestHandlerOutput` function exported from an endpoint that corresponds to an HTTP verb (`get`, `put`, `patch`, etc) and handles requests with that method. Note that since 'delete' is a reserved word in JavaScript, delete handles are called `del` instead.
248
+ *
249
+ * Note that you can use [generated types](/docs/types#generated-types) instead of manually specifying the `Params` generic argument.
250
+ */
251
+ export interface RequestHandler<
252
+ Params extends Record<string, string> = Record<string, string>,
253
+ Output = ResponseBody
254
+ > {
255
+ (event: RequestEvent<Params>): MaybePromise<RequestHandlerOutput<Output>>;
256
+ }
257
+
258
+ export interface RequestHandlerOutput<Output = ResponseBody> {
259
+ status?: number;
260
+ headers?: Headers | Partial<ResponseHeaders>;
261
+ body?: Output extends ResponseBody ? Output : BodyValidator<Output>;
262
+ }
263
+
264
+ export interface ResolveOptions {
265
+ ssr?: boolean;
266
+ transformPage?: ({ html }: { html: string }) => MaybePromise<string>;
267
+ }
268
+
269
+ export type ResponseBody = JSONValue | Uint8Array | ReadableStream | import('stream').Readable;
270
+
271
+ export class Server {
272
+ constructor(manifest: SSRManifest);
273
+ respond(request: Request, options: RequestOptions): Promise<Response>;
274
+ }
275
+
276
+ export interface SSRManifest {
277
+ appDir: string;
278
+ assets: Set<string>;
279
+ mimeTypes: Record<string, string>;
280
+
281
+ /** private fields */
282
+ _: {
283
+ entry: {
284
+ file: string;
285
+ js: string[];
286
+ css: string[];
287
+ };
288
+ nodes: SSRNodeLoader[];
289
+ routes: SSRRoute[];
290
+ matchers: () => Promise<Record<string, ParamMatcher>>;
291
+ };
292
+ }