@sveltejs/kit 3.0.0-next.3 → 3.0.0-next.6
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/package.json +17 -17
- package/src/core/adapt/builder.js +18 -4
- package/src/core/adapt/index.js +1 -4
- package/src/core/config/index.js +64 -5
- package/src/core/config/options.js +73 -21
- package/src/core/env.js +35 -4
- package/src/core/postbuild/analyse.js +8 -12
- package/src/core/postbuild/crawl.js +22 -6
- package/src/core/postbuild/prerender.js +40 -23
- package/src/core/sync/create_manifest_data/index.js +23 -5
- package/src/core/sync/write_client_manifest.js +7 -0
- package/src/core/sync/write_server.js +13 -10
- package/src/core/sync/write_tsconfig.js +2 -4
- package/src/exports/index.js +32 -10
- package/src/exports/internal/env.js +1 -1
- package/src/exports/internal/index.js +6 -5
- package/src/exports/node/index.js +57 -6
- package/src/exports/public.d.ts +218 -114
- package/src/exports/vite/build/build_server.js +6 -1
- package/src/exports/vite/dev/index.js +10 -20
- package/src/exports/vite/index.js +306 -222
- package/src/exports/vite/preview/index.js +15 -7
- package/src/exports/vite/utils.js +8 -10
- package/src/runtime/app/env/types.d.ts +1 -1
- package/src/runtime/app/forms.js +22 -5
- package/src/runtime/app/paths/client.js +1 -3
- package/src/runtime/app/paths/public.d.ts +0 -28
- package/src/runtime/app/paths/server.js +7 -3
- package/src/runtime/app/server/remote/form.js +10 -3
- package/src/runtime/app/server/remote/query.js +3 -6
- package/src/runtime/app/server/remote/requested.js +8 -4
- package/src/runtime/app/server/remote/shared.js +5 -7
- package/src/runtime/client/client.js +190 -95
- package/src/runtime/client/fetcher.js +3 -2
- package/src/runtime/client/remote-functions/form.svelte.js +134 -24
- package/src/runtime/client/remote-functions/prerender.svelte.js +8 -2
- package/src/runtime/client/remote-functions/query/index.js +3 -2
- package/src/runtime/client/remote-functions/query/instance.svelte.js +26 -10
- package/src/runtime/client/remote-functions/query-batch.svelte.js +4 -3
- package/src/runtime/client/remote-functions/query-live/instance.svelte.js +26 -9
- package/src/runtime/client/remote-functions/shared.svelte.js +17 -7
- package/src/runtime/client/types.d.ts +9 -1
- package/src/runtime/client/utils.js +1 -1
- package/src/runtime/form-utils.js +84 -16
- package/src/runtime/server/cookie.js +22 -33
- package/src/runtime/server/csrf.js +65 -0
- package/src/runtime/server/data/index.js +7 -7
- package/src/runtime/server/env_module.js +0 -5
- package/src/runtime/server/index.js +1 -1
- package/src/runtime/server/page/actions.js +41 -26
- package/src/runtime/server/page/index.js +2 -1
- package/src/runtime/server/page/render.js +21 -23
- package/src/runtime/server/page/respond_with_error.js +7 -8
- package/src/runtime/server/remote.js +64 -27
- package/src/runtime/server/respond.js +81 -50
- package/src/runtime/server/utils.js +7 -7
- package/src/runtime/telemetry/otel.js +1 -1
- package/src/types/ambient.d.ts +5 -4
- package/src/types/global-private.d.ts +4 -4
- package/src/types/internal.d.ts +8 -10
- package/src/types/private.d.ts +33 -1
- package/src/types/synthetic/$lib.md +1 -1
- package/src/utils/error.js +11 -3
- package/src/utils/shared-iterator.js +5 -0
- package/src/utils/url.js +99 -2
- package/src/version.js +1 -1
- package/types/index.d.ts +340 -186
- package/types/index.d.ts.map +10 -9
package/types/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ declare module '@sveltejs/kit' {
|
|
|
8
8
|
// @ts-ignore this is an optional peer dependency so could be missing. Written like this so dts-buddy preserves the ts-ignore
|
|
9
9
|
type Span = import('@opentelemetry/api').Span;
|
|
10
10
|
|
|
11
|
+
type AppErrorWithOptionalStatus = Omit<App.Error, 'status'> & { status?: App.Error['status'] };
|
|
12
|
+
|
|
11
13
|
/**
|
|
12
14
|
* [Adapters](https://svelte.dev/docs/kit/adapters) are responsible for taking the production build and turning it into something that can be deployed to a platform of your choosing.
|
|
13
15
|
*/
|
|
@@ -90,7 +92,7 @@ declare module '@sveltejs/kit' {
|
|
|
90
92
|
/** Create `dir` and any required parent directories. */
|
|
91
93
|
mkdirp: (dir: string) => void;
|
|
92
94
|
|
|
93
|
-
/** The fully resolved
|
|
95
|
+
/** The fully resolved SvelteKit config. */
|
|
94
96
|
config: ValidatedConfig;
|
|
95
97
|
/** Information about prerendered pages and assets, if any. */
|
|
96
98
|
prerendered: Prerendered;
|
|
@@ -237,13 +239,13 @@ declare module '@sveltejs/kit' {
|
|
|
237
239
|
/**
|
|
238
240
|
* Gets a cookie that was previously set with `cookies.set`, or from the request headers.
|
|
239
241
|
* @param name the name of the cookie
|
|
240
|
-
* @param opts the options, passed directly to `cookie.
|
|
242
|
+
* @param opts the options, passed directly to `cookie.parseCookie`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
|
|
241
243
|
*/
|
|
242
244
|
get: (name: string, opts?: import('cookie').ParseOptions) => string | undefined;
|
|
243
245
|
|
|
244
246
|
/**
|
|
245
247
|
* Gets all cookies that were previously set with `cookies.set`, or from the request headers.
|
|
246
|
-
* @param opts the options, passed directly to `cookie.
|
|
248
|
+
* @param opts the options, passed directly to `cookie.parseCookie`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
|
|
247
249
|
*/
|
|
248
250
|
getAll: (opts?: import('cookie').ParseOptions) => Array<{ name: string; value: string }>;
|
|
249
251
|
|
|
@@ -255,7 +257,7 @@ declare module '@sveltejs/kit' {
|
|
|
255
257
|
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
256
258
|
* @param name the name of the cookie
|
|
257
259
|
* @param value the cookie value
|
|
258
|
-
* @param opts the options passed to `cookie.
|
|
260
|
+
* @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
|
|
259
261
|
*/
|
|
260
262
|
set: (name: string, value: string, opts: import('cookie').SerializeOptions) => void;
|
|
261
263
|
|
|
@@ -266,10 +268,34 @@ declare module '@sveltejs/kit' {
|
|
|
266
268
|
*
|
|
267
269
|
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
268
270
|
* @param name the name of the cookie
|
|
269
|
-
* @param opts the options passed to `cookie.
|
|
271
|
+
* @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
|
|
270
272
|
*/
|
|
271
273
|
delete: (name: string, opts: import('cookie').SerializeOptions) => void;
|
|
272
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Parses a single `Set-Cookie` header. This allows you to apply cookies received from an external source:
|
|
277
|
+
*
|
|
278
|
+
* ```js
|
|
279
|
+
* import { getRequestEvent } from '$app/server';
|
|
280
|
+
*
|
|
281
|
+
* export async function GET() {
|
|
282
|
+
* const { cookies } = getRequestEvent();
|
|
283
|
+
*
|
|
284
|
+
* const response = await fetch('...');
|
|
285
|
+
*
|
|
286
|
+
* for (const str of response.headers.getSetCookie()) {
|
|
287
|
+
* const { name, value, ...options } = cookies.parse(str);
|
|
288
|
+
* cookies.set(name, value, { ...options, path: '/' });
|
|
289
|
+
* }
|
|
290
|
+
*
|
|
291
|
+
* // ...
|
|
292
|
+
* }
|
|
293
|
+
* ```
|
|
294
|
+
*
|
|
295
|
+
* Note the use of `headers.getSetCookie()`, which returns an array of cookie headers, _not_ `headers.get('set-cookie')` which returns a single comma-separated string.
|
|
296
|
+
*/
|
|
297
|
+
parse: typeof import('cookie').parseSetCookie;
|
|
298
|
+
|
|
273
299
|
/**
|
|
274
300
|
* Serialize a cookie name-value pair into a `Set-Cookie` header string, but don't apply it to the response.
|
|
275
301
|
*
|
|
@@ -278,7 +304,7 @@ declare module '@sveltejs/kit' {
|
|
|
278
304
|
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
279
305
|
* @param name the name of the cookie
|
|
280
306
|
* @param value the cookie value
|
|
281
|
-
* @param opts the options passed to `cookie.
|
|
307
|
+
* @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
|
|
282
308
|
*/
|
|
283
309
|
serialize: (name: string, value: string, opts: import('cookie').SerializeOptions) => string;
|
|
284
310
|
}
|
|
@@ -295,35 +321,37 @@ declare module '@sveltejs/kit' {
|
|
|
295
321
|
}
|
|
296
322
|
|
|
297
323
|
export interface KitConfig {
|
|
298
|
-
// TODO: remove this in 4.0
|
|
299
324
|
/**
|
|
300
325
|
* Your [adapter](https://svelte.dev/docs/kit/adapters) is run when executing `vite build`. It determines how the output is converted for different platforms.
|
|
301
326
|
* @default undefined
|
|
302
|
-
* @deprecated removed in 3.0.0. Adapters should now be passed to the `sveltekit` Vite plugin in `vite.config.js`
|
|
303
327
|
*/
|
|
304
328
|
adapter?: Adapter;
|
|
305
329
|
/**
|
|
306
330
|
* An object containing zero or more aliases used to replace values in `import` statements. These aliases are automatically passed to Vite and TypeScript.
|
|
307
331
|
*
|
|
308
332
|
* ```js
|
|
309
|
-
* /// file:
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
333
|
+
* /// file: vite.config.js
|
|
334
|
+
* import { defineConfig } from 'vite';
|
|
335
|
+
* import { sveltekit } from '@sveltejs/kit/vite';
|
|
336
|
+
*
|
|
337
|
+
* export default defineConfig({
|
|
338
|
+
* plugins: [
|
|
339
|
+
* sveltekit({
|
|
340
|
+
* alias: {
|
|
341
|
+
* // this will match a file
|
|
342
|
+
* 'my-file': 'path/to/my-file.js',
|
|
343
|
+
*
|
|
344
|
+
* // this will match a directory and its contents
|
|
345
|
+
* // (`my-directory/x` resolves to `path/to/my-directory/x`)
|
|
346
|
+
* 'my-directory': 'path/to/my-directory',
|
|
347
|
+
*
|
|
348
|
+
* // an alias ending /* will only match
|
|
349
|
+
* // the contents of a directory, not the directory itself
|
|
350
|
+
* 'my-directory/*': 'path/to/my-directory/*'
|
|
351
|
+
* }
|
|
352
|
+
* })
|
|
353
|
+
* ]
|
|
354
|
+
* });
|
|
327
355
|
* ```
|
|
328
356
|
*
|
|
329
357
|
* > [!NOTE] You will need to run `npm run dev` to have SvelteKit automatically generate the required alias configuration in `jsconfig.json` or `tsconfig.json`.
|
|
@@ -341,24 +369,26 @@ declare module '@sveltejs/kit' {
|
|
|
341
369
|
* [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) configuration. CSP helps to protect your users against cross-site scripting (XSS) attacks, by limiting the places resources can be loaded from. For example, a configuration like this...
|
|
342
370
|
*
|
|
343
371
|
* ```js
|
|
344
|
-
* /// file:
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
372
|
+
* /// file: vite.config.js
|
|
373
|
+
* import { sveltekit } from '@sveltejs/kit/vite';
|
|
374
|
+
* import { defineConfig } from 'vite';
|
|
375
|
+
*
|
|
376
|
+
* export default defineConfig({
|
|
377
|
+
* plugins: [
|
|
378
|
+
* sveltekit({
|
|
379
|
+
* csp: {
|
|
380
|
+
* directives: {
|
|
381
|
+
* 'script-src': ['self']
|
|
382
|
+
* },
|
|
383
|
+
* // must be specified with either the `report-uri` or `report-to` directives, or both
|
|
384
|
+
* reportOnly: {
|
|
385
|
+
* 'script-src': ['self'],
|
|
386
|
+
* 'report-uri': ['/']
|
|
387
|
+
* }
|
|
388
|
+
* }
|
|
389
|
+
* })
|
|
390
|
+
* ]
|
|
391
|
+
* });
|
|
362
392
|
* ```
|
|
363
393
|
*
|
|
364
394
|
* ...would prevent scripts loading from external sites. SvelteKit will augment the specified directives with nonces or hashes (depending on `mode`) for any inline styles and scripts it generates.
|
|
@@ -564,7 +594,7 @@ declare module '@sveltejs/kit' {
|
|
|
564
594
|
*/
|
|
565
595
|
inlineStyleThreshold?: number;
|
|
566
596
|
/**
|
|
567
|
-
* An array of file extensions that SvelteKit will treat as modules. Files with extensions that match neither `config.extensions` nor `config.
|
|
597
|
+
* An array of file extensions that SvelteKit will treat as modules. Files with extensions that match neither `config.extensions` nor `config.moduleExtensions` will be ignored by the router.
|
|
568
598
|
* @default [".js", ".ts"]
|
|
569
599
|
*/
|
|
570
600
|
moduleExtensions?: string[];
|
|
@@ -646,14 +676,27 @@ declare module '@sveltejs/kit' {
|
|
|
646
676
|
*/
|
|
647
677
|
assets?: '' | `http://${string}` | `https://${string}`;
|
|
648
678
|
/**
|
|
649
|
-
* A root-relative path that must start, but not end with `/` (e.g. `/base-path`), unless it is the empty string. This specifies where your app is served from and allows the app to live on a non-root path. Note that you need to prepend all your root-relative links with the base value or they will point to the root of your domain, not your `base` (this is how the browser works). You can use [`
|
|
679
|
+
* A root-relative path that must start, but not end with `/` (e.g. `/base-path`), unless it is the empty string. This specifies where your app is served from and allows the app to live on a non-root path. Note that you need to prepend all your root-relative links with the base value or they will point to the root of your domain, not your `base` (this is how the browser works). You can use [`resolve(...)` from `$app/paths`](https://svelte.dev/docs/kit/$app-paths#resolve) for that: `<a href="{resolve('/your-page')}">Link</a>`. If you find yourself writing this often, it may make sense to extract this into a reusable component.
|
|
650
680
|
* @default ""
|
|
651
681
|
*/
|
|
652
682
|
base?: '' | `/${string}`;
|
|
683
|
+
/**
|
|
684
|
+
* The origin of your app, used for CSRF protection and prerendering.
|
|
685
|
+
*
|
|
686
|
+
* By default, this is `undefined`, meaning SvelteKit will derive the origin from `request.url` (which is set by the adapter, and ultimately by the platform).
|
|
687
|
+
*
|
|
688
|
+
* If your app is served from an origin that isn't known at request time — for example because it's deployed to a preview deployment whose URL isn't known at build time, or because it's behind a reverse proxy that doesn't pass the `host` header — you can set this to a string like `https://my-site.com`.
|
|
689
|
+
*
|
|
690
|
+
* This is also used as the value of `url.origin` during prerendering (when unset, it defaults to `http://sveltekit-prerender`), and as the trusted origin for CSRF checks on form submissions and remote function calls.
|
|
691
|
+
*
|
|
692
|
+
* @default undefined
|
|
693
|
+
* @since 3.0
|
|
694
|
+
*/
|
|
695
|
+
origin?: `http://${string}` | `https://${string}`;
|
|
653
696
|
/**
|
|
654
697
|
* Whether to use relative asset paths.
|
|
655
698
|
*
|
|
656
|
-
* If `true`, `
|
|
699
|
+
* If `true`, paths created with `resolve()` and `asset()` imported from `$app/paths` will be replaced with relative asset paths during server-side rendering, resulting in more portable HTML.
|
|
657
700
|
* If `false`, `%sveltekit.assets%` and references to build artifacts will always be root-relative paths, unless `paths.assets` is an external URL
|
|
658
701
|
*
|
|
659
702
|
* [Single-page app](https://svelte.dev/docs/kit/single-page-apps) fallback pages will always use absolute paths, regardless of this setting.
|
|
@@ -695,23 +738,27 @@ declare module '@sveltejs/kit' {
|
|
|
695
738
|
* - `(details) => void` — a custom error handler that takes a `details` object with `status`, `path`, `referrer`, `referenceType` and `message` properties. If you `throw` from this function, the build will fail
|
|
696
739
|
*
|
|
697
740
|
* ```js
|
|
698
|
-
* /// file:
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
* kit: {
|
|
702
|
-
* prerender: {
|
|
703
|
-
* handleHttpError: ({ path, referrer, message }) => {
|
|
704
|
-
* // ignore deliberate link to shiny 404 page
|
|
705
|
-
* if (path === '/not-found' && referrer === '/blog/how-we-built-our-404-page') {
|
|
706
|
-
* return;
|
|
707
|
-
* }
|
|
741
|
+
* /// file: vite.config.js
|
|
742
|
+
* import { sveltekit } from '@sveltejs/kit/vite';
|
|
743
|
+
* import { defineConfig } from 'vite';
|
|
708
744
|
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
745
|
+
* export default defineConfig({
|
|
746
|
+
* plugins: [
|
|
747
|
+
* sveltekit({
|
|
748
|
+
* prerender: {
|
|
749
|
+
* handleHttpError: ({ path, referrer, message }) => {
|
|
750
|
+
* // ignore deliberate link to shiny 404 page
|
|
751
|
+
* if (path === '/not-found' && referrer === '/blog/how-we-built-our-404-page') {
|
|
752
|
+
* return;
|
|
753
|
+
* }
|
|
754
|
+
*
|
|
755
|
+
* // otherwise fail the build
|
|
756
|
+
* throw new Error(message);
|
|
757
|
+
* }
|
|
758
|
+
* }
|
|
759
|
+
* })
|
|
760
|
+
* ]
|
|
761
|
+
* });
|
|
715
762
|
* ```
|
|
716
763
|
*
|
|
717
764
|
* @default "fail"
|
|
@@ -758,10 +805,17 @@ declare module '@sveltejs/kit' {
|
|
|
758
805
|
*/
|
|
759
806
|
handleUnseenRoutes?: PrerenderUnseenRoutesHandlerValue;
|
|
760
807
|
/**
|
|
761
|
-
*
|
|
762
|
-
*
|
|
808
|
+
* How to respond when SvelteKit encounters a URL it cannot parse while crawling prerendered HTML (for example, an AT Protocol URL such as `at://did:plc:...`).
|
|
809
|
+
*
|
|
810
|
+
* - `'fail'` — fail the build
|
|
811
|
+
* - `'ignore'` - silently ignore the failure and continue
|
|
812
|
+
* - `'warn'` — continue, but print a warning
|
|
813
|
+
* - `(details) => void` — a custom error handler that takes a `details` object with `href`, `referrer` and `message` properties. If you `throw` from this function, the build will fail
|
|
814
|
+
*
|
|
815
|
+
* @default "fail"
|
|
816
|
+
* @since 2.67.0
|
|
763
817
|
*/
|
|
764
|
-
|
|
818
|
+
handleInvalidUrl?: PrerenderInvalidUrlHandlerValue;
|
|
765
819
|
};
|
|
766
820
|
router?: {
|
|
767
821
|
/**
|
|
@@ -863,16 +917,20 @@ declare module '@sveltejs/kit' {
|
|
|
863
917
|
* For example, to use the current commit hash, you could do use `git rev-parse HEAD`:
|
|
864
918
|
*
|
|
865
919
|
* ```js
|
|
866
|
-
* /// file:
|
|
920
|
+
* /// file: vite.config.js
|
|
867
921
|
* import * as child_process from 'node:child_process';
|
|
922
|
+
* import { sveltekit } from '@sveltejs/kit/vite';
|
|
923
|
+
* import { defineConfig } from 'vite';
|
|
868
924
|
*
|
|
869
|
-
* export default {
|
|
870
|
-
*
|
|
871
|
-
*
|
|
872
|
-
*
|
|
873
|
-
*
|
|
874
|
-
*
|
|
875
|
-
*
|
|
925
|
+
* export default defineConfig({
|
|
926
|
+
* plugins: [
|
|
927
|
+
* sveltekit({
|
|
928
|
+
* version: {
|
|
929
|
+
* name: child_process.execSync('git rev-parse HEAD').toString().trim()
|
|
930
|
+
* }
|
|
931
|
+
* })
|
|
932
|
+
* ]
|
|
933
|
+
* });
|
|
876
934
|
* ```
|
|
877
935
|
*/
|
|
878
936
|
name?: string;
|
|
@@ -900,13 +958,16 @@ declare module '@sveltejs/kit' {
|
|
|
900
958
|
*
|
|
901
959
|
* If an unexpected error is thrown during loading or rendering, this function will be called with the error and the event.
|
|
902
960
|
* Make sure that this function _never_ throws an error.
|
|
961
|
+
*
|
|
962
|
+
* The returned object can include a `status` property to override the HTTP status code used in the response.
|
|
963
|
+
* If omitted, the status defaults to 500.
|
|
903
964
|
*/
|
|
904
965
|
export type HandleServerError = (input: {
|
|
905
966
|
error: unknown;
|
|
906
967
|
event: RequestEvent;
|
|
907
968
|
status: number;
|
|
908
969
|
message: string;
|
|
909
|
-
}) => MaybePromise<void |
|
|
970
|
+
}) => MaybePromise<void | AppErrorWithOptionalStatus>;
|
|
910
971
|
|
|
911
972
|
/**
|
|
912
973
|
* The [`handleValidationError`](https://svelte.dev/docs/kit/hooks#Server-hooks-handleValidationError) hook runs when the argument to a remote function fails validation.
|
|
@@ -914,20 +975,23 @@ declare module '@sveltejs/kit' {
|
|
|
914
975
|
* It will be called with the validation issues and the event, and must return an object shape that matches `App.Error`.
|
|
915
976
|
*/
|
|
916
977
|
export type HandleValidationError<Issue extends StandardSchemaV1.Issue = StandardSchemaV1.Issue> =
|
|
917
|
-
(input: { issues: Issue[]; event: RequestEvent }) => MaybePromise<
|
|
978
|
+
(input: { issues: Issue[]; event: RequestEvent }) => MaybePromise<AppErrorWithOptionalStatus>;
|
|
918
979
|
|
|
919
980
|
/**
|
|
920
981
|
* The client-side [`handleError`](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError) hook runs when an unexpected error is thrown while navigating.
|
|
921
982
|
*
|
|
922
983
|
* If an unexpected error is thrown during loading or the following render, this function will be called with the error and the event.
|
|
923
984
|
* Make sure that this function _never_ throws an error.
|
|
985
|
+
*
|
|
986
|
+
* The returned object can include a `status` property to override the HTTP status code used in the response.
|
|
987
|
+
* If omitted, the status defaults to 500.
|
|
924
988
|
*/
|
|
925
989
|
export type HandleClientError = (input: {
|
|
926
990
|
error: unknown;
|
|
927
991
|
event: NavigationEvent;
|
|
928
992
|
status: number;
|
|
929
993
|
message: string;
|
|
930
|
-
}) => MaybePromise<void |
|
|
994
|
+
}) => MaybePromise<void | AppErrorWithOptionalStatus>;
|
|
931
995
|
|
|
932
996
|
/**
|
|
933
997
|
* The [`handleFetch`](https://svelte.dev/docs/kit/hooks#Server-hooks-handleFetch) hook allows you to modify (or replace) the result of an [`event.fetch`](https://svelte.dev/docs/kit/load#Making-fetch-requests) call that runs on the server (or during prerendering) inside an endpoint, `load`, `action`, `handle`, `handleError` or `reroute`.
|
|
@@ -1196,14 +1260,24 @@ declare module '@sveltejs/kit' {
|
|
|
1196
1260
|
/**
|
|
1197
1261
|
* - `enter`: The app has hydrated/started
|
|
1198
1262
|
* - `form`: The user submitted a `<form method="GET">`
|
|
1263
|
+
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1199
1264
|
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
1200
1265
|
* - `link`: Navigation was triggered by a link click
|
|
1201
|
-
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1202
1266
|
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1203
1267
|
*/
|
|
1204
1268
|
export type NavigationType = 'enter' | 'form' | 'leave' | 'link' | 'goto' | 'popstate';
|
|
1205
1269
|
|
|
1206
1270
|
export interface NavigationBase {
|
|
1271
|
+
/**
|
|
1272
|
+
* The type of navigation:
|
|
1273
|
+
* - `enter`: The app has hydrated/started
|
|
1274
|
+
* - `form`: The user submitted a `<form method="GET">`
|
|
1275
|
+
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1276
|
+
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
1277
|
+
* - `link`: Navigation was triggered by a link click
|
|
1278
|
+
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1279
|
+
*/
|
|
1280
|
+
type: NavigationType;
|
|
1207
1281
|
/**
|
|
1208
1282
|
* Where navigation was triggered from
|
|
1209
1283
|
*/
|
|
@@ -1223,11 +1297,10 @@ declare module '@sveltejs/kit' {
|
|
|
1223
1297
|
complete: Promise<void>;
|
|
1224
1298
|
}
|
|
1225
1299
|
|
|
1300
|
+
/**
|
|
1301
|
+
* The navigation that occurs when the app starts/hydrates
|
|
1302
|
+
*/
|
|
1226
1303
|
export interface NavigationEnter extends NavigationBase {
|
|
1227
|
-
/**
|
|
1228
|
-
* The type of navigation:
|
|
1229
|
-
* - `enter`: The app has hydrated/started
|
|
1230
|
-
*/
|
|
1231
1304
|
type: 'enter';
|
|
1232
1305
|
|
|
1233
1306
|
/**
|
|
@@ -1243,27 +1316,24 @@ declare module '@sveltejs/kit' {
|
|
|
1243
1316
|
|
|
1244
1317
|
export type NavigationExternal = NavigationGoto | NavigationLeave;
|
|
1245
1318
|
|
|
1319
|
+
/**
|
|
1320
|
+
* A navigation triggered by a `goto(...)` call or a redirect
|
|
1321
|
+
*/
|
|
1246
1322
|
export interface NavigationGoto extends NavigationBase {
|
|
1247
|
-
/**
|
|
1248
|
-
* The type of navigation:
|
|
1249
|
-
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1250
|
-
*/
|
|
1251
1323
|
type: 'goto';
|
|
1252
1324
|
}
|
|
1253
1325
|
|
|
1326
|
+
/**
|
|
1327
|
+
* A navigation triggered by the tab being closed, or the user navigating to a different document
|
|
1328
|
+
*/
|
|
1254
1329
|
export interface NavigationLeave extends NavigationBase {
|
|
1255
|
-
/**
|
|
1256
|
-
* The type of navigation:
|
|
1257
|
-
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
1258
|
-
*/
|
|
1259
1330
|
type: 'leave';
|
|
1260
1331
|
}
|
|
1261
1332
|
|
|
1333
|
+
/**
|
|
1334
|
+
* A navigation triggered by a `<form method="GET">`
|
|
1335
|
+
*/
|
|
1262
1336
|
export interface NavigationFormSubmit extends NavigationBase {
|
|
1263
|
-
/**
|
|
1264
|
-
* The type of navigation:
|
|
1265
|
-
* - `form`: The user submitted a `<form method="GET">`
|
|
1266
|
-
*/
|
|
1267
1337
|
type: 'form';
|
|
1268
1338
|
|
|
1269
1339
|
/**
|
|
@@ -1272,11 +1342,10 @@ declare module '@sveltejs/kit' {
|
|
|
1272
1342
|
event: SubmitEvent;
|
|
1273
1343
|
}
|
|
1274
1344
|
|
|
1345
|
+
/**
|
|
1346
|
+
* A navigation triggered by back/forward navigation
|
|
1347
|
+
*/
|
|
1275
1348
|
export interface NavigationPopState extends NavigationBase {
|
|
1276
|
-
/**
|
|
1277
|
-
* The type of navigation:
|
|
1278
|
-
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1279
|
-
*/
|
|
1280
1349
|
type: 'popstate';
|
|
1281
1350
|
|
|
1282
1351
|
/**
|
|
@@ -1290,11 +1359,10 @@ declare module '@sveltejs/kit' {
|
|
|
1290
1359
|
event: PopStateEvent;
|
|
1291
1360
|
}
|
|
1292
1361
|
|
|
1362
|
+
/**
|
|
1363
|
+
* A navigation triggered by a link click
|
|
1364
|
+
*/
|
|
1293
1365
|
export interface NavigationLink extends NavigationBase {
|
|
1294
|
-
/**
|
|
1295
|
-
* The type of navigation:
|
|
1296
|
-
* - `link`: Navigation was triggered by a link click
|
|
1297
|
-
*/
|
|
1298
1366
|
type: 'link';
|
|
1299
1367
|
|
|
1300
1368
|
/**
|
|
@@ -1483,6 +1551,10 @@ declare module '@sveltejs/kit' {
|
|
|
1483
1551
|
locals: App.Locals;
|
|
1484
1552
|
/**
|
|
1485
1553
|
* The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
|
|
1554
|
+
*
|
|
1555
|
+
* In the context of a remote function request initiated by the client, this relates to the page the remote function
|
|
1556
|
+
* was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use this to determine
|
|
1557
|
+
* whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
1486
1558
|
*/
|
|
1487
1559
|
params: Params;
|
|
1488
1560
|
/**
|
|
@@ -1499,6 +1571,10 @@ declare module '@sveltejs/kit' {
|
|
|
1499
1571
|
route: {
|
|
1500
1572
|
/**
|
|
1501
1573
|
* The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.
|
|
1574
|
+
*
|
|
1575
|
+
* In the context of a remote function request initiated by the client, this relates to the page the remote function
|
|
1576
|
+
* was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use this to determine
|
|
1577
|
+
* whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
1502
1578
|
*/
|
|
1503
1579
|
id: RouteId;
|
|
1504
1580
|
};
|
|
@@ -1527,6 +1603,10 @@ declare module '@sveltejs/kit' {
|
|
|
1527
1603
|
setHeaders: (headers: Record<string, string>) => void;
|
|
1528
1604
|
/**
|
|
1529
1605
|
* The requested URL.
|
|
1606
|
+
*
|
|
1607
|
+
* In the context of a remote function request initiated by the client, this relates to the page the remote function
|
|
1608
|
+
* was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use this to determine
|
|
1609
|
+
* whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
1530
1610
|
*/
|
|
1531
1611
|
url: URL;
|
|
1532
1612
|
/**
|
|
@@ -1623,7 +1703,7 @@ declare module '@sveltejs/kit' {
|
|
|
1623
1703
|
export interface SSRManifest {
|
|
1624
1704
|
appDir: string;
|
|
1625
1705
|
appPath: string;
|
|
1626
|
-
/** Static files from `
|
|
1706
|
+
/** Static files from `config.files.assets` and the service worker (if any). */
|
|
1627
1707
|
assets: Set<string>;
|
|
1628
1708
|
mimeTypes: Record<string, string>;
|
|
1629
1709
|
|
|
@@ -1767,7 +1847,7 @@ declare module '@sveltejs/kit' {
|
|
|
1767
1847
|
| { type: 'success'; status: number; data?: Success }
|
|
1768
1848
|
| { type: 'failure'; status: number; data?: Failure }
|
|
1769
1849
|
| { type: 'redirect'; status: number; location: string }
|
|
1770
|
-
| { type: 'error'; status?: number; error:
|
|
1850
|
+
| { type: 'error'; status?: number; error: App.Error };
|
|
1771
1851
|
|
|
1772
1852
|
/**
|
|
1773
1853
|
* The object returned by the [`error`](https://svelte.dev/docs/kit/@sveltejs-kit#error) function.
|
|
@@ -1916,6 +1996,10 @@ declare module '@sveltejs/kit' {
|
|
|
1916
1996
|
value(): DeepPartial<T>;
|
|
1917
1997
|
/** Set the values that will be submitted */
|
|
1918
1998
|
set(input: DeepPartial<T>): DeepPartial<T>;
|
|
1999
|
+
/** Whether the field or any nested field has been interacted with since the form was mounted */
|
|
2000
|
+
touched(): boolean;
|
|
2001
|
+
/** Whether the field or any nested field has been edited since the form was mounted */
|
|
2002
|
+
dirty(): boolean;
|
|
1919
2003
|
/** Validation issues, if any */
|
|
1920
2004
|
issues(): RemoteFormIssue[] | undefined;
|
|
1921
2005
|
};
|
|
@@ -2030,7 +2114,7 @@ declare module '@sveltejs/kit' {
|
|
|
2030
2114
|
type MaybeArray<T> = T | T[];
|
|
2031
2115
|
|
|
2032
2116
|
export interface RemoteFormInput {
|
|
2033
|
-
[key: string]: MaybeArray<string | number | boolean | File | RemoteFormInput
|
|
2117
|
+
[key: string]: MaybeArray<string | number | boolean | File | RemoteFormInput> | undefined;
|
|
2034
2118
|
}
|
|
2035
2119
|
|
|
2036
2120
|
export interface RemoteFormIssue {
|
|
@@ -2076,6 +2160,24 @@ declare module '@sveltejs/kit' {
|
|
|
2076
2160
|
issues: StandardSchemaV1.Issue[];
|
|
2077
2161
|
}
|
|
2078
2162
|
|
|
2163
|
+
/**
|
|
2164
|
+
* The form instance as received inside an `enhance` callback. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
|
|
2165
|
+
*/
|
|
2166
|
+
export type RemoteFormEnhanceInstance<
|
|
2167
|
+
Input extends RemoteFormInput | void = RemoteFormInput | void,
|
|
2168
|
+
Output = any
|
|
2169
|
+
> = Omit<RemoteForm<Input, Output>, 'enhance' | 'element'> & {
|
|
2170
|
+
readonly element: HTMLFormElement;
|
|
2171
|
+
};
|
|
2172
|
+
|
|
2173
|
+
/**
|
|
2174
|
+
* The callback passed to a remote form's `enhance` method. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
|
|
2175
|
+
*/
|
|
2176
|
+
export type RemoteFormEnhanceCallback<
|
|
2177
|
+
Input extends RemoteFormInput | void = RemoteFormInput | void,
|
|
2178
|
+
Output = any
|
|
2179
|
+
> = (form: RemoteFormEnhanceInstance<Input, Output>) => MaybePromise<void>;
|
|
2180
|
+
|
|
2079
2181
|
/**
|
|
2080
2182
|
* The type of a remote `form` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
|
|
2081
2183
|
*/
|
|
@@ -2092,13 +2194,7 @@ declare module '@sveltejs/kit' {
|
|
|
2092
2194
|
updates: (...updates: RemoteQueryUpdate[]) => Promise<boolean>;
|
|
2093
2195
|
};
|
|
2094
2196
|
/** Use the `enhance` method to influence what happens when the form is submitted. */
|
|
2095
|
-
enhance(
|
|
2096
|
-
callback: (
|
|
2097
|
-
form: Omit<RemoteForm<Input, Output>, 'enhance' | 'element'> & {
|
|
2098
|
-
readonly element: HTMLFormElement;
|
|
2099
|
-
}
|
|
2100
|
-
) => MaybePromise<void>
|
|
2101
|
-
): {
|
|
2197
|
+
enhance(callback: RemoteFormEnhanceCallback<Input, Output>): {
|
|
2102
2198
|
method: 'POST';
|
|
2103
2199
|
action: string;
|
|
2104
2200
|
[attachment: symbol]: (node: HTMLFormElement) => void;
|
|
@@ -2122,8 +2218,13 @@ declare module '@sveltejs/kit' {
|
|
|
2122
2218
|
preflight(schema: StandardSchemaV1<Input, any>): RemoteForm<Input, Output>;
|
|
2123
2219
|
/** Validate the form contents programmatically */
|
|
2124
2220
|
validate(options?: {
|
|
2125
|
-
/**
|
|
2126
|
-
|
|
2221
|
+
/**
|
|
2222
|
+
* Set this to `true` to also show validation issues of fields that haven't yet been
|
|
2223
|
+
* edited and blurred. This option is ignored for forms that have previously been
|
|
2224
|
+
* submitted, in which case all fields are always subject to validation
|
|
2225
|
+
* (unless the form is reset, at which point it is treated as pristine)
|
|
2226
|
+
*/
|
|
2227
|
+
all?: boolean;
|
|
2127
2228
|
/** Set this to `true` to only run the `preflight` validation. */
|
|
2128
2229
|
preflightOnly?: boolean;
|
|
2129
2230
|
}): Promise<void>;
|
|
@@ -2131,6 +2232,8 @@ declare module '@sveltejs/kit' {
|
|
|
2131
2232
|
get result(): Output | undefined;
|
|
2132
2233
|
/** The number of pending submissions */
|
|
2133
2234
|
get pending(): number;
|
|
2235
|
+
/** True if the form has been submitted at least once, and hasn't been reset since */
|
|
2236
|
+
get submitted(): boolean;
|
|
2134
2237
|
/** Access form fields using object notation */
|
|
2135
2238
|
fields: RemoteFormFieldsRoot<Input>;
|
|
2136
2239
|
};
|
|
@@ -2343,7 +2446,10 @@ declare module '@sveltejs/kit' {
|
|
|
2343
2446
|
| 'unsafe-eval'
|
|
2344
2447
|
| 'unsafe-hashes'
|
|
2345
2448
|
| 'unsafe-inline'
|
|
2449
|
+
| 'unsafe-allow-redirects'
|
|
2450
|
+
| 'unsafe-webtransport-hashes'
|
|
2346
2451
|
| 'wasm-unsafe-eval'
|
|
2452
|
+
| 'trusted-types-eval'
|
|
2347
2453
|
| 'none';
|
|
2348
2454
|
type CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`;
|
|
2349
2455
|
type FrameSource = HostSource | SchemeSource | 'self' | 'none';
|
|
@@ -2352,7 +2458,16 @@ declare module '@sveltejs/kit' {
|
|
|
2352
2458
|
type HostProtocolSchemes = `${string}://` | '';
|
|
2353
2459
|
type HttpDelineator = '/' | '?' | '#' | '\\';
|
|
2354
2460
|
type PortScheme = `:${number}` | '' | ':*';
|
|
2355
|
-
type SchemeSource =
|
|
2461
|
+
type SchemeSource =
|
|
2462
|
+
| 'http:'
|
|
2463
|
+
| 'https:'
|
|
2464
|
+
| 'ws:'
|
|
2465
|
+
| 'wss:'
|
|
2466
|
+
| 'data:'
|
|
2467
|
+
| 'mediastream:'
|
|
2468
|
+
| 'blob:'
|
|
2469
|
+
| 'filesystem:'
|
|
2470
|
+
| (`${string}:` & {});
|
|
2356
2471
|
type Source = HostSource | SchemeSource | CryptoSource | BaseSource;
|
|
2357
2472
|
type Sources = Source[];
|
|
2358
2473
|
}
|
|
@@ -2494,6 +2609,10 @@ declare module '@sveltejs/kit' {
|
|
|
2494
2609
|
(details: { routes: string[]; message: string }): void;
|
|
2495
2610
|
}
|
|
2496
2611
|
|
|
2612
|
+
interface PrerenderInvalidUrlHandler {
|
|
2613
|
+
(details: { href: string; referrer: string | null; message: string }): void;
|
|
2614
|
+
}
|
|
2615
|
+
|
|
2497
2616
|
type PrerenderHttpErrorHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderHttpErrorHandler;
|
|
2498
2617
|
type PrerenderMissingIdHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderMissingIdHandler;
|
|
2499
2618
|
type PrerenderUnseenRoutesHandlerValue =
|
|
@@ -2506,6 +2625,11 @@ declare module '@sveltejs/kit' {
|
|
|
2506
2625
|
| 'warn'
|
|
2507
2626
|
| 'ignore'
|
|
2508
2627
|
| PrerenderEntryGeneratorMismatchHandler;
|
|
2628
|
+
type PrerenderInvalidUrlHandlerValue =
|
|
2629
|
+
| 'fail'
|
|
2630
|
+
| 'warn'
|
|
2631
|
+
| 'ignore'
|
|
2632
|
+
| PrerenderInvalidUrlHandler;
|
|
2509
2633
|
|
|
2510
2634
|
export type PrerenderOption = boolean | 'auto';
|
|
2511
2635
|
|
|
@@ -2571,6 +2695,9 @@ declare module '@sveltejs/kit' {
|
|
|
2571
2695
|
routes?: SSRClientRoute[];
|
|
2572
2696
|
stylesheets: string[];
|
|
2573
2697
|
fonts: string[];
|
|
2698
|
+
/**
|
|
2699
|
+
* Whether the client uses public dynamic env vars — `$env/dynamic/public` or `$app/env/public`.
|
|
2700
|
+
*/
|
|
2574
2701
|
uses_env_dynamic_public: boolean;
|
|
2575
2702
|
/** Only set in case of `bundleStrategy === 'inline'`. */
|
|
2576
2703
|
inline?: {
|
|
@@ -2582,7 +2709,7 @@ declare module '@sveltejs/kit' {
|
|
|
2582
2709
|
}
|
|
2583
2710
|
|
|
2584
2711
|
interface ManifestData {
|
|
2585
|
-
/** Static files from `
|
|
2712
|
+
/** Static files from `config.files.assets`. */
|
|
2586
2713
|
assets: Asset[];
|
|
2587
2714
|
hooks: {
|
|
2588
2715
|
client: string | null;
|
|
@@ -2770,8 +2897,7 @@ declare module '@sveltejs/kit' {
|
|
|
2770
2897
|
extensions: string[];
|
|
2771
2898
|
};
|
|
2772
2899
|
|
|
2773
|
-
|
|
2774
|
-
type ValidatedKitConfig = Omit<RecursiveRequired<KitConfig>, 'adapter'>;
|
|
2900
|
+
type ValidatedKitConfig = RecursiveRequired<KitConfig>;
|
|
2775
2901
|
/**
|
|
2776
2902
|
* Throws an error with a HTTP status code and an optional message.
|
|
2777
2903
|
* When called during request handling, this will cause SvelteKit to
|
|
@@ -2782,20 +2908,38 @@ declare module '@sveltejs/kit' {
|
|
|
2782
2908
|
* @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
|
|
2783
2909
|
* @throws {Error} If the provided status is invalid (not between 400 and 599).
|
|
2784
2910
|
*/
|
|
2785
|
-
function
|
|
2911
|
+
export function error(status: number, body: Omit<App.Error, "status"> & {
|
|
2912
|
+
status?: App.Error["status"];
|
|
2913
|
+
}): never;
|
|
2786
2914
|
/**
|
|
2787
2915
|
* Throws an error with a HTTP status code and an optional message.
|
|
2788
2916
|
* When called during request handling, this will cause SvelteKit to
|
|
2789
2917
|
* return an error response without invoking `handleError`.
|
|
2790
2918
|
* Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
|
|
2791
2919
|
* @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
|
|
2792
|
-
* @param body
|
|
2920
|
+
* @param body The error message.
|
|
2921
|
+
* @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
|
|
2922
|
+
* @throws {Error} If the provided status is invalid (not between 400 and 599).
|
|
2923
|
+
*/
|
|
2924
|
+
export function error(status: number, body: {
|
|
2925
|
+
status: number;
|
|
2926
|
+
message: string;
|
|
2927
|
+
} extends App.Error ? string | void | undefined : never): never;
|
|
2928
|
+
/**
|
|
2929
|
+
* Throws an error with a HTTP status code and an optional message.
|
|
2930
|
+
* When called during request handling, this will cause SvelteKit to
|
|
2931
|
+
* return an error response without invoking `handleError`.
|
|
2932
|
+
* Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
|
|
2933
|
+
* @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
|
|
2934
|
+
* @param body The error message.
|
|
2935
|
+
* @param properties Additional properties of the App.Error type.
|
|
2793
2936
|
* @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
|
|
2794
2937
|
* @throws {Error} If the provided status is invalid (not between 400 and 599).
|
|
2795
2938
|
*/
|
|
2796
|
-
function
|
|
2939
|
+
export function error(status: number, body: string, properties: {
|
|
2940
|
+
status: number;
|
|
2797
2941
|
message: string;
|
|
2798
|
-
} extends App.Error ? App.Error
|
|
2942
|
+
} extends App.Error ? never : Omit<App.Error, "status" | "message">): never;
|
|
2799
2943
|
/**
|
|
2800
2944
|
* Checks whether this is an error thrown by {@link error}.
|
|
2801
2945
|
* @param status The status to filter for.
|
|
@@ -2816,10 +2960,13 @@ declare module '@sveltejs/kit' {
|
|
|
2816
2960
|
*
|
|
2817
2961
|
* @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages). Must be in the range 300-308.
|
|
2818
2962
|
* @param location The location to redirect to.
|
|
2963
|
+
* @param options To redirect to an external URL, you must pass `{ external: true }` to allow any external URL except `javascript:` URLs, or `{ external: [...] }` with an allowlist of permitted origins.
|
|
2819
2964
|
* @throws {import('./public.js').Redirect} This error instructs SvelteKit to redirect to the specified location.
|
|
2820
|
-
* @throws {Error} If the provided status is invalid
|
|
2965
|
+
* @throws {Error} If the provided status is invalid, the location cannot be used as a header value, or the location is an external URL without permission.
|
|
2821
2966
|
* */
|
|
2822
|
-
export function redirect(status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | ({} & number), location: string | URL
|
|
2967
|
+
export function redirect(status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | ({} & number), location: string | URL, options?: {
|
|
2968
|
+
external?: boolean | string[];
|
|
2969
|
+
}): never;
|
|
2823
2970
|
/**
|
|
2824
2971
|
* Checks whether this is a redirect thrown by {@link redirect}.
|
|
2825
2972
|
* @param e The object to check.
|
|
@@ -2919,7 +3066,7 @@ declare module '@sveltejs/kit' {
|
|
|
2919
3066
|
export const VERSION: string;
|
|
2920
3067
|
const valid_page_options_array: readonly ["ssr", "prerender", "csr", "trailingSlash", "config", "entries", "load"];
|
|
2921
3068
|
|
|
2922
|
-
export {
|
|
3069
|
+
export {};
|
|
2923
3070
|
}
|
|
2924
3071
|
|
|
2925
3072
|
declare module '@sveltejs/kit/hooks' {
|
|
@@ -3023,13 +3170,18 @@ declare module '@sveltejs/kit/node' {
|
|
|
3023
3170
|
|
|
3024
3171
|
declare module '@sveltejs/kit/vite' {
|
|
3025
3172
|
import type { KitConfig } from '@sveltejs/kit';
|
|
3026
|
-
import type { SvelteConfig } from '@sveltejs/vite-plugin-svelte';
|
|
3173
|
+
import type { Options, SvelteConfig } from '@sveltejs/vite-plugin-svelte';
|
|
3027
3174
|
import type { Plugin } from 'vite';
|
|
3028
3175
|
/**
|
|
3029
3176
|
* Returns the SvelteKit Vite plugins.
|
|
3030
|
-
*
|
|
3177
|
+
* Any options that don't belong to SvelteKit are passed through to `vite-plugin-svelte`.
|
|
3178
|
+
*
|
|
3179
|
+
* Since version 3.0.0 you must pass [configuration](configuration) directly.
|
|
3180
|
+
*
|
|
3181
|
+
* Since version 2.62.0 you can pass configuration directly, in which case `svelte.config.js` is ignored.
|
|
3182
|
+
*
|
|
3031
3183
|
* */
|
|
3032
|
-
export function sveltekit(config?: KitConfig & Omit<
|
|
3184
|
+
export function sveltekit(config?: KitConfig & Omit<Options, "onwarn"> & Pick<SvelteConfig, "vitePlugin">): Promise<Plugin[]>;
|
|
3033
3185
|
|
|
3034
3186
|
export {};
|
|
3035
3187
|
}
|
|
@@ -3051,7 +3203,7 @@ declare module '$app/env' {
|
|
|
3051
3203
|
export const building: boolean;
|
|
3052
3204
|
|
|
3053
3205
|
/**
|
|
3054
|
-
* The value of `config.
|
|
3206
|
+
* The value of `config.version.name`.
|
|
3055
3207
|
*/
|
|
3056
3208
|
export const version: string;
|
|
3057
3209
|
|
|
@@ -3151,9 +3303,11 @@ declare module '$app/navigation' {
|
|
|
3151
3303
|
* Allows you to navigate programmatically to a given route, with options such as keeping the current element focused.
|
|
3152
3304
|
* Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`.
|
|
3153
3305
|
*
|
|
3154
|
-
*
|
|
3306
|
+
* `goto` is intended for navigations to routes that belong to the app.
|
|
3307
|
+
* If the URL does not resolve to a route within the app, the returned promise will reject.
|
|
3308
|
+
* For external URLs, use `window.location = url` to perform a full-page navigation instead of calling `goto(url)`.
|
|
3155
3309
|
*
|
|
3156
|
-
* @param url Where to navigate to. Note that if you've set [`config.
|
|
3310
|
+
* @param url Where to navigate to. Note that if you've set [`config.paths.base`](https://svelte.dev/docs/kit/configuration#paths) and the URL is root-relative, you need to prepend the base path if you want to navigate within the app.
|
|
3157
3311
|
* @param {Object} opts Options related to the navigation
|
|
3158
3312
|
* */
|
|
3159
3313
|
export function goto(url: string | URL, opts?: {
|
|
@@ -3204,13 +3358,17 @@ declare module '$app/navigation' {
|
|
|
3204
3358
|
*
|
|
3205
3359
|
* @param href Page to preload
|
|
3206
3360
|
* */
|
|
3207
|
-
export function preloadData(href: string): Promise<{
|
|
3361
|
+
export function preloadData(href: string): Promise<({
|
|
3208
3362
|
type: "loaded";
|
|
3209
|
-
status: number;
|
|
3210
3363
|
data: Record<string, any>;
|
|
3211
3364
|
} | {
|
|
3212
3365
|
type: "redirect";
|
|
3213
3366
|
location: string;
|
|
3367
|
+
} | {
|
|
3368
|
+
type: "error";
|
|
3369
|
+
error: App.Error;
|
|
3370
|
+
}) & {
|
|
3371
|
+
status: number;
|
|
3214
3372
|
}>;
|
|
3215
3373
|
/**
|
|
3216
3374
|
* Programmatically imports the code for routes that haven't yet been fetched.
|
|
@@ -3239,49 +3397,9 @@ declare module '$app/navigation' {
|
|
|
3239
3397
|
}
|
|
3240
3398
|
|
|
3241
3399
|
declare module '$app/paths' {
|
|
3242
|
-
import type { RouteIdWithSearchOrHash, PathnameWithSearchOrHash, ResolvedPathname, RouteId, RouteParams
|
|
3243
|
-
/**
|
|
3244
|
-
* A string that matches [`config.kit.paths.base`](https://svelte.dev/docs/kit/configuration#paths).
|
|
3245
|
-
*
|
|
3246
|
-
* Example usage: `<a href="{base}/your-page">Link</a>`
|
|
3247
|
-
*
|
|
3248
|
-
* @deprecated Use [`resolve(...)`](https://svelte.dev/docs/kit/$app-paths#resolve) instead
|
|
3249
|
-
*/
|
|
3250
|
-
export let base: '' | `/${string}`;
|
|
3251
|
-
|
|
3400
|
+
import type { Asset, RouteIdWithSearchOrHash, PathnameWithSearchOrHash, ResolvedPathname, Pathname, RouteId, RouteParams } from '$app/types';
|
|
3252
3401
|
/**
|
|
3253
|
-
*
|
|
3254
|
-
*
|
|
3255
|
-
* > [!NOTE] If a value for `config.kit.paths.assets` is specified, it will be replaced with `'/_svelte_kit_assets'` during `vite dev` or `vite preview`, since the assets don't yet live at their eventual URL.
|
|
3256
|
-
*
|
|
3257
|
-
* @deprecated Use [`asset(...)`](https://svelte.dev/docs/kit/$app-paths#asset) instead
|
|
3258
|
-
*/
|
|
3259
|
-
export let assets: '' | `https://${string}` | `http://${string}` | '/_svelte_kit_assets';
|
|
3260
|
-
|
|
3261
|
-
/**
|
|
3262
|
-
* @deprecated Use [`resolve(...)`](https://svelte.dev/docs/kit/$app-paths#resolve) instead
|
|
3263
|
-
*/
|
|
3264
|
-
export function resolveRoute<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash>(
|
|
3265
|
-
...args: ResolveArgs<T>
|
|
3266
|
-
): ResolvedPathname;
|
|
3267
|
-
type StripSearchOrHash<T extends string> = T extends `${infer Pathname}?${string}`
|
|
3268
|
-
? Pathname
|
|
3269
|
-
: T extends `${infer Pathname}#${string}`
|
|
3270
|
-
? Pathname
|
|
3271
|
-
: T;
|
|
3272
|
-
|
|
3273
|
-
type ResolveArgs<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash> =
|
|
3274
|
-
T extends RouteId
|
|
3275
|
-
? RouteParams<T> extends Record<string, never>
|
|
3276
|
-
? [route: T]
|
|
3277
|
-
: [route: T, params: RouteParams<T>]
|
|
3278
|
-
: StripSearchOrHash<T> extends infer U extends RouteId
|
|
3279
|
-
? RouteParams<U> extends Record<string, never>
|
|
3280
|
-
? [route: T]
|
|
3281
|
-
: [route: T, params: RouteParams<U>]
|
|
3282
|
-
: [route: T];
|
|
3283
|
-
/**
|
|
3284
|
-
* Resolve the URL of an asset in your `static` directory, by prefixing it with [`config.kit.paths.assets`](https://svelte.dev/docs/kit/configuration#paths) if configured, or otherwise by prefixing it with the base path.
|
|
3402
|
+
* Resolve the URL of an asset in your `static` directory, by prefixing it with [`config.paths.assets`](https://svelte.dev/docs/kit/configuration#paths) if configured, or otherwise by prefixing it with the base path.
|
|
3285
3403
|
*
|
|
3286
3404
|
* During server rendering, the base path is relative and depends on the page currently being rendered.
|
|
3287
3405
|
*
|
|
@@ -3336,10 +3454,26 @@ declare module '$app/paths' {
|
|
|
3336
3454
|
* @since 2.52.0
|
|
3337
3455
|
*
|
|
3338
3456
|
* */
|
|
3339
|
-
export function match(url:
|
|
3457
|
+
export function match(url: Pathname | URL | (string & {})): Promise<{
|
|
3340
3458
|
id: RouteId;
|
|
3341
3459
|
params: Record<string, string>;
|
|
3342
3460
|
} | null>;
|
|
3461
|
+
type StripSearchOrHash<T extends string> = T extends `${infer Pathname}?${string}`
|
|
3462
|
+
? Pathname
|
|
3463
|
+
: T extends `${infer Pathname}#${string}`
|
|
3464
|
+
? Pathname
|
|
3465
|
+
: T;
|
|
3466
|
+
|
|
3467
|
+
type ResolveArgs<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash> =
|
|
3468
|
+
T extends RouteId
|
|
3469
|
+
? RouteParams<T> extends Record<string, never>
|
|
3470
|
+
? [route: T]
|
|
3471
|
+
: [route: T, params: RouteParams<T>]
|
|
3472
|
+
: StripSearchOrHash<T> extends infer U extends RouteId
|
|
3473
|
+
? RouteParams<U> extends Record<string, never>
|
|
3474
|
+
? [route: T]
|
|
3475
|
+
: [route: T, params: RouteParams<U>]
|
|
3476
|
+
: [route: T];
|
|
3343
3477
|
|
|
3344
3478
|
export {};
|
|
3345
3479
|
}
|
|
@@ -3415,7 +3549,7 @@ declare module '$app/server' {
|
|
|
3415
3549
|
*
|
|
3416
3550
|
* @since 2.27
|
|
3417
3551
|
*/
|
|
3418
|
-
export function form<Schema extends StandardSchemaV1<RemoteFormInput, Record<string, any>>, Output>(validate: Schema, fn: (data: StandardSchemaV1.InferOutput<Schema>, issue: InvalidField<StandardSchemaV1.InferInput<Schema>>) => MaybePromise<Output>): RemoteForm<StandardSchemaV1.InferInput<Schema>, Output>;
|
|
3552
|
+
export function form<Schema extends StandardSchemaV1<RemoteFormInput, Record<string, any>>, Output>(validate: true extends HasNonOptionalBoolean<StandardSchemaV1.InferInput<Schema>> ? "Error: All booleans in form schemas must be optional (e.g. `v.optional(v.boolean(), false)`) because checkbox inputs do not send a false value when unchecked." : Schema, fn: (data: StandardSchemaV1.InferOutput<Schema>, issue: InvalidField<StandardSchemaV1.InferInput<Schema>>) => MaybePromise<Output>): RemoteForm<StandardSchemaV1.InferInput<Schema>, Output>;
|
|
3419
3553
|
/**
|
|
3420
3554
|
* Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a `fetch` call.
|
|
3421
3555
|
*
|
|
@@ -3503,8 +3637,8 @@ declare module '$app/server' {
|
|
|
3503
3637
|
function live<Schema extends StandardSchemaV1, Output>(schema: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => RemoteLiveQueryUserFunctionReturnType<Output>): RemoteLiveQueryFunction<StandardSchemaV1.InferInput<Schema>, Output, StandardSchemaV1.InferOutput<Schema>>;
|
|
3504
3638
|
}
|
|
3505
3639
|
/**
|
|
3506
|
-
*
|
|
3507
|
-
* of `{ arg, query }` entries for the
|
|
3640
|
+
* Inside a remote `command` or `form` callback, returns an iterable
|
|
3641
|
+
* of `{ arg, query }` entries for the query instances the client asked to refresh, up to
|
|
3508
3642
|
* the supplied `limit`. Each `query` is a `RemoteQuery` bound to the original
|
|
3509
3643
|
* client-side cache key, so `refresh()` / `set()` propagate correctly even when
|
|
3510
3644
|
* the query's schema transforms the input. `arg` is the *validated* argument,
|
|
@@ -3513,6 +3647,8 @@ declare module '$app/server' {
|
|
|
3513
3647
|
*
|
|
3514
3648
|
* Arguments that fail validation or exceed `limit` are recorded as failures in
|
|
3515
3649
|
* the response to the client.
|
|
3650
|
+
* See [Client-requested refreshes](https://svelte.dev/docs/kit/remote-functions#Single-flight-mutations-Client-requested-refreshes)
|
|
3651
|
+
* for usage in a remote `command` or `form`.
|
|
3516
3652
|
*
|
|
3517
3653
|
* @example
|
|
3518
3654
|
* ```ts
|
|
@@ -3543,14 +3679,16 @@ declare module '$app/server' {
|
|
|
3543
3679
|
* */
|
|
3544
3680
|
export function requested<Input, Output, Validated = Input>(query: RemoteQueryFunction<Input, Output, Validated>, limit: number): QueryRequestedResult<Validated, Output>;
|
|
3545
3681
|
/**
|
|
3546
|
-
*
|
|
3547
|
-
* of `{ arg, query }` entries for the
|
|
3682
|
+
* Inside a remote `command` or `form` callback, returns an iterable
|
|
3683
|
+
* of `{ arg, query }` entries for the live query instances the client asked to reconnect, up to
|
|
3548
3684
|
* the supplied `limit`. Each `query` is a `RemoteLiveQuery` bound to the original
|
|
3549
3685
|
* client-side cache key, so `reconnect()` propagates correctly even when
|
|
3550
3686
|
* the query's schema transforms the input. `arg` is the *validated* argument.
|
|
3551
3687
|
*
|
|
3552
3688
|
* Arguments that fail validation or exceed `limit` are recorded as failures in
|
|
3553
3689
|
* the response to the client.
|
|
3690
|
+
* See [Client-requested refreshes](https://svelte.dev/docs/kit/remote-functions#Single-flight-mutations-Client-requested-refreshes)
|
|
3691
|
+
* for usage in a remote `command` or `form`.
|
|
3554
3692
|
*
|
|
3555
3693
|
* @example
|
|
3556
3694
|
* ```ts
|
|
@@ -3583,6 +3721,19 @@ declare module '$app/server' {
|
|
|
3583
3721
|
type RemotePrerenderInputsGenerator<Input = any> = () => MaybePromise<Input[]>;
|
|
3584
3722
|
type MaybePromise<T> = T | Promise<T>;
|
|
3585
3723
|
|
|
3724
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
3725
|
+
|
|
3726
|
+
type HasNonOptionalBoolean<T> =
|
|
3727
|
+
IsAny<T> extends true
|
|
3728
|
+
? never
|
|
3729
|
+
: [T] extends [boolean]
|
|
3730
|
+
? true
|
|
3731
|
+
: T extends Array<infer U>
|
|
3732
|
+
? HasNonOptionalBoolean<U>
|
|
3733
|
+
: T extends Record<string, any>
|
|
3734
|
+
? { [K in keyof T]: HasNonOptionalBoolean<T[K]> }[keyof T]
|
|
3735
|
+
: never;
|
|
3736
|
+
|
|
3586
3737
|
export {};
|
|
3587
3738
|
}
|
|
3588
3739
|
|
|
@@ -3686,7 +3837,9 @@ declare module '$app/stores' {
|
|
|
3686
3837
|
};
|
|
3687
3838
|
|
|
3688
3839
|
export {};
|
|
3689
|
-
}
|
|
3840
|
+
}
|
|
3841
|
+
|
|
3842
|
+
/**
|
|
3690
3843
|
* It's possible to tell SvelteKit how to type objects inside your app by declaring the `App` namespace. By default, a new project will have a file called `src/app.d.ts` containing the following:
|
|
3691
3844
|
*
|
|
3692
3845
|
* ```ts
|
|
@@ -3713,6 +3866,7 @@ declare namespace App {
|
|
|
3713
3866
|
* Defines the common shape of expected and unexpected errors. Expected errors are thrown using the `error` function. Unexpected errors are handled by the `handleError` hooks which should return this shape.
|
|
3714
3867
|
*/
|
|
3715
3868
|
export interface Error {
|
|
3869
|
+
status: number;
|
|
3716
3870
|
message: string;
|
|
3717
3871
|
}
|
|
3718
3872
|
|
|
@@ -3744,8 +3898,8 @@ declare namespace App {
|
|
|
3744
3898
|
*/
|
|
3745
3899
|
declare module '$service-worker' {
|
|
3746
3900
|
/**
|
|
3747
|
-
* The `base` path of the deployment. Typically this is equivalent to `config.
|
|
3748
|
-
* Note that there is a `base` but no `assets`, since service workers cannot be used if `config.
|
|
3901
|
+
* The `base` path of the deployment. Typically this is equivalent to `config.paths.base`, but it is calculated from `location.pathname` meaning that it will continue to work correctly if the site is deployed to a subdirectory.
|
|
3902
|
+
* Note that there is a `base` but no `assets`, since service workers cannot be used if `config.paths.assets` is specified.
|
|
3749
3903
|
*/
|
|
3750
3904
|
export const base: string;
|
|
3751
3905
|
/**
|
|
@@ -3754,7 +3908,7 @@ declare module '$service-worker' {
|
|
|
3754
3908
|
*/
|
|
3755
3909
|
export const build: string[];
|
|
3756
3910
|
/**
|
|
3757
|
-
* An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.
|
|
3911
|
+
* An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.files.assets`. You can customize which files are included from `static` directory using [`config.serviceWorker.files`](https://svelte.dev/docs/kit/configuration#serviceWorker)
|
|
3758
3912
|
*/
|
|
3759
3913
|
export const files: string[];
|
|
3760
3914
|
/**
|
|
@@ -3763,7 +3917,7 @@ declare module '$service-worker' {
|
|
|
3763
3917
|
*/
|
|
3764
3918
|
export const prerendered: string[];
|
|
3765
3919
|
/**
|
|
3766
|
-
* See [`config.
|
|
3920
|
+
* See [`config.version`](https://svelte.dev/docs/kit/configuration#version). It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches.
|
|
3767
3921
|
*/
|
|
3768
3922
|
export const version: string;
|
|
3769
3923
|
}
|