@sveltejs/kit 1.26.0 → 1.27.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 +1 -1
- package/src/exports/node/polyfills.js +22 -6
- package/src/exports/public.d.ts +2 -1
- package/src/runtime/app/forms.js +18 -4
- package/src/version.js +1 -1
- package/types/index.d.ts +6 -5
- package/types/index.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -3,11 +3,17 @@ import buffer from 'node:buffer';
|
|
|
3
3
|
import { webcrypto as crypto } from 'node:crypto';
|
|
4
4
|
import { fetch, Response, Request, Headers, FormData, File as UndiciFile } from 'undici';
|
|
5
5
|
|
|
6
|
+
/** @type {Record<string, any>} */
|
|
7
|
+
const globals_post_node_18_11 = {
|
|
8
|
+
crypto
|
|
9
|
+
};
|
|
10
|
+
|
|
6
11
|
// @ts-expect-error
|
|
7
12
|
const File = buffer.File ?? UndiciFile;
|
|
8
13
|
|
|
9
14
|
/** @type {Record<string, any>} */
|
|
10
|
-
|
|
15
|
+
// TODO: remove this once we only support Node 18.11+ (the version multipart/form-data was added)
|
|
16
|
+
const globals_pre_node_18_11 = {
|
|
11
17
|
crypto,
|
|
12
18
|
fetch,
|
|
13
19
|
Response,
|
|
@@ -21,16 +27,26 @@ const globals = {
|
|
|
21
27
|
};
|
|
22
28
|
|
|
23
29
|
// exported for dev/preview and node environments
|
|
24
|
-
// TODO: remove this once we only support Node 18.11+ (the version multipart/form-data was added)
|
|
25
30
|
/**
|
|
26
31
|
* Make various web APIs available as globals:
|
|
27
32
|
* - `crypto`
|
|
28
|
-
* - `fetch`
|
|
29
|
-
* - `Headers`
|
|
30
|
-
* - `Request`
|
|
31
|
-
* - `Response`
|
|
33
|
+
* - `fetch` (only in node < 18.11)
|
|
34
|
+
* - `Headers` (only in node < 18.11)
|
|
35
|
+
* - `Request` (only in node < 18.11)
|
|
36
|
+
* - `Response` (only in node < 18.11)
|
|
32
37
|
*/
|
|
33
38
|
export function installPolyfills() {
|
|
39
|
+
// Be defensive (we don't know in which environments this is called) and always apply if something goes wrong
|
|
40
|
+
let globals = globals_pre_node_18_11;
|
|
41
|
+
try {
|
|
42
|
+
const version = process.versions.node.split('.').map((n) => parseInt(n, 10));
|
|
43
|
+
if ((version[0] === 18 && version[1] >= 11) || version[0] > 18) {
|
|
44
|
+
globals = globals_post_node_18_11;
|
|
45
|
+
}
|
|
46
|
+
} catch (e) {
|
|
47
|
+
// ignore
|
|
48
|
+
}
|
|
49
|
+
|
|
34
50
|
for (const name in globals) {
|
|
35
51
|
Object.defineProperty(globalThis, name, {
|
|
36
52
|
enumerable: true,
|
package/src/exports/public.d.ts
CHANGED
|
@@ -1282,8 +1282,9 @@ export type SubmitFunction<
|
|
|
1282
1282
|
/**
|
|
1283
1283
|
* Call this to get the default behavior of a form submission response.
|
|
1284
1284
|
* @param options Set `reset: false` if you don't want the `<form>` values to be reset after a successful submission.
|
|
1285
|
+
* @param invalidateAll Set `invalidateAll: false` if you don't want the action to call `invalidateAll` after submission.
|
|
1285
1286
|
*/
|
|
1286
|
-
update(options?: { reset
|
|
1287
|
+
update(options?: { reset?: boolean; invalidateAll?: boolean }): Promise<void>;
|
|
1287
1288
|
}) => void)
|
|
1288
1289
|
>;
|
|
1289
1290
|
|
package/src/runtime/app/forms.js
CHANGED
|
@@ -104,17 +104,25 @@ export function enhance(form_element, submit = () => {}) {
|
|
|
104
104
|
/**
|
|
105
105
|
* @param {{
|
|
106
106
|
* action: URL;
|
|
107
|
+
* invalidateAll?: boolean;
|
|
107
108
|
* result: import('@sveltejs/kit').ActionResult;
|
|
108
109
|
* reset?: boolean
|
|
109
110
|
* }} opts
|
|
110
111
|
*/
|
|
111
|
-
const fallback_callback = async ({
|
|
112
|
+
const fallback_callback = async ({
|
|
113
|
+
action,
|
|
114
|
+
result,
|
|
115
|
+
reset = true,
|
|
116
|
+
invalidateAll: shouldInvalidateAll = true
|
|
117
|
+
}) => {
|
|
112
118
|
if (result.type === 'success') {
|
|
113
|
-
if (reset
|
|
119
|
+
if (reset) {
|
|
114
120
|
// We call reset from the prototype to avoid DOM clobbering
|
|
115
121
|
HTMLFormElement.prototype.reset.call(form_element);
|
|
116
122
|
}
|
|
117
|
-
|
|
123
|
+
if (shouldInvalidateAll) {
|
|
124
|
+
await invalidateAll();
|
|
125
|
+
}
|
|
118
126
|
}
|
|
119
127
|
|
|
120
128
|
// For success/failure results, only apply action if it belongs to the
|
|
@@ -222,7 +230,13 @@ export function enhance(form_element, submit = () => {}) {
|
|
|
222
230
|
return form_element;
|
|
223
231
|
},
|
|
224
232
|
formElement: form_element,
|
|
225
|
-
update: (opts) =>
|
|
233
|
+
update: (opts) =>
|
|
234
|
+
fallback_callback({
|
|
235
|
+
action,
|
|
236
|
+
result,
|
|
237
|
+
reset: opts?.reset,
|
|
238
|
+
invalidateAll: opts?.invalidateAll
|
|
239
|
+
}),
|
|
226
240
|
// @ts-expect-error generic constraints stuff we don't care about
|
|
227
241
|
result
|
|
228
242
|
});
|
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1262,8 +1262,9 @@ declare module '@sveltejs/kit' {
|
|
|
1262
1262
|
/**
|
|
1263
1263
|
* Call this to get the default behavior of a form submission response.
|
|
1264
1264
|
* @param options Set `reset: false` if you don't want the `<form>` values to be reset after a successful submission.
|
|
1265
|
+
* @param invalidateAll Set `invalidateAll: false` if you don't want the action to call `invalidateAll` after submission.
|
|
1265
1266
|
*/
|
|
1266
|
-
update(options?: { reset
|
|
1267
|
+
update(options?: { reset?: boolean; invalidateAll?: boolean }): Promise<void>;
|
|
1267
1268
|
}) => void)
|
|
1268
1269
|
>;
|
|
1269
1270
|
|
|
@@ -1820,10 +1821,10 @@ declare module '@sveltejs/kit/node/polyfills' {
|
|
|
1820
1821
|
/**
|
|
1821
1822
|
* Make various web APIs available as globals:
|
|
1822
1823
|
* - `crypto`
|
|
1823
|
-
* - `fetch`
|
|
1824
|
-
* - `Headers`
|
|
1825
|
-
* - `Request`
|
|
1826
|
-
* - `Response`
|
|
1824
|
+
* - `fetch` (only in node < 18.11)
|
|
1825
|
+
* - `Headers` (only in node < 18.11)
|
|
1826
|
+
* - `Request` (only in node < 18.11)
|
|
1827
|
+
* - `Response` (only in node < 18.11)
|
|
1827
1828
|
*/
|
|
1828
1829
|
export function installPolyfills(): void;
|
|
1829
1830
|
}
|
package/types/index.d.ts.map
CHANGED
|
@@ -136,5 +136,5 @@
|
|
|
136
136
|
null,
|
|
137
137
|
null
|
|
138
138
|
],
|
|
139
|
-
"mappings": ";;;;;;;;;kBA6BiBA,OAAOA;;;;;;;;;;;;;;;;;;;;;;aAsBZC,iBAAiBA;;;;;aAKjBC,cAAcA;;;;;;;;;;;;;;;;;;;;;;;kBAuBTC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAuFPC,MAAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA6BNC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAiDPC,SAASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA0YdC,MAAMA;;;;;;;;;;;aAWNC,iBA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