@sveltejs/kit 1.0.0-next.49 → 1.0.0-next.490
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 -66
- 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 +112 -0
- package/src/constants.js +7 -0
- package/src/core/adapt/builder.js +206 -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 +504 -0
- package/src/core/config/types.d.ts +1 -0
- package/src/core/env.js +121 -0
- package/src/core/generate_manifest/index.js +92 -0
- package/src/core/prerender/crawl.js +198 -0
- package/src/core/prerender/entities.js +2252 -0
- package/src/core/prerender/prerender.js +431 -0
- package/src/core/prerender/queue.js +80 -0
- package/src/core/sync/create_manifest_data/index.js +467 -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 +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 +678 -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 +168 -0
- package/src/exports/node/polyfills.js +41 -0
- package/src/exports/vite/build/build_server.js +372 -0
- package/src/exports/vite/build/build_service_worker.js +90 -0
- package/src/exports/vite/build/utils.js +162 -0
- package/src/exports/vite/dev/index.js +576 -0
- package/src/exports/vite/graph_analysis/index.js +277 -0
- package/src/exports/vite/graph_analysis/types.d.ts +5 -0
- package/src/exports/vite/graph_analysis/utils.js +30 -0
- package/src/exports/vite/index.js +598 -0
- package/src/exports/vite/preview/index.js +189 -0
- package/src/exports/vite/types.d.ts +3 -0
- package/src/exports/vite/utils.js +157 -0
- package/src/runtime/app/env.js +1 -0
- package/src/runtime/app/environment.js +11 -0
- package/src/runtime/app/forms.js +108 -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 +26 -0
- package/src/runtime/client/client.js +1581 -0
- package/src/runtime/client/fetcher.js +107 -0
- package/src/runtime/client/parse.js +60 -0
- package/src/runtime/client/singletons.js +21 -0
- package/src/runtime/client/start.js +37 -0
- package/src/runtime/client/types.d.ts +85 -0
- package/src/runtime/client/utils.js +159 -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 +16 -0
- package/src/runtime/paths.js +11 -0
- package/src/runtime/server/cookie.js +115 -0
- package/src/runtime/server/data/index.js +136 -0
- package/src/runtime/server/endpoint.js +83 -0
- package/src/runtime/server/index.js +337 -0
- package/src/runtime/server/page/actions.js +243 -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 +288 -0
- package/src/runtime/server/page/index.js +304 -0
- package/src/runtime/server/page/load_data.js +124 -0
- package/src/runtime/server/page/render.js +342 -0
- package/src/runtime/server/page/respond_with_error.js +104 -0
- package/src/runtime/server/page/serialize_data.js +87 -0
- package/src/runtime/server/page/types.d.ts +41 -0
- package/src/runtime/server/utils.js +179 -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 +137 -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 +117 -0
- package/src/utils/unit_test.js +11 -0
- package/src/utils/url.js +142 -0
- package/svelte-kit.js +1 -1
- package/types/ambient.d.ts +426 -0
- package/types/index.d.ts +428 -0
- package/types/internal.d.ts +378 -0
- package/types/private.d.ts +209 -0
- package/CHANGELOG.md +0 -476
- 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 -773
- package/assets/runtime/paths.js +0 -12
- package/dist/chunks/index.js +0 -3517
- package/dist/chunks/index2.js +0 -587
- package/dist/chunks/index3.js +0 -246
- package/dist/chunks/index4.js +0 -530
- 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 -553
- package/dist/ssr.js +0 -2584
- package/types.d.ts +0 -32
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
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
|
+
RouteDefinition,
|
|
16
|
+
TrailingSlash
|
|
17
|
+
} from './private.js';
|
|
18
|
+
import { SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal.js';
|
|
19
|
+
import { HttpError, Redirect } from '../src/runtime/control.js';
|
|
20
|
+
|
|
21
|
+
export { PrerenderOption } from './private.js';
|
|
22
|
+
|
|
23
|
+
export interface Adapter {
|
|
24
|
+
name: string;
|
|
25
|
+
adapt(builder: Builder): MaybePromise<void>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type AwaitedPropertiesUnion<input extends Record<string, any> | void> = input extends void
|
|
29
|
+
? undefined // needs to be undefined, because void will break intellisense
|
|
30
|
+
: input extends Record<string, any>
|
|
31
|
+
? {
|
|
32
|
+
[key in keyof input]: Awaited<input[key]>;
|
|
33
|
+
}
|
|
34
|
+
: {} extends input // handles the any case
|
|
35
|
+
? input
|
|
36
|
+
: unknown;
|
|
37
|
+
|
|
38
|
+
export type AwaitedProperties<input extends Record<string, any> | void> =
|
|
39
|
+
AwaitedPropertiesUnion<input> extends Record<string, any>
|
|
40
|
+
? OptionalUnion<AwaitedPropertiesUnion<input>>
|
|
41
|
+
: AwaitedPropertiesUnion<input>;
|
|
42
|
+
|
|
43
|
+
export type AwaitedActions<T extends Record<string, (...args: any) => any>> = {
|
|
44
|
+
[Key in keyof T]: OptionalUnion<UnpackValidationError<Awaited<ReturnType<T[Key]>>>>;
|
|
45
|
+
}[keyof T];
|
|
46
|
+
|
|
47
|
+
// Takes a union type and returns a union type where each type also has all properties
|
|
48
|
+
// of all possible types (typed as undefined), making accessing them more ergonomic
|
|
49
|
+
type OptionalUnion<
|
|
50
|
+
U extends Record<string, any>, // not unknown, else interfaces don't satisfy this constraint
|
|
51
|
+
A extends keyof U = U extends U ? keyof U : never
|
|
52
|
+
> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;
|
|
53
|
+
|
|
54
|
+
// Needs to be here, else ActionData will be resolved to unknown - probably because of "d.ts file imports .js file" in combination with allowJs
|
|
55
|
+
interface ValidationError<T extends Record<string, unknown> | undefined = undefined> {
|
|
56
|
+
status: number;
|
|
57
|
+
data: T;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
type UnpackValidationError<T> = T extends ValidationError<infer X> ? X : T;
|
|
61
|
+
|
|
62
|
+
export interface Builder {
|
|
63
|
+
log: Logger;
|
|
64
|
+
rimraf(dir: string): void;
|
|
65
|
+
mkdirp(dir: string): void;
|
|
66
|
+
|
|
67
|
+
config: ValidatedConfig;
|
|
68
|
+
prerendered: Prerendered;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Create entry points that map to individual functions
|
|
72
|
+
* @param fn A function that groups a set of routes into an entry point
|
|
73
|
+
*/
|
|
74
|
+
createEntries(fn: (route: RouteDefinition) => AdapterEntry): Promise<void>;
|
|
75
|
+
|
|
76
|
+
generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
|
|
77
|
+
|
|
78
|
+
getBuildDirectory(name: string): string;
|
|
79
|
+
getClientDirectory(): string;
|
|
80
|
+
getServerDirectory(): string;
|
|
81
|
+
getStaticDirectory(): string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param dest the destination folder to which files should be copied
|
|
85
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
86
|
+
*/
|
|
87
|
+
writeClient(dest: string): string[];
|
|
88
|
+
/**
|
|
89
|
+
* @param dest
|
|
90
|
+
*/
|
|
91
|
+
writePrerendered(
|
|
92
|
+
dest: string,
|
|
93
|
+
opts?: {
|
|
94
|
+
fallback?: string;
|
|
95
|
+
}
|
|
96
|
+
): string[];
|
|
97
|
+
/**
|
|
98
|
+
* @param dest the destination folder to which files should be copied
|
|
99
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
100
|
+
*/
|
|
101
|
+
writeServer(dest: string): string[];
|
|
102
|
+
/**
|
|
103
|
+
* @param from the source file or folder
|
|
104
|
+
* @param to the destination file or folder
|
|
105
|
+
* @param opts.filter a function to determine whether a file or folder should be copied
|
|
106
|
+
* @param opts.replace a map of strings to replace
|
|
107
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
108
|
+
*/
|
|
109
|
+
copy(
|
|
110
|
+
from: string,
|
|
111
|
+
to: string,
|
|
112
|
+
opts?: {
|
|
113
|
+
filter?: (basename: string) => boolean;
|
|
114
|
+
replace?: Record<string, string>;
|
|
115
|
+
}
|
|
116
|
+
): string[];
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @param {string} directory Path to the directory containing the files to be compressed
|
|
120
|
+
*/
|
|
121
|
+
compress(directory: string): Promise<void>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface Config {
|
|
125
|
+
compilerOptions?: CompileOptions;
|
|
126
|
+
extensions?: string[];
|
|
127
|
+
kit?: KitConfig;
|
|
128
|
+
package?: {
|
|
129
|
+
source?: string;
|
|
130
|
+
dir?: string;
|
|
131
|
+
emitTypes?: boolean;
|
|
132
|
+
exports?: (filepath: string) => boolean;
|
|
133
|
+
files?: (filepath: string) => boolean;
|
|
134
|
+
};
|
|
135
|
+
preprocess?: any;
|
|
136
|
+
[key: string]: any;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface Cookies {
|
|
140
|
+
/**
|
|
141
|
+
* Gets a cookie that was previously set with `cookies.set`, or from the request headers.
|
|
142
|
+
*/
|
|
143
|
+
get(name: string, opts?: import('cookie').CookieParseOptions): string | undefined;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Sets a cookie. This will add a `set-cookie` header to the response, but also make the cookie available via `cookies.get` during the current request.
|
|
147
|
+
*
|
|
148
|
+
* The `httpOnly` and `secure` options are `true` by default, and must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP. The `sameSite` option defaults to `lax`.
|
|
149
|
+
*
|
|
150
|
+
* By default, the `path` of a cookie is the 'directory' of the current pathname. In most cases you should explicitly set `path: '/'` to make the cookie available throughout your app.
|
|
151
|
+
*/
|
|
152
|
+
set(name: string, value: string, opts?: import('cookie').CookieSerializeOptions): void;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Deletes a cookie by setting its value to an empty string and setting the expiry date in the past.
|
|
156
|
+
*/
|
|
157
|
+
delete(name: string, opts?: import('cookie').CookieSerializeOptions): void;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface KitConfig {
|
|
161
|
+
adapter?: Adapter;
|
|
162
|
+
alias?: Record<string, string>;
|
|
163
|
+
appDir?: string;
|
|
164
|
+
csp?: {
|
|
165
|
+
mode?: 'hash' | 'nonce' | 'auto';
|
|
166
|
+
directives?: CspDirectives;
|
|
167
|
+
reportOnly?: CspDirectives;
|
|
168
|
+
};
|
|
169
|
+
csrf?: {
|
|
170
|
+
checkOrigin?: boolean;
|
|
171
|
+
};
|
|
172
|
+
env?: {
|
|
173
|
+
dir?: string;
|
|
174
|
+
publicPrefix?: string;
|
|
175
|
+
};
|
|
176
|
+
moduleExtensions?: string[];
|
|
177
|
+
files?: {
|
|
178
|
+
assets?: string;
|
|
179
|
+
hooks?: {
|
|
180
|
+
client?: string;
|
|
181
|
+
server?: string;
|
|
182
|
+
};
|
|
183
|
+
lib?: string;
|
|
184
|
+
params?: string;
|
|
185
|
+
routes?: string;
|
|
186
|
+
serviceWorker?: string;
|
|
187
|
+
appTemplate?: string;
|
|
188
|
+
errorTemplate?: string;
|
|
189
|
+
};
|
|
190
|
+
inlineStyleThreshold?: number;
|
|
191
|
+
outDir?: string;
|
|
192
|
+
paths?: {
|
|
193
|
+
assets?: string;
|
|
194
|
+
base?: string;
|
|
195
|
+
};
|
|
196
|
+
prerender?: {
|
|
197
|
+
concurrency?: number;
|
|
198
|
+
crawl?: boolean;
|
|
199
|
+
default?: boolean;
|
|
200
|
+
enabled?: boolean;
|
|
201
|
+
entries?: Array<'*' | `/${string}`>;
|
|
202
|
+
onError?: PrerenderOnErrorValue;
|
|
203
|
+
origin?: string;
|
|
204
|
+
};
|
|
205
|
+
serviceWorker?: {
|
|
206
|
+
register?: boolean;
|
|
207
|
+
files?: (filepath: string) => boolean;
|
|
208
|
+
};
|
|
209
|
+
trailingSlash?: TrailingSlash;
|
|
210
|
+
version?: {
|
|
211
|
+
name?: string;
|
|
212
|
+
pollInterval?: number;
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export interface Handle {
|
|
217
|
+
(input: {
|
|
218
|
+
event: RequestEvent;
|
|
219
|
+
resolve(event: RequestEvent, opts?: ResolveOptions): MaybePromise<Response>;
|
|
220
|
+
}): MaybePromise<Response>;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface HandleServerError {
|
|
224
|
+
(input: { error: unknown; event: RequestEvent }): void | App.PageError;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export interface HandleClientError {
|
|
228
|
+
(input: { error: unknown; event: NavigationEvent }): void | App.PageError;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface HandleFetch {
|
|
232
|
+
(input: { event: RequestEvent; request: Request; fetch: typeof fetch }): MaybePromise<Response>;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The generic form of `PageLoad` and `LayoutLoad`. You should import those from `./$types` (see [generated types](https://kit.svelte.dev/docs/types#generated-types))
|
|
237
|
+
* rather than using `Load` directly.
|
|
238
|
+
*/
|
|
239
|
+
export interface Load<
|
|
240
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
241
|
+
InputData extends Record<string, unknown> | null = Record<string, any> | null,
|
|
242
|
+
ParentData extends Record<string, unknown> = Record<string, any>,
|
|
243
|
+
OutputData extends Record<string, unknown> | void = Record<string, any> | void
|
|
244
|
+
> {
|
|
245
|
+
(event: LoadEvent<Params, InputData, ParentData>): MaybePromise<OutputData>;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface LoadEvent<
|
|
249
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
250
|
+
Data extends Record<string, unknown> | null = Record<string, any> | null,
|
|
251
|
+
ParentData extends Record<string, unknown> = Record<string, any>
|
|
252
|
+
> extends NavigationEvent<Params> {
|
|
253
|
+
fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
254
|
+
data: Data;
|
|
255
|
+
setHeaders: (headers: Record<string, string>) => void;
|
|
256
|
+
parent: () => Promise<ParentData>;
|
|
257
|
+
depends: (...deps: string[]) => void;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export interface NavigationEvent<
|
|
261
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>
|
|
262
|
+
> {
|
|
263
|
+
params: Params;
|
|
264
|
+
routeId: string | null;
|
|
265
|
+
url: URL;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export interface NavigationTarget {
|
|
269
|
+
params: Record<string, string> | null;
|
|
270
|
+
routeId: string | null;
|
|
271
|
+
url: URL;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export type NavigationType = 'load' | 'unload' | 'link' | 'goto' | 'popstate';
|
|
275
|
+
|
|
276
|
+
export interface Navigation {
|
|
277
|
+
from: NavigationTarget | null;
|
|
278
|
+
to: NavigationTarget | null;
|
|
279
|
+
type: NavigationType;
|
|
280
|
+
delta?: number;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export interface Page<Params extends Record<string, string> = Record<string, string>> {
|
|
284
|
+
url: URL;
|
|
285
|
+
params: Params;
|
|
286
|
+
routeId: string | null;
|
|
287
|
+
status: number;
|
|
288
|
+
error: App.PageError | null;
|
|
289
|
+
data: App.PageData & Record<string, any>;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export interface ParamMatcher {
|
|
293
|
+
(param: string): boolean;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export interface RequestEvent<
|
|
297
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>
|
|
298
|
+
> {
|
|
299
|
+
cookies: Cookies;
|
|
300
|
+
getClientAddress: () => string;
|
|
301
|
+
locals: App.Locals;
|
|
302
|
+
params: Params;
|
|
303
|
+
platform: Readonly<App.Platform>;
|
|
304
|
+
request: Request;
|
|
305
|
+
routeId: string | null;
|
|
306
|
+
setHeaders: (headers: Record<string, string>) => void;
|
|
307
|
+
url: URL;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* 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.
|
|
312
|
+
*
|
|
313
|
+
* It receives `Params` as the first generic argument, which you can skip by using [generated types](https://kit.svelte.dev/docs/types#generated-types) instead.
|
|
314
|
+
*/
|
|
315
|
+
export interface RequestHandler<
|
|
316
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>
|
|
317
|
+
> {
|
|
318
|
+
(event: RequestEvent<Params>): MaybePromise<Response>;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export interface ResolveOptions {
|
|
322
|
+
transformPageChunk?: (input: { html: string; done: boolean }) => MaybePromise<string | undefined>;
|
|
323
|
+
filterSerializedResponseHeaders?: (name: string, value: string) => boolean;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export class Server {
|
|
327
|
+
constructor(manifest: SSRManifest);
|
|
328
|
+
init(options: ServerInitOptions): Promise<void>;
|
|
329
|
+
respond(request: Request, options: RequestOptions): Promise<Response>;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export interface ServerInitOptions {
|
|
333
|
+
env: Record<string, string>;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export interface SSRManifest {
|
|
337
|
+
appDir: string;
|
|
338
|
+
assets: Set<string>;
|
|
339
|
+
mimeTypes: Record<string, string>;
|
|
340
|
+
|
|
341
|
+
/** private fields */
|
|
342
|
+
_: {
|
|
343
|
+
entry: {
|
|
344
|
+
file: string;
|
|
345
|
+
imports: string[];
|
|
346
|
+
stylesheets: string[];
|
|
347
|
+
};
|
|
348
|
+
nodes: SSRNodeLoader[];
|
|
349
|
+
routes: SSRRoute[];
|
|
350
|
+
matchers: () => Promise<Record<string, ParamMatcher>>;
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* The generic form of `PageServerLoad` and `LayoutServerLoad`. You should import those from `./$types` (see [generated types](https://kit.svelte.dev/docs/types#generated-types))
|
|
356
|
+
* rather than using `ServerLoad` directly.
|
|
357
|
+
*/
|
|
358
|
+
export interface ServerLoad<
|
|
359
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
360
|
+
ParentData extends Record<string, any> = Record<string, any>,
|
|
361
|
+
OutputData extends Record<string, any> | void = Record<string, any> | void
|
|
362
|
+
> {
|
|
363
|
+
(event: ServerLoadEvent<Params, ParentData>): MaybePromise<OutputData>;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export interface ServerLoadEvent<
|
|
367
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
368
|
+
ParentData extends Record<string, any> = Record<string, any>
|
|
369
|
+
> extends RequestEvent<Params> {
|
|
370
|
+
parent: () => Promise<ParentData>;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export interface Action<
|
|
374
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
375
|
+
OutputData extends Record<string, any> | void = Record<string, any> | void
|
|
376
|
+
> {
|
|
377
|
+
(event: RequestEvent<Params>): MaybePromise<OutputData>;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export type Actions<
|
|
381
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
382
|
+
OutputData extends Record<string, any> | void = Record<string, any> | void
|
|
383
|
+
> = Record<string, Action<Params, OutputData>>;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* When calling a form action via fetch, the response will be one of these shapes.
|
|
387
|
+
*/
|
|
388
|
+
export type ActionResult<
|
|
389
|
+
Success extends Record<string, unknown> | undefined = Record<string, any>,
|
|
390
|
+
Invalid extends Record<string, unknown> | undefined = Record<string, any>
|
|
391
|
+
> =
|
|
392
|
+
| { type: 'success'; status: number; data?: Success }
|
|
393
|
+
| { type: 'invalid'; status: number; data?: Invalid }
|
|
394
|
+
| { type: 'redirect'; status: number; location: string }
|
|
395
|
+
| { type: 'error'; error: any };
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Creates an `HttpError` object with an HTTP status code and an optional message.
|
|
399
|
+
* This object, if thrown during request handling, will cause SvelteKit to
|
|
400
|
+
* return an error response without invoking `handleError`
|
|
401
|
+
* @param status The HTTP status code
|
|
402
|
+
* @param body An object that conforms to the App.PageError type. If a string is passed, it will be used as the message property.
|
|
403
|
+
*/
|
|
404
|
+
export function error(status: number, body: App.PageError): HttpError;
|
|
405
|
+
export function error(
|
|
406
|
+
status: number,
|
|
407
|
+
// this overload ensures you can omit the argument or pass in a string if App.PageError is of type { message: string }
|
|
408
|
+
body?: { message: string } extends App.PageError ? App.PageError | string | undefined : never
|
|
409
|
+
): HttpError;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Creates a `Redirect` object. If thrown during request handling, SvelteKit will
|
|
413
|
+
* return a redirect response.
|
|
414
|
+
*/
|
|
415
|
+
export function redirect(status: number, location: string): Redirect;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Generates a JSON `Response` object from the supplied data.
|
|
419
|
+
*/
|
|
420
|
+
export function json(data: any, init?: ResponseInit): Response;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Generates a `ValidationError` object.
|
|
424
|
+
*/
|
|
425
|
+
export function invalid<T extends Record<string, unknown> | undefined>(
|
|
426
|
+
status: number,
|
|
427
|
+
data?: T
|
|
428
|
+
): ValidationError<T>;
|