@sveltejs/kit 1.28.0 → 1.29.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": "1.28.0",
3
+ "version": "1.29.1",
4
4
  "description": "The fastest way to build Svelte apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -113,7 +113,11 @@ export function fail(status, data) {
113
113
 
114
114
  const basic_param_pattern = /\[(\[)?(\.\.\.)?(\w+?)(?:=(\w+))?\]\]?/g;
115
115
 
116
+ let warned = false;
117
+
116
118
  /**
119
+ * @deprecated Use `resolveRoute` from `$app/paths` instead.
120
+ *
117
121
  * Populate a route ID with params to resolve a pathname.
118
122
  * @example
119
123
  * ```js
@@ -130,6 +134,11 @@ const basic_param_pattern = /\[(\[)?(\.\.\.)?(\w+?)(?:=(\w+))?\]\]?/g;
130
134
  * @returns {string}
131
135
  */
132
136
  export function resolvePath(id, params) {
137
+ if (!warned) {
138
+ console.warn('`resolvePath` is deprecated. Use `resolveRoute` from `$app/paths` instead.');
139
+ warned = true;
140
+ }
141
+
133
142
  const segments = get_route_segments(id);
134
143
  return (
135
144
  '/' +
@@ -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
  */
@@ -1 +1,50 @@
1
1
  export { base, assets } from '__sveltekit/paths';
2
+ import { base } from '__sveltekit/paths';
3
+ import { get_route_segments } from '../../utils/routing.js';
4
+
5
+ const basic_param_pattern = /\[(\[)?(\.\.\.)?(\w+?)(?:=(\w+))?\]\]?/g;
6
+
7
+ /**
8
+ * Populate a route ID with params to resolve a pathname.
9
+ * @example
10
+ * ```js
11
+ * resolveRoute(
12
+ * `/blog/[slug]/[...somethingElse]`,
13
+ * {
14
+ * slug: 'hello-world',
15
+ * somethingElse: 'something/else'
16
+ * }
17
+ * ); // `/blog/hello-world/something/else`
18
+ * ```
19
+ * @param {string} id
20
+ * @param {Record<string, string | undefined>} params
21
+ * @returns {string}
22
+ */
23
+ export function resolveRoute(id, params) {
24
+ const segments = get_route_segments(id);
25
+ return (
26
+ base +
27
+ '/' +
28
+ segments
29
+ .map((segment) =>
30
+ segment.replace(basic_param_pattern, (_, optional, rest, name) => {
31
+ const param_value = params[name];
32
+
33
+ // This is nested so TS correctly narrows the type
34
+ if (!param_value) {
35
+ if (optional) return '';
36
+ if (rest && param_value !== undefined) return '';
37
+ throw new Error(`Missing parameter '${name}' in route ${id}`);
38
+ }
39
+
40
+ if (param_value.startsWith('/') || param_value.endsWith('/'))
41
+ throw new Error(
42
+ `Parameter '${name}' in route ${id} cannot start or end with a slash -- this would cause an invalid route like foo//bar`
43
+ );
44
+ return param_value;
45
+ })
46
+ )
47
+ .filter(Boolean)
48
+ .join('/')
49
+ );
50
+ }
@@ -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) => {
@@ -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 new Error(
223
+ throw error(
224
+ 415,
224
225
  `Actions expect form-encoded data (received ${event.request.headers.get('content-type')})`
225
226
  );
226
227
  }
@@ -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
@@ -1,4 +1,4 @@
1
1
  // generated during release, do not modify
2
2
 
3
3
  /** @type {string} */
4
- export const VERSION = '1.28.0';
4
+ export const VERSION = '1.29.1';
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
  */
@@ -1720,6 +1722,8 @@ declare module '@sveltejs/kit' {
1720
1722
  * */
1721
1723
  export function fail<T extends Record<string, unknown> | undefined = undefined>(status: number, data?: T | undefined): ActionFailure<T>;
1722
1724
  /**
1725
+ * @deprecated Use `resolveRoute` from `$app/paths` instead.
1726
+ *
1723
1727
  * Populate a route ID with params to resolve a pathname.
1724
1728
  * @example
1725
1729
  * ```js
@@ -1997,6 +2001,20 @@ declare module '$app/navigation' {
1997
2001
 
1998
2002
  declare module '$app/paths' {
1999
2003
  export { base, assets } from '__sveltekit/paths';
2004
+ /**
2005
+ * Populate a route ID with params to resolve a pathname.
2006
+ * @example
2007
+ * ```js
2008
+ * resolveRoute(
2009
+ * `/blog/[slug]/[...somethingElse]`,
2010
+ * {
2011
+ * slug: 'hello-world',
2012
+ * somethingElse: 'something/else'
2013
+ * }
2014
+ * ); // `/blog/hello-world/something/else`
2015
+ * ```
2016
+ * */
2017
+ export function resolveRoute(id: string, params: Record<string, string | undefined>): string;
2000
2018
  }
2001
2019
 
2002
2020
  declare module '$app/stores' {
@@ -99,6 +99,7 @@
99
99
  "beforeNavigate",
100
100
  "onNavigate",
101
101
  "afterNavigate",
102
+ "resolveRoute",
102
103
  "getStores",
103
104
  "page",
104
105
  "navigating",
@@ -118,6 +119,7 @@
118
119
  "../src/runtime/app/environment.js",
119
120
  "../src/runtime/app/forms.js",
120
121
  "../src/runtime/app/navigation.js",
122
+ "../src/runtime/app/paths.js",
121
123
  "../src/runtime/app/stores.js"
122
124
  ],
123
125
  "sourcesContent": [
@@ -134,7 +136,8 @@
134
136
  null,
135
137
  null,
136
138
  null,
139
+ null,
137
140
  null
138
141
  ],
139
- "mappings": ";;;;;;;;;kBA6BiBA,OAAOA;;;;;;;;;;;;;;;;;;;;;;aAsBZC,iBAAiBA;;;;;aAKjBC,cAAcA;;;;;;;;;;;;;;;;;;;;;;;kBAuBTC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAuFPC,MAAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA6BNC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAiDPC,SAASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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