@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.
Files changed (83) hide show
  1. package/package.json +12 -5
  2. package/src/cli.js +1 -1
  3. package/src/constants.js +3 -0
  4. package/src/core/config/index.js +1 -1
  5. package/src/core/env.js +1 -1
  6. package/src/core/postbuild/analyse.js +1 -1
  7. package/src/core/postbuild/prerender.js +1 -1
  8. package/src/core/sync/create_manifest_data/index.js +9 -0
  9. package/src/core/sync/sync.js +22 -9
  10. package/src/core/sync/ts.js +1 -1
  11. package/src/core/sync/write_app_types.js +1 -1
  12. package/src/core/sync/write_client_manifest.js +1 -1
  13. package/src/core/sync/write_server.js +1 -3
  14. package/src/core/sync/write_tsconfig/index.js +1 -1
  15. package/src/core/sync/write_types/index.js +6 -3
  16. package/src/exports/index.js +9 -9
  17. package/src/exports/internal/server/event.js +1 -1
  18. package/src/exports/internal/server/telemetry.js +1 -1
  19. package/src/exports/internal/shared.js +9 -0
  20. package/src/exports/{params.js → params/index.js} +6 -4
  21. package/src/exports/params/public.d.ts +63 -0
  22. package/src/exports/public.d.ts +77 -447
  23. package/src/exports/vite/build/build_server.js +2 -2
  24. package/src/exports/vite/dev/index.js +2 -3
  25. package/src/exports/vite/index.js +14 -3
  26. package/src/pathname.js +55 -0
  27. package/src/runtime/app/{forms.js → forms/index.js} +9 -8
  28. package/src/runtime/app/forms/public.d.ts +2 -0
  29. package/src/runtime/app/forms/types.d.ts +56 -0
  30. package/src/runtime/app/{navigation.js → navigation/index.js} +2 -2
  31. package/src/runtime/app/navigation/public.d.ts +237 -0
  32. package/src/runtime/app/paths/client.js +14 -8
  33. package/src/runtime/app/paths/index.js +1 -1
  34. package/src/runtime/app/paths/internal/client.js +4 -0
  35. package/src/runtime/app/paths/internal/server.js +4 -0
  36. package/src/runtime/app/paths/internal.d.ts +3 -0
  37. package/src/runtime/app/paths/public.d.ts +1 -1
  38. package/src/runtime/app/paths/server.js +6 -4
  39. package/src/runtime/app/server/index.js +1 -1
  40. package/src/runtime/app/server/remote/form.js +3 -4
  41. package/src/runtime/app/server/remote/prerender.js +3 -3
  42. package/src/runtime/app/server/remote/shared.js +3 -10
  43. package/src/runtime/app/state/index.js +4 -2
  44. package/src/runtime/app/state/public.d.ts +72 -0
  45. package/src/runtime/app/stores.js +2 -2
  46. package/src/runtime/client/client.js +65 -54
  47. package/src/runtime/client/entry.js +2 -2
  48. package/src/runtime/client/remote-functions/command.svelte.js +36 -34
  49. package/src/runtime/client/remote-functions/form.svelte.js +76 -78
  50. package/src/runtime/client/remote-functions/prerender.svelte.js +3 -3
  51. package/src/runtime/client/remote-functions/query/index.js +1 -1
  52. package/src/runtime/client/remote-functions/query/instance.svelte.js +4 -3
  53. package/src/runtime/client/remote-functions/query-batch.svelte.js +3 -3
  54. package/src/runtime/client/remote-functions/query-live/instance.svelte.js +5 -5
  55. package/src/runtime/client/remote-functions/query-live/iterator.js +5 -7
  56. package/src/runtime/client/remote-functions/shared.svelte.js +9 -14
  57. package/src/runtime/client/state.svelte.js +5 -3
  58. package/src/runtime/client/types.d.ts +2 -1
  59. package/src/runtime/pathname.js +6 -61
  60. package/src/runtime/props.svelte.js +1 -1
  61. package/src/runtime/server/constants.js +0 -3
  62. package/src/runtime/server/errors.js +53 -28
  63. package/src/runtime/server/fetch.js +1 -1
  64. package/src/runtime/server/index.js +9 -14
  65. package/src/runtime/server/page/actions.js +2 -1
  66. package/src/runtime/server/page/index.js +7 -3
  67. package/src/runtime/server/page/load_data.js +1 -1
  68. package/src/runtime/server/page/render.js +17 -11
  69. package/src/runtime/server/page/server_routing.js +3 -2
  70. package/src/runtime/server/remote-functions.js +3 -2
  71. package/src/runtime/server/respond.js +4 -8
  72. package/src/runtime/server/state.js +3 -6
  73. package/src/types/ambient.d.ts +1 -1
  74. package/src/types/internal.d.ts +8 -10
  75. package/src/types/private.d.ts +12 -3
  76. package/src/utils/error.js +30 -14
  77. package/src/utils/page_nodes.js +3 -2
  78. package/src/utils/params.js +3 -2
  79. package/src/utils/routing.js +5 -4
  80. package/src/version.js +1 -1
  81. package/types/index.d.ts +992 -932
  82. package/types/index.d.ts.map +43 -31
  83. /package/src/{runtime/telemetry/noop.js → telemetry.js} +0 -0
@@ -0,0 +1,72 @@
1
+ import type {
2
+ LayoutParams as AppLayoutParams,
3
+ ResolvedPathname,
4
+ RouteId as AppRouteId
5
+ } from '$app/types';
6
+
7
+ export * from './index.js';
8
+
9
+ export type ReadonlyURLSearchParams = Omit<URLSearchParams, 'set' | 'append' | 'delete' | 'sort'>;
10
+
11
+ export type ReadonlyURL = Readonly<
12
+ Omit<URL, 'searchParams'> & {
13
+ searchParams: ReadonlyURLSearchParams;
14
+ }
15
+ >;
16
+
17
+ /**
18
+ * The shape of the [`page`](https://svelte.dev/docs/kit/$app-state#page) reactive object.
19
+ */
20
+ export interface Page<
21
+ Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
22
+ RouteId extends AppRouteId | null = AppRouteId | null
23
+ > {
24
+ /**
25
+ * The URL of the current page.
26
+ */
27
+ url: ReadonlyURL & { readonly pathname: ResolvedPathname | (string & {}) };
28
+ /**
29
+ * The parameters of the current page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
30
+ */
31
+ params: Params;
32
+ /**
33
+ * Info about the current route.
34
+ */
35
+ route: {
36
+ /**
37
+ * 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.
38
+ */
39
+ id: RouteId;
40
+ };
41
+ /**
42
+ * HTTP status code of the current page.
43
+ */
44
+ status: number;
45
+ /**
46
+ * The error object of the current page, if any. Filled from the `handleError` hooks.
47
+ */
48
+ error: App.Error | null;
49
+ /**
50
+ * The merged result of all data from all `load` functions on the current page. You can type a common denominator through `App.PageData`.
51
+ */
52
+ data: App.PageData & Record<string, any>;
53
+ /**
54
+ * The page state, which can be manipulated using [`goto`](https://svelte.dev/docs/kit/$app-navigation#goto) from `$app/navigation`.
55
+ */
56
+ state: App.PageState;
57
+ /**
58
+ * Information about the target of the current shallow navigation, or `null` if no shallow navigation has occurred.
59
+ */
60
+ shallow: {
61
+ /** Parameters of the target route, or `null` if the URL does not resolve to a route. */
62
+ params: AppLayoutParams<'/'> | null;
63
+ /** Info about the target route, or `null` if the URL does not resolve to a route. */
64
+ route: { id: AppRouteId } | null;
65
+ /** The normalized URL passed to `goto(..., { shallow: true })`. */
66
+ url: ReadonlyURL;
67
+ } | null;
68
+ /**
69
+ * Filled only after a form submission. See [form actions](https://svelte.dev/docs/kit/form-actions) for more info.
70
+ */
71
+ form: any;
72
+ }
@@ -14,7 +14,7 @@ export const getStores = removed;
14
14
 
15
15
  /**
16
16
  * @deprecated Use `page` from `$app/state` instead (requires Svelte 5, [see docs for more info](https://svelte.dev/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated))
17
- * @type {import('svelte/store').Readable<import('@sveltejs/kit').Page>}
17
+ * @type {import('svelte/store').Readable<import('$app/state').Page>}
18
18
  */
19
19
  export const page = {
20
20
  subscribe: removed
@@ -22,7 +22,7 @@ export const page = {
22
22
 
23
23
  /**
24
24
  * @deprecated Use `navigating` from `$app/state` instead (requires Svelte 5, [see docs for more info](https://svelte.dev/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated))
25
- * @type {import('svelte/store').Readable<import('@sveltejs/kit').Navigation | null>}
25
+ * @type {import('svelte/store').Readable<import('$app/navigation').Navigation | null>}
26
26
  */
27
27
  export const navigating = {
28
28
  subscribe: removed
@@ -1,4 +1,6 @@
1
- /** @import { RouteId } from '$app/types' */
1
+ /** @import { LoadEvent, NavigationEvent } from '@sveltejs/kit' */
2
+ /** @import { ActionResult } from '$app/forms' */
3
+ /** @import { AfterNavigate, BeforeNavigate, GotoOptions, Navigation, NavigationTarget, NavigationType, OnNavigate } from '$app/navigation' */
2
4
  /** @import { RemoteFunctionDataNode, ServerNodesResponse, ServerRedirectNode } from 'types' */
3
5
  /** @import { NavigationFinished, NavigationIntent } from './types.js' */
4
6
  /** @import { CacheEntry } from './remote-functions/cache.svelte.js' */
@@ -6,7 +8,7 @@
6
8
  /** @import { LiveQuery } from './remote-functions/query-live/instance.svelte.js' */
7
9
  import { BROWSER, DEV } from 'esm-env';
8
10
  import { settled, tick, fork, onMount, hydrate, mount } from 'svelte';
9
- import { HttpError, Redirect, SvelteKitError } from '@sveltejs/kit/internal';
11
+ import { HttpError, Redirect, SvelteKitError, HandledHttpError } from '@sveltejs/kit/internal';
10
12
  import { decode_pathname, strip_hash, make_trackable, normalize_path } from '../../utils/url.js';
11
13
  import { dev_fetch, initial_fetch, lock_fetch, subsequent_fetch, unlock_fetch } from './fetcher.js';
12
14
  import { parse_routes, parse_server_route } from './parse.js';
@@ -21,7 +23,7 @@ import {
21
23
  scroll_state,
22
24
  load_css
23
25
  } from './utils.js';
24
- import { base, app_dir, set_match_implementation } from '$app/paths/internal/client';
26
+ import { base, set_match_implementation } from '$app/paths/internal/client';
25
27
  import * as devalue from 'devalue';
26
28
  import {
27
29
  HISTORY_INFO_KEY,
@@ -38,6 +40,7 @@ import {
38
40
  restore_navigation_snapshot
39
41
  } from './snapshots.js';
40
42
  import { validate_page_exports } from '../../utils/exports.js';
43
+ import { add_deprecated_handle_error_properties } from '../../utils/error.js';
41
44
  import { noop } from '../../utils/functions.js';
42
45
  import {
43
46
  INVALIDATED_PARAM,
@@ -46,7 +49,7 @@ import {
46
49
  validate_depends,
47
50
  validate_load_response
48
51
  } from '../shared.js';
49
- import { get_message, get_status } from '../../utils/error.js';
52
+
50
53
  import { page, navigating, updated, notify_version } from './state.svelte.js';
51
54
  import { payload } from './payload.js';
52
55
  import {
@@ -54,7 +57,7 @@ import {
54
57
  add_resolution_suffix,
55
58
  route_id_resolution_pathname
56
59
  } from '../pathname.js';
57
- import { noop_span } from '../telemetry/noop.js';
60
+ import { noop_span } from '../../telemetry.js';
58
61
  import { read_ndjson } from './ndjson.js';
59
62
  import Root from '../components/root.svelte';
60
63
  import { Props, RenderNode } from '../props.svelte.js';
@@ -346,16 +349,16 @@ function parse_and_cache_server_route(server_route) {
346
349
  * Note on before_navigate_callbacks, on_navigate_callbacks and after_navigate_callbacks:
347
350
  * do not re-assign as some closures keep references to these Sets
348
351
  */
349
- /** @type {Set<(navigation: import('@sveltejs/kit').BeforeNavigate) => void>} */
352
+ /** @type {Set<(navigation: BeforeNavigate) => void>} */
350
353
  const before_navigate_callbacks = new Set();
351
354
 
352
- /** @type {Set<(navigation: import('@sveltejs/kit').OnNavigate) => import('types').MaybePromise<(() => void) | void>>} */
355
+ /** @type {Set<(navigation: OnNavigate) => import('types').MaybePromise<(() => void) | void>>} */
353
356
  const on_navigate_callbacks = new Set();
354
357
 
355
- /** @type {Set<(navigation: import('@sveltejs/kit').AfterNavigate) => void>} */
358
+ /** @type {Set<(navigation: AfterNavigate) => void>} */
356
359
  const after_navigate_callbacks = new Set();
357
360
 
358
- /** @type {import('./types.js').NavigationState & { nav: import('@sveltejs/kit').NavigationEvent }} */
361
+ /** @type {import('./types.js').NavigationState & { nav: NavigationEvent }} */
359
362
  let current = {
360
363
  branch: [],
361
364
  error: null,
@@ -440,7 +443,7 @@ set_match_implementation(async (url) => {
440
443
 
441
444
  if (intent) {
442
445
  return {
443
- id: /** @type {RouteId} */ (intent.route.id),
446
+ id: /** @type {import('$app/types').RouteId} */ (intent.route.id),
444
447
  params: intent.params
445
448
  };
446
449
  }
@@ -727,7 +730,7 @@ function persist_state() {
727
730
 
728
731
  /**
729
732
  * @param {string | URL} url
730
- * @param {{ type?: import('@sveltejs/kit').NavigationType; replace?: boolean; reset?: boolean; refreshAll?: boolean; invalidate?: Array<string | URL | ((url: URL) => boolean)>; state?: Record<string, any>; persistState?: boolean; event?: Event; action_result?: import('@sveltejs/kit').ActionResult }} [options]
733
+ * @param {{ type?: NavigationType; replace?: boolean; reset?: boolean; refreshAll?: boolean; invalidate?: Array<string | URL | ((url: URL) => boolean)>; state?: Record<string, any>; persistState?: boolean; event?: Event; action_result?: ActionResult }} [options]
731
734
  * @param {number} [redirect_count]
732
735
  * @param {{}} [nav_token]
733
736
  * @param {NavigationIntent | undefined} [intent] navigation intent, when already known by the caller (avoids recomputing it)
@@ -868,7 +871,7 @@ async function load_route_by_id(id) {
868
871
  try {
869
872
  module = await import(
870
873
  /* @vite-ignore */
871
- base + route_id_resolution_pathname(app_dir, id)
874
+ base + route_id_resolution_pathname(id)
872
875
  );
873
876
  } catch {
874
877
  // if there's no module at that path the response is a 404 (or, on a static
@@ -922,7 +925,7 @@ async function initialize(result, target, should_hydrate) {
922
925
  if (__SVELTEKIT_DEV__ && result.state.error && document.querySelector('vite-error-overlay'))
923
926
  return;
924
927
 
925
- /** @type {import('@sveltejs/kit').NavigationEvent} */
928
+ /** @type {NavigationEvent} */
926
929
  const nav = {
927
930
  params: current.params,
928
931
  route: { id: current.route?.id ?? null },
@@ -961,7 +964,7 @@ async function initialize(result, target, should_hydrate) {
961
964
  void (await Promise.resolve());
962
965
 
963
966
  if (should_hydrate) {
964
- /** @type {import('@sveltejs/kit').AfterNavigate} */
967
+ /** @type {AfterNavigate} */
965
968
  const navigation = {
966
969
  from: null,
967
970
  to: {
@@ -1184,7 +1187,7 @@ async function load_node({ loader, parent, url, params, route, server_data_node
1184
1187
  }
1185
1188
  }
1186
1189
 
1187
- /** @type {import('@sveltejs/kit').LoadEvent} */
1190
+ /** @type {LoadEvent} */
1188
1191
  const load_input = {
1189
1192
  tracing: { enabled: false, root: noop_span, current: noop_span },
1190
1193
  route: new Proxy(route, {
@@ -1398,7 +1401,7 @@ function diff_search_params(old_url, new_url) {
1398
1401
 
1399
1402
  /**
1400
1403
  * @overload
1401
- * @param {import('./types.js').NavigationIntent & { action_result?: import('@sveltejs/kit').ActionResult }} intent
1404
+ * @param {import('./types.js').NavigationIntent & { action_result?: ActionResult }} intent
1402
1405
  * @returns {Promise<import('./types.js').NavigationResult | undefined>}
1403
1406
  */
1404
1407
  /**
@@ -1407,7 +1410,7 @@ function diff_search_params(old_url, new_url) {
1407
1410
  * @returns {Promise<import('./types.js').NavigationResult>}
1408
1411
  */
1409
1412
  /**
1410
- * @param {import('./types.js').NavigationIntent & { preload?: {}; action_result?: import('@sveltejs/kit').ActionResult }} intent
1413
+ * @param {import('./types.js').NavigationIntent & { preload?: {}; action_result?: ActionResult }} intent
1411
1414
  * @returns {Promise<import('./types.js').NavigationResult | undefined>}
1412
1415
  */
1413
1416
  async function load_route({ id, invalidating, url, params, route, preload, action_result }) {
@@ -1517,7 +1520,7 @@ async function load_route({ id, invalidating, url, params, route, preload, actio
1517
1520
 
1518
1521
  if (server_data_node?.type === 'error') {
1519
1522
  // rethrow and catch below
1520
- throw new HttpError(server_data_node.error);
1523
+ throw new HandledHttpError(server_data_node.error);
1521
1524
  }
1522
1525
 
1523
1526
  return load_node({
@@ -1572,7 +1575,7 @@ async function load_route({ id, invalidating, url, params, route, preload, actio
1572
1575
  // the client error handler; it should've already been handled on the server
1573
1576
  error = /** @type {import('types').ServerErrorNode} */ (err).error;
1574
1577
  } else if (err instanceof HttpError) {
1575
- error = err.body;
1578
+ error = await handle_error(err, { params, url, route: { id: route.id } });
1576
1579
  } else {
1577
1580
  // Referenced node could have been removed due to redeploy, check
1578
1581
  if (await updated.check()) {
@@ -1916,7 +1919,7 @@ function get_page_key(url) {
1916
1919
  /**
1917
1920
  * @param {{
1918
1921
  * url: URL;
1919
- * type: import('@sveltejs/kit').Navigation["type"];
1922
+ * type: Navigation["type"];
1920
1923
  * intent?: import('./types.js').NavigationIntent;
1921
1924
  * delta?: number;
1922
1925
  * event?: PopStateEvent | MouseEvent;
@@ -1960,7 +1963,7 @@ function _before_navigate({ url, type, intent, delta, event, scroll, shallow = f
1960
1963
 
1961
1964
  /**
1962
1965
  * @param {{
1963
- * type: import('@sveltejs/kit').NavigationType;
1966
+ * type: NavigationType;
1964
1967
  * url: URL;
1965
1968
  * popped?: {
1966
1969
  * state: Record<string, any>;
@@ -1978,7 +1981,7 @@ function _before_navigate({ url, type, intent, delta, event, scroll, shallow = f
1978
1981
  * block?: () => void;
1979
1982
  * event?: Event;
1980
1983
  * intent?: NavigationIntent | undefined;
1981
- * action_result?: import('@sveltejs/kit').ActionResult;
1984
+ * action_result?: ActionResult;
1982
1985
  * }} opts
1983
1986
  * @returns {Promise<void>}
1984
1987
  */
@@ -2205,9 +2208,7 @@ async function navigate({
2205
2208
  const after_navigate = (
2206
2209
  await Promise.all(
2207
2210
  // eslint-disable-next-line @typescript-eslint/await-thenable -- we need to await because they can be asynchronous
2208
- Array.from(on_navigate_callbacks, (fn) =>
2209
- fn(/** @type {import('@sveltejs/kit').OnNavigate} */ (nav.navigation))
2210
- )
2211
+ Array.from(on_navigate_callbacks, (fn) => fn(/** @type {OnNavigate} */ (nav.navigation)))
2211
2212
  )
2212
2213
  ).filter(/** @returns {value is () => void} */ (value) => typeof value === 'function');
2213
2214
 
@@ -2232,7 +2233,7 @@ async function navigate({
2232
2233
  route: { id: navigation_result.state.route?.id ?? null },
2233
2234
  url: navigation_result.state.url
2234
2235
  }
2235
- : /** @type {import('@sveltejs/kit').NavigationTarget} */ (nav.navigation.to);
2236
+ : /** @type {NavigationTarget} */ (nav.navigation.to);
2236
2237
  current = {
2237
2238
  ...navigation_result.state,
2238
2239
  nav: {
@@ -2302,9 +2303,7 @@ async function navigate({
2302
2303
  nav.navigation.to.scroll = scroll_state();
2303
2304
  }
2304
2305
 
2305
- after_navigate_callbacks.forEach((fn) =>
2306
- fn(/** @type {import('@sveltejs/kit').AfterNavigate} */ (nav.navigation))
2307
- );
2306
+ after_navigate_callbacks.forEach((fn) => fn(/** @type {AfterNavigate} */ (nav.navigation)));
2308
2307
 
2309
2308
  if (type === 'popstate') {
2310
2309
  restore_snapshot(current_navigation_index);
@@ -2511,24 +2510,41 @@ function setup_preload() {
2511
2510
 
2512
2511
  /**
2513
2512
  * @param {unknown} error
2514
- * @param {import('@sveltejs/kit').NavigationEvent} event
2513
+ * @param {NavigationEvent} event
2515
2514
  * @returns {Promise<App.Error>}
2516
2515
  */
2517
2516
  export async function handle_error(error, event) {
2518
- if (error instanceof HttpError) {
2517
+ if (error instanceof HandledHttpError) {
2519
2518
  return error.body;
2520
2519
  }
2521
2520
 
2522
- if (DEV) {
2521
+ /** @type {import('@sveltejs/kit').ClientCaughtError} */
2522
+ let caught;
2523
+
2524
+ if (error instanceof HttpError) {
2525
+ caught = { kind: 'app', error: error.body };
2526
+ } else if (error instanceof SvelteKitError) {
2527
+ caught = { kind: 'framework', error: { status: error.status, message: error.text } };
2528
+ } else {
2529
+ caught = { kind: 'unknown', error };
2530
+ }
2531
+
2532
+ if (DEV && caught.kind !== 'app') {
2523
2533
  errored = true;
2524
2534
  console.warn('The next HMR update will cause the page to reload');
2525
2535
  }
2526
2536
 
2527
- const status = get_status(error);
2528
- const message = get_message(error);
2529
- const app_error = (await app.hooks.handleError({ error, event, status, message })) ?? { message };
2537
+ const fallback =
2538
+ caught.kind === 'unknown' ? { status: 500, message: 'Internal Error' } : caught.error;
2530
2539
 
2531
- return { ...app_error, status: get_status(app_error, error) };
2540
+ const input = { ...caught, event };
2541
+ if (DEV) add_deprecated_handle_error_properties(input, fallback);
2542
+
2543
+ const app_error = await app.hooks.handleError(input);
2544
+
2545
+ // the hook returns only the properties it wants to override; anything it omits
2546
+ // (including by returning nothing at all) is inherited from the caught error
2547
+ return { ...fallback, ...app_error };
2532
2548
  }
2533
2549
 
2534
2550
  /**
@@ -2550,7 +2566,7 @@ function add_navigation_callback(callbacks, callback) {
2550
2566
  * A lifecycle function that runs the supplied `callback` when the current component mounts, and also whenever we navigate to a URL.
2551
2567
  *
2552
2568
  * `afterNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
2553
- * @param {(navigation: import('@sveltejs/kit').AfterNavigate) => void} callback
2569
+ * @param {(navigation: AfterNavigate) => void} callback
2554
2570
  * @returns {void}
2555
2571
  */
2556
2572
  export function afterNavigate(callback) {
@@ -2567,7 +2583,7 @@ export function afterNavigate(callback) {
2567
2583
  * 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`.
2568
2584
  *
2569
2585
  * `beforeNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
2570
- * @param {(navigation: import('@sveltejs/kit').BeforeNavigate) => void} callback
2586
+ * @param {(navigation: BeforeNavigate) => void} callback
2571
2587
  * @returns {void}
2572
2588
  */
2573
2589
  export function beforeNavigate(callback) {
@@ -2582,7 +2598,7 @@ export function beforeNavigate(callback) {
2582
2598
  * 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.
2583
2599
  *
2584
2600
  * `onNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
2585
- * @param {(navigation: import('@sveltejs/kit').OnNavigate) => import('types').MaybePromise<(() => void) | void>} callback
2601
+ * @param {(navigation: OnNavigate) => import('types').MaybePromise<(() => void) | void>} callback
2586
2602
  * @returns {void}
2587
2603
  */
2588
2604
  export function onNavigate(callback) {
@@ -2651,7 +2667,7 @@ async function resolve_intent(url, caller) {
2651
2667
  * For external URLs, use `window.location = url` to perform a full-page navigation instead of calling `goto(url)`.
2652
2668
  *
2653
2669
  * @param {string | URL} 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.
2654
- * @param {import('@sveltejs/kit').GotoOptions} [opts] Options related to the navigation
2670
+ * @param {GotoOptions} [opts] Options related to the navigation
2655
2671
  * @returns {Promise<void>}
2656
2672
  */
2657
2673
  export async function goto(url, opts = {}) {
@@ -2852,7 +2868,7 @@ export async function preloadData(href) {
2852
2868
  * Unlike `preloadData`, this won't call `load` functions.
2853
2869
  * Returns a Promise that resolves when the modules have been imported.
2854
2870
  *
2855
- * @param {RouteId} id
2871
+ * @param {import('$app/types').RouteId} id
2856
2872
  * @returns {Promise<void>}
2857
2873
  */
2858
2874
  export async function preloadCode(id) {
@@ -3033,9 +3049,7 @@ async function update_state(intent, state, { replace, persist_state, reset }, ca
3033
3049
  const after_navigate = (
3034
3050
  await Promise.all(
3035
3051
  // eslint-disable-next-line @typescript-eslint/await-thenable -- we need to await because they can be asynchronous
3036
- Array.from(on_navigate_callbacks, (fn) =>
3037
- fn(/** @type {import('@sveltejs/kit').OnNavigate} */ (nav.navigation))
3038
- )
3052
+ Array.from(on_navigate_callbacks, (fn) => fn(/** @type {OnNavigate} */ (nav.navigation)))
3039
3053
  )
3040
3054
  ).filter(/** @returns {value is () => void} */ (value) => typeof value === 'function');
3041
3055
 
@@ -3078,9 +3092,7 @@ async function update_state(intent, state, { replace, persist_state, reset }, ca
3078
3092
  nav.navigation.to.scroll = scroll_state();
3079
3093
  }
3080
3094
 
3081
- after_navigate_callbacks.forEach((fn) =>
3082
- fn(/** @type {import('@sveltejs/kit').AfterNavigate} */ (nav.navigation))
3083
- );
3095
+ after_navigate_callbacks.forEach((fn) => fn(/** @type {AfterNavigate} */ (nav.navigation)));
3084
3096
  }
3085
3097
 
3086
3098
  restore_navigation_snapshot(current_history_index, previous_snapshot_registrations);
@@ -3097,7 +3109,7 @@ async function update_state(intent, state, { replace, persist_state, reset }, ca
3097
3109
  * the redirect location.
3098
3110
  * @template {Record<string, unknown> | undefined} Success
3099
3111
  * @template {Record<string, unknown> | undefined} Failure
3100
- * @param {import('@sveltejs/kit').ActionResult<Success, Failure>} result
3112
+ * @param {ActionResult<Success, Failure>} result
3101
3113
  * @returns {Promise<void>}
3102
3114
  */
3103
3115
  export async function applyAction(result) {
@@ -3164,7 +3176,7 @@ export function is_current_location(value) {
3164
3176
  * Navigate to where a form submission should land, rendering that page with the given result
3165
3177
  * — what the browser would do for a native submission.
3166
3178
  * @param {string} location
3167
- * @param {import('@sveltejs/kit').ActionResult} result
3179
+ * @param {ActionResult} result
3168
3180
  * @param {boolean} refresh_all
3169
3181
  * @returns {Promise<void>}
3170
3182
  */
@@ -3221,7 +3233,7 @@ function _start_router() {
3221
3233
 
3222
3234
  // If we're navigating, beforeNavigate was already called. If we end up in here during navigation,
3223
3235
  // it's due to an external or full-page-reload link, for which we don't want to call the hook again.
3224
- /** @type {import('@sveltejs/kit').BeforeNavigate} */
3236
+ /** @type {BeforeNavigate} */
3225
3237
  const navigation = {
3226
3238
  ...nav.navigation,
3227
3239
  cancel: () => {
@@ -3725,7 +3737,6 @@ async function load_data(url, invalid) {
3725
3737
  notify_version(res.headers.get('x-sveltekit-version'));
3726
3738
 
3727
3739
  if (!res.ok) {
3728
- // turn it into a HttpError to not call handleError on the client again (was already handled on the server)
3729
3740
  // if `__data.json` doesn't exist or the server has an internal error,
3730
3741
  // avoid parsing the HTML error page as a JSON
3731
3742
  /** @type {App.Error} */
@@ -3737,7 +3748,7 @@ async function load_data(url, invalid) {
3737
3748
  error.message = 'Not Found';
3738
3749
  }
3739
3750
 
3740
- throw new HttpError(error);
3751
+ throw new HandledHttpError(error);
3741
3752
  }
3742
3753
 
3743
3754
  return new Promise((resolve, reject) => {
@@ -3924,7 +3935,7 @@ function reset_focus(url, scroll = true) {
3924
3935
  }
3925
3936
 
3926
3937
  /**
3927
- * @template {import('@sveltejs/kit').NavigationType} T
3938
+ * @template {NavigationType} T
3928
3939
  * @param {import('./types.js').NavigationState} current
3929
3940
  * @param {import('./types.js').NavigationIntent | undefined} intent
3930
3941
  * @param {URL | null} url
@@ -3956,7 +3967,7 @@ function create_navigation(
3956
3967
  // Handle any errors off-chain so that it doesn't show up as an unhandled rejection
3957
3968
  complete.catch(noop);
3958
3969
 
3959
- /** @type {(import('@sveltejs/kit').Navigation | import('@sveltejs/kit').AfterNavigate) & { type: T }} */
3970
+ /** @type {(Navigation | AfterNavigate) & { type: T }} */
3960
3971
  const navigation = /** @type {any} */ ({
3961
3972
  from: {
3962
3973
  params: current.params,
@@ -13,12 +13,12 @@ export function init(payload) {
13
13
  client ??= import('./client-entry.js');
14
14
  }
15
15
 
16
- /** @param {Parameters<import('./client-entry.js').start>} args */
16
+ /** @param {Parameters<typeof import('./client-entry.js').start>} args */
17
17
  export async function start(...args) {
18
18
  return (await client).start(...args);
19
19
  }
20
20
 
21
- /** @param {Parameters<import('./client-entry.js').load_css>} args */
21
+ /** @param {Parameters<typeof import('./client-entry.js').load_css>} args */
22
22
  export async function load_css(...args) {
23
23
  return (await client).load_css(...args);
24
24
  }
@@ -1,5 +1,5 @@
1
1
  /** @import { RemoteCommand, RemoteQueryUpdate } from '@sveltejs/kit' */
2
- import { app_dir, base } from '$app/paths/internal/client';
2
+ import { app_dir, base } from '#app/paths';
3
3
  import { stringify_command_arg } from '../../shared.js';
4
4
  import { get_remote_request_headers, categorize_updates, remote_request } from './shared.svelte.js';
5
5
 
@@ -34,39 +34,41 @@ export function command(id) {
34
34
  ...get_remote_request_headers()
35
35
  };
36
36
 
37
- /** @type {Promise<any> & { updates: (...args: RemoteQueryUpdate[]) => Promise<any> }} */
38
- const promise = (async () => {
39
- try {
40
- // Wait a tick to give room for the `updates` method to be called
41
- await Promise.resolve();
42
-
43
- if (updates_error) {
44
- throw updates_error;
45
- }
46
-
47
- const response = await remote_request(`${base}/${app_dir}/remote/${id}`, {
48
- method: 'POST',
49
- body: JSON.stringify({
50
- payload: await stringify_command_arg(arg),
51
- refreshes: Array.from(refreshes ?? [])
52
- }),
53
- headers
54
- });
55
-
56
- if (response.redirect) {
57
- throw new Error(
58
- 'Redirects are not allowed in commands. Return a result instead and use goto on the client'
59
- );
60
- }
61
-
62
- return response._;
63
- } finally {
64
- overrides?.forEach((fn) => fn());
65
-
66
- // Decrement pending count when command completes
67
- pending_count--;
68
- }
69
- })();
37
+ const promise =
38
+ /** @type {Promise<any> & { updates: (...args: RemoteQueryUpdate[]) => Promise<any> }} */ (
39
+ (async () => {
40
+ try {
41
+ // Wait a tick to give room for the `updates` method to be called
42
+ await Promise.resolve();
43
+
44
+ if (updates_error) {
45
+ throw updates_error;
46
+ }
47
+
48
+ const response = await remote_request(`${base}/${app_dir}/remote/${id}`, {
49
+ method: 'POST',
50
+ body: JSON.stringify({
51
+ payload: await stringify_command_arg(arg),
52
+ refreshes: Array.from(refreshes ?? [])
53
+ }),
54
+ headers
55
+ });
56
+
57
+ if (response.redirect) {
58
+ throw new Error(
59
+ 'Redirects are not allowed in commands. Return a result instead and use goto on the client'
60
+ );
61
+ }
62
+
63
+ return response._;
64
+ } finally {
65
+ overrides?.forEach((fn) => fn());
66
+
67
+ // Decrement pending count when command completes
68
+ pending_count--;
69
+ }
70
+ })()
71
+ );
70
72
 
71
73
  let updates_called = false;
72
74
  promise.updates = (...args) => {