@sveltejs/kit 3.0.0-next.18 → 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 +77 -447
- 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 +14 -3
- 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/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 +992 -932
- 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.
|
|
@@ -950,45 +960,76 @@ export type Handle = (input: {
|
|
|
950
960
|
resolve: (event: RequestEvent, opts?: ResolveOptions) => Promise<Response>;
|
|
951
961
|
}) => MaybePromise<Response>;
|
|
952
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
|
+
|
|
953
975
|
/**
|
|
954
|
-
* The
|
|
955
|
-
*
|
|
956
|
-
*
|
|
957
|
-
*
|
|
958
|
-
*
|
|
959
|
-
* The returned object can include a `status` property to override the HTTP status code used in the response.
|
|
960
|
-
* 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).
|
|
961
981
|
*/
|
|
962
|
-
export type
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
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' }>;
|
|
968
997
|
|
|
969
998
|
/**
|
|
970
|
-
* 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).
|
|
971
1009
|
*
|
|
972
|
-
*
|
|
1010
|
+
* Make sure that this function _never_ throws an error.
|
|
973
1011
|
*/
|
|
974
|
-
export type
|
|
975
|
-
|
|
1012
|
+
export type HandleServerError<Issue extends StandardSchemaV1.Issue = StandardSchemaV1.Issue> = (
|
|
1013
|
+
input: CaughtError<Issue> & { event: RequestEvent }
|
|
1014
|
+
) => MaybePromise<AppErrorWithOptionalDefaults | VoidIfNoRequiredAppErrorProperties>;
|
|
976
1015
|
|
|
977
1016
|
/**
|
|
978
|
-
* 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.
|
|
979
1019
|
*
|
|
980
|
-
*
|
|
981
|
-
*
|
|
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).
|
|
1022
|
+
*
|
|
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).
|
|
982
1027
|
*
|
|
983
|
-
*
|
|
984
|
-
* If omitted, the status defaults to 500.
|
|
1028
|
+
* Make sure that this function _never_ throws an error.
|
|
985
1029
|
*/
|
|
986
|
-
export type HandleClientError = (
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
status: number;
|
|
990
|
-
message: string;
|
|
991
|
-
}) => MaybePromise<void | AppErrorWithOptionalStatus>;
|
|
1030
|
+
export type HandleClientError = (
|
|
1031
|
+
input: ClientCaughtError & { event: NavigationEvent }
|
|
1032
|
+
) => MaybePromise<AppErrorWithOptionalDefaults | VoidIfNoRequiredAppErrorProperties>;
|
|
992
1033
|
|
|
993
1034
|
/**
|
|
994
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`.
|
|
@@ -1214,355 +1255,6 @@ export interface NavigationEvent<
|
|
|
1214
1255
|
url: URL;
|
|
1215
1256
|
}
|
|
1216
1257
|
|
|
1217
|
-
/**
|
|
1218
|
-
* Information about the target of a specific navigation.
|
|
1219
|
-
*/
|
|
1220
|
-
export interface NavigationTarget<
|
|
1221
|
-
Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
|
|
1222
|
-
RouteId extends AppRouteId | null = AppRouteId | null
|
|
1223
|
-
> {
|
|
1224
|
-
/**
|
|
1225
|
-
* Parameters of the target page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
|
|
1226
|
-
* Is `null` if the target is not part of the SvelteKit app (could not be resolved to a route).
|
|
1227
|
-
*/
|
|
1228
|
-
params: Params | null;
|
|
1229
|
-
/**
|
|
1230
|
-
* Info about the target route
|
|
1231
|
-
*/
|
|
1232
|
-
route: {
|
|
1233
|
-
/**
|
|
1234
|
-
* 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.
|
|
1235
|
-
*/
|
|
1236
|
-
id: RouteId | null;
|
|
1237
|
-
};
|
|
1238
|
-
/**
|
|
1239
|
-
* The URL that is navigated to
|
|
1240
|
-
*/
|
|
1241
|
-
url: URL;
|
|
1242
|
-
/**
|
|
1243
|
-
* The scroll position associated with this navigation.
|
|
1244
|
-
*
|
|
1245
|
-
* For the `from` target, this is the scroll position at the moment of navigation.
|
|
1246
|
-
*
|
|
1247
|
-
* For the `to` target, this represents the scroll position that will be or was restored:
|
|
1248
|
-
* - In `beforeNavigate` and `onNavigate`, this is only available for `popstate` navigations (back/forward button)
|
|
1249
|
-
* and will be `null` for other navigation types, since the final scroll position isn't known
|
|
1250
|
-
* ahead of time.
|
|
1251
|
-
* - In `afterNavigate`, this is always the scroll position that was applied after the navigation
|
|
1252
|
-
* completed.
|
|
1253
|
-
*/
|
|
1254
|
-
scroll: { x: number; y: number } | null;
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1257
|
-
export interface GotoOptions {
|
|
1258
|
-
/**
|
|
1259
|
-
* If `true`, replaces the current history entry rather than creating a new one.
|
|
1260
|
-
* @default false
|
|
1261
|
-
*/
|
|
1262
|
-
replace?: boolean;
|
|
1263
|
-
/** @deprecated Use `replace` instead. */
|
|
1264
|
-
replaceState?: boolean;
|
|
1265
|
-
/**
|
|
1266
|
-
* If `true`, updates the URL and `page.state` without navigating.
|
|
1267
|
-
* @default false
|
|
1268
|
-
*/
|
|
1269
|
-
shallow?: boolean;
|
|
1270
|
-
/**
|
|
1271
|
-
* If `true`, resets the scroll position (to the top of the page, or to the element
|
|
1272
|
-
* matching the URL's `#hash` if there is one) and resets focus (to the `<body>`, or the
|
|
1273
|
-
* `autofocus` element if there is one) once the navigation completes.
|
|
1274
|
-
*
|
|
1275
|
-
* If `false`, the current scroll position and focused element are left alone.
|
|
1276
|
-
* @default true, or false when `shallow` is true
|
|
1277
|
-
*/
|
|
1278
|
-
reset?: boolean;
|
|
1279
|
-
/**
|
|
1280
|
-
* If `true`, reruns all `load` functions and queries of the page.
|
|
1281
|
-
* @default false
|
|
1282
|
-
*/
|
|
1283
|
-
refreshAll?: boolean;
|
|
1284
|
-
/** Causes any `load` functions to rerun if they depend on one of the URLs. */
|
|
1285
|
-
invalidate?: Array<string | URL | ((url: URL) => boolean)>;
|
|
1286
|
-
/** @deprecated Use `refreshAll` instead. */
|
|
1287
|
-
invalidateAll?: boolean;
|
|
1288
|
-
/** An optional object that will be available as `page.state`. */
|
|
1289
|
-
state?: App.PageState;
|
|
1290
|
-
/**
|
|
1291
|
-
* If `true`, `page.state` will be restored after a full page reload.
|
|
1292
|
-
* @default false
|
|
1293
|
-
*/
|
|
1294
|
-
persistState?: boolean;
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
/**
|
|
1298
|
-
* - `enter`: The app has hydrated/started
|
|
1299
|
-
* - `form`: The user submitted a `<form method="GET">`
|
|
1300
|
-
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1301
|
-
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
1302
|
-
* - `link`: Navigation was triggered by a link click
|
|
1303
|
-
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1304
|
-
*/
|
|
1305
|
-
export type NavigationType = 'enter' | 'form' | 'leave' | 'link' | 'goto' | 'popstate';
|
|
1306
|
-
|
|
1307
|
-
export interface NavigationBase {
|
|
1308
|
-
/**
|
|
1309
|
-
* The type of navigation:
|
|
1310
|
-
* - `enter`: The app has hydrated/started
|
|
1311
|
-
* - `form`: The user submitted a `<form method="GET">`
|
|
1312
|
-
* - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
|
|
1313
|
-
* - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
|
|
1314
|
-
* - `link`: Navigation was triggered by a link click
|
|
1315
|
-
* - `popstate`: Navigation was triggered by back/forward navigation
|
|
1316
|
-
*/
|
|
1317
|
-
type: NavigationType;
|
|
1318
|
-
/** Whether this is a shallow navigation. */
|
|
1319
|
-
shallow: boolean;
|
|
1320
|
-
/**
|
|
1321
|
-
* Where navigation was triggered from
|
|
1322
|
-
*/
|
|
1323
|
-
from: NavigationTarget | null;
|
|
1324
|
-
/**
|
|
1325
|
-
* Where navigation is going to/has gone to
|
|
1326
|
-
*/
|
|
1327
|
-
to: NavigationTarget | null;
|
|
1328
|
-
/**
|
|
1329
|
-
* Whether or not the navigation will result in the page being unloaded (i.e. not a client-side navigation).
|
|
1330
|
-
*/
|
|
1331
|
-
willUnload: boolean;
|
|
1332
|
-
/**
|
|
1333
|
-
* A promise that resolves once the navigation is complete, and rejects if the navigation
|
|
1334
|
-
* fails or is aborted. In the case of a `willUnload` navigation, the promise will never resolve
|
|
1335
|
-
*/
|
|
1336
|
-
complete: Promise<void>;
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
/**
|
|
1340
|
-
* The navigation that occurs when the app starts/hydrates
|
|
1341
|
-
*/
|
|
1342
|
-
export interface NavigationEnter extends NavigationBase {
|
|
1343
|
-
type: 'enter';
|
|
1344
|
-
|
|
1345
|
-
/**
|
|
1346
|
-
* In case of a history back/forward navigation, the number of steps to go back/forward
|
|
1347
|
-
*/
|
|
1348
|
-
delta?: undefined;
|
|
1349
|
-
|
|
1350
|
-
/**
|
|
1351
|
-
* Dispatched `Event` object when navigation occurred by `popstate` or `link`.
|
|
1352
|
-
*/
|
|
1353
|
-
event?: undefined;
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
export type NavigationExternal = NavigationGoto | NavigationLeave;
|
|
1357
|
-
|
|
1358
|
-
/**
|
|
1359
|
-
* A navigation triggered by a `goto(...)` call or a redirect
|
|
1360
|
-
*/
|
|
1361
|
-
export interface NavigationGoto extends NavigationBase {
|
|
1362
|
-
type: 'goto';
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
/**
|
|
1366
|
-
* A navigation triggered by the tab being closed, or the user navigating to a different document
|
|
1367
|
-
*/
|
|
1368
|
-
export interface NavigationLeave extends NavigationBase {
|
|
1369
|
-
type: 'leave';
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
/**
|
|
1373
|
-
* A navigation triggered by a `<form method="GET">`
|
|
1374
|
-
*/
|
|
1375
|
-
export interface NavigationFormSubmit extends NavigationBase {
|
|
1376
|
-
type: 'form';
|
|
1377
|
-
|
|
1378
|
-
/**
|
|
1379
|
-
* The `SubmitEvent` that caused the navigation
|
|
1380
|
-
*/
|
|
1381
|
-
event: SubmitEvent;
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
/**
|
|
1385
|
-
* A navigation triggered by back/forward navigation
|
|
1386
|
-
*/
|
|
1387
|
-
export interface NavigationPopState extends NavigationBase {
|
|
1388
|
-
type: 'popstate';
|
|
1389
|
-
|
|
1390
|
-
/**
|
|
1391
|
-
* In case of a history back/forward navigation, the number of steps to go back/forward
|
|
1392
|
-
*/
|
|
1393
|
-
delta: number;
|
|
1394
|
-
|
|
1395
|
-
/**
|
|
1396
|
-
* The `PopStateEvent` that caused the navigation
|
|
1397
|
-
*/
|
|
1398
|
-
event: PopStateEvent;
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
/**
|
|
1402
|
-
* A navigation triggered by a link click
|
|
1403
|
-
*/
|
|
1404
|
-
export interface NavigationLink extends NavigationBase {
|
|
1405
|
-
type: 'link';
|
|
1406
|
-
|
|
1407
|
-
/**
|
|
1408
|
-
* The `PointerEvent` that caused the navigation
|
|
1409
|
-
*/
|
|
1410
|
-
event: PointerEvent;
|
|
1411
|
-
}
|
|
1412
|
-
|
|
1413
|
-
export type Navigation =
|
|
1414
|
-
NavigationExternal | NavigationFormSubmit | NavigationPopState | NavigationLink;
|
|
1415
|
-
|
|
1416
|
-
/**
|
|
1417
|
-
* The argument passed to [`beforeNavigate`](https://svelte.dev/docs/kit/$app-navigation#beforeNavigate) callbacks.
|
|
1418
|
-
*/
|
|
1419
|
-
export type BeforeNavigate = Navigation & {
|
|
1420
|
-
/**
|
|
1421
|
-
* Call this to prevent the navigation from starting.
|
|
1422
|
-
*/
|
|
1423
|
-
cancel: () => void;
|
|
1424
|
-
};
|
|
1425
|
-
|
|
1426
|
-
/**
|
|
1427
|
-
* The argument passed to [`onNavigate`](https://svelte.dev/docs/kit/$app-navigation#onNavigate) callbacks.
|
|
1428
|
-
*/
|
|
1429
|
-
export type OnNavigate = Navigation & {
|
|
1430
|
-
type: Exclude<NavigationType, 'enter' | 'leave'>;
|
|
1431
|
-
/**
|
|
1432
|
-
* Since `onNavigate` callbacks are called immediately before a client-side navigation, they will never be called with a navigation that unloads the page.
|
|
1433
|
-
*/
|
|
1434
|
-
willUnload: false;
|
|
1435
|
-
};
|
|
1436
|
-
|
|
1437
|
-
/**
|
|
1438
|
-
* The argument passed to [`afterNavigate`](https://svelte.dev/docs/kit/$app-navigation#afterNavigate) callbacks.
|
|
1439
|
-
*/
|
|
1440
|
-
export type AfterNavigate = (Navigation | NavigationEnter) & {
|
|
1441
|
-
type: Exclude<NavigationType, 'leave'>;
|
|
1442
|
-
/**
|
|
1443
|
-
* Since `afterNavigate` callbacks are called after a navigation completes, they will never be called with a navigation that unloads the page.
|
|
1444
|
-
*/
|
|
1445
|
-
willUnload: false;
|
|
1446
|
-
};
|
|
1447
|
-
|
|
1448
|
-
/**
|
|
1449
|
-
* The shape of the [`page`](https://svelte.dev/docs/kit/$app-state#page) reactive object.
|
|
1450
|
-
*/
|
|
1451
|
-
export interface Page<
|
|
1452
|
-
Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
|
|
1453
|
-
RouteId extends AppRouteId | null = AppRouteId | null
|
|
1454
|
-
> {
|
|
1455
|
-
/**
|
|
1456
|
-
* The URL of the current page.
|
|
1457
|
-
*/
|
|
1458
|
-
url: ReadonlyURL & { readonly pathname: ResolvedPathname | (string & {}) };
|
|
1459
|
-
/**
|
|
1460
|
-
* The parameters of the current page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
|
|
1461
|
-
*/
|
|
1462
|
-
params: Params;
|
|
1463
|
-
/**
|
|
1464
|
-
* Info about the current route.
|
|
1465
|
-
*/
|
|
1466
|
-
route: {
|
|
1467
|
-
/**
|
|
1468
|
-
* 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.
|
|
1469
|
-
*/
|
|
1470
|
-
id: RouteId;
|
|
1471
|
-
};
|
|
1472
|
-
/**
|
|
1473
|
-
* HTTP status code of the current page.
|
|
1474
|
-
*/
|
|
1475
|
-
status: number;
|
|
1476
|
-
/**
|
|
1477
|
-
* The error object of the current page, if any. Filled from the `handleError` hooks.
|
|
1478
|
-
*/
|
|
1479
|
-
error: App.Error | null;
|
|
1480
|
-
/**
|
|
1481
|
-
* The merged result of all data from all `load` functions on the current page. You can type a common denominator through `App.PageData`.
|
|
1482
|
-
*/
|
|
1483
|
-
data: App.PageData & Record<string, any>;
|
|
1484
|
-
/**
|
|
1485
|
-
* The page state, which can be manipulated using [`goto`](https://svelte.dev/docs/kit/$app-navigation#goto) from `$app/navigation`.
|
|
1486
|
-
*/
|
|
1487
|
-
state: App.PageState;
|
|
1488
|
-
/**
|
|
1489
|
-
* Information about the target of the current shallow navigation, or `null` if no shallow navigation has occurred.
|
|
1490
|
-
*/
|
|
1491
|
-
shallow: {
|
|
1492
|
-
/** Parameters of the target route, or `null` if the URL does not resolve to a route. */
|
|
1493
|
-
params: AppLayoutParams<'/'> | null;
|
|
1494
|
-
/** Info about the target route, or `null` if the URL does not resolve to a route. */
|
|
1495
|
-
route: { id: AppRouteId } | null;
|
|
1496
|
-
/** The normalized URL passed to `goto(..., { shallow: true })`. */
|
|
1497
|
-
url: ReadonlyURL;
|
|
1498
|
-
} | null;
|
|
1499
|
-
/**
|
|
1500
|
-
* Filled only after a form submission. See [form actions](https://svelte.dev/docs/kit/form-actions) for more info.
|
|
1501
|
-
*/
|
|
1502
|
-
form: any;
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
/**
|
|
1506
|
-
* The shape of a param matcher. See [matching](https://svelte.dev/docs/kit/advanced-routing#Matching) for more info.
|
|
1507
|
-
*/
|
|
1508
|
-
export type ParamMatcher<Output = any> = StandardSchemaV1<string, Output>;
|
|
1509
|
-
|
|
1510
|
-
/**
|
|
1511
|
-
* A value that can be parsed from a URL param and losslessly encoded with `String(...)`.
|
|
1512
|
-
*/
|
|
1513
|
-
export type ParamValue = string | number | boolean | bigint;
|
|
1514
|
-
|
|
1515
|
-
/**
|
|
1516
|
-
* A param matcher definition passed to [`defineParams`](https://svelte.dev/docs/kit/@sveltejs-kit#defineParams).
|
|
1517
|
-
*/
|
|
1518
|
-
export type ParamDefinition =
|
|
1519
|
-
((param: string) => ParamValue | undefined) | StandardSchemaV1<string, ParamValue>;
|
|
1520
|
-
|
|
1521
|
-
/**
|
|
1522
|
-
* The return type of [`defineParams`](https://svelte.dev/docs/kit/@sveltejs-kit#defineParams).
|
|
1523
|
-
*/
|
|
1524
|
-
export type DefinedParams<T extends Record<string, ParamDefinition>> = {
|
|
1525
|
-
readonly [K in keyof T]: ParamEntry<T[K]>;
|
|
1526
|
-
};
|
|
1527
|
-
|
|
1528
|
-
/**
|
|
1529
|
-
* Normalizes a property of defineParams (schema or function) to standard schema.
|
|
1530
|
-
*/
|
|
1531
|
-
type ParamEntry<M> =
|
|
1532
|
-
M extends StandardSchemaV1<any, any>
|
|
1533
|
-
? StandardSchemaV1.InferOutput<M> extends ParamValue
|
|
1534
|
-
? StandardSchemaV1<any, M>
|
|
1535
|
-
: StandardSchemaV1<any, never>
|
|
1536
|
-
: M extends (param: string) => infer R
|
|
1537
|
-
? Exclude<R, undefined> extends ParamValue
|
|
1538
|
-
? StandardSchemaV1<any, Exclude<R, undefined>>
|
|
1539
|
-
: StandardSchemaV1<any, never>
|
|
1540
|
-
: never;
|
|
1541
|
-
|
|
1542
|
-
/**
|
|
1543
|
-
* Extracts the param type from a matcher.
|
|
1544
|
-
*/
|
|
1545
|
-
export type MatcherParam<M extends StandardSchemaV1<any, any>> =
|
|
1546
|
-
M extends StandardSchemaV1<any, infer Inner>
|
|
1547
|
-
? Inner extends ParamValue
|
|
1548
|
-
? Inner
|
|
1549
|
-
: Inner extends StandardSchemaV1<any, any>
|
|
1550
|
-
? StandardSchemaV1.InferOutput<Inner> extends ParamValue
|
|
1551
|
-
? StandardSchemaV1.InferOutput<Inner>
|
|
1552
|
-
: never
|
|
1553
|
-
: never
|
|
1554
|
-
: never;
|
|
1555
|
-
|
|
1556
|
-
/**
|
|
1557
|
-
* Define [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#Matching) for your app.
|
|
1558
|
-
*
|
|
1559
|
-
* @template T
|
|
1560
|
-
* @param definitions
|
|
1561
|
-
*/
|
|
1562
|
-
export function defineParams<T extends Record<string, ParamDefinition>>(
|
|
1563
|
-
definitions: T
|
|
1564
|
-
): DefinedParams<T>;
|
|
1565
|
-
|
|
1566
1258
|
/**
|
|
1567
1259
|
* A single entry yielded by [`requested`](https://svelte.dev/docs/kit/$app-server#requested)
|
|
1568
1260
|
* when called with a regular `query`. `arg` is the validated argument (the input *after*
|
|
@@ -1621,7 +1313,8 @@ export type LiveQueryRequestedResult<Validated, Output> = Iterable<
|
|
|
1621
1313
|
};
|
|
1622
1314
|
|
|
1623
1315
|
export type RequestedResult<Validated, Output> =
|
|
1624
|
-
QueryRequestedResult<Validated, Output>
|
|
1316
|
+
| QueryRequestedResult<Validated, Output>
|
|
1317
|
+
| LiveQueryRequestedResult<Validated, Output>;
|
|
1625
1318
|
|
|
1626
1319
|
export interface RequestEvent<
|
|
1627
1320
|
Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
|
|
@@ -1942,30 +1635,6 @@ export type Actions<
|
|
|
1942
1635
|
RouteId extends AppRouteId | null = AppRouteId | null
|
|
1943
1636
|
> = Record<string, Action<Params, OutputData, RouteId>>;
|
|
1944
1637
|
|
|
1945
|
-
/**
|
|
1946
|
-
* When calling a form action via fetch, the response will be one of these shapes.
|
|
1947
|
-
* ```svelte
|
|
1948
|
-
* <form method="post" use:enhance={() => {
|
|
1949
|
-
* return ({ result }) => {
|
|
1950
|
-
* // result is of type ActionResult
|
|
1951
|
-
* };
|
|
1952
|
-
* }}
|
|
1953
|
-
* ```
|
|
1954
|
-
*
|
|
1955
|
-
* Success and failure results carry the root-relative `pathname + search` of the action URL, with
|
|
1956
|
-
* the `?/actionName` parameter removed. Redirect results carry the redirect target. Server-generated
|
|
1957
|
-
* error results also carry the action location, while client-generated errors such as network
|
|
1958
|
-
* failures do not. `update` uses this location to emulate native form navigation.
|
|
1959
|
-
*/
|
|
1960
|
-
export type ActionResult<
|
|
1961
|
-
Success extends Record<string, unknown> | undefined = Record<string, any>,
|
|
1962
|
-
Failure extends Record<string, unknown> | undefined = Record<string, any>
|
|
1963
|
-
> =
|
|
1964
|
-
| { type: 'success'; status: number; data?: Success; location: string }
|
|
1965
|
-
| { type: 'failure'; status: number; data?: Failure; location: string }
|
|
1966
|
-
| { type: 'redirect'; status: number; location: string }
|
|
1967
|
-
| { type: 'error'; status?: number; error: App.Error; location?: string };
|
|
1968
|
-
|
|
1969
1638
|
/**
|
|
1970
1639
|
* The object returned by the [`error`](https://svelte.dev/docs/kit/@sveltejs-kit#error) function.
|
|
1971
1640
|
*/
|
|
@@ -1986,37 +1655,6 @@ export interface Redirect {
|
|
|
1986
1655
|
location: string;
|
|
1987
1656
|
}
|
|
1988
1657
|
|
|
1989
|
-
export type SubmitFunction<
|
|
1990
|
-
Success extends Record<string, unknown> | undefined = Record<string, any>,
|
|
1991
|
-
Failure extends Record<string, unknown> | undefined = Record<string, any>
|
|
1992
|
-
> = (input: {
|
|
1993
|
-
action: URL;
|
|
1994
|
-
formData: FormData;
|
|
1995
|
-
formElement: HTMLFormElement;
|
|
1996
|
-
controller: AbortController;
|
|
1997
|
-
submitter: HTMLElement | null;
|
|
1998
|
-
cancel: () => void;
|
|
1999
|
-
}) => MaybePromise<
|
|
2000
|
-
| void
|
|
2001
|
-
| ((opts: {
|
|
2002
|
-
formData: FormData;
|
|
2003
|
-
formElement: HTMLFormElement;
|
|
2004
|
-
action: URL;
|
|
2005
|
-
result: ActionResult<Success, Failure>;
|
|
2006
|
-
/**
|
|
2007
|
-
* Call this to get the default behavior of a form submission response.
|
|
2008
|
-
* @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.
|
|
2009
|
-
*/
|
|
2010
|
-
update: (options?: {
|
|
2011
|
-
reset?: boolean;
|
|
2012
|
-
refreshAll?: boolean;
|
|
2013
|
-
navigate?: boolean;
|
|
2014
|
-
/** @deprecated Use `refreshAll` instead. */
|
|
2015
|
-
invalidateAll?: boolean;
|
|
2016
|
-
}) => Promise<void>;
|
|
2017
|
-
}) => MaybePromise<void>)
|
|
2018
|
-
>;
|
|
2019
|
-
|
|
2020
1658
|
/**
|
|
2021
1659
|
* The type of `export const snapshot` exported from a page or layout component.
|
|
2022
1660
|
* @deprecated Use the [`snapshot`](https://svelte.dev/docs/kit/$app-navigation#snapshot) helper from `$app/navigation` instead.
|
|
@@ -2026,14 +1664,6 @@ export interface Snapshot<T = any> {
|
|
|
2026
1664
|
restore: (snapshot: T) => void;
|
|
2027
1665
|
}
|
|
2028
1666
|
|
|
2029
|
-
export type ReadonlyURLSearchParams = Omit<URLSearchParams, 'set' | 'append' | 'delete' | 'sort'>;
|
|
2030
|
-
|
|
2031
|
-
export type ReadonlyURL = Readonly<
|
|
2032
|
-
Omit<URL, 'searchParams'> & {
|
|
2033
|
-
searchParams: ReadonlyURLSearchParams;
|
|
2034
|
-
}
|
|
2035
|
-
>;
|
|
2036
|
-
|
|
2037
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
|
|
2038
1668
|
type WillRecurseIndefinitely<T> = unknown extends T ? true : string extends keyof T ? true : false;
|
|
2039
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;
|
|
@@ -555,7 +555,18 @@ function kit({ svelte_config }) {
|
|
|
555
555
|
|
|
556
556
|
// These Kit dependencies are packaged as CommonJS, which means they must always be externalized.
|
|
557
557
|
// Without this, the tests will still pass but `pnpm dev` will fail in projects that link `@sveltejs/kit`.
|
|
558
|
-
|
|
558
|
+
//
|
|
559
|
+
// `@opentelemetry/api` must be externalized so that `instrumentation.server.js` and the
|
|
560
|
+
// SvelteKit runtime share a single instance of the module (the global tracer/propagation
|
|
561
|
+
// is set on that instance — two bundled copies would mean instrumentation hooks are
|
|
562
|
+
// invisible to the runtime). Externalizing also prevents the bundler from colocating
|
|
563
|
+
// `@opentelemetry/api` into a shared chunk that also contains application modules, which
|
|
564
|
+
// would cause those modules to be evaluated before `Server.init()` sets env vars — see
|
|
565
|
+
// https://github.com/sveltejs/kit/issues/16288
|
|
566
|
+
/** @type {NonNullable<UserConfig['ssr']>} */ (new_config.ssr).external = [
|
|
567
|
+
'cookie',
|
|
568
|
+
'@opentelemetry/api'
|
|
569
|
+
];
|
|
559
570
|
}
|
|
560
571
|
|
|
561
572
|
// Vite's `define` is a compile-time text replacement, but Vitest strips
|
|
@@ -1218,8 +1229,8 @@ function kit({ svelte_config }) {
|
|
|
1218
1229
|
generateBundle(_, bundle) {
|
|
1219
1230
|
const invalid_modules = new Set();
|
|
1220
1231
|
const modules = new Map([
|
|
1221
|
-
[`${runtime_directory}/app/forms.js`, '$app/forms'],
|
|
1222
|
-
[`${runtime_directory}/app/navigation.js`, '$app/navigation'],
|
|
1232
|
+
[`${runtime_directory}/app/forms/index.js`, '$app/forms'],
|
|
1233
|
+
[`${runtime_directory}/app/navigation/index.js`, '$app/navigation'],
|
|
1223
1234
|
[`${runtime_directory}/app/state/index.js`, '$app/state']
|
|
1224
1235
|
]);
|
|
1225
1236
|
|