@sveltejs/kit 2.7.2 → 2.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/package.json +2 -2
- package/src/core/config/index.js +1 -1
- package/src/core/config/options.js +8 -8
- package/src/core/postbuild/prerender.js +6 -6
- package/src/core/sync/write_ambient.js +1 -1
- package/src/core/sync/write_tsconfig.js +1 -1
- package/src/exports/public.d.ts +54 -55
- package/src/exports/vite/dev/index.js +1 -1
- package/src/exports/vite/index.js +19 -3
- package/src/exports/vite/preview/index.js +7 -0
- package/src/runtime/app/paths/types.d.ts +2 -2
- package/src/runtime/app/stores.js +2 -2
- package/src/runtime/client/client.js +5 -5
- package/src/runtime/client/fetcher.js +1 -1
- package/src/runtime/server/fetch.js +1 -1
- package/src/runtime/server/page/actions.js +9 -1
- package/src/runtime/server/page/index.js +2 -2
- package/src/runtime/server/page/load_data.js +1 -1
- package/src/runtime/server/page/render.js +3 -4
- package/src/types/ambient.d.ts +7 -7
- package/src/types/synthetic/$env+dynamic+private.md +1 -1
- package/src/types/synthetic/$env+dynamic+public.md +1 -1
- package/src/types/synthetic/$env+static+private.md +2 -2
- package/src/types/synthetic/$env+static+public.md +1 -1
- package/src/types/synthetic/$lib.md +2 -2
- package/src/version.js +1 -1
- package/types/index.d.ts +67 -68
- package/types/index.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# The fastest way to build Svelte apps
|
|
2
2
|
|
|
3
|
-
This is the [SvelteKit](https://
|
|
3
|
+
This is the [SvelteKit](https://svelte.dev/docs/kit) framework and CLI.
|
|
4
4
|
|
|
5
|
-
The quickest way to get started is via the [
|
|
5
|
+
The quickest way to get started is via the [sv](https://npmjs.com/package/sv) package:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
npx sv create my-app
|
|
9
9
|
cd my-app
|
|
10
10
|
npm install
|
|
11
11
|
npm run dev
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
See the [documentation](https://
|
|
14
|
+
See the [documentation](https://svelte.dev/docs/kit) to learn more.
|
|
15
15
|
|
|
16
16
|
## Changelog
|
|
17
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/kit",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.3",
|
|
4
4
|
"description": "SvelteKit is the fastest way to build Svelte apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"directory": "packages/kit"
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
|
-
"homepage": "https://
|
|
18
|
+
"homepage": "https://svelte.dev",
|
|
19
19
|
"type": "module",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@types/cookie": "^0.6.0",
|
package/src/core/config/index.js
CHANGED
|
@@ -111,7 +111,7 @@ function process_config(config, { cwd = process.cwd() } = {}) {
|
|
|
111
111
|
export function validate_config(config) {
|
|
112
112
|
if (typeof config !== 'object') {
|
|
113
113
|
throw new Error(
|
|
114
|
-
'svelte.config.js must have a configuration object as its default export. See https://
|
|
114
|
+
'svelte.config.js must have a configuration object as its default export. See https://svelte.dev/docs/kit/configuration'
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -68,7 +68,7 @@ const options = object(
|
|
|
68
68
|
message += ', rather than the name of an adapter';
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
throw new Error(`${message}. See https://
|
|
71
|
+
throw new Error(`${message}. See https://svelte.dev/docs/kit/adapters`);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
return input;
|
|
@@ -92,7 +92,7 @@ const options = object(
|
|
|
92
92
|
if (input) {
|
|
93
93
|
if (input.startsWith('/') || input.endsWith('/')) {
|
|
94
94
|
throw new Error(
|
|
95
|
-
"config.kit.appDir cannot start or end with '/'. See https://
|
|
95
|
+
"config.kit.appDir cannot start or end with '/'. See https://svelte.dev/docs/kit/configuration"
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
98
|
} else {
|
|
@@ -151,7 +151,7 @@ const options = object(
|
|
|
151
151
|
|
|
152
152
|
if (input !== '' && (input.endsWith('/') || !input.startsWith('/'))) {
|
|
153
153
|
throw new Error(
|
|
154
|
-
`${keypath} option must either be the empty string or a root-relative path that starts but doesn't end with '/'. See https://
|
|
154
|
+
`${keypath} option must either be the empty string or a root-relative path that starts but doesn't end with '/'. See https://svelte.dev/docs/kit/configuration#paths`
|
|
155
155
|
);
|
|
156
156
|
}
|
|
157
157
|
|
|
@@ -163,13 +163,13 @@ const options = object(
|
|
|
163
163
|
if (input) {
|
|
164
164
|
if (!/^[a-z]+:\/\//.test(input)) {
|
|
165
165
|
throw new Error(
|
|
166
|
-
`${keypath} option must be an absolute path, if specified. See https://
|
|
166
|
+
`${keypath} option must be an absolute path, if specified. See https://svelte.dev/docs/kit/configuration#paths`
|
|
167
167
|
);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
if (input.endsWith('/')) {
|
|
171
171
|
throw new Error(
|
|
172
|
-
`${keypath} option must not end with '/'. See https://
|
|
172
|
+
`${keypath} option must not end with '/'. See https://svelte.dev/docs/kit/configuration#paths`
|
|
173
173
|
);
|
|
174
174
|
}
|
|
175
175
|
}
|
|
@@ -202,7 +202,7 @@ const options = object(
|
|
|
202
202
|
(/** @type {any} */ { message }) => {
|
|
203
203
|
throw new Error(
|
|
204
204
|
message +
|
|
205
|
-
'\nTo suppress or handle this error, implement `handleHttpError` in https://
|
|
205
|
+
'\nTo suppress or handle this error, implement `handleHttpError` in https://svelte.dev/docs/kit/configuration#prerender'
|
|
206
206
|
);
|
|
207
207
|
},
|
|
208
208
|
(input, keypath) => {
|
|
@@ -216,7 +216,7 @@ const options = object(
|
|
|
216
216
|
(/** @type {any} */ { message }) => {
|
|
217
217
|
throw new Error(
|
|
218
218
|
message +
|
|
219
|
-
'\nTo suppress or handle this error, implement `handleMissingId` in https://
|
|
219
|
+
'\nTo suppress or handle this error, implement `handleMissingId` in https://svelte.dev/docs/kit/configuration#prerender'
|
|
220
220
|
);
|
|
221
221
|
},
|
|
222
222
|
(input, keypath) => {
|
|
@@ -230,7 +230,7 @@ const options = object(
|
|
|
230
230
|
(/** @type {any} */ { message }) => {
|
|
231
231
|
throw new Error(
|
|
232
232
|
message +
|
|
233
|
-
'\nTo suppress or handle this error, implement `handleEntryGeneratorMismatch` in https://
|
|
233
|
+
'\nTo suppress or handle this error, implement `handleEntryGeneratorMismatch` in https://svelte.dev/docs/kit/configuration#prerender'
|
|
234
234
|
);
|
|
235
235
|
},
|
|
236
236
|
(input, keypath) => {
|
|
@@ -114,7 +114,7 @@ async function prerender({ out, manifest_path, metadata, verbose, env }) {
|
|
|
114
114
|
({ status, path, referrer, referenceType }) => {
|
|
115
115
|
const message =
|
|
116
116
|
status === 404 && !path.startsWith(config.paths.base)
|
|
117
|
-
? `${path} does not begin with \`base\`, which is configured in \`paths.base\` and can be imported from \`$app/paths\` - see https://
|
|
117
|
+
? `${path} does not begin with \`base\`, which is configured in \`paths.base\` and can be imported from \`$app/paths\` - see https://svelte.dev/docs/kit/configuration#paths for more info`
|
|
118
118
|
: path;
|
|
119
119
|
|
|
120
120
|
return `${status} ${message}${referrer ? ` (${referenceType} from ${referrer})` : ''}`;
|
|
@@ -126,7 +126,7 @@ async function prerender({ out, manifest_path, metadata, verbose, env }) {
|
|
|
126
126
|
config.prerender.handleMissingId,
|
|
127
127
|
({ path, id, referrers }) => {
|
|
128
128
|
return (
|
|
129
|
-
`The following pages contain links to ${path}#${id}, but no element with id="${id}" exists on ${path} - see the \`handleMissingId\` option in https://
|
|
129
|
+
`The following pages contain links to ${path}#${id}, but no element with id="${id}" exists on ${path} - see the \`handleMissingId\` option in https://svelte.dev/docs/kit/configuration#prerender for more info:` +
|
|
130
130
|
referrers.map((l) => `\n - ${l}`).join('')
|
|
131
131
|
);
|
|
132
132
|
}
|
|
@@ -136,7 +136,7 @@ async function prerender({ out, manifest_path, metadata, verbose, env }) {
|
|
|
136
136
|
log,
|
|
137
137
|
config.prerender.handleEntryGeneratorMismatch,
|
|
138
138
|
({ generatedFromId, entry, matchedId }) => {
|
|
139
|
-
return `The entries export from ${generatedFromId} generated entry ${entry}, which was matched by ${matchedId} - see the \`handleEntryGeneratorMismatch\` option in https://
|
|
139
|
+
return `The entries export from ${generatedFromId} generated entry ${entry}, which was matched by ${matchedId} - see the \`handleEntryGeneratorMismatch\` option in https://svelte.dev/docs/kit/configuration#prerender for more info.`;
|
|
140
140
|
}
|
|
141
141
|
);
|
|
142
142
|
|
|
@@ -385,7 +385,7 @@ async function prerender({ out, manifest_path, metadata, verbose, env }) {
|
|
|
385
385
|
if (response.status === 200) {
|
|
386
386
|
if (existsSync(dest) && statSync(dest).isDirectory()) {
|
|
387
387
|
throw new Error(
|
|
388
|
-
`Cannot save ${decoded} as it is already a directory. See https://
|
|
388
|
+
`Cannot save ${decoded} as it is already a directory. See https://svelte.dev/docs/kit/page-options#prerender-route-conflicts for more information`
|
|
389
389
|
);
|
|
390
390
|
}
|
|
391
391
|
|
|
@@ -394,7 +394,7 @@ async function prerender({ out, manifest_path, metadata, verbose, env }) {
|
|
|
394
394
|
if (existsSync(dir) && !statSync(dir).isDirectory()) {
|
|
395
395
|
const parent = decoded.split('/').slice(0, -1).join('/');
|
|
396
396
|
throw new Error(
|
|
397
|
-
`Cannot save ${decoded} as ${parent} is already a file. See https://
|
|
397
|
+
`Cannot save ${decoded} as ${parent} is already a file. See https://svelte.dev/docs/kit/page-options#prerender-route-conflicts for more information`
|
|
398
398
|
);
|
|
399
399
|
}
|
|
400
400
|
|
|
@@ -509,7 +509,7 @@ async function prerender({ out, manifest_path, metadata, verbose, env }) {
|
|
|
509
509
|
const list = not_prerendered.map((id) => ` - ${id}`).join('\n');
|
|
510
510
|
|
|
511
511
|
throw new Error(
|
|
512
|
-
`The following routes were marked as prerenderable, but were not prerendered because they were not found while crawling your app:\n${list}\n\nSee https://
|
|
512
|
+
`The following routes were marked as prerenderable, but were not prerendered because they were not found while crawling your app:\n${list}\n\nSee https://svelte.dev/docs/kit/page-options#prerender-troubleshooting for info on how to solve this`
|
|
513
513
|
);
|
|
514
514
|
}
|
|
515
515
|
|
|
@@ -7,7 +7,7 @@ import { create_dynamic_types, create_static_types } from '../env.js';
|
|
|
7
7
|
import { write_if_changed } from './utils.js';
|
|
8
8
|
|
|
9
9
|
// TODO these types should be described in a neutral place, rather than
|
|
10
|
-
// inside either `packages/kit` or `
|
|
10
|
+
// inside either `packages/kit` or `svelte.dev/docs/kit`
|
|
11
11
|
const descriptions_dir = fileURLToPath(new URL('../../../src/types/synthetic', import.meta.url));
|
|
12
12
|
|
|
13
13
|
/** @param {string} filename */
|
|
@@ -166,7 +166,7 @@ function validate_user_config(cwd, out, config) {
|
|
|
166
166
|
.bold()
|
|
167
167
|
.yellow(
|
|
168
168
|
`You have specified a baseUrl and/or paths in your ${config.kind} which interferes with SvelteKit's auto-generated tsconfig.json. ` +
|
|
169
|
-
'Remove it to avoid problems with intellisense. For path aliases, use `kit.alias` instead: https://
|
|
169
|
+
'Remove it to avoid problems with intellisense. For path aliases, use `kit.alias` instead: https://svelte.dev/docs/kit/configuration#alias'
|
|
170
170
|
)
|
|
171
171
|
);
|
|
172
172
|
}
|
package/src/exports/public.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ import type { PluginOptions } from '@sveltejs/vite-plugin-svelte';
|
|
|
23
23
|
export { PrerenderOption } from '../types/private.js';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* [Adapters](https://
|
|
26
|
+
* [Adapters](https://svelte.dev/docs/kit/adapters) are responsible for taking the production build and turning it into something that can be deployed to a platform of your choosing.
|
|
27
27
|
*/
|
|
28
28
|
export interface Adapter {
|
|
29
29
|
/**
|
|
@@ -79,12 +79,11 @@ export interface ActionFailure<T extends Record<string, unknown> | undefined = u
|
|
|
79
79
|
[uniqueSymbol]: true; // necessary or else UnpackValidationError could wrongly unpack objects with the same shape as ActionFailure
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
type UnpackValidationError<T> =
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
: T;
|
|
82
|
+
type UnpackValidationError<T> = T extends ActionFailure<infer X>
|
|
83
|
+
? X
|
|
84
|
+
: T extends void
|
|
85
|
+
? undefined // needs to be undefined, because void will corrupt union type
|
|
86
|
+
: T;
|
|
88
87
|
|
|
89
88
|
/**
|
|
90
89
|
* This object is passed to the `adapt` function of adapters.
|
|
@@ -129,7 +128,7 @@ export interface Builder {
|
|
|
129
128
|
generateEnvModule(): void;
|
|
130
129
|
|
|
131
130
|
/**
|
|
132
|
-
* Generate a server-side manifest to initialise the SvelteKit [server](https://
|
|
131
|
+
* Generate a server-side manifest to initialise the SvelteKit [server](https://svelte.dev/docs/kit/@sveltejs-kit#Server) with.
|
|
133
132
|
* @param opts a relative path to the base directory of the app and optionally in which format (esm or cjs) the manifest should be generated
|
|
134
133
|
*/
|
|
135
134
|
generateManifest(opts: { relativePath: string; routes?: RouteDefinition[] }): string;
|
|
@@ -190,7 +189,7 @@ export interface Builder {
|
|
|
190
189
|
|
|
191
190
|
export interface Config {
|
|
192
191
|
/**
|
|
193
|
-
* Options passed to [`svelte.compile`](https://svelte.dev/docs
|
|
192
|
+
* Options passed to [`svelte.compile`](https://svelte.dev/docs/svelte/svelte-compiler#CompileOptions).
|
|
194
193
|
* @default {}
|
|
195
194
|
*/
|
|
196
195
|
compilerOptions?: CompileOptions;
|
|
@@ -279,7 +278,7 @@ export interface Emulator {
|
|
|
279
278
|
|
|
280
279
|
export interface KitConfig {
|
|
281
280
|
/**
|
|
282
|
-
* Your [adapter](https://
|
|
281
|
+
* Your [adapter](https://svelte.dev/docs/kit/adapters) is run when executing `vite build`. It determines how the output is converted for different platforms.
|
|
283
282
|
* @default undefined
|
|
284
283
|
*/
|
|
285
284
|
adapter?: Adapter;
|
|
@@ -352,9 +351,9 @@ export interface KitConfig {
|
|
|
352
351
|
*
|
|
353
352
|
* > [!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.
|
|
354
353
|
*
|
|
355
|
-
* > [!NOTE] Note that most [Svelte transitions](https://svelte.dev/tutorial/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`.
|
|
354
|
+
* > [!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`.
|
|
356
355
|
*
|
|
357
|
-
* If this level of configuration is insufficient and you have more dynamic requirements, you can use the [`handle` hook](https://
|
|
356
|
+
* 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.
|
|
358
357
|
*/
|
|
359
358
|
csp?: {
|
|
360
359
|
/**
|
|
@@ -398,12 +397,12 @@ export interface KitConfig {
|
|
|
398
397
|
*/
|
|
399
398
|
dir?: string;
|
|
400
399
|
/**
|
|
401
|
-
* A prefix that signals that an environment variable is safe to expose to client-side code. See [`$env/static/public`](https://
|
|
400
|
+
* A prefix that signals that an environment variable is safe to expose to client-side code. See [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public) and [`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public). Note that Vite's [`envPrefix`](https://vitejs.dev/config/shared-options.html#envprefix) must be set separately if you are using Vite's environment variable handling - though use of that feature should generally be unnecessary.
|
|
402
401
|
* @default "PUBLIC_"
|
|
403
402
|
*/
|
|
404
403
|
publicPrefix?: string;
|
|
405
404
|
/**
|
|
406
|
-
* A prefix that signals that an environment variable is unsafe to expose to client-side code. Environment variables matching neither the public nor the private prefix will be discarded completely. See [`$env/static/private`](https://
|
|
405
|
+
* A prefix that signals that an environment variable is unsafe to expose to client-side code. Environment variables matching neither the public nor the private prefix will be discarded completely. See [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private) and [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private).
|
|
407
406
|
* @default ""
|
|
408
407
|
* @since 1.21.0
|
|
409
408
|
*/
|
|
@@ -420,17 +419,17 @@ export interface KitConfig {
|
|
|
420
419
|
assets?: string;
|
|
421
420
|
hooks?: {
|
|
422
421
|
/**
|
|
423
|
-
* The location of your client [hooks](https://
|
|
422
|
+
* The location of your client [hooks](https://svelte.dev/docs/kit/hooks).
|
|
424
423
|
* @default "src/hooks.client"
|
|
425
424
|
*/
|
|
426
425
|
client?: string;
|
|
427
426
|
/**
|
|
428
|
-
* The location of your server [hooks](https://
|
|
427
|
+
* The location of your server [hooks](https://svelte.dev/docs/kit/hooks).
|
|
429
428
|
* @default "src/hooks.server"
|
|
430
429
|
*/
|
|
431
430
|
server?: string;
|
|
432
431
|
/**
|
|
433
|
-
* The location of your universal [hooks](https://
|
|
432
|
+
* The location of your universal [hooks](https://svelte.dev/docs/kit/hooks).
|
|
434
433
|
* @default "src/hooks"
|
|
435
434
|
* @since 2.3.0
|
|
436
435
|
*/
|
|
@@ -442,17 +441,17 @@ export interface KitConfig {
|
|
|
442
441
|
*/
|
|
443
442
|
lib?: string;
|
|
444
443
|
/**
|
|
445
|
-
* a directory containing [parameter matchers](https://
|
|
444
|
+
* a directory containing [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#matching)
|
|
446
445
|
* @default "src/params"
|
|
447
446
|
*/
|
|
448
447
|
params?: string;
|
|
449
448
|
/**
|
|
450
|
-
* the files that define the structure of your app (see [Routing](https://
|
|
449
|
+
* the files that define the structure of your app (see [Routing](https://svelte.dev/docs/kit/routing))
|
|
451
450
|
* @default "src/routes"
|
|
452
451
|
*/
|
|
453
452
|
routes?: string;
|
|
454
453
|
/**
|
|
455
|
-
* the location of your service worker's entry point (see [Service workers](https://
|
|
454
|
+
* the location of your service worker's entry point (see [Service workers](https://svelte.dev/docs/kit/service-workers))
|
|
456
455
|
* @default "src/service-worker"
|
|
457
456
|
*/
|
|
458
457
|
serviceWorker?: string;
|
|
@@ -506,7 +505,7 @@ export interface KitConfig {
|
|
|
506
505
|
*/
|
|
507
506
|
assets?: '' | `http://${string}` | `https://${string}`;
|
|
508
507
|
/**
|
|
509
|
-
* 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://
|
|
508
|
+
* 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.
|
|
510
509
|
* @default ""
|
|
511
510
|
*/
|
|
512
511
|
base?: '' | `/${string}`;
|
|
@@ -516,7 +515,7 @@ export interface KitConfig {
|
|
|
516
515
|
* 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.
|
|
517
516
|
* If `false`, `%sveltekit.assets%` and references to build artifacts will always be root-relative paths, unless `paths.assets` is an external URL
|
|
518
517
|
*
|
|
519
|
-
* [Single-page app](https://
|
|
518
|
+
* [Single-page app](https://svelte.dev/docs/kit/single-page-apps) fallback pages will always use absolute paths, regardless of this setting.
|
|
520
519
|
*
|
|
521
520
|
* 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.
|
|
522
521
|
*
|
|
@@ -528,7 +527,7 @@ export interface KitConfig {
|
|
|
528
527
|
relative?: boolean;
|
|
529
528
|
};
|
|
530
529
|
/**
|
|
531
|
-
* See [Prerendering](https://
|
|
530
|
+
* See [Prerendering](https://svelte.dev/docs/kit/page-options#prerender).
|
|
532
531
|
*/
|
|
533
532
|
prerender?: {
|
|
534
533
|
/**
|
|
@@ -648,7 +647,7 @@ export interface KitConfig {
|
|
|
648
647
|
* </script>
|
|
649
648
|
* ```
|
|
650
649
|
*
|
|
651
|
-
* If you set `pollInterval` to a non-zero value, SvelteKit will poll for new versions in the background and set the value of the [`updated`](https://
|
|
650
|
+
* If you set `pollInterval` to a non-zero value, SvelteKit will poll for new versions in the background and set the value of the [`updated`](https://svelte.dev/docs/kit/$app-stores#updated) store to `true` when it detects one.
|
|
652
651
|
*/
|
|
653
652
|
version?: {
|
|
654
653
|
/**
|
|
@@ -679,8 +678,8 @@ export interface KitConfig {
|
|
|
679
678
|
}
|
|
680
679
|
|
|
681
680
|
/**
|
|
682
|
-
* The [`handle`](https://
|
|
683
|
-
* determines the [response](https://
|
|
681
|
+
* 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
|
|
682
|
+
* determines the [response](https://svelte.dev/docs/kit/web-standards#Fetch-APIs-Response).
|
|
684
683
|
* It receives an `event` object representing the request and a function called `resolve`, which renders the route and generates a `Response`.
|
|
685
684
|
* This allows you to modify response headers or bodies, or bypass SvelteKit entirely (for implementing routes programmatically, for example).
|
|
686
685
|
*/
|
|
@@ -690,7 +689,7 @@ export type Handle = (input: {
|
|
|
690
689
|
}) => MaybePromise<Response>;
|
|
691
690
|
|
|
692
691
|
/**
|
|
693
|
-
* The server-side [`handleError`](https://
|
|
692
|
+
* 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.
|
|
694
693
|
*
|
|
695
694
|
* If an unexpected error is thrown during loading or rendering, this function will be called with the error and the event.
|
|
696
695
|
* Make sure that this function _never_ throws an error.
|
|
@@ -703,7 +702,7 @@ export type HandleServerError = (input: {
|
|
|
703
702
|
}) => MaybePromise<void | App.Error>;
|
|
704
703
|
|
|
705
704
|
/**
|
|
706
|
-
* The client-side [`handleError`](https://
|
|
705
|
+
* The client-side [`handleError`](https://svelte.dev/docs/kit/hooks#shared-hooks-handleError) hook runs when an unexpected error is thrown while navigating.
|
|
707
706
|
*
|
|
708
707
|
* If an unexpected error is thrown during loading or the following render, this function will be called with the error and the event.
|
|
709
708
|
* Make sure that this function _never_ throws an error.
|
|
@@ -716,7 +715,7 @@ export type HandleClientError = (input: {
|
|
|
716
715
|
}) => MaybePromise<void | App.Error>;
|
|
717
716
|
|
|
718
717
|
/**
|
|
719
|
-
* The [`handleFetch`](https://
|
|
718
|
+
* The [`handleFetch`](https://svelte.dev/docs/kit/hooks#server-hooks-handleFetch) hook allows you to modify (or replace) a `fetch` request that happens inside a `load` function that runs on the server (or during pre-rendering)
|
|
720
719
|
*/
|
|
721
720
|
export type HandleFetch = (input: {
|
|
722
721
|
event: RequestEvent;
|
|
@@ -725,13 +724,13 @@ export type HandleFetch = (input: {
|
|
|
725
724
|
}) => MaybePromise<Response>;
|
|
726
725
|
|
|
727
726
|
/**
|
|
728
|
-
* The [`reroute`](https://
|
|
727
|
+
* 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.
|
|
729
728
|
* @since 2.3.0
|
|
730
729
|
*/
|
|
731
730
|
export type Reroute = (event: { url: URL }) => void | string;
|
|
732
731
|
|
|
733
732
|
/**
|
|
734
|
-
* The generic form of `PageLoad` and `LayoutLoad`. You should import those from `./$types` (see [generated types](https://
|
|
733
|
+
* The generic form of `PageLoad` and `LayoutLoad`. You should import those from `./$types` (see [generated types](https://svelte.dev/docs/kit/types#Generated-types))
|
|
735
734
|
* rather than using `Load` directly.
|
|
736
735
|
*/
|
|
737
736
|
export type Load<
|
|
@@ -743,7 +742,7 @@ export type Load<
|
|
|
743
742
|
> = (event: LoadEvent<Params, InputData, ParentData, RouteId>) => MaybePromise<OutputData>;
|
|
744
743
|
|
|
745
744
|
/**
|
|
746
|
-
* The generic form of `PageLoadEvent` and `LayoutLoadEvent`. You should import those from `./$types` (see [generated types](https://
|
|
745
|
+
* The generic form of `PageLoadEvent` and `LayoutLoadEvent`. You should import those from `./$types` (see [generated types](https://svelte.dev/docs/kit/types#Generated-types))
|
|
747
746
|
* rather than using `LoadEvent` directly.
|
|
748
747
|
*/
|
|
749
748
|
export interface LoadEvent<
|
|
@@ -758,10 +757,10 @@ export interface LoadEvent<
|
|
|
758
757
|
* - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.
|
|
759
758
|
* - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).
|
|
760
759
|
* - 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.
|
|
761
|
-
* - 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://
|
|
760
|
+
* - 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)
|
|
762
761
|
* - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.
|
|
763
762
|
*
|
|
764
|
-
* You can learn more about making credentialed requests with cookies [here](https://
|
|
763
|
+
* You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies)
|
|
765
764
|
*/
|
|
766
765
|
fetch: typeof fetch;
|
|
767
766
|
/**
|
|
@@ -788,7 +787,7 @@ export interface LoadEvent<
|
|
|
788
787
|
*
|
|
789
788
|
* Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.
|
|
790
789
|
*
|
|
791
|
-
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://
|
|
790
|
+
* 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.
|
|
792
791
|
*
|
|
793
792
|
* `setHeaders` has no effect when a `load` function runs in the browser.
|
|
794
793
|
*/
|
|
@@ -801,7 +800,7 @@ export interface LoadEvent<
|
|
|
801
800
|
*/
|
|
802
801
|
parent(): Promise<ParentData>;
|
|
803
802
|
/**
|
|
804
|
-
* This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](https://
|
|
803
|
+
* This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](https://svelte.dev/docs/kit/$app-navigation#invalidate) to cause `load` to rerun.
|
|
805
804
|
*
|
|
806
805
|
* Most of the time you won't need this, as `fetch` calls `depends` on your behalf — it's only necessary if you're using a custom API client that bypasses `fetch`.
|
|
807
806
|
*
|
|
@@ -826,7 +825,7 @@ export interface LoadEvent<
|
|
|
826
825
|
* <script>
|
|
827
826
|
* import { invalidate } from '$app/navigation';
|
|
828
827
|
*
|
|
829
|
-
*
|
|
828
|
+
* let { data } = $props();
|
|
830
829
|
*
|
|
831
830
|
* const increase = async () => {
|
|
832
831
|
* await invalidate('increase:count');
|
|
@@ -940,7 +939,7 @@ export interface Navigation {
|
|
|
940
939
|
}
|
|
941
940
|
|
|
942
941
|
/**
|
|
943
|
-
* The argument passed to [`beforeNavigate`](https://
|
|
942
|
+
* The argument passed to [`beforeNavigate`](https://svelte.dev/docs/kit/$app-navigation#beforeNavigate) callbacks.
|
|
944
943
|
*/
|
|
945
944
|
export interface BeforeNavigate extends Navigation {
|
|
946
945
|
/**
|
|
@@ -950,7 +949,7 @@ export interface BeforeNavigate extends Navigation {
|
|
|
950
949
|
}
|
|
951
950
|
|
|
952
951
|
/**
|
|
953
|
-
* The argument passed to [`onNavigate`](https://
|
|
952
|
+
* The argument passed to [`onNavigate`](https://svelte.dev/docs/kit/$app-navigation#onNavigate) callbacks.
|
|
954
953
|
*/
|
|
955
954
|
export interface OnNavigate extends Navigation {
|
|
956
955
|
/**
|
|
@@ -968,7 +967,7 @@ export interface OnNavigate extends Navigation {
|
|
|
968
967
|
}
|
|
969
968
|
|
|
970
969
|
/**
|
|
971
|
-
* The argument passed to [`afterNavigate`](https://
|
|
970
|
+
* The argument passed to [`afterNavigate`](https://svelte.dev/docs/kit/$app-navigation#afterNavigate) callbacks.
|
|
972
971
|
*/
|
|
973
972
|
export interface AfterNavigate extends Omit<Navigation, 'type'> {
|
|
974
973
|
/**
|
|
@@ -1023,17 +1022,17 @@ export interface Page<
|
|
|
1023
1022
|
*/
|
|
1024
1023
|
data: App.PageData & Record<string, any>;
|
|
1025
1024
|
/**
|
|
1026
|
-
* The page state, which can be manipulated using the [`pushState`](https://
|
|
1025
|
+
* 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`.
|
|
1027
1026
|
*/
|
|
1028
1027
|
state: App.PageState;
|
|
1029
1028
|
/**
|
|
1030
|
-
* Filled only after a form submission. See [form actions](https://
|
|
1029
|
+
* Filled only after a form submission. See [form actions](https://svelte.dev/docs/kit/form-actions) for more info.
|
|
1031
1030
|
*/
|
|
1032
1031
|
form: any;
|
|
1033
1032
|
}
|
|
1034
1033
|
|
|
1035
1034
|
/**
|
|
1036
|
-
* The shape of a param matcher. See [matching](https://
|
|
1035
|
+
* The shape of a param matcher. See [matching](https://svelte.dev/docs/kit/advanced-routing#Matching) for more info.
|
|
1037
1036
|
*/
|
|
1038
1037
|
export type ParamMatcher = (param: string) => boolean;
|
|
1039
1038
|
|
|
@@ -1051,10 +1050,10 @@ export interface RequestEvent<
|
|
|
1051
1050
|
* - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.
|
|
1052
1051
|
* - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).
|
|
1053
1052
|
* - 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.
|
|
1054
|
-
* - 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://
|
|
1053
|
+
* - 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)
|
|
1055
1054
|
* - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.
|
|
1056
1055
|
*
|
|
1057
|
-
* You can learn more about making credentialed requests with cookies [here](https://
|
|
1056
|
+
* You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies)
|
|
1058
1057
|
*/
|
|
1059
1058
|
fetch: typeof fetch;
|
|
1060
1059
|
/**
|
|
@@ -1062,7 +1061,7 @@ export interface RequestEvent<
|
|
|
1062
1061
|
*/
|
|
1063
1062
|
getClientAddress(): string;
|
|
1064
1063
|
/**
|
|
1065
|
-
* Contains custom data that was added to the request within the [`handle hook`](https://
|
|
1064
|
+
* Contains custom data that was added to the request within the [`handle hook`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle).
|
|
1066
1065
|
*/
|
|
1067
1066
|
locals: App.Locals;
|
|
1068
1067
|
/**
|
|
@@ -1106,7 +1105,7 @@ export interface RequestEvent<
|
|
|
1106
1105
|
*
|
|
1107
1106
|
* Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.
|
|
1108
1107
|
*
|
|
1109
|
-
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://
|
|
1108
|
+
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/@sveltejs-kit#Cookies) API instead.
|
|
1110
1109
|
*/
|
|
1111
1110
|
setHeaders(headers: Record<string, string>): void;
|
|
1112
1111
|
/**
|
|
@@ -1127,7 +1126,7 @@ export interface RequestEvent<
|
|
|
1127
1126
|
/**
|
|
1128
1127
|
* 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.
|
|
1129
1128
|
*
|
|
1130
|
-
* It receives `Params` as the first generic argument, which you can skip by using [generated types](https://
|
|
1129
|
+
* 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.
|
|
1131
1130
|
*/
|
|
1132
1131
|
export type RequestHandler<
|
|
1133
1132
|
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
@@ -1203,7 +1202,7 @@ export interface SSRManifest {
|
|
|
1203
1202
|
}
|
|
1204
1203
|
|
|
1205
1204
|
/**
|
|
1206
|
-
* The generic form of `PageServerLoad` and `LayoutServerLoad`. You should import those from `./$types` (see [generated types](https://
|
|
1205
|
+
* The generic form of `PageServerLoad` and `LayoutServerLoad`. You should import those from `./$types` (see [generated types](https://svelte.dev/docs/kit/types#Generated-types))
|
|
1207
1206
|
* rather than using `ServerLoad` directly.
|
|
1208
1207
|
*/
|
|
1209
1208
|
export type ServerLoad<
|
|
@@ -1225,7 +1224,7 @@ export interface ServerLoadEvent<
|
|
|
1225
1224
|
*/
|
|
1226
1225
|
parent(): Promise<ParentData>;
|
|
1227
1226
|
/**
|
|
1228
|
-
* This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](https://
|
|
1227
|
+
* This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](https://svelte.dev/docs/kit/$app-navigation#invalidate) to cause `load` to rerun.
|
|
1229
1228
|
*
|
|
1230
1229
|
* Most of the time you won't need this, as `fetch` calls `depends` on your behalf — it's only necessary if you're using a custom API client that bypasses `fetch`.
|
|
1231
1230
|
*
|
|
@@ -1250,7 +1249,7 @@ export interface ServerLoadEvent<
|
|
|
1250
1249
|
* <script>
|
|
1251
1250
|
* import { invalidate } from '$app/navigation';
|
|
1252
1251
|
*
|
|
1253
|
-
*
|
|
1252
|
+
* let { data } = $props();
|
|
1254
1253
|
*
|
|
1255
1254
|
* const increase = async () => {
|
|
1256
1255
|
* await invalidate('increase:count');
|
|
@@ -1280,7 +1279,7 @@ export interface ServerLoadEvent<
|
|
|
1280
1279
|
|
|
1281
1280
|
/**
|
|
1282
1281
|
* Shape of a form action method that is part of `export const actions = {..}` in `+page.server.js`.
|
|
1283
|
-
* See [form actions](https://
|
|
1282
|
+
* See [form actions](https://svelte.dev/docs/kit/form-actions) for more information.
|
|
1284
1283
|
*/
|
|
1285
1284
|
export type Action<
|
|
1286
1285
|
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
@@ -1290,7 +1289,7 @@ export type Action<
|
|
|
1290
1289
|
|
|
1291
1290
|
/**
|
|
1292
1291
|
* Shape of the `export const actions = {..}` object in `+page.server.js`.
|
|
1293
|
-
* See [form actions](https://
|
|
1292
|
+
* See [form actions](https://svelte.dev/docs/kit/form-actions) for more information.
|
|
1294
1293
|
*/
|
|
1295
1294
|
export type Actions<
|
|
1296
1295
|
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
@@ -1318,7 +1317,7 @@ export type ActionResult<
|
|
|
1318
1317
|
| { type: 'error'; status?: number; error: any };
|
|
1319
1318
|
|
|
1320
1319
|
/**
|
|
1321
|
-
* The object returned by the [`error`](https://
|
|
1320
|
+
* The object returned by the [`error`](https://svelte.dev/docs/kit/@sveltejs-kit#error) function.
|
|
1322
1321
|
*/
|
|
1323
1322
|
export interface HttpError {
|
|
1324
1323
|
/** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses), in the range 400-599. */
|
|
@@ -1328,7 +1327,7 @@ export interface HttpError {
|
|
|
1328
1327
|
}
|
|
1329
1328
|
|
|
1330
1329
|
/**
|
|
1331
|
-
* The object returned by the [`redirect`](https://
|
|
1330
|
+
* The object returned by the [`redirect`](https://svelte.dev/docs/kit/@sveltejs-kit#redirect) function
|
|
1332
1331
|
*/
|
|
1333
1332
|
export interface Redirect {
|
|
1334
1333
|
/** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages), in the range 300-308. */
|
|
@@ -43,7 +43,7 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
43
43
|
globalThis.fetch = (info, init) => {
|
|
44
44
|
if (typeof info === 'string' && !SCHEME.test(info)) {
|
|
45
45
|
throw new Error(
|
|
46
|
-
`Cannot use relative URL (${info}) with global fetch — use \`event.fetch\` instead: https://
|
|
46
|
+
`Cannot use relative URL (${info}) with global fetch — use \`event.fetch\` instead: https://svelte.dev/docs/kit/web-standards#fetch-apis`
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
|