@sveltejs/kit 2.17.0 → 2.17.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "2.17.0",
3
+ "version": "2.17.2",
4
4
  "description": "SvelteKit is the fastest way to build Svelte apps",
5
5
  "keywords": [
6
6
  "framework",
@@ -330,7 +330,7 @@ async function prerender({ hash, out, manifest_path, metadata, verbose, env }) {
330
330
  /** @type {Set<string>} */ (expected_hashlinks.get(key)).add(decoded);
331
331
  }
332
332
 
333
- enqueue(decoded, decode_uri(pathname), pathname);
333
+ void enqueue(decoded, decode_uri(pathname), pathname);
334
334
  }
335
335
  }
336
336
  }
@@ -366,7 +366,7 @@ async function prerender({ hash, out, manifest_path, metadata, verbose, env }) {
366
366
  if (location) {
367
367
  const resolved = resolve(encoded, location);
368
368
  if (is_root_relative(resolved)) {
369
- enqueue(decoded, decode_uri(resolved), resolved);
369
+ void enqueue(decoded, decode_uri(resolved), resolved);
370
370
  }
371
371
 
372
372
  if (!headers['x-sveltekit-normalize']) {
@@ -485,17 +485,17 @@ async function prerender({ hash, out, manifest_path, metadata, verbose, env }) {
485
485
 
486
486
  if (processed_id.includes('[')) continue;
487
487
  const path = `/${get_route_segments(processed_id).join('/')}`;
488
- enqueue(null, config.paths.base + path);
488
+ void enqueue(null, config.paths.base + path);
489
489
  }
490
490
  }
491
491
  } else {
492
- enqueue(null, config.paths.base + entry);
492
+ void enqueue(null, config.paths.base + entry);
493
493
  }
494
494
  }
495
495
 
496
496
  for (const { id, entries } of route_level_entries) {
497
497
  for (const entry of entries) {
498
- enqueue(null, config.paths.base + entry, undefined, id);
498
+ void enqueue(null, config.paths.base + entry, undefined, id);
499
499
  }
500
500
  }
501
501
 
@@ -13,6 +13,7 @@ export function queue(concurrency) {
13
13
 
14
14
  let current = 0;
15
15
 
16
+ // TODO: Whenever Node >21 is minimum supported version, we can use `Promise.withResolvers` to avoid this ceremony
16
17
  /** @type {(value?: any) => void} */
17
18
  let fulfil;
18
19
 
@@ -39,7 +40,7 @@ export function queue(concurrency) {
39
40
  current += 1;
40
41
  const promise = Promise.resolve(task.fn());
41
42
 
42
- promise
43
+ void promise
43
44
  .then(task.fulfil, (err) => {
44
45
  task.reject(err);
45
46
  reject(err);
@@ -26,7 +26,7 @@ function get_raw_body(req, body_size_limit) {
26
26
 
27
27
  if (req.destroyed) {
28
28
  const readable = new ReadableStream();
29
- readable.cancel();
29
+ void readable.cancel();
30
30
  return readable;
31
31
  }
32
32
 
@@ -176,7 +176,7 @@ export async function setResponse(res, response) {
176
176
  const reader = response.body.getReader();
177
177
 
178
178
  if (res.destroyed) {
179
- reader.cancel();
179
+ void reader.cancel();
180
180
  return;
181
181
  }
182
182
 
@@ -193,7 +193,7 @@ export async function setResponse(res, response) {
193
193
  res.on('close', cancel);
194
194
  res.on('error', cancel);
195
195
 
196
- next();
196
+ void next();
197
197
  async function next() {
198
198
  try {
199
199
  for (;;) {
@@ -1484,7 +1484,7 @@ export type SubmitFunction<
1484
1484
  * @param invalidateAll Set `invalidateAll: false` if you don't want the action to call `invalidateAll` after submission.
1485
1485
  */
1486
1486
  update: (options?: { reset?: boolean; invalidateAll?: boolean }) => Promise<void>;
1487
- }) => void)
1487
+ }) => MaybePromise<void>)
1488
1488
  >;
1489
1489
 
1490
1490
  /**
@@ -375,11 +375,11 @@ export async function dev(vite, vite_config, svelte_config) {
375
375
  // changing the svelte config requires restarting the dev server
376
376
  // the config is only read on start and passed on to vite-plugin-svelte
377
377
  // which needs up-to-date values to operate correctly
378
- vite.watcher.on('change', (file) => {
378
+ vite.watcher.on('change', async (file) => {
379
379
  if (path.basename(file) === 'svelte.config.js') {
380
380
  console.log(`svelte config changed, restarting vite dev-server. changed file: ${file}`);
381
381
  restarting = true;
382
- vite.restart();
382
+ await vite.restart();
383
383
  }
384
384
  });
385
385
 
@@ -408,14 +408,14 @@ export async function dev(vite, vite_config, svelte_config) {
408
408
  SvelteKitError: control_module_vite.SvelteKitError
409
409
  });
410
410
  }
411
- align_exports();
411
+ await align_exports();
412
412
  const ws_send = vite.ws.send;
413
413
  /** @param {any} args */
414
414
  vite.ws.send = function (...args) {
415
415
  // We need to reapply the patch after Vite did dependency optimizations
416
416
  // because that clears the module resolutions
417
417
  if (args[0]?.type === 'full-reload' && args[0].path === '*') {
418
- align_exports();
418
+ void align_exports();
419
419
  }
420
420
  return ws_send.apply(vite.ws, args);
421
421
  };
@@ -568,10 +568,10 @@ export async function dev(vite, vite_config, svelte_config) {
568
568
  if (rendered.status === 404) {
569
569
  // @ts-expect-error
570
570
  serve_static_middleware.handle(req, res, () => {
571
- setResponse(res, rendered);
571
+ void setResponse(res, rendered);
572
572
  });
573
573
  } else {
574
- setResponse(res, rendered);
574
+ void setResponse(res, rendered);
575
575
  }
576
576
  } catch (e) {
577
577
  const error = coalesce_to_error(e);
@@ -192,7 +192,7 @@ export async function preview(vite, vite_config, svelte_config) {
192
192
  request: req
193
193
  });
194
194
 
195
- setResponse(
195
+ await setResponse(
196
196
  res,
197
197
  await server.respond(request, {
198
198
  getClientAddress: () => {
@@ -109,7 +109,7 @@ export function enhance(form_element, submit = () => {}) {
109
109
  result.type === 'redirect' ||
110
110
  result.type === 'error'
111
111
  ) {
112
- applyAction(result);
112
+ await applyAction(result);
113
113
  }
114
114
  };
115
115
 
@@ -205,7 +205,7 @@ export function enhance(form_element, submit = () => {}) {
205
205
  result = { type: 'error', error };
206
206
  }
207
207
 
208
- callback({
208
+ await callback({
209
209
  action,
210
210
  formData: form_data,
211
211
  formElement: form_element,
@@ -11,5 +11,5 @@ import * as app from '__sveltekit/manifest';
11
11
  * @param {import('./types.js').HydrateOptions} options
12
12
  */
13
13
  export function start(element, options) {
14
- kit.start(app, element, options);
14
+ void kit.start(app, element, options);
15
15
  }
@@ -39,7 +39,7 @@ import { INVALIDATED_PARAM, TRAILING_SLASH_PARAM, validate_depends } from '../sh
39
39
  import { get_message, get_status } from '../../utils/error.js';
40
40
  import { writable } from 'svelte/store';
41
41
  import { page, update, navigating } from './state.svelte.js';
42
- import { add_data_suffix, add_resolution_prefix } from '../pathname.js';
42
+ import { add_data_suffix, add_resolution_suffix } from '../pathname.js';
43
43
 
44
44
  const ICON_REL_ATTRIBUTES = new Set(['icon', 'shortcut icon', 'apple-touch-icon']);
45
45
 
@@ -273,8 +273,8 @@ export async function start(_app, _target, hydrate) {
273
273
  // connectivity errors after initialisation don't nuke the app
274
274
  default_layout_loader = _app.nodes[0];
275
275
  default_error_loader = _app.nodes[1];
276
- default_layout_loader();
277
- default_error_loader();
276
+ void default_layout_loader();
277
+ void default_error_loader();
278
278
 
279
279
  current_history_index = history.state?.[HISTORY_INDEX];
280
280
  current_navigation_index = history.state?.[NAVIGATION_INDEX];
@@ -306,7 +306,7 @@ export async function start(_app, _target, hydrate) {
306
306
  if (hydrate) {
307
307
  await _hydrate(target, hydrate);
308
308
  } else {
309
- goto(app.hash ? decode_hash(new URL(location.href)) : location.href, {
309
+ await goto(app.hash ? decode_hash(new URL(location.href)) : location.href, {
310
310
  replaceState: true
311
311
  });
312
312
  }
@@ -1265,7 +1265,7 @@ async function get_navigation_intent(url, invalidating) {
1265
1265
  /** @type {{ route?: import('types').CSRRouteServer, params: Record<string, string>}} */
1266
1266
  const { route, params } = await import(
1267
1267
  /* @vite-ignore */
1268
- add_resolution_prefix(url.pathname)
1268
+ add_resolution_suffix(url.pathname)
1269
1269
  );
1270
1270
 
1271
1271
  if (!route) return;
@@ -1448,7 +1448,7 @@ async function navigate({
1448
1448
  route: { id: null }
1449
1449
  });
1450
1450
  } else {
1451
- _goto(new URL(navigation_result.location, url).href, {}, redirect_count + 1, nav_token);
1451
+ await _goto(new URL(navigation_result.location, url).href, {}, redirect_count + 1, nav_token);
1452
1452
  return false;
1453
1453
  }
1454
1454
  } else if (/** @type {number} */ (navigation_result.props.page.status) >= 400) {
@@ -1644,14 +1644,14 @@ function setup_preload() {
1644
1644
 
1645
1645
  clearTimeout(mousemove_timeout);
1646
1646
  mousemove_timeout = setTimeout(() => {
1647
- preload(target, 2);
1647
+ void preload(target, 2);
1648
1648
  }, 20);
1649
1649
  });
1650
1650
 
1651
1651
  /** @param {Event} event */
1652
1652
  function tap(event) {
1653
1653
  if (event.defaultPrevented) return;
1654
- preload(/** @type {Element} */ (event.composedPath()[0]), 1);
1654
+ void preload(/** @type {Element} */ (event.composedPath()[0]), 1);
1655
1655
  }
1656
1656
 
1657
1657
  container.addEventListener('mousedown', tap);
@@ -1661,7 +1661,7 @@ function setup_preload() {
1661
1661
  (entries) => {
1662
1662
  for (const entry of entries) {
1663
1663
  if (entry.isIntersecting) {
1664
- _preload_code(new URL(/** @type {HTMLAnchorElement} */ (entry.target).href));
1664
+ void _preload_code(new URL(/** @type {HTMLAnchorElement} */ (entry.target).href));
1665
1665
  observer.unobserve(entry.target);
1666
1666
  }
1667
1667
  }
@@ -1692,7 +1692,7 @@ function setup_preload() {
1692
1692
  const intent = await get_navigation_intent(url, false);
1693
1693
  if (intent) {
1694
1694
  if (DEV) {
1695
- _preload_data(intent).then((result) => {
1695
+ void _preload_data(intent).then((result) => {
1696
1696
  if (result.type === 'loaded' && result.state.error) {
1697
1697
  console.warn(
1698
1698
  `Preloading data for ${intent.url.pathname} failed with the following error: ${result.state.error.message}\n` +
@@ -1703,11 +1703,11 @@ function setup_preload() {
1703
1703
  }
1704
1704
  });
1705
1705
  } else {
1706
- _preload_data(intent);
1706
+ void _preload_data(intent);
1707
1707
  }
1708
1708
  }
1709
1709
  } else if (priority <= options.preload_code) {
1710
- _preload_code(/** @type {URL} */ (url));
1710
+ void _preload_code(/** @type {URL} */ (url));
1711
1711
  }
1712
1712
  }
1713
1713
  }
@@ -1727,7 +1727,7 @@ function setup_preload() {
1727
1727
  }
1728
1728
 
1729
1729
  if (options.preload_code === PRELOAD_PRIORITIES.eager) {
1730
- _preload_code(/** @type {URL} */ (url));
1730
+ void _preload_code(/** @type {URL} */ (url));
1731
1731
  }
1732
1732
  }
1733
1733
  }
@@ -2127,10 +2127,10 @@ export async function applyAction(result) {
2127
2127
  root.$set(navigation_result.props);
2128
2128
  update(navigation_result.props.page);
2129
2129
 
2130
- tick().then(reset_focus);
2130
+ void tick().then(reset_focus);
2131
2131
  }
2132
2132
  } else if (result.type === 'redirect') {
2133
- _goto(result.location, { invalidateAll: true }, 0);
2133
+ await _goto(result.location, { invalidateAll: true }, 0);
2134
2134
  } else {
2135
2135
  page.form = result.data;
2136
2136
  page.status = result.status;
@@ -2311,7 +2311,7 @@ function _start_router() {
2311
2311
  setTimeout(fulfil, 100); // fallback for edge case where rAF doesn't fire because e.g. tab was backgrounded
2312
2312
  });
2313
2313
 
2314
- navigate({
2314
+ await navigate({
2315
2315
  type: 'link',
2316
2316
  url,
2317
2317
  keepfocus: options.keepfocus,
@@ -2362,7 +2362,7 @@ function _start_router() {
2362
2362
  // @ts-expect-error `URLSearchParams(fd)` is kosher, but typescript doesn't know that
2363
2363
  url.search = new URLSearchParams(data).toString();
2364
2364
 
2365
- navigate({
2365
+ void navigate({
2366
2366
  type: 'form',
2367
2367
  url,
2368
2368
  keepfocus: options.keepfocus,
@@ -2455,7 +2455,7 @@ function _start_router() {
2455
2455
  // (surprisingly!) mutates `current.url`, allowing us to
2456
2456
  // detect it and trigger a navigation
2457
2457
  if (current.url.hash === location.hash) {
2458
- navigate({ type: 'goto', url: decode_hash(current.url) });
2458
+ void navigate({ type: 'goto', url: decode_hash(current.url) });
2459
2459
  }
2460
2460
  }
2461
2461
  });
@@ -25,7 +25,7 @@ if (DEV && BROWSER) {
25
25
  can_inspect_stack_trace = stack.includes('check_stack_trace');
26
26
  };
27
27
 
28
- check_stack_trace();
28
+ void check_stack_trace();
29
29
 
30
30
  /**
31
31
  * @param {RequestInfo | URL} input
@@ -1,5 +1,3 @@
1
- import { base, app_dir } from '__sveltekit/paths';
2
-
3
1
  const DATA_SUFFIX = '/__data.json';
4
2
  const HTML_DATA_SUFFIX = '.html__data.json';
5
3
 
@@ -23,14 +21,14 @@ export function strip_data_suffix(pathname) {
23
21
  return pathname.slice(0, -DATA_SUFFIX.length);
24
22
  }
25
23
 
26
- const ROUTE_PREFIX = `${base}/${app_dir}/route`;
24
+ const ROUTE_SUFFIX = '/__route.js';
27
25
 
28
26
  /**
29
27
  * @param {string} pathname
30
28
  * @returns {boolean}
31
29
  */
32
- export function has_resolution_prefix(pathname) {
33
- return pathname === `${ROUTE_PREFIX}.js` || pathname.startsWith(`${ROUTE_PREFIX}/`);
30
+ export function has_resolution_suffix(pathname) {
31
+ return pathname.endsWith(ROUTE_SUFFIX);
34
32
  }
35
33
 
36
34
  /**
@@ -38,17 +36,14 @@ export function has_resolution_prefix(pathname) {
38
36
  * @param {string} pathname
39
37
  * @returns {string}
40
38
  */
41
- export function add_resolution_prefix(pathname) {
42
- let normalized = pathname.slice(base.length);
43
- if (normalized.endsWith('/')) normalized = normalized.slice(0, -1);
44
-
45
- return `${ROUTE_PREFIX}${normalized}.js`;
39
+ export function add_resolution_suffix(pathname) {
40
+ return pathname.replace(/\/$/, '') + ROUTE_SUFFIX;
46
41
  }
47
42
 
48
43
  /**
49
44
  * @param {string} pathname
50
45
  * @returns {string}
51
46
  */
52
- export function strip_resolution_prefix(pathname) {
53
- return base + (pathname.slice(ROUTE_PREFIX.length, -3) || '/');
47
+ export function strip_resolution_suffix(pathname) {
48
+ return pathname.slice(0, -ROUTE_SUFFIX.length);
54
49
  }
@@ -14,7 +14,7 @@ import { create_async_iterator } from '../../../utils/streaming.js';
14
14
  import { SVELTE_KIT_ASSETS } from '../../../constants.js';
15
15
  import { SCHEME } from '../../../utils/url.js';
16
16
  import { create_server_routing_response, generate_route_object } from './server_routing.js';
17
- import { add_resolution_prefix } from '../../pathname.js';
17
+ import { add_resolution_suffix } from '../../pathname.js';
18
18
 
19
19
  // TODO rename this function/module
20
20
 
@@ -321,9 +321,9 @@ export async function render_response({
321
321
  }
322
322
  }
323
323
 
324
- // prerender a `/_app/route/path/to/page.js` module
324
+ // prerender a `/path/to/page/__route.js` module
325
325
  if (manifest._.client.routes && state.prerendering && !state.prerendering.fallback) {
326
- const pathname = add_resolution_prefix(event.url.pathname);
326
+ const pathname = add_resolution_suffix(event.url.pathname);
327
327
 
328
328
  state.prerendering.dependencies.set(
329
329
  pathname,
@@ -1,4 +1,4 @@
1
- import { base, assets } from '__sveltekit/paths';
1
+ import { base, assets, relative } from '__sveltekit/paths';
2
2
  import { text } from '../../../exports/index.js';
3
3
  import { s } from '../../../utils/misc.js';
4
4
  import { exec } from '../../../utils/routing.js';
@@ -47,6 +47,10 @@ function create_client_import(import_path, url) {
47
47
  return `import('${assets}/${import_path}')`;
48
48
  }
49
49
 
50
+ if (!relative) {
51
+ return `import('${base}/${import_path}')`;
52
+ }
53
+
50
54
  // Else we make them relative to the server-side route resolution request
51
55
  // to support IPFS, the internet archive, etc.
52
56
  let path = get_relative_path(url.pathname, `${base}/${import_path}`);
@@ -30,9 +30,9 @@ import { resolve_route } from './page/server_routing.js';
30
30
  import { validateHeaders } from './validate-headers.js';
31
31
  import {
32
32
  has_data_suffix,
33
- has_resolution_prefix,
33
+ has_resolution_suffix,
34
34
  strip_data_suffix,
35
- strip_resolution_prefix
35
+ strip_resolution_suffix
36
36
  } from '../pathname.js';
37
37
 
38
38
  /* global __SVELTEKIT_ADAPTER_NAME__ */
@@ -94,11 +94,11 @@ export async function respond(request, options, manifest, state) {
94
94
  * If the request is for a route resolution, first modify the URL, then continue as normal
95
95
  * for path resolution, then return the route object as a JS file.
96
96
  */
97
- const is_route_resolution_request = has_resolution_prefix(url.pathname);
97
+ const is_route_resolution_request = has_resolution_suffix(url.pathname);
98
98
  const is_data_request = has_data_suffix(url.pathname);
99
99
 
100
100
  if (is_route_resolution_request) {
101
- url.pathname = strip_resolution_prefix(url.pathname);
101
+ url.pathname = strip_resolution_suffix(url.pathname);
102
102
  } else if (is_data_request) {
103
103
  url.pathname =
104
104
  strip_data_suffix(url.pathname) +
@@ -121,7 +121,7 @@ export type CSRRoute = {
121
121
  };
122
122
 
123
123
  /**
124
- * Definition of a client side route as transported via `_app/route/...` when using server-side route resolution.
124
+ * Definition of a client side route as transported via `<pathname>/__route.js` when using server-side route resolution.
125
125
  */
126
126
  export type CSRRouteServer = {
127
127
  id: string;
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // generated during release, do not modify
2
2
 
3
3
  /** @type {string} */
4
- export const VERSION = '2.17.0';
4
+ export const VERSION = '2.17.2';
package/types/index.d.ts CHANGED
@@ -1466,7 +1466,7 @@ declare module '@sveltejs/kit' {
1466
1466
  * @param invalidateAll Set `invalidateAll: false` if you don't want the action to call `invalidateAll` after submission.
1467
1467
  */
1468
1468
  update: (options?: { reset?: boolean; invalidateAll?: boolean }) => Promise<void>;
1469
- }) => void)
1469
+ }) => MaybePromise<void>)
1470
1470
  >;
1471
1471
 
1472
1472
  /**