@sveltejs/kit 2.7.1 → 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/hooks/sequence.js +4 -1
- package/src/exports/public.d.ts +58 -59
- 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 +5 -3
- 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 +78 -74
- package/types/index.d.ts.map +1 -1
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;
|
|
@@ -307,9 +306,9 @@ export interface KitConfig {
|
|
|
307
306
|
* };
|
|
308
307
|
* ```
|
|
309
308
|
*
|
|
310
|
-
* > The built-in `$lib` alias is controlled by `config.kit.files.lib` as it is used for packaging.
|
|
309
|
+
* > [!NOTE] The built-in `$lib` alias is controlled by `config.kit.files.lib` as it is used for packaging.
|
|
311
310
|
*
|
|
312
|
-
* > You will need to run `npm run dev` to have SvelteKit automatically generate the required alias configuration in `jsconfig.json` or `tsconfig.json`.
|
|
311
|
+
* > [!NOTE] You will need to run `npm run dev` to have SvelteKit automatically generate the required alias configuration in `jsconfig.json` or `tsconfig.json`.
|
|
313
312
|
* @default {}
|
|
314
313
|
*/
|
|
315
314
|
alias?: Record<string, string>;
|
|
@@ -350,11 +349,11 @@ export interface KitConfig {
|
|
|
350
349
|
*
|
|
351
350
|
* 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).
|
|
352
351
|
*
|
|
353
|
-
* > 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.
|
|
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 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;
|
|
@@ -470,7 +469,7 @@ export interface KitConfig {
|
|
|
470
469
|
/**
|
|
471
470
|
* 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 and smaller than this value are merged and inlined in a `<style>` block.
|
|
472
471
|
*
|
|
473
|
-
* > 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.
|
|
472
|
+
* > [!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.
|
|
474
473
|
* @default 0
|
|
475
474
|
*/
|
|
476
475
|
inlineStyleThreshold?: number;
|
|
@@ -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
|
|
|
@@ -93,7 +93,7 @@ const warning_preprocessor = {
|
|
|
93
93
|
|
|
94
94
|
const message =
|
|
95
95
|
`\n${colors.bold().red(path.relative('.', filename))}\n` +
|
|
96
|
-
`\`${match[1]}\` will be ignored — move it to ${fixed} instead. See https://
|
|
96
|
+
`\`${match[1]}\` will be ignored — move it to ${fixed} instead. See https://svelte.dev/docs/kit/page-options for more information.`;
|
|
97
97
|
|
|
98
98
|
if (!warned.has(message)) {
|
|
99
99
|
console.log(message);
|
|
@@ -352,6 +352,9 @@ async function kit({ svelte_config }) {
|
|
|
352
352
|
}
|
|
353
353
|
};
|
|
354
354
|
|
|
355
|
+
/** @type {Map<string, string>} */
|
|
356
|
+
const import_map = new Map();
|
|
357
|
+
|
|
355
358
|
/** @type {import('vite').Plugin} */
|
|
356
359
|
const plugin_virtual_modules = {
|
|
357
360
|
name: 'vite-plugin-sveltekit-virtual-modules',
|
|
@@ -372,6 +375,8 @@ async function kit({ svelte_config }) {
|
|
|
372
375
|
`Cannot import ${id} into service-worker code. Only the modules $service-worker and $env/static/public are available in service workers.`
|
|
373
376
|
);
|
|
374
377
|
}
|
|
378
|
+
|
|
379
|
+
import_map.set(id, importer);
|
|
375
380
|
}
|
|
376
381
|
|
|
377
382
|
// treat $env/static/[public|private] as virtual
|
|
@@ -398,7 +403,18 @@ async function kit({ svelte_config }) {
|
|
|
398
403
|
})
|
|
399
404
|
) {
|
|
400
405
|
const relative = normalize_id(id, normalized_lib, normalized_cwd);
|
|
401
|
-
|
|
406
|
+
|
|
407
|
+
const illegal_module = strip_virtual_prefix(relative);
|
|
408
|
+
|
|
409
|
+
if (import_map.has(illegal_module)) {
|
|
410
|
+
const importer = path.relative(
|
|
411
|
+
cwd,
|
|
412
|
+
/** @type {string} */ (import_map.get(illegal_module))
|
|
413
|
+
);
|
|
414
|
+
throw new Error(`Cannot import ${illegal_module} into client-side code: ${importer}`);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
throw new Error(`Cannot import ${illegal_module} into client-side code`);
|
|
402
418
|
}
|
|
403
419
|
}
|
|
404
420
|
|
|
@@ -900,7 +916,7 @@ async function kit({ svelte_config }) {
|
|
|
900
916
|
} else {
|
|
901
917
|
console.log(colors.bold().yellow('\nNo adapter specified'));
|
|
902
918
|
|
|
903
|
-
const link = colors.bold().cyan('https://
|
|
919
|
+
const link = colors.bold().cyan('https://svelte.dev/docs/kit/adapters');
|
|
904
920
|
console.log(
|
|
905
921
|
`See ${link} to learn how to configure your app to run on the platform of your choosing`
|
|
906
922
|
);
|
|
@@ -131,6 +131,13 @@ export async function preview(vite, vite_config, svelte_config) {
|
|
|
131
131
|
let filename = normalizePath(
|
|
132
132
|
join(svelte_config.kit.outDir, 'output/prerendered/pages' + pathname)
|
|
133
133
|
);
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
filename = decodeURI(filename);
|
|
137
|
+
} catch {
|
|
138
|
+
// malformed URI
|
|
139
|
+
}
|
|
140
|
+
|
|
134
141
|
let prerendered = is_file(filename);
|
|
135
142
|
|
|
136
143
|
if (!prerendered) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A string that matches [`config.kit.paths.base`](https://
|
|
2
|
+
* A string that matches [`config.kit.paths.base`](https://svelte.dev/docs/kit/configuration#paths).
|
|
3
3
|
*
|
|
4
4
|
* Example usage: `<a href="{base}/your-page">Link</a>`
|
|
5
5
|
*/
|
|
6
6
|
export let base: '' | `/${string}`;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* An absolute path that matches [`config.kit.paths.assets`](https://
|
|
9
|
+
* An absolute path that matches [`config.kit.paths.assets`](https://svelte.dev/docs/kit/configuration#paths).
|
|
10
10
|
*
|
|
11
|
-
* > If a value for `config.kit.paths.assets` is specified, it will be replaced with `'/_svelte_kit_assets'` during `vite dev` or `vite preview`, since the assets don't yet live at their eventual URL.
|
|
11
|
+
* > [!NOTE] If a value for `config.kit.paths.assets` is specified, it will be replaced with `'/_svelte_kit_assets'` during `vite dev` or `vite preview`, since the assets don't yet live at their eventual URL.
|
|
12
12
|
*/
|
|
13
13
|
export let assets: '' | `https://${string}` | `http://${string}` | '/_svelte_kit_assets';
|
|
14
14
|
|
|
@@ -16,6 +16,8 @@ export let assets: '' | `https://${string}` | `http://${string}` | '/_svelte_kit
|
|
|
16
16
|
* Populate a route ID with params to resolve a pathname.
|
|
17
17
|
* @example
|
|
18
18
|
* ```js
|
|
19
|
+
* import { resolveRoute } from '$app/paths';
|
|
20
|
+
*
|
|
19
21
|
* resolveRoute(
|
|
20
22
|
* `/blog/[slug]/[...somethingElse]`,
|
|
21
23
|
* {
|
|
@@ -53,7 +53,7 @@ export const navigating = {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* A readable store whose initial value is `false`. If [`version.pollInterval`](https://
|
|
56
|
+
* A readable store whose initial value is `false`. If [`version.pollInterval`](https://svelte.dev/docs/kit/configuration#version) is a non-zero value, SvelteKit will poll for new versions of the app and update the store value to `true` when it detects one. `updated.check()` will force an immediate check, regardless of polling.
|
|
57
57
|
*
|
|
58
58
|
* On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.
|
|
59
59
|
* @type {import('svelte/store').Readable<boolean> & { check(): Promise<boolean> }}
|
|
@@ -88,7 +88,7 @@ function get_store(name) {
|
|
|
88
88
|
} catch {
|
|
89
89
|
throw new Error(
|
|
90
90
|
`Cannot subscribe to '${name}' store on the server outside of a Svelte component, as it is bound to the current request via component context. This prevents state from leaking between users.` +
|
|
91
|
-
'For more information, see https://
|
|
91
|
+
'For more information, see https://svelte.dev/docs/kit/state-management#avoid-shared-state-on-the-server'
|
|
92
92
|
);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -1574,7 +1574,7 @@ function setup_preload() {
|
|
|
1574
1574
|
`Preloading data for ${intent.url.pathname} failed with the following error: ${result.state.error.message}\n` +
|
|
1575
1575
|
'If this error is transient, you can ignore it. Otherwise, consider disabling preloading for this route. ' +
|
|
1576
1576
|
'This route was preloaded due to a data-sveltekit-preload-data attribute. ' +
|
|
1577
|
-
'See https://
|
|
1577
|
+
'See https://svelte.dev/docs/kit/link-options for more info'
|
|
1578
1578
|
);
|
|
1579
1579
|
}
|
|
1580
1580
|
});
|
|
@@ -1717,12 +1717,12 @@ export function disableScrollHandling() {
|
|
|
1717
1717
|
* Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`.
|
|
1718
1718
|
* For external URLs, use `window.location = url` instead of calling `goto(url)`.
|
|
1719
1719
|
*
|
|
1720
|
-
* @param {string | URL} url Where to navigate to. Note that if you've set [`config.kit.paths.base`](https://
|
|
1720
|
+
* @param {string | URL} url Where to navigate to. Note that if you've set [`config.kit.paths.base`](https://svelte.dev/docs/kit/configuration#paths) and the URL is root-relative, you need to prepend the base path if you want to navigate within the app.
|
|
1721
1721
|
* @param {Object} [opts] Options related to the navigation
|
|
1722
1722
|
* @param {boolean} [opts.replaceState] If `true`, will replace the current `history` entry rather than creating a new one with `pushState`
|
|
1723
1723
|
* @param {boolean} [opts.noScroll] If `true`, the browser will maintain its scroll position rather than scrolling to the top of the page after navigation
|
|
1724
1724
|
* @param {boolean} [opts.keepFocus] If `true`, the currently focused element will retain focus after navigation. Otherwise, focus will be reset to the body
|
|
1725
|
-
* @param {boolean} [opts.invalidateAll] If `true`, all `load` functions of the page will be rerun. See https://
|
|
1725
|
+
* @param {boolean} [opts.invalidateAll] If `true`, all `load` functions of the page will be rerun. See https://svelte.dev/docs/kit/load#rerunning-load-functions for more info on invalidation.
|
|
1726
1726
|
* @param {App.PageState} [opts.state] An optional object that will be available on the `$page.state` store
|
|
1727
1727
|
* @returns {Promise<void>}
|
|
1728
1728
|
*/
|
|
@@ -1861,7 +1861,7 @@ export function preloadCode(pathname) {
|
|
|
1861
1861
|
}
|
|
1862
1862
|
|
|
1863
1863
|
/**
|
|
1864
|
-
* Programmatically create a new history entry with the given `$page.state`. To use the current URL, you can pass `''` as the first argument. Used for [shallow routing](https://
|
|
1864
|
+
* Programmatically create a new history entry with the given `$page.state`. To use the current URL, you can pass `''` as the first argument. Used for [shallow routing](https://svelte.dev/docs/kit/shallow-routing).
|
|
1865
1865
|
*
|
|
1866
1866
|
* @param {string | URL} url
|
|
1867
1867
|
* @param {App.PageState} state
|
|
@@ -1905,7 +1905,7 @@ export function pushState(url, state) {
|
|
|
1905
1905
|
}
|
|
1906
1906
|
|
|
1907
1907
|
/**
|
|
1908
|
-
* Programmatically replace the current history entry with the given `$page.state`. To use the current URL, you can pass `''` as the first argument. Used for [shallow routing](https://
|
|
1908
|
+
* Programmatically replace the current history entry with the given `$page.state`. To use the current URL, you can pass `''` as the first argument. Used for [shallow routing](https://svelte.dev/docs/kit/shallow-routing).
|
|
1909
1909
|
*
|
|
1910
1910
|
* @param {string | URL} url
|
|
1911
1911
|
* @param {App.PageState} state
|
|
@@ -53,7 +53,7 @@ if (DEV && BROWSER) {
|
|
|
53
53
|
|
|
54
54
|
if (in_load_heuristic && !used_kit_fetch) {
|
|
55
55
|
console.warn(
|
|
56
|
-
`Loading ${url} using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://
|
|
56
|
+
`Loading ${url} using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://svelte.dev/docs/kit/load#making-fetch-requests`
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -97,7 +97,7 @@ export function create_fetch({ event, options, manifest, state, get_cookie_heade
|
|
|
97
97
|
return new Response(state.read(file), {
|
|
98
98
|
headers: type ? { 'content-type': type } : {}
|
|
99
99
|
});
|
|
100
|
-
} else if (read_implementation) {
|
|
100
|
+
} else if (read_implementation && file in manifest._.server_assets) {
|
|
101
101
|
const length = manifest._.server_assets[file];
|
|
102
102
|
const type = manifest.mimeTypes[file.slice(file.lastIndexOf('.'))];
|
|
103
103
|
|