@sveltejs/kit 3.0.0-next.10 → 3.0.0-next.12
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/package.json +1 -1
- package/src/cli.js +8 -8
- package/src/constants.js +3 -1
- package/src/core/adapt/builder.js +3 -6
- package/src/core/config/index.js +6 -1
- package/src/core/config/options.js +54 -104
- package/src/core/env.js +25 -11
- package/src/core/postbuild/fallback.js +2 -1
- package/src/core/postbuild/prerender.js +75 -28
- package/src/core/postbuild/queue.js +2 -1
- package/src/core/sync/sync.js +11 -14
- package/src/core/sync/utils.js +21 -1
- package/src/core/sync/{write_non_ambient.js → write_app_types.js} +23 -21
- package/src/core/sync/write_client_manifest.js +4 -12
- package/src/core/sync/write_env.js +6 -4
- package/src/core/sync/write_server.js +12 -17
- package/src/core/sync/write_tsconfig/index.js +245 -0
- package/src/core/sync/write_tsconfig/utils.js +162 -0
- package/src/core/sync/write_types/index.js +80 -88
- package/src/core/utils.js +28 -3
- package/src/exports/env/index.js +68 -3
- package/src/exports/internal/env.js +6 -3
- package/src/exports/internal/server/index.js +3 -1
- package/src/exports/params.js +9 -4
- package/src/exports/public.d.ts +69 -71
- package/src/exports/vite/dev/index.js +112 -56
- package/src/exports/vite/index.js +483 -258
- package/src/exports/vite/module_ids.js +2 -2
- package/src/exports/vite/preview/index.js +3 -2
- package/src/exports/vite/utils.js +21 -10
- package/src/runner.js +13 -0
- package/src/runtime/app/forms.js +4 -0
- package/src/runtime/app/manifest/index.js +1 -0
- package/src/runtime/app/paths/client.js +30 -30
- package/src/runtime/app/paths/internal/client.js +26 -0
- package/src/runtime/app/paths/server.js +23 -10
- package/src/runtime/app/paths/types.d.ts +11 -19
- package/src/runtime/app/server/index.js +1 -1
- package/src/runtime/app/server/remote/command.js +12 -7
- package/src/runtime/app/server/remote/form.js +29 -26
- package/src/runtime/app/server/remote/prerender.js +9 -2
- package/src/runtime/app/server/remote/query.js +6 -5
- package/src/runtime/app/server/remote/shared.js +48 -30
- package/src/runtime/app/service-worker/index.js +24 -0
- package/src/runtime/app/state/index.js +1 -1
- package/src/runtime/client/client.js +46 -9
- package/src/runtime/client/ndjson.js +1 -1
- package/src/runtime/client/remote-functions/form.svelte.js +43 -51
- package/src/runtime/client/remote-functions/query/index.js +2 -2
- package/src/runtime/client/remote-functions/query-batch.svelte.js +2 -3
- package/src/runtime/client/remote-functions/query-live/iterator.js +5 -2
- package/src/runtime/client/remote-functions/shared.svelte.js +4 -1
- package/src/runtime/client/state.svelte.js +54 -21
- package/src/runtime/client/stream.js +3 -2
- package/src/runtime/form-utils.js +89 -54
- package/src/runtime/server/cookie.js +1 -1
- package/src/runtime/server/data/index.js +32 -29
- package/src/runtime/server/errors.js +135 -0
- package/src/runtime/server/fetch.js +1 -1
- package/src/runtime/server/index.js +20 -10
- package/src/runtime/server/internal.js +25 -0
- package/src/runtime/server/page/actions.js +4 -3
- package/src/runtime/server/page/data_serializer.js +10 -10
- package/src/runtime/server/page/index.js +3 -2
- package/src/runtime/server/page/load_data.js +1 -1
- package/src/runtime/server/page/render.js +22 -35
- package/src/runtime/server/page/respond_with_error.js +6 -5
- package/src/runtime/server/{remote.js → remote-functions.js} +67 -36
- package/src/runtime/server/respond.js +58 -20
- package/src/runtime/server/sourcemaps.js +183 -0
- package/src/runtime/server/utils.js +12 -157
- package/src/types/ambient-private.d.ts +10 -0
- package/src/types/ambient.d.ts +22 -27
- package/src/types/global-private.d.ts +12 -5
- package/src/types/internal.d.ts +19 -9
- package/src/types/private.d.ts +8 -0
- package/src/utils/escape.js +9 -25
- package/src/utils/features.js +1 -1
- package/src/utils/fork.js +7 -2
- package/src/utils/page_nodes.js +3 -5
- package/src/utils/url.js +12 -0
- package/src/version.js +1 -1
- package/types/index.d.ts +152 -120
- package/types/index.d.ts.map +6 -1
- package/src/core/sync/write_ambient.js +0 -18
- package/src/core/sync/write_tsconfig.js +0 -258
- package/src/runtime/shared-server.js +0 -7
- /package/src/core/sync/{write_tsconfig_test → write_tsconfig/test-app}/package.json +0 -0
package/types/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ declare module '@sveltejs/kit' {
|
|
|
32
32
|
* Test support for `read` from `$app/server`.
|
|
33
33
|
* @param details.config The merged adapter-specific route config exported from the route with `export const config`
|
|
34
34
|
*/
|
|
35
|
-
read?: (details: { config: any
|
|
35
|
+
read?: (details: { config: Record<string, any>; route: { id: string } }) => boolean;
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Test support for `instrumentation.server.js`. To pass, the adapter must support running `instrumentation.server.js` prior to the application code.
|
|
@@ -260,7 +260,7 @@ declare module '@sveltejs/kit' {
|
|
|
260
260
|
/**
|
|
261
261
|
* 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.
|
|
262
262
|
*
|
|
263
|
-
* The `httpOnly`
|
|
263
|
+
* The `httpOnly` is `true` by default, as is `secure`, except during development, when it defaults to `false`. These must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
|
|
264
264
|
*
|
|
265
265
|
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
266
266
|
* @param name the name of the cookie
|
|
@@ -272,7 +272,7 @@ declare module '@sveltejs/kit' {
|
|
|
272
272
|
/**
|
|
273
273
|
* Deletes a cookie by setting its value to an empty string and setting the expiry date in the past.
|
|
274
274
|
*
|
|
275
|
-
* The `httpOnly`
|
|
275
|
+
* The `httpOnly` is `true` by default, as is `secure`, except during development, when it defaults to `false`. These must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
|
|
276
276
|
*
|
|
277
277
|
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
278
278
|
* @param name the name of the cookie
|
|
@@ -307,7 +307,7 @@ declare module '@sveltejs/kit' {
|
|
|
307
307
|
/**
|
|
308
308
|
* Serialize a cookie name-value pair into a `Set-Cookie` header string, but don't apply it to the response.
|
|
309
309
|
*
|
|
310
|
-
* The `httpOnly`
|
|
310
|
+
* The `httpOnly` is `true` by default, as is `secure`, except during development, when it defaults to `false`. These must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
|
|
311
311
|
*
|
|
312
312
|
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
313
313
|
* @param name the name of the cookie
|
|
@@ -337,32 +337,10 @@ declare module '@sveltejs/kit' {
|
|
|
337
337
|
/**
|
|
338
338
|
* An object containing zero or more aliases used to replace values in `import` statements. These aliases are automatically passed to Vite and TypeScript.
|
|
339
339
|
*
|
|
340
|
-
*
|
|
341
|
-
* /// file: vite.config.js
|
|
342
|
-
* import { defineConfig } from 'vite';
|
|
343
|
-
* import { sveltekit } from '@sveltejs/kit/vite';
|
|
344
|
-
*
|
|
345
|
-
* export default defineConfig({
|
|
346
|
-
* plugins: [
|
|
347
|
-
* sveltekit({
|
|
348
|
-
* alias: {
|
|
349
|
-
* // this will match a file
|
|
350
|
-
* 'my-file': 'path/to/my-file.js',
|
|
351
|
-
*
|
|
352
|
-
* // this will match a directory and its contents
|
|
353
|
-
* // (`my-directory/x` resolves to `path/to/my-directory/x`)
|
|
354
|
-
* 'my-directory': 'path/to/my-directory',
|
|
355
|
-
*
|
|
356
|
-
* // an alias ending /* will only match
|
|
357
|
-
* // the contents of a directory, not the directory itself
|
|
358
|
-
* 'my-directory/*': 'path/to/my-directory/*'
|
|
359
|
-
* }
|
|
360
|
-
* })
|
|
361
|
-
* ]
|
|
362
|
-
* });
|
|
363
|
-
* ```
|
|
340
|
+
* This option is deprecated. Use [subpath imports](https://svelte.dev/docs/kit/$lib) instead.
|
|
364
341
|
*
|
|
365
342
|
* > [!NOTE] You will need to run `npm run dev` to have SvelteKit automatically generate the required alias configuration in `jsconfig.json` or `tsconfig.json`.
|
|
343
|
+
* @deprecated
|
|
366
344
|
* @default {}
|
|
367
345
|
*/
|
|
368
346
|
alias?: Record<string, string>;
|
|
@@ -407,7 +385,7 @@ declare module '@sveltejs/kit' {
|
|
|
407
385
|
*
|
|
408
386
|
* > [!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.
|
|
409
387
|
*
|
|
410
|
-
* If this level of configuration is insufficient and you have more dynamic requirements, you can use the [`handle` hook](https://svelte.dev/docs/kit/hooks#
|
|
388
|
+
* If this level of configuration is insufficient and you have more dynamic requirements, you can use the [`handle` hook](https://svelte.dev/docs/kit/hooks#handle) to roll your own CSP.
|
|
411
389
|
*/
|
|
412
390
|
csp?: {
|
|
413
391
|
/**
|
|
@@ -805,8 +783,10 @@ declare module '@sveltejs/kit' {
|
|
|
805
783
|
* This has several advantages:
|
|
806
784
|
* - The client does not need to load the routing manifest upfront, which can lead to faster initial page loads
|
|
807
785
|
* - The list of routes is hidden from public view
|
|
808
|
-
* - The server has an opportunity to intercept each navigation (for example through a
|
|
809
|
-
|
|
786
|
+
* - The server has an opportunity to intercept each navigation (for example through middleware in front of SvelteKit, such as a reverse proxy or your platform's edge functions), enabling (for example) A/B testing opaque to SvelteKit
|
|
787
|
+
*
|
|
788
|
+
* Route resolution requests are answered as soon as the route has been looked up, before the `handle` hook is invoked. To intercept them within SvelteKit itself, use the `reroute` hook, which runs for these requests too.
|
|
789
|
+
*
|
|
810
790
|
* 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)).
|
|
811
791
|
*
|
|
812
792
|
* > [!NOTE] When using server-side route resolution and prerendering, the resolution is prerendered along with the route itself.
|
|
@@ -816,13 +796,7 @@ declare module '@sveltejs/kit' {
|
|
|
816
796
|
*/
|
|
817
797
|
resolution?: 'client' | 'server';
|
|
818
798
|
};
|
|
819
|
-
serviceWorker?:
|
|
820
|
-
/**
|
|
821
|
-
* Determine which files in your `static` directory will be available in `$service-worker.files`.
|
|
822
|
-
* @default (filename) => !/\.DS_Store/.test(filename)
|
|
823
|
-
*/
|
|
824
|
-
files?: (file: string) => boolean;
|
|
825
|
-
} & (
|
|
799
|
+
serviceWorker?:
|
|
826
800
|
| {
|
|
827
801
|
/**
|
|
828
802
|
* Whether to automatically register the service worker, if it exists.
|
|
@@ -840,19 +814,21 @@ declare module '@sveltejs/kit' {
|
|
|
840
814
|
* @default true
|
|
841
815
|
*/
|
|
842
816
|
register?: false;
|
|
843
|
-
}
|
|
844
|
-
);
|
|
817
|
+
};
|
|
845
818
|
/**
|
|
846
819
|
* Options for enabling [OpenTelemetry](https://opentelemetry.io/) tracing for SvelteKit operations.
|
|
847
820
|
* @default { server: false }
|
|
848
821
|
*/
|
|
849
822
|
tracing?: {
|
|
850
823
|
/**
|
|
851
|
-
* Enables server-side [OpenTelemetry](https://opentelemetry.io/) span emission for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#
|
|
824
|
+
* Enables server-side [OpenTelemetry](https://opentelemetry.io/) span emission for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#handle), [`load` functions](https://svelte.dev/docs/kit/load), [form actions](https://svelte.dev/docs/kit/form-actions), and [remote functions](https://svelte.dev/docs/kit/remote-functions). Tracing — and more significantly, observability instrumentation — can have a nontrivial overhead, so consider whether you really need it, or if it might be more appropriate to turn it on in development and preview environments only.
|
|
852
825
|
* @default false
|
|
853
826
|
*/
|
|
854
827
|
server?: boolean;
|
|
855
828
|
};
|
|
829
|
+
/**
|
|
830
|
+
* @deprecated Add configuration to `tsconfig.json` directly
|
|
831
|
+
*/
|
|
856
832
|
typescript?: {
|
|
857
833
|
/**
|
|
858
834
|
* A function that allows you to edit the generated `tsconfig.json`. You can mutate the config (recommended) or return a new one.
|
|
@@ -867,9 +843,9 @@ declare module '@sveltejs/kit' {
|
|
|
867
843
|
};
|
|
868
844
|
/**
|
|
869
845
|
* 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.
|
|
870
|
-
* SvelteKit helps you solve this problem through version management.
|
|
846
|
+
* SvelteKit helps you solve this problem through version management. The current version is included in data, remote, and form action responses via the `x-sveltekit-version` header, so SvelteKit can detect new deployments without polling — for example when a navigation triggers a server `load` function, or when a remote function is called. SvelteKit also checks for new versions when the tab regains focus or becomes visible.
|
|
871
847
|
* 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.
|
|
872
|
-
* 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
|
|
848
|
+
* 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 `beforeNavigate`:
|
|
873
849
|
* ```html
|
|
874
850
|
* /// file: +layout.svelte
|
|
875
851
|
* <script>
|
|
@@ -884,7 +860,7 @@ declare module '@sveltejs/kit' {
|
|
|
884
860
|
* </script>
|
|
885
861
|
* ```
|
|
886
862
|
*
|
|
887
|
-
*
|
|
863
|
+
* In addition to these checks, SvelteKit polls for new versions on an interval and sets [`updated.current`](https://svelte.dev/docs/kit/$app-state#updated) to `true` when it detects one. Set `pollInterval` to `0` to disable polling (the header- and event-based checks will still run).
|
|
888
864
|
*/
|
|
889
865
|
version?: {
|
|
890
866
|
/**
|
|
@@ -911,15 +887,15 @@ declare module '@sveltejs/kit' {
|
|
|
911
887
|
*/
|
|
912
888
|
name?: string;
|
|
913
889
|
/**
|
|
914
|
-
* The interval in milliseconds to poll for version changes. If this is `0`, no polling occurs.
|
|
915
|
-
* @default
|
|
890
|
+
* The interval in milliseconds to poll for version changes. If this is `0`, no polling occurs. SvelteKit also checks for new versions on server responses (via the `x-sveltekit-version` header) and when the tab regains focus or becomes visible, so polling is only needed for long-lived sessions on a single page.
|
|
891
|
+
* @default 3600000
|
|
916
892
|
*/
|
|
917
893
|
pollInterval?: number;
|
|
918
894
|
};
|
|
919
895
|
}
|
|
920
896
|
|
|
921
897
|
/**
|
|
922
|
-
* The [`handle`](https://svelte.dev/docs/kit/hooks#
|
|
898
|
+
* The [`handle`](https://svelte.dev/docs/kit/hooks#handle) hook runs every time the SvelteKit server receives a [request](https://svelte.dev/docs/kit/web-standards#Fetch-APIs-Request) and
|
|
923
899
|
* determines the [response](https://svelte.dev/docs/kit/web-standards#Fetch-APIs-Response).
|
|
924
900
|
* It receives an `event` object representing the request and a function called `resolve`, which renders the route and generates a `Response`.
|
|
925
901
|
* This allows you to modify response headers or bodies, or bypass SvelteKit entirely (for implementing routes programmatically, for example).
|
|
@@ -930,7 +906,7 @@ declare module '@sveltejs/kit' {
|
|
|
930
906
|
}) => MaybePromise<Response>;
|
|
931
907
|
|
|
932
908
|
/**
|
|
933
|
-
* The server-side [`handleError`](https://svelte.dev/docs/kit/hooks#
|
|
909
|
+
* The server-side [`handleError`](https://svelte.dev/docs/kit/hooks#handleError) hook runs when an unexpected error is thrown while responding to a request.
|
|
934
910
|
*
|
|
935
911
|
* If an unexpected error is thrown during loading or rendering, this function will be called with the error and the event.
|
|
936
912
|
* Make sure that this function _never_ throws an error.
|
|
@@ -946,7 +922,7 @@ declare module '@sveltejs/kit' {
|
|
|
946
922
|
}) => MaybePromise<void | AppErrorWithOptionalStatus>;
|
|
947
923
|
|
|
948
924
|
/**
|
|
949
|
-
* The [`handleValidationError`](https://svelte.dev/docs/kit/hooks#
|
|
925
|
+
* The [`handleValidationError`](https://svelte.dev/docs/kit/hooks#handleValidationError) hook runs when the argument to a remote function fails validation.
|
|
950
926
|
*
|
|
951
927
|
* It will be called with the validation issues and the event, and must return an object shape that matches `App.Error`.
|
|
952
928
|
*/
|
|
@@ -954,7 +930,7 @@ declare module '@sveltejs/kit' {
|
|
|
954
930
|
(input: { issues: Issue[]; event: RequestEvent }) => MaybePromise<AppErrorWithOptionalStatus>;
|
|
955
931
|
|
|
956
932
|
/**
|
|
957
|
-
* The client-side [`handleError`](https://svelte.dev/docs/kit/hooks#
|
|
933
|
+
* The client-side [`handleError`](https://svelte.dev/docs/kit/hooks#handleError) hook runs when an unexpected error is thrown while navigating.
|
|
958
934
|
*
|
|
959
935
|
* If an unexpected error is thrown during loading or the following render, this function will be called with the error and the event.
|
|
960
936
|
* Make sure that this function _never_ throws an error.
|
|
@@ -970,7 +946,7 @@ declare module '@sveltejs/kit' {
|
|
|
970
946
|
}) => MaybePromise<void | AppErrorWithOptionalStatus>;
|
|
971
947
|
|
|
972
948
|
/**
|
|
973
|
-
* The [`handleFetch`](https://svelte.dev/docs/kit/hooks#
|
|
949
|
+
* The [`handleFetch`](https://svelte.dev/docs/kit/hooks#handleFetch) hook allows you to modify (or replace) the result of an [`event.fetch`](https://svelte.dev/docs/kit/load#Making-fetch-requests) call that runs on the server (or during prerendering) inside an endpoint, `load`, `action`, `handle`, `handleError` or `reroute`.
|
|
974
950
|
*/
|
|
975
951
|
export type HandleFetch = (input: {
|
|
976
952
|
event: RequestEvent;
|
|
@@ -979,25 +955,25 @@ declare module '@sveltejs/kit' {
|
|
|
979
955
|
}) => MaybePromise<Response>;
|
|
980
956
|
|
|
981
957
|
/**
|
|
982
|
-
* The [`init`](https://svelte.dev/docs/kit/hooks#
|
|
958
|
+
* The [`init`](https://svelte.dev/docs/kit/hooks#init) will be invoked before the server responds to its first request
|
|
983
959
|
* @since 2.10.0
|
|
984
960
|
*/
|
|
985
961
|
export type ServerInit = () => MaybePromise<void>;
|
|
986
962
|
|
|
987
963
|
/**
|
|
988
|
-
* The [`init`](https://svelte.dev/docs/kit/hooks#
|
|
964
|
+
* The [`init`](https://svelte.dev/docs/kit/hooks#init) will be invoked once the app starts in the browser
|
|
989
965
|
* @since 2.10.0
|
|
990
966
|
*/
|
|
991
967
|
export type ClientInit = () => MaybePromise<void>;
|
|
992
968
|
|
|
993
969
|
/**
|
|
994
|
-
* The [`reroute`](https://svelte.dev/docs/kit/hooks#
|
|
970
|
+
* The [`reroute`](https://svelte.dev/docs/kit/hooks#reroute) hook allows you to modify the URL before it is used to determine which route to render.
|
|
995
971
|
* @since 2.3.0
|
|
996
972
|
*/
|
|
997
973
|
export type Reroute = (event: { url: URL; fetch: typeof fetch }) => MaybePromise<void | string>;
|
|
998
974
|
|
|
999
975
|
/**
|
|
1000
|
-
* The [`transport`](https://svelte.dev/docs/kit/hooks#
|
|
976
|
+
* The [`transport`](https://svelte.dev/docs/kit/hooks#transport) hook allows you to transport custom types across the server/client boundary.
|
|
1001
977
|
*
|
|
1002
978
|
* 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).
|
|
1003
979
|
*
|
|
@@ -1023,7 +999,7 @@ declare module '@sveltejs/kit' {
|
|
|
1023
999
|
export type Transport = Record<string, Transporter>;
|
|
1024
1000
|
|
|
1025
1001
|
/**
|
|
1026
|
-
* A member of the [`transport`](https://svelte.dev/docs/kit/hooks#
|
|
1002
|
+
* A member of the [`transport`](https://svelte.dev/docs/kit/hooks#transport) hook.
|
|
1027
1003
|
*/
|
|
1028
1004
|
export interface Transporter<
|
|
1029
1005
|
T = any,
|
|
@@ -1061,7 +1037,7 @@ declare module '@sveltejs/kit' {
|
|
|
1061
1037
|
* - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.
|
|
1062
1038
|
* - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).
|
|
1063
1039
|
* - 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.
|
|
1064
|
-
* - 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#
|
|
1040
|
+
* - 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)
|
|
1065
1041
|
* - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.
|
|
1066
1042
|
*
|
|
1067
1043
|
* You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies)
|
|
@@ -1566,7 +1542,7 @@ declare module '@sveltejs/kit' {
|
|
|
1566
1542
|
* - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.
|
|
1567
1543
|
* - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).
|
|
1568
1544
|
* - 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.
|
|
1569
|
-
* - 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#
|
|
1545
|
+
* - 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)
|
|
1570
1546
|
* - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.
|
|
1571
1547
|
*
|
|
1572
1548
|
* You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies).
|
|
@@ -1577,15 +1553,16 @@ declare module '@sveltejs/kit' {
|
|
|
1577
1553
|
*/
|
|
1578
1554
|
getClientAddress: () => string;
|
|
1579
1555
|
/**
|
|
1580
|
-
* Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#
|
|
1556
|
+
* Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#handle).
|
|
1581
1557
|
*/
|
|
1582
1558
|
locals: App.Locals;
|
|
1583
1559
|
/**
|
|
1584
1560
|
* The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
|
|
1585
1561
|
*
|
|
1586
|
-
*
|
|
1587
|
-
*
|
|
1588
|
-
*
|
|
1562
|
+
* Inside `query` functions (including `query.batch` and `query.live`), accessing this property throws an error.
|
|
1563
|
+
* Pass values from the page as arguments to the query instead. Inside `form` and `command` functions it relates to the page
|
|
1564
|
+
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
1565
|
+
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
1589
1566
|
*/
|
|
1590
1567
|
params: Params;
|
|
1591
1568
|
/**
|
|
@@ -1603,9 +1580,10 @@ declare module '@sveltejs/kit' {
|
|
|
1603
1580
|
/**
|
|
1604
1581
|
* The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.
|
|
1605
1582
|
*
|
|
1606
|
-
*
|
|
1607
|
-
*
|
|
1608
|
-
*
|
|
1583
|
+
* Inside `query` functions (including `query.batch` and `query.live`), accessing this property throws an error.
|
|
1584
|
+
* Pass values from the page as arguments to the query instead. Inside `form` and `command` functions it relates to the page
|
|
1585
|
+
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
1586
|
+
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
1609
1587
|
*/
|
|
1610
1588
|
id: RouteId;
|
|
1611
1589
|
};
|
|
@@ -1635,9 +1613,10 @@ declare module '@sveltejs/kit' {
|
|
|
1635
1613
|
/**
|
|
1636
1614
|
* The requested URL.
|
|
1637
1615
|
*
|
|
1638
|
-
*
|
|
1639
|
-
*
|
|
1640
|
-
*
|
|
1616
|
+
* Inside `query` functions (including `query.batch` and `query.live`), accessing this property throws an error.
|
|
1617
|
+
* Pass values from the page as arguments to the query instead. Inside `form` and `command` functions it relates to the page
|
|
1618
|
+
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
1619
|
+
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
1641
1620
|
*/
|
|
1642
1621
|
url: URL;
|
|
1643
1622
|
/**
|
|
@@ -2062,7 +2041,7 @@ declare module '@sveltejs/kit' {
|
|
|
2062
2041
|
? [type: Type, value: Value | (string & {})]
|
|
2063
2042
|
: Type extends 'file' | 'file multiple'
|
|
2064
2043
|
? [type: Type]
|
|
2065
|
-
: [type: Type] | [type: Type, value: Value |
|
|
2044
|
+
: [type: Type] | [type: Type, value: Value | undefined];
|
|
2066
2045
|
|
|
2067
2046
|
/**
|
|
2068
2047
|
* Form field accessor type that provides name(), value(), and issues() methods
|
|
@@ -2411,17 +2390,36 @@ declare module '@sveltejs/kit' {
|
|
|
2411
2390
|
static?: boolean;
|
|
2412
2391
|
/**
|
|
2413
2392
|
* A [Standard Schema](https://standardschema.dev/) validator that is applied to the value when the app starts.
|
|
2393
|
+
* Alternatively, a function that returns the (possibly transformed) value, or throws an error explaining
|
|
2394
|
+
* the problem. Returning `undefined` is valid, so a function can describe an optional variable.
|
|
2414
2395
|
* The validator can output any value — not necessarily a string — but public, non-static values must be
|
|
2415
2396
|
* serializable by [devalue](https://github.com/sveltejs/devalue) so that they can be sent to the browser.
|
|
2416
2397
|
*
|
|
2417
|
-
* If omitted, the value must be
|
|
2398
|
+
* If omitted, the value must be set, but may be an empty string.
|
|
2418
2399
|
*/
|
|
2419
|
-
schema?: StandardSchemaV1<string | undefined, T
|
|
2400
|
+
schema?: StandardSchemaV1<string | undefined, T> | ((value: string | undefined) => T | undefined);
|
|
2420
2401
|
/**
|
|
2421
2402
|
* A description of the variable that will be used for inline documentation on hover.
|
|
2422
2403
|
*/
|
|
2423
2404
|
description?: string;
|
|
2424
2405
|
}
|
|
2406
|
+
|
|
2407
|
+
/**
|
|
2408
|
+
* The return type of [`defineEnvVars`](https://svelte.dev/docs/kit/@sveltejs-kit-env#defineEnvVars).
|
|
2409
|
+
*/
|
|
2410
|
+
export type DefinedEnvVars<T extends Record<string, EnvVarConfig<any>>> = {
|
|
2411
|
+
readonly [K in keyof T]: EnvVarEntry<T[K]>;
|
|
2412
|
+
};
|
|
2413
|
+
|
|
2414
|
+
/**
|
|
2415
|
+
* Normalizes an environment variable config's schema (standard schema or function) to standard schema.
|
|
2416
|
+
*/
|
|
2417
|
+
type EnvVarEntry<C extends EnvVarConfig<any>> =
|
|
2418
|
+
C['schema'] extends StandardSchemaV1<any, any>
|
|
2419
|
+
? C
|
|
2420
|
+
: C['schema'] extends (value: any) => infer R
|
|
2421
|
+
? Omit<C, 'schema'> & { schema: StandardSchemaV1<string | undefined, R> }
|
|
2422
|
+
: C;
|
|
2425
2423
|
interface AdapterEntry {
|
|
2426
2424
|
/**
|
|
2427
2425
|
* A string that uniquely identifies an HTTP service (e.g. serverless function) and is used for deduplication.
|
|
@@ -2577,10 +2575,18 @@ declare module '@sveltejs/kit' {
|
|
|
2577
2575
|
interface Logger {
|
|
2578
2576
|
(msg: string): void;
|
|
2579
2577
|
success(msg: string): void;
|
|
2578
|
+
/** Print a bold red message to stderr */
|
|
2580
2579
|
error(msg: string): void;
|
|
2580
|
+
/** Print a bold yellow message to stderr */
|
|
2581
2581
|
warn(msg: string): void;
|
|
2582
|
+
/** Print faded text to stdout if `verbose === true` */
|
|
2582
2583
|
minor(msg: string): void;
|
|
2584
|
+
/** Print to stdout if `verbose === true` */
|
|
2583
2585
|
info(msg: string): void;
|
|
2586
|
+
/** Print to stderr without formatting */
|
|
2587
|
+
err(msg: string): void;
|
|
2588
|
+
/** Print a bold red message, followed by a stack trace for each error (following `.cause` chains) */
|
|
2589
|
+
prettyError(error: unknown, caller?: string): void;
|
|
2584
2590
|
}
|
|
2585
2591
|
|
|
2586
2592
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -2861,12 +2867,33 @@ declare module '@sveltejs/kit' {
|
|
|
2861
2867
|
}
|
|
2862
2868
|
|
|
2863
2869
|
declare module '@sveltejs/kit/env' {
|
|
2864
|
-
import type { EnvVarConfig } from '@sveltejs/kit';
|
|
2870
|
+
import type { EnvVarConfig, DefinedEnvVars } from '@sveltejs/kit';
|
|
2865
2871
|
/**
|
|
2866
2872
|
* Utility for defining [environment variables](https://svelte.dev/docs/kit/environment-variables),
|
|
2867
2873
|
* which are made available via `$app/env/public` and `$app/env/private`.
|
|
2874
|
+
*
|
|
2875
|
+
* @example
|
|
2876
|
+
* ```js
|
|
2877
|
+
* import { defineEnvVars } from '@sveltejs/kit/env';
|
|
2878
|
+
* import * as v from 'valibot';
|
|
2879
|
+
*
|
|
2880
|
+
* export const variables = defineEnvVars({
|
|
2881
|
+
* API_URL: {
|
|
2882
|
+
* schema: v.pipe(v.string(), v.url())
|
|
2883
|
+
* },
|
|
2884
|
+
* PORT: {
|
|
2885
|
+
* schema: (value) => {
|
|
2886
|
+
* if (value === undefined) return 3000;
|
|
2887
|
+
* const port = Number(value);
|
|
2888
|
+
* if (!Number.isInteger(port)) throw new Error('PORT must be an integer');
|
|
2889
|
+
* return port;
|
|
2890
|
+
* }
|
|
2891
|
+
* }
|
|
2892
|
+
* });
|
|
2893
|
+
* ```
|
|
2894
|
+
*
|
|
2868
2895
|
* */
|
|
2869
|
-
export function defineEnvVars<T extends Record<string, EnvVarConfig<any>>>(variables: T): T
|
|
2896
|
+
export function defineEnvVars<T extends Record<string, EnvVarConfig<any>>>(variables: T): DefinedEnvVars<T>;
|
|
2870
2897
|
|
|
2871
2898
|
export {};
|
|
2872
2899
|
}
|
|
@@ -3200,7 +3227,7 @@ declare module '$app/navigation' {
|
|
|
3200
3227
|
}
|
|
3201
3228
|
|
|
3202
3229
|
declare module '$app/paths' {
|
|
3203
|
-
import type {
|
|
3230
|
+
import type { AssetPath, RouteIdWithSearchOrHash, PathnameWithSearchOrHash, ResolvedPathname, Path, RouteId, RouteParams } from '$app/types';
|
|
3204
3231
|
/**
|
|
3205
3232
|
* Resolve the URL of an asset in your `static` directory, by prefixing it with [`config.paths.assets`](https://svelte.dev/docs/kit/configuration#paths) if configured, or otherwise by prefixing it with the base path.
|
|
3206
3233
|
*
|
|
@@ -3212,12 +3239,12 @@ declare module '$app/paths' {
|
|
|
3212
3239
|
* import { asset } from '$app/paths';
|
|
3213
3240
|
* </script>
|
|
3214
3241
|
*
|
|
3215
|
-
* <img alt="a potato" src={asset('
|
|
3242
|
+
* <img alt="a potato" src={asset('potato.jpg')} />
|
|
3216
3243
|
* ```
|
|
3217
3244
|
* @since 2.26
|
|
3218
3245
|
*
|
|
3219
3246
|
* */
|
|
3220
|
-
export function asset(file:
|
|
3247
|
+
export function asset(file: AssetPath): string;
|
|
3221
3248
|
/**
|
|
3222
3249
|
* Resolve a pathname by prefixing it with the base path, if any, or resolve a route ID by populating dynamic segments with parameters.
|
|
3223
3250
|
*
|
|
@@ -3228,7 +3255,7 @@ declare module '$app/paths' {
|
|
|
3228
3255
|
* import { resolve } from '$app/paths';
|
|
3229
3256
|
*
|
|
3230
3257
|
* // using a pathname
|
|
3231
|
-
* const resolved = resolve(
|
|
3258
|
+
* const resolved = resolve(`blog/hello-world`);
|
|
3232
3259
|
*
|
|
3233
3260
|
* // using a route ID plus parameters
|
|
3234
3261
|
* const resolved = resolve('/blog/[slug]', {
|
|
@@ -3246,7 +3273,7 @@ declare module '$app/paths' {
|
|
|
3246
3273
|
* ```js
|
|
3247
3274
|
* import { match } from '$app/paths';
|
|
3248
3275
|
*
|
|
3249
|
-
* const route = await match('
|
|
3276
|
+
* const route = await match('blog/hello-world');
|
|
3250
3277
|
*
|
|
3251
3278
|
* if (route?.id === '/blog/[slug]') {
|
|
3252
3279
|
* const slug = route.params.slug;
|
|
@@ -3257,26 +3284,23 @@ declare module '$app/paths' {
|
|
|
3257
3284
|
* @since 2.52.0
|
|
3258
3285
|
*
|
|
3259
3286
|
* */
|
|
3260
|
-
export function match(url:
|
|
3287
|
+
export function match(url: Path | URL | (string & {})): Promise<{ [K in RouteId]: {
|
|
3261
3288
|
id: K;
|
|
3262
3289
|
params: RouteParams<K>;
|
|
3263
3290
|
}; }[RouteId] | null>;
|
|
3264
|
-
type StripSearchOrHash<T extends string> = T extends `${infer
|
|
3265
|
-
?
|
|
3266
|
-
: T extends `${infer
|
|
3267
|
-
?
|
|
3291
|
+
type StripSearchOrHash<T extends string> = T extends `${infer U}?${string}`
|
|
3292
|
+
? U
|
|
3293
|
+
: T extends `${infer U}#${string}`
|
|
3294
|
+
? U
|
|
3268
3295
|
: T;
|
|
3269
3296
|
|
|
3270
|
-
type ResolveArgs<T
|
|
3271
|
-
T extends RouteId
|
|
3272
|
-
? RouteParams<
|
|
3297
|
+
type ResolveArgs<T> = T extends `/${string}`
|
|
3298
|
+
? StripSearchOrHash<T> extends infer U extends RouteId
|
|
3299
|
+
? RouteParams<U> extends Record<string, never>
|
|
3273
3300
|
? [route: T]
|
|
3274
|
-
: [route: T, params: RouteParams<
|
|
3275
|
-
:
|
|
3276
|
-
|
|
3277
|
-
? [route: T]
|
|
3278
|
-
: [route: T, params: RouteParams<U>]
|
|
3279
|
-
: [route: T];
|
|
3301
|
+
: [route: T, params: RouteParams<U>]
|
|
3302
|
+
: [never]
|
|
3303
|
+
: [pathname: T];
|
|
3280
3304
|
|
|
3281
3305
|
export {};
|
|
3282
3306
|
}
|
|
@@ -3540,6 +3564,19 @@ declare module '$app/server' {
|
|
|
3540
3564
|
export {};
|
|
3541
3565
|
}
|
|
3542
3566
|
|
|
3567
|
+
declare module '$app/service-worker' {
|
|
3568
|
+
/**
|
|
3569
|
+
* The execution context of a service worker. This export exists to make it easier to
|
|
3570
|
+
* use service workers with the correct types, provided the importing module is governed
|
|
3571
|
+
* by a `tsconfig.json` that extends [`$app/tsconfig/service-worker`](https://svelte.dev/docs/kit/$app-tsconfig-service-worker).
|
|
3572
|
+
*
|
|
3573
|
+
*/
|
|
3574
|
+
// @ts-ignore
|
|
3575
|
+
export const self: ServiceWorkerGlobalScope;
|
|
3576
|
+
|
|
3577
|
+
export {};
|
|
3578
|
+
}
|
|
3579
|
+
|
|
3543
3580
|
declare module '$app/state' {
|
|
3544
3581
|
/**
|
|
3545
3582
|
* A read-only reactive object with information about the current page, serving several use cases:
|
|
@@ -3591,7 +3628,7 @@ declare module '$app/state' {
|
|
|
3591
3628
|
complete: null;
|
|
3592
3629
|
};
|
|
3593
3630
|
/**
|
|
3594
|
-
* A read-only reactive value that's initially `false`.
|
|
3631
|
+
* A read-only reactive value that's initially `false`. SvelteKit checks for new versions on data, remote, and form action responses (via the `x-sveltekit-version` header), when the tab regains focus or becomes visible, and on a poll interval (see [`version.pollInterval`](https://svelte.dev/docs/kit/configuration#version)). `updated.current` is set to `true` when a new version is detected. `updated.check()` will force an immediate check, regardless of polling.
|
|
3595
3632
|
* */
|
|
3596
3633
|
export const updated: {
|
|
3597
3634
|
get current(): boolean;
|
|
@@ -3660,32 +3697,30 @@ declare namespace App {
|
|
|
3660
3697
|
}
|
|
3661
3698
|
|
|
3662
3699
|
/**
|
|
3663
|
-
* This module is
|
|
3700
|
+
* This module is available to [service workers](https://svelte.dev/docs/kit/service-workers) and other contexts.
|
|
3701
|
+
* It exports information about the build output, static files, prerendered pages, and routes.
|
|
3664
3702
|
*/
|
|
3665
|
-
declare module '$
|
|
3703
|
+
declare module '$app/manifest' {
|
|
3666
3704
|
/**
|
|
3667
|
-
*
|
|
3668
|
-
*
|
|
3669
|
-
*/
|
|
3670
|
-
export const base: string;
|
|
3671
|
-
/**
|
|
3672
|
-
* An array of URL strings representing the files generated by Vite, suitable for caching with `cache.addAll(build)`.
|
|
3705
|
+
* An array of `{ path: string }` objects representing the files generated by Vite.
|
|
3706
|
+
* The path is relative to the [base path](https://svelte.dev/docs/kit/configuration#paths), and is intended for use with `cache.add(...)` inside a [service worker](https://svelte.dev/docs/kit/service-workers).
|
|
3673
3707
|
* During development, this is an empty array.
|
|
3674
3708
|
*/
|
|
3675
|
-
export const
|
|
3709
|
+
export const immutable: Array<{ path: string }>;
|
|
3676
3710
|
/**
|
|
3677
|
-
* An array of
|
|
3711
|
+
* An array of `{ path: AssetPath }` objects representing the files in your `static` directory, or whatever directory is specified by `config.files.assets`.
|
|
3712
|
+
* The path is relative to the [base path](https://svelte.dev/docs/kit/configuration#paths), and can be used with [`asset(...)`](https://svelte.dev/docs/kit/$app-paths#asset).
|
|
3678
3713
|
*/
|
|
3679
|
-
export const
|
|
3714
|
+
export const assets: Array<{ path: import('$app/types').AssetPath }>;
|
|
3680
3715
|
/**
|
|
3681
|
-
* An array of
|
|
3716
|
+
* An array of `{ path: Path }` objects representing prerendered pages and endpoints, relative to the [base path](https://svelte.dev/docs/kit/configuration#paths).
|
|
3682
3717
|
* During development, this is an empty array.
|
|
3683
3718
|
*/
|
|
3684
|
-
export const prerendered:
|
|
3719
|
+
export const prerendered: Array<{ path: import('$app/types').Path }>;
|
|
3685
3720
|
/**
|
|
3686
|
-
*
|
|
3721
|
+
* An array of objects with an `id` property representing the routes in your app.
|
|
3687
3722
|
*/
|
|
3688
|
-
export const
|
|
3723
|
+
export const routes: Array<{ id: import('$app/types').RouteId }>;
|
|
3689
3724
|
}
|
|
3690
3725
|
|
|
3691
3726
|
/**
|
|
@@ -3702,9 +3737,9 @@ declare module '$app/types' {
|
|
|
3702
3737
|
RouteId(): string;
|
|
3703
3738
|
RouteParams(): Record<string, Record<string, string>>;
|
|
3704
3739
|
LayoutParams(): Record<string, Record<string, string>>;
|
|
3705
|
-
|
|
3740
|
+
Path(): string;
|
|
3706
3741
|
ResolvedPathname(): string;
|
|
3707
|
-
|
|
3742
|
+
AssetPath(): string;
|
|
3708
3743
|
}
|
|
3709
3744
|
|
|
3710
3745
|
/**
|
|
@@ -3732,27 +3767,24 @@ declare module '$app/types' {
|
|
|
3732
3767
|
: Record<string, never>;
|
|
3733
3768
|
|
|
3734
3769
|
/**
|
|
3735
|
-
* A union of all valid
|
|
3770
|
+
* A union of all valid paths in your app, relative to the `base` path.
|
|
3736
3771
|
*/
|
|
3737
|
-
export type
|
|
3772
|
+
export type Path = ReturnType<AppTypes['Path']>;
|
|
3738
3773
|
|
|
3739
3774
|
/**
|
|
3740
|
-
* `
|
|
3775
|
+
* `Path`, but possibly suffixed with a search string and/or hash.
|
|
3741
3776
|
*/
|
|
3742
|
-
export type PathnameWithSearchOrHash =
|
|
3743
|
-
| Pathname
|
|
3744
|
-
| `${Pathname}?${string}`
|
|
3745
|
-
| `${Pathname}#${string}`;
|
|
3777
|
+
export type PathnameWithSearchOrHash = Path | `${Path}?${string}` | `${Path}#${string}`;
|
|
3746
3778
|
|
|
3747
3779
|
/**
|
|
3748
|
-
* `
|
|
3780
|
+
* `Path`, but prefixed with a base path. Used for `page.url.pathname`.
|
|
3749
3781
|
*/
|
|
3750
3782
|
export type ResolvedPathname = ReturnType<AppTypes['ResolvedPathname']>;
|
|
3751
3783
|
|
|
3752
3784
|
/**
|
|
3753
|
-
* A union of all the filenames of assets contained in your `static` directory.
|
|
3785
|
+
* A union of all the filenames of assets contained in your `static` directory, relative to the `base` path.
|
|
3754
3786
|
*/
|
|
3755
|
-
export type
|
|
3787
|
+
export type AssetPath = ReturnType<AppTypes['AssetPath']>;
|
|
3756
3788
|
}
|
|
3757
3789
|
|
|
3758
3790
|
//# sourceMappingURL=index.d.ts.map
|