@sveltejs/kit 1.20.4 → 1.20.5

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.20.4",
3
+ "version": "1.20.5",
4
4
  "description": "The fastest way to build Svelte apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,5 +1,5 @@
1
1
  import { existsSync, statSync, createReadStream, createWriteStream } from 'node:fs';
2
- import { extname, join } from 'node:path/posix';
2
+ import { extname, join, 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';
@@ -12,7 +12,7 @@ import { write } from '../sync/utils.js';
12
12
  import { list_files } from '../utils.js';
13
13
 
14
14
  const pipe = promisify(pipeline);
15
- const extensions = ['html', 'js', 'mjs', 'json', 'css', 'svg', 'xml', 'wasm'];
15
+ const extensions = ['.html', '.js', '.mjs', '.json', '.css', '.svg', '.xml', '.wasm'];
16
16
 
17
17
  /**
18
18
  * Creates the Builder which is passed to adapters for building the application.
@@ -84,9 +84,12 @@ export function create_builder({
84
84
  return;
85
85
  }
86
86
 
87
- const files = list_files(directory, (file) => extensions.includes(extname(file)));
87
+ const files = list_files(directory, (file) => extensions.includes(extname(file))).map(
88
+ (file) => resolve(directory, file)
89
+ );
90
+
88
91
  await Promise.all(
89
- files.map((file) => Promise.all([compress_file(file, 'gz'), compress_file(file, 'br')]))
92
+ files.flatMap((file) => [compress_file(file, 'gz'), compress_file(file, 'br')])
90
93
  );
91
94
  },
92
95
 
@@ -104,7 +104,7 @@ export function fail(status, data) {
104
104
  return new ActionFailure(status, data);
105
105
  }
106
106
 
107
- const basic_param_pattern = /\[(\[)?(?:\.\.\.)?(\w+?)(?:=(\w+))?\]\]?/g;
107
+ const basic_param_pattern = /\[(\[)?(\.\.\.)?(\w+?)(?:=(\w+))?\]\]?/g;
108
108
 
109
109
  /**
110
110
  * Populate a route ID with params to resolve a pathname.
@@ -128,12 +128,13 @@ export function resolvePath(id, params) {
128
128
  '/' +
129
129
  segments
130
130
  .map((segment) =>
131
- segment.replace(basic_param_pattern, (_, optional, name) => {
131
+ segment.replace(basic_param_pattern, (_, optional, rest, name) => {
132
132
  const param_value = params[name];
133
133
 
134
134
  // This is nested so TS correctly narrows the type
135
135
  if (!param_value) {
136
136
  if (optional) return '';
137
+ if (rest && param_value !== undefined) return '';
137
138
  throw new Error(`Missing parameter '${name}' in route ${id}`);
138
139
  }
139
140
 
@@ -130,6 +130,11 @@ export function enhance(form_element, submit = () => {}) {
130
130
 
131
131
  /** @param {SubmitEvent} event */
132
132
  async function handle_submit(event) {
133
+ const method = event.submitter?.hasAttribute('formmethod')
134
+ ? /** @type {HTMLButtonElement | HTMLInputElement} */ (event.submitter).formMethod
135
+ : clone(form_element).method;
136
+ if (method !== 'post') return;
137
+
133
138
  event.preventDefault();
134
139
 
135
140
  const action = new URL(
@@ -153,6 +153,7 @@ export function create_client(app, target) {
153
153
  // but batch multiple synchronous invalidations.
154
154
  pending_invalidate = pending_invalidate || Promise.resolve();
155
155
  await pending_invalidate;
156
+ if (!pending_invalidate) return;
156
157
  pending_invalidate = null;
157
158
 
158
159
  const url = new URL(location.href);