@sveltejs/kit 3.0.0-next.17 → 3.0.0-next.19
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 +12 -5
- package/src/cli.js +1 -1
- package/src/constants.js +3 -0
- package/src/core/config/index.js +1 -1
- package/src/core/env.js +1 -1
- package/src/core/postbuild/analyse.js +1 -1
- package/src/core/postbuild/prerender.js +1 -1
- package/src/core/sync/create_manifest_data/index.js +9 -0
- package/src/core/sync/sync.js +22 -9
- package/src/core/sync/ts.js +1 -1
- package/src/core/sync/write_app_types.js +1 -1
- package/src/core/sync/write_client_manifest.js +1 -1
- package/src/core/sync/write_server.js +1 -3
- package/src/core/sync/write_tsconfig/index.js +1 -1
- package/src/core/sync/write_types/index.js +6 -3
- package/src/exports/index.js +9 -9
- package/src/exports/internal/server/event.js +1 -1
- package/src/exports/internal/server/telemetry.js +1 -1
- package/src/exports/internal/shared.js +9 -0
- package/src/exports/{params.js → params/index.js} +6 -4
- package/src/exports/params/public.d.ts +63 -0
- package/src/exports/public.d.ts +93 -453
- package/src/exports/vite/build/build_server.js +2 -2
- package/src/exports/vite/dev/index.js +2 -3
- package/src/exports/vite/index.js +17 -5
- package/src/pathname.js +55 -0
- package/src/runtime/app/{forms.js → forms/index.js} +9 -8
- package/src/runtime/app/forms/public.d.ts +2 -0
- package/src/runtime/app/forms/types.d.ts +56 -0
- package/src/runtime/app/{navigation.js → navigation/index.js} +2 -2
- package/src/runtime/app/navigation/public.d.ts +237 -0
- package/src/runtime/app/paths/client.js +14 -8
- package/src/runtime/app/paths/index.js +1 -1
- package/src/runtime/app/paths/internal/client.js +4 -0
- package/src/runtime/app/paths/internal/server.js +4 -0
- package/src/runtime/app/paths/internal.d.ts +3 -0
- package/src/runtime/app/paths/public.d.ts +1 -1
- package/src/runtime/app/paths/server.js +6 -4
- package/src/runtime/app/server/index.js +1 -1
- package/src/runtime/app/server/remote/form.js +3 -4
- package/src/runtime/app/server/remote/prerender.js +3 -3
- package/src/runtime/app/server/remote/shared.js +3 -10
- package/src/runtime/app/state/index.js +4 -2
- package/src/runtime/app/state/public.d.ts +72 -0
- package/src/runtime/app/stores.js +2 -2
- package/src/runtime/client/client.js +65 -54
- package/src/runtime/client/entry.js +2 -2
- package/src/runtime/client/remote-functions/command.svelte.js +36 -34
- package/src/runtime/client/remote-functions/form.svelte.js +76 -78
- package/src/runtime/client/remote-functions/prerender.svelte.js +3 -3
- package/src/runtime/client/remote-functions/query/index.js +1 -1
- package/src/runtime/client/remote-functions/query/instance.svelte.js +4 -3
- package/src/runtime/client/remote-functions/query-batch.svelte.js +3 -3
- package/src/runtime/client/remote-functions/query-live/instance.svelte.js +5 -5
- package/src/runtime/client/remote-functions/query-live/iterator.js +5 -7
- package/src/runtime/client/remote-functions/shared.svelte.js +9 -14
- package/src/runtime/client/state.svelte.js +5 -3
- package/src/runtime/client/types.d.ts +2 -1
- package/src/runtime/pathname.js +6 -61
- package/src/runtime/props.svelte.js +1 -1
- package/src/runtime/server/constants.js +0 -3
- package/src/runtime/server/csrf.js +1 -1
- package/src/runtime/server/errors.js +53 -28
- package/src/runtime/server/fetch.js +1 -1
- package/src/runtime/server/index.js +9 -14
- package/src/runtime/server/page/actions.js +2 -1
- package/src/runtime/server/page/index.js +7 -3
- package/src/runtime/server/page/load_data.js +1 -1
- package/src/runtime/server/page/render.js +17 -11
- package/src/runtime/server/page/server_routing.js +3 -2
- package/src/runtime/server/remote-functions.js +3 -2
- package/src/runtime/server/respond.js +4 -8
- package/src/runtime/server/state.js +3 -6
- package/src/types/ambient.d.ts +1 -1
- package/src/types/internal.d.ts +8 -10
- package/src/types/private.d.ts +12 -3
- package/src/utils/error.js +30 -14
- package/src/utils/page_nodes.js +3 -2
- package/src/utils/params.js +3 -2
- package/src/utils/routing.js +5 -4
- package/src/version.js +1 -1
- package/types/index.d.ts +1005 -935
- package/types/index.d.ts.map +43 -31
- /package/src/{runtime/telemetry/noop.js → telemetry.js} +0 -0
package/src/exports/public.d.ts
CHANGED
|
@@ -24,18 +24,28 @@ import { BuildData, SSRNodeLoader, SSRRoute, ValidatedConfig } from 'types';
|
|
|
24
24
|
import { SvelteConfig } from '@sveltejs/vite-plugin-svelte';
|
|
25
25
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
26
26
|
import { Plugin } from 'vite';
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
LayoutParams as AppLayoutParams,
|
|
30
|
-
ResolvedPathname
|
|
31
|
-
} from '$app/types';
|
|
27
|
+
import { RouteId as AppRouteId, LayoutParams as AppLayoutParams } from '$app/types';
|
|
28
|
+
import { ParamMatcher } from '@sveltejs/kit/params';
|
|
32
29
|
|
|
33
30
|
export { PrerenderOption } from '../types/private.js';
|
|
34
31
|
|
|
35
32
|
// @ts-ignore this is an optional peer dependency so could be missing. Written like this so dts-buddy preserves the ts-ignore
|
|
36
33
|
type Span = import('@opentelemetry/api').Span;
|
|
37
34
|
|
|
38
|
-
type
|
|
35
|
+
type AppErrorWithOptionalDefaults = Omit<App.Error, 'status' | 'message'> & {
|
|
36
|
+
status?: App.Error['status'];
|
|
37
|
+
message?: App.Error['message'];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* `void` is only a valid `handleError` return when `App.Error` adds no required properties
|
|
42
|
+
* beyond `status` and `message` — both of which are optional in the return, since they default
|
|
43
|
+
* to those of the caught error. If `App.Error` is augmented with required properties, the hook
|
|
44
|
+
* must return them, so returning nothing becomes a type error.
|
|
45
|
+
*/
|
|
46
|
+
type VoidIfNoRequiredAppErrorProperties = { status: number; message: string } extends App.Error
|
|
47
|
+
? void
|
|
48
|
+
: never;
|
|
39
49
|
|
|
40
50
|
/**
|
|
41
51
|
* [Adapters](https://svelte.dev/docs/kit/adapters) are responsible for taking the production build and turning it into something that can be deployed to a platform of your choosing.
|
|
@@ -72,11 +82,18 @@ export interface Adapter {
|
|
|
72
82
|
*/
|
|
73
83
|
emulate?: () => MaybePromise<Emulator>;
|
|
74
84
|
vite?: {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
plugins?: {
|
|
86
|
+
/**
|
|
87
|
+
* Vite plugins placed before any of SvelteKit's own plugins.
|
|
88
|
+
* @since 3.0.0
|
|
89
|
+
*/
|
|
90
|
+
pre?: Plugin[];
|
|
91
|
+
/**
|
|
92
|
+
* Vite plugins placed after any of SvelteKit's own plugins.
|
|
93
|
+
* @since 3.0.0
|
|
94
|
+
*/
|
|
95
|
+
post?: Plugin[];
|
|
96
|
+
};
|
|
80
97
|
};
|
|
81
98
|
}
|
|
82
99
|
|
|
@@ -460,7 +477,10 @@ export interface KitConfig {
|
|
|
460
477
|
*
|
|
461
478
|
* CSRF checks only apply in production, not in local development.
|
|
462
479
|
* @default []
|
|
463
|
-
* @example
|
|
480
|
+
* @example
|
|
481
|
+
* ```js
|
|
482
|
+
* ['https://checkout.stripe.com', 'https://accounts.google.com']
|
|
483
|
+
* ```
|
|
464
484
|
*/
|
|
465
485
|
trustedOrigins?: string[];
|
|
466
486
|
};
|
|
@@ -940,45 +960,76 @@ export type Handle = (input: {
|
|
|
940
960
|
resolve: (event: RequestEvent, opts?: ResolveOptions) => Promise<Response>;
|
|
941
961
|
}) => MaybePromise<Response>;
|
|
942
962
|
|
|
963
|
+
type CaughtErrorMap = {
|
|
964
|
+
app: App.Error;
|
|
965
|
+
framework: { status: number; message: string };
|
|
966
|
+
unknown: unknown;
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
type ValidationCaughtError<Issue extends StandardSchemaV1.Issue> = {
|
|
970
|
+
kind: 'validation';
|
|
971
|
+
error: { status: number; message: string };
|
|
972
|
+
issues: Issue[];
|
|
973
|
+
};
|
|
974
|
+
|
|
943
975
|
/**
|
|
944
|
-
* The
|
|
945
|
-
*
|
|
946
|
-
*
|
|
947
|
-
*
|
|
948
|
-
*
|
|
949
|
-
* The returned object can include a `status` property to override the HTTP status code used in the response.
|
|
950
|
-
* If omitted, the status defaults to 500.
|
|
976
|
+
* The error passed to the [`handleError`](https://svelte.dev/docs/kit/hooks#handleError) hooks.
|
|
977
|
+
* Use the `kind` discriminant to distinguish errors from your app (thrown with the
|
|
978
|
+
* [`error`](https://svelte.dev/docs/kit/errors#App-errors) helper), errors generated by
|
|
979
|
+
* SvelteKit itself (such as 404s), validation errors, and unknown errors (thrown by your code,
|
|
980
|
+
* or code it calls).
|
|
951
981
|
*/
|
|
952
|
-
export type
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
982
|
+
export type CaughtError<Issue extends StandardSchemaV1.Issue = StandardSchemaV1.Issue> =
|
|
983
|
+
| {
|
|
984
|
+
[Kind in keyof CaughtErrorMap]: {
|
|
985
|
+
/** Identifies the category and origin of the error */
|
|
986
|
+
kind: Kind;
|
|
987
|
+
/** The caught error. Its type depends on `kind` */
|
|
988
|
+
error: CaughtErrorMap[Kind];
|
|
989
|
+
/** Only present for validation errors */
|
|
990
|
+
issues?: undefined;
|
|
991
|
+
};
|
|
992
|
+
}[keyof CaughtErrorMap]
|
|
993
|
+
| ValidationCaughtError<Issue>;
|
|
994
|
+
|
|
995
|
+
/** The error passed to the client-side `handleError` hook. */
|
|
996
|
+
export type ClientCaughtError = Exclude<CaughtError, { kind: 'validation' }>;
|
|
958
997
|
|
|
959
998
|
/**
|
|
960
|
-
* The [`
|
|
999
|
+
* The server-side [`handleError`](https://svelte.dev/docs/kit/hooks#handleError) hook runs for every error thrown while responding to a request, except redirects.
|
|
1000
|
+
*
|
|
1001
|
+
* The `kind` property discriminates between _app_ errors (thrown with the [`error`](https://svelte.dev/docs/kit/errors#App-errors) helper),
|
|
1002
|
+
* _framework_ errors (generated by SvelteKit itself, such as 404s), _validation_ errors (caused by invalid remote function arguments)
|
|
1003
|
+
* and _unknown_ errors (thrown by your code, or code it calls).
|
|
1004
|
+
*
|
|
1005
|
+
* The hook returns an object matching `App.Error`, in which `status` and `message` are optional — return them only to
|
|
1006
|
+
* override the defaults. Omitted properties are inherited from the caught error: the body passed to `error(...)` for app errors,
|
|
1007
|
+
* the status and safe message for framework and validation errors, and `500`/`'Internal Error'` for unknown errors. Return nothing to
|
|
1008
|
+
* keep the defaults entirely (if you augment `App.Error` with required properties, you must return those).
|
|
961
1009
|
*
|
|
962
|
-
*
|
|
1010
|
+
* Make sure that this function _never_ throws an error.
|
|
963
1011
|
*/
|
|
964
|
-
export type
|
|
965
|
-
|
|
1012
|
+
export type HandleServerError<Issue extends StandardSchemaV1.Issue = StandardSchemaV1.Issue> = (
|
|
1013
|
+
input: CaughtError<Issue> & { event: RequestEvent }
|
|
1014
|
+
) => MaybePromise<AppErrorWithOptionalDefaults | VoidIfNoRequiredAppErrorProperties>;
|
|
966
1015
|
|
|
967
1016
|
/**
|
|
968
|
-
* The client-side [`handleError`](https://svelte.dev/docs/kit/hooks#handleError) hook runs
|
|
1017
|
+
* The client-side [`handleError`](https://svelte.dev/docs/kit/hooks#handleError) hook runs for every error thrown while navigating, except redirects.
|
|
1018
|
+
* Errors that were already transformed by the server-side hook are not passed to it a second time.
|
|
969
1019
|
*
|
|
970
|
-
*
|
|
971
|
-
*
|
|
1020
|
+
* The `kind` property discriminates between _app_ errors (thrown with the [`error`](https://svelte.dev/docs/kit/errors#App-errors) helper),
|
|
1021
|
+
* _framework_ errors (generated by SvelteKit itself, such as 404s) and _unknown_ errors (thrown by your code, or code it calls).
|
|
972
1022
|
*
|
|
973
|
-
* The
|
|
974
|
-
*
|
|
1023
|
+
* The hook returns an object matching `App.Error`, in which `status` and `message` are optional — return them only to
|
|
1024
|
+
* override the defaults. Omitted properties are inherited from the caught error: the body passed to `error(...)` for app errors,
|
|
1025
|
+
* the status and safe message for framework errors, and `500`/`'Internal Error'` for unknown errors. Return nothing to
|
|
1026
|
+
* keep the defaults entirely (if you augment `App.Error` with required properties, you must return those).
|
|
1027
|
+
*
|
|
1028
|
+
* Make sure that this function _never_ throws an error.
|
|
975
1029
|
*/
|
|
976
|
-
export type HandleClientError = (
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
status: number;
|
|
980
|
-
message: string;
|
|
981
|
-
}) => MaybePromise<void | AppErrorWithOptionalStatus>;
|
|
1030
|
+
export type HandleClientError = (
|
|
1031
|
+
input: ClientCaughtError & { event: NavigationEvent }
|
|
1032
|
+
) => MaybePromise<AppErrorWithOptionalDefaults | VoidIfNoRequiredAppErrorProperties>;
|
|
982
1033
|
|
|
983
1034
|
/**
|
|
984
1035
|
* The [`handleFetch`](https://svelte.dev/docs/kit/hooks#handleFetch) hook allows you to modify (or replace) the result of an [`event.fetch`](https://svelte.dev/docs/kit/load#Making-fetch-requests) call that runs on the server (or during prerendering) inside an endpoint, `load`, `action`, `handle`, `handleError` or `reroute`.
|
|
@@ -1204,355 +1255,6 @@ export interface NavigationEvent<
|
|
|
1204
1255
|
url: URL;
|
|
1205
1256
|
}
|
|
1206
1257
|
|
|
1207
|
-
/**
|
|
1208
|
-
* Information about the target of a specific navigation.
|
|
1209
|
-
*/
|
|
1210
|
-
export interface NavigationTarget<
|
|
1211
|
-
Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
|
|
1212
|
-
RouteId extends AppRouteId | null = AppRouteId | null
|
|
1213
|
-
> {
|
|
1214
|
-
/**
|
|
1215
|
-
* Parameters of the target page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
|
|
1216
|
-
* Is `null` if the target is not part of the SvelteKit app (could not be resolved to a route).
|
|
1217
|
-
*/
|
|
1218
|
-
params: Params | null;
|
|
1219
|
-
/**
|
|
1220
|
-
* Info about the target route
|
|
1221
|
-
*/
|
|
1222
|
-
route: {
|
|
1223
|
-
/**
|
|
1224
|
-
* The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.
|
|
1225
|
-
*/
|
|
1226
|
-
id: RouteId | null;
|
|
1227
|
-
};
|
|
1228
|
-
/**
|
|
1229
|
-
* The URL that is navigated to
|
|
1230
|
-
*/
|
|
1231
|
-
url: URL;
|
|
1232
|
-
/**
|
|
1233
|
-
* The scroll position associated with this navigation.
|
|
1234
|
-
*
|
|
1235
|
-
* For the `from` target, this is the scroll position at the moment of navigation.
|
|
1236
|
-
*
|
|
1237
|
-
* For the `to` target, this represents the scroll position that will be or was restored:
|
|
1238
|
-
* - In `beforeNavigate` and `onNavigate`, this is only available for `popstate` navigations (back/forward button)
|
|
1239
|
-
* and will be `null` for other navigation types, since the final scroll position isn't known
|
|
1240
|
-
* ahead of time.
|
|
1241
|
-
* - In `afterNavigate`, this is always the scroll position that was applied after the navigation
|
|
1242
|
-
* completed.
|
|
1243
|
-
*/
|
|
1244
|
-
scroll: { x: number; y: number } | null;
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
export interface GotoOptions {
|
|
1248
|
-
/**
|
|
1249
|
-
* If `true`, replaces the current history entry rather than creating a new one.
|
|
1250
|
-
* @default false
|
|
1251
|
-
*/
|
|
1252
|
-
replace?: boolean;
|
|
1253
|
-
/** @deprecated Use `replace` instead. */
|
|
1254
|
-
replaceState?: boolean;
|
|
1255
|
-
/**
|
|
1256
|
-
* If `true`, updates the URL and `page.state` without navigating.
|
|
1257
|
-
* @default false
|
|
1258
|
-
*/
|
|
1259
|
-
shallow?: boolean;
|
|
1260
|
-
/**
|
|
1261
|
-
* If `true`, resets the scroll position (to the top of the page, or to the element
|
|
1262
|
-
* matching the URL's `#hash` if there is one) and resets focus (to the `<body>`, or the
|
|
1263
|
-
* `autofocus` element if there is one) once the navigation completes.
|
|
1264
|
-
*
|
|
1265
|
-
* If `false`, the current scroll position and focused element are left alone.
|
|
1266
|
-
* @default true, or false when `shallow` is true
|
|
1267
|
-
*/
|
|
1268
|
-
reset?: boolean;
|
|
1269
|
-
/**
|
|
1270
|
-
* If `true`, reruns all `load` functions and queries of the page.
|
|
1271
|
-
* @default false
|
|
1272
|
-
*/
|
|
1273
|
-
refreshAll?: boolean;
|
|
1274
|
-
/** Causes any `load` functions to rerun if they depend on one of the URLs. */
|
|
1275
|
-
invalidate?: Array<string | URL | ((url: URL) => boolean)>;
|
|
1276
|
-
/** @deprecated Use `refreshAll` instead. */
|
|
1277
|
-
invalidateAll?: boolean;
|
|
1278
|
-
/** An optional object that will be available as `page.state`. */
|
|
1279
|
-
state?: App.PageState;
|
|
1280
|
-
/**
|
|
1281
|
-
* If `true`, `page.state` will be restored after a full page reload.
|
|
1282
|
-
* @default false
|
|
1283
|
-
*/
|
|
1284
|
-
persistState?: boolean;
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
/**
|
|
1288
|
-
* - `enter`: The app has hydrated/started
|
|
1289
|
-
* - `form`: The user submitted a `<form method="GET">`
|
|
1290
|
-
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1291
|
-
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
1292
|
-
* - `link`: Navigation was triggered by a link click
|
|
1293
|
-
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1294
|
-
*/
|
|
1295
|
-
export type NavigationType = 'enter' | 'form' | 'leave' | 'link' | 'goto' | 'popstate';
|
|
1296
|
-
|
|
1297
|
-
export interface NavigationBase {
|
|
1298
|
-
/**
|
|
1299
|
-
* The type of navigation:
|
|
1300
|
-
* - `enter`: The app has hydrated/started
|
|
1301
|
-
* - `form`: The user submitted a `<form method="GET">`
|
|
1302
|
-
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1303
|
-
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
1304
|
-
* - `link`: Navigation was triggered by a link click
|
|
1305
|
-
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1306
|
-
*/
|
|
1307
|
-
type: NavigationType;
|
|
1308
|
-
/** Whether this is a shallow navigation. */
|
|
1309
|
-
shallow: boolean;
|
|
1310
|
-
/**
|
|
1311
|
-
* Where navigation was triggered from
|
|
1312
|
-
*/
|
|
1313
|
-
from: NavigationTarget | null;
|
|
1314
|
-
/**
|
|
1315
|
-
* Where navigation is going to/has gone to
|
|
1316
|
-
*/
|
|
1317
|
-
to: NavigationTarget | null;
|
|
1318
|
-
/**
|
|
1319
|
-
* Whether or not the navigation will result in the page being unloaded (i.e. not a client-side navigation).
|
|
1320
|
-
*/
|
|
1321
|
-
willUnload: boolean;
|
|
1322
|
-
/**
|
|
1323
|
-
* A promise that resolves once the navigation is complete, and rejects if the navigation
|
|
1324
|
-
* fails or is aborted. In the case of a `willUnload` navigation, the promise will never resolve
|
|
1325
|
-
*/
|
|
1326
|
-
complete: Promise<void>;
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
/**
|
|
1330
|
-
* The navigation that occurs when the app starts/hydrates
|
|
1331
|
-
*/
|
|
1332
|
-
export interface NavigationEnter extends NavigationBase {
|
|
1333
|
-
type: 'enter';
|
|
1334
|
-
|
|
1335
|
-
/**
|
|
1336
|
-
* In case of a history back/forward navigation, the number of steps to go back/forward
|
|
1337
|
-
*/
|
|
1338
|
-
delta?: undefined;
|
|
1339
|
-
|
|
1340
|
-
/**
|
|
1341
|
-
* Dispatched `Event` object when navigation occurred by `popstate` or `link`.
|
|
1342
|
-
*/
|
|
1343
|
-
event?: undefined;
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
|
-
export type NavigationExternal = NavigationGoto | NavigationLeave;
|
|
1347
|
-
|
|
1348
|
-
/**
|
|
1349
|
-
* A navigation triggered by a `goto(...)` call or a redirect
|
|
1350
|
-
*/
|
|
1351
|
-
export interface NavigationGoto extends NavigationBase {
|
|
1352
|
-
type: 'goto';
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
/**
|
|
1356
|
-
* A navigation triggered by the tab being closed, or the user navigating to a different document
|
|
1357
|
-
*/
|
|
1358
|
-
export interface NavigationLeave extends NavigationBase {
|
|
1359
|
-
type: 'leave';
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
/**
|
|
1363
|
-
* A navigation triggered by a `<form method="GET">`
|
|
1364
|
-
*/
|
|
1365
|
-
export interface NavigationFormSubmit extends NavigationBase {
|
|
1366
|
-
type: 'form';
|
|
1367
|
-
|
|
1368
|
-
/**
|
|
1369
|
-
* The `SubmitEvent` that caused the navigation
|
|
1370
|
-
*/
|
|
1371
|
-
event: SubmitEvent;
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
/**
|
|
1375
|
-
* A navigation triggered by back/forward navigation
|
|
1376
|
-
*/
|
|
1377
|
-
export interface NavigationPopState extends NavigationBase {
|
|
1378
|
-
type: 'popstate';
|
|
1379
|
-
|
|
1380
|
-
/**
|
|
1381
|
-
* In case of a history back/forward navigation, the number of steps to go back/forward
|
|
1382
|
-
*/
|
|
1383
|
-
delta: number;
|
|
1384
|
-
|
|
1385
|
-
/**
|
|
1386
|
-
* The `PopStateEvent` that caused the navigation
|
|
1387
|
-
*/
|
|
1388
|
-
event: PopStateEvent;
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
/**
|
|
1392
|
-
* A navigation triggered by a link click
|
|
1393
|
-
*/
|
|
1394
|
-
export interface NavigationLink extends NavigationBase {
|
|
1395
|
-
type: 'link';
|
|
1396
|
-
|
|
1397
|
-
/**
|
|
1398
|
-
* The `PointerEvent` that caused the navigation
|
|
1399
|
-
*/
|
|
1400
|
-
event: PointerEvent;
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
export type Navigation =
|
|
1404
|
-
NavigationExternal | NavigationFormSubmit | NavigationPopState | NavigationLink;
|
|
1405
|
-
|
|
1406
|
-
/**
|
|
1407
|
-
* The argument passed to [`beforeNavigate`](https://svelte.dev/docs/kit/$app-navigation#beforeNavigate) callbacks.
|
|
1408
|
-
*/
|
|
1409
|
-
export type BeforeNavigate = Navigation & {
|
|
1410
|
-
/**
|
|
1411
|
-
* Call this to prevent the navigation from starting.
|
|
1412
|
-
*/
|
|
1413
|
-
cancel: () => void;
|
|
1414
|
-
};
|
|
1415
|
-
|
|
1416
|
-
/**
|
|
1417
|
-
* The argument passed to [`onNavigate`](https://svelte.dev/docs/kit/$app-navigation#onNavigate) callbacks.
|
|
1418
|
-
*/
|
|
1419
|
-
export type OnNavigate = Navigation & {
|
|
1420
|
-
type: Exclude<NavigationType, 'enter' | 'leave'>;
|
|
1421
|
-
/**
|
|
1422
|
-
* Since `onNavigate` callbacks are called immediately before a client-side navigation, they will never be called with a navigation that unloads the page.
|
|
1423
|
-
*/
|
|
1424
|
-
willUnload: false;
|
|
1425
|
-
};
|
|
1426
|
-
|
|
1427
|
-
/**
|
|
1428
|
-
* The argument passed to [`afterNavigate`](https://svelte.dev/docs/kit/$app-navigation#afterNavigate) callbacks.
|
|
1429
|
-
*/
|
|
1430
|
-
export type AfterNavigate = (Navigation | NavigationEnter) & {
|
|
1431
|
-
type: Exclude<NavigationType, 'leave'>;
|
|
1432
|
-
/**
|
|
1433
|
-
* Since `afterNavigate` callbacks are called after a navigation completes, they will never be called with a navigation that unloads the page.
|
|
1434
|
-
*/
|
|
1435
|
-
willUnload: false;
|
|
1436
|
-
};
|
|
1437
|
-
|
|
1438
|
-
/**
|
|
1439
|
-
* The shape of the [`page`](https://svelte.dev/docs/kit/$app-state#page) reactive object.
|
|
1440
|
-
*/
|
|
1441
|
-
export interface Page<
|
|
1442
|
-
Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
|
|
1443
|
-
RouteId extends AppRouteId | null = AppRouteId | null
|
|
1444
|
-
> {
|
|
1445
|
-
/**
|
|
1446
|
-
* The URL of the current page.
|
|
1447
|
-
*/
|
|
1448
|
-
url: ReadonlyURL & { readonly pathname: ResolvedPathname | (string & {}) };
|
|
1449
|
-
/**
|
|
1450
|
-
* The parameters of the current page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
|
|
1451
|
-
*/
|
|
1452
|
-
params: Params;
|
|
1453
|
-
/**
|
|
1454
|
-
* Info about the current route.
|
|
1455
|
-
*/
|
|
1456
|
-
route: {
|
|
1457
|
-
/**
|
|
1458
|
-
* The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.
|
|
1459
|
-
*/
|
|
1460
|
-
id: RouteId;
|
|
1461
|
-
};
|
|
1462
|
-
/**
|
|
1463
|
-
* HTTP status code of the current page.
|
|
1464
|
-
*/
|
|
1465
|
-
status: number;
|
|
1466
|
-
/**
|
|
1467
|
-
* The error object of the current page, if any. Filled from the `handleError` hooks.
|
|
1468
|
-
*/
|
|
1469
|
-
error: App.Error | null;
|
|
1470
|
-
/**
|
|
1471
|
-
* The merged result of all data from all `load` functions on the current page. You can type a common denominator through `App.PageData`.
|
|
1472
|
-
*/
|
|
1473
|
-
data: App.PageData & Record<string, any>;
|
|
1474
|
-
/**
|
|
1475
|
-
* The page state, which can be manipulated using [`goto`](https://svelte.dev/docs/kit/$app-navigation#goto) from `$app/navigation`.
|
|
1476
|
-
*/
|
|
1477
|
-
state: App.PageState;
|
|
1478
|
-
/**
|
|
1479
|
-
* Information about the target of the current shallow navigation, or `null` if no shallow navigation has occurred.
|
|
1480
|
-
*/
|
|
1481
|
-
shallow: {
|
|
1482
|
-
/** Parameters of the target route, or `null` if the URL does not resolve to a route. */
|
|
1483
|
-
params: AppLayoutParams<'/'> | null;
|
|
1484
|
-
/** Info about the target route, or `null` if the URL does not resolve to a route. */
|
|
1485
|
-
route: { id: AppRouteId } | null;
|
|
1486
|
-
/** The normalized URL passed to `goto(..., { shallow: true })`. */
|
|
1487
|
-
url: ReadonlyURL;
|
|
1488
|
-
} | null;
|
|
1489
|
-
/**
|
|
1490
|
-
* Filled only after a form submission. See [form actions](https://svelte.dev/docs/kit/form-actions) for more info.
|
|
1491
|
-
*/
|
|
1492
|
-
form: any;
|
|
1493
|
-
}
|
|
1494
|
-
|
|
1495
|
-
/**
|
|
1496
|
-
* The shape of a param matcher. See [matching](https://svelte.dev/docs/kit/advanced-routing#Matching) for more info.
|
|
1497
|
-
*/
|
|
1498
|
-
export type ParamMatcher<Output = any> = StandardSchemaV1<string, Output>;
|
|
1499
|
-
|
|
1500
|
-
/**
|
|
1501
|
-
* A value that can be parsed from a URL param and losslessly encoded with `String(...)`.
|
|
1502
|
-
*/
|
|
1503
|
-
export type ParamValue = string | number | boolean | bigint;
|
|
1504
|
-
|
|
1505
|
-
/**
|
|
1506
|
-
* A param matcher definition passed to [`defineParams`](https://svelte.dev/docs/kit/@sveltejs-kit#defineParams).
|
|
1507
|
-
*/
|
|
1508
|
-
export type ParamDefinition =
|
|
1509
|
-
((param: string) => ParamValue | undefined) | StandardSchemaV1<string, ParamValue>;
|
|
1510
|
-
|
|
1511
|
-
/**
|
|
1512
|
-
* The return type of [`defineParams`](https://svelte.dev/docs/kit/@sveltejs-kit#defineParams).
|
|
1513
|
-
*/
|
|
1514
|
-
export type DefinedParams<T extends Record<string, ParamDefinition>> = {
|
|
1515
|
-
readonly [K in keyof T]: ParamEntry<T[K]>;
|
|
1516
|
-
};
|
|
1517
|
-
|
|
1518
|
-
/**
|
|
1519
|
-
* Normalizes a property of defineParams (schema or function) to standard schema.
|
|
1520
|
-
*/
|
|
1521
|
-
type ParamEntry<M> =
|
|
1522
|
-
M extends StandardSchemaV1<any, any>
|
|
1523
|
-
? StandardSchemaV1.InferOutput<M> extends ParamValue
|
|
1524
|
-
? StandardSchemaV1<any, M>
|
|
1525
|
-
: StandardSchemaV1<any, never>
|
|
1526
|
-
: M extends (param: string) => infer R
|
|
1527
|
-
? Exclude<R, undefined> extends ParamValue
|
|
1528
|
-
? StandardSchemaV1<any, Exclude<R, undefined>>
|
|
1529
|
-
: StandardSchemaV1<any, never>
|
|
1530
|
-
: never;
|
|
1531
|
-
|
|
1532
|
-
/**
|
|
1533
|
-
* Extracts the param type from a matcher.
|
|
1534
|
-
*/
|
|
1535
|
-
export type MatcherParam<M extends StandardSchemaV1<any, any>> =
|
|
1536
|
-
M extends StandardSchemaV1<any, infer Inner>
|
|
1537
|
-
? Inner extends ParamValue
|
|
1538
|
-
? Inner
|
|
1539
|
-
: Inner extends StandardSchemaV1<any, any>
|
|
1540
|
-
? StandardSchemaV1.InferOutput<Inner> extends ParamValue
|
|
1541
|
-
? StandardSchemaV1.InferOutput<Inner>
|
|
1542
|
-
: never
|
|
1543
|
-
: never
|
|
1544
|
-
: never;
|
|
1545
|
-
|
|
1546
|
-
/**
|
|
1547
|
-
* Define [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#Matching) for your app.
|
|
1548
|
-
*
|
|
1549
|
-
* @template T
|
|
1550
|
-
* @param definitions
|
|
1551
|
-
*/
|
|
1552
|
-
export function defineParams<T extends Record<string, ParamDefinition>>(
|
|
1553
|
-
definitions: T
|
|
1554
|
-
): DefinedParams<T>;
|
|
1555
|
-
|
|
1556
1258
|
/**
|
|
1557
1259
|
* A single entry yielded by [`requested`](https://svelte.dev/docs/kit/$app-server#requested)
|
|
1558
1260
|
* when called with a regular `query`. `arg` is the validated argument (the input *after*
|
|
@@ -1611,7 +1313,8 @@ export type LiveQueryRequestedResult<Validated, Output> = Iterable<
|
|
|
1611
1313
|
};
|
|
1612
1314
|
|
|
1613
1315
|
export type RequestedResult<Validated, Output> =
|
|
1614
|
-
QueryRequestedResult<Validated, Output>
|
|
1316
|
+
| QueryRequestedResult<Validated, Output>
|
|
1317
|
+
| LiveQueryRequestedResult<Validated, Output>;
|
|
1615
1318
|
|
|
1616
1319
|
export interface RequestEvent<
|
|
1617
1320
|
Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
|
|
@@ -1932,30 +1635,6 @@ export type Actions<
|
|
|
1932
1635
|
RouteId extends AppRouteId | null = AppRouteId | null
|
|
1933
1636
|
> = Record<string, Action<Params, OutputData, RouteId>>;
|
|
1934
1637
|
|
|
1935
|
-
/**
|
|
1936
|
-
* When calling a form action via fetch, the response will be one of these shapes.
|
|
1937
|
-
* ```svelte
|
|
1938
|
-
* <form method="post" use:enhance={() => {
|
|
1939
|
-
* return ({ result }) => {
|
|
1940
|
-
* // result is of type ActionResult
|
|
1941
|
-
* };
|
|
1942
|
-
* }}
|
|
1943
|
-
* ```
|
|
1944
|
-
*
|
|
1945
|
-
* Success and failure results carry the root-relative `pathname + search` of the action URL, with
|
|
1946
|
-
* the `?/actionName` parameter removed. Redirect results carry the redirect target. Server-generated
|
|
1947
|
-
* error results also carry the action location, while client-generated errors such as network
|
|
1948
|
-
* failures do not. `update` uses this location to emulate native form navigation.
|
|
1949
|
-
*/
|
|
1950
|
-
export type ActionResult<
|
|
1951
|
-
Success extends Record<string, unknown> | undefined = Record<string, any>,
|
|
1952
|
-
Failure extends Record<string, unknown> | undefined = Record<string, any>
|
|
1953
|
-
> =
|
|
1954
|
-
| { type: 'success'; status: number; data?: Success; location: string }
|
|
1955
|
-
| { type: 'failure'; status: number; data?: Failure; location: string }
|
|
1956
|
-
| { type: 'redirect'; status: number; location: string }
|
|
1957
|
-
| { type: 'error'; status?: number; error: App.Error; location?: string };
|
|
1958
|
-
|
|
1959
1638
|
/**
|
|
1960
1639
|
* The object returned by the [`error`](https://svelte.dev/docs/kit/@sveltejs-kit#error) function.
|
|
1961
1640
|
*/
|
|
@@ -1976,37 +1655,6 @@ export interface Redirect {
|
|
|
1976
1655
|
location: string;
|
|
1977
1656
|
}
|
|
1978
1657
|
|
|
1979
|
-
export type SubmitFunction<
|
|
1980
|
-
Success extends Record<string, unknown> | undefined = Record<string, any>,
|
|
1981
|
-
Failure extends Record<string, unknown> | undefined = Record<string, any>
|
|
1982
|
-
> = (input: {
|
|
1983
|
-
action: URL;
|
|
1984
|
-
formData: FormData;
|
|
1985
|
-
formElement: HTMLFormElement;
|
|
1986
|
-
controller: AbortController;
|
|
1987
|
-
submitter: HTMLElement | null;
|
|
1988
|
-
cancel: () => void;
|
|
1989
|
-
}) => MaybePromise<
|
|
1990
|
-
| void
|
|
1991
|
-
| ((opts: {
|
|
1992
|
-
formData: FormData;
|
|
1993
|
-
formElement: HTMLFormElement;
|
|
1994
|
-
action: URL;
|
|
1995
|
-
result: ActionResult<Success, Failure>;
|
|
1996
|
-
/**
|
|
1997
|
-
* Call this to get the default behavior of a form submission response.
|
|
1998
|
-
* @param options Set `reset: false` if you don't want the `<form>` values to be reset after a successful submission. `refreshAll` defaults to `true` for successful results and `false` for failures. When the submission navigates, setting it to `false` still runs the destination's `load` functions but may reuse shared layout data. Set `navigate: false` to apply non-redirect results to the current page instead of navigating to `result.location`. Redirects are always followed.
|
|
1999
|
-
*/
|
|
2000
|
-
update: (options?: {
|
|
2001
|
-
reset?: boolean;
|
|
2002
|
-
refreshAll?: boolean;
|
|
2003
|
-
navigate?: boolean;
|
|
2004
|
-
/** @deprecated Use `refreshAll` instead. */
|
|
2005
|
-
invalidateAll?: boolean;
|
|
2006
|
-
}) => Promise<void>;
|
|
2007
|
-
}) => MaybePromise<void>)
|
|
2008
|
-
>;
|
|
2009
|
-
|
|
2010
1658
|
/**
|
|
2011
1659
|
* The type of `export const snapshot` exported from a page or layout component.
|
|
2012
1660
|
* @deprecated Use the [`snapshot`](https://svelte.dev/docs/kit/$app-navigation#snapshot) helper from `$app/navigation` instead.
|
|
@@ -2016,14 +1664,6 @@ export interface Snapshot<T = any> {
|
|
|
2016
1664
|
restore: (snapshot: T) => void;
|
|
2017
1665
|
}
|
|
2018
1666
|
|
|
2019
|
-
export type ReadonlyURLSearchParams = Omit<URLSearchParams, 'set' | 'append' | 'delete' | 'sort'>;
|
|
2020
|
-
|
|
2021
|
-
export type ReadonlyURL = Readonly<
|
|
2022
|
-
Omit<URL, 'searchParams'> & {
|
|
2023
|
-
searchParams: ReadonlyURLSearchParams;
|
|
2024
|
-
}
|
|
2025
|
-
>;
|
|
2026
|
-
|
|
2027
1667
|
// If T is unknown or has an index signature, the types below will recurse indefinitely and create giant unions that TS can't handle
|
|
2028
1668
|
type WillRecurseIndefinitely<T> = unknown extends T ? true : string extends keyof T ? true : false;
|
|
2029
1669
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { AssetDependencies, ManifestData,
|
|
1
|
+
/** @import { AssetDependencies, ManifestData, ValidatedKitConfig } from 'types' */
|
|
2
2
|
/** @import { Manifest, Rolldown } from 'vite' */
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import {
|
|
@@ -118,7 +118,7 @@ export function build_server_nodes(
|
|
|
118
118
|
const imports = [];
|
|
119
119
|
|
|
120
120
|
// String representation of
|
|
121
|
-
|
|
121
|
+
/* @type {SSRNode} */
|
|
122
122
|
/** @type {string[]} */
|
|
123
123
|
const exports = [`export const index = ${i};`];
|
|
124
124
|
|
|
@@ -215,8 +215,7 @@ export async function dev(
|
|
|
215
215
|
),
|
|
216
216
|
nodes: manifest_data.nodes.map((node, index) => {
|
|
217
217
|
return async () => {
|
|
218
|
-
/** @type {SSRNode} */
|
|
219
|
-
const result = {};
|
|
218
|
+
const result = /** @type {SSRNode} */ ({});
|
|
220
219
|
result.index = index;
|
|
221
220
|
result.universal_id = node.universal;
|
|
222
221
|
result.server_id = node.server;
|
|
@@ -428,7 +427,7 @@ export async function dev(
|
|
|
428
427
|
// Don't run for a single file if the whole manifest is about to get updated
|
|
429
428
|
// Unless it's a file where the trailing slash page option might have changed
|
|
430
429
|
if (timeout || !/\+(page|layout|server).*$/.test(file)) return;
|
|
431
|
-
sync.update(svelte_config, manifest_data, file, root);
|
|
430
|
+
if (!sync.update(svelte_config, manifest_data, file, root)) debounce(update_manifest);
|
|
432
431
|
});
|
|
433
432
|
|
|
434
433
|
const { appTemplate, errorTemplate, serviceWorker, hooks } = svelte_config.kit.files;
|