@sveltejs/kit 3.0.0-next.2 → 3.0.0-next.21

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 (195) hide show
  1. package/package.json +62 -36
  2. package/src/cli.js +15 -12
  3. package/src/constants.js +6 -1
  4. package/src/core/adapt/builder.js +66 -72
  5. package/src/core/adapt/index.js +17 -6
  6. package/src/core/config/index.js +134 -80
  7. package/src/core/config/options.js +295 -273
  8. package/src/core/config/types.d.ts +1 -1
  9. package/src/core/env.js +146 -16
  10. package/src/core/generate_manifest/index.js +18 -15
  11. package/src/core/postbuild/analyse.js +8 -20
  12. package/src/core/postbuild/crawl.js +22 -6
  13. package/src/core/postbuild/entities.js +8 -2
  14. package/src/core/postbuild/fallback.js +4 -2
  15. package/src/core/postbuild/prerender.js +222 -70
  16. package/src/core/postbuild/queue.js +2 -1
  17. package/src/core/sync/create_manifest_data/conflict.js +1 -1
  18. package/src/core/sync/create_manifest_data/index.js +82 -62
  19. package/src/core/sync/sync.js +40 -31
  20. package/src/core/sync/ts.js +1 -1
  21. package/src/core/sync/utils.js +22 -2
  22. package/src/core/sync/{write_non_ambient.js → write_app_types.js} +107 -58
  23. package/src/core/sync/write_client_manifest.js +14 -29
  24. package/src/core/sync/write_env.js +7 -5
  25. package/src/core/sync/write_server.js +37 -45
  26. package/src/core/sync/write_tsconfig/index.js +274 -0
  27. package/src/core/sync/write_tsconfig/test-app/package.json +7 -0
  28. package/src/core/sync/write_tsconfig/utils.js +77 -0
  29. package/src/core/sync/write_tsconfig/validate.js +128 -0
  30. package/src/core/sync/write_types/index.js +127 -123
  31. package/src/core/utils.js +30 -5
  32. package/src/exports/env/index.js +77 -0
  33. package/src/exports/env/public.d.ts +55 -0
  34. package/src/exports/hooks/index.js +3 -9
  35. package/src/exports/hooks/public.d.ts +195 -0
  36. package/src/exports/hooks/sequence.js +9 -6
  37. package/src/exports/index.js +52 -29
  38. package/src/exports/internal/client.js +5 -0
  39. package/src/exports/internal/env.js +8 -5
  40. package/src/exports/internal/index.js +1 -90
  41. package/src/exports/internal/{event.js → server/event.js} +2 -3
  42. package/src/exports/internal/server/index.js +37 -0
  43. package/src/exports/internal/server/telemetry.js +95 -0
  44. package/src/exports/internal/shared.js +90 -0
  45. package/src/exports/node/index.js +64 -22
  46. package/src/exports/params/index.js +70 -0
  47. package/src/exports/params/public.d.ts +63 -0
  48. package/src/exports/public.d.ts +50 -1733
  49. package/src/exports/remote/index.js +11 -0
  50. package/src/exports/remote/public.d.ts +519 -0
  51. package/src/exports/url.js +86 -0
  52. package/src/exports/vite/build/build_server.js +54 -65
  53. package/src/exports/vite/build/remote.js +24 -19
  54. package/src/exports/vite/build/utils.js +0 -8
  55. package/src/exports/vite/dev/index.js +218 -146
  56. package/src/exports/vite/index.js +1590 -858
  57. package/src/exports/vite/module_ids.js +2 -2
  58. package/src/exports/vite/preview/index.js +40 -32
  59. package/src/exports/vite/public.d.ts +588 -0
  60. package/src/exports/vite/utils.js +84 -46
  61. package/src/pathname.js +55 -0
  62. package/src/runner.js +15 -0
  63. package/src/runtime/app/env/internal.js +4 -4
  64. package/src/runtime/app/env/types.d.ts +1 -1
  65. package/src/runtime/app/environment/index.js +3 -3
  66. package/src/runtime/app/{forms.js → forms/index.js} +73 -42
  67. package/src/runtime/app/forms/public.d.ts +2 -0
  68. package/src/runtime/app/forms/types.d.ts +56 -0
  69. package/src/runtime/app/internal/transport.js +53 -0
  70. package/src/runtime/app/manifest/index.js +1 -0
  71. package/src/runtime/app/{navigation.js → navigation/index.js} +2 -1
  72. package/src/runtime/app/navigation/public.d.ts +237 -0
  73. package/src/runtime/app/paths/client.js +37 -37
  74. package/src/runtime/app/paths/index.js +1 -1
  75. package/src/runtime/app/paths/internal/client.js +34 -2
  76. package/src/runtime/app/paths/internal/server.js +6 -23
  77. package/src/runtime/app/paths/internal.d.ts +3 -0
  78. package/src/runtime/app/paths/public.d.ts +1 -29
  79. package/src/runtime/app/paths/server.js +36 -17
  80. package/src/runtime/app/paths/types.d.ts +11 -19
  81. package/src/runtime/app/server/index.js +2 -2
  82. package/src/runtime/app/server/public.d.ts +201 -0
  83. package/src/runtime/app/server/remote/command.js +13 -11
  84. package/src/runtime/app/server/remote/form.js +61 -39
  85. package/src/runtime/app/server/remote/prerender.js +45 -45
  86. package/src/runtime/app/server/remote/query.js +106 -108
  87. package/src/runtime/app/server/remote/requested.js +27 -19
  88. package/src/runtime/app/server/remote/shared.js +76 -76
  89. package/src/runtime/app/service-worker/index.js +24 -0
  90. package/src/runtime/app/state/client.js +4 -2
  91. package/src/runtime/app/state/index.js +7 -5
  92. package/src/runtime/app/state/public.d.ts +72 -0
  93. package/src/runtime/app/state/server.js +3 -0
  94. package/src/runtime/app/stores.js +15 -78
  95. package/src/runtime/client/bundle.js +1 -1
  96. package/src/runtime/client/client-entry.js +3 -0
  97. package/src/runtime/client/client.js +1336 -648
  98. package/src/runtime/client/constants.js +3 -6
  99. package/src/runtime/client/entry.js +24 -3
  100. package/src/runtime/client/fetcher.js +25 -25
  101. package/src/runtime/client/ndjson.js +1 -1
  102. package/src/runtime/client/parse.js +1 -1
  103. package/src/runtime/client/payload.js +17 -0
  104. package/src/runtime/client/remote-functions/cache.svelte.js +3 -1
  105. package/src/runtime/client/remote-functions/command.svelte.js +37 -61
  106. package/src/runtime/client/remote-functions/form.svelte.js +267 -178
  107. package/src/runtime/client/remote-functions/prerender.svelte.js +32 -11
  108. package/src/runtime/client/remote-functions/query/index.js +10 -17
  109. package/src/runtime/client/remote-functions/query/instance.svelte.js +64 -18
  110. package/src/runtime/client/remote-functions/query/proxy.js +5 -5
  111. package/src/runtime/client/remote-functions/query-batch.svelte.js +61 -70
  112. package/src/runtime/client/remote-functions/query-live/index.js +1 -1
  113. package/src/runtime/client/remote-functions/query-live/instance.svelte.js +63 -21
  114. package/src/runtime/client/remote-functions/query-live/iterator.js +15 -12
  115. package/src/runtime/client/remote-functions/query-live/proxy.js +2 -12
  116. package/src/runtime/client/remote-functions/shared.svelte.js +90 -65
  117. package/src/runtime/client/snapshots.js +147 -0
  118. package/src/runtime/client/state.svelte.js +94 -55
  119. package/src/runtime/client/stream.js +3 -2
  120. package/src/runtime/client/types.d.ts +13 -9
  121. package/src/runtime/client/utils.js +22 -110
  122. package/src/runtime/components/root.svelte +56 -0
  123. package/src/runtime/env/dynamic/private.js +7 -0
  124. package/src/runtime/env/dynamic/public.js +7 -0
  125. package/src/runtime/env/static/private.js +6 -0
  126. package/src/runtime/env/static/public.js +6 -0
  127. package/src/runtime/form-utils.js +172 -61
  128. package/src/runtime/pathname.js +20 -32
  129. package/src/runtime/props.svelte.js +72 -0
  130. package/src/runtime/server/constants.js +0 -3
  131. package/src/runtime/server/cookie.js +72 -55
  132. package/src/runtime/server/csrf.js +65 -0
  133. package/src/runtime/server/data/index.js +49 -53
  134. package/src/runtime/server/dev.js +22 -0
  135. package/src/runtime/server/endpoint.js +6 -7
  136. package/src/runtime/server/env_module.js +0 -5
  137. package/src/runtime/server/errors.js +160 -0
  138. package/src/runtime/server/fetch.js +32 -39
  139. package/src/runtime/server/index.js +90 -64
  140. package/src/runtime/server/internal.js +71 -0
  141. package/src/runtime/server/page/actions.js +85 -64
  142. package/src/runtime/server/page/crypto.js +2 -2
  143. package/src/runtime/server/page/csp.js +88 -104
  144. package/src/runtime/server/page/data_serializer.js +24 -25
  145. package/src/runtime/server/page/index.js +36 -53
  146. package/src/runtime/server/page/load_data.js +50 -57
  147. package/src/runtime/server/page/render.js +173 -239
  148. package/src/runtime/server/page/respond_with_error.js +17 -31
  149. package/src/runtime/server/page/serialize_data.js +2 -13
  150. package/src/runtime/server/page/server_routing.js +85 -26
  151. package/src/runtime/server/remote-functions.js +640 -0
  152. package/src/runtime/server/respond.js +190 -131
  153. package/src/runtime/server/sourcemaps.js +183 -0
  154. package/src/runtime/server/state.js +53 -0
  155. package/src/runtime/server/utils.js +13 -155
  156. package/src/runtime/shared.js +20 -40
  157. package/src/runtime/utils.js +3 -0
  158. package/src/types/ambient-private.d.ts +11 -1
  159. package/src/types/ambient.d.ts +87 -36
  160. package/src/types/global-private.d.ts +25 -25
  161. package/src/types/internal.d.ts +163 -157
  162. package/src/types/private.d.ts +41 -1
  163. package/src/utils/error.js +28 -4
  164. package/src/utils/escape.js +9 -25
  165. package/src/utils/features.js +1 -1
  166. package/src/utils/filesystem.js +1 -23
  167. package/src/utils/fork.js +7 -2
  168. package/src/utils/hash.js +21 -0
  169. package/src/utils/http.js +8 -7
  170. package/src/utils/import.js +9 -2
  171. package/src/utils/imports.js +83 -0
  172. package/src/utils/mime.js +9 -0
  173. package/src/utils/page_nodes.js +6 -7
  174. package/src/utils/params.js +67 -0
  175. package/src/utils/regex.js +9 -0
  176. package/src/utils/routing.js +145 -73
  177. package/src/utils/shared-iterator.js +5 -0
  178. package/src/utils/streaming.js +14 -4
  179. package/src/utils/url.js +33 -2
  180. package/src/version.js +1 -1
  181. package/types/index.d.ts +2616 -2433
  182. package/types/index.d.ts.map +120 -106
  183. package/src/core/sync/write_ambient.js +0 -18
  184. package/src/core/sync/write_root.js +0 -148
  185. package/src/core/sync/write_tsconfig.js +0 -250
  186. package/src/exports/internal/server.js +0 -22
  187. package/src/exports/node/polyfills.js +0 -30
  188. package/src/runtime/server/app.js +0 -9
  189. package/src/runtime/server/remote.js +0 -457
  190. package/src/runtime/shared-server.js +0 -7
  191. package/src/runtime/telemetry/otel.js +0 -21
  192. package/src/runtime/telemetry/record_span.js +0 -65
  193. package/src/types/synthetic/$lib.md +0 -5
  194. /package/src/exports/internal/{remote-functions.js → server/remote-functions.js} +0 -0
  195. /package/src/{runtime/telemetry/noop.js → telemetry.js} +0 -0
@@ -4,29 +4,19 @@ import '../types/ambient.js';
4
4
 
5
5
  import {
6
6
  AdapterEntry,
7
- CspDirectives,
8
7
  HttpMethod,
9
8
  Logger,
10
9
  MaybePromise,
11
10
  Prerendered,
12
- PrerenderEntryGeneratorMismatchHandlerValue,
13
- PrerenderHttpErrorHandlerValue,
14
- PrerenderMissingIdHandlerValue,
15
- PrerenderUnseenRoutesHandlerValue,
16
11
  PrerenderOption,
17
12
  RequestOptions,
18
- RouteSegment,
19
- DeepPartial,
20
- IsAny
13
+ RouteSegment
21
14
  } from '../types/private.js';
22
15
  import { BuildData, SSRNodeLoader, SSRRoute, ValidatedConfig } from 'types';
23
- import { SvelteConfig } from '@sveltejs/vite-plugin-svelte';
24
- import { StandardSchemaV1 } from '@standard-schema/spec';
25
- import {
26
- RouteId as AppRouteId,
27
- LayoutParams as AppLayoutParams,
28
- ResolvedPathname
29
- } from '$app/types';
16
+ import { Plugin } from 'vite';
17
+ import { RequestEvent } from '$app/server';
18
+ import { RouteId as AppRouteId, LayoutParams as AppLayoutParams } from '$app/types';
19
+ import { ParamMatcher } from '@sveltejs/kit/params';
30
20
 
31
21
  export { PrerenderOption } from '../types/private.js';
32
22
 
@@ -54,7 +44,7 @@ export interface Adapter {
54
44
  * Test support for `read` from `$app/server`.
55
45
  * @param details.config The merged adapter-specific route config exported from the route with `export const config`
56
46
  */
57
- read?: (details: { config: any; route: { id: string } }) => boolean;
47
+ read?: (details: { config: Record<string, any>; route: { id: string } }) => boolean;
58
48
 
59
49
  /**
60
50
  * Test support for `instrumentation.server.js`. To pass, the adapter must support running `instrumentation.server.js` prior to the application code.
@@ -67,6 +57,20 @@ export interface Adapter {
67
57
  * during dev, build and prerendering.
68
58
  */
69
59
  emulate?: () => MaybePromise<Emulator>;
60
+ vite?: {
61
+ plugins?: {
62
+ /**
63
+ * Vite plugins placed before any of SvelteKit's own plugins.
64
+ * @since 3.0.0
65
+ */
66
+ pre?: Plugin[];
67
+ /**
68
+ * Vite plugins placed after any of SvelteKit's own plugins.
69
+ * @since 3.0.0
70
+ */
71
+ post?: Plugin[];
72
+ };
73
+ };
70
74
  }
71
75
 
72
76
  export type LoadProperties<input extends Record<string, any> | void> = input extends void
@@ -110,12 +114,18 @@ type UnpackValidationError<T> =
110
114
  export interface Builder {
111
115
  /** Print messages to the console. `log.info` and `log.minor` are silent unless Vite's `logLevel` is `info`. */
112
116
  log: Logger;
113
- /** Remove `dir` and all its contents. */
117
+ /**
118
+ * Remove `dir` and all its contents.
119
+ * @deprecated Use `fs.rmSync(dir, { force: true, recursive: true })` instead
120
+ */
114
121
  rimraf: (dir: string) => void;
115
- /** Create `dir` and any required parent directories. */
122
+ /**
123
+ * Create `dir` and any required parent directories.
124
+ * @deprecated Use `fs.mkdirSync(dir, { recursive: true })` instead
125
+ */
116
126
  mkdirp: (dir: string) => void;
117
127
 
118
- /** The fully resolved Svelte config. */
128
+ /** The fully resolved SvelteKit config. */
119
129
  config: ValidatedConfig;
120
130
  /** Information about prerendered pages and assets, if any. */
121
131
  prerendered: Prerendered;
@@ -146,7 +156,8 @@ export interface Builder {
146
156
 
147
157
  /**
148
158
  * Generate a server-side manifest to initialise the SvelteKit [server](https://svelte.dev/docs/kit/@sveltejs-kit#Server) with.
149
- * @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
159
+ * @param opts
160
+ * @param opts.relativePath A relative path to the base directory of the server build output
150
161
  */
151
162
  generateManifest: (opts: { relativePath: string; routes?: RouteDefinition[] }) => string;
152
163
 
@@ -241,72 +252,9 @@ export interface Builder {
241
252
  /**
242
253
  * Compress files in `directory` with gzip and brotli, where appropriate. Generates `.gz` and `.br` files alongside the originals.
243
254
  * @param {string} directory The directory containing the files to be compressed
255
+ * @returns an array of the files in `directory` that were compressed
244
256
  */
245
- compress: (directory: string) => Promise<void>;
246
- }
247
-
248
- /**
249
- * An extension of [`vite-plugin-svelte`'s options](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#svelte-options).
250
- */
251
- export interface Config extends SvelteConfig {
252
- /**
253
- * SvelteKit options.
254
- *
255
- * @see https://svelte.dev/docs/kit/configuration
256
- */
257
- kit?: KitConfig;
258
- /** Any additional options required by tooling that integrates with Svelte. */
259
- [key: string]: any;
260
- }
261
-
262
- export interface Cookies {
263
- /**
264
- * Gets a cookie that was previously set with `cookies.set`, or from the request headers.
265
- * @param name the name of the cookie
266
- * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
267
- */
268
- get: (name: string, opts?: import('cookie').ParseOptions) => string | undefined;
269
-
270
- /**
271
- * Gets all cookies that were previously set with `cookies.set`, or from the request headers.
272
- * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
273
- */
274
- getAll: (opts?: import('cookie').ParseOptions) => Array<{ name: string; value: string }>;
275
-
276
- /**
277
- * Sets a cookie. This will add a `set-cookie` header to the response, but also make the cookie available via `cookies.get` or `cookies.getAll` during the current request.
278
- *
279
- * The `httpOnly` and `secure` options are `true` by default (except on http://localhost, where `secure` is `false`), and must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
280
- *
281
- * 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.
282
- * @param name the name of the cookie
283
- * @param value the cookie value
284
- * @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)
285
- */
286
- set: (name: string, value: string, opts: import('cookie').SerializeOptions) => void;
287
-
288
- /**
289
- * Deletes a cookie by setting its value to an empty string and setting the expiry date in the past.
290
- *
291
- * The `httpOnly` and `secure` options are `true` by default (except on http://localhost, where `secure` is `false`), and must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
292
- *
293
- * 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.
294
- * @param name the name of the cookie
295
- * @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)
296
- */
297
- delete: (name: string, opts: import('cookie').SerializeOptions) => void;
298
-
299
- /**
300
- * Serialize a cookie name-value pair into a `Set-Cookie` header string, but don't apply it to the response.
301
- *
302
- * The `httpOnly` and `secure` options are `true` by default (except on http://localhost, where `secure` is `false`), and must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
303
- *
304
- * 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.
305
- * @param name the name of the cookie
306
- * @param value the cookie value
307
- * @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)
308
- */
309
- serialize: (name: string, value: string, opts: import('cookie').SerializeOptions) => string;
257
+ compress: (directory: string) => Promise<string[]>;
310
258
  }
311
259
 
312
260
  /**
@@ -320,705 +268,6 @@ export interface Emulator {
320
268
  platform?(details: { config: any; prerender: PrerenderOption }): MaybePromise<App.Platform>;
321
269
  }
322
270
 
323
- export interface KitConfig {
324
- // TODO: remove this in 4.0
325
- /**
326
- * Your [adapter](https://svelte.dev/docs/kit/adapters) is run when executing `vite build`. It determines how the output is converted for different platforms.
327
- * @default undefined
328
- * @deprecated removed in 3.0.0. Adapters should now be passed to the `sveltekit` Vite plugin in `vite.config.js`
329
- */
330
- adapter?: Adapter;
331
- /**
332
- * An object containing zero or more aliases used to replace values in `import` statements. These aliases are automatically passed to Vite and TypeScript.
333
- *
334
- * ```js
335
- * /// file: svelte.config.js
336
- * /// type: import('@sveltejs/kit').Config
337
- * const config = {
338
- * kit: {
339
- * alias: {
340
- * // this will match a file
341
- * 'my-file': 'path/to/my-file.js',
342
- *
343
- * // this will match a directory and its contents
344
- * // (`my-directory/x` resolves to `path/to/my-directory/x`)
345
- * 'my-directory': 'path/to/my-directory',
346
- *
347
- * // an alias ending /* will only match
348
- * // the contents of a directory, not the directory itself
349
- * 'my-directory/*': 'path/to/my-directory/*'
350
- * }
351
- * }
352
- * };
353
- * ```
354
- *
355
- * > [!NOTE] You will need to run `npm run dev` to have SvelteKit automatically generate the required alias configuration in `jsconfig.json` or `tsconfig.json`.
356
- * @default {}
357
- */
358
- alias?: Record<string, string>;
359
- /**
360
- * The directory where SvelteKit keeps its stuff, including static assets (such as JS and CSS) and internally-used routes.
361
- *
362
- * If `paths.assets` is specified, there will be two app directories — `${paths.assets}/${appDir}` and `${paths.base}/${appDir}`.
363
- * @default "_app"
364
- */
365
- appDir?: string;
366
- /**
367
- * [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...
368
- *
369
- * ```js
370
- * /// file: svelte.config.js
371
- * /// type: import('@sveltejs/kit').Config
372
- * const config = {
373
- * kit: {
374
- * csp: {
375
- * directives: {
376
- * 'script-src': ['self']
377
- * },
378
- * // must be specified with either the `report-uri` or `report-to` directives, or both
379
- * reportOnly: {
380
- * 'script-src': ['self'],
381
- * 'report-uri': ['/']
382
- * }
383
- * }
384
- * }
385
- * };
386
- *
387
- * export default config;
388
- * ```
389
- *
390
- * ...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.
391
- *
392
- * To add a nonce for scripts and links manually included in `src/app.html`, you may use the placeholder `%sveltekit.nonce%` (for example `<script nonce="%sveltekit.nonce%">`).
393
- *
394
- * When pages are prerendered, the CSP header is added via a `<meta http-equiv>` tag (note that in this case, `frame-ancestors`, `report-uri` and `sandbox` directives will be ignored).
395
- *
396
- * > [!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.
397
- *
398
- * > [!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`.
399
- *
400
- * 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.
401
- */
402
- csp?: {
403
- /**
404
- * Whether to use hashes or nonces to restrict `<script>` and `<style>` elements. `'auto'` will use hashes for prerendered pages, and nonces for dynamically rendered pages.
405
- */
406
- mode?: 'hash' | 'nonce' | 'auto';
407
- /**
408
- * Directives that will be added to `Content-Security-Policy` headers.
409
- */
410
- directives?: CspDirectives;
411
- /**
412
- * Directives that will be added to `Content-Security-Policy-Report-Only` headers.
413
- */
414
- reportOnly?: CspDirectives;
415
- };
416
- /**
417
- * Protection against [cross-site request forgery (CSRF)](https://owasp.org/www-community/attacks/csrf) attacks.
418
- */
419
- csrf?: {
420
- /**
421
- * Whether to check the incoming `origin` header for `POST`, `PUT`, `PATCH`, or `DELETE` form submissions and verify that it matches the server's origin.
422
- *
423
- * To allow people to make `POST`, `PUT`, `PATCH`, or `DELETE` requests with a `Content-Type` of `application/x-www-form-urlencoded`, `multipart/form-data`, or `text/plain` to your app from other origins, you will need to disable this option. Be careful!
424
- * @default true
425
- * @deprecated removed in 3.0. Use `trustedOrigins: ['*']` instead
426
- */
427
- checkOrigin?: boolean;
428
- /**
429
- * An array of origins that are allowed to make cross-origin form submissions to your app.
430
- *
431
- * Each origin should be a complete origin including protocol (e.g., `https://payment-gateway.com`).
432
- * This is useful for allowing trusted third-party services like payment gateways or authentication providers to submit forms to your app.
433
- *
434
- * If the array contains `'*'`, all origins will be trusted. This is generally not recommended!
435
- *
436
- * > [!NOTE] Only add origins you completely trust, as this bypasses CSRF protection for those origins.
437
- *
438
- * CSRF checks only apply in production, not in local development.
439
- * @default []
440
- * @example ['https://checkout.stripe.com', 'https://accounts.google.com']
441
- */
442
- trustedOrigins?: string[];
443
- };
444
- /**
445
- * Whether or not the app is embedded inside a larger app. If `true`, SvelteKit will add its event listeners related to navigation etc on the parent of `%sveltekit.body%` instead of `window`, and will pass `params` from the server rather than inferring them from `location.pathname`.
446
- * Note that it is generally not supported to embed multiple SvelteKit apps on the same page and use client-side SvelteKit features within them (things such as pushing to the history state assume a single instance).
447
- * @default false
448
- */
449
- embedded?: boolean;
450
- /**
451
- * Environment variable configuration
452
- */
453
- env?: {
454
- /**
455
- * The directory to search for `.env` files.
456
- * @default "."
457
- */
458
- dir?: string;
459
- };
460
- /** Experimental features. Here be dragons. These are not subject to semantic versioning, so breaking changes or removal can happen in any release. */
461
- experimental?: {
462
- /**
463
- * 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).
464
- * @default { server: false, serverFile: false }
465
- * @since 2.31.0
466
- */
467
- tracing?: {
468
- /**
469
- * 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).
470
- * @default false
471
- * @since 2.31.0
472
- */
473
- server?: boolean;
474
- };
475
-
476
- /**
477
- * @since 2.31.0
478
- */
479
- instrumentation?: {
480
- /**
481
- * Enables `instrumentation.server.js` for tracing and observability instrumentation.
482
- * @default false
483
- * @since 2.31.0
484
- */
485
- server?: boolean;
486
- };
487
-
488
- /**
489
- * Whether to enable the experimental remote functions feature. This feature is not yet stable and may be changed or removed at any time.
490
- * @default false
491
- */
492
- remoteFunctions?: boolean;
493
-
494
- /**
495
- * Whether to enable the experimental forked preloading feature using Svelte's fork API.
496
- * @default false
497
- */
498
- forkPreloads?: boolean;
499
-
500
- /**
501
- * Whether to enable the experimental handling of rendering errors.
502
- * When enabled, `<svelte:boundary>` is used to wrap components at each level
503
- * where there's an `+error.svelte`, rendering the error page if the component fails.
504
- * In addition, error boundaries also work on the server and the error object goes through `handleError`.
505
- * @default false
506
- */
507
- handleRenderingErrors?: boolean;
508
- };
509
- /**
510
- * Where to find various files within your project.
511
- * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
512
- */
513
- files?: {
514
- /**
515
- * The location of your source code.
516
- * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
517
- * @default "src"
518
- * @since 2.28
519
- */
520
- src?: string;
521
- /**
522
- * A place to put static files that should have stable URLs and undergo no processing, such as `favicon.ico` or `manifest.json`.
523
- * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
524
- * @default "static"
525
- */
526
- assets?: string;
527
- hooks?: {
528
- /**
529
- * The location of your client [hooks](https://svelte.dev/docs/kit/hooks).
530
- * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
531
- * @default "src/hooks.client"
532
- */
533
- client?: string;
534
- /**
535
- * The location of your server [hooks](https://svelte.dev/docs/kit/hooks).
536
- * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
537
- * @default "src/hooks.server"
538
- */
539
- server?: string;
540
- /**
541
- * The location of your universal [hooks](https://svelte.dev/docs/kit/hooks).
542
- * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
543
- * @default "src/hooks"
544
- * @since 2.3.0
545
- */
546
- universal?: string;
547
- };
548
- /**
549
- * Your app's internal library, accessible throughout the codebase as `$lib`.
550
- * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
551
- * @default "src/lib"
552
- */
553
- lib?: string;
554
- /**
555
- * A directory containing [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#Matching).
556
- * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
557
- * @default "src/params"
558
- */
559
- params?: string;
560
- /**
561
- * The files that define the structure of your app (see [Routing](https://svelte.dev/docs/kit/routing)).
562
- * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
563
- * @default "src/routes"
564
- */
565
- routes?: string;
566
- /**
567
- * The location of your service worker's entry point (see [Service workers](https://svelte.dev/docs/kit/service-workers)).
568
- * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
569
- * @default "src/service-worker"
570
- */
571
- serviceWorker?: string;
572
- /**
573
- * The location of the template for HTML responses.
574
- * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
575
- * @default "src/app.html"
576
- */
577
- appTemplate?: string;
578
- /**
579
- * The location of the template for fallback error responses.
580
- * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
581
- * @default "src/error.html"
582
- */
583
- errorTemplate?: string;
584
- };
585
- /**
586
- * Inline CSS inside a `<style>` block at the head of the HTML. This option is a number that specifies the maximum length of a CSS file in UTF-16 code units, as specified by the [String.length](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length) property, to be inlined. All CSS files needed for the page that are smaller than this value are merged and inlined in a `<style>` block.
587
- *
588
- * > [!NOTE] This results in fewer initial requests and can improve your [First Contentful Paint](https://web.dev/first-contentful-paint) score. However, it generates larger HTML output and reduces the effectiveness of browser caches. Use it advisedly.
589
- * @default 0
590
- */
591
- inlineStyleThreshold?: number;
592
- /**
593
- * 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.
594
- * @default [".js", ".ts"]
595
- */
596
- moduleExtensions?: string[];
597
- /**
598
- * The directory that SvelteKit writes files to during `dev` and `build`. You should exclude this directory from version control.
599
- * @default ".svelte-kit"
600
- */
601
- outDir?: string;
602
- /**
603
- * Options related to the build output format
604
- */
605
- output?: {
606
- /**
607
- * Whether to use the [HTTP `Link` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link) to preload assets instead of the [`<link>` HTML element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link) for non-prerendered pages.
608
- *
609
- * Note that some web servers such as Nginx and Apache have a default header size limit which may be easily exceeded.
610
- * If you are using one of these web servers, you may want to leave this as `false` or configure a higher limit.
611
- *
612
- * @default false
613
- * @since 3.0.0
614
- */
615
- linkHeaderPreload?: boolean;
616
- /**
617
- * SvelteKit will preload the JavaScript modules needed for the initial page to avoid import 'waterfalls', resulting in faster application startup. There
618
- * are three strategies with different trade-offs:
619
- * - `modulepreload` - uses `<link rel="modulepreload">`. This delivers the best results in Chromium-based browsers, in Firefox 115+, and Safari 17+. It is ignored in older browsers.
620
- * - `preload-js` - uses `<link rel="preload">`. Prevents waterfalls in Chromium and Safari, but Chromium will parse each module twice (once as a script, once as a module). Causes modules to be requested twice in Firefox. This is a good setting if you want to maximise performance for users on iOS devices at the cost of a very slight degradation for Chromium users.
621
- * - `preload-mjs` - uses `<link rel="preload">` but with the `.mjs` extension which prevents double-parsing in Chromium. Some static webservers will fail to serve .mjs files with a `Content-Type: application/javascript` header, which will cause your application to break. If that doesn't apply to you, this is the option that will deliver the best performance for the largest number of users, until `modulepreload` is more widely supported.
622
- * @default "modulepreload"
623
- * @since 1.8.4
624
- * @deprecated removed in 3.0
625
- */
626
- preloadStrategy?: 'modulepreload' | 'preload-js' | 'preload-mjs';
627
- /**
628
- * The bundle strategy option affects how your app's JavaScript and CSS files are loaded.
629
- * - If `'split'`, splits the app up into multiple .js/.css files so that they are loaded lazily as the user navigates around the app. This is the default, and is recommended for most scenarios.
630
- * - If `'single'`, creates just one .js bundle and one .css file containing code for the entire app.
631
- * - If `'inline'`, inlines all JavaScript and CSS of the entire app into the HTML. The result is usable without a server (i.e. you can just open the file in your browser).
632
- *
633
- * When using `'split'`, you can also adjust the bundling behaviour by setting [`output.codeSplitting`](https://rolldown.rs/reference/OutputOptions.codeSplitting) inside your Vite config's [`build.rolldownOptions`](https://vite.dev/config/build-options#build-rolldownoptions).
634
- *
635
- * If you want to inline your assets, you'll need to set Vite's [`build.assetsInlineLimit`](https://vite.dev/config/build-options.html#build-assetsinlinelimit) option to an appropriate size then import your assets through Vite.
636
- *
637
- * ```js
638
- * /// file: vite.config.js
639
- * import { sveltekit } from '@sveltejs/kit/vite';
640
- * import { defineConfig } from 'vite';
641
- *
642
- * export default defineConfig({
643
- * plugins: [sveltekit()],
644
- * build: {
645
- * // inline all imported assets
646
- * assetsInlineLimit: Infinity
647
- * }
648
- * });
649
- * ```
650
- *
651
- * ```svelte
652
- * /// file: src/routes/+layout.svelte
653
- * <script>
654
- * // import the asset through Vite
655
- * import favicon from './favicon.png';
656
- * </script>
657
- *
658
- * <svelte:head>
659
- * <!-- this asset will be inlined as a base64 URL -->
660
- * <link rel="icon" href={favicon} />
661
- * </svelte:head>
662
- * ```
663
- * @default 'split'
664
- * @since 2.13.0
665
- */
666
- bundleStrategy?: 'split' | 'single' | 'inline';
667
- };
668
- paths?: {
669
- /**
670
- * An absolute path that your app's files are served from. This is useful if your files are served from a storage bucket of some kind.
671
- * @default ""
672
- */
673
- assets?: '' | `http://${string}` | `https://${string}`;
674
- /**
675
- * 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.
676
- * @default ""
677
- */
678
- base?: '' | `/${string}`;
679
- /**
680
- * Whether to use relative asset paths.
681
- *
682
- * 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.
683
- * If `false`, `%sveltekit.assets%` and references to build artifacts will always be root-relative paths, unless `paths.assets` is an external URL
684
- *
685
- * [Single-page app](https://svelte.dev/docs/kit/single-page-apps) fallback pages will always use absolute paths, regardless of this setting.
686
- *
687
- * If your app uses a `<base>` element, you should set this to `false`, otherwise asset URLs will incorrectly be resolved against the `<base>` URL rather than the current page.
688
- *
689
- * In 1.0, `undefined` was a valid value, which was set by default. In that case, if `paths.assets` was not external, SvelteKit would replace `%sveltekit.assets%` with a relative path and use relative paths to reference build artifacts, but `base` and `assets` imported from `$app/paths` would be as specified in your config.
690
- *
691
- * @default true
692
- * @since 1.9.0
693
- */
694
- relative?: boolean;
695
- };
696
- /**
697
- * See [Prerendering](https://svelte.dev/docs/kit/page-options#prerender).
698
- */
699
- prerender?: {
700
- /**
701
- * How many pages can be prerendered simultaneously. JS is single-threaded, but in cases where prerendering performance is network-bound (for example loading content from a remote CMS) this can speed things up by processing other tasks while waiting on the network response.
702
- * @default 1
703
- */
704
- concurrency?: number;
705
- /**
706
- * Whether SvelteKit should find pages to prerender by following links from `entries`.
707
- * @default true
708
- */
709
- crawl?: boolean;
710
- /**
711
- * An array of pages to prerender, or start crawling from (if `crawl: true`). The `*` string includes all routes containing no required `[parameters]` with optional parameters included as being empty (since SvelteKit doesn't know what value any parameters should have).
712
- * @default ["*"]
713
- */
714
- entries?: Array<'*' | `/${string}`>;
715
- /**
716
- * How to respond to HTTP errors encountered while prerendering the app.
717
- *
718
- * - `'fail'` — fail the build
719
- * - `'ignore'` - silently ignore the failure and continue
720
- * - `'warn'` — continue, but print a warning
721
- * - `(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
722
- *
723
- * ```js
724
- * /// file: svelte.config.js
725
- * /// type: import('@sveltejs/kit').Config
726
- * const config = {
727
- * kit: {
728
- * prerender: {
729
- * handleHttpError: ({ path, referrer, message }) => {
730
- * // ignore deliberate link to shiny 404 page
731
- * if (path === '/not-found' && referrer === '/blog/how-we-built-our-404-page') {
732
- * return;
733
- * }
734
- *
735
- * // otherwise fail the build
736
- * throw new Error(message);
737
- * }
738
- * }
739
- * }
740
- * };
741
- * ```
742
- *
743
- * @default "fail"
744
- * @since 1.15.7
745
- */
746
- handleHttpError?: PrerenderHttpErrorHandlerValue;
747
- /**
748
- * How to respond when hash links from one prerendered page to another don't correspond to an `id` on the destination page.
749
- *
750
- * - `'fail'` — fail the build
751
- * - `'ignore'` - silently ignore the failure and continue
752
- * - `'warn'` — continue, but print a warning
753
- * - `(details) => void` — a custom error handler that takes a `details` object with `path`, `id`, `referrers` and `message` properties. If you `throw` from this function, the build will fail
754
- *
755
- * @default "fail"
756
- * @since 1.15.7
757
- */
758
- handleMissingId?: PrerenderMissingIdHandlerValue;
759
- /**
760
- * How to respond when an entry generated by the `entries` export doesn't match the route it was generated from.
761
- *
762
- * - `'fail'` — fail the build
763
- * - `'ignore'` - silently ignore the failure and continue
764
- * - `'warn'` — continue, but print a warning
765
- * - `(details) => void` — a custom error handler that takes a `details` object with `generatedFromId`, `entry`, `matchedId` and `message` properties. If you `throw` from this function, the build will fail
766
- *
767
- * @default "fail"
768
- * @since 1.16.0
769
- */
770
- handleEntryGeneratorMismatch?: PrerenderEntryGeneratorMismatchHandlerValue;
771
- /**
772
- * How to respond when a route is marked as prerenderable but has not been prerendered.
773
- *
774
- * - `'fail'` — fail the build
775
- * - `'ignore'` - silently ignore the failure and continue
776
- * - `'warn'` — continue, but print a warning
777
- * - `(details) => void` — a custom error handler that takes a `details` object with a `routes` property which contains all routes that haven't been prerendered. If you `throw` from this function, the build will fail
778
- *
779
- * The default behavior is to fail the build. This may be undesirable when you know that some of your routes may never be reached under certain
780
- * circumstances such as a CMS not returning data for a specific area, resulting in certain routes never being reached.
781
- *
782
- * @default "fail"
783
- * @since 2.16.0
784
- */
785
- handleUnseenRoutes?: PrerenderUnseenRoutesHandlerValue;
786
- /**
787
- * The value of `url.origin` during prerendering; useful if it is included in rendered content.
788
- * @default "http://sveltekit-prerender"
789
- */
790
- origin?: string;
791
- };
792
- router?: {
793
- /**
794
- * What type of client-side router to use.
795
- * - `'pathname'` is the default and means the current URL pathname determines the route
796
- * - `'hash'` means the route is determined by `location.hash`. In this case, SSR and prerendering are disabled. This is only recommended if `pathname` is not an option, for example because you don't control the webserver where your app is deployed.
797
- * It comes with some caveats: you can't use server-side rendering (or indeed any server logic), and you have to make sure that the links in your app all start with #/, or they won't work. Beyond that, everything works exactly like a normal SvelteKit app.
798
- *
799
- * @default "pathname"
800
- * @since 2.14.0
801
- */
802
- type?: 'pathname' | 'hash';
803
- /**
804
- * How to determine which route to load when navigating to a new page.
805
- *
806
- * By default, SvelteKit will serve a route manifest to the browser.
807
- * When navigating, this manifest is used (along with the `reroute` hook, if it exists) to determine which components to load and which `load` functions to run.
808
- * Because everything happens on the client, this decision can be made immediately. The drawback is that the manifest needs to be
809
- * loaded and parsed before the first navigation can happen, which may have an impact if your app contains many routes.
810
- *
811
- * Alternatively, SvelteKit can determine the route on the server. This means that for every navigation to a path that has not yet been visited, the server will be asked to determine the route.
812
- * This has several advantages:
813
- * - The client does not need to load the routing manifest upfront, which can lead to faster initial page loads
814
- * - The list of routes is hidden from public view
815
- * - The server has an opportunity to intercept each navigation (for example through a middleware), enabling (for example) A/B testing opaque to SvelteKit
816
-
817
- * The drawback is that for unvisited paths, resolution will take slightly longer (though this is mitigated by [preloading](https://svelte.dev/docs/kit/link-options#data-sveltekit-preload-data)).
818
- *
819
- * > [!NOTE] When using server-side route resolution and prerendering, the resolution is prerendered along with the route itself.
820
- *
821
- * @default "client"
822
- * @since 2.17.0
823
- */
824
- resolution?: 'client' | 'server';
825
- };
826
- serviceWorker?: {
827
- /**
828
- * Determine which files in your `static` directory will be available in `$service-worker.files`.
829
- * @default (filename) => !/\.DS_Store/.test(filename)
830
- */
831
- files?: (file: string) => boolean;
832
- } & (
833
- | {
834
- /**
835
- * Whether to automatically register the service worker, if it exists.
836
- * @default true
837
- */
838
- register: true;
839
- /**
840
- * Options for serviceWorker.register("...", options);
841
- */
842
- options?: RegistrationOptions;
843
- }
844
- | {
845
- /**
846
- * Whether to automatically register the service worker, if it exists.
847
- * @default true
848
- */
849
- register?: false;
850
- }
851
- );
852
- typescript?: {
853
- /**
854
- * A function that allows you to edit the generated `tsconfig.json`. You can mutate the config (recommended) or return a new one.
855
- * This is useful for extending a shared `tsconfig.json` in a monorepo root, for example.
856
- *
857
- * Note that any paths configured here should be relative to the generated config file, which is written to `.svelte-kit/tsconfig.json`.
858
- *
859
- * @default (config) => config
860
- * @since 1.3.0
861
- */
862
- config?: (config: Record<string, any>) => Record<string, any> | void;
863
- };
864
- /**
865
- * Client-side navigation can be buggy if you deploy a new version of your app while people are using it. If the code for the new page is already loaded, it may have stale content; if it isn't, the app's route manifest may point to a JavaScript file that no longer exists.
866
- * SvelteKit helps you solve this problem through version management.
867
- * If SvelteKit encounters an error while loading the page and detects that a new version has been deployed (using the `name` specified here, which defaults to a timestamp of the build) it will fall back to traditional full-page navigation.
868
- * Not all navigations will result in an error though, for example if the JavaScript for the next page is already loaded. If you still want to force a full-page navigation in these cases, use techniques such as setting the `pollInterval` and then using `beforeNavigate`:
869
- * ```html
870
- * /// file: +layout.svelte
871
- * <script>
872
- * import { beforeNavigate } from '$app/navigation';
873
- * import { updated } from '$app/state';
874
- *
875
- * beforeNavigate(({ willUnload, to }) => {
876
- * if (updated.current && !willUnload && to?.url) {
877
- * location.href = to.url.href;
878
- * }
879
- * });
880
- * </script>
881
- * ```
882
- *
883
- * If you set `pollInterval` to a non-zero value, SvelteKit will poll for new versions in the background and set the value of [`updated.current`](https://svelte.dev/docs/kit/$app-state#updated) `true` when it detects one.
884
- */
885
- version?: {
886
- /**
887
- * The current app version string. If specified, this must be deterministic (e.g. a commit ref rather than `Math.random()` or `Date.now().toString()`), otherwise defaults to a timestamp of the build.
888
- *
889
- * For example, to use the current commit hash, you could do use `git rev-parse HEAD`:
890
- *
891
- * ```js
892
- * /// file: svelte.config.js
893
- * import * as child_process from 'node:child_process';
894
- *
895
- * export default {
896
- * kit: {
897
- * version: {
898
- * name: child_process.execSync('git rev-parse HEAD').toString().trim()
899
- * }
900
- * }
901
- * };
902
- * ```
903
- */
904
- name?: string;
905
- /**
906
- * The interval in milliseconds to poll for version changes. If this is `0`, no polling occurs.
907
- * @default 0
908
- */
909
- pollInterval?: number;
910
- };
911
- }
912
-
913
- /**
914
- * The [`handle`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle) hook runs every time the SvelteKit server receives a [request](https://svelte.dev/docs/kit/web-standards#Fetch-APIs-Request) and
915
- * determines the [response](https://svelte.dev/docs/kit/web-standards#Fetch-APIs-Response).
916
- * It receives an `event` object representing the request and a function called `resolve`, which renders the route and generates a `Response`.
917
- * This allows you to modify response headers or bodies, or bypass SvelteKit entirely (for implementing routes programmatically, for example).
918
- */
919
- export type Handle = (input: {
920
- event: RequestEvent;
921
- resolve: (event: RequestEvent, opts?: ResolveOptions) => MaybePromise<Response>;
922
- }) => MaybePromise<Response>;
923
-
924
- /**
925
- * The server-side [`handleError`](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError) hook runs when an unexpected error is thrown while responding to a request.
926
- *
927
- * If an unexpected error is thrown during loading or rendering, this function will be called with the error and the event.
928
- * Make sure that this function _never_ throws an error.
929
- */
930
- export type HandleServerError = (input: {
931
- error: unknown;
932
- event: RequestEvent;
933
- status: number;
934
- message: string;
935
- }) => MaybePromise<void | App.Error>;
936
-
937
- /**
938
- * The [`handleValidationError`](https://svelte.dev/docs/kit/hooks#Server-hooks-handleValidationError) hook runs when the argument to a remote function fails validation.
939
- *
940
- * It will be called with the validation issues and the event, and must return an object shape that matches `App.Error`.
941
- */
942
- export type HandleValidationError<Issue extends StandardSchemaV1.Issue = StandardSchemaV1.Issue> =
943
- (input: { issues: Issue[]; event: RequestEvent }) => MaybePromise<App.Error>;
944
-
945
- /**
946
- * The client-side [`handleError`](https://svelte.dev/docs/kit/hooks#Shared-hooks-handleError) hook runs when an unexpected error is thrown while navigating.
947
- *
948
- * If an unexpected error is thrown during loading or the following render, this function will be called with the error and the event.
949
- * Make sure that this function _never_ throws an error.
950
- */
951
- export type HandleClientError = (input: {
952
- error: unknown;
953
- event: NavigationEvent;
954
- status: number;
955
- message: string;
956
- }) => MaybePromise<void | App.Error>;
957
-
958
- /**
959
- * 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`.
960
- */
961
- export type HandleFetch = (input: {
962
- event: RequestEvent;
963
- request: Request;
964
- fetch: typeof fetch;
965
- }) => MaybePromise<Response>;
966
-
967
- /**
968
- * The [`init`](https://svelte.dev/docs/kit/hooks#Shared-hooks-init) will be invoked before the server responds to its first request
969
- * @since 2.10.0
970
- */
971
- export type ServerInit = () => MaybePromise<void>;
972
-
973
- /**
974
- * The [`init`](https://svelte.dev/docs/kit/hooks#Shared-hooks-init) will be invoked once the app starts in the browser
975
- * @since 2.10.0
976
- */
977
- export type ClientInit = () => MaybePromise<void>;
978
-
979
- /**
980
- * The [`reroute`](https://svelte.dev/docs/kit/hooks#Universal-hooks-reroute) hook allows you to modify the URL before it is used to determine which route to render.
981
- * @since 2.3.0
982
- */
983
- export type Reroute = (event: { url: URL; fetch: typeof fetch }) => MaybePromise<void | string>;
984
-
985
- /**
986
- * The [`transport`](https://svelte.dev/docs/kit/hooks#Universal-hooks-transport) hook allows you to transport custom types across the server/client boundary.
987
- *
988
- * Each transporter has a pair of `encode` and `decode` functions. On the server, `encode` determines whether a value is an instance of the custom type and, if so, returns a non-falsy encoding of the value which can be an object or an array (or `false` otherwise).
989
- *
990
- * In the browser, `decode` turns the encoding back into an instance of the custom type.
991
- *
992
- * ```ts
993
- * import type { Transport } from '@sveltejs/kit';
994
- *
995
- * declare class MyCustomType {
996
- * data: any
997
- * }
998
- *
999
- * // hooks.js
1000
- * export const transport: Transport = {
1001
- * MyCustomType: {
1002
- * encode: (value) => value instanceof MyCustomType && [value.data],
1003
- * decode: ([data]) => new MyCustomType(data)
1004
- * }
1005
- * };
1006
- * ```
1007
- * @since 2.11.0
1008
- */
1009
- export type Transport = Record<string, Transporter>;
1010
-
1011
- /**
1012
- * A member of the [`transport`](https://svelte.dev/docs/kit/hooks#Universal-hooks-transport) hook.
1013
- */
1014
- export interface Transporter<
1015
- T = any,
1016
- U = Exclude<any, false | 0 | '' | null | undefined | typeof NaN>
1017
- > {
1018
- encode: (value: T) => false | U;
1019
- decode: (data: U) => T;
1020
- }
1021
-
1022
271
  /**
1023
272
  * The generic form of `PageLoad` and `LayoutLoad`. You should import those from `./$types` (see [generated types](https://svelte.dev/docs/kit/types#Generated-types))
1024
273
  * rather than using `Load` directly.
@@ -1047,7 +296,7 @@ export interface LoadEvent<
1047
296
  * - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.
1048
297
  * - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).
1049
298
  * - Internal requests (e.g. for `+server.js` routes) go directly to the handler function when running on the server, without the overhead of an HTTP call.
1050
- * - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle)
299
+ * - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://svelte.dev/docs/kit/hooks#handle)
1051
300
  * - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.
1052
301
  *
1053
302
  * You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies)
@@ -1077,7 +326,7 @@ export interface LoadEvent<
1077
326
  *
1078
327
  * Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.
1079
328
  *
1080
- * You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/@sveltejs-kit#Cookies) API in a server-only `load` function instead.
329
+ * You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/$app-server#Cookies) API in a server-only `load` function instead.
1081
330
  *
1082
331
  * `setHeaders` has no effect when a `load` function runs in the browser.
1083
332
  */
@@ -1180,444 +429,15 @@ export interface NavigationEvent<
1180
429
  }
1181
430
 
1182
431
  /**
1183
- * Information about the target of a specific navigation.
432
+ * A `(event: RequestEvent) => Response` function exported from a `+server.js` file that corresponds to an HTTP verb (`GET`, `PUT`, `PATCH`, etc) and handles requests with that method.
433
+ *
434
+ * It receives `Params` as the first generic argument, which you can skip by using [generated types](https://svelte.dev/docs/kit/types#Generated-types) instead.
1184
435
  */
1185
- export interface NavigationTarget<
1186
- Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
1187
- RouteId extends AppRouteId | null = AppRouteId | null
1188
- > {
1189
- /**
1190
- * Parameters of the target page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
1191
- * Is `null` if the target is not part of the SvelteKit app (could not be resolved to a route).
1192
- */
1193
- params: Params | null;
1194
- /**
1195
- * Info about the target route
1196
- */
1197
- route: {
1198
- /**
1199
- * 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.
1200
- */
1201
- id: RouteId | null;
1202
- };
1203
- /**
1204
- * The URL that is navigated to
1205
- */
1206
- url: URL;
1207
- /**
1208
- * The scroll position associated with this navigation.
1209
- *
1210
- * For the `from` target, this is the scroll position at the moment of navigation.
1211
- *
1212
- * For the `to` target, this represents the scroll position that will be or was restored:
1213
- * - In `beforeNavigate` and `onNavigate`, this is only available for `popstate` navigations (back/forward button)
1214
- * and will be `null` for other navigation types, since the final scroll position isn't known
1215
- * ahead of time.
1216
- * - In `afterNavigate`, this is always the scroll position that was applied after the navigation
1217
- * completed.
1218
- */
1219
- scroll: { x: number; y: number } | null;
1220
- }
1221
-
1222
- /**
1223
- * - `enter`: The app has hydrated/started
1224
- * - `form`: The user submitted a `<form method="GET">`
1225
- * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
1226
- * - `link`: Navigation was triggered by a link click
1227
- * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
1228
- * - `popstate`: Navigation was triggered by back/forward navigation
1229
- */
1230
- export type NavigationType = 'enter' | 'form' | 'leave' | 'link' | 'goto' | 'popstate';
1231
-
1232
- export interface NavigationBase {
1233
- /**
1234
- * Where navigation was triggered from
1235
- */
1236
- from: NavigationTarget | null;
1237
- /**
1238
- * Where navigation is going to/has gone to
1239
- */
1240
- to: NavigationTarget | null;
1241
- /**
1242
- * Whether or not the navigation will result in the page being unloaded (i.e. not a client-side navigation).
1243
- */
1244
- willUnload: boolean;
1245
- /**
1246
- * A promise that resolves once the navigation is complete, and rejects if the navigation
1247
- * fails or is aborted. In the case of a `willUnload` navigation, the promise will never resolve
1248
- */
1249
- complete: Promise<void>;
1250
- }
1251
-
1252
- export interface NavigationEnter extends NavigationBase {
1253
- /**
1254
- * The type of navigation:
1255
- * - `enter`: The app has hydrated/started
1256
- */
1257
- type: 'enter';
1258
-
1259
- /**
1260
- * In case of a history back/forward navigation, the number of steps to go back/forward
1261
- */
1262
- delta?: undefined;
1263
-
1264
- /**
1265
- * Dispatched `Event` object when navigation occurred by `popstate` or `link`.
1266
- */
1267
- event?: undefined;
1268
- }
1269
-
1270
- export type NavigationExternal = NavigationGoto | NavigationLeave;
1271
-
1272
- export interface NavigationGoto extends NavigationBase {
1273
- /**
1274
- * The type of navigation:
1275
- * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
1276
- */
1277
- type: 'goto';
1278
- }
1279
-
1280
- export interface NavigationLeave extends NavigationBase {
1281
- /**
1282
- * The type of navigation:
1283
- * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
1284
- */
1285
- type: 'leave';
1286
- }
1287
-
1288
- export interface NavigationFormSubmit extends NavigationBase {
1289
- /**
1290
- * The type of navigation:
1291
- * - `form`: The user submitted a `<form method="GET">`
1292
- */
1293
- type: 'form';
1294
-
1295
- /**
1296
- * The `SubmitEvent` that caused the navigation
1297
- */
1298
- event: SubmitEvent;
1299
- }
1300
-
1301
- export interface NavigationPopState extends NavigationBase {
1302
- /**
1303
- * The type of navigation:
1304
- * - `popstate`: Navigation was triggered by back/forward navigation
1305
- */
1306
- type: 'popstate';
1307
-
1308
- /**
1309
- * In case of a history back/forward navigation, the number of steps to go back/forward
1310
- */
1311
- delta: number;
1312
-
1313
- /**
1314
- * The `PopStateEvent` that caused the navigation
1315
- */
1316
- event: PopStateEvent;
1317
- }
1318
-
1319
- export interface NavigationLink extends NavigationBase {
1320
- /**
1321
- * The type of navigation:
1322
- * - `link`: Navigation was triggered by a link click
1323
- */
1324
- type: 'link';
1325
-
1326
- /**
1327
- * The `PointerEvent` that caused the navigation
1328
- */
1329
- event: PointerEvent;
1330
- }
1331
-
1332
- export type Navigation =
1333
- | NavigationExternal
1334
- | NavigationFormSubmit
1335
- | NavigationPopState
1336
- | NavigationLink;
1337
-
1338
- /**
1339
- * The argument passed to [`beforeNavigate`](https://svelte.dev/docs/kit/$app-navigation#beforeNavigate) callbacks.
1340
- */
1341
- export type BeforeNavigate = Navigation & {
1342
- /**
1343
- * Call this to prevent the navigation from starting.
1344
- */
1345
- cancel: () => void;
1346
- };
1347
-
1348
- /**
1349
- * The argument passed to [`onNavigate`](https://svelte.dev/docs/kit/$app-navigation#onNavigate) callbacks.
1350
- */
1351
- export type OnNavigate = Navigation & {
1352
- type: Exclude<NavigationType, 'enter' | 'leave'>;
1353
- /**
1354
- * Since `onNavigate` callbacks are called immediately before a client-side navigation, they will never be called with a navigation that unloads the page.
1355
- */
1356
- willUnload: false;
1357
- };
1358
-
1359
- /**
1360
- * The argument passed to [`afterNavigate`](https://svelte.dev/docs/kit/$app-navigation#afterNavigate) callbacks.
1361
- */
1362
- export type AfterNavigate = (Navigation | NavigationEnter) & {
1363
- type: Exclude<NavigationType, 'leave'>;
1364
- /**
1365
- * Since `afterNavigate` callbacks are called after a navigation completes, they will never be called with a navigation that unloads the page.
1366
- */
1367
- willUnload: false;
1368
- };
1369
-
1370
- /**
1371
- * 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.
1372
- */
1373
- export interface Page<
1374
- Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
1375
- RouteId extends AppRouteId | null = AppRouteId | null
1376
- > {
1377
- /**
1378
- * The URL of the current page.
1379
- */
1380
- url: URL & { pathname: ResolvedPathname };
1381
- /**
1382
- * The parameters of the current page - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
1383
- */
1384
- params: Params;
1385
- /**
1386
- * Info about the current route.
1387
- */
1388
- route: {
1389
- /**
1390
- * 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.
1391
- */
1392
- id: RouteId;
1393
- };
1394
- /**
1395
- * HTTP status code of the current page.
1396
- */
1397
- status: number;
1398
- /**
1399
- * The error object of the current page, if any. Filled from the `handleError` hooks.
1400
- */
1401
- error: App.Error | null;
1402
- /**
1403
- * The merged result of all data from all `load` functions on the current page. You can type a common denominator through `App.PageData`.
1404
- */
1405
- data: App.PageData & Record<string, any>;
1406
- /**
1407
- * The page state, 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`.
1408
- */
1409
- state: App.PageState;
1410
- /**
1411
- * Filled only after a form submission. See [form actions](https://svelte.dev/docs/kit/form-actions) for more info.
1412
- */
1413
- form: any;
1414
- }
1415
-
1416
- /**
1417
- * The shape of a param matcher. See [matching](https://svelte.dev/docs/kit/advanced-routing#Matching) for more info.
1418
- */
1419
- export type ParamMatcher = (param: string) => boolean;
1420
-
1421
- /**
1422
- * A single entry yielded by [`requested`](https://svelte.dev/docs/kit/$app-server#requested)
1423
- * when called with a regular `query`. `arg` is the validated argument (the input *after*
1424
- * the query's schema validated and transformed it, if applicable); `query` is a
1425
- * `RemoteQuery` bound to the client's original cache key, so `refresh()` / `set()` will
1426
- * update the correct client entry.
1427
- */
1428
- export type RequestedEntry<Validated, Output> = {
1429
- arg: Validated;
1430
- query: RemoteQuery<Output>;
1431
- };
1432
-
1433
- /**
1434
- * A single entry yielded by [`requested`](https://svelte.dev/docs/kit/$app-server#requested)
1435
- * when called with a `query.live`. `arg` is the validated argument; `query` is a
1436
- * `RemoteLiveQuery` bound to the client's original cache key, so `reconnect()` targets
1437
- * the correct client subscription.
1438
- */
1439
- export type LiveRequestedEntry<Validated, Output> = {
1440
- arg: Validated;
1441
- query: RemoteLiveQuery<Output>;
1442
- };
1443
-
1444
- export type QueryRequestedResult<Validated, Output> = Iterable<RequestedEntry<Validated, Output>> &
1445
- AsyncIterable<RequestedEntry<Validated, Output>> & {
1446
- /**
1447
- * Call `refresh` on all queries selected by this `requested` invocation.
1448
- * This is identical to:
1449
- * ```ts
1450
- * import { requested } from '$app/server';
1451
- *
1452
- * for await (const { query } of requested(getPost, ...)) {
1453
- * void query.refresh();
1454
- * }
1455
- * ```
1456
- */
1457
- refreshAll: () => Promise<void>;
1458
- };
1459
-
1460
- export type LiveQueryRequestedResult<Validated, Output> = Iterable<
1461
- LiveRequestedEntry<Validated, Output>
1462
- > &
1463
- AsyncIterable<LiveRequestedEntry<Validated, Output>> & {
1464
- /**
1465
- * Call `reconnect` on all live queries selected by this `requested` invocation.
1466
- * This is identical to:
1467
- * ```ts
1468
- * import { requested } from '$app/server';
1469
- *
1470
- * for await (const { query } of requested(liveQuery, ...)) {
1471
- * void query.reconnect();
1472
- * }
1473
- * ```
1474
- */
1475
- reconnectAll: () => Promise<void>;
1476
- };
1477
-
1478
- export type RequestedResult<Validated, Output> =
1479
- | QueryRequestedResult<Validated, Output>
1480
- | LiveQueryRequestedResult<Validated, Output>;
1481
-
1482
- export interface RequestEvent<
1483
- Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
1484
- RouteId extends AppRouteId | null = AppRouteId | null
1485
- > {
1486
- /**
1487
- * Get or set cookies related to the current request
1488
- */
1489
- cookies: Cookies;
1490
- /**
1491
- * `fetch` is equivalent to the [native `fetch` web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch), with a few additional features:
1492
- *
1493
- * - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.
1494
- * - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).
1495
- * - Internal requests (e.g. for `+server.js` routes) go directly to the handler function when running on the server, without the overhead of an HTTP call.
1496
- * - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle)
1497
- * - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.
1498
- *
1499
- * You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies).
1500
- */
1501
- fetch: typeof fetch;
1502
- /**
1503
- * The client's IP address, set by the adapter.
1504
- */
1505
- getClientAddress: () => string;
1506
- /**
1507
- * Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle).
1508
- */
1509
- locals: App.Locals;
1510
- /**
1511
- * The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
1512
- */
1513
- params: Params;
1514
- /**
1515
- * Additional data made available through the adapter.
1516
- */
1517
- platform: Readonly<App.Platform> | undefined;
1518
- /**
1519
- * The original request object.
1520
- */
1521
- request: Request;
1522
- /**
1523
- * Info about the current route.
1524
- */
1525
- route: {
1526
- /**
1527
- * 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.
1528
- */
1529
- id: RouteId;
1530
- };
1531
- /**
1532
- * If you need to set headers for the response, you can do so using the this method. This is useful if you want the page to be cached, for example:
1533
- *
1534
- * ```js
1535
- * /// file: src/routes/blog/+page.js
1536
- * export async function load({ fetch, setHeaders }) {
1537
- * const url = `https://cms.example.com/articles.json`;
1538
- * const response = await fetch(url);
1539
- *
1540
- * setHeaders({
1541
- * age: response.headers.get('age'),
1542
- * 'cache-control': response.headers.get('cache-control')
1543
- * });
1544
- *
1545
- * return response.json();
1546
- * }
1547
- * ```
1548
- *
1549
- * Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.
1550
- *
1551
- * You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/@sveltejs-kit#Cookies) API instead.
1552
- */
1553
- setHeaders: (headers: Record<string, string>) => void;
1554
- /**
1555
- * The requested URL.
1556
- */
1557
- url: URL;
1558
- /**
1559
- * `true` if the request comes from the client asking for `+page/layout.server.js` data. The `url` property will be stripped of the internal information
1560
- * related to the data request in this case. Use this property instead if the distinction is important to you.
1561
- */
1562
- isDataRequest: boolean;
1563
- /**
1564
- * `true` for `+server.js` calls coming from SvelteKit without the overhead of actually making an HTTP request. This happens when you make same-origin `fetch` requests on the server.
1565
- */
1566
- isSubRequest: boolean;
1567
-
1568
- /**
1569
- * Access to spans for tracing. If tracing is not enabled, these spans will do nothing.
1570
- * @since 2.31.0
1571
- */
1572
- tracing: {
1573
- /** Whether tracing is enabled. */
1574
- enabled: boolean;
1575
- /** The root span for the request. This span is named `sveltekit.handle.root`. */
1576
- root: Span;
1577
- /** The span associated with the current `handle` hook, `load` function, or form action. */
1578
- current: Span;
1579
- };
1580
-
1581
- /**
1582
- * `true` if the request comes from the client via a remote function. The `url` property will be stripped of the internal information
1583
- * related to the data request in this case. Use this property instead if the distinction is important to you.
1584
- */
1585
- isRemoteRequest: boolean;
1586
- }
1587
-
1588
- /**
1589
- * A `(event: RequestEvent) => Response` function exported from a `+server.js` file that corresponds to an HTTP verb (`GET`, `PUT`, `PATCH`, etc) and handles requests with that method.
1590
- *
1591
- * It receives `Params` as the first generic argument, which you can skip by using [generated types](https://svelte.dev/docs/kit/types#Generated-types) instead.
1592
- */
1593
- export type RequestHandler<
436
+ export type RequestHandler<
1594
437
  Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
1595
438
  RouteId extends AppRouteId | null = AppRouteId | null
1596
439
  > = (event: RequestEvent<Params, RouteId>) => MaybePromise<Response>;
1597
440
 
1598
- export interface ResolveOptions {
1599
- /**
1600
- * Applies custom transforms to HTML. If `done` is true, it's the final chunk. Chunks are not guaranteed to be well-formed HTML
1601
- * (they could include an element's opening tag but not its closing tag, for example)
1602
- * but they will always be split at sensible boundaries such as `%sveltekit.head%` or layout/page components.
1603
- * @param input the html chunk and the info if this is the last chunk
1604
- */
1605
- transformPageChunk?: (input: { html: string; done: boolean }) => MaybePromise<string | undefined>;
1606
- /**
1607
- * Determines which headers should be included in serialized responses when a `load` function loads a resource with `fetch`.
1608
- * By default, none will be included.
1609
- * @param name header name
1610
- * @param value header value
1611
- */
1612
- filterSerializedResponseHeaders?: (name: string, value: string) => boolean;
1613
- /**
1614
- * Determines what should be added to the `<head>` tag to preload it.
1615
- * By default, `js` and `css` files will be preloaded.
1616
- * @param input the type of the file and its path
1617
- */
1618
- preload?: (input: { type: 'font' | 'css' | 'js' | 'asset'; path: string }) => boolean;
1619
- }
1620
-
1621
441
  export interface RouteDefinition<Config = any> {
1622
442
  id: string;
1623
443
  api: {
@@ -1641,24 +461,29 @@ export class Server {
1641
461
 
1642
462
  export interface ServerInitOptions {
1643
463
  /** A map of environment variables. */
1644
- env: Record<string, string>;
464
+ env: Record<string, string | undefined>;
1645
465
  /** A function that turns an asset filename into a `ReadableStream`. Required for the `read` export from `$app/server` to work. */
1646
466
  read?: (file: string) => MaybePromise<ReadableStream | null>;
1647
467
  }
1648
468
 
469
+ /**
470
+ * Information required to instantiate a new `Server` instance.
471
+ */
1649
472
  export interface SSRManifest {
473
+ /** The directory where SvelteKit keeps its stuff, including static assets (such as JS and CSS) and internally-used routes. */
1650
474
  appDir: string;
475
+ /** The `base` and `appDir` settings combined without a leading slash. */
1651
476
  appPath: string;
1652
- /** Static files from `kit.config.files.assets` and the service worker (if any). */
477
+ /** Static files from `config.files.assets` and the service worker (if any). */
1653
478
  assets: Set<string>;
1654
479
  mimeTypes: Record<string, string>;
1655
480
 
1656
- /** private fields */
481
+ /** @internal private fields */
1657
482
  _: {
1658
- client: NonNullable<BuildData['client']>;
483
+ client: BuildData['client'];
1659
484
  nodes: SSRNodeLoader[];
1660
485
  /** hashed filename -> import to that file */
1661
- remotes: Record<string, () => Promise<any>>;
486
+ remotes: Record<string, () => Promise<{ default: Record<string, any> }>>;
1662
487
  routes: SSRRoute[];
1663
488
  prerendered_routes: Set<string>;
1664
489
  matchers: () => Promise<Record<string, ParamMatcher>>;
@@ -1776,25 +601,6 @@ export type Actions<
1776
601
  RouteId extends AppRouteId | null = AppRouteId | null
1777
602
  > = Record<string, Action<Params, OutputData, RouteId>>;
1778
603
 
1779
- /**
1780
- * When calling a form action via fetch, the response will be one of these shapes.
1781
- * ```svelte
1782
- * <form method="post" use:enhance={() => {
1783
- * return ({ result }) => {
1784
- * // result is of type ActionResult
1785
- * };
1786
- * }}
1787
- * ```
1788
- */
1789
- export type ActionResult<
1790
- Success extends Record<string, unknown> | undefined = Record<string, any>,
1791
- Failure extends Record<string, unknown> | undefined = Record<string, any>
1792
- > =
1793
- | { type: 'success'; status: number; data?: Success }
1794
- | { type: 'failure'; status: number; data?: Failure }
1795
- | { type: 'redirect'; status: number; location: string }
1796
- | { type: 'error'; status?: number; error: any };
1797
-
1798
604
  /**
1799
605
  * The object returned by the [`error`](https://svelte.dev/docs/kit/@sveltejs-kit#error) function.
1800
606
  */
@@ -1815,502 +621,13 @@ export interface Redirect {
1815
621
  location: string;
1816
622
  }
1817
623
 
1818
- export type SubmitFunction<
1819
- Success extends Record<string, unknown> | undefined = Record<string, any>,
1820
- Failure extends Record<string, unknown> | undefined = Record<string, any>
1821
- > = (input: {
1822
- action: URL;
1823
- formData: FormData;
1824
- formElement: HTMLFormElement;
1825
- controller: AbortController;
1826
- submitter: HTMLElement | null;
1827
- cancel: () => void;
1828
- }) => MaybePromise<
1829
- | void
1830
- | ((opts: {
1831
- formData: FormData;
1832
- formElement: HTMLFormElement;
1833
- action: URL;
1834
- result: ActionResult<Success, Failure>;
1835
- /**
1836
- * Call this to get the default behavior of a form submission response.
1837
- * @param options Set `reset: false` if you don't want the `<form>` values to be reset after a successful submission.
1838
- * @param invalidateAll Set `invalidateAll: false` if you don't want the action to call `invalidateAll` after submission.
1839
- */
1840
- update: (options?: { reset?: boolean; invalidateAll?: boolean }) => Promise<void>;
1841
- }) => MaybePromise<void>)
1842
- >;
1843
-
1844
624
  /**
1845
625
  * The type of `export const snapshot` exported from a page or layout component.
626
+ * @deprecated Use the [`snapshot`](https://svelte.dev/docs/kit/$app-navigation#snapshot) helper from `$app/navigation` instead.
1846
627
  */
1847
628
  export interface Snapshot<T = any> {
1848
629
  capture: () => T;
1849
630
  restore: (snapshot: T) => void;
1850
631
  }
1851
632
 
1852
- // If T is unknown or has an index signature, the types below will recurse indefinitely and create giant unions that TS can't handle
1853
- type WillRecurseIndefinitely<T> = unknown extends T ? true : string extends keyof T ? true : false;
1854
-
1855
- // Input type mappings for form fields
1856
- type InputTypeMap = {
1857
- text: string;
1858
- email: string;
1859
- password: string;
1860
- url: string;
1861
- tel: string;
1862
- search: string;
1863
- number: number;
1864
- range: number;
1865
- date: string;
1866
- 'datetime-local': string;
1867
- time: string;
1868
- month: string;
1869
- week: string;
1870
- color: string;
1871
- checkbox: boolean | string[];
1872
- radio: string;
1873
- file: File;
1874
- hidden: string | number | boolean;
1875
- submit: string | number | boolean;
1876
- button: string;
1877
- reset: string;
1878
- image: string;
1879
- select: string;
1880
- 'select multiple': string[];
1881
- 'file multiple': File[];
1882
- };
1883
-
1884
- // Valid input types for a given value type
1885
- export type RemoteFormFieldType<T> = {
1886
- [K in keyof InputTypeMap]: T extends InputTypeMap[K] ? K : never;
1887
- }[keyof InputTypeMap];
1888
-
1889
- // Input element properties based on type
1890
- type InputElementProps<T extends keyof InputTypeMap> = T extends 'checkbox' | 'radio'
1891
- ? {
1892
- name: string;
1893
- type: T;
1894
- value?: string;
1895
- 'aria-invalid': boolean | 'false' | 'true' | undefined;
1896
- get checked(): boolean;
1897
- set checked(value: boolean);
1898
- readonly defaultChecked?: boolean;
1899
- }
1900
- : T extends 'file'
1901
- ? {
1902
- name: string;
1903
- type: 'file';
1904
- 'aria-invalid': boolean | 'false' | 'true' | undefined;
1905
- get files(): FileList | null;
1906
- set files(v: FileList | null);
1907
- }
1908
- : T extends 'select'
1909
- ? {
1910
- name: string;
1911
- 'aria-invalid': boolean | 'false' | 'true' | undefined;
1912
- get value(): string;
1913
- set value(v: string);
1914
- }
1915
- : T extends 'select multiple'
1916
- ? {
1917
- name: string;
1918
- multiple: true;
1919
- 'aria-invalid': boolean | 'false' | 'true' | undefined;
1920
- get value(): string[];
1921
- set value(v: string[]);
1922
- }
1923
- : T extends 'text'
1924
- ? {
1925
- name: string;
1926
- 'aria-invalid': boolean | 'false' | 'true' | undefined;
1927
- get value(): string | number;
1928
- set value(v: string | number);
1929
- readonly defaultValue?: string | number;
1930
- }
1931
- : {
1932
- name: string;
1933
- type: T;
1934
- 'aria-invalid': boolean | 'false' | 'true' | undefined;
1935
- get value(): string | number;
1936
- set value(v: string | number);
1937
- readonly defaultValue?: string | number;
1938
- };
1939
-
1940
- type RemoteFormFieldMethods<T> = {
1941
- /** The values that will be submitted */
1942
- value(): DeepPartial<T>;
1943
- /** Set the values that will be submitted */
1944
- set(input: DeepPartial<T>): DeepPartial<T>;
1945
- /** Validation issues, if any */
1946
- issues(): RemoteFormIssue[] | undefined;
1947
- };
1948
-
1949
- // These two types use "T extends unknown ? .. : .." to distribute over unions.
1950
- // Example: if "type T = A | b" then "keyof T" only contains keys that both A and B have, with "KeysOfUnion<T>" we get the keys of both A and B
1951
- type KeysOfUnion<T> = T extends unknown ? keyof T : never;
1952
- type ValueOfUnionKey<T, K extends PropertyKey> = T extends unknown
1953
- ? K extends keyof T
1954
- ? T[K]
1955
- : never
1956
- : never;
1957
-
1958
- export type RemoteFormFieldValue = string | string[] | number | boolean | File | File[];
1959
-
1960
- type AsArgs<Type extends keyof InputTypeMap, Value> = Type extends 'checkbox'
1961
- ? Value extends string[]
1962
- ? [type: Type, value: Value[number] | (string & {})]
1963
- : Value extends boolean
1964
- ? [type: Type] | [type: Type, value: boolean]
1965
- : [type: Type] | [type: Type, value: Value | (string & {})]
1966
- : Type extends 'submit' | 'hidden'
1967
- ? Value extends string
1968
- ? [type: Type, value: Value | (string & {})]
1969
- : [type: Type, value: Value]
1970
- : Type extends 'radio'
1971
- ? [type: Type, value: Value | (string & {})]
1972
- : Type extends 'file' | 'file multiple'
1973
- ? [type: Type]
1974
- : [type: Type] | [type: Type, value: Value | (string & {})];
1975
-
1976
- /**
1977
- * Form field accessor type that provides name(), value(), and issues() methods
1978
- */
1979
- export type RemoteFormField<Value extends RemoteFormFieldValue> = RemoteFormFieldMethods<Value> & {
1980
- /**
1981
- * Returns an object that can be spread onto an input element with the correct type attribute,
1982
- * aria-invalid attribute if the field is invalid, and appropriate value/checked property getters/setters.
1983
- * @example
1984
- * ```svelte
1985
- * <input {...myForm.fields.myString.as('text')} />
1986
- * <input {...myForm.fields.myNumber.as('number')} />
1987
- * <input {...myForm.fields.myBoolean.as('checkbox')} />
1988
- * ```
1989
- */
1990
- as<T extends RemoteFormFieldType<Value>>(...args: AsArgs<T, Value>): InputElementProps<T>;
1991
- };
1992
-
1993
- type RemoteFormFieldContainer<Value> = RemoteFormFieldMethods<Value> & {
1994
- /** Validation issues belonging to this or any of the fields that belong to it, if any */
1995
- allIssues(): RemoteFormIssue[] | undefined;
1996
- };
1997
-
1998
- type UnknownField<Value> = RemoteFormFieldMethods<Value> & {
1999
- /** Validation issues belonging to this or any of the fields that belong to it, if any */
2000
- allIssues(): RemoteFormIssue[] | undefined;
2001
- /**
2002
- * Returns an object that can be spread onto an input element with the correct type attribute,
2003
- * aria-invalid attribute if the field is invalid, and appropriate value/checked property getters/setters.
2004
- * @example
2005
- * ```svelte
2006
- * <input {...myForm.fields.myString.as('text')} />
2007
- * <input {...myForm.fields.myNumber.as('number')} />
2008
- * <input {...myForm.fields.myBoolean.as('checkbox')} />
2009
- * ```
2010
- */
2011
- as<T extends RemoteFormFieldType<Value>>(...args: AsArgs<T, Value>): InputElementProps<T>;
2012
- } & {
2013
- [key: string | number]: UnknownField<any>;
2014
- };
2015
-
2016
- type RemoteFormFieldsRoot<Input extends RemoteFormInput | void> =
2017
- IsAny<Input> extends true
2018
- ? RecursiveFormFields
2019
- : Input extends void
2020
- ? {
2021
- /** Validation issues, if any */
2022
- issues(): RemoteFormIssue[] | undefined;
2023
- /** Validation issues belonging to this or any of the fields that belong to it, if any */
2024
- allIssues(): RemoteFormIssue[] | undefined;
2025
- }
2026
- : RemoteFormFields<Input>;
2027
-
2028
- /**
2029
- * Recursive type to build form fields structure with proxy access
2030
- */
2031
- export type RemoteFormFields<T> =
2032
- WillRecurseIndefinitely<T> extends true
2033
- ? RecursiveFormFields
2034
- : NonNullable<T> extends string | number | boolean | File
2035
- ? RemoteFormField<NonNullable<T>>
2036
- : // [NonNullable<T>] is used to prevent distributing over union while still allowing
2037
- // nullable wrappers (e.g. `string[] | undefined` from a schema with `.default([])`)
2038
- // to be treated as arrays; only the last condition should distribute over unions
2039
- [NonNullable<T>] extends [string[] | File[]]
2040
- ? RemoteFormField<NonNullable<T>> & {
2041
- [K in number]: RemoteFormField<NonNullable<T>[number]>;
2042
- }
2043
- : [NonNullable<T>] extends [Array<infer U>]
2044
- ? RemoteFormFieldContainer<NonNullable<T>> & {
2045
- [K in number]: RemoteFormFields<U>;
2046
- }
2047
- : RemoteFormFieldContainer<T> & {
2048
- [K in KeysOfUnion<T>]-?: RemoteFormFields<ValueOfUnionKey<T, K>>;
2049
- };
2050
-
2051
- // By breaking this out into its own type, we avoid the TS recursion depth limit
2052
- type RecursiveFormFields = RemoteFormFieldContainer<any> & {
2053
- [key: string | number]: UnknownField<any>;
2054
- };
2055
-
2056
- type MaybeArray<T> = T | T[];
2057
-
2058
- export interface RemoteFormInput {
2059
- [key: string]: MaybeArray<string | number | boolean | File | RemoteFormInput>;
2060
- }
2061
-
2062
- export interface RemoteFormIssue {
2063
- message: string;
2064
- path: Array<string | number>;
2065
- }
2066
-
2067
- // If the schema specifies `id` as a string or number, ensure that `for(...)`
2068
- // only accepts that type. Otherwise, accept `string | number`
2069
- type ExtractId<Input> = Input extends { id: infer Id }
2070
- ? Id extends string | number
2071
- ? Id
2072
- : string | number
2073
- : string | number;
2074
-
2075
- /**
2076
- * A function and proxy object used to imperatively create validation errors in form handlers.
2077
- *
2078
- * Access properties to create field-specific issues: `issue.fieldName('message')`.
2079
- * The type structure mirrors the input data structure for type-safe field access.
2080
- * Call `invalid(issue.foo(...), issue.nested.bar(...))` to throw a validation error.
2081
- */
2082
- export type InvalidField<T> =
2083
- WillRecurseIndefinitely<T> extends true
2084
- ? Record<string | number, any>
2085
- : NonNullable<T> extends string | number | boolean | File
2086
- ? (message: string) => StandardSchemaV1.Issue
2087
- : NonNullable<T> extends Array<infer U>
2088
- ? {
2089
- [K in number]: InvalidField<U>;
2090
- } & ((message: string) => StandardSchemaV1.Issue)
2091
- : NonNullable<T> extends RemoteFormInput
2092
- ? {
2093
- [K in keyof T]-?: InvalidField<T[K]>;
2094
- } & ((message: string) => StandardSchemaV1.Issue)
2095
- : Record<string, never>;
2096
-
2097
- /**
2098
- * A validation error thrown by `invalid`.
2099
- */
2100
- export interface ValidationError {
2101
- /** The validation issues */
2102
- issues: StandardSchemaV1.Issue[];
2103
- }
2104
-
2105
- /**
2106
- * The type of a remote `form` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
2107
- */
2108
- export type RemoteForm<Input extends RemoteFormInput | void, Output> = {
2109
- /** Attachment that sets up an event handler that intercepts the form submission on the client to prevent a full page reload */
2110
- [attachment: symbol]: (node: HTMLFormElement) => void;
2111
- method: 'POST';
2112
- /** The URL to send the form to. */
2113
- action: string;
2114
- /** The `<form>` element this instance is currently attached to, if any. */
2115
- get element(): HTMLFormElement | null;
2116
- /** Submit the currently attached form programmatically. */
2117
- submit(): Promise<boolean> & {
2118
- updates: (...updates: RemoteQueryUpdate[]) => Promise<boolean>;
2119
- };
2120
- /** Use the `enhance` method to influence what happens when the form is submitted. */
2121
- enhance(
2122
- callback: (
2123
- form: Omit<RemoteForm<Input, Output>, 'enhance' | 'element'> & {
2124
- readonly element: HTMLFormElement;
2125
- }
2126
- ) => MaybePromise<void>
2127
- ): {
2128
- method: 'POST';
2129
- action: string;
2130
- [attachment: symbol]: (node: HTMLFormElement) => void;
2131
- };
2132
- /**
2133
- * Create an instance of the form for the given `id`.
2134
- * The `id` is stringified and used for deduplication to potentially reuse existing instances.
2135
- * Useful when you have multiple forms that use the same remote form action, for example in a loop.
2136
- * ```svelte
2137
- * {#each todos as todo}
2138
- * {@const todoForm = updateTodo.for(todo.id)}
2139
- * <form {...todoForm}>
2140
- * {#if todoForm.result?.invalid}<p>Invalid data</p>{/if}
2141
- * ...
2142
- * </form>
2143
- * {/each}
2144
- * ```
2145
- */
2146
- for(id: ExtractId<Input>): Omit<RemoteForm<Input, Output>, 'for'>;
2147
- /** Preflight checks */
2148
- preflight(schema: StandardSchemaV1<Input, any>): RemoteForm<Input, Output>;
2149
- /** Validate the form contents programmatically */
2150
- validate(options?: {
2151
- /** Set this to `true` to also show validation issues of fields that haven't been touched yet. */
2152
- includeUntouched?: boolean;
2153
- /** Set this to `true` to only run the `preflight` validation. */
2154
- preflightOnly?: boolean;
2155
- }): Promise<void>;
2156
- /** The result of the form submission */
2157
- get result(): Output | undefined;
2158
- /** The number of pending submissions */
2159
- get pending(): number;
2160
- /** Access form fields using object notation */
2161
- fields: RemoteFormFieldsRoot<Input>;
2162
- };
2163
-
2164
- /**
2165
- * The type of a remote `command` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#command) for full documentation.
2166
- */
2167
- export type RemoteCommand<Input, Output> = {
2168
- (arg: undefined extends Input ? Input | void : Input): Promise<Output> & {
2169
- updates(...updates: RemoteQueryUpdate[]): Promise<Output>;
2170
- };
2171
- /** The number of pending command executions */
2172
- get pending(): number;
2173
- };
2174
-
2175
- export type RemoteQueryUpdate =
2176
- | RemoteQuery<any>
2177
- | RemoteLiveQuery<any>
2178
- | RemoteQueryFunction<any, any>
2179
- | RemoteLiveQueryFunction<any, any>
2180
- | RemoteQueryOverride;
2181
-
2182
- export type RemoteResource<T> = Promise<T> & {
2183
- /** 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. */
2184
- get error(): any;
2185
- /** `true` before the first result is available and during refreshes */
2186
- get loading(): boolean;
2187
- } & (
2188
- | {
2189
- /** The current value of the query. Undefined until `ready` is `true` */
2190
- get current(): undefined;
2191
- ready: false;
2192
- }
2193
- | {
2194
- /** The current value of the query. Undefined until `ready` is `true` */
2195
- get current(): T;
2196
- ready: true;
2197
- }
2198
- );
2199
-
2200
- export type RemoteQuery<T> = RemoteResource<T> & {
2201
- /**
2202
- * On the client, this function will update the value of the query without re-fetching it.
2203
- *
2204
- * On the server, this can be called in the context of a `command` or `form` and the specified data will accompany the action response back to the client.
2205
- * This prevents SvelteKit needing to refresh all queries on the page in a second server round-trip.
2206
- */
2207
- set(value: T): void;
2208
- /**
2209
- * On the client, this function will re-fetch the query from the server.
2210
- *
2211
- * On the server, this can be called in the context of a `command` or `form` and the refreshed data will accompany the action response back to the client.
2212
- * This prevents SvelteKit needing to refresh all queries on the page in a second server round-trip.
2213
- */
2214
- refresh(): Promise<void>;
2215
- /**
2216
- * Temporarily override a query's value during a [single-flight mutation](https://svelte.dev/docs/kit/remote-functions#Single-flight-mutations) to provide optimistic updates.
2217
- *
2218
- * ```svelte
2219
- * <script>
2220
- * import { getTodos, addTodo } from './todos.remote.js';
2221
- * const todos = getTodos();
2222
- * </script>
2223
- *
2224
- * <form {...addTodo.enhance(async (form) => {
2225
- * await form.submit().updates(
2226
- * todos.withOverride((todos) => [...todos, { text: form.fields.text.value() }])
2227
- * );
2228
- * })}>
2229
- * <input type="text" name="text" />
2230
- * <button type="submit">Add Todo</button>
2231
- * </form>
2232
- * ```
2233
- */
2234
- withOverride(update: (current: T) => T): RemoteQueryOverride;
2235
- };
2236
-
2237
- export type RemoteLiveQuery<T> = RemoteResource<T> &
2238
- AsyncIterable<T> & {
2239
- /** `true` if the live stream is currently connected. */
2240
- readonly connected: boolean;
2241
- /** `true` once the current live stream iterator is done. */
2242
- readonly done: boolean;
2243
- /** Reconnects the live stream immediately. */
2244
- reconnect(): Promise<void>;
2245
- };
2246
-
2247
- export type RemoteQueryOverride = () => void;
2248
-
2249
- /**
2250
- * The type of a remote `prerender` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#prerender) for full documentation.
2251
- */
2252
- export type RemotePrerenderFunction<Input, Output> = (
2253
- arg: undefined extends Input ? Input | void : Input
2254
- ) => RemoteResource<Output>;
2255
-
2256
- /**
2257
- * The return value of a remote `query` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query) for full documentation.
2258
- *
2259
- * The optional `Validated` generic parameter represents the argument type *after* the
2260
- * query's schema has validated and (optionally) transformed it — this is the type the
2261
- * query's implementation function receives on the server, and the type yielded by
2262
- * [`requested`](https://svelte.dev/docs/kit/$app-server#requested). For queries declared
2263
- * with [Standard Schema](https://standardschema.dev/) it differs from `Input` when the
2264
- * schema contains a transform (e.g. `v.pipe(v.number(), v.transform(String))` has
2265
- * `Input = number` but `Validated = string`). For `'unchecked'` validators and queries
2266
- * without arguments it defaults to `Input`.
2267
- */
2268
- export type RemoteQueryFunction<Input, Output, _Validated = Input> = (
2269
- arg: undefined extends Input ? Input | void : Input
2270
- ) => RemoteQuery<Output>;
2271
-
2272
- /**
2273
- * The type of a remote `query.live` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query.live) for full documentation.
2274
- *
2275
- * The optional `Validated` generic parameter represents the argument type *after* the
2276
- * query's schema has validated and (optionally) transformed it, and matches the type
2277
- * yielded by [`requested`](https://svelte.dev/docs/kit/$app-server#requested).
2278
- */
2279
- export type RemoteLiveQueryFunction<Input, Output, _Validated = Input> = (
2280
- arg: undefined extends Input ? Input | void : Input
2281
- ) => RemoteLiveQuery<Output>;
2282
-
2283
- /**
2284
- * [Environment variables](https://svelte.dev/docs/kit/environment-variables) can be configured by exporting
2285
- * a `variables` object from `src/env.ts`, using [`defineEnvVars`](https://svelte.dev/docs/kit/@sveltejs-kit-hooks#defineEnvVars).
2286
- */
2287
- export interface EnvVarConfig<T> {
2288
- /**
2289
- * Whether the environment variable can be accessed by client-side code.
2290
- * - if `true`, it can be imported from `$app/env/public`
2291
- * - if `false`, it can be imported from `$app/env/private`, which is a [server-only module](https://svelte.dev/docs/kit/server-only-modules)
2292
- * @default false
2293
- */
2294
- public?: boolean;
2295
- /**
2296
- * Whether the value is determined at build time or when the app runs.
2297
- * - if `true`, the build time value is inlined into the bundle. This enables optimisations like dead-code elimination
2298
- * - if `false`, the value is read from the environment when the app starts
2299
- * @default false
2300
- */
2301
- static?: boolean;
2302
- /**
2303
- * A [Standard Schema](https://standardschema.dev/) validator that is applied to the value when the app starts.
2304
- * The validator can output any value — not necessarily a string — but public, non-static values must be
2305
- * serializable by [devalue](https://github.com/sveltejs/devalue) so that they can be sent to the browser.
2306
- *
2307
- * If omitted, the value must be a non-empty string.
2308
- */
2309
- schema?: StandardSchemaV1<string | undefined, T>;
2310
- /**
2311
- * A description of the variable that will be used for inline documentation on hover.
2312
- */
2313
- description?: string;
2314
- }
2315
-
2316
633
  export * from './index.js';