From 59c4cbe69e00d6f7c3697a4cba38eff2ebe68d68 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2026 00:56:16 +0000 Subject: [PATCH 1/2] Lock file maintenance --- yarn.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index 16fb2e0..6eab6b5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -167,9 +167,9 @@ "@octokit/types" "^16.0.0" "@octokit/request@^10.0.6", "@octokit/request@^10.0.7": - version "10.0.10" - resolved "https://registry.yarnpkg.com/@octokit/request/-/request-10.0.10.tgz#45e46934f3d772f006733be6b5ec18f22e54a00c" - integrity sha512-KxNC2pTqqhszMNrf12ZRd4PonRgyJdsM4F/jySiddQK+DsRcfBtUvqn8t7UsyZhnRJHvX46OohDt5N3VqIWC2w== + version "10.0.11" + resolved "https://registry.yarnpkg.com/@octokit/request/-/request-10.0.11.tgz#a11d8b9bae5f6e868efb7dea946edd855ebb2549" + integrity sha512-+s7HUxjfFqOMS9VlIwDffq0MikjSAK0gSpG73W+meAvVAvX4MBrHYTK5Bj3Uot55qFT4gzUtfzE4mGWY4Br8/Q== dependencies: "@octokit/endpoint" "^11.0.3" "@octokit/request-error" "^7.0.2" @@ -201,9 +201,9 @@ content-type@^2.0.0: integrity sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ== json-with-bigint@^3.5.3: - version "3.5.8" - resolved "https://registry.yarnpkg.com/json-with-bigint/-/json-with-bigint-3.5.8.tgz#1b1edb55a1bc4816ca87ac684297591acd822383" - integrity sha512-eq/4KP6K34kwa7TcFdtvnftvHCD9KvHOGGICWwMFc4dOOKF5t4iYqnfLK8otCRCRv06FXOzGGyqE8h8ElMvvdw== + version "3.5.10" + resolved "https://registry.yarnpkg.com/json-with-bigint/-/json-with-bigint-3.5.10.tgz#1de608a5520ec47749e5147b0b3a686c979b1c7c" + integrity sha512-Vcx+JVNEBts/xfcoCS69sKrOhOk/3TVlvlT+XzUOefVKnnrbYSCKpDCm10pohsJFtsJVYnwa/cXRZ4eElzaM6w== tunnel@^0.0.6: version "0.0.6" From 27fac68919fd97b7f35a17e13efba53103ee3a28 Mon Sep 17 00:00:00 2001 From: Jeppe Fihl-Pearson Date: Mon, 13 Jul 2026 08:12:50 +0100 Subject: [PATCH 2/2] Update dist file --- dist/index.js | 521 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 453 insertions(+), 68 deletions(-) diff --git a/dist/index.js b/dist/index.js index 3350267..ca46786 100644 --- a/dist/index.js +++ b/dist/index.js @@ -32707,15 +32707,270 @@ const originalStringify = JSON.stringify; const originalParse = JSON.parse; const customFormat = /^-?\d+n$/; -const bigIntsStringify = /([\[:])?"(-?\d+)n"($|([\\n]|\s)*(\s|[\\n])*[,\}\]])/g; -const noiseStringify = - /([\[:])?("-?\d+n+)n("$|"([\\n]|\s)*(\s|[\\n])*[,\}\]])/g; +const bigIntsStringify = /([\[:])?"(-?\d+)n"($|\s*[,\}\]])/g; +const noiseStringify = /([\[:])?("-?\d+n+)n("$|"\s*[,\}\]])/g; /** * @typedef {(this: any, key: string | number | undefined, value: any) => any} Replacer * @typedef {(key: string | number | undefined, value: any, context?: { source: string }) => any} Reviver */ +/** + * Checks if a value is unstringifiable according to native JSON.stringify rules. + * + * @param {any} val The value to check. + * @returns {boolean} True if the value is undefined, a function, or a symbol. + */ +const isUnstringifiable = (val) => + val === undefined || typeof val === "function" || typeof val === "symbol"; + +/** + * Checks if a value is a native JSON.rawJSON object (Node.js 22+). + * + * @param {any} val The value to check. + * @returns {boolean} True if the value is a RawJSON instance. + */ +const isRawJSON = (val) => + val !== null && + typeof val === "object" && + val.constructor && + val.constructor.name === "RawJSON"; + +/** + * Iteratively converts a JS value to a JSON string. + * Used as a fallback when the native JSON.stringify hits the Maximum Call Stack size. + * Fully compliant with JSON formatting (space), replacers, and toJSON behaviors. + * + * @param {any} rootValue The value to stringify. + * @param {Replacer | Array | null} [replacer] User's custom replacer function. + * @param {string | number} [spaceParam] Indentation for pretty-printing. + * @returns {string | undefined} The generated JSON string. + */ +const stringifyIteratively = (rootValue, replacer, spaceParam) => { + let space = ""; + + if (typeof spaceParam === "number") { + space = " ".repeat(Math.min(10, Math.max(0, Math.floor(spaceParam)))); + } else if (typeof spaceParam === "string") { + space = spaceParam.slice(0, 10); + } + + const isFunctionReplacer = typeof replacer === "function"; + const propertyList = Array.isArray(replacer) + ? new Set(replacer.map(String)) + : null; + + /** + * Prepares a value for stringification by resolving toJSON, handling BigInts, + * applying custom replacers, and unwrapping primitive objects. + * + * @param {object|Array} parent The parent object or array holding the value. + * @param {string} key The key associated with the value. + * @param {any} val The raw value to process. + * @returns {any} The processed value ready for stringification. + */ + const prepareVal = (parent, key, val) => { + const isObject = val !== null && typeof val === "object"; + const hasToJSON = isObject && typeof val.toJSON === "function"; + + if (hasToJSON) { + val = val.toJSON(key); + } + + const isNoise = typeof val === "string" && noiseValue.test(val); + + if (isNoise) return val + "n"; + + const isBigInt = typeof val === "bigint"; + + if (isBigInt) { + const supportsRawJSON = "rawJSON" in JSON; + + if (supportsRawJSON) return JSON.rawJSON(val.toString()); + + return val.toString() + "n"; + } + + if (isFunctionReplacer) { + val = replacer.call(parent, key, val); + } + + const isPostReplacerObject = val !== null && typeof val === "object"; + + if (isPostReplacerObject) { + const isPrimitiveWrapper = + val instanceof Number || + val instanceof String || + val instanceof Boolean; + + if (isPrimitiveWrapper) { + val = val.valueOf(); + } + } + + return val; + }; + + const rootProcessed = prepareVal({ "": rootValue }, "", rootValue); + + if (isUnstringifiable(rootProcessed)) { + return undefined; + } + + const isRootPrimitive = + rootProcessed === null || typeof rootProcessed !== "object"; + const isRootNativeRawJSON = isRawJSON(rootProcessed); + + if (isRootPrimitive || isRootNativeRawJSON) { + return originalStringify(rootProcessed); + } + + const chunks = []; + let level = 0; + + const stack = [ + { + parent: { "": rootProcessed }, + key: "", + val: rootProcessed, + isArray: Array.isArray(rootProcessed), + keys: Array.isArray(rootProcessed) ? null : Object.keys(rootProcessed), + index: 0, + first: true, + }, + ]; + + const visited = new WeakSet([rootProcessed]); + + while (stack.length > 0) { + const node = stack[stack.length - 1]; + + if (node.index === 0) { + chunks.push(node.isArray ? "[" : "{"); + level++; + } + + let isDone = false; + + if (node.isArray) { + if (node.index < node.val.length) { + if (!node.first) chunks.push(","); + + if (space) chunks.push("\n" + space.repeat(level)); + + const childRaw = node.val[node.index]; + const childVal = prepareVal(node.val, String(node.index), childRaw); + + if (isUnstringifiable(childVal)) { + chunks.push("null"); + node.first = false; + node.index++; + } else { + const isComplexObject = + childVal !== null && typeof childVal === "object"; + const isNativeRaw = isRawJSON(childVal); + + if (isComplexObject && !isNativeRaw) { + if (visited.has(childVal)) { + throw new TypeError("Converting circular structure to JSON"); + } + + visited.add(childVal); + + stack.push({ + parent: node.val, + key: String(node.index), + val: childVal, + isArray: Array.isArray(childVal), + keys: Array.isArray(childVal) ? null : Object.keys(childVal), + index: 0, + first: true, + }); + + node.first = false; + node.index++; + } else { + chunks.push(originalStringify(childVal)); + node.first = false; + node.index++; + } + } + } else { + isDone = true; + } + } else { + while (node.index < node.keys.length) { + const k = node.keys[node.index++]; + + const isFilteredOutByArray = propertyList && !propertyList.has(k); + + if (isFilteredOutByArray) continue; + + const childRaw = node.val[k]; + const childVal = prepareVal(node.val, k, childRaw); + + if (isUnstringifiable(childVal)) continue; + + if (!node.first) chunks.push(","); + + if (space) { + chunks.push("\n" + space.repeat(level) + originalStringify(k) + ": "); + } else { + chunks.push(originalStringify(k) + ":"); + } + + const isComplexObject = + childVal !== null && typeof childVal === "object"; + const isNativeRaw = isRawJSON(childVal); + + if (isComplexObject && !isNativeRaw) { + if (visited.has(childVal)) { + throw new TypeError("Converting circular structure to JSON"); + } + + visited.add(childVal); + + stack.push({ + parent: node.val, + key: k, + val: childVal, + isArray: Array.isArray(childVal), + keys: Array.isArray(childVal) ? null : Object.keys(childVal), + index: 0, + first: true, + }); + + node.first = false; + + break; // Stop current loop level to process the newly pushed stack node + } else { + chunks.push(originalStringify(childVal)); + node.first = false; + } + } + + const isNodeFullyProcessed = + node.index >= node.keys.length && stack[stack.length - 1] === node; + + if (isNodeFullyProcessed) { + isDone = true; + } + } + + if (isDone) { + level--; + + if (!node.first && space) chunks.push("\n" + space.repeat(level)); + + chunks.push(node.isArray ? "]" : "}"); + visited.delete(node.val); + stack.pop(); + } + } + + return chunks.join(""); +}; + /** * Converts a JavaScript value to a JSON string. * @@ -32727,55 +32982,87 @@ const noiseStringify = * * @param {*} value The value to convert to a JSON string. * @param {Replacer | Array | null} [replacer] - * A function that alters the behavior of the stringification process, - * or an array of strings/numbers to indicate properties to exclude. + * A function that alters the behavior of the stringification process, + * or an array of strings/numbers to indicate properties to exclude. * @param {string | number} [space] - * A string or number to specify indentation or pretty-printing. + * A string or number to specify indentation or pretty-printing. * @returns {string} The JSON string representation. */ const JSONStringify = (value, replacer, space) => { - if ("rawJSON" in JSON) { - return originalStringify( + try { + const supportsRawJSON = "rawJSON" in JSON; + + if (supportsRawJSON) { + return originalStringify( + value, + (key, val) => { + if (typeof val === "bigint") return JSON.rawJSON(val.toString()); + + const hasFunctionReplacer = typeof replacer === "function"; + + if (hasFunctionReplacer) return replacer(key, val); + + const isKeyInArrayReplacer = + Array.isArray(replacer) && replacer.includes(key); + + if (isKeyInArrayReplacer) return val; + + return val; + }, + space, + ); + } + + if (!value) return originalStringify(value, replacer, space); + + const convertedToCustomJSON = originalStringify( value, - (key, value) => { - if (typeof value === "bigint") return JSON.rawJSON(value.toString()); + (key, val) => { + const isNoise = typeof val === "string" && noiseValue.test(val); - if (typeof replacer === "function") return replacer(key, value); + if (isNoise) return val.toString() + "n"; // Mark noise values with additional "n" to offset the deletion of one "n" during the processing - if (Array.isArray(replacer) && replacer.includes(key)) return value; + if (typeof val === "bigint") return val.toString() + "n"; - return value; + const hasFunctionReplacer = typeof replacer === "function"; + + if (hasFunctionReplacer) return replacer(key, val); + + const isKeyInArrayReplacer = + Array.isArray(replacer) && replacer.includes(key); + + if (isKeyInArrayReplacer) return val; + + return val; }, space, ); - } - if (!value) return originalStringify(value, replacer, space); + const processedJSON = convertedToCustomJSON.replace( + bigIntsStringify, + "$1$2$3", + ); // Delete one "n" off the end of every BigInt value - const convertedToCustomJSON = originalStringify( - value, - (key, value) => { - const isNoise = typeof value === "string" && noiseValue.test(value); + const denoisedJSON = processedJSON.replace(noiseStringify, "$1$2$3"); // Remove one "n" off the end of every noisy string - if (isNoise) return value.toString() + "n"; // Mark noise values with additional "n" to offset the deletion of one "n" during the processing + return denoisedJSON; + } catch (error) { + if (error instanceof RangeError) { + const convertedJSON = stringifyIteratively(value, replacer, space); - if (typeof value === "bigint") return value.toString() + "n"; + if (convertedJSON === undefined) return undefined; - if (typeof replacer === "function") return replacer(key, value); + const supportsRawJSON = "rawJSON" in JSON; - if (Array.isArray(replacer) && replacer.includes(key)) return value; + if (supportsRawJSON) return convertedJSON; - return value; - }, - space, - ); - const processedJSON = convertedToCustomJSON.replace( - bigIntsStringify, - "$1$2$3", - ); // Delete one "n" off the end of every BigInt value - const denoisedJSON = processedJSON.replace(noiseStringify, "$1$2$3"); // Remove one "n" off the end of every noisy string + const processedJSON = convertedJSON.replace(bigIntsStringify, "$1$2$3"); - return denoisedJSON; + return processedJSON.replace(noiseStringify, "$1$2$3"); + } + + throw error; + } }; const featureCache = new Map(); @@ -32823,12 +33110,15 @@ const isContextSourceSupported = () => { const convertMarkedBigIntsReviver = (key, value, context, userReviver) => { const isCustomFormatBigInt = typeof value === "string" && customFormat.test(value); + if (isCustomFormatBigInt) return BigInt(value.slice(0, -1)); const isNoiseValue = typeof value === "string" && noiseValue.test(value); if (isNoiseValue) return value.slice(0, -1); - if (typeof userReviver !== "function") return value; + const hasUserReviver = typeof userReviver === "function"; + + if (!hasUserReviver) return value; return userReviver(key, value, context); }; @@ -32846,15 +33136,18 @@ const convertMarkedBigIntsReviver = (key, value, context, userReviver) => { */ const JSONParseV2 = (text, reviver) => { return JSON.parse(text, (key, value, context) => { - const isBigNumber = - typeof value === "number" && - (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER); + const isNumber = typeof value === "number"; + const isOutOfBounds = + value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER; + const isBigNumber = isNumber && isOutOfBounds; const isInt = context && intRegex.test(context.source); const isBigInt = isBigNumber && isInt; if (isBigInt) return BigInt(context.source); - if (typeof reviver !== "function") return value; + const hasCustomReviver = typeof reviver === "function"; + + if (!hasCustomReviver) return value; return reviver(key, value, context); }); @@ -32866,6 +33159,105 @@ const stringsOrLargeNumbers = /"(?:\\.|[^"])*"|-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?/g; const noiseValueWithQuotes = /^"-?\d+n+"$/; // Noise - strings that match the custom format before being converted to it +/** + * Iteratively traverses the parsed object bottom-up (post-order), + * emulating the native JSON.parse reviver behavior. + * This avoids Call Stack overflows (RangeError) on deeply nested structures. + * + * @param {any} parsed The natively parsed JSON object. + * @param {Reviver} [userReviver] User's custom reviver function. + * @returns {any} The fully processed object. + */ +const applyReviverIteratively = (parsed, userReviver) => { + const rootHolder = { "": parsed }; + const stack = [{ parent: rootHolder, key: "", visited: false }]; + + while (stack.length > 0) { + const node = stack[stack.length - 1]; + + if (!node.visited) { + node.visited = true; + + const value = node.parent[node.key]; + const isComplexObject = value !== null && typeof value === "object"; + + if (isComplexObject) { + const keys = Object.keys(value); + + for (let i = keys.length - 1; i >= 0; i--) { + stack.push({ parent: value, key: keys[i], visited: false }); + } + } + } else { + const { parent, key } = node; + let value = parent[key]; + + if (typeof value === "string") { + const isCustomFormatBigInt = customFormat.test(value); + + if (isCustomFormatBigInt) { + value = BigInt(value.slice(0, -1)); + } else { + const isNoise = noiseValue.test(value); + + if (isNoise) value = value.slice(0, -1); + } + } + + const hasUserReviver = typeof userReviver === "function"; + + if (hasUserReviver) { + value = userReviver.call(parent, key, value); + } + + const isDeleted = value === undefined; + + if (isDeleted) { + delete parent[key]; + } else { + parent[key] = value; + } + + stack.pop(); + } + } + + return rootHolder[""]; +}; + +/** + * Pre-processes the JSON string to mark large numbers with an 'n' suffix. + * + * @param {string} text The raw JSON string. + * @returns {string} The serialized string with marked BigInts. + */ +const serializeBigInts = (text) => { + return text.replace( + stringsOrLargeNumbers, + (match, digits, fractional, exponential) => { + const isString = match[0] === '"'; + const isNoise = isString && noiseValueWithQuotes.test(match); + + if (isNoise) return match.substring(0, match.length - 1) + 'n"'; // Mark noise values with additional "n" to offset the deletion of one "n" during the processing + + const hasFractionalOrExponential = fractional || exponential; + + // With a fixed number of digits, we can correctly use lexicographical comparison to do a numeric comparison + const isLessThanMaxSafeInt = + digits && + (digits.length < MAX_DIGITS || + (digits.length === MAX_DIGITS && digits <= MAX_INT)); + + const isStandardValue = + isString || hasFractionalOrExponential || isLessThanMaxSafeInt; + + if (isStandardValue) return match; + + return '"' + match + 'n"'; + }, + ); +}; + /** * Converts a JSON string into a JavaScript value. * @@ -32877,42 +33269,34 @@ const noiseValueWithQuotes = /^"-?\d+n+"$/; // Noise - strings that match the cu * * @param {string} text A valid JSON string. * @param {Reviver} [reviver] - * A function that transforms the results. This function is called for each member - * of the object. If a member contains nested objects, the nested objects are - * transformed before the parent object is. + * A function that transforms the results. This function is called for each member + * of the object. If a member contains nested objects, the nested objects are + * transformed before the parent object is. * @returns {any} The parsed JavaScript value. * @throws {SyntaxError} If text is not valid JSON. */ const JSONParse = (text, reviver) => { if (!text) return originalParse(text, reviver); - if (isContextSourceSupported()) return JSONParseV2(text, reviver); // Shortcut to a faster (2x) and simpler version - - // Find and mark big numbers with "n" - const serializedData = text.replace( - stringsOrLargeNumbers, - (text, digits, fractional, exponential) => { - const isString = text[0] === '"'; - const isNoise = isString && noiseValueWithQuotes.test(text); - - if (isNoise) return text.substring(0, text.length - 1) + 'n"'; // Mark noise values with additional "n" to offset the deletion of one "n" during the processing + try { + if (isContextSourceSupported()) return JSONParseV2(text, reviver); // Shortcut to a faster (2x) and simpler version - const isFractionalOrExponential = fractional || exponential; - const isLessThanMaxSafeInt = - digits && - (digits.length < MAX_DIGITS || - (digits.length === MAX_DIGITS && digits <= MAX_INT)); // With a fixed number of digits, we can correctly use lexicographical comparison to do a numeric comparison + // Find and mark big numbers with "n" + const serializedData = serializeBigInts(text); - if (isString || isFractionalOrExponential || isLessThanMaxSafeInt) - return text; + return originalParse(serializedData, (key, value, context) => + convertMarkedBigIntsReviver(key, value, context, reviver), + ); + } catch (error) { + if (error instanceof RangeError) { + const serializedData = serializeBigInts(text); + const parsed = originalParse(serializedData); - return '"' + text + 'n"'; - }, - ); + return applyReviverIteratively(parsed, reviver); + } - return originalParse(serializedData, (key, value, context) => - convertMarkedBigIntsReviver(key, value, context, reviver), - ); + throw error; + } }; @@ -32966,7 +33350,7 @@ class RequestError extends Error { // pkg/dist-src/version.js -var dist_bundle_VERSION = "10.0.10"; +var dist_bundle_VERSION = "10.0.11"; // pkg/dist-src/defaults.js var defaults_default = { @@ -33123,9 +33507,10 @@ function toErrorMessage(data) { if (data instanceof ArrayBuffer) { return "Unknown error"; } - if ("message" in data) { - const suffix = "documentation_url" in data ? ` - ${data.documentation_url}` : ""; - return Array.isArray(data.errors) ? `${data.message}: ${data.errors.map((v) => JSON.stringify(v)).join(", ")}${suffix}` : `${data.message}${suffix}`; + if (typeof data === "object" && data !== null && "message" in data) { + const objectData = data; + const suffix = "documentation_url" in objectData ? ` - ${objectData.documentation_url}` : ""; + return Array.isArray(objectData.errors) ? `${objectData.message}: ${objectData.errors.map((v) => JSON.stringify(v)).join(", ")}${suffix}` : `${objectData.message}${suffix}`; } return `Unknown error: ${JSON.stringify(data)}`; }