@sveltejs/kit 3.0.0-next.22 → 3.0.0-next.24
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 +40 -9
- package/src/cli.js +3 -3
- package/src/constants.js +13 -1
- package/src/core/adapt/builder.js +2 -3
- package/src/core/env.js +139 -181
- package/src/core/postbuild/analyse.js +9 -4
- package/src/core/postbuild/prerender.js +22 -23
- package/src/core/sync/create_manifest_data/index.js +29 -33
- package/src/core/sync/sync.js +23 -40
- package/src/core/sync/write_app_manifest.js +83 -0
- package/src/core/sync/write_client_manifest.js +6 -4
- package/src/core/sync/write_server.js +10 -6
- package/src/core/sync/write_types/index.js +2 -2
- package/src/core/utils.js +0 -28
- package/src/exports/hooks/public.d.ts +9 -1
- package/src/exports/index.js +10 -0
- package/src/exports/node/index.js +77 -5
- package/src/exports/public.d.ts +9 -0
- package/src/exports/vite/build/build_server.js +3 -3
- package/src/exports/vite/build/utils.js +48 -4
- package/src/exports/vite/dev/index.js +11 -22
- package/src/exports/vite/index.js +62 -345
- package/src/exports/vite/module_ids.js +1 -11
- package/src/exports/vite/plugins/env-vars.js +117 -0
- package/src/exports/vite/preview/index.js +6 -4
- package/src/exports/vite/utils.js +2 -4
- package/src/runtime/app/env/{types.d.ts → client.js} +9 -4
- package/src/runtime/app/env/index.js +1 -2
- package/src/runtime/app/env/private/index.js +1 -0
- package/src/runtime/app/env/public/client.js +1 -1
- package/src/runtime/app/env/public/server.js +1 -1
- package/src/runtime/app/env/{internal.js → server.js} +4 -4
- package/src/runtime/app/forms/client.js +263 -0
- package/src/runtime/app/forms/index.js +1 -263
- package/src/runtime/app/forms/public.d.ts +1 -1
- package/src/runtime/app/forms/server.js +6 -0
- package/src/runtime/app/forms/shared.js +34 -0
- package/src/runtime/app/manifest/index.js +1 -1
- package/src/runtime/app/navigation/client.js +15 -0
- package/src/runtime/app/navigation/index.js +1 -15
- package/src/runtime/app/navigation/public.d.ts +1 -1
- package/src/runtime/app/navigation/server.js +15 -0
- package/src/runtime/app/paths/server.js +1 -1
- package/src/runtime/app/server/public.d.ts +512 -0
- package/src/runtime/app/server/remote/command.js +1 -1
- package/src/runtime/app/server/remote/form.js +16 -6
- package/src/runtime/app/server/remote/prerender.js +2 -3
- package/src/runtime/app/server/remote/query.js +2 -2
- package/src/runtime/app/server/remote/requested.js +3 -3
- package/src/runtime/app/state/client.svelte.js +207 -0
- package/src/runtime/app/state/index.js +1 -66
- package/src/runtime/app/state/public.d.ts +1 -1
- package/src/runtime/client/bundle.js +1 -1
- package/src/runtime/client/client.js +206 -274
- package/src/runtime/client/fetcher.js +18 -8
- package/src/runtime/client/remote-functions/command.svelte.js +1 -1
- package/src/runtime/client/remote-functions/form.svelte.js +10 -7
- package/src/runtime/client/remote-functions/prerender.svelte.js +2 -2
- package/src/runtime/client/remote-functions/query/index.js +1 -1
- package/src/runtime/client/remote-functions/query/instance.svelte.js +2 -1
- package/src/runtime/client/remote-functions/query-batch.svelte.js +1 -1
- package/src/runtime/client/remote-functions/query-live/index.js +1 -1
- package/src/runtime/client/remote-functions/query-live/instance.svelte.js +4 -3
- package/src/runtime/client/remote-functions/query-live/iterator.js +1 -1
- package/src/runtime/client/remote-functions/shared.svelte.js +3 -3
- package/src/runtime/client/snapshots.js +1 -3
- package/src/runtime/client/stream.js +27 -20
- package/src/runtime/client/utils.js +7 -3
- package/src/runtime/components/root.svelte +5 -5
- package/src/runtime/env/dynamic/private.js +1 -1
- package/src/runtime/env/static/private.js +1 -1
- package/src/runtime/error-chain.js +54 -0
- package/src/runtime/form-utils.js +53 -77
- package/src/runtime/invalid-import.js +1 -0
- package/src/runtime/props.svelte.js +1 -1
- package/src/runtime/server/data/index.js +1 -1
- package/src/runtime/server/endpoint.js +8 -3
- package/src/runtime/server/env_module.js +1 -1
- package/src/runtime/server/errors.js +2 -2
- package/src/runtime/server/index.js +2 -2
- package/src/runtime/server/page/actions.js +77 -122
- package/src/runtime/server/page/index.js +37 -69
- package/src/runtime/server/page/render.js +18 -23
- package/src/runtime/server/remote-functions.js +15 -43
- package/src/runtime/server/respond.js +23 -3
- package/src/telemetry.js +1 -33
- package/src/types/ambient-private.d.ts +9 -17
- package/src/types/internal.d.ts +21 -5
- package/src/types/private.d.ts +1 -1
- package/src/utils/exports.js +1 -0
- package/src/utils/filesystem.js +9 -21
- package/src/utils/functions.js +10 -0
- package/src/utils/promise.js +25 -0
- package/src/utils/routing.js +0 -11
- package/src/utils/url.js +0 -11
- package/src/version.js +1 -1
- package/types/index.d.ts +1134 -1136
- package/types/index.d.ts.map +50 -50
- package/src/exports/remote/index.js +0 -11
- package/src/exports/remote/public.d.ts +0 -519
- package/src/runtime/app/env/private.js +0 -1
- package/src/runtime/app/env/standard-schema.d.ts +0 -0
- package/src/runtime/app/state/client.js +0 -63
- package/src/runtime/client/state.svelte.js +0 -98
- package/src/runtime/server/ambient.d.ts +0 -4
- package/src/utils/path.js +0 -23
package/types/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
declare module '@sveltejs/kit' {
|
|
5
5
|
import type { Plugin } from 'vite';
|
|
6
6
|
import type { RouteId as AppRouteId, LayoutParams as AppLayoutParams } from '$app/types';
|
|
7
|
-
import type { Config } from '@sveltejs/kit/vite';
|
|
8
7
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
8
|
+
import type { Config } from '@sveltejs/kit/vite';
|
|
9
9
|
// @ts-ignore this is an optional peer dependency so could be missing. Written like this so dts-buddy preserves the ts-ignore
|
|
10
10
|
type Span = import('@opentelemetry/api').Span;
|
|
11
11
|
|
|
@@ -86,6 +86,14 @@ declare module '@sveltejs/kit' {
|
|
|
86
86
|
[uniqueSymbol]: true; // necessary or else UnpackValidationError could wrongly unpack objects with the same shape as ActionFailure
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* A validation error thrown by `invalid`.
|
|
91
|
+
*/
|
|
92
|
+
export interface ValidationError {
|
|
93
|
+
/** The validation issues */
|
|
94
|
+
issues: StandardSchemaV1.Issue[];
|
|
95
|
+
}
|
|
96
|
+
|
|
89
97
|
type UnpackValidationError<T> =
|
|
90
98
|
T extends ActionFailure<infer X>
|
|
91
99
|
? X
|
|
@@ -820,7 +828,7 @@ declare module '@sveltejs/kit' {
|
|
|
820
828
|
complete(entry: { generateManifest(opts: { relativePath: string }): string }): MaybePromise<void>;
|
|
821
829
|
}
|
|
822
830
|
|
|
823
|
-
type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS';
|
|
831
|
+
type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'QUERY';
|
|
824
832
|
|
|
825
833
|
interface Logger {
|
|
826
834
|
(msg: string): void;
|
|
@@ -1028,6 +1036,12 @@ declare module '@sveltejs/kit' {
|
|
|
1028
1036
|
* @since 2.47.3
|
|
1029
1037
|
*/
|
|
1030
1038
|
export function invalid(...issues: (StandardSchemaV1.Issue | string)[]): never;
|
|
1039
|
+
/**
|
|
1040
|
+
* Checks whether this is a validation error thrown by {@link invalid}.
|
|
1041
|
+
* @param e The object to check.
|
|
1042
|
+
* @since 2.47.3
|
|
1043
|
+
*/
|
|
1044
|
+
export function isValidationError(e: unknown): e is ValidationError;
|
|
1031
1045
|
/**
|
|
1032
1046
|
* Strips possible SvelteKit-internal suffixes and trailing slashes from the URL pathname.
|
|
1033
1047
|
* Returns the normalized URL as well as a method for adding the potential suffix back
|
|
@@ -1303,9 +1317,17 @@ declare module '@sveltejs/kit/hooks' {
|
|
|
1303
1317
|
* `<head>` tag; if `output.linkHeaderPreload` is enabled, dynamically rendered pages use the
|
|
1304
1318
|
* [`Link` response header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link) instead.
|
|
1305
1319
|
* By default, `js` and `css` files will be preloaded.
|
|
1320
|
+
*
|
|
1321
|
+
* For `font` files, `input` also has a `filename` property, the source file's pathname relative
|
|
1322
|
+
* to the project root, so that a filter can match on it instead of the hashed path. `js` and
|
|
1323
|
+
* `css` files are bundled and have no single source file name.
|
|
1306
1324
|
* @param input the type of the file and its path
|
|
1307
1325
|
*/
|
|
1308
|
-
preload?: (
|
|
1326
|
+
preload?: (
|
|
1327
|
+
input:
|
|
1328
|
+
| { type: 'css' | 'js' | 'asset'; path: string }
|
|
1329
|
+
| { type: 'font'; path: string; filename: string }
|
|
1330
|
+
) => boolean;
|
|
1309
1331
|
}
|
|
1310
1332
|
|
|
1311
1333
|
type AppErrorWithOptionalDefaults = Omit<App.Error, 'status' | 'message'> & {
|
|
@@ -1404,8 +1426,9 @@ declare module '@sveltejs/kit/hooks' {
|
|
|
1404
1426
|
}
|
|
1405
1427
|
|
|
1406
1428
|
declare module '@sveltejs/kit/node' {
|
|
1407
|
-
export function getRequest({ request, base, bodySizeLimit }: {
|
|
1429
|
+
export function getRequest({ request, response, base, bodySizeLimit }: {
|
|
1408
1430
|
request: import("http").IncomingMessage;
|
|
1431
|
+
response?: import("http").ServerResponse;
|
|
1409
1432
|
base: string;
|
|
1410
1433
|
bodySizeLimit?: number;
|
|
1411
1434
|
}): Request;
|
|
@@ -1485,775 +1508,238 @@ declare module '@sveltejs/kit/params' {
|
|
|
1485
1508
|
export {};
|
|
1486
1509
|
}
|
|
1487
1510
|
|
|
1488
|
-
declare module '@sveltejs/kit/
|
|
1489
|
-
import type {
|
|
1490
|
-
|
|
1491
|
-
type
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
type
|
|
1495
|
-
text: string;
|
|
1496
|
-
email: string;
|
|
1497
|
-
password: string;
|
|
1498
|
-
url: string;
|
|
1499
|
-
tel: string;
|
|
1500
|
-
search: string;
|
|
1501
|
-
number: number;
|
|
1502
|
-
range: number;
|
|
1503
|
-
date: string;
|
|
1504
|
-
'datetime-local': string;
|
|
1505
|
-
time: string;
|
|
1506
|
-
month: string;
|
|
1507
|
-
week: string;
|
|
1508
|
-
color: string;
|
|
1509
|
-
checkbox: boolean | string[];
|
|
1510
|
-
radio: string;
|
|
1511
|
-
file: File;
|
|
1512
|
-
hidden: string | number | boolean;
|
|
1513
|
-
submit: string | number | boolean;
|
|
1514
|
-
button: string;
|
|
1515
|
-
reset: string;
|
|
1516
|
-
image: string;
|
|
1517
|
-
select: string;
|
|
1518
|
-
'select multiple': string[];
|
|
1519
|
-
'file multiple': File[];
|
|
1520
|
-
};
|
|
1521
|
-
|
|
1522
|
-
// Valid input types for a given value type
|
|
1523
|
-
export type RemoteFormFieldType<T> = {
|
|
1524
|
-
[K in keyof InputTypeMap]: T extends InputTypeMap[K] ? K : never;
|
|
1525
|
-
}[keyof InputTypeMap];
|
|
1526
|
-
|
|
1527
|
-
// Input element properties based on type
|
|
1528
|
-
type InputElementProps<T extends keyof InputTypeMap> = T extends 'checkbox' | 'radio'
|
|
1529
|
-
? {
|
|
1530
|
-
name: string;
|
|
1531
|
-
type: T;
|
|
1532
|
-
value?: string;
|
|
1533
|
-
'aria-invalid': boolean | 'false' | 'true' | undefined;
|
|
1534
|
-
get checked(): boolean;
|
|
1535
|
-
set checked(value: boolean);
|
|
1536
|
-
readonly defaultChecked?: boolean;
|
|
1537
|
-
}
|
|
1538
|
-
: T extends 'file'
|
|
1539
|
-
? {
|
|
1540
|
-
name: string;
|
|
1541
|
-
type: 'file';
|
|
1542
|
-
'aria-invalid': boolean | 'false' | 'true' | undefined;
|
|
1543
|
-
get files(): FileList | null;
|
|
1544
|
-
set files(v: FileList | null);
|
|
1545
|
-
}
|
|
1546
|
-
: T extends 'select'
|
|
1547
|
-
? {
|
|
1548
|
-
name: string;
|
|
1549
|
-
'aria-invalid': boolean | 'false' | 'true' | undefined;
|
|
1550
|
-
get value(): string;
|
|
1551
|
-
set value(v: string);
|
|
1552
|
-
}
|
|
1553
|
-
: T extends 'select multiple'
|
|
1554
|
-
? {
|
|
1555
|
-
name: string;
|
|
1556
|
-
multiple: true;
|
|
1557
|
-
'aria-invalid': boolean | 'false' | 'true' | undefined;
|
|
1558
|
-
get value(): string[];
|
|
1559
|
-
set value(v: string[]);
|
|
1560
|
-
}
|
|
1561
|
-
: T extends 'text'
|
|
1562
|
-
? {
|
|
1563
|
-
name: string;
|
|
1564
|
-
'aria-invalid': boolean | 'false' | 'true' | undefined;
|
|
1565
|
-
get value(): string | number;
|
|
1566
|
-
set value(v: string | number);
|
|
1567
|
-
readonly defaultValue?: string | number;
|
|
1568
|
-
}
|
|
1569
|
-
: {
|
|
1570
|
-
name: string;
|
|
1571
|
-
type: T;
|
|
1572
|
-
'aria-invalid': boolean | 'false' | 'true' | undefined;
|
|
1573
|
-
get value(): string | number;
|
|
1574
|
-
set value(v: string | number);
|
|
1575
|
-
readonly defaultValue?: string | number;
|
|
1576
|
-
};
|
|
1577
|
-
|
|
1578
|
-
type RemoteFormFieldMethods<T> = {
|
|
1579
|
-
/** The values that will be submitted */
|
|
1580
|
-
value(): DeepPartial<T>;
|
|
1581
|
-
/** Set the values that will be submitted */
|
|
1582
|
-
set(input: DeepPartial<T>): DeepPartial<T>;
|
|
1583
|
-
/** Whether the field or any nested field has been interacted with since the form was mounted */
|
|
1584
|
-
touched(): boolean;
|
|
1585
|
-
/** Whether the field or any nested field has been edited since the form was mounted */
|
|
1586
|
-
dirty(): boolean;
|
|
1587
|
-
/** Validation issues, if any */
|
|
1588
|
-
issues(): RemoteFormIssue[] | undefined;
|
|
1589
|
-
};
|
|
1590
|
-
|
|
1591
|
-
// These two types use "T extends unknown ? .. : .." to distribute over unions.
|
|
1592
|
-
// Example: if "type T = A | b" then "keyof T" only contains keys that both A and B have, with "KeysOfUnion<T>" we get the keys of both A and B
|
|
1593
|
-
type KeysOfUnion<T> = T extends unknown ? keyof T : never;
|
|
1594
|
-
type ValueOfUnionKey<T, K extends PropertyKey> = T extends unknown
|
|
1595
|
-
? K extends keyof T
|
|
1596
|
-
? T[K]
|
|
1597
|
-
: never
|
|
1598
|
-
: never;
|
|
1599
|
-
|
|
1600
|
-
export type RemoteFormFieldValue = string | string[] | number | boolean | File | File[];
|
|
1601
|
-
|
|
1602
|
-
type AsArgs<Type extends keyof InputTypeMap, Value> = Type extends 'checkbox'
|
|
1603
|
-
? Value extends string[]
|
|
1604
|
-
? [type: Type, value: Value[number] | (string & {})]
|
|
1605
|
-
: Value extends boolean
|
|
1606
|
-
? [type: Type] | [type: Type, value: boolean]
|
|
1607
|
-
: [type: Type] | [type: Type, value: Value | (string & {})]
|
|
1608
|
-
: Type extends 'submit' | 'hidden'
|
|
1609
|
-
? Value extends string
|
|
1610
|
-
? [type: Type, value: Value | (string & {})]
|
|
1611
|
-
: [type: Type, value: Value]
|
|
1612
|
-
: Type extends 'radio'
|
|
1613
|
-
? [type: Type, value: Value | (string & {})]
|
|
1614
|
-
: Type extends 'file' | 'file multiple'
|
|
1615
|
-
? [type: Type]
|
|
1616
|
-
: [type: Type] | [type: Type, value: Value | undefined];
|
|
1511
|
+
declare module '@sveltejs/kit/vite' {
|
|
1512
|
+
import type { Adapter } from '@sveltejs/kit';
|
|
1513
|
+
import type { Options } from '@sveltejs/vite-plugin-svelte';
|
|
1514
|
+
import type { Plugin } from 'vite';
|
|
1515
|
+
// this indirection helps make the docs look pretty
|
|
1516
|
+
type VitePluginSvelteOptions = Omit<Options, 'experimental'>;
|
|
1517
|
+
type VitePluginSvelteOptionsExperimental = Options['experimental'];
|
|
1617
1518
|
|
|
1618
1519
|
/**
|
|
1619
|
-
*
|
|
1520
|
+
* An extension of [`vite-plugin-svelte`'s options](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#svelte-options).
|
|
1620
1521
|
*/
|
|
1621
|
-
export
|
|
1522
|
+
export interface Config extends VitePluginSvelteOptions {
|
|
1622
1523
|
/**
|
|
1623
|
-
*
|
|
1624
|
-
*
|
|
1625
|
-
* @example
|
|
1626
|
-
* ```svelte
|
|
1627
|
-
* <input {...myForm.fields.myString.as('text')} />
|
|
1628
|
-
* <input {...myForm.fields.myNumber.as('number')} />
|
|
1629
|
-
* <input {...myForm.fields.myBoolean.as('checkbox')} />
|
|
1630
|
-
* ```
|
|
1524
|
+
* Your [adapter](https://svelte.dev/docs/kit/adapters) is run when executing `vite build`. It determines how the output is converted for different platforms.
|
|
1525
|
+
* @default undefined
|
|
1631
1526
|
*/
|
|
1632
|
-
|
|
1633
|
-
};
|
|
1634
|
-
|
|
1635
|
-
type RemoteFormFieldContainer<Value> = RemoteFormFieldMethods<Value> & {
|
|
1636
|
-
/** Validation issues belonging to this or any of the fields that belong to it, if any */
|
|
1637
|
-
allIssues(): RemoteFormIssue[] | undefined;
|
|
1638
|
-
};
|
|
1639
|
-
|
|
1640
|
-
type UnknownField<Value> = RemoteFormFieldMethods<Value> & {
|
|
1641
|
-
/** Validation issues belonging to this or any of the fields that belong to it, if any */
|
|
1642
|
-
allIssues(): RemoteFormIssue[] | undefined;
|
|
1527
|
+
adapter?: Adapter;
|
|
1643
1528
|
/**
|
|
1644
|
-
*
|
|
1645
|
-
*
|
|
1646
|
-
*
|
|
1647
|
-
*
|
|
1648
|
-
*
|
|
1649
|
-
*
|
|
1650
|
-
*
|
|
1529
|
+
* An object containing zero or more aliases used to replace values in `import` statements. These aliases are automatically passed to Vite and TypeScript.
|
|
1530
|
+
*
|
|
1531
|
+
* This option is deprecated. Use [subpath imports](https://svelte.dev/docs/kit/$lib) instead.
|
|
1532
|
+
*
|
|
1533
|
+
* > [!NOTE] You will need to run `npm run dev` to have SvelteKit automatically generate the required alias configuration in `jsconfig.json` or `tsconfig.json`.
|
|
1534
|
+
* @deprecated
|
|
1535
|
+
* @default {}
|
|
1536
|
+
*/
|
|
1537
|
+
alias?: Record<string, string>;
|
|
1538
|
+
/**
|
|
1539
|
+
* The directory where SvelteKit keeps its stuff, including static assets (such as JS and CSS) and internally-used routes.
|
|
1540
|
+
*
|
|
1541
|
+
* If `paths.assets` is specified, there will be two app directories — `${paths.assets}/${appDir}` and `${paths.base}/${appDir}`.
|
|
1542
|
+
* @default "_app"
|
|
1543
|
+
*/
|
|
1544
|
+
appDir?: string;
|
|
1545
|
+
/**
|
|
1546
|
+
* [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...
|
|
1547
|
+
*
|
|
1548
|
+
* ```js
|
|
1549
|
+
* /// file: vite.config.js
|
|
1550
|
+
* import { sveltekit } from '@sveltejs/kit/vite';
|
|
1551
|
+
* import { defineConfig } from 'vite';
|
|
1552
|
+
*
|
|
1553
|
+
* export default defineConfig({
|
|
1554
|
+
* plugins: [
|
|
1555
|
+
* sveltekit({
|
|
1556
|
+
* csp: {
|
|
1557
|
+
* directives: {
|
|
1558
|
+
* 'script-src': ['self']
|
|
1559
|
+
* },
|
|
1560
|
+
* // must be specified with either the `report-uri` or `report-to` directives, or both
|
|
1561
|
+
* reportOnly: {
|
|
1562
|
+
* 'script-src': ['self'],
|
|
1563
|
+
* 'report-uri': ['/']
|
|
1564
|
+
* }
|
|
1565
|
+
* }
|
|
1566
|
+
* })
|
|
1567
|
+
* ]
|
|
1568
|
+
* });
|
|
1651
1569
|
* ```
|
|
1570
|
+
*
|
|
1571
|
+
* ...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.
|
|
1572
|
+
*
|
|
1573
|
+
* To add a nonce for scripts and links manually included in `src/app.html`, you may use the placeholder `%sveltekit.nonce%` (for example `<script nonce="%sveltekit.nonce%">`).
|
|
1574
|
+
*
|
|
1575
|
+
* When pages are prerendered, the CSP header is added via a `<meta http-equiv>` tag (note that in this case, `frame-ancestors`, `report-uri` and `sandbox` directives will be ignored).
|
|
1576
|
+
*
|
|
1577
|
+
* > [!NOTE] When `mode` is `'auto'`, SvelteKit will use nonces for dynamically rendered pages and hashes for prerendered pages. Using nonces with prerendered pages is insecure and therefore forbidden.
|
|
1578
|
+
*
|
|
1579
|
+
* If this level of configuration is insufficient and you have more dynamic requirements, you can use the [`handle` hook](https://svelte.dev/docs/kit/hooks#handle) to roll your own CSP.
|
|
1652
1580
|
*/
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
allIssues(): RemoteFormIssue[] | undefined;
|
|
1667
|
-
}
|
|
1668
|
-
: RemoteFormFields<Input>;
|
|
1669
|
-
|
|
1670
|
-
/**
|
|
1671
|
-
* Recursive type to build form fields structure with proxy access
|
|
1672
|
-
*/
|
|
1673
|
-
export type RemoteFormFields<T> =
|
|
1674
|
-
WillRecurseIndefinitely<T> extends true
|
|
1675
|
-
? RecursiveFormFields
|
|
1676
|
-
: NonNullable<T> extends string | number | boolean | File
|
|
1677
|
-
? RemoteFormField<NonNullable<T>>
|
|
1678
|
-
: // [NonNullable<T>] is used to prevent distributing over union while still allowing
|
|
1679
|
-
// nullable wrappers (e.g. `string[] | undefined` from a schema with `.default([])`)
|
|
1680
|
-
// to be treated as arrays; only the last condition should distribute over unions
|
|
1681
|
-
[NonNullable<T>] extends [string[] | File[]]
|
|
1682
|
-
? RemoteFormField<NonNullable<T>> & {
|
|
1683
|
-
[K in number]: RemoteFormField<NonNullable<T>[number]>;
|
|
1684
|
-
}
|
|
1685
|
-
: [NonNullable<T>] extends [Array<infer U>]
|
|
1686
|
-
? RemoteFormFieldContainer<NonNullable<T>> & {
|
|
1687
|
-
[K in number]: RemoteFormFields<U>;
|
|
1688
|
-
}
|
|
1689
|
-
: RemoteFormFieldContainer<T> & {
|
|
1690
|
-
[K in KeysOfUnion<T>]-?: RemoteFormFields<ValueOfUnionKey<T, K>>;
|
|
1691
|
-
};
|
|
1692
|
-
|
|
1693
|
-
// By breaking this out into its own type, we avoid the TS recursion depth limit
|
|
1694
|
-
type RecursiveFormFields = RemoteFormFieldContainer<any> & {
|
|
1695
|
-
[key: string | number]: UnknownField<any>;
|
|
1696
|
-
};
|
|
1697
|
-
|
|
1698
|
-
type MaybeArray<T> = T | T[];
|
|
1699
|
-
|
|
1700
|
-
export interface RemoteFormInput {
|
|
1701
|
-
[key: string]: MaybeArray<string | number | boolean | File | RemoteFormInput> | undefined;
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
export interface RemoteFormIssue {
|
|
1705
|
-
message: string;
|
|
1706
|
-
path: Array<string | number>;
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
// If the schema specifies `id` as a string or number, ensure that `for(...)`
|
|
1710
|
-
// only accepts that type. Otherwise, accept `string | number`
|
|
1711
|
-
type ExtractId<Input> = Input extends { id: infer Id }
|
|
1712
|
-
? Id extends string | number
|
|
1713
|
-
? Id
|
|
1714
|
-
: string | number
|
|
1715
|
-
: string | number;
|
|
1716
|
-
|
|
1717
|
-
/**
|
|
1718
|
-
* A function and proxy object used to imperatively create validation errors in form handlers.
|
|
1719
|
-
*
|
|
1720
|
-
* Access properties to create field-specific issues: `issue.fieldName('message')`.
|
|
1721
|
-
* The type structure mirrors the input data structure for type-safe field access.
|
|
1722
|
-
* Call `invalid(issue.foo(...), issue.nested.bar(...))` to throw a validation error.
|
|
1723
|
-
*/
|
|
1724
|
-
export type InvalidField<T> =
|
|
1725
|
-
WillRecurseIndefinitely<T> extends true
|
|
1726
|
-
? Record<string | number, any>
|
|
1727
|
-
: NonNullable<T> extends string | number | boolean | File
|
|
1728
|
-
? (message: string) => StandardSchemaV1.Issue
|
|
1729
|
-
: NonNullable<T> extends Array<infer U>
|
|
1730
|
-
? {
|
|
1731
|
-
[K in number]: InvalidField<U>;
|
|
1732
|
-
} & ((message: string) => StandardSchemaV1.Issue)
|
|
1733
|
-
: NonNullable<T> extends RemoteFormInput
|
|
1734
|
-
? {
|
|
1735
|
-
[K in keyof T]-?: InvalidField<T[K]>;
|
|
1736
|
-
} & ((message: string) => StandardSchemaV1.Issue)
|
|
1737
|
-
: Record<string, never>;
|
|
1738
|
-
|
|
1739
|
-
/**
|
|
1740
|
-
* A validation error thrown by `invalid`.
|
|
1741
|
-
*/
|
|
1742
|
-
export interface ValidationError {
|
|
1743
|
-
/** The validation issues */
|
|
1744
|
-
issues: StandardSchemaV1.Issue[];
|
|
1745
|
-
}
|
|
1746
|
-
|
|
1747
|
-
/**
|
|
1748
|
-
* The form instance as received inside an `enhance` callback. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
|
|
1749
|
-
*/
|
|
1750
|
-
export type RemoteFormEnhanceInstance<
|
|
1751
|
-
Input extends RemoteFormInput | void = RemoteFormInput | void,
|
|
1752
|
-
Output = any
|
|
1753
|
-
> = Omit<RemoteForm<Input, Output>, 'enhance' | 'element'> & {
|
|
1754
|
-
readonly element: HTMLFormElement;
|
|
1755
|
-
};
|
|
1756
|
-
|
|
1757
|
-
/**
|
|
1758
|
-
* The callback passed to a remote form's `enhance` method. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
|
|
1759
|
-
*/
|
|
1760
|
-
export type RemoteFormEnhanceCallback<
|
|
1761
|
-
Input extends RemoteFormInput | void = RemoteFormInput | void,
|
|
1762
|
-
Output = any
|
|
1763
|
-
> = (form: RemoteFormEnhanceInstance<Input, Output>) => MaybePromise<void>;
|
|
1764
|
-
|
|
1765
|
-
/**
|
|
1766
|
-
* The type of a remote `form` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
|
|
1767
|
-
*/
|
|
1768
|
-
export type RemoteForm<Input extends RemoteFormInput | void, Output> = {
|
|
1769
|
-
/** Attachment that sets up an event handler that intercepts the form submission on the client to prevent a full page reload */
|
|
1770
|
-
[attachment: symbol]: (node: HTMLFormElement) => void;
|
|
1771
|
-
method: 'POST';
|
|
1772
|
-
/** The URL to send the form to. */
|
|
1773
|
-
action: string;
|
|
1774
|
-
/** The `<form>` element this instance is currently attached to, if any. */
|
|
1775
|
-
get element(): HTMLFormElement | null;
|
|
1776
|
-
/** Submit the currently attached form programmatically. */
|
|
1777
|
-
submit(): Promise<boolean> & {
|
|
1778
|
-
updates: (...updates: RemoteQueryUpdate[]) => Promise<boolean>;
|
|
1779
|
-
};
|
|
1780
|
-
/** Use the `enhance` method to influence what happens when the form is submitted. */
|
|
1781
|
-
enhance(callback: RemoteFormEnhanceCallback<Input, Output>): {
|
|
1782
|
-
method: 'POST';
|
|
1783
|
-
action: string;
|
|
1784
|
-
[attachment: symbol]: (node: HTMLFormElement) => void;
|
|
1581
|
+
csp?: {
|
|
1582
|
+
/**
|
|
1583
|
+
* Whether to use hashes or nonces to restrict `<script>` and `<style>` elements. `'auto'` will use hashes for prerendered pages, and nonces for dynamically rendered pages.
|
|
1584
|
+
*/
|
|
1585
|
+
mode?: 'hash' | 'nonce' | 'auto';
|
|
1586
|
+
/**
|
|
1587
|
+
* Directives that will be added to `Content-Security-Policy` headers.
|
|
1588
|
+
*/
|
|
1589
|
+
directives?: CspDirectives;
|
|
1590
|
+
/**
|
|
1591
|
+
* Directives that will be added to `Content-Security-Policy-Report-Only` headers.
|
|
1592
|
+
*/
|
|
1593
|
+
reportOnly?: CspDirectives;
|
|
1785
1594
|
};
|
|
1786
1595
|
/**
|
|
1787
|
-
*
|
|
1788
|
-
* The `id` is stringified and used for deduplication to potentially reuse existing instances.
|
|
1789
|
-
* Useful when you have multiple forms that use the same remote form action, for example in a loop.
|
|
1790
|
-
* ```svelte
|
|
1791
|
-
* {#each todos as todo}
|
|
1792
|
-
* {const todoForm = updateTodo.for(todo.id)}
|
|
1793
|
-
* <form {...todoForm}>
|
|
1794
|
-
* {#if todoForm.result?.invalid}<p>Invalid data</p>{/if}
|
|
1795
|
-
* ...
|
|
1796
|
-
* </form>
|
|
1797
|
-
* {/each}
|
|
1798
|
-
* ```
|
|
1596
|
+
* Protection against [cross-site request forgery (CSRF)](https://owasp.org/www-community/attacks/csrf) attacks.
|
|
1799
1597
|
*/
|
|
1800
|
-
|
|
1801
|
-
/** Preflight checks */
|
|
1802
|
-
preflight(schema: StandardSchemaV1<Input, any>): RemoteForm<Input, Output>;
|
|
1803
|
-
/** Validate the form contents programmatically */
|
|
1804
|
-
validate(options?: {
|
|
1598
|
+
csrf?: {
|
|
1805
1599
|
/**
|
|
1806
|
-
*
|
|
1807
|
-
*
|
|
1808
|
-
*
|
|
1809
|
-
*
|
|
1600
|
+
* Whether to check the incoming `origin` header for `POST`, `PUT`, `PATCH`, or `DELETE` form submissions and verify that it matches the server's origin.
|
|
1601
|
+
*
|
|
1602
|
+
* To allow people to make `POST`, `PUT`, `PATCH`, or `DELETE` requests with a `Content-Type` of `application/x-www-form-urlencoded`, `multipart/form-data`, or `text/plain` to your app from other origins, you will need to disable this option. Be careful!
|
|
1603
|
+
* @default true
|
|
1604
|
+
* @deprecated removed in 3.0. Use `trustedOrigins: ['*']` instead
|
|
1810
1605
|
*/
|
|
1811
|
-
|
|
1812
|
-
/**
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
updates(...updates: RemoteQueryUpdate[]): Promise<Output>;
|
|
1606
|
+
checkOrigin?: boolean;
|
|
1607
|
+
/**
|
|
1608
|
+
* An array of origins that are allowed to make cross-origin form submissions to your app.
|
|
1609
|
+
*
|
|
1610
|
+
* Each origin should be a complete origin including protocol (e.g., `https://payment-gateway.com`).
|
|
1611
|
+
* This is useful for allowing trusted third-party services like payment gateways or authentication providers to submit forms to your app.
|
|
1612
|
+
*
|
|
1613
|
+
* If the array contains `'*'`, all origins will be trusted. This is generally not recommended!
|
|
1614
|
+
*
|
|
1615
|
+
* > [!NOTE] Only add origins you completely trust, as this bypasses CSRF protection for those origins.
|
|
1616
|
+
*
|
|
1617
|
+
* CSRF checks only apply in production, not in local development.
|
|
1618
|
+
* @default []
|
|
1619
|
+
* @example
|
|
1620
|
+
* ```js
|
|
1621
|
+
* ['https://checkout.stripe.com', 'https://accounts.google.com']
|
|
1622
|
+
* ```
|
|
1623
|
+
*/
|
|
1624
|
+
trustedOrigins?: string[];
|
|
1831
1625
|
};
|
|
1832
|
-
/** The number of pending command executions */
|
|
1833
|
-
get pending(): number;
|
|
1834
|
-
};
|
|
1835
|
-
|
|
1836
|
-
export type RemoteQueryUpdate =
|
|
1837
|
-
| RemoteQuery<any>
|
|
1838
|
-
| RemoteLiveQuery<any>
|
|
1839
|
-
| RemoteQueryFunction<any, any>
|
|
1840
|
-
| RemoteLiveQueryFunction<any, any>
|
|
1841
|
-
| RemoteQueryOverride;
|
|
1842
|
-
|
|
1843
|
-
export type RemoteResource<T> = Promise<T> & {
|
|
1844
|
-
/** The error in case the query fails. */
|
|
1845
|
-
get error(): App.Error | undefined;
|
|
1846
|
-
/** `true` before the first result is available and during refreshes */
|
|
1847
|
-
get loading(): boolean;
|
|
1848
|
-
} & (
|
|
1849
|
-
| {
|
|
1850
|
-
/** The current value of the query. Undefined until `ready` is `true` */
|
|
1851
|
-
get current(): undefined;
|
|
1852
|
-
ready: false;
|
|
1853
|
-
}
|
|
1854
|
-
| {
|
|
1855
|
-
/** The current value of the query. Undefined until `ready` is `true` */
|
|
1856
|
-
get current(): T;
|
|
1857
|
-
ready: true;
|
|
1858
|
-
}
|
|
1859
|
-
);
|
|
1860
|
-
|
|
1861
|
-
export type RemoteQuery<T> = RemoteResource<T> & {
|
|
1862
1626
|
/**
|
|
1863
|
-
*
|
|
1864
|
-
*
|
|
1865
|
-
*
|
|
1866
|
-
* This prevents SvelteKit needing to refresh all queries on the page in a second server round-trip.
|
|
1627
|
+
* Whether or not the app is embedded inside a larger app. If `true`, SvelteKit will add its event listeners related to navigation etc on the parent of `%sveltekit.body%` instead of `window`, and will pass `params` from the server rather than inferring them from `location.pathname`.
|
|
1628
|
+
* Note that it is generally not supported to embed multiple SvelteKit apps on the same page and use client-side SvelteKit features within them (things such as pushing to the history state assume a single instance).
|
|
1629
|
+
* @default false
|
|
1867
1630
|
*/
|
|
1868
|
-
|
|
1631
|
+
embedded?: boolean;
|
|
1869
1632
|
/**
|
|
1870
|
-
*
|
|
1871
|
-
*
|
|
1872
|
-
* On the server, this can be called in the context of a `command` or `form` and the refreshed data will accompany the action response back to the client.
|
|
1873
|
-
* This prevents SvelteKit needing to refresh all queries on the page in a second server round-trip.
|
|
1633
|
+
* Environment variable configuration
|
|
1874
1634
|
*/
|
|
1875
|
-
|
|
1635
|
+
env?: {
|
|
1636
|
+
/**
|
|
1637
|
+
* The directory to search for `.env` files.
|
|
1638
|
+
* @default "."
|
|
1639
|
+
*/
|
|
1640
|
+
dir?: string;
|
|
1641
|
+
};
|
|
1642
|
+
/** Experimental features. Here be dragons. These are not subject to semantic versioning, so breaking changes or removal can happen in any release. */
|
|
1643
|
+
experimental?: VitePluginSvelteOptionsExperimental & {
|
|
1644
|
+
/**
|
|
1645
|
+
* Whether to enable the experimental remote functions feature. This feature is not yet stable and may be changed or removed at any time.
|
|
1646
|
+
* @default false
|
|
1647
|
+
*/
|
|
1648
|
+
remoteFunctions?: boolean;
|
|
1649
|
+
|
|
1650
|
+
/**
|
|
1651
|
+
* Whether to enable the experimental forked preloading feature using Svelte's fork API.
|
|
1652
|
+
* @default false
|
|
1653
|
+
*/
|
|
1654
|
+
forkPreloads?: boolean;
|
|
1655
|
+
};
|
|
1876
1656
|
/**
|
|
1877
|
-
*
|
|
1878
|
-
*
|
|
1879
|
-
* ```svelte
|
|
1880
|
-
* <script>
|
|
1881
|
-
* import { getTodos, addTodo } from './todos.remote.js';
|
|
1882
|
-
* const todos = getTodos();
|
|
1883
|
-
* </script>
|
|
1884
|
-
*
|
|
1885
|
-
* <form {...addTodo.enhance(async (form) => {
|
|
1886
|
-
* await form.submit().updates(
|
|
1887
|
-
* todos.withOverride((todos) => [...todos, { text: form.fields.text.value() }])
|
|
1888
|
-
* );
|
|
1889
|
-
* })}>
|
|
1890
|
-
* <input type="text" name="text" />
|
|
1891
|
-
* <button type="submit">Add Todo</button>
|
|
1892
|
-
* </form>
|
|
1893
|
-
* ```
|
|
1657
|
+
* Where to find various files within your project.
|
|
1658
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
1894
1659
|
*/
|
|
1895
|
-
|
|
1896
|
-
};
|
|
1897
|
-
|
|
1898
|
-
export type RemoteLiveQuery<T> = RemoteResource<T> &
|
|
1899
|
-
AsyncIterable<T> & {
|
|
1900
|
-
/** `true` if the live stream is currently connected. */
|
|
1901
|
-
readonly connected: boolean;
|
|
1902
|
-
/** `true` once the current live stream iterator is done. */
|
|
1903
|
-
readonly done: boolean;
|
|
1904
|
-
/** Reconnects the live stream immediately. */
|
|
1905
|
-
reconnect(): Promise<void>;
|
|
1906
|
-
};
|
|
1907
|
-
|
|
1908
|
-
export type RemoteQueryOverride = () => void;
|
|
1909
|
-
|
|
1910
|
-
/**
|
|
1911
|
-
* The type of a remote `prerender` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#prerender) for full documentation.
|
|
1912
|
-
*/
|
|
1913
|
-
export type RemotePrerenderFunction<Input, Output> = (
|
|
1914
|
-
arg: undefined extends Input ? Input | void : Input
|
|
1915
|
-
) => RemoteResource<Output>;
|
|
1916
|
-
|
|
1917
|
-
/**
|
|
1918
|
-
* The return value of a remote `query` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query) for full documentation.
|
|
1919
|
-
*
|
|
1920
|
-
* The optional `Validated` generic parameter represents the argument type *after* the
|
|
1921
|
-
* query's schema has validated and (optionally) transformed it — this is the type the
|
|
1922
|
-
* query's implementation function receives on the server, and the type yielded by
|
|
1923
|
-
* [`requested`](https://svelte.dev/docs/kit/$app-server#requested). For queries declared
|
|
1924
|
-
* with [Standard Schema](https://standardschema.dev/) it differs from `Input` when the
|
|
1925
|
-
* schema contains a transform (e.g. `v.pipe(v.number(), v.transform(String))` has
|
|
1926
|
-
* `Input = number` but `Validated = string`). For `'unchecked'` validators and queries
|
|
1927
|
-
* without arguments it defaults to `Input`.
|
|
1928
|
-
*/
|
|
1929
|
-
export type RemoteQueryFunction<Input, Output, _Validated = Input> = (
|
|
1930
|
-
arg: undefined extends Input ? Input | void : Input
|
|
1931
|
-
) => RemoteQuery<Output>;
|
|
1932
|
-
|
|
1933
|
-
/**
|
|
1934
|
-
* The type of a remote `query.live` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query.live) for full documentation.
|
|
1935
|
-
*
|
|
1936
|
-
* The optional `Validated` generic parameter represents the argument type *after* the
|
|
1937
|
-
* query's schema has validated and (optionally) transformed it, and matches the type
|
|
1938
|
-
* yielded by [`requested`](https://svelte.dev/docs/kit/$app-server#requested).
|
|
1939
|
-
*/
|
|
1940
|
-
export type RemoteLiveQueryFunction<Input, Output, _Validated = Input> = (
|
|
1941
|
-
arg: undefined extends Input ? Input | void : Input
|
|
1942
|
-
) => RemoteLiveQuery<Output>;
|
|
1943
|
-
|
|
1944
|
-
/**
|
|
1945
|
-
* A single entry yielded by [`requested`](https://svelte.dev/docs/kit/$app-server#requested)
|
|
1946
|
-
* when called with a regular `query`. `arg` is the validated argument (the input *after*
|
|
1947
|
-
* the query's schema validated and transformed it, if applicable); `query` is a
|
|
1948
|
-
* `RemoteQuery` bound to the client's original cache key, so `refresh()` / `set()` will
|
|
1949
|
-
* update the correct client entry.
|
|
1950
|
-
*/
|
|
1951
|
-
export type RequestedEntry<Validated, Output> = {
|
|
1952
|
-
arg: Validated;
|
|
1953
|
-
query: RemoteQuery<Output>;
|
|
1954
|
-
};
|
|
1955
|
-
|
|
1956
|
-
/**
|
|
1957
|
-
* A single entry yielded by [`requested`](https://svelte.dev/docs/kit/$app-server#requested)
|
|
1958
|
-
* when called with a `query.live`. `arg` is the validated argument; `query` is a
|
|
1959
|
-
* `RemoteLiveQuery` bound to the client's original cache key, so `reconnect()` targets
|
|
1960
|
-
* the correct client subscription.
|
|
1961
|
-
*/
|
|
1962
|
-
export type LiveRequestedEntry<Validated, Output> = {
|
|
1963
|
-
arg: Validated;
|
|
1964
|
-
query: RemoteLiveQuery<Output>;
|
|
1965
|
-
};
|
|
1966
|
-
|
|
1967
|
-
export type QueryRequestedResult<Validated, Output> = Iterable<RequestedEntry<Validated, Output>> &
|
|
1968
|
-
AsyncIterable<RequestedEntry<Validated, Output>> & {
|
|
1660
|
+
files?: {
|
|
1969
1661
|
/**
|
|
1970
|
-
*
|
|
1971
|
-
*
|
|
1972
|
-
*
|
|
1973
|
-
*
|
|
1974
|
-
*
|
|
1975
|
-
* for await (const { query } of requested(getPost, ...)) {
|
|
1976
|
-
* void query.refresh();
|
|
1977
|
-
* }
|
|
1978
|
-
* ```
|
|
1662
|
+
* The location of your source code.
|
|
1663
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
1664
|
+
* @default "src"
|
|
1665
|
+
* @since 2.28
|
|
1979
1666
|
*/
|
|
1980
|
-
|
|
1981
|
-
};
|
|
1982
|
-
|
|
1983
|
-
export type LiveQueryRequestedResult<Validated, Output> = Iterable<
|
|
1984
|
-
LiveRequestedEntry<Validated, Output>
|
|
1985
|
-
> &
|
|
1986
|
-
AsyncIterable<LiveRequestedEntry<Validated, Output>> & {
|
|
1667
|
+
src?: string;
|
|
1987
1668
|
/**
|
|
1988
|
-
*
|
|
1989
|
-
*
|
|
1990
|
-
*
|
|
1991
|
-
* import { requested } from '$app/server';
|
|
1992
|
-
*
|
|
1993
|
-
* for await (const { query } of requested(liveQuery, ...)) {
|
|
1994
|
-
* void query.reconnect();
|
|
1995
|
-
* }
|
|
1996
|
-
* ```
|
|
1669
|
+
* A place to put static files that should have stable URLs and undergo no processing, such as `favicon.ico` or `manifest.json`.
|
|
1670
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
1671
|
+
* @default "static"
|
|
1997
1672
|
*/
|
|
1998
|
-
|
|
1673
|
+
assets?: string;
|
|
1674
|
+
hooks?: {
|
|
1675
|
+
/**
|
|
1676
|
+
* The location of your client [hooks](https://svelte.dev/docs/kit/hooks).
|
|
1677
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
1678
|
+
* @default "src/hooks.client"
|
|
1679
|
+
*/
|
|
1680
|
+
client?: string;
|
|
1681
|
+
/**
|
|
1682
|
+
* The location of your server [hooks](https://svelte.dev/docs/kit/hooks).
|
|
1683
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
1684
|
+
* @default "src/hooks.server"
|
|
1685
|
+
*/
|
|
1686
|
+
server?: string;
|
|
1687
|
+
/**
|
|
1688
|
+
* The location of your universal [hooks](https://svelte.dev/docs/kit/hooks).
|
|
1689
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
1690
|
+
* @default "src/hooks"
|
|
1691
|
+
* @since 2.3.0
|
|
1692
|
+
*/
|
|
1693
|
+
universal?: string;
|
|
1694
|
+
};
|
|
1695
|
+
/**
|
|
1696
|
+
* A directory containing [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#Matching).
|
|
1697
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
1698
|
+
* @default "src/params"
|
|
1699
|
+
*/
|
|
1700
|
+
params?: string;
|
|
1701
|
+
/**
|
|
1702
|
+
* The files that define the structure of your app (see [Routing](https://svelte.dev/docs/kit/routing)).
|
|
1703
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
1704
|
+
* @default "src/routes"
|
|
1705
|
+
*/
|
|
1706
|
+
routes?: string;
|
|
1707
|
+
/**
|
|
1708
|
+
* The location of your service worker's entry point (see [Service workers](https://svelte.dev/docs/kit/service-workers)).
|
|
1709
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
1710
|
+
* @default "src/service-worker"
|
|
1711
|
+
*/
|
|
1712
|
+
serviceWorker?: string;
|
|
1713
|
+
/**
|
|
1714
|
+
* The location of the template for HTML responses.
|
|
1715
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
1716
|
+
* @default "src/app.html"
|
|
1717
|
+
*/
|
|
1718
|
+
appTemplate?: string;
|
|
1719
|
+
/**
|
|
1720
|
+
* The location of the template for fallback error responses.
|
|
1721
|
+
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
1722
|
+
* @default "src/error.html"
|
|
1723
|
+
*/
|
|
1724
|
+
errorTemplate?: string;
|
|
1999
1725
|
};
|
|
2000
|
-
|
|
2001
|
-
export type RequestedResult<Validated, Output> =
|
|
2002
|
-
| QueryRequestedResult<Validated, Output>
|
|
2003
|
-
| LiveQueryRequestedResult<Validated, Output>;
|
|
2004
|
-
/**
|
|
2005
|
-
* Checks whether this is a validation error thrown by [`invalid`](https://svelte.dev/docs/kit/@sveltejs-kit#invalid).
|
|
2006
|
-
* @param e The object to check.
|
|
2007
|
-
* @since 2.47.3
|
|
2008
|
-
*/
|
|
2009
|
-
export function isValidationError(e: unknown): e is import("@sveltejs/kit/remote").ValidationError;
|
|
2010
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
2011
|
-
|
|
2012
|
-
type DeepPartial<T> = T extends Record<PropertyKey, unknown> | unknown[]
|
|
2013
|
-
? {
|
|
2014
|
-
[K in keyof T]?: T[K] extends Record<PropertyKey, unknown> | unknown[]
|
|
2015
|
-
? DeepPartial<T[K]>
|
|
2016
|
-
: T[K];
|
|
2017
|
-
}
|
|
2018
|
-
: T | undefined;
|
|
2019
|
-
|
|
2020
|
-
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
2021
|
-
|
|
2022
|
-
export {};
|
|
2023
|
-
}
|
|
2024
|
-
|
|
2025
|
-
declare module '@sveltejs/kit/vite' {
|
|
2026
|
-
import type { Adapter } from '@sveltejs/kit';
|
|
2027
|
-
import type { Options } from '@sveltejs/vite-plugin-svelte';
|
|
2028
|
-
import type { Plugin } from 'vite';
|
|
2029
|
-
// this indirection helps make the docs look pretty
|
|
2030
|
-
type VitePluginSvelteOptions = Omit<Options, 'experimental'>;
|
|
2031
|
-
type VitePluginSvelteOptionsExperimental = Options['experimental'];
|
|
2032
|
-
|
|
2033
|
-
/**
|
|
2034
|
-
* An extension of [`vite-plugin-svelte`'s options](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#svelte-options).
|
|
2035
|
-
*/
|
|
2036
|
-
export interface Config extends VitePluginSvelteOptions {
|
|
2037
1726
|
/**
|
|
2038
|
-
*
|
|
2039
|
-
*
|
|
1727
|
+
* Inline CSS inside a `<style>` block at the head of the HTML. This option is a number that specifies the maximum length of a CSS file in UTF-16 code units, as specified by the [String.length](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length) property, to be inlined. All CSS files needed for the page that are smaller than this value are merged and inlined in a `<style>` block.
|
|
1728
|
+
*
|
|
1729
|
+
* > [!NOTE] This results in fewer initial requests and can improve your [First Contentful Paint](https://web.dev/first-contentful-paint) score. However, it generates larger HTML output and reduces the effectiveness of browser caches. Use it advisedly.
|
|
1730
|
+
* @default 0
|
|
2040
1731
|
*/
|
|
2041
|
-
|
|
1732
|
+
inlineStyleThreshold?: number;
|
|
2042
1733
|
/**
|
|
2043
|
-
* An
|
|
2044
|
-
*
|
|
2045
|
-
* This option is deprecated. Use [subpath imports](https://svelte.dev/docs/kit/$lib) instead.
|
|
2046
|
-
*
|
|
2047
|
-
* > [!NOTE] You will need to run `npm run dev` to have SvelteKit automatically generate the required alias configuration in `jsconfig.json` or `tsconfig.json`.
|
|
2048
|
-
* @deprecated
|
|
2049
|
-
* @default {}
|
|
1734
|
+
* 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.
|
|
1735
|
+
* @default [".js", ".ts"]
|
|
2050
1736
|
*/
|
|
2051
|
-
|
|
1737
|
+
moduleExtensions?: string[];
|
|
2052
1738
|
/**
|
|
2053
|
-
* The directory
|
|
2054
|
-
*
|
|
2055
|
-
* If `paths.assets` is specified, there will be two app directories — `${paths.assets}/${appDir}` and `${paths.base}/${appDir}`.
|
|
2056
|
-
* @default "_app"
|
|
1739
|
+
* The directory that SvelteKit writes files to during `dev` and `build`. You should exclude this directory from version control.
|
|
1740
|
+
* @default ".svelte-kit"
|
|
2057
1741
|
*/
|
|
2058
|
-
|
|
2059
|
-
/**
|
|
2060
|
-
* [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...
|
|
2061
|
-
*
|
|
2062
|
-
* ```js
|
|
2063
|
-
* /// file: vite.config.js
|
|
2064
|
-
* import { sveltekit } from '@sveltejs/kit/vite';
|
|
2065
|
-
* import { defineConfig } from 'vite';
|
|
2066
|
-
*
|
|
2067
|
-
* export default defineConfig({
|
|
2068
|
-
* plugins: [
|
|
2069
|
-
* sveltekit({
|
|
2070
|
-
* csp: {
|
|
2071
|
-
* directives: {
|
|
2072
|
-
* 'script-src': ['self']
|
|
2073
|
-
* },
|
|
2074
|
-
* // must be specified with either the `report-uri` or `report-to` directives, or both
|
|
2075
|
-
* reportOnly: {
|
|
2076
|
-
* 'script-src': ['self'],
|
|
2077
|
-
* 'report-uri': ['/']
|
|
2078
|
-
* }
|
|
2079
|
-
* }
|
|
2080
|
-
* })
|
|
2081
|
-
* ]
|
|
2082
|
-
* });
|
|
2083
|
-
* ```
|
|
2084
|
-
*
|
|
2085
|
-
* ...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.
|
|
2086
|
-
*
|
|
2087
|
-
* To add a nonce for scripts and links manually included in `src/app.html`, you may use the placeholder `%sveltekit.nonce%` (for example `<script nonce="%sveltekit.nonce%">`).
|
|
2088
|
-
*
|
|
2089
|
-
* When pages are prerendered, the CSP header is added via a `<meta http-equiv>` tag (note that in this case, `frame-ancestors`, `report-uri` and `sandbox` directives will be ignored).
|
|
2090
|
-
*
|
|
2091
|
-
* > [!NOTE] When `mode` is `'auto'`, SvelteKit will use nonces for dynamically rendered pages and hashes for prerendered pages. Using nonces with prerendered pages is insecure and therefore forbidden.
|
|
2092
|
-
*
|
|
2093
|
-
* If this level of configuration is insufficient and you have more dynamic requirements, you can use the [`handle` hook](https://svelte.dev/docs/kit/hooks#handle) to roll your own CSP.
|
|
2094
|
-
*/
|
|
2095
|
-
csp?: {
|
|
2096
|
-
/**
|
|
2097
|
-
* Whether to use hashes or nonces to restrict `<script>` and `<style>` elements. `'auto'` will use hashes for prerendered pages, and nonces for dynamically rendered pages.
|
|
2098
|
-
*/
|
|
2099
|
-
mode?: 'hash' | 'nonce' | 'auto';
|
|
2100
|
-
/**
|
|
2101
|
-
* Directives that will be added to `Content-Security-Policy` headers.
|
|
2102
|
-
*/
|
|
2103
|
-
directives?: CspDirectives;
|
|
2104
|
-
/**
|
|
2105
|
-
* Directives that will be added to `Content-Security-Policy-Report-Only` headers.
|
|
2106
|
-
*/
|
|
2107
|
-
reportOnly?: CspDirectives;
|
|
2108
|
-
};
|
|
2109
|
-
/**
|
|
2110
|
-
* Protection against [cross-site request forgery (CSRF)](https://owasp.org/www-community/attacks/csrf) attacks.
|
|
2111
|
-
*/
|
|
2112
|
-
csrf?: {
|
|
2113
|
-
/**
|
|
2114
|
-
* Whether to check the incoming `origin` header for `POST`, `PUT`, `PATCH`, or `DELETE` form submissions and verify that it matches the server's origin.
|
|
2115
|
-
*
|
|
2116
|
-
* To allow people to make `POST`, `PUT`, `PATCH`, or `DELETE` requests with a `Content-Type` of `application/x-www-form-urlencoded`, `multipart/form-data`, or `text/plain` to your app from other origins, you will need to disable this option. Be careful!
|
|
2117
|
-
* @default true
|
|
2118
|
-
* @deprecated removed in 3.0. Use `trustedOrigins: ['*']` instead
|
|
2119
|
-
*/
|
|
2120
|
-
checkOrigin?: boolean;
|
|
2121
|
-
/**
|
|
2122
|
-
* An array of origins that are allowed to make cross-origin form submissions to your app.
|
|
2123
|
-
*
|
|
2124
|
-
* Each origin should be a complete origin including protocol (e.g., `https://payment-gateway.com`).
|
|
2125
|
-
* This is useful for allowing trusted third-party services like payment gateways or authentication providers to submit forms to your app.
|
|
2126
|
-
*
|
|
2127
|
-
* If the array contains `'*'`, all origins will be trusted. This is generally not recommended!
|
|
2128
|
-
*
|
|
2129
|
-
* > [!NOTE] Only add origins you completely trust, as this bypasses CSRF protection for those origins.
|
|
2130
|
-
*
|
|
2131
|
-
* CSRF checks only apply in production, not in local development.
|
|
2132
|
-
* @default []
|
|
2133
|
-
* @example
|
|
2134
|
-
* ```js
|
|
2135
|
-
* ['https://checkout.stripe.com', 'https://accounts.google.com']
|
|
2136
|
-
* ```
|
|
2137
|
-
*/
|
|
2138
|
-
trustedOrigins?: string[];
|
|
2139
|
-
};
|
|
2140
|
-
/**
|
|
2141
|
-
* Whether or not the app is embedded inside a larger app. If `true`, SvelteKit will add its event listeners related to navigation etc on the parent of `%sveltekit.body%` instead of `window`, and will pass `params` from the server rather than inferring them from `location.pathname`.
|
|
2142
|
-
* Note that it is generally not supported to embed multiple SvelteKit apps on the same page and use client-side SvelteKit features within them (things such as pushing to the history state assume a single instance).
|
|
2143
|
-
* @default false
|
|
2144
|
-
*/
|
|
2145
|
-
embedded?: boolean;
|
|
2146
|
-
/**
|
|
2147
|
-
* Environment variable configuration
|
|
2148
|
-
*/
|
|
2149
|
-
env?: {
|
|
2150
|
-
/**
|
|
2151
|
-
* The directory to search for `.env` files.
|
|
2152
|
-
* @default "."
|
|
2153
|
-
*/
|
|
2154
|
-
dir?: string;
|
|
2155
|
-
};
|
|
2156
|
-
/** Experimental features. Here be dragons. These are not subject to semantic versioning, so breaking changes or removal can happen in any release. */
|
|
2157
|
-
experimental?: VitePluginSvelteOptionsExperimental & {
|
|
2158
|
-
/**
|
|
2159
|
-
* Whether to enable the experimental remote functions feature. This feature is not yet stable and may be changed or removed at any time.
|
|
2160
|
-
* @default false
|
|
2161
|
-
*/
|
|
2162
|
-
remoteFunctions?: boolean;
|
|
2163
|
-
|
|
2164
|
-
/**
|
|
2165
|
-
* Whether to enable the experimental forked preloading feature using Svelte's fork API.
|
|
2166
|
-
* @default false
|
|
2167
|
-
*/
|
|
2168
|
-
forkPreloads?: boolean;
|
|
2169
|
-
};
|
|
2170
|
-
/**
|
|
2171
|
-
* Where to find various files within your project.
|
|
2172
|
-
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
2173
|
-
*/
|
|
2174
|
-
files?: {
|
|
2175
|
-
/**
|
|
2176
|
-
* The location of your source code.
|
|
2177
|
-
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
2178
|
-
* @default "src"
|
|
2179
|
-
* @since 2.28
|
|
2180
|
-
*/
|
|
2181
|
-
src?: string;
|
|
2182
|
-
/**
|
|
2183
|
-
* A place to put static files that should have stable URLs and undergo no processing, such as `favicon.ico` or `manifest.json`.
|
|
2184
|
-
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
2185
|
-
* @default "static"
|
|
2186
|
-
*/
|
|
2187
|
-
assets?: string;
|
|
2188
|
-
hooks?: {
|
|
2189
|
-
/**
|
|
2190
|
-
* The location of your client [hooks](https://svelte.dev/docs/kit/hooks).
|
|
2191
|
-
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
2192
|
-
* @default "src/hooks.client"
|
|
2193
|
-
*/
|
|
2194
|
-
client?: string;
|
|
2195
|
-
/**
|
|
2196
|
-
* The location of your server [hooks](https://svelte.dev/docs/kit/hooks).
|
|
2197
|
-
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
2198
|
-
* @default "src/hooks.server"
|
|
2199
|
-
*/
|
|
2200
|
-
server?: string;
|
|
2201
|
-
/**
|
|
2202
|
-
* The location of your universal [hooks](https://svelte.dev/docs/kit/hooks).
|
|
2203
|
-
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
2204
|
-
* @default "src/hooks"
|
|
2205
|
-
* @since 2.3.0
|
|
2206
|
-
*/
|
|
2207
|
-
universal?: string;
|
|
2208
|
-
};
|
|
2209
|
-
/**
|
|
2210
|
-
* A directory containing [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#Matching).
|
|
2211
|
-
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
2212
|
-
* @default "src/params"
|
|
2213
|
-
*/
|
|
2214
|
-
params?: string;
|
|
2215
|
-
/**
|
|
2216
|
-
* The files that define the structure of your app (see [Routing](https://svelte.dev/docs/kit/routing)).
|
|
2217
|
-
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
2218
|
-
* @default "src/routes"
|
|
2219
|
-
*/
|
|
2220
|
-
routes?: string;
|
|
2221
|
-
/**
|
|
2222
|
-
* The location of your service worker's entry point (see [Service workers](https://svelte.dev/docs/kit/service-workers)).
|
|
2223
|
-
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
2224
|
-
* @default "src/service-worker"
|
|
2225
|
-
*/
|
|
2226
|
-
serviceWorker?: string;
|
|
2227
|
-
/**
|
|
2228
|
-
* The location of the template for HTML responses.
|
|
2229
|
-
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
2230
|
-
* @default "src/app.html"
|
|
2231
|
-
*/
|
|
2232
|
-
appTemplate?: string;
|
|
2233
|
-
/**
|
|
2234
|
-
* The location of the template for fallback error responses.
|
|
2235
|
-
* @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
|
|
2236
|
-
* @default "src/error.html"
|
|
2237
|
-
*/
|
|
2238
|
-
errorTemplate?: string;
|
|
2239
|
-
};
|
|
2240
|
-
/**
|
|
2241
|
-
* Inline CSS inside a `<style>` block at the head of the HTML. This option is a number that specifies the maximum length of a CSS file in UTF-16 code units, as specified by the [String.length](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length) property, to be inlined. All CSS files needed for the page that are smaller than this value are merged and inlined in a `<style>` block.
|
|
2242
|
-
*
|
|
2243
|
-
* > [!NOTE] This results in fewer initial requests and can improve your [First Contentful Paint](https://web.dev/first-contentful-paint) score. However, it generates larger HTML output and reduces the effectiveness of browser caches. Use it advisedly.
|
|
2244
|
-
* @default 0
|
|
2245
|
-
*/
|
|
2246
|
-
inlineStyleThreshold?: number;
|
|
2247
|
-
/**
|
|
2248
|
-
* 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.
|
|
2249
|
-
* @default [".js", ".ts"]
|
|
2250
|
-
*/
|
|
2251
|
-
moduleExtensions?: string[];
|
|
2252
|
-
/**
|
|
2253
|
-
* The directory that SvelteKit writes files to during `dev` and `build`. You should exclude this directory from version control.
|
|
2254
|
-
* @default ".svelte-kit"
|
|
2255
|
-
*/
|
|
2256
|
-
outDir?: string;
|
|
1742
|
+
outDir?: string;
|
|
2257
1743
|
/**
|
|
2258
1744
|
* Options related to the build output format
|
|
2259
1745
|
*/
|
|
@@ -2811,19 +2297,16 @@ declare module '@sveltejs/kit/vite' {
|
|
|
2811
2297
|
declare module '$app/env' {
|
|
2812
2298
|
/**
|
|
2813
2299
|
* `true` if the app is running in the browser.
|
|
2814
|
-
*/
|
|
2300
|
+
* */
|
|
2815
2301
|
export const browser: boolean;
|
|
2816
|
-
|
|
2817
2302
|
/**
|
|
2818
2303
|
* Whether the dev server is running. This is not guaranteed to correspond to `NODE_ENV` or `MODE`.
|
|
2819
|
-
*/
|
|
2304
|
+
* */
|
|
2820
2305
|
export const dev: boolean;
|
|
2821
|
-
|
|
2822
2306
|
/**
|
|
2823
2307
|
* SvelteKit analyses your app during the `build` step by running it. During this process, `building` is `true`. This also applies during prerendering.
|
|
2824
|
-
*/
|
|
2308
|
+
* */
|
|
2825
2309
|
export const building: boolean;
|
|
2826
|
-
|
|
2827
2310
|
/**
|
|
2828
2311
|
* The value of `config.version.name`.
|
|
2829
2312
|
*/
|
|
@@ -2833,25 +2316,6 @@ declare module '$app/env' {
|
|
|
2833
2316
|
}
|
|
2834
2317
|
|
|
2835
2318
|
declare module '$app/forms' {
|
|
2836
|
-
/**
|
|
2837
|
-
* Use this function to deserialize the response from a form submission.
|
|
2838
|
-
* Usage:
|
|
2839
|
-
*
|
|
2840
|
-
* ```js
|
|
2841
|
-
* import { deserialize } from '$app/forms';
|
|
2842
|
-
*
|
|
2843
|
-
* async function handleSubmit(event) {
|
|
2844
|
-
* const response = await fetch('/form?/action', {
|
|
2845
|
-
* method: 'POST',
|
|
2846
|
-
* body: new FormData(event.target)
|
|
2847
|
-
* });
|
|
2848
|
-
*
|
|
2849
|
-
* const result = deserialize(await response.text());
|
|
2850
|
-
* // ...
|
|
2851
|
-
* }
|
|
2852
|
-
* ```
|
|
2853
|
-
* */
|
|
2854
|
-
export function deserialize<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(result: string): ActionResult<Success, Failure>;
|
|
2855
2319
|
/**
|
|
2856
2320
|
* This action enhances a `<form>` element that otherwise would work without JavaScript.
|
|
2857
2321
|
*
|
|
@@ -2939,6 +2403,25 @@ declare module '$app/forms' {
|
|
|
2939
2403
|
* the redirect location.
|
|
2940
2404
|
* */
|
|
2941
2405
|
export function applyAction<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(result: ActionResult<Success, Failure>): Promise<void>;
|
|
2406
|
+
/**
|
|
2407
|
+
* Use this function to deserialize the response from a form submission.
|
|
2408
|
+
* Usage:
|
|
2409
|
+
*
|
|
2410
|
+
* ```js
|
|
2411
|
+
* import { deserialize } from '$app/forms';
|
|
2412
|
+
*
|
|
2413
|
+
* async function handleSubmit(event) {
|
|
2414
|
+
* const response = await fetch('/form?/action', {
|
|
2415
|
+
* method: 'POST',
|
|
2416
|
+
* body: new FormData(event.target)
|
|
2417
|
+
* });
|
|
2418
|
+
*
|
|
2419
|
+
* const result = deserialize(await response.text());
|
|
2420
|
+
* // ...
|
|
2421
|
+
* }
|
|
2422
|
+
* ```
|
|
2423
|
+
* */
|
|
2424
|
+
export function deserialize<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(result: string): ActionResult<Success, Failure>;
|
|
2942
2425
|
type MaybePromise<T> = T | Promise<T>;
|
|
2943
2426
|
|
|
2944
2427
|
export {};
|
|
@@ -3026,397 +2509,913 @@ declare module '$app/navigation' {
|
|
|
3026
2509
|
persistState?: boolean;
|
|
3027
2510
|
}
|
|
3028
2511
|
|
|
3029
|
-
/**
|
|
3030
|
-
* - `enter`: The app has hydrated/started
|
|
3031
|
-
* - `form`: The user submitted a `<form method="GET">`
|
|
3032
|
-
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
3033
|
-
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
3034
|
-
* - `link`: Navigation was triggered by a link click
|
|
3035
|
-
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
3036
|
-
*/
|
|
3037
|
-
export type NavigationType = 'enter' | 'form' | 'leave' | 'link' | 'goto' | 'popstate';
|
|
2512
|
+
/**
|
|
2513
|
+
* - `enter`: The app has hydrated/started
|
|
2514
|
+
* - `form`: The user submitted a `<form method="GET">`
|
|
2515
|
+
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
2516
|
+
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
2517
|
+
* - `link`: Navigation was triggered by a link click
|
|
2518
|
+
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
2519
|
+
*/
|
|
2520
|
+
export type NavigationType = 'enter' | 'form' | 'leave' | 'link' | 'goto' | 'popstate';
|
|
2521
|
+
|
|
2522
|
+
export interface NavigationBase {
|
|
2523
|
+
/**
|
|
2524
|
+
* The type of navigation:
|
|
2525
|
+
* - `enter`: The app has hydrated/started
|
|
2526
|
+
* - `form`: The user submitted a `<form method="GET">`
|
|
2527
|
+
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
2528
|
+
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
2529
|
+
* - `link`: Navigation was triggered by a link click
|
|
2530
|
+
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
2531
|
+
*/
|
|
2532
|
+
type: NavigationType;
|
|
2533
|
+
/** Whether this is a shallow navigation. */
|
|
2534
|
+
shallow: boolean;
|
|
2535
|
+
/**
|
|
2536
|
+
* Where navigation was triggered from
|
|
2537
|
+
*/
|
|
2538
|
+
from: NavigationTarget | null;
|
|
2539
|
+
/**
|
|
2540
|
+
* Where navigation is going to/has gone to
|
|
2541
|
+
*/
|
|
2542
|
+
to: NavigationTarget | null;
|
|
2543
|
+
/**
|
|
2544
|
+
* Whether or not the navigation will result in the page being unloaded (i.e. not a client-side navigation).
|
|
2545
|
+
*/
|
|
2546
|
+
willUnload: boolean;
|
|
2547
|
+
/**
|
|
2548
|
+
* A promise that resolves once the navigation is complete, and rejects if the navigation
|
|
2549
|
+
* fails or is aborted. In the case of a `willUnload` navigation, the promise will never resolve
|
|
2550
|
+
*/
|
|
2551
|
+
complete: Promise<void>;
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
/**
|
|
2555
|
+
* The navigation that occurs when the app starts/hydrates
|
|
2556
|
+
*/
|
|
2557
|
+
export interface NavigationEnter extends NavigationBase {
|
|
2558
|
+
type: 'enter';
|
|
2559
|
+
|
|
2560
|
+
/**
|
|
2561
|
+
* In case of a history back/forward navigation, the number of steps to go back/forward
|
|
2562
|
+
*/
|
|
2563
|
+
delta?: undefined;
|
|
2564
|
+
|
|
2565
|
+
/**
|
|
2566
|
+
* Dispatched `Event` object when navigation occurred by `popstate` or `link`.
|
|
2567
|
+
*/
|
|
2568
|
+
event?: undefined;
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
export type NavigationExternal = NavigationGoto | NavigationLeave;
|
|
2572
|
+
|
|
2573
|
+
/**
|
|
2574
|
+
* A navigation triggered by a `goto(...)` call or a redirect
|
|
2575
|
+
*/
|
|
2576
|
+
export interface NavigationGoto extends NavigationBase {
|
|
2577
|
+
type: 'goto';
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
/**
|
|
2581
|
+
* A navigation triggered by the tab being closed, or the user navigating to a different document
|
|
2582
|
+
*/
|
|
2583
|
+
export interface NavigationLeave extends NavigationBase {
|
|
2584
|
+
type: 'leave';
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
/**
|
|
2588
|
+
* A navigation triggered by a `<form method="GET">`
|
|
2589
|
+
*/
|
|
2590
|
+
export interface NavigationFormSubmit extends NavigationBase {
|
|
2591
|
+
type: 'form';
|
|
2592
|
+
|
|
2593
|
+
/**
|
|
2594
|
+
* The `SubmitEvent` that caused the navigation
|
|
2595
|
+
*/
|
|
2596
|
+
event: SubmitEvent;
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
/**
|
|
2600
|
+
* A navigation triggered by back/forward navigation
|
|
2601
|
+
*/
|
|
2602
|
+
export interface NavigationPopState extends NavigationBase {
|
|
2603
|
+
type: 'popstate';
|
|
2604
|
+
|
|
2605
|
+
/**
|
|
2606
|
+
* In case of a history back/forward navigation, the number of steps to go back/forward
|
|
2607
|
+
*/
|
|
2608
|
+
delta: number;
|
|
2609
|
+
|
|
2610
|
+
/**
|
|
2611
|
+
* The `PopStateEvent` that caused the navigation
|
|
2612
|
+
*/
|
|
2613
|
+
event: PopStateEvent;
|
|
2614
|
+
}
|
|
2615
|
+
|
|
2616
|
+
/**
|
|
2617
|
+
* A navigation triggered by a link click
|
|
2618
|
+
*/
|
|
2619
|
+
export interface NavigationLink extends NavigationBase {
|
|
2620
|
+
type: 'link';
|
|
2621
|
+
|
|
2622
|
+
/**
|
|
2623
|
+
* The `PointerEvent` that caused the navigation
|
|
2624
|
+
*/
|
|
2625
|
+
event: PointerEvent;
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
export type Navigation =
|
|
2629
|
+
| NavigationExternal
|
|
2630
|
+
| NavigationFormSubmit
|
|
2631
|
+
| NavigationPopState
|
|
2632
|
+
| NavigationLink;
|
|
2633
|
+
|
|
2634
|
+
/**
|
|
2635
|
+
* The argument passed to [`beforeNavigate`](https://svelte.dev/docs/kit/$app-navigation#beforeNavigate) callbacks.
|
|
2636
|
+
*/
|
|
2637
|
+
export type BeforeNavigate = Navigation & {
|
|
2638
|
+
/**
|
|
2639
|
+
* Call this to prevent the navigation from starting.
|
|
2640
|
+
*/
|
|
2641
|
+
cancel: () => void;
|
|
2642
|
+
};
|
|
2643
|
+
|
|
2644
|
+
/**
|
|
2645
|
+
* The argument passed to [`onNavigate`](https://svelte.dev/docs/kit/$app-navigation#onNavigate) callbacks.
|
|
2646
|
+
*/
|
|
2647
|
+
export type OnNavigate = Navigation & {
|
|
2648
|
+
type: Exclude<NavigationType, 'enter' | 'leave'>;
|
|
2649
|
+
/**
|
|
2650
|
+
* Since `onNavigate` callbacks are called immediately before a client-side navigation, they will never be called with a navigation that unloads the page.
|
|
2651
|
+
*/
|
|
2652
|
+
willUnload: false;
|
|
2653
|
+
};
|
|
2654
|
+
|
|
2655
|
+
/**
|
|
2656
|
+
* The argument passed to [`afterNavigate`](https://svelte.dev/docs/kit/$app-navigation#afterNavigate) callbacks.
|
|
2657
|
+
*/
|
|
2658
|
+
export type AfterNavigate = (Navigation | NavigationEnter) & {
|
|
2659
|
+
type: Exclude<NavigationType, 'leave'>;
|
|
2660
|
+
/**
|
|
2661
|
+
* Since `afterNavigate` callbacks are called after a navigation completes, they will never be called with a navigation that unloads the page.
|
|
2662
|
+
*/
|
|
2663
|
+
willUnload: false;
|
|
2664
|
+
};
|
|
2665
|
+
/**
|
|
2666
|
+
* A lifecycle function that captures state before navigating and restores it when traversing history.
|
|
2667
|
+
*
|
|
2668
|
+
* By default, the snapshot `id` is generated from the call site. Pass an explicit `id` to keep snapshots stable across deployments or distinguish multiple uses of a shared helper.
|
|
2669
|
+
*
|
|
2670
|
+
* The optional `reset` callback runs on navigations where there is no captured value to restore, such as when a new history entry is created. Captured values are serialized with the app's transport hook.
|
|
2671
|
+
*
|
|
2672
|
+
* `snapshot` must be called during a component initialization. It remains active as long as the component is mounted.
|
|
2673
|
+
* */
|
|
2674
|
+
export function snapshot<T>(options: {
|
|
2675
|
+
id?: string;
|
|
2676
|
+
capture: () => T;
|
|
2677
|
+
restore: (value: T) => void;
|
|
2678
|
+
reset?: () => void;
|
|
2679
|
+
}): void;
|
|
2680
|
+
/**
|
|
2681
|
+
* A lifecycle function that runs the supplied `callback` when the current component mounts, and also whenever we navigate to a URL.
|
|
2682
|
+
*
|
|
2683
|
+
* `afterNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
|
|
2684
|
+
* */
|
|
2685
|
+
export function afterNavigate(callback: (navigation: AfterNavigate) => void): void;
|
|
2686
|
+
/**
|
|
2687
|
+
* A navigation interceptor that triggers before we navigate to a URL, whether by clicking a link, calling `goto(...)`, or using the browser back/forward controls.
|
|
2688
|
+
*
|
|
2689
|
+
* Calling `cancel()` will prevent the navigation from completing. If `navigation.type === 'leave'` — meaning the user is navigating away from the app (or closing the tab) — calling `cancel` will trigger the native browser unload confirmation dialog. In this case, the navigation may or may not be cancelled depending on the user's response.
|
|
2690
|
+
*
|
|
2691
|
+
* When a navigation isn't to a SvelteKit-owned route (and therefore controlled by SvelteKit's client-side router), `navigation.to.route.id` will be `null`.
|
|
2692
|
+
*
|
|
2693
|
+
* If the navigation will (if not cancelled) cause the document to unload — in other words `'leave'` navigations and `'link'` navigations where `navigation.to.route === null` — `navigation.willUnload` is `true`.
|
|
2694
|
+
*
|
|
2695
|
+
* `beforeNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
|
|
2696
|
+
* */
|
|
2697
|
+
export function beforeNavigate(callback: (navigation: BeforeNavigate) => void): void;
|
|
2698
|
+
/**
|
|
2699
|
+
* A lifecycle function that runs the supplied `callback` immediately before we navigate to a new URL except during full-page navigations.
|
|
2700
|
+
*
|
|
2701
|
+
* If you return a `Promise`, SvelteKit will wait for it to resolve before completing the navigation. This allows you to — for example — use `document.startViewTransition`. Avoid promises that are slow to resolve, since navigation will appear stalled to the user.
|
|
2702
|
+
*
|
|
2703
|
+
* If a function (or a `Promise` that resolves to a function) is returned from the callback, it will be called once the DOM has updated.
|
|
2704
|
+
*
|
|
2705
|
+
* `onNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
|
|
2706
|
+
* */
|
|
2707
|
+
export function onNavigate(callback: (navigation: OnNavigate) => MaybePromise<(() => void) | void>): void;
|
|
2708
|
+
/**
|
|
2709
|
+
* If called when the page is being updated following a navigation (in `onMount` or `afterNavigate` or an action, for example), this disables SvelteKit's built-in scroll handling.
|
|
2710
|
+
* This is generally discouraged, since it breaks user expectations.
|
|
2711
|
+
* */
|
|
2712
|
+
export function disableScrollHandling(): void;
|
|
2713
|
+
/**
|
|
2714
|
+
* Allows you to navigate programmatically to a given route, with control over details such as whether scroll and focus are reset
|
|
2715
|
+
* (as they would be with a regular navigation) or preserved.
|
|
2716
|
+
*
|
|
2717
|
+
* Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) or the state change has been applied.
|
|
2718
|
+
*
|
|
2719
|
+
* `goto` is intended for navigations to routes that belong to the app, and will reject if a route cannot be resolved.
|
|
2720
|
+
* For external URLs, use `window.location = url` to perform a full-page navigation instead of calling `goto(url)`.
|
|
2721
|
+
*
|
|
2722
|
+
* @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.
|
|
2723
|
+
* @param opts Options related to the navigation
|
|
2724
|
+
* */
|
|
2725
|
+
export function goto(url: string | URL, opts?: GotoOptions): Promise<void>;
|
|
2726
|
+
/**
|
|
2727
|
+
* Causes any `load` functions belonging to the currently active page to re-run if they depend on the `url` in question, via `fetch` or `depends`. Returns a `Promise` that resolves when the page is subsequently updated.
|
|
2728
|
+
*
|
|
2729
|
+
* If the argument is given as a `string` or `URL`, it must resolve to the same URL that was passed to `fetch` or `depends` (including query parameters).
|
|
2730
|
+
* To create a custom identifier, use a string beginning with `[a-z]+:` (e.g. `custom:state`) — this is a valid URL.
|
|
2731
|
+
*
|
|
2732
|
+
* The `function` argument can be used define a custom predicate. It receives the full `URL` and causes `load` to rerun if `true` is returned.
|
|
2733
|
+
* This can be useful if you want to invalidate based on a pattern instead of a exact match.
|
|
2734
|
+
*
|
|
2735
|
+
* ```ts
|
|
2736
|
+
* // Example: Match '/path' regardless of the query parameters
|
|
2737
|
+
* import { invalidate } from '$app/navigation';
|
|
2738
|
+
*
|
|
2739
|
+
* invalidate((url) => url.pathname === '/path');
|
|
2740
|
+
* ```
|
|
2741
|
+
* @param resource The invalidated URL
|
|
2742
|
+
* @param keepState If `true`, the current `page.state` will be preserved. Otherwise, it will be reset to an empty object. `false` by default.
|
|
2743
|
+
* */
|
|
2744
|
+
export function invalidate(resource: string | URL | ((url: URL) => boolean), keepState?: boolean): Promise<void>;
|
|
2745
|
+
/**
|
|
2746
|
+
* Causes all `load` and `query` functions belonging to the currently active page to re-run. Returns a `Promise` that resolves when the page is subsequently updated.
|
|
2747
|
+
*
|
|
2748
|
+
* Note that this resets `page.state` to an empty object. If you want to preserve `page.state` (for example when using [shallow routing](https://svelte.dev/docs/kit/shallow-routing)), use `refreshAll` instead.
|
|
2749
|
+
*
|
|
2750
|
+
* @deprecated Use [`refreshAll`](https://svelte.dev/docs/kit/$app-navigation#refreshAll) instead. Unlike `invalidateAll`, `refreshAll` does not reset `page.state`.
|
|
2751
|
+
* */
|
|
2752
|
+
export function invalidateAll(): Promise<void>;
|
|
2753
|
+
/**
|
|
2754
|
+
* Causes all currently active remote functions to refresh, and all `load` functions belonging to the currently active page to re-run.
|
|
2755
|
+
* Returns a `Promise` that resolves when the page is subsequently updated.
|
|
2756
|
+
* */
|
|
2757
|
+
export function refreshAll(): Promise<void>;
|
|
2758
|
+
/**
|
|
2759
|
+
* Programmatically preloads the given page, which means
|
|
2760
|
+
* 1. ensuring that the code for the page is loaded, and
|
|
2761
|
+
* 2. calling the page's load function with the appropriate options.
|
|
2762
|
+
*
|
|
2763
|
+
* This is the same behaviour that SvelteKit triggers when the user taps or mouses over an `<a>` element with `data-sveltekit-preload-data`.
|
|
2764
|
+
* If the next navigation is to `href`, the values returned from load will be used, making navigation instantaneous.
|
|
2765
|
+
* Returns a Promise that resolves with the result of running the new route's `load` functions once the preload is complete.
|
|
2766
|
+
*
|
|
2767
|
+
* @param href Page to preload
|
|
2768
|
+
* */
|
|
2769
|
+
export function preloadData(href: string): Promise<({
|
|
2770
|
+
type: "loaded";
|
|
2771
|
+
data: Record<string, any>;
|
|
2772
|
+
} | {
|
|
2773
|
+
type: "redirect";
|
|
2774
|
+
location: string;
|
|
2775
|
+
} | {
|
|
2776
|
+
type: "error";
|
|
2777
|
+
error: App.Error;
|
|
2778
|
+
}) & {
|
|
2779
|
+
status: number;
|
|
2780
|
+
}>;
|
|
2781
|
+
/**
|
|
2782
|
+
* Programmatically imports the code for routes that haven't yet been fetched.
|
|
2783
|
+
* Typically, you might call this to speed up subsequent navigation.
|
|
2784
|
+
*
|
|
2785
|
+
* Takes a route ID such as `/about` or `/blog/[slug]`. Unlike pathnames, route IDs
|
|
2786
|
+
* are never prefixed with the app's [base path](https://svelte.dev/docs/kit/configuration#paths).
|
|
2787
|
+
* If you have a pathname rather than a route ID, you can convert it with
|
|
2788
|
+
* [`match`](https://svelte.dev/docs/kit/$app-paths#match) from `$app/paths`:
|
|
2789
|
+
*
|
|
2790
|
+
* ```js
|
|
2791
|
+
* import { match } from '$app/paths';
|
|
2792
|
+
* import { preloadCode } from '$app/navigation';
|
|
2793
|
+
*
|
|
2794
|
+
* const matched = await match('/blog/hello-world');
|
|
2795
|
+
* if (matched) await preloadCode(matched.id);
|
|
2796
|
+
* ```
|
|
2797
|
+
*
|
|
2798
|
+
* Unlike `preloadData`, this won't call `load` functions.
|
|
2799
|
+
* Returns a Promise that resolves when the modules have been imported.
|
|
2800
|
+
*
|
|
2801
|
+
* */
|
|
2802
|
+
export function preloadCode(id: import("$app/types").RouteId): Promise<void>;
|
|
2803
|
+
/**
|
|
2804
|
+
* Programmatically create a new history entry with the given `page.state`. Used for [shallow routing](https://svelte.dev/docs/kit/shallow-routing).
|
|
2805
|
+
*
|
|
2806
|
+
* @deprecated Use `goto(url, { state, shallow: true })` instead.
|
|
2807
|
+
* */
|
|
2808
|
+
export function pushState(url: string | URL, state: App.PageState): Promise<void>;
|
|
2809
|
+
/**
|
|
2810
|
+
* Programmatically replace the current history entry with the given `page.state`. Used for [shallow routing](https://svelte.dev/docs/kit/shallow-routing).
|
|
2811
|
+
*
|
|
2812
|
+
* @deprecated Use `goto(url, { state, shallow: true, replace: true })` instead.
|
|
2813
|
+
* */
|
|
2814
|
+
export function replaceState(url: string | URL, state: App.PageState): Promise<void>;
|
|
2815
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
2816
|
+
|
|
2817
|
+
export {};
|
|
2818
|
+
}
|
|
2819
|
+
|
|
2820
|
+
declare module '$app/paths' {
|
|
2821
|
+
import type { AssetPath, RouteIdWithSearchOrHash, PathnameWithSearchOrHash, ResolvedPathname, RouteId, RouteParams } from '$app/types';
|
|
2822
|
+
/**
|
|
2823
|
+
* 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.
|
|
2824
|
+
*
|
|
2825
|
+
* During server rendering, the base path is relative and depends on the page currently being rendered.
|
|
2826
|
+
*
|
|
2827
|
+
* @example
|
|
2828
|
+
* ```svelte
|
|
2829
|
+
* <script>
|
|
2830
|
+
* import { asset } from '$app/paths';
|
|
2831
|
+
* </script>
|
|
2832
|
+
*
|
|
2833
|
+
* <img alt="a potato" src={asset('potato.jpg')} />
|
|
2834
|
+
* ```
|
|
2835
|
+
* @since 2.26
|
|
2836
|
+
*
|
|
2837
|
+
* */
|
|
2838
|
+
export function asset(file: AssetPath): string;
|
|
2839
|
+
/**
|
|
2840
|
+
* Resolve a pathname by prefixing it with the base path, if any, or resolve a route ID by populating dynamic segments with parameters.
|
|
2841
|
+
*
|
|
2842
|
+
* During server rendering, the base path is relative and depends on the page currently being rendered.
|
|
2843
|
+
*
|
|
2844
|
+
* @example
|
|
2845
|
+
* ```js
|
|
2846
|
+
* import { resolve } from '$app/paths';
|
|
2847
|
+
*
|
|
2848
|
+
* // using a pathname
|
|
2849
|
+
* const resolved = resolve(`blog/hello-world`);
|
|
2850
|
+
*
|
|
2851
|
+
* // using a route ID plus parameters
|
|
2852
|
+
* const resolved = resolve('/blog/[slug]', {
|
|
2853
|
+
* slug: 'hello-world'
|
|
2854
|
+
* });
|
|
2855
|
+
* ```
|
|
2856
|
+
* @since 2.26
|
|
2857
|
+
*
|
|
2858
|
+
* */
|
|
2859
|
+
export function resolve<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash>(...args: ResolveArgs<T>): ResolvedPathname;
|
|
2860
|
+
/**
|
|
2861
|
+
* Match a path or URL to a route ID and extracts any parameters.
|
|
2862
|
+
*
|
|
2863
|
+
* @example
|
|
2864
|
+
* ```js
|
|
2865
|
+
* import { match } from '$app/paths';
|
|
2866
|
+
*
|
|
2867
|
+
* const route = await match('blog/hello-world');
|
|
2868
|
+
*
|
|
2869
|
+
* if (route?.id === '/blog/[slug]') {
|
|
2870
|
+
* const slug = route.params.slug;
|
|
2871
|
+
* const response = await fetch(`/api/posts/${slug}`);
|
|
2872
|
+
* const post = await response.json();
|
|
2873
|
+
* }
|
|
2874
|
+
* ```
|
|
2875
|
+
* @since 2.52.0
|
|
2876
|
+
*
|
|
2877
|
+
* */
|
|
2878
|
+
export function match(url: URL | string): Promise<{ [K in RouteId]: {
|
|
2879
|
+
id: K;
|
|
2880
|
+
params: RouteParams<K>;
|
|
2881
|
+
}; }[RouteId] | null>;
|
|
2882
|
+
type StripSearchOrHash<T extends string> = T extends `${infer U}?${string}`
|
|
2883
|
+
? U
|
|
2884
|
+
: T extends `${infer U}#${string}`
|
|
2885
|
+
? U
|
|
2886
|
+
: T;
|
|
2887
|
+
|
|
2888
|
+
type ResolveArgs<T> = T extends `/${string}`
|
|
2889
|
+
? StripSearchOrHash<T> extends infer U extends RouteId
|
|
2890
|
+
? RouteParams<U> extends Record<string, never>
|
|
2891
|
+
? [route: T]
|
|
2892
|
+
: [route: T, params: RouteParams<U>]
|
|
2893
|
+
: [never]
|
|
2894
|
+
: [pathname: T];
|
|
2895
|
+
|
|
2896
|
+
export {};
|
|
2897
|
+
}
|
|
2898
|
+
|
|
2899
|
+
declare module '$app/server' {
|
|
2900
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2901
|
+
import type { RequestEvent } from '@sveltejs/kit';
|
|
2902
|
+
// If T is unknown or has an index signature, the types below will recurse indefinitely and create giant unions that TS can't handle
|
|
2903
|
+
type WillRecurseIndefinitely<T> = unknown extends T ? true : string extends keyof T ? true : false;
|
|
2904
|
+
|
|
2905
|
+
// Input type mappings for form fields
|
|
2906
|
+
type InputTypeMap = {
|
|
2907
|
+
text: string;
|
|
2908
|
+
email: string;
|
|
2909
|
+
password: string;
|
|
2910
|
+
url: string;
|
|
2911
|
+
tel: string;
|
|
2912
|
+
search: string;
|
|
2913
|
+
number: number;
|
|
2914
|
+
range: number;
|
|
2915
|
+
date: string;
|
|
2916
|
+
'datetime-local': string;
|
|
2917
|
+
time: string;
|
|
2918
|
+
month: string;
|
|
2919
|
+
week: string;
|
|
2920
|
+
color: string;
|
|
2921
|
+
checkbox: boolean | string[];
|
|
2922
|
+
radio: string;
|
|
2923
|
+
file: File;
|
|
2924
|
+
hidden: string | number | boolean;
|
|
2925
|
+
submit: string | number | boolean;
|
|
2926
|
+
button: string;
|
|
2927
|
+
reset: string;
|
|
2928
|
+
image: string;
|
|
2929
|
+
select: string;
|
|
2930
|
+
'select multiple': string[];
|
|
2931
|
+
'file multiple': File[];
|
|
2932
|
+
};
|
|
2933
|
+
|
|
2934
|
+
// Valid input types for a given value type
|
|
2935
|
+
export type RemoteFormFieldType<T> = {
|
|
2936
|
+
[K in keyof InputTypeMap]: T extends InputTypeMap[K] ? K : never;
|
|
2937
|
+
}[keyof InputTypeMap];
|
|
2938
|
+
|
|
2939
|
+
// Input element properties based on type
|
|
2940
|
+
type InputElementProps<T extends keyof InputTypeMap> = T extends 'checkbox' | 'radio'
|
|
2941
|
+
? {
|
|
2942
|
+
name: string;
|
|
2943
|
+
type: T;
|
|
2944
|
+
value?: string;
|
|
2945
|
+
'aria-invalid': boolean | 'false' | 'true' | undefined;
|
|
2946
|
+
get checked(): boolean;
|
|
2947
|
+
set checked(value: boolean);
|
|
2948
|
+
readonly defaultChecked?: boolean;
|
|
2949
|
+
}
|
|
2950
|
+
: T extends 'file'
|
|
2951
|
+
? {
|
|
2952
|
+
name: string;
|
|
2953
|
+
type: 'file';
|
|
2954
|
+
'aria-invalid': boolean | 'false' | 'true' | undefined;
|
|
2955
|
+
get files(): FileList | null;
|
|
2956
|
+
set files(v: FileList | null);
|
|
2957
|
+
}
|
|
2958
|
+
: T extends 'select'
|
|
2959
|
+
? {
|
|
2960
|
+
name: string;
|
|
2961
|
+
'aria-invalid': boolean | 'false' | 'true' | undefined;
|
|
2962
|
+
get value(): string;
|
|
2963
|
+
set value(v: string);
|
|
2964
|
+
}
|
|
2965
|
+
: T extends 'select multiple'
|
|
2966
|
+
? {
|
|
2967
|
+
name: string;
|
|
2968
|
+
multiple: true;
|
|
2969
|
+
'aria-invalid': boolean | 'false' | 'true' | undefined;
|
|
2970
|
+
get value(): string[];
|
|
2971
|
+
set value(v: string[]);
|
|
2972
|
+
}
|
|
2973
|
+
: T extends 'text'
|
|
2974
|
+
? {
|
|
2975
|
+
name: string;
|
|
2976
|
+
'aria-invalid': boolean | 'false' | 'true' | undefined;
|
|
2977
|
+
get value(): string | number;
|
|
2978
|
+
set value(v: string | number);
|
|
2979
|
+
readonly defaultValue?: string | number;
|
|
2980
|
+
}
|
|
2981
|
+
: {
|
|
2982
|
+
name: string;
|
|
2983
|
+
type: T;
|
|
2984
|
+
'aria-invalid': boolean | 'false' | 'true' | undefined;
|
|
2985
|
+
get value(): string | number;
|
|
2986
|
+
set value(v: string | number);
|
|
2987
|
+
readonly defaultValue?: string | number;
|
|
2988
|
+
};
|
|
2989
|
+
|
|
2990
|
+
type RemoteFormFieldMethods<T> = {
|
|
2991
|
+
/** The values that will be submitted */
|
|
2992
|
+
value(): DeepPartial<T>;
|
|
2993
|
+
/** Set the values that will be submitted */
|
|
2994
|
+
set(input: DeepPartial<T>): DeepPartial<T>;
|
|
2995
|
+
/** Whether the field or any nested field has been interacted with since the form was mounted */
|
|
2996
|
+
touched(): boolean;
|
|
2997
|
+
/** Whether the field or any nested field has been edited since the form was mounted */
|
|
2998
|
+
dirty(): boolean;
|
|
2999
|
+
/** Validation issues, if any */
|
|
3000
|
+
issues(): RemoteFormIssue[] | undefined;
|
|
3001
|
+
};
|
|
3038
3002
|
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
* A promise that resolves once the navigation is complete, and rejects if the navigation
|
|
3066
|
-
* fails or is aborted. In the case of a `willUnload` navigation, the promise will never resolve
|
|
3067
|
-
*/
|
|
3068
|
-
complete: Promise<void>;
|
|
3069
|
-
}
|
|
3003
|
+
// These two types use "T extends unknown ? .. : .." to distribute over unions.
|
|
3004
|
+
// Example: if "type T = A | b" then "keyof T" only contains keys that both A and B have, with "KeysOfUnion<T>" we get the keys of both A and B
|
|
3005
|
+
type KeysOfUnion<T> = T extends unknown ? keyof T : never;
|
|
3006
|
+
type ValueOfUnionKey<T, K extends PropertyKey> = T extends unknown
|
|
3007
|
+
? K extends keyof T
|
|
3008
|
+
? T[K]
|
|
3009
|
+
: never
|
|
3010
|
+
: never;
|
|
3011
|
+
|
|
3012
|
+
export type RemoteFormFieldValue = string | string[] | number | boolean | File | File[];
|
|
3013
|
+
|
|
3014
|
+
type AsArgs<Type extends keyof InputTypeMap, Value> = Type extends 'checkbox'
|
|
3015
|
+
? Value extends string[]
|
|
3016
|
+
? [type: Type, value: Value[number] | (string & {})]
|
|
3017
|
+
: Value extends boolean
|
|
3018
|
+
? [type: Type] | [type: Type, value: boolean]
|
|
3019
|
+
: [type: Type] | [type: Type, value: Value | (string & {})]
|
|
3020
|
+
: Type extends 'submit' | 'hidden'
|
|
3021
|
+
? Value extends string
|
|
3022
|
+
? [type: Type, value: Value | (string & {})]
|
|
3023
|
+
: [type: Type, value: Value]
|
|
3024
|
+
: Type extends 'radio'
|
|
3025
|
+
? [type: Type, value: Value | (string & {})]
|
|
3026
|
+
: Type extends 'file' | 'file multiple'
|
|
3027
|
+
? [type: Type]
|
|
3028
|
+
: [type: Type] | [type: Type, value: Value | undefined];
|
|
3070
3029
|
|
|
3071
3030
|
/**
|
|
3072
|
-
*
|
|
3031
|
+
* Form field accessor type that provides name(), value(), and issues() methods
|
|
3073
3032
|
*/
|
|
3074
|
-
export
|
|
3075
|
-
type: 'enter';
|
|
3076
|
-
|
|
3033
|
+
export type RemoteFormField<Value extends RemoteFormFieldValue> = RemoteFormFieldMethods<Value> & {
|
|
3077
3034
|
/**
|
|
3078
|
-
*
|
|
3035
|
+
* Returns an object that can be spread onto an input element with the correct type attribute,
|
|
3036
|
+
* aria-invalid attribute if the field is invalid, and appropriate value/checked property getters/setters.
|
|
3037
|
+
* @example
|
|
3038
|
+
* ```svelte
|
|
3039
|
+
* <input {...myForm.fields.myString.as('text')} />
|
|
3040
|
+
* <input {...myForm.fields.myNumber.as('number')} />
|
|
3041
|
+
* <input {...myForm.fields.myBoolean.as('checkbox')} />
|
|
3042
|
+
* ```
|
|
3079
3043
|
*/
|
|
3080
|
-
|
|
3044
|
+
as<T extends RemoteFormFieldType<Value>>(...args: AsArgs<T, Value>): InputElementProps<T>;
|
|
3045
|
+
};
|
|
3046
|
+
|
|
3047
|
+
type RemoteFormFieldContainer<Value> = RemoteFormFieldMethods<Value> & {
|
|
3048
|
+
/** Validation issues belonging to this or any of the fields that belong to it, if any */
|
|
3049
|
+
allIssues(): RemoteFormIssue[] | undefined;
|
|
3050
|
+
};
|
|
3081
3051
|
|
|
3052
|
+
type UnknownField<Value> = RemoteFormFieldMethods<Value> & {
|
|
3053
|
+
/** Validation issues belonging to this or any of the fields that belong to it, if any */
|
|
3054
|
+
allIssues(): RemoteFormIssue[] | undefined;
|
|
3082
3055
|
/**
|
|
3083
|
-
*
|
|
3056
|
+
* Returns an object that can be spread onto an input element with the correct type attribute,
|
|
3057
|
+
* aria-invalid attribute if the field is invalid, and appropriate value/checked property getters/setters.
|
|
3058
|
+
* @example
|
|
3059
|
+
* ```svelte
|
|
3060
|
+
* <input {...myForm.fields.myString.as('text')} />
|
|
3061
|
+
* <input {...myForm.fields.myNumber.as('number')} />
|
|
3062
|
+
* <input {...myForm.fields.myBoolean.as('checkbox')} />
|
|
3063
|
+
* ```
|
|
3084
3064
|
*/
|
|
3085
|
-
|
|
3086
|
-
}
|
|
3065
|
+
as<T extends RemoteFormFieldType<Value>>(...args: AsArgs<T, Value>): InputElementProps<T>;
|
|
3066
|
+
} & {
|
|
3067
|
+
[key: string | number]: UnknownField<any>;
|
|
3068
|
+
};
|
|
3087
3069
|
|
|
3088
|
-
|
|
3070
|
+
type RemoteFormFieldsRoot<Input extends RemoteFormInput | void> =
|
|
3071
|
+
IsAny<Input> extends true
|
|
3072
|
+
? RecursiveFormFields
|
|
3073
|
+
: Input extends void
|
|
3074
|
+
? {
|
|
3075
|
+
/** Validation issues, if any */
|
|
3076
|
+
issues(): RemoteFormIssue[] | undefined;
|
|
3077
|
+
/** Validation issues belonging to this or any of the fields that belong to it, if any */
|
|
3078
|
+
allIssues(): RemoteFormIssue[] | undefined;
|
|
3079
|
+
}
|
|
3080
|
+
: RemoteFormFields<Input>;
|
|
3089
3081
|
|
|
3090
3082
|
/**
|
|
3091
|
-
*
|
|
3083
|
+
* Recursive type to build form fields structure with proxy access
|
|
3092
3084
|
*/
|
|
3093
|
-
export
|
|
3094
|
-
|
|
3085
|
+
export type RemoteFormFields<T> =
|
|
3086
|
+
WillRecurseIndefinitely<T> extends true
|
|
3087
|
+
? RecursiveFormFields
|
|
3088
|
+
: NonNullable<T> extends string | number | boolean | File
|
|
3089
|
+
? RemoteFormField<NonNullable<T>>
|
|
3090
|
+
: // [NonNullable<T>] is used to prevent distributing over union while still allowing
|
|
3091
|
+
// nullable wrappers (e.g. `string[] | undefined` from a schema with `.default([])`)
|
|
3092
|
+
// to be treated as arrays; only the last condition should distribute over unions
|
|
3093
|
+
[NonNullable<T>] extends [string[] | File[]]
|
|
3094
|
+
? RemoteFormField<NonNullable<T>> & {
|
|
3095
|
+
[K in number]: RemoteFormField<NonNullable<T>[number]>;
|
|
3096
|
+
}
|
|
3097
|
+
: [NonNullable<T>] extends [Array<infer U>]
|
|
3098
|
+
? RemoteFormFieldContainer<NonNullable<T>> & {
|
|
3099
|
+
[K in number]: RemoteFormFields<U>;
|
|
3100
|
+
}
|
|
3101
|
+
: RemoteFormFieldContainer<T> & {
|
|
3102
|
+
[K in KeysOfUnion<T>]-?: RemoteFormFields<ValueOfUnionKey<T, K>>;
|
|
3103
|
+
};
|
|
3104
|
+
|
|
3105
|
+
// By breaking this out into its own type, we avoid the TS recursion depth limit
|
|
3106
|
+
type RecursiveFormFields = RemoteFormFieldContainer<any> & {
|
|
3107
|
+
[key: string | number]: UnknownField<any>;
|
|
3108
|
+
};
|
|
3109
|
+
|
|
3110
|
+
type MaybeArray<T> = T | T[];
|
|
3111
|
+
|
|
3112
|
+
export interface RemoteFormInput {
|
|
3113
|
+
[key: string]: MaybeArray<string | number | boolean | File | RemoteFormInput> | undefined;
|
|
3095
3114
|
}
|
|
3096
3115
|
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
export interface NavigationLeave extends NavigationBase {
|
|
3101
|
-
type: 'leave';
|
|
3116
|
+
export interface RemoteFormIssue {
|
|
3117
|
+
message: string;
|
|
3118
|
+
path: Array<string | number>;
|
|
3102
3119
|
}
|
|
3103
3120
|
|
|
3121
|
+
// If the schema specifies `id` as a string or number, ensure that `for(...)`
|
|
3122
|
+
// only accepts that type. Otherwise, accept `string | number`
|
|
3123
|
+
type ExtractId<Input> = Input extends { id: infer Id }
|
|
3124
|
+
? Id extends string | number
|
|
3125
|
+
? Id
|
|
3126
|
+
: string | number
|
|
3127
|
+
: string | number;
|
|
3128
|
+
|
|
3104
3129
|
/**
|
|
3105
|
-
* A
|
|
3130
|
+
* A function and proxy object used to imperatively create validation errors in form handlers.
|
|
3131
|
+
*
|
|
3132
|
+
* Access properties to create field-specific issues: `issue.fieldName('message')`.
|
|
3133
|
+
* The type structure mirrors the input data structure for type-safe field access.
|
|
3134
|
+
* Call `invalid(issue.foo(...), issue.nested.bar(...))` to throw a validation error.
|
|
3106
3135
|
*/
|
|
3107
|
-
export
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3136
|
+
export type RemoteFormInvalidField<T> =
|
|
3137
|
+
WillRecurseIndefinitely<T> extends true
|
|
3138
|
+
? Record<string | number, any>
|
|
3139
|
+
: NonNullable<T> extends string | number | boolean | File
|
|
3140
|
+
? (message: string) => StandardSchemaV1.Issue
|
|
3141
|
+
: NonNullable<T> extends Array<infer U>
|
|
3142
|
+
? {
|
|
3143
|
+
[K in number]: RemoteFormInvalidField<U>;
|
|
3144
|
+
} & ((message: string) => StandardSchemaV1.Issue)
|
|
3145
|
+
: NonNullable<T> extends RemoteFormInput
|
|
3146
|
+
? {
|
|
3147
|
+
[K in keyof T]-?: RemoteFormInvalidField<T[K]>;
|
|
3148
|
+
} & ((message: string) => StandardSchemaV1.Issue)
|
|
3149
|
+
: Record<string, never>;
|
|
3115
3150
|
|
|
3116
3151
|
/**
|
|
3117
|
-
*
|
|
3152
|
+
* The form instance as received inside an `enhance` callback. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
|
|
3118
3153
|
*/
|
|
3119
|
-
export
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
delta: number;
|
|
3126
|
-
|
|
3127
|
-
/**
|
|
3128
|
-
* The `PopStateEvent` that caused the navigation
|
|
3129
|
-
*/
|
|
3130
|
-
event: PopStateEvent;
|
|
3131
|
-
}
|
|
3154
|
+
export type RemoteFormEnhanceInstance<
|
|
3155
|
+
Input extends RemoteFormInput | void = RemoteFormInput | void,
|
|
3156
|
+
Output = any
|
|
3157
|
+
> = Omit<RemoteForm<Input, Output>, 'enhance' | 'element'> & {
|
|
3158
|
+
readonly element: HTMLFormElement;
|
|
3159
|
+
};
|
|
3132
3160
|
|
|
3133
3161
|
/**
|
|
3134
|
-
*
|
|
3162
|
+
* The callback passed to a remote form's `enhance` method. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
|
|
3135
3163
|
*/
|
|
3136
|
-
export
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
* The `PointerEvent` that caused the navigation
|
|
3141
|
-
*/
|
|
3142
|
-
event: PointerEvent;
|
|
3143
|
-
}
|
|
3144
|
-
|
|
3145
|
-
export type Navigation =
|
|
3146
|
-
| NavigationExternal
|
|
3147
|
-
| NavigationFormSubmit
|
|
3148
|
-
| NavigationPopState
|
|
3149
|
-
| NavigationLink;
|
|
3164
|
+
export type RemoteFormEnhanceCallback<
|
|
3165
|
+
Input extends RemoteFormInput | void = RemoteFormInput | void,
|
|
3166
|
+
Output = any
|
|
3167
|
+
> = (form: RemoteFormEnhanceInstance<Input, Output>) => MaybePromise<void>;
|
|
3150
3168
|
|
|
3151
3169
|
/**
|
|
3152
|
-
* The
|
|
3170
|
+
* The type of a remote `form` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
|
|
3153
3171
|
*/
|
|
3154
|
-
export type
|
|
3172
|
+
export type RemoteForm<Input extends RemoteFormInput | void, Output> = {
|
|
3173
|
+
/** Attachment that sets up an event handler that intercepts the form submission on the client to prevent a full page reload */
|
|
3174
|
+
[attachment: symbol]: (node: HTMLFormElement) => void;
|
|
3175
|
+
method: 'POST';
|
|
3176
|
+
/** The URL to send the form to. */
|
|
3177
|
+
action: string;
|
|
3178
|
+
/** The `<form>` element this instance is currently attached to, if any. */
|
|
3179
|
+
get element(): HTMLFormElement | null;
|
|
3180
|
+
/** Submit the currently attached form programmatically. */
|
|
3181
|
+
submit(): Promise<boolean> & {
|
|
3182
|
+
updates: (...updates: RemoteQueryUpdate[]) => Promise<boolean>;
|
|
3183
|
+
};
|
|
3184
|
+
/** Use the `enhance` method to influence what happens when the form is submitted. */
|
|
3185
|
+
enhance(callback: RemoteFormEnhanceCallback<Input, Output>): {
|
|
3186
|
+
method: 'POST';
|
|
3187
|
+
action: string;
|
|
3188
|
+
[attachment: symbol]: (node: HTMLFormElement) => void;
|
|
3189
|
+
};
|
|
3155
3190
|
/**
|
|
3156
|
-
*
|
|
3191
|
+
* Create an instance of the form for the given `id`.
|
|
3192
|
+
* The `id` is stringified and used for deduplication to potentially reuse existing instances.
|
|
3193
|
+
* Useful when you have multiple forms that use the same remote form action, for example in a loop.
|
|
3194
|
+
* ```svelte
|
|
3195
|
+
* {#each todos as todo}
|
|
3196
|
+
* {const todoForm = updateTodo.for(todo.id)}
|
|
3197
|
+
* <form {...todoForm}>
|
|
3198
|
+
* {#if todoForm.result?.invalid}<p>Invalid data</p>{/if}
|
|
3199
|
+
* ...
|
|
3200
|
+
* </form>
|
|
3201
|
+
* {/each}
|
|
3202
|
+
* ```
|
|
3157
3203
|
*/
|
|
3158
|
-
|
|
3204
|
+
for(id: ExtractId<Input>): Omit<RemoteForm<Input, Output>, 'for'>;
|
|
3205
|
+
/** Preflight checks */
|
|
3206
|
+
preflight(schema: StandardSchemaV1<Input, any>): RemoteForm<Input, Output>;
|
|
3207
|
+
/** Validate the form contents programmatically */
|
|
3208
|
+
validate(options?: {
|
|
3209
|
+
/**
|
|
3210
|
+
* Set this to `true` to also show validation issues of fields that haven't yet been
|
|
3211
|
+
* edited and blurred. This option is ignored for forms that have previously been
|
|
3212
|
+
* submitted, in which case all fields are always subject to validation
|
|
3213
|
+
* (unless the form is reset, at which point it is treated as pristine)
|
|
3214
|
+
*/
|
|
3215
|
+
all?: boolean;
|
|
3216
|
+
/** Set this to `true` to only run the `preflight` validation. */
|
|
3217
|
+
preflightOnly?: boolean;
|
|
3218
|
+
}): Promise<void>;
|
|
3219
|
+
/** The result of the form submission */
|
|
3220
|
+
get result(): Output | undefined;
|
|
3221
|
+
/** The number of pending submissions */
|
|
3222
|
+
get pending(): number;
|
|
3223
|
+
/** True if the form has been submitted at least once, and hasn't been reset since */
|
|
3224
|
+
get submitted(): boolean;
|
|
3225
|
+
/** Access form fields using object notation */
|
|
3226
|
+
fields: RemoteFormFieldsRoot<Input>;
|
|
3159
3227
|
};
|
|
3160
3228
|
|
|
3161
3229
|
/**
|
|
3162
|
-
* The
|
|
3230
|
+
* The type of a remote `command` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#command) for full documentation.
|
|
3163
3231
|
*/
|
|
3164
|
-
export type
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3232
|
+
export type RemoteCommand<Input, Output> = {
|
|
3233
|
+
(arg: undefined extends Input ? Input | void : Input): Promise<Output> & {
|
|
3234
|
+
updates(...updates: RemoteQueryUpdate[]): Promise<Output>;
|
|
3235
|
+
};
|
|
3236
|
+
/** The number of pending command executions */
|
|
3237
|
+
get pending(): number;
|
|
3170
3238
|
};
|
|
3171
3239
|
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3240
|
+
export type RemoteQueryUpdate =
|
|
3241
|
+
| RemoteQuery<any>
|
|
3242
|
+
| RemoteLiveQuery<any>
|
|
3243
|
+
| RemoteQueryFunction<any, any>
|
|
3244
|
+
| RemoteLiveQueryFunction<any, any>
|
|
3245
|
+
| RemoteQueryOverride;
|
|
3246
|
+
|
|
3247
|
+
export type RemoteResource<T> = Promise<T> & {
|
|
3248
|
+
/** The error in case the query fails. */
|
|
3249
|
+
get error(): App.Error | undefined;
|
|
3250
|
+
/** `true` before the first result is available and during refreshes */
|
|
3251
|
+
get loading(): boolean;
|
|
3252
|
+
} & (
|
|
3253
|
+
| {
|
|
3254
|
+
/** The current value of the query. Undefined until `ready` is `true` */
|
|
3255
|
+
get current(): undefined;
|
|
3256
|
+
ready: false;
|
|
3257
|
+
}
|
|
3258
|
+
| {
|
|
3259
|
+
/** The current value of the query. Undefined until `ready` is `true` */
|
|
3260
|
+
get current(): T;
|
|
3261
|
+
ready: true;
|
|
3262
|
+
}
|
|
3263
|
+
);
|
|
3264
|
+
|
|
3265
|
+
export type RemoteQuery<T> = RemoteResource<T> & {
|
|
3177
3266
|
/**
|
|
3178
|
-
*
|
|
3267
|
+
* On the client, this function will update the value of the query without re-fetching it.
|
|
3268
|
+
*
|
|
3269
|
+
* On the server, this can be called in the context of a `command` or `form` and the specified data will accompany the action response back to the client.
|
|
3270
|
+
* This prevents SvelteKit needing to refresh all queries on the page in a second server round-trip.
|
|
3179
3271
|
*/
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
* `onNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
|
|
3223
|
-
* */
|
|
3224
|
-
export function onNavigate(callback: (navigation: OnNavigate) => MaybePromise<(() => void) | void>): void;
|
|
3225
|
-
/**
|
|
3226
|
-
* If called when the page is being updated following a navigation (in `onMount` or `afterNavigate` or an action, for example), this disables SvelteKit's built-in scroll handling.
|
|
3227
|
-
* This is generally discouraged, since it breaks user expectations.
|
|
3228
|
-
* */
|
|
3229
|
-
export function disableScrollHandling(): void;
|
|
3230
|
-
/**
|
|
3231
|
-
* Allows you to navigate programmatically to a given route, with control over details such as whether scroll and focus are reset
|
|
3232
|
-
* (as they would be with a regular navigation) or preserved.
|
|
3233
|
-
*
|
|
3234
|
-
* Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) or the state change has been applied.
|
|
3235
|
-
*
|
|
3236
|
-
* `goto` is intended for navigations to routes that belong to the app, and will reject if a route cannot be resolved.
|
|
3237
|
-
* For external URLs, use `window.location = url` to perform a full-page navigation instead of calling `goto(url)`.
|
|
3238
|
-
*
|
|
3239
|
-
* @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.
|
|
3240
|
-
* @param opts Options related to the navigation
|
|
3241
|
-
* */
|
|
3242
|
-
export function goto(url: string | URL, opts?: GotoOptions): Promise<void>;
|
|
3243
|
-
/**
|
|
3244
|
-
* Causes any `load` functions belonging to the currently active page to re-run if they depend on the `url` in question, via `fetch` or `depends`. Returns a `Promise` that resolves when the page is subsequently updated.
|
|
3245
|
-
*
|
|
3246
|
-
* If the argument is given as a `string` or `URL`, it must resolve to the same URL that was passed to `fetch` or `depends` (including query parameters).
|
|
3247
|
-
* To create a custom identifier, use a string beginning with `[a-z]+:` (e.g. `custom:state`) — this is a valid URL.
|
|
3248
|
-
*
|
|
3249
|
-
* The `function` argument can be used define a custom predicate. It receives the full `URL` and causes `load` to rerun if `true` is returned.
|
|
3250
|
-
* This can be useful if you want to invalidate based on a pattern instead of a exact match.
|
|
3251
|
-
*
|
|
3252
|
-
* ```ts
|
|
3253
|
-
* // Example: Match '/path' regardless of the query parameters
|
|
3254
|
-
* import { invalidate } from '$app/navigation';
|
|
3255
|
-
*
|
|
3256
|
-
* invalidate((url) => url.pathname === '/path');
|
|
3257
|
-
* ```
|
|
3258
|
-
* @param resource The invalidated URL
|
|
3259
|
-
* @param keepState If `true`, the current `page.state` will be preserved. Otherwise, it will be reset to an empty object. `false` by default.
|
|
3260
|
-
* */
|
|
3261
|
-
export function invalidate(resource: string | URL | ((url: URL) => boolean), keepState?: boolean): Promise<void>;
|
|
3262
|
-
/**
|
|
3263
|
-
* Causes all `load` and `query` functions belonging to the currently active page to re-run. Returns a `Promise` that resolves when the page is subsequently updated.
|
|
3264
|
-
*
|
|
3265
|
-
* Note that this resets `page.state` to an empty object. If you want to preserve `page.state` (for example when using [shallow routing](https://svelte.dev/docs/kit/shallow-routing)), use `refreshAll` instead.
|
|
3266
|
-
*
|
|
3267
|
-
* @deprecated Use [`refreshAll`](https://svelte.dev/docs/kit/$app-navigation#refreshAll) instead. Unlike `invalidateAll`, `refreshAll` does not reset `page.state`.
|
|
3268
|
-
* */
|
|
3269
|
-
export function invalidateAll(): Promise<void>;
|
|
3270
|
-
/**
|
|
3271
|
-
* Causes all currently active remote functions to refresh, and all `load` functions belonging to the currently active page to re-run.
|
|
3272
|
-
* Returns a `Promise` that resolves when the page is subsequently updated.
|
|
3273
|
-
* */
|
|
3274
|
-
export function refreshAll(): Promise<void>;
|
|
3275
|
-
/**
|
|
3276
|
-
* Programmatically preloads the given page, which means
|
|
3277
|
-
* 1. ensuring that the code for the page is loaded, and
|
|
3278
|
-
* 2. calling the page's load function with the appropriate options.
|
|
3279
|
-
*
|
|
3280
|
-
* This is the same behaviour that SvelteKit triggers when the user taps or mouses over an `<a>` element with `data-sveltekit-preload-data`.
|
|
3281
|
-
* If the next navigation is to `href`, the values returned from load will be used, making navigation instantaneous.
|
|
3282
|
-
* Returns a Promise that resolves with the result of running the new route's `load` functions once the preload is complete.
|
|
3283
|
-
*
|
|
3284
|
-
* @param href Page to preload
|
|
3285
|
-
* */
|
|
3286
|
-
export function preloadData(href: string): Promise<({
|
|
3287
|
-
type: "loaded";
|
|
3288
|
-
data: Record<string, any>;
|
|
3289
|
-
} | {
|
|
3290
|
-
type: "redirect";
|
|
3291
|
-
location: string;
|
|
3292
|
-
} | {
|
|
3293
|
-
type: "error";
|
|
3294
|
-
error: App.Error;
|
|
3295
|
-
}) & {
|
|
3296
|
-
status: number;
|
|
3297
|
-
}>;
|
|
3298
|
-
/**
|
|
3299
|
-
* Programmatically imports the code for routes that haven't yet been fetched.
|
|
3300
|
-
* Typically, you might call this to speed up subsequent navigation.
|
|
3301
|
-
*
|
|
3302
|
-
* Takes a route ID such as `/about` or `/blog/[slug]`. Unlike pathnames, route IDs
|
|
3303
|
-
* are never prefixed with the app's [base path](https://svelte.dev/docs/kit/configuration#paths).
|
|
3304
|
-
* If you have a pathname rather than a route ID, you can convert it with
|
|
3305
|
-
* [`match`](https://svelte.dev/docs/kit/$app-paths#match) from `$app/paths`:
|
|
3306
|
-
*
|
|
3307
|
-
* ```js
|
|
3308
|
-
* import { match } from '$app/paths';
|
|
3309
|
-
* import { preloadCode } from '$app/navigation';
|
|
3310
|
-
*
|
|
3311
|
-
* const matched = await match('/blog/hello-world');
|
|
3312
|
-
* if (matched) await preloadCode(matched.id);
|
|
3313
|
-
* ```
|
|
3314
|
-
*
|
|
3315
|
-
* Unlike `preloadData`, this won't call `load` functions.
|
|
3316
|
-
* Returns a Promise that resolves when the modules have been imported.
|
|
3317
|
-
*
|
|
3318
|
-
* */
|
|
3319
|
-
export function preloadCode(id: import("$app/types").RouteId): Promise<void>;
|
|
3272
|
+
set(value: T): void;
|
|
3273
|
+
/**
|
|
3274
|
+
* On the client, this function will re-fetch the query from the server.
|
|
3275
|
+
*
|
|
3276
|
+
* On the server, this can be called in the context of a `command` or `form` and the refreshed data will accompany the action response back to the client.
|
|
3277
|
+
* This prevents SvelteKit needing to refresh all queries on the page in a second server round-trip.
|
|
3278
|
+
*/
|
|
3279
|
+
refresh(): Promise<void>;
|
|
3280
|
+
/**
|
|
3281
|
+
* Temporarily override a query's value during a [single-flight mutation](https://svelte.dev/docs/kit/remote-functions#Single-flight-mutations) to provide optimistic updates.
|
|
3282
|
+
*
|
|
3283
|
+
* ```svelte
|
|
3284
|
+
* <script>
|
|
3285
|
+
* import { getTodos, addTodo } from './todos.remote.js';
|
|
3286
|
+
* const todos = getTodos();
|
|
3287
|
+
* </script>
|
|
3288
|
+
*
|
|
3289
|
+
* <form {...addTodo.enhance(async (form) => {
|
|
3290
|
+
* await form.submit().updates(
|
|
3291
|
+
* todos.withOverride((todos) => [...todos, { text: form.fields.text.value() }])
|
|
3292
|
+
* );
|
|
3293
|
+
* })}>
|
|
3294
|
+
* <input type="text" name="text" />
|
|
3295
|
+
* <button type="submit">Add Todo</button>
|
|
3296
|
+
* </form>
|
|
3297
|
+
* ```
|
|
3298
|
+
*/
|
|
3299
|
+
withOverride(update: (current: T) => T): RemoteQueryOverride;
|
|
3300
|
+
};
|
|
3301
|
+
|
|
3302
|
+
export type RemoteLiveQuery<T> = RemoteResource<T> &
|
|
3303
|
+
AsyncIterable<T> & {
|
|
3304
|
+
/** `true` if the live stream is currently connected. */
|
|
3305
|
+
readonly connected: boolean;
|
|
3306
|
+
/** `true` once the current live stream iterator is done. */
|
|
3307
|
+
readonly done: boolean;
|
|
3308
|
+
/** Reconnects the live stream immediately. */
|
|
3309
|
+
reconnect(): Promise<void>;
|
|
3310
|
+
};
|
|
3311
|
+
|
|
3312
|
+
export type RemoteQueryOverride = () => void;
|
|
3313
|
+
|
|
3320
3314
|
/**
|
|
3321
|
-
*
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3315
|
+
* The type of a remote `prerender` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#prerender) for full documentation.
|
|
3316
|
+
*/
|
|
3317
|
+
export type RemotePrerenderFunction<Input, Output> = (
|
|
3318
|
+
arg: undefined extends Input ? Input | void : Input
|
|
3319
|
+
) => RemoteResource<Output>;
|
|
3320
|
+
|
|
3326
3321
|
/**
|
|
3327
|
-
*
|
|
3322
|
+
* The return value of a remote `query` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query) for full documentation.
|
|
3328
3323
|
*
|
|
3329
|
-
*
|
|
3330
|
-
*
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3324
|
+
* The optional `Validated` generic parameter represents the argument type *after* the
|
|
3325
|
+
* query's schema has validated and (optionally) transformed it — this is the type the
|
|
3326
|
+
* query's implementation function receives on the server, and the type yielded by
|
|
3327
|
+
* [`requested`](https://svelte.dev/docs/kit/$app-server#requested). For queries declared
|
|
3328
|
+
* with [Standard Schema](https://standardschema.dev/) it differs from `Input` when the
|
|
3329
|
+
* schema contains a transform (e.g. `v.pipe(v.number(), v.transform(String))` has
|
|
3330
|
+
* `Input = number` but `Validated = string`). For `'unchecked'` validators and queries
|
|
3331
|
+
* without arguments it defaults to `Input`.
|
|
3332
|
+
*/
|
|
3333
|
+
export type RemoteQueryFunction<Input, Output, _Validated = Input> = (
|
|
3334
|
+
arg: undefined extends Input ? Input | void : Input
|
|
3335
|
+
) => RemoteQuery<Output>;
|
|
3336
3336
|
|
|
3337
|
-
declare module '$app/paths' {
|
|
3338
|
-
import type { AssetPath, RouteIdWithSearchOrHash, PathnameWithSearchOrHash, ResolvedPathname, RouteId, RouteParams } from '$app/types';
|
|
3339
3337
|
/**
|
|
3340
|
-
*
|
|
3341
|
-
*
|
|
3342
|
-
* During server rendering, the base path is relative and depends on the page currently being rendered.
|
|
3343
|
-
*
|
|
3344
|
-
* @example
|
|
3345
|
-
* ```svelte
|
|
3346
|
-
* <script>
|
|
3347
|
-
* import { asset } from '$app/paths';
|
|
3348
|
-
* </script>
|
|
3349
|
-
*
|
|
3350
|
-
* <img alt="a potato" src={asset('potato.jpg')} />
|
|
3351
|
-
* ```
|
|
3352
|
-
* @since 2.26
|
|
3338
|
+
* The type of a remote `query.live` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query.live) for full documentation.
|
|
3353
3339
|
*
|
|
3354
|
-
*
|
|
3355
|
-
|
|
3340
|
+
* The optional `Validated` generic parameter represents the argument type *after* the
|
|
3341
|
+
* query's schema has validated and (optionally) transformed it, and matches the type
|
|
3342
|
+
* yielded by [`requested`](https://svelte.dev/docs/kit/$app-server#requested).
|
|
3343
|
+
*/
|
|
3344
|
+
export type RemoteLiveQueryFunction<Input, Output, _Validated = Input> = (
|
|
3345
|
+
arg: undefined extends Input ? Input | void : Input
|
|
3346
|
+
) => RemoteLiveQuery<Output>;
|
|
3347
|
+
|
|
3356
3348
|
/**
|
|
3357
|
-
*
|
|
3358
|
-
*
|
|
3359
|
-
*
|
|
3360
|
-
*
|
|
3361
|
-
*
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
* // using a route ID plus parameters
|
|
3369
|
-
* const resolved = resolve('/blog/[slug]', {
|
|
3370
|
-
* slug: 'hello-world'
|
|
3371
|
-
* });
|
|
3372
|
-
* ```
|
|
3373
|
-
* @since 2.26
|
|
3374
|
-
*
|
|
3375
|
-
* */
|
|
3376
|
-
export function resolve<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash>(...args: ResolveArgs<T>): ResolvedPathname;
|
|
3349
|
+
* A single entry yielded by [`requested`](https://svelte.dev/docs/kit/$app-server#requested)
|
|
3350
|
+
* when called with a regular `query`. `arg` is the validated argument (the input *after*
|
|
3351
|
+
* the query's schema validated and transformed it, if applicable); `query` is a
|
|
3352
|
+
* `RemoteQuery` bound to the client's original cache key, so `refresh()` / `set()` will
|
|
3353
|
+
* update the correct client entry.
|
|
3354
|
+
*/
|
|
3355
|
+
export type RequestedEntry<Validated, Output> = {
|
|
3356
|
+
arg: Validated;
|
|
3357
|
+
query: RemoteQuery<Output>;
|
|
3358
|
+
};
|
|
3359
|
+
|
|
3377
3360
|
/**
|
|
3378
|
-
*
|
|
3379
|
-
*
|
|
3380
|
-
*
|
|
3381
|
-
*
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
* const slug = route.params.slug;
|
|
3388
|
-
* const response = await fetch(`/api/posts/${slug}`);
|
|
3389
|
-
* const post = await response.json();
|
|
3390
|
-
* }
|
|
3391
|
-
* ```
|
|
3392
|
-
* @since 2.52.0
|
|
3393
|
-
*
|
|
3394
|
-
* */
|
|
3395
|
-
export function match(url: URL | string): Promise<{ [K in RouteId]: {
|
|
3396
|
-
id: K;
|
|
3397
|
-
params: RouteParams<K>;
|
|
3398
|
-
}; }[RouteId] | null>;
|
|
3399
|
-
type StripSearchOrHash<T extends string> = T extends `${infer U}?${string}`
|
|
3400
|
-
? U
|
|
3401
|
-
: T extends `${infer U}#${string}`
|
|
3402
|
-
? U
|
|
3403
|
-
: T;
|
|
3361
|
+
* A single entry yielded by [`requested`](https://svelte.dev/docs/kit/$app-server#requested)
|
|
3362
|
+
* when called with a `query.live`. `arg` is the validated argument; `query` is a
|
|
3363
|
+
* `RemoteLiveQuery` bound to the client's original cache key, so `reconnect()` targets
|
|
3364
|
+
* the correct client subscription.
|
|
3365
|
+
*/
|
|
3366
|
+
export type RemoteLiveQueryRequestedEntry<Validated, Output> = {
|
|
3367
|
+
arg: Validated;
|
|
3368
|
+
query: RemoteLiveQuery<Output>;
|
|
3369
|
+
};
|
|
3404
3370
|
|
|
3405
|
-
type
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3371
|
+
export type RemoteQueryRequestedResult<Validated, Output> = Iterable<
|
|
3372
|
+
RequestedEntry<Validated, Output>
|
|
3373
|
+
> &
|
|
3374
|
+
AsyncIterable<RequestedEntry<Validated, Output>> & {
|
|
3375
|
+
/**
|
|
3376
|
+
* Call `refresh` on all queries selected by this `requested` invocation.
|
|
3377
|
+
* This is identical to:
|
|
3378
|
+
* ```ts
|
|
3379
|
+
* import { requested } from '$app/server';
|
|
3380
|
+
*
|
|
3381
|
+
* for await (const { query } of requested(getPost, ...)) {
|
|
3382
|
+
* void query.refresh();
|
|
3383
|
+
* }
|
|
3384
|
+
* ```
|
|
3385
|
+
*/
|
|
3386
|
+
refreshAll: () => Promise<void>;
|
|
3387
|
+
};
|
|
3412
3388
|
|
|
3413
|
-
export
|
|
3414
|
-
|
|
3389
|
+
export type RemoteLiveQueryRequestedResult<Validated, Output> = Iterable<
|
|
3390
|
+
RemoteLiveQueryRequestedEntry<Validated, Output>
|
|
3391
|
+
> &
|
|
3392
|
+
AsyncIterable<RemoteLiveQueryRequestedEntry<Validated, Output>> & {
|
|
3393
|
+
/**
|
|
3394
|
+
* Call `reconnect` on all live queries selected by this `requested` invocation.
|
|
3395
|
+
* This is identical to:
|
|
3396
|
+
* ```ts
|
|
3397
|
+
* import { requested } from '$app/server';
|
|
3398
|
+
*
|
|
3399
|
+
* for await (const { query } of requested(liveQuery, ...)) {
|
|
3400
|
+
* void query.reconnect();
|
|
3401
|
+
* }
|
|
3402
|
+
* ```
|
|
3403
|
+
*/
|
|
3404
|
+
reconnectAll: () => Promise<void>;
|
|
3405
|
+
};
|
|
3415
3406
|
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3407
|
+
export type RequestedResult<Validated, Output> =
|
|
3408
|
+
| RemoteQueryRequestedResult<Validated, Output>
|
|
3409
|
+
| RemoteLiveQueryRequestedResult<Validated, Output>;
|
|
3410
|
+
type RemoteLiveQueryUserFunctionReturnType<Output> = MaybePromise<
|
|
3411
|
+
| AsyncGenerator<Output>
|
|
3412
|
+
| AsyncIterator<Output>
|
|
3413
|
+
| AsyncIterable<Output>
|
|
3414
|
+
| Generator<Output>
|
|
3415
|
+
| Iterator<Output>
|
|
3416
|
+
| Iterable<Output>
|
|
3417
|
+
>;
|
|
3418
|
+
type RemotePrerenderInputsGenerator<Input = any> = () => MaybePromise<Input[]>;
|
|
3420
3419
|
/**
|
|
3421
3420
|
* Read the contents of an imported asset from the filesystem
|
|
3422
3421
|
* @example
|
|
@@ -3430,6 +3429,28 @@ declare module '$app/server' {
|
|
|
3430
3429
|
* @since 2.4.0
|
|
3431
3430
|
*/
|
|
3432
3431
|
export function read(asset: string): Response;
|
|
3432
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
3433
|
+
|
|
3434
|
+
type DeepPartial<T> = T extends Record<PropertyKey, unknown> | unknown[]
|
|
3435
|
+
? {
|
|
3436
|
+
[K in keyof T]?: T[K] extends Record<PropertyKey, unknown> | unknown[]
|
|
3437
|
+
? DeepPartial<T[K]>
|
|
3438
|
+
: T[K];
|
|
3439
|
+
}
|
|
3440
|
+
: T | undefined;
|
|
3441
|
+
|
|
3442
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
3443
|
+
|
|
3444
|
+
type HasNonOptionalBoolean<T> =
|
|
3445
|
+
IsAny<T> extends true
|
|
3446
|
+
? never
|
|
3447
|
+
: [T] extends [boolean]
|
|
3448
|
+
? true
|
|
3449
|
+
: T extends Array<infer U>
|
|
3450
|
+
? HasNonOptionalBoolean<U>
|
|
3451
|
+
: T extends Record<string, any>
|
|
3452
|
+
? { [K in keyof T]: HasNonOptionalBoolean<T[K]> }[keyof T]
|
|
3453
|
+
: never;
|
|
3433
3454
|
/**
|
|
3434
3455
|
* Returns the current `RequestEvent`. Can be used inside server hooks, server `load` functions, actions, and endpoints (and functions called by them).
|
|
3435
3456
|
*
|
|
@@ -3477,7 +3498,7 @@ declare module '$app/server' {
|
|
|
3477
3498
|
*
|
|
3478
3499
|
* @since 2.27
|
|
3479
3500
|
*/
|
|
3480
|
-
export function form<Input extends RemoteFormInput, Output>(validate: "unchecked", fn: (data: Input, issue:
|
|
3501
|
+
export function form<Input extends RemoteFormInput, Output>(validate: "unchecked", fn: (data: Input, issue: RemoteFormInvalidField<Input>) => MaybePromise<Output>): RemoteForm<Input, Output>;
|
|
3481
3502
|
/**
|
|
3482
3503
|
* Creates a form object that can be spread onto a `<form>` element.
|
|
3483
3504
|
*
|
|
@@ -3485,7 +3506,7 @@ declare module '$app/server' {
|
|
|
3485
3506
|
*
|
|
3486
3507
|
* @since 2.27
|
|
3487
3508
|
*/
|
|
3488
|
-
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:
|
|
3509
|
+
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: RemoteFormInvalidField<StandardSchemaV1.InferInput<Schema>>) => MaybePromise<Output>): RemoteForm<StandardSchemaV1.InferInput<Schema>, Output>;
|
|
3489
3510
|
/**
|
|
3490
3511
|
* Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a `fetch` call.
|
|
3491
3512
|
*
|
|
@@ -3613,7 +3634,7 @@ declare module '$app/server' {
|
|
|
3613
3634
|
* For live queries, the same applies, but with `reconnect` and `reconnectAll`.
|
|
3614
3635
|
*
|
|
3615
3636
|
* */
|
|
3616
|
-
export function requested<Input, Output, Validated = Input>(query: RemoteQueryFunction<Input, Output, Validated>, limit: number):
|
|
3637
|
+
export function requested<Input, Output, Validated = Input>(query: RemoteQueryFunction<Input, Output, Validated>, limit: number): RemoteQueryRequestedResult<Validated, Output>;
|
|
3617
3638
|
/**
|
|
3618
3639
|
* Inside a remote `command` or `form` callback, returns an iterable
|
|
3619
3640
|
* of `{ arg, query }` entries for the live query instances the client asked to reconnect, up to
|
|
@@ -3645,30 +3666,7 @@ declare module '$app/server' {
|
|
|
3645
3666
|
* ```
|
|
3646
3667
|
*
|
|
3647
3668
|
* */
|
|
3648
|
-
export function requested<Input, Output, Validated = Input>(query: RemoteLiveQueryFunction<Input, Output, Validated>, limit: number):
|
|
3649
|
-
type RemoteLiveQueryUserFunctionReturnType<Output> = MaybePromise<
|
|
3650
|
-
| AsyncGenerator<Output>
|
|
3651
|
-
| AsyncIterator<Output>
|
|
3652
|
-
| AsyncIterable<Output>
|
|
3653
|
-
| Generator<Output>
|
|
3654
|
-
| Iterator<Output>
|
|
3655
|
-
| Iterable<Output>
|
|
3656
|
-
>;
|
|
3657
|
-
type RemotePrerenderInputsGenerator<Input = any> = () => MaybePromise<Input[]>;
|
|
3658
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
3659
|
-
|
|
3660
|
-
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
3661
|
-
|
|
3662
|
-
type HasNonOptionalBoolean<T> =
|
|
3663
|
-
IsAny<T> extends true
|
|
3664
|
-
? never
|
|
3665
|
-
: [T] extends [boolean]
|
|
3666
|
-
? true
|
|
3667
|
-
: T extends Array<infer U>
|
|
3668
|
-
? HasNonOptionalBoolean<U>
|
|
3669
|
-
: T extends Record<string, any>
|
|
3670
|
-
? { [K in keyof T]: HasNonOptionalBoolean<T[K]> }[keyof T]
|
|
3671
|
-
: never;
|
|
3669
|
+
export function requested<Input, Output, Validated = Input>(query: RemoteLiveQueryFunction<Input, Output, Validated>, limit: number): RemoteLiveQueryRequestedResult<Validated, Output>;
|
|
3672
3670
|
|
|
3673
3671
|
export {};
|
|
3674
3672
|
}
|