@sveltejs/kit 2.5.17 → 2.5.19

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.5.17",
3
+ "version": "2.5.19",
4
4
  "description": "SvelteKit is the fastest way to build Svelte apps",
5
5
  "keywords": [
6
6
  "framework",
@@ -36,15 +36,14 @@
36
36
  "@sveltejs/vite-plugin-svelte": "^3.0.1",
37
37
  "@types/connect": "^3.4.38",
38
38
  "@types/node": "^18.19.3",
39
- "@types/sade": "^1.7.8",
40
39
  "@types/set-cookie-parser": "^2.4.7",
41
40
  "dts-buddy": "0.4.6",
42
41
  "rollup": "^4.14.2",
43
42
  "svelte": "^4.2.10",
44
43
  "svelte-preprocess": "^6.0.0",
45
44
  "typescript": "^5.3.3",
46
- "vite": "^5.2.8",
47
- "vitest": "^1.6.0"
45
+ "vite": "^5.3.2",
46
+ "vitest": "^2.0.1"
48
47
  },
49
48
  "peerDependencies": {
50
49
  "@sveltejs/vite-plugin-svelte": "^3.0.0",
@@ -21,15 +21,20 @@ export function write_root(manifest_data, output) {
21
21
 
22
22
  let l = max_depth;
23
23
 
24
- let pyramid = `<svelte:component this={constructors[${l}]} bind:this={components[${l}]} data={data_${l}} {form} />`;
24
+ let pyramid = dedent`
25
+ ${isSvelte5Plus() ? '<!-- svelte-ignore binding_property_non_reactive -->' : ''}
26
+ <svelte:component this={constructors[${l}]} bind:this={components[${l}]} data={data_${l}} {form} />
27
+ `;
25
28
 
26
29
  while (l--) {
27
30
  pyramid = dedent`
28
31
  {#if constructors[${l + 1}]}
32
+ ${isSvelte5Plus() ? '<!-- svelte-ignore binding_property_non_reactive -->' : ''}
29
33
  <svelte:component this={constructors[${l}]} bind:this={components[${l}]} data={data_${l}}>
30
34
  ${pyramid}
31
35
  </svelte:component>
32
36
  {:else}
37
+ ${isSvelte5Plus() ? '<!-- svelte-ignore binding_property_non_reactive -->' : ''}
33
38
  <svelte:component this={constructors[${l}]} bind:this={components[${l}]} data={data_${l}} {form} />
34
39
  {/if}
35
40
  `;
@@ -56,7 +56,7 @@ function clone(element) {
56
56
  * If nothing is returned, the fallback will be used.
57
57
  *
58
58
  * If this function or its return value isn't set, it
59
- * - falls back to updating the `form` prop with the returned data if the action is one same page as the form
59
+ * - falls back to updating the `form` prop with the returned data if the action is on the same page as the form
60
60
  * - updates `$page.status`
61
61
  * - resets the `<form>` element and invalidates all data in case of successful submission with no redirect response
62
62
  * - redirects in case of a redirect response
@@ -124,9 +124,13 @@ export function enhance(form_element, submit = () => {}) {
124
124
  : clone(form_element).action
125
125
  );
126
126
 
127
+ const enctype = event.submitter?.hasAttribute('formenctype')
128
+ ? /** @type {HTMLButtonElement | HTMLInputElement} */ (event.submitter).formEnctype
129
+ : clone(form_element).enctype;
130
+
127
131
  const form_data = new FormData(form_element);
128
132
 
129
- if (DEV && clone(form_element).enctype !== 'multipart/form-data') {
133
+ if (DEV && enctype !== 'multipart/form-data') {
130
134
  for (const value of form_data.values()) {
131
135
  if (value instanceof File) {
132
136
  throw new Error(
@@ -161,14 +165,31 @@ export function enhance(form_element, submit = () => {}) {
161
165
  let result;
162
166
 
163
167
  try {
168
+ const headers = new Headers({
169
+ accept: 'application/json',
170
+ 'x-sveltekit-action': 'true'
171
+ });
172
+
173
+ // do not explicitly set the `Content-Type` header when sending `FormData`
174
+ // or else it will interfere with the browser's header setting
175
+ // see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest_API/Using_FormData_Objects#sect4
176
+ if (enctype !== 'multipart/form-data') {
177
+ headers.set(
178
+ 'Content-Type',
179
+ /^(:?application\/x-www-form-urlencoded|text\/plain)$/.test(enctype)
180
+ ? enctype
181
+ : 'application/x-www-form-urlencoded'
182
+ );
183
+ }
184
+
185
+ // @ts-expect-error `URLSearchParams(form_data)` is kosher, but typescript doesn't know that
186
+ const body = enctype === 'multipart/form-data' ? form_data : new URLSearchParams(form_data);
187
+
164
188
  const response = await fetch(action, {
165
189
  method: 'POST',
166
- headers: {
167
- accept: 'application/json',
168
- 'x-sveltekit-action': 'true'
169
- },
190
+ headers,
170
191
  cache: 'no-store',
171
- body: form_data,
192
+ body,
172
193
  signal: controller.signal
173
194
  });
174
195
 
@@ -181,7 +181,7 @@ export function resolve_entry(entry) {
181
181
  const base = path.basename(entry);
182
182
  const files = fs.readdirSync(dir);
183
183
 
184
- const found = files.find((file) => file.replace(/\.[^.]+$/, '') === base);
184
+ const found = files.find((file) => file.replace(/\.(js|ts)$/, '') === base);
185
185
 
186
186
  if (found) return path.join(dir, found);
187
187
  }
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.5.17';
4
+ export const VERSION = '2.5.19';
package/types/index.d.ts CHANGED
@@ -1999,7 +1999,7 @@ declare module '$app/forms' {
1999
1999
  * If nothing is returned, the fallback will be used.
2000
2000
  *
2001
2001
  * If this function or its return value isn't set, it
2002
- * - falls back to updating the `form` prop with the returned data if the action is one same page as the form
2002
+ * - falls back to updating the `form` prop with the returned data if the action is on the same page as the form
2003
2003
  * - updates `$page.status`
2004
2004
  * - resets the `<form>` element and invalidates all data in case of successful submission with no redirect response
2005
2005
  * - redirects in case of a redirect response