@sveltejs/kit 3.0.0-next.10 → 3.0.0-next.11
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/constants.js +2 -0
- package/src/core/adapt/builder.js +3 -6
- package/src/core/config/index.js +6 -1
- package/src/core/config/options.js +11 -69
- 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/write_server.js +2 -2
- 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/params.js +9 -4
- package/src/exports/public.d.ts +41 -20
- package/src/exports/vite/dev/index.js +50 -6
- package/src/exports/vite/index.js +130 -125
- package/src/exports/vite/module_ids.js +0 -2
- package/src/exports/vite/preview/index.js +3 -2
- package/src/exports/vite/utils.js +20 -0
- package/src/runtime/app/paths/server.js +1 -1
- package/src/runtime/app/server/index.js +1 -1
- package/src/runtime/app/server/remote/query.js +1 -1
- package/src/runtime/client/ndjson.js +1 -1
- package/src/runtime/client/stream.js +3 -2
- package/src/runtime/server/data/index.js +1 -1
- 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 +2 -1
- 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 +3 -7
- package/src/runtime/server/page/respond_with_error.js +6 -5
- package/src/runtime/server/{remote.js → remote-functions.js} +1 -1
- package/src/runtime/server/respond.js +3 -7
- package/src/runtime/server/sourcemaps.js +183 -0
- package/src/runtime/server/utils.js +2 -157
- package/src/types/ambient-private.d.ts +2 -0
- package/src/types/global-private.d.ts +0 -5
- package/src/types/internal.d.ts +6 -6
- 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/version.js +1 -1
- package/types/index.d.ts +72 -22
- package/types/index.d.ts.map +3 -1
- package/src/runtime/shared-server.js +0 -7
package/src/types/internal.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export interface ServerInternalModule {
|
|
|
47
47
|
set_prerendering(): void;
|
|
48
48
|
set_read_implementation(implementation: (path: string) => ReadableStream): void;
|
|
49
49
|
set_version(version: string): void;
|
|
50
|
-
set_fix_stack_trace(fix_stack_trace: (error:
|
|
50
|
+
set_fix_stack_trace(fix_stack_trace: (error: Error) => void): void;
|
|
51
51
|
get_hooks: () => Promise<Record<string, any>>;
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -394,7 +394,7 @@ export interface ServerErrorNode {
|
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
export interface ServerMetadataRoute {
|
|
397
|
-
config: any
|
|
397
|
+
config: Record<string, any>;
|
|
398
398
|
api: {
|
|
399
399
|
methods: Array<HttpMethod | '*'>;
|
|
400
400
|
};
|
|
@@ -426,7 +426,7 @@ export interface UniversalNode {
|
|
|
426
426
|
ssr?: boolean;
|
|
427
427
|
csr?: boolean;
|
|
428
428
|
trailingSlash?: TrailingSlash;
|
|
429
|
-
config?: any
|
|
429
|
+
config?: Record<string, any>;
|
|
430
430
|
entries?: PrerenderEntryGenerator;
|
|
431
431
|
}
|
|
432
432
|
|
|
@@ -437,7 +437,7 @@ export interface ServerNode {
|
|
|
437
437
|
csr?: boolean;
|
|
438
438
|
trailingSlash?: TrailingSlash;
|
|
439
439
|
actions?: Actions;
|
|
440
|
-
config?: any
|
|
440
|
+
config?: Record<string, any>;
|
|
441
441
|
entries?: PrerenderEntryGenerator;
|
|
442
442
|
}
|
|
443
443
|
|
|
@@ -511,7 +511,7 @@ export type RemotePrerenderInputsGenerator<Input = any> = () => MaybePromise<Inp
|
|
|
511
511
|
export type SSREndpoint = Partial<Record<HttpMethod, RequestHandler>> & {
|
|
512
512
|
prerender?: PrerenderOption;
|
|
513
513
|
trailingSlash?: TrailingSlash;
|
|
514
|
-
config?: any
|
|
514
|
+
config?: Record<string, any>;
|
|
515
515
|
entries?: PrerenderEntryGenerator;
|
|
516
516
|
fallback?: RequestHandler;
|
|
517
517
|
};
|
|
@@ -560,7 +560,7 @@ export interface SSRState {
|
|
|
560
560
|
*/
|
|
561
561
|
before_handle?: (
|
|
562
562
|
event: RequestEvent,
|
|
563
|
-
config: any
|
|
563
|
+
config: Record<string, any>,
|
|
564
564
|
prerender: PrerenderOption,
|
|
565
565
|
handle: () => Promise<Response>
|
|
566
566
|
) => Promise<Response>;
|
package/src/types/private.d.ts
CHANGED
|
@@ -159,10 +159,18 @@ export type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' |
|
|
|
159
159
|
export interface Logger {
|
|
160
160
|
(msg: string): void;
|
|
161
161
|
success(msg: string): void;
|
|
162
|
+
/** Print a bold red message to stderr */
|
|
162
163
|
error(msg: string): void;
|
|
164
|
+
/** Print a bold yellow message to stderr */
|
|
163
165
|
warn(msg: string): void;
|
|
166
|
+
/** Print faded text to stdout if `verbose === true` */
|
|
164
167
|
minor(msg: string): void;
|
|
168
|
+
/** Print to stdout if `verbose === true` */
|
|
165
169
|
info(msg: string): void;
|
|
170
|
+
/** Print to stderr without formatting */
|
|
171
|
+
err(msg: string): void;
|
|
172
|
+
/** Print a bold red message, followed by a stack trace for each error (following `.cause` chains) */
|
|
173
|
+
prettyError(error: unknown, caller?: string): void;
|
|
166
174
|
}
|
|
167
175
|
|
|
168
176
|
export type MaybePromise<T> = T | Promise<T>;
|
package/src/utils/escape.js
CHANGED
|
@@ -21,24 +21,12 @@ const escape_html_dict = {
|
|
|
21
21
|
'<': '<'
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// we match it so that we can match unpaired low surrogates in the same pass
|
|
28
|
-
// TODO: use lookbehind assertions once they are widely supported: (?<![\ud800-udbff])[\udc00-\udfff]
|
|
29
|
-
'[\\ud800-\\udbff][\\udc00-\\udfff]|' +
|
|
30
|
-
// unpaired low surrogate (see previous match)
|
|
31
|
-
'[\\udc00-\\udfff]';
|
|
24
|
+
// `\p{Surrogate}` only matches unpaired surrogates with the `u` flag (a pair is one code point)
|
|
25
|
+
/** @param {Record<string, string>} dict */
|
|
26
|
+
const escape_regex = (dict) => new RegExp(`[${Object.keys(dict).join('')}]|\\p{Surrogate}`, 'gu');
|
|
32
27
|
|
|
33
|
-
const escape_html_attr_regex =
|
|
34
|
-
|
|
35
|
-
'g'
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const escape_html_regex = new RegExp(
|
|
39
|
-
`[${Object.keys(escape_html_dict).join('')}]|` + surrogates,
|
|
40
|
-
'g'
|
|
41
|
-
);
|
|
28
|
+
const escape_html_attr_regex = escape_regex(escape_html_attr_dict);
|
|
29
|
+
const escape_html_regex = escape_regex(escape_html_dict);
|
|
42
30
|
|
|
43
31
|
/**
|
|
44
32
|
* Escapes unpaired surrogates (which are allowed in js strings but invalid in HTML) and
|
|
@@ -51,14 +39,10 @@ const escape_html_regex = new RegExp(
|
|
|
51
39
|
*/
|
|
52
40
|
export function escape_html(str, is_attr) {
|
|
53
41
|
const dict = is_attr ? escape_html_attr_dict : escape_html_dict;
|
|
54
|
-
const escaped_str = str.replace(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return dict[match] ?? `&#${match.charCodeAt(0)};`;
|
|
61
|
-
});
|
|
42
|
+
const escaped_str = str.replace(
|
|
43
|
+
is_attr ? escape_html_attr_regex : escape_html_regex,
|
|
44
|
+
(match) => dict[match] ?? `&#${match.charCodeAt(0)};`
|
|
45
|
+
);
|
|
62
46
|
|
|
63
47
|
return escaped_str;
|
|
64
48
|
}
|
package/src/utils/features.js
CHANGED
package/src/utils/fork.js
CHANGED
|
@@ -38,7 +38,8 @@ export function forked(module, callback) {
|
|
|
38
38
|
const worker = new Worker(fileURLToPath(module), {
|
|
39
39
|
env: {
|
|
40
40
|
...process.env,
|
|
41
|
-
SVELTEKIT_FORK: 'true'
|
|
41
|
+
SVELTEKIT_FORK: 'true',
|
|
42
|
+
FORCE_COLOR: '1'
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
45
|
|
|
@@ -60,9 +61,13 @@ export function forked(module, callback) {
|
|
|
60
61
|
}
|
|
61
62
|
);
|
|
62
63
|
|
|
64
|
+
worker.once('error', reject);
|
|
65
|
+
|
|
63
66
|
worker.on('exit', (code) => {
|
|
64
67
|
if (code) {
|
|
65
|
-
|
|
68
|
+
const error = new Error(`Failed with code ${code}`);
|
|
69
|
+
error.stack = error.message;
|
|
70
|
+
reject(error);
|
|
66
71
|
}
|
|
67
72
|
});
|
|
68
73
|
});
|
package/src/utils/page_nodes.js
CHANGED
|
@@ -69,7 +69,7 @@ export class PageNodes {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
get_config() {
|
|
72
|
-
/** @type {any} */
|
|
72
|
+
/** @type {Record<string, any>} */
|
|
73
73
|
let current = {};
|
|
74
74
|
|
|
75
75
|
for (const node of this.data) {
|
|
@@ -77,13 +77,11 @@ export class PageNodes {
|
|
|
77
77
|
|
|
78
78
|
current = {
|
|
79
79
|
...current,
|
|
80
|
-
|
|
81
|
-
...node?.universal?.config
|
|
82
|
-
...node?.server?.config
|
|
80
|
+
...node?.server?.config,
|
|
81
|
+
...node?.universal?.config
|
|
83
82
|
};
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
// TODO 3.0 always return `current`? then we can get rid of `?? {}` in other places
|
|
87
85
|
return Object.keys(current).length ? current : undefined;
|
|
88
86
|
}
|
|
89
87
|
|
package/src/version.js
CHANGED
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.
|
|
@@ -407,7 +407,7 @@ declare module '@sveltejs/kit' {
|
|
|
407
407
|
*
|
|
408
408
|
* > [!NOTE] When `mode` is `'auto'`, SvelteKit will use nonces for dynamically rendered pages and hashes for prerendered pages. Using nonces with prerendered pages is insecure and therefore forbidden.
|
|
409
409
|
*
|
|
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#
|
|
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#handle) to roll your own CSP.
|
|
411
411
|
*/
|
|
412
412
|
csp?: {
|
|
413
413
|
/**
|
|
@@ -805,8 +805,10 @@ declare module '@sveltejs/kit' {
|
|
|
805
805
|
* This has several advantages:
|
|
806
806
|
* - The client does not need to load the routing manifest upfront, which can lead to faster initial page loads
|
|
807
807
|
* - The list of routes is hidden from public view
|
|
808
|
-
* - The server has an opportunity to intercept each navigation (for example through a
|
|
809
|
-
|
|
808
|
+
* - 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
|
|
809
|
+
*
|
|
810
|
+
* 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.
|
|
811
|
+
*
|
|
810
812
|
* 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
813
|
*
|
|
812
814
|
* > [!NOTE] When using server-side route resolution and prerendering, the resolution is prerendered along with the route itself.
|
|
@@ -848,7 +850,7 @@ declare module '@sveltejs/kit' {
|
|
|
848
850
|
*/
|
|
849
851
|
tracing?: {
|
|
850
852
|
/**
|
|
851
|
-
* Enables server-side [OpenTelemetry](https://opentelemetry.io/) span emission for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#
|
|
853
|
+
* 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
854
|
* @default false
|
|
853
855
|
*/
|
|
854
856
|
server?: boolean;
|
|
@@ -919,7 +921,7 @@ declare module '@sveltejs/kit' {
|
|
|
919
921
|
}
|
|
920
922
|
|
|
921
923
|
/**
|
|
922
|
-
* The [`handle`](https://svelte.dev/docs/kit/hooks#
|
|
924
|
+
* 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
925
|
* determines the [response](https://svelte.dev/docs/kit/web-standards#Fetch-APIs-Response).
|
|
924
926
|
* It receives an `event` object representing the request and a function called `resolve`, which renders the route and generates a `Response`.
|
|
925
927
|
* This allows you to modify response headers or bodies, or bypass SvelteKit entirely (for implementing routes programmatically, for example).
|
|
@@ -930,7 +932,7 @@ declare module '@sveltejs/kit' {
|
|
|
930
932
|
}) => MaybePromise<Response>;
|
|
931
933
|
|
|
932
934
|
/**
|
|
933
|
-
* The server-side [`handleError`](https://svelte.dev/docs/kit/hooks#
|
|
935
|
+
* 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
936
|
*
|
|
935
937
|
* If an unexpected error is thrown during loading or rendering, this function will be called with the error and the event.
|
|
936
938
|
* Make sure that this function _never_ throws an error.
|
|
@@ -946,7 +948,7 @@ declare module '@sveltejs/kit' {
|
|
|
946
948
|
}) => MaybePromise<void | AppErrorWithOptionalStatus>;
|
|
947
949
|
|
|
948
950
|
/**
|
|
949
|
-
* The [`handleValidationError`](https://svelte.dev/docs/kit/hooks#
|
|
951
|
+
* The [`handleValidationError`](https://svelte.dev/docs/kit/hooks#handleValidationError) hook runs when the argument to a remote function fails validation.
|
|
950
952
|
*
|
|
951
953
|
* It will be called with the validation issues and the event, and must return an object shape that matches `App.Error`.
|
|
952
954
|
*/
|
|
@@ -954,7 +956,7 @@ declare module '@sveltejs/kit' {
|
|
|
954
956
|
(input: { issues: Issue[]; event: RequestEvent }) => MaybePromise<AppErrorWithOptionalStatus>;
|
|
955
957
|
|
|
956
958
|
/**
|
|
957
|
-
* The client-side [`handleError`](https://svelte.dev/docs/kit/hooks#
|
|
959
|
+
* The client-side [`handleError`](https://svelte.dev/docs/kit/hooks#handleError) hook runs when an unexpected error is thrown while navigating.
|
|
958
960
|
*
|
|
959
961
|
* If an unexpected error is thrown during loading or the following render, this function will be called with the error and the event.
|
|
960
962
|
* Make sure that this function _never_ throws an error.
|
|
@@ -970,7 +972,7 @@ declare module '@sveltejs/kit' {
|
|
|
970
972
|
}) => MaybePromise<void | AppErrorWithOptionalStatus>;
|
|
971
973
|
|
|
972
974
|
/**
|
|
973
|
-
* The [`handleFetch`](https://svelte.dev/docs/kit/hooks#
|
|
975
|
+
* 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
976
|
*/
|
|
975
977
|
export type HandleFetch = (input: {
|
|
976
978
|
event: RequestEvent;
|
|
@@ -979,25 +981,25 @@ declare module '@sveltejs/kit' {
|
|
|
979
981
|
}) => MaybePromise<Response>;
|
|
980
982
|
|
|
981
983
|
/**
|
|
982
|
-
* The [`init`](https://svelte.dev/docs/kit/hooks#
|
|
984
|
+
* The [`init`](https://svelte.dev/docs/kit/hooks#init) will be invoked before the server responds to its first request
|
|
983
985
|
* @since 2.10.0
|
|
984
986
|
*/
|
|
985
987
|
export type ServerInit = () => MaybePromise<void>;
|
|
986
988
|
|
|
987
989
|
/**
|
|
988
|
-
* The [`init`](https://svelte.dev/docs/kit/hooks#
|
|
990
|
+
* The [`init`](https://svelte.dev/docs/kit/hooks#init) will be invoked once the app starts in the browser
|
|
989
991
|
* @since 2.10.0
|
|
990
992
|
*/
|
|
991
993
|
export type ClientInit = () => MaybePromise<void>;
|
|
992
994
|
|
|
993
995
|
/**
|
|
994
|
-
* The [`reroute`](https://svelte.dev/docs/kit/hooks#
|
|
996
|
+
* 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
997
|
* @since 2.3.0
|
|
996
998
|
*/
|
|
997
999
|
export type Reroute = (event: { url: URL; fetch: typeof fetch }) => MaybePromise<void | string>;
|
|
998
1000
|
|
|
999
1001
|
/**
|
|
1000
|
-
* The [`transport`](https://svelte.dev/docs/kit/hooks#
|
|
1002
|
+
* The [`transport`](https://svelte.dev/docs/kit/hooks#transport) hook allows you to transport custom types across the server/client boundary.
|
|
1001
1003
|
*
|
|
1002
1004
|
* 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
1005
|
*
|
|
@@ -1023,7 +1025,7 @@ declare module '@sveltejs/kit' {
|
|
|
1023
1025
|
export type Transport = Record<string, Transporter>;
|
|
1024
1026
|
|
|
1025
1027
|
/**
|
|
1026
|
-
* A member of the [`transport`](https://svelte.dev/docs/kit/hooks#
|
|
1028
|
+
* A member of the [`transport`](https://svelte.dev/docs/kit/hooks#transport) hook.
|
|
1027
1029
|
*/
|
|
1028
1030
|
export interface Transporter<
|
|
1029
1031
|
T = any,
|
|
@@ -1061,7 +1063,7 @@ declare module '@sveltejs/kit' {
|
|
|
1061
1063
|
* - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.
|
|
1062
1064
|
* - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).
|
|
1063
1065
|
* - 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#
|
|
1066
|
+
* - 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
1067
|
* - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.
|
|
1066
1068
|
*
|
|
1067
1069
|
* You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies)
|
|
@@ -1566,7 +1568,7 @@ declare module '@sveltejs/kit' {
|
|
|
1566
1568
|
* - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.
|
|
1567
1569
|
* - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).
|
|
1568
1570
|
* - 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#
|
|
1571
|
+
* - 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
1572
|
* - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.
|
|
1571
1573
|
*
|
|
1572
1574
|
* You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies).
|
|
@@ -1577,7 +1579,7 @@ declare module '@sveltejs/kit' {
|
|
|
1577
1579
|
*/
|
|
1578
1580
|
getClientAddress: () => string;
|
|
1579
1581
|
/**
|
|
1580
|
-
* Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#
|
|
1582
|
+
* Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#handle).
|
|
1581
1583
|
*/
|
|
1582
1584
|
locals: App.Locals;
|
|
1583
1585
|
/**
|
|
@@ -2411,17 +2413,36 @@ declare module '@sveltejs/kit' {
|
|
|
2411
2413
|
static?: boolean;
|
|
2412
2414
|
/**
|
|
2413
2415
|
* A [Standard Schema](https://standardschema.dev/) validator that is applied to the value when the app starts.
|
|
2416
|
+
* Alternatively, a function that returns the (possibly transformed) value, or throws an error explaining
|
|
2417
|
+
* the problem. Returning `undefined` is valid, so a function can describe an optional variable.
|
|
2414
2418
|
* The validator can output any value — not necessarily a string — but public, non-static values must be
|
|
2415
2419
|
* serializable by [devalue](https://github.com/sveltejs/devalue) so that they can be sent to the browser.
|
|
2416
2420
|
*
|
|
2417
|
-
* If omitted, the value must be
|
|
2421
|
+
* If omitted, the value must be set, but may be an empty string.
|
|
2418
2422
|
*/
|
|
2419
|
-
schema?: StandardSchemaV1<string | undefined, T
|
|
2423
|
+
schema?: StandardSchemaV1<string | undefined, T> | ((value: string | undefined) => T | undefined);
|
|
2420
2424
|
/**
|
|
2421
2425
|
* A description of the variable that will be used for inline documentation on hover.
|
|
2422
2426
|
*/
|
|
2423
2427
|
description?: string;
|
|
2424
2428
|
}
|
|
2429
|
+
|
|
2430
|
+
/**
|
|
2431
|
+
* The return type of [`defineEnvVars`](https://svelte.dev/docs/kit/@sveltejs-kit-env#defineEnvVars).
|
|
2432
|
+
*/
|
|
2433
|
+
export type DefinedEnvVars<T extends Record<string, EnvVarConfig<any>>> = {
|
|
2434
|
+
readonly [K in keyof T]: EnvVarEntry<T[K]>;
|
|
2435
|
+
};
|
|
2436
|
+
|
|
2437
|
+
/**
|
|
2438
|
+
* Normalizes an environment variable config's schema (standard schema or function) to standard schema.
|
|
2439
|
+
*/
|
|
2440
|
+
type EnvVarEntry<C extends EnvVarConfig<any>> =
|
|
2441
|
+
C['schema'] extends StandardSchemaV1<any, any>
|
|
2442
|
+
? C
|
|
2443
|
+
: C['schema'] extends (value: any) => infer R
|
|
2444
|
+
? Omit<C, 'schema'> & { schema: StandardSchemaV1<string | undefined, R> }
|
|
2445
|
+
: C;
|
|
2425
2446
|
interface AdapterEntry {
|
|
2426
2447
|
/**
|
|
2427
2448
|
* A string that uniquely identifies an HTTP service (e.g. serverless function) and is used for deduplication.
|
|
@@ -2577,10 +2598,18 @@ declare module '@sveltejs/kit' {
|
|
|
2577
2598
|
interface Logger {
|
|
2578
2599
|
(msg: string): void;
|
|
2579
2600
|
success(msg: string): void;
|
|
2601
|
+
/** Print a bold red message to stderr */
|
|
2580
2602
|
error(msg: string): void;
|
|
2603
|
+
/** Print a bold yellow message to stderr */
|
|
2581
2604
|
warn(msg: string): void;
|
|
2605
|
+
/** Print faded text to stdout if `verbose === true` */
|
|
2582
2606
|
minor(msg: string): void;
|
|
2607
|
+
/** Print to stdout if `verbose === true` */
|
|
2583
2608
|
info(msg: string): void;
|
|
2609
|
+
/** Print to stderr without formatting */
|
|
2610
|
+
err(msg: string): void;
|
|
2611
|
+
/** Print a bold red message, followed by a stack trace for each error (following `.cause` chains) */
|
|
2612
|
+
prettyError(error: unknown, caller?: string): void;
|
|
2584
2613
|
}
|
|
2585
2614
|
|
|
2586
2615
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -2861,12 +2890,33 @@ declare module '@sveltejs/kit' {
|
|
|
2861
2890
|
}
|
|
2862
2891
|
|
|
2863
2892
|
declare module '@sveltejs/kit/env' {
|
|
2864
|
-
import type { EnvVarConfig } from '@sveltejs/kit';
|
|
2893
|
+
import type { EnvVarConfig, DefinedEnvVars } from '@sveltejs/kit';
|
|
2865
2894
|
/**
|
|
2866
2895
|
* Utility for defining [environment variables](https://svelte.dev/docs/kit/environment-variables),
|
|
2867
2896
|
* which are made available via `$app/env/public` and `$app/env/private`.
|
|
2897
|
+
*
|
|
2898
|
+
* @example
|
|
2899
|
+
* ```js
|
|
2900
|
+
* import { defineEnvVars } from '@sveltejs/kit/env';
|
|
2901
|
+
* import * as v from 'valibot';
|
|
2902
|
+
*
|
|
2903
|
+
* export const variables = defineEnvVars({
|
|
2904
|
+
* API_URL: {
|
|
2905
|
+
* schema: v.pipe(v.string(), v.url())
|
|
2906
|
+
* },
|
|
2907
|
+
* PORT: {
|
|
2908
|
+
* schema: (value) => {
|
|
2909
|
+
* if (value === undefined) return 3000;
|
|
2910
|
+
* const port = Number(value);
|
|
2911
|
+
* if (!Number.isInteger(port)) throw new Error('PORT must be an integer');
|
|
2912
|
+
* return port;
|
|
2913
|
+
* }
|
|
2914
|
+
* }
|
|
2915
|
+
* });
|
|
2916
|
+
* ```
|
|
2917
|
+
*
|
|
2868
2918
|
* */
|
|
2869
|
-
export function defineEnvVars<T extends Record<string, EnvVarConfig<any>>>(variables: T): T
|
|
2919
|
+
export function defineEnvVars<T extends Record<string, EnvVarConfig<any>>>(variables: T): DefinedEnvVars<T>;
|
|
2870
2920
|
|
|
2871
2921
|
export {};
|
|
2872
2922
|
}
|
package/types/index.d.ts.map
CHANGED
|
@@ -108,6 +108,8 @@
|
|
|
108
108
|
"RemoteQueryFunction",
|
|
109
109
|
"RemoteLiveQueryFunction",
|
|
110
110
|
"EnvVarConfig",
|
|
111
|
+
"DefinedEnvVars",
|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