@sveltejs/kit 1.0.0-next.52 → 1.0.0-next.520

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