@sveltejs/kit 3.0.0-next.4 → 3.0.0-next.7
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 +23 -18
- package/src/core/adapt/builder.js +29 -43
- package/src/core/adapt/index.js +1 -4
- package/src/core/config/index.js +135 -71
- package/src/core/config/options.js +291 -244
- package/src/core/config/types.d.ts +1 -1
- package/src/core/env.js +120 -5
- package/src/core/generate_manifest/index.js +12 -15
- 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 +29 -49
- package/src/core/sync/write_client_manifest.js +14 -14
- package/src/core/sync/write_non_ambient.js +10 -7
- package/src/core/sync/write_root.js +9 -30
- package/src/core/sync/write_server.js +13 -11
- package/src/core/sync/write_tsconfig.js +2 -4
- package/src/core/sync/write_types/index.js +11 -10
- package/src/exports/index.js +34 -12
- package/src/exports/internal/client.js +5 -0
- package/src/exports/internal/env.js +1 -1
- package/src/exports/internal/index.js +1 -90
- package/src/exports/internal/{event.js → server/event.js} +1 -2
- package/src/exports/internal/server/index.js +33 -0
- package/src/exports/internal/shared.js +89 -0
- package/src/exports/node/index.js +58 -7
- package/src/exports/params.js +63 -0
- package/src/exports/public.d.ts +299 -145
- package/src/exports/url.js +84 -0
- package/src/exports/vite/build/build_server.js +6 -1
- package/src/exports/vite/dev/index.js +38 -37
- package/src/exports/vite/index.js +498 -353
- package/src/exports/vite/preview/index.js +16 -8
- package/src/exports/vite/utils.js +7 -11
- 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 +4 -10
- package/src/runtime/app/paths/public.d.ts +0 -28
- package/src/runtime/app/paths/server.js +8 -4
- package/src/runtime/app/server/remote/form.js +10 -3
- package/src/runtime/app/server/remote/query.js +9 -18
- package/src/runtime/app/server/remote/requested.js +8 -4
- package/src/runtime/app/server/remote/shared.js +5 -7
- package/src/runtime/app/state/client.js +1 -2
- package/src/runtime/app/stores.js +13 -76
- package/src/runtime/client/client.js +205 -167
- package/src/runtime/client/fetcher.js +3 -2
- package/src/runtime/client/remote-functions/cache.svelte.js +3 -1
- package/src/runtime/client/remote-functions/form.svelte.js +122 -31
- package/src/runtime/client/remote-functions/prerender.svelte.js +17 -4
- package/src/runtime/client/remote-functions/query/index.js +3 -2
- package/src/runtime/client/remote-functions/query/instance.svelte.js +27 -11
- package/src/runtime/client/remote-functions/query-batch.svelte.js +4 -3
- package/src/runtime/client/remote-functions/query-live/instance.svelte.js +42 -15
- package/src/runtime/client/remote-functions/shared.svelte.js +18 -9
- package/src/runtime/client/state.svelte.js +66 -49
- package/src/runtime/client/types.d.ts +10 -2
- package/src/runtime/client/utils.js +0 -96
- package/src/runtime/form-utils.js +99 -18
- 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 +2 -2
- package/src/runtime/server/page/actions.js +41 -26
- package/src/runtime/server/page/index.js +2 -1
- package/src/runtime/server/page/load_data.js +1 -1
- package/src/runtime/server/page/render.js +36 -47
- package/src/runtime/server/page/respond_with_error.js +7 -8
- package/src/runtime/server/page/server_routing.js +13 -9
- package/src/runtime/server/remote.js +85 -39
- package/src/runtime/server/respond.js +92 -58
- package/src/runtime/server/utils.js +7 -7
- package/src/runtime/telemetry/otel.js +1 -1
- package/src/types/ambient.d.ts +10 -5
- package/src/types/global-private.d.ts +4 -4
- package/src/types/internal.d.ts +17 -20
- package/src/types/private.d.ts +33 -1
- package/src/types/synthetic/$lib.md +1 -1
- package/src/utils/error.js +12 -4
- package/src/utils/mime.js +9 -0
- package/src/utils/params.js +66 -0
- package/src/utils/routing.js +84 -38
- package/src/utils/shared-iterator.js +5 -0
- package/src/utils/streaming.js +14 -4
- package/src/utils/url.js +20 -2
- package/src/version.js +1 -1
- package/types/index.d.ts +434 -269
- package/types/index.d.ts.map +19 -15
- package/src/exports/internal/server.js +0 -22
- /package/src/exports/internal/{remote-functions.js → server/remote-functions.js} +0 -0
package/types/index.d.ts
CHANGED
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
declare module '@sveltejs/kit' {
|
|
5
5
|
import type { SvelteConfig } from '@sveltejs/vite-plugin-svelte';
|
|
6
6
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
7
|
+
import type { Plugin } from 'vite';
|
|
7
8
|
import type { RouteId as AppRouteId, LayoutParams as AppLayoutParams, ResolvedPathname } from '$app/types';
|
|
8
9
|
// @ts-ignore this is an optional peer dependency so could be missing. Written like this so dts-buddy preserves the ts-ignore
|
|
9
10
|
type Span = import('@opentelemetry/api').Span;
|
|
10
11
|
|
|
12
|
+
type AppErrorWithOptionalStatus = Omit<App.Error, 'status'> & { status?: App.Error['status'] };
|
|
13
|
+
|
|
11
14
|
/**
|
|
12
15
|
* [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
16
|
*/
|
|
@@ -42,6 +45,13 @@ declare module '@sveltejs/kit' {
|
|
|
42
45
|
* during dev, build and prerendering.
|
|
43
46
|
*/
|
|
44
47
|
emulate?: () => MaybePromise<Emulator>;
|
|
48
|
+
vite?: {
|
|
49
|
+
/**
|
|
50
|
+
* Plugins provided by the adapter are placed before any of SvelteKit's own plugins.
|
|
51
|
+
* @since 3.0.0
|
|
52
|
+
*/
|
|
53
|
+
plugins?: Plugin[];
|
|
54
|
+
};
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
export type LoadProperties<input extends Record<string, any> | void> = input extends void
|
|
@@ -90,7 +100,7 @@ declare module '@sveltejs/kit' {
|
|
|
90
100
|
/** Create `dir` and any required parent directories. */
|
|
91
101
|
mkdirp: (dir: string) => void;
|
|
92
102
|
|
|
93
|
-
/** The fully resolved
|
|
103
|
+
/** The fully resolved SvelteKit config. */
|
|
94
104
|
config: ValidatedConfig;
|
|
95
105
|
/** Information about prerendered pages and assets, if any. */
|
|
96
106
|
prerendered: Prerendered;
|
|
@@ -237,13 +247,13 @@ declare module '@sveltejs/kit' {
|
|
|
237
247
|
/**
|
|
238
248
|
* Gets a cookie that was previously set with `cookies.set`, or from the request headers.
|
|
239
249
|
* @param name the name of the cookie
|
|
240
|
-
* @param opts the options, passed directly to `cookie.
|
|
250
|
+
* @param opts the options, passed directly to `cookie.parseCookie`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
|
|
241
251
|
*/
|
|
242
252
|
get: (name: string, opts?: import('cookie').ParseOptions) => string | undefined;
|
|
243
253
|
|
|
244
254
|
/**
|
|
245
255
|
* Gets all cookies that were previously set with `cookies.set`, or from the request headers.
|
|
246
|
-
* @param opts the options, passed directly to `cookie.
|
|
256
|
+
* @param opts the options, passed directly to `cookie.parseCookie`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
|
|
247
257
|
*/
|
|
248
258
|
getAll: (opts?: import('cookie').ParseOptions) => Array<{ name: string; value: string }>;
|
|
249
259
|
|
|
@@ -255,7 +265,7 @@ declare module '@sveltejs/kit' {
|
|
|
255
265
|
* 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
266
|
* @param name the name of the cookie
|
|
257
267
|
* @param value the cookie value
|
|
258
|
-
* @param opts the options passed to `cookie.
|
|
268
|
+
* @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
269
|
*/
|
|
260
270
|
set: (name: string, value: string, opts: import('cookie').SerializeOptions) => void;
|
|
261
271
|
|
|
@@ -266,10 +276,34 @@ declare module '@sveltejs/kit' {
|
|
|
266
276
|
*
|
|
267
277
|
* 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
278
|
* @param name the name of the cookie
|
|
269
|
-
* @param opts the options passed to `cookie.
|
|
279
|
+
* @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
280
|
*/
|
|
271
281
|
delete: (name: string, opts: import('cookie').SerializeOptions) => void;
|
|
272
282
|
|
|
283
|
+
/**
|
|
284
|
+
* Parses a single `Set-Cookie` header. This allows you to apply cookies received from an external source:
|
|
285
|
+
*
|
|
286
|
+
* ```js
|
|
287
|
+
* import { getRequestEvent } from '$app/server';
|
|
288
|
+
*
|
|
289
|
+
* export async function GET() {
|
|
290
|
+
* const { cookies } = getRequestEvent();
|
|
291
|
+
*
|
|
292
|
+
* const response = await fetch('...');
|
|
293
|
+
*
|
|
294
|
+
* for (const str of response.headers.getSetCookie()) {
|
|
295
|
+
* const { name, value, ...options } = cookies.parse(str);
|
|
296
|
+
* cookies.set(name, value, { ...options, path: '/' });
|
|
297
|
+
* }
|
|
298
|
+
*
|
|
299
|
+
* // ...
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
303
|
+
* 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.
|
|
304
|
+
*/
|
|
305
|
+
parse: typeof import('cookie').parseSetCookie;
|
|
306
|
+
|
|
273
307
|
/**
|
|
274
308
|
* Serialize a cookie name-value pair into a `Set-Cookie` header string, but don't apply it to the response.
|
|
275
309
|
*
|
|
@@ -278,7 +312,7 @@ declare module '@sveltejs/kit' {
|
|
|
278
312
|
* 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
313
|
* @param name the name of the cookie
|
|
280
314
|
* @param value the cookie value
|
|
281
|
-
* @param opts the options passed to `cookie.
|
|
315
|
+
* @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
316
|
*/
|
|
283
317
|
serialize: (name: string, value: string, opts: import('cookie').SerializeOptions) => string;
|
|
284
318
|
}
|
|
@@ -295,35 +329,37 @@ declare module '@sveltejs/kit' {
|
|
|
295
329
|
}
|
|
296
330
|
|
|
297
331
|
export interface KitConfig {
|
|
298
|
-
// TODO: remove this in 4.0
|
|
299
332
|
/**
|
|
300
333
|
* 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
334
|
* @default undefined
|
|
302
|
-
* @deprecated removed in 3.0.0. Adapters should now be passed to the `sveltekit` Vite plugin in `vite.config.js`
|
|
303
335
|
*/
|
|
304
336
|
adapter?: Adapter;
|
|
305
337
|
/**
|
|
306
338
|
* An object containing zero or more aliases used to replace values in `import` statements. These aliases are automatically passed to Vite and TypeScript.
|
|
307
339
|
*
|
|
308
340
|
* ```js
|
|
309
|
-
* /// file:
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
341
|
+
* /// file: vite.config.js
|
|
342
|
+
* import { defineConfig } from 'vite';
|
|
343
|
+
* import { sveltekit } from '@sveltejs/kit/vite';
|
|
344
|
+
*
|
|
345
|
+
* export default defineConfig({
|
|
346
|
+
* plugins: [
|
|
347
|
+
* sveltekit({
|
|
348
|
+
* alias: {
|
|
349
|
+
* // this will match a file
|
|
350
|
+
* 'my-file': 'path/to/my-file.js',
|
|
351
|
+
*
|
|
352
|
+
* // this will match a directory and its contents
|
|
353
|
+
* // (`my-directory/x` resolves to `path/to/my-directory/x`)
|
|
354
|
+
* 'my-directory': 'path/to/my-directory',
|
|
355
|
+
*
|
|
356
|
+
* // an alias ending /* will only match
|
|
357
|
+
* // the contents of a directory, not the directory itself
|
|
358
|
+
* 'my-directory/*': 'path/to/my-directory/*'
|
|
359
|
+
* }
|
|
360
|
+
* })
|
|
361
|
+
* ]
|
|
362
|
+
* });
|
|
327
363
|
* ```
|
|
328
364
|
*
|
|
329
365
|
* > [!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 +377,26 @@ declare module '@sveltejs/kit' {
|
|
|
341
377
|
* [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
378
|
*
|
|
343
379
|
* ```js
|
|
344
|
-
* /// file:
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
380
|
+
* /// file: vite.config.js
|
|
381
|
+
* import { sveltekit } from '@sveltejs/kit/vite';
|
|
382
|
+
* import { defineConfig } from 'vite';
|
|
383
|
+
*
|
|
384
|
+
* export default defineConfig({
|
|
385
|
+
* plugins: [
|
|
386
|
+
* sveltekit({
|
|
387
|
+
* csp: {
|
|
388
|
+
* directives: {
|
|
389
|
+
* 'script-src': ['self']
|
|
390
|
+
* },
|
|
391
|
+
* // must be specified with either the `report-uri` or `report-to` directives, or both
|
|
392
|
+
* reportOnly: {
|
|
393
|
+
* 'script-src': ['self'],
|
|
394
|
+
* 'report-uri': ['/']
|
|
395
|
+
* }
|
|
396
|
+
* }
|
|
397
|
+
* })
|
|
398
|
+
* ]
|
|
399
|
+
* });
|
|
362
400
|
* ```
|
|
363
401
|
*
|
|
364
402
|
* ...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.
|
|
@@ -433,32 +471,6 @@ declare module '@sveltejs/kit' {
|
|
|
433
471
|
};
|
|
434
472
|
/** Experimental features. Here be dragons. These are not subject to semantic versioning, so breaking changes or removal can happen in any release. */
|
|
435
473
|
experimental?: {
|
|
436
|
-
/**
|
|
437
|
-
* Options for enabling server-side [OpenTelemetry](https://opentelemetry.io/) tracing for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#Server-hooks-handle), [`load` functions](https://svelte.dev/docs/kit/load), [form actions](https://svelte.dev/docs/kit/form-actions), and [remote functions](https://svelte.dev/docs/kit/remote-functions).
|
|
438
|
-
* @default { server: false, serverFile: false }
|
|
439
|
-
* @since 2.31.0
|
|
440
|
-
*/
|
|
441
|
-
tracing?: {
|
|
442
|
-
/**
|
|
443
|
-
* Enables server-side [OpenTelemetry](https://opentelemetry.io/) span emission for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#Server-hooks-handle), [`load` functions](https://svelte.dev/docs/kit/load), [form actions](https://svelte.dev/docs/kit/form-actions), and [remote functions](https://svelte.dev/docs/kit/remote-functions).
|
|
444
|
-
* @default false
|
|
445
|
-
* @since 2.31.0
|
|
446
|
-
*/
|
|
447
|
-
server?: boolean;
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* @since 2.31.0
|
|
452
|
-
*/
|
|
453
|
-
instrumentation?: {
|
|
454
|
-
/**
|
|
455
|
-
* Enables `instrumentation.server.js` for tracing and observability instrumentation.
|
|
456
|
-
* @default false
|
|
457
|
-
* @since 2.31.0
|
|
458
|
-
*/
|
|
459
|
-
server?: boolean;
|
|
460
|
-
};
|
|
461
|
-
|
|
462
474
|
/**
|
|
463
475
|
* Whether to enable the experimental remote functions feature. This feature is not yet stable and may be changed or removed at any time.
|
|
464
476
|
* @default false
|
|
@@ -564,7 +576,7 @@ declare module '@sveltejs/kit' {
|
|
|
564
576
|
*/
|
|
565
577
|
inlineStyleThreshold?: number;
|
|
566
578
|
/**
|
|
567
|
-
* An array of file extensions that SvelteKit will treat as modules. Files with extensions that match neither `config.extensions` nor `config.
|
|
579
|
+
* 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
580
|
* @default [".js", ".ts"]
|
|
569
581
|
*/
|
|
570
582
|
moduleExtensions?: string[];
|
|
@@ -646,14 +658,27 @@ declare module '@sveltejs/kit' {
|
|
|
646
658
|
*/
|
|
647
659
|
assets?: '' | `http://${string}` | `https://${string}`;
|
|
648
660
|
/**
|
|
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 [`
|
|
661
|
+
* 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
662
|
* @default ""
|
|
651
663
|
*/
|
|
652
664
|
base?: '' | `/${string}`;
|
|
665
|
+
/**
|
|
666
|
+
* The origin of your app, used for CSRF protection and prerendering.
|
|
667
|
+
*
|
|
668
|
+
* 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).
|
|
669
|
+
*
|
|
670
|
+
* 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`.
|
|
671
|
+
*
|
|
672
|
+
* 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.
|
|
673
|
+
*
|
|
674
|
+
* @default undefined
|
|
675
|
+
* @since 3.0
|
|
676
|
+
*/
|
|
677
|
+
origin?: string;
|
|
653
678
|
/**
|
|
654
679
|
* Whether to use relative asset paths.
|
|
655
680
|
*
|
|
656
|
-
* If `true`, `
|
|
681
|
+
* 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
682
|
* If `false`, `%sveltekit.assets%` and references to build artifacts will always be root-relative paths, unless `paths.assets` is an external URL
|
|
658
683
|
*
|
|
659
684
|
* [Single-page app](https://svelte.dev/docs/kit/single-page-apps) fallback pages will always use absolute paths, regardless of this setting.
|
|
@@ -695,23 +720,27 @@ declare module '@sveltejs/kit' {
|
|
|
695
720
|
* - `(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
721
|
*
|
|
697
722
|
* ```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
|
-
* }
|
|
723
|
+
* /// file: vite.config.js
|
|
724
|
+
* import { sveltekit } from '@sveltejs/kit/vite';
|
|
725
|
+
* import { defineConfig } from 'vite';
|
|
708
726
|
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
727
|
+
* export default defineConfig({
|
|
728
|
+
* plugins: [
|
|
729
|
+
* sveltekit({
|
|
730
|
+
* prerender: {
|
|
731
|
+
* handleHttpError: ({ path, referrer, message }) => {
|
|
732
|
+
* // ignore deliberate link to shiny 404 page
|
|
733
|
+
* if (path === '/not-found' && referrer === '/blog/how-we-built-our-404-page') {
|
|
734
|
+
* return;
|
|
735
|
+
* }
|
|
736
|
+
*
|
|
737
|
+
* // otherwise fail the build
|
|
738
|
+
* throw new Error(message);
|
|
739
|
+
* }
|
|
740
|
+
* }
|
|
741
|
+
* })
|
|
742
|
+
* ]
|
|
743
|
+
* });
|
|
715
744
|
* ```
|
|
716
745
|
*
|
|
717
746
|
* @default "fail"
|
|
@@ -758,10 +787,17 @@ declare module '@sveltejs/kit' {
|
|
|
758
787
|
*/
|
|
759
788
|
handleUnseenRoutes?: PrerenderUnseenRoutesHandlerValue;
|
|
760
789
|
/**
|
|
761
|
-
*
|
|
762
|
-
*
|
|
790
|
+
* 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:...`).
|
|
791
|
+
*
|
|
792
|
+
* - `'fail'` — fail the build
|
|
793
|
+
* - `'ignore'` - silently ignore the failure and continue
|
|
794
|
+
* - `'warn'` — continue, but print a warning
|
|
795
|
+
* - `(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
|
|
796
|
+
*
|
|
797
|
+
* @default "fail"
|
|
798
|
+
* @since 2.67.0
|
|
763
799
|
*/
|
|
764
|
-
|
|
800
|
+
handleInvalidUrl?: PrerenderInvalidUrlHandlerValue;
|
|
765
801
|
};
|
|
766
802
|
router?: {
|
|
767
803
|
/**
|
|
@@ -823,6 +859,17 @@ declare module '@sveltejs/kit' {
|
|
|
823
859
|
register?: false;
|
|
824
860
|
}
|
|
825
861
|
);
|
|
862
|
+
/**
|
|
863
|
+
* Options for enabling [OpenTelemetry](https://opentelemetry.io/) tracing for SvelteKit operations.
|
|
864
|
+
* @default { server: false }
|
|
865
|
+
*/
|
|
866
|
+
tracing?: {
|
|
867
|
+
/**
|
|
868
|
+
* Enables server-side [OpenTelemetry](https://opentelemetry.io/) span emission for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#Server-hooks-handle), [`load` functions](https://svelte.dev/docs/kit/load), [form actions](https://svelte.dev/docs/kit/form-actions), and [remote functions](https://svelte.dev/docs/kit/remote-functions). Tracing — and more significantly, observability instrumentation — can have a nontrivial overhead, so consider whether you really need it, or if it might be more appropriate to turn it on in development and preview environments only.
|
|
869
|
+
* @default false
|
|
870
|
+
*/
|
|
871
|
+
server?: boolean;
|
|
872
|
+
};
|
|
826
873
|
typescript?: {
|
|
827
874
|
/**
|
|
828
875
|
* A function that allows you to edit the generated `tsconfig.json`. You can mutate the config (recommended) or return a new one.
|
|
@@ -863,16 +910,20 @@ declare module '@sveltejs/kit' {
|
|
|
863
910
|
* For example, to use the current commit hash, you could do use `git rev-parse HEAD`:
|
|
864
911
|
*
|
|
865
912
|
* ```js
|
|
866
|
-
* /// file:
|
|
913
|
+
* /// file: vite.config.js
|
|
867
914
|
* import * as child_process from 'node:child_process';
|
|
915
|
+
* import { sveltekit } from '@sveltejs/kit/vite';
|
|
916
|
+
* import { defineConfig } from 'vite';
|
|
868
917
|
*
|
|
869
|
-
* export default {
|
|
870
|
-
*
|
|
871
|
-
*
|
|
872
|
-
*
|
|
873
|
-
*
|
|
874
|
-
*
|
|
875
|
-
*
|
|
918
|
+
* export default defineConfig({
|
|
919
|
+
* plugins: [
|
|
920
|
+
* sveltekit({
|
|
921
|
+
* version: {
|
|
922
|
+
* name: child_process.execSync('git rev-parse HEAD').toString().trim()
|
|
923
|
+
* }
|
|
924
|
+
* })
|
|
925
|
+
* ]
|
|
926
|
+
* });
|
|
876
927
|
* ```
|
|
877
928
|
*/
|
|
878
929
|
name?: string;
|
|
@@ -900,13 +951,16 @@ declare module '@sveltejs/kit' {
|
|
|
900
951
|
*
|
|
901
952
|
* If an unexpected error is thrown during loading or rendering, this function will be called with the error and the event.
|
|
902
953
|
* Make sure that this function _never_ throws an error.
|
|
954
|
+
*
|
|
955
|
+
* The returned object can include a `status` property to override the HTTP status code used in the response.
|
|
956
|
+
* If omitted, the status defaults to 500.
|
|
903
957
|
*/
|
|
904
958
|
export type HandleServerError = (input: {
|
|
905
959
|
error: unknown;
|
|
906
960
|
event: RequestEvent;
|
|
907
961
|
status: number;
|
|
908
962
|
message: string;
|
|
909
|
-
}) => MaybePromise<void |
|
|
963
|
+
}) => MaybePromise<void | AppErrorWithOptionalStatus>;
|
|
910
964
|
|
|
911
965
|
/**
|
|
912
966
|
* The [`handleValidationError`](https://svelte.dev/docs/kit/hooks#Server-hooks-handleValidationError) hook runs when the argument to a remote function fails validation.
|
|
@@ -914,20 +968,23 @@ declare module '@sveltejs/kit' {
|
|
|
914
968
|
* It will be called with the validation issues and the event, and must return an object shape that matches `App.Error`.
|
|
915
969
|
*/
|
|
916
970
|
export type HandleValidationError<Issue extends StandardSchemaV1.Issue = StandardSchemaV1.Issue> =
|
|
917
|
-
(input: { issues: Issue[]; event: RequestEvent }) => MaybePromise<
|
|
971
|
+
(input: { issues: Issue[]; event: RequestEvent }) => MaybePromise<AppErrorWithOptionalStatus>;
|
|
918
972
|
|
|
919
973
|
/**
|
|
920
974
|
* The client-side [`handleError`](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError) hook runs when an unexpected error is thrown while navigating.
|
|
921
975
|
*
|
|
922
976
|
* If an unexpected error is thrown during loading or the following render, this function will be called with the error and the event.
|
|
923
977
|
* Make sure that this function _never_ throws an error.
|
|
978
|
+
*
|
|
979
|
+
* The returned object can include a `status` property to override the HTTP status code used in the response.
|
|
980
|
+
* If omitted, the status defaults to 500.
|
|
924
981
|
*/
|
|
925
982
|
export type HandleClientError = (input: {
|
|
926
983
|
error: unknown;
|
|
927
984
|
event: NavigationEvent;
|
|
928
985
|
status: number;
|
|
929
986
|
message: string;
|
|
930
|
-
}) => MaybePromise<void |
|
|
987
|
+
}) => MaybePromise<void | AppErrorWithOptionalStatus>;
|
|
931
988
|
|
|
932
989
|
/**
|
|
933
990
|
* 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`.
|
|
@@ -987,7 +1044,7 @@ declare module '@sveltejs/kit' {
|
|
|
987
1044
|
*/
|
|
988
1045
|
export interface Transporter<
|
|
989
1046
|
T = any,
|
|
990
|
-
U =
|
|
1047
|
+
U = any /* minus falsy values, but we can't properly express that */
|
|
991
1048
|
> {
|
|
992
1049
|
encode: (value: T) => false | U;
|
|
993
1050
|
decode: (data: U) => T;
|
|
@@ -1196,14 +1253,24 @@ declare module '@sveltejs/kit' {
|
|
|
1196
1253
|
/**
|
|
1197
1254
|
* - `enter`: The app has hydrated/started
|
|
1198
1255
|
* - `form`: The user submitted a `<form method="GET">`
|
|
1256
|
+
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1199
1257
|
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
1200
1258
|
* - `link`: Navigation was triggered by a link click
|
|
1201
|
-
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1202
1259
|
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1203
1260
|
*/
|
|
1204
1261
|
export type NavigationType = 'enter' | 'form' | 'leave' | 'link' | 'goto' | 'popstate';
|
|
1205
1262
|
|
|
1206
1263
|
export interface NavigationBase {
|
|
1264
|
+
/**
|
|
1265
|
+
* The type of navigation:
|
|
1266
|
+
* - `enter`: The app has hydrated/started
|
|
1267
|
+
* - `form`: The user submitted a `<form method="GET">`
|
|
1268
|
+
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1269
|
+
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
1270
|
+
* - `link`: Navigation was triggered by a link click
|
|
1271
|
+
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1272
|
+
*/
|
|
1273
|
+
type: NavigationType;
|
|
1207
1274
|
/**
|
|
1208
1275
|
* Where navigation was triggered from
|
|
1209
1276
|
*/
|
|
@@ -1223,11 +1290,10 @@ declare module '@sveltejs/kit' {
|
|
|
1223
1290
|
complete: Promise<void>;
|
|
1224
1291
|
}
|
|
1225
1292
|
|
|
1293
|
+
/**
|
|
1294
|
+
* The navigation that occurs when the app starts/hydrates
|
|
1295
|
+
*/
|
|
1226
1296
|
export interface NavigationEnter extends NavigationBase {
|
|
1227
|
-
/**
|
|
1228
|
-
* The type of navigation:
|
|
1229
|
-
* - `enter`: The app has hydrated/started
|
|
1230
|
-
*/
|
|
1231
1297
|
type: 'enter';
|
|
1232
1298
|
|
|
1233
1299
|
/**
|
|
@@ -1243,27 +1309,24 @@ declare module '@sveltejs/kit' {
|
|
|
1243
1309
|
|
|
1244
1310
|
export type NavigationExternal = NavigationGoto | NavigationLeave;
|
|
1245
1311
|
|
|
1312
|
+
/**
|
|
1313
|
+
* A navigation triggered by a `goto(...)` call or a redirect
|
|
1314
|
+
*/
|
|
1246
1315
|
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
1316
|
type: 'goto';
|
|
1252
1317
|
}
|
|
1253
1318
|
|
|
1319
|
+
/**
|
|
1320
|
+
* A navigation triggered by the tab being closed, or the user navigating to a different document
|
|
1321
|
+
*/
|
|
1254
1322
|
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
1323
|
type: 'leave';
|
|
1260
1324
|
}
|
|
1261
1325
|
|
|
1326
|
+
/**
|
|
1327
|
+
* A navigation triggered by a `<form method="GET">`
|
|
1328
|
+
*/
|
|
1262
1329
|
export interface NavigationFormSubmit extends NavigationBase {
|
|
1263
|
-
/**
|
|
1264
|
-
* The type of navigation:
|
|
1265
|
-
* - `form`: The user submitted a `<form method="GET">`
|
|
1266
|
-
*/
|
|
1267
1330
|
type: 'form';
|
|
1268
1331
|
|
|
1269
1332
|
/**
|
|
@@ -1272,11 +1335,10 @@ declare module '@sveltejs/kit' {
|
|
|
1272
1335
|
event: SubmitEvent;
|
|
1273
1336
|
}
|
|
1274
1337
|
|
|
1338
|
+
/**
|
|
1339
|
+
* A navigation triggered by back/forward navigation
|
|
1340
|
+
*/
|
|
1275
1341
|
export interface NavigationPopState extends NavigationBase {
|
|
1276
|
-
/**
|
|
1277
|
-
* The type of navigation:
|
|
1278
|
-
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1279
|
-
*/
|
|
1280
1342
|
type: 'popstate';
|
|
1281
1343
|
|
|
1282
1344
|
/**
|
|
@@ -1290,11 +1352,10 @@ declare module '@sveltejs/kit' {
|
|
|
1290
1352
|
event: PopStateEvent;
|
|
1291
1353
|
}
|
|
1292
1354
|
|
|
1355
|
+
/**
|
|
1356
|
+
* A navigation triggered by a link click
|
|
1357
|
+
*/
|
|
1293
1358
|
export interface NavigationLink extends NavigationBase {
|
|
1294
|
-
/**
|
|
1295
|
-
* The type of navigation:
|
|
1296
|
-
* - `link`: Navigation was triggered by a link click
|
|
1297
|
-
*/
|
|
1298
1359
|
type: 'link';
|
|
1299
1360
|
|
|
1300
1361
|
/**
|
|
@@ -1342,7 +1403,7 @@ declare module '@sveltejs/kit' {
|
|
|
1342
1403
|
};
|
|
1343
1404
|
|
|
1344
1405
|
/**
|
|
1345
|
-
* The shape of the [`page`](https://svelte.dev/docs/kit/$app-state#page) reactive object
|
|
1406
|
+
* The shape of the [`page`](https://svelte.dev/docs/kit/$app-state#page) reactive object.
|
|
1346
1407
|
*/
|
|
1347
1408
|
export interface Page<
|
|
1348
1409
|
Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
|
|
@@ -1390,7 +1451,62 @@ declare module '@sveltejs/kit' {
|
|
|
1390
1451
|
/**
|
|
1391
1452
|
* The shape of a param matcher. See [matching](https://svelte.dev/docs/kit/advanced-routing#Matching) for more info.
|
|
1392
1453
|
*/
|
|
1393
|
-
export type ParamMatcher =
|
|
1454
|
+
export type ParamMatcher<Output = any> = StandardSchemaV1<string, Output>;
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* A value that can be parsed from a URL param and losslessly encoded with `String(...)`.
|
|
1458
|
+
*/
|
|
1459
|
+
export type ParamValue = string | number | boolean | bigint;
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* A param matcher definition passed to [`defineParams`](https://svelte.dev/docs/kit/@sveltejs-kit#defineParams).
|
|
1463
|
+
*/
|
|
1464
|
+
export type ParamDefinition =
|
|
1465
|
+
| ((param: string) => ParamValue | undefined)
|
|
1466
|
+
| StandardSchemaV1<string, ParamValue>;
|
|
1467
|
+
|
|
1468
|
+
/**
|
|
1469
|
+
* The return type of [`defineParams`](https://svelte.dev/docs/kit/@sveltejs-kit#defineParams).
|
|
1470
|
+
*/
|
|
1471
|
+
export type DefinedParams<T extends Record<string, ParamDefinition>> = {
|
|
1472
|
+
readonly [K in keyof T]: ParamEntry<T[K]>;
|
|
1473
|
+
};
|
|
1474
|
+
|
|
1475
|
+
/**
|
|
1476
|
+
* Normalizes a property of defineParams (schema or function) to standard schema.
|
|
1477
|
+
*/
|
|
1478
|
+
type ParamEntry<M> =
|
|
1479
|
+
M extends StandardSchemaV1<any, any>
|
|
1480
|
+
? StandardSchemaV1.InferOutput<M> extends ParamValue
|
|
1481
|
+
? StandardSchemaV1<any, M>
|
|
1482
|
+
: StandardSchemaV1<any, never>
|
|
1483
|
+
: M extends (param: string) => infer R
|
|
1484
|
+
? Exclude<R, undefined> extends ParamValue
|
|
1485
|
+
? StandardSchemaV1<any, Exclude<R, undefined>>
|
|
1486
|
+
: StandardSchemaV1<any, never>
|
|
1487
|
+
: never;
|
|
1488
|
+
|
|
1489
|
+
/**
|
|
1490
|
+
* Extracts the param type from a matcher.
|
|
1491
|
+
*/
|
|
1492
|
+
export type MatcherParam<M extends StandardSchemaV1<any, any>> =
|
|
1493
|
+
M extends StandardSchemaV1<any, infer Inner>
|
|
1494
|
+
? Inner extends ParamValue
|
|
1495
|
+
? Inner
|
|
1496
|
+
: Inner extends StandardSchemaV1<any, any>
|
|
1497
|
+
? StandardSchemaV1.InferOutput<Inner> extends ParamValue
|
|
1498
|
+
? StandardSchemaV1.InferOutput<Inner>
|
|
1499
|
+
: never
|
|
1500
|
+
: never
|
|
1501
|
+
: never;
|
|
1502
|
+
|
|
1503
|
+
/**
|
|
1504
|
+
* Define [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#Matching) for your app.
|
|
1505
|
+
*
|
|
1506
|
+
* */
|
|
1507
|
+
export function defineParams<T extends Record<string, ParamDefinition>>(
|
|
1508
|
+
definitions: T
|
|
1509
|
+
): DefinedParams<T>;
|
|
1394
1510
|
|
|
1395
1511
|
/**
|
|
1396
1512
|
* A single entry yielded by [`requested`](https://svelte.dev/docs/kit/$app-server#requested)
|
|
@@ -1483,6 +1599,10 @@ declare module '@sveltejs/kit' {
|
|
|
1483
1599
|
locals: App.Locals;
|
|
1484
1600
|
/**
|
|
1485
1601
|
* The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
|
|
1602
|
+
*
|
|
1603
|
+
* In the context of a remote function request initiated by the client, this relates to the page the remote function
|
|
1604
|
+
* was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use this to determine
|
|
1605
|
+
* whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
1486
1606
|
*/
|
|
1487
1607
|
params: Params;
|
|
1488
1608
|
/**
|
|
@@ -1499,6 +1619,10 @@ declare module '@sveltejs/kit' {
|
|
|
1499
1619
|
route: {
|
|
1500
1620
|
/**
|
|
1501
1621
|
* 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.
|
|
1622
|
+
*
|
|
1623
|
+
* In the context of a remote function request initiated by the client, this relates to the page the remote function
|
|
1624
|
+
* was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use this to determine
|
|
1625
|
+
* whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
1502
1626
|
*/
|
|
1503
1627
|
id: RouteId;
|
|
1504
1628
|
};
|
|
@@ -1527,6 +1651,10 @@ declare module '@sveltejs/kit' {
|
|
|
1527
1651
|
setHeaders: (headers: Record<string, string>) => void;
|
|
1528
1652
|
/**
|
|
1529
1653
|
* The requested URL.
|
|
1654
|
+
*
|
|
1655
|
+
* In the context of a remote function request initiated by the client, this relates to the page the remote function
|
|
1656
|
+
* was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use this to determine
|
|
1657
|
+
* whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
1530
1658
|
*/
|
|
1531
1659
|
url: URL;
|
|
1532
1660
|
/**
|
|
@@ -1623,7 +1751,7 @@ declare module '@sveltejs/kit' {
|
|
|
1623
1751
|
export interface SSRManifest {
|
|
1624
1752
|
appDir: string;
|
|
1625
1753
|
appPath: string;
|
|
1626
|
-
/** Static files from `
|
|
1754
|
+
/** Static files from `config.files.assets` and the service worker (if any). */
|
|
1627
1755
|
assets: Set<string>;
|
|
1628
1756
|
mimeTypes: Record<string, string>;
|
|
1629
1757
|
|
|
@@ -1767,7 +1895,7 @@ declare module '@sveltejs/kit' {
|
|
|
1767
1895
|
| { type: 'success'; status: number; data?: Success }
|
|
1768
1896
|
| { type: 'failure'; status: number; data?: Failure }
|
|
1769
1897
|
| { type: 'redirect'; status: number; location: string }
|
|
1770
|
-
| { type: 'error'; status?: number; error:
|
|
1898
|
+
| { type: 'error'; status?: number; error: App.Error };
|
|
1771
1899
|
|
|
1772
1900
|
/**
|
|
1773
1901
|
* The object returned by the [`error`](https://svelte.dev/docs/kit/@sveltejs-kit#error) function.
|
|
@@ -1916,6 +2044,10 @@ declare module '@sveltejs/kit' {
|
|
|
1916
2044
|
value(): DeepPartial<T>;
|
|
1917
2045
|
/** Set the values that will be submitted */
|
|
1918
2046
|
set(input: DeepPartial<T>): DeepPartial<T>;
|
|
2047
|
+
/** Whether the field or any nested field has been interacted with since the form was mounted */
|
|
2048
|
+
touched(): boolean;
|
|
2049
|
+
/** Whether the field or any nested field has been edited since the form was mounted */
|
|
2050
|
+
dirty(): boolean;
|
|
1919
2051
|
/** Validation issues, if any */
|
|
1920
2052
|
issues(): RemoteFormIssue[] | undefined;
|
|
1921
2053
|
};
|
|
@@ -2030,7 +2162,7 @@ declare module '@sveltejs/kit' {
|
|
|
2030
2162
|
type MaybeArray<T> = T | T[];
|
|
2031
2163
|
|
|
2032
2164
|
export interface RemoteFormInput {
|
|
2033
|
-
[key: string]: MaybeArray<string | number | boolean | File | RemoteFormInput
|
|
2165
|
+
[key: string]: MaybeArray<string | number | boolean | File | RemoteFormInput> | undefined;
|
|
2034
2166
|
}
|
|
2035
2167
|
|
|
2036
2168
|
export interface RemoteFormIssue {
|
|
@@ -2076,6 +2208,24 @@ declare module '@sveltejs/kit' {
|
|
|
2076
2208
|
issues: StandardSchemaV1.Issue[];
|
|
2077
2209
|
}
|
|
2078
2210
|
|
|
2211
|
+
/**
|
|
2212
|
+
* The form instance as received inside an `enhance` callback. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
|
|
2213
|
+
*/
|
|
2214
|
+
export type RemoteFormEnhanceInstance<
|
|
2215
|
+
Input extends RemoteFormInput | void = RemoteFormInput | void,
|
|
2216
|
+
Output = any
|
|
2217
|
+
> = Omit<RemoteForm<Input, Output>, 'enhance' | 'element'> & {
|
|
2218
|
+
readonly element: HTMLFormElement;
|
|
2219
|
+
};
|
|
2220
|
+
|
|
2221
|
+
/**
|
|
2222
|
+
* The callback passed to a remote form's `enhance` method. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
|
|
2223
|
+
*/
|
|
2224
|
+
export type RemoteFormEnhanceCallback<
|
|
2225
|
+
Input extends RemoteFormInput | void = RemoteFormInput | void,
|
|
2226
|
+
Output = any
|
|
2227
|
+
> = (form: RemoteFormEnhanceInstance<Input, Output>) => MaybePromise<void>;
|
|
2228
|
+
|
|
2079
2229
|
/**
|
|
2080
2230
|
* The type of a remote `form` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
|
|
2081
2231
|
*/
|
|
@@ -2092,13 +2242,7 @@ declare module '@sveltejs/kit' {
|
|
|
2092
2242
|
updates: (...updates: RemoteQueryUpdate[]) => Promise<boolean>;
|
|
2093
2243
|
};
|
|
2094
2244
|
/** 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
|
-
): {
|
|
2245
|
+
enhance(callback: RemoteFormEnhanceCallback<Input, Output>): {
|
|
2102
2246
|
method: 'POST';
|
|
2103
2247
|
action: string;
|
|
2104
2248
|
[attachment: symbol]: (node: HTMLFormElement) => void;
|
|
@@ -2122,8 +2266,13 @@ declare module '@sveltejs/kit' {
|
|
|
2122
2266
|
preflight(schema: StandardSchemaV1<Input, any>): RemoteForm<Input, Output>;
|
|
2123
2267
|
/** Validate the form contents programmatically */
|
|
2124
2268
|
validate(options?: {
|
|
2125
|
-
/**
|
|
2126
|
-
|
|
2269
|
+
/**
|
|
2270
|
+
* Set this to `true` to also show validation issues of fields that haven't yet been
|
|
2271
|
+
* edited and blurred. This option is ignored for forms that have previously been
|
|
2272
|
+
* submitted, in which case all fields are always subject to validation
|
|
2273
|
+
* (unless the form is reset, at which point it is treated as pristine)
|
|
2274
|
+
*/
|
|
2275
|
+
all?: boolean;
|
|
2127
2276
|
/** Set this to `true` to only run the `preflight` validation. */
|
|
2128
2277
|
preflightOnly?: boolean;
|
|
2129
2278
|
}): Promise<void>;
|
|
@@ -2131,6 +2280,8 @@ declare module '@sveltejs/kit' {
|
|
|
2131
2280
|
get result(): Output | undefined;
|
|
2132
2281
|
/** The number of pending submissions */
|
|
2133
2282
|
get pending(): number;
|
|
2283
|
+
/** True if the form has been submitted at least once, and hasn't been reset since */
|
|
2284
|
+
get submitted(): boolean;
|
|
2134
2285
|
/** Access form fields using object notation */
|
|
2135
2286
|
fields: RemoteFormFieldsRoot<Input>;
|
|
2136
2287
|
};
|
|
@@ -2154,8 +2305,8 @@ declare module '@sveltejs/kit' {
|
|
|
2154
2305
|
| RemoteQueryOverride;
|
|
2155
2306
|
|
|
2156
2307
|
export type RemoteResource<T> = Promise<T> & {
|
|
2157
|
-
/** The error in case the query fails.
|
|
2158
|
-
get error():
|
|
2308
|
+
/** The error in case the query fails. */
|
|
2309
|
+
get error(): App.Error | undefined;
|
|
2159
2310
|
/** `true` before the first result is available and during refreshes */
|
|
2160
2311
|
get loading(): boolean;
|
|
2161
2312
|
} & (
|
|
@@ -2343,7 +2494,10 @@ declare module '@sveltejs/kit' {
|
|
|
2343
2494
|
| 'unsafe-eval'
|
|
2344
2495
|
| 'unsafe-hashes'
|
|
2345
2496
|
| 'unsafe-inline'
|
|
2497
|
+
| 'unsafe-allow-redirects'
|
|
2498
|
+
| 'unsafe-webtransport-hashes'
|
|
2346
2499
|
| 'wasm-unsafe-eval'
|
|
2500
|
+
| 'trusted-types-eval'
|
|
2347
2501
|
| 'none';
|
|
2348
2502
|
type CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`;
|
|
2349
2503
|
type FrameSource = HostSource | SchemeSource | 'self' | 'none';
|
|
@@ -2352,7 +2506,16 @@ declare module '@sveltejs/kit' {
|
|
|
2352
2506
|
type HostProtocolSchemes = `${string}://` | '';
|
|
2353
2507
|
type HttpDelineator = '/' | '?' | '#' | '\\';
|
|
2354
2508
|
type PortScheme = `:${number}` | '' | ':*';
|
|
2355
|
-
type SchemeSource =
|
|
2509
|
+
type SchemeSource =
|
|
2510
|
+
| 'http:'
|
|
2511
|
+
| 'https:'
|
|
2512
|
+
| 'ws:'
|
|
2513
|
+
| 'wss:'
|
|
2514
|
+
| 'data:'
|
|
2515
|
+
| 'mediastream:'
|
|
2516
|
+
| 'blob:'
|
|
2517
|
+
| 'filesystem:'
|
|
2518
|
+
| (`${string}:` & {});
|
|
2356
2519
|
type Source = HostSource | SchemeSource | CryptoSource | BaseSource;
|
|
2357
2520
|
type Sources = Source[];
|
|
2358
2521
|
}
|
|
@@ -2494,6 +2657,10 @@ declare module '@sveltejs/kit' {
|
|
|
2494
2657
|
(details: { routes: string[]; message: string }): void;
|
|
2495
2658
|
}
|
|
2496
2659
|
|
|
2660
|
+
interface PrerenderInvalidUrlHandler {
|
|
2661
|
+
(details: { href: string; referrer: string | null; message: string }): void;
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2497
2664
|
type PrerenderHttpErrorHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderHttpErrorHandler;
|
|
2498
2665
|
type PrerenderMissingIdHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderMissingIdHandler;
|
|
2499
2666
|
type PrerenderUnseenRoutesHandlerValue =
|
|
@@ -2506,6 +2673,11 @@ declare module '@sveltejs/kit' {
|
|
|
2506
2673
|
| 'warn'
|
|
2507
2674
|
| 'ignore'
|
|
2508
2675
|
| PrerenderEntryGeneratorMismatchHandler;
|
|
2676
|
+
type PrerenderInvalidUrlHandlerValue =
|
|
2677
|
+
| 'fail'
|
|
2678
|
+
| 'warn'
|
|
2679
|
+
| 'ignore'
|
|
2680
|
+
| PrerenderInvalidUrlHandler;
|
|
2509
2681
|
|
|
2510
2682
|
export type PrerenderOption = boolean | 'auto';
|
|
2511
2683
|
|
|
@@ -2571,6 +2743,9 @@ declare module '@sveltejs/kit' {
|
|
|
2571
2743
|
routes?: SSRClientRoute[];
|
|
2572
2744
|
stylesheets: string[];
|
|
2573
2745
|
fonts: string[];
|
|
2746
|
+
/**
|
|
2747
|
+
* Whether the client uses public dynamic env vars — `$env/dynamic/public` or `$app/env/public`.
|
|
2748
|
+
*/
|
|
2574
2749
|
uses_env_dynamic_public: boolean;
|
|
2575
2750
|
/** Only set in case of `bundleStrategy === 'inline'`. */
|
|
2576
2751
|
inline?: {
|
|
@@ -2582,7 +2757,7 @@ declare module '@sveltejs/kit' {
|
|
|
2582
2757
|
}
|
|
2583
2758
|
|
|
2584
2759
|
interface ManifestData {
|
|
2585
|
-
/** Static files from `
|
|
2760
|
+
/** Static files from `config.files.assets`. */
|
|
2586
2761
|
assets: Asset[];
|
|
2587
2762
|
hooks: {
|
|
2588
2763
|
client: string | null;
|
|
@@ -2591,7 +2766,7 @@ declare module '@sveltejs/kit' {
|
|
|
2591
2766
|
};
|
|
2592
2767
|
nodes: PageNode[];
|
|
2593
2768
|
routes: RouteData[];
|
|
2594
|
-
|
|
2769
|
+
params: string | null;
|
|
2595
2770
|
}
|
|
2596
2771
|
|
|
2597
2772
|
interface PageNode {
|
|
@@ -2614,7 +2789,7 @@ declare module '@sveltejs/kit' {
|
|
|
2614
2789
|
// Recursive implementation of TypeScript's Required utility type.
|
|
2615
2790
|
// Will recursively continue until it reaches a primitive or Function
|
|
2616
2791
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
2617
|
-
[K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type
|
|
2792
|
+
[K in keyof T]-?: Extract<T[K], Function | (`${string}:` & {})> extends never // If it does not have a Function type
|
|
2618
2793
|
? RecursiveRequired<T[K]> // recursively continue through.
|
|
2619
2794
|
: T[K]; // Use the exact type for everything else
|
|
2620
2795
|
};
|
|
@@ -2657,23 +2832,23 @@ declare module '@sveltejs/kit' {
|
|
|
2657
2832
|
} | null;
|
|
2658
2833
|
}
|
|
2659
2834
|
|
|
2835
|
+
// TODO get rid of this in favor us using just import('svelte').Component<any, any, any>
|
|
2660
2836
|
interface SSRComponent {
|
|
2661
2837
|
default: {
|
|
2662
2838
|
render(
|
|
2663
2839
|
props: Record<string, any>,
|
|
2664
2840
|
opts: { context: Map<any, any>; csp?: { nonce?: string; hash?: boolean } }
|
|
2665
|
-
): {
|
|
2666
|
-
|
|
2841
|
+
): Promise<{
|
|
2842
|
+
body: string;
|
|
2667
2843
|
head: string;
|
|
2668
2844
|
css: {
|
|
2669
2845
|
code: string;
|
|
2670
2846
|
map: any; // TODO
|
|
2671
2847
|
};
|
|
2672
|
-
|
|
2673
|
-
hashes?: {
|
|
2848
|
+
hashes: {
|
|
2674
2849
|
script: Array<`sha256-${string}`>;
|
|
2675
2850
|
};
|
|
2676
|
-
}
|
|
2851
|
+
}>;
|
|
2677
2852
|
};
|
|
2678
2853
|
}
|
|
2679
2854
|
|
|
@@ -2765,13 +2940,12 @@ declare module '@sveltejs/kit' {
|
|
|
2765
2940
|
leaf: [has_server_load: boolean, node_id: number];
|
|
2766
2941
|
}
|
|
2767
2942
|
|
|
2768
|
-
type ValidatedConfig = Config & {
|
|
2943
|
+
type ValidatedConfig = Omit<Config, 'kit'> & {
|
|
2769
2944
|
kit: ValidatedKitConfig;
|
|
2770
2945
|
extensions: string[];
|
|
2771
2946
|
};
|
|
2772
2947
|
|
|
2773
|
-
|
|
2774
|
-
type ValidatedKitConfig = Omit<RecursiveRequired<KitConfig>, 'adapter'>;
|
|
2948
|
+
type ValidatedKitConfig = RecursiveRequired<KitConfig>;
|
|
2775
2949
|
/**
|
|
2776
2950
|
* Throws an error with a HTTP status code and an optional message.
|
|
2777
2951
|
* When called during request handling, this will cause SvelteKit to
|
|
@@ -2782,20 +2956,38 @@ declare module '@sveltejs/kit' {
|
|
|
2782
2956
|
* @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
|
|
2783
2957
|
* @throws {Error} If the provided status is invalid (not between 400 and 599).
|
|
2784
2958
|
*/
|
|
2785
|
-
function
|
|
2959
|
+
export function error(status: number, body: Omit<App.Error, "status"> & {
|
|
2960
|
+
status?: App.Error["status"];
|
|
2961
|
+
}): never;
|
|
2786
2962
|
/**
|
|
2787
2963
|
* Throws an error with a HTTP status code and an optional message.
|
|
2788
2964
|
* When called during request handling, this will cause SvelteKit to
|
|
2789
2965
|
* return an error response without invoking `handleError`.
|
|
2790
2966
|
* Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
|
|
2791
2967
|
* @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
|
|
2968
|
+
* @param body The error message.
|
|
2969
|
+
* @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
|
|
2970
|
+
* @throws {Error} If the provided status is invalid (not between 400 and 599).
|
|
2971
|
+
*/
|
|
2972
|
+
export function error(status: number, body: {
|
|
2973
|
+
status: number;
|
|
2974
|
+
message: string;
|
|
2975
|
+
} extends App.Error ? string | void | undefined : never): never;
|
|
2976
|
+
/**
|
|
2977
|
+
* Throws an error with a HTTP status code and an optional message.
|
|
2978
|
+
* When called during request handling, this will cause SvelteKit to
|
|
2979
|
+
* return an error response without invoking `handleError`.
|
|
2980
|
+
* Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
|
|
2981
|
+
* @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.
|
|
2982
|
+
* @param body The error message.
|
|
2983
|
+
* @param properties Additional properties of the App.Error type.
|
|
2793
2984
|
* @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
|
|
2794
2985
|
* @throws {Error} If the provided status is invalid (not between 400 and 599).
|
|
2795
2986
|
*/
|
|
2796
|
-
function
|
|
2987
|
+
export function error(status: number, body: string, properties: {
|
|
2988
|
+
status: number;
|
|
2797
2989
|
message: string;
|
|
2798
|
-
} extends App.Error ? App.Error
|
|
2990
|
+
} extends App.Error ? never : Omit<App.Error, "status" | "message">): never;
|
|
2799
2991
|
/**
|
|
2800
2992
|
* Checks whether this is an error thrown by {@link error}.
|
|
2801
2993
|
* @param status The status to filter for.
|
|
@@ -2816,10 +3008,13 @@ declare module '@sveltejs/kit' {
|
|
|
2816
3008
|
*
|
|
2817
3009
|
* @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
3010
|
* @param location The location to redirect to.
|
|
3011
|
+
* @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
3012
|
* @throws {import('./public.js').Redirect} This error instructs SvelteKit to redirect to the specified location.
|
|
2820
|
-
* @throws {Error} If the provided status is invalid
|
|
3013
|
+
* @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
3014
|
* */
|
|
2822
|
-
export function redirect(status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | ({} & number), location: string | URL
|
|
3015
|
+
export function redirect(status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | ({} & number), location: string | URL, options?: {
|
|
3016
|
+
external?: boolean | string[];
|
|
3017
|
+
}): never;
|
|
2823
3018
|
/**
|
|
2824
3019
|
* Checks whether this is a redirect thrown by {@link redirect}.
|
|
2825
3020
|
* @param e The object to check.
|
|
@@ -2919,7 +3114,7 @@ declare module '@sveltejs/kit' {
|
|
|
2919
3114
|
export const VERSION: string;
|
|
2920
3115
|
const valid_page_options_array: readonly ["ssr", "prerender", "csr", "trailingSlash", "config", "entries", "load"];
|
|
2921
3116
|
|
|
2922
|
-
export {
|
|
3117
|
+
export {};
|
|
2923
3118
|
}
|
|
2924
3119
|
|
|
2925
3120
|
declare module '@sveltejs/kit/hooks' {
|
|
@@ -3023,13 +3218,18 @@ declare module '@sveltejs/kit/node' {
|
|
|
3023
3218
|
|
|
3024
3219
|
declare module '@sveltejs/kit/vite' {
|
|
3025
3220
|
import type { KitConfig } from '@sveltejs/kit';
|
|
3026
|
-
import type { SvelteConfig } from '@sveltejs/vite-plugin-svelte';
|
|
3221
|
+
import type { Options, SvelteConfig } from '@sveltejs/vite-plugin-svelte';
|
|
3027
3222
|
import type { Plugin } from 'vite';
|
|
3028
3223
|
/**
|
|
3029
3224
|
* Returns the SvelteKit Vite plugins.
|
|
3030
|
-
*
|
|
3225
|
+
* Any options that don't belong to SvelteKit are passed through to `vite-plugin-svelte`.
|
|
3226
|
+
*
|
|
3227
|
+
* Since version 3.0.0 you must pass [configuration](configuration) directly.
|
|
3228
|
+
*
|
|
3229
|
+
* Since version 2.62.0 you can pass configuration directly, in which case `svelte.config.js` is ignored.
|
|
3230
|
+
*
|
|
3031
3231
|
* */
|
|
3032
|
-
export function sveltekit(config?: KitConfig & Omit<
|
|
3232
|
+
export function sveltekit(config?: KitConfig & Omit<Options, "onwarn"> & Pick<SvelteConfig, "vitePlugin">): Promise<Plugin[]>;
|
|
3033
3233
|
|
|
3034
3234
|
export {};
|
|
3035
3235
|
}
|
|
@@ -3051,7 +3251,7 @@ declare module '$app/env' {
|
|
|
3051
3251
|
export const building: boolean;
|
|
3052
3252
|
|
|
3053
3253
|
/**
|
|
3054
|
-
* The value of `config.
|
|
3254
|
+
* The value of `config.version.name`.
|
|
3055
3255
|
*/
|
|
3056
3256
|
export const version: string;
|
|
3057
3257
|
|
|
@@ -3151,9 +3351,11 @@ declare module '$app/navigation' {
|
|
|
3151
3351
|
* Allows you to navigate programmatically to a given route, with options such as keeping the current element focused.
|
|
3152
3352
|
* Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`.
|
|
3153
3353
|
*
|
|
3154
|
-
*
|
|
3354
|
+
* `goto` is intended for navigations to routes that belong to the app.
|
|
3355
|
+
* If the URL does not resolve to a route within the app, the returned promise will reject.
|
|
3356
|
+
* For external URLs, use `window.location = url` to perform a full-page navigation instead of calling `goto(url)`.
|
|
3155
3357
|
*
|
|
3156
|
-
* @param url Where to navigate to. Note that if you've set [`config.
|
|
3358
|
+
* @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
3359
|
* @param {Object} opts Options related to the navigation
|
|
3158
3360
|
* */
|
|
3159
3361
|
export function goto(url: string | URL, opts?: {
|
|
@@ -3204,13 +3406,17 @@ declare module '$app/navigation' {
|
|
|
3204
3406
|
*
|
|
3205
3407
|
* @param href Page to preload
|
|
3206
3408
|
* */
|
|
3207
|
-
export function preloadData(href: string): Promise<{
|
|
3409
|
+
export function preloadData(href: string): Promise<({
|
|
3208
3410
|
type: "loaded";
|
|
3209
|
-
status: number;
|
|
3210
3411
|
data: Record<string, any>;
|
|
3211
3412
|
} | {
|
|
3212
3413
|
type: "redirect";
|
|
3213
3414
|
location: string;
|
|
3415
|
+
} | {
|
|
3416
|
+
type: "error";
|
|
3417
|
+
error: App.Error;
|
|
3418
|
+
}) & {
|
|
3419
|
+
status: number;
|
|
3214
3420
|
}>;
|
|
3215
3421
|
/**
|
|
3216
3422
|
* Programmatically imports the code for routes that haven't yet been fetched.
|
|
@@ -3239,49 +3445,9 @@ declare module '$app/navigation' {
|
|
|
3239
3445
|
}
|
|
3240
3446
|
|
|
3241
3447
|
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
|
-
|
|
3252
|
-
/**
|
|
3253
|
-
* An absolute path that matches [`config.kit.paths.assets`](https://svelte.dev/docs/kit/configuration#paths).
|
|
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];
|
|
3448
|
+
import type { Asset, RouteIdWithSearchOrHash, PathnameWithSearchOrHash, ResolvedPathname, Pathname, RouteId, RouteParams } from '$app/types';
|
|
3283
3449
|
/**
|
|
3284
|
-
* Resolve the URL of an asset in your `static` directory, by prefixing it with [`config.
|
|
3450
|
+
* 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
3451
|
*
|
|
3286
3452
|
* During server rendering, the base path is relative and depends on the page currently being rendered.
|
|
3287
3453
|
*
|
|
@@ -3336,17 +3502,33 @@ declare module '$app/paths' {
|
|
|
3336
3502
|
* @since 2.52.0
|
|
3337
3503
|
*
|
|
3338
3504
|
* */
|
|
3339
|
-
export function match(url:
|
|
3340
|
-
id:
|
|
3341
|
-
params:
|
|
3342
|
-
} | null>;
|
|
3505
|
+
export function match(url: Pathname | URL | (string & {})): Promise<{ [K in RouteId]: {
|
|
3506
|
+
id: K;
|
|
3507
|
+
params: RouteParams<K>;
|
|
3508
|
+
}; }[RouteId] | null>;
|
|
3509
|
+
type StripSearchOrHash<T extends string> = T extends `${infer Pathname}?${string}`
|
|
3510
|
+
? Pathname
|
|
3511
|
+
: T extends `${infer Pathname}#${string}`
|
|
3512
|
+
? Pathname
|
|
3513
|
+
: T;
|
|
3514
|
+
|
|
3515
|
+
type ResolveArgs<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash> =
|
|
3516
|
+
T extends RouteId
|
|
3517
|
+
? RouteParams<T> extends Record<string, never>
|
|
3518
|
+
? [route: T]
|
|
3519
|
+
: [route: T, params: RouteParams<T>]
|
|
3520
|
+
: StripSearchOrHash<T> extends infer U extends RouteId
|
|
3521
|
+
? RouteParams<U> extends Record<string, never>
|
|
3522
|
+
? [route: T]
|
|
3523
|
+
: [route: T, params: RouteParams<U>]
|
|
3524
|
+
: [route: T];
|
|
3343
3525
|
|
|
3344
3526
|
export {};
|
|
3345
3527
|
}
|
|
3346
3528
|
|
|
3347
3529
|
declare module '$app/server' {
|
|
3348
|
-
import type { RequestEvent, RemoteCommand, RemoteForm, RemoteFormInput, InvalidField, RemotePrerenderFunction, RemoteQueryFunction, RemoteLiveQueryFunction, QueryRequestedResult, LiveQueryRequestedResult } from '@sveltejs/kit';
|
|
3349
3530
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3531
|
+
import type { RequestEvent, RemoteCommand, RemoteForm, RemoteFormInput, InvalidField, RemotePrerenderFunction, RemoteQueryFunction, RemoteLiveQueryFunction, QueryRequestedResult, LiveQueryRequestedResult } from '@sveltejs/kit';
|
|
3350
3532
|
/**
|
|
3351
3533
|
* Read the contents of an imported asset from the filesystem
|
|
3352
3534
|
* @example
|
|
@@ -3415,7 +3597,7 @@ declare module '$app/server' {
|
|
|
3415
3597
|
*
|
|
3416
3598
|
* @since 2.27
|
|
3417
3599
|
*/
|
|
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>;
|
|
3600
|
+
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
3601
|
/**
|
|
3420
3602
|
* Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a `fetch` call.
|
|
3421
3603
|
*
|
|
@@ -3503,8 +3685,8 @@ declare module '$app/server' {
|
|
|
3503
3685
|
function live<Schema extends StandardSchemaV1, Output>(schema: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => RemoteLiveQueryUserFunctionReturnType<Output>): RemoteLiveQueryFunction<StandardSchemaV1.InferInput<Schema>, Output, StandardSchemaV1.InferOutput<Schema>>;
|
|
3504
3686
|
}
|
|
3505
3687
|
/**
|
|
3506
|
-
*
|
|
3507
|
-
* of `{ arg, query }` entries for the
|
|
3688
|
+
* Inside a remote `command` or `form` callback, returns an iterable
|
|
3689
|
+
* of `{ arg, query }` entries for the query instances the client asked to refresh, up to
|
|
3508
3690
|
* the supplied `limit`. Each `query` is a `RemoteQuery` bound to the original
|
|
3509
3691
|
* client-side cache key, so `refresh()` / `set()` propagate correctly even when
|
|
3510
3692
|
* the query's schema transforms the input. `arg` is the *validated* argument,
|
|
@@ -3513,6 +3695,8 @@ declare module '$app/server' {
|
|
|
3513
3695
|
*
|
|
3514
3696
|
* Arguments that fail validation or exceed `limit` are recorded as failures in
|
|
3515
3697
|
* the response to the client.
|
|
3698
|
+
* See [Client-requested refreshes](https://svelte.dev/docs/kit/remote-functions#Single-flight-mutations-Client-requested-refreshes)
|
|
3699
|
+
* for usage in a remote `command` or `form`.
|
|
3516
3700
|
*
|
|
3517
3701
|
* @example
|
|
3518
3702
|
* ```ts
|
|
@@ -3543,14 +3727,16 @@ declare module '$app/server' {
|
|
|
3543
3727
|
* */
|
|
3544
3728
|
export function requested<Input, Output, Validated = Input>(query: RemoteQueryFunction<Input, Output, Validated>, limit: number): QueryRequestedResult<Validated, Output>;
|
|
3545
3729
|
/**
|
|
3546
|
-
*
|
|
3547
|
-
* of `{ arg, query }` entries for the
|
|
3730
|
+
* Inside a remote `command` or `form` callback, returns an iterable
|
|
3731
|
+
* of `{ arg, query }` entries for the live query instances the client asked to reconnect, up to
|
|
3548
3732
|
* the supplied `limit`. Each `query` is a `RemoteLiveQuery` bound to the original
|
|
3549
3733
|
* client-side cache key, so `reconnect()` propagates correctly even when
|
|
3550
3734
|
* the query's schema transforms the input. `arg` is the *validated* argument.
|
|
3551
3735
|
*
|
|
3552
3736
|
* Arguments that fail validation or exceed `limit` are recorded as failures in
|
|
3553
3737
|
* the response to the client.
|
|
3738
|
+
* See [Client-requested refreshes](https://svelte.dev/docs/kit/remote-functions#Single-flight-mutations-Client-requested-refreshes)
|
|
3739
|
+
* for usage in a remote `command` or `form`.
|
|
3554
3740
|
*
|
|
3555
3741
|
* @example
|
|
3556
3742
|
* ```ts
|
|
@@ -3583,6 +3769,19 @@ declare module '$app/server' {
|
|
|
3583
3769
|
type RemotePrerenderInputsGenerator<Input = any> = () => MaybePromise<Input[]>;
|
|
3584
3770
|
type MaybePromise<T> = T | Promise<T>;
|
|
3585
3771
|
|
|
3772
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
3773
|
+
|
|
3774
|
+
type HasNonOptionalBoolean<T> =
|
|
3775
|
+
IsAny<T> extends true
|
|
3776
|
+
? never
|
|
3777
|
+
: [T] extends [boolean]
|
|
3778
|
+
? true
|
|
3779
|
+
: T extends Array<infer U>
|
|
3780
|
+
? HasNonOptionalBoolean<U>
|
|
3781
|
+
: T extends Record<string, any>
|
|
3782
|
+
? { [K in keyof T]: HasNonOptionalBoolean<T[K]> }[keyof T]
|
|
3783
|
+
: never;
|
|
3784
|
+
|
|
3586
3785
|
export {};
|
|
3587
3786
|
}
|
|
3588
3787
|
|
|
@@ -3647,46 +3846,7 @@ declare module '$app/state' {
|
|
|
3647
3846
|
export {};
|
|
3648
3847
|
}
|
|
3649
3848
|
|
|
3650
|
-
|
|
3651
|
-
export function getStores(): {
|
|
3652
|
-
|
|
3653
|
-
page: typeof page;
|
|
3654
|
-
|
|
3655
|
-
navigating: typeof navigating;
|
|
3656
|
-
|
|
3657
|
-
updated: typeof updated;
|
|
3658
|
-
};
|
|
3659
|
-
/**
|
|
3660
|
-
* A readable store whose value contains page data.
|
|
3661
|
-
*
|
|
3662
|
-
* On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.
|
|
3663
|
-
*
|
|
3664
|
-
* @deprecated Use `page` from `$app/state` instead (requires Svelte 5, [see docs for more info](https://svelte.dev/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated))
|
|
3665
|
-
* */
|
|
3666
|
-
export const page: import("svelte/store").Readable<import("@sveltejs/kit").Page>;
|
|
3667
|
-
/**
|
|
3668
|
-
* A readable store.
|
|
3669
|
-
* When navigating starts, its value is a `Navigation` object with `from`, `to`, `type` and (if `type === 'popstate'`) `delta` properties.
|
|
3670
|
-
* When navigating finishes, its value reverts to `null`.
|
|
3671
|
-
*
|
|
3672
|
-
* On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.
|
|
3673
|
-
*
|
|
3674
|
-
* @deprecated Use `navigating` from `$app/state` instead (requires Svelte 5, [see docs for more info](https://svelte.dev/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated))
|
|
3675
|
-
* */
|
|
3676
|
-
export const navigating: import("svelte/store").Readable<import("@sveltejs/kit").Navigation | null>;
|
|
3677
|
-
/**
|
|
3678
|
-
* A readable store whose initial value is `false`. If [`version.pollInterval`](https://svelte.dev/docs/kit/configuration#version) is a non-zero value, SvelteKit will poll for new versions of the app and update the store value to `true` when it detects one. `updated.check()` will force an immediate check, regardless of polling.
|
|
3679
|
-
*
|
|
3680
|
-
* On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.
|
|
3681
|
-
*
|
|
3682
|
-
* @deprecated Use `updated` from `$app/state` instead (requires Svelte 5, [see docs for more info](https://svelte.dev/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated))
|
|
3683
|
-
* */
|
|
3684
|
-
export const updated: import("svelte/store").Readable<boolean> & {
|
|
3685
|
-
check(): Promise<boolean>;
|
|
3686
|
-
};
|
|
3687
|
-
|
|
3688
|
-
export {};
|
|
3689
|
-
}/**
|
|
3849
|
+
/**
|
|
3690
3850
|
* 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
3851
|
*
|
|
3692
3852
|
* ```ts
|
|
@@ -3713,29 +3873,34 @@ declare namespace App {
|
|
|
3713
3873
|
* 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
3874
|
*/
|
|
3715
3875
|
export interface Error {
|
|
3876
|
+
status: number;
|
|
3716
3877
|
message: string;
|
|
3717
3878
|
}
|
|
3718
3879
|
|
|
3719
3880
|
/**
|
|
3720
3881
|
* The interface that defines `event.locals`, which can be accessed in server [hooks](https://svelte.dev/docs/kit/hooks) (`handle`, and `handleError`), server-only `load` functions, and `+server.js` files.
|
|
3721
3882
|
*/
|
|
3883
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
3722
3884
|
export interface Locals {}
|
|
3723
3885
|
|
|
3724
3886
|
/**
|
|
3725
|
-
* Defines the common shape of the [page.data state](https://svelte.dev/docs/kit/$app-state#page)
|
|
3887
|
+
* Defines the common shape of the [page.data state](https://svelte.dev/docs/kit/$app-state#page) - that is, the data that is shared between all pages.
|
|
3726
3888
|
* The `Load` and `ServerLoad` functions in `./$types` will be narrowed accordingly.
|
|
3727
3889
|
* Use optional properties for data that is only present on specific pages. Do not add an index signature (`[key: string]: any`).
|
|
3728
3890
|
*/
|
|
3891
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
3729
3892
|
export interface PageData {}
|
|
3730
3893
|
|
|
3731
3894
|
/**
|
|
3732
3895
|
* The shape of the `page.state` object, which can be manipulated using the [`pushState`](https://svelte.dev/docs/kit/$app-navigation#pushState) and [`replaceState`](https://svelte.dev/docs/kit/$app-navigation#replaceState) functions from `$app/navigation`.
|
|
3733
3896
|
*/
|
|
3897
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
3734
3898
|
export interface PageState {}
|
|
3735
3899
|
|
|
3736
3900
|
/**
|
|
3737
3901
|
* If your adapter provides [platform-specific context](https://svelte.dev/docs/kit/adapters#Platform-specific-context) via `event.platform`, you can specify it here.
|
|
3738
3902
|
*/
|
|
3903
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
3739
3904
|
export interface Platform {}
|
|
3740
3905
|
}
|
|
3741
3906
|
|
|
@@ -3744,8 +3909,8 @@ declare namespace App {
|
|
|
3744
3909
|
*/
|
|
3745
3910
|
declare module '$service-worker' {
|
|
3746
3911
|
/**
|
|
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.
|
|
3912
|
+
* 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.
|
|
3913
|
+
* Note that there is a `base` but no `assets`, since service workers cannot be used if `config.paths.assets` is specified.
|
|
3749
3914
|
*/
|
|
3750
3915
|
export const base: string;
|
|
3751
3916
|
/**
|
|
@@ -3754,7 +3919,7 @@ declare module '$service-worker' {
|
|
|
3754
3919
|
*/
|
|
3755
3920
|
export const build: string[];
|
|
3756
3921
|
/**
|
|
3757
|
-
* An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.
|
|
3922
|
+
* 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
3923
|
*/
|
|
3759
3924
|
export const files: string[];
|
|
3760
3925
|
/**
|
|
@@ -3763,7 +3928,7 @@ declare module '$service-worker' {
|
|
|
3763
3928
|
*/
|
|
3764
3929
|
export const prerendered: string[];
|
|
3765
3930
|
/**
|
|
3766
|
-
* See [`config.
|
|
3931
|
+
* 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
3932
|
*/
|
|
3768
3933
|
export const version: string;
|
|
3769
3934
|
}
|