@sveltejs/kit 2.69.0 → 2.69.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
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
build_path_string,
|
|
19
19
|
normalize_issue,
|
|
20
20
|
serialize_binary_form,
|
|
21
|
+
DELETE_KEY,
|
|
21
22
|
BINARY_FORM_CONTENT_TYPE
|
|
22
23
|
} from '../../form-utils.js';
|
|
23
24
|
|
|
@@ -513,14 +514,7 @@ export function form(id) {
|
|
|
513
514
|
if (file) {
|
|
514
515
|
set_nested_value(input, name, file);
|
|
515
516
|
} else {
|
|
516
|
-
|
|
517
|
-
const path_parts = name.split(/\.|\[|\]/).filter(Boolean);
|
|
518
|
-
let current = /** @type {any} */ (input);
|
|
519
|
-
for (let i = 0; i < path_parts.length - 1; i++) {
|
|
520
|
-
if (current[path_parts[i]] == null) return;
|
|
521
|
-
current = current[path_parts[i]];
|
|
522
|
-
}
|
|
523
|
-
delete current[path_parts[path_parts.length - 1]];
|
|
517
|
+
set_nested_value(input, name, DELETE_KEY);
|
|
524
518
|
}
|
|
525
519
|
} else {
|
|
526
520
|
set_nested_value(
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { DEV } from 'esm-env';
|
|
6
6
|
import * as devalue from 'devalue';
|
|
7
7
|
import { text_encoder } from './utils.js';
|
|
8
|
+
import { noop } from '../utils/functions.js';
|
|
8
9
|
import { SvelteKitError } from '@sveltejs/kit/internal';
|
|
9
10
|
|
|
10
11
|
const decoder = new TextDecoder();
|
|
@@ -27,6 +28,9 @@ export function set_nested_value(object, path_string, value) {
|
|
|
27
28
|
deep_set(object, split_path(path_string), value);
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
/** Pass this to set_nested_value to delete the last part of the given path */
|
|
32
|
+
export const DELETE_KEY = {};
|
|
33
|
+
|
|
30
34
|
/**
|
|
31
35
|
* Convert `FormData` into a POJO
|
|
32
36
|
* @param {FormData} data
|
|
@@ -318,7 +322,7 @@ export async function deserialize_binary_form(request) {
|
|
|
318
322
|
const chunk = await get_chunk(chunks.length);
|
|
319
323
|
has_more = !!chunk;
|
|
320
324
|
}
|
|
321
|
-
})();
|
|
325
|
+
})().catch(noop); // prevent unhandled rejection potentially crashing the process
|
|
322
326
|
|
|
323
327
|
return { data, meta, form_data: null };
|
|
324
328
|
}
|
|
@@ -502,6 +506,10 @@ export function deep_set(object, keys, value) {
|
|
|
502
506
|
}
|
|
503
507
|
|
|
504
508
|
if (!exists) {
|
|
509
|
+
if (value === DELETE_KEY) {
|
|
510
|
+
// don't create the nested structure if we want to delete the key anyway
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
505
513
|
current[key] = is_array ? [] : {};
|
|
506
514
|
}
|
|
507
515
|
|
|
@@ -510,7 +518,12 @@ export function deep_set(object, keys, value) {
|
|
|
510
518
|
|
|
511
519
|
const final_key = keys[keys.length - 1];
|
|
512
520
|
check_prototype_pollution(final_key);
|
|
513
|
-
|
|
521
|
+
|
|
522
|
+
if (value === DELETE_KEY) {
|
|
523
|
+
delete current[final_key];
|
|
524
|
+
} else {
|
|
525
|
+
current[final_key] = value;
|
|
526
|
+
}
|
|
514
527
|
}
|
|
515
528
|
|
|
516
529
|
/**
|
|
@@ -377,7 +377,7 @@ export function create_universal_fetch(event, state, fetched, csr, resolve_opts)
|
|
|
377
377
|
}
|
|
378
378
|
|
|
379
379
|
void push_fetched(base64_encode(result), true);
|
|
380
|
-
})();
|
|
380
|
+
})().catch(noop); // prevent unhandled rejection potentially crashing the process
|
|
381
381
|
|
|
382
382
|
return (teed_body = b);
|
|
383
383
|
}
|
package/src/utils/streaming.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { noop } from './functions.js';
|
|
1
2
|
import { with_resolvers } from './promise.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -32,10 +33,19 @@ export function create_async_iterator() {
|
|
|
32
33
|
};
|
|
33
34
|
},
|
|
34
35
|
add: (promise) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
/** @type {import('./promise.js').PromiseWithResolvers<T>} */
|
|
37
|
+
const next = with_resolvers();
|
|
38
|
+
void next.promise.catch(noop); // prevent unhandled rejection potentially crashing the process
|
|
39
|
+
deferred.push(next);
|
|
40
|
+
|
|
41
|
+
void promise.then(
|
|
42
|
+
(value) => {
|
|
43
|
+
deferred[++resolved].resolve(value);
|
|
44
|
+
},
|
|
45
|
+
(error) => {
|
|
46
|
+
deferred[++resolved].reject(error);
|
|
47
|
+
}
|
|
48
|
+
);
|
|
39
49
|
}
|
|
40
50
|
};
|
|
41
51
|
}
|
package/src/version.js
CHANGED