@sveltejs/kit 1.0.0-next.46 → 1.0.0-next.460
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 +93 -65
- package/scripts/special-types/$env+dynamic+private.md +8 -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 +1 -0
- package/src/cli.js +112 -0
- package/src/constants.js +7 -0
- package/src/core/adapt/builder.js +207 -0
- package/src/core/adapt/index.js +31 -0
- package/src/core/config/default-error.html +56 -0
- package/src/core/config/index.js +105 -0
- package/src/core/config/options.js +498 -0
- package/src/core/config/types.d.ts +1 -0
- package/src/core/env.js +112 -0
- package/src/core/generate_manifest/index.js +78 -0
- package/src/core/prerender/crawl.js +194 -0
- package/src/core/prerender/prerender.js +425 -0
- package/src/core/prerender/queue.js +80 -0
- package/src/core/sync/create_manifest_data/index.js +452 -0
- package/src/core/sync/create_manifest_data/types.d.ts +37 -0
- package/src/core/sync/sync.js +59 -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 +94 -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 +595 -0
- package/src/core/utils.js +70 -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 +145 -0
- package/src/exports/node/polyfills.js +40 -0
- package/src/exports/vite/build/build_server.js +349 -0
- package/src/exports/vite/build/build_service_worker.js +90 -0
- package/src/exports/vite/build/utils.js +160 -0
- package/src/exports/vite/dev/index.js +543 -0
- package/src/exports/vite/index.js +595 -0
- package/src/exports/vite/preview/index.js +186 -0
- package/src/exports/vite/types.d.ts +3 -0
- package/src/exports/vite/utils.js +345 -0
- package/src/runtime/app/env.js +1 -0
- package/src/runtime/app/environment.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 +24 -0
- package/src/runtime/client/client.js +1387 -0
- package/src/runtime/client/fetcher.js +60 -0
- package/src/runtime/client/parse.js +60 -0
- package/src/runtime/client/singletons.js +21 -0
- package/src/runtime/client/start.js +45 -0
- package/src/runtime/client/types.d.ts +88 -0
- package/src/runtime/client/utils.js +140 -0
- package/src/runtime/components/error.svelte +16 -0
- package/{assets → src/runtime}/components/layout.svelte +0 -0
- package/src/runtime/control.js +33 -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 +16 -0
- package/src/runtime/paths.js +11 -0
- package/src/runtime/server/data/index.js +146 -0
- package/src/runtime/server/endpoint.js +63 -0
- package/src/runtime/server/index.js +339 -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 +269 -0
- package/src/runtime/server/page/index.js +404 -0
- package/src/runtime/server/page/load_data.js +124 -0
- package/src/runtime/server/page/render.js +358 -0
- package/src/runtime/server/page/respond_with_error.js +92 -0
- package/src/runtime/server/page/serialize_data.js +58 -0
- package/src/runtime/server/page/types.d.ts +44 -0
- package/src/runtime/server/utils.js +209 -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 +108 -0
- package/src/utils/functions.js +16 -0
- package/src/utils/http.js +55 -0
- package/src/utils/misc.js +1 -0
- package/src/utils/routing.js +137 -0
- package/src/utils/url.js +142 -0
- package/svelte-kit.js +1 -1
- package/types/ambient.d.ts +332 -0
- package/types/index.d.ts +343 -0
- package/types/internal.d.ts +383 -0
- package/types/private.d.ts +213 -0
- package/CHANGELOG.md +0 -456
- package/assets/components/error.svelte +0 -13
- package/assets/runtime/app/env.js +0 -5
- package/assets/runtime/app/navigation.js +0 -44
- 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 -771
- package/assets/runtime/paths.js +0 -12
- package/dist/chunks/index.js +0 -3522
- package/dist/chunks/index2.js +0 -587
- package/dist/chunks/index3.js +0 -246
- package/dist/chunks/index4.js +0 -539
- package/dist/chunks/index5.js +0 -763
- 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
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
/// <reference types="vite/client" />
|
|
3
|
+
|
|
4
|
+
import './ambient.js';
|
|
5
|
+
|
|
6
|
+
import { CompileOptions } from 'svelte/types/compiler/interfaces';
|
|
7
|
+
import {
|
|
8
|
+
AdapterEntry,
|
|
9
|
+
CspDirectives,
|
|
10
|
+
Logger,
|
|
11
|
+
MaybePromise,
|
|
12
|
+
Prerendered,
|
|
13
|
+
PrerenderOnErrorValue,
|
|
14
|
+
RequestOptions,
|
|
15
|
+
ResponseHeaders,
|
|
16
|
+
RouteDefinition,
|
|
17
|
+
TrailingSlash
|
|
18
|
+
} from './private.js';
|
|
19
|
+
import { SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal.js';
|
|
20
|
+
import { HttpError, Redirect } from '../src/runtime/control.js';
|
|
21
|
+
|
|
22
|
+
export { PrerenderOption } from './private.js';
|
|
23
|
+
|
|
24
|
+
export interface Adapter {
|
|
25
|
+
name: string;
|
|
26
|
+
adapt(builder: Builder): MaybePromise<void>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type AwaitedProperties<input extends Record<string, any> | void> = input extends void
|
|
30
|
+
? undefined // needs to be undefined, because void will break intellisense
|
|
31
|
+
: input extends Record<string, any>
|
|
32
|
+
? {
|
|
33
|
+
[key in keyof input]: Awaited<input[key]>;
|
|
34
|
+
}
|
|
35
|
+
: {} extends input // handles the any case
|
|
36
|
+
? input
|
|
37
|
+
: unknown;
|
|
38
|
+
|
|
39
|
+
export type AwaitedErrors<T extends (...args: any) => any> = Awaited<ReturnType<T>> extends {
|
|
40
|
+
errors?: any;
|
|
41
|
+
}
|
|
42
|
+
? Awaited<ReturnType<T>>['errors']
|
|
43
|
+
: undefined;
|
|
44
|
+
|
|
45
|
+
export interface Builder {
|
|
46
|
+
log: Logger;
|
|
47
|
+
rimraf(dir: string): void;
|
|
48
|
+
mkdirp(dir: string): void;
|
|
49
|
+
|
|
50
|
+
config: ValidatedConfig;
|
|
51
|
+
prerendered: Prerendered;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Create entry points that map to individual functions
|
|
55
|
+
* @param fn A function that groups a set of routes into an entry point
|
|
56
|
+
*/
|
|
57
|
+
createEntries(fn: (route: RouteDefinition) => AdapterEntry): Promise<void>;
|
|
58
|
+
|
|
59
|
+
generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
|
|
60
|
+
|
|
61
|
+
getBuildDirectory(name: string): string;
|
|
62
|
+
getClientDirectory(): string;
|
|
63
|
+
getServerDirectory(): string;
|
|
64
|
+
getStaticDirectory(): string;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param dest the destination folder to which files should be copied
|
|
68
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
69
|
+
*/
|
|
70
|
+
writeClient(dest: string): string[];
|
|
71
|
+
/**
|
|
72
|
+
* @param dest
|
|
73
|
+
*/
|
|
74
|
+
writePrerendered(
|
|
75
|
+
dest: string,
|
|
76
|
+
opts?: {
|
|
77
|
+
fallback?: string;
|
|
78
|
+
}
|
|
79
|
+
): string[];
|
|
80
|
+
/**
|
|
81
|
+
* @param dest the destination folder to which files should be copied
|
|
82
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
83
|
+
*/
|
|
84
|
+
writeServer(dest: string): string[];
|
|
85
|
+
/**
|
|
86
|
+
* @param from the source file or folder
|
|
87
|
+
* @param to the destination file or folder
|
|
88
|
+
* @param opts.filter a function to determine whether a file or folder should be copied
|
|
89
|
+
* @param opts.replace a map of strings to replace
|
|
90
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
91
|
+
*/
|
|
92
|
+
copy(
|
|
93
|
+
from: string,
|
|
94
|
+
to: string,
|
|
95
|
+
opts?: {
|
|
96
|
+
filter?: (basename: string) => boolean;
|
|
97
|
+
replace?: Record<string, string>;
|
|
98
|
+
}
|
|
99
|
+
): string[];
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @param {string} directory Path to the directory containing the files to be compressed
|
|
103
|
+
*/
|
|
104
|
+
compress(directory: string): Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface Config {
|
|
108
|
+
compilerOptions?: CompileOptions;
|
|
109
|
+
extensions?: string[];
|
|
110
|
+
kit?: KitConfig;
|
|
111
|
+
package?: {
|
|
112
|
+
source?: string;
|
|
113
|
+
dir?: string;
|
|
114
|
+
emitTypes?: boolean;
|
|
115
|
+
exports?: (filepath: string) => boolean;
|
|
116
|
+
files?: (filepath: string) => boolean;
|
|
117
|
+
};
|
|
118
|
+
preprocess?: any;
|
|
119
|
+
[key: string]: any;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface KitConfig {
|
|
123
|
+
adapter?: Adapter;
|
|
124
|
+
alias?: Record<string, string>;
|
|
125
|
+
appDir?: string;
|
|
126
|
+
csp?: {
|
|
127
|
+
mode?: 'hash' | 'nonce' | 'auto';
|
|
128
|
+
directives?: CspDirectives;
|
|
129
|
+
reportOnly?: CspDirectives;
|
|
130
|
+
};
|
|
131
|
+
env?: {
|
|
132
|
+
dir?: string;
|
|
133
|
+
publicPrefix?: string;
|
|
134
|
+
};
|
|
135
|
+
moduleExtensions?: string[];
|
|
136
|
+
files?: {
|
|
137
|
+
assets?: string;
|
|
138
|
+
hooks?: string;
|
|
139
|
+
lib?: string;
|
|
140
|
+
params?: string;
|
|
141
|
+
routes?: string;
|
|
142
|
+
serviceWorker?: string;
|
|
143
|
+
appTemplate?: string;
|
|
144
|
+
errorTemplate?: string;
|
|
145
|
+
};
|
|
146
|
+
inlineStyleThreshold?: number;
|
|
147
|
+
methodOverride?: {
|
|
148
|
+
parameter?: string;
|
|
149
|
+
allowed?: string[];
|
|
150
|
+
};
|
|
151
|
+
outDir?: string;
|
|
152
|
+
paths?: {
|
|
153
|
+
assets?: string;
|
|
154
|
+
base?: string;
|
|
155
|
+
};
|
|
156
|
+
prerender?: {
|
|
157
|
+
concurrency?: number;
|
|
158
|
+
crawl?: boolean;
|
|
159
|
+
default?: boolean;
|
|
160
|
+
enabled?: boolean;
|
|
161
|
+
entries?: Array<'*' | `/${string}`>;
|
|
162
|
+
onError?: PrerenderOnErrorValue;
|
|
163
|
+
origin?: string;
|
|
164
|
+
};
|
|
165
|
+
serviceWorker?: {
|
|
166
|
+
register?: boolean;
|
|
167
|
+
files?: (filepath: string) => boolean;
|
|
168
|
+
};
|
|
169
|
+
trailingSlash?: TrailingSlash;
|
|
170
|
+
version?: {
|
|
171
|
+
name?: string;
|
|
172
|
+
pollInterval?: number;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface ExternalFetch {
|
|
177
|
+
(req: Request): Promise<Response>;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface Handle {
|
|
181
|
+
(input: {
|
|
182
|
+
event: RequestEvent;
|
|
183
|
+
resolve(event: RequestEvent, opts?: ResolveOptions): MaybePromise<Response>;
|
|
184
|
+
}): MaybePromise<Response>;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface HandleError {
|
|
188
|
+
(input: { error: Error & { frame?: string }; event: RequestEvent }): void;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The generic form of `PageLoad` and `LayoutLoad`. You should import those from `./$types` (see [generated types](https://kit.svelte.dev/docs/types#generated-types))
|
|
193
|
+
* rather than using `Load` directly.
|
|
194
|
+
*/
|
|
195
|
+
export interface Load<
|
|
196
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
197
|
+
InputData extends Record<string, unknown> | null = Record<string, any> | null,
|
|
198
|
+
ParentData extends Record<string, unknown> = Record<string, any>,
|
|
199
|
+
OutputData extends Record<string, unknown> | void = Record<string, any> | void
|
|
200
|
+
> {
|
|
201
|
+
(event: LoadEvent<Params, InputData, ParentData>): MaybePromise<OutputData>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface LoadEvent<
|
|
205
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
206
|
+
Data extends Record<string, unknown> | null = Record<string, any> | null,
|
|
207
|
+
ParentData extends Record<string, unknown> = Record<string, any>
|
|
208
|
+
> {
|
|
209
|
+
fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
210
|
+
params: Params;
|
|
211
|
+
data: Data;
|
|
212
|
+
routeId: string | null;
|
|
213
|
+
setHeaders: (headers: ResponseHeaders) => void;
|
|
214
|
+
url: URL;
|
|
215
|
+
parent: () => Promise<ParentData>;
|
|
216
|
+
depends: (...deps: string[]) => void;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface Navigation {
|
|
220
|
+
from: URL;
|
|
221
|
+
to: URL;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface Page<Params extends Record<string, string> = Record<string, string>> {
|
|
225
|
+
url: URL;
|
|
226
|
+
params: Params;
|
|
227
|
+
routeId: string | null;
|
|
228
|
+
status: number;
|
|
229
|
+
error: HttpError | Error | null;
|
|
230
|
+
data: App.PageData & Record<string, any>;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface ParamMatcher {
|
|
234
|
+
(param: string): boolean;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export interface RequestEvent<
|
|
238
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>
|
|
239
|
+
> {
|
|
240
|
+
getClientAddress: () => string;
|
|
241
|
+
locals: App.Locals;
|
|
242
|
+
params: Params;
|
|
243
|
+
platform: Readonly<App.Platform>;
|
|
244
|
+
request: Request;
|
|
245
|
+
routeId: string | null;
|
|
246
|
+
setHeaders: (headers: ResponseHeaders) => void;
|
|
247
|
+
url: URL;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* A `(event: RequestEvent) => Response` function exported from a `+server.js` file that corresponds to an HTTP verb (`GET`, `PUT`, `PATCH`, etc) and handles requests with that method.
|
|
252
|
+
*
|
|
253
|
+
* It receives `Params` as the first generic argument, which you can skip by using [generated types](/docs/types#generated-types) instead.
|
|
254
|
+
*/
|
|
255
|
+
export interface RequestHandler<
|
|
256
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>
|
|
257
|
+
> {
|
|
258
|
+
(event: RequestEvent<Params>): MaybePromise<Response>;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export interface ResolveOptions {
|
|
262
|
+
transformPageChunk?: (input: { html: string; done: boolean }) => MaybePromise<string | undefined>;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export class Server {
|
|
266
|
+
constructor(manifest: SSRManifest);
|
|
267
|
+
init(options: ServerInitOptions): Promise<void>;
|
|
268
|
+
respond(request: Request, options: RequestOptions): Promise<Response>;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export interface ServerInitOptions {
|
|
272
|
+
env: Record<string, string>;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export interface SSRManifest {
|
|
276
|
+
appDir: string;
|
|
277
|
+
assets: Set<string>;
|
|
278
|
+
mimeTypes: Record<string, string>;
|
|
279
|
+
|
|
280
|
+
/** private fields */
|
|
281
|
+
_: {
|
|
282
|
+
entry: {
|
|
283
|
+
file: string;
|
|
284
|
+
imports: string[];
|
|
285
|
+
stylesheets: string[];
|
|
286
|
+
};
|
|
287
|
+
nodes: SSRNodeLoader[];
|
|
288
|
+
routes: SSRRoute[];
|
|
289
|
+
matchers: () => Promise<Record<string, ParamMatcher>>;
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* The generic form of `PageServerLoad` and `LayoutServerLoad`. You should import those from `./$types` (see [generated types](https://kit.svelte.dev/docs/types#generated-types))
|
|
295
|
+
* rather than using `ServerLoad` directly.
|
|
296
|
+
*/
|
|
297
|
+
export interface ServerLoad<
|
|
298
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
299
|
+
ParentData extends Record<string, any> = Record<string, any>,
|
|
300
|
+
OutputData extends Record<string, any> | void = Record<string, any> | void
|
|
301
|
+
> {
|
|
302
|
+
(event: ServerLoadEvent<Params, ParentData>): MaybePromise<OutputData>;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export interface ServerLoadEvent<
|
|
306
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
307
|
+
ParentData extends Record<string, any> = Record<string, any>
|
|
308
|
+
> extends RequestEvent<Params> {
|
|
309
|
+
parent: () => Promise<ParentData>;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export interface Action<
|
|
313
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>
|
|
314
|
+
> {
|
|
315
|
+
(event: RequestEvent<Params>): MaybePromise<
|
|
316
|
+
| { status?: number; errors: Record<string, any>; location?: never }
|
|
317
|
+
| { status?: never; errors?: never; location: string }
|
|
318
|
+
| void
|
|
319
|
+
>;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// TODO figure out how to just re-export from '../src/index/index.js' without
|
|
323
|
+
// breaking the site
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Creates an `HttpError` object with an HTTP status code and an optional message.
|
|
327
|
+
* This object, if thrown during request handling, will cause SvelteKit to
|
|
328
|
+
* return an error response without invoking `handleError`
|
|
329
|
+
* @param {number} status
|
|
330
|
+
* @param {string | undefined} [message]
|
|
331
|
+
*/
|
|
332
|
+
export function error(status: number, message?: string | undefined): HttpError;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Creates a `Redirect` object. If thrown during request handling, SvelteKit will
|
|
336
|
+
* return a redirect response.
|
|
337
|
+
*/
|
|
338
|
+
export function redirect(status: number, location: string): Redirect;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Generates a JSON `Response` object from the supplied data.
|
|
342
|
+
*/
|
|
343
|
+
export function json(data: any, init?: ResponseInit): Response;
|
|
@@ -0,0 +1,383 @@
|
|
|
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 {
|
|
20
|
+
HttpMethod,
|
|
21
|
+
MaybePromise,
|
|
22
|
+
PrerenderOption,
|
|
23
|
+
RequestOptions,
|
|
24
|
+
TrailingSlash
|
|
25
|
+
} from './private.js';
|
|
26
|
+
|
|
27
|
+
export interface ServerModule {
|
|
28
|
+
Server: typeof InternalServer;
|
|
29
|
+
|
|
30
|
+
override(options: {
|
|
31
|
+
paths: {
|
|
32
|
+
base: string;
|
|
33
|
+
assets: string;
|
|
34
|
+
};
|
|
35
|
+
prerendering: boolean;
|
|
36
|
+
protocol?: 'http' | 'https';
|
|
37
|
+
read(file: string): Buffer;
|
|
38
|
+
}): void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface Asset {
|
|
42
|
+
file: string;
|
|
43
|
+
size: number;
|
|
44
|
+
type: string | null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface BuildData {
|
|
48
|
+
app_dir: string;
|
|
49
|
+
manifest_data: ManifestData;
|
|
50
|
+
service_worker: string | null;
|
|
51
|
+
client: {
|
|
52
|
+
assets: OutputAsset[];
|
|
53
|
+
chunks: OutputChunk[];
|
|
54
|
+
entry: {
|
|
55
|
+
file: string;
|
|
56
|
+
imports: string[];
|
|
57
|
+
stylesheets: string[];
|
|
58
|
+
};
|
|
59
|
+
vite_manifest: import('vite').Manifest;
|
|
60
|
+
};
|
|
61
|
+
server: {
|
|
62
|
+
chunks: OutputChunk[];
|
|
63
|
+
methods: Record<string, HttpMethod[]>;
|
|
64
|
+
vite_manifest: import('vite').Manifest;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface CSRPageNode {
|
|
69
|
+
component: typeof SvelteComponent;
|
|
70
|
+
shared: {
|
|
71
|
+
load?: Load;
|
|
72
|
+
};
|
|
73
|
+
server: boolean;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export type CSRPageNodeLoader = () => Promise<CSRPageNode>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Definition of a client side route.
|
|
80
|
+
* The boolean in the tuples indicates whether the route has a server load.
|
|
81
|
+
*/
|
|
82
|
+
export type CSRRoute = {
|
|
83
|
+
id: string;
|
|
84
|
+
exec: (path: string) => undefined | Record<string, string>;
|
|
85
|
+
errors: Array<CSRPageNodeLoader | undefined>;
|
|
86
|
+
layouts: Array<[boolean, CSRPageNodeLoader] | undefined>;
|
|
87
|
+
leaf: [boolean, CSRPageNodeLoader];
|
|
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): Promise<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
|
+
depth: number;
|
|
127
|
+
component?: string; // TODO supply default component if it's missing (bit of an edge case)
|
|
128
|
+
shared?: string;
|
|
129
|
+
server?: string;
|
|
130
|
+
parent_id?: string;
|
|
131
|
+
parent?: PageNode;
|
|
132
|
+
/**
|
|
133
|
+
* Filled with the pages that reference this layout (if this is a layout)
|
|
134
|
+
*/
|
|
135
|
+
child_pages?: PageNode[];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface PrerenderDependency {
|
|
139
|
+
response: Response;
|
|
140
|
+
body: null | string | Uint8Array;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface PrerenderOptions {
|
|
144
|
+
cache?: string; // including this here is a bit of a hack, but it makes it easy to add <meta http-equiv>
|
|
145
|
+
fallback?: boolean;
|
|
146
|
+
dependencies: Map<string, PrerenderDependency>;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export type RecursiveRequired<T> = {
|
|
150
|
+
// Recursive implementation of TypeScript's Required utility type.
|
|
151
|
+
// Will recursively continue until it reaches a primitive or Function
|
|
152
|
+
[K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type
|
|
153
|
+
? RecursiveRequired<T[K]> // recursively continue through.
|
|
154
|
+
: T[K]; // Use the exact type for everything else
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export type RequiredResolveOptions = Required<ResolveOptions>;
|
|
158
|
+
|
|
159
|
+
export interface Respond {
|
|
160
|
+
(request: Request, options: SSROptions, state: SSRState): Promise<Response>;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Represents a route segment in the app. It can either be an intermediate node
|
|
165
|
+
* with only layout/error pages, or a leaf, at which point either `page` and `leaf`
|
|
166
|
+
* or `endpoint` is set.
|
|
167
|
+
*/
|
|
168
|
+
export interface RouteData {
|
|
169
|
+
id: string;
|
|
170
|
+
parent: RouteData | null;
|
|
171
|
+
|
|
172
|
+
segment: string;
|
|
173
|
+
pattern: RegExp;
|
|
174
|
+
names: string[];
|
|
175
|
+
types: string[];
|
|
176
|
+
|
|
177
|
+
layout: PageNode | null;
|
|
178
|
+
error: PageNode | null;
|
|
179
|
+
leaf: PageNode | null;
|
|
180
|
+
|
|
181
|
+
page: {
|
|
182
|
+
layouts: Array<number | undefined>;
|
|
183
|
+
errors: Array<number | undefined>;
|
|
184
|
+
leaf: number;
|
|
185
|
+
} | null;
|
|
186
|
+
|
|
187
|
+
endpoint: {
|
|
188
|
+
file: string;
|
|
189
|
+
} | null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export type ServerData =
|
|
193
|
+
| {
|
|
194
|
+
type: 'redirect';
|
|
195
|
+
location: string;
|
|
196
|
+
}
|
|
197
|
+
| {
|
|
198
|
+
type: 'data';
|
|
199
|
+
/**
|
|
200
|
+
* If `null`, then there was no load function
|
|
201
|
+
*/
|
|
202
|
+
nodes: Array<ServerDataNode | ServerDataSkippedNode | ServerErrorNode | null>;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Signals a successful response of the server `load` function.
|
|
207
|
+
* The `uses` property tells the client when it's possible to reuse this data
|
|
208
|
+
* in a subsequent request.
|
|
209
|
+
*/
|
|
210
|
+
export interface ServerDataNode {
|
|
211
|
+
type: 'data';
|
|
212
|
+
data: Record<string, any> | null;
|
|
213
|
+
uses: {
|
|
214
|
+
dependencies?: string[];
|
|
215
|
+
params?: string[];
|
|
216
|
+
parent?: number | void; // 1 or undefined
|
|
217
|
+
url?: number | void; // 1 or undefined
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Signals that the server `load` function was not run, and the
|
|
223
|
+
* client should use what it has in memory
|
|
224
|
+
*/
|
|
225
|
+
export interface ServerDataSkippedNode {
|
|
226
|
+
type: 'skip';
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Signals that the server `load` function failed
|
|
231
|
+
*/
|
|
232
|
+
export interface ServerErrorNode {
|
|
233
|
+
type: 'error';
|
|
234
|
+
// Either-or situation, but we don't want to have to do a type assertion
|
|
235
|
+
error?: Record<string, any>;
|
|
236
|
+
httperror?: { status: number; message: string };
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface SSRComponent {
|
|
240
|
+
default: {
|
|
241
|
+
render(props: Record<string, any>): {
|
|
242
|
+
html: string;
|
|
243
|
+
head: string;
|
|
244
|
+
css: {
|
|
245
|
+
code: string;
|
|
246
|
+
map: any; // TODO
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export type SSRComponentLoader = () => Promise<SSRComponent>;
|
|
253
|
+
|
|
254
|
+
export interface SSRNode {
|
|
255
|
+
component: SSRComponentLoader;
|
|
256
|
+
/** index into the `components` array in client-manifest.js */
|
|
257
|
+
index: number;
|
|
258
|
+
/** client-side module URL for this component */
|
|
259
|
+
file: string;
|
|
260
|
+
/** external JS files */
|
|
261
|
+
imports: string[];
|
|
262
|
+
/** external CSS files */
|
|
263
|
+
stylesheets: string[];
|
|
264
|
+
/** inlined styles */
|
|
265
|
+
inline_styles?: () => MaybePromise<Record<string, string>>;
|
|
266
|
+
|
|
267
|
+
shared: {
|
|
268
|
+
load?: Load;
|
|
269
|
+
prerender?: PrerenderOption;
|
|
270
|
+
ssr?: boolean;
|
|
271
|
+
csr?: boolean;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
server: {
|
|
275
|
+
load?: ServerLoad;
|
|
276
|
+
prerender?: PrerenderOption;
|
|
277
|
+
ssr?: boolean;
|
|
278
|
+
csr?: boolean;
|
|
279
|
+
POST?: Action;
|
|
280
|
+
PATCH?: Action;
|
|
281
|
+
PUT?: Action;
|
|
282
|
+
DELETE?: Action;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
// store this in dev so we can print serialization errors
|
|
286
|
+
server_id?: string;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export type SSRNodeLoader = () => Promise<SSRNode>;
|
|
290
|
+
|
|
291
|
+
export interface SSROptions {
|
|
292
|
+
csp: ValidatedConfig['kit']['csp'];
|
|
293
|
+
dev: boolean;
|
|
294
|
+
get_stack: (error: Error) => string | undefined;
|
|
295
|
+
handle_error(error: Error & { frame?: string }, event: RequestEvent): void;
|
|
296
|
+
hooks: Hooks;
|
|
297
|
+
manifest: SSRManifest;
|
|
298
|
+
method_override: MethodOverride;
|
|
299
|
+
paths: {
|
|
300
|
+
base: string;
|
|
301
|
+
assets: string;
|
|
302
|
+
};
|
|
303
|
+
public_env: Record<string, string>;
|
|
304
|
+
read(file: string): Buffer;
|
|
305
|
+
root: SSRComponent['default'];
|
|
306
|
+
service_worker?: string;
|
|
307
|
+
app_template({
|
|
308
|
+
head,
|
|
309
|
+
body,
|
|
310
|
+
assets,
|
|
311
|
+
nonce
|
|
312
|
+
}: {
|
|
313
|
+
head: string;
|
|
314
|
+
body: string;
|
|
315
|
+
assets: string;
|
|
316
|
+
nonce: string;
|
|
317
|
+
}): string;
|
|
318
|
+
app_template_contains_nonce: boolean;
|
|
319
|
+
error_template({ message, status }: { message: string; status: number }): string;
|
|
320
|
+
trailing_slash: TrailingSlash;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export interface SSRErrorPage {
|
|
324
|
+
id: '__error';
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export interface PageNodeIndexes {
|
|
328
|
+
errors: Array<number | undefined>;
|
|
329
|
+
layouts: Array<number | undefined>;
|
|
330
|
+
leaf: number;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export type SSREndpoint = Partial<Record<HttpMethod, RequestHandler>> & {
|
|
334
|
+
prerender?: PrerenderOption;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
export interface SSRRoute {
|
|
338
|
+
id: string;
|
|
339
|
+
pattern: RegExp;
|
|
340
|
+
names: string[];
|
|
341
|
+
types: string[];
|
|
342
|
+
|
|
343
|
+
page: PageNodeIndexes | null;
|
|
344
|
+
|
|
345
|
+
endpoint: (() => Promise<SSREndpoint>) | null;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export interface SSRState {
|
|
349
|
+
fallback?: string;
|
|
350
|
+
getClientAddress: () => string;
|
|
351
|
+
initiator?: SSRRoute | SSRErrorPage;
|
|
352
|
+
platform?: any;
|
|
353
|
+
prerendering?: PrerenderOptions;
|
|
354
|
+
/**
|
|
355
|
+
* When fetching data from a +server.js endpoint in `load`, the page's
|
|
356
|
+
* prerender option is inherited by the endpoint, unless overridden
|
|
357
|
+
*/
|
|
358
|
+
prerender_default?: PrerenderOption;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export type StrictBody = string | Uint8Array;
|
|
362
|
+
|
|
363
|
+
export interface Uses {
|
|
364
|
+
dependencies: Set<string>;
|
|
365
|
+
params: Set<string>;
|
|
366
|
+
parent: boolean;
|
|
367
|
+
url: boolean;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export type ValidatedConfig = RecursiveRequired<Config>;
|
|
371
|
+
|
|
372
|
+
export type ValidatedKitConfig = RecursiveRequired<KitConfig>;
|
|
373
|
+
|
|
374
|
+
export * from './index';
|
|
375
|
+
export * from './private';
|
|
376
|
+
|
|
377
|
+
declare global {
|
|
378
|
+
const __SVELTEKIT_ADAPTER_NAME__: string;
|
|
379
|
+
const __SVELTEKIT_APP_VERSION__: string;
|
|
380
|
+
const __SVELTEKIT_APP_VERSION_FILE__: string;
|
|
381
|
+
const __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: number;
|
|
382
|
+
const __SVELTEKIT_DEV__: boolean;
|
|
383
|
+
}
|