@sveltejs/kit 1.29.0 → 1.30.0
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 -10
- package/src/core/postbuild/analyse.js +7 -7
- package/src/exports/public.d.ts +2 -0
- package/src/exports/vite/build/build_service_worker.js +14 -8
- package/src/exports/vite/build/utils.js +11 -0
- package/src/runtime/app/navigation.js +1 -1
- package/src/runtime/client/client.js +11 -4
- package/src/runtime/client/constants.js +2 -1
- package/src/runtime/client/fetcher.js +23 -1
- package/src/runtime/client/utils.js +2 -2
- package/src/runtime/control.js +12 -0
- package/src/runtime/server/endpoint.js +1 -1
- package/src/runtime/server/page/actions.js +2 -1
- package/src/runtime/server/page/load_data.js +61 -32
- package/src/runtime/server/page/serialize_data.js +4 -0
- package/src/runtime/server/page/types.d.ts +1 -0
- package/src/runtime/server/respond.js +2 -2
- package/src/runtime/server/utils.js +11 -11
- package/src/utils/fork.js +2 -4
- package/src/utils/promises.js +1 -1
- package/src/version.js +1 -1
- package/types/index.d.ts +3 -1
- package/types/index.d.ts.map +1 -1
package/package.json
CHANGED
package/src/constants.js
CHANGED
|
@@ -6,14 +6,6 @@ export const SVELTE_KIT_ASSETS = '/_svelte_kit_assets';
|
|
|
6
6
|
|
|
7
7
|
export const GENERATED_COMMENT = '// this file is generated — do not edit it\n';
|
|
8
8
|
|
|
9
|
-
export const ENDPOINT_METHODS =
|
|
10
|
-
'GET',
|
|
11
|
-
'POST',
|
|
12
|
-
'PUT',
|
|
13
|
-
'PATCH',
|
|
14
|
-
'DELETE',
|
|
15
|
-
'OPTIONS',
|
|
16
|
-
'HEAD'
|
|
17
|
-
]);
|
|
9
|
+
export const ENDPOINT_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD'];
|
|
18
10
|
|
|
19
|
-
export const PAGE_METHODS =
|
|
11
|
+
export const PAGE_METHODS = ['GET', 'POST', 'HEAD'];
|
|
@@ -93,13 +93,13 @@ async function analyse({ manifest_path, env }) {
|
|
|
93
93
|
prerender = mod.prerender;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
if (mod[method]
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
96
|
+
for (const method of /** @type {import('types').HttpMethod[]} */ (ENDPOINT_METHODS)) {
|
|
97
|
+
if (mod[method]) api_methods.push(method);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (mod.fallback) {
|
|
101
|
+
api_methods.push('*');
|
|
102
|
+
}
|
|
103
103
|
|
|
104
104
|
config = mod.config;
|
|
105
105
|
entries = mod.entries;
|
package/src/exports/public.d.ts
CHANGED
|
@@ -478,6 +478,8 @@ export interface KitConfig {
|
|
|
478
478
|
* If `true`, `base` and `assets` imported from `$app/paths` will be replaced with relative asset paths during server-side rendering, resulting in portable HTML.
|
|
479
479
|
* If `false`, `%sveltekit.assets%` and references to build artifacts will always be root-relative paths, unless `paths.assets` is an external URL
|
|
480
480
|
*
|
|
481
|
+
* [Single-page app](https://kit.svelte.dev/docs/single-page-apps) fallback pages will always use absolute paths, regardless of this setting.
|
|
482
|
+
*
|
|
481
483
|
* If your app uses a `<base>` element, you should set this to `false`, otherwise asset URLs will incorrectly be resolved against the `<base>` URL rather than the current page.
|
|
482
484
|
* @default undefined
|
|
483
485
|
*/
|
|
@@ -3,7 +3,6 @@ import * as vite from 'vite';
|
|
|
3
3
|
import { dedent } from '../../../core/sync/utils.js';
|
|
4
4
|
import { s } from '../../../utils/misc.js';
|
|
5
5
|
import { get_config_aliases } from '../utils.js';
|
|
6
|
-
import { assets_base } from './utils.js';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* @param {string} out
|
|
@@ -64,16 +63,16 @@ export async function build_service_worker(
|
|
|
64
63
|
);
|
|
65
64
|
|
|
66
65
|
await vite.build({
|
|
67
|
-
base: assets_base(kit),
|
|
68
66
|
build: {
|
|
69
|
-
|
|
70
|
-
entry: /** @type {string} */ (service_worker_entry_file),
|
|
71
|
-
name: 'app',
|
|
72
|
-
formats: ['es']
|
|
73
|
-
},
|
|
67
|
+
modulePreload: false,
|
|
74
68
|
rollupOptions: {
|
|
69
|
+
input: {
|
|
70
|
+
'service-worker': service_worker_entry_file
|
|
71
|
+
},
|
|
75
72
|
output: {
|
|
76
|
-
entryFileNames: '
|
|
73
|
+
entryFileNames: '[name].js',
|
|
74
|
+
assetFileNames: `${kit.appDir}/immutable/assets/[name].[hash][extname]`,
|
|
75
|
+
inlineDynamicImports: true
|
|
77
76
|
}
|
|
78
77
|
},
|
|
79
78
|
outDir: `${out}/client`,
|
|
@@ -84,6 +83,13 @@ export async function build_service_worker(
|
|
|
84
83
|
publicDir: false,
|
|
85
84
|
resolve: {
|
|
86
85
|
alias: [...get_config_aliases(kit), { find: '$service-worker', replacement: service_worker }]
|
|
86
|
+
},
|
|
87
|
+
experimental: {
|
|
88
|
+
renderBuiltUrl(filename) {
|
|
89
|
+
return {
|
|
90
|
+
runtime: `new URL(${JSON.stringify(filename)}, location.href).pathname`
|
|
91
|
+
};
|
|
92
|
+
}
|
|
87
93
|
}
|
|
88
94
|
});
|
|
89
95
|
}
|
|
@@ -83,6 +83,17 @@ export function resolve_symlinks(manifest, file) {
|
|
|
83
83
|
return { chunk, file };
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
const method_names = new Set(['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH', 'OPTIONS']);
|
|
87
|
+
|
|
88
|
+
// If we'd written this in TypeScript, it could be easy...
|
|
89
|
+
/**
|
|
90
|
+
* @param {string} str
|
|
91
|
+
* @returns {str is import('types').HttpMethod}
|
|
92
|
+
*/
|
|
93
|
+
export function is_http_method(str) {
|
|
94
|
+
return method_names.has(str);
|
|
95
|
+
}
|
|
96
|
+
|
|
86
97
|
/**
|
|
87
98
|
* @param {import('types').ValidatedKitConfig} config
|
|
88
99
|
* @returns {string}
|
|
@@ -102,7 +102,7 @@ export const preloadCode = /* @__PURE__ */ client_method('preload_code');
|
|
|
102
102
|
export const beforeNavigate = /* @__PURE__ */ client_method('before_navigate');
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
* A lifecycle function that runs the supplied `callback` immediately before we navigate to a new URL.
|
|
105
|
+
* A lifecycle function that runs the supplied `callback` immediately before we navigate to a new URL except during full-page navigations.
|
|
106
106
|
*
|
|
107
107
|
* If you return a `Promise`, SvelteKit will wait for it to resolve before completing the navigation. This allows you to — for example — use `document.startViewTransition`. Avoid promises that are slow to resolve, since navigation will appear stalled to the user.
|
|
108
108
|
*
|
|
@@ -31,7 +31,7 @@ import * as devalue from 'devalue';
|
|
|
31
31
|
import { compact } from '../../utils/array.js';
|
|
32
32
|
import { validate_page_exports } from '../../utils/exports.js';
|
|
33
33
|
import { unwrap_promises } from '../../utils/promises.js';
|
|
34
|
-
import { HttpError, Redirect } from '../control.js';
|
|
34
|
+
import { HttpError, Redirect, NotFound } from '../control.js';
|
|
35
35
|
import { INVALIDATED_PARAM, TRAILING_SLASH_PARAM, validate_depends } from '../shared.js';
|
|
36
36
|
import { INDEX_KEY, PRELOAD_PRIORITIES, SCROLL_KEY, SNAPSHOT_KEY } from './constants.js';
|
|
37
37
|
import { stores } from './singletons.js';
|
|
@@ -277,6 +277,10 @@ export function create_client(app, target) {
|
|
|
277
277
|
|
|
278
278
|
/** @param {...string} pathnames */
|
|
279
279
|
async function preload_code(...pathnames) {
|
|
280
|
+
if (DEV && pathnames.length > 1) {
|
|
281
|
+
console.warn('Calling `preloadCode` with multiple arguments is deprecated');
|
|
282
|
+
}
|
|
283
|
+
|
|
280
284
|
const matching = routes.filter((route) => pathnames.some((pathname) => route.exec(pathname)));
|
|
281
285
|
|
|
282
286
|
const promises = matching.map((r) => {
|
|
@@ -1327,7 +1331,10 @@ export function create_client(app, target) {
|
|
|
1327
1331
|
|
|
1328
1332
|
return (
|
|
1329
1333
|
app.hooks.handleError({ error, event }) ??
|
|
1330
|
-
/** @type {any} */ ({
|
|
1334
|
+
/** @type {any} */ ({
|
|
1335
|
+
message:
|
|
1336
|
+
event.route.id === null && error instanceof NotFound ? 'Not Found' : 'Internal Error'
|
|
1337
|
+
})
|
|
1331
1338
|
);
|
|
1332
1339
|
}
|
|
1333
1340
|
|
|
@@ -1668,8 +1675,8 @@ export function create_client(app, target) {
|
|
|
1668
1675
|
const scroll = scroll_positions[event.state[INDEX_KEY]];
|
|
1669
1676
|
const url = new URL(location.href);
|
|
1670
1677
|
|
|
1671
|
-
// if the only change is the hash, we don't need to do anything...
|
|
1672
|
-
if (current.url
|
|
1678
|
+
// if the only change is the hash, we don't need to do anything (see https://github.com/sveltejs/kit/pull/10636 for why we need to do `url?.`)...
|
|
1679
|
+
if (current.url?.href.split('#')[0] === location.href.split('#')[0]) {
|
|
1673
1680
|
// ...except update our internal URL tracking and handle scroll
|
|
1674
1681
|
update_url(url);
|
|
1675
1682
|
scroll_positions[current_history_index] = scroll_state();
|
|
@@ -75,6 +75,22 @@ if (DEV) {
|
|
|
75
75
|
|
|
76
76
|
const cache = new Map();
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* @param {string} text
|
|
80
|
+
* @returns {ArrayBufferLike}
|
|
81
|
+
*/
|
|
82
|
+
function b64_decode(text) {
|
|
83
|
+
const d = atob(text);
|
|
84
|
+
|
|
85
|
+
const u8 = new Uint8Array(d.length);
|
|
86
|
+
|
|
87
|
+
for (let i = 0; i < d.length; i++) {
|
|
88
|
+
u8[i] = d.charCodeAt(i);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return u8.buffer;
|
|
92
|
+
}
|
|
93
|
+
|
|
78
94
|
/**
|
|
79
95
|
* Should be called on the initial run of load functions that hydrate the page.
|
|
80
96
|
* Saves any requests with cache-control max-age to the cache.
|
|
@@ -86,10 +102,16 @@ export function initial_fetch(resource, opts) {
|
|
|
86
102
|
|
|
87
103
|
const script = document.querySelector(selector);
|
|
88
104
|
if (script?.textContent) {
|
|
89
|
-
|
|
105
|
+
let { body, ...init } = JSON.parse(script.textContent);
|
|
90
106
|
|
|
91
107
|
const ttl = script.getAttribute('data-ttl');
|
|
92
108
|
if (ttl) cache.set(selector, { body, init, ttl: 1000 * Number(ttl) });
|
|
109
|
+
const b64 = script.getAttribute('data-b64');
|
|
110
|
+
if (b64 !== null) {
|
|
111
|
+
// Can't use native_fetch('data:...;base64,${body}')
|
|
112
|
+
// csp can block the request
|
|
113
|
+
body = b64_decode(body);
|
|
114
|
+
}
|
|
93
115
|
|
|
94
116
|
return Promise.resolve(new Response(body, init));
|
|
95
117
|
}
|
|
@@ -32,8 +32,8 @@ const warned = new WeakSet();
|
|
|
32
32
|
/** @typedef {keyof typeof valid_link_options} LinkOptionName */
|
|
33
33
|
|
|
34
34
|
const valid_link_options = /** @type {const} */ ({
|
|
35
|
-
'preload-code': ['', 'off', 'tap', 'hover', 'viewport', 'eager'],
|
|
36
|
-
'preload-data': ['', 'off', 'tap', 'hover'],
|
|
35
|
+
'preload-code': ['', 'off', 'false', 'tap', 'hover', 'viewport', 'eager'],
|
|
36
|
+
'preload-data': ['', 'off', 'false', 'tap', 'hover'],
|
|
37
37
|
keepfocus: ['', 'true', 'off', 'false'],
|
|
38
38
|
noscroll: ['', 'true', 'off', 'false'],
|
|
39
39
|
reload: ['', 'true', 'off', 'false'],
|
package/src/runtime/control.js
CHANGED
|
@@ -30,6 +30,18 @@ export class Redirect {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
export class NotFound extends Error {
|
|
34
|
+
/**
|
|
35
|
+
* @param {string} pathname
|
|
36
|
+
*/
|
|
37
|
+
constructor(pathname) {
|
|
38
|
+
super();
|
|
39
|
+
|
|
40
|
+
this.status = 404;
|
|
41
|
+
this.message = `Not found: ${pathname}`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
33
45
|
/**
|
|
34
46
|
* @template {Record<string, unknown> | undefined} [T=undefined]
|
|
35
47
|
*/
|
|
@@ -81,7 +81,7 @@ export function is_endpoint_request(event) {
|
|
|
81
81
|
const { method, headers } = event.request;
|
|
82
82
|
|
|
83
83
|
// These methods exist exclusively for endpoints
|
|
84
|
-
if (ENDPOINT_METHODS.
|
|
84
|
+
if (ENDPOINT_METHODS.includes(method) && !PAGE_METHODS.includes(method)) {
|
|
85
85
|
return true;
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -220,7 +220,8 @@ async function call_action(event, actions) {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
if (!is_form_content_type(event.request)) {
|
|
223
|
-
throw
|
|
223
|
+
throw error(
|
|
224
|
+
415,
|
|
224
225
|
`Actions expect form-encoded data (received ${event.request.headers.get('content-type')})`
|
|
225
226
|
);
|
|
226
227
|
}
|
|
@@ -189,6 +189,25 @@ export async function load_data({
|
|
|
189
189
|
return data;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
/**
|
|
193
|
+
* @param {ArrayBuffer} buffer
|
|
194
|
+
* @returns {string}
|
|
195
|
+
*/
|
|
196
|
+
function b64_encode(buffer) {
|
|
197
|
+
if (globalThis.Buffer) {
|
|
198
|
+
return Buffer.from(buffer).toString('base64');
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const little_endian = new Uint8Array(new Uint16Array([1]).buffer)[0] > 0;
|
|
202
|
+
|
|
203
|
+
// The Uint16Array(Uint8Array(...)) ensures the code points are padded with 0's
|
|
204
|
+
return btoa(
|
|
205
|
+
new TextDecoder(little_endian ? 'utf-16le' : 'utf-16be').decode(
|
|
206
|
+
new Uint16Array(new Uint8Array(buffer))
|
|
207
|
+
)
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
192
211
|
/**
|
|
193
212
|
* @param {Pick<import('@sveltejs/kit').RequestEvent, 'fetch' | 'url' | 'request' | 'route'>} event
|
|
194
213
|
* @param {import('types').SSRState} state
|
|
@@ -246,38 +265,33 @@ export function create_universal_fetch(event, state, fetched, csr, resolve_opts)
|
|
|
246
265
|
|
|
247
266
|
const proxy = new Proxy(response, {
|
|
248
267
|
get(response, key, _receiver) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
fetched.push({
|
|
263
|
-
url: same_origin ? url.href.slice(event.url.origin.length) : url.href,
|
|
264
|
-
method: event.request.method,
|
|
265
|
-
request_body: /** @type {string | ArrayBufferView | undefined} */ (
|
|
266
|
-
input instanceof Request && cloned_body
|
|
267
|
-
? await stream_to_string(cloned_body)
|
|
268
|
-
: init?.body
|
|
269
|
-
),
|
|
270
|
-
request_headers: cloned_headers,
|
|
271
|
-
response_body: body,
|
|
272
|
-
response
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
if (dependency) {
|
|
277
|
-
dependency.body = body;
|
|
268
|
+
/**
|
|
269
|
+
* @param {string} body
|
|
270
|
+
* @param {boolean} is_b64
|
|
271
|
+
*/
|
|
272
|
+
async function push_fetched(body, is_b64) {
|
|
273
|
+
const status_number = Number(response.status);
|
|
274
|
+
if (isNaN(status_number)) {
|
|
275
|
+
throw new Error(
|
|
276
|
+
`response.status is not a number. value: "${
|
|
277
|
+
response.status
|
|
278
|
+
}" type: ${typeof response.status}`
|
|
279
|
+
);
|
|
278
280
|
}
|
|
279
281
|
|
|
280
|
-
|
|
282
|
+
fetched.push({
|
|
283
|
+
url: same_origin ? url.href.slice(event.url.origin.length) : url.href,
|
|
284
|
+
method: event.request.method,
|
|
285
|
+
request_body: /** @type {string | ArrayBufferView | undefined} */ (
|
|
286
|
+
input instanceof Request && cloned_body
|
|
287
|
+
? await stream_to_string(cloned_body)
|
|
288
|
+
: init?.body
|
|
289
|
+
),
|
|
290
|
+
request_headers: cloned_headers,
|
|
291
|
+
response_body: body,
|
|
292
|
+
response,
|
|
293
|
+
is_b64
|
|
294
|
+
});
|
|
281
295
|
}
|
|
282
296
|
|
|
283
297
|
if (key === 'arrayBuffer') {
|
|
@@ -288,13 +302,28 @@ export function create_universal_fetch(event, state, fetched, csr, resolve_opts)
|
|
|
288
302
|
dependency.body = new Uint8Array(buffer);
|
|
289
303
|
}
|
|
290
304
|
|
|
291
|
-
|
|
292
|
-
|
|
305
|
+
if (buffer instanceof ArrayBuffer) {
|
|
306
|
+
await push_fetched(b64_encode(buffer), true);
|
|
307
|
+
}
|
|
293
308
|
|
|
294
309
|
return buffer;
|
|
295
310
|
};
|
|
296
311
|
}
|
|
297
312
|
|
|
313
|
+
async function text() {
|
|
314
|
+
const body = await response.text();
|
|
315
|
+
|
|
316
|
+
if (!body || typeof body === 'string') {
|
|
317
|
+
await push_fetched(body, false);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (dependency) {
|
|
321
|
+
dependency.body = body;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return body;
|
|
325
|
+
}
|
|
326
|
+
|
|
298
327
|
if (key === 'text') {
|
|
299
328
|
return text;
|
|
300
329
|
}
|
|
@@ -73,6 +73,10 @@ export function serialize_data(fetched, filter, prerendering = false) {
|
|
|
73
73
|
`data-url=${escape_html_attr(fetched.url)}`
|
|
74
74
|
];
|
|
75
75
|
|
|
76
|
+
if (fetched.is_b64) {
|
|
77
|
+
attrs.push('data-b64');
|
|
78
|
+
}
|
|
79
|
+
|
|
76
80
|
if (fetched.request_headers || fetched.request_body) {
|
|
77
81
|
/** @type {import('types').StrictBody[]} */
|
|
78
82
|
const values = [];
|
|
@@ -18,7 +18,7 @@ import { exec } from '../../utils/routing.js';
|
|
|
18
18
|
import { redirect_json_response, render_data } from './data/index.js';
|
|
19
19
|
import { add_cookies_to_headers, get_cookies } from './cookie.js';
|
|
20
20
|
import { create_fetch } from './fetch.js';
|
|
21
|
-
import { Redirect } from '../control.js';
|
|
21
|
+
import { Redirect, NotFound } from '../control.js';
|
|
22
22
|
import {
|
|
23
23
|
validate_layout_exports,
|
|
24
24
|
validate_layout_server_exports,
|
|
@@ -480,7 +480,7 @@ export async function respond(request, options, manifest, state) {
|
|
|
480
480
|
manifest,
|
|
481
481
|
state,
|
|
482
482
|
status: 404,
|
|
483
|
-
error: new
|
|
483
|
+
error: new NotFound(event.url.pathname),
|
|
484
484
|
resolve_opts
|
|
485
485
|
});
|
|
486
486
|
}
|
|
@@ -2,7 +2,7 @@ import { DEV } from 'esm-env';
|
|
|
2
2
|
import { json, text } from '../../exports/index.js';
|
|
3
3
|
import { coalesce_to_error } from '../../utils/error.js';
|
|
4
4
|
import { negotiate } from '../../utils/http.js';
|
|
5
|
-
import { HttpError } from '../control.js';
|
|
5
|
+
import { HttpError, NotFound } from '../control.js';
|
|
6
6
|
import { fix_stack_trace } from '../shared-server.js';
|
|
7
7
|
import { ENDPOINT_METHODS } from '../../constants.js';
|
|
8
8
|
|
|
@@ -35,7 +35,7 @@ export function method_not_allowed(mod, method) {
|
|
|
35
35
|
|
|
36
36
|
/** @param {Partial<Record<import('types').HttpMethod, any>>} mod */
|
|
37
37
|
export function allowed_methods(mod) {
|
|
38
|
-
const allowed =
|
|
38
|
+
const allowed = ENDPOINT_METHODS.filter((method) => method in mod);
|
|
39
39
|
|
|
40
40
|
if ('GET' in mod || 'HEAD' in mod) allowed.push('HEAD');
|
|
41
41
|
|
|
@@ -97,17 +97,17 @@ export async function handle_fatal_error(event, options, error) {
|
|
|
97
97
|
export async function handle_error_and_jsonify(event, options, error) {
|
|
98
98
|
if (error instanceof HttpError) {
|
|
99
99
|
return error.body;
|
|
100
|
-
}
|
|
101
|
-
if (__SVELTEKIT_DEV__ && typeof error == 'object') {
|
|
102
|
-
fix_stack_trace(error);
|
|
103
|
-
}
|
|
100
|
+
}
|
|
104
101
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
message: event.route.id != null ? 'Internal Error' : 'Not Found'
|
|
108
|
-
}
|
|
109
|
-
);
|
|
102
|
+
if (__SVELTEKIT_DEV__ && typeof error == 'object') {
|
|
103
|
+
fix_stack_trace(error);
|
|
110
104
|
}
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
(await options.hooks.handleError({ error, event })) ?? {
|
|
108
|
+
message: event.route.id === null && error instanceof NotFound ? 'Not Found' : 'Internal Error'
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/**
|
package/src/utils/fork.js
CHANGED
|
@@ -32,7 +32,7 @@ export function forked(module, callback) {
|
|
|
32
32
|
* @param {T} opts
|
|
33
33
|
* @returns {Promise<U>}
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
return function (opts) {
|
|
36
36
|
return new Promise((fulfil, reject) => {
|
|
37
37
|
const worker = new Worker(fileURLToPath(module), {
|
|
38
38
|
env: {
|
|
@@ -53,7 +53,7 @@ export function forked(module, callback) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
if (data?.type === 'result' && data.module === module) {
|
|
56
|
-
worker.
|
|
56
|
+
worker.unref();
|
|
57
57
|
fulfil(data.payload);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -66,6 +66,4 @@ export function forked(module, callback) {
|
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
68
|
};
|
|
69
|
-
|
|
70
|
-
return fn;
|
|
71
69
|
}
|
package/src/utils/promises.js
CHANGED
|
@@ -41,7 +41,7 @@ export async function unwrap_promises(object, id) {
|
|
|
41
41
|
|
|
42
42
|
if (!warned.has(message)) {
|
|
43
43
|
console.warn(
|
|
44
|
-
`\n${message}\n\nIn SvelteKit 2.0, these will longer be awaited automatically. To get rid of this warning, await all promises included as top-level properties in \`load\` return values.\n`
|
|
44
|
+
`\n${message}\n\nIn SvelteKit 2.0, these will no longer be awaited automatically. To get rid of this warning, await all promises included as top-level properties in \`load\` return values.\n`
|
|
45
45
|
);
|
|
46
46
|
|
|
47
47
|
warned.add(message);
|
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -458,6 +458,8 @@ declare module '@sveltejs/kit' {
|
|
|
458
458
|
* If `true`, `base` and `assets` imported from `$app/paths` will be replaced with relative asset paths during server-side rendering, resulting in portable HTML.
|
|
459
459
|
* If `false`, `%sveltekit.assets%` and references to build artifacts will always be root-relative paths, unless `paths.assets` is an external URL
|
|
460
460
|
*
|
|
461
|
+
* [Single-page app](https://kit.svelte.dev/docs/single-page-apps) fallback pages will always use absolute paths, regardless of this setting.
|
|
462
|
+
*
|
|
461
463
|
* If your app uses a `<base>` element, you should set this to `false`, otherwise asset URLs will incorrectly be resolved against the `<base>` URL rather than the current page.
|
|
462
464
|
* @default undefined
|
|
463
465
|
*/
|
|
@@ -1979,7 +1981,7 @@ declare module '$app/navigation' {
|
|
|
1979
1981
|
* */
|
|
1980
1982
|
export const beforeNavigate: (callback: (navigation: import('@sveltejs/kit').BeforeNavigate) => void) => void;
|
|
1981
1983
|
/**
|
|
1982
|
-
* A lifecycle function that runs the supplied `callback` immediately before we navigate to a new URL.
|
|
1984
|
+
* A lifecycle function that runs the supplied `callback` immediately before we navigate to a new URL except during full-page navigations.
|
|
1983
1985
|
*
|
|
1984
1986
|
* If you return a `Promise`, SvelteKit will wait for it to resolve before completing the navigation. This allows you to — for example — use `document.startViewTransition`. Avoid promises that are slow to resolve, since navigation will appear stalled to the user.
|
|
1985
1987
|
*
|
package/types/index.d.ts.map
CHANGED
|
@@ -139,5 +139,5 @@
|
|
|
139
139
|
null,
|
|
140
140
|
null
|
|
141
141
|
],
|
|
142
|
-
"mappings": ";;;;;;;;;kBA6BiBA,OAAOA;;;;;;;;;;;;;;;;;;;;;;aAsBZC,iBAAiBA;;;;;aAKjBC,cAAcA;;;;;;;;;;;;;;;;;;;;;;;kBAuBTC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAuFPC,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