@sveltejs/kit 1.0.0-next.55 → 1.0.0-next.550
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 +5 -2
- package/package.json +93 -67
- package/postinstall.js +47 -0
- package/scripts/special-types/$env+dynamic+private.md +10 -0
- package/scripts/special-types/$env+dynamic+public.md +8 -0
- package/scripts/special-types/$env+static+private.md +19 -0
- package/scripts/special-types/$env+static+public.md +7 -0
- package/scripts/special-types/$lib.md +5 -0
- package/src/cli.js +108 -0
- package/src/constants.js +5 -0
- package/src/core/adapt/builder.js +212 -0
- package/src/core/adapt/index.js +31 -0
- package/src/core/config/default-error.html +56 -0
- package/src/core/config/index.js +110 -0
- package/src/core/config/options.js +516 -0
- package/src/core/config/types.d.ts +1 -0
- package/src/core/env.js +121 -0
- package/src/core/generate_manifest/index.js +125 -0
- package/src/core/prerender/crawl.js +207 -0
- package/src/core/prerender/entities.js +2252 -0
- package/src/core/prerender/prerender.js +460 -0
- package/src/core/prerender/queue.js +80 -0
- package/src/core/sync/create_manifest_data/conflict.js +0 -0
- package/src/core/sync/create_manifest_data/index.js +513 -0
- package/src/core/sync/create_manifest_data/sort.js +161 -0
- package/src/core/sync/create_manifest_data/types.d.ts +37 -0
- package/src/core/sync/sync.js +78 -0
- package/src/core/sync/utils.js +33 -0
- package/src/core/sync/write_ambient.js +53 -0
- package/src/core/sync/write_client_manifest.js +106 -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/index.js +809 -0
- package/src/core/utils.js +67 -0
- package/src/exports/hooks/index.js +1 -0
- package/src/exports/hooks/sequence.js +44 -0
- package/src/exports/index.js +45 -0
- package/src/exports/node/index.js +172 -0
- package/src/exports/node/polyfills.js +28 -0
- package/src/exports/vite/build/build_server.js +384 -0
- package/src/exports/vite/build/build_service_worker.js +92 -0
- package/src/exports/vite/build/utils.js +195 -0
- package/src/exports/vite/dev/index.js +588 -0
- package/src/exports/vite/graph_analysis/index.js +107 -0
- package/src/exports/vite/graph_analysis/types.d.ts +5 -0
- package/src/exports/vite/graph_analysis/utils.js +6 -0
- package/src/exports/vite/index.js +651 -0
- package/src/exports/vite/preview/index.js +193 -0
- package/src/exports/vite/types.d.ts +3 -0
- package/src/exports/vite/utils.js +171 -0
- package/src/runtime/app/env.js +1 -0
- package/src/runtime/app/environment.js +11 -0
- package/src/runtime/app/forms.js +141 -0
- package/src/runtime/app/navigation.js +23 -0
- package/src/runtime/app/paths.js +1 -0
- package/src/runtime/app/stores.js +102 -0
- package/src/runtime/client/ambient.d.ts +30 -0
- package/src/runtime/client/client.js +1726 -0
- package/src/runtime/client/fetcher.js +121 -0
- package/src/runtime/client/parse.js +60 -0
- package/src/runtime/client/singletons.js +21 -0
- package/src/runtime/client/start.js +43 -0
- package/src/runtime/client/types.d.ts +84 -0
- package/src/runtime/client/utils.js +166 -0
- package/src/runtime/components/error.svelte +16 -0
- package/{assets → src/runtime}/components/layout.svelte +0 -0
- package/src/runtime/control.js +98 -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 +6 -0
- package/src/runtime/env-public.js +6 -0
- package/src/runtime/env.js +6 -0
- package/src/runtime/hash.js +20 -0
- package/src/runtime/paths.js +11 -0
- package/src/runtime/server/cookie.js +231 -0
- package/src/runtime/server/data/index.js +144 -0
- package/src/runtime/server/endpoint.js +89 -0
- package/src/runtime/server/fetch.js +164 -0
- package/src/runtime/server/index.js +375 -0
- package/src/runtime/server/page/actions.js +258 -0
- package/src/runtime/server/page/crypto.js +239 -0
- package/src/runtime/server/page/csp.js +250 -0
- package/src/runtime/server/page/index.js +303 -0
- package/src/runtime/server/page/load_data.js +258 -0
- package/src/runtime/server/page/render.js +391 -0
- package/src/runtime/server/page/respond_with_error.js +102 -0
- package/src/runtime/server/page/serialize_data.js +87 -0
- package/src/runtime/server/page/types.d.ts +35 -0
- package/src/runtime/server/utils.js +205 -0
- package/src/utils/array.js +9 -0
- package/src/utils/error.js +22 -0
- package/src/utils/escape.js +46 -0
- package/src/utils/filesystem.js +166 -0
- package/src/utils/functions.js +16 -0
- package/src/utils/http.js +72 -0
- package/src/utils/misc.js +1 -0
- package/src/utils/promises.js +17 -0
- package/src/utils/routing.js +168 -0
- package/src/utils/unit_test.js +11 -0
- package/src/utils/url.js +159 -0
- package/svelte-kit.js +1 -1
- package/types/ambient.d.ts +469 -0
- package/types/index.d.ts +775 -0
- package/types/internal.d.ts +381 -0
- package/types/private.d.ts +229 -0
- package/CHANGELOG.md +0 -519
- package/assets/components/error.svelte +0 -13
- package/assets/runtime/app/env.js +0 -5
- package/assets/runtime/app/navigation.js +0 -48
- package/assets/runtime/app/paths.js +0 -1
- package/assets/runtime/app/stores.js +0 -93
- package/assets/runtime/chunks/utils.js +0 -22
- package/assets/runtime/internal/singletons.js +0 -23
- package/assets/runtime/internal/start.js +0 -823
- package/assets/runtime/paths.js +0 -12
- package/dist/chunks/index.js +0 -3544
- package/dist/chunks/index2.js +0 -572
- package/dist/chunks/index3.js +0 -246
- package/dist/chunks/index4.js +0 -569
- package/dist/chunks/index5.js +0 -751
- package/dist/chunks/index6.js +0 -323
- package/dist/chunks/standard.js +0 -99
- package/dist/chunks/utils.js +0 -83
- package/dist/cli.js +0 -558
- package/dist/ssr.js +0 -2620
- package/types.d.ts +0 -74
- package/types.internal.d.ts +0 -237
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { OutputAsset, OutputChunk } from 'rollup';
|
|
2
|
+
import { SvelteComponent } from 'svelte/internal';
|
|
3
|
+
import {
|
|
4
|
+
Config,
|
|
5
|
+
ServerLoad,
|
|
6
|
+
Handle,
|
|
7
|
+
HandleServerError,
|
|
8
|
+
KitConfig,
|
|
9
|
+
Load,
|
|
10
|
+
RequestEvent,
|
|
11
|
+
RequestHandler,
|
|
12
|
+
ResolveOptions,
|
|
13
|
+
Server,
|
|
14
|
+
ServerInitOptions,
|
|
15
|
+
SSRManifest,
|
|
16
|
+
HandleFetch,
|
|
17
|
+
Actions,
|
|
18
|
+
HandleClientError
|
|
19
|
+
} from './index.js';
|
|
20
|
+
import {
|
|
21
|
+
HttpMethod,
|
|
22
|
+
MaybePromise,
|
|
23
|
+
PrerenderOption,
|
|
24
|
+
RequestOptions,
|
|
25
|
+
TrailingSlash
|
|
26
|
+
} from './private.js';
|
|
27
|
+
|
|
28
|
+
export interface ServerModule {
|
|
29
|
+
Server: typeof InternalServer;
|
|
30
|
+
|
|
31
|
+
override(options: {
|
|
32
|
+
paths: {
|
|
33
|
+
base: string;
|
|
34
|
+
assets: string;
|
|
35
|
+
};
|
|
36
|
+
prerendering: boolean;
|
|
37
|
+
protocol?: 'http' | 'https';
|
|
38
|
+
read(file: string): Buffer;
|
|
39
|
+
}): void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface Asset {
|
|
43
|
+
file: string;
|
|
44
|
+
size: number;
|
|
45
|
+
type: string | null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface BuildData {
|
|
49
|
+
app_dir: string;
|
|
50
|
+
app_path: string;
|
|
51
|
+
manifest_data: ManifestData;
|
|
52
|
+
service_worker: string | null;
|
|
53
|
+
client: {
|
|
54
|
+
assets: OutputAsset[];
|
|
55
|
+
chunks: OutputChunk[];
|
|
56
|
+
entry: {
|
|
57
|
+
file: string;
|
|
58
|
+
imports: string[];
|
|
59
|
+
stylesheets: string[];
|
|
60
|
+
fonts: string[];
|
|
61
|
+
};
|
|
62
|
+
vite_manifest: import('vite').Manifest;
|
|
63
|
+
};
|
|
64
|
+
server: {
|
|
65
|
+
chunks: OutputChunk[];
|
|
66
|
+
methods: Record<string, HttpMethod[]>;
|
|
67
|
+
vite_manifest: import('vite').Manifest;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface CSRPageNode {
|
|
72
|
+
component: typeof SvelteComponent;
|
|
73
|
+
shared: {
|
|
74
|
+
load?: Load;
|
|
75
|
+
};
|
|
76
|
+
server: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type CSRPageNodeLoader = () => Promise<CSRPageNode>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Definition of a client side route.
|
|
83
|
+
* The boolean in the tuples indicates whether the route has a server load.
|
|
84
|
+
*/
|
|
85
|
+
export type CSRRoute = {
|
|
86
|
+
id: string;
|
|
87
|
+
exec(path: string): undefined | Record<string, string>;
|
|
88
|
+
errors: Array<CSRPageNodeLoader | undefined>;
|
|
89
|
+
layouts: Array<[boolean, CSRPageNodeLoader] | undefined>;
|
|
90
|
+
leaf: [boolean, CSRPageNodeLoader];
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export type GetParams = (match: RegExpExecArray) => Record<string, string>;
|
|
94
|
+
|
|
95
|
+
export interface ServerHooks {
|
|
96
|
+
handleFetch: HandleFetch;
|
|
97
|
+
handle: Handle;
|
|
98
|
+
handleError: HandleServerError;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface ClientHooks {
|
|
102
|
+
handleError: HandleClientError;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export class InternalServer extends Server {
|
|
106
|
+
init(options: ServerInitOptions): Promise<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 PageNode {
|
|
123
|
+
depth: number;
|
|
124
|
+
component?: string; // TODO supply default component if it's missing (bit of an edge case)
|
|
125
|
+
shared?: string;
|
|
126
|
+
server?: string;
|
|
127
|
+
parent_id?: string;
|
|
128
|
+
parent?: PageNode;
|
|
129
|
+
/**
|
|
130
|
+
* Filled with the pages that reference this layout (if this is a layout)
|
|
131
|
+
*/
|
|
132
|
+
child_pages?: PageNode[];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface PrerenderDependency {
|
|
136
|
+
response: Response;
|
|
137
|
+
body: null | string | Uint8Array;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface PrerenderOptions {
|
|
141
|
+
cache?: string; // including this here is a bit of a hack, but it makes it easy to add <meta http-equiv>
|
|
142
|
+
fallback?: boolean;
|
|
143
|
+
dependencies: Map<string, PrerenderDependency>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export type RecursiveRequired<T> = {
|
|
147
|
+
// Recursive implementation of TypeScript's Required utility type.
|
|
148
|
+
// Will recursively continue until it reaches a primitive or Function
|
|
149
|
+
[K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type
|
|
150
|
+
? RecursiveRequired<T[K]> // recursively continue through.
|
|
151
|
+
: T[K]; // Use the exact type for everything else
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export type RequiredResolveOptions = Required<ResolveOptions>;
|
|
155
|
+
|
|
156
|
+
export interface Respond {
|
|
157
|
+
(request: Request, options: SSROptions, state: SSRState): Promise<Response>;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Represents a route segment in the app. It can either be an intermediate node
|
|
162
|
+
* with only layout/error pages, or a leaf, at which point either `page` and `leaf`
|
|
163
|
+
* or `endpoint` is set.
|
|
164
|
+
*/
|
|
165
|
+
export interface RouteData {
|
|
166
|
+
id: string;
|
|
167
|
+
parent: RouteData | null;
|
|
168
|
+
|
|
169
|
+
segment: string;
|
|
170
|
+
pattern: RegExp;
|
|
171
|
+
names: string[];
|
|
172
|
+
types: string[];
|
|
173
|
+
optional: boolean[];
|
|
174
|
+
|
|
175
|
+
layout: PageNode | null;
|
|
176
|
+
error: PageNode | null;
|
|
177
|
+
leaf: PageNode | null;
|
|
178
|
+
|
|
179
|
+
page: {
|
|
180
|
+
layouts: Array<number | undefined>;
|
|
181
|
+
errors: Array<number | undefined>;
|
|
182
|
+
leaf: number;
|
|
183
|
+
} | null;
|
|
184
|
+
|
|
185
|
+
endpoint: {
|
|
186
|
+
file: string;
|
|
187
|
+
} | null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export type ServerData =
|
|
191
|
+
| {
|
|
192
|
+
type: 'redirect';
|
|
193
|
+
location: string;
|
|
194
|
+
}
|
|
195
|
+
| {
|
|
196
|
+
type: 'data';
|
|
197
|
+
/**
|
|
198
|
+
* If `null`, then there was no load function
|
|
199
|
+
*/
|
|
200
|
+
nodes: Array<ServerDataNode | ServerDataSkippedNode | ServerErrorNode | null>;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Signals a successful response of the server `load` function.
|
|
205
|
+
* The `uses` property tells the client when it's possible to reuse this data
|
|
206
|
+
* in a subsequent request.
|
|
207
|
+
*/
|
|
208
|
+
export interface ServerDataNode {
|
|
209
|
+
type: 'data';
|
|
210
|
+
data: Record<string, any> | null;
|
|
211
|
+
uses: Uses;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Signals that the server `load` function was not run, and the
|
|
216
|
+
* client should use what it has in memory
|
|
217
|
+
*/
|
|
218
|
+
export interface ServerDataSkippedNode {
|
|
219
|
+
type: 'skip';
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Signals that the server `load` function failed
|
|
224
|
+
*/
|
|
225
|
+
export interface ServerErrorNode {
|
|
226
|
+
type: 'error';
|
|
227
|
+
error: App.Error;
|
|
228
|
+
/**
|
|
229
|
+
* Only set for HttpErrors
|
|
230
|
+
*/
|
|
231
|
+
status?: number;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface SSRComponent {
|
|
235
|
+
default: {
|
|
236
|
+
render(props: Record<string, any>): {
|
|
237
|
+
html: string;
|
|
238
|
+
head: string;
|
|
239
|
+
css: {
|
|
240
|
+
code: string;
|
|
241
|
+
map: any; // TODO
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export type SSRComponentLoader = () => Promise<SSRComponent>;
|
|
248
|
+
|
|
249
|
+
export interface SSRNode {
|
|
250
|
+
component: SSRComponentLoader;
|
|
251
|
+
/** index into the `components` array in client-manifest.js */
|
|
252
|
+
index: number;
|
|
253
|
+
/** client-side module URL for this component */
|
|
254
|
+
file: string;
|
|
255
|
+
/** external JS files */
|
|
256
|
+
imports: string[];
|
|
257
|
+
/** external CSS files */
|
|
258
|
+
stylesheets: string[];
|
|
259
|
+
/** external font files */
|
|
260
|
+
fonts: string[];
|
|
261
|
+
/** inlined styles */
|
|
262
|
+
inline_styles?(): MaybePromise<Record<string, string>>;
|
|
263
|
+
|
|
264
|
+
shared: {
|
|
265
|
+
load?: Load;
|
|
266
|
+
prerender?: PrerenderOption;
|
|
267
|
+
ssr?: boolean;
|
|
268
|
+
csr?: boolean;
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
server: {
|
|
272
|
+
load?: ServerLoad;
|
|
273
|
+
prerender?: PrerenderOption;
|
|
274
|
+
ssr?: boolean;
|
|
275
|
+
csr?: boolean;
|
|
276
|
+
actions?: Actions;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
// store this in dev so we can print serialization errors
|
|
280
|
+
server_id?: string;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export type SSRNodeLoader = () => Promise<SSRNode>;
|
|
284
|
+
|
|
285
|
+
export interface SSROptions {
|
|
286
|
+
csp: ValidatedConfig['kit']['csp'];
|
|
287
|
+
csrf: {
|
|
288
|
+
check_origin: boolean;
|
|
289
|
+
};
|
|
290
|
+
dev: boolean;
|
|
291
|
+
handle_error(error: Error & { frame?: string }, event: RequestEvent): App.Error;
|
|
292
|
+
hooks: ServerHooks;
|
|
293
|
+
manifest: SSRManifest;
|
|
294
|
+
paths: {
|
|
295
|
+
base: string;
|
|
296
|
+
assets: string;
|
|
297
|
+
};
|
|
298
|
+
public_env: Record<string, string>;
|
|
299
|
+
read(file: string): Buffer;
|
|
300
|
+
root: SSRComponent['default'];
|
|
301
|
+
service_worker: boolean;
|
|
302
|
+
app_template({
|
|
303
|
+
head,
|
|
304
|
+
body,
|
|
305
|
+
assets,
|
|
306
|
+
nonce
|
|
307
|
+
}: {
|
|
308
|
+
head: string;
|
|
309
|
+
body: string;
|
|
310
|
+
assets: string;
|
|
311
|
+
nonce: string;
|
|
312
|
+
}): string;
|
|
313
|
+
app_template_contains_nonce: boolean;
|
|
314
|
+
error_template({ message, status }: { message: string; status: number }): string;
|
|
315
|
+
trailing_slash: TrailingSlash;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export interface SSRErrorPage {
|
|
319
|
+
id: '__error';
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export interface PageNodeIndexes {
|
|
323
|
+
errors: Array<number | undefined>;
|
|
324
|
+
layouts: Array<number | undefined>;
|
|
325
|
+
leaf: number;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export type SSREndpoint = Partial<Record<HttpMethod, RequestHandler>> & {
|
|
329
|
+
prerender?: PrerenderOption;
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
export interface SSRRoute {
|
|
333
|
+
id: string;
|
|
334
|
+
pattern: RegExp;
|
|
335
|
+
names: string[];
|
|
336
|
+
types: string[];
|
|
337
|
+
optional: boolean[];
|
|
338
|
+
|
|
339
|
+
page: PageNodeIndexes | null;
|
|
340
|
+
|
|
341
|
+
endpoint: (() => Promise<SSREndpoint>) | null;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface SSRState {
|
|
345
|
+
fallback?: string;
|
|
346
|
+
getClientAddress(): string;
|
|
347
|
+
initiator?: SSRRoute | SSRErrorPage;
|
|
348
|
+
platform?: any;
|
|
349
|
+
prerendering?: PrerenderOptions;
|
|
350
|
+
/**
|
|
351
|
+
* When fetching data from a +server.js endpoint in `load`, the page's
|
|
352
|
+
* prerender option is inherited by the endpoint, unless overridden
|
|
353
|
+
*/
|
|
354
|
+
prerender_default?: PrerenderOption;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export type StrictBody = string | ArrayBufferView;
|
|
358
|
+
|
|
359
|
+
export interface Uses {
|
|
360
|
+
dependencies: Set<string>;
|
|
361
|
+
params: Set<string>;
|
|
362
|
+
parent: boolean;
|
|
363
|
+
route: boolean;
|
|
364
|
+
url: boolean;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export type ValidatedConfig = RecursiveRequired<Config>;
|
|
368
|
+
|
|
369
|
+
export type ValidatedKitConfig = RecursiveRequired<KitConfig>;
|
|
370
|
+
|
|
371
|
+
export * from './index';
|
|
372
|
+
export * from './private';
|
|
373
|
+
|
|
374
|
+
declare global {
|
|
375
|
+
const __SVELTEKIT_ADAPTER_NAME__: string;
|
|
376
|
+
const __SVELTEKIT_APP_VERSION__: string;
|
|
377
|
+
const __SVELTEKIT_APP_VERSION_FILE__: string;
|
|
378
|
+
const __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: number;
|
|
379
|
+
const __SVELTEKIT_BROWSER__: boolean;
|
|
380
|
+
const __SVELTEKIT_DEV__: boolean;
|
|
381
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
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 =
|
|
57
|
+
| 'self'
|
|
58
|
+
| 'unsafe-eval'
|
|
59
|
+
| 'unsafe-hashes'
|
|
60
|
+
| 'unsafe-inline'
|
|
61
|
+
| 'wasm-unsafe-eval'
|
|
62
|
+
| 'none';
|
|
63
|
+
type CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`;
|
|
64
|
+
type FrameSource = HostSource | SchemeSource | 'self' | 'none';
|
|
65
|
+
type HostNameScheme = `${string}.${string}` | 'localhost';
|
|
66
|
+
type HostSource = `${HostProtocolSchemes}${HostNameScheme}${PortScheme}`;
|
|
67
|
+
type HostProtocolSchemes = `${string}://` | '';
|
|
68
|
+
type HttpDelineator = '/' | '?' | '#' | '\\';
|
|
69
|
+
type PortScheme = `:${number}` | '' | ':*';
|
|
70
|
+
type SchemeSource = 'http:' | 'https:' | 'data:' | 'mediastream:' | 'blob:' | 'filesystem:';
|
|
71
|
+
type Source = HostSource | SchemeSource | CryptoSource | BaseSource;
|
|
72
|
+
type Sources = Source[];
|
|
73
|
+
type UriPath = `${HttpDelineator}${string}`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface CspDirectives {
|
|
77
|
+
'child-src'?: Csp.Sources;
|
|
78
|
+
'default-src'?: Array<Csp.Source | Csp.ActionSource>;
|
|
79
|
+
'frame-src'?: Csp.Sources;
|
|
80
|
+
'worker-src'?: Csp.Sources;
|
|
81
|
+
'connect-src'?: Csp.Sources;
|
|
82
|
+
'font-src'?: Csp.Sources;
|
|
83
|
+
'img-src'?: Csp.Sources;
|
|
84
|
+
'manifest-src'?: Csp.Sources;
|
|
85
|
+
'media-src'?: Csp.Sources;
|
|
86
|
+
'object-src'?: Csp.Sources;
|
|
87
|
+
'prefetch-src'?: Csp.Sources;
|
|
88
|
+
'script-src'?: Array<Csp.Source | Csp.ActionSource>;
|
|
89
|
+
'script-src-elem'?: Csp.Sources;
|
|
90
|
+
'script-src-attr'?: Csp.Sources;
|
|
91
|
+
'style-src'?: Array<Csp.Source | Csp.ActionSource>;
|
|
92
|
+
'style-src-elem'?: Csp.Sources;
|
|
93
|
+
'style-src-attr'?: Csp.Sources;
|
|
94
|
+
'base-uri'?: Array<Csp.Source | Csp.ActionSource>;
|
|
95
|
+
sandbox?: Array<
|
|
96
|
+
| 'allow-downloads-without-user-activation'
|
|
97
|
+
| 'allow-forms'
|
|
98
|
+
| 'allow-modals'
|
|
99
|
+
| 'allow-orientation-lock'
|
|
100
|
+
| 'allow-pointer-lock'
|
|
101
|
+
| 'allow-popups'
|
|
102
|
+
| 'allow-popups-to-escape-sandbox'
|
|
103
|
+
| 'allow-presentation'
|
|
104
|
+
| 'allow-same-origin'
|
|
105
|
+
| 'allow-scripts'
|
|
106
|
+
| 'allow-storage-access-by-user-activation'
|
|
107
|
+
| 'allow-top-navigation'
|
|
108
|
+
| 'allow-top-navigation-by-user-activation'
|
|
109
|
+
>;
|
|
110
|
+
'form-action'?: Array<Csp.Source | Csp.ActionSource>;
|
|
111
|
+
'frame-ancestors'?: Array<Csp.HostSource | Csp.SchemeSource | Csp.FrameSource>;
|
|
112
|
+
'navigate-to'?: Array<Csp.Source | Csp.ActionSource>;
|
|
113
|
+
'report-uri'?: Csp.UriPath[];
|
|
114
|
+
'report-to'?: string[];
|
|
115
|
+
|
|
116
|
+
'require-trusted-types-for'?: Array<'script'>;
|
|
117
|
+
'trusted-types'?: Array<'none' | 'allow-duplicates' | '*' | string>;
|
|
118
|
+
'upgrade-insecure-requests'?: boolean;
|
|
119
|
+
|
|
120
|
+
/** @deprecated */
|
|
121
|
+
'require-sri-for'?: Array<'script' | 'style' | 'script style'>;
|
|
122
|
+
|
|
123
|
+
/** @deprecated */
|
|
124
|
+
'block-all-mixed-content'?: boolean;
|
|
125
|
+
|
|
126
|
+
/** @deprecated */
|
|
127
|
+
'plugin-types'?: Array<`${string}/${string}` | 'none'>;
|
|
128
|
+
|
|
129
|
+
/** @deprecated */
|
|
130
|
+
referrer?: Array<
|
|
131
|
+
| 'no-referrer'
|
|
132
|
+
| 'no-referrer-when-downgrade'
|
|
133
|
+
| 'origin'
|
|
134
|
+
| 'origin-when-cross-origin'
|
|
135
|
+
| 'same-origin'
|
|
136
|
+
| 'strict-origin'
|
|
137
|
+
| 'strict-origin-when-cross-origin'
|
|
138
|
+
| 'unsafe-url'
|
|
139
|
+
| 'none'
|
|
140
|
+
>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
144
|
+
|
|
145
|
+
export interface Logger {
|
|
146
|
+
(msg: string): void;
|
|
147
|
+
success(msg: string): void;
|
|
148
|
+
error(msg: string): void;
|
|
149
|
+
warn(msg: string): void;
|
|
150
|
+
minor(msg: string): void;
|
|
151
|
+
info(msg: string): void;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
155
|
+
|
|
156
|
+
export interface Prerendered {
|
|
157
|
+
pages: Map<
|
|
158
|
+
string,
|
|
159
|
+
{
|
|
160
|
+
/** The location of the .html file relative to the output directory */
|
|
161
|
+
file: string;
|
|
162
|
+
}
|
|
163
|
+
>;
|
|
164
|
+
assets: Map<
|
|
165
|
+
string,
|
|
166
|
+
{
|
|
167
|
+
/** The MIME type of the asset */
|
|
168
|
+
type: string;
|
|
169
|
+
}
|
|
170
|
+
>;
|
|
171
|
+
redirects: Map<
|
|
172
|
+
string,
|
|
173
|
+
{
|
|
174
|
+
status: number;
|
|
175
|
+
location: string;
|
|
176
|
+
}
|
|
177
|
+
>;
|
|
178
|
+
/** An array of prerendered paths (without trailing slashes, regardless of the trailingSlash config) */
|
|
179
|
+
paths: string[];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface PrerenderHttpErrorHandler {
|
|
183
|
+
(details: {
|
|
184
|
+
status: number;
|
|
185
|
+
path: string;
|
|
186
|
+
referrer: string | null;
|
|
187
|
+
referenceType: 'linked' | 'fetched';
|
|
188
|
+
}): void;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface PrerenderMissingIdHandler {
|
|
192
|
+
(details: { path: string; id: string; referrers: string[] }): void;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export type PrerenderHttpErrorHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderHttpErrorHandler;
|
|
196
|
+
export type PrerenderMissingIdHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderMissingIdHandler;
|
|
197
|
+
|
|
198
|
+
export type PrerenderOption = boolean | 'auto';
|
|
199
|
+
|
|
200
|
+
export type PrerenderMap = Map<string, PrerenderOption>;
|
|
201
|
+
|
|
202
|
+
export interface RequestOptions {
|
|
203
|
+
getClientAddress(): string;
|
|
204
|
+
platform?: App.Platform;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface RouteDefinition {
|
|
208
|
+
id: string;
|
|
209
|
+
pattern: RegExp;
|
|
210
|
+
segments: RouteSegment[];
|
|
211
|
+
methods: HttpMethod[];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface RouteSegment {
|
|
215
|
+
content: string;
|
|
216
|
+
dynamic: boolean;
|
|
217
|
+
rest: boolean;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export type TrailingSlash = 'never' | 'always' | 'ignore';
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* This doesn't actually exist, it's a way to better distinguish the type
|
|
224
|
+
*/
|
|
225
|
+
declare const uniqueSymbol: unique symbol;
|
|
226
|
+
|
|
227
|
+
export interface UniqueInterface {
|
|
228
|
+
readonly [uniqueSymbol]: unknown;
|
|
229
|
+
}
|