@sveltejs/kit 2.26.0 → 2.26.1

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.26.0",
3
+ "version": "2.26.1",
4
4
  "description": "SvelteKit is the fastest way to build Svelte apps",
5
5
  "keywords": [
6
6
  "framework",
@@ -6,6 +6,7 @@ import { posixify, rimraf, walk } from '../../../utils/filesystem.js';
6
6
  import { compact } from '../../../utils/array.js';
7
7
  import { ts } from '../ts.js';
8
8
  import { s } from '../../../utils/misc.js';
9
+ import { get_route_segments } from '../../../utils/routing.js';
9
10
 
10
11
  const remove_relative_parent_traversals = (/** @type {string} */ path) =>
11
12
  path.replace(/\.\.\//g, '');
@@ -13,6 +14,10 @@ const replace_optional_params = (/** @type {string} */ id) =>
13
14
  id.replace(/\/\[\[[^\]]+\]\]/g, '${string}');
14
15
  const replace_required_params = (/** @type {string} */ id) =>
15
16
  id.replace(/\/\[[^\]]+\]/g, '/${string}');
17
+ /** Convert route ID to pathname by removing layout groups */
18
+ const remove_group_segments = (/** @type {string} */ id) => {
19
+ return '/' + get_route_segments(id).join('/');
20
+ };
16
21
  const is_whitespace = (/** @type {string} */ char) => /\s/.test(char);
17
22
 
18
23
  /**
@@ -60,8 +65,8 @@ export function write_all_types(config, manifest_data) {
60
65
  }
61
66
  }
62
67
 
63
- /** @type {string[]} */
64
- const pathnames = [];
68
+ /** @type {Set<string>} */
69
+ const pathnames = new Set();
65
70
 
66
71
  /** @type {string[]} */
67
72
  const dynamic_routes = [];
@@ -76,9 +81,11 @@ export function write_all_types(config, manifest_data) {
76
81
 
77
82
  dynamic_routes.push(route_type);
78
83
 
79
- pathnames.push(`\`${replace_required_params(replace_optional_params(route.id))}\` & {}`);
84
+ const pathname = remove_group_segments(route.id);
85
+ pathnames.add(`\`${replace_required_params(replace_optional_params(pathname))}\` & {}`);
80
86
  } else {
81
- pathnames.push(s(route.id));
87
+ const pathname = remove_group_segments(route.id);
88
+ pathnames.add(s(pathname));
82
89
  }
83
90
 
84
91
  /** @type {Map<string, boolean>} */
@@ -113,7 +120,7 @@ export function write_all_types(config, manifest_data) {
113
120
  `export type RouteId = ${manifest_data.routes.map((r) => s(r.id)).join(' | ')};`,
114
121
  'export type RouteParams<T extends RouteId> = T extends keyof DynamicRoutes ? DynamicRoutes[T] : Record<string, never>;',
115
122
  'export type LayoutParams<T extends RouteId> = Layouts[T] | Record<string, never>;',
116
- `export type Pathname = ${pathnames.join(' | ')};`,
123
+ `export type Pathname = ${Array.from(pathnames).join(' | ')};`,
117
124
  'export type ResolvedPathname = `${"" | `/${string}`}${Pathname}`;',
118
125
  `export type Asset = ${manifest_data.assets.map((asset) => s('/' + asset.file)).join(' | ') || 'never'};`
119
126
  ].join('\n\n')
@@ -1,4 +1,5 @@
1
1
  import { fileURLToPath } from 'node:url';
2
+ import { posixify } from '../../utils/filesystem.js';
2
3
 
3
4
  export const env_static_private = '\0virtual:env/static/private';
4
5
  export const env_static_public = '\0virtual:env/static/public';
@@ -11,6 +12,6 @@ export const sveltekit_environment = '\0virtual:__sveltekit/environment';
11
12
  export const sveltekit_paths = '\0virtual:__sveltekit/paths';
12
13
  export const sveltekit_server = '\0virtual:__sveltekit/server';
13
14
 
14
- export const app_server = fileURLToPath(
15
- new URL('../../runtime/app/server/index.js', import.meta.url)
15
+ export const app_server = posixify(
16
+ fileURLToPath(new URL('../../runtime/app/server/index.js', import.meta.url))
16
17
  );
@@ -117,7 +117,7 @@ export function remove_optional_params(id) {
117
117
  * @param {string} segment
118
118
  */
119
119
  function affects_path(segment) {
120
- return !/^\([^)]+\)$/.test(segment);
120
+ return segment !== '' && !/^\([^)]+\)$/.test(segment);
121
121
  }
122
122
 
123
123
  /**
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.26.0';
4
+ export const VERSION = '2.26.1';