@sveltejs/kit 3.0.0-next.6 → 3.0.0-next.7
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 +7 -2
- package/src/core/adapt/builder.js +11 -39
- package/src/core/config/index.js +76 -71
- package/src/core/config/options.js +280 -285
- package/src/core/config/types.d.ts +1 -1
- package/src/core/env.js +85 -1
- package/src/core/generate_manifest/index.js +12 -15
- package/src/core/sync/create_manifest_data/index.js +6 -44
- package/src/core/sync/write_client_manifest.js +7 -14
- package/src/core/sync/write_non_ambient.js +10 -7
- package/src/core/sync/write_root.js +9 -30
- package/src/core/sync/write_server.js +0 -1
- package/src/core/sync/write_types/index.js +11 -10
- package/src/exports/index.js +3 -3
- package/src/exports/internal/client.js +5 -0
- package/src/exports/internal/index.js +1 -91
- 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 +1 -1
- package/src/exports/params.js +63 -0
- package/src/exports/public.d.ts +82 -32
- package/src/exports/url.js +84 -0
- package/src/exports/vite/dev/index.js +28 -17
- package/src/exports/vite/index.js +217 -156
- package/src/exports/vite/preview/index.js +1 -1
- package/src/exports/vite/utils.js +3 -5
- package/src/runtime/app/paths/client.js +3 -7
- package/src/runtime/app/paths/server.js +1 -1
- package/src/runtime/app/server/remote/query.js +6 -12
- package/src/runtime/app/state/client.js +1 -2
- package/src/runtime/app/stores.js +13 -76
- package/src/runtime/client/client.js +26 -79
- package/src/runtime/client/remote-functions/cache.svelte.js +3 -1
- package/src/runtime/client/remote-functions/form.svelte.js +5 -24
- package/src/runtime/client/remote-functions/prerender.svelte.js +10 -3
- package/src/runtime/client/remote-functions/query/instance.svelte.js +18 -9
- package/src/runtime/client/remote-functions/query-live/instance.svelte.js +16 -6
- package/src/runtime/client/remote-functions/shared.svelte.js +1 -2
- package/src/runtime/client/state.svelte.js +66 -49
- package/src/runtime/client/types.d.ts +1 -1
- package/src/runtime/client/utils.js +0 -96
- package/src/runtime/form-utils.js +15 -2
- package/src/runtime/server/index.js +1 -1
- package/src/runtime/server/page/load_data.js +1 -1
- package/src/runtime/server/page/render.js +15 -24
- package/src/runtime/server/page/server_routing.js +13 -9
- package/src/runtime/server/remote.js +21 -12
- package/src/runtime/server/respond.js +11 -8
- package/src/runtime/telemetry/otel.js +1 -1
- package/src/types/ambient.d.ts +5 -1
- package/src/types/global-private.d.ts +1 -1
- package/src/types/internal.d.ts +9 -10
- package/src/utils/error.js +1 -1
- package/src/utils/mime.js +9 -0
- package/src/utils/params.js +66 -0
- package/src/utils/routing.js +84 -38
- package/src/utils/streaming.js +14 -4
- package/src/utils/url.js +0 -79
- package/src/version.js +1 -1
- package/types/index.d.ts +98 -87
- package/types/index.d.ts.map +10 -7
- package/src/exports/internal/server.js +0 -22
- /package/src/exports/internal/{remote-functions.js → server/remote-functions.js} +0 -0
|
@@ -1,54 +1,71 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { version } from '$app/env';
|
|
2
|
+
import { assets } from '$app/paths/internal/client';
|
|
3
|
+
import { BROWSER, DEV } from 'esm-env';
|
|
3
4
|
|
|
4
5
|
/** @type {import('@sveltejs/kit').Page} */
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
6
|
+
export const page = new (class Page {
|
|
7
|
+
data = $state.raw({});
|
|
8
|
+
form = $state.raw(null);
|
|
9
|
+
error = $state.raw(null);
|
|
10
|
+
params = $state.raw({});
|
|
11
|
+
route = $state.raw({ id: null });
|
|
12
|
+
state = $state.raw({});
|
|
13
|
+
status = $state.raw(-1);
|
|
14
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
15
|
+
url = $state.raw(new URL('a:'));
|
|
16
|
+
})();
|
|
17
|
+
|
|
18
|
+
export const navigating = new (class Navigating {
|
|
19
|
+
/** @type {import('@sveltejs/kit').Navigation | null} */
|
|
20
|
+
current = $state.raw(null);
|
|
21
|
+
})();
|
|
22
|
+
|
|
23
|
+
export const updated = new (class Updated {
|
|
24
|
+
current = $state.raw(false);
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
26
|
+
check = async () => false;
|
|
27
|
+
})();
|
|
28
|
+
|
|
29
|
+
if (!DEV && BROWSER) {
|
|
30
|
+
const interval = __SVELTEKIT_APP_VERSION_POLL_INTERVAL__;
|
|
31
|
+
|
|
32
|
+
/** @type {number} */
|
|
33
|
+
let timeout;
|
|
34
|
+
|
|
35
|
+
/** @type {() => Promise<boolean>} */
|
|
36
|
+
async function check() {
|
|
37
|
+
window.clearTimeout(timeout);
|
|
38
|
+
|
|
39
|
+
if (interval) timeout = window.setTimeout(check, interval);
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const res = await fetch(`${assets}/${__SVELTEKIT_APP_VERSION_FILE__}`, {
|
|
43
|
+
headers: {
|
|
44
|
+
'cache-control': 'no-cache'
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (!res.ok) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const data = await res.json();
|
|
53
|
+
const new_update = data.version !== version;
|
|
54
|
+
|
|
55
|
+
if (new_update) {
|
|
56
|
+
updated.current = true;
|
|
57
|
+
window.clearTimeout(timeout);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return new_update;
|
|
61
|
+
} catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (interval) timeout = window.setTimeout(check, interval);
|
|
67
|
+
|
|
68
|
+
updated.check = check;
|
|
52
69
|
}
|
|
53
70
|
|
|
54
71
|
/**
|
|
@@ -39,7 +39,7 @@ export interface SvelteKitApp {
|
|
|
39
39
|
dictionary: Record<string, [leaf: number, layouts: number[], errors?: number[]]>;
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* A map of `[matcherName: string]:
|
|
42
|
+
* A map of `[matcherName: string]: ParamMatcher`, which is used to match and parse route parameters.
|
|
43
43
|
*
|
|
44
44
|
* In case of router.resolution=server, this object is empty, as resolution happens on the server.
|
|
45
45
|
*/
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { BROWSER, DEV } from 'esm-env';
|
|
2
|
-
import { writable } from 'svelte/store';
|
|
3
|
-
import { assets } from '$app/paths/internal/client';
|
|
4
|
-
import { version } from '$app/env';
|
|
5
|
-
import { noop } from '../../utils/functions.js';
|
|
6
2
|
import { PRELOAD_PRIORITIES } from './constants.js';
|
|
7
3
|
|
|
8
|
-
/* global __SVELTEKIT_APP_VERSION_FILE__, __SVELTEKIT_APP_VERSION_POLL_INTERVAL__ */
|
|
9
|
-
|
|
10
4
|
export const origin = BROWSER ? location.origin : '';
|
|
11
5
|
|
|
12
6
|
/** @param {string | URL} url */
|
|
@@ -211,96 +205,6 @@ export function get_router_options(element) {
|
|
|
211
205
|
};
|
|
212
206
|
}
|
|
213
207
|
|
|
214
|
-
/** @param {any} value */
|
|
215
|
-
export function notifiable_store(value) {
|
|
216
|
-
const store = writable(value);
|
|
217
|
-
let ready = true;
|
|
218
|
-
|
|
219
|
-
function notify() {
|
|
220
|
-
ready = true;
|
|
221
|
-
store.update((val) => val);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/** @param {any} new_value */
|
|
225
|
-
function set(new_value) {
|
|
226
|
-
ready = false;
|
|
227
|
-
store.set(new_value);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/** @param {(value: any) => void} run */
|
|
231
|
-
function subscribe(run) {
|
|
232
|
-
/** @type {any} */
|
|
233
|
-
let old_value;
|
|
234
|
-
return store.subscribe((new_value) => {
|
|
235
|
-
if (old_value === undefined || (ready && new_value !== old_value)) {
|
|
236
|
-
run((old_value = new_value));
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
return { notify, set, subscribe };
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
export const updated_listener = {
|
|
245
|
-
v: noop
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
export function create_updated_store() {
|
|
249
|
-
const { set, subscribe } = writable(false);
|
|
250
|
-
|
|
251
|
-
if (__SVELTEKIT_DEV__ || !BROWSER) {
|
|
252
|
-
return {
|
|
253
|
-
subscribe,
|
|
254
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
255
|
-
check: async () => false
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
const interval = __SVELTEKIT_APP_VERSION_POLL_INTERVAL__;
|
|
260
|
-
|
|
261
|
-
/** @type {NodeJS.Timeout} */
|
|
262
|
-
let timeout;
|
|
263
|
-
|
|
264
|
-
/** @type {() => Promise<boolean>} */
|
|
265
|
-
async function check() {
|
|
266
|
-
clearTimeout(timeout);
|
|
267
|
-
|
|
268
|
-
if (interval) timeout = setTimeout(check, interval);
|
|
269
|
-
|
|
270
|
-
try {
|
|
271
|
-
const res = await fetch(`${assets}/${__SVELTEKIT_APP_VERSION_FILE__}`, {
|
|
272
|
-
headers: {
|
|
273
|
-
'cache-control': 'no-cache'
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
if (!res.ok) {
|
|
278
|
-
return false;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
const data = await res.json();
|
|
282
|
-
const updated = data.version !== version;
|
|
283
|
-
|
|
284
|
-
if (updated) {
|
|
285
|
-
set(true);
|
|
286
|
-
updated_listener.v();
|
|
287
|
-
clearTimeout(timeout);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
return updated;
|
|
291
|
-
} catch {
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (interval) timeout = setTimeout(check, interval);
|
|
297
|
-
|
|
298
|
-
return {
|
|
299
|
-
subscribe,
|
|
300
|
-
check
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
|
|
304
208
|
/**
|
|
305
209
|
* Is external if
|
|
306
210
|
* - origin different
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { DEV } from 'esm-env';
|
|
5
5
|
import * as devalue from 'devalue';
|
|
6
6
|
import { text_encoder } from './utils.js';
|
|
7
|
+
import { noop } from '../utils/functions.js';
|
|
7
8
|
import { SvelteKitError } from '@sveltejs/kit/internal';
|
|
8
9
|
|
|
9
10
|
const decoder = new TextDecoder();
|
|
@@ -26,6 +27,9 @@ export function set_nested_value(object, path_string, value) {
|
|
|
26
27
|
deep_set(object, split_path(path_string), value);
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
/** Pass this to set_nested_value to delete the last part of the given path */
|
|
31
|
+
export const DELETE_KEY = {};
|
|
32
|
+
|
|
29
33
|
/**
|
|
30
34
|
* Convert `FormData` into a POJO
|
|
31
35
|
* @param {FormData} data
|
|
@@ -320,7 +324,7 @@ export async function deserialize_binary_form(request) {
|
|
|
320
324
|
const chunk = await get_chunk(chunks.length);
|
|
321
325
|
has_more = !!chunk;
|
|
322
326
|
}
|
|
323
|
-
})();
|
|
327
|
+
})().catch(noop); // prevent unhandled rejection potentially crashing the process
|
|
324
328
|
|
|
325
329
|
return { data, meta, form_data: null };
|
|
326
330
|
}
|
|
@@ -504,6 +508,10 @@ export function deep_set(object, keys, value) {
|
|
|
504
508
|
}
|
|
505
509
|
|
|
506
510
|
if (!exists) {
|
|
511
|
+
if (value === DELETE_KEY) {
|
|
512
|
+
// don't create the nested structure if we want to delete the key anyway
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
507
515
|
current[key] = is_array ? [] : {};
|
|
508
516
|
}
|
|
509
517
|
|
|
@@ -512,7 +520,12 @@ export function deep_set(object, keys, value) {
|
|
|
512
520
|
|
|
513
521
|
const final_key = keys[keys.length - 1];
|
|
514
522
|
check_prototype_pollution(final_key);
|
|
515
|
-
|
|
523
|
+
|
|
524
|
+
if (value === DELETE_KEY) {
|
|
525
|
+
delete current[final_key];
|
|
526
|
+
} else {
|
|
527
|
+
current[final_key] = value;
|
|
528
|
+
}
|
|
516
529
|
}
|
|
517
530
|
|
|
518
531
|
/**
|
|
@@ -27,7 +27,7 @@ export class Server {
|
|
|
27
27
|
this.#manifest = manifest;
|
|
28
28
|
|
|
29
29
|
// Since AsyncLocalStorage is not working in webcontainers, we don't reset `sync_store`
|
|
30
|
-
// in `src/exports/internal/event.js` and handle only one request at a time.
|
|
30
|
+
// in `src/exports/internal/server/event.js` and handle only one request at a time.
|
|
31
31
|
if (IN_WEBCONTAINER) {
|
|
32
32
|
const respond = this.respond.bind(this);
|
|
33
33
|
|
|
@@ -377,7 +377,7 @@ export function create_universal_fetch(event, state, fetched, csr, resolve_opts)
|
|
|
377
377
|
}
|
|
378
378
|
|
|
379
379
|
void push_fetched(base64_encode(result), true);
|
|
380
|
-
})();
|
|
380
|
+
})().catch(noop); // prevent unhandled rejection potentially crashing the process
|
|
381
381
|
|
|
382
382
|
return (teed_body = b);
|
|
383
383
|
}
|
|
@@ -91,7 +91,7 @@ export async function render_response({
|
|
|
91
91
|
// TODO if we add a client entry point one day, we will need to include inline_styles with the entry, otherwise stylesheets will be linked even if they are below inlineStyleThreshold
|
|
92
92
|
const inline_styles = new Map();
|
|
93
93
|
|
|
94
|
-
/** @type {ReturnType<typeof options.root.render
|
|
94
|
+
/** @type {Awaited<ReturnType<typeof options.root.render>>} */
|
|
95
95
|
let rendered;
|
|
96
96
|
|
|
97
97
|
const form_value =
|
|
@@ -238,36 +238,27 @@ export async function render_response({
|
|
|
238
238
|
// portable as possible, but reset afterwards
|
|
239
239
|
if (paths.relative) paths.override({ base, assets });
|
|
240
240
|
|
|
241
|
-
const maybe_promise = options.root.render(props, render_opts);
|
|
242
241
|
// We have to invoke .then eagerly here in order to kick off rendering: it's only starting on access,
|
|
243
242
|
// and `await maybe_promise` would eagerly access the .then property but call its function only after a tick, which is too late
|
|
244
243
|
// for the paths.reset() below and for any eager getRequestEvent() calls during rendering without AsyncLocalStorage available.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
? /** @type {ReturnType<typeof options.root.render> & Promise<any>} */ (
|
|
248
|
-
maybe_promise
|
|
249
|
-
).then((r) => r)
|
|
250
|
-
: maybe_promise;
|
|
251
|
-
|
|
252
|
-
// TODO 3.0 remove options.async
|
|
253
|
-
if (options.async) {
|
|
254
|
-
// we reset this synchronously, rather than after async rendering is complete,
|
|
255
|
-
// to avoid cross-talk between requests. This is a breaking change for
|
|
256
|
-
// anyone who opts into async SSR, since `base` and `assets` will no
|
|
257
|
-
// longer be relative to the current pathname.
|
|
258
|
-
// TODO 3.0 remove `base` and `assets` in favour of `resolve(...)` and `asset(...)`
|
|
259
|
-
paths.reset();
|
|
260
|
-
}
|
|
244
|
+
// TODO use render from 'svelte/server' here
|
|
245
|
+
const rendered = options.root.render(props, render_opts).then((r) => r);
|
|
261
246
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
247
|
+
// we reset this synchronously, rather than after async rendering is complete,
|
|
248
|
+
// to avoid cross-talk between requests. This is a breaking change for
|
|
249
|
+
// anyone who opts into async SSR, since `base` and `assets` will no
|
|
250
|
+
// longer be relative to the current pathname.
|
|
251
|
+
// TODO 3.0 remove `base` and `assets` in favour of `resolve(...)` and `asset(...)`
|
|
252
|
+
paths.reset();
|
|
253
|
+
|
|
254
|
+
// @ts-expect-error the legacy `render` API only returns html still, but the new API uses body
|
|
255
|
+
const { head, html: body, css, hashes } = await rendered;
|
|
265
256
|
|
|
266
257
|
if (hashes) {
|
|
267
258
|
csp.add_script_hashes(hashes.script);
|
|
268
259
|
}
|
|
269
260
|
|
|
270
|
-
return { head,
|
|
261
|
+
return { head, body, css, hashes };
|
|
271
262
|
});
|
|
272
263
|
} finally {
|
|
273
264
|
if (DEV) {
|
|
@@ -277,7 +268,7 @@ export async function render_response({
|
|
|
277
268
|
paths.reset(); // just in case `options.root.render(...)` failed
|
|
278
269
|
}
|
|
279
270
|
} else {
|
|
280
|
-
rendered = { head: '',
|
|
271
|
+
rendered = { head: '', body: '', css: { code: '', map: null }, hashes: { script: [] } };
|
|
281
272
|
}
|
|
282
273
|
|
|
283
274
|
for (const { node } of branch) {
|
|
@@ -298,7 +289,7 @@ export async function render_response({
|
|
|
298
289
|
}
|
|
299
290
|
|
|
300
291
|
const head = new Head(rendered.head);
|
|
301
|
-
let body = rendered.
|
|
292
|
+
let body = rendered.body;
|
|
302
293
|
|
|
303
294
|
/** @param {string} path */
|
|
304
295
|
const prefixed = (path) => {
|
|
@@ -69,15 +69,19 @@ export async function resolve_route(resolved_path, url, manifest) {
|
|
|
69
69
|
return text('Server-side route resolution disabled', { status: 400 });
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
try {
|
|
73
|
+
const matchers = await manifest._.matchers();
|
|
74
|
+
const result = find_route(resolved_path, manifest._.client.routes, matchers);
|
|
75
|
+
|
|
76
|
+
return create_server_routing_response(
|
|
77
|
+
result?.route ?? null,
|
|
78
|
+
result?.params ?? {},
|
|
79
|
+
url,
|
|
80
|
+
manifest._.client
|
|
81
|
+
).response;
|
|
82
|
+
} catch {
|
|
83
|
+
return text('Error resolving route', { status: 500 });
|
|
84
|
+
}
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
/**
|
|
@@ -368,7 +368,7 @@ export async function collect_remote_data(data, event, state, options) {
|
|
|
368
368
|
const promises = [];
|
|
369
369
|
|
|
370
370
|
if (state.remote.explicit) {
|
|
371
|
-
for (const [remote_key, { internals,
|
|
371
|
+
for (const [remote_key, { internals, fn }] of state.remote.explicit) {
|
|
372
372
|
// there were explicit refreshes/reconnects (via `refresh()`/`set()`/`reconnect()`),
|
|
373
373
|
// so the client should apply these single-flight updates instead of calling `invalidateAll()`
|
|
374
374
|
data.r = true;
|
|
@@ -377,18 +377,27 @@ export async function collect_remote_data(data, event, state, options) {
|
|
|
377
377
|
internals.type === 'query_live' ? 'l' : internals.type[0]
|
|
378
378
|
);
|
|
379
379
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
380
|
+
// `fn` is deferred until now so the query runs after any state mutations
|
|
381
|
+
// in the command/form body. If the query was re-awaited in the meantime,
|
|
382
|
+
// `fn` returns the existing (fresh) cache entry rather than re-running.
|
|
383
|
+
// Kick off the query immediately and collect the promise so that multiple
|
|
384
|
+
// explicit refreshes run concurrently rather than serially.
|
|
385
|
+
const promise = fn();
|
|
386
|
+
|
|
387
|
+
promises.push(
|
|
388
|
+
promise.then(
|
|
389
|
+
(v) => {
|
|
390
|
+
((data[type] ??= {})[remote_key] ??= {}).v = v;
|
|
391
|
+
},
|
|
392
|
+
async (e) => {
|
|
393
|
+
if (e instanceof Redirect) {
|
|
394
|
+
// already handled elsewhere
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
389
397
|
|
|
390
|
-
|
|
391
|
-
|
|
398
|
+
((data[type] ??= {})[remote_key] ??= {}).e = await convert_error(e);
|
|
399
|
+
}
|
|
400
|
+
)
|
|
392
401
|
);
|
|
393
402
|
}
|
|
394
403
|
}
|
|
@@ -336,14 +336,17 @@ export async function internal_respond(request, options, manifest, state) {
|
|
|
336
336
|
}
|
|
337
337
|
|
|
338
338
|
if (!state.prerendering?.fallback) {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
339
|
+
try {
|
|
340
|
+
const matchers = await manifest._.matchers();
|
|
341
|
+
const result = find_route(resolved_path, manifest._.routes, matchers);
|
|
342
|
+
|
|
343
|
+
if (result) {
|
|
344
|
+
route = result.route;
|
|
345
|
+
event.route = { id: route.id };
|
|
346
|
+
event.params = result.params;
|
|
347
|
+
}
|
|
348
|
+
} catch (e) {
|
|
349
|
+
return await handle_fatal_error(event, event_state, options, e);
|
|
347
350
|
}
|
|
348
351
|
}
|
|
349
352
|
|
|
@@ -15,7 +15,7 @@ if (__SVELTEKIT_SERVER_TRACING_ENABLED__) {
|
|
|
15
15
|
})
|
|
16
16
|
.catch(() => {
|
|
17
17
|
throw new Error(
|
|
18
|
-
'Tracing is enabled (see the SvelteKit plugin `
|
|
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
|
}
|
package/src/types/ambient.d.ts
CHANGED
|
@@ -32,23 +32,27 @@ declare namespace App {
|
|
|
32
32
|
/**
|
|
33
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.
|
|
34
34
|
*/
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
35
36
|
export interface Locals {}
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
|
-
* 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.
|
|
39
40
|
* The `Load` and `ServerLoad` functions in `./$types` will be narrowed accordingly.
|
|
40
41
|
* Use optional properties for data that is only present on specific pages. Do not add an index signature (`[key: string]: any`).
|
|
41
42
|
*/
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
42
44
|
export interface PageData {}
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
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`.
|
|
46
48
|
*/
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
47
50
|
export interface PageState {}
|
|
48
51
|
|
|
49
52
|
/**
|
|
50
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.
|
|
51
54
|
*/
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
52
56
|
export interface Platform {}
|
|
53
57
|
}
|
|
54
58
|
|
|
@@ -15,7 +15,7 @@ declare global {
|
|
|
15
15
|
const __SVELTEKIT_PATHS_ASSETS__: string;
|
|
16
16
|
const __SVELTEKIT_PATHS_BASE__: string;
|
|
17
17
|
const __SVELTEKIT_PATHS_RELATIVE__: boolean;
|
|
18
|
-
/** True if `config.
|
|
18
|
+
/** True if `config.tracing.server` is `true` */
|
|
19
19
|
const __SVELTEKIT_SERVER_TRACING_ENABLED__: boolean;
|
|
20
20
|
/** True if `config.experimental.forkPreloads` is `true` */
|
|
21
21
|
const __SVELTEKIT_FORK_PRELOADS__: boolean;
|
package/src/types/internal.d.ts
CHANGED
|
@@ -204,7 +204,7 @@ export interface ManifestData {
|
|
|
204
204
|
};
|
|
205
205
|
nodes: PageNode[];
|
|
206
206
|
routes: RouteData[];
|
|
207
|
-
|
|
207
|
+
params: string | null;
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
export interface RemoteChunk {
|
|
@@ -247,7 +247,7 @@ export type RecursiveRequired<T> = {
|
|
|
247
247
|
// Recursive implementation of TypeScript's Required utility type.
|
|
248
248
|
// Will recursively continue until it reaches a primitive or Function
|
|
249
249
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
250
|
-
[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
|
|
251
251
|
? RecursiveRequired<T[K]> // recursively continue through.
|
|
252
252
|
: T[K]; // Use the exact type for everything else
|
|
253
253
|
};
|
|
@@ -417,23 +417,23 @@ export interface ServerMetadata {
|
|
|
417
417
|
remotes: Map<string, Map<string, { type: RemoteInternals['type']; dynamic: boolean }>>;
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
+
// TODO get rid of this in favor us using just import('svelte').Component<any, any, any>
|
|
420
421
|
export interface SSRComponent {
|
|
421
422
|
default: {
|
|
422
423
|
render(
|
|
423
424
|
props: Record<string, any>,
|
|
424
425
|
opts: { context: Map<any, any>; csp?: { nonce?: string; hash?: boolean } }
|
|
425
|
-
): {
|
|
426
|
-
|
|
426
|
+
): Promise<{
|
|
427
|
+
body: string;
|
|
427
428
|
head: string;
|
|
428
429
|
css: {
|
|
429
430
|
code: string;
|
|
430
431
|
map: any; // TODO
|
|
431
432
|
};
|
|
432
|
-
|
|
433
|
-
hashes?: {
|
|
433
|
+
hashes: {
|
|
434
434
|
script: Array<`sha256-${string}`>;
|
|
435
435
|
};
|
|
436
|
-
}
|
|
436
|
+
}>;
|
|
437
437
|
};
|
|
438
438
|
}
|
|
439
439
|
|
|
@@ -493,7 +493,6 @@ export type SSRNodeLoader = () => Promise<SSRNode>;
|
|
|
493
493
|
|
|
494
494
|
export interface SSROptions {
|
|
495
495
|
app_template_contains_nonce: boolean;
|
|
496
|
-
async: boolean;
|
|
497
496
|
csp: ValidatedConfig['kit']['csp'];
|
|
498
497
|
csrf_check_origin: boolean;
|
|
499
498
|
csrf_trusted_origins: string[];
|
|
@@ -598,7 +597,7 @@ export interface Uses {
|
|
|
598
597
|
search_params: Set<string>;
|
|
599
598
|
}
|
|
600
599
|
|
|
601
|
-
export type ValidatedConfig = Config & {
|
|
600
|
+
export type ValidatedConfig = Omit<Config, 'kit'> & {
|
|
602
601
|
kit: ValidatedKitConfig;
|
|
603
602
|
extensions: string[];
|
|
604
603
|
};
|
|
@@ -727,7 +726,7 @@ export interface RequestState {
|
|
|
727
726
|
string,
|
|
728
727
|
{
|
|
729
728
|
internals: RemoteInternals;
|
|
730
|
-
|
|
729
|
+
fn: () => Promise<any>;
|
|
731
730
|
}
|
|
732
731
|
>;
|
|
733
732
|
/** Instances created via `myForm.for(...)` */
|
package/src/utils/error.js
CHANGED
|
@@ -30,7 +30,7 @@ export function coalesce_to_error(err) {
|
|
|
30
30
|
* @param {unknown} error
|
|
31
31
|
*/
|
|
32
32
|
export function normalize_error(error) {
|
|
33
|
-
return /** @type {import('../exports/internal/
|
|
33
|
+
return /** @type {import('../exports/internal/shared.js').Redirect | HttpError | SvelteKitError | Error} */ (
|
|
34
34
|
error
|
|
35
35
|
);
|
|
36
36
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { mimes, lookup } from 'mrmime';
|
|
2
|
+
|
|
3
|
+
// `mrmime` does not include `.ico` in its database. The IANA-registered
|
|
4
|
+
// type is `image/vnd.microsoft.icon`, but `image/x-icon` is the
|
|
5
|
+
// semi-official type that is universally supported by browsers and other
|
|
6
|
+
// tools, so we use that.
|
|
7
|
+
mimes['ico'] = 'image/x-icon';
|
|
8
|
+
|
|
9
|
+
export { lookup };
|