@sveltejs/kit 1.22.4 → 1.22.6

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.22.4",
3
+ "version": "1.22.6",
4
4
  "description": "The fastest way to build Svelte apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,24 +22,23 @@
22
22
  "sade": "^1.8.1",
23
23
  "set-cookie-parser": "^2.6.0",
24
24
  "sirv": "^2.0.2",
25
- "undici": "~5.22.0"
25
+ "undici": "~5.23.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@playwright/test": "1.30.0",
29
29
  "@types/connect": "^3.4.35",
30
- "@types/marked": "^4.0.7",
31
30
  "@types/mime": "^3.0.1",
32
31
  "@types/node": "^16.18.6",
33
32
  "@types/sade": "^1.7.4",
34
33
  "@types/set-cookie-parser": "^2.4.2",
35
34
  "dts-buddy": "^0.1.9",
36
- "marked": "^4.2.3",
35
+ "marked": "^7.0.0",
37
36
  "rollup": "^3.7.0",
38
37
  "svelte": "^4.0.5",
39
38
  "svelte-preprocess": "^5.0.4",
40
39
  "typescript": "^4.9.4",
41
40
  "vite": "^4.4.2",
42
- "vitest": "^0.33.0"
41
+ "vitest": "^0.34.0"
43
42
  },
44
43
  "peerDependencies": {
45
44
  "svelte": "^3.54.0 || ^4.0.0-next.0",
@@ -1,5 +1,5 @@
1
1
  import { existsSync, statSync, createReadStream, createWriteStream } from 'node:fs';
2
- import { extname, join, resolve } from 'node:path';
2
+ import { extname, resolve } from 'node:path';
3
3
  import { pipeline } from 'node:stream';
4
4
  import { promisify } from 'node:util';
5
5
  import zlib from 'node:zlib';
@@ -181,12 +181,7 @@ export function create_builder({
181
181
  },
182
182
 
183
183
  writeClient(dest) {
184
- const server_assets = copy(
185
- `${config.kit.outDir}/output/server/${config.kit.appDir}/immutable/assets`,
186
- join(dest, config.kit.appDir, 'immutable/assets')
187
- ).map((filename) => join(config.kit.appDir, 'immutable/assets', filename));
188
- const client_assets = copy(`${config.kit.outDir}/output/client`, dest);
189
- return Array.from(new Set([...server_assets, ...client_assets]));
184
+ return copy(`${config.kit.outDir}/output/client`, dest);
190
185
  },
191
186
 
192
187
  writePrerendered(dest) {
@@ -60,7 +60,7 @@ async function analyse({ manifest_path, env }) {
60
60
  const node = await loader();
61
61
 
62
62
  metadata.nodes[node.index] = {
63
- has_server_load: node.server?.load !== undefined
63
+ has_server_load: node.server?.load !== undefined || node.server?.trailingSlash !== undefined
64
64
  };
65
65
  }
66
66
 
@@ -431,7 +431,7 @@ export interface KitConfig {
431
431
  errorTemplate?: string;
432
432
  };
433
433
  /**
434
- * Inline CSS inside a `<style>` block at the head of the HTML. This option is a number that specifies the maximum length of a CSS file to be inlined. All CSS files needed for the page and smaller than this value are merged and inlined in a `<style>` block.
434
+ * Inline CSS inside a `<style>` block at the head of the HTML. This option is a number that specifies the maximum length of a CSS file in UTF-16 code units, as specified by the [String.length](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length) property, to be inlined. All CSS files needed for the page and smaller than this value are merged and inlined in a `<style>` block.
435
435
  *
436
436
  * > This results in fewer initial requests and can improve your [First Contentful Paint](https://web.dev/first-contentful-paint) score. However, it generates larger HTML output and reduces the effectiveness of browser caches. Use it advisedly.
437
437
  * @default 0
@@ -5,7 +5,7 @@ import { svelte } from '@sveltejs/vite-plugin-svelte';
5
5
  import colors from 'kleur';
6
6
  import * as vite from 'vite';
7
7
 
8
- import { mkdirp, posixify, read, resolve_entry, rimraf } from '../../utils/filesystem.js';
8
+ import { copy, mkdirp, posixify, read, resolve_entry, rimraf } from '../../utils/filesystem.js';
9
9
  import { create_static_module, create_dynamic_module } from '../../core/env.js';
10
10
  import * as sync from '../../core/sync/sync.js';
11
11
  import { create_assets } from '../../core/sync/create_manifest_data/index.js';
@@ -720,6 +720,11 @@ function kit({ svelte_config }) {
720
720
  })
721
721
  );
722
722
 
723
+ copy(
724
+ `${out}/server/${kit.appDir}/immutable/assets`,
725
+ `${out}/client/${kit.appDir}/immutable/assets`
726
+ );
727
+
723
728
  /** @type {import('vite').Manifest} */
724
729
  const client_manifest = JSON.parse(read(`${out}/client/${vite_config.build.manifest}`));
725
730
 
@@ -31,7 +31,7 @@ import { compact } from '../../utils/array.js';
31
31
  import { validate_page_exports } from '../../utils/exports.js';
32
32
  import { unwrap_promises } from '../../utils/promises.js';
33
33
  import { HttpError, Redirect } from '../control.js';
34
- import { INVALIDATED_PARAM, validate_depends } from '../shared.js';
34
+ import { INVALIDATED_PARAM, TRAILING_SLASH_PARAM, validate_depends } from '../shared.js';
35
35
  import { INDEX_KEY, PRELOAD_PRIORITIES, SCROLL_KEY, SNAPSHOT_KEY } from './constants.js';
36
36
  import { stores } from './singletons.js';
37
37
 
@@ -1819,6 +1819,9 @@ export function create_client(app, target) {
1819
1819
  async function load_data(url, invalid) {
1820
1820
  const data_url = new URL(url);
1821
1821
  data_url.pathname = add_data_suffix(url.pathname);
1822
+ if (url.pathname.endsWith('/')) {
1823
+ data_url.searchParams.append(TRAILING_SLASH_PARAM, '1');
1824
+ }
1822
1825
  if (DEV && url.searchParams.has(INVALIDATED_PARAM)) {
1823
1826
  throw new Error(`Cannot used reserved query parameter "${INVALIDATED_PARAM}"`);
1824
1827
  }
@@ -29,7 +29,7 @@ import {
29
29
  import { get_option } from '../../utils/options.js';
30
30
  import { error, json, text } from '../../exports/index.js';
31
31
  import { action_json_redirect, is_action_json_request } from './page/actions.js';
32
- import { INVALIDATED_PARAM } from '../shared.js';
32
+ import { INVALIDATED_PARAM, TRAILING_SLASH_PARAM } from '../shared.js';
33
33
 
34
34
  /* global __SVELTEKIT_ADAPTER_NAME__ */
35
35
 
@@ -100,7 +100,10 @@ export async function respond(request, options, manifest, state) {
100
100
  let invalidated_data_nodes;
101
101
  if (is_data_request) {
102
102
  decoded = strip_data_suffix(decoded) || '/';
103
- url.pathname = strip_data_suffix(url.pathname) || '/';
103
+ url.pathname =
104
+ strip_data_suffix(url.pathname) +
105
+ (url.searchParams.get(TRAILING_SLASH_PARAM) === '1' ? '/' : '') || '/';
106
+ url.searchParams.delete(TRAILING_SLASH_PARAM);
104
107
  invalidated_data_nodes = url.searchParams
105
108
  .get(INVALIDATED_PARAM)
106
109
  ?.split('')
@@ -12,3 +12,5 @@ export function validate_depends(route_id, dep) {
12
12
  }
13
13
 
14
14
  export const INVALIDATED_PARAM = 'x-sveltekit-invalidated';
15
+
16
+ export const TRAILING_SLASH_PARAM = 'x-sveltekit-trailing-slash';
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.22.4';
4
+ export const VERSION = '1.22.6';
package/types/index.d.ts CHANGED
@@ -411,7 +411,7 @@ declare module '@sveltejs/kit' {
411
411
  errorTemplate?: string;
412
412
  };
413
413
  /**
414
- * Inline CSS inside a `<style>` block at the head of the HTML. This option is a number that specifies the maximum length of a CSS file to be inlined. All CSS files needed for the page and smaller than this value are merged and inlined in a `<style>` block.
414
+ * Inline CSS inside a `<style>` block at the head of the HTML. This option is a number that specifies the maximum length of a CSS file in UTF-16 code units, as specified by the [String.length](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length) property, to be inlined. All CSS files needed for the page and smaller than this value are merged and inlined in a `<style>` block.
415
415
  *
416
416
  * > This results in fewer initial requests and can improve your [First Contentful Paint](https://web.dev/first-contentful-paint) score. However, it generates larger HTML output and reduces the effectiveness of browser caches. Use it advisedly.
417
417
  * @default 0