@sveltejs/kit 1.0.0-next.27 → 1.0.0-next.273

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 (86) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +20 -0
  3. package/assets/app/navigation.js +79 -0
  4. package/assets/app/paths.js +1 -0
  5. package/assets/app/stores.js +97 -0
  6. package/assets/chunks/utils.js +13 -0
  7. package/assets/client/singletons.js +21 -0
  8. package/assets/client/start.js +1520 -0
  9. package/assets/components/error.svelte +18 -2
  10. package/assets/env.js +8 -0
  11. package/assets/paths.js +13 -0
  12. package/assets/server/index.js +2760 -0
  13. package/dist/chunks/amp_hook.js +56 -0
  14. package/dist/chunks/build.js +658 -0
  15. package/dist/chunks/cert.js +28154 -0
  16. package/dist/chunks/index.js +467 -0
  17. package/dist/chunks/index2.js +836 -0
  18. package/dist/chunks/index3.js +638 -0
  19. package/dist/chunks/index4.js +115 -0
  20. package/dist/chunks/index5.js +891 -0
  21. package/dist/chunks/index6.js +170 -0
  22. package/dist/chunks/index7.js +15584 -0
  23. package/dist/chunks/index8.js +4207 -0
  24. package/dist/chunks/misc.js +3 -0
  25. package/dist/chunks/multipart-parser.js +449 -0
  26. package/dist/cli.js +1132 -86
  27. package/dist/hooks.js +28 -0
  28. package/dist/install-fetch.js +6518 -0
  29. package/dist/node.js +95 -0
  30. package/package.json +96 -54
  31. package/svelte-kit.js +2 -0
  32. package/types/ambient-modules.d.ts +208 -0
  33. package/types/app.d.ts +35 -0
  34. package/types/config.d.ts +200 -0
  35. package/types/csp.d.ts +115 -0
  36. package/types/endpoint.d.ts +39 -0
  37. package/types/helper.d.ts +23 -0
  38. package/types/hooks.d.ts +37 -0
  39. package/types/index.d.ts +24 -0
  40. package/types/internal.d.ts +260 -0
  41. package/types/page.d.ts +33 -0
  42. package/CHANGELOG.md +0 -319
  43. package/assets/runtime/app/navigation.js +0 -23
  44. package/assets/runtime/app/navigation.js.map +0 -1
  45. package/assets/runtime/app/paths.js +0 -2
  46. package/assets/runtime/app/paths.js.map +0 -1
  47. package/assets/runtime/app/stores.js +0 -78
  48. package/assets/runtime/app/stores.js.map +0 -1
  49. package/assets/runtime/internal/singletons.js +0 -15
  50. package/assets/runtime/internal/singletons.js.map +0 -1
  51. package/assets/runtime/internal/start.js +0 -591
  52. package/assets/runtime/internal/start.js.map +0 -1
  53. package/assets/runtime/utils-85ebcc60.js +0 -18
  54. package/assets/runtime/utils-85ebcc60.js.map +0 -1
  55. package/dist/api.js +0 -44
  56. package/dist/api.js.map +0 -1
  57. package/dist/build.js +0 -246
  58. package/dist/build.js.map +0 -1
  59. package/dist/cli.js.map +0 -1
  60. package/dist/colors.js +0 -37
  61. package/dist/colors.js.map +0 -1
  62. package/dist/create_app.js +0 -580
  63. package/dist/create_app.js.map +0 -1
  64. package/dist/index.js +0 -368
  65. package/dist/index.js.map +0 -1
  66. package/dist/index2.js +0 -12035
  67. package/dist/index2.js.map +0 -1
  68. package/dist/index3.js +0 -547
  69. package/dist/index3.js.map +0 -1
  70. package/dist/index4.js +0 -74
  71. package/dist/index4.js.map +0 -1
  72. package/dist/index5.js +0 -464
  73. package/dist/index5.js.map +0 -1
  74. package/dist/index6.js +0 -734
  75. package/dist/index6.js.map +0 -1
  76. package/dist/logging.js +0 -43
  77. package/dist/logging.js.map +0 -1
  78. package/dist/package.js +0 -432
  79. package/dist/package.js.map +0 -1
  80. package/dist/renderer.js +0 -2403
  81. package/dist/renderer.js.map +0 -1
  82. package/dist/standard.js +0 -101
  83. package/dist/standard.js.map +0 -1
  84. package/dist/utils.js +0 -58
  85. package/dist/utils.js.map +0 -1
  86. package/svelte-kit +0 -3
@@ -0,0 +1,200 @@
1
+ import { CompileOptions } from 'svelte/types/compiler/interfaces';
2
+ import { UserConfig as ViteConfig } from 'vite';
3
+ import { CspDirectives } from './csp';
4
+ import { MaybePromise, RecursiveRequired } from './helper';
5
+ import { HttpMethod, Logger, RouteSegment, TrailingSlash } from './internal';
6
+
7
+ export interface RouteDefinition {
8
+ type: 'page' | 'endpoint';
9
+ pattern: RegExp;
10
+ segments: RouteSegment[];
11
+ methods: HttpMethod[];
12
+ }
13
+
14
+ export interface AdapterEntry {
15
+ /**
16
+ * A string that uniquely identifies an HTTP service (e.g. serverless function) and is used for deduplication.
17
+ * For example, `/foo/a-[b]` and `/foo/[c]` are different routes, but would both
18
+ * be represented in a Netlify _redirects file as `/foo/:param`, so they share an ID
19
+ */
20
+ id: string;
21
+
22
+ /**
23
+ * A function that compares the candidate route with the current route to determine
24
+ * if it should be treated as a fallback for the current route. For example, `/foo/[c]`
25
+ * is a fallback for `/foo/a-[b]`, and `/[...catchall]` is a fallback for all routes
26
+ */
27
+ filter: (route: RouteDefinition) => boolean;
28
+
29
+ /**
30
+ * A function that is invoked once the entry has been created. This is where you
31
+ * should write the function to the filesystem and generate redirect manifests.
32
+ */
33
+ complete: (entry: {
34
+ generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
35
+ }) => void;
36
+ }
37
+
38
+ export interface Prerendered {
39
+ pages: Map<
40
+ string,
41
+ {
42
+ /** The location of the .html file relative to the output directory */
43
+ file: string;
44
+ }
45
+ >;
46
+ assets: Map<
47
+ string,
48
+ {
49
+ /** The MIME type of the asset */
50
+ type: string;
51
+ }
52
+ >;
53
+ redirects: Map<
54
+ string,
55
+ {
56
+ status: number;
57
+ location: string;
58
+ }
59
+ >;
60
+ /** An array of prerendered paths (without trailing slashes, regardless of the trailingSlash config) */
61
+ paths: string[];
62
+ }
63
+
64
+ export interface Builder {
65
+ log: Logger;
66
+ rimraf(dir: string): void;
67
+ mkdirp(dir: string): void;
68
+
69
+ appDir: string;
70
+ trailingSlash: 'always' | 'never' | 'ignore';
71
+
72
+ /**
73
+ * Create entry points that map to individual functions
74
+ * @param fn A function that groups a set of routes into an entry point
75
+ */
76
+ createEntries(fn: (route: RouteDefinition) => AdapterEntry): void;
77
+
78
+ generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
79
+
80
+ getBuildDirectory(name: string): string;
81
+ getClientDirectory(): string;
82
+ getServerDirectory(): string;
83
+ getStaticDirectory(): string;
84
+
85
+ /**
86
+ * @param dest the destination folder to which files should be copied
87
+ * @returns an array of paths corresponding to the files that have been created by the copy
88
+ */
89
+ writeClient(dest: string): string[];
90
+ /**
91
+ * @param dest the destination folder to which files should be copied
92
+ * @returns an array of paths corresponding to the files that have been created by the copy
93
+ */
94
+ writeServer(dest: string): string[];
95
+ /**
96
+ * @param dest the destination folder to which files should be copied
97
+ * @returns an array of paths corresponding to the files that have been created by the copy
98
+ */
99
+ writeStatic(dest: string): string[];
100
+ /**
101
+ * @param from the source file or folder
102
+ * @param to the destination file or folder
103
+ * @param opts.filter a function to determine whether a file or folder should be copied
104
+ * @param opts.replace a map of strings to replace
105
+ * @returns an array of paths corresponding to the files that have been created by the copy
106
+ */
107
+ copy(
108
+ from: string,
109
+ to: string,
110
+ opts?: {
111
+ filter?: (basename: string) => boolean;
112
+ replace?: Record<string, string>;
113
+ }
114
+ ): string[];
115
+
116
+ prerender(options: { all?: boolean; dest: string; fallback?: string }): Promise<Prerendered>;
117
+ }
118
+
119
+ export interface Adapter {
120
+ name: string;
121
+ headers?: {
122
+ host?: string;
123
+ protocol?: string;
124
+ };
125
+ adapt(builder: Builder): Promise<void>;
126
+ }
127
+
128
+ export interface PrerenderErrorHandler {
129
+ (details: {
130
+ status: number;
131
+ path: string;
132
+ referrer: string | null;
133
+ referenceType: 'linked' | 'fetched';
134
+ }): void;
135
+ }
136
+
137
+ export type PrerenderOnErrorValue = 'fail' | 'continue' | PrerenderErrorHandler;
138
+
139
+ export interface Config {
140
+ compilerOptions?: CompileOptions;
141
+ extensions?: string[];
142
+ kit?: {
143
+ adapter?: Adapter;
144
+ amp?: boolean;
145
+ appDir?: string;
146
+ browser?: {
147
+ hydrate?: boolean;
148
+ router?: boolean;
149
+ };
150
+ csp?: {
151
+ mode?: 'hash' | 'nonce' | 'auto';
152
+ directives?: CspDirectives;
153
+ };
154
+ files?: {
155
+ assets?: string;
156
+ hooks?: string;
157
+ lib?: string;
158
+ routes?: string;
159
+ serviceWorker?: string;
160
+ template?: string;
161
+ };
162
+ floc?: boolean;
163
+ inlineStyleThreshold?: number;
164
+ methodOverride?: {
165
+ parameter?: string;
166
+ allowed?: string[];
167
+ };
168
+ package?: {
169
+ dir?: string;
170
+ emitTypes?: boolean;
171
+ exports?(filepath: string): boolean;
172
+ files?(filepath: string): boolean;
173
+ };
174
+ paths?: {
175
+ assets?: string;
176
+ base?: string;
177
+ };
178
+ prerender?: {
179
+ concurrency?: number;
180
+ crawl?: boolean;
181
+ enabled?: boolean;
182
+ entries?: string[];
183
+ onError?: PrerenderOnErrorValue;
184
+ };
185
+ routes?: (filepath: string) => boolean;
186
+ serviceWorker?: {
187
+ register?: boolean;
188
+ files?: (filepath: string) => boolean;
189
+ };
190
+ trailingSlash?: TrailingSlash;
191
+ version?: {
192
+ name?: string;
193
+ pollInterval?: number;
194
+ };
195
+ vite?: ViteConfig | (() => MaybePromise<ViteConfig>);
196
+ };
197
+ preprocess?: any;
198
+ }
199
+
200
+ export type ValidatedConfig = RecursiveRequired<Config>;
package/types/csp.d.ts ADDED
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Based on https://github.com/josh-hemphill/csp-typed-directives/blob/latest/src/csp.types.ts
3
+ *
4
+ * MIT License
5
+ *
6
+ * Copyright (c) 2021-present, Joshua Hemphill
7
+ * Copyright (c) 2021, Tecnico Corporation
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ */
27
+ type SchemeSource = 'http:' | 'https:' | 'data:' | 'mediastream:' | 'blob:' | 'filesystem:';
28
+
29
+ type HostProtocolSchemes = `${string}://` | '';
30
+ type PortScheme = `:${number}` | '' | ':*';
31
+ /** Can actually be any string, but typed more explicitly to
32
+ * restrict the combined optional types of Source from collapsing to just bing `string` */
33
+ type HostNameScheme = `${string}.${string}` | `localhost`;
34
+ type HostSource = `${HostProtocolSchemes}${HostNameScheme}${PortScheme}`;
35
+
36
+ type CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`;
37
+
38
+ type BaseSource = 'self' | 'unsafe-eval' | 'unsafe-hashes' | 'unsafe-inline' | 'none';
39
+
40
+ export type Source = HostSource | SchemeSource | CryptoSource | BaseSource;
41
+ type Sources = Source[];
42
+
43
+ type ActionSource = 'strict-dynamic' | 'report-sample';
44
+
45
+ type FrameSource = HostSource | SchemeSource | 'self' | 'none';
46
+
47
+ type HttpDelineator = '/' | '?' | '#' | '\\';
48
+ type UriPath = `${HttpDelineator}${string}`;
49
+
50
+ export type CspDirectives = {
51
+ 'child-src'?: Sources;
52
+ 'default-src'?: Array<Source | ActionSource>;
53
+ 'frame-src'?: Sources;
54
+ 'worker-src'?: Sources;
55
+ 'connect-src'?: Sources;
56
+ 'font-src'?: Sources;
57
+ 'img-src'?: Sources;
58
+ 'manifest-src'?: Sources;
59
+ 'media-src'?: Sources;
60
+ 'object-src'?: Sources;
61
+ 'prefetch-src'?: Sources;
62
+ 'script-src'?: Array<Source | ActionSource>;
63
+ 'script-src-elem'?: Sources;
64
+ 'script-src-attr'?: Sources;
65
+ 'style-src'?: Array<Source | ActionSource>;
66
+ 'style-src-elem'?: Sources;
67
+ 'style-src-attr'?: Sources;
68
+ 'base-uri'?: Array<Source | ActionSource>;
69
+ sandbox?: Array<
70
+ | 'allow-downloads-without-user-activation'
71
+ | 'allow-forms'
72
+ | 'allow-modals'
73
+ | 'allow-orientation-lock'
74
+ | 'allow-pointer-lock'
75
+ | 'allow-popups'
76
+ | 'allow-popups-to-escape-sandbox'
77
+ | 'allow-presentation'
78
+ | 'allow-same-origin'
79
+ | 'allow-scripts'
80
+ | 'allow-storage-access-by-user-activation'
81
+ | 'allow-top-navigation'
82
+ | 'allow-top-navigation-by-user-activation'
83
+ >;
84
+ 'form-action'?: Array<Source | ActionSource>;
85
+ 'frame-ancestors'?: Array<HostSource | SchemeSource | FrameSource>;
86
+ 'navigate-to'?: Array<Source | ActionSource>;
87
+ 'report-uri'?: UriPath[];
88
+ 'report-to'?: string[];
89
+
90
+ 'require-trusted-types-for'?: Array<'script'>;
91
+ 'trusted-types'?: Array<'none' | 'allow-duplicates' | '*' | string>;
92
+ 'upgrade-insecure-requests'?: boolean;
93
+
94
+ /** @deprecated */
95
+ 'require-sri-for'?: Array<'script' | 'style' | 'script style'>;
96
+
97
+ /** @deprecated */
98
+ 'block-all-mixed-content'?: boolean;
99
+
100
+ /** @deprecated */
101
+ 'plugin-types'?: Array<`${string}/${string}` | 'none'>;
102
+
103
+ /** @deprecated */
104
+ referrer?: Array<
105
+ | 'no-referrer'
106
+ | 'no-referrer-when-downgrade'
107
+ | 'origin'
108
+ | 'origin-when-cross-origin'
109
+ | 'same-origin'
110
+ | 'strict-origin'
111
+ | 'strict-origin-when-cross-origin'
112
+ | 'unsafe-url'
113
+ | 'none'
114
+ >;
115
+ };
@@ -0,0 +1,39 @@
1
+ import { RequestEvent } from './hooks';
2
+ import { Either, JSONObject, JSONValue, MaybePromise, ResponseHeaders } from './helper';
3
+
4
+ type Body = JSONValue | Uint8Array | ReadableStream | import('stream').Readable;
5
+
6
+ export interface EndpointOutput<Output extends Body = Body> {
7
+ status?: number;
8
+ headers?: Headers | Partial<ResponseHeaders>;
9
+ body?: Output;
10
+ }
11
+
12
+ export interface Fallthrough {
13
+ fallthrough: true;
14
+ }
15
+
16
+ export interface RequestHandler<Output extends Body = Body> {
17
+ (event: RequestEvent): MaybePromise<
18
+ Either<Output extends Response ? Response : EndpointOutput<Output>, Fallthrough>
19
+ >;
20
+ }
21
+
22
+ export interface ShadowEndpointOutput<Output extends JSONObject = JSONObject> {
23
+ status?: number;
24
+ headers?: Partial<ResponseHeaders>;
25
+ body?: Output;
26
+ }
27
+
28
+ export interface ShadowRequestHandler<Output extends JSONObject = JSONObject> {
29
+ (event: RequestEvent): MaybePromise<Either<ShadowEndpointOutput<Output>, Fallthrough>>;
30
+ }
31
+
32
+ export interface ShadowData {
33
+ fallthrough?: boolean;
34
+ status?: number;
35
+ error?: Error;
36
+ redirect?: string;
37
+ cookies?: string[];
38
+ body?: JSONObject;
39
+ }
@@ -0,0 +1,23 @@
1
+ type ToJSON = { toJSON(...args: any[]): Exclude<JSONValue, ToJSON> };
2
+
3
+ export type JSONObject = { [key: string]: JSONValue };
4
+ export type JSONValue = string | number | boolean | null | ToJSON | JSONValue[] | JSONObject;
5
+
6
+ /** `string[]` is only for set-cookie, everything else must be type of `string` */
7
+ export type ResponseHeaders = Record<string, string | number | string[]>;
8
+
9
+ // <-- Utility Types -->
10
+ type Only<T, U> = { [P in keyof T]: T[P] } & { [P in Exclude<keyof U, keyof T>]?: never };
11
+
12
+ export type Either<T, U> = Only<T, U> | Only<U, T>;
13
+ export type MaybePromise<T> = T | Promise<T>;
14
+ export type RecursiveRequired<T> = {
15
+ // Recursive implementation of TypeScript's Required utility type.
16
+ // Will recursively continue until it reaches primitive or union
17
+ // with a Function in it, except those commented below
18
+ [K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type
19
+ ? RecursiveRequired<T[K]> // recursively continue through.
20
+ : K extends 'vite' // If it reaches the 'vite' key
21
+ ? Extract<T[K], Function> // only take the Function type.
22
+ : T[K]; // Use the exact type for everything else
23
+ };
@@ -0,0 +1,37 @@
1
+ import { MaybePromise } from './helper';
2
+
3
+ export type StrictBody = string | Uint8Array;
4
+
5
+ export interface RequestEvent {
6
+ request: Request;
7
+ url: URL;
8
+ params: Record<string, string>;
9
+ locals: App.Locals;
10
+ platform: Readonly<App.Platform>;
11
+ }
12
+
13
+ export interface GetSession {
14
+ (event: RequestEvent): MaybePromise<App.Session>;
15
+ }
16
+
17
+ export interface RequiredResolveOptions {
18
+ ssr: boolean;
19
+ transformPage: ({ html }: { html: string }) => string;
20
+ }
21
+
22
+ export type ResolveOptions = Partial<RequiredResolveOptions>;
23
+
24
+ export interface Handle {
25
+ (input: {
26
+ event: RequestEvent;
27
+ resolve(event: RequestEvent, opts?: ResolveOptions): MaybePromise<Response>;
28
+ }): MaybePromise<Response>;
29
+ }
30
+
31
+ export interface HandleError {
32
+ (input: { error: Error & { frame?: string }; event: RequestEvent }): void;
33
+ }
34
+
35
+ export interface ExternalFetch {
36
+ (req: Request): Promise<Response>;
37
+ }
@@ -0,0 +1,24 @@
1
+ /// <reference types="svelte" />
2
+ /// <reference types="vite/client" />
3
+
4
+ import './ambient-modules';
5
+
6
+ export { App, SSRManifest } from './app';
7
+ export {
8
+ Adapter,
9
+ Builder,
10
+ Config,
11
+ Prerendered,
12
+ PrerenderErrorHandler,
13
+ ValidatedConfig
14
+ } from './config';
15
+ export { EndpointOutput, RequestHandler } from './endpoint';
16
+ export { ErrorLoad, ErrorLoadInput, Load, LoadInput, LoadOutput } from './page';
17
+ export {
18
+ ExternalFetch,
19
+ GetSession,
20
+ Handle,
21
+ HandleError,
22
+ RequestEvent,
23
+ ResolveOptions
24
+ } from './hooks';
@@ -0,0 +1,260 @@
1
+ import { OutputAsset, OutputChunk } from 'rollup';
2
+ import { ValidatedConfig } from './config';
3
+ import { InternalApp, SSRManifest } from './app';
4
+ import { Fallthrough, RequestHandler, ShadowRequestHandler } from './endpoint';
5
+ import { Either } from './helper';
6
+ import { ExternalFetch, GetSession, Handle, HandleError, RequestEvent } from './hooks';
7
+ import { Load } from './page';
8
+
9
+ export interface PrerenderDependency {
10
+ response: Response;
11
+ body: null | string | Uint8Array;
12
+ }
13
+
14
+ export interface PrerenderOptions {
15
+ fallback?: string;
16
+ all: boolean;
17
+ dependencies: Map<string, PrerenderDependency>;
18
+ }
19
+
20
+ export interface AppModule {
21
+ App: typeof InternalApp;
22
+
23
+ override(options: {
24
+ paths: {
25
+ base: string;
26
+ assets: string;
27
+ };
28
+ prerendering: boolean;
29
+ protocol?: 'http' | 'https';
30
+ read(file: string): Buffer;
31
+ }): void;
32
+ }
33
+
34
+ export interface Logger {
35
+ (msg: string): void;
36
+ success(msg: string): void;
37
+ error(msg: string): void;
38
+ warn(msg: string): void;
39
+ minor(msg: string): void;
40
+ info(msg: string): void;
41
+ }
42
+
43
+ export interface SSRComponent {
44
+ router?: boolean;
45
+ hydrate?: boolean;
46
+ prerender?: boolean;
47
+ load: Load;
48
+ default: {
49
+ render(props: Record<string, any>): {
50
+ html: string;
51
+ head: string;
52
+ css: {
53
+ code: string;
54
+ map: any; // TODO
55
+ };
56
+ };
57
+ };
58
+ }
59
+
60
+ export type SSRComponentLoader = () => Promise<SSRComponent>;
61
+
62
+ export type CSRComponent = any; // TODO
63
+
64
+ export type CSRComponentLoader = () => Promise<CSRComponent>;
65
+
66
+ export interface SSRPagePart {
67
+ id: string;
68
+ load: SSRComponentLoader;
69
+ }
70
+
71
+ export type GetParams = (match: RegExpExecArray) => Record<string, string>;
72
+
73
+ export interface SSRPage {
74
+ type: 'page';
75
+ pattern: RegExp;
76
+ params: GetParams;
77
+ shadow:
78
+ | null
79
+ | (() => Promise<{
80
+ [method: string]: ShadowRequestHandler;
81
+ }>);
82
+ /**
83
+ * plan a is to render 1 or more layout components followed by a leaf component.
84
+ */
85
+ a: number[];
86
+ /**
87
+ * plan b — if one of them components fails in `load` we backtrack until we find
88
+ * the nearest error component.
89
+ */
90
+ b: number[];
91
+ }
92
+
93
+ export interface SSREndpoint {
94
+ type: 'endpoint';
95
+ pattern: RegExp;
96
+ params: GetParams;
97
+ load(): Promise<{
98
+ [method: string]: RequestHandler;
99
+ }>;
100
+ }
101
+
102
+ export type SSRRoute = SSREndpoint | SSRPage;
103
+
104
+ type HasShadow = 1;
105
+ export type CSRRoute = [RegExp, CSRComponentLoader[], CSRComponentLoader[], GetParams?, HasShadow?];
106
+
107
+ export type SSRNodeLoader = () => Promise<SSRNode>;
108
+
109
+ export interface Hooks {
110
+ externalFetch: ExternalFetch;
111
+ getSession: GetSession;
112
+ handle: Handle;
113
+ handleError: HandleError;
114
+ }
115
+
116
+ export interface SSRNode {
117
+ module: SSRComponent;
118
+ /** client-side module URL for this component */
119
+ entry: string;
120
+ /** external CSS files */
121
+ css: string[];
122
+ /** external JS files */
123
+ js: string[];
124
+ /** inlined styles */
125
+ styles?: Record<string, string>;
126
+ }
127
+
128
+ export interface SSROptions {
129
+ amp: boolean;
130
+ csp: ValidatedConfig['kit']['csp'];
131
+ dev: boolean;
132
+ floc: boolean;
133
+ get_stack: (error: Error) => string | undefined;
134
+ handle_error(error: Error & { frame?: string }, event: RequestEvent): void;
135
+ hooks: Hooks;
136
+ hydrate: boolean;
137
+ manifest: SSRManifest;
138
+ method_override: MethodOverride;
139
+ paths: {
140
+ base: string;
141
+ assets: string;
142
+ };
143
+ prefix: string;
144
+ prerender: boolean;
145
+ read(file: string): Buffer;
146
+ root: SSRComponent['default'];
147
+ router: boolean;
148
+ service_worker?: string;
149
+ template({
150
+ head,
151
+ body,
152
+ assets,
153
+ nonce
154
+ }: {
155
+ head: string;
156
+ body: string;
157
+ assets: string;
158
+ nonce: string;
159
+ }): string;
160
+ template_contains_nonce: boolean;
161
+ trailing_slash: TrailingSlash;
162
+ }
163
+
164
+ export interface SSRState {
165
+ fetched?: string;
166
+ initiator?: SSRPage | null;
167
+ platform?: any;
168
+ prerender?: PrerenderOptions;
169
+ fallback?: string;
170
+ }
171
+
172
+ export interface Asset {
173
+ file: string;
174
+ size: number;
175
+ type: string | null;
176
+ }
177
+
178
+ export interface RouteSegment {
179
+ content: string;
180
+ dynamic: boolean;
181
+ rest: boolean;
182
+ }
183
+
184
+ export type HttpMethod = 'get' | 'head' | 'post' | 'put' | 'delete' | 'patch';
185
+
186
+ export interface PageData {
187
+ type: 'page';
188
+ key: string;
189
+ shadow: string | null;
190
+ segments: RouteSegment[];
191
+ pattern: RegExp;
192
+ params: string[];
193
+ path: string;
194
+ a: string[];
195
+ b: string[];
196
+ }
197
+
198
+ export interface EndpointData {
199
+ type: 'endpoint';
200
+ key: string;
201
+ segments: RouteSegment[];
202
+ pattern: RegExp;
203
+ params: string[];
204
+ file: string;
205
+ }
206
+
207
+ export type RouteData = PageData | EndpointData;
208
+
209
+ export interface ManifestData {
210
+ assets: Asset[];
211
+ layout: string;
212
+ error: string;
213
+ components: string[];
214
+ routes: RouteData[];
215
+ }
216
+
217
+ export interface BuildData {
218
+ app_dir: string;
219
+ manifest_data: ManifestData;
220
+ service_worker: string | null;
221
+ client: {
222
+ assets: OutputAsset[];
223
+ chunks: OutputChunk[];
224
+ entry: {
225
+ file: string;
226
+ js: string[];
227
+ css: string[];
228
+ };
229
+ vite_manifest: import('vite').Manifest;
230
+ };
231
+ server: {
232
+ chunks: OutputChunk[];
233
+ methods: Record<string, HttpMethod[]>;
234
+ vite_manifest: import('vite').Manifest;
235
+ };
236
+ static: string[];
237
+ entries: string[];
238
+ }
239
+
240
+ export type NormalizedLoadOutput = Either<
241
+ {
242
+ status: number;
243
+ error?: Error;
244
+ redirect?: string;
245
+ props?: Record<string, any> | Promise<Record<string, any>>;
246
+ stuff?: Record<string, any>;
247
+ maxage?: number;
248
+ },
249
+ Fallthrough
250
+ >;
251
+
252
+ export type TrailingSlash = 'never' | 'always' | 'ignore';
253
+ export interface MethodOverride {
254
+ parameter: string;
255
+ allowed: string[];
256
+ }
257
+
258
+ export interface Respond {
259
+ (request: Request, options: SSROptions, state?: SSRState): Promise<Response>;
260
+ }