@sveltejs/kit 2.7.1 → 2.7.3

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.
@@ -197,7 +197,7 @@ export async function handle_action_request(event, server) {
197
197
  function check_named_default_separate(actions) {
198
198
  if (actions.default && Object.keys(actions).length > 1) {
199
199
  throw new Error(
200
- 'When using named actions, the default action cannot be used. See the docs for more info: https://kit.svelte.dev/docs/form-actions#named-actions'
200
+ 'When using named actions, the default action cannot be used. See the docs for more info: https://svelte.dev/docs/kit/form-actions#named-actions'
201
201
  );
202
202
  }
203
203
  }
@@ -280,6 +280,14 @@ function try_deserialize(data, fn, route_id) {
280
280
  // If we're here, the data could not be serialized with devalue
281
281
  const error = /** @type {any} */ (e);
282
282
 
283
+ // if someone tries to use `json()` in their action
284
+ if (data instanceof Response) {
285
+ throw new Error(
286
+ `Data returned from action inside ${route_id} is not serializable. Form actions need to return plain objects or fail(). E.g. return { success: true } or return fail(400, { message: "invalid" });`
287
+ );
288
+ }
289
+
290
+ // if devalue could not serialize a property on the object, etc.
283
291
  if ('path' in error) {
284
292
  let message = `Data returned from action inside ${route_id} is not serializable: ${error.message}`;
285
293
  if (error.path !== '') message += ` (data.${error.path})`;
@@ -105,12 +105,12 @@ export async function render_page(event, page, options, manifest, state, resolve
105
105
  if (DEV && action_result && !event.request.headers.has('x-sveltekit-action')) {
106
106
  if (action_result.type === 'error') {
107
107
  console.warn(
108
- "The form action returned an error, but +error.svelte wasn't rendered because SSR is off. To get the error page with CSR, enhance your form with `use:enhance`. See https://kit.svelte.dev/docs/form-actions#progressive-enhancement-use-enhance"
108
+ "The form action returned an error, but +error.svelte wasn't rendered because SSR is off. To get the error page with CSR, enhance your form with `use:enhance`. See https://svelte.dev/docs/kit/form-actions#progressive-enhancement-use-enhance"
109
109
  );
110
110
  } else if (action_result.data) {
111
111
  /// case: lost data
112
112
  console.warn(
113
- "The form action returned a value, but it isn't available in `$page.form`, because SSR is off. To handle the returned value in CSR, enhance your form with `use:enhance`. See https://kit.svelte.dev/docs/form-actions#progressive-enhancement-use-enhance"
113
+ "The form action returned a value, but it isn't available in `$page.form`, because SSR is off. To handle the returned value in CSR, enhance your form with `use:enhance`. See https://svelte.dev/docs/kit/form-actions#progressive-enhancement-use-enhance"
114
114
  );
115
115
  }
116
116
  }
@@ -348,7 +348,7 @@ export function create_universal_fetch(event, state, fetched, csr, resolve_opts)
348
348
  const included = resolve_opts.filterSerializedResponseHeaders(lower, value);
349
349
  if (!included) {
350
350
  throw new Error(
351
- `Failed to get response header "${lower}" — it must be included by the \`filterSerializedResponseHeaders\` option: https://kit.svelte.dev/docs/hooks#server-hooks-handle (at ${event.route.id})`
351
+ `Failed to get response header "${lower}" — it must be included by the \`filterSerializedResponseHeaders\` option: https://svelte.dev/docs/kit/hooks#Server-hooks-handle (at ${event.route.id})`
352
352
  );
353
353
  }
354
354
  }
@@ -480,7 +480,7 @@ export async function render_response({
480
480
  if (page_config.csr) {
481
481
  if (transformed.split('<!--').length < html.split('<!--').length) {
482
482
  // the \u001B stuff is ANSI codes, so that we don't need to add a library to the runtime
483
- // https://svelte.dev/repl/1b3f49696f0c44c881c34587f2537aa2
483
+ // https://svelte.dev/playground/1b3f49696f0c44c881c34587f2537aa2?version=4.2.19
484
484
  console.warn(
485
485
  "\u001B[1m\u001B[31mRemoving comments in transformPageChunk can break Svelte's hydration\u001B[39m\u001B[22m"
486
486
  );
@@ -566,9 +566,8 @@ function get_data(event, options, nodes, csp, global) {
566
566
  str = devalue.uneval({ id, data, error }, replacer);
567
567
  }
568
568
 
569
- push(
570
- `<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ''}>${global}.resolve(${str})</script>\n`
571
- );
569
+ const nonce = csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : '';
570
+ push(`<script${nonce}>${global}.resolve(${str})</script>\n`);
572
571
  if (count === 0) done();
573
572
  }
574
573
  );
@@ -29,30 +29,30 @@ declare namespace App {
29
29
  }
30
30
 
31
31
  /**
32
- * The interface that defines `event.locals`, which can be accessed in [hooks](https://kit.svelte.dev/docs/hooks) (`handle`, and `handleError`), server-only `load` functions, and `+server.js` files.
32
+ * The interface that defines `event.locals`, which can be accessed in [hooks](https://svelte.dev/docs/kit/hooks) (`handle`, and `handleError`), server-only `load` functions, and `+server.js` files.
33
33
  */
34
34
  export interface Locals {}
35
35
 
36
36
  /**
37
- * Defines the common shape of the [$page.data store](https://kit.svelte.dev/docs/modules#$app-stores-page) - that is, the data that is shared between all pages.
37
+ * Defines the common shape of the [$page.data store](https://svelte.dev/docs/kit/$app-stores#page) - that is, the data that is shared between all pages.
38
38
  * The `Load` and `ServerLoad` functions in `./$types` will be narrowed accordingly.
39
39
  * Use optional properties for data that is only present on specific pages. Do not add an index signature (`[key: string]: any`).
40
40
  */
41
41
  export interface PageData {}
42
42
 
43
43
  /**
44
- * The shape of the `$page.state` object, which can be manipulated using the [`pushState`](https://kit.svelte.dev/docs/modules#$app-navigation-pushstate) and [`replaceState`](https://kit.svelte.dev/docs/modules#$app-navigation-replacestate) functions from `$app/navigation`.
44
+ * The shape of the `$page.state` object, which can be manipulated using the [`pushState`](https://svelte.dev/docs/kit/$app-navigation#pushState) and [`replaceState`](https://svelte.dev/docs/kit/$app-navigation#replaceState) functions from `$app/navigation`.
45
45
  */
46
46
  export interface PageState {}
47
47
 
48
48
  /**
49
- * If your adapter provides [platform-specific context](https://kit.svelte.dev/docs/adapters#platform-specific-context) via `event.platform`, you can specify it here.
49
+ * If your adapter provides [platform-specific context](https://svelte.dev/docs/kit/adapters#platform-specific-context) via `event.platform`, you can specify it here.
50
50
  */
51
51
  export interface Platform {}
52
52
  }
53
53
 
54
54
  /**
55
- * This module is only available to [service workers](https://kit.svelte.dev/docs/service-workers).
55
+ * This module is only available to [service workers](https://svelte.dev/docs/kit/service-workers).
56
56
  */
57
57
  declare module '$service-worker' {
58
58
  /**
@@ -66,7 +66,7 @@ declare module '$service-worker' {
66
66
  */
67
67
  export const build: string[];
68
68
  /**
69
- * An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.kit.files.assets`. You can customize which files are included from `static` directory using [`config.kit.serviceWorker.files`](https://kit.svelte.dev/docs/configuration)
69
+ * An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.kit.files.assets`. You can customize which files are included from `static` directory using [`config.kit.serviceWorker.files`](https://svelte.dev/docs/kit/configuration)
70
70
  */
71
71
  export const files: string[];
72
72
  /**
@@ -75,7 +75,7 @@ declare module '$service-worker' {
75
75
  */
76
76
  export const prerendered: string[];
77
77
  /**
78
- * See [`config.kit.version`](https://kit.svelte.dev/docs/configuration#version). It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches.
78
+ * See [`config.kit.version`](https://svelte.dev/docs/kit/configuration#version). It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches.
79
79
  */
80
80
  export const version: string;
81
81
  }
@@ -1,4 +1,4 @@
1
- This module provides access to runtime environment variables, as defined by the platform you're running on. For example if you're using [`adapter-node`](https://github.com/sveltejs/kit/tree/main/packages/adapter-node) (or running [`vite preview`](https://kit.svelte.dev/docs/cli)), this is equivalent to `process.env`. This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://kit.svelte.dev/docs/configuration#env) (if configured).
1
+ This module provides access to runtime environment variables, as defined by the platform you're running on. For example if you're using [`adapter-node`](https://github.com/sveltejs/kit/tree/main/packages/adapter-node) (or running [`vite preview`](https://svelte.dev/docs/kit/cli)), this is equivalent to `process.env`. This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://svelte.dev/docs/kit/configuration#env) (if configured).
2
2
 
3
3
  This module cannot be imported into client-side code.
4
4
 
@@ -1,4 +1,4 @@
1
- Similar to [`$env/dynamic/private`](https://kit.svelte.dev/docs/modules#$env-dynamic-private), but only includes variables that begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#env) (which defaults to `PUBLIC_`), and can therefore safely be exposed to client-side code.
1
+ Similar to [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private), but only includes variables that begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) (which defaults to `PUBLIC_`), and can therefore safely be exposed to client-side code.
2
2
 
3
3
  Note that public dynamic environment variables must all be sent from the server to the client, causing larger network requests — when possible, use `$env/static/public` instead.
4
4
 
@@ -1,6 +1,6 @@
1
- Environment variables [loaded by Vite](https://vitejs.dev/guide/env-and-mode.html#env-files) from `.env` files and `process.env`. Like [`$env/dynamic/private`](https://kit.svelte.dev/docs/modules#$env-dynamic-private), this module cannot be imported into client-side code. This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://kit.svelte.dev/docs/configuration#env) (if configured).
1
+ Environment variables [loaded by Vite](https://vitejs.dev/guide/env-and-mode.html#env-files) from `.env` files and `process.env`. Like [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private), this module cannot be imported into client-side code. This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://svelte.dev/docs/kit/configuration#env) (if configured).
2
2
 
3
- _Unlike_ [`$env/dynamic/private`](https://kit.svelte.dev/docs/modules#$env-dynamic-private), the values exported from this module are statically injected into your bundle at build time, enabling optimisations like dead code elimination.
3
+ _Unlike_ [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private), the values exported from this module are statically injected into your bundle at build time, enabling optimisations like dead code elimination.
4
4
 
5
5
  ```ts
6
6
  import { API_KEY } from '$env/static/private';
@@ -1,4 +1,4 @@
1
- Similar to [`$env/static/private`](https://kit.svelte.dev/docs/modules#$env-static-private), except that it only includes environment variables that begin with [`config.kit.env.publicPrefix`](https://kit.svelte.dev/docs/configuration#env) (which defaults to `PUBLIC_`), and can therefore safely be exposed to client-side code.
1
+ Similar to [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private), except that it only includes environment variables that begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) (which defaults to `PUBLIC_`), and can therefore safely be exposed to client-side code.
2
2
 
3
3
  Values are replaced statically at build time.
4
4
 
@@ -1,5 +1,5 @@
1
- This is a simple alias to `src/lib`, or whatever directory is specified as [`config.kit.files.lib`](https://kit.svelte.dev/docs/configuration#files). It allows you to access common components and utility modules without `../../../../` nonsense.
1
+ This is a simple alias to `src/lib`, or whatever directory is specified as [`config.kit.files.lib`](https://svelte.dev/docs/kit/configuration#files). It allows you to access common components and utility modules without `../../../../` nonsense.
2
2
 
3
3
  ### `$lib/server`
4
4
 
5
- A subdirectory of `$lib`. SvelteKit will prevent you from importing any modules in `$lib/server` into client-side code. See [server-only modules](https://kit.svelte.dev/docs/server-only-modules).
5
+ A subdirectory of `$lib`. SvelteKit will prevent you from importing any modules in `$lib/server` into client-side code. See [server-only modules](https://svelte.dev/docs/kit/server-only-modules).
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.7.1';
4
+ export const VERSION = '2.7.3';