@sveltejs/kit 1.0.0-next.277 → 1.0.0-next.280
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/assets/client/start.js +12 -12
- package/assets/server/index.js +92 -97
- package/dist/chunks/amp_hook.js +1 -1
- package/dist/chunks/index.js +9 -9
- package/dist/chunks/index2.js +6 -6
- package/dist/chunks/index3.js +18 -18
- package/dist/chunks/index4.js +2 -2
- package/dist/chunks/index5.js +56 -66
- package/dist/chunks/index6.js +9 -9
- package/dist/chunks/index7.js +3 -3
- package/dist/cli.js +6 -6
- package/dist/hooks.js +4 -4
- package/dist/node.js +1 -1
- package/package.json +4 -3
- package/types/{ambient-modules.d.ts → ambient.d.ts} +0 -0
- package/types/index.d.ts +388 -21
- package/types/internal.d.ts +257 -145
- package/types/app.d.ts +0 -35
- package/types/config.d.ts +0 -200
- package/types/csp.d.ts +0 -115
- package/types/endpoint.d.ts +0 -39
- package/types/helper.d.ts +0 -23
- package/types/hooks.d.ts +0 -37
- package/types/page.d.ts +0 -33
package/types/internal.d.ts
CHANGED
|
@@ -1,24 +1,45 @@
|
|
|
1
1
|
import { OutputAsset, OutputChunk } from 'rollup';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import {
|
|
3
|
+
SSRManifest,
|
|
4
|
+
ValidatedConfig,
|
|
5
|
+
RequestHandler,
|
|
6
|
+
Load,
|
|
7
|
+
ExternalFetch,
|
|
8
|
+
GetSession,
|
|
9
|
+
Handle,
|
|
10
|
+
HandleError,
|
|
11
|
+
RequestEvent,
|
|
12
|
+
RequestOptions,
|
|
13
|
+
PrerenderErrorHandler,
|
|
14
|
+
Server
|
|
15
|
+
} from './index';
|
|
8
16
|
|
|
9
|
-
export interface
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
export interface AdapterEntry {
|
|
18
|
+
/**
|
|
19
|
+
* A string that uniquely identifies an HTTP service (e.g. serverless function) and is used for deduplication.
|
|
20
|
+
* For example, `/foo/a-[b]` and `/foo/[c]` are different routes, but would both
|
|
21
|
+
* be represented in a Netlify _redirects file as `/foo/:param`, so they share an ID
|
|
22
|
+
*/
|
|
23
|
+
id: string;
|
|
13
24
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
/**
|
|
26
|
+
* A function that compares the candidate route with the current route to determine
|
|
27
|
+
* if it should be treated as a fallback for the current route. For example, `/foo/[c]`
|
|
28
|
+
* is a fallback for `/foo/a-[b]`, and `/[...catchall]` is a fallback for all routes
|
|
29
|
+
*/
|
|
30
|
+
filter: (route: RouteDefinition) => boolean;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A function that is invoked once the entry has been created. This is where you
|
|
34
|
+
* should write the function to the filesystem and generate redirect manifests.
|
|
35
|
+
*/
|
|
36
|
+
complete: (entry: {
|
|
37
|
+
generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
|
|
38
|
+
}) => void;
|
|
18
39
|
}
|
|
19
40
|
|
|
20
|
-
export interface
|
|
21
|
-
|
|
41
|
+
export interface ServerModule {
|
|
42
|
+
Server: typeof InternalServer;
|
|
22
43
|
|
|
23
44
|
override(options: {
|
|
24
45
|
paths: {
|
|
@@ -31,6 +52,84 @@ export interface AppModule {
|
|
|
31
52
|
}): void;
|
|
32
53
|
}
|
|
33
54
|
|
|
55
|
+
export interface Asset {
|
|
56
|
+
file: string;
|
|
57
|
+
size: number;
|
|
58
|
+
type: string | null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type Body = JSONValue | Uint8Array | ReadableStream | import('stream').Readable;
|
|
62
|
+
|
|
63
|
+
export interface BuildData {
|
|
64
|
+
app_dir: string;
|
|
65
|
+
manifest_data: ManifestData;
|
|
66
|
+
service_worker: string | null;
|
|
67
|
+
client: {
|
|
68
|
+
assets: OutputAsset[];
|
|
69
|
+
chunks: OutputChunk[];
|
|
70
|
+
entry: {
|
|
71
|
+
file: string;
|
|
72
|
+
js: string[];
|
|
73
|
+
css: string[];
|
|
74
|
+
};
|
|
75
|
+
vite_manifest: import('vite').Manifest;
|
|
76
|
+
};
|
|
77
|
+
server: {
|
|
78
|
+
chunks: OutputChunk[];
|
|
79
|
+
methods: Record<string, HttpMethod[]>;
|
|
80
|
+
vite_manifest: import('vite').Manifest;
|
|
81
|
+
};
|
|
82
|
+
static: string[];
|
|
83
|
+
entries: string[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export type CSRComponent = any; // TODO
|
|
87
|
+
|
|
88
|
+
export type CSRComponentLoader = () => Promise<CSRComponent>;
|
|
89
|
+
|
|
90
|
+
export type CSRRoute = [RegExp, CSRComponentLoader[], CSRComponentLoader[], GetParams?, HasShadow?];
|
|
91
|
+
|
|
92
|
+
export type Either<T, U> = Only<T, U> | Only<U, T>;
|
|
93
|
+
|
|
94
|
+
export interface EndpointData {
|
|
95
|
+
type: 'endpoint';
|
|
96
|
+
key: string;
|
|
97
|
+
segments: RouteSegment[];
|
|
98
|
+
pattern: RegExp;
|
|
99
|
+
params: string[];
|
|
100
|
+
file: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface Fallthrough {
|
|
104
|
+
fallthrough: true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export type GetParams = (match: RegExpExecArray) => Record<string, string>;
|
|
108
|
+
|
|
109
|
+
type HasShadow = 1;
|
|
110
|
+
|
|
111
|
+
export interface Hooks {
|
|
112
|
+
externalFetch: ExternalFetch;
|
|
113
|
+
getSession: GetSession;
|
|
114
|
+
handle: Handle;
|
|
115
|
+
handleError: HandleError;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type HttpMethod = 'get' | 'head' | 'post' | 'put' | 'delete' | 'patch';
|
|
119
|
+
|
|
120
|
+
export class InternalServer extends Server {
|
|
121
|
+
respond(
|
|
122
|
+
request: Request,
|
|
123
|
+
options?: RequestOptions & {
|
|
124
|
+
prerender?: PrerenderOptions;
|
|
125
|
+
}
|
|
126
|
+
): Promise<Response>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export type JSONObject = { [key: string]: JSONValue };
|
|
130
|
+
|
|
131
|
+
export type JSONValue = string | number | boolean | null | ToJSON | JSONValue[] | JSONObject;
|
|
132
|
+
|
|
34
133
|
export interface Logger {
|
|
35
134
|
(msg: string): void;
|
|
36
135
|
success(msg: string): void;
|
|
@@ -40,6 +139,117 @@ export interface Logger {
|
|
|
40
139
|
info(msg: string): void;
|
|
41
140
|
}
|
|
42
141
|
|
|
142
|
+
export interface ManifestData {
|
|
143
|
+
assets: Asset[];
|
|
144
|
+
layout: string;
|
|
145
|
+
error: string;
|
|
146
|
+
components: string[];
|
|
147
|
+
routes: RouteData[];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
151
|
+
|
|
152
|
+
export interface MethodOverride {
|
|
153
|
+
parameter: string;
|
|
154
|
+
allowed: string[];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export type NormalizedLoadOutput = Either<
|
|
158
|
+
{
|
|
159
|
+
status: number;
|
|
160
|
+
error?: Error;
|
|
161
|
+
redirect?: string;
|
|
162
|
+
props?: Record<string, any> | Promise<Record<string, any>>;
|
|
163
|
+
stuff?: Record<string, any>;
|
|
164
|
+
maxage?: number;
|
|
165
|
+
},
|
|
166
|
+
Fallthrough
|
|
167
|
+
>;
|
|
168
|
+
|
|
169
|
+
type Only<T, U> = { [P in keyof T]: T[P] } & { [P in Exclude<keyof U, keyof T>]?: never };
|
|
170
|
+
|
|
171
|
+
export interface PageData {
|
|
172
|
+
type: 'page';
|
|
173
|
+
key: string;
|
|
174
|
+
shadow: string | null;
|
|
175
|
+
segments: RouteSegment[];
|
|
176
|
+
pattern: RegExp;
|
|
177
|
+
params: string[];
|
|
178
|
+
path: string;
|
|
179
|
+
a: string[];
|
|
180
|
+
b: string[];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface PrerenderDependency {
|
|
184
|
+
response: Response;
|
|
185
|
+
body: null | string | Uint8Array;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export type PrerenderOnErrorValue = 'fail' | 'continue' | PrerenderErrorHandler;
|
|
189
|
+
|
|
190
|
+
export interface PrerenderOptions {
|
|
191
|
+
fallback?: string;
|
|
192
|
+
all: boolean;
|
|
193
|
+
dependencies: Map<string, PrerenderDependency>;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export type RecursiveRequired<T> = {
|
|
197
|
+
// Recursive implementation of TypeScript's Required utility type.
|
|
198
|
+
// Will recursively continue until it reaches primitive or union
|
|
199
|
+
// with a Function in it, except those commented below
|
|
200
|
+
[K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type
|
|
201
|
+
? RecursiveRequired<T[K]> // recursively continue through.
|
|
202
|
+
: K extends 'vite' // If it reaches the 'vite' key
|
|
203
|
+
? Extract<T[K], Function> // only take the Function type.
|
|
204
|
+
: T[K]; // Use the exact type for everything else
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export interface RequiredResolveOptions {
|
|
208
|
+
ssr: boolean;
|
|
209
|
+
transformPage: ({ html }: { html: string }) => string;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface Respond {
|
|
213
|
+
(request: Request, options: SSROptions, state?: SSRState): Promise<Response>;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** `string[]` is only for set-cookie, everything else must be type of `string` */
|
|
217
|
+
export type ResponseHeaders = Record<string, string | number | string[]>;
|
|
218
|
+
|
|
219
|
+
export type RouteData = PageData | EndpointData;
|
|
220
|
+
|
|
221
|
+
export interface RouteDefinition {
|
|
222
|
+
type: 'page' | 'endpoint';
|
|
223
|
+
pattern: RegExp;
|
|
224
|
+
segments: RouteSegment[];
|
|
225
|
+
methods: HttpMethod[];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface RouteSegment {
|
|
229
|
+
content: string;
|
|
230
|
+
dynamic: boolean;
|
|
231
|
+
rest: boolean;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface ShadowEndpointOutput<Output extends JSONObject = JSONObject> {
|
|
235
|
+
status?: number;
|
|
236
|
+
headers?: Partial<ResponseHeaders>;
|
|
237
|
+
body?: Output;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface ShadowRequestHandler<Output extends JSONObject = JSONObject> {
|
|
241
|
+
(event: RequestEvent): MaybePromise<Either<ShadowEndpointOutput<Output>, Fallthrough>>;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export interface ShadowData {
|
|
245
|
+
fallthrough?: boolean;
|
|
246
|
+
status?: number;
|
|
247
|
+
error?: Error;
|
|
248
|
+
redirect?: string;
|
|
249
|
+
cookies?: string[];
|
|
250
|
+
body?: JSONObject;
|
|
251
|
+
}
|
|
252
|
+
|
|
43
253
|
export interface SSRComponent {
|
|
44
254
|
router?: boolean;
|
|
45
255
|
hydrate?: boolean;
|
|
@@ -59,37 +269,6 @@ export interface SSRComponent {
|
|
|
59
269
|
|
|
60
270
|
export type SSRComponentLoader = () => Promise<SSRComponent>;
|
|
61
271
|
|
|
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
272
|
export interface SSREndpoint {
|
|
94
273
|
type: 'endpoint';
|
|
95
274
|
pattern: RegExp;
|
|
@@ -99,20 +278,6 @@ export interface SSREndpoint {
|
|
|
99
278
|
}>;
|
|
100
279
|
}
|
|
101
280
|
|
|
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
281
|
export interface SSRNode {
|
|
117
282
|
module: SSRComponent;
|
|
118
283
|
/** client-side module URL for this component */
|
|
@@ -125,6 +290,8 @@ export interface SSRNode {
|
|
|
125
290
|
styles?: Record<string, string>;
|
|
126
291
|
}
|
|
127
292
|
|
|
293
|
+
export type SSRNodeLoader = () => Promise<SSRNode>;
|
|
294
|
+
|
|
128
295
|
export interface SSROptions {
|
|
129
296
|
amp: boolean;
|
|
130
297
|
csp: ValidatedConfig['kit']['csp'];
|
|
@@ -161,100 +328,45 @@ export interface SSROptions {
|
|
|
161
328
|
trailing_slash: TrailingSlash;
|
|
162
329
|
}
|
|
163
330
|
|
|
164
|
-
export interface
|
|
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 {
|
|
331
|
+
export interface SSRPage {
|
|
187
332
|
type: 'page';
|
|
188
|
-
key: string;
|
|
189
|
-
shadow: string | null;
|
|
190
|
-
segments: RouteSegment[];
|
|
191
333
|
pattern: RegExp;
|
|
192
|
-
params:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
334
|
+
params: GetParams;
|
|
335
|
+
shadow:
|
|
336
|
+
| null
|
|
337
|
+
| (() => Promise<{
|
|
338
|
+
[method: string]: ShadowRequestHandler;
|
|
339
|
+
}>);
|
|
340
|
+
/**
|
|
341
|
+
* plan a is to render 1 or more layout components followed by a leaf component.
|
|
342
|
+
*/
|
|
343
|
+
a: number[];
|
|
344
|
+
/**
|
|
345
|
+
* plan b — if one of them components fails in `load` we backtrack until we find
|
|
346
|
+
* the nearest error component.
|
|
347
|
+
*/
|
|
348
|
+
b: number[];
|
|
196
349
|
}
|
|
197
350
|
|
|
198
|
-
export interface
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
segments: RouteSegment[];
|
|
202
|
-
pattern: RegExp;
|
|
203
|
-
params: string[];
|
|
204
|
-
file: string;
|
|
351
|
+
export interface SSRPagePart {
|
|
352
|
+
id: string;
|
|
353
|
+
load: SSRComponentLoader;
|
|
205
354
|
}
|
|
206
355
|
|
|
207
|
-
export type
|
|
356
|
+
export type SSRRoute = SSREndpoint | SSRPage;
|
|
208
357
|
|
|
209
|
-
export interface
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
358
|
+
export interface SSRState {
|
|
359
|
+
fetched?: string;
|
|
360
|
+
initiator?: SSRPage | null;
|
|
361
|
+
platform?: any;
|
|
362
|
+
prerender?: PrerenderOptions;
|
|
363
|
+
fallback?: string;
|
|
215
364
|
}
|
|
216
365
|
|
|
217
|
-
export
|
|
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
|
-
}
|
|
366
|
+
export type StrictBody = string | Uint8Array;
|
|
239
367
|
|
|
240
|
-
|
|
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
|
-
>;
|
|
368
|
+
type ToJSON = { toJSON(...args: any[]): Exclude<JSONValue, ToJSON> };
|
|
251
369
|
|
|
252
370
|
export type TrailingSlash = 'never' | 'always' | 'ignore';
|
|
253
|
-
export interface MethodOverride {
|
|
254
|
-
parameter: string;
|
|
255
|
-
allowed: string[];
|
|
256
|
-
}
|
|
257
371
|
|
|
258
|
-
export
|
|
259
|
-
(request: Request, options: SSROptions, state?: SSRState): Promise<Response>;
|
|
260
|
-
}
|
|
372
|
+
export * from './index';
|
package/types/app.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { PrerenderOptions, SSRNodeLoader, SSRRoute } from './internal';
|
|
2
|
-
|
|
3
|
-
export interface RequestOptions<Platform = Record<string, any>> {
|
|
4
|
-
platform?: Platform;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export class App {
|
|
8
|
-
constructor(manifest: SSRManifest);
|
|
9
|
-
render(request: Request, options?: RequestOptions): Promise<Response>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class InternalApp extends App {
|
|
13
|
-
render(
|
|
14
|
-
request: Request,
|
|
15
|
-
options?: RequestOptions & {
|
|
16
|
-
prerender?: PrerenderOptions;
|
|
17
|
-
}
|
|
18
|
-
): Promise<Response>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface SSRManifest {
|
|
22
|
-
appDir: string;
|
|
23
|
-
assets: Set<string>;
|
|
24
|
-
/** private fields */
|
|
25
|
-
_: {
|
|
26
|
-
mime: Record<string, string>;
|
|
27
|
-
entry: {
|
|
28
|
-
file: string;
|
|
29
|
-
js: string[];
|
|
30
|
-
css: string[];
|
|
31
|
-
};
|
|
32
|
-
nodes: SSRNodeLoader[];
|
|
33
|
-
routes: SSRRoute[];
|
|
34
|
-
};
|
|
35
|
-
}
|
package/types/config.d.ts
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
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>;
|