{"draft":null,"from":2,"to":318,"files":[{"path":"server/src/small-frame-json.ts","added":22,"removed":0,"diff":"--- /dev/null\n+++ b/server/src/small-frame-json.ts\n@@ -0,0 +1,22 @@\n+import { jsonEvents } from \"./json-events.ts\";\n+\n+/** Decode a small canonical frame with the same validation as the streamed path. */\n+export function smallFrameJson(chunks: Iterable<string>): unknown {\n+\tlet text = \"\";\n+\tfor (const chunk of chunks) {\n+\t\tif (text.length + chunk.length > 4096) throw Error(\"small canonical frame exceeds bound\");\n+\t\ttext += chunk;\n+\t}\n+\t// Count UTF-8 after joining so a surrogate pair split across chunks counts once.\n+\tif (new TextEncoder().encode(text).byteLength > 4096) throw Error(\"small canonical frame exceeds bound\");\n+\t// Preserve depth, key and scalar limits; the fast path must not change acceptance.\n+\tfor (const event of jsonEvents([text], { finiteNumbers: true })) void event;\n+\tconst freeze = (value: unknown): unknown => {\n+\t\tif (value !== null && typeof value === \"object\") {\n+\t\t\tfor (const child of Object.values(value)) freeze(child);\n+\t\t\tObject.freeze(value);\n+\t\t}\n+\t\treturn value;\n+\t};\n+\treturn freeze(JSON.parse(text));\n+}"}],"unmatched":[]}