@sveltejs/kit 1.0.0-next.41 → 1.0.0-next.412

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 (129) hide show
  1. package/README.md +12 -9
  2. package/package.json +97 -63
  3. package/src/cli.js +119 -0
  4. package/src/core/adapt/builder.js +207 -0
  5. package/src/core/adapt/index.js +19 -0
  6. package/src/core/config/index.js +86 -0
  7. package/src/core/config/options.js +488 -0
  8. package/src/core/config/types.d.ts +1 -0
  9. package/src/core/constants.js +3 -0
  10. package/src/core/generate_manifest/index.js +99 -0
  11. package/src/core/prerender/crawl.js +194 -0
  12. package/src/core/prerender/prerender.js +378 -0
  13. package/src/core/prerender/queue.js +80 -0
  14. package/src/core/sync/create_manifest_data/index.js +496 -0
  15. package/src/core/sync/create_manifest_data/types.d.ts +40 -0
  16. package/src/core/sync/sync.js +59 -0
  17. package/src/core/sync/utils.js +97 -0
  18. package/src/core/sync/write_ambient.js +87 -0
  19. package/src/core/sync/write_client_manifest.js +82 -0
  20. package/src/core/sync/write_matchers.js +25 -0
  21. package/src/core/sync/write_root.js +88 -0
  22. package/src/core/sync/write_tsconfig.js +189 -0
  23. package/src/core/sync/write_types.js +727 -0
  24. package/src/core/utils.js +58 -0
  25. package/src/hooks.js +26 -0
  26. package/src/index/index.js +45 -0
  27. package/src/index/private.js +33 -0
  28. package/src/node/index.js +145 -0
  29. package/src/node/polyfills.js +40 -0
  30. package/src/packaging/index.js +218 -0
  31. package/src/packaging/types.d.ts +8 -0
  32. package/src/packaging/typescript.js +150 -0
  33. package/src/packaging/utils.js +143 -0
  34. package/src/runtime/app/env.js +11 -0
  35. package/src/runtime/app/navigation.js +22 -0
  36. package/src/runtime/app/paths.js +1 -0
  37. package/src/runtime/app/stores.js +94 -0
  38. package/src/runtime/client/ambient.d.ts +17 -0
  39. package/src/runtime/client/client.js +1281 -0
  40. package/src/runtime/client/fetcher.js +60 -0
  41. package/src/runtime/client/parse.js +36 -0
  42. package/src/runtime/client/singletons.js +11 -0
  43. package/src/runtime/client/start.js +48 -0
  44. package/src/runtime/client/types.d.ts +106 -0
  45. package/src/runtime/client/utils.js +113 -0
  46. package/src/runtime/components/error.svelte +16 -0
  47. package/{assets → src/runtime}/components/layout.svelte +0 -0
  48. package/src/runtime/env/dynamic/private.js +1 -0
  49. package/src/runtime/env/dynamic/public.js +1 -0
  50. package/src/runtime/env-private.js +7 -0
  51. package/src/runtime/env-public.js +7 -0
  52. package/src/runtime/env.js +6 -0
  53. package/src/runtime/hash.js +16 -0
  54. package/src/runtime/paths.js +11 -0
  55. package/src/runtime/server/endpoint.js +42 -0
  56. package/src/runtime/server/index.js +434 -0
  57. package/src/runtime/server/page/cookie.js +25 -0
  58. package/src/runtime/server/page/crypto.js +239 -0
  59. package/src/runtime/server/page/csp.js +249 -0
  60. package/src/runtime/server/page/fetch.js +266 -0
  61. package/src/runtime/server/page/index.js +418 -0
  62. package/src/runtime/server/page/load_data.js +94 -0
  63. package/src/runtime/server/page/render.js +363 -0
  64. package/src/runtime/server/page/respond_with_error.js +105 -0
  65. package/src/runtime/server/page/types.d.ts +44 -0
  66. package/src/runtime/server/utils.js +116 -0
  67. package/src/utils/error.js +22 -0
  68. package/src/utils/escape.js +104 -0
  69. package/src/utils/filesystem.js +108 -0
  70. package/src/utils/http.js +55 -0
  71. package/src/utils/misc.js +1 -0
  72. package/src/utils/routing.js +107 -0
  73. package/src/utils/url.js +97 -0
  74. package/src/vite/build/build_server.js +339 -0
  75. package/src/vite/build/build_service_worker.js +90 -0
  76. package/src/vite/build/utils.js +153 -0
  77. package/src/vite/dev/index.js +569 -0
  78. package/src/vite/index.js +540 -0
  79. package/src/vite/preview/index.js +186 -0
  80. package/src/vite/types.d.ts +3 -0
  81. package/src/vite/utils.js +335 -0
  82. package/svelte-kit.js +1 -1
  83. package/types/ambient.d.ts +368 -0
  84. package/types/index.d.ts +345 -0
  85. package/types/internal.d.ts +309 -0
  86. package/types/private.d.ts +236 -0
  87. package/CHANGELOG.md +0 -419
  88. package/assets/components/error.svelte +0 -13
  89. package/assets/runtime/app/env.js +0 -5
  90. package/assets/runtime/app/navigation.js +0 -41
  91. package/assets/runtime/app/paths.js +0 -1
  92. package/assets/runtime/app/stores.js +0 -93
  93. package/assets/runtime/chunks/utils.js +0 -19
  94. package/assets/runtime/internal/singletons.js +0 -23
  95. package/assets/runtime/internal/start.js +0 -770
  96. package/assets/runtime/paths.js +0 -12
  97. package/dist/api.js +0 -28
  98. package/dist/api.js.map +0 -1
  99. package/dist/chunks/index.js +0 -3519
  100. package/dist/chunks/index2.js +0 -587
  101. package/dist/chunks/index3.js +0 -246
  102. package/dist/chunks/index4.js +0 -524
  103. package/dist/chunks/index5.js +0 -761
  104. package/dist/chunks/index6.js +0 -322
  105. package/dist/chunks/standard.js +0 -99
  106. package/dist/chunks/utils.js +0 -83
  107. package/dist/cli.js +0 -546
  108. package/dist/cli.js.map +0 -1
  109. package/dist/create_app.js +0 -592
  110. package/dist/create_app.js.map +0 -1
  111. package/dist/index.js +0 -392
  112. package/dist/index.js.map +0 -1
  113. package/dist/index2.js +0 -3519
  114. package/dist/index2.js.map +0 -1
  115. package/dist/index3.js +0 -320
  116. package/dist/index3.js.map +0 -1
  117. package/dist/index4.js +0 -323
  118. package/dist/index4.js.map +0 -1
  119. package/dist/index5.js +0 -247
  120. package/dist/index5.js.map +0 -1
  121. package/dist/index6.js +0 -761
  122. package/dist/index6.js.map +0 -1
  123. package/dist/renderer.js +0 -2499
  124. package/dist/renderer.js.map +0 -1
  125. package/dist/ssr.js +0 -2581
  126. package/dist/standard.js +0 -100
  127. package/dist/standard.js.map +0 -1
  128. package/dist/utils.js +0 -84
  129. package/dist/utils.js.map +0 -1
@@ -0,0 +1,309 @@
1
+ import { OutputAsset, OutputChunk } from 'rollup';
2
+ import { SvelteComponent } from 'svelte/internal';
3
+ import {
4
+ Action,
5
+ Config,
6
+ ExternalFetch,
7
+ ServerLoad,
8
+ GetSession,
9
+ Handle,
10
+ HandleError,
11
+ KitConfig,
12
+ Load,
13
+ RequestEvent,
14
+ RequestHandler,
15
+ ResolveOptions,
16
+ Server,
17
+ ServerInitOptions,
18
+ SSRManifest
19
+ } from './index.js';
20
+ import { HttpMethod, MaybePromise, RequestOptions, TrailingSlash } from './private.js';
21
+
22
+ export interface ServerModule {
23
+ Server: typeof InternalServer;
24
+
25
+ override(options: {
26
+ paths: {
27
+ base: string;
28
+ assets: string;
29
+ };
30
+ prerendering: boolean;
31
+ protocol?: 'http' | 'https';
32
+ read(file: string): Buffer;
33
+ }): void;
34
+ }
35
+
36
+ export interface Asset {
37
+ file: string;
38
+ size: number;
39
+ type: string | null;
40
+ }
41
+
42
+ export interface BuildData {
43
+ app_dir: string;
44
+ manifest_data: ManifestData;
45
+ service_worker: string | null;
46
+ client: {
47
+ assets: OutputAsset[];
48
+ chunks: OutputChunk[];
49
+ entry: {
50
+ file: string;
51
+ imports: string[];
52
+ stylesheets: string[];
53
+ };
54
+ vite_manifest: import('vite').Manifest;
55
+ };
56
+ server: {
57
+ chunks: OutputChunk[];
58
+ methods: Record<string, HttpMethod[]>;
59
+ vite_manifest: import('vite').Manifest;
60
+ };
61
+ }
62
+
63
+ export interface CSRPageNode {
64
+ component: typeof SvelteComponent;
65
+ shared: {
66
+ load: Load;
67
+ hydrate: boolean;
68
+ router: boolean;
69
+ };
70
+ server: boolean;
71
+ }
72
+
73
+ export type CSRPageNodeLoader = () => Promise<CSRPageNode>;
74
+
75
+ export type CSRRoute = {
76
+ id: string;
77
+ exec: (path: string) => undefined | Record<string, string>;
78
+ errors: CSRPageNodeLoader[];
79
+ layouts: CSRPageNodeLoader[];
80
+ leaf: CSRPageNodeLoader;
81
+ uses_server_data: boolean;
82
+ };
83
+
84
+ export interface EndpointData {
85
+ type: 'endpoint';
86
+ id: string;
87
+ pattern: RegExp;
88
+ file: string;
89
+ }
90
+
91
+ export type GetParams = (match: RegExpExecArray) => Record<string, string>;
92
+
93
+ export interface Hooks {
94
+ externalFetch: ExternalFetch;
95
+ getSession: GetSession;
96
+ handle: Handle;
97
+ handleError: HandleError;
98
+ }
99
+
100
+ export interface ImportNode {
101
+ name: string;
102
+ dynamic: boolean;
103
+ }
104
+
105
+ export class InternalServer extends Server {
106
+ init(options: ServerInitOptions): void;
107
+ respond(
108
+ request: Request,
109
+ options: RequestOptions & {
110
+ prerendering?: PrerenderOptions;
111
+ }
112
+ ): Promise<Response>;
113
+ }
114
+
115
+ export interface ManifestData {
116
+ assets: Asset[];
117
+ nodes: PageNode[];
118
+ routes: RouteData[];
119
+ matchers: Record<string, string>;
120
+ }
121
+
122
+ export interface MethodOverride {
123
+ parameter: string;
124
+ allowed: string[];
125
+ }
126
+
127
+ export interface PageNode {
128
+ component?: string; // TODO supply default component if it's missing (bit of an edge case)
129
+ shared?: string;
130
+ server?: string;
131
+ }
132
+
133
+ export interface PageData {
134
+ type: 'page';
135
+ id: string;
136
+ pattern: RegExp;
137
+ errors: Array<PageNode | undefined>;
138
+ layouts: Array<PageNode | undefined>;
139
+ leaf: PageNode;
140
+ }
141
+
142
+ export type PayloadScriptAttributes =
143
+ | { type: 'data'; url: string; body?: string }
144
+ | { type: 'server_data' }
145
+ | { type: 'validation_errors' };
146
+
147
+ export interface PrerenderDependency {
148
+ response: Response;
149
+ body: null | string | Uint8Array;
150
+ }
151
+
152
+ export interface PrerenderOptions {
153
+ cache?: string; // including this here is a bit of a hack, but it makes it easy to add <meta http-equiv>
154
+ fallback?: boolean;
155
+ dependencies: Map<string, PrerenderDependency>;
156
+ }
157
+
158
+ export type RecursiveRequired<T> = {
159
+ // Recursive implementation of TypeScript's Required utility type.
160
+ // Will recursively continue until it reaches a primitive or Function
161
+ [K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type
162
+ ? RecursiveRequired<T[K]> // recursively continue through.
163
+ : T[K]; // Use the exact type for everything else
164
+ };
165
+
166
+ export type RequiredResolveOptions = Required<ResolveOptions>;
167
+
168
+ export interface Respond {
169
+ (request: Request, options: SSROptions, state: SSRState): Promise<Response>;
170
+ }
171
+
172
+ export type RouteData = PageData | EndpointData;
173
+
174
+ export interface SSRComponent {
175
+ default: {
176
+ render(props: Record<string, any>): {
177
+ html: string;
178
+ head: string;
179
+ css: {
180
+ code: string;
181
+ map: any; // TODO
182
+ };
183
+ };
184
+ };
185
+ }
186
+
187
+ export type SSRComponentLoader = () => Promise<SSRComponent>;
188
+
189
+ export interface SSREndpoint {
190
+ type: 'endpoint';
191
+ id: string;
192
+ pattern: RegExp;
193
+ names: string[];
194
+ types: string[];
195
+ load(): Promise<Partial<Record<HttpMethod, RequestHandler>>>;
196
+ }
197
+
198
+ export interface SSRNode {
199
+ component: SSRComponentLoader;
200
+ /** index into the `components` array in client-manifest.js */
201
+ index: number;
202
+ /** client-side module URL for this component */
203
+ file: string;
204
+ /** external JS files */
205
+ imports: string[];
206
+ /** external CSS files */
207
+ stylesheets: string[];
208
+ /** inlined styles */
209
+ inline_styles?: () => MaybePromise<Record<string, string>>;
210
+
211
+ shared: {
212
+ load?: Load;
213
+ hydrate?: boolean;
214
+ prerender?: boolean;
215
+ router?: boolean;
216
+ ssr?: boolean;
217
+ };
218
+
219
+ server: {
220
+ load?: ServerLoad;
221
+ HEAD?: ServerLoad;
222
+ POST?: Action;
223
+ PATCH?: Action;
224
+ PUT?: Action;
225
+ DELETE?: Action;
226
+ };
227
+ }
228
+
229
+ export type SSRNodeLoader = () => Promise<SSRNode>;
230
+
231
+ export interface SSROptions {
232
+ csp: ValidatedConfig['kit']['csp'];
233
+ dev: boolean;
234
+ get_stack: (error: Error) => string | undefined;
235
+ handle_error(error: Error & { frame?: string }, event: RequestEvent): void;
236
+ hooks: Hooks;
237
+ hydrate: boolean;
238
+ manifest: SSRManifest;
239
+ method_override: MethodOverride;
240
+ paths: {
241
+ base: string;
242
+ assets: string;
243
+ };
244
+ prefix: string;
245
+ prerender: {
246
+ default: boolean;
247
+ enabled: boolean;
248
+ };
249
+ public_env: Record<string, string>;
250
+ read(file: string): Buffer;
251
+ root: SSRComponent['default'];
252
+ router: boolean;
253
+ service_worker?: string;
254
+ template({
255
+ head,
256
+ body,
257
+ assets,
258
+ nonce
259
+ }: {
260
+ head: string;
261
+ body: string;
262
+ assets: string;
263
+ nonce: string;
264
+ }): string;
265
+ template_contains_nonce: boolean;
266
+ trailing_slash: TrailingSlash;
267
+ }
268
+
269
+ export interface SSRPage {
270
+ type: 'page';
271
+ id: string;
272
+ pattern: RegExp;
273
+ names: string[];
274
+ types: string[];
275
+ errors: Array<number | undefined>;
276
+ layouts: Array<number | undefined>;
277
+ leaf: number;
278
+ }
279
+
280
+ export interface SSRErrorPage {
281
+ id: '__error';
282
+ }
283
+
284
+ export type SSRRoute = SSREndpoint | SSRPage;
285
+
286
+ export interface SSRState {
287
+ fallback?: string;
288
+ getClientAddress: () => string;
289
+ initiator?: SSRPage | SSRErrorPage;
290
+ platform?: any;
291
+ prerendering?: PrerenderOptions;
292
+ }
293
+
294
+ export type StrictBody = string | Uint8Array;
295
+
296
+ export type ValidatedConfig = RecursiveRequired<Config>;
297
+
298
+ export type ValidatedKitConfig = RecursiveRequired<KitConfig>;
299
+
300
+ export * from './index';
301
+ export * from './private';
302
+
303
+ declare global {
304
+ const __SVELTEKIT_ADAPTER_NAME__: string;
305
+ const __SVELTEKIT_APP_VERSION__: string;
306
+ const __SVELTEKIT_APP_VERSION_FILE__: string;
307
+ const __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: number;
308
+ const __SVELTEKIT_DEV__: boolean;
309
+ }
@@ -0,0 +1,236 @@
1
+ // This module contains types that are visible in the documentation,
2
+ // but which cannot be imported from `@sveltejs/kit`. Care should
3
+ // be taken to avoid breaking changes when editing this file
4
+
5
+ export interface AdapterEntry {
6
+ /**
7
+ * A string that uniquely identifies an HTTP service (e.g. serverless function) and is used for deduplication.
8
+ * For example, `/foo/a-[b]` and `/foo/[c]` are different routes, but would both
9
+ * be represented in a Netlify _redirects file as `/foo/:param`, so they share an ID
10
+ */
11
+ id: string;
12
+
13
+ /**
14
+ * A function that compares the candidate route with the current route to determine
15
+ * if it should be treated as a fallback for the current route. For example, `/foo/[c]`
16
+ * is a fallback for `/foo/a-[b]`, and `/[...catchall]` is a fallback for all routes
17
+ */
18
+ filter: (route: RouteDefinition) => boolean;
19
+
20
+ /**
21
+ * A function that is invoked once the entry has been created. This is where you
22
+ * should write the function to the filesystem and generate redirect manifests.
23
+ */
24
+ complete: (entry: {
25
+ generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
26
+ }) => MaybePromise<void>;
27
+ }
28
+
29
+ // TODO is this still used?
30
+ export type BodyValidator<T> = {
31
+ [P in keyof T]: T[P] extends { [k: string]: unknown }
32
+ ? BodyValidator<T[P]> // recurse when T[P] is an object
33
+ : T[P] extends BigInt | Function | Symbol
34
+ ? never
35
+ : T[P];
36
+ };
37
+
38
+ // Based on https://github.com/josh-hemphill/csp-typed-directives/blob/latest/src/csp.types.ts
39
+ //
40
+ // MIT License
41
+ //
42
+ // Copyright (c) 2021-present, Joshua Hemphill
43
+ // Copyright (c) 2021, Tecnico Corporation
44
+ //
45
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
46
+ // of this software and associated documentation files (the "Software"), to deal
47
+ // in the Software without restriction, including without limitation the rights
48
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
49
+ // copies of the Software, and to permit persons to whom the Software is
50
+ // furnished to do so, subject to the following conditions:
51
+ //
52
+ // The above copyright notice and this permission notice shall be included in all
53
+ // copies or substantial portions of the Software.
54
+ //
55
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
56
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
57
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
58
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
59
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
60
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
61
+ // SOFTWARE.
62
+
63
+ export namespace Csp {
64
+ type ActionSource = 'strict-dynamic' | 'report-sample';
65
+ type BaseSource = 'self' | 'unsafe-eval' | 'unsafe-hashes' | 'unsafe-inline' | 'none';
66
+ type CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`;
67
+ type FrameSource = HostSource | SchemeSource | 'self' | 'none';
68
+ type HostNameScheme = `${string}.${string}` | 'localhost';
69
+ type HostSource = `${HostProtocolSchemes}${HostNameScheme}${PortScheme}`;
70
+ type HostProtocolSchemes = `${string}://` | '';
71
+ type HttpDelineator = '/' | '?' | '#' | '\\';
72
+ type PortScheme = `:${number}` | '' | ':*';
73
+ type SchemeSource = 'http:' | 'https:' | 'data:' | 'mediastream:' | 'blob:' | 'filesystem:';
74
+ type Source = HostSource | SchemeSource | CryptoSource | BaseSource;
75
+ type Sources = Source[];
76
+ type UriPath = `${HttpDelineator}${string}`;
77
+ }
78
+
79
+ export interface CspDirectives {
80
+ 'child-src'?: Csp.Sources;
81
+ 'default-src'?: Array<Csp.Source | Csp.ActionSource>;
82
+ 'frame-src'?: Csp.Sources;
83
+ 'worker-src'?: Csp.Sources;
84
+ 'connect-src'?: Csp.Sources;
85
+ 'font-src'?: Csp.Sources;
86
+ 'img-src'?: Csp.Sources;
87
+ 'manifest-src'?: Csp.Sources;
88
+ 'media-src'?: Csp.Sources;
89
+ 'object-src'?: Csp.Sources;
90
+ 'prefetch-src'?: Csp.Sources;
91
+ 'script-src'?: Array<Csp.Source | Csp.ActionSource>;
92
+ 'script-src-elem'?: Csp.Sources;
93
+ 'script-src-attr'?: Csp.Sources;
94
+ 'style-src'?: Array<Csp.Source | Csp.ActionSource>;
95
+ 'style-src-elem'?: Csp.Sources;
96
+ 'style-src-attr'?: Csp.Sources;
97
+ 'base-uri'?: Array<Csp.Source | Csp.ActionSource>;
98
+ sandbox?: Array<
99
+ | 'allow-downloads-without-user-activation'
100
+ | 'allow-forms'
101
+ | 'allow-modals'
102
+ | 'allow-orientation-lock'
103
+ | 'allow-pointer-lock'
104
+ | 'allow-popups'
105
+ | 'allow-popups-to-escape-sandbox'
106
+ | 'allow-presentation'
107
+ | 'allow-same-origin'
108
+ | 'allow-scripts'
109
+ | 'allow-storage-access-by-user-activation'
110
+ | 'allow-top-navigation'
111
+ | 'allow-top-navigation-by-user-activation'
112
+ >;
113
+ 'form-action'?: Array<Csp.Source | Csp.ActionSource>;
114
+ 'frame-ancestors'?: Array<Csp.HostSource | Csp.SchemeSource | Csp.FrameSource>;
115
+ 'navigate-to'?: Array<Csp.Source | Csp.ActionSource>;
116
+ 'report-uri'?: Csp.UriPath[];
117
+ 'report-to'?: string[];
118
+
119
+ 'require-trusted-types-for'?: Array<'script'>;
120
+ 'trusted-types'?: Array<'none' | 'allow-duplicates' | '*' | string>;
121
+ 'upgrade-insecure-requests'?: boolean;
122
+
123
+ /** @deprecated */
124
+ 'require-sri-for'?: Array<'script' | 'style' | 'script style'>;
125
+
126
+ /** @deprecated */
127
+ 'block-all-mixed-content'?: boolean;
128
+
129
+ /** @deprecated */
130
+ 'plugin-types'?: Array<`${string}/${string}` | 'none'>;
131
+
132
+ /** @deprecated */
133
+ referrer?: Array<
134
+ | 'no-referrer'
135
+ | 'no-referrer-when-downgrade'
136
+ | 'origin'
137
+ | 'origin-when-cross-origin'
138
+ | 'same-origin'
139
+ | 'strict-origin'
140
+ | 'strict-origin-when-cross-origin'
141
+ | 'unsafe-url'
142
+ | 'none'
143
+ >;
144
+ }
145
+
146
+ export type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
147
+
148
+ export interface JSONObject {
149
+ [key: string]: JSONValue;
150
+ }
151
+
152
+ export type JSONValue =
153
+ | string
154
+ | number
155
+ | boolean
156
+ | null
157
+ | undefined
158
+ | ToJSON
159
+ | JSONValue[]
160
+ | JSONObject;
161
+
162
+ export interface Logger {
163
+ (msg: string): void;
164
+ success(msg: string): void;
165
+ error(msg: string): void;
166
+ warn(msg: string): void;
167
+ minor(msg: string): void;
168
+ info(msg: string): void;
169
+ }
170
+
171
+ export type MaybePromise<T> = T | Promise<T>;
172
+
173
+ export interface Prerendered {
174
+ pages: Map<
175
+ string,
176
+ {
177
+ /** The location of the .html file relative to the output directory */
178
+ file: string;
179
+ }
180
+ >;
181
+ assets: Map<
182
+ string,
183
+ {
184
+ /** The MIME type of the asset */
185
+ type: string;
186
+ }
187
+ >;
188
+ redirects: Map<
189
+ string,
190
+ {
191
+ status: number;
192
+ location: string;
193
+ }
194
+ >;
195
+ /** An array of prerendered paths (without trailing slashes, regardless of the trailingSlash config) */
196
+ paths: string[];
197
+ }
198
+
199
+ export interface PrerenderErrorHandler {
200
+ (details: {
201
+ status: number;
202
+ path: string;
203
+ referrer: string | null;
204
+ referenceType: 'linked' | 'fetched';
205
+ }): void;
206
+ }
207
+
208
+ export type PrerenderOnErrorValue = 'fail' | 'continue' | PrerenderErrorHandler;
209
+
210
+ export interface RequestOptions {
211
+ getClientAddress: () => string;
212
+ platform?: App.Platform;
213
+ }
214
+
215
+ /** `string[]` is only for set-cookie, everything else must be type of `string` */
216
+ export type ResponseHeaders = Record<string, string | number | string[] | null>;
217
+
218
+ export interface RouteDefinition {
219
+ id: string;
220
+ type: 'page' | 'endpoint';
221
+ pattern: RegExp;
222
+ segments: RouteSegment[];
223
+ methods: HttpMethod[];
224
+ }
225
+
226
+ export interface RouteSegment {
227
+ content: string;
228
+ dynamic: boolean;
229
+ rest: boolean;
230
+ }
231
+
232
+ export interface ToJSON {
233
+ toJSON(...args: any[]): Exclude<JSONValue, ToJSON>;
234
+ }
235
+
236
+ export type TrailingSlash = 'never' | 'always' | 'ignore';