{"draft":null,"from":175,"to":318,"files":[{"path":"src/engine/json-value-chunks.ts","added":8,"removed":3,"diff":"--- a/src/engine/json-value-chunks.ts\n+++ b/src/engine/json-value-chunks.ts\n@@ -18,7 +18,10 @@\n /** JSON.stringify-compatible chunks for canonical data, without a whole-value string.\n  * Individual input strings and object key lists still belong to the caller.\n  */\n-export function* jsonValueChunks(input: unknown): IterableIterator<string> {\n+export function* jsonValueChunks(\n+\tinput: unknown,\n+\toptions: { maxDepth?: number; unboxPrimitives?: boolean } = {},\n+): IterableIterator<string> {\n \tconst active = new Set<object>();\n \tfunction* string(value: string): IterableIterator<string> {\n \t\tyield '\"';\n@@ -38,8 +41,10 @@\n \t\t\tconst streaming = streamingValues.get(value);\n \t\t\tif (streaming) return streaming();\n \t\t\tconst toJSON = (value as { toJSON?: unknown }).toJSON;\n-\t\t\tif (typeof toJSON === \"function\") return toJSON.call(value, key);\n+\t\t\tif (typeof toJSON === \"function\") value = toJSON.call(value, key);\n \t\t}\n+\t\tif (options.unboxPrimitives && (value instanceof String || value instanceof Number || value instanceof Boolean))\n+\t\t\treturn value.valueOf();\n \t\treturn value;\n \t};\n \tconst omitted = (value: unknown) => value === undefined || typeof value === \"function\" || typeof value === \"symbol\";\n@@ -63,7 +68,7 @@\n \t\telse if (typeof value !== \"object\" || value === null) throw Error(\"unsupported canonical JSON value\");\n \t\telse {\n \t\t\tif (active.has(value)) throw Error(\"cyclic canonical JSON value\");\n-\t\t\tif (active.size >= 128) throw Error(\"canonical JSON depth exceeds bound\");\n+\t\t\tif (active.size >= (options.maxDepth ?? 128)) throw Error(\"canonical JSON depth exceeds bound\");\n \t\t\tactive.add(value);\n \t\t\ttry {\n \t\t\t\tif (Array.isArray(value)) {"}],"unmatched":[]}