@sveltejs/kit 3.0.0-next.0 → 3.0.0-next.10

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 (127) hide show
  1. package/package.json +33 -21
  2. package/src/core/adapt/builder.js +29 -43
  3. package/src/core/adapt/index.js +1 -4
  4. package/src/core/config/index.js +132 -71
  5. package/src/core/config/options.js +294 -244
  6. package/src/core/config/types.d.ts +1 -1
  7. package/src/core/env.js +121 -5
  8. package/src/core/generate_manifest/index.js +12 -15
  9. package/src/core/postbuild/analyse.js +7 -19
  10. package/src/core/postbuild/crawl.js +22 -6
  11. package/src/core/postbuild/prerender.js +42 -23
  12. package/src/core/sync/create_manifest_data/index.js +53 -50
  13. package/src/core/sync/sync.js +0 -2
  14. package/src/core/sync/write_client_manifest.js +8 -15
  15. package/src/core/sync/write_env.js +2 -1
  16. package/src/core/sync/write_non_ambient.js +12 -9
  17. package/src/core/sync/write_server.js +13 -14
  18. package/src/core/sync/write_tsconfig.js +16 -8
  19. package/src/core/sync/write_tsconfig_test/package.json +7 -0
  20. package/src/core/sync/write_types/index.js +28 -24
  21. package/src/core/utils.js +2 -2
  22. package/src/exports/env/index.js +12 -0
  23. package/src/exports/hooks/index.js +3 -9
  24. package/src/exports/hooks/sequence.js +3 -2
  25. package/src/exports/index.js +35 -13
  26. package/src/exports/internal/client.js +5 -0
  27. package/src/exports/internal/env.js +2 -2
  28. package/src/exports/internal/index.js +1 -90
  29. package/src/exports/internal/{event.js → server/event.js} +1 -2
  30. package/src/exports/internal/server/index.js +33 -0
  31. package/src/exports/internal/shared.js +89 -0
  32. package/src/exports/node/index.js +62 -15
  33. package/src/exports/params.js +63 -0
  34. package/src/exports/public.d.ts +323 -170
  35. package/src/exports/url.js +86 -0
  36. package/src/exports/vite/build/build_server.js +53 -59
  37. package/src/exports/vite/build/remote.js +18 -11
  38. package/src/exports/vite/build/utils.js +0 -8
  39. package/src/exports/vite/dev/index.js +42 -44
  40. package/src/exports/vite/index.js +810 -593
  41. package/src/exports/vite/preview/index.js +29 -22
  42. package/src/exports/vite/static_analysis/index.js +2 -4
  43. package/src/exports/vite/static_analysis/types.d.ts +14 -0
  44. package/src/exports/vite/utils.js +21 -36
  45. package/src/runtime/app/env/internal.js +4 -4
  46. package/src/runtime/app/env/types.d.ts +1 -1
  47. package/src/runtime/app/environment/index.js +6 -0
  48. package/src/runtime/app/forms.js +24 -7
  49. package/src/runtime/app/paths/client.js +4 -10
  50. package/src/runtime/app/paths/internal/client.js +4 -2
  51. package/src/runtime/app/paths/internal/server.js +2 -23
  52. package/src/runtime/app/paths/public.d.ts +0 -28
  53. package/src/runtime/app/paths/server.js +9 -5
  54. package/src/runtime/app/server/remote/command.js +0 -3
  55. package/src/runtime/app/server/remote/form.js +27 -15
  56. package/src/runtime/app/server/remote/prerender.js +29 -36
  57. package/src/runtime/app/server/remote/query.js +101 -99
  58. package/src/runtime/app/server/remote/requested.js +22 -14
  59. package/src/runtime/app/server/remote/shared.js +30 -26
  60. package/src/runtime/app/state/client.js +1 -2
  61. package/src/runtime/app/stores.js +13 -76
  62. package/src/runtime/client/bundle.js +1 -1
  63. package/src/runtime/client/client-entry.js +3 -0
  64. package/src/runtime/client/client.js +411 -318
  65. package/src/runtime/client/entry.js +24 -3
  66. package/src/runtime/client/fetcher.js +3 -2
  67. package/src/runtime/client/ndjson.js +6 -33
  68. package/src/runtime/client/payload.js +17 -0
  69. package/src/runtime/client/remote-functions/cache.svelte.js +3 -1
  70. package/src/runtime/client/remote-functions/command.svelte.js +7 -32
  71. package/src/runtime/client/remote-functions/form.svelte.js +183 -112
  72. package/src/runtime/client/remote-functions/prerender.svelte.js +29 -8
  73. package/src/runtime/client/remote-functions/query/index.js +7 -14
  74. package/src/runtime/client/remote-functions/query/instance.svelte.js +63 -18
  75. package/src/runtime/client/remote-functions/query/proxy.js +3 -3
  76. package/src/runtime/client/remote-functions/query-batch.svelte.js +60 -68
  77. package/src/runtime/client/remote-functions/query-live/instance.svelte.js +60 -18
  78. package/src/runtime/client/remote-functions/query-live/iterator.js +36 -55
  79. package/src/runtime/client/remote-functions/shared.svelte.js +88 -62
  80. package/src/runtime/client/sse.js +32 -0
  81. package/src/runtime/client/state.svelte.js +65 -49
  82. package/src/runtime/client/stream.js +38 -0
  83. package/src/runtime/client/types.d.ts +11 -7
  84. package/src/runtime/client/utils.js +0 -96
  85. package/src/runtime/components/root.svelte +66 -0
  86. package/src/runtime/env/dynamic/private.js +7 -0
  87. package/src/runtime/env/dynamic/public.js +7 -0
  88. package/src/runtime/env/static/private.js +6 -0
  89. package/src/runtime/env/static/public.js +6 -0
  90. package/src/runtime/form-utils.js +100 -22
  91. package/src/runtime/server/cookie.js +69 -52
  92. package/src/runtime/server/csrf.js +65 -0
  93. package/src/runtime/server/data/index.js +14 -18
  94. package/src/runtime/server/env_module.js +0 -5
  95. package/src/runtime/server/index.js +2 -2
  96. package/src/runtime/server/page/actions.js +41 -26
  97. package/src/runtime/server/page/index.js +9 -15
  98. package/src/runtime/server/page/load_data.js +1 -1
  99. package/src/runtime/server/page/render.js +112 -187
  100. package/src/runtime/server/page/respond_with_error.js +7 -8
  101. package/src/runtime/server/page/server_routing.js +27 -18
  102. package/src/runtime/server/remote.js +355 -216
  103. package/src/runtime/server/respond.js +97 -61
  104. package/src/runtime/server/utils.js +32 -9
  105. package/src/runtime/shared.js +83 -13
  106. package/src/runtime/telemetry/otel.js +1 -1
  107. package/src/runtime/types.d.ts +8 -0
  108. package/src/types/ambient.d.ts +10 -5
  109. package/src/types/global-private.d.ts +15 -22
  110. package/src/types/internal.d.ts +89 -74
  111. package/src/types/private.d.ts +33 -1
  112. package/src/utils/error.js +24 -4
  113. package/src/utils/import.js +6 -1
  114. package/src/utils/imports.js +83 -0
  115. package/src/utils/mime.js +9 -0
  116. package/src/utils/params.js +66 -0
  117. package/src/utils/routing.js +90 -44
  118. package/src/utils/shared-iterator.js +5 -0
  119. package/src/utils/streaming.js +14 -4
  120. package/src/utils/url.js +20 -2
  121. package/src/version.js +1 -1
  122. package/types/index.d.ts +467 -537
  123. package/types/index.d.ts.map +22 -39
  124. package/src/core/sync/write_root.js +0 -148
  125. package/src/exports/internal/server.js +0 -22
  126. package/src/types/synthetic/$lib.md +0 -5
  127. /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
  */
@@ -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,8 +407,6 @@ 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
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#Server-hooks-handle) to roll your own CSP.
375
411
  */
376
412
  csp?: {
@@ -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
  /**
@@ -823,6 +842,17 @@ declare module '@sveltejs/kit' {
823
842
  register?: false;
824
843
  }
825
844
  );
845
+ /**
846
+ * Options for enabling [OpenTelemetry](https://opentelemetry.io/) tracing for SvelteKit operations.
847
+ * @default { server: false }
848
+ */
849
+ tracing?: {
850
+ /**
851
+ * 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). 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.
852
+ * @default false
853
+ */
854
+ server?: boolean;
855
+ };
826
856
  typescript?: {
827
857
  /**
828
858
  * A function that allows you to edit the generated `tsconfig.json`. You can mutate the config (recommended) or return a new one.
@@ -863,16 +893,20 @@ declare module '@sveltejs/kit' {
863
893
  * For example, to use the current commit hash, you could do use `git rev-parse HEAD`:
864
894
  *
865
895
  * ```js
866
- * /// file: svelte.config.js
896
+ * /// file: vite.config.js
867
897
  * import * as child_process from 'node:child_process';
898
+ * import { sveltekit } from '@sveltejs/kit/vite';
899
+ * import { defineConfig } from 'vite';
868
900
  *
869
- * export default {
870
- * kit: {
871
- * version: {
872
- * name: child_process.execSync('git rev-parse HEAD').toString().trim()
873
- * }
874
- * }
875
- * };
901
+ * export default defineConfig({
902
+ * plugins: [
903
+ * sveltekit({
904
+ * version: {
905
+ * name: child_process.execSync('git rev-parse HEAD').toString().trim()
906
+ * }
907
+ * })
908
+ * ]
909
+ * });
876
910
  * ```
877
911
  */
878
912
  name?: string;
@@ -892,7 +926,7 @@ declare module '@sveltejs/kit' {
892
926
  */
893
927
  export type Handle = (input: {
894
928
  event: RequestEvent;
895
- resolve: (event: RequestEvent, opts?: ResolveOptions) => MaybePromise<Response>;
929
+ resolve: (event: RequestEvent, opts?: ResolveOptions) => Promise<Response>;
896
930
  }) => MaybePromise<Response>;
897
931
 
898
932
  /**
@@ -900,13 +934,16 @@ declare module '@sveltejs/kit' {
900
934
  *
901
935
  * If an unexpected error is thrown during loading or rendering, this function will be called with the error and the event.
902
936
  * Make sure that this function _never_ throws an error.
937
+ *
938
+ * The returned object can include a `status` property to override the HTTP status code used in the response.
939
+ * If omitted, the status defaults to 500.
903
940
  */
904
941
  export type HandleServerError = (input: {
905
942
  error: unknown;
906
943
  event: RequestEvent;
907
944
  status: number;
908
945
  message: string;
909
- }) => MaybePromise<void | App.Error>;
946
+ }) => MaybePromise<void | AppErrorWithOptionalStatus>;
910
947
 
911
948
  /**
912
949
  * The [`handleValidationError`](https://svelte.dev/docs/kit/hooks#Server-hooks-handleValidationError) hook runs when the argument to a remote function fails validation.
@@ -914,20 +951,23 @@ declare module '@sveltejs/kit' {
914
951
  * It will be called with the validation issues and the event, and must return an object shape that matches `App.Error`.
915
952
  */
916
953
  export type HandleValidationError<Issue extends StandardSchemaV1.Issue = StandardSchemaV1.Issue> =
917
- (input: { issues: Issue[]; event: RequestEvent }) => MaybePromise<App.Error>;
954
+ (input: { issues: Issue[]; event: RequestEvent }) => MaybePromise<AppErrorWithOptionalStatus>;
918
955
 
919
956
  /**
920
957
  * The client-side [`handleError`](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError) hook runs when an unexpected error is thrown while navigating.
921
958
  *
922
959
  * If an unexpected error is thrown during loading or the following render, this function will be called with the error and the event.
923
960
  * Make sure that this function _never_ throws an error.
961
+ *
962
+ * The returned object can include a `status` property to override the HTTP status code used in the response.
963
+ * If omitted, the status defaults to 500.
924
964
  */
925
965
  export type HandleClientError = (input: {
926
966
  error: unknown;
927
967
  event: NavigationEvent;
928
968
  status: number;
929
969
  message: string;
930
- }) => MaybePromise<void | App.Error>;
970
+ }) => MaybePromise<void | AppErrorWithOptionalStatus>;
931
971
 
932
972
  /**
933
973
  * 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`.
@@ -987,7 +1027,7 @@ declare module '@sveltejs/kit' {
987
1027
  */
988
1028
  export interface Transporter<
989
1029
  T = any,
990
- U = Exclude<any, false | 0 | '' | null | undefined | typeof NaN>
1030
+ U = any /* minus falsy values, but we can't properly express that */
991
1031
  > {
992
1032
  encode: (value: T) => false | U;
993
1033
  decode: (data: U) => T;
@@ -1196,14 +1236,24 @@ declare module '@sveltejs/kit' {
1196
1236
  /**
1197
1237
  * - `enter`: The app has hydrated/started
1198
1238
  * - `form`: The user submitted a `<form method="GET">`
1239
+ * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
1199
1240
  * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
1200
1241
  * - `link`: Navigation was triggered by a link click
1201
- * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
1202
1242
  * - `popstate`: Navigation was triggered by back/forward navigation
1203
1243
  */
1204
1244
  export type NavigationType = 'enter' | 'form' | 'leave' | 'link' | 'goto' | 'popstate';
1205
1245
 
1206
1246
  export interface NavigationBase {
1247
+ /**
1248
+ * The type of navigation:
1249
+ * - `enter`: The app has hydrated/started
1250
+ * - `form`: The user submitted a `<form method="GET">`
1251
+ * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
1252
+ * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
1253
+ * - `link`: Navigation was triggered by a link click
1254
+ * - `popstate`: Navigation was triggered by back/forward navigation
1255
+ */
1256
+ type: NavigationType;
1207
1257
  /**
1208
1258
  * Where navigation was triggered from
1209
1259
  */
@@ -1223,11 +1273,10 @@ declare module '@sveltejs/kit' {
1223
1273
  complete: Promise<void>;
1224
1274
  }
1225
1275
 
1276
+ /**
1277
+ * The navigation that occurs when the app starts/hydrates
1278
+ */
1226
1279
  export interface NavigationEnter extends NavigationBase {
1227
- /**
1228
- * The type of navigation:
1229
- * - `enter`: The app has hydrated/started
1230
- */
1231
1280
  type: 'enter';
1232
1281
 
1233
1282
  /**
@@ -1243,27 +1292,24 @@ declare module '@sveltejs/kit' {
1243
1292
 
1244
1293
  export type NavigationExternal = NavigationGoto | NavigationLeave;
1245
1294
 
1295
+ /**
1296
+ * A navigation triggered by a `goto(...)` call or a redirect
1297
+ */
1246
1298
  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
1299
  type: 'goto';
1252
1300
  }
1253
1301
 
1302
+ /**
1303
+ * A navigation triggered by the tab being closed, or the user navigating to a different document
1304
+ */
1254
1305
  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
1306
  type: 'leave';
1260
1307
  }
1261
1308
 
1309
+ /**
1310
+ * A navigation triggered by a `<form method="GET">`
1311
+ */
1262
1312
  export interface NavigationFormSubmit extends NavigationBase {
1263
- /**
1264
- * The type of navigation:
1265
- * - `form`: The user submitted a `<form method="GET">`
1266
- */
1267
1313
  type: 'form';
1268
1314
 
1269
1315
  /**
@@ -1272,11 +1318,10 @@ declare module '@sveltejs/kit' {
1272
1318
  event: SubmitEvent;
1273
1319
  }
1274
1320
 
1321
+ /**
1322
+ * A navigation triggered by back/forward navigation
1323
+ */
1275
1324
  export interface NavigationPopState extends NavigationBase {
1276
- /**
1277
- * The type of navigation:
1278
- * - `popstate`: Navigation was triggered by back/forward navigation
1279
- */
1280
1325
  type: 'popstate';
1281
1326
 
1282
1327
  /**
@@ -1290,11 +1335,10 @@ declare module '@sveltejs/kit' {
1290
1335
  event: PopStateEvent;
1291
1336
  }
1292
1337
 
1338
+ /**
1339
+ * A navigation triggered by a link click
1340
+ */
1293
1341
  export interface NavigationLink extends NavigationBase {
1294
- /**
1295
- * The type of navigation:
1296
- * - `link`: Navigation was triggered by a link click
1297
- */
1298
1342
  type: 'link';
1299
1343
 
1300
1344
  /**
@@ -1342,7 +1386,7 @@ declare module '@sveltejs/kit' {
1342
1386
  };
1343
1387
 
1344
1388
  /**
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.
1389
+ * The shape of the [`page`](https://svelte.dev/docs/kit/$app-state#page) reactive object.
1346
1390
  */
1347
1391
  export interface Page<
1348
1392
  Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
@@ -1351,7 +1395,7 @@ declare module '@sveltejs/kit' {
1351
1395
  /**
1352
1396
  * The URL of the current page.
1353
1397
  */
1354
- url: URL & { pathname: ResolvedPathname };
1398
+ url: ReadonlyURL & { readonly pathname: ResolvedPathname | (string & {}) };
1355
1399
  /**
1356
1400
  * The parameters of the current page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
1357
1401
  */
@@ -1390,7 +1434,62 @@ declare module '@sveltejs/kit' {
1390
1434
  /**
1391
1435
  * The shape of a param matcher. See [matching](https://svelte.dev/docs/kit/advanced-routing#Matching) for more info.
1392
1436
  */
1393
- export type ParamMatcher = (param: string) => boolean;
1437
+ export type ParamMatcher<Output = any> = StandardSchemaV1<string, Output>;
1438
+
1439
+ /**
1440
+ * A value that can be parsed from a URL param and losslessly encoded with `String(...)`.
1441
+ */
1442
+ export type ParamValue = string | number | boolean | bigint;
1443
+
1444
+ /**
1445
+ * A param matcher definition passed to [`defineParams`](https://svelte.dev/docs/kit/@sveltejs-kit#defineParams).
1446
+ */
1447
+ export type ParamDefinition =
1448
+ | ((param: string) => ParamValue | undefined)
1449
+ | StandardSchemaV1<string, ParamValue>;
1450
+
1451
+ /**
1452
+ * The return type of [`defineParams`](https://svelte.dev/docs/kit/@sveltejs-kit#defineParams).
1453
+ */
1454
+ export type DefinedParams<T extends Record<string, ParamDefinition>> = {
1455
+ readonly [K in keyof T]: ParamEntry<T[K]>;
1456
+ };
1457
+
1458
+ /**
1459
+ * Normalizes a property of defineParams (schema or function) to standard schema.
1460
+ */
1461
+ type ParamEntry<M> =
1462
+ M extends StandardSchemaV1<any, any>
1463
+ ? StandardSchemaV1.InferOutput<M> extends ParamValue
1464
+ ? StandardSchemaV1<any, M>
1465
+ : StandardSchemaV1<any, never>
1466
+ : M extends (param: string) => infer R
1467
+ ? Exclude<R, undefined> extends ParamValue
1468
+ ? StandardSchemaV1<any, Exclude<R, undefined>>
1469
+ : StandardSchemaV1<any, never>
1470
+ : never;
1471
+
1472
+ /**
1473
+ * Extracts the param type from a matcher.
1474
+ */
1475
+ export type MatcherParam<M extends StandardSchemaV1<any, any>> =
1476
+ M extends StandardSchemaV1<any, infer Inner>
1477
+ ? Inner extends ParamValue
1478
+ ? Inner
1479
+ : Inner extends StandardSchemaV1<any, any>
1480
+ ? StandardSchemaV1.InferOutput<Inner> extends ParamValue
1481
+ ? StandardSchemaV1.InferOutput<Inner>
1482
+ : never
1483
+ : never
1484
+ : never;
1485
+
1486
+ /**
1487
+ * Define [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#Matching) for your app.
1488
+ *
1489
+ * */
1490
+ export function defineParams<T extends Record<string, ParamDefinition>>(
1491
+ definitions: T
1492
+ ): DefinedParams<T>;
1394
1493
 
1395
1494
  /**
1396
1495
  * A single entry yielded by [`requested`](https://svelte.dev/docs/kit/$app-server#requested)
@@ -1483,6 +1582,10 @@ declare module '@sveltejs/kit' {
1483
1582
  locals: App.Locals;
1484
1583
  /**
1485
1584
  * The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
1585
+ *
1586
+ * In the context of a remote function request initiated by the client, this relates to the page the remote function
1587
+ * was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use this to determine
1588
+ * whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
1486
1589
  */
1487
1590
  params: Params;
1488
1591
  /**
@@ -1499,6 +1602,10 @@ declare module '@sveltejs/kit' {
1499
1602
  route: {
1500
1603
  /**
1501
1604
  * 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.
1605
+ *
1606
+ * In the context of a remote function request initiated by the client, this relates to the page the remote function
1607
+ * was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use this to determine
1608
+ * whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
1502
1609
  */
1503
1610
  id: RouteId;
1504
1611
  };
@@ -1527,6 +1634,10 @@ declare module '@sveltejs/kit' {
1527
1634
  setHeaders: (headers: Record<string, string>) => void;
1528
1635
  /**
1529
1636
  * The requested URL.
1637
+ *
1638
+ * In the context of a remote function request initiated by the client, this relates to the page the remote function
1639
+ * was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use this to determine
1640
+ * whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
1530
1641
  */
1531
1642
  url: URL;
1532
1643
  /**
@@ -1585,7 +1696,9 @@ declare module '@sveltejs/kit' {
1585
1696
  */
1586
1697
  filterSerializedResponseHeaders?: (name: string, value: string) => boolean;
1587
1698
  /**
1588
- * Determines what should be added to the `<head>` tag to preload it.
1699
+ * Determines which files should be preloaded. Files are preloaded via `<link>` tags added to the
1700
+ * `<head>` tag; if `output.linkHeaderPreload` is enabled, dynamically rendered pages use the
1701
+ * [`Link` response header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link) instead.
1589
1702
  * By default, `js` and `css` files will be preloaded.
1590
1703
  * @param input the type of the file and its path
1591
1704
  */
@@ -1620,25 +1733,17 @@ declare module '@sveltejs/kit' {
1620
1733
  read?: (file: string) => MaybePromise<ReadableStream | null>;
1621
1734
  }
1622
1735
 
1736
+ /**
1737
+ * Information required to instantiate a new `Server` instance.
1738
+ */
1623
1739
  export interface SSRManifest {
1740
+ /** The directory where SvelteKit keeps its stuff, including static assets (such as JS and CSS) and internally-used routes. */
1624
1741
  appDir: string;
1742
+ /** The `base` and `appDir` settings combined without a leading slash. */
1625
1743
  appPath: string;
1626
- /** Static files from `kit.config.files.assets` and the service worker (if any). */
1744
+ /** Static files from `config.files.assets` and the service worker (if any). */
1627
1745
  assets: Set<string>;
1628
1746
  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
1747
  }
1643
1748
 
1644
1749
  /**
@@ -1767,7 +1872,7 @@ declare module '@sveltejs/kit' {
1767
1872
  | { type: 'success'; status: number; data?: Success }
1768
1873
  | { type: 'failure'; status: number; data?: Failure }
1769
1874
  | { type: 'redirect'; status: number; location: string }
1770
- | { type: 'error'; status?: number; error: any };
1875
+ | { type: 'error'; status?: number; error: App.Error };
1771
1876
 
1772
1877
  /**
1773
1878
  * The object returned by the [`error`](https://svelte.dev/docs/kit/@sveltejs-kit#error) function.
@@ -1823,6 +1928,14 @@ declare module '@sveltejs/kit' {
1823
1928
  restore: (snapshot: T) => void;
1824
1929
  }
1825
1930
 
1931
+ export type ReadonlyURLSearchParams = Omit<URLSearchParams, 'set' | 'append' | 'delete' | 'sort'>;
1932
+
1933
+ export type ReadonlyURL = Readonly<
1934
+ Omit<URL, 'searchParams'> & {
1935
+ searchParams: ReadonlyURLSearchParams;
1936
+ }
1937
+ >;
1938
+
1826
1939
  // 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
1940
  type WillRecurseIndefinitely<T> = unknown extends T ? true : string extends keyof T ? true : false;
1828
1941
 
@@ -1916,6 +2029,10 @@ declare module '@sveltejs/kit' {
1916
2029
  value(): DeepPartial<T>;
1917
2030
  /** Set the values that will be submitted */
1918
2031
  set(input: DeepPartial<T>): DeepPartial<T>;
2032
+ /** Whether the field or any nested field has been interacted with since the form was mounted */
2033
+ touched(): boolean;
2034
+ /** Whether the field or any nested field has been edited since the form was mounted */
2035
+ dirty(): boolean;
1919
2036
  /** Validation issues, if any */
1920
2037
  issues(): RemoteFormIssue[] | undefined;
1921
2038
  };
@@ -2030,7 +2147,7 @@ declare module '@sveltejs/kit' {
2030
2147
  type MaybeArray<T> = T | T[];
2031
2148
 
2032
2149
  export interface RemoteFormInput {
2033
- [key: string]: MaybeArray<string | number | boolean | File | RemoteFormInput>;
2150
+ [key: string]: MaybeArray<string | number | boolean | File | RemoteFormInput> | undefined;
2034
2151
  }
2035
2152
 
2036
2153
  export interface RemoteFormIssue {
@@ -2076,6 +2193,24 @@ declare module '@sveltejs/kit' {
2076
2193
  issues: StandardSchemaV1.Issue[];
2077
2194
  }
2078
2195
 
2196
+ /**
2197
+ * The form instance as received inside an `enhance` callback. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
2198
+ */
2199
+ export type RemoteFormEnhanceInstance<
2200
+ Input extends RemoteFormInput | void = RemoteFormInput | void,
2201
+ Output = any
2202
+ > = Omit<RemoteForm<Input, Output>, 'enhance' | 'element'> & {
2203
+ readonly element: HTMLFormElement;
2204
+ };
2205
+
2206
+ /**
2207
+ * The callback passed to a remote form's `enhance` method. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
2208
+ */
2209
+ export type RemoteFormEnhanceCallback<
2210
+ Input extends RemoteFormInput | void = RemoteFormInput | void,
2211
+ Output = any
2212
+ > = (form: RemoteFormEnhanceInstance<Input, Output>) => MaybePromise<void>;
2213
+
2079
2214
  /**
2080
2215
  * The type of a remote `form` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
2081
2216
  */
@@ -2092,13 +2227,7 @@ declare module '@sveltejs/kit' {
2092
2227
  updates: (...updates: RemoteQueryUpdate[]) => Promise<boolean>;
2093
2228
  };
2094
2229
  /** 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
- ): {
2230
+ enhance(callback: RemoteFormEnhanceCallback<Input, Output>): {
2102
2231
  method: 'POST';
2103
2232
  action: string;
2104
2233
  [attachment: symbol]: (node: HTMLFormElement) => void;
@@ -2122,8 +2251,13 @@ declare module '@sveltejs/kit' {
2122
2251
  preflight(schema: StandardSchemaV1<Input, any>): RemoteForm<Input, Output>;
2123
2252
  /** Validate the form contents programmatically */
2124
2253
  validate(options?: {
2125
- /** Set this to `true` to also show validation issues of fields that haven't been touched yet. */
2126
- includeUntouched?: boolean;
2254
+ /**
2255
+ * Set this to `true` to also show validation issues of fields that haven't yet been
2256
+ * edited and blurred. This option is ignored for forms that have previously been
2257
+ * submitted, in which case all fields are always subject to validation
2258
+ * (unless the form is reset, at which point it is treated as pristine)
2259
+ */
2260
+ all?: boolean;
2127
2261
  /** Set this to `true` to only run the `preflight` validation. */
2128
2262
  preflightOnly?: boolean;
2129
2263
  }): Promise<void>;
@@ -2131,6 +2265,8 @@ declare module '@sveltejs/kit' {
2131
2265
  get result(): Output | undefined;
2132
2266
  /** The number of pending submissions */
2133
2267
  get pending(): number;
2268
+ /** True if the form has been submitted at least once, and hasn't been reset since */
2269
+ get submitted(): boolean;
2134
2270
  /** Access form fields using object notation */
2135
2271
  fields: RemoteFormFieldsRoot<Input>;
2136
2272
  };
@@ -2154,8 +2290,8 @@ declare module '@sveltejs/kit' {
2154
2290
  | RemoteQueryOverride;
2155
2291
 
2156
2292
  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;
2293
+ /** The error in case the query fails. */
2294
+ get error(): App.Error | undefined;
2159
2295
  /** `true` before the first result is available and during refreshes */
2160
2296
  get loading(): boolean;
2161
2297
  } & (
@@ -2256,7 +2392,7 @@ declare module '@sveltejs/kit' {
2256
2392
 
2257
2393
  /**
2258
2394
  * [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).
2395
+ * a `variables` object from `src/env.ts`, using [`defineEnvVars`](https://svelte.dev/docs/kit/@sveltejs-kit-env#defineEnvVars).
2260
2396
  */
2261
2397
  export interface EnvVarConfig<T> {
2262
2398
  /**
@@ -2343,7 +2479,10 @@ declare module '@sveltejs/kit' {
2343
2479
  | 'unsafe-eval'
2344
2480
  | 'unsafe-hashes'
2345
2481
  | 'unsafe-inline'
2482
+ | 'unsafe-allow-redirects'
2483
+ | 'unsafe-webtransport-hashes'
2346
2484
  | 'wasm-unsafe-eval'
2485
+ | 'trusted-types-eval'
2347
2486
  | 'none';
2348
2487
  type CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`;
2349
2488
  type FrameSource = HostSource | SchemeSource | 'self' | 'none';
@@ -2352,7 +2491,16 @@ declare module '@sveltejs/kit' {
2352
2491
  type HostProtocolSchemes = `${string}://` | '';
2353
2492
  type HttpDelineator = '/' | '?' | '#' | '\\';
2354
2493
  type PortScheme = `:${number}` | '' | ':*';
2355
- type SchemeSource = 'http:' | 'https:' | 'data:' | 'mediastream:' | 'blob:' | 'filesystem:';
2494
+ type SchemeSource =
2495
+ | 'http:'
2496
+ | 'https:'
2497
+ | 'ws:'
2498
+ | 'wss:'
2499
+ | 'data:'
2500
+ | 'mediastream:'
2501
+ | 'blob:'
2502
+ | 'filesystem:'
2503
+ | (`${string}:` & {});
2356
2504
  type Source = HostSource | SchemeSource | CryptoSource | BaseSource;
2357
2505
  type Sources = Source[];
2358
2506
  }
@@ -2494,6 +2642,10 @@ declare module '@sveltejs/kit' {
2494
2642
  (details: { routes: string[]; message: string }): void;
2495
2643
  }
2496
2644
 
2645
+ interface PrerenderInvalidUrlHandler {
2646
+ (details: { href: string; referrer: string | null; message: string }): void;
2647
+ }
2648
+
2497
2649
  type PrerenderHttpErrorHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderHttpErrorHandler;
2498
2650
  type PrerenderMissingIdHandlerValue = 'fail' | 'warn' | 'ignore' | PrerenderMissingIdHandler;
2499
2651
  type PrerenderUnseenRoutesHandlerValue =
@@ -2506,6 +2658,11 @@ declare module '@sveltejs/kit' {
2506
2658
  | 'warn'
2507
2659
  | 'ignore'
2508
2660
  | PrerenderEntryGeneratorMismatchHandler;
2661
+ type PrerenderInvalidUrlHandlerValue =
2662
+ | 'fail'
2663
+ | 'warn'
2664
+ | 'ignore'
2665
+ | PrerenderInvalidUrlHandler;
2509
2666
 
2510
2667
  export type PrerenderOption = boolean | 'auto';
2511
2668
 
@@ -2520,9 +2677,6 @@ declare module '@sveltejs/kit' {
2520
2677
  rest: boolean;
2521
2678
  }
2522
2679
 
2523
- /** @default 'never' */
2524
- type TrailingSlash = 'never' | 'always' | 'ignore';
2525
-
2526
2680
  type DeepPartial<T> = T extends Record<PropertyKey, unknown> | unknown[]
2527
2681
  ? {
2528
2682
  [K in keyof T]?: T[K] extends Record<PropertyKey, unknown> | unknown[]
@@ -2532,246 +2686,21 @@ declare module '@sveltejs/kit' {
2532
2686
  : T | undefined;
2533
2687
 
2534
2688
  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
2689
  type RecursiveRequired<T> = {
2614
2690
  // Recursive implementation of TypeScript's Required utility type.
2615
2691
  // Will recursively continue until it reaches a primitive or Function
2616
2692
  // 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
2693
+ [K in keyof T]-?: Extract<T[K], Function | (`${string}:` & {})> extends never // If it does not have a Function type
2618
2694
  ? RecursiveRequired<T[K]> // recursively continue through.
2619
2695
  : T[K]; // Use the exact type for everything else
2620
2696
  };
2621
2697
 
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 & {
2698
+ type ValidatedConfig = Omit<Config, 'kit'> & {
2769
2699
  kit: ValidatedKitConfig;
2770
2700
  extensions: string[];
2771
2701
  };
2772
2702
 
2773
- // TODO: remove the omit in 4.0
2774
- type ValidatedKitConfig = Omit<RecursiveRequired<KitConfig>, 'adapter'>;
2703
+ type ValidatedKitConfig = RecursiveRequired<KitConfig>;
2775
2704
  /**
2776
2705
  * Throws an error with a HTTP status code and an optional message.
2777
2706
  * When called during request handling, this will cause SvelteKit to
@@ -2782,20 +2711,38 @@ declare module '@sveltejs/kit' {
2782
2711
  * @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
2783
2712
  * @throws {Error} If the provided status is invalid (not between 400 and 599).
2784
2713
  */
2785
- export function error(status: number, body: App.Error): never;
2714
+ export function error(status: number, body: Omit<App.Error, "status"> & {
2715
+ status?: App.Error["status"];
2716
+ }): never;
2786
2717
  /**
2787
2718
  * Throws an error with a HTTP status code and an optional message.
2788
2719
  * When called during request handling, this will cause SvelteKit to
2789
2720
  * return an error response without invoking `handleError`.
2790
2721
  * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
2791
2722
  * @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.
2723
+ * @param body The error message.
2793
2724
  * @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
2794
2725
  * @throws {Error} If the provided status is invalid (not between 400 and 599).
2795
2726
  */
2796
- export function error(status: number, body?: {
2727
+ export function error(status: number, body: {
2728
+ status: number;
2797
2729
  message: string;
2798
- } extends App.Error ? App.Error | string | undefined : never): never;
2730
+ } extends App.Error ? string | void | undefined : never): never;
2731
+ /**
2732
+ * Throws an error with a HTTP status code and an optional message.
2733
+ * When called during request handling, this will cause SvelteKit to
2734
+ * return an error response without invoking `handleError`.
2735
+ * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
2736
+ * @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.
2737
+ * @param body The error message.
2738
+ * @param properties Additional properties of the App.Error type.
2739
+ * @throws {import('./public.js').HttpError} This error instructs SvelteKit to initiate HTTP error handling.
2740
+ * @throws {Error} If the provided status is invalid (not between 400 and 599).
2741
+ */
2742
+ export function error(status: number, body: string, properties: {
2743
+ status: number;
2744
+ message: string;
2745
+ } extends App.Error ? never : Omit<App.Error, "status" | "message">): never;
2799
2746
  /**
2800
2747
  * Checks whether this is an error thrown by {@link error}.
2801
2748
  * @param status The status to filter for.
@@ -2816,10 +2763,13 @@ declare module '@sveltejs/kit' {
2816
2763
  *
2817
2764
  * @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
2765
  * @param location The location to redirect to.
2766
+ * @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
2767
  * @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.
2768
+ * @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
2769
  * */
2822
- export function redirect(status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | ({} & number), location: string | URL): never;
2770
+ export function redirect(status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | ({} & number), location: string | URL, options?: {
2771
+ external?: boolean | string[];
2772
+ }): never;
2823
2773
  /**
2824
2774
  * Checks whether this is a redirect thrown by {@link redirect}.
2825
2775
  * @param e The object to check.
@@ -2863,7 +2813,7 @@ declare module '@sveltejs/kit' {
2863
2813
  * ```ts
2864
2814
  * import { invalid } from '@sveltejs/kit';
2865
2815
  * import { form } from '$app/server';
2866
- * import { tryLogin } from '$lib/server/auth';
2816
+ * import { tryLogin } from '#lib/server/auth';
2867
2817
  * import * as v from 'valibot';
2868
2818
  *
2869
2819
  * export const login = form(
@@ -2905,21 +2855,24 @@ declare module '@sveltejs/kit' {
2905
2855
  wasNormalized: boolean;
2906
2856
  denormalize: (url?: string | URL) => URL;
2907
2857
  };
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
2858
  export const VERSION: string;
2912
2859
 
2913
2860
  export {};
2914
2861
  }
2915
2862
 
2916
- declare module '@sveltejs/kit/hooks' {
2917
- import type { EnvVarConfig, Handle } from '@sveltejs/kit';
2863
+ declare module '@sveltejs/kit/env' {
2864
+ import type { EnvVarConfig } from '@sveltejs/kit';
2918
2865
  /**
2919
2866
  * Utility for defining [environment variables](https://svelte.dev/docs/kit/environment-variables),
2920
2867
  * which are made available via `$app/env/public` and `$app/env/private`.
2921
2868
  * */
2922
2869
  export function defineEnvVars<T extends Record<string, EnvVarConfig<any>>>(variables: T): T;
2870
+
2871
+ export {};
2872
+ }
2873
+
2874
+ declare module '@sveltejs/kit/hooks' {
2875
+ import type { Handle } from '@sveltejs/kit';
2923
2876
  /**
2924
2877
  * A helper function for sequencing multiple `handle` calls in a middleware-like manner.
2925
2878
  * The behavior for the `handle` options is as follows:
@@ -2988,6 +2941,8 @@ declare module '@sveltejs/kit/hooks' {
2988
2941
  * first post-processing
2989
2942
  * ```
2990
2943
  *
2944
+ * 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`.
2945
+ *
2991
2946
  * @param handlers The chain of `handle` functions
2992
2947
  * */
2993
2948
  export function sequence(...handlers: Handle[]): Handle;
@@ -3000,9 +2955,9 @@ declare module '@sveltejs/kit/node' {
3000
2955
  request: import("http").IncomingMessage;
3001
2956
  base: string;
3002
2957
  bodySizeLimit?: number;
3003
- }): Promise<Request>;
2958
+ }): Request;
3004
2959
 
3005
- export function setResponse(res: import("http").ServerResponse, response: Response): Promise<void>;
2960
+ export function setResponse(res: import("http").ServerResponse, response: Response): void;
3006
2961
  /**
3007
2962
  * Converts a file on disk to a readable stream
3008
2963
  * @since 2.4.0
@@ -3013,13 +2968,19 @@ declare module '@sveltejs/kit/node' {
3013
2968
  }
3014
2969
 
3015
2970
  declare module '@sveltejs/kit/vite' {
3016
- import type { SvelteConfig } from '@sveltejs/vite-plugin-svelte';
2971
+ import type { KitConfig } from '@sveltejs/kit';
2972
+ import type { Options, SvelteConfig } from '@sveltejs/vite-plugin-svelte';
3017
2973
  import type { Plugin } from 'vite';
3018
2974
  /**
3019
2975
  * 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.
2976
+ * Any options that don't belong to SvelteKit are passed through to `vite-plugin-svelte`.
2977
+ *
2978
+ * Since version 3.0.0 you must pass [configuration](configuration) directly.
2979
+ *
2980
+ * Since version 2.62.0 you can pass configuration directly, in which case `svelte.config.js` is ignored.
2981
+ *
3021
2982
  * */
3022
- export function sveltekit(config?: import("@sveltejs/kit").KitConfig & Omit<SvelteConfig, "onwarn">): Promise<Plugin[]>;
2983
+ export function sveltekit(config?: KitConfig & Omit<Options, "onwarn"> & Pick<SvelteConfig, "vitePlugin">): Promise<Plugin[]>;
3023
2984
 
3024
2985
  export {};
3025
2986
  }
@@ -3041,7 +3002,7 @@ declare module '$app/env' {
3041
3002
  export const building: boolean;
3042
3003
 
3043
3004
  /**
3044
- * The value of `config.kit.version.name`.
3005
+ * The value of `config.version.name`.
3045
3006
  */
3046
3007
  export const version: string;
3047
3008
 
@@ -3141,17 +3102,20 @@ declare module '$app/navigation' {
3141
3102
  * Allows you to navigate programmatically to a given route, with options such as keeping the current element focused.
3142
3103
  * Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`.
3143
3104
  *
3144
- * For external URLs, use `window.location = url` instead of calling `goto(url)`.
3105
+ * `goto` is intended for navigations to routes that belong to the app.
3106
+ * If the URL does not resolve to a route within the app, the returned promise will reject.
3107
+ * For external URLs, use `window.location = url` to perform a full-page navigation instead of calling `goto(url)`.
3145
3108
  *
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.
3109
+ * @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
3110
  * @param {Object} opts Options related to the navigation
3148
3111
  * */
3149
3112
  export function goto(url: string | URL, opts?: {
3150
3113
  replaceState?: boolean | undefined;
3151
3114
  noScroll?: boolean | undefined;
3152
3115
  keepFocus?: boolean | undefined;
3153
- invalidateAll?: boolean | undefined;
3116
+ refreshAll?: boolean | undefined;
3154
3117
  invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
3118
+ invalidateAll?: boolean | undefined;
3155
3119
  state?: App.PageState | undefined;
3156
3120
  }): Promise<void>;
3157
3121
  /**
@@ -3170,19 +3134,22 @@ declare module '$app/navigation' {
3170
3134
  * invalidate((url) => url.pathname === '/path');
3171
3135
  * ```
3172
3136
  * @param resource The invalidated URL
3137
+ * @param keepState If `true`, the current `page.state` will be preserved. Otherwise, it will be reset to an empty object. `false` by default.
3173
3138
  * */
3174
- export function invalidate(resource: string | URL | ((url: URL) => boolean)): Promise<void>;
3139
+ export function invalidate(resource: string | URL | ((url: URL) => boolean), keepState?: boolean): Promise<void>;
3175
3140
  /**
3176
3141
  * 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.
3142
+ *
3143
+ * 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.
3144
+ *
3145
+ * @deprecated Use [`refreshAll`](https://svelte.dev/docs/kit/$app-navigation#refreshAll) instead. Unlike `invalidateAll`, `refreshAll` does not reset `page.state`.
3177
3146
  * */
3178
3147
  export function invalidateAll(): Promise<void>;
3179
3148
  /**
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).
3149
+ * Causes all currently active remote functions to refresh, and all `load` functions belonging to the currently active page to re-run.
3181
3150
  * Returns a `Promise` that resolves when the page is subsequently updated.
3182
3151
  * */
3183
- export function refreshAll({ includeLoadFunctions }?: {
3184
- includeLoadFunctions?: boolean;
3185
- }): Promise<void>;
3152
+ export function refreshAll(): Promise<void>;
3186
3153
  /**
3187
3154
  * Programmatically preloads the given page, which means
3188
3155
  * 1. ensuring that the code for the page is loaded, and
@@ -3194,13 +3161,17 @@ declare module '$app/navigation' {
3194
3161
  *
3195
3162
  * @param href Page to preload
3196
3163
  * */
3197
- export function preloadData(href: string): Promise<{
3164
+ export function preloadData(href: string): Promise<({
3198
3165
  type: "loaded";
3199
- status: number;
3200
3166
  data: Record<string, any>;
3201
3167
  } | {
3202
3168
  type: "redirect";
3203
3169
  location: string;
3170
+ } | {
3171
+ type: "error";
3172
+ error: App.Error;
3173
+ }) & {
3174
+ status: number;
3204
3175
  }>;
3205
3176
  /**
3206
3177
  * Programmatically imports the code for routes that haven't yet been fetched.
@@ -3229,49 +3200,9 @@ declare module '$app/navigation' {
3229
3200
  }
3230
3201
 
3231
3202
  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
-
3242
- /**
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
-
3203
+ import type { Asset, RouteIdWithSearchOrHash, PathnameWithSearchOrHash, ResolvedPathname, Pathname, RouteId, RouteParams } from '$app/types';
3251
3204
  /**
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.
3205
+ * 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
3206
  *
3276
3207
  * During server rendering, the base path is relative and depends on the page currently being rendered.
3277
3208
  *
@@ -3326,17 +3257,33 @@ declare module '$app/paths' {
3326
3257
  * @since 2.52.0
3327
3258
  *
3328
3259
  * */
3329
- export function match(url: Pathname_1 | URL | (string & {})): Promise<{
3330
- id: RouteId;
3331
- params: Record<string, string>;
3332
- } | null>;
3260
+ export function match(url: Pathname | URL | (string & {})): Promise<{ [K in RouteId]: {
3261
+ id: K;
3262
+ params: RouteParams<K>;
3263
+ }; }[RouteId] | null>;
3264
+ type StripSearchOrHash<T extends string> = T extends `${infer Pathname}?${string}`
3265
+ ? Pathname
3266
+ : T extends `${infer Pathname}#${string}`
3267
+ ? Pathname
3268
+ : T;
3269
+
3270
+ type ResolveArgs<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash> =
3271
+ T extends RouteId
3272
+ ? RouteParams<T> extends Record<string, never>
3273
+ ? [route: T]
3274
+ : [route: T, params: RouteParams<T>]
3275
+ : StripSearchOrHash<T> extends infer U extends RouteId
3276
+ ? RouteParams<U> extends Record<string, never>
3277
+ ? [route: T]
3278
+ : [route: T, params: RouteParams<U>]
3279
+ : [route: T];
3333
3280
 
3334
3281
  export {};
3335
3282
  }
3336
3283
 
3337
3284
  declare module '$app/server' {
3338
- import type { RequestEvent, RemoteCommand, RemoteForm, RemoteFormInput, InvalidField, RemotePrerenderFunction, RemoteQueryFunction, RemoteLiveQueryFunction, QueryRequestedResult, LiveQueryRequestedResult } from '@sveltejs/kit';
3339
3285
  import type { StandardSchemaV1 } from '@standard-schema/spec';
3286
+ import type { RequestEvent, RemoteCommand, RemoteForm, RemoteFormInput, InvalidField, RemotePrerenderFunction, RemoteQueryFunction, RemoteLiveQueryFunction, QueryRequestedResult, LiveQueryRequestedResult } from '@sveltejs/kit';
3340
3287
  /**
3341
3288
  * Read the contents of an imported asset from the filesystem
3342
3289
  * @example
@@ -3405,7 +3352,7 @@ declare module '$app/server' {
3405
3352
  *
3406
3353
  * @since 2.27
3407
3354
  */
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>;
3355
+ 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
3356
  /**
3410
3357
  * Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a `fetch` call.
3411
3358
  *
@@ -3493,8 +3440,8 @@ declare module '$app/server' {
3493
3440
  function live<Schema extends StandardSchemaV1, Output>(schema: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => RemoteLiveQueryUserFunctionReturnType<Output>): RemoteLiveQueryFunction<StandardSchemaV1.InferInput<Schema>, Output, StandardSchemaV1.InferOutput<Schema>>;
3494
3441
  }
3495
3442
  /**
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
3443
+ * Inside a remote `command` or `form` callback, returns an iterable
3444
+ * of `{ arg, query }` entries for the query instances the client asked to refresh, up to
3498
3445
  * the supplied `limit`. Each `query` is a `RemoteQuery` bound to the original
3499
3446
  * client-side cache key, so `refresh()` / `set()` propagate correctly even when
3500
3447
  * the query's schema transforms the input. `arg` is the *validated* argument,
@@ -3503,6 +3450,8 @@ declare module '$app/server' {
3503
3450
  *
3504
3451
  * Arguments that fail validation or exceed `limit` are recorded as failures in
3505
3452
  * the response to the client.
3453
+ * See [Client-requested refreshes](https://svelte.dev/docs/kit/remote-functions#Single-flight-mutations-Client-requested-refreshes)
3454
+ * for usage in a remote `command` or `form`.
3506
3455
  *
3507
3456
  * @example
3508
3457
  * ```ts
@@ -3533,14 +3482,16 @@ declare module '$app/server' {
3533
3482
  * */
3534
3483
  export function requested<Input, Output, Validated = Input>(query: RemoteQueryFunction<Input, Output, Validated>, limit: number): QueryRequestedResult<Validated, Output>;
3535
3484
  /**
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
3485
+ * Inside a remote `command` or `form` callback, returns an iterable
3486
+ * of `{ arg, query }` entries for the live query instances the client asked to reconnect, up to
3538
3487
  * the supplied `limit`. Each `query` is a `RemoteLiveQuery` bound to the original
3539
3488
  * client-side cache key, so `reconnect()` propagates correctly even when
3540
3489
  * the query's schema transforms the input. `arg` is the *validated* argument.
3541
3490
  *
3542
3491
  * Arguments that fail validation or exceed `limit` are recorded as failures in
3543
3492
  * the response to the client.
3493
+ * See [Client-requested refreshes](https://svelte.dev/docs/kit/remote-functions#Single-flight-mutations-Client-requested-refreshes)
3494
+ * for usage in a remote `command` or `form`.
3544
3495
  *
3545
3496
  * @example
3546
3497
  * ```ts
@@ -3573,6 +3524,19 @@ declare module '$app/server' {
3573
3524
  type RemotePrerenderInputsGenerator<Input = any> = () => MaybePromise<Input[]>;
3574
3525
  type MaybePromise<T> = T | Promise<T>;
3575
3526
 
3527
+ type IsAny<T> = 0 extends 1 & T ? true : false;
3528
+
3529
+ type HasNonOptionalBoolean<T> =
3530
+ IsAny<T> extends true
3531
+ ? never
3532
+ : [T] extends [boolean]
3533
+ ? true
3534
+ : T extends Array<infer U>
3535
+ ? HasNonOptionalBoolean<U>
3536
+ : T extends Record<string, any>
3537
+ ? { [K in keyof T]: HasNonOptionalBoolean<T[K]> }[keyof T]
3538
+ : never;
3539
+
3576
3540
  export {};
3577
3541
  }
3578
3542
 
@@ -3637,46 +3601,7 @@ declare module '$app/state' {
3637
3601
  export {};
3638
3602
  }
3639
3603
 
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
- }/**
3604
+ /**
3680
3605
  * 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
3606
  *
3682
3607
  * ```ts
@@ -3703,29 +3628,34 @@ declare namespace App {
3703
3628
  * 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
3629
  */
3705
3630
  export interface Error {
3631
+ status: number;
3706
3632
  message: string;
3707
3633
  }
3708
3634
 
3709
3635
  /**
3710
3636
  * 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
3637
  */
3638
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
3712
3639
  export interface Locals {}
3713
3640
 
3714
3641
  /**
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.
3642
+ * 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
3643
  * The `Load` and `ServerLoad` functions in `./$types` will be narrowed accordingly.
3717
3644
  * Use optional properties for data that is only present on specific pages. Do not add an index signature (`[key: string]: any`).
3718
3645
  */
3646
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
3719
3647
  export interface PageData {}
3720
3648
 
3721
3649
  /**
3722
3650
  * 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
3651
  */
3652
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
3724
3653
  export interface PageState {}
3725
3654
 
3726
3655
  /**
3727
3656
  * 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
3657
  */
3658
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
3729
3659
  export interface Platform {}
3730
3660
  }
3731
3661
 
@@ -3734,8 +3664,8 @@ declare namespace App {
3734
3664
  */
3735
3665
  declare module '$service-worker' {
3736
3666
  /**
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.
3667
+ * 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.
3668
+ * Note that there is a `base` but no `assets`, since service workers cannot be used if `config.paths.assets` is specified.
3739
3669
  */
3740
3670
  export const base: string;
3741
3671
  /**
@@ -3744,7 +3674,7 @@ declare module '$service-worker' {
3744
3674
  */
3745
3675
  export const build: string[];
3746
3676
  /**
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)
3677
+ * 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
3678
  */
3749
3679
  export const files: string[];
3750
3680
  /**
@@ -3753,7 +3683,7 @@ declare module '$service-worker' {
3753
3683
  */
3754
3684
  export const prerendered: string[];
3755
3685
  /**
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.
3686
+ * 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
3687
  */
3758
3688
  export const version: string;
3759
3689
  }