@sveltejs/kit 3.0.0-next.1 → 3.0.0-next.11

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 (144) hide show
  1. package/package.json +33 -21
  2. package/src/constants.js +2 -0
  3. package/src/core/adapt/builder.js +32 -49
  4. package/src/core/adapt/index.js +1 -4
  5. package/src/core/config/index.js +137 -71
  6. package/src/core/config/options.js +236 -244
  7. package/src/core/config/types.d.ts +1 -1
  8. package/src/core/env.js +121 -5
  9. package/src/core/generate_manifest/index.js +12 -15
  10. package/src/core/postbuild/analyse.js +7 -19
  11. package/src/core/postbuild/crawl.js +22 -6
  12. package/src/core/postbuild/fallback.js +2 -1
  13. package/src/core/postbuild/prerender.js +114 -48
  14. package/src/core/postbuild/queue.js +2 -1
  15. package/src/core/sync/create_manifest_data/index.js +53 -50
  16. package/src/core/sync/sync.js +0 -2
  17. package/src/core/sync/write_client_manifest.js +8 -15
  18. package/src/core/sync/write_env.js +2 -1
  19. package/src/core/sync/write_non_ambient.js +12 -9
  20. package/src/core/sync/write_server.js +14 -15
  21. package/src/core/sync/write_tsconfig.js +16 -8
  22. package/src/core/sync/write_tsconfig_test/package.json +7 -0
  23. package/src/core/sync/write_types/index.js +28 -24
  24. package/src/core/utils.js +30 -5
  25. package/src/exports/env/index.js +77 -0
  26. package/src/exports/hooks/index.js +3 -9
  27. package/src/exports/hooks/sequence.js +3 -2
  28. package/src/exports/index.js +35 -13
  29. package/src/exports/internal/client.js +5 -0
  30. package/src/exports/internal/env.js +8 -5
  31. package/src/exports/internal/index.js +1 -90
  32. package/src/exports/internal/{event.js → server/event.js} +1 -2
  33. package/src/exports/internal/server/index.js +33 -0
  34. package/src/exports/internal/shared.js +89 -0
  35. package/src/exports/node/index.js +62 -15
  36. package/src/exports/params.js +68 -0
  37. package/src/exports/public.d.ts +363 -189
  38. package/src/exports/url.js +86 -0
  39. package/src/exports/vite/build/build_server.js +53 -59
  40. package/src/exports/vite/build/remote.js +18 -11
  41. package/src/exports/vite/build/utils.js +0 -8
  42. package/src/exports/vite/dev/index.js +92 -50
  43. package/src/exports/vite/index.js +903 -681
  44. package/src/exports/vite/module_ids.js +0 -2
  45. package/src/exports/vite/preview/index.js +32 -24
  46. package/src/exports/vite/static_analysis/index.js +2 -4
  47. package/src/exports/vite/static_analysis/types.d.ts +14 -0
  48. package/src/exports/vite/utils.js +40 -35
  49. package/src/runtime/app/env/internal.js +4 -4
  50. package/src/runtime/app/env/types.d.ts +1 -1
  51. package/src/runtime/app/environment/index.js +3 -3
  52. package/src/runtime/app/forms.js +24 -7
  53. package/src/runtime/app/paths/client.js +4 -10
  54. package/src/runtime/app/paths/internal/client.js +4 -2
  55. package/src/runtime/app/paths/internal/server.js +2 -23
  56. package/src/runtime/app/paths/public.d.ts +0 -28
  57. package/src/runtime/app/paths/server.js +10 -6
  58. package/src/runtime/app/server/index.js +1 -1
  59. package/src/runtime/app/server/remote/command.js +0 -3
  60. package/src/runtime/app/server/remote/form.js +27 -15
  61. package/src/runtime/app/server/remote/prerender.js +29 -36
  62. package/src/runtime/app/server/remote/query.js +101 -99
  63. package/src/runtime/app/server/remote/requested.js +22 -14
  64. package/src/runtime/app/server/remote/shared.js +30 -26
  65. package/src/runtime/app/state/client.js +1 -2
  66. package/src/runtime/app/stores.js +13 -76
  67. package/src/runtime/client/bundle.js +1 -1
  68. package/src/runtime/client/client-entry.js +3 -0
  69. package/src/runtime/client/client.js +411 -318
  70. package/src/runtime/client/entry.js +24 -3
  71. package/src/runtime/client/fetcher.js +3 -2
  72. package/src/runtime/client/ndjson.js +6 -33
  73. package/src/runtime/client/payload.js +17 -0
  74. package/src/runtime/client/remote-functions/cache.svelte.js +3 -1
  75. package/src/runtime/client/remote-functions/command.svelte.js +7 -32
  76. package/src/runtime/client/remote-functions/form.svelte.js +183 -112
  77. package/src/runtime/client/remote-functions/prerender.svelte.js +29 -8
  78. package/src/runtime/client/remote-functions/query/index.js +7 -14
  79. package/src/runtime/client/remote-functions/query/instance.svelte.js +63 -18
  80. package/src/runtime/client/remote-functions/query/proxy.js +3 -3
  81. package/src/runtime/client/remote-functions/query-batch.svelte.js +60 -68
  82. package/src/runtime/client/remote-functions/query-live/instance.svelte.js +60 -18
  83. package/src/runtime/client/remote-functions/query-live/iterator.js +36 -55
  84. package/src/runtime/client/remote-functions/shared.svelte.js +88 -62
  85. package/src/runtime/client/sse.js +32 -0
  86. package/src/runtime/client/state.svelte.js +65 -49
  87. package/src/runtime/client/stream.js +39 -0
  88. package/src/runtime/client/types.d.ts +11 -7
  89. package/src/runtime/client/utils.js +0 -96
  90. package/src/runtime/components/root.svelte +66 -0
  91. package/src/runtime/env/dynamic/private.js +7 -0
  92. package/src/runtime/env/dynamic/public.js +7 -0
  93. package/src/runtime/env/static/private.js +6 -0
  94. package/src/runtime/env/static/public.js +6 -0
  95. package/src/runtime/form-utils.js +100 -22
  96. package/src/runtime/server/cookie.js +69 -52
  97. package/src/runtime/server/csrf.js +65 -0
  98. package/src/runtime/server/data/index.js +15 -19
  99. package/src/runtime/server/env_module.js +0 -5
  100. package/src/runtime/server/errors.js +135 -0
  101. package/src/runtime/server/fetch.js +1 -1
  102. package/src/runtime/server/index.js +22 -12
  103. package/src/runtime/server/internal.js +25 -0
  104. package/src/runtime/server/page/actions.js +43 -27
  105. package/src/runtime/server/page/data_serializer.js +10 -10
  106. package/src/runtime/server/page/index.js +12 -17
  107. package/src/runtime/server/page/load_data.js +2 -2
  108. package/src/runtime/server/page/render.js +114 -193
  109. package/src/runtime/server/page/respond_with_error.js +11 -11
  110. package/src/runtime/server/page/server_routing.js +27 -18
  111. package/src/runtime/server/remote-functions.js +596 -0
  112. package/src/runtime/server/respond.js +100 -68
  113. package/src/runtime/server/sourcemaps.js +183 -0
  114. package/src/runtime/server/utils.js +2 -134
  115. package/src/runtime/shared.js +83 -13
  116. package/src/runtime/telemetry/otel.js +1 -1
  117. package/src/runtime/types.d.ts +8 -0
  118. package/src/types/ambient-private.d.ts +2 -0
  119. package/src/types/ambient.d.ts +10 -5
  120. package/src/types/global-private.d.ts +13 -25
  121. package/src/types/internal.d.ts +95 -80
  122. package/src/types/private.d.ts +41 -1
  123. package/src/utils/error.js +24 -4
  124. package/src/utils/escape.js +9 -25
  125. package/src/utils/features.js +1 -1
  126. package/src/utils/fork.js +7 -2
  127. package/src/utils/import.js +6 -1
  128. package/src/utils/imports.js +83 -0
  129. package/src/utils/mime.js +9 -0
  130. package/src/utils/page_nodes.js +3 -5
  131. package/src/utils/params.js +66 -0
  132. package/src/utils/routing.js +90 -44
  133. package/src/utils/shared-iterator.js +5 -0
  134. package/src/utils/streaming.js +14 -4
  135. package/src/utils/url.js +20 -2
  136. package/src/version.js +1 -1
  137. package/types/index.d.ts +537 -557
  138. package/types/index.d.ts.map +24 -39
  139. package/src/core/sync/write_root.js +0 -148
  140. package/src/exports/internal/server.js +0 -22
  141. package/src/runtime/server/remote.js +0 -457
  142. package/src/runtime/shared-server.js +0 -7
  143. package/src/types/synthetic/$lib.md +0 -5
  144. /package/src/exports/internal/{remote-functions.js → server/remote-functions.js} +0 -0
package/types/index.d.ts CHANGED
@@ -4,10 +4,13 @@
4
4
  declare module '@sveltejs/kit' {
5
5
  import type { SvelteConfig } from '@sveltejs/vite-plugin-svelte';
6
6
  import type { StandardSchemaV1 } from '@standard-schema/spec';
7
+ import type { Plugin } from 'vite';
7
8
  import type { RouteId as AppRouteId, LayoutParams as AppLayoutParams, ResolvedPathname } from '$app/types';
8
9
  // @ts-ignore this is an optional peer dependency so could be missing. Written like this so dts-buddy preserves the ts-ignore
9
10
  type Span = import('@opentelemetry/api').Span;
10
11
 
12
+ type AppErrorWithOptionalStatus = Omit<App.Error, 'status'> & { status?: App.Error['status'] };
13
+
11
14
  /**
12
15
  * [Adapters](https://svelte.dev/docs/kit/adapters) are responsible for taking the production build and turning it into something that can be deployed to a platform of your choosing.
13
16
  */
@@ -29,7 +32,7 @@ declare module '@sveltejs/kit' {
29
32
  * Test support for `read` from `$app/server`.
30
33
  * @param details.config The merged adapter-specific route config exported from the route with `export const config`
31
34
  */
32
- read?: (details: { config: any; route: { id: string } }) => boolean;
35
+ read?: (details: { config: Record<string, any>; route: { id: string } }) => boolean;
33
36
 
34
37
  /**
35
38
  * Test support for `instrumentation.server.js`. To pass, the adapter must support running `instrumentation.server.js` prior to the application code.
@@ -42,6 +45,13 @@ declare module '@sveltejs/kit' {
42
45
  * during dev, build and prerendering.
43
46
  */
44
47
  emulate?: () => MaybePromise<Emulator>;
48
+ vite?: {
49
+ /**
50
+ * Plugins provided by the adapter are placed before any of SvelteKit's own plugins.
51
+ * @since 3.0.0
52
+ */
53
+ plugins?: Plugin[];
54
+ };
45
55
  }
46
56
 
47
57
  export type LoadProperties<input extends Record<string, any> | void> = input extends void
@@ -90,7 +100,7 @@ declare module '@sveltejs/kit' {
90
100
  /** Create `dir` and any required parent directories. */
91
101
  mkdirp: (dir: string) => void;
92
102
 
93
- /** The fully resolved Svelte config. */
103
+ /** The fully resolved SvelteKit config. */
94
104
  config: ValidatedConfig;
95
105
  /** Information about prerendered pages and assets, if any. */
96
106
  prerendered: Prerendered;
@@ -121,7 +131,7 @@ declare module '@sveltejs/kit' {
121
131
 
122
132
  /**
123
133
  * Generate a server-side manifest to initialise the SvelteKit [server](https://svelte.dev/docs/kit/@sveltejs-kit#Server) with.
124
- * @param opts a relative path to the base directory of the app and optionally in which format (esm or cjs) the manifest should be generated
134
+ * @param opts.relativePath A relative path to the base directory of the server build output
125
135
  */
126
136
  generateManifest: (opts: { relativePath: string; routes?: RouteDefinition[] }) => string;
127
137
 
@@ -237,13 +247,13 @@ declare module '@sveltejs/kit' {
237
247
  /**
238
248
  * Gets a cookie that was previously set with `cookies.set`, or from the request headers.
239
249
  * @param name the name of the cookie
240
- * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
250
+ * @param opts the options, passed directly to `cookie.parseCookie`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
241
251
  */
242
252
  get: (name: string, opts?: import('cookie').ParseOptions) => string | undefined;
243
253
 
244
254
  /**
245
255
  * Gets all cookies that were previously set with `cookies.set`, or from the request headers.
246
- * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
256
+ * @param opts the options, passed directly to `cookie.parseCookie`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
247
257
  */
248
258
  getAll: (opts?: import('cookie').ParseOptions) => Array<{ name: string; value: string }>;
249
259
 
@@ -255,7 +265,7 @@ declare module '@sveltejs/kit' {
255
265
  * The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
256
266
  * @param name the name of the cookie
257
267
  * @param value the cookie value
258
- * @param opts the options passed to `cookie.serialize` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
268
+ * @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
259
269
  */
260
270
  set: (name: string, value: string, opts: import('cookie').SerializeOptions) => void;
261
271
 
@@ -266,10 +276,34 @@ declare module '@sveltejs/kit' {
266
276
  *
267
277
  * The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
268
278
  * @param name the name of the cookie
269
- * @param opts the options passed to `cookie.serialize` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
279
+ * @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
270
280
  */
271
281
  delete: (name: string, opts: import('cookie').SerializeOptions) => void;
272
282
 
283
+ /**
284
+ * Parses a single `Set-Cookie` header. This allows you to apply cookies received from an external source:
285
+ *
286
+ * ```js
287
+ * import { getRequestEvent } from '$app/server';
288
+ *
289
+ * export async function GET() {
290
+ * const { cookies } = getRequestEvent();
291
+ *
292
+ * const response = await fetch('...');
293
+ *
294
+ * for (const str of response.headers.getSetCookie()) {
295
+ * const { name, value, ...options } = cookies.parse(str);
296
+ * cookies.set(name, value, { ...options, path: '/' });
297
+ * }
298
+ *
299
+ * // ...
300
+ * }
301
+ * ```
302
+ *
303
+ * Note the use of `headers.getSetCookie()`, which returns an array of cookie headers, _not_ `headers.get('set-cookie')` which returns a single comma-separated string.
304
+ */
305
+ parse: typeof import('cookie').parseSetCookie;
306
+
273
307
  /**
274
308
  * Serialize a cookie name-value pair into a `Set-Cookie` header string, but don't apply it to the response.
275
309
  *
@@ -278,7 +312,7 @@ declare module '@sveltejs/kit' {
278
312
  * The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
279
313
  * @param name the name of the cookie
280
314
  * @param value the cookie value
281
- * @param opts the options passed to `cookie.serialize` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
315
+ * @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
282
316
  */
283
317
  serialize: (name: string, value: string, opts: import('cookie').SerializeOptions) => string;
284
318
  }
@@ -295,35 +329,37 @@ declare module '@sveltejs/kit' {
295
329
  }
296
330
 
297
331
  export interface KitConfig {
298
- // TODO: remove this in 4.0
299
332
  /**
300
333
  * Your [adapter](https://svelte.dev/docs/kit/adapters) is run when executing `vite build`. It determines how the output is converted for different platforms.
301
334
  * @default undefined
302
- * @deprecated removed in 3.0.0. Adapters should now be passed to the `sveltekit` Vite plugin in `vite.config.js`
303
335
  */
304
336
  adapter?: Adapter;
305
337
  /**
306
338
  * An object containing zero or more aliases used to replace values in `import` statements. These aliases are automatically passed to Vite and TypeScript.
307
339
  *
308
340
  * ```js
309
- * /// file: svelte.config.js
310
- * /// type: import('@sveltejs/kit').Config
311
- * const config = {
312
- * kit: {
313
- * alias: {
314
- * // this will match a file
315
- * 'my-file': 'path/to/my-file.js',
316
- *
317
- * // this will match a directory and its contents
318
- * // (`my-directory/x` resolves to `path/to/my-directory/x`)
319
- * 'my-directory': 'path/to/my-directory',
320
- *
321
- * // an alias ending /* will only match
322
- * // the contents of a directory, not the directory itself
323
- * 'my-directory/*': 'path/to/my-directory/*'
324
- * }
325
- * }
326
- * };
341
+ * /// file: vite.config.js
342
+ * import { defineConfig } from 'vite';
343
+ * import { sveltekit } from '@sveltejs/kit/vite';
344
+ *
345
+ * export default defineConfig({
346
+ * plugins: [
347
+ * sveltekit({
348
+ * alias: {
349
+ * // this will match a file
350
+ * 'my-file': 'path/to/my-file.js',
351
+ *
352
+ * // this will match a directory and its contents
353
+ * // (`my-directory/x` resolves to `path/to/my-directory/x`)
354
+ * 'my-directory': 'path/to/my-directory',
355
+ *
356
+ * // an alias ending /* will only match
357
+ * // the contents of a directory, not the directory itself
358
+ * 'my-directory/*': 'path/to/my-directory/*'
359
+ * }
360
+ * })
361
+ * ]
362
+ * });
327
363
  * ```
328
364
  *
329
365
  * > [!NOTE] You will need to run `npm run dev` to have SvelteKit automatically generate the required alias configuration in `jsconfig.json` or `tsconfig.json`.
@@ -341,24 +377,26 @@ declare module '@sveltejs/kit' {
341
377
  * [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) configuration. CSP helps to protect your users against cross-site scripting (XSS) attacks, by limiting the places resources can be loaded from. For example, a configuration like this...
342
378
  *
343
379
  * ```js
344
- * /// file: svelte.config.js
345
- * /// type: import('@sveltejs/kit').Config
346
- * const config = {
347
- * kit: {
348
- * csp: {
349
- * directives: {
350
- * 'script-src': ['self']
351
- * },
352
- * // must be specified with either the `report-uri` or `report-to` directives, or both
353
- * reportOnly: {
354
- * 'script-src': ['self'],
355
- * 'report-uri': ['/']
356
- * }
357
- * }
358
- * }
359
- * };
360
- *
361
- * export default config;
380
+ * /// file: vite.config.js
381
+ * import { sveltekit } from '@sveltejs/kit/vite';
382
+ * import { defineConfig } from 'vite';
383
+ *
384
+ * export default defineConfig({
385
+ * plugins: [
386
+ * sveltekit({
387
+ * csp: {
388
+ * directives: {
389
+ * 'script-src': ['self']
390
+ * },
391
+ * // must be specified with either the `report-uri` or `report-to` directives, or both
392
+ * reportOnly: {
393
+ * 'script-src': ['self'],
394
+ * 'report-uri': ['/']
395
+ * }
396
+ * }
397
+ * })
398
+ * ]
399
+ * });
362
400
  * ```
363
401
  *
364
402
  * ...would prevent scripts loading from external sites. SvelteKit will augment the specified directives with nonces or hashes (depending on `mode`) for any inline styles and scripts it generates.
@@ -369,9 +407,7 @@ declare module '@sveltejs/kit' {
369
407
  *
370
408
  * > [!NOTE] When `mode` is `'auto'`, SvelteKit will use nonces for dynamically rendered pages and hashes for prerendered pages. Using nonces with prerendered pages is insecure and therefore forbidden.
371
409
  *
372
- * > [!NOTE] Note that most [Svelte transitions](https://svelte.dev/tutorial/svelte/transition) work by creating an inline `<style>` element. If you use these in your app, you must either leave the `style-src` directive unspecified or add `unsafe-inline`.
373
- *
374
- * If this level of configuration is insufficient and you have more dynamic requirements, you can use the [`handle` hook](https://svelte.dev/docs/kit/hooks#Server-hooks-handle) to roll your own CSP.
410
+ * If this level of configuration is insufficient and you have more dynamic requirements, you can use the [`handle` hook](https://svelte.dev/docs/kit/hooks#handle) to roll your own CSP.
375
411
  */
376
412
  csp?: {
377
413
  /**
@@ -433,32 +469,6 @@ declare module '@sveltejs/kit' {
433
469
  };
434
470
  /** Experimental features. Here be dragons. These are not subject to semantic versioning, so breaking changes or removal can happen in any release. */
435
471
  experimental?: {
436
- /**
437
- * Options for enabling server-side [OpenTelemetry](https://opentelemetry.io/) tracing for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#Server-hooks-handle), [`load` functions](https://svelte.dev/docs/kit/load), [form actions](https://svelte.dev/docs/kit/form-actions), and [remote functions](https://svelte.dev/docs/kit/remote-functions).
438
- * @default { server: false, serverFile: false }
439
- * @since 2.31.0
440
- */
441
- tracing?: {
442
- /**
443
- * Enables server-side [OpenTelemetry](https://opentelemetry.io/) span emission for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#Server-hooks-handle), [`load` functions](https://svelte.dev/docs/kit/load), [form actions](https://svelte.dev/docs/kit/form-actions), and [remote functions](https://svelte.dev/docs/kit/remote-functions).
444
- * @default false
445
- * @since 2.31.0
446
- */
447
- server?: boolean;
448
- };
449
-
450
- /**
451
- * @since 2.31.0
452
- */
453
- instrumentation?: {
454
- /**
455
- * Enables `instrumentation.server.js` for tracing and observability instrumentation.
456
- * @default false
457
- * @since 2.31.0
458
- */
459
- server?: boolean;
460
- };
461
-
462
472
  /**
463
473
  * Whether to enable the experimental remote functions feature. This feature is not yet stable and may be changed or removed at any time.
464
474
  * @default false
@@ -470,15 +480,6 @@ declare module '@sveltejs/kit' {
470
480
  * @default false
471
481
  */
472
482
  forkPreloads?: boolean;
473
-
474
- /**
475
- * Whether to enable the experimental handling of rendering errors.
476
- * When enabled, `<svelte:boundary>` is used to wrap components at each level
477
- * where there's an `+error.svelte`, rendering the error page if the component fails.
478
- * In addition, error boundaries also work on the server and the error object goes through `handleError`.
479
- * @default false
480
- */
481
- handleRenderingErrors?: boolean;
482
483
  };
483
484
  /**
484
485
  * Where to find various files within your project.
@@ -519,12 +520,6 @@ declare module '@sveltejs/kit' {
519
520
  */
520
521
  universal?: string;
521
522
  };
522
- /**
523
- * Your app's internal library, accessible throughout the codebase as `$lib`.
524
- * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
525
- * @default "src/lib"
526
- */
527
- lib?: string;
528
523
  /**
529
524
  * A directory containing [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#Matching).
530
525
  * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
@@ -564,7 +559,7 @@ declare module '@sveltejs/kit' {
564
559
  */
565
560
  inlineStyleThreshold?: number;
566
561
  /**
567
- * An array of file extensions that SvelteKit will treat as modules. Files with extensions that match neither `config.extensions` nor `config.kit.moduleExtensions` will be ignored by the router.
562
+ * An array of file extensions that SvelteKit will treat as modules. Files with extensions that match neither `config.extensions` nor `config.moduleExtensions` will be ignored by the router.
568
563
  * @default [".js", ".ts"]
569
564
  */
570
565
  moduleExtensions?: string[];
@@ -646,14 +641,27 @@ declare module '@sveltejs/kit' {
646
641
  */
647
642
  assets?: '' | `http://${string}` | `https://${string}`;
648
643
  /**
649
- * A root-relative path that must start, but not end with `/` (e.g. `/base-path`), unless it is the empty string. This specifies where your app is served from and allows the app to live on a non-root path. Note that you need to prepend all your root-relative links with the base value or they will point to the root of your domain, not your `base` (this is how the browser works). You can use [`base` from `$app/paths`](https://svelte.dev/docs/kit/$app-paths#base) for that: `<a href="{base}/your-page">Link</a>`. If you find yourself writing this often, it may make sense to extract this into a reusable component.
644
+ * A root-relative path that must start, but not end with `/` (e.g. `/base-path`), unless it is the empty string. This specifies where your app is served from and allows the app to live on a non-root path. Note that you need to prepend all your root-relative links with the base value or they will point to the root of your domain, not your `base` (this is how the browser works). You can use [`resolve(...)` from `$app/paths`](https://svelte.dev/docs/kit/$app-paths#resolve) for that: `<a href="{resolve('/your-page')}">Link</a>`. If you find yourself writing this often, it may make sense to extract this into a reusable component.
650
645
  * @default ""
651
646
  */
652
647
  base?: '' | `/${string}`;
648
+ /**
649
+ * The origin of your app, used for CSRF protection and prerendering.
650
+ *
651
+ * By default, this is `undefined`, meaning SvelteKit will derive the origin from `request.url` (which is set by the adapter, and ultimately by the platform).
652
+ *
653
+ * If your app is served from an origin that isn't known at request time — for example because it's deployed to a preview deployment whose URL isn't known at build time, or because it's behind a reverse proxy that doesn't pass the `host` header — you can set this to a string like `https://my-site.com`.
654
+ *
655
+ * This is also used as the value of `url.origin` during prerendering (when unset, it defaults to `http://sveltekit-prerender`), and as the trusted origin for CSRF checks on form submissions and remote function calls.
656
+ *
657
+ * @default undefined
658
+ * @since 3.0
659
+ */
660
+ origin?: string;
653
661
  /**
654
662
  * Whether to use relative asset paths.
655
663
  *
656
- * If `true`, `base` and `assets` imported from `$app/paths` will be replaced with relative asset paths during server-side rendering, resulting in more portable HTML.
664
+ * If `true`, paths created with `resolve()` and `asset()` imported from `$app/paths` will be replaced with relative asset paths during server-side rendering, resulting in more portable HTML.
657
665
  * If `false`, `%sveltekit.assets%` and references to build artifacts will always be root-relative paths, unless `paths.assets` is an external URL
658
666
  *
659
667
  * [Single-page app](https://svelte.dev/docs/kit/single-page-apps) fallback pages will always use absolute paths, regardless of this setting.
@@ -695,23 +703,27 @@ declare module '@sveltejs/kit' {
695
703
  * - `(details) => void` — a custom error handler that takes a `details` object with `status`, `path`, `referrer`, `referenceType` and `message` properties. If you `throw` from this function, the build will fail
696
704
  *
697
705
  * ```js
698
- * /// file: svelte.config.js
699
- * /// type: import('@sveltejs/kit').Config
700
- * const config = {
701
- * kit: {
702
- * prerender: {
703
- * handleHttpError: ({ path, referrer, message }) => {
704
- * // ignore deliberate link to shiny 404 page
705
- * if (path === '/not-found' && referrer === '/blog/how-we-built-our-404-page') {
706
- * return;
707
- * }
706
+ * /// file: vite.config.js
707
+ * import { sveltekit } from '@sveltejs/kit/vite';
708
+ * import { defineConfig } from 'vite';
708
709
  *
709
- * // otherwise fail the build
710
- * throw new Error(message);
711
- * }
712
- * }
713
- * }
714
- * };
710
+ * export default defineConfig({
711
+ * plugins: [
712
+ * sveltekit({
713
+ * prerender: {
714
+ * handleHttpError: ({ path, referrer, message }) => {
715
+ * // ignore deliberate link to shiny 404 page
716
+ * if (path === '/not-found' && referrer === '/blog/how-we-built-our-404-page') {
717
+ * return;
718
+ * }
719
+ *
720
+ * // otherwise fail the build
721
+ * throw new Error(message);
722
+ * }
723
+ * }
724
+ * })
725
+ * ]
726
+ * });
715
727
  * ```
716
728
  *
717
729
  * @default "fail"
@@ -758,10 +770,17 @@ declare module '@sveltejs/kit' {
758
770
  */
759
771
  handleUnseenRoutes?: PrerenderUnseenRoutesHandlerValue;
760
772
  /**
761
- * The value of `url.origin` during prerendering; useful if it is included in rendered content.
762
- * @default "http://sveltekit-prerender"
773
+ * How to respond when SvelteKit encounters a URL it cannot parse while crawling prerendered HTML (for example, an AT Protocol URL such as `at://did:plc:...`).
774
+ *
775
+ * - `'fail'` — fail the build
776
+ * - `'ignore'` - silently ignore the failure and continue
777
+ * - `'warn'` — continue, but print a warning
778
+ * - `(details) => void` — a custom error handler that takes a `details` object with `href`, `referrer` and `message` properties. If you `throw` from this function, the build will fail
779
+ *
780
+ * @default "fail"
781
+ * @since 2.67.0
763
782
  */
764
- origin?: string;
783
+ handleInvalidUrl?: PrerenderInvalidUrlHandlerValue;
765
784
  };
766
785
  router?: {
767
786
  /**
@@ -786,8 +805,10 @@ declare module '@sveltejs/kit' {
786
805
  * This has several advantages:
787
806
  * - The client does not need to load the routing manifest upfront, which can lead to faster initial page loads
788
807
  * - The list of routes is hidden from public view
789
- * - The server has an opportunity to intercept each navigation (for example through a middleware), enabling (for example) A/B testing opaque to SvelteKit
790
-
808
+ * - The server has an opportunity to intercept each navigation (for example through middleware in front of SvelteKit, such as a reverse proxy or your platform's edge functions), enabling (for example) A/B testing opaque to SvelteKit
809
+ *
810
+ * Route resolution requests are answered as soon as the route has been looked up, before the `handle` hook is invoked. To intercept them within SvelteKit itself, use the `reroute` hook, which runs for these requests too.
811
+ *
791
812
  * The drawback is that for unvisited paths, resolution will take slightly longer (though this is mitigated by [preloading](https://svelte.dev/docs/kit/link-options#data-sveltekit-preload-data)).
792
813
  *
793
814
  * > [!NOTE] When using server-side route resolution and prerendering, the resolution is prerendered along with the route itself.
@@ -823,6 +844,17 @@ declare module '@sveltejs/kit' {
823
844
  register?: false;
824
845
  }
825
846
  );
847
+ /**
848
+ * Options for enabling [OpenTelemetry](https://opentelemetry.io/) tracing for SvelteKit operations.
849
+ * @default { server: false }
850
+ */
851
+ tracing?: {
852
+ /**
853
+ * Enables server-side [OpenTelemetry](https://opentelemetry.io/) span emission for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#handle), [`load` functions](https://svelte.dev/docs/kit/load), [form actions](https://svelte.dev/docs/kit/form-actions), and [remote functions](https://svelte.dev/docs/kit/remote-functions). Tracing — and more significantly, observability instrumentation — can have a nontrivial overhead, so consider whether you really need it, or if it might be more appropriate to turn it on in development and preview environments only.
854
+ * @default false
855
+ */
856
+ server?: boolean;
857
+ };
826
858
  typescript?: {
827
859
  /**
828
860
  * A function that allows you to edit the generated `tsconfig.json`. You can mutate the config (recommended) or return a new one.
@@ -863,16 +895,20 @@ declare module '@sveltejs/kit' {
863
895
  * For example, to use the current commit hash, you could do use `git rev-parse HEAD`:
864
896
  *
865
897
  * ```js
866
- * /// file: svelte.config.js
898
+ * /// file: vite.config.js
867
899
  * import * as child_process from 'node:child_process';
900
+ * import { sveltekit } from '@sveltejs/kit/vite';
901
+ * import { defineConfig } from 'vite';
868
902
  *
869
- * export default {
870
- * kit: {
871
- * version: {
872
- * name: child_process.execSync('git rev-parse HEAD').toString().trim()
873
- * }
874
- * }
875
- * };
903
+ * export default defineConfig({
904
+ * plugins: [
905
+ * sveltekit({
906
+ * version: {
907
+ * name: child_process.execSync('git rev-parse HEAD').toString().trim()
908
+ * }
909
+ * })
910
+ * ]
911
+ * });
876
912
  * ```
877
913
  */
878
914
  name?: string;
@@ -885,52 +921,58 @@ declare module '@sveltejs/kit' {
885
921
  }
886
922
 
887
923
  /**
888
- * The [`handle`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle) hook runs every time the SvelteKit server receives a [request](https://svelte.dev/docs/kit/web-standards#Fetch-APIs-Request) and
924
+ * The [`handle`](https://svelte.dev/docs/kit/hooks#handle) hook runs every time the SvelteKit server receives a [request](https://svelte.dev/docs/kit/web-standards#Fetch-APIs-Request) and
889
925
  * determines the [response](https://svelte.dev/docs/kit/web-standards#Fetch-APIs-Response).
890
926
  * It receives an `event` object representing the request and a function called `resolve`, which renders the route and generates a `Response`.
891
927
  * This allows you to modify response headers or bodies, or bypass SvelteKit entirely (for implementing routes programmatically, for example).
892
928
  */
893
929
  export type Handle = (input: {
894
930
  event: RequestEvent;
895
- resolve: (event: RequestEvent, opts?: ResolveOptions) => MaybePromise<Response>;
931
+ resolve: (event: RequestEvent, opts?: ResolveOptions) => Promise<Response>;
896
932
  }) => MaybePromise<Response>;
897
933
 
898
934
  /**
899
- * The server-side [`handleError`](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError) hook runs when an unexpected error is thrown while responding to a request.
935
+ * The server-side [`handleError`](https://svelte.dev/docs/kit/hooks#handleError) hook runs when an unexpected error is thrown while responding to a request.
900
936
  *
901
937
  * If an unexpected error is thrown during loading or rendering, this function will be called with the error and the event.
902
938
  * Make sure that this function _never_ throws an error.
939
+ *
940
+ * The returned object can include a `status` property to override the HTTP status code used in the response.
941
+ * If omitted, the status defaults to 500.
903
942
  */
904
943
  export type HandleServerError = (input: {
905
944
  error: unknown;
906
945
  event: RequestEvent;
907
946
  status: number;
908
947
  message: string;
909
- }) => MaybePromise<void | App.Error>;
948
+ }) => MaybePromise<void | AppErrorWithOptionalStatus>;
910
949
 
911
950
  /**
912
- * The [`handleValidationError`](https://svelte.dev/docs/kit/hooks#Server-hooks-handleValidationError) hook runs when the argument to a remote function fails validation.
951
+ * The [`handleValidationError`](https://svelte.dev/docs/kit/hooks#handleValidationError) hook runs when the argument to a remote function fails validation.
913
952
  *
914
953
  * It will be called with the validation issues and the event, and must return an object shape that matches `App.Error`.
915
954
  */
916
955
  export type HandleValidationError<Issue extends StandardSchemaV1.Issue = StandardSchemaV1.Issue> =
917
- (input: { issues: Issue[]; event: RequestEvent }) => MaybePromise<App.Error>;
956
+ (input: { issues: Issue[]; event: RequestEvent }) => MaybePromise<AppErrorWithOptionalStatus>;
918
957
 
919
958
  /**
920
- * The client-side [`handleError`](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError) hook runs when an unexpected error is thrown while navigating.
959
+ * The client-side [`handleError`](https://svelte.dev/docs/kit/hooks#handleError) hook runs when an unexpected error is thrown while navigating.
921
960
  *
922
961
  * If an unexpected error is thrown during loading or the following render, this function will be called with the error and the event.
923
962
  * Make sure that this function _never_ throws an error.
963
+ *
964
+ * The returned object can include a `status` property to override the HTTP status code used in the response.
965
+ * If omitted, the status defaults to 500.
924
966
  */
925
967
  export type HandleClientError = (input: {
926
968
  error: unknown;
927
969
  event: NavigationEvent;
928
970
  status: number;
929
971
  message: string;
930
- }) => MaybePromise<void | App.Error>;
972
+ }) => MaybePromise<void | AppErrorWithOptionalStatus>;
931
973
 
932
974
  /**
933
- * The [`handleFetch`](https://svelte.dev/docs/kit/hooks#Server-hooks-handleFetch) hook allows you to modify (or replace) the result of an [`event.fetch`](https://svelte.dev/docs/kit/load#Making-fetch-requests) call that runs on the server (or during prerendering) inside an endpoint, `load`, `action`, `handle`, `handleError` or `reroute`.
975
+ * 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`.
934
976
  */
935
977
  export type HandleFetch = (input: {
936
978
  event: RequestEvent;
@@ -939,25 +981,25 @@ declare module '@sveltejs/kit' {
939
981
  }) => MaybePromise<Response>;
940
982
 
941
983
  /**
942
- * The [`init`](https://svelte.dev/docs/kit/hooks#Shared-hooks-init) will be invoked before the server responds to its first request
984
+ * The [`init`](https://svelte.dev/docs/kit/hooks#init) will be invoked before the server responds to its first request
943
985
  * @since 2.10.0
944
986
  */
945
987
  export type ServerInit = () => MaybePromise<void>;
946
988
 
947
989
  /**
948
- * The [`init`](https://svelte.dev/docs/kit/hooks#Shared-hooks-init) will be invoked once the app starts in the browser
990
+ * The [`init`](https://svelte.dev/docs/kit/hooks#init) will be invoked once the app starts in the browser
949
991
  * @since 2.10.0
950
992
  */
951
993
  export type ClientInit = () => MaybePromise<void>;
952
994
 
953
995
  /**
954
- * The [`reroute`](https://svelte.dev/docs/kit/hooks#Universal-hooks-reroute) hook allows you to modify the URL before it is used to determine which route to render.
996
+ * The [`reroute`](https://svelte.dev/docs/kit/hooks#reroute) hook allows you to modify the URL before it is used to determine which route to render.
955
997
  * @since 2.3.0
956
998
  */
957
999
  export type Reroute = (event: { url: URL; fetch: typeof fetch }) => MaybePromise<void | string>;
958
1000
 
959
1001
  /**
960
- * The [`transport`](https://svelte.dev/docs/kit/hooks#Universal-hooks-transport) hook allows you to transport custom types across the server/client boundary.
1002
+ * The [`transport`](https://svelte.dev/docs/kit/hooks#transport) hook allows you to transport custom types across the server/client boundary.
961
1003
  *
962
1004
  * Each transporter has a pair of `encode` and `decode` functions. On the server, `encode` determines whether a value is an instance of the custom type and, if so, returns a non-falsy encoding of the value which can be an object or an array (or `false` otherwise).
963
1005
  *
@@ -983,11 +1025,11 @@ declare module '@sveltejs/kit' {
983
1025
  export type Transport = Record<string, Transporter>;
984
1026
 
985
1027
  /**
986
- * A member of the [`transport`](https://svelte.dev/docs/kit/hooks#Universal-hooks-transport) hook.
1028
+ * A member of the [`transport`](https://svelte.dev/docs/kit/hooks#transport) hook.
987
1029
  */
988
1030
  export interface Transporter<
989
1031
  T = any,
990
- U = Exclude<any, false | 0 | '' | null | undefined | typeof NaN>
1032
+ U = any /* minus falsy values, but we can't properly express that */
991
1033
  > {
992
1034
  encode: (value: T) => false | U;
993
1035
  decode: (data: U) => T;
@@ -1021,7 +1063,7 @@ declare module '@sveltejs/kit' {
1021
1063
  * - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.
1022
1064
  * - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).
1023
1065
  * - Internal requests (e.g. for `+server.js` routes) go directly to the handler function when running on the server, without the overhead of an HTTP call.
1024
- * - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle)
1066
+ * - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://svelte.dev/docs/kit/hooks#handle)
1025
1067
  * - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.
1026
1068
  *
1027
1069
  * You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies)
@@ -1196,14 +1238,24 @@ declare module '@sveltejs/kit' {
1196
1238
  /**
1197
1239
  * - `enter`: The app has hydrated/started
1198
1240
  * - `form`: The user submitted a `<form method="GET">`
1241
+ * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
1199
1242
  * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
1200
1243
  * - `link`: Navigation was triggered by a link click
1201
- * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
1202
1244
  * - `popstate`: Navigation was triggered by back/forward navigation
1203
1245
  */
1204
1246
  export type NavigationType = 'enter' | 'form' | 'leave' | 'link' | 'goto' | 'popstate';
1205
1247
 
1206
1248
  export interface NavigationBase {
1249
+ /**
1250
+ * The type of navigation:
1251
+ * - `enter`: The app has hydrated/started
1252
+ * - `form`: The user submitted a `<form method="GET">`
1253
+ * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
1254
+ * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
1255
+ * - `link`: Navigation was triggered by a link click
1256
+ * - `popstate`: Navigation was triggered by back/forward navigation
1257
+ */
1258
+ type: NavigationType;
1207
1259
  /**
1208
1260
  * Where navigation was triggered from
1209
1261
  */
@@ -1223,11 +1275,10 @@ declare module '@sveltejs/kit' {
1223
1275
  complete: Promise<void>;
1224
1276
  }
1225
1277
 
1278
+ /**
1279
+ * The navigation that occurs when the app starts/hydrates
1280
+ */
1226
1281
  export interface NavigationEnter extends NavigationBase {
1227
- /**
1228
- * The type of navigation:
1229
- * - `enter`: The app has hydrated/started
1230
- */
1231
1282
  type: 'enter';
1232
1283
 
1233
1284
  /**
@@ -1243,27 +1294,24 @@ declare module '@sveltejs/kit' {
1243
1294
 
1244
1295
  export type NavigationExternal = NavigationGoto | NavigationLeave;
1245
1296
 
1297
+ /**
1298
+ * A navigation triggered by a `goto(...)` call or a redirect
1299
+ */
1246
1300
  export interface NavigationGoto extends NavigationBase {
1247
- /**
1248
- * The type of navigation:
1249
- * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
1250
- */
1251
1301
  type: 'goto';
1252
1302
  }
1253
1303
 
1304
+ /**
1305
+ * A navigation triggered by the tab being closed, or the user navigating to a different document
1306
+ */
1254
1307
  export interface NavigationLeave extends NavigationBase {
1255
- /**
1256
- * The type of navigation:
1257
- * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
1258
- */
1259
1308
  type: 'leave';
1260
1309
  }
1261
1310
 
1311
+ /**
1312
+ * A navigation triggered by a `<form method="GET">`
1313
+ */
1262
1314
  export interface NavigationFormSubmit extends NavigationBase {
1263
- /**
1264
- * The type of navigation:
1265
- * - `form`: The user submitted a `<form method="GET">`
1266
- */
1267
1315
  type: 'form';
1268
1316
 
1269
1317
  /**
@@ -1272,11 +1320,10 @@ declare module '@sveltejs/kit' {
1272
1320
  event: SubmitEvent;
1273
1321
  }
1274
1322
 
1323
+ /**
1324
+ * A navigation triggered by back/forward navigation
1325
+ */
1275
1326
  export interface NavigationPopState extends NavigationBase {
1276
- /**
1277
- * The type of navigation:
1278
- * - `popstate`: Navigation was triggered by back/forward navigation
1279
- */
1280
1327
  type: 'popstate';
1281
1328
 
1282
1329
  /**
@@ -1290,11 +1337,10 @@ declare module '@sveltejs/kit' {
1290
1337
  event: PopStateEvent;
1291
1338
  }
1292
1339
 
1340
+ /**
1341
+ * A navigation triggered by a link click
1342
+ */
1293
1343
  export interface NavigationLink extends NavigationBase {
1294
- /**
1295
- * The type of navigation:
1296
- * - `link`: Navigation was triggered by a link click
1297
- */
1298
1344
  type: 'link';
1299
1345
 
1300
1346
  /**
@@ -1342,7 +1388,7 @@ declare module '@sveltejs/kit' {
1342
1388
  };
1343
1389
 
1344
1390
  /**
1345
- * The shape of the [`page`](https://svelte.dev/docs/kit/$app-state#page) reactive object and the [`$page`](https://svelte.dev/docs/kit/$app-stores) store.
1391
+ * The shape of the [`page`](https://svelte.dev/docs/kit/$app-state#page) reactive object.
1346
1392
  */
1347
1393
  export interface Page<
1348
1394
  Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
@@ -1351,7 +1397,7 @@ declare module '@sveltejs/kit' {
1351
1397
  /**
1352
1398
  * The URL of the current page.
1353
1399
  */
1354
- url: URL & { pathname: ResolvedPathname };
1400
+ url: ReadonlyURL & { readonly pathname: ResolvedPathname | (string & {}) };
1355
1401
  /**
1356
1402
  * The parameters of the current page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
1357
1403
  */
@@ -1390,7 +1436,62 @@ declare module '@sveltejs/kit' {
1390
1436
  /**
1391
1437
  * The shape of a param matcher. See [matching](https://svelte.dev/docs/kit/advanced-routing#Matching) for more info.
1392
1438
  */
1393
- export type ParamMatcher = (param: string) => boolean;
1439
+ export type ParamMatcher<Output = any> = StandardSchemaV1<string, Output>;
1440
+
1441
+ /**
1442
+ * A value that can be parsed from a URL param and losslessly encoded with `String(...)`.
1443
+ */
1444
+ export type ParamValue = string | number | boolean | bigint;
1445
+
1446
+ /**
1447
+ * A param matcher definition passed to [`defineParams`](https://svelte.dev/docs/kit/@sveltejs-kit#defineParams).
1448
+ */
1449
+ export type ParamDefinition =
1450
+ | ((param: string) => ParamValue | undefined)
1451
+ | StandardSchemaV1<string, ParamValue>;
1452
+
1453
+ /**
1454
+ * The return type of [`defineParams`](https://svelte.dev/docs/kit/@sveltejs-kit#defineParams).
1455
+ */
1456
+ export type DefinedParams<T extends Record<string, ParamDefinition>> = {
1457
+ readonly [K in keyof T]: ParamEntry<T[K]>;
1458
+ };
1459
+
1460
+ /**
1461
+ * Normalizes a property of defineParams (schema or function) to standard schema.
1462
+ */
1463
+ type ParamEntry<M> =
1464
+ M extends StandardSchemaV1<any, any>
1465
+ ? StandardSchemaV1.InferOutput<M> extends ParamValue
1466
+ ? StandardSchemaV1<any, M>
1467
+ : StandardSchemaV1<any, never>
1468
+ : M extends (param: string) => infer R
1469
+ ? Exclude<R, undefined> extends ParamValue
1470
+ ? StandardSchemaV1<any, Exclude<R, undefined>>
1471
+ : StandardSchemaV1<any, never>
1472
+ : never;
1473
+
1474
+ /**
1475
+ * Extracts the param type from a matcher.
1476
+ */
1477
+ export type MatcherParam<M extends StandardSchemaV1<any, any>> =
1478
+ M extends StandardSchemaV1<any, infer Inner>
1479
+ ? Inner extends ParamValue
1480
+ ? Inner
1481
+ : Inner extends StandardSchemaV1<any, any>
1482
+ ? StandardSchemaV1.InferOutput<Inner> extends ParamValue
1483
+ ? StandardSchemaV1.InferOutput<Inner>
1484
+ : never
1485
+ : never
1486
+ : never;
1487
+
1488
+ /**
1489
+ * Define [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#Matching) for your app.
1490
+ *
1491
+ * */
1492
+ export function defineParams<T extends Record<string, ParamDefinition>>(
1493
+ definitions: T
1494
+ ): DefinedParams<T>;
1394
1495
 
1395
1496
  /**
1396
1497
  * A single entry yielded by [`requested`](https://svelte.dev/docs/kit/$app-server#requested)
@@ -1467,7 +1568,7 @@ declare module '@sveltejs/kit' {
1467
1568
  * - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.
1468
1569
  * - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).
1469
1570
  * - Internal requests (e.g. for `+server.js` routes) go directly to the handler function when running on the server, without the overhead of an HTTP call.
1470
- * - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle)
1571
+ * - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://svelte.dev/docs/kit/hooks#handle)
1471
1572
  * - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.
1472
1573
  *
1473
1574
  * You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies).
@@ -1478,11 +1579,15 @@ declare module '@sveltejs/kit' {
1478
1579
  */
1479
1580
  getClientAddress: () => string;
1480
1581
  /**
1481
- * Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle).
1582
+ * Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#handle).
1482
1583
  */
1483
1584
  locals: App.Locals;
1484
1585
  /**
1485
1586
  * The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
1587
+ *
1588
+ * In the context of a remote function request initiated by the client, this relates to the page the remote function
1589
+ * was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use this to determine
1590
+ * whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
1486
1591
  */
1487
1592
  params: Params;
1488
1593
  /**
@@ -1499,6 +1604,10 @@ declare module '@sveltejs/kit' {
1499
1604
  route: {
1500
1605
  /**
1501
1606
  * 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.
1607
+ *
1608
+ * In the context of a remote function request initiated by the client, this relates to the page the remote function
1609
+ * was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use this to determine
1610
+ * whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
1502
1611
  */
1503
1612
  id: RouteId;
1504
1613
  };
@@ -1527,6 +1636,10 @@ declare module '@sveltejs/kit' {
1527
1636
  setHeaders: (headers: Record<string, string>) => void;
1528
1637
  /**
1529
1638
  * The requested URL.
1639
+ *
1640
+ * In the context of a remote function request initiated by the client, this relates to the page the remote function
1641
+ * was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use this to determine
1642
+ * whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
1530
1643
  */
1531
1644
  url: URL;
1532
1645
  /**
@@ -1585,7 +1698,9 @@ declare module '@sveltejs/kit' {
1585
1698
  */
1586
1699
  filterSerializedResponseHeaders?: (name: string, value: string) => boolean;
1587
1700
  /**
1588
- * Determines what should be added to the `<head>` tag to preload it.
1701
+ * Determines which files should be preloaded. Files are preloaded via `<link>` tags added to the
1702
+ * `<head>` tag; if `output.linkHeaderPreload` is enabled, dynamically rendered pages use the
1703
+ * [`Link` response header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link) instead.
1589
1704
  * By default, `js` and `css` files will be preloaded.
1590
1705
  * @param input the type of the file and its path
1591
1706
  */
@@ -1620,25 +1735,17 @@ declare module '@sveltejs/kit' {
1620
1735
  read?: (file: string) => MaybePromise<ReadableStream | null>;
1621
1736
  }
1622
1737
 
1738
+ /**
1739
+ * Information required to instantiate a new `Server` instance.
1740
+ */
1623
1741
  export interface SSRManifest {
1742
+ /** The directory where SvelteKit keeps its stuff, including static assets (such as JS and CSS) and internally-used routes. */
1624
1743
  appDir: string;
1744
+ /** The `base` and `appDir` settings combined without a leading slash. */
1625
1745
  appPath: string;
1626
- /** Static files from `kit.config.files.assets` and the service worker (if any). */
1746
+ /** Static files from `config.files.assets` and the service worker (if any). */
1627
1747
  assets: Set<string>;
1628
1748
  mimeTypes: Record<string, string>;
1629
-
1630
- /** private fields */
1631
- _: {
1632
- client: NonNullable<BuildData['client']>;
1633
- nodes: SSRNodeLoader[];
1634
- /** hashed filename -> import to that file */
1635
- remotes: Record<string, () => Promise<any>>;
1636
- routes: SSRRoute[];
1637
- prerendered_routes: Set<string>;
1638
- matchers: () => Promise<Record<string, ParamMatcher>>;
1639
- /** A `[file]: size` map of all assets imported by server code. */
1640
- server_assets: Record<string, number>;
1641
- };
1642
1749
  }
1643
1750
 
1644
1751
  /**
@@ -1767,7 +1874,7 @@ declare module '@sveltejs/kit' {
1767
1874
  | { type: 'success'; status: number; data?: Success }
1768
1875
  | { type: 'failure'; status: number; data?: Failure }
1769
1876
  | { type: 'redirect'; status: number; location: string }
1770
- | { type: 'error'; status?: number; error: any };
1877
+ | { type: 'error'; status?: number; error: App.Error };
1771
1878
 
1772
1879
  /**
1773
1880
  * The object returned by the [`error`](https://svelte.dev/docs/kit/@sveltejs-kit#error) function.
@@ -1823,6 +1930,14 @@ declare module '@sveltejs/kit' {
1823
1930
  restore: (snapshot: T) => void;
1824
1931
  }
1825
1932
 
1933
+ export type ReadonlyURLSearchParams = Omit<URLSearchParams, 'set' | 'append' | 'delete' | 'sort'>;
1934
+
1935
+ export type ReadonlyURL = Readonly<
1936
+ Omit<URL, 'searchParams'> & {
1937
+ searchParams: ReadonlyURLSearchParams;
1938
+ }
1939
+ >;
1940
+
1826
1941
  // If T is unknown or has an index signature, the types below will recurse indefinitely and create giant unions that TS can't handle
1827
1942
  type WillRecurseIndefinitely<T> = unknown extends T ? true : string extends keyof T ? true : false;
1828
1943
 
@@ -1916,6 +2031,10 @@ declare module '@sveltejs/kit' {
1916
2031
  value(): DeepPartial<T>;
1917
2032
  /** Set the values that will be submitted */
1918
2033
  set(input: DeepPartial<T>): DeepPartial<T>;
2034
+ /** Whether the field or any nested field has been interacted with since the form was mounted */
2035
+ touched(): boolean;
2036
+ /** Whether the field or any nested field has been edited since the form was mounted */
2037
+ dirty(): boolean;
1919
2038
  /** Validation issues, if any */
1920
2039
  issues(): RemoteFormIssue[] | undefined;
1921
2040
  };
@@ -2030,7 +2149,7 @@ declare module '@sveltejs/kit' {
2030
2149
  type MaybeArray<T> = T | T[];
2031
2150
 
2032
2151
  export interface RemoteFormInput {
2033
- [key: string]: MaybeArray<string | number | boolean | File | RemoteFormInput>;
2152
+ [key: string]: MaybeArray<string | number | boolean | File | RemoteFormInput> | undefined;
2034
2153
  }
2035
2154
 
2036
2155
  export interface RemoteFormIssue {
@@ -2076,6 +2195,24 @@ declare module '@sveltejs/kit' {
2076
2195
  issues: StandardSchemaV1.Issue[];
2077
2196
  }
2078
2197
 
2198
+ /**
2199
+ * The form instance as received inside an `enhance` callback. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
2200
+ */
2201
+ export type RemoteFormEnhanceInstance<
2202
+ Input extends RemoteFormInput | void = RemoteFormInput | void,
2203
+ Output = any
2204
+ > = Omit<RemoteForm<Input, Output>, 'enhance' | 'element'> & {
2205
+ readonly element: HTMLFormElement;
2206
+ };
2207
+
2208
+ /**
2209
+ * The callback passed to a remote form's `enhance` method. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
2210
+ */
2211
+ export type RemoteFormEnhanceCallback<
2212
+ Input extends RemoteFormInput | void = RemoteFormInput | void,
2213
+ Output = any
2214
+ > = (form: RemoteFormEnhanceInstance<Input, Output>) => MaybePromise<void>;
2215
+
2079
2216
  /**
2080
2217
  * The type of a remote `form` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
2081
2218
  */
@@ -2092,13 +2229,7 @@ declare module '@sveltejs/kit' {
2092
2229
  updates: (...updates: RemoteQueryUpdate[]) => Promise<boolean>;
2093
2230
  };
2094
2231
  /** Use the `enhance` method to influence what happens when the form is submitted. */
2095
- enhance(
2096
- callback: (
2097
- form: Omit<RemoteForm<Input, Output>, 'enhance' | 'element'> & {
2098
- readonly element: HTMLFormElement;
2099
- }
2100
- ) => MaybePromise<void>
2101
- ): {
2232
+ enhance(callback: RemoteFormEnhanceCallback<Input, Output>): {
2102
2233
  method: 'POST';
2103
2234
  action: string;
2104
2235
  [attachment: symbol]: (node: HTMLFormElement) => void;
@@ -2122,8 +2253,13 @@ declare module '@sveltejs/kit' {
2122
2253
  preflight(schema: StandardSchemaV1<Input, any>): RemoteForm<Input, Output>;
2123
2254
  /** Validate the form contents programmatically */
2124
2255
  validate(options?: {
2125
- /** Set this to `true` to also show validation issues of fields that haven't been touched yet. */
2126
- includeUntouched?: boolean;
2256
+ /**
2257
+ * Set this to `true` to also show validation issues of fields that haven't yet been
2258
+ * edited and blurred. This option is ignored for forms that have previously been
2259
+ * submitted, in which case all fields are always subject to validation
2260
+ * (unless the form is reset, at which point it is treated as pristine)
2261
+ */
2262
+ all?: boolean;
2127
2263
  /** Set this to `true` to only run the `preflight` validation. */
2128
2264
  preflightOnly?: boolean;
2129
2265
  }): Promise<void>;
@@ -2131,6 +2267,8 @@ declare module '@sveltejs/kit' {
2131
2267
  get result(): Output | undefined;
2132
2268
  /** The number of pending submissions */
2133
2269
  get pending(): number;
2270
+ /** True if the form has been submitted at least once, and hasn't been reset since */
2271
+ get submitted(): boolean;
2134
2272
  /** Access form fields using object notation */
2135
2273
  fields: RemoteFormFieldsRoot<Input>;
2136
2274
  };
@@ -2154,8 +2292,8 @@ declare module '@sveltejs/kit' {
2154
2292
  | RemoteQueryOverride;
2155
2293
 
2156
2294
  export type RemoteResource<T> = Promise<T> & {
2157
- /** The error in case the query fails. Most often this is a [`HttpError`](https://svelte.dev/docs/kit/@sveltejs-kit#HttpError) but it isn't guaranteed to be. */
2158
- get error(): any;
2295
+ /** The error in case the query fails. */
2296
+ get error(): App.Error | undefined;
2159
2297
  /** `true` before the first result is available and during refreshes */
2160
2298
  get loading(): boolean;
2161
2299
  } & (
@@ -2256,7 +2394,7 @@ declare module '@sveltejs/kit' {
2256
2394
 
2257
2395
  /**
2258
2396
  * [Environment variables](https://svelte.dev/docs/kit/environment-variables) can be configured by exporting
2259
- * a `variables` object from `src/env.ts`, using [`defineEnvVars`](https://svelte.dev/docs/kit/@sveltejs-kit-hooks#defineEnvVars).
2397
+ * a `variables` object from `src/env.ts`, using [`defineEnvVars`](https://svelte.dev/docs/kit/@sveltejs-kit-env#defineEnvVars).
2260
2398
  */
2261
2399
  export interface EnvVarConfig<T> {
2262
2400
  /**
@@ -2275,17 +2413,36 @@ declare module '@sveltejs/kit' {
2275
2413
  static?: boolean;
2276
2414
  /**
2277
2415
  * A [Standard Schema](https://standardschema.dev/) validator that is applied to the value when the app starts.
2416
+ * Alternatively, a function that returns the (possibly transformed) value, or throws an error explaining
2417
+ * the problem. Returning `undefined` is valid, so a function can describe an optional variable.
2278
2418
  * The validator can output any value — not necessarily a string — but public, non-static values must be
2279
2419
  * serializable by [devalue](https://github.com/sveltejs/devalue) so that they can be sent to the browser.
2280
2420
  *
2281
- * If omitted, the value must be a non-empty string.
2421
+ * If omitted, the value must be set, but may be an empty string.
2282
2422
  */
2283
- schema?: StandardSchemaV1<string | undefined, T>;
2423
+ schema?: StandardSchemaV1<string | undefined, T> | ((value: string | undefined) => T | undefined);
2284
2424
  /**
2285
2425
  * A description of the variable that will be used for inline documentation on hover.
2286
2426
  */
2287
2427
  description?: string;
2288
2428
  }
2429
+
2430
+ /**
2431
+ * The return type of [`defineEnvVars`](https://svelte.dev/docs/kit/@sveltejs-kit-env#defineEnvVars).
2432
+ */
2433
+ export type DefinedEnvVars<T extends Record<string, EnvVarConfig<any>>> = {
2434
+ readonly [K in keyof T]: EnvVarEntry<T[K]>;
2435
+ };
2436
+
2437
+ /**
2438
+ * Normalizes an environment variable config's schema (standard schema or function) to standard schema.
2439
+ */
2440
+ type EnvVarEntry<C extends EnvVarConfig<any>> =
2441
+ C['schema'] extends StandardSchemaV1<any, any>
2442
+ ? C
2443
+ : C['schema'] extends (value: any) => infer R
2444
+ ? Omit<C, 'schema'> & { schema: StandardSchemaV1<string | undefined, R> }
2445
+ : C;
2289
2446
  interface AdapterEntry {
2290
2447
  /**
2291
2448
  * A string that uniquely identifies an HTTP service (e.g. serverless function) and is used for deduplication.
@@ -2343,7 +2500,10 @@ declare module '@sveltejs/kit' {
2343
2500
  | 'unsafe-eval'
2344
2501
  | 'unsafe-hashes'
2345
2502
  | 'unsafe-inline'
2503
+ | 'unsafe-allow-redirects'
2504
+ | 'unsafe-webtransport-hashes'
2346
2505
  | 'wasm-unsafe-eval'
2506
+ | 'trusted-types-eval'
2347
2507
  | 'none';
2348
2508
  type CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`;
2349
2509
  type FrameSource = HostSource | SchemeSource | 'self' | 'none';
@@ -2352,7 +2512,16 @@ declare module '@sveltejs/kit' {
2352
2512
  type HostProtocolSchemes = `${string}://` | '';
2353
2513
  type HttpDelineator = '/' | '?' | '#' | '\\';
2354
2514
  type PortScheme = `:${number}` | '' | ':*';
2355
- type SchemeSource = 'http:' | 'https:' | 'data:' | 'mediastream:' | 'blob:' | 'filesystem:';
2515
+ type SchemeSource =
2516
+ | 'http:'
2517
+ | 'https:'
2518
+ | 'ws:'
2519
+ | 'wss:'
2520
+ | 'data:'
2521
+ | 'mediastream:'
2522
+ | 'blob:'
2523
+ | 'filesystem:'
2524
+ | (`${string}:` & {});
2356
2525
  type Source = HostSource | SchemeSource | CryptoSource | BaseSource;
2357
2526
  type Sources = Source[];
2358
2527
  }
@@ -2429,10 +2598,18 @@ declare module '@sveltejs/kit' {
2429
2598
  interface Logger {
2430
2599
  (msg: string): void;
2431
2600
  success(msg: string): void;
2601
+ /** Print a bold red message to stderr */
2432
2602
  error(msg: string): void;
2603
+ /** Print a bold yellow message to stderr */
2433
2604
  warn(msg: string): void;
2605
+ /** Print faded text to stdout if `verbose === true` */
2434
2606
  minor(msg: string): void;
2607
+ /** Print to stdout if `verbose === true` */
2435
2608
  info(msg: string): void;
2609
+ /** Print to stderr without formatting */
2610
+ err(msg: string): void;
2611
+ /** Print a bold red message, followed by a stack trace for each error (following `.cause` chains) */
2612
+ prettyError(error: unknown, caller?: string): void;
2436
2613
  }
2437
2614
 
2438
2615
  type MaybePromise<T> = T | Promise<T>;
@@ -2494,6 +2671,10 @@ declare module '@sveltejs/kit' {
2494
2671
  (details: { routes: string[]; message: string }): void;
2495
2672
  }
2496
2673
 
2674
+ interface PrerenderInvalidUrlHandler {
2675
+ (details: { href: string; referrer: string | null; message: string }): void;
2676
+ }
2677
+
2497
2678
  type PrerenderHttpErrorHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderHttpErrorHandler;
2498
2679
  type PrerenderMissingIdHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderMissingIdHandler;
2499
2680
  type PrerenderUnseenRoutesHandlerValue =
@@ -2506,6 +2687,11 @@ declare module '@sveltejs/kit' {
2506
2687
  | 'warn'
2507
2688
  | 'ignore'
2508
2689
  | PrerenderEntryGeneratorMismatchHandler;
2690
+ type PrerenderInvalidUrlHandlerValue =
2691
+ | 'fail'
2692
+ | 'warn'
2693
+ | 'ignore'
2694
+ | PrerenderInvalidUrlHandler;
2509
2695
 
2510
2696
  export type PrerenderOption = boolean | 'auto';
2511
2697
 
@@ -2520,9 +2706,6 @@ declare module '@sveltejs/kit' {
2520
2706
  rest: boolean;
2521
2707
  }
2522
2708
 
2523
- /** @default 'never' */
2524
- type TrailingSlash = 'never' | 'always' | 'ignore';
2525
-
2526
2709
  type DeepPartial<T> = T extends Record<PropertyKey, unknown> | unknown[]
2527
2710
  ? {
2528
2711
  [K in keyof T]?: T[K] extends Record<PropertyKey, unknown> | unknown[]
@@ -2532,246 +2715,21 @@ declare module '@sveltejs/kit' {
2532
2715
  : T | undefined;
2533
2716
 
2534
2717
  type IsAny<T> = 0 extends 1 & T ? true : false;
2535
- interface Asset {
2536
- file: string;
2537
- size: number;
2538
- type: string | null;
2539
- }
2540
-
2541
- interface BuildData {
2542
- app_dir: string;
2543
- app_path: string;
2544
- manifest_data: ManifestData;
2545
- out_dir: string;
2546
- service_worker: string | null;
2547
- client: {
2548
- /** Path to the client entry point. */
2549
- start: string;
2550
- /** Path to the generated `app.js` file that contains the client manifest. Only set in case of `bundleStrategy === 'split'`. */
2551
- app?: string;
2552
- /** JS files that the client entry point relies on. */
2553
- imports: string[];
2554
- /**
2555
- * JS files that represent the entry points of the layouts/pages.
2556
- * An entry is undefined if the layout/page has no component or universal file (i.e. only has a `.server.js` file).
2557
- * Only set in case of `router.resolution === 'server'`.
2558
- */
2559
- nodes?: Array<string | undefined>;
2560
- /**
2561
- * CSS files referenced in the entry points of the layouts/pages.
2562
- * An entry is undefined if the layout/page has no component or universal file (i.e. only has a `.server.js` file) or if has no CSS.
2563
- * Only set in case of `router.resolution === 'server'`.
2564
- */
2565
- css?: Array<string[] | undefined>;
2566
- /**
2567
- * Contains the client route manifest in a form suitable for the server which is used for server-side route resolution.
2568
- * Notably, it contains all routes, regardless of whether they are prerendered or not (those are missing in the optimized server route manifest).
2569
- * Only set in case of `router.resolution === 'server'`.
2570
- */
2571
- routes?: SSRClientRoute[];
2572
- stylesheets: string[];
2573
- fonts: string[];
2574
- uses_env_dynamic_public: boolean;
2575
- /** Only set in case of `bundleStrategy === 'inline'`. */
2576
- inline?: {
2577
- script: string;
2578
- style: string | undefined;
2579
- };
2580
- } | null;
2581
- server_manifest: import('vite').Manifest;
2582
- }
2583
-
2584
- interface ManifestData {
2585
- /** Static files from `kit.config.files.assets`. */
2586
- assets: Asset[];
2587
- hooks: {
2588
- client: string | null;
2589
- server: string | null;
2590
- universal: string | null;
2591
- };
2592
- nodes: PageNode[];
2593
- routes: RouteData[];
2594
- matchers: Record<string, string>;
2595
- }
2596
-
2597
- interface PageNode {
2598
- depth: number;
2599
- /** The `+page/layout.svelte`. */
2600
- component?: string; // TODO supply default component if it's missing (bit of an edge case)
2601
- /** The `+page/layout.js/.ts`. */
2602
- universal?: string;
2603
- /** The `+page/layout.server.js/ts`. */
2604
- server?: string;
2605
- parent_id?: string;
2606
- parent?: PageNode;
2607
- /** Filled with the pages that reference this layout (if this is a layout). */
2608
- child_pages?: PageNode[];
2609
- /** The final page options for a node if it was statically analysable */
2610
- page_options?: PageOptions | null;
2611
- }
2612
-
2613
2718
  type RecursiveRequired<T> = {
2614
2719
  // Recursive implementation of TypeScript's Required utility type.
2615
2720
  // Will recursively continue until it reaches a primitive or Function
2616
2721
  // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
2617
- [K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type
2722
+ [K in keyof T]-?: Extract<T[K], Function | (`${string}:` & {})> extends never // If it does not have a Function type
2618
2723
  ? RecursiveRequired<T[K]> // recursively continue through.
2619
2724
  : T[K]; // Use the exact type for everything else
2620
2725
  };
2621
2726
 
2622
- interface RouteParam {
2623
- name: string;
2624
- matcher: string;
2625
- optional: boolean;
2626
- rest: boolean;
2627
- chained: boolean;
2628
- }
2629
-
2630
- /**
2631
- * Represents a route segment in the app. It can either be an intermediate node
2632
- * with only layout/error pages, or a leaf, at which point either `page` and `leaf`
2633
- * or `endpoint` is set.
2634
- */
2635
- interface RouteData {
2636
- id: string;
2637
- parent: RouteData | null;
2638
-
2639
- segment: string;
2640
- pattern: RegExp;
2641
- params: RouteParam[];
2642
-
2643
- layout: PageNode | null;
2644
- error: PageNode | null;
2645
- leaf: PageNode | null;
2646
-
2647
- page: {
2648
- layouts: Array<number | undefined>;
2649
- errors: Array<number | undefined>;
2650
- leaf: number;
2651
- } | null;
2652
-
2653
- endpoint: {
2654
- file: string;
2655
- /** The final page options for the endpoint if it was statically analysable */
2656
- page_options: PageOptions | null;
2657
- } | null;
2658
- }
2659
-
2660
- interface SSRComponent {
2661
- default: {
2662
- render(
2663
- props: Record<string, any>,
2664
- opts: { context: Map<any, any>; csp?: { nonce?: string; hash?: boolean } }
2665
- ): {
2666
- html: string;
2667
- head: string;
2668
- css: {
2669
- code: string;
2670
- map: any; // TODO
2671
- };
2672
- /** Until we require all Svelte versions that support hashes, this might not be defined */
2673
- hashes?: {
2674
- script: Array<`sha256-${string}`>;
2675
- };
2676
- };
2677
- };
2678
- }
2679
-
2680
- type SSRComponentLoader = () => Promise<SSRComponent>;
2681
-
2682
- interface UniversalNode {
2683
- /** Is `null` in case static analysis succeeds but the node is ssr=false */
2684
- load?: Load;
2685
- prerender?: PrerenderOption;
2686
- ssr?: boolean;
2687
- csr?: boolean;
2688
- trailingSlash?: TrailingSlash;
2689
- config?: any;
2690
- entries?: PrerenderEntryGenerator;
2691
- }
2692
-
2693
- interface ServerNode {
2694
- load?: ServerLoad;
2695
- prerender?: PrerenderOption;
2696
- ssr?: boolean;
2697
- csr?: boolean;
2698
- trailingSlash?: TrailingSlash;
2699
- actions?: Actions;
2700
- config?: any;
2701
- entries?: PrerenderEntryGenerator;
2702
- }
2703
-
2704
- interface SSRNode {
2705
- /** index into the `nodes` array in the generated `client/app.js`. */
2706
- index: number;
2707
- /** external JS files that are loaded on the client. `imports[0]` is the entry point (e.g. `client/nodes/0.js`) */
2708
- imports: string[];
2709
- /** external CSS files that are loaded on the client */
2710
- stylesheets: string[];
2711
- /** external font files that are loaded on the client */
2712
- fonts: string[];
2713
-
2714
- universal_id?: string;
2715
- server_id?: string;
2716
-
2717
- /**
2718
- * During development, all styles are inlined for the page to avoid FOUC.
2719
- * But in production, this stores styles that are below the inline threshold
2720
- */
2721
- inline_styles?(): MaybePromise<
2722
- Record<string, string | ((assets: string, base: string) => string)>
2723
- >;
2724
- /** Svelte component */
2725
- component?: SSRComponentLoader;
2726
- /** +page.js or +layout.js */
2727
- universal?: UniversalNode;
2728
- /** +page.server.js, +layout.server.js, or +server.js */
2729
- server?: ServerNode;
2730
- }
2731
-
2732
- type SSRNodeLoader = () => Promise<SSRNode>;
2733
-
2734
- interface PageNodeIndexes {
2735
- errors: Array<number | undefined>;
2736
- layouts: Array<number | undefined>;
2737
- leaf: number;
2738
- }
2739
-
2740
- type PrerenderEntryGenerator = () => MaybePromise<Array<Record<string, string>>>;
2741
-
2742
- type SSREndpoint = Partial<Record<HttpMethod, RequestHandler>> & {
2743
- prerender?: PrerenderOption;
2744
- trailingSlash?: TrailingSlash;
2745
- config?: any;
2746
- entries?: PrerenderEntryGenerator;
2747
- fallback?: RequestHandler;
2748
- };
2749
-
2750
- interface SSRRoute {
2751
- id: string;
2752
- pattern: RegExp;
2753
- params: RouteParam[];
2754
- page: PageNodeIndexes | null;
2755
- endpoint: (() => Promise<SSREndpoint>) | null;
2756
- endpoint_id?: string;
2757
- }
2758
-
2759
- interface SSRClientRoute {
2760
- id: string;
2761
- pattern: RegExp;
2762
- params: RouteParam[];
2763
- errors: Array<number | undefined>;
2764
- layouts: Array<[has_server_load: boolean, node_id: number] | undefined>;
2765
- leaf: [has_server_load: boolean, node_id: number];
2766
- }
2767
-
2768
- type ValidatedConfig = Config & {
2727
+ type ValidatedConfig = Omit<Config, 'kit'> & {
2769
2728
  kit: ValidatedKitConfig;
2770
2729
  extensions: string[];
2771
2730
  };
2772
2731
 
2773
- // TODO: remove the omit in 4.0
2774
- type ValidatedKitConfig = Omit<RecursiveRequired<KitConfig>, 'adapter'>;
2732
+ type ValidatedKitConfig = RecursiveRequired<KitConfig>;
2775
2733
  /**
2776
2734
  * Throws an error with a HTTP status code and an optional message.
2777
2735
  * When called during request handling, this will cause SvelteKit to
@@ -2782,20 +2740,38 @@ declare module '@sveltejs/kit' {
2782
2740
  * @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
2783
2741
  * @throws {Error} If the provided status is invalid (not between 400 and 599).
2784
2742
  */
2785
- export function error(status: number, body: App.Error): never;
2743
+ export function error(status: number, body: Omit<App.Error, "status"> & {
2744
+ status?: App.Error["status"];
2745
+ }): never;
2786
2746
  /**
2787
2747
  * Throws an error with a HTTP status code and an optional message.
2788
2748
  * When called during request handling, this will cause SvelteKit to
2789
2749
  * return an error response without invoking `handleError`.
2790
2750
  * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
2791
2751
  * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
2792
- * @param body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property.
2752
+ * @param body The error message.
2753
+ * @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
2754
+ * @throws {Error} If the provided status is invalid (not between 400 and 599).
2755
+ */
2756
+ export function error(status: number, body: {
2757
+ status: number;
2758
+ message: string;
2759
+ } extends App.Error ? string | void | undefined : never): never;
2760
+ /**
2761
+ * Throws an error with a HTTP status code and an optional message.
2762
+ * When called during request handling, this will cause SvelteKit to
2763
+ * return an error response without invoking `handleError`.
2764
+ * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
2765
+ * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
2766
+ * @param body The error message.
2767
+ * @param properties Additional properties of the App.Error type.
2793
2768
  * @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
2794
2769
  * @throws {Error} If the provided status is invalid (not between 400 and 599).
2795
2770
  */
2796
- export function error(status: number, body?: {
2771
+ export function error(status: number, body: string, properties: {
2772
+ status: number;
2797
2773
  message: string;
2798
- } extends App.Error ? App.Error | string | undefined : never): never;
2774
+ } extends App.Error ? never : Omit<App.Error, "status" | "message">): never;
2799
2775
  /**
2800
2776
  * Checks whether this is an error thrown by {@link error}.
2801
2777
  * @param status The status to filter for.
@@ -2816,10 +2792,13 @@ declare module '@sveltejs/kit' {
2816
2792
  *
2817
2793
  * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages). Must be in the range 300-308.
2818
2794
  * @param location The location to redirect to.
2795
+ * @param options To redirect to an external URL, you must pass `{ external: true }` to allow any external URL except `javascript:` URLs, or `{ external: [...] }` with an allowlist of permitted origins.
2819
2796
  * @throws {import('./public.js').Redirect} This error instructs SvelteKit to redirect to the specified location.
2820
- * @throws {Error} If the provided status is invalid or the location cannot be used as a header value.
2797
+ * @throws {Error} If the provided status is invalid, the location cannot be used as a header value, or the location is an external URL without permission.
2821
2798
  * */
2822
- export function redirect(status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | ({} & number), location: string | URL): never;
2799
+ export function redirect(status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | ({} & number), location: string | URL, options?: {
2800
+ external?: boolean | string[];
2801
+ }): never;
2823
2802
  /**
2824
2803
  * Checks whether this is a redirect thrown by {@link redirect}.
2825
2804
  * @param e The object to check.
@@ -2863,7 +2842,7 @@ declare module '@sveltejs/kit' {
2863
2842
  * ```ts
2864
2843
  * import { invalid } from '@sveltejs/kit';
2865
2844
  * import { form } from '$app/server';
2866
- * import { tryLogin } from '$lib/server/auth';
2845
+ * import { tryLogin } from '#lib/server/auth';
2867
2846
  * import * as v from 'valibot';
2868
2847
  *
2869
2848
  * export const login = form(
@@ -2905,21 +2884,45 @@ declare module '@sveltejs/kit' {
2905
2884
  wasNormalized: boolean;
2906
2885
  denormalize: (url?: string | URL) => URL;
2907
2886
  };
2908
- type ValidPageOption = (typeof valid_page_options_array)[number];
2909
- type PageOptions = Partial<Record<ValidPageOption, any>>;
2910
- const valid_page_options_array: readonly ["ssr", "prerender", "csr", "trailingSlash", "config", "entries", "load"];
2911
2887
  export const VERSION: string;
2912
2888
 
2913
2889
  export {};
2914
2890
  }
2915
2891
 
2916
- declare module '@sveltejs/kit/hooks' {
2917
- import type { EnvVarConfig, Handle } from '@sveltejs/kit';
2892
+ declare module '@sveltejs/kit/env' {
2893
+ import type { EnvVarConfig, DefinedEnvVars } from '@sveltejs/kit';
2918
2894
  /**
2919
2895
  * Utility for defining [environment variables](https://svelte.dev/docs/kit/environment-variables),
2920
2896
  * which are made available via `$app/env/public` and `$app/env/private`.
2897
+ *
2898
+ * @example
2899
+ * ```js
2900
+ * import { defineEnvVars } from '@sveltejs/kit/env';
2901
+ * import * as v from 'valibot';
2902
+ *
2903
+ * export const variables = defineEnvVars({
2904
+ * API_URL: {
2905
+ * schema: v.pipe(v.string(), v.url())
2906
+ * },
2907
+ * PORT: {
2908
+ * schema: (value) => {
2909
+ * if (value === undefined) return 3000;
2910
+ * const port = Number(value);
2911
+ * if (!Number.isInteger(port)) throw new Error('PORT must be an integer');
2912
+ * return port;
2913
+ * }
2914
+ * }
2915
+ * });
2916
+ * ```
2917
+ *
2921
2918
  * */
2922
- export function defineEnvVars<T extends Record<string, EnvVarConfig<any>>>(variables: T): T;
2919
+ export function defineEnvVars<T extends Record<string, EnvVarConfig<any>>>(variables: T): DefinedEnvVars<T>;
2920
+
2921
+ export {};
2922
+ }
2923
+
2924
+ declare module '@sveltejs/kit/hooks' {
2925
+ import type { Handle } from '@sveltejs/kit';
2923
2926
  /**
2924
2927
  * A helper function for sequencing multiple `handle` calls in a middleware-like manner.
2925
2928
  * The behavior for the `handle` options is as follows:
@@ -2988,6 +2991,8 @@ declare module '@sveltejs/kit/hooks' {
2988
2991
  * first post-processing
2989
2992
  * ```
2990
2993
  *
2994
+ * Calling `resolve` invokes the next handler in the sequence (or SvelteKit itself, if it is the last one). To pass data between handlers, use `event.locals`.
2995
+ *
2991
2996
  * @param handlers The chain of `handle` functions
2992
2997
  * */
2993
2998
  export function sequence(...handlers: Handle[]): Handle;
@@ -3000,9 +3005,9 @@ declare module '@sveltejs/kit/node' {
3000
3005
  request: import("http").IncomingMessage;
3001
3006
  base: string;
3002
3007
  bodySizeLimit?: number;
3003
- }): Promise<Request>;
3008
+ }): Request;
3004
3009
 
3005
- export function setResponse(res: import("http").ServerResponse, response: Response): Promise<void>;
3010
+ export function setResponse(res: import("http").ServerResponse, response: Response): void;
3006
3011
  /**
3007
3012
  * Converts a file on disk to a readable stream
3008
3013
  * @since 2.4.0
@@ -3013,13 +3018,19 @@ declare module '@sveltejs/kit/node' {
3013
3018
  }
3014
3019
 
3015
3020
  declare module '@sveltejs/kit/vite' {
3016
- import type { SvelteConfig } from '@sveltejs/vite-plugin-svelte';
3021
+ import type { KitConfig } from '@sveltejs/kit';
3022
+ import type { Options, SvelteConfig } from '@sveltejs/vite-plugin-svelte';
3017
3023
  import type { Plugin } from 'vite';
3018
3024
  /**
3019
3025
  * Returns the SvelteKit Vite plugins.
3020
- * Since version 2.62.0 you can pass [configuration](configuration) directly, in which case `svelte.config.js` is ignored.
3026
+ * Any options that don't belong to SvelteKit are passed through to `vite-plugin-svelte`.
3027
+ *
3028
+ * Since version 3.0.0 you must pass [configuration](configuration) directly.
3029
+ *
3030
+ * Since version 2.62.0 you can pass configuration directly, in which case `svelte.config.js` is ignored.
3031
+ *
3021
3032
  * */
3022
- export function sveltekit(config?: import("@sveltejs/kit").KitConfig & Omit<SvelteConfig, "onwarn">): Promise<Plugin[]>;
3033
+ export function sveltekit(config?: KitConfig & Omit<Options, "onwarn"> & Pick<SvelteConfig, "vitePlugin">): Promise<Plugin[]>;
3023
3034
 
3024
3035
  export {};
3025
3036
  }
@@ -3041,7 +3052,7 @@ declare module '$app/env' {
3041
3052
  export const building: boolean;
3042
3053
 
3043
3054
  /**
3044
- * The value of `config.kit.version.name`.
3055
+ * The value of `config.version.name`.
3045
3056
  */
3046
3057
  export const version: string;
3047
3058
 
@@ -3141,17 +3152,20 @@ declare module '$app/navigation' {
3141
3152
  * Allows you to navigate programmatically to a given route, with options such as keeping the current element focused.
3142
3153
  * Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`.
3143
3154
  *
3144
- * For external URLs, use `window.location = url` instead of calling `goto(url)`.
3155
+ * `goto` is intended for navigations to routes that belong to the app.
3156
+ * If the URL does not resolve to a route within the app, the returned promise will reject.
3157
+ * For external URLs, use `window.location = url` to perform a full-page navigation instead of calling `goto(url)`.
3145
3158
  *
3146
- * @param url Where to navigate to. Note that if you've set [`config.kit.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.
3159
+ * @param url Where to navigate to. Note that if you've set [`config.paths.base`](https://svelte.dev/docs/kit/configuration#paths) and the URL is root-relative, you need to prepend the base path if you want to navigate within the app.
3147
3160
  * @param {Object} opts Options related to the navigation
3148
3161
  * */
3149
3162
  export function goto(url: string | URL, opts?: {
3150
3163
  replaceState?: boolean | undefined;
3151
3164
  noScroll?: boolean | undefined;
3152
3165
  keepFocus?: boolean | undefined;
3153
- invalidateAll?: boolean | undefined;
3166
+ refreshAll?: boolean | undefined;
3154
3167
  invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
3168
+ invalidateAll?: boolean | undefined;
3155
3169
  state?: App.PageState | undefined;
3156
3170
  }): Promise<void>;
3157
3171
  /**
@@ -3170,19 +3184,22 @@ declare module '$app/navigation' {
3170
3184
  * invalidate((url) => url.pathname === '/path');
3171
3185
  * ```
3172
3186
  * @param resource The invalidated URL
3187
+ * @param keepState If `true`, the current `page.state` will be preserved. Otherwise, it will be reset to an empty object. `false` by default.
3173
3188
  * */
3174
- export function invalidate(resource: string | URL | ((url: URL) => boolean)): Promise<void>;
3189
+ export function invalidate(resource: string | URL | ((url: URL) => boolean), keepState?: boolean): Promise<void>;
3175
3190
  /**
3176
3191
  * Causes all `load` and `query` functions belonging to the currently active page to re-run. Returns a `Promise` that resolves when the page is subsequently updated.
3192
+ *
3193
+ * Note that this resets `page.state` to an empty object. If you want to preserve `page.state` (for example when using [shallow routing](https://svelte.dev/docs/kit/shallow-routing)), use `refreshAll` instead.
3194
+ *
3195
+ * @deprecated Use [`refreshAll`](https://svelte.dev/docs/kit/$app-navigation#refreshAll) instead. Unlike `invalidateAll`, `refreshAll` does not reset `page.state`.
3177
3196
  * */
3178
3197
  export function invalidateAll(): Promise<void>;
3179
3198
  /**
3180
- * Causes all currently active remote functions to refresh, and all `load` functions belonging to the currently active page to re-run (unless disabled via the option argument).
3199
+ * Causes all currently active remote functions to refresh, and all `load` functions belonging to the currently active page to re-run.
3181
3200
  * Returns a `Promise` that resolves when the page is subsequently updated.
3182
3201
  * */
3183
- export function refreshAll({ includeLoadFunctions }?: {
3184
- includeLoadFunctions?: boolean;
3185
- }): Promise<void>;
3202
+ export function refreshAll(): Promise<void>;
3186
3203
  /**
3187
3204
  * Programmatically preloads the given page, which means
3188
3205
  * 1. ensuring that the code for the page is loaded, and
@@ -3194,13 +3211,17 @@ declare module '$app/navigation' {
3194
3211
  *
3195
3212
  * @param href Page to preload
3196
3213
  * */
3197
- export function preloadData(href: string): Promise<{
3214
+ export function preloadData(href: string): Promise<({
3198
3215
  type: "loaded";
3199
- status: number;
3200
3216
  data: Record<string, any>;
3201
3217
  } | {
3202
3218
  type: "redirect";
3203
3219
  location: string;
3220
+ } | {
3221
+ type: "error";
3222
+ error: App.Error;
3223
+ }) & {
3224
+ status: number;
3204
3225
  }>;
3205
3226
  /**
3206
3227
  * Programmatically imports the code for routes that haven't yet been fetched.
@@ -3229,49 +3250,9 @@ declare module '$app/navigation' {
3229
3250
  }
3230
3251
 
3231
3252
  declare module '$app/paths' {
3232
- import type { RouteIdWithSearchOrHash, PathnameWithSearchOrHash, ResolvedPathname, RouteId, RouteParams, Asset, Pathname as Pathname_1 } from '$app/types';
3233
- /**
3234
- * A string that matches [`config.kit.paths.base`](https://svelte.dev/docs/kit/configuration#paths).
3235
- *
3236
- * Example usage: `<a href="{base}/your-page">Link</a>`
3237
- *
3238
- * @deprecated Use [`resolve(...)`](https://svelte.dev/docs/kit/$app-paths#resolve) instead
3239
- */
3240
- export let base: '' | `/${string}`;
3241
-
3253
+ import type { Asset, RouteIdWithSearchOrHash, PathnameWithSearchOrHash, ResolvedPathname, Pathname, RouteId, RouteParams } from '$app/types';
3242
3254
  /**
3243
- * An absolute path that matches [`config.kit.paths.assets`](https://svelte.dev/docs/kit/configuration#paths).
3244
- *
3245
- * > [!NOTE] If a value for `config.kit.paths.assets` is specified, it will be replaced with `'/_svelte_kit_assets'` during `vite dev` or `vite preview`, since the assets don't yet live at their eventual URL.
3246
- *
3247
- * @deprecated Use [`asset(...)`](https://svelte.dev/docs/kit/$app-paths#asset) instead
3248
- */
3249
- export let assets: '' | `https://${string}` | `http://${string}` | '/_svelte_kit_assets';
3250
-
3251
- /**
3252
- * @deprecated Use [`resolve(...)`](https://svelte.dev/docs/kit/$app-paths#resolve) instead
3253
- */
3254
- export function resolveRoute<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash>(
3255
- ...args: ResolveArgs<T>
3256
- ): ResolvedPathname;
3257
- type StripSearchOrHash<T extends string> = T extends `${infer Pathname}?${string}`
3258
- ? Pathname
3259
- : T extends `${infer Pathname}#${string}`
3260
- ? Pathname
3261
- : T;
3262
-
3263
- type ResolveArgs<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash> =
3264
- T extends RouteId
3265
- ? RouteParams<T> extends Record<string, never>
3266
- ? [route: T]
3267
- : [route: T, params: RouteParams<T>]
3268
- : StripSearchOrHash<T> extends infer U extends RouteId
3269
- ? RouteParams<U> extends Record<string, never>
3270
- ? [route: T]
3271
- : [route: T, params: RouteParams<U>]
3272
- : [route: T];
3273
- /**
3274
- * Resolve the URL of an asset in your `static` directory, by prefixing it with [`config.kit.paths.assets`](https://svelte.dev/docs/kit/configuration#paths) if configured, or otherwise by prefixing it with the base path.
3255
+ * Resolve the URL of an asset in your `static` directory, by prefixing it with [`config.paths.assets`](https://svelte.dev/docs/kit/configuration#paths) if configured, or otherwise by prefixing it with the base path.
3275
3256
  *
3276
3257
  * During server rendering, the base path is relative and depends on the page currently being rendered.
3277
3258
  *
@@ -3326,17 +3307,33 @@ declare module '$app/paths' {
3326
3307
  * @since 2.52.0
3327
3308
  *
3328
3309
  * */
3329
- export function match(url: Pathname_1 | URL | (string & {})): Promise<{
3330
- id: RouteId;
3331
- params: Record<string, string>;
3332
- } | null>;
3310
+ export function match(url: Pathname | URL | (string & {})): Promise<{ [K in RouteId]: {
3311
+ id: K;
3312
+ params: RouteParams<K>;
3313
+ }; }[RouteId] | null>;
3314
+ type StripSearchOrHash<T extends string> = T extends `${infer Pathname}?${string}`
3315
+ ? Pathname
3316
+ : T extends `${infer Pathname}#${string}`
3317
+ ? Pathname
3318
+ : T;
3319
+
3320
+ type ResolveArgs<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash> =
3321
+ T extends RouteId
3322
+ ? RouteParams<T> extends Record<string, never>
3323
+ ? [route: T]
3324
+ : [route: T, params: RouteParams<T>]
3325
+ : StripSearchOrHash<T> extends infer U extends RouteId
3326
+ ? RouteParams<U> extends Record<string, never>
3327
+ ? [route: T]
3328
+ : [route: T, params: RouteParams<U>]
3329
+ : [route: T];
3333
3330
 
3334
3331
  export {};
3335
3332
  }
3336
3333
 
3337
3334
  declare module '$app/server' {
3338
- import type { RequestEvent, RemoteCommand, RemoteForm, RemoteFormInput, InvalidField, RemotePrerenderFunction, RemoteQueryFunction, RemoteLiveQueryFunction, QueryRequestedResult, LiveQueryRequestedResult } from '@sveltejs/kit';
3339
3335
  import type { StandardSchemaV1 } from '@standard-schema/spec';
3336
+ import type { RequestEvent, RemoteCommand, RemoteForm, RemoteFormInput, InvalidField, RemotePrerenderFunction, RemoteQueryFunction, RemoteLiveQueryFunction, QueryRequestedResult, LiveQueryRequestedResult } from '@sveltejs/kit';
3340
3337
  /**
3341
3338
  * Read the contents of an imported asset from the filesystem
3342
3339
  * @example
@@ -3405,7 +3402,7 @@ declare module '$app/server' {
3405
3402
  *
3406
3403
  * @since 2.27
3407
3404
  */
3408
- export function form<Schema extends StandardSchemaV1<RemoteFormInput, Record<string, any>>, Output>(validate: Schema, fn: (data: StandardSchemaV1.InferOutput<Schema>, issue: InvalidField<StandardSchemaV1.InferInput<Schema>>) => MaybePromise<Output>): RemoteForm<StandardSchemaV1.InferInput<Schema>, Output>;
3405
+ export function form<Schema extends StandardSchemaV1<RemoteFormInput, Record<string, any>>, Output>(validate: true extends HasNonOptionalBoolean<StandardSchemaV1.InferInput<Schema>> ? "Error: All booleans in form schemas must be optional (e.g. `v.optional(v.boolean(), false)`) because checkbox inputs do not send a false value when unchecked." : Schema, fn: (data: StandardSchemaV1.InferOutput<Schema>, issue: InvalidField<StandardSchemaV1.InferInput<Schema>>) => MaybePromise<Output>): RemoteForm<StandardSchemaV1.InferInput<Schema>, Output>;
3409
3406
  /**
3410
3407
  * Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a `fetch` call.
3411
3408
  *
@@ -3493,8 +3490,8 @@ declare module '$app/server' {
3493
3490
  function live<Schema extends StandardSchemaV1, Output>(schema: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => RemoteLiveQueryUserFunctionReturnType<Output>): RemoteLiveQueryFunction<StandardSchemaV1.InferInput<Schema>, Output, StandardSchemaV1.InferOutput<Schema>>;
3494
3491
  }
3495
3492
  /**
3496
- * In the context of a remote `command` or `form` request, returns an iterable
3497
- * of `{ arg, query }` entries for the refreshes requested by the client, up to
3493
+ * Inside a remote `command` or `form` callback, returns an iterable
3494
+ * of `{ arg, query }` entries for the query instances the client asked to refresh, up to
3498
3495
  * the supplied `limit`. Each `query` is a `RemoteQuery` bound to the original
3499
3496
  * client-side cache key, so `refresh()` / `set()` propagate correctly even when
3500
3497
  * the query's schema transforms the input. `arg` is the *validated* argument,
@@ -3503,6 +3500,8 @@ declare module '$app/server' {
3503
3500
  *
3504
3501
  * Arguments that fail validation or exceed `limit` are recorded as failures in
3505
3502
  * the response to the client.
3503
+ * See [Client-requested refreshes](https://svelte.dev/docs/kit/remote-functions#Single-flight-mutations-Client-requested-refreshes)
3504
+ * for usage in a remote `command` or `form`.
3506
3505
  *
3507
3506
  * @example
3508
3507
  * ```ts
@@ -3533,14 +3532,16 @@ declare module '$app/server' {
3533
3532
  * */
3534
3533
  export function requested<Input, Output, Validated = Input>(query: RemoteQueryFunction<Input, Output, Validated>, limit: number): QueryRequestedResult<Validated, Output>;
3535
3534
  /**
3536
- * In the context of a remote `command` or `form` request, returns an iterable
3537
- * of `{ arg, query }` entries for the reconnects requested by the client, up to
3535
+ * Inside a remote `command` or `form` callback, returns an iterable
3536
+ * of `{ arg, query }` entries for the live query instances the client asked to reconnect, up to
3538
3537
  * the supplied `limit`. Each `query` is a `RemoteLiveQuery` bound to the original
3539
3538
  * client-side cache key, so `reconnect()` propagates correctly even when
3540
3539
  * the query's schema transforms the input. `arg` is the *validated* argument.
3541
3540
  *
3542
3541
  * Arguments that fail validation or exceed `limit` are recorded as failures in
3543
3542
  * the response to the client.
3543
+ * See [Client-requested refreshes](https://svelte.dev/docs/kit/remote-functions#Single-flight-mutations-Client-requested-refreshes)
3544
+ * for usage in a remote `command` or `form`.
3544
3545
  *
3545
3546
  * @example
3546
3547
  * ```ts
@@ -3573,6 +3574,19 @@ declare module '$app/server' {
3573
3574
  type RemotePrerenderInputsGenerator<Input = any> = () => MaybePromise<Input[]>;
3574
3575
  type MaybePromise<T> = T | Promise<T>;
3575
3576
 
3577
+ type IsAny<T> = 0 extends 1 & T ? true : false;
3578
+
3579
+ type HasNonOptionalBoolean<T> =
3580
+ IsAny<T> extends true
3581
+ ? never
3582
+ : [T] extends [boolean]
3583
+ ? true
3584
+ : T extends Array<infer U>
3585
+ ? HasNonOptionalBoolean<U>
3586
+ : T extends Record<string, any>
3587
+ ? { [K in keyof T]: HasNonOptionalBoolean<T[K]> }[keyof T]
3588
+ : never;
3589
+
3576
3590
  export {};
3577
3591
  }
3578
3592
 
@@ -3637,46 +3651,7 @@ declare module '$app/state' {
3637
3651
  export {};
3638
3652
  }
3639
3653
 
3640
- declare module '$app/stores' {
3641
- export function getStores(): {
3642
-
3643
- page: typeof page;
3644
-
3645
- navigating: typeof navigating;
3646
-
3647
- updated: typeof updated;
3648
- };
3649
- /**
3650
- * A readable store whose value contains page data.
3651
- *
3652
- * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.
3653
- *
3654
- * @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))
3655
- * */
3656
- export const page: import("svelte/store").Readable<import("@sveltejs/kit").Page>;
3657
- /**
3658
- * A readable store.
3659
- * When navigating starts, its value is a `Navigation` object with `from`, `to`, `type` and (if `type === 'popstate'`) `delta` properties.
3660
- * When navigating finishes, its value reverts to `null`.
3661
- *
3662
- * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.
3663
- *
3664
- * @deprecated Use `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))
3665
- * */
3666
- export const navigating: import("svelte/store").Readable<import("@sveltejs/kit").Navigation | null>;
3667
- /**
3668
- * A readable store whose initial value is `false`. If [`version.pollInterval`](https://svelte.dev/docs/kit/configuration#version) is a non-zero value, SvelteKit will poll for new versions of the app and update the store value to `true` when it detects one. `updated.check()` will force an immediate check, regardless of polling.
3669
- *
3670
- * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.
3671
- *
3672
- * @deprecated Use `updated` from `$app/state` instead (requires Svelte 5, [see docs for more info](https://svelte.dev/docs/kit/migrating-to-sveltekit-2#SvelteKit-2.12:-$app-stores-deprecated))
3673
- * */
3674
- export const updated: import("svelte/store").Readable<boolean> & {
3675
- check(): Promise<boolean>;
3676
- };
3677
-
3678
- export {};
3679
- }/**
3654
+ /**
3680
3655
  * It's possible to tell SvelteKit how to type objects inside your app by declaring the `App` namespace. By default, a new project will have a file called `src/app.d.ts` containing the following:
3681
3656
  *
3682
3657
  * ```ts
@@ -3703,29 +3678,34 @@ declare namespace App {
3703
3678
  * Defines the common shape of expected and unexpected errors. Expected errors are thrown using the `error` function. Unexpected errors are handled by the `handleError` hooks which should return this shape.
3704
3679
  */
3705
3680
  export interface Error {
3681
+ status: number;
3706
3682
  message: string;
3707
3683
  }
3708
3684
 
3709
3685
  /**
3710
3686
  * The interface that defines `event.locals`, which can be accessed in server [hooks](https://svelte.dev/docs/kit/hooks) (`handle`, and `handleError`), server-only `load` functions, and `+server.js` files.
3711
3687
  */
3688
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
3712
3689
  export interface Locals {}
3713
3690
 
3714
3691
  /**
3715
- * Defines the common shape of the [page.data state](https://svelte.dev/docs/kit/$app-state#page) and [$page.data store](https://svelte.dev/docs/kit/$app-stores#page) - that is, the data that is shared between all pages.
3692
+ * Defines the common shape of the [page.data state](https://svelte.dev/docs/kit/$app-state#page) - that is, the data that is shared between all pages.
3716
3693
  * The `Load` and `ServerLoad` functions in `./$types` will be narrowed accordingly.
3717
3694
  * Use optional properties for data that is only present on specific pages. Do not add an index signature (`[key: string]: any`).
3718
3695
  */
3696
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
3719
3697
  export interface PageData {}
3720
3698
 
3721
3699
  /**
3722
3700
  * The shape of the `page.state` object, which can be manipulated using the [`pushState`](https://svelte.dev/docs/kit/$app-navigation#pushState) and [`replaceState`](https://svelte.dev/docs/kit/$app-navigation#replaceState) functions from `$app/navigation`.
3723
3701
  */
3702
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
3724
3703
  export interface PageState {}
3725
3704
 
3726
3705
  /**
3727
3706
  * If your adapter provides [platform-specific context](https://svelte.dev/docs/kit/adapters#Platform-specific-context) via `event.platform`, you can specify it here.
3728
3707
  */
3708
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
3729
3709
  export interface Platform {}
3730
3710
  }
3731
3711
 
@@ -3734,8 +3714,8 @@ declare namespace App {
3734
3714
  */
3735
3715
  declare module '$service-worker' {
3736
3716
  /**
3737
- * The `base` path of the deployment. Typically this is equivalent to `config.kit.paths.base`, but it is calculated from `location.pathname` meaning that it will continue to work correctly if the site is deployed to a subdirectory.
3738
- * Note that there is a `base` but no `assets`, since service workers cannot be used if `config.kit.paths.assets` is specified.
3717
+ * The `base` path of the deployment. Typically this is equivalent to `config.paths.base`, but it is calculated from `location.pathname` meaning that it will continue to work correctly if the site is deployed to a subdirectory.
3718
+ * Note that there is a `base` but no `assets`, since service workers cannot be used if `config.paths.assets` is specified.
3739
3719
  */
3740
3720
  export const base: string;
3741
3721
  /**
@@ -3744,7 +3724,7 @@ declare module '$service-worker' {
3744
3724
  */
3745
3725
  export const build: string[];
3746
3726
  /**
3747
- * An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.kit.files.assets`. You can customize which files are included from `static` directory using [`config.kit.serviceWorker.files`](https://svelte.dev/docs/kit/configuration#serviceWorker)
3727
+ * An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.files.assets`. You can customize which files are included from `static` directory using [`config.serviceWorker.files`](https://svelte.dev/docs/kit/configuration#serviceWorker)
3748
3728
  */
3749
3729
  export const files: string[];
3750
3730
  /**
@@ -3753,7 +3733,7 @@ declare module '$service-worker' {
3753
3733
  */
3754
3734
  export const prerendered: string[];
3755
3735
  /**
3756
- * See [`config.kit.version`](https://svelte.dev/docs/kit/configuration#version). It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches.
3736
+ * See [`config.version`](https://svelte.dev/docs/kit/configuration#version). It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches.
3757
3737
  */
3758
3738
  export const version: string;
3759
3739
  }