@sveltejs/kit 3.0.0-next.1 → 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 +33 -21
- package/src/constants.js +2 -0
- package/src/core/adapt/builder.js +32 -49
- package/src/core/adapt/index.js +1 -4
- package/src/core/config/index.js +137 -71
- package/src/core/config/options.js +236 -244
- package/src/core/config/types.d.ts +1 -1
- package/src/core/env.js +121 -5
- package/src/core/generate_manifest/index.js +12 -15
- package/src/core/postbuild/analyse.js +7 -19
- package/src/core/postbuild/crawl.js +22 -6
- package/src/core/postbuild/fallback.js +2 -1
- package/src/core/postbuild/prerender.js +114 -48
- package/src/core/postbuild/queue.js +2 -1
- package/src/core/sync/create_manifest_data/index.js +53 -50
- package/src/core/sync/sync.js +0 -2
- package/src/core/sync/write_client_manifest.js +8 -15
- package/src/core/sync/write_env.js +2 -1
- package/src/core/sync/write_non_ambient.js +12 -9
- package/src/core/sync/write_server.js +14 -15
- package/src/core/sync/write_tsconfig.js +16 -8
- package/src/core/sync/write_tsconfig_test/package.json +7 -0
- package/src/core/sync/write_types/index.js +28 -24
- package/src/core/utils.js +30 -5
- package/src/exports/env/index.js +77 -0
- package/src/exports/hooks/index.js +3 -9
- package/src/exports/hooks/sequence.js +3 -2
- package/src/exports/index.js +35 -13
- package/src/exports/internal/client.js +5 -0
- package/src/exports/internal/env.js +8 -5
- package/src/exports/internal/index.js +1 -90
- package/src/exports/internal/{event.js → server/event.js} +1 -2
- package/src/exports/internal/server/index.js +33 -0
- package/src/exports/internal/shared.js +89 -0
- package/src/exports/node/index.js +62 -15
- package/src/exports/params.js +68 -0
- package/src/exports/public.d.ts +363 -189
- package/src/exports/url.js +86 -0
- package/src/exports/vite/build/build_server.js +53 -59
- package/src/exports/vite/build/remote.js +18 -11
- package/src/exports/vite/build/utils.js +0 -8
- package/src/exports/vite/dev/index.js +92 -50
- package/src/exports/vite/index.js +903 -681
- package/src/exports/vite/module_ids.js +0 -2
- package/src/exports/vite/preview/index.js +32 -24
- package/src/exports/vite/static_analysis/index.js +2 -4
- package/src/exports/vite/static_analysis/types.d.ts +14 -0
- package/src/exports/vite/utils.js +40 -35
- package/src/runtime/app/env/internal.js +4 -4
- package/src/runtime/app/env/types.d.ts +1 -1
- package/src/runtime/app/environment/index.js +3 -3
- package/src/runtime/app/forms.js +24 -7
- package/src/runtime/app/paths/client.js +4 -10
- package/src/runtime/app/paths/internal/client.js +4 -2
- package/src/runtime/app/paths/internal/server.js +2 -23
- package/src/runtime/app/paths/public.d.ts +0 -28
- package/src/runtime/app/paths/server.js +10 -6
- package/src/runtime/app/server/index.js +1 -1
- package/src/runtime/app/server/remote/command.js +0 -3
- package/src/runtime/app/server/remote/form.js +27 -15
- package/src/runtime/app/server/remote/prerender.js +29 -36
- package/src/runtime/app/server/remote/query.js +101 -99
- package/src/runtime/app/server/remote/requested.js +22 -14
- package/src/runtime/app/server/remote/shared.js +30 -26
- package/src/runtime/app/state/client.js +1 -2
- package/src/runtime/app/stores.js +13 -76
- package/src/runtime/client/bundle.js +1 -1
- package/src/runtime/client/client-entry.js +3 -0
- package/src/runtime/client/client.js +411 -318
- package/src/runtime/client/entry.js +24 -3
- package/src/runtime/client/fetcher.js +3 -2
- package/src/runtime/client/ndjson.js +6 -33
- package/src/runtime/client/payload.js +17 -0
- package/src/runtime/client/remote-functions/cache.svelte.js +3 -1
- package/src/runtime/client/remote-functions/command.svelte.js +7 -32
- package/src/runtime/client/remote-functions/form.svelte.js +183 -112
- package/src/runtime/client/remote-functions/prerender.svelte.js +29 -8
- package/src/runtime/client/remote-functions/query/index.js +7 -14
- package/src/runtime/client/remote-functions/query/instance.svelte.js +63 -18
- package/src/runtime/client/remote-functions/query/proxy.js +3 -3
- package/src/runtime/client/remote-functions/query-batch.svelte.js +60 -68
- package/src/runtime/client/remote-functions/query-live/instance.svelte.js +60 -18
- package/src/runtime/client/remote-functions/query-live/iterator.js +36 -55
- package/src/runtime/client/remote-functions/shared.svelte.js +88 -62
- package/src/runtime/client/sse.js +32 -0
- package/src/runtime/client/state.svelte.js +65 -49
- package/src/runtime/client/stream.js +39 -0
- package/src/runtime/client/types.d.ts +11 -7
- package/src/runtime/client/utils.js +0 -96
- package/src/runtime/components/root.svelte +66 -0
- package/src/runtime/env/dynamic/private.js +7 -0
- package/src/runtime/env/dynamic/public.js +7 -0
- package/src/runtime/env/static/private.js +6 -0
- package/src/runtime/env/static/public.js +6 -0
- package/src/runtime/form-utils.js +100 -22
- package/src/runtime/server/cookie.js +69 -52
- package/src/runtime/server/csrf.js +65 -0
- package/src/runtime/server/data/index.js +15 -19
- package/src/runtime/server/env_module.js +0 -5
- package/src/runtime/server/errors.js +135 -0
- package/src/runtime/server/fetch.js +1 -1
- package/src/runtime/server/index.js +22 -12
- package/src/runtime/server/internal.js +25 -0
- package/src/runtime/server/page/actions.js +43 -27
- package/src/runtime/server/page/data_serializer.js +10 -10
- package/src/runtime/server/page/index.js +12 -17
- package/src/runtime/server/page/load_data.js +2 -2
- package/src/runtime/server/page/render.js +114 -193
- package/src/runtime/server/page/respond_with_error.js +11 -11
- package/src/runtime/server/page/server_routing.js +27 -18
- package/src/runtime/server/remote-functions.js +596 -0
- package/src/runtime/server/respond.js +100 -68
- package/src/runtime/server/sourcemaps.js +183 -0
- package/src/runtime/server/utils.js +2 -134
- package/src/runtime/shared.js +83 -13
- package/src/runtime/telemetry/otel.js +1 -1
- package/src/runtime/types.d.ts +8 -0
- package/src/types/ambient-private.d.ts +2 -0
- package/src/types/ambient.d.ts +10 -5
- package/src/types/global-private.d.ts +13 -25
- package/src/types/internal.d.ts +95 -80
- package/src/types/private.d.ts +41 -1
- package/src/utils/error.js +24 -4
- package/src/utils/escape.js +9 -25
- package/src/utils/features.js +1 -1
- package/src/utils/fork.js +7 -2
- package/src/utils/import.js +6 -1
- package/src/utils/imports.js +83 -0
- package/src/utils/mime.js +9 -0
- package/src/utils/page_nodes.js +3 -5
- package/src/utils/params.js +66 -0
- package/src/utils/routing.js +90 -44
- package/src/utils/shared-iterator.js +5 -0
- package/src/utils/streaming.js +14 -4
- package/src/utils/url.js +20 -2
- package/src/version.js +1 -1
- package/types/index.d.ts +537 -557
- package/types/index.d.ts.map +24 -39
- package/src/core/sync/write_root.js +0 -148
- package/src/exports/internal/server.js +0 -22
- package/src/runtime/server/remote.js +0 -457
- package/src/runtime/shared-server.js +0 -7
- package/src/types/synthetic/$lib.md +0 -5
- /package/src/exports/internal/{remote-functions.js → server/remote-functions.js} +0 -0
package/src/runtime/shared.js
CHANGED
|
@@ -96,6 +96,8 @@ function to_sorted(value, clones) {
|
|
|
96
96
|
const remote_object = '__skrao';
|
|
97
97
|
const remote_map = '__skram';
|
|
98
98
|
const remote_set = '__skras';
|
|
99
|
+
const remote_file = '__skraf';
|
|
100
|
+
const remote_promise_guard = '__skrap';
|
|
99
101
|
const remote_regex_guard = '__skrag';
|
|
100
102
|
const remote_arg_marker = Symbol(remote_object);
|
|
101
103
|
|
|
@@ -107,13 +109,12 @@ const remote_arg_marker = Symbol(remote_object);
|
|
|
107
109
|
function create_remote_arg_reducers(transport, sort, remote_arg_clones) {
|
|
108
110
|
/** @type {Record<string, (value: unknown) => unknown>} */
|
|
109
111
|
const remote_fns_reducers = {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
(value)
|
|
113
|
-
|
|
114
|
-
throw new Error('Regular expressions are not valid remote function arguments');
|
|
115
|
-
}
|
|
112
|
+
/** @param {unknown} value */
|
|
113
|
+
[remote_regex_guard]: (value) => {
|
|
114
|
+
if (value instanceof RegExp) {
|
|
115
|
+
throw new Error('Regular expressions are not valid remote function arguments');
|
|
116
116
|
}
|
|
117
|
+
}
|
|
117
118
|
};
|
|
118
119
|
|
|
119
120
|
if (sort) {
|
|
@@ -229,6 +230,24 @@ function create_remote_arg_revivers(transport) {
|
|
|
229
230
|
}
|
|
230
231
|
|
|
231
232
|
return set;
|
|
233
|
+
},
|
|
234
|
+
/** @type {(value: any) => File} */
|
|
235
|
+
[remote_file]: (value) => {
|
|
236
|
+
if (
|
|
237
|
+
!value ||
|
|
238
|
+
typeof value !== 'object' ||
|
|
239
|
+
typeof value.name !== 'string' ||
|
|
240
|
+
typeof value.type !== 'string' ||
|
|
241
|
+
typeof value.size !== 'number' ||
|
|
242
|
+
typeof value.lastModified !== 'number' ||
|
|
243
|
+
!(value.data instanceof ArrayBuffer)
|
|
244
|
+
) {
|
|
245
|
+
throw new Error('Invalid data for File reviver');
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const { data, name, ...meta } = value;
|
|
249
|
+
|
|
250
|
+
return new File([data], name, meta);
|
|
232
251
|
}
|
|
233
252
|
};
|
|
234
253
|
|
|
@@ -249,18 +268,69 @@ function create_remote_arg_revivers(transport) {
|
|
|
249
268
|
* it is both a valid URL and a valid file name (necessary for prerendering).
|
|
250
269
|
* @param {any} value
|
|
251
270
|
* @param {Transport} transport
|
|
252
|
-
* @param {boolean} [sort]
|
|
253
271
|
*/
|
|
254
|
-
export function stringify_remote_arg(value, transport
|
|
272
|
+
export function stringify_remote_arg(value, transport) {
|
|
255
273
|
if (value === undefined) return '';
|
|
256
274
|
|
|
257
275
|
// If people hit file/url size limits, we can look into using something like compress_and_encode_text from svelte.dev beyond a certain size
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
276
|
+
const json = devalue.stringify(value, create_remote_arg_reducers(transport, true, new Map()));
|
|
277
|
+
|
|
278
|
+
return url_friendly_base64_encode(json);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Stringifies command arguments, including `File` objects.
|
|
283
|
+
* @param {any} value
|
|
284
|
+
* @param {Transport} transport
|
|
285
|
+
*/
|
|
286
|
+
export async function stringify_command_arg(value, transport) {
|
|
287
|
+
if (value === undefined) return '';
|
|
288
|
+
|
|
289
|
+
const reducers = create_remote_arg_reducers(transport, false, new Map());
|
|
262
290
|
|
|
263
|
-
|
|
291
|
+
/** @type {Set<Promise<any>>} */
|
|
292
|
+
const allowed_promises = new Set();
|
|
293
|
+
|
|
294
|
+
/** @param {any} value */
|
|
295
|
+
reducers[remote_file] = (value) => {
|
|
296
|
+
if (value instanceof File) {
|
|
297
|
+
const promise = value.arrayBuffer().then((data) => ({
|
|
298
|
+
data,
|
|
299
|
+
lastModified: value.lastModified,
|
|
300
|
+
name: value.name,
|
|
301
|
+
size: value.size,
|
|
302
|
+
type: value.type
|
|
303
|
+
}));
|
|
304
|
+
|
|
305
|
+
allowed_promises.add(promise);
|
|
306
|
+
|
|
307
|
+
return promise;
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
// we don't want to allow arbitrary promises, because they won't
|
|
312
|
+
// show up as promises on the other side. this is something
|
|
313
|
+
// we could potentially change in future. stringifyAsync
|
|
314
|
+
// will await them, so we need to explicitly deny them
|
|
315
|
+
/** @param {unknown} value */
|
|
316
|
+
reducers[remote_promise_guard] = (value) => {
|
|
317
|
+
if (value instanceof Promise && !allowed_promises.has(value)) {
|
|
318
|
+
throw new Error('Promises are not valid remote function arguments');
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
const json = await devalue.stringifyAsync(value, reducers);
|
|
323
|
+
|
|
324
|
+
return url_friendly_base64_encode(json);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Base64-encodes `string` in such a way that the result is safe to use
|
|
329
|
+
* as both a URI component and a filename
|
|
330
|
+
* @param {string} string
|
|
331
|
+
*/
|
|
332
|
+
function url_friendly_base64_encode(string) {
|
|
333
|
+
const bytes = text_encoder.encode(string);
|
|
264
334
|
return base64_encode(bytes).replaceAll('=', '').replaceAll('+', '-').replaceAll('/', '_');
|
|
265
335
|
}
|
|
266
336
|
|
|
@@ -15,7 +15,7 @@ if (__SVELTEKIT_SERVER_TRACING_ENABLED__) {
|
|
|
15
15
|
})
|
|
16
16
|
.catch(() => {
|
|
17
17
|
throw new Error(
|
|
18
|
-
'Tracing is enabled (see `
|
|
18
|
+
'Tracing is enabled (see the SvelteKit plugin `tracing.server` option in your vite.config.js), but `@opentelemetry/api` is not available. This error will likely resolve itself when you set up your tracing instrumentation in `instrumentation.server.js`. For more information, see https://svelte.dev/docs/kit/observability#opentelemetry-api'
|
|
19
19
|
);
|
|
20
20
|
});
|
|
21
21
|
}
|
|
@@ -13,8 +13,10 @@ declare module '__sveltekit/paths' {
|
|
|
13
13
|
declare module '__sveltekit/server' {
|
|
14
14
|
import { SSRManifest } from '@sveltejs/kit';
|
|
15
15
|
|
|
16
|
+
export let fix_stack_trace: (error: Error) => string;
|
|
16
17
|
export let manifest: SSRManifest;
|
|
17
18
|
export function read_implementation(path: string): ReadableStream;
|
|
19
|
+
export function set_fix_stack_trace(fn: (error: Error) => string): void;
|
|
18
20
|
export function set_manifest(manifest: SSRManifest): void;
|
|
19
21
|
export function set_read_implementation(fn: (path: string) => ReadableStream): void;
|
|
20
22
|
}
|
package/src/types/ambient.d.ts
CHANGED
|
@@ -25,29 +25,34 @@ declare namespace App {
|
|
|
25
25
|
* Defines the common shape of expected and unexpected errors. Expected errors are thrown using the `error` function. Unexpected errors are handled by the `handleError` hooks which should return this shape.
|
|
26
26
|
*/
|
|
27
27
|
export interface Error {
|
|
28
|
+
status: number;
|
|
28
29
|
message: string;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* The interface that defines `event.locals`, which can be accessed in server [hooks](https://svelte.dev/docs/kit/hooks) (`handle`, and `handleError`), server-only `load` functions, and `+server.js` files.
|
|
33
34
|
*/
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
34
36
|
export interface Locals {}
|
|
35
37
|
|
|
36
38
|
/**
|
|
37
|
-
* Defines the common shape of the [page.data state](https://svelte.dev/docs/kit/$app-state#page)
|
|
39
|
+
* Defines the common shape of the [page.data state](https://svelte.dev/docs/kit/$app-state#page) - that is, the data that is shared between all pages.
|
|
38
40
|
* The `Load` and `ServerLoad` functions in `./$types` will be narrowed accordingly.
|
|
39
41
|
* Use optional properties for data that is only present on specific pages. Do not add an index signature (`[key: string]: any`).
|
|
40
42
|
*/
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
41
44
|
export interface PageData {}
|
|
42
45
|
|
|
43
46
|
/**
|
|
44
47
|
* The shape of the `page.state` object, 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`.
|
|
45
48
|
*/
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
46
50
|
export interface PageState {}
|
|
47
51
|
|
|
48
52
|
/**
|
|
49
53
|
* If your adapter provides [platform-specific context](https://svelte.dev/docs/kit/adapters#Platform-specific-context) via `event.platform`, you can specify it here.
|
|
50
54
|
*/
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
51
56
|
export interface Platform {}
|
|
52
57
|
}
|
|
53
58
|
|
|
@@ -56,8 +61,8 @@ declare namespace App {
|
|
|
56
61
|
*/
|
|
57
62
|
declare module '$service-worker' {
|
|
58
63
|
/**
|
|
59
|
-
* The `base` path of the deployment. Typically this is equivalent to `config.
|
|
60
|
-
* Note that there is a `base` but no `assets`, since service workers cannot be used if `config.
|
|
64
|
+
* The `base` path of the deployment. Typically this is equivalent to `config.paths.base`, but it is calculated from `location.pathname` meaning that it will continue to work correctly if the site is deployed to a subdirectory.
|
|
65
|
+
* Note that there is a `base` but no `assets`, since service workers cannot be used if `config.paths.assets` is specified.
|
|
61
66
|
*/
|
|
62
67
|
export const base: string;
|
|
63
68
|
/**
|
|
@@ -66,7 +71,7 @@ declare module '$service-worker' {
|
|
|
66
71
|
*/
|
|
67
72
|
export const build: string[];
|
|
68
73
|
/**
|
|
69
|
-
* An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.
|
|
74
|
+
* An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.files.assets`. You can customize which files are included from `static` directory using [`config.serviceWorker.files`](https://svelte.dev/docs/kit/configuration#serviceWorker)
|
|
70
75
|
*/
|
|
71
76
|
export const files: string[];
|
|
72
77
|
/**
|
|
@@ -75,7 +80,7 @@ declare module '$service-worker' {
|
|
|
75
80
|
*/
|
|
76
81
|
export const prerendered: string[];
|
|
77
82
|
/**
|
|
78
|
-
* See [`config.
|
|
83
|
+
* See [`config.version`](https://svelte.dev/docs/kit/configuration#version). It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches.
|
|
79
84
|
*/
|
|
80
85
|
export const version: string;
|
|
81
86
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SvelteKitPayload } from 'types';
|
|
2
|
+
|
|
1
3
|
declare global {
|
|
2
4
|
const __SVELTEKIT_ADAPTER_NAME__: string;
|
|
3
5
|
const __SVELTEKIT_APP_DIR__: string;
|
|
@@ -13,13 +15,13 @@ declare global {
|
|
|
13
15
|
const __SVELTEKIT_PATHS_ASSETS__: string;
|
|
14
16
|
const __SVELTEKIT_PATHS_BASE__: string;
|
|
15
17
|
const __SVELTEKIT_PATHS_RELATIVE__: boolean;
|
|
16
|
-
/** True if `config.
|
|
18
|
+
/** True if `config.tracing.server` is `true` */
|
|
17
19
|
const __SVELTEKIT_SERVER_TRACING_ENABLED__: boolean;
|
|
18
|
-
/** True if `config.
|
|
20
|
+
/** True if `config.experimental.forkPreloads` is `true` */
|
|
19
21
|
const __SVELTEKIT_FORK_PRELOADS__: boolean;
|
|
20
|
-
/** True if `config.
|
|
22
|
+
/** True if `config.router.resolution === 'client'` */
|
|
21
23
|
const __SVELTEKIT_CLIENT_ROUTING__: boolean;
|
|
22
|
-
/** True if `config.
|
|
24
|
+
/** True if `config.router.type === 'hash'` */
|
|
23
25
|
const __SVELTEKIT_HASH_ROUTING__: boolean;
|
|
24
26
|
/**
|
|
25
27
|
* True if any node in the manifest has a server load function.
|
|
@@ -31,28 +33,15 @@ declare global {
|
|
|
31
33
|
* Used for treeshaking universal load code from client bundles when no universal loads exist.
|
|
32
34
|
*/
|
|
33
35
|
const __SVELTEKIT_HAS_UNIVERSAL_LOAD__: boolean;
|
|
34
|
-
/** The `__sveltekit_abc123` object in the init `<script>` */
|
|
35
|
-
const __SVELTEKIT_PAYLOAD__: {
|
|
36
|
-
/** The basepath, usually relative to the current page */
|
|
37
|
-
base: string;
|
|
38
|
-
/** Path to externally-hosted assets */
|
|
39
|
-
assets?: string;
|
|
40
|
-
/** Public environment variables */
|
|
41
|
-
env?: Record<string, string>;
|
|
42
|
-
/** Serialized data from query/form/command functions */
|
|
43
|
-
query?: Record<string, any>;
|
|
44
|
-
/** Serialized data from prerender functions */
|
|
45
|
-
prerender?: Record<string, any>;
|
|
46
|
-
/** Create a placeholder promise */
|
|
47
|
-
defer?: (id: number) => Promise<any>;
|
|
48
|
-
/** Resolve a placeholder promise */
|
|
49
|
-
resolve?: (data: { id: number; data: any; error: any }) => void;
|
|
50
|
-
};
|
|
51
36
|
/**
|
|
52
|
-
* The
|
|
53
|
-
*
|
|
37
|
+
* The `__sveltekit_abc123` object in the init `<script>`.
|
|
38
|
+
* Should only be used when bundleStrategy !== 'inline' to avoid SvelteKit runtime changing on every build, preventing cacheability.
|
|
39
|
+
*/
|
|
40
|
+
const __SVELTEKIT_PAYLOAD__: SvelteKitPayload;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the `experimental.async` flag is applied
|
|
54
43
|
*/
|
|
55
|
-
const
|
|
44
|
+
const __SVELTEKIT_SUPPORTS_ASYNC__: boolean;
|
|
56
45
|
/**
|
|
57
46
|
* This makes the use of specific features visible at both dev and build time, in such a
|
|
58
47
|
* way that we can error when they are not supported by the target platform.
|
|
@@ -68,7 +57,6 @@ declare global {
|
|
|
68
57
|
* to throw an error if the feature would fail in production.
|
|
69
58
|
*/
|
|
70
59
|
var __SVELTEKIT_TRACK__: (label: string) => void;
|
|
71
|
-
var __SVELTEKIT_EXPERIMENTAL_USE_TRANSFORM_ERROR__: boolean;
|
|
72
60
|
var Bun: object;
|
|
73
61
|
var Deno: object;
|
|
74
62
|
}
|
package/src/types/internal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component } from 'svelte';
|
|
2
2
|
import {
|
|
3
3
|
Config,
|
|
4
4
|
ServerLoad,
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
RequestEvent,
|
|
18
18
|
SSRManifest,
|
|
19
19
|
Emulator,
|
|
20
|
-
Adapter,
|
|
21
20
|
ServerInit,
|
|
22
21
|
ClientInit,
|
|
23
22
|
Transport,
|
|
@@ -34,7 +33,7 @@ import {
|
|
|
34
33
|
TrailingSlash
|
|
35
34
|
} from './private.js';
|
|
36
35
|
import { Span } from '@opentelemetry/api';
|
|
37
|
-
import
|
|
36
|
+
import { PageOptions } from '../exports/vite/static_analysis/types.js';
|
|
38
37
|
import { SharedIterator } from '../utils/shared-iterator.js';
|
|
39
38
|
|
|
40
39
|
export interface ServerModule {
|
|
@@ -44,12 +43,11 @@ export interface ServerModule {
|
|
|
44
43
|
export interface ServerInternalModule {
|
|
45
44
|
set_assets(path: string): void;
|
|
46
45
|
set_building(): void;
|
|
47
|
-
set_env(environment: Record<string, string>): void;
|
|
48
46
|
set_manifest(manifest: SSRManifest): void;
|
|
49
47
|
set_prerendering(): void;
|
|
50
48
|
set_read_implementation(implementation: (path: string) => ReadableStream): void;
|
|
51
49
|
set_version(version: string): void;
|
|
52
|
-
set_fix_stack_trace(fix_stack_trace: (error:
|
|
50
|
+
set_fix_stack_trace(fix_stack_trace: (error: Error) => void): void;
|
|
53
51
|
get_hooks: () => Promise<Record<string, any>>;
|
|
54
52
|
}
|
|
55
53
|
|
|
@@ -101,6 +99,9 @@ export interface BuildData {
|
|
|
101
99
|
routes?: SSRClientRoute[];
|
|
102
100
|
stylesheets: string[];
|
|
103
101
|
fonts: string[];
|
|
102
|
+
/**
|
|
103
|
+
* Whether the client uses public dynamic env vars — `$env/dynamic/public` or `$app/env/public`.
|
|
104
|
+
*/
|
|
104
105
|
uses_env_dynamic_public: boolean;
|
|
105
106
|
/** Only set in case of `bundleStrategy === 'inline'`. */
|
|
106
107
|
inline?: {
|
|
@@ -112,7 +113,7 @@ export interface BuildData {
|
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
export interface CSRPageNode {
|
|
115
|
-
component:
|
|
116
|
+
component: Component;
|
|
116
117
|
universal: {
|
|
117
118
|
load?: Load;
|
|
118
119
|
trailingSlash?: TrailingSlash;
|
|
@@ -194,7 +195,7 @@ export class InternalServer extends Server {
|
|
|
194
195
|
}
|
|
195
196
|
|
|
196
197
|
export interface ManifestData {
|
|
197
|
-
/** Static files from `
|
|
198
|
+
/** Static files from `config.files.assets`. */
|
|
198
199
|
assets: Asset[];
|
|
199
200
|
hooks: {
|
|
200
201
|
client: string | null;
|
|
@@ -203,7 +204,7 @@ export interface ManifestData {
|
|
|
203
204
|
};
|
|
204
205
|
nodes: PageNode[];
|
|
205
206
|
routes: RouteData[];
|
|
206
|
-
|
|
207
|
+
params: string | null;
|
|
207
208
|
}
|
|
208
209
|
|
|
209
210
|
export interface RemoteChunk {
|
|
@@ -236,10 +237,7 @@ export interface PrerenderOptions {
|
|
|
236
237
|
cache?: string; // including this here is a bit of a hack, but it makes it easy to add <meta http-equiv>
|
|
237
238
|
fallback?: boolean;
|
|
238
239
|
dependencies: Map<string, PrerenderDependency>;
|
|
239
|
-
/**
|
|
240
|
-
* For each key the (possibly still pending) result of a prerendered remote function.
|
|
241
|
-
* Used to deduplicate requests to the same remote function with the same arguments.
|
|
242
|
-
*/
|
|
240
|
+
/** Results of remote `prerender` functions, shared across the whole prerender run so that each only executes once */
|
|
243
241
|
remote_responses: Map<string, Promise<any>>;
|
|
244
242
|
/** True for the duration of a call to the `reroute` hook */
|
|
245
243
|
inside_reroute?: boolean;
|
|
@@ -249,7 +247,7 @@ export type RecursiveRequired<T> = {
|
|
|
249
247
|
// Recursive implementation of TypeScript's Required utility type.
|
|
250
248
|
// Will recursively continue until it reaches a primitive or Function
|
|
251
249
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
252
|
-
[K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type
|
|
250
|
+
[K in keyof T]-?: Extract<T[K], Function | (`${string}:` & {})> extends never // If it does not have a Function type
|
|
253
251
|
? RecursiveRequired<T[K]> // recursively continue through.
|
|
254
252
|
: T[K]; // Use the exact type for everything else
|
|
255
253
|
};
|
|
@@ -296,6 +294,7 @@ export interface RouteData {
|
|
|
296
294
|
|
|
297
295
|
export type ServerRedirectNode = {
|
|
298
296
|
type: 'redirect';
|
|
297
|
+
status: number;
|
|
299
298
|
location: string;
|
|
300
299
|
};
|
|
301
300
|
|
|
@@ -307,38 +306,42 @@ export type ServerNodesResponse = {
|
|
|
307
306
|
nodes: Array<ServerDataNode | ServerDataSkippedNode | ServerErrorNode | null>;
|
|
308
307
|
};
|
|
309
308
|
|
|
309
|
+
export type RemoteFunctionDataNode = {
|
|
310
|
+
/** value */
|
|
311
|
+
v?: any;
|
|
312
|
+
/** error */
|
|
313
|
+
e?: App.Error;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
export type RemoteFunctionData = {
|
|
317
|
+
/** The result of a command/form invocation */
|
|
318
|
+
_?: any;
|
|
319
|
+
/** `prerender` data that was accessed during the request */
|
|
320
|
+
p?: Record<string, RemoteFunctionDataNode>;
|
|
321
|
+
/** `query` or `query.batch` data that was accessed during the request */
|
|
322
|
+
q?: Record<string, RemoteFunctionDataNode>;
|
|
323
|
+
/** `query.live` data that was accessed during the request */
|
|
324
|
+
l?: Record<string, RemoteFunctionDataNode>;
|
|
325
|
+
/** `form` outputs (result/issues/input) from a non-enhanced submission, keyed by the client-side action id */
|
|
326
|
+
f?: Record<string, RemoteFunctionDataNode>;
|
|
327
|
+
/** Whether there were any refreshes/reconnects during the request */
|
|
328
|
+
r?: true;
|
|
329
|
+
/** The redirect location, if any */
|
|
330
|
+
redirect?: string;
|
|
331
|
+
};
|
|
332
|
+
|
|
310
333
|
export type RemoteFunctionResponse =
|
|
311
334
|
| (ServerRedirectNode & {
|
|
312
|
-
/**
|
|
313
|
-
|
|
314
|
-
/** devalue'd Record<string, any> */
|
|
315
|
-
reconnects?: string;
|
|
335
|
+
/** stringified RemoteFunctionData */
|
|
336
|
+
data: string;
|
|
316
337
|
})
|
|
317
338
|
| ServerErrorNode
|
|
318
339
|
| {
|
|
319
340
|
type: 'result';
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
refreshes: string | undefined;
|
|
323
|
-
/** devalue'd Record<string, any> */
|
|
324
|
-
reconnects: string | undefined;
|
|
341
|
+
/** stringified RemoteFunctionData */
|
|
342
|
+
data: string;
|
|
325
343
|
};
|
|
326
344
|
|
|
327
|
-
export type RemoteSingleflightResult = {
|
|
328
|
-
type: 'result';
|
|
329
|
-
data: any;
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
export type RemoteSingleflightError = {
|
|
333
|
-
type: 'error';
|
|
334
|
-
status?: number;
|
|
335
|
-
error: App.Error;
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
export type RemoteSingleflightEntry = RemoteSingleflightResult | RemoteSingleflightError;
|
|
339
|
-
|
|
340
|
-
export type RemoteSingleflightMap = Record<string, RemoteSingleflightEntry>;
|
|
341
|
-
|
|
342
345
|
export type RemoteLiveQueryUserFunctionReturnType<Output> = MaybePromise<
|
|
343
346
|
| AsyncGenerator<Output>
|
|
344
347
|
| AsyncIterator<Output>
|
|
@@ -388,14 +391,10 @@ export interface ServerDataSkippedNode {
|
|
|
388
391
|
export interface ServerErrorNode {
|
|
389
392
|
type: 'error';
|
|
390
393
|
error: App.Error;
|
|
391
|
-
/**
|
|
392
|
-
* Only set for HttpErrors.
|
|
393
|
-
*/
|
|
394
|
-
status?: number;
|
|
395
394
|
}
|
|
396
395
|
|
|
397
396
|
export interface ServerMetadataRoute {
|
|
398
|
-
config: any
|
|
397
|
+
config: Record<string, any>;
|
|
399
398
|
api: {
|
|
400
399
|
methods: Array<HttpMethod | '*'>;
|
|
401
400
|
};
|
|
@@ -418,27 +417,7 @@ export interface ServerMetadata {
|
|
|
418
417
|
remotes: Map<string, Map<string, { type: RemoteInternals['type']; dynamic: boolean }>>;
|
|
419
418
|
}
|
|
420
419
|
|
|
421
|
-
export
|
|
422
|
-
default: {
|
|
423
|
-
render(
|
|
424
|
-
props: Record<string, any>,
|
|
425
|
-
opts: { context: Map<any, any>; csp?: { nonce?: string; hash?: boolean } }
|
|
426
|
-
): {
|
|
427
|
-
html: string;
|
|
428
|
-
head: string;
|
|
429
|
-
css: {
|
|
430
|
-
code: string;
|
|
431
|
-
map: any; // TODO
|
|
432
|
-
};
|
|
433
|
-
/** Until we require all Svelte versions that support hashes, this might not be defined */
|
|
434
|
-
hashes?: {
|
|
435
|
-
script: Array<`sha256-${string}`>;
|
|
436
|
-
};
|
|
437
|
-
};
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
export type SSRComponentLoader = () => Promise<SSRComponent>;
|
|
420
|
+
export type SSRComponentLoader = () => Promise<Component>;
|
|
442
421
|
|
|
443
422
|
export interface UniversalNode {
|
|
444
423
|
/** Is `null` in case static analysis succeeds but the node is ssr=false */
|
|
@@ -447,7 +426,7 @@ export interface UniversalNode {
|
|
|
447
426
|
ssr?: boolean;
|
|
448
427
|
csr?: boolean;
|
|
449
428
|
trailingSlash?: TrailingSlash;
|
|
450
|
-
config?: any
|
|
429
|
+
config?: Record<string, any>;
|
|
451
430
|
entries?: PrerenderEntryGenerator;
|
|
452
431
|
}
|
|
453
432
|
|
|
@@ -458,7 +437,7 @@ export interface ServerNode {
|
|
|
458
437
|
csr?: boolean;
|
|
459
438
|
trailingSlash?: TrailingSlash;
|
|
460
439
|
actions?: Actions;
|
|
461
|
-
config?: any
|
|
440
|
+
config?: Record<string, any>;
|
|
462
441
|
entries?: PrerenderEntryGenerator;
|
|
463
442
|
}
|
|
464
443
|
|
|
@@ -477,7 +456,10 @@ export interface SSRNode {
|
|
|
477
456
|
|
|
478
457
|
/**
|
|
479
458
|
* During development, all styles are inlined for the page to avoid FOUC.
|
|
480
|
-
* But in production, this stores styles that are below the inline threshold
|
|
459
|
+
* But in production, this stores styles that are below the inline threshold.
|
|
460
|
+
* It returns a Promise during development because Vite needs to load the
|
|
461
|
+
* modules on demand. But in production, the contents have been precomputed
|
|
462
|
+
* during the build, so it can return synchronously.
|
|
481
463
|
*/
|
|
482
464
|
inline_styles?(): MaybePromise<
|
|
483
465
|
Record<string, string | ((assets: string, base: string) => string)>
|
|
@@ -494,7 +476,6 @@ export type SSRNodeLoader = () => Promise<SSRNode>;
|
|
|
494
476
|
|
|
495
477
|
export interface SSROptions {
|
|
496
478
|
app_template_contains_nonce: boolean;
|
|
497
|
-
async: boolean;
|
|
498
479
|
csp: ValidatedConfig['kit']['csp'];
|
|
499
480
|
csrf_check_origin: boolean;
|
|
500
481
|
csrf_trusted_origins: string[];
|
|
@@ -502,10 +483,9 @@ export interface SSROptions {
|
|
|
502
483
|
hash_routing: boolean;
|
|
503
484
|
hooks: ServerHooks;
|
|
504
485
|
link_header_preload: ValidatedConfig['kit']['output']['linkHeaderPreload'];
|
|
505
|
-
|
|
486
|
+
paths_origin: string | undefined;
|
|
506
487
|
service_worker: boolean;
|
|
507
488
|
service_worker_options: RegistrationOptions;
|
|
508
|
-
server_error_boundaries: boolean;
|
|
509
489
|
templates: {
|
|
510
490
|
app(values: {
|
|
511
491
|
head: string;
|
|
@@ -531,7 +511,7 @@ export type RemotePrerenderInputsGenerator<Input = any> = () => MaybePromise<Inp
|
|
|
531
511
|
export type SSREndpoint = Partial<Record<HttpMethod, RequestHandler>> & {
|
|
532
512
|
prerender?: PrerenderOption;
|
|
533
513
|
trailingSlash?: TrailingSlash;
|
|
534
|
-
config?: any
|
|
514
|
+
config?: Record<string, any>;
|
|
535
515
|
entries?: PrerenderEntryGenerator;
|
|
536
516
|
fallback?: RequestHandler;
|
|
537
517
|
};
|
|
@@ -580,7 +560,7 @@ export interface SSRState {
|
|
|
580
560
|
*/
|
|
581
561
|
before_handle?: (
|
|
582
562
|
event: RequestEvent,
|
|
583
|
-
config: any
|
|
563
|
+
config: Record<string, any>,
|
|
584
564
|
prerender: PrerenderOption,
|
|
585
565
|
handle: () => Promise<Response>
|
|
586
566
|
) => Promise<Response>;
|
|
@@ -598,13 +578,12 @@ export interface Uses {
|
|
|
598
578
|
search_params: Set<string>;
|
|
599
579
|
}
|
|
600
580
|
|
|
601
|
-
export type ValidatedConfig = Config & {
|
|
581
|
+
export type ValidatedConfig = Omit<Config, 'kit'> & {
|
|
602
582
|
kit: ValidatedKitConfig;
|
|
603
583
|
extensions: string[];
|
|
604
584
|
};
|
|
605
585
|
|
|
606
|
-
|
|
607
|
-
export type ValidatedKitConfig = Omit<RecursiveRequired<KitConfig>, 'adapter'>;
|
|
586
|
+
export type ValidatedKitConfig = RecursiveRequired<KitConfig>;
|
|
608
587
|
|
|
609
588
|
export type BinaryFormMeta = {
|
|
610
589
|
remote_refreshes?: string[];
|
|
@@ -663,6 +642,11 @@ export interface RemoteCommandInternals extends BaseRemoteInternals {
|
|
|
663
642
|
|
|
664
643
|
export interface RemoteFormInternals extends BaseRemoteInternals {
|
|
665
644
|
type: 'form';
|
|
645
|
+
/**
|
|
646
|
+
* For keyed (`form.for(key)`) instances: the id as the client computes it
|
|
647
|
+
* (the key is JSON-stringified but not URI-encoded, unlike `id`)
|
|
648
|
+
*/
|
|
649
|
+
action_id?: string;
|
|
666
650
|
fn(body: Record<string, any>, meta: BinaryFormMeta, form_data: FormData | null): Promise<any>;
|
|
667
651
|
}
|
|
668
652
|
|
|
@@ -708,15 +692,26 @@ export interface RequestState {
|
|
|
708
692
|
record_span: RecordSpan;
|
|
709
693
|
};
|
|
710
694
|
readonly remote: {
|
|
711
|
-
data
|
|
712
|
-
|
|
713
|
-
|
|
695
|
+
/** Resolved query/prerender data, populated by `await myQuery()` or `myQuery.set(...)` */
|
|
696
|
+
data: null | Map<RemoteInternals, Record<string, MaybePromise<any>>>;
|
|
697
|
+
/**
|
|
698
|
+
* Data that is implicitly included because it was awaited during render.
|
|
699
|
+
* This is serialized during SSR if the promise already resolved
|
|
700
|
+
*/
|
|
701
|
+
implicit: null | Map<RemoteInternals, Record<string, () => MaybePromise<any>>>;
|
|
702
|
+
/**
|
|
703
|
+
* Data that is explicitly included because of a `set(...)` or `refresh()`.
|
|
704
|
+
* This is always awaited
|
|
705
|
+
*/
|
|
706
|
+
explicit: null | Map<
|
|
707
|
+
string,
|
|
708
|
+
{
|
|
709
|
+
internals: RemoteInternals;
|
|
710
|
+
fn: () => Promise<any>;
|
|
711
|
+
}
|
|
714
712
|
>;
|
|
715
713
|
/** Instances created via `myForm.for(...)` */
|
|
716
714
|
forms: null | Map<string, any>;
|
|
717
|
-
/** A map of remote function key to corresponding single-flight-mutation promise */
|
|
718
|
-
refreshes: null | Map<string, Promise<any>>;
|
|
719
|
-
reconnects: null | Map<string, Promise<void>>;
|
|
720
715
|
/** A map of remote function ID to payloads requested for refreshing by the client */
|
|
721
716
|
requested: null | Map<string, string[]>;
|
|
722
717
|
/** A map of query.batch ID to payloads requested for that batch within the same macrotask */
|
|
@@ -739,6 +734,8 @@ export interface RequestState {
|
|
|
739
734
|
live_iterators: null | Map<string, SharedIterator<any>>;
|
|
740
735
|
};
|
|
741
736
|
readonly is_in_remote_function: boolean;
|
|
737
|
+
readonly is_in_remote_form_or_command: boolean;
|
|
738
|
+
readonly is_in_remote_query: boolean;
|
|
742
739
|
readonly is_in_render: boolean;
|
|
743
740
|
readonly is_in_universal_load: boolean;
|
|
744
741
|
}
|
|
@@ -748,5 +745,23 @@ export interface RequestStore {
|
|
|
748
745
|
state: RequestState;
|
|
749
746
|
}
|
|
750
747
|
|
|
748
|
+
/** Type of the `__sveltekit_abc123` object in the init `<script>` */
|
|
749
|
+
export interface SvelteKitPayload {
|
|
750
|
+
/** The application version */
|
|
751
|
+
version: string;
|
|
752
|
+
/** The basepath, usually relative to the current page */
|
|
753
|
+
base: string;
|
|
754
|
+
/** Path to externally-hosted assets */
|
|
755
|
+
assets?: string;
|
|
756
|
+
/** Public environment variables */
|
|
757
|
+
env?: Record<string, string>;
|
|
758
|
+
/** Serialized data from query/form/command functions */
|
|
759
|
+
data?: RemoteFunctionData;
|
|
760
|
+
/** Create a placeholder promise */
|
|
761
|
+
defer?: (id: number) => Promise<any>;
|
|
762
|
+
/** Resolve a placeholder promise */
|
|
763
|
+
resolve?: (data: { id: number; data: any; error: any }) => void;
|
|
764
|
+
}
|
|
765
|
+
|
|
751
766
|
export * from '../exports/index.js';
|
|
752
767
|
export * from './private.js';
|