@sveltejs/kit 1.5.5 → 1.5.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.5.5",
3
+ "version": "1.5.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -80,7 +80,7 @@
80
80
  "node": "^16.14 || >=18"
81
81
  },
82
82
  "scripts": {
83
- "lint": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore && eslint src/**",
83
+ "lint": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore && eslint src/**/*.js",
84
84
  "check": "tsc",
85
85
  "check:all": "tsc && pnpm -r --filter=\"./**\" check",
86
86
  "format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore",
@@ -179,6 +179,9 @@ function kit({ svelte_config }) {
179
179
  /** @type {() => Promise<void>} */
180
180
  let finalise;
181
181
 
182
+ /** @type {import('vite').UserConfig} */
183
+ let initial_config;
184
+
182
185
  const service_worker_entry_file = resolve_entry(kit.files.serviceWorker);
183
186
 
184
187
  /** @type {import('vite').Plugin} */
@@ -190,6 +193,7 @@ function kit({ svelte_config }) {
190
193
  * @see https://vitejs.dev/guide/api-plugin.html#config
191
194
  */
192
195
  async config(config, config_env) {
196
+ initial_config = config;
193
197
  vite_config_env = config_env;
194
198
  is_build = config_env.command === 'build';
195
199
 
@@ -316,7 +320,7 @@ function kit({ svelte_config }) {
316
320
 
317
321
  async resolveId(id) {
318
322
  // treat $env/static/[public|private] as virtual
319
- if (id.startsWith('$env/') || id === '$internal/paths' || id === '$service-worker') {
323
+ if (id.startsWith('$env/') || id === '@sveltejs/kit/paths' || id === '$service-worker') {
320
324
  return `\0${id}`;
321
325
  }
322
326
  },
@@ -354,7 +358,9 @@ function kit({ svelte_config }) {
354
358
  );
355
359
  case '\0$service-worker':
356
360
  return create_service_worker_module(svelte_config);
357
- case '\0$internal/paths':
361
+ // for internal use only. it's published as $app/paths externally
362
+ // we use this alias so that we won't collide with user aliases
363
+ case '\0@sveltejs/kit/paths':
358
364
  const { assets, base } = svelte_config.kit.paths;
359
365
  return `export const base = ${s(base)};
360
366
  export let assets = ${assets ? s(assets) : 'base'};
@@ -634,7 +640,7 @@ export function set_assets(path) {
634
640
  logLevel: vite_config.logLevel,
635
641
  clearScreen: vite_config.clearScreen,
636
642
  build: {
637
- minify: vite_config.build.minify,
643
+ minify: initial_config.build?.minify,
638
644
  assetsInlineLimit: vite_config.build.assetsInlineLimit,
639
645
  sourcemap: vite_config.build.sourcemap
640
646
  },
@@ -0,0 +1,6 @@
1
+ /** Internal version of $app/paths */
2
+ declare module '@sveltejs/kit/paths' {
3
+ export const base: `/${string}`;
4
+ export let assets: `https://${string}` | `http://${string}`;
5
+ export function set_assets(path: string): void;
6
+ }
@@ -1 +1 @@
1
- export { base, assets } from '$internal/paths';
1
+ export { base, assets } from '@sveltejs/kit/paths';
@@ -27,7 +27,7 @@ import { parse } from './parse.js';
27
27
 
28
28
  import Root from '__GENERATED__/root.svelte';
29
29
  import { nodes, server_loads, dictionary, matchers, hooks } from '__CLIENT__/manifest.js';
30
- import { base } from '$internal/paths';
30
+ import { base } from '@sveltejs/kit/paths';
31
31
  import { HttpError, Redirect } from '../control.js';
32
32
  import { stores } from './singletons.js';
33
33
  import { unwrap_promises } from '../../utils/promises.js';
@@ -311,7 +311,7 @@ export function create_client({ target }) {
311
311
  );
312
312
  return false;
313
313
  }
314
- } else if (/** @type {number} */ (navigation_result.props?.page?.status) >= 400) {
314
+ } else if (/** @type {number} */ (navigation_result.props.page?.status) >= 400) {
315
315
  const updated = await stores.updated.check();
316
316
  if (updated) {
317
317
  await native_navigation(url);
@@ -331,6 +331,14 @@ export function create_client({ target }) {
331
331
  capture_snapshot(previous_history_index);
332
332
  }
333
333
 
334
+ // ensure the url pathname matches the page's trailing slash option
335
+ if (
336
+ navigation_result.props.page?.url &&
337
+ navigation_result.props.page.url.pathname !== url.pathname
338
+ ) {
339
+ url.pathname = navigation_result.props.page?.url.pathname;
340
+ }
341
+
334
342
  if (opts && opts.details) {
335
343
  const { details } = opts;
336
344
  const change = details.replaceState ? 0 : 1;
@@ -355,6 +363,7 @@ export function create_client({ target }) {
355
363
  if (started) {
356
364
  current = navigation_result.state;
357
365
 
366
+ // reset url before updating page store
358
367
  if (navigation_result.props.page) {
359
368
  navigation_result.props.page.url = url;
360
369
  }
@@ -1,6 +1,6 @@
1
1
  import { BROWSER, DEV } from 'esm-env';
2
2
  import { writable } from 'svelte/store';
3
- import { assets } from '$internal/paths';
3
+ import { assets } from '@sveltejs/kit/paths';
4
4
  import { version } from '../shared.js';
5
5
  import { PRELOAD_PRIORITIES } from './constants.js';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import * as set_cookie_parser from 'set-cookie-parser';
2
2
  import { respond } from './respond.js';
3
- import * as paths from '$internal/paths';
3
+ import * as paths from '@sveltejs/kit/paths';
4
4
 
5
5
  /**
6
6
  * @param {{
@@ -1,7 +1,7 @@
1
1
  import * as devalue from 'devalue';
2
2
  import { readable, writable } from 'svelte/store';
3
3
  import { DEV } from 'esm-env';
4
- import { assets, base } from '$internal/paths';
4
+ import { assets, base } from '@sveltejs/kit/paths';
5
5
  import { hash } from '../../hash.js';
6
6
  import { serialize_data } from './serialize_data.js';
7
7
  import { s } from '../../../utils/misc.js';
@@ -1,5 +1,5 @@
1
1
  import { DEV } from 'esm-env';
2
- import { base } from '$internal/paths';
2
+ import { base } from '@sveltejs/kit/paths';
3
3
  import { is_endpoint_request, render_endpoint } from './endpoint.js';
4
4
  import { render_page } from './page/index.js';
5
5
  import { render_response } from './page/render.js';
@@ -1,4 +1,4 @@
1
- export { set_assets } from '$internal/paths';
1
+ export { set_assets } from '@sveltejs/kit/paths';
2
2
 
3
3
  export let building = false;
4
4
  export let version = '';
@@ -438,10 +438,3 @@ declare module '@sveltejs/kit/vite' {
438
438
  export function sveltekit(): Promise<Plugin[]>;
439
439
  export { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
440
440
  }
441
-
442
- /** Internal version of $app/paths */
443
- declare module '$internal/paths' {
444
- export const base: `/${string}`;
445
- export let assets: `https://${string}` | `http://${string}`;
446
- export function set_assets(path: string): void;
447
- }
package/types/index.d.ts CHANGED
@@ -1129,7 +1129,7 @@ export type ActionResult<
1129
1129
  * Creates an `HttpError` object with an HTTP status code and an optional message.
1130
1130
  * This object, if thrown during request handling, will cause SvelteKit to
1131
1131
  * return an error response without invoking `handleError`.
1132
- * Make sure you're not catching the thrown error, which results in a noop.
1132
+ * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
1133
1133
  * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
1134
1134
  * @param body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property.
1135
1135
  */
@@ -1152,7 +1152,7 @@ export interface HttpError {
1152
1152
 
1153
1153
  /**
1154
1154
  * Create a `Redirect` object. If thrown during request handling, SvelteKit will return a redirect response.
1155
- * Make sure you're not catching the thrown redirect, which results in a noop.
1155
+ * Make sure you're not catching the thrown redirect, which would prevent SvelteKit from handling it.
1156
1156
  * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages). Must be in the range 300-308.
1157
1157
  * @param location The location to redirect to.
1158
1158
  */