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