@carbonenginejs/runtime-resource 0.18.0 → 0.19.0

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.
Files changed (81) hide show
  1. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js +16 -4
  2. package/dist/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -1
  3. package/dist/format/carbonEffect/buildCarbonEffectContainer.js +11 -1
  4. package/dist/format/carbonEffect/buildCarbonEffectContainer.js.map +1 -1
  5. package/dist/format/carbonEffect/carbonEffectBackendBlock.js +36 -0
  6. package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
  7. package/dist/format/carbonEffect/carbonEffectRecords.js +45 -1
  8. package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -1
  9. package/dist/format/carbonEffect/carbonEffectResourceTransform.js +120 -60
  10. package/dist/format/carbonEffect/carbonEffectResourceTransform.js.map +1 -1
  11. package/dist/format/index.js +1 -1
  12. package/dist/formats/dds/core/helpers.js +35 -6
  13. package/dist/formats/dds/core/helpers.js.map +1 -1
  14. package/dist/formats/fbx/core/helpers.js +1 -1
  15. package/dist/formats/fbx/core/helpers.js.map +1 -1
  16. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +53 -1
  17. package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -1
  18. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js +10 -1
  19. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js.map +1 -1
  20. package/dist/formats/index.js +3 -0
  21. package/dist/formats/index.js.map +1 -1
  22. package/dist/formats/jpeg/core/helpers.js +1 -1
  23. package/dist/formats/jpeg/core/helpers.js.map +1 -1
  24. package/dist/formats/pickle/core/CjsPickleProtocol0Reader.js +205 -44
  25. package/dist/formats/pickle/core/CjsPickleProtocol0Reader.js.map +1 -1
  26. package/dist/formats/schemabound/CjsSchemaBoundFormat.js +236 -0
  27. package/dist/formats/schemabound/CjsSchemaBoundFormat.js.map +1 -0
  28. package/dist/formats/schemabound/core/schemaBoundErrors.js +9 -0
  29. package/dist/formats/schemabound/core/schemaBoundErrors.js.map +1 -0
  30. package/dist/formats/schemabound/core/schemaBoundValues.js +336 -0
  31. package/dist/formats/schemabound/core/schemaBoundValues.js.map +1 -0
  32. package/dist/formats/schemabound/index.js +2 -0
  33. package/dist/formats/schemabound/index.js.map +1 -0
  34. package/dist/formats/sqlite/CjsSqliteFormat.js +244 -0
  35. package/dist/formats/sqlite/CjsSqliteFormat.js.map +1 -0
  36. package/dist/formats/sqlite/core/sqlitePages.js +159 -0
  37. package/dist/formats/sqlite/core/sqlitePages.js.map +1 -0
  38. package/dist/formats/sqlite/core/sqliteRecords.js +174 -0
  39. package/dist/formats/sqlite/core/sqliteRecords.js.map +1 -0
  40. package/dist/formats/sqlite/core/sqliteSchema.js +100 -0
  41. package/dist/formats/sqlite/core/sqliteSchema.js.map +1 -0
  42. package/dist/formats/sqlite/index.js +2 -0
  43. package/dist/formats/sqlite/index.js.map +1 -0
  44. package/dist/formats/static/CjsStaticFormat.js +222 -0
  45. package/dist/formats/static/CjsStaticFormat.js.map +1 -0
  46. package/dist/formats/static/index.js +3 -0
  47. package/dist/formats/static/index.js.map +1 -0
  48. package/dist/formats/static/staticContainers.js +157 -0
  49. package/dist/formats/static/staticContainers.js.map +1 -0
  50. package/dist/formats/webgl/core/buildGlslEffectContainer.js +3 -1
  51. package/dist/formats/webgl/core/buildGlslEffectContainer.js.map +1 -1
  52. package/dist/formats/webgl/core/effectPackage.js +11 -2
  53. package/dist/formats/webgl/core/effectPackage.js.map +1 -1
  54. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +10 -2
  55. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
  56. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +3 -1
  57. package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -1
  58. package/dist/formats/webgpu/core/carbonWebgpu/containerViews.js +179 -131
  59. package/dist/formats/webgpu/core/carbonWebgpu/containerViews.js.map +1 -1
  60. package/dist/formats/webgpu/core/effectBackendBodySet.js +20 -20
  61. package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
  62. package/dist/formats/webgpu/core/packageEffect.js +14 -1
  63. package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
  64. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +9 -1
  65. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
  66. package/dist/resource/shader/reflection/Tr2EffectStageInput.js +14 -0
  67. package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
  68. package/docs/concepts/shader-resource-model.md +34 -1
  69. package/docs/formats/README.md +21 -0
  70. package/docs/formats/carbon-effect-container.md +54 -27
  71. package/docs/formats/pickle.md +36 -0
  72. package/docs/formats/schemabound.md +123 -0
  73. package/docs/formats/static.md +166 -0
  74. package/docs/formats/webgl/README.md +5 -3
  75. package/docs/formats/webgpu/README.md +2 -2
  76. package/docs/formats/webgpu/architecture.md +2 -2
  77. package/docs/formats/webgpu/formats/carbon-webgpu.md +13 -2
  78. package/docs/formats/webgpu/guides/effect-packaging.md +1 -2
  79. package/docs/formats/webgpu/reference/wgsl-compatibility.md +2 -2
  80. package/docs/reference/classes/formats.md +33 -0
  81. package/package.json +4 -1
@@ -1 +1 @@
1
- {"version":3,"file":"CjsPickleProtocol0Reader.js","sources":["../../../../../src/formats/pickle/core/CjsPickleProtocol0Reader.js"],"sourcesContent":["const MARK = Symbol(\"pickle-mark\");\n\nexport const PICKLE_PROTOCOL_0_LIMITS = {\n maxContainerItems: 1000000,\n maxInputBytes: 32 * 1024 * 1024,\n maxMemoEntries: 500000,\n maxMemoID: 1000000,\n maxOperations: 2000000,\n maxStackDepth: 100000,\n maxStringBytes: 4 * 1024 * 1024\n};\n\nconst LIMIT_NAMES = Object.keys(PICKLE_PROTOCOL_0_LIMITS);\n\n/**\n * Construction-bound decoder for the inert data subset of Python pickle\n * protocol 0.\n *\n * The reader never imports modules, resolves globals, invokes reducers, or\n * constructs Python objects. Unsupported opcodes fail closed at their byte\n * offset.\n */\nexport class CjsPickleProtocol0Reader\n{\n #bytes;\n #limits;\n\n /**\n * Bind one byte source and its resource limits.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Pickle protocol-0 bytes.\n * @param {object} [options] Reader options containing optional limits.\n */\n constructor(input, options = {})\n {\n this.#bytes = normalizeBytes(input);\n this.#limits = normalizeLimits(options.limits ?? options);\n\n if (this.#bytes.byteLength > this.#limits.maxInputBytes)\n {\n throw pickleError(\n \"CJS_PICKLE_LIMIT_EXCEEDED\",\n `Pickle input exceeds maxInputBytes (${this.#limits.maxInputBytes}).`,\n 0\n );\n }\n }\n\n /**\n * Decode an inert JavaScript value while preserving pickle memo identity.\n *\n * @returns {*} Decoded scalar, array, or plain object graph.\n */\n Read()\n {\n return decode(this.#bytes, this.#limits);\n }\n\n /**\n * Decode a value and reject cycles or values JSON cannot represent.\n *\n * @returns {*} JSON-compatible decoded graph.\n */\n ReadJSON()\n {\n const value = this.Read();\n assertJSONCompatible(value);\n return value;\n }\n\n /**\n * Verify that a decoded value can cross the JSON boundary unchanged.\n *\n * @param {*} value Candidate decoded graph.\n * @returns {*} The supplied value.\n */\n static ToJSON(value)\n {\n assertJSONCompatible(value);\n return value;\n }\n}\n\nfunction decode(bytes, limits)\n{\n const state = {\n bytes,\n containers: new WeakMap(),\n dictionaryKeys: new WeakMap(),\n limits,\n lists: new WeakSet(),\n marks: [],\n memo: new Map(),\n offset: 0,\n operations: 0,\n stack: []\n };\n\n while (state.offset < bytes.byteLength)\n {\n const opcodeOffset = state.offset;\n const opcode = bytes[state.offset++];\n\n state.operations += 1;\n if (state.operations > limits.maxOperations)\n {\n throw pickleError(\n \"CJS_PICKLE_LIMIT_EXCEEDED\",\n `Pickle operation count exceeds maxOperations (${limits.maxOperations}).`,\n opcodeOffset\n );\n }\n\n switch (opcode)\n {\n case 0x28: // MARK\n state.marks.push(state.stack.length);\n push(state, MARK, opcodeOffset);\n break;\n\n case 0x2e: // STOP\n return stop(state, opcodeOffset);\n\n case 0x46: // FLOAT\n push(state, readFloat(state, opcodeOffset), opcodeOffset);\n break;\n\n case 0x49: // INT\n push(state, readInteger(state, opcodeOffset, false), opcodeOffset);\n break;\n\n case 0x4c: // LONG\n push(state, readInteger(state, opcodeOffset, true), opcodeOffset);\n break;\n\n case 0x4e: // NONE\n push(state, null, opcodeOffset);\n break;\n\n case 0x53: // STRING\n push(state, readString(state, opcodeOffset), opcodeOffset);\n break;\n\n case 0x56: // UNICODE\n push(state, readUnicode(state, opcodeOffset), opcodeOffset);\n break;\n\n case 0x61: // APPEND\n append(state, opcodeOffset);\n break;\n\n case 0x64: // DICT\n push(state, readDictionary(state, opcodeOffset), opcodeOffset);\n break;\n\n case 0x67: // GET\n getMemo(state, opcodeOffset);\n break;\n\n case 0x6c: // LIST\n push(state, readSequence(state, opcodeOffset, true), opcodeOffset);\n break;\n\n case 0x74: // TUPLE\n push(state, readSequence(state, opcodeOffset, false), opcodeOffset);\n break;\n\n case 0x70: // PUT\n putMemo(state, opcodeOffset);\n break;\n\n case 0x73: // SETITEM\n setItem(state, opcodeOffset);\n break;\n\n default:\n throw pickleError(\n \"CJS_PICKLE_OPCODE_UNSUPPORTED\",\n `Data-only pickle protocol 0 rejects opcode ${displayOpcode(opcode)}.`,\n opcodeOffset\n );\n }\n }\n\n throw pickleError(\n \"CJS_PICKLE_STOP_MISSING\",\n \"Pickle input ended without a STOP opcode.\",\n state.offset\n );\n}\n\nfunction stop(state, offset)\n{\n if (state.marks.length || state.stack.length !== 1 || state.stack[0] === MARK)\n {\n throw pickleError(\n \"CJS_PICKLE_STACK_INVALID\",\n \"Pickle STOP requires one completed value and no open marks.\",\n offset\n );\n }\n if (state.offset !== state.bytes.byteLength)\n {\n throw pickleError(\n \"CJS_PICKLE_TRAILING_DATA\",\n \"Pickle input contains bytes after STOP.\",\n state.offset\n );\n }\n return state.stack[0];\n}\n\nfunction readFloat(state, offset)\n{\n const value = readAsciiLine(state, state.limits.maxStringBytes, offset);\n if (!/^[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?$/u.test(value))\n {\n throw pickleError(\n \"CJS_PICKLE_NUMBER_INVALID\",\n `Pickle FLOAT value is invalid: ${JSON.stringify(value)}.`,\n offset\n );\n }\n\n const result = Number(value);\n if (!Number.isFinite(result))\n {\n throw pickleError(\n \"CJS_PICKLE_NUMBER_INVALID\",\n \"Pickle FLOAT must be finite for JSON-compatible output.\",\n offset\n );\n }\n return result;\n}\n\nfunction readInteger(state, offset, isLong)\n{\n let value = readAsciiLine(state, 128, offset);\n\n if (!isLong && value === \"00\") return false;\n if (!isLong && value === \"01\") return true;\n if (isLong && value.endsWith(\"L\")) value = value.slice(0, -1);\n\n if (!/^[+-]?\\d+$/u.test(value))\n {\n throw pickleError(\n \"CJS_PICKLE_NUMBER_INVALID\",\n `Pickle integer value is invalid: ${JSON.stringify(value)}.`,\n offset\n );\n }\n\n const result = BigInt(value);\n if (result >= BigInt(Number.MIN_SAFE_INTEGER)\n && result <= BigInt(Number.MAX_SAFE_INTEGER))\n {\n return Number(result);\n }\n return result.toString();\n}\n\nfunction readString(state, offset)\n{\n const bytes = readLine(state, state.limits.maxStringBytes, offset);\n if (bytes.byteLength < 2)\n {\n throw pickleError(\n \"CJS_PICKLE_STRING_INVALID\",\n \"Pickle STRING must be a quoted Python string literal.\",\n offset\n );\n }\n\n const quote = bytes[0];\n if ((quote !== 0x27 && quote !== 0x22)\n || bytes[bytes.byteLength - 1] !== quote)\n {\n throw pickleError(\n \"CJS_PICKLE_STRING_INVALID\",\n \"Pickle STRING must use matching single or double quotes.\",\n offset\n );\n }\n\n const result = [];\n for (let index = 1; index < bytes.byteLength - 1; index += 1)\n {\n const byte = bytes[index];\n if (byte !== 0x5c)\n {\n result.push(String.fromCharCode(byte));\n continue;\n }\n\n index += 1;\n if (index >= bytes.byteLength - 1)\n {\n throw pickleError(\n \"CJS_PICKLE_STRING_INVALID\",\n \"Pickle STRING ends with an incomplete escape.\",\n offset\n );\n }\n\n const escaped = bytes[index];\n const simple = decodeSimpleEscape(escaped);\n if (simple !== null)\n {\n result.push(String.fromCharCode(simple));\n }\n else if (escaped === 0x78)\n {\n result.push(String.fromCharCode(readHex(bytes, index + 1, 2, offset)));\n index += 2;\n }\n else if (escaped >= 0x30 && escaped <= 0x37)\n {\n let digits = String.fromCharCode(escaped);\n while (digits.length < 3\n && index + 1 < bytes.byteLength - 1\n && bytes[index + 1] >= 0x30\n && bytes[index + 1] <= 0x37)\n {\n index += 1;\n digits += String.fromCharCode(bytes[index]);\n }\n result.push(String.fromCharCode(Number.parseInt(digits, 8)));\n }\n else\n {\n throw pickleError(\n \"CJS_PICKLE_STRING_INVALID\",\n `Pickle STRING contains unsupported escape \\\\${String.fromCharCode(escaped)}.`,\n offset\n );\n }\n }\n return result.join(\"\");\n}\n\nfunction readUnicode(state, offset)\n{\n const bytes = readLine(state, state.limits.maxStringBytes, offset);\n const result = [];\n\n for (let index = 0; index < bytes.byteLength; index += 1)\n {\n const byte = bytes[index];\n if (byte !== 0x5c || index + 1 >= bytes.byteLength)\n {\n result.push(String.fromCharCode(byte));\n continue;\n }\n\n const escaped = bytes[index + 1];\n if (escaped === 0x75)\n {\n result.push(String.fromCharCode(readHex(bytes, index + 2, 4, offset)));\n index += 5;\n }\n else if (escaped === 0x55)\n {\n const codePoint = readHex(bytes, index + 2, 8, offset);\n if (codePoint > 0x10ffff)\n {\n throw pickleError(\n \"CJS_PICKLE_STRING_INVALID\",\n `Pickle UNICODE code point is out of range: ${codePoint}.`,\n offset\n );\n }\n result.push(String.fromCodePoint(codePoint));\n index += 9;\n }\n else\n {\n result.push(\"\\\\\");\n }\n }\n return result.join(\"\");\n}\n\nfunction readSequence(state, offset, isList)\n{\n const values = popMarkedValues(state, offset);\n requireContainerLimit(state, values.length, offset);\n state.containers.set(values, values.length);\n if (isList) state.lists.add(values);\n return values;\n}\n\nfunction readDictionary(state, offset)\n{\n const values = popMarkedValues(state, offset);\n if (values.length % 2 !== 0)\n {\n throw pickleError(\n \"CJS_PICKLE_CONTAINER_INVALID\",\n \"Pickle DICT requires key/value pairs.\",\n offset\n );\n }\n\n requireContainerLimit(state, values.length / 2, offset);\n const result = {};\n let count = 0;\n state.dictionaryKeys.set(result, new Map());\n\n for (let index = 0; index < values.length; index += 2)\n {\n count = defineDictionaryValue(\n state,\n result,\n values[index],\n values[index + 1],\n count,\n offset\n );\n }\n state.containers.set(result, count);\n return result;\n}\n\nfunction append(state, offset)\n{\n requireStack(state, 2, offset);\n const value = state.stack.pop();\n const target = state.stack[state.stack.length - 1];\n if (!Array.isArray(target) || !state.lists.has(target))\n {\n throw pickleError(\n \"CJS_PICKLE_CONTAINER_INVALID\",\n \"Pickle APPEND target must be a list.\",\n offset\n );\n }\n\n requireContainerLimit(state, target.length + 1, offset);\n target.push(value);\n state.containers.set(target, target.length);\n}\n\nfunction setItem(state, offset)\n{\n requireStack(state, 3, offset);\n const value = state.stack.pop();\n const key = state.stack.pop();\n const target = state.stack[state.stack.length - 1];\n if (!isDictionary(target))\n {\n throw pickleError(\n \"CJS_PICKLE_CONTAINER_INVALID\",\n \"Pickle SETITEM target must be a dictionary.\",\n offset\n );\n }\n\n const count = defineDictionaryValue(\n state,\n target,\n key,\n value,\n state.containers.get(target) ?? Object.keys(target).length,\n offset\n );\n requireContainerLimit(state, count, offset);\n state.containers.set(target, count);\n}\n\nfunction defineDictionaryValue(state, target, key, value, count, offset)\n{\n const normalized = normalizeDictionaryKey(key, offset);\n const keyTypes = state.dictionaryKeys.get(target) ?? new Map();\n const previousType = keyTypes.get(normalized.value);\n if (previousType && previousType !== normalized.type)\n {\n throw pickleError(\n \"CJS_PICKLE_CONTAINER_INVALID\",\n `Pickle dictionary keys collide after JSON normalization: ${JSON.stringify(normalized.value)}.`,\n offset\n );\n }\n\n const exists = Object.hasOwn(target, normalized.value);\n Object.defineProperty(target, normalized.value, {\n configurable: true,\n enumerable: true,\n value,\n writable: true\n });\n keyTypes.set(normalized.value, normalized.type);\n state.dictionaryKeys.set(target, keyTypes);\n return exists ? count : count + 1;\n}\n\nfunction normalizeDictionaryKey(key, offset)\n{\n if (typeof key === \"string\") return { type: \"string\", value: key };\n if (typeof key === \"number\" && Number.isSafeInteger(key))\n {\n return { type: \"integer\", value: String(key) };\n }\n throw pickleError(\n \"CJS_PICKLE_CONTAINER_INVALID\",\n \"Data-only pickle dictionaries require string or safe-integer keys.\",\n offset\n );\n}\n\nfunction putMemo(state, offset)\n{\n requireStack(state, 1, offset);\n if (state.stack[state.stack.length - 1] === MARK)\n {\n throw pickleError(\n \"CJS_PICKLE_MARK_INVALID\",\n \"Pickle MARK cannot be stored in the memo.\",\n offset\n );\n }\n const id = readMemoID(state, offset);\n if (!state.memo.has(id) && state.memo.size >= state.limits.maxMemoEntries)\n {\n throw pickleError(\n \"CJS_PICKLE_LIMIT_EXCEEDED\",\n `Pickle memo exceeds maxMemoEntries (${state.limits.maxMemoEntries}).`,\n offset\n );\n }\n state.memo.set(id, state.stack[state.stack.length - 1]);\n}\n\nfunction getMemo(state, offset)\n{\n const id = readMemoID(state, offset);\n if (!state.memo.has(id))\n {\n throw pickleError(\n \"CJS_PICKLE_MEMO_INVALID\",\n `Pickle memo entry ${id} does not exist.`,\n offset\n );\n }\n push(state, state.memo.get(id), offset);\n}\n\nfunction readMemoID(state, offset)\n{\n const value = readAsciiLine(state, 64, offset);\n if (!/^\\d+$/u.test(value))\n {\n throw pickleError(\n \"CJS_PICKLE_MEMO_INVALID\",\n `Pickle memo ID is invalid: ${JSON.stringify(value)}.`,\n offset\n );\n }\n\n const result = Number(value);\n if (!Number.isSafeInteger(result) || result > state.limits.maxMemoID)\n {\n throw pickleError(\n \"CJS_PICKLE_LIMIT_EXCEEDED\",\n `Pickle memo ID exceeds maxMemoID (${state.limits.maxMemoID}).`,\n offset\n );\n }\n return result;\n}\n\nfunction popMarkedValues(state, offset)\n{\n if (!state.marks.length)\n {\n throw pickleError(\n \"CJS_PICKLE_MARK_INVALID\",\n \"Pickle container has no matching MARK.\",\n offset\n );\n }\n\n const mark = state.marks.pop();\n if (state.stack[mark] !== MARK)\n {\n throw pickleError(\n \"CJS_PICKLE_MARK_INVALID\",\n \"Pickle MARK stack is inconsistent.\",\n offset\n );\n }\n\n const values = state.stack.slice(mark + 1);\n state.stack.length = mark;\n return values;\n}\n\nfunction push(state, value, offset)\n{\n if (state.stack.length >= state.limits.maxStackDepth)\n {\n throw pickleError(\n \"CJS_PICKLE_LIMIT_EXCEEDED\",\n `Pickle stack exceeds maxStackDepth (${state.limits.maxStackDepth}).`,\n offset\n );\n }\n state.stack.push(value);\n}\n\nfunction requireStack(state, count, offset)\n{\n if (state.stack.length < count)\n {\n throw pickleError(\n \"CJS_PICKLE_STACK_INVALID\",\n `Pickle opcode requires ${count} stack values.`,\n offset\n );\n }\n}\n\nfunction requireContainerLimit(state, count, offset)\n{\n if (count > state.limits.maxContainerItems)\n {\n throw pickleError(\n \"CJS_PICKLE_LIMIT_EXCEEDED\",\n `Pickle container exceeds maxContainerItems (${state.limits.maxContainerItems}).`,\n offset\n );\n }\n}\n\nfunction readAsciiLine(state, limit, offset)\n{\n const bytes = readLine(state, limit, offset);\n let result = \"\";\n for (const byte of bytes)\n {\n if (byte > 0x7f)\n {\n throw pickleError(\n \"CJS_PICKLE_STRING_INVALID\",\n \"Pickle control line must contain ASCII bytes.\",\n offset\n );\n }\n result += String.fromCharCode(byte);\n }\n return result;\n}\n\nfunction readLine(state, limit, offset)\n{\n const start = state.offset;\n while (state.offset < state.bytes.byteLength && state.bytes[state.offset] !== 0x0a)\n {\n state.offset += 1;\n if (state.offset - start > limit)\n {\n throw pickleError(\n \"CJS_PICKLE_LIMIT_EXCEEDED\",\n `Pickle line exceeds its ${limit}-byte limit.`,\n offset\n );\n }\n }\n\n if (state.offset >= state.bytes.byteLength)\n {\n throw pickleError(\n \"CJS_PICKLE_EOF\",\n \"Pickle line is missing its newline terminator.\",\n offset\n );\n }\n\n const result = state.bytes.subarray(start, state.offset);\n state.offset += 1;\n return result;\n}\n\nfunction readHex(bytes, start, length, offset)\n{\n if (start + length > bytes.byteLength)\n {\n throw pickleError(\n \"CJS_PICKLE_STRING_INVALID\",\n \"Pickle escape sequence is truncated.\",\n offset\n );\n }\n\n let result = 0;\n for (let index = 0; index < length; index += 1)\n {\n const value = hexValue(bytes[start + index]);\n if (value === -1)\n {\n throw pickleError(\n \"CJS_PICKLE_STRING_INVALID\",\n \"Pickle escape sequence contains a non-hexadecimal digit.\",\n offset\n );\n }\n result = result * 16 + value;\n }\n return result;\n}\n\nfunction hexValue(byte)\n{\n if (byte >= 0x30 && byte <= 0x39) return byte - 0x30;\n if (byte >= 0x41 && byte <= 0x46) return byte - 0x41 + 10;\n if (byte >= 0x61 && byte <= 0x66) return byte - 0x61 + 10;\n return -1;\n}\n\nfunction decodeSimpleEscape(byte)\n{\n const values = {\n 0x22: 0x22,\n 0x27: 0x27,\n 0x5c: 0x5c,\n 0x61: 0x07,\n 0x62: 0x08,\n 0x66: 0x0c,\n 0x6e: 0x0a,\n 0x72: 0x0d,\n 0x74: 0x09,\n 0x76: 0x0b\n };\n return Object.hasOwn(values, byte) ? values[byte] : null;\n}\n\nfunction assertJSONCompatible(value)\n{\n const active = new WeakSet();\n const verified = new WeakSet();\n const pending = [ { exit: false, value } ];\n\n while (pending.length)\n {\n const item = pending.pop();\n const current = item.value;\n if (current === null\n || typeof current === \"string\"\n || typeof current === \"boolean\")\n {\n continue;\n }\n if (typeof current === \"number\")\n {\n if (!Number.isFinite(current))\n {\n throw pickleError(\n \"CJS_PICKLE_JSON_INVALID\",\n \"Pickle output contains a non-finite number.\",\n null\n );\n }\n continue;\n }\n if (!current || typeof current !== \"object\")\n {\n throw pickleError(\n \"CJS_PICKLE_JSON_INVALID\",\n `Pickle output contains unsupported ${typeof current} data.`,\n null\n );\n }\n if (item.exit)\n {\n active.delete(current);\n verified.add(current);\n continue;\n }\n if (verified.has(current)) continue;\n if (active.has(current))\n {\n throw pickleError(\n \"CJS_PICKLE_JSON_INVALID\",\n \"Pickle output contains a cyclic reference.\",\n null\n );\n }\n\n active.add(current);\n pending.push({ exit: true, value: current });\n\n if (Array.isArray(current))\n {\n for (let index = current.length - 1; index >= 0; index -= 1)\n {\n pending.push({ exit: false, value: current[index] });\n }\n }\n else if (Object.getPrototypeOf(current) === Object.prototype)\n {\n const keys = Object.keys(current);\n for (let index = keys.length - 1; index >= 0; index -= 1)\n {\n pending.push({ exit: false, value: current[keys[index]] });\n }\n }\n else\n {\n throw pickleError(\n \"CJS_PICKLE_JSON_INVALID\",\n \"Pickle output contains a non-plain object.\",\n null\n );\n }\n }\n}\n\nfunction normalizeBytes(input)\n{\n if (input instanceof ArrayBuffer) return new Uint8Array(input);\n if (ArrayBuffer.isView(input))\n {\n return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n }\n throw pickleError(\n \"CJS_PICKLE_INPUT_INVALID\",\n \"Pickle input must be an ArrayBuffer or an ArrayBuffer view.\",\n 0\n );\n}\n\nfunction normalizeLimits(options)\n{\n if (!options || typeof options !== \"object\" || Array.isArray(options))\n {\n throw pickleError(\n \"CJS_PICKLE_LIMIT_INVALID\",\n \"Pickle limits must be an object.\",\n 0\n );\n }\n\n for (const name of Object.keys(options))\n {\n if (!LIMIT_NAMES.includes(name))\n {\n throw pickleError(\n \"CJS_PICKLE_LIMIT_INVALID\",\n `Pickle limits contain unknown value ${JSON.stringify(name)}.`,\n 0\n );\n }\n }\n\n const result = {};\n for (const name of LIMIT_NAMES)\n {\n const value = options[name] ?? PICKLE_PROTOCOL_0_LIMITS[name];\n if (!Number.isSafeInteger(value) || value <= 0)\n {\n throw pickleError(\n \"CJS_PICKLE_LIMIT_INVALID\",\n `Pickle ${name} must be a positive safe integer.`,\n 0\n );\n }\n result[name] = value;\n }\n return result;\n}\n\nfunction isDictionary(value)\n{\n return Boolean(value\n && typeof value === \"object\"\n && !Array.isArray(value)\n && Object.getPrototypeOf(value) === Object.prototype);\n}\n\nfunction displayOpcode(value)\n{\n if (value >= 0x20 && value <= 0x7e)\n {\n return JSON.stringify(String.fromCharCode(value));\n }\n return `0x${value.toString(16).padStart(2, \"0\")}`;\n}\n\nfunction pickleError(code, message, offset)\n{\n const error = new Error(message);\n error.code = code;\n error.protocol = 0;\n if (offset !== null) error.offset = offset;\n return error;\n}\n\nexport default CjsPickleProtocol0Reader;\n"],"names":["MARK","Symbol","PICKLE_PROTOCOL_0_LIMITS","maxContainerItems","maxInputBytes","maxMemoEntries","maxMemoID","maxOperations","maxStackDepth","maxStringBytes","LIMIT_NAMES","Object","keys","CjsPickleProtocol0Reader","constructor","input","options","normalizeBytes","normalizeLimits","limits","byteLength","pickleError","Read","decode","ReadJSON","value","assertJSONCompatible","ToJSON","bytes","state","containers","WeakMap","dictionaryKeys","lists","WeakSet","marks","memo","Map","offset","operations","stack","opcodeOffset","opcode","push","length","stop","readFloat","readInteger","readString","readUnicode","append","readDictionary","getMemo","readSequence","putMemo","setItem","displayOpcode","readAsciiLine","test","JSON","stringify","result","Number","isFinite","isLong","endsWith","slice","BigInt","MIN_SAFE_INTEGER","MAX_SAFE_INTEGER","toString","readLine","quote","index","byte","String","fromCharCode","escaped","simple","decodeSimpleEscape","readHex","digits","parseInt","join","codePoint","fromCodePoint","isList","values","popMarkedValues","requireContainerLimit","set","add","count","defineDictionaryValue","requireStack","pop","target","Array","isArray","has","key","isDictionary","get","normalized","normalizeDictionaryKey","keyTypes","previousType","type","exists","hasOwn","defineProperty","configurable","enumerable","writable","isSafeInteger","id","readMemoID","size","mark","limit","start","subarray","hexValue","active","verified","pending","exit","item","current","delete","getPrototypeOf","prototype","ArrayBuffer","Uint8Array","isView","buffer","byteOffset","name","includes","Boolean","padStart","code","message","error","Error","protocol"],"mappings":"AAAA,MAAMA,IAAI,GAAGC,MAAM,CAAC,aAAa,CAAC;AAE3B,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AK,CAACzG,MAAM,GAAGA,MAAM;AAC1C,EAAA,OAAOyG,KAAK;AACd;;;;"}
1
+ {"version":3,"file":"CjsPickleProtocol0Reader.js","sources":["../../../../../src/formats/pickle/core/CjsPickleProtocol0Reader.js"],"sourcesContent":["const MARK = Symbol(\"pickle-mark\");\n\nexport const PICKLE_PROTOCOL_0_LIMITS = {\n maxContainerItems: 1000000,\n maxInputBytes: 32 * 1024 * 1024,\n maxMemoEntries: 500000,\n maxMemoID: 1000000,\n maxOperations: 2000000,\n maxStackDepth: 100000,\n maxStringBytes: 4 * 1024 * 1024\n};\n\nconst LIMIT_NAMES = Object.keys(PICKLE_PROTOCOL_0_LIMITS);\n\n/**\n * Construction-bound decoder for the inert data subset of Python pickle\n * protocol 0.\n *\n * The reader never imports modules, resolves globals, invokes reducers, or\n * constructs Python objects. Unsupported opcodes fail closed at their byte\n * offset.\n */\nexport class CjsPickleProtocol0Reader\n{\n #bytes;\n #limits;\n\n /**\n * Bind one byte source and its resource limits.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Pickle protocol-0 bytes.\n * @param {object} [options] Reader options containing optional limits.\n */\n constructor(input, options = {})\n {\n this.#bytes = normalizeBytes(input);\n this.#limits = normalizeLimits(options.limits ?? options);\n\n if (this.#bytes.byteLength > this.#limits.maxInputBytes)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_LIMIT_EXCEEDED\",\n `Pickle input exceeds maxInputBytes (${this.#limits.maxInputBytes}).`,\n 0\n );\n }\n }\n\n /**\n * Decode an inert JavaScript value while preserving pickle memo identity.\n *\n * @returns {*} Decoded scalar, array, or plain object graph.\n */\n Read()\n {\n return decode(this.#bytes, this.#limits);\n }\n\n /**\n * Decode a value and reject cycles or values JSON cannot represent.\n *\n * @returns {*} JSON-compatible decoded graph.\n */\n ReadJSON()\n {\n const value = this.Read();\n assertJSONCompatible(value);\n return value;\n }\n\n /**\n * Verify that a decoded value can cross the JSON boundary unchanged.\n *\n * @param {*} value Candidate decoded graph.\n * @returns {*} The supplied value.\n */\n static ToJSON(value)\n {\n assertJSONCompatible(value);\n return value;\n }\n}\n\nfunction decode(bytes, limits)\n{\n const state = {\n bytes,\n containers: new WeakMap(),\n dictionaryKeys: new WeakMap(),\n limits,\n lists: new WeakSet(),\n marks: [],\n memo: new Map(),\n offset: 0,\n operations: 0,\n // Every global marker created, and separately those no REDUCE has consumed.\n // A marker is a decoding artifact, never data: it may sit on the stack and\n // in the memo on its way to a REDUCE, and it may reach nothing else.\n globalMarkers: new WeakSet(),\n pendingGlobals: new Set(),\n // Properties built by REDUCE across the WHOLE decode, not per container.\n rebuiltItems: 0,\n stack: []\n };\n\n while (state.offset < bytes.byteLength)\n {\n const opcodeOffset = state.offset;\n const opcode = bytes[state.offset++];\n\n state.operations += 1;\n if (state.operations > limits.maxOperations)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_LIMIT_EXCEEDED\",\n `Pickle operation count exceeds maxOperations (${limits.maxOperations}).`,\n opcodeOffset\n );\n }\n\n switch (opcode)\n {\n case 0x28: // MARK\n state.marks.push(state.stack.length);\n push(state, MARK, opcodeOffset);\n break;\n\n case 0x2e: // STOP\n return stop(state, opcodeOffset);\n\n case 0x46: // FLOAT\n push(state, readFloat(state, opcodeOffset), opcodeOffset);\n break;\n\n case 0x49: // INT\n push(state, readInteger(state, opcodeOffset, false), opcodeOffset);\n break;\n\n case 0x4c: // LONG\n push(state, readInteger(state, opcodeOffset, true), opcodeOffset);\n break;\n\n case 0x4e: // NONE\n push(state, null, opcodeOffset);\n break;\n\n case 0x53: // STRING\n push(state, readString(state, opcodeOffset), opcodeOffset);\n break;\n\n case 0x56: // UNICODE\n push(state, readUnicode(state, opcodeOffset), opcodeOffset);\n break;\n\n case 0x61: // APPEND\n append(state, opcodeOffset);\n break;\n\n case 0x64: // DICT\n push(state, readDictionary(state, opcodeOffset), opcodeOffset);\n break;\n\n case 0x67: // GET\n getMemo(state, opcodeOffset);\n break;\n\n case 0x6c: // LIST\n push(state, readSequence(state, opcodeOffset, true), opcodeOffset);\n break;\n\n case 0x74: // TUPLE\n push(state, readSequence(state, opcodeOffset, false), opcodeOffset);\n break;\n\n case 0x70: // PUT\n putMemo(state, opcodeOffset);\n break;\n\n case 0x73: // SETITEM\n setItem(state, opcodeOffset);\n break;\n\n case 0x63: // GLOBAL\n push(state, readGlobal(state, opcodeOffset), opcodeOffset);\n break;\n\n case 0x52: // REDUCE\n reduce(state, opcodeOffset);\n break;\n\n default:\n throw pickleError(\n \"CJS_PICKLE_FORMAT_OPCODE_UNSUPPORTED\",\n `Data-only pickle protocol 0 rejects opcode ${displayOpcode(opcode)}.`,\n opcodeOffset\n );\n }\n }\n\n throw pickleError(\n \"CJS_PICKLE_FORMAT_STOP_MISSING\",\n \"Pickle input ended without a STOP opcode.\",\n state.offset\n );\n}\n\nfunction stop(state, offset)\n{\n // A GLOBAL that no REDUCE consumed would otherwise reach the caller as an\n // empty object, indistinguishable from an empty dictionary.\n if (state.pendingGlobals.size)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_GLOBAL_UNSUPPORTED\",\n \"Pickle names a global that no REDUCE consumes.\",\n offset\n );\n }\n rejectGlobalMarker(state, state.stack[0], offset);\n if (state.marks.length || state.stack.length !== 1 || state.stack[0] === MARK)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_STACK_INVALID\",\n \"Pickle STOP requires one completed value and no open marks.\",\n offset\n );\n }\n if (state.offset !== state.bytes.byteLength)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_TRAILING_DATA\",\n \"Pickle input contains bytes after STOP.\",\n state.offset\n );\n }\n return state.stack[0];\n}\n\nfunction readFloat(state, offset)\n{\n const value = readAsciiLine(state, state.limits.maxStringBytes, offset);\n if (!/^[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?$/u.test(value))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_NUMBER_INVALID\",\n `Pickle FLOAT value is invalid: ${JSON.stringify(value)}.`,\n offset\n );\n }\n\n const result = Number(value);\n if (!Number.isFinite(result))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_NUMBER_INVALID\",\n \"Pickle FLOAT must be finite for JSON-compatible output.\",\n offset\n );\n }\n return result;\n}\n\nfunction readInteger(state, offset, isLong)\n{\n let value = readAsciiLine(state, 128, offset);\n\n if (!isLong && value === \"00\") return false;\n if (!isLong && value === \"01\") return true;\n if (isLong && value.endsWith(\"L\")) value = value.slice(0, -1);\n\n if (!/^[+-]?\\d+$/u.test(value))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_NUMBER_INVALID\",\n `Pickle integer value is invalid: ${JSON.stringify(value)}.`,\n offset\n );\n }\n\n const result = BigInt(value);\n if (result >= BigInt(Number.MIN_SAFE_INTEGER)\n && result <= BigInt(Number.MAX_SAFE_INTEGER))\n {\n return Number(result);\n }\n return result.toString();\n}\n\nfunction readString(state, offset)\n{\n const bytes = readLine(state, state.limits.maxStringBytes, offset);\n if (bytes.byteLength < 2)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_STRING_INVALID\",\n \"Pickle STRING must be a quoted Python string literal.\",\n offset\n );\n }\n\n const quote = bytes[0];\n if ((quote !== 0x27 && quote !== 0x22)\n || bytes[bytes.byteLength - 1] !== quote)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_STRING_INVALID\",\n \"Pickle STRING must use matching single or double quotes.\",\n offset\n );\n }\n\n const result = [];\n for (let index = 1; index < bytes.byteLength - 1; index += 1)\n {\n const byte = bytes[index];\n if (byte !== 0x5c)\n {\n result.push(String.fromCharCode(byte));\n continue;\n }\n\n index += 1;\n if (index >= bytes.byteLength - 1)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_STRING_INVALID\",\n \"Pickle STRING ends with an incomplete escape.\",\n offset\n );\n }\n\n const escaped = bytes[index];\n const simple = decodeSimpleEscape(escaped);\n if (simple !== null)\n {\n result.push(String.fromCharCode(simple));\n }\n else if (escaped === 0x78)\n {\n result.push(String.fromCharCode(readHex(bytes, index + 1, 2, offset)));\n index += 2;\n }\n else if (escaped >= 0x30 && escaped <= 0x37)\n {\n let digits = String.fromCharCode(escaped);\n while (digits.length < 3\n && index + 1 < bytes.byteLength - 1\n && bytes[index + 1] >= 0x30\n && bytes[index + 1] <= 0x37)\n {\n index += 1;\n digits += String.fromCharCode(bytes[index]);\n }\n result.push(String.fromCharCode(Number.parseInt(digits, 8)));\n }\n else\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_STRING_INVALID\",\n `Pickle STRING contains unsupported escape \\\\${String.fromCharCode(escaped)}.`,\n offset\n );\n }\n }\n return result.join(\"\");\n}\n\nfunction readUnicode(state, offset)\n{\n const bytes = readLine(state, state.limits.maxStringBytes, offset);\n const result = [];\n\n for (let index = 0; index < bytes.byteLength; index += 1)\n {\n const byte = bytes[index];\n if (byte !== 0x5c || index + 1 >= bytes.byteLength)\n {\n result.push(String.fromCharCode(byte));\n continue;\n }\n\n const escaped = bytes[index + 1];\n if (escaped === 0x75)\n {\n result.push(String.fromCharCode(readHex(bytes, index + 2, 4, offset)));\n index += 5;\n }\n else if (escaped === 0x55)\n {\n const codePoint = readHex(bytes, index + 2, 8, offset);\n if (codePoint > 0x10ffff)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_STRING_INVALID\",\n `Pickle UNICODE code point is out of range: ${codePoint}.`,\n offset\n );\n }\n result.push(String.fromCodePoint(codePoint));\n index += 9;\n }\n else\n {\n result.push(\"\\\\\");\n }\n }\n return result.join(\"\");\n}\n\nfunction readSequence(state, offset, isList)\n{\n const values = popMarkedValues(state, offset);\n requireContainerLimit(state, values.length, offset);\n state.containers.set(values, values.length);\n if (isList) state.lists.add(values);\n return values;\n}\n\nfunction readDictionary(state, offset)\n{\n const values = popMarkedValues(state, offset);\n if (values.length % 2 !== 0)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_CONTAINER_INVALID\",\n \"Pickle DICT requires key/value pairs.\",\n offset\n );\n }\n\n requireContainerLimit(state, values.length / 2, offset);\n const result = {};\n let count = 0;\n state.dictionaryKeys.set(result, new Map());\n\n for (let index = 0; index < values.length; index += 2)\n {\n count = defineDictionaryValue(\n state,\n result,\n values[index],\n values[index + 1],\n count,\n offset\n );\n }\n state.containers.set(result, count);\n return result;\n}\n\nfunction append(state, offset)\n{\n requireStack(state, 2, offset);\n const value = rejectGlobalMarker(state, state.stack.pop(), offset);\n const target = state.stack[state.stack.length - 1];\n if (!Array.isArray(target) || !state.lists.has(target))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_CONTAINER_INVALID\",\n \"Pickle APPEND target must be a list.\",\n offset\n );\n }\n\n requireContainerLimit(state, target.length + 1, offset);\n target.push(value);\n state.containers.set(target, target.length);\n}\n\nfunction setItem(state, offset)\n{\n requireStack(state, 3, offset);\n const value = rejectGlobalMarker(state, state.stack.pop(), offset);\n const key = state.stack.pop();\n const target = state.stack[state.stack.length - 1];\n if (!isDictionary(target))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_CONTAINER_INVALID\",\n \"Pickle SETITEM target must be a dictionary.\",\n offset\n );\n }\n\n const count = defineDictionaryValue(\n state,\n target,\n key,\n value,\n state.containers.get(target) ?? Object.keys(target).length,\n offset\n );\n requireContainerLimit(state, count, offset);\n state.containers.set(target, count);\n}\n\nfunction defineDictionaryValue(state, target, key, value, count, offset)\n{\n const normalized = normalizeDictionaryKey(key, offset);\n const keyTypes = state.dictionaryKeys.get(target) ?? new Map();\n const previousType = keyTypes.get(normalized.value);\n if (previousType && previousType !== normalized.type)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_CONTAINER_INVALID\",\n `Pickle dictionary keys collide after JSON normalization: ${JSON.stringify(normalized.value)}.`,\n offset\n );\n }\n\n const exists = Object.hasOwn(target, normalized.value);\n Object.defineProperty(target, normalized.value, {\n configurable: true,\n enumerable: true,\n value,\n writable: true\n });\n keyTypes.set(normalized.value, normalized.type);\n state.dictionaryKeys.set(target, keyTypes);\n return exists ? count : count + 1;\n}\n\nfunction normalizeDictionaryKey(key, offset)\n{\n if (typeof key === \"string\") return { type: \"string\", value: key };\n if (typeof key === \"number\" && Number.isSafeInteger(key))\n {\n return { type: \"integer\", value: String(key) };\n }\n throw pickleError(\n \"CJS_PICKLE_FORMAT_CONTAINER_INVALID\",\n \"Data-only pickle dictionaries require string or safe-integer keys.\",\n offset\n );\n}\n\nfunction putMemo(state, offset)\n{\n requireStack(state, 1, offset);\n if (state.stack[state.stack.length - 1] === MARK)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_MARK_INVALID\",\n \"Pickle MARK cannot be stored in the memo.\",\n offset\n );\n }\n const id = readMemoID(state, offset);\n if (!state.memo.has(id) && state.memo.size >= state.limits.maxMemoEntries)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_LIMIT_EXCEEDED\",\n `Pickle memo exceeds maxMemoEntries (${state.limits.maxMemoEntries}).`,\n offset\n );\n }\n state.memo.set(id, state.stack[state.stack.length - 1]);\n}\n\nfunction getMemo(state, offset)\n{\n const id = readMemoID(state, offset);\n if (!state.memo.has(id))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_MEMO_INVALID\",\n `Pickle memo entry ${id} does not exist.`,\n offset\n );\n }\n push(state, state.memo.get(id), offset);\n}\n\nfunction readMemoID(state, offset)\n{\n const value = readAsciiLine(state, 64, offset);\n if (!/^\\d+$/u.test(value))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_MEMO_INVALID\",\n `Pickle memo ID is invalid: ${JSON.stringify(value)}.`,\n offset\n );\n }\n\n const result = Number(value);\n if (!Number.isSafeInteger(result) || result > state.limits.maxMemoID)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_LIMIT_EXCEEDED\",\n `Pickle memo ID exceeds maxMemoID (${state.limits.maxMemoID}).`,\n offset\n );\n }\n return result;\n}\n\n/**\n * The one closed set of globals this reader will name, and how each rebuilds.\n *\n * `GLOBAL` is the opcode that makes a pickle dangerous: it names a module and an\n * attribute for the unpickler to import, and `REDUCE` then calls it. The general\n * form stays refused, and nothing here imports, resolves or invokes anything.\n * What this table does instead is recognize a fixed name and build the plain\n * data it stands for.\n *\n * `collections.OrderedDict` earns its place because it is not a behaviour, it is\n * a dictionary that remembers insertion order — and a JavaScript object already\n * does. It is also, measured across every self-describing container CCP ships,\n * **the only global any of them uses**: 25 files, one name, once each. They use\n * it because a schema's attribute order is its field order, which is exactly the\n * property an ordinary dict would lose.\n *\n * **Adding to this table is not a small change.** A name belongs here only if\n * reconstructing it is pure data with no behaviour of its own, and the entry has\n * to build that data directly rather than defer to anything callable.\n */\nconst REBUILDABLE_GLOBALS = new Map([\n [ \"collections.OrderedDict\", RebuildOrderedDict ]\n]);\n\nconst GLOBAL_NAME = Symbol(\"pickle-global\");\n\n/** Reads a GLOBAL, and refuses every name outside the closed set above. */\nfunction readGlobal(state, offset)\n{\n const module = decodeAscii(readLine(state, state.limits.maxStringBytes, offset));\n const attribute = decodeAscii(readLine(state, state.limits.maxStringBytes, offset));\n const name = `${module}.${attribute}`;\n\n if (!REBUILDABLE_GLOBALS.has(name))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_GLOBAL_UNSUPPORTED\",\n `Data-only pickle protocol 0 rejects the global ${JSON.stringify(name)}. `\n + \"Only a closed set of pure-data containers can be rebuilt, and this is not one.\",\n offset\n );\n }\n\n const marker = { [GLOBAL_NAME]: name };\n\n state.globalMarkers.add(marker);\n state.pendingGlobals.add(marker);\n\n return marker;\n}\n\n/** Rebuilds one allowed global from its arguments. Calls nothing. */\nfunction reduce(state, offset)\n{\n const args = state.stack.pop();\n const callable = state.stack.pop();\n const name = callable && typeof callable === \"object\" ? callable[GLOBAL_NAME] : undefined;\n\n if (!name || !REBUILDABLE_GLOBALS.has(name))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_REDUCE_INVALID\",\n \"Pickle REDUCE applies only to a global this reader can rebuild.\",\n offset\n );\n }\n\n if (!Array.isArray(args))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_REDUCE_INVALID\",\n \"Pickle REDUCE requires an argument tuple.\",\n offset\n );\n }\n\n state.pendingGlobals.delete(callable);\n push(state, REBUILDABLE_GLOBALS.get(name)(args, state, offset), offset);\n}\n\n/**\n * Rebuilds `OrderedDict(pairs)` as a plain object.\n *\n * JavaScript preserves the insertion order of string keys, but NOT of keys that\n * look like array indices — those sort ahead of everything else, in ascending\n * numeric order. Refusing every numeric key was too blunt: real containers use\n * them, and where they already ascend the object's order is the source's order\n * and nothing is lost.\n *\n * So the order is checked rather than the keys. The result is compared against\n * the order it was built in, and only a dictionary JavaScript would actually\n * reorder is refused.\n */\nfunction RebuildOrderedDict(args, state, offset)\n{\n const pairs = args.length ? args[0] : [];\n\n if (!Array.isArray(pairs))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_REDUCE_INVALID\",\n \"An ordered dictionary is rebuilt from a list of key/value pairs.\",\n offset\n );\n }\n\n requireContainerLimit(state, pairs.length, offset);\n\n const order = [];\n\n // A per-container check is not enough here. REDUCE is the only path that\n // builds N properties for a constant number of opcodes, so a memoized pair\n // list rebuilt in a loop multiplies `maxOperations` by `maxContainerItems`\n // instead of being bounded by either. A decode-wide budget is what bounds it.\n state.rebuiltItems += pairs.length;\n\n if (state.rebuiltItems > state.limits.maxContainerItems)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_LIMIT_EXCEEDED\",\n `Rebuilt items exceed maxContainerItems (${state.limits.maxContainerItems}) across the decode.`,\n offset\n );\n }\n\n const result = {};\n\n for (const pair of pairs)\n {\n if (!Array.isArray(pair) || pair.length !== 2)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_REDUCE_INVALID\",\n \"An ordered dictionary entry must be a key/value pair.\",\n offset\n );\n }\n\n const key = pair[0];\n\n if (typeof key !== \"string\")\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_REDUCE_INVALID\",\n \"An ordered dictionary key must be a string.\",\n offset\n );\n }\n\n order.push(key);\n\n // Defined rather than assigned, as the dictionary path already does. A\n // plain assignment to `__proto__` sets the object's prototype instead of\n // storing a property: the field silently disappears from the decoded record\n // and, if its value is an object, becomes a phantom the JSON never shows.\n Object.defineProperty(result, key, {\n configurable: true,\n enumerable: true,\n value: pair[1],\n writable: true\n });\n }\n\n // Order is the one thing this type exists to carry, so it is checked rather\n // than assumed. A repeated key keeps its first position, which is what both\n // Python and JavaScript do.\n const expected = [ ...new Set(order) ];\n const kept = Object.keys(result);\n\n if (kept.length !== expected.length || kept.some((key, index) => key !== expected[index])) {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_REDUCE_INVALID\",\n \"An ordered dictionary's key order would not survive as a JavaScript object.\",\n offset\n );\n }\n\n return result;\n}\n\n/** Decodes a GLOBAL's module or attribute line, which is always ASCII. */\nfunction decodeAscii(bytes)\n{\n let result = \"\";\n\n for (const byte of bytes) result += String.fromCharCode(byte);\n\n return result.trim();\n}\n\n/**\n * Refuses a global marker anywhere a decoded value is stored or returned.\n *\n * Consuming a marker with REDUCE is the only thing it is for. Appended to a\n * list, set as a dictionary value or left as the result, it would reach the\n * caller as `{}` - indistinguishable from an empty dictionary, and buryable\n * anywhere in the graph through the memo.\n */\nfunction rejectGlobalMarker(state, value, offset)\n{\n if (value && typeof value === \"object\" && state.globalMarkers.has(value))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_GLOBAL_UNSUPPORTED\",\n \"A pickle global is only usable as the target of a REDUCE.\",\n offset\n );\n }\n\n return value;\n}\n\nfunction popMarkedValues(state, offset)\n{\n if (!state.marks.length)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_MARK_INVALID\",\n \"Pickle container has no matching MARK.\",\n offset\n );\n }\n\n const mark = state.marks.pop();\n if (state.stack[mark] !== MARK)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_MARK_INVALID\",\n \"Pickle MARK stack is inconsistent.\",\n offset\n );\n }\n\n const values = state.stack.slice(mark + 1);\n state.stack.length = mark;\n for (const value of values) rejectGlobalMarker(state, value, offset);\n return values;\n}\n\nfunction push(state, value, offset)\n{\n if (state.stack.length >= state.limits.maxStackDepth)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_LIMIT_EXCEEDED\",\n `Pickle stack exceeds maxStackDepth (${state.limits.maxStackDepth}).`,\n offset\n );\n }\n state.stack.push(value);\n}\n\nfunction requireStack(state, count, offset)\n{\n if (state.stack.length < count)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_STACK_INVALID\",\n `Pickle opcode requires ${count} stack values.`,\n offset\n );\n }\n}\n\nfunction requireContainerLimit(state, count, offset)\n{\n if (count > state.limits.maxContainerItems)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_LIMIT_EXCEEDED\",\n `Pickle container exceeds maxContainerItems (${state.limits.maxContainerItems}).`,\n offset\n );\n }\n}\n\nfunction readAsciiLine(state, limit, offset)\n{\n const bytes = readLine(state, limit, offset);\n let result = \"\";\n for (const byte of bytes)\n {\n if (byte > 0x7f)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_STRING_INVALID\",\n \"Pickle control line must contain ASCII bytes.\",\n offset\n );\n }\n result += String.fromCharCode(byte);\n }\n return result;\n}\n\nfunction readLine(state, limit, offset)\n{\n const start = state.offset;\n while (state.offset < state.bytes.byteLength && state.bytes[state.offset] !== 0x0a)\n {\n state.offset += 1;\n if (state.offset - start > limit)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_LIMIT_EXCEEDED\",\n `Pickle line exceeds its ${limit}-byte limit.`,\n offset\n );\n }\n }\n\n if (state.offset >= state.bytes.byteLength)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_EOF\",\n \"Pickle line is missing its newline terminator.\",\n offset\n );\n }\n\n const result = state.bytes.subarray(start, state.offset);\n state.offset += 1;\n return result;\n}\n\nfunction readHex(bytes, start, length, offset)\n{\n if (start + length > bytes.byteLength)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_STRING_INVALID\",\n \"Pickle escape sequence is truncated.\",\n offset\n );\n }\n\n let result = 0;\n for (let index = 0; index < length; index += 1)\n {\n const value = hexValue(bytes[start + index]);\n if (value === -1)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_STRING_INVALID\",\n \"Pickle escape sequence contains a non-hexadecimal digit.\",\n offset\n );\n }\n result = result * 16 + value;\n }\n return result;\n}\n\nfunction hexValue(byte)\n{\n if (byte >= 0x30 && byte <= 0x39) return byte - 0x30;\n if (byte >= 0x41 && byte <= 0x46) return byte - 0x41 + 10;\n if (byte >= 0x61 && byte <= 0x66) return byte - 0x61 + 10;\n return -1;\n}\n\nfunction decodeSimpleEscape(byte)\n{\n const values = {\n 0x22: 0x22,\n 0x27: 0x27,\n 0x5c: 0x5c,\n 0x61: 0x07,\n 0x62: 0x08,\n 0x66: 0x0c,\n 0x6e: 0x0a,\n 0x72: 0x0d,\n 0x74: 0x09,\n 0x76: 0x0b\n };\n return Object.hasOwn(values, byte) ? values[byte] : null;\n}\n\nfunction assertJSONCompatible(value)\n{\n const active = new WeakSet();\n const verified = new WeakSet();\n const pending = [ { exit: false, value } ];\n\n while (pending.length)\n {\n const item = pending.pop();\n const current = item.value;\n if (current === null\n || typeof current === \"string\"\n || typeof current === \"boolean\")\n {\n continue;\n }\n if (typeof current === \"number\")\n {\n if (!Number.isFinite(current))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_JSON_INVALID\",\n \"Pickle output contains a non-finite number.\",\n null\n );\n }\n continue;\n }\n if (!current || typeof current !== \"object\")\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_JSON_INVALID\",\n `Pickle output contains unsupported ${typeof current} data.`,\n null\n );\n }\n if (item.exit)\n {\n active.delete(current);\n verified.add(current);\n continue;\n }\n if (verified.has(current)) continue;\n if (active.has(current))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_JSON_INVALID\",\n \"Pickle output contains a cyclic reference.\",\n null\n );\n }\n\n active.add(current);\n pending.push({ exit: true, value: current });\n\n if (Array.isArray(current))\n {\n for (let index = current.length - 1; index >= 0; index -= 1)\n {\n pending.push({ exit: false, value: current[index] });\n }\n }\n else if (Object.getPrototypeOf(current) === Object.prototype)\n {\n const keys = Object.keys(current);\n for (let index = keys.length - 1; index >= 0; index -= 1)\n {\n pending.push({ exit: false, value: current[keys[index]] });\n }\n }\n else\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_JSON_INVALID\",\n \"Pickle output contains a non-plain object.\",\n null\n );\n }\n }\n}\n\nfunction normalizeBytes(input)\n{\n if (input instanceof ArrayBuffer) return new Uint8Array(input);\n if (ArrayBuffer.isView(input))\n {\n return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n }\n throw pickleError(\n \"CJS_PICKLE_FORMAT_INPUT_INVALID\",\n \"Pickle input must be an ArrayBuffer or an ArrayBuffer view.\",\n 0\n );\n}\n\nfunction normalizeLimits(options)\n{\n if (!options || typeof options !== \"object\" || Array.isArray(options))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_LIMIT_INVALID\",\n \"Pickle limits must be an object.\",\n 0\n );\n }\n\n for (const name of Object.keys(options))\n {\n if (!LIMIT_NAMES.includes(name))\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_LIMIT_INVALID\",\n `Pickle limits contain unknown value ${JSON.stringify(name)}.`,\n 0\n );\n }\n }\n\n const result = {};\n for (const name of LIMIT_NAMES)\n {\n const value = options[name] ?? PICKLE_PROTOCOL_0_LIMITS[name];\n if (!Number.isSafeInteger(value) || value <= 0)\n {\n throw pickleError(\n \"CJS_PICKLE_FORMAT_LIMIT_INVALID\",\n `Pickle ${name} must be a positive safe integer.`,\n 0\n );\n }\n result[name] = value;\n }\n return result;\n}\n\nfunction isDictionary(value)\n{\n return Boolean(value\n && typeof value === \"object\"\n && !Array.isArray(value)\n && Object.getPrototypeOf(value) === Object.prototype);\n}\n\nfunction displayOpcode(value)\n{\n if (value >= 0x20 && value <= 0x7e)\n {\n return JSON.stringify(String.fromCharCode(value));\n }\n return `0x${value.toString(16).padStart(2, \"0\")}`;\n}\n\nfunction pickleError(code, message, offset)\n{\n const error = new Error(message);\n error.code = code;\n error.protocol = 0;\n if (offset !== null) error.offset = offset;\n return error;\n}\n\nexport default CjsPickleProtocol0Reader;\n"],"names":["MARK","Symbol","PICKLE_PROTOCOL_0_LIMITS","maxContainerItems","maxInputBytes","maxMemoEntries","maxMemoID","maxOperations","maxStackDepth","maxStringBytes","LIMIT_NAMES","Object","keys","CjsPickleProtocol0Reader","constructor","input","options","normalizeBytes","normalizeLimits","limits","byteLength","pickleError","Read","decode","ReadJSON","value","assertJSONCompatible","ToJSON","bytes","state","containers","WeakMap","dictionaryKeys","lists","WeakSet","marks","memo","Map","offset","operations","globalMarkers","pendingGlobals","Set","rebuiltItems","stack","opcodeOffset","opcode","push","length","stop","readFloat","readInteger","readString","readUnicode","append","readDictionary","getMemo","readSequence","putMemo","setItem","readGlobal","reduce","displayOpcode","size","rejectGlobalMarker","readAsciiLine","test","JSON","stringify","result","Number","isFinite","isLong","endsWith","slice","BigInt","MIN_SAFE_INTEGER","MAX_SAFE_INTEGER","toString","readLine","quote","index","byte","String","fromCharCode","escaped","simple","decodeSimpleEscape","readHex","digits","parseInt","join","codePoint","fromCodePoint","isList","values","popMarkedValues","requireContainerLimit","set","add","count","defineDictionaryValue","requireStack","pop","target","Array","isArray","has","key","isDictionary","get","normalized","normalizeDictionaryKey","keyTypes","previousType","type","exists","hasOwn","defineProperty","configurable","enumerable","writable","isSafeInteger","id","readMemoID","REBUILDABLE_GLOBALS","RebuildOrderedDict","GLOBAL_NAME","module","decodeAscii","attribute","name","marker","args","callable","undefined","delete","pairs","order","pair","expected","kept","some","trim","mark","limit","start","subarray","hexValue","active","verified","pending","exit","item","current","getPrototypeOf","prototype","ArrayBuffer","Uint8Array","isView","buffer","byteOffset","includes","Boolean","padStart","code","message","error","Error","protocol"],"mappings":"AAAA,MAAMA,IAAI,GAAGC,MAAM,CAAC,a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AAC;AACzD;AAEA,SAAS9F,aAAaA,CAACrC,KAAK,EAC5B;AACE,EAAA,IAAIA,KAAK,IAAI,IAAI,IAAIA,KAAK,IAAI,IAAI,EAClC;IACE,OAAO0C,IAAI,CAACC,SAAS,CAACe,MAAM,CAACC,YAAY,CAAC3D,KAAK,CAAC,CAAC;AACnD,EAAA;AACA,EAAA,OAAO,CAAA,EAAA,EAAKA,KAAK,CAACqD,QAAQ,CAAC,EAAE,CAAC,CAACsF,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA,CAAE;AACnD;AAEA,SAAS/I,WAAWA,CAACgJ,IAAI,EAAEC,OAAO,EAAEhI,MAAM,EAC1C;AACE,EAAA,MAAMiI,KAAK,GAAG,IAAIC,KAAK,CAACF,OAAO,CAAC;EAChCC,KAAK,CAACF,IAAI,GAAGA,IAAI;EACjBE,KAAK,CAACE,QAAQ,GAAG,CAAC;EAClB,IAAInI,MAAM,KAAK,IAAI,EAAEiI,KAAK,CAACjI,MAAM,GAAGA,MAAM;AAC1C,EAAA,OAAOiI,KAAK;AACd;;;;"}
@@ -0,0 +1,236 @@
1
+ import { CjsYamlFormat } from '../yaml/CjsYamlFormat.js';
2
+ import { ReadValue } from './core/schemaBoundValues.js';
3
+ import { SchemaBoundError } from './core/schemaBoundErrors.js';
4
+
5
+ const OUTPUT_JSON = "json";
6
+ const OUTPUT_PAYLOAD = "payload";
7
+ const ROOT_TYPES = new Set(["dict", "list", "object"]);
8
+
9
+ /**
10
+ * Reads a container whose layout lives in a separate schema.
11
+ *
12
+ * This is the third of the three families that share the `.static` extension,
13
+ * and the one an extension check is least able to help with: the bytes carry no
14
+ * signature, no version and no self-description. What they carry is a payload
15
+ * whose every field position, width and meaning is stated in a sibling `.schema`
16
+ * document — so the schema is not a hint here, it is the reader.
17
+ *
18
+ * That makes this the opposite of the hash-identified containers, where the
19
+ * header names a layout it does not describe and the layout has to be derived
20
+ * and pinned per dataset. Nothing needs deriving for this family. Supply the
21
+ * schema and the bytes decode.
22
+ *
23
+ * **The schema is required and there is no default.** Given the wrong schema
24
+ * these bytes decode into plausible nonsense rather than failing, because there
25
+ * is nothing in them to disagree with. Pair each payload with the `.schema`
26
+ * that shipped beside it.
27
+ *
28
+ * Read {@link CjsSchemaBoundFormat.read} before writing anything that walks the
29
+ * result: a record's variable section changes length from record to record, and
30
+ * a decoder written around a constant stride will read the first record
31
+ * correctly and everything after it wrongly.
32
+ */
33
+ class CjsSchemaBoundFormat {
34
+ /**
35
+ * Reports whether a schema can drive this reader.
36
+ *
37
+ * The question is about the schema, never the payload. These containers have
38
+ * no signature to test, so claiming to recognize the bytes would be a claim
39
+ * this format cannot support - and `CjsStaticFormat` already answers which
40
+ * family a `.static` file belongs to.
41
+ *
42
+ * @param {object|Uint8Array|ArrayBuffer|string} schema Schema document or its bytes.
43
+ * @returns {boolean} True when the schema has a root this reader understands.
44
+ */
45
+ static is(schema) {
46
+ try {
47
+ return ROOT_TYPES.has(this.schema(schema).type);
48
+ } catch {
49
+ return false;
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Reports whether this format can read a payload described by a schema.
55
+ *
56
+ * @param {object|Uint8Array|ArrayBuffer|string} schema Schema document or its bytes.
57
+ * @param {object} [options] Probe options.
58
+ * @returns {object} Resource probe.
59
+ */
60
+ static isSupported(schema, options = null) {
61
+ return Probe(this.is(schema), options);
62
+ }
63
+
64
+ // INTERIM, 2026-08-16. No `inspect` alias, matching CjsSqliteFormat and
65
+ // diverging from the older formats. Both are held by the same undecided
66
+ // question; see maintenance/INTERIM-sqlite-and-static-2026-08-16.md.
67
+
68
+ /**
69
+ * Reads a container against its schema.
70
+ *
71
+ * The whole payload decodes in one pass. Three properties are worth knowing
72
+ * before relying on the result:
73
+ *
74
+ * - **A keyed container's index is at the end.** Nothing at the front points
75
+ * at it; it is found by reading the last four bytes as the index's own size.
76
+ * - **Record offsets are relative to the four-byte header**, not to the file.
77
+ * Decoding from the file start reads one field early, which looks like a
78
+ * wrong layout rather than a wrong base.
79
+ * - **The per-record offset table varies in length.** An optional attribute
80
+ * that is absent occupies no slot, so consecutive records hold their
81
+ * variable data at different distances from their own start.
82
+ *
83
+ * An absent optional takes the default its schema declares. Where none is
84
+ * declared the attribute is left off the record entirely, which is what the
85
+ * published static data exports show for those same rows.
86
+ *
87
+ * @param {Uint8Array|ArrayBuffer} input Container bytes.
88
+ * @param {object} options Read options.
89
+ * @param {object|Uint8Array|ArrayBuffer|string} options.schema The sibling schema.
90
+ * @param {string} [options.output] `json` or `payload`.
91
+ * @returns {object|Array} The decoded container.
92
+ */
93
+ static read(input, options = {}) {
94
+ const bytes = Normalize(input);
95
+ const schema = this.schema(options.schema);
96
+ if (!ROOT_TYPES.has(schema.type)) {
97
+ throw SchemaBoundError(`A container's root must be a dict, list or object, not ${schema.type}.`);
98
+ }
99
+ const context = {
100
+ bytes,
101
+ view: new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)
102
+ };
103
+ const decoded = ReadValue(context, 0, schema).value;
104
+ return options.output === OUTPUT_PAYLOAD ? decoded : ToJSON(decoded);
105
+ }
106
+
107
+ /** Reads to plain JSON-compatible values. */
108
+ static readJSON(input, options = {}) {
109
+ return this.read(input, {
110
+ ...options,
111
+ output: OUTPUT_JSON
112
+ });
113
+ }
114
+
115
+ /** Reads with wide integers left as `BigInt`. */
116
+ static readPayload(input, options = {}) {
117
+ return this.read(input, {
118
+ ...options,
119
+ output: OUTPUT_PAYLOAD
120
+ });
121
+ }
122
+
123
+ /**
124
+ * Parses a schema document, accepting YAML bytes, YAML text or a parsed object.
125
+ *
126
+ * @param {object|Uint8Array|ArrayBuffer|string} schema Schema in any accepted form.
127
+ * @returns {object} The parsed schema.
128
+ */
129
+ static schema(schema) {
130
+ if (!schema) {
131
+ throw SchemaBoundError("This format cannot read a container without its schema.");
132
+ }
133
+ if (typeof schema === "object" && !ArrayBuffer.isView(schema) && !(schema instanceof ArrayBuffer)) {
134
+ return schema;
135
+ }
136
+ const parsed = CjsYamlFormat.read(typeof schema === "string" ? schema : Normalize(schema));
137
+ if (!parsed || typeof parsed !== "object") {
138
+ throw SchemaBoundError("A schema must parse to a mapping.");
139
+ }
140
+ return Resolve(parsed);
141
+ }
142
+ static Output = Object.freeze({
143
+ JSON: OUTPUT_JSON,
144
+ PAYLOAD: OUTPUT_PAYLOAD
145
+ });
146
+ static id = "schemabound";
147
+ static extensions = Object.freeze([".static"]);
148
+ static type = Object.freeze(["data"]);
149
+ static mediaTypes = Object.freeze(["data"]);
150
+ static inputTypes = Object.freeze(["schemabound"]);
151
+ static outputTypes = Object.freeze([OUTPUT_JSON, OUTPUT_PAYLOAD]);
152
+ }
153
+
154
+ /**
155
+ * Rejoins YAML anchors and aliases into the graph they describe.
156
+ *
157
+ * These schemas share repeated declarations by anchor - a container with two
158
+ * coordinates writes the vector's component aliases once - and the YAML reader
159
+ * reports that sharing as `$yamlId` and `$yamlRef` markers rather than
160
+ * duplicating the node. Left alone, `$yamlId` reads as one more component and
161
+ * `$yamlRef` as a declaration with no fields at all.
162
+ *
163
+ * @param {*} value Parsed schema, or any part of one.
164
+ * @returns {*} The same schema with anchors resolved and markers removed.
165
+ */
166
+ function Resolve(value) {
167
+ const anchors = new Map();
168
+ const walk = node => {
169
+ if (Array.isArray(node)) return node.map(walk);
170
+ if (!node || typeof node !== "object") return node;
171
+ if (Object.hasOwn(node, "$yamlRef")) {
172
+ const target = anchors.get(node.$yamlRef);
173
+ if (!target) {
174
+ throw SchemaBoundError(`The schema refers to an anchor it never declares: ${node.$yamlRef}.`);
175
+ }
176
+ return target;
177
+ }
178
+ const result = {};
179
+ const id = node.$yamlId;
180
+ if (id !== undefined) anchors.set(id, result);
181
+ for (const [key, member] of Object.entries(node)) {
182
+ if (key !== "$yamlId") result[key] = walk(member);
183
+ }
184
+ return result;
185
+ };
186
+ return walk(value);
187
+ }
188
+
189
+ /** Builds the probe shape the resource manager routes on. */
190
+ function Probe(usable, options) {
191
+ return {
192
+ format: "schemabound",
193
+ source: "buffer",
194
+ supported: usable ? "full" : "none",
195
+ confidence: usable ? 1 : 0,
196
+ preferred: "schemabound",
197
+ // The schema is read to answer this, so it is measured rather than declared.
198
+ // It says nothing about any payload: these containers carry no signature.
199
+ verified: true,
200
+ reason: usable ? "The schema declares a root this reader can decode." : "The schema is missing, unparsable, or declares an unreadable root.",
201
+ variants: [{
202
+ kind: "container",
203
+ codec: "schemabound",
204
+ supported: usable
205
+ }],
206
+ metadata: {
207
+ family: "schemabound",
208
+ requiresSchema: true,
209
+ decodable: usable
210
+ },
211
+ ...(options || {})
212
+ };
213
+ }
214
+
215
+ /** Converts decoded values to something `JSON.stringify` keeps losslessly. */
216
+ function ToJSON(value) {
217
+ if (typeof value === "bigint") return value.toString(10);
218
+ if (Array.isArray(value)) return value.map(ToJSON);
219
+ if (value && typeof value === "object") {
220
+ const result = {};
221
+ for (const [key, member] of Object.entries(value)) result[key] = ToJSON(member);
222
+ return result;
223
+ }
224
+ return value;
225
+ }
226
+
227
+ /** Accepts the byte forms every other format here accepts. */
228
+ function Normalize(input) {
229
+ if (input instanceof Uint8Array) return input;
230
+ if (input instanceof ArrayBuffer) return new Uint8Array(input);
231
+ if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
232
+ throw SchemaBoundError("A schema-bound container must be supplied as bytes.");
233
+ }
234
+
235
+ export { CjsSchemaBoundFormat };
236
+ //# sourceMappingURL=CjsSchemaBoundFormat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CjsSchemaBoundFormat.js","sources":["../../../../src/formats/schemabound/CjsSchemaBoundFormat.js"],"sourcesContent":["import { CjsYamlFormat } from \"../yaml/index.js\";\nimport { ReadValue } from \"./core/schemaBoundValues.js\";\nimport { SchemaBoundError } from \"./core/schemaBoundErrors.js\";\n\nconst OUTPUT_JSON = \"json\";\nconst OUTPUT_PAYLOAD = \"payload\";\nconst ROOT_TYPES = new Set([ \"dict\", \"list\", \"object\" ]);\n\n/**\n * Reads a container whose layout lives in a separate schema.\n *\n * This is the third of the three families that share the `.static` extension,\n * and the one an extension check is least able to help with: the bytes carry no\n * signature, no version and no self-description. What they carry is a payload\n * whose every field position, width and meaning is stated in a sibling `.schema`\n * document — so the schema is not a hint here, it is the reader.\n *\n * That makes this the opposite of the hash-identified containers, where the\n * header names a layout it does not describe and the layout has to be derived\n * and pinned per dataset. Nothing needs deriving for this family. Supply the\n * schema and the bytes decode.\n *\n * **The schema is required and there is no default.** Given the wrong schema\n * these bytes decode into plausible nonsense rather than failing, because there\n * is nothing in them to disagree with. Pair each payload with the `.schema`\n * that shipped beside it.\n *\n * Read {@link CjsSchemaBoundFormat.read} before writing anything that walks the\n * result: a record's variable section changes length from record to record, and\n * a decoder written around a constant stride will read the first record\n * correctly and everything after it wrongly.\n */\nexport class CjsSchemaBoundFormat {\n\n /**\n * Reports whether a schema can drive this reader.\n *\n * The question is about the schema, never the payload. These containers have\n * no signature to test, so claiming to recognize the bytes would be a claim\n * this format cannot support - and `CjsStaticFormat` already answers which\n * family a `.static` file belongs to.\n *\n * @param {object|Uint8Array|ArrayBuffer|string} schema Schema document or its bytes.\n * @returns {boolean} True when the schema has a root this reader understands.\n */\n static is(schema) {\n try {\n return ROOT_TYPES.has(this.schema(schema).type);\n } catch {\n return false;\n }\n }\n\n /**\n * Reports whether this format can read a payload described by a schema.\n *\n * @param {object|Uint8Array|ArrayBuffer|string} schema Schema document or its bytes.\n * @param {object} [options] Probe options.\n * @returns {object} Resource probe.\n */\n static isSupported(schema, options = null) {\n return Probe(this.is(schema), options);\n }\n\n // INTERIM, 2026-08-16. No `inspect` alias, matching CjsSqliteFormat and\n // diverging from the older formats. Both are held by the same undecided\n // question; see maintenance/INTERIM-sqlite-and-static-2026-08-16.md.\n\n /**\n * Reads a container against its schema.\n *\n * The whole payload decodes in one pass. Three properties are worth knowing\n * before relying on the result:\n *\n * - **A keyed container's index is at the end.** Nothing at the front points\n * at it; it is found by reading the last four bytes as the index's own size.\n * - **Record offsets are relative to the four-byte header**, not to the file.\n * Decoding from the file start reads one field early, which looks like a\n * wrong layout rather than a wrong base.\n * - **The per-record offset table varies in length.** An optional attribute\n * that is absent occupies no slot, so consecutive records hold their\n * variable data at different distances from their own start.\n *\n * An absent optional takes the default its schema declares. Where none is\n * declared the attribute is left off the record entirely, which is what the\n * published static data exports show for those same rows.\n *\n * @param {Uint8Array|ArrayBuffer} input Container bytes.\n * @param {object} options Read options.\n * @param {object|Uint8Array|ArrayBuffer|string} options.schema The sibling schema.\n * @param {string} [options.output] `json` or `payload`.\n * @returns {object|Array} The decoded container.\n */\n static read(input, options = {}) {\n const bytes = Normalize(input);\n const schema = this.schema(options.schema);\n\n if (!ROOT_TYPES.has(schema.type)) {\n throw SchemaBoundError(`A container's root must be a dict, list or object, not ${schema.type}.`);\n }\n\n const context = {\n bytes,\n view: new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)\n };\n const decoded = ReadValue(context, 0, schema).value;\n\n return options.output === OUTPUT_PAYLOAD ? decoded : ToJSON(decoded);\n }\n\n /** Reads to plain JSON-compatible values. */\n static readJSON(input, options = {}) {\n return this.read(input, { ...options, output: OUTPUT_JSON });\n }\n\n /** Reads with wide integers left as `BigInt`. */\n static readPayload(input, options = {}) {\n return this.read(input, { ...options, output: OUTPUT_PAYLOAD });\n }\n\n /**\n * Parses a schema document, accepting YAML bytes, YAML text or a parsed object.\n *\n * @param {object|Uint8Array|ArrayBuffer|string} schema Schema in any accepted form.\n * @returns {object} The parsed schema.\n */\n static schema(schema) {\n if (!schema) {\n throw SchemaBoundError(\"This format cannot read a container without its schema.\");\n }\n\n if (typeof schema === \"object\" && !ArrayBuffer.isView(schema) && !(schema instanceof ArrayBuffer)) {\n return schema;\n }\n\n const parsed = CjsYamlFormat.read(typeof schema === \"string\" ? schema : Normalize(schema));\n\n if (!parsed || typeof parsed !== \"object\") {\n throw SchemaBoundError(\"A schema must parse to a mapping.\");\n }\n\n return Resolve(parsed);\n }\n\n static Output = Object.freeze({ JSON: OUTPUT_JSON, PAYLOAD: OUTPUT_PAYLOAD });\n\n static id = \"schemabound\";\n static extensions = Object.freeze([ \".static\" ]);\n static type = Object.freeze([ \"data\" ]);\n static mediaTypes = Object.freeze([ \"data\" ]);\n static inputTypes = Object.freeze([ \"schemabound\" ]);\n static outputTypes = Object.freeze([ OUTPUT_JSON, OUTPUT_PAYLOAD ]);\n}\n\n/**\n * Rejoins YAML anchors and aliases into the graph they describe.\n *\n * These schemas share repeated declarations by anchor - a container with two\n * coordinates writes the vector's component aliases once - and the YAML reader\n * reports that sharing as `$yamlId` and `$yamlRef` markers rather than\n * duplicating the node. Left alone, `$yamlId` reads as one more component and\n * `$yamlRef` as a declaration with no fields at all.\n *\n * @param {*} value Parsed schema, or any part of one.\n * @returns {*} The same schema with anchors resolved and markers removed.\n */\nfunction Resolve(value) {\n const anchors = new Map();\n\n const walk = node => {\n if (Array.isArray(node)) return node.map(walk);\n\n if (!node || typeof node !== \"object\") return node;\n\n if (Object.hasOwn(node, \"$yamlRef\")) {\n const target = anchors.get(node.$yamlRef);\n\n if (!target) {\n throw SchemaBoundError(`The schema refers to an anchor it never declares: ${node.$yamlRef}.`);\n }\n\n return target;\n }\n\n const result = {};\n const id = node.$yamlId;\n\n if (id !== undefined) anchors.set(id, result);\n\n for (const [ key, member ] of Object.entries(node)) {\n if (key !== \"$yamlId\") result[key] = walk(member);\n }\n\n return result;\n };\n\n return walk(value);\n}\n\n/** Builds the probe shape the resource manager routes on. */\nfunction Probe(usable, options) {\n return {\n format: \"schemabound\",\n source: \"buffer\",\n supported: usable ? \"full\" : \"none\",\n confidence: usable ? 1 : 0,\n preferred: \"schemabound\",\n // The schema is read to answer this, so it is measured rather than declared.\n // It says nothing about any payload: these containers carry no signature.\n verified: true,\n reason: usable\n ? \"The schema declares a root this reader can decode.\"\n : \"The schema is missing, unparsable, or declares an unreadable root.\",\n variants: [ { kind: \"container\", codec: \"schemabound\", supported: usable } ],\n metadata: { family: \"schemabound\", requiresSchema: true, decodable: usable },\n ...(options || {})\n };\n}\n\n/** Converts decoded values to something `JSON.stringify` keeps losslessly. */\nfunction ToJSON(value) {\n if (typeof value === \"bigint\") return value.toString(10);\n\n if (Array.isArray(value)) return value.map(ToJSON);\n\n if (value && typeof value === \"object\") {\n const result = {};\n\n for (const [ key, member ] of Object.entries(value)) result[key] = ToJSON(member);\n\n return result;\n }\n\n return value;\n}\n\n/** Accepts the byte forms every other format here accepts. */\nfunction Normalize(input) {\n if (input instanceof Uint8Array) return input;\n\n if (input instanceof ArrayBuffer) return new Uint8Array(input);\n\n if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n\n throw SchemaBoundError(\"A schema-bound container must be supplied as bytes.\");\n}\n\nexport default CjsSchemaBoundFormat;\n"],"names":["OUTPUT_JSON","OUTPUT_PAYLOAD","ROOT_TYPES","Set","CjsSchemaBoundFormat","is","schema","has","type","isSupported","options","Probe","read","input","bytes","Normalize","SchemaBoundError","context","view","DataView","buffer","byteOffset","byteLength","decoded","ReadValue","value","output","ToJSON","readJSON","readPayload","ArrayBuffer","isView","parsed","CjsYamlFormat","Resolve","Output","Object","freeze","JSON","PAYLOAD","id","extensions","mediaTypes","inputTypes","outputTypes","anchors","Map","walk","node","Array","isArray","map","hasOwn","target","get","$yamlRef","result","$yamlId","undefined","set","key","member","entries","usable","format","source","supported","confidence","preferred","verified","reason","variants","kind","codec","metadata","family","requiresSchema","decodable","toString","Uint8Array"],"mappings":";;;;AAIA,MAAMA,WAAW,GAAG,MAAM;AAC1B,MAAMC,cAAc,GAAG,SAAS;AAChC,MAAMC,UAAU,GAAG,IAAIC,GAAG,CAAC,CAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAE,CAAC;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,oBAAoB,CAAC;AAEhC;AACF;AACA;AACA;AACA;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KAAK,CAACqD,QAAQ,CAAC,EAAE,CAAC;AAExD,EAAA,IAAI7B,KAAK,CAACC,OAAO,CAACzB,KAAK,CAAC,EAAE,OAAOA,KAAK,CAAC0B,GAAG,CAACxB,MAAM,CAAC;AAElD,EAAA,IAAIF,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACtC,MAAM+B,MAAM,GAAG,EAAE;IAEjB,KAAK,MAAM,CAAEI,GAAG,EAAEC,MAAM,CAAE,IAAIzB,MAAM,CAAC0B,OAAO,CAACrC,KAAK,CAAC,EAAE+B,MAAM,CAACI,GAAG,CAAC,GAAGjC,MAAM,CAACkC,MAAM,CAAC;AAEjF,IAAA,OAAOL,MAAM;AACf,EAAA;AAEA,EAAA,OAAO/B,KAAK;AACd;;AAEA;AACA,SAASV,SAASA,CAACF,KAAK,EAAE;AACxB,EAAA,IAAIA,KAAK,YAAYkE,UAAU,EAAE,OAAOlE,KAAK;EAE7C,IAAIA,KAAK,YAAYiB,WAAW,EAAE,OAAO,IAAIiD,UAAU,CAAClE,KAAK,CAAC;EAE9D,IAAIiB,WAAW,CAACC,MAAM,CAAClB,KAAK,CAAC,EAAE,OAAO,IAAIkE,UAAU,CAAClE,KAAK,CAACO,MAAM,EAAEP,KAAK,CAACQ,UAAU,EAAER,KAAK,CAACS,UAAU,CAAC;EAEtG,MAAMN,gBAAgB,CAAC,qDAAqD,CAAC;AAC/E;;;;"}
@@ -0,0 +1,9 @@
1
+ /** Builds the error every part of this format throws, with one code. */
2
+ function SchemaBoundError(message, extra = null) {
3
+ const error = new TypeError(message);
4
+ error.code = "CJS_SCHEMA_BOUND_FORMAT_INVALID";
5
+ return Object.assign(error, extra || {});
6
+ }
7
+
8
+ export { SchemaBoundError };
9
+ //# sourceMappingURL=schemaBoundErrors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaBoundErrors.js","sources":["../../../../../src/formats/schemabound/core/schemaBoundErrors.js"],"sourcesContent":["/** Builds the error every part of this format throws, with one code. */\nexport function SchemaBoundError(message, extra = null) {\n const error = new TypeError(message);\n\n error.code = \"CJS_SCHEMA_BOUND_FORMAT_INVALID\";\n\n return Object.assign(error, extra || {});\n}\n\nexport default SchemaBoundError;\n"],"names":["SchemaBoundError","message","extra","error","TypeError","code","Object","assign"],"mappings":"AAAA;AACO,SAASA,gBAAgBA,CAACC,OAAO,EAAEC,KAAK,GAAG,IAAI,EAAE;AACtD,EAAA,MAAMC,KAAK,GAAG,IAAIC,SAAS,CAACH,OAAO,CAAC;EAEpCE,KAAK,CAACE,IAAI,GAAG,iCAAiC;EAE9C,OAAOC,MAAM,CAACC,MAAM,CAACJ,KAAK,EAAED,KAAK,IAAI,EAAE,CAAC;AAC1C;;;;"}