fix price and modular

This commit is contained in:
2026-02-01 17:38:39 +03:30
parent 55f34aa15d
commit 164542d3e2
801 changed files with 16129 additions and 14478 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "devalue",
"description": "Gets the job done when JSON.stringify can't",
"version": "5.6.1",
"version": "5.6.2",
"repository": "sveltejs/devalue",
"sideEffects": false,
"exports": {
+31 -2
View File
@@ -33,6 +33,13 @@ export function unflatten(parsed, revivers) {
const hydrated = Array(values.length);
/**
* A set of values currently being hydrated with custom revivers,
* used to detect invalid cyclical dependencies
* @type {Set<number> | null}
*/
let hydrating = null;
/**
* @param {number} index
* @returns {any}
@@ -70,7 +77,18 @@ export function unflatten(parsed, revivers) {
// so we need to munge it into the format expected by a custom reviver
i = values.push(value[1]) - 1;
}
return (hydrated[index] = reviver(hydrate(i)));
hydrating ??= new Set();
if (hydrating.has(i)) {
throw new Error('Invalid circular reference');
}
hydrating.add(i);
hydrated[index] = reviver(hydrate(i));
hydrating.delete(i);
return hydrated[index];
}
switch (type) {
@@ -125,8 +143,16 @@ export function unflatten(parsed, revivers) {
case 'Float64Array':
case 'BigInt64Array':
case 'BigUint64Array': {
if (values[value[1]][0] !== 'ArrayBuffer') {
// without this, if we receive malformed input we could
// end up trying to hydrate in a circle or allocate
// huge amounts of memory when we call `new TypedArrayConstructor(buffer)`
throw new Error('Invalid data');
}
const TypedArrayConstructor = globalThis[type];
const typedArray = new TypedArrayConstructor(hydrate(value[1]));
const buffer = hydrate(value[1]);
const typedArray = new TypedArrayConstructor(buffer);
hydrated[index] =
value[2] !== undefined
@@ -138,6 +164,9 @@ export function unflatten(parsed, revivers) {
case 'ArrayBuffer': {
const base64 = value[1];
if (typeof base64 !== 'string') {
throw new Error('Invalid ArrayBuffer encoding');
}
const arraybuffer = decode64(base64);
hydrated[index] = arraybuffer;
break;