@sveltejs/kit 1.0.0-next.278 → 1.0.0-next.279
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 +12 -12
- package/dist/chunks/index4.js +2 -2
- package/dist/chunks/index5.js +50 -55
- package/dist/chunks/index6.js +2 -2
- 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 +255 -143
- 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/index.d.ts
CHANGED
|
@@ -1,24 +1,391 @@
|
|
|
1
1
|
/// <reference types="svelte" />
|
|
2
2
|
/// <reference types="vite/client" />
|
|
3
3
|
|
|
4
|
-
import '
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
import { CompileOptions } from 'svelte/types/compiler/interfaces';
|
|
5
|
+
import {
|
|
6
|
+
Logger,
|
|
7
|
+
PrerenderOnErrorValue,
|
|
8
|
+
SSRNodeLoader,
|
|
9
|
+
SSRRoute,
|
|
10
|
+
TrailingSlash,
|
|
11
|
+
Either,
|
|
12
|
+
MaybePromise,
|
|
13
|
+
RecursiveRequired,
|
|
14
|
+
RouteDefinition,
|
|
15
|
+
AdapterEntry,
|
|
16
|
+
ResponseHeaders,
|
|
17
|
+
Fallthrough,
|
|
18
|
+
RequiredResolveOptions,
|
|
19
|
+
Body
|
|
20
|
+
} from './internal';
|
|
21
|
+
import './ambient';
|
|
22
|
+
|
|
23
|
+
export class App {
|
|
24
|
+
constructor(manifest: SSRManifest);
|
|
25
|
+
render(request: Request, options?: RequestOptions): Promise<Response>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface Adapter {
|
|
29
|
+
name: string;
|
|
30
|
+
adapt(builder: Builder): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface Builder {
|
|
34
|
+
log: Logger;
|
|
35
|
+
rimraf(dir: string): void;
|
|
36
|
+
mkdirp(dir: string): void;
|
|
37
|
+
|
|
38
|
+
appDir: string;
|
|
39
|
+
trailingSlash: 'always' | 'never' | 'ignore';
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Create entry points that map to individual functions
|
|
43
|
+
* @param fn A function that groups a set of routes into an entry point
|
|
44
|
+
*/
|
|
45
|
+
createEntries(fn: (route: RouteDefinition) => AdapterEntry): void;
|
|
46
|
+
|
|
47
|
+
generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
|
|
48
|
+
|
|
49
|
+
getBuildDirectory(name: string): string;
|
|
50
|
+
getClientDirectory(): string;
|
|
51
|
+
getServerDirectory(): string;
|
|
52
|
+
getStaticDirectory(): string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param dest the destination folder to which files should be copied
|
|
56
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
57
|
+
*/
|
|
58
|
+
writeClient(dest: string): string[];
|
|
59
|
+
/**
|
|
60
|
+
* @param dest the destination folder to which files should be copied
|
|
61
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
62
|
+
*/
|
|
63
|
+
writeServer(dest: string): string[];
|
|
64
|
+
/**
|
|
65
|
+
* @param dest the destination folder to which files should be copied
|
|
66
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
67
|
+
*/
|
|
68
|
+
writeStatic(dest: string): string[];
|
|
69
|
+
/**
|
|
70
|
+
* @param from the source file or folder
|
|
71
|
+
* @param to the destination file or folder
|
|
72
|
+
* @param opts.filter a function to determine whether a file or folder should be copied
|
|
73
|
+
* @param opts.replace a map of strings to replace
|
|
74
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
75
|
+
*/
|
|
76
|
+
copy(
|
|
77
|
+
from: string,
|
|
78
|
+
to: string,
|
|
79
|
+
opts?: {
|
|
80
|
+
filter?: (basename: string) => boolean;
|
|
81
|
+
replace?: Record<string, string>;
|
|
82
|
+
}
|
|
83
|
+
): string[];
|
|
84
|
+
|
|
85
|
+
prerender(options: { all?: boolean; dest: string; fallback?: string }): Promise<Prerendered>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface Config {
|
|
89
|
+
compilerOptions?: CompileOptions;
|
|
90
|
+
extensions?: string[];
|
|
91
|
+
kit?: {
|
|
92
|
+
adapter?: Adapter;
|
|
93
|
+
amp?: boolean;
|
|
94
|
+
appDir?: string;
|
|
95
|
+
browser?: {
|
|
96
|
+
hydrate?: boolean;
|
|
97
|
+
router?: boolean;
|
|
98
|
+
};
|
|
99
|
+
csp?: {
|
|
100
|
+
mode?: 'hash' | 'nonce' | 'auto';
|
|
101
|
+
directives?: CspDirectives;
|
|
102
|
+
};
|
|
103
|
+
files?: {
|
|
104
|
+
assets?: string;
|
|
105
|
+
hooks?: string;
|
|
106
|
+
lib?: string;
|
|
107
|
+
routes?: string;
|
|
108
|
+
serviceWorker?: string;
|
|
109
|
+
template?: string;
|
|
110
|
+
};
|
|
111
|
+
floc?: boolean;
|
|
112
|
+
inlineStyleThreshold?: number;
|
|
113
|
+
methodOverride?: {
|
|
114
|
+
parameter?: string;
|
|
115
|
+
allowed?: string[];
|
|
116
|
+
};
|
|
117
|
+
package?: {
|
|
118
|
+
dir?: string;
|
|
119
|
+
emitTypes?: boolean;
|
|
120
|
+
exports?(filepath: string): boolean;
|
|
121
|
+
files?(filepath: string): boolean;
|
|
122
|
+
};
|
|
123
|
+
paths?: {
|
|
124
|
+
assets?: string;
|
|
125
|
+
base?: string;
|
|
126
|
+
};
|
|
127
|
+
prerender?: {
|
|
128
|
+
concurrency?: number;
|
|
129
|
+
crawl?: boolean;
|
|
130
|
+
enabled?: boolean;
|
|
131
|
+
entries?: string[];
|
|
132
|
+
onError?: PrerenderOnErrorValue;
|
|
133
|
+
};
|
|
134
|
+
routes?: (filepath: string) => boolean;
|
|
135
|
+
serviceWorker?: {
|
|
136
|
+
register?: boolean;
|
|
137
|
+
files?: (filepath: string) => boolean;
|
|
138
|
+
};
|
|
139
|
+
trailingSlash?: TrailingSlash;
|
|
140
|
+
version?: {
|
|
141
|
+
name?: string;
|
|
142
|
+
pollInterval?: number;
|
|
143
|
+
};
|
|
144
|
+
vite?: import('vite').UserConfig | (() => MaybePromise<import('vite').UserConfig>);
|
|
145
|
+
};
|
|
146
|
+
preprocess?: any;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Based on https://github.com/josh-hemphill/csp-typed-directives/blob/latest/src/csp.types.ts
|
|
150
|
+
//
|
|
151
|
+
// MIT License
|
|
152
|
+
//
|
|
153
|
+
// Copyright (c) 2021-present, Joshua Hemphill
|
|
154
|
+
// Copyright (c) 2021, Tecnico Corporation
|
|
155
|
+
//
|
|
156
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
157
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
158
|
+
// in the Software without restriction, including without limitation the rights
|
|
159
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
160
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
161
|
+
// furnished to do so, subject to the following conditions:
|
|
162
|
+
//
|
|
163
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
164
|
+
// copies or substantial portions of the Software.
|
|
165
|
+
//
|
|
166
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
167
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
168
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
169
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
170
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
171
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
172
|
+
// SOFTWARE.
|
|
173
|
+
|
|
174
|
+
export namespace Csp {
|
|
175
|
+
type ActionSource = 'strict-dynamic' | 'report-sample';
|
|
176
|
+
type BaseSource = 'self' | 'unsafe-eval' | 'unsafe-hashes' | 'unsafe-inline' | 'none';
|
|
177
|
+
type CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`;
|
|
178
|
+
type FrameSource = HostSource | SchemeSource | 'self' | 'none';
|
|
179
|
+
type HostNameScheme = `${string}.${string}` | `localhost`;
|
|
180
|
+
type HostSource = `${HostProtocolSchemes}${HostNameScheme}${PortScheme}`;
|
|
181
|
+
type HostProtocolSchemes = `${string}://` | '';
|
|
182
|
+
type HttpDelineator = '/' | '?' | '#' | '\\';
|
|
183
|
+
type PortScheme = `:${number}` | '' | ':*';
|
|
184
|
+
type SchemeSource = 'http:' | 'https:' | 'data:' | 'mediastream:' | 'blob:' | 'filesystem:';
|
|
185
|
+
type Source = HostSource | SchemeSource | CryptoSource | BaseSource;
|
|
186
|
+
type Sources = Source[];
|
|
187
|
+
type UriPath = `${HttpDelineator}${string}`;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export type CspDirectives = {
|
|
191
|
+
'child-src'?: Csp.Sources;
|
|
192
|
+
'default-src'?: Array<Csp.Source | Csp.ActionSource>;
|
|
193
|
+
'frame-src'?: Csp.Sources;
|
|
194
|
+
'worker-src'?: Csp.Sources;
|
|
195
|
+
'connect-src'?: Csp.Sources;
|
|
196
|
+
'font-src'?: Csp.Sources;
|
|
197
|
+
'img-src'?: Csp.Sources;
|
|
198
|
+
'manifest-src'?: Csp.Sources;
|
|
199
|
+
'media-src'?: Csp.Sources;
|
|
200
|
+
'object-src'?: Csp.Sources;
|
|
201
|
+
'prefetch-src'?: Csp.Sources;
|
|
202
|
+
'script-src'?: Array<Csp.Source | Csp.ActionSource>;
|
|
203
|
+
'script-src-elem'?: Csp.Sources;
|
|
204
|
+
'script-src-attr'?: Csp.Sources;
|
|
205
|
+
'style-src'?: Array<Csp.Source | Csp.ActionSource>;
|
|
206
|
+
'style-src-elem'?: Csp.Sources;
|
|
207
|
+
'style-src-attr'?: Csp.Sources;
|
|
208
|
+
'base-uri'?: Array<Csp.Source | Csp.ActionSource>;
|
|
209
|
+
sandbox?: Array<
|
|
210
|
+
| 'allow-downloads-without-user-activation'
|
|
211
|
+
| 'allow-forms'
|
|
212
|
+
| 'allow-modals'
|
|
213
|
+
| 'allow-orientation-lock'
|
|
214
|
+
| 'allow-pointer-lock'
|
|
215
|
+
| 'allow-popups'
|
|
216
|
+
| 'allow-popups-to-escape-sandbox'
|
|
217
|
+
| 'allow-presentation'
|
|
218
|
+
| 'allow-same-origin'
|
|
219
|
+
| 'allow-scripts'
|
|
220
|
+
| 'allow-storage-access-by-user-activation'
|
|
221
|
+
| 'allow-top-navigation'
|
|
222
|
+
| 'allow-top-navigation-by-user-activation'
|
|
223
|
+
>;
|
|
224
|
+
'form-action'?: Array<Csp.Source | Csp.ActionSource>;
|
|
225
|
+
'frame-ancestors'?: Array<Csp.HostSource | Csp.SchemeSource | Csp.FrameSource>;
|
|
226
|
+
'navigate-to'?: Array<Csp.Source | Csp.ActionSource>;
|
|
227
|
+
'report-uri'?: Csp.UriPath[];
|
|
228
|
+
'report-to'?: string[];
|
|
229
|
+
|
|
230
|
+
'require-trusted-types-for'?: Array<'script'>;
|
|
231
|
+
'trusted-types'?: Array<'none' | 'allow-duplicates' | '*' | string>;
|
|
232
|
+
'upgrade-insecure-requests'?: boolean;
|
|
233
|
+
|
|
234
|
+
/** @deprecated */
|
|
235
|
+
'require-sri-for'?: Array<'script' | 'style' | 'script style'>;
|
|
236
|
+
|
|
237
|
+
/** @deprecated */
|
|
238
|
+
'block-all-mixed-content'?: boolean;
|
|
239
|
+
|
|
240
|
+
/** @deprecated */
|
|
241
|
+
'plugin-types'?: Array<`${string}/${string}` | 'none'>;
|
|
242
|
+
|
|
243
|
+
/** @deprecated */
|
|
244
|
+
referrer?: Array<
|
|
245
|
+
| 'no-referrer'
|
|
246
|
+
| 'no-referrer-when-downgrade'
|
|
247
|
+
| 'origin'
|
|
248
|
+
| 'origin-when-cross-origin'
|
|
249
|
+
| 'same-origin'
|
|
250
|
+
| 'strict-origin'
|
|
251
|
+
| 'strict-origin-when-cross-origin'
|
|
252
|
+
| 'unsafe-url'
|
|
253
|
+
| 'none'
|
|
254
|
+
>;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
export interface EndpointOutput<Output extends Body = Body> {
|
|
258
|
+
status?: number;
|
|
259
|
+
headers?: Headers | Partial<ResponseHeaders>;
|
|
260
|
+
body?: Output;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface ErrorLoad<Params = Record<string, string>, Props = Record<string, any>> {
|
|
264
|
+
(input: ErrorLoadInput<Params>): MaybePromise<LoadOutput<Props>>;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface ErrorLoadInput<Params = Record<string, string>> extends LoadInput<Params> {
|
|
268
|
+
status?: number;
|
|
269
|
+
error?: Error;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface ExternalFetch {
|
|
273
|
+
(req: Request): Promise<Response>;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export interface GetSession {
|
|
277
|
+
(event: RequestEvent): MaybePromise<App.Session>;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export interface Handle {
|
|
281
|
+
(input: {
|
|
282
|
+
event: RequestEvent;
|
|
283
|
+
resolve(event: RequestEvent, opts?: ResolveOptions): MaybePromise<Response>;
|
|
284
|
+
}): MaybePromise<Response>;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface HandleError {
|
|
288
|
+
(input: { error: Error & { frame?: string }; event: RequestEvent }): void;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export interface Load<Params = Record<string, string>, Props = Record<string, any>> {
|
|
292
|
+
(input: LoadInput<Params>): MaybePromise<Either<Fallthrough, LoadOutput<Props>>>;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface LoadInput<Params = Record<string, string>> {
|
|
296
|
+
url: URL;
|
|
297
|
+
params: Params;
|
|
298
|
+
props: Record<string, any>;
|
|
299
|
+
fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
300
|
+
session: App.Session;
|
|
301
|
+
stuff: Partial<App.Stuff>;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export interface LoadOutput<Props = Record<string, any>> {
|
|
305
|
+
status?: number;
|
|
306
|
+
error?: string | Error;
|
|
307
|
+
redirect?: string;
|
|
308
|
+
props?: Props;
|
|
309
|
+
stuff?: Partial<App.Stuff>;
|
|
310
|
+
maxage?: number;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export interface Prerendered {
|
|
314
|
+
pages: Map<
|
|
315
|
+
string,
|
|
316
|
+
{
|
|
317
|
+
/** The location of the .html file relative to the output directory */
|
|
318
|
+
file: string;
|
|
319
|
+
}
|
|
320
|
+
>;
|
|
321
|
+
assets: Map<
|
|
322
|
+
string,
|
|
323
|
+
{
|
|
324
|
+
/** The MIME type of the asset */
|
|
325
|
+
type: string;
|
|
326
|
+
}
|
|
327
|
+
>;
|
|
328
|
+
redirects: Map<
|
|
329
|
+
string,
|
|
330
|
+
{
|
|
331
|
+
status: number;
|
|
332
|
+
location: string;
|
|
333
|
+
}
|
|
334
|
+
>;
|
|
335
|
+
/** An array of prerendered paths (without trailing slashes, regardless of the trailingSlash config) */
|
|
336
|
+
paths: string[];
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export interface PrerenderErrorHandler {
|
|
340
|
+
(details: {
|
|
341
|
+
status: number;
|
|
342
|
+
path: string;
|
|
343
|
+
referrer: string | null;
|
|
344
|
+
referenceType: 'linked' | 'fetched';
|
|
345
|
+
}): void;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export interface RequestEvent {
|
|
349
|
+
request: Request;
|
|
350
|
+
url: URL;
|
|
351
|
+
params: Record<string, string>;
|
|
352
|
+
locals: App.Locals;
|
|
353
|
+
platform: Readonly<App.Platform>;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* A function exported from an endpoint that corresponds to an
|
|
358
|
+
* HTTP verb (get, put, patch, etc) and handles requests with
|
|
359
|
+
* that method. Note that since 'delete' is a reserved word in
|
|
360
|
+
* JavaScript, delete handles are called 'del' instead.
|
|
361
|
+
*/
|
|
362
|
+
export interface RequestHandler<Output extends Body = Body> {
|
|
363
|
+
(event: RequestEvent): MaybePromise<
|
|
364
|
+
Either<Output extends Response ? Response : EndpointOutput<Output>, Fallthrough>
|
|
365
|
+
>;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export interface RequestOptions {
|
|
369
|
+
platform?: App.Platform;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export type ResolveOptions = Partial<RequiredResolveOptions>;
|
|
373
|
+
|
|
374
|
+
export interface SSRManifest {
|
|
375
|
+
appDir: string;
|
|
376
|
+
assets: Set<string>;
|
|
377
|
+
/** private fields */
|
|
378
|
+
_: {
|
|
379
|
+
mime: Record<string, string>;
|
|
380
|
+
entry: {
|
|
381
|
+
file: string;
|
|
382
|
+
js: string[];
|
|
383
|
+
css: string[];
|
|
384
|
+
};
|
|
385
|
+
nodes: SSRNodeLoader[];
|
|
386
|
+
routes: SSRRoute[];
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// TODO should this be public?
|
|
391
|
+
export type ValidatedConfig = RecursiveRequired<Config>;
|