@forgeax/engine-image 0.1.2

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 (122) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +168 -0
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/__tests__/compression-mode.unit.test.d.ts +2 -0
  5. package/dist/__tests__/compression-mode.unit.test.d.ts.map +1 -0
  6. package/dist/__tests__/encode-source-too-large.unit.test.d.ts +2 -0
  7. package/dist/__tests__/encode-source-too-large.unit.test.d.ts.map +1 -0
  8. package/dist/__tests__/errors.test-d.d.ts +2 -0
  9. package/dist/__tests__/errors.test-d.d.ts.map +1 -0
  10. package/dist/__tests__/image-importer-conversion-failure.unit.test.d.ts +2 -0
  11. package/dist/__tests__/image-importer-conversion-failure.unit.test.d.ts.map +1 -0
  12. package/dist/__tests__/image-importer-hdr-equirect.test.d.ts +2 -0
  13. package/dist/__tests__/image-importer-hdr-equirect.test.d.ts.map +1 -0
  14. package/dist/__tests__/image-importer-topology.unit.test.d.ts +2 -0
  15. package/dist/__tests__/image-importer-topology.unit.test.d.ts.map +1 -0
  16. package/dist/__tests__/image-importer.test.d.ts +2 -0
  17. package/dist/__tests__/image-importer.test.d.ts.map +1 -0
  18. package/dist/__tests__/image-local-artifacts.test.d.ts +2 -0
  19. package/dist/__tests__/image-local-artifacts.test.d.ts.map +1 -0
  20. package/dist/__tests__/image.unit.test.d.ts +2 -0
  21. package/dist/__tests__/image.unit.test.d.ts.map +1 -0
  22. package/dist/__tests__/ktx2-basis-importer.unit.test.d.ts +2 -0
  23. package/dist/__tests__/ktx2-basis-importer.unit.test.d.ts.map +1 -0
  24. package/dist/__tests__/ktx2-encode-mode-owner.test-d.d.ts +2 -0
  25. package/dist/__tests__/ktx2-encode-mode-owner.test-d.d.ts.map +1 -0
  26. package/dist/__tests__/make-fixture.d.ts +12 -0
  27. package/dist/__tests__/make-fixture.d.ts.map +1 -0
  28. package/dist/__tests__/parse-image-downscale.test.d.ts +2 -0
  29. package/dist/__tests__/parse-image-downscale.test.d.ts.map +1 -0
  30. package/dist/__tests__/runtime-decode.unit.test.d.ts +2 -0
  31. package/dist/__tests__/runtime-decode.unit.test.d.ts.map +1 -0
  32. package/dist/__tests__/source-key.unit.test.d.ts +2 -0
  33. package/dist/__tests__/source-key.unit.test.d.ts.map +1 -0
  34. package/dist/__tests__/tga.unit.test.d.ts +2 -0
  35. package/dist/__tests__/tga.unit.test.d.ts.map +1 -0
  36. package/dist/decode-image-from-file.d.ts +40 -0
  37. package/dist/decode-image-from-file.d.ts.map +1 -0
  38. package/dist/decode-image-from-file.mjs +590 -0
  39. package/dist/decode-image-from-file.mjs.map +1 -0
  40. package/dist/errors.d.ts +14 -0
  41. package/dist/errors.d.ts.map +1 -0
  42. package/dist/hdr-decoder.d.ts +28 -0
  43. package/dist/hdr-decoder.d.ts.map +1 -0
  44. package/dist/hdr-decoder.mjs +212 -0
  45. package/dist/hdr-decoder.mjs.map +1 -0
  46. package/dist/image-decoder-browser.d.ts +22 -0
  47. package/dist/image-decoder-browser.d.ts.map +1 -0
  48. package/dist/image-decoder-node.d.ts +50 -0
  49. package/dist/image-decoder-node.d.ts.map +1 -0
  50. package/dist/image-importer.d.ts +15 -0
  51. package/dist/image-importer.d.ts.map +1 -0
  52. package/dist/image-importer.mjs +1107 -0
  53. package/dist/image-importer.mjs.map +1 -0
  54. package/dist/index.d.ts +19 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.mjs +503 -0
  57. package/dist/index.mjs.map +1 -0
  58. package/dist/ktx2-encode.d.ts +84 -0
  59. package/dist/ktx2-encode.d.ts.map +1 -0
  60. package/dist/ktx2-encode.mjs +100 -0
  61. package/dist/ktx2-encode.mjs.map +1 -0
  62. package/dist/parse-image.d.ts +48 -0
  63. package/dist/parse-image.d.ts.map +1 -0
  64. package/dist/parse-image.mjs +231 -0
  65. package/dist/parse-image.mjs.map +1 -0
  66. package/dist/reimport-reuse-meta.d.ts +81 -0
  67. package/dist/reimport-reuse-meta.d.ts.map +1 -0
  68. package/dist/resize-image.d.ts +7 -0
  69. package/dist/resize-image.d.ts.map +1 -0
  70. package/dist/result.d.ts +2 -0
  71. package/dist/result.d.ts.map +1 -0
  72. package/dist/runtime/__tests__/asset-decoders.unit.test.d.ts +2 -0
  73. package/dist/runtime/__tests__/asset-decoders.unit.test.d.ts.map +1 -0
  74. package/dist/runtime/asset-decoders.d.ts +4 -0
  75. package/dist/runtime/asset-decoders.d.ts.map +1 -0
  76. package/dist/runtime/decode-image-bytes.d.ts +7 -0
  77. package/dist/runtime/decode-image-bytes.d.ts.map +1 -0
  78. package/dist/runtime/image-error.d.ts +3 -0
  79. package/dist/runtime/image-error.d.ts.map +1 -0
  80. package/dist/source-key.d.ts +21 -0
  81. package/dist/source-key.d.ts.map +1 -0
  82. package/dist/sub-asset-key.d.ts +50 -0
  83. package/dist/sub-asset-key.d.ts.map +1 -0
  84. package/dist/to-asset-pack.d.ts +61 -0
  85. package/dist/to-asset-pack.d.ts.map +1 -0
  86. package/package.json +105 -0
  87. package/src/__tests__/compression-mode.unit.test.ts +104 -0
  88. package/src/__tests__/encode-source-too-large.unit.test.ts +81 -0
  89. package/src/__tests__/errors.test-d.ts +148 -0
  90. package/src/__tests__/image-importer-conversion-failure.unit.test.ts +297 -0
  91. package/src/__tests__/image-importer-hdr-equirect.test.ts +218 -0
  92. package/src/__tests__/image-importer-topology.unit.test.ts +209 -0
  93. package/src/__tests__/image-importer.test.ts +12 -0
  94. package/src/__tests__/image-local-artifacts.test.ts +38 -0
  95. package/src/__tests__/image.unit.test.ts +1387 -0
  96. package/src/__tests__/ktx2-basis-importer.unit.test.ts +126 -0
  97. package/src/__tests__/ktx2-encode-mode-owner.test-d.ts +70 -0
  98. package/src/__tests__/make-fixture.ts +100 -0
  99. package/src/__tests__/parse-image-downscale.test.ts +26 -0
  100. package/src/__tests__/runtime-decode.unit.test.ts +22 -0
  101. package/src/__tests__/source-key.unit.test.ts +65 -0
  102. package/src/__tests__/tga.unit.test.ts +59 -0
  103. package/src/decode-image-from-file.ts +298 -0
  104. package/src/errors.ts +60 -0
  105. package/src/hdr-decoder.ts +255 -0
  106. package/src/image-decoder-browser.ts +88 -0
  107. package/src/image-decoder-node.ts +67 -0
  108. package/src/image-decoders.d.ts +23 -0
  109. package/src/image-importer.ts +780 -0
  110. package/src/index.ts +46 -0
  111. package/src/ktx2-encode.ts +221 -0
  112. package/src/parse-image.ts +276 -0
  113. package/src/reimport-reuse-meta.ts +160 -0
  114. package/src/resize-image.ts +39 -0
  115. package/src/result.ts +13 -0
  116. package/src/runtime/__tests__/asset-decoders.unit.test.ts +66 -0
  117. package/src/runtime/asset-decoders.ts +152 -0
  118. package/src/runtime/decode-image-bytes.ts +41 -0
  119. package/src/runtime/image-error.ts +8 -0
  120. package/src/source-key.ts +41 -0
  121. package/src/sub-asset-key.ts +67 -0
  122. package/src/to-asset-pack.ts +95 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts","../src/hdr-decoder.ts","../src/resize-image.ts","../src/parse-image.ts","../src/decode-image-from-file.ts"],"names":[],"mappings":";;;;;;;;AAOA,IAAM,oBAAA,GAAiE;AAAA,EACrE,qBAAA,EAAuB,4CAAA;AAAA,EACvB,0BAAA,EACE,8GAAA;AAAA,EACF,+BAAA,EACE,mFAAA;AAAA,EACF,oBAAA,EACE,6EAAA;AAAA,EACF,yBAAA,EAA2B,mEAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ3B,mBAAA,EAAqB,oBAAA;AAAA,EACrB,qBAAA,EACE,mFAAA;AAAA,EACF,uBAAA,EAAyB;AAC3B,CAAA;AAGO,IAAM,cAAA,GAAN,cACG,KAAA,CAEV;AAAA,EACW,IAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA;AAAA,EACA,MAAA;AAAA,EAET,YAAY,MAAA,EAAgC;AAC1C,IAAA,MAAM,OAAO,MAAA,CAAO,IA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OAAA,GAAwB;AAAA,MAC5B,KAAA,EAAO,KAAA;AAAA,MACP,KAAA,EAAO,OAAO,KAAA,CAAM,KAAA;AAAA,MACpB,MAAA,EAAQ,OAAO,KAAA,CAAM,MAAA;AAAA,MACrB,IAAA,EAAM,YAAA;AAAA,MACN,UAAA,EAAY,QAAA;AAAA,MACZ,MAAA,EAAQ;AAAA,KACV;AACA,IAAA,OAAO,EAAA,CAAG,EAAE,OAAA,EAAS,IAAA,EAAM,CAAA;AAAA,EAC7B;AAEA,EAAA,MAAM,CAAA,GAAI,UAAA,CAAW,KAAA,EAAO,IAAA,EAAM;AAAA,IAChC,UAAA;AAAA,IACA,QAAQ,MAAA,KAAW,MAAA;AAAA,IACnB,IAAA,EAAM;AAAA,GACP,CAAA;AACD,EAAA,IAAI,CAAC,EAAE,EAAA,EAAI;AACT,IAAA,OAAO,GAAA,CAAI,EAAE,KAAK,CAAA;AAAA,EACpB;AAEA,EAAA,OAAO,GAAG,EAAE,OAAA,EAAS,CAAA,CAAE,KAAA,EAAO,MAAM,CAAA;AACtC","file":"decode-image-from-file.mjs","sourcesContent":["import type { ImageErrorCode, ImageErrorDetailFor, ImageErrorFor } from '@forgeax/engine-types';\nimport { IMAGE_ERROR_HINTS } from '@forgeax/engine-types';\n\n// Per-code .expected string literals SSOT.\n// Mirrors ASSET_ERROR_HINTS / IMAGE_ERROR_HINTS shape (charter P5 consistent\n// abstraction). AI users surface .expected when a structured error needs to\n// describe the precondition that was violated.\nconst IMAGE_ERROR_EXPECTED: Readonly<Record<ImageErrorCode, string>> = {\n 'image-decode-failed': 'PNG / JPG byte stream decodes successfully',\n 'image-format-unsupported':\n \"mime is one of ['image/png', 'image/jpeg', 'image/x-tga']; uploadTexture format <-> colorSpace family agrees\",\n 'image-dimension-out-of-bounds':\n 'width and height fall under device caps maxTextureDimension2D (or 16384 hard cap)',\n 'image-meta-missing':\n \"<source>.meta.json sidecar (importer: 'image') exists in the same directory\",\n 'image-hdr-decode-failed': 'Radiance RGBE header is valid and pixel data decodes successfully',\n // feat-20260521-sprite-atlas-animation M1 T-03 — vite-plugin-image atlas\n // hook .expected literals (plan-strategy section 2 D-2 + AC-10 a/b/c).\n // ImageErrorImpl construction path is unchanged: the new atlas-* errors\n // flow through `new ImageErrorImpl({ code: 'atlas-...', ...detail })` and\n // pick the .expected string up from this Record at construction time\n // (charter P3 explicit failure SSOT — AI users surface .expected next to\n // .hint after switch (err.code) without parsing the message).\n 'atlas-empty-input': 'images.length >= 1',\n 'atlas-size-exceeded':\n 'image width x height <= maxAtlasSize^2 and each image fits in the atlas footprint',\n 'atlas-region-mismatch': 'sum(regions[i].w x regions[i].h) <= atlasWidth x atlasHeight',\n};\n\n/** Runtime implementation of the correlated `ImageErrorFor<C>` envelope. */\nexport class ImageErrorImpl<C extends ImageErrorCode = ImageErrorCode>\n extends Error\n implements ImageErrorFor<C>\n{\n readonly code: C;\n readonly expected: string;\n readonly hint: string;\n readonly detail: ImageErrorDetailFor<C>;\n\n constructor(detail: ImageErrorDetailFor<C>) {\n const code = detail.code;\n const expected = IMAGE_ERROR_EXPECTED[code];\n const hint = IMAGE_ERROR_HINTS[code];\n super(`[ImageError ${code}] expected: ${expected}; hint: ${hint}`);\n this.name = 'ImageError';\n this.code = code;\n this.expected = expected;\n this.hint = hint;\n this.detail = detail;\n }\n}\n\n/** Construct a structured image error while preserving its code/detail pair. */\nexport function imageError<C extends ImageErrorCode>(\n detail: ImageErrorDetailFor<C>,\n): ImageErrorFor<C> {\n return new ImageErrorImpl<C>(detail);\n}\n\nexport { IMAGE_ERROR_EXPECTED };\n","import type { ImageError } from '@forgeax/engine-types';\nimport { imageError } from './errors.js';\nimport type { Result } from './result.js';\nimport { err, ok } from './result.js';\n\n/**\n * Decoded HDR image POD.\n *\n * `data` is an interleaved RGBA Float32Array (4 floats per pixel, row-major).\n * Color space is always linear (RGBE is radiance).\n */\nexport interface HdrDecoded {\n readonly width: number;\n readonly height: number;\n readonly data: Float32Array;\n}\n\n// ASCII code points\nconst LF = 0x0a;\n\n/**\n * Decode a Radiance RGBE (.hdr) byte stream into linear RGBA float pixels.\n *\n * Steps per research F-6:\n * 1. Parse ASCII header: magic (#?RADIANCE), FORMAT=32-bit_rle_rgbe,\n * resolution line (-Y height +X width).\n * 2. Decode per-scanline new-RLE pixel data: 4 independent channel runs.\n * 3. Convert RGBE to float: if E==0 -> 0; else f=2^(E-136), R=(Rm+0.5)*f.\n * 4. Output as interleaved RGBA Float32Array (alpha=1.0).\n *\n * Old-RLE scanlines (prefix not matching 0x02,0x02,hi,lo with correct width)\n * return image-hdr-decode-failed.\n */\nexport function decodeHdr(bytes: Uint8Array): Result<HdrDecoded, ImageError> {\n let pos = 0;\n\n // Step 1a: magic -- must start with \"#?RADIANCE\" or \"#?RGBE\"\n if (bytes.length < 11) {\n return err(hdrDecodeError('file too short for Radiance HDR header'));\n }\n const magic = String.fromCharCode(...bytes.subarray(0, 11));\n if (magic !== '#?RADIANCE\\n' && magic !== '#?RGBE\\n') {\n return err(\n hdrDecodeError('missing or invalid Radiance HDR magic; expected #?RADIANCE or #?RGBE'),\n );\n }\n pos = 11;\n\n // Step 1b: key=value lines until empty line\n let formatFound = false;\n while (pos < bytes.length) {\n const lineEnd = findByte(bytes, LF, pos);\n if (lineEnd === -1) return err(hdrDecodeError('header truncated before empty line'));\n const line = asciiSubstring(bytes, pos, lineEnd);\n pos = lineEnd + 1;\n if (line === '') break;\n if (line.startsWith('FORMAT=')) {\n const val = line.slice(7);\n if (val === '32-bit_rle_rgbe') {\n formatFound = true;\n }\n }\n }\n if (!formatFound) {\n return err(hdrDecodeError('missing or unsupported FORMAT; expected FORMAT=32-bit_rle_rgbe'));\n }\n\n // Step 1c: resolution line (-Y height +X width)\n if (pos >= bytes.length) return err(hdrDecodeError('missing resolution line'));\n const resLineEnd = findByte(bytes, LF, pos);\n if (resLineEnd === -1) return err(hdrDecodeError('resolution line truncated'));\n const resLine = asciiSubstring(bytes, pos, resLineEnd);\n pos = resLineEnd + 1;\n const resMatch = /^-Y\\s+(\\d+)\\s+\\+X\\s+(\\d+)\\s*$/.exec(resLine);\n if (resMatch === null) {\n return err(\n hdrDecodeError(`unexpected resolution line format: \"${resLine}\"; expected \"-Y H +X W\"`),\n );\n }\n const height = Number(resMatch[1]);\n const width = Number(resMatch[2]);\n if (height === undefined || width === undefined || height <= 0 || width <= 0) {\n return err(hdrDecodeError(`invalid dimensions: ${width}x${height}`));\n }\n\n // Step 2: decode per-scanline new-RLE pixel data\n const pixelCount = width * height;\n const rgbe = new Uint8Array(pixelCount * 4);\n const scanlineBytes = width * 4;\n\n for (let y = 0; y < height; y++) {\n if (pos + 4 > bytes.length) {\n return err(hdrDecodeError(`truncated at scanline ${y}: expected 4-byte prefix`));\n }\n const p0 = bytes[pos];\n const p1 = bytes[pos + 1];\n const pHi = bytes[pos + 2];\n const pLo = bytes[pos + 3];\n if (p0 === undefined || p1 === undefined || pHi === undefined || pLo === undefined) {\n return err(hdrDecodeError(`truncated at scanline ${y}`));\n }\n // biome-ignore lint/style/noNonNullAssertion: checked above\n const prefixWidth = (pHi! << 8) | pLo!;\n\n if (p0 === 0x02 && p1 === 0x02 && prefixWidth === width && width >= 8 && width <= 32767) {\n // New-RLE: 4 channels independently RLE-encoded, then interleaved\n const decoded = decodeNewRleScanline(bytes, pos + 4, width);\n if (decoded === null) {\n return err(hdrDecodeError(`RLE decode failed at scanline ${y}`));\n }\n // Copy into rgbe interleaved buffer\n const base = y * scanlineBytes;\n const channels = [decoded[0], decoded[1], decoded[2], decoded[3]];\n for (let x = 0; x < width; x++) {\n for (let ch = 0; ch < 4; ch++) {\n // biome-ignore lint/style/noNonNullAssertion: checked at allocation\n rgbe[base + x * 4 + ch] = channels[ch]![x]!;\n }\n }\n // Advance pos past the 4-byte prefix + the total RLE bytes consumed\n pos += 4 + decoded.totalBytes;\n } else {\n // Old-RLE: not supported\n return err(\n hdrDecodeError(\n 'old-RLE format is not supported; only new-RLE (32-bit_rle_rgbe) is accepted',\n ),\n );\n }\n }\n\n // Step 3: RGBE to float\n const out = new Float32Array(pixelCount * 4);\n for (let i = 0; i < pixelCount; i++) {\n const base = i * 4;\n // biome-ignore lint/style/noNonNullAssertion: checked at allocation\n const r = rgbe[base]!;\n // biome-ignore lint/style/noNonNullAssertion: checked at allocation\n const g = rgbe[base + 1]!;\n // biome-ignore lint/style/noNonNullAssertion: checked at allocation\n const b = rgbe[base + 2]!;\n // biome-ignore lint/style/noNonNullAssertion: checked at allocation\n const e = rgbe[base + 3]!;\n out[base + 3] = 1.0;\n\n if (e === 0) {\n out[base] = 0;\n out[base + 1] = 0;\n out[base + 2] = 0;\n } else {\n // f = 2^(E - 136) = ldexp(1.0, E - 128 - 8)\n // Equivalent: ldexp(1.0 / 256.0, E - 128)\n // But simpler: const f = (1.0 / 256.0) * Math.pow(2, e - 128);\n // Using ldexp: Math.pow(2, e - 136)\n const f = 2 ** (e - 136);\n out[base] = (r + 0.5) * f;\n out[base + 1] = (g + 0.5) * f;\n out[base + 2] = (b + 0.5) * f;\n }\n }\n\n return ok({ width, height, data: out });\n}\n\ninterface DecodedScanline {\n /** 4 channels, each width bytes */\n readonly 0: Uint8Array;\n readonly 1: Uint8Array;\n readonly 2: Uint8Array;\n readonly 3: Uint8Array;\n readonly totalBytes: number;\n}\n\n/**\n * Decode one scanline of new-RLE data into 4 channel arrays.\n * Returns null on failure (data underrun).\n */\nfunction decodeNewRleScanline(\n bytes: Uint8Array,\n start: number,\n width: number,\n): DecodedScanline | null {\n const channels: Uint8Array[] = [];\n let cursor = start;\n\n for (let ch = 0; ch < 4; ch++) {\n const data = new Uint8Array(width);\n let x = 0;\n while (x < width) {\n if (cursor >= bytes.length) return null;\n // biome-ignore lint/style/noNonNullAssertion: checked above\n const code = bytes[cursor]!;\n cursor++;\n if (code > 128) {\n // RLE run: next byte repeated (code - 128) times\n const count = code - 128;\n if (cursor >= bytes.length || x + count > width) return null;\n // biome-ignore lint/style/noNonNullAssertion: checked above\n const val = bytes[cursor]!;\n cursor++;\n data.fill(val, x, x + count);\n x += count;\n } else {\n // Literal run: next `code` bytes copied verbatim\n if (code === 0) continue;\n if (cursor + code > bytes.length || x + code > width) return null;\n for (let k = 0; k < code; k++) {\n // biome-ignore lint/style/noNonNullAssertion: checked above\n data[x + k] = bytes[cursor + k]!;\n }\n cursor += code;\n x += code;\n }\n }\n channels.push(data);\n }\n\n const ch0 = channels[0];\n const ch1 = channels[1];\n const ch2 = channels[2];\n const ch3 = channels[3];\n if (ch0 === undefined || ch1 === undefined || ch2 === undefined || ch3 === undefined) {\n return null; // channels should always have 4 entries\n }\n return {\n 0: ch0,\n 1: ch1,\n 2: ch2,\n 3: ch3,\n totalBytes: cursor - start,\n };\n}\n\nfunction findByte(bytes: Uint8Array, target: number, start: number): number {\n for (let i = start; i < bytes.length; i++) {\n if (bytes[i] === target) return i;\n }\n return -1;\n}\n\nfunction asciiSubstring(bytes: Uint8Array, start: number, end: number): string {\n let s = '';\n for (let i = start; i < end; i++) {\n // biome-ignore lint/style/noNonNullAssertion: in bounds\n s += String.fromCharCode(bytes[i]!);\n }\n return s;\n}\n\nfunction hdrDecodeError(reason: string): ImageError {\n return imageError({\n code: 'image-hdr-decode-failed',\n reason,\n });\n}\n","/** Deterministically downscale tight-packed RGBA pixels with bilinear sampling. */\nexport function downscaleRgba(\n bytes: Uint8Array,\n width: number,\n height: number,\n maxDimension: number,\n): { readonly bytes: Uint8Array; readonly width: number; readonly height: number } {\n if (width <= maxDimension && height <= maxDimension) {\n return { bytes, width, height };\n }\n\n const scale = maxDimension / Math.max(width, height);\n const targetWidth = Math.max(1, Math.round(width * scale));\n const targetHeight = Math.max(1, Math.round(height * scale));\n const output = new Uint8Array(targetWidth * targetHeight * 4);\n const source = (x: number, y: number, channel: number): number =>\n bytes[(y * width + x) * 4 + channel] ?? 0;\n\n for (let y = 0; y < targetHeight; y += 1) {\n const sourceY = ((y + 0.5) * height) / targetHeight - 0.5;\n const y0 = Math.max(0, Math.floor(sourceY));\n const y1 = Math.min(height - 1, y0 + 1);\n const yWeight = Math.max(0, Math.min(1, sourceY - y0));\n for (let x = 0; x < targetWidth; x += 1) {\n const sourceX = ((x + 0.5) * width) / targetWidth - 0.5;\n const x0 = Math.max(0, Math.floor(sourceX));\n const x1 = Math.min(width - 1, x0 + 1);\n const xWeight = Math.max(0, Math.min(1, sourceX - x0));\n const outputOffset = (y * targetWidth + x) * 4;\n for (let channel = 0; channel < 4; channel += 1) {\n const top = source(x0, y0, channel) * (1 - xWeight) + source(x1, y0, channel) * xWeight;\n const bottom = source(x0, y1, channel) * (1 - xWeight) + source(x1, y1, channel) * xWeight;\n output[outputOffset + channel] = Math.round(top * (1 - yWeight) + bottom * yWeight);\n }\n }\n }\n\n return { bytes: output, width: targetWidth, height: targetHeight };\n}\n","import type { DecodedImage, ImageColorSpace, ImageError } from '@forgeax/engine-types';\nimport * as jpeg from 'jpeg-js';\n// Static imports of upng-js + jpeg-js. tsup external keeps both as runtime\n// require() calls so the browser bundle still tree-shakes them out when\n// only image-decoder-browser.ts (createImageBitmap) is reached at runtime.\n// Synchronous decode is required by the parseImage signature contract (see\n// plan-strategy section 3.3).\nimport * as UPNG from 'upng-js';\nimport { imageError } from './errors.js';\nimport { downscaleRgba } from './resize-image.js';\nimport type { Result } from './result.js';\nimport { err, ok } from './result.js';\n\nexport interface ParseImageOptions {\n /**\n * Maximum allowed dimension (width or height). Defaults to 16384 -- the\n * conservative WebGPU `maxTextureDimension2D` floor across desktop +\n * high-end mobile (research F-3 / spec). Test fixtures pass smaller\n * values to exercise the bounds-check code path with tiny fixtures.\n */\n readonly maxDimension?: number;\n\n /** Optional asset-owned cooked-payload target; source bytes remain unchanged. */\n readonly downscaleMaxDimension?: number;\n\n /**\n * Sidecar `colorSpace` carried over to the DecodedImage POD. Defaults to\n * 'srgb' (typical baseColor / albedo path; plan-strategy section 2.5).\n */\n readonly colorSpace?: ImageColorSpace;\n\n /**\n * Sidecar `mipmap` flag carried over to DecodedImage. Defaults to true\n * (auto-generate via runtime mipmap-generator; plan-strategy section 2.6).\n */\n readonly mipmap?: boolean;\n\n /**\n * Optional source path to embed in error.detail.path (decode-failed /\n * format-unsupported variants). decodeImageFromFile fills this in;\n * in-memory parseImage callers leave it empty.\n */\n readonly path?: string;\n}\n\nconst DEFAULT_MAX_DIMENSION = 16384;\n\nconst SUPPORTED_MIMES: readonly string[] = ['image/png', 'image/jpeg', 'image/x-tga'];\n\ninterface UpngDecoded {\n readonly width: number;\n readonly height: number;\n readonly data: Uint8Array;\n}\n\ninterface JpegDecoded {\n readonly width: number;\n readonly height: number;\n readonly data: Uint8Array;\n}\n\n/**\n * Pure synchronous image decoder. Translates raw byte stream + mime hint\n * into a tight-packed RGBA `DecodedImage` POD. Surfaces all four\n * ImageErrorCode members through the structured `Result<DecodedImage,\n * ImageError>` return (charter P3 explicit failure; AGENTS.md \"Return\n * Result, never throw\").\n *\n * Decoder selection follows the mime hint:\n * - `image/png` -> upng-js `UPNG.decode` + `UPNG.toRGBA8`\n * - `image/jpeg` -> jpeg-js `decode` with `formatAsRGBA: true`\n * - `image/x-tga` -> the built-in TGA true-color/grayscale decoder\n * - other -> `image-format-unsupported`\n *\n * Decoded bytes are always tight-packed RGBA (`bytes.length === width *\n * height * 4`). `colorSpace` and `mipmap` are carried from the supplied\n * `ParseImageOptions` (decodeImageFromFile passes the sidecar settings).\n */\nexport function parseImage(\n bytes: Uint8Array,\n mime: string,\n opts: ParseImageOptions = {},\n): Result<DecodedImage, ImageError> {\n if (!SUPPORTED_MIMES.includes(mime)) {\n return err(\n imageError({\n code: 'image-format-unsupported',\n actualMime: mime,\n ...(opts.path !== undefined ? { path: opts.path } : {}),\n }),\n );\n }\n\n let width = 0;\n let height = 0;\n let rgba: Uint8Array;\n\n try {\n if (mime === 'image/png') {\n const upngMod: {\n decode: (b: Uint8Array | ArrayBuffer) => UpngDecoded;\n toRGBA8: (i: UpngDecoded) => ArrayBuffer[];\n } = ((UPNG as unknown as { default?: typeof UPNG }).default ?? UPNG) as unknown as {\n decode: (b: Uint8Array | ArrayBuffer) => UpngDecoded;\n toRGBA8: (i: UpngDecoded) => ArrayBuffer[];\n };\n const decoded = upngMod.decode(bytes);\n width = decoded.width;\n height = decoded.height;\n const frames = upngMod.toRGBA8(decoded);\n const first = frames[0];\n if (first === undefined) {\n return err(\n imageError({\n code: 'image-decode-failed',\n reason: 'UPNG.toRGBA8 returned no frames',\n ...(opts.path !== undefined ? { path: opts.path } : {}),\n }),\n );\n }\n rgba = new Uint8Array(first);\n } else if (mime === 'image/jpeg') {\n // image/jpeg\n const jpegMod: {\n decode: (\n b: Uint8Array | ArrayBuffer,\n o?: { useTArray?: boolean; formatAsRGBA?: boolean },\n ) => JpegDecoded;\n } = ((jpeg as unknown as { default?: typeof jpeg }).default ?? jpeg) as unknown as {\n decode: (\n b: Uint8Array | ArrayBuffer,\n o?: { useTArray?: boolean; formatAsRGBA?: boolean },\n ) => JpegDecoded;\n };\n const decoded = jpegMod.decode(bytes, { useTArray: true, formatAsRGBA: true });\n width = decoded.width;\n height = decoded.height;\n rgba = decoded.data;\n } else {\n const decoded = decodeTga(bytes);\n width = decoded.width;\n height = decoded.height;\n rgba = decoded.bytes;\n }\n } catch (e) {\n return err(\n imageError({\n code: 'image-decode-failed',\n reason: e instanceof Error ? e.message : String(e),\n ...(opts.path !== undefined ? { path: opts.path } : {}),\n }),\n );\n }\n\n const downscaleLimit = opts.downscaleMaxDimension;\n if (downscaleLimit !== undefined && Number.isInteger(downscaleLimit) && downscaleLimit > 0) {\n const downscaled = downscaleRgba(rgba, width, height, downscaleLimit);\n rgba = downscaled.bytes;\n width = downscaled.width;\n height = downscaled.height;\n }\n\n const limit = opts.maxDimension ?? DEFAULT_MAX_DIMENSION;\n if (width > limit || height > limit) {\n return err(\n imageError({\n code: 'image-dimension-out-of-bounds',\n requested: { width, height },\n limit,\n }),\n );\n }\n\n return ok({\n bytes: rgba,\n width,\n height,\n mime: mime as 'image/png' | 'image/jpeg' | 'image/x-tga',\n colorSpace: opts.colorSpace ?? 'srgb',\n mipmap: opts.mipmap ?? true,\n });\n}\n\ninterface TgaDecoded {\n readonly width: number;\n readonly height: number;\n readonly bytes: Uint8Array;\n}\n\n/**\n * Decode the portable TGA subset used by common FBX exports.\n *\n * The decoder owns the format boundary instead of trusting the extension: it\n * validates the header, supports uncompressed and RLE true-colour (24/32-bit)\n * plus grayscale (8-bit), and applies the origin bits from the image\n * descriptor while producing a top-left RGBA POD.\n */\nfunction decodeTga(bytes: Uint8Array): TgaDecoded {\n if (bytes.length < 18) throw new Error('TGA header is truncated');\n\n const colorMapType = bytes[1];\n const imageType = bytes[2];\n const idLength = bytes[0] ?? 0;\n const width = (bytes[12] ?? 0) | ((bytes[13] ?? 0) << 8);\n const height = (bytes[14] ?? 0) | ((bytes[15] ?? 0) << 8);\n const pixelDepth = bytes[16] ?? 0;\n const descriptor = bytes[17] ?? 0;\n if (colorMapType !== 0) throw new Error('color-mapped TGA is unsupported');\n if (width < 1 || height < 1) throw new Error('TGA dimensions must be positive');\n\n const isTrueColor = imageType === 2 || imageType === 10;\n const isGray = imageType === 3 || imageType === 11;\n if (!isTrueColor && !isGray) throw new Error(`TGA image type ${imageType} is unsupported`);\n if (isTrueColor && pixelDepth !== 24 && pixelDepth !== 32) {\n throw new Error(`TGA true-color depth ${pixelDepth} is unsupported`);\n }\n if (isGray && pixelDepth !== 8)\n throw new Error(`TGA grayscale depth ${pixelDepth} is unsupported`);\n\n const bytesPerPixel = pixelDepth / 8;\n let offset = 18 + idLength;\n const pixelCount = width * height;\n const out = new Uint8Array(pixelCount * 4);\n const topOrigin = (descriptor & 0x20) !== 0;\n const rightOrigin = (descriptor & 0x10) !== 0;\n let filePixel = 0;\n\n const writePixel = (pixel: Uint8Array): void => {\n if (filePixel >= pixelCount) throw new Error('TGA pixel data has too many pixels');\n const fileX = filePixel % width;\n const fileY = Math.floor(filePixel / width);\n const x = rightOrigin ? width - 1 - fileX : fileX;\n const y = topOrigin ? fileY : height - 1 - fileY;\n const destination = (y * width + x) * 4;\n if (isGray) {\n const value = pixel[0] ?? 0;\n out[destination] = value;\n out[destination + 1] = value;\n out[destination + 2] = value;\n out[destination + 3] = 255;\n } else {\n out[destination] = pixel[2] ?? 0;\n out[destination + 1] = pixel[1] ?? 0;\n out[destination + 2] = pixel[0] ?? 0;\n out[destination + 3] = bytesPerPixel === 4 ? (pixel[3] ?? 255) : 255;\n }\n filePixel += 1;\n };\n\n const readPixel = (): Uint8Array => {\n if (offset + bytesPerPixel > bytes.length) throw new Error('TGA pixel data is truncated');\n const pixel = bytes.slice(offset, offset + bytesPerPixel);\n offset += bytesPerPixel;\n return pixel;\n };\n\n if (imageType === 2 || imageType === 3) {\n while (filePixel < pixelCount) writePixel(readPixel());\n } else {\n while (filePixel < pixelCount) {\n if (offset >= bytes.length) throw new Error('TGA RLE packet header is truncated');\n const packet = bytes[offset++] ?? 0;\n const count = (packet & 0x7f) + 1;\n if (filePixel + count > pixelCount) throw new Error('TGA RLE packet exceeds image bounds');\n if ((packet & 0x80) !== 0) {\n const pixel = readPixel();\n for (let i = 0; i < count; i++) writePixel(pixel);\n } else {\n for (let i = 0; i < count; i++) writePixel(readPixel());\n }\n }\n }\n\n if (filePixel !== pixelCount) throw new Error('TGA pixel count mismatch');\n return { width, height, bytes: out };\n}\n","import { readFile, stat } from 'node:fs/promises';\nimport { dirname, extname, join } from 'node:path';\n\nimport { validateMeta } from '@forgeax/engine-pack';\nimport type { DecodedImage, ImageError, ImageMeta } from '@forgeax/engine-types';\nimport { imageError } from './errors.js';\nimport { decodeHdr, type HdrDecoded } from './hdr-decoder.js';\nimport { parseImage } from './parse-image.js';\nimport type { Result } from './result.js';\nimport { err, ok } from './result.js';\n\n/**\n * Sidecar JSON shape consumed by decodeImageFromFile. The schema is the\n * external-asset-package $defs from `packages/pack/schema/meta.schema.json`\n * (research F-9). Only the fields required by the Node-side decoder are\n * enumerated here; importSettings remains free-form per plan-strategy R5.\n */\ninterface SidecarMeta {\n readonly schemaVersion: string;\n readonly kind: 'external-asset-package';\n readonly importer: 'image';\n readonly source: string;\n readonly importSettings: Partial<{\n colorSpace: ImageMeta['colorSpace'];\n mipmap: ImageMeta['mipmap'];\n addressMode: ImageMeta['addressMode'];\n filterMode: ImageMeta['filterMode'];\n }>;\n readonly subAssets: ReadonlyArray<{\n readonly guid: string;\n readonly sourceIndex: number;\n readonly kind: string;\n }>;\n}\n\n/**\n * Result envelope returned by decodeImageFromFile for PNG/JPG sources.\n * Carries both the raw DecodedImage POD (for direct uploadTexture consumption)\n * and the parsed ImageMeta POD.\n */\nexport interface DecodedImageWithMeta {\n readonly decoded: DecodedImage;\n readonly meta: ImageMeta;\n}\n\n/**\n * Result envelope returned by decodeImageFromFile for .hdr sources.\n * Carries the HDR-decoded float data ready for cubemap upload.\n */\nexport interface DecodedHdrWithMeta {\n readonly hdr: HdrDecoded;\n readonly meta: ImageMeta;\n}\n\nconst EXT_TO_MIME: Readonly<\n Record<string, 'image/png' | 'image/jpeg' | 'image/x-tga' | 'image/vnd.radiance'>\n> = {\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.tga': 'image/x-tga',\n '.hdr': 'image/vnd.radiance',\n};\n\nfunction deriveSidecarPath(sourcePath: string): string {\n const dir = dirname(sourcePath);\n // sidecar lives next to source as <source-with-ext>.meta.json\n // (feat-20260521 unify-sidecar-meta-dispatch-by-content; the importer field\n // in the JSON drives importer dispatch instead of filename suffix).\n const base = sourcePath.slice(dir.length + 1);\n return join(dir, `${base}.meta.json`);\n}\n\nfunction sidecarSchemaFailureReason(): string {\n const firstError = validateMeta.errors?.[0];\n if (firstError === undefined) return 'sidecar schema validation failed';\n const location = firstError.instancePath === '' ? '/' : firstError.instancePath;\n return `sidecar schema validation failed: ${firstError.keyword} at ${location}`.slice(0, 256);\n}\n\nfunction imageSidecarFailureReason(\n sidecar: SidecarMeta,\n mime: (typeof EXT_TO_MIME)[keyof typeof EXT_TO_MIME],\n): string | undefined {\n const subAsset = sidecar.subAssets[0];\n const settings = sidecar.importSettings;\n const expectedKind = mime === 'image/vnd.radiance' ? 'equirect' : 'texture';\n if (sidecar.importer !== 'image') return 'image sidecar importer must be image';\n if (sidecar.subAssets.length !== 1 || subAsset === undefined) {\n return 'image sidecar must declare one sub-asset';\n }\n if (subAsset.kind !== expectedKind || subAsset.sourceIndex !== 0) {\n return `image sidecar sub-asset must be ${expectedKind} at sourceIndex 0`;\n }\n if (settings.colorSpace !== undefined && !['srgb', 'linear'].includes(settings.colorSpace)) {\n return 'image sidecar colorSpace must be srgb or linear';\n }\n if (settings.mipmap !== undefined && !['auto', 'none'].includes(settings.mipmap)) {\n return 'image sidecar mipmap must be auto or none';\n }\n if (\n settings.addressMode !== undefined &&\n !['repeat', 'clamp-to-edge', 'mirror-repeat'].includes(settings.addressMode)\n ) {\n return 'image sidecar addressMode is unsupported';\n }\n if (settings.filterMode !== undefined && !['nearest', 'linear'].includes(settings.filterMode)) {\n return 'image sidecar filterMode is unsupported';\n }\n return undefined;\n}\n\n/**\n * Async file-system entry to the image importer (plan-strategy section 3.2\n * sequence A; AC-17 path (a) sidecar three-way fallback).\n *\n * Behaviour (left-to-right, fail-fast on first surfaced ImageError):\n * 1. Sniff extension -- not in `.png / .jpg / .jpeg` -> image-format-unsupported\n * 2. Stat source -- absent -> image-decode-failed with the source path\n * 3. Stat sibling `<source>.meta.json` (importer: 'image') -- absent -> image-meta-missing\n * 4. Read source bytes + parse sidecar JSON\n * 5. Hand off to `parseImage(bytes, mime, opts)` -- surfaces image-decode-failed\n * / image-format-unsupported / image-dimension-out-of-bounds\n * 6. Compose DecodedImage POD + ImageMeta POD return envelope.\n *\n * AC-17 path (a) lock: when the sidecar is absent, the returned error\n * carries `detail.sourcePath` + `detail.expectedSidecarPath` so AI users\n * read .hint and run `forgeax-engine-remote-asset import <path>` to\n * self-recover (charter P3 explicit failure + IDE jump-to-source).\n */\nexport async function decodeImageFromFile(\n sourcePath: string,\n): Promise<Result<DecodedImageWithMeta, ImageError>> {\n const ext = extname(sourcePath).toLowerCase();\n const mime = EXT_TO_MIME[ext];\n if (mime === undefined) {\n return err(\n imageError({\n code: 'image-format-unsupported',\n actualMime: `extension '${ext || '<none>'}'`,\n path: sourcePath,\n }),\n );\n }\n\n const sidecarPath = deriveSidecarPath(sourcePath);\n\n try {\n await stat(sourcePath);\n } catch (e) {\n return err(\n imageError({\n code: 'image-decode-failed',\n reason: `failed to read source: ${e instanceof Error ? e.message : String(e)}`,\n path: sourcePath,\n }),\n );\n }\n\n try {\n await stat(sidecarPath);\n } catch {\n return err(\n imageError({\n code: 'image-meta-missing',\n sourcePath,\n expectedSidecarPath: sidecarPath,\n }),\n );\n }\n\n let sidecarText: string;\n try {\n sidecarText = (await readFile(sidecarPath)).toString('utf8');\n } catch (e) {\n return err(\n imageError({\n code: 'image-decode-failed',\n reason: `failed to read sidecar: ${e instanceof Error ? e.message : String(e)}`,\n path: sidecarPath,\n }),\n );\n }\n\n let parsedSidecar: unknown;\n try {\n parsedSidecar = JSON.parse(sidecarText) as unknown;\n } catch (e) {\n return err(\n imageError({\n code: 'image-decode-failed',\n reason: `sidecar JSON parse failed: ${e instanceof Error ? e.message : String(e)}`,\n path: sidecarPath,\n }),\n );\n }\n\n if (!validateMeta(parsedSidecar)) {\n return err(\n imageError({\n code: 'image-decode-failed',\n reason: sidecarSchemaFailureReason(),\n path: sidecarPath,\n }),\n );\n }\n\n const sidecar = parsedSidecar as unknown as SidecarMeta;\n const imageSidecarFailure = imageSidecarFailureReason(sidecar, mime);\n if (imageSidecarFailure !== undefined) {\n return err(\n imageError({\n code: 'image-decode-failed',\n reason: imageSidecarFailure,\n path: sidecarPath,\n }),\n );\n }\n\n const settings = sidecar.importSettings ?? {};\n const colorSpace: ImageMeta['colorSpace'] = settings.colorSpace ?? 'srgb';\n const mipmap: ImageMeta['mipmap'] = settings.mipmap ?? 'auto';\n const addressMode: ImageMeta['addressMode'] = settings.addressMode ?? 'repeat';\n const filterMode: ImageMeta['filterMode'] = settings.filterMode ?? 'linear';\n const guid = sidecar.subAssets[0]?.guid ?? '';\n\n const meta: ImageMeta = {\n guid,\n colorSpace,\n mipmap,\n addressMode,\n filterMode,\n };\n\n let bytes: Uint8Array;\n try {\n const buf = await readFile(sourcePath);\n bytes = new Uint8Array(buf);\n } catch (e) {\n return err(\n imageError({\n code: 'image-decode-failed',\n reason: `failed to read source: ${e instanceof Error ? e.message : String(e)}`,\n path: sourcePath,\n }),\n );\n }\n\n // .hdr path: delegate to HDR decoder, enforce linear color space\n if (mime === 'image/vnd.radiance') {\n if (colorSpace !== 'linear') {\n return err(\n imageError({\n code: 'image-format-unsupported',\n actualMime: `colorSpace conflict: HDR requires linear, got ${colorSpace}`,\n path: sourcePath,\n }),\n );\n }\n const hdrRes = decodeHdr(bytes);\n if (!hdrRes.ok) return err(hdrRes.error);\n // DecodedImageWithMeta expects DecodedImage; for HDR we return the HDR\n // variant through a separate export path. Downstream consumers\n // distinguish by file extension.\n // For the DecodedImageWithMeta return type compatibility, we synthesise\n // a minimal DecodedImage POD carrying the byte representation.\n // This keeps the return type stable for existing PNG/JPG callers.\n // The HDR data is available through the separate decodeHdr export.\n const rgba8 = new Uint8Array(hdrRes.value.width * hdrRes.value.height * 4);\n // convert float to quantised 8-bit for the POD shape (lossy; consumers\n // should use decodeHdr directly for float precision)\n for (let i = 0; i < hdrRes.value.data.length; i++) {\n const v = hdrRes.value.data[i];\n const clamped = v !== undefined ? Math.max(0, Math.min(1, v as number)) : 0;\n rgba8[i] = Math.round(clamped * 255);\n }\n const decoded: DecodedImage = {\n bytes: rgba8,\n width: hdrRes.value.width,\n height: hdrRes.value.height,\n mime: 'image/jpeg',\n colorSpace: 'linear',\n mipmap: false,\n };\n return ok({ decoded, meta });\n }\n\n const r = parseImage(bytes, mime, {\n colorSpace,\n mipmap: mipmap === 'auto',\n path: sourcePath,\n });\n if (!r.ok) {\n return err(r.error);\n }\n\n return ok({ decoded: r.value, meta });\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import type { ImageErrorCode, ImageErrorDetailFor, ImageErrorFor } from '@forgeax/engine-types';
2
+ declare const IMAGE_ERROR_EXPECTED: Readonly<Record<ImageErrorCode, string>>;
3
+ /** Runtime implementation of the correlated `ImageErrorFor<C>` envelope. */
4
+ export declare class ImageErrorImpl<C extends ImageErrorCode = ImageErrorCode> extends Error implements ImageErrorFor<C> {
5
+ readonly code: C;
6
+ readonly expected: string;
7
+ readonly hint: string;
8
+ readonly detail: ImageErrorDetailFor<C>;
9
+ constructor(detail: ImageErrorDetailFor<C>);
10
+ }
11
+ /** Construct a structured image error while preserving its code/detail pair. */
12
+ export declare function imageError<C extends ImageErrorCode>(detail: ImageErrorDetailFor<C>): ImageErrorFor<C>;
13
+ export { IMAGE_ERROR_EXPECTED };
14
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAOhG,QAAA,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAoBlE,CAAC;AAEF,4EAA4E;AAC5E,qBAAa,cAAc,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,CACnE,SAAQ,KACR,YAAW,aAAa,CAAC,CAAC,CAAC;IAE3B,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;gBAE5B,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;CAW3C;AAED,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,CAAC,SAAS,cAAc,EACjD,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAC7B,aAAa,CAAC,CAAC,CAAC,CAElB;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { ImageError } from '@forgeax/engine-types';
2
+ import type { Result } from './result.js';
3
+ /**
4
+ * Decoded HDR image POD.
5
+ *
6
+ * `data` is an interleaved RGBA Float32Array (4 floats per pixel, row-major).
7
+ * Color space is always linear (RGBE is radiance).
8
+ */
9
+ export interface HdrDecoded {
10
+ readonly width: number;
11
+ readonly height: number;
12
+ readonly data: Float32Array;
13
+ }
14
+ /**
15
+ * Decode a Radiance RGBE (.hdr) byte stream into linear RGBA float pixels.
16
+ *
17
+ * Steps per research F-6:
18
+ * 1. Parse ASCII header: magic (#?RADIANCE), FORMAT=32-bit_rle_rgbe,
19
+ * resolution line (-Y height +X width).
20
+ * 2. Decode per-scanline new-RLE pixel data: 4 independent channel runs.
21
+ * 3. Convert RGBE to float: if E==0 -> 0; else f=2^(E-136), R=(Rm+0.5)*f.
22
+ * 4. Output as interleaved RGBA Float32Array (alpha=1.0).
23
+ *
24
+ * Old-RLE scanlines (prefix not matching 0x02,0x02,hi,lo with correct width)
25
+ * return image-hdr-decode-failed.
26
+ */
27
+ export declare function decodeHdr(bytes: Uint8Array): Result<HdrDecoded, ImageError>;
28
+ //# sourceMappingURL=hdr-decoder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hdr-decoder.d.ts","sourceRoot":"","sources":["../src/hdr-decoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;CAC7B;AAKD;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,CAiI3E"}
@@ -0,0 +1,212 @@
1
+ import { err, ok, IMAGE_ERROR_HINTS } from '@forgeax/engine-types';
2
+
3
+ // src/errors.ts
4
+ var IMAGE_ERROR_EXPECTED = {
5
+ "image-decode-failed": "PNG / JPG byte stream decodes successfully",
6
+ "image-format-unsupported": "mime is one of ['image/png', 'image/jpeg', 'image/x-tga']; uploadTexture format <-> colorSpace family agrees",
7
+ "image-dimension-out-of-bounds": "width and height fall under device caps maxTextureDimension2D (or 16384 hard cap)",
8
+ "image-meta-missing": "<source>.meta.json sidecar (importer: 'image') exists in the same directory",
9
+ "image-hdr-decode-failed": "Radiance RGBE header is valid and pixel data decodes successfully",
10
+ // feat-20260521-sprite-atlas-animation M1 T-03 — vite-plugin-image atlas
11
+ // hook .expected literals (plan-strategy section 2 D-2 + AC-10 a/b/c).
12
+ // ImageErrorImpl construction path is unchanged: the new atlas-* errors
13
+ // flow through `new ImageErrorImpl({ code: 'atlas-...', ...detail })` and
14
+ // pick the .expected string up from this Record at construction time
15
+ // (charter P3 explicit failure SSOT — AI users surface .expected next to
16
+ // .hint after switch (err.code) without parsing the message).
17
+ "atlas-empty-input": "images.length >= 1",
18
+ "atlas-size-exceeded": "image width x height <= maxAtlasSize^2 and each image fits in the atlas footprint",
19
+ "atlas-region-mismatch": "sum(regions[i].w x regions[i].h) <= atlasWidth x atlasHeight"
20
+ };
21
+ var ImageErrorImpl = class extends Error {
22
+ code;
23
+ expected;
24
+ hint;
25
+ detail;
26
+ constructor(detail) {
27
+ const code = detail.code;
28
+ const expected = IMAGE_ERROR_EXPECTED[code];
29
+ const hint = IMAGE_ERROR_HINTS[code];
30
+ super(`[ImageError ${code}] expected: ${expected}; hint: ${hint}`);
31
+ this.name = "ImageError";
32
+ this.code = code;
33
+ this.expected = expected;
34
+ this.hint = hint;
35
+ this.detail = detail;
36
+ }
37
+ };
38
+ function imageError(detail) {
39
+ return new ImageErrorImpl(detail);
40
+ }
41
+
42
+ // src/hdr-decoder.ts
43
+ var LF = 10;
44
+ function decodeHdr(bytes) {
45
+ let pos = 0;
46
+ if (bytes.length < 11) {
47
+ return err(hdrDecodeError("file too short for Radiance HDR header"));
48
+ }
49
+ const magic = String.fromCharCode(...bytes.subarray(0, 11));
50
+ if (magic !== "#?RADIANCE\n" && magic !== "#?RGBE\n") {
51
+ return err(
52
+ hdrDecodeError("missing or invalid Radiance HDR magic; expected #?RADIANCE or #?RGBE")
53
+ );
54
+ }
55
+ pos = 11;
56
+ let formatFound = false;
57
+ while (pos < bytes.length) {
58
+ const lineEnd = findByte(bytes, LF, pos);
59
+ if (lineEnd === -1) return err(hdrDecodeError("header truncated before empty line"));
60
+ const line = asciiSubstring(bytes, pos, lineEnd);
61
+ pos = lineEnd + 1;
62
+ if (line === "") break;
63
+ if (line.startsWith("FORMAT=")) {
64
+ const val = line.slice(7);
65
+ if (val === "32-bit_rle_rgbe") {
66
+ formatFound = true;
67
+ }
68
+ }
69
+ }
70
+ if (!formatFound) {
71
+ return err(hdrDecodeError("missing or unsupported FORMAT; expected FORMAT=32-bit_rle_rgbe"));
72
+ }
73
+ if (pos >= bytes.length) return err(hdrDecodeError("missing resolution line"));
74
+ const resLineEnd = findByte(bytes, LF, pos);
75
+ if (resLineEnd === -1) return err(hdrDecodeError("resolution line truncated"));
76
+ const resLine = asciiSubstring(bytes, pos, resLineEnd);
77
+ pos = resLineEnd + 1;
78
+ const resMatch = /^-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/.exec(resLine);
79
+ if (resMatch === null) {
80
+ return err(
81
+ hdrDecodeError(`unexpected resolution line format: "${resLine}"; expected "-Y H +X W"`)
82
+ );
83
+ }
84
+ const height = Number(resMatch[1]);
85
+ const width = Number(resMatch[2]);
86
+ if (height === void 0 || width === void 0 || height <= 0 || width <= 0) {
87
+ return err(hdrDecodeError(`invalid dimensions: ${width}x${height}`));
88
+ }
89
+ const pixelCount = width * height;
90
+ const rgbe = new Uint8Array(pixelCount * 4);
91
+ const scanlineBytes = width * 4;
92
+ for (let y = 0; y < height; y++) {
93
+ if (pos + 4 > bytes.length) {
94
+ return err(hdrDecodeError(`truncated at scanline ${y}: expected 4-byte prefix`));
95
+ }
96
+ const p0 = bytes[pos];
97
+ const p1 = bytes[pos + 1];
98
+ const pHi = bytes[pos + 2];
99
+ const pLo = bytes[pos + 3];
100
+ if (p0 === void 0 || p1 === void 0 || pHi === void 0 || pLo === void 0) {
101
+ return err(hdrDecodeError(`truncated at scanline ${y}`));
102
+ }
103
+ const prefixWidth = pHi << 8 | pLo;
104
+ if (p0 === 2 && p1 === 2 && prefixWidth === width && width >= 8 && width <= 32767) {
105
+ const decoded = decodeNewRleScanline(bytes, pos + 4, width);
106
+ if (decoded === null) {
107
+ return err(hdrDecodeError(`RLE decode failed at scanline ${y}`));
108
+ }
109
+ const base = y * scanlineBytes;
110
+ const channels = [decoded[0], decoded[1], decoded[2], decoded[3]];
111
+ for (let x = 0; x < width; x++) {
112
+ for (let ch = 0; ch < 4; ch++) {
113
+ rgbe[base + x * 4 + ch] = channels[ch][x];
114
+ }
115
+ }
116
+ pos += 4 + decoded.totalBytes;
117
+ } else {
118
+ return err(
119
+ hdrDecodeError(
120
+ "old-RLE format is not supported; only new-RLE (32-bit_rle_rgbe) is accepted"
121
+ )
122
+ );
123
+ }
124
+ }
125
+ const out = new Float32Array(pixelCount * 4);
126
+ for (let i = 0; i < pixelCount; i++) {
127
+ const base = i * 4;
128
+ const r = rgbe[base];
129
+ const g = rgbe[base + 1];
130
+ const b = rgbe[base + 2];
131
+ const e = rgbe[base + 3];
132
+ out[base + 3] = 1;
133
+ if (e === 0) {
134
+ out[base] = 0;
135
+ out[base + 1] = 0;
136
+ out[base + 2] = 0;
137
+ } else {
138
+ const f = 2 ** (e - 136);
139
+ out[base] = (r + 0.5) * f;
140
+ out[base + 1] = (g + 0.5) * f;
141
+ out[base + 2] = (b + 0.5) * f;
142
+ }
143
+ }
144
+ return ok({ width, height, data: out });
145
+ }
146
+ function decodeNewRleScanline(bytes, start, width) {
147
+ const channels = [];
148
+ let cursor = start;
149
+ for (let ch = 0; ch < 4; ch++) {
150
+ const data = new Uint8Array(width);
151
+ let x = 0;
152
+ while (x < width) {
153
+ if (cursor >= bytes.length) return null;
154
+ const code = bytes[cursor];
155
+ cursor++;
156
+ if (code > 128) {
157
+ const count = code - 128;
158
+ if (cursor >= bytes.length || x + count > width) return null;
159
+ const val = bytes[cursor];
160
+ cursor++;
161
+ data.fill(val, x, x + count);
162
+ x += count;
163
+ } else {
164
+ if (code === 0) continue;
165
+ if (cursor + code > bytes.length || x + code > width) return null;
166
+ for (let k = 0; k < code; k++) {
167
+ data[x + k] = bytes[cursor + k];
168
+ }
169
+ cursor += code;
170
+ x += code;
171
+ }
172
+ }
173
+ channels.push(data);
174
+ }
175
+ const ch0 = channels[0];
176
+ const ch1 = channels[1];
177
+ const ch2 = channels[2];
178
+ const ch3 = channels[3];
179
+ if (ch0 === void 0 || ch1 === void 0 || ch2 === void 0 || ch3 === void 0) {
180
+ return null;
181
+ }
182
+ return {
183
+ 0: ch0,
184
+ 1: ch1,
185
+ 2: ch2,
186
+ 3: ch3,
187
+ totalBytes: cursor - start
188
+ };
189
+ }
190
+ function findByte(bytes, target, start) {
191
+ for (let i = start; i < bytes.length; i++) {
192
+ if (bytes[i] === target) return i;
193
+ }
194
+ return -1;
195
+ }
196
+ function asciiSubstring(bytes, start, end) {
197
+ let s = "";
198
+ for (let i = start; i < end; i++) {
199
+ s += String.fromCharCode(bytes[i]);
200
+ }
201
+ return s;
202
+ }
203
+ function hdrDecodeError(reason) {
204
+ return imageError({
205
+ code: "image-hdr-decode-failed",
206
+ reason
207
+ });
208
+ }
209
+
210
+ export { decodeHdr };
211
+ //# sourceMappingURL=hdr-decoder.mjs.map
212
+ //# sourceMappingURL=hdr-decoder.mjs.map
@@ -0,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IAAI,CAAA,GAAI,EAAA;AACR,EAAA,KAAA,IAAS,CAAA,GAAI,KAAA,EAAO,CAAA,GAAI,GAAA,EAAK,CAAA,EAAA,EAAK;AAEhC,IAAA,CAAA,IAAK,MAAA,CAAO,YAAA,CAAa,KAAA,CAAM,CAAC,CAAE,CAAA;AAAA,EACpC;AACA,EAAA,OAAO,CAAA;AACT;AAEA,SAAS,eAAe,MAAA,EAA4B;AAClD,EAAA,OAAO,UAAA,CAAW;AAAA,IAChB,IAAA,EAAM,yBAAA;AAAA,IACN;AAAA,GACD,CAAA;AACH","file":"hdr-decoder.mjs","sourcesContent":["import type { ImageErrorCode, ImageErrorDetailFor, ImageErrorFor } from '@forgeax/engine-types';\nimport { IMAGE_ERROR_HINTS } from '@forgeax/engine-types';\n\n// Per-code .expected string literals SSOT.\n// Mirrors ASSET_ERROR_HINTS / IMAGE_ERROR_HINTS shape (charter P5 consistent\n// abstraction). AI users surface .expected when a structured error needs to\n// describe the precondition that was violated.\nconst IMAGE_ERROR_EXPECTED: Readonly<Record<ImageErrorCode, string>> = {\n 'image-decode-failed': 'PNG / JPG byte stream decodes successfully',\n 'image-format-unsupported':\n \"mime is one of ['image/png', 'image/jpeg', 'image/x-tga']; uploadTexture format <-> colorSpace family agrees\",\n 'image-dimension-out-of-bounds':\n 'width and height fall under device caps maxTextureDimension2D (or 16384 hard cap)',\n 'image-meta-missing':\n \"<source>.meta.json sidecar (importer: 'image') exists in the same directory\",\n 'image-hdr-decode-failed': 'Radiance RGBE header is valid and pixel data decodes successfully',\n // feat-20260521-sprite-atlas-animation M1 T-03 — vite-plugin-image atlas\n // hook .expected literals (plan-strategy section 2 D-2 + AC-10 a/b/c).\n // ImageErrorImpl construction path is unchanged: the new atlas-* errors\n // flow through `new ImageErrorImpl({ code: 'atlas-...', ...detail })` and\n // pick the .expected string up from this Record at construction time\n // (charter P3 explicit failure SSOT — AI users surface .expected next to\n // .hint after switch (err.code) without parsing the message).\n 'atlas-empty-input': 'images.length >= 1',\n 'atlas-size-exceeded':\n 'image width x height <= maxAtlasSize^2 and each image fits in the atlas footprint',\n 'atlas-region-mismatch': 'sum(regions[i].w x regions[i].h) <= atlasWidth x atlasHeight',\n};\n\n/** Runtime implementation of the correlated `ImageErrorFor<C>` envelope. */\nexport class ImageErrorImpl<C extends ImageErrorCode = ImageErrorCode>\n extends Error\n implements ImageErrorFor<C>\n{\n readonly code: C;\n readonly expected: string;\n readonly hint: string;\n readonly detail: ImageErrorDetailFor<C>;\n\n constructor(detail: ImageErrorDetailFor<C>) {\n const code = detail.code;\n const expected = IMAGE_ERROR_EXPECTED[code];\n const hint = IMAGE_ERROR_HINTS[code];\n super(`[ImageError ${code}] expected: ${expected}; hint: ${hint}`);\n this.name = 'ImageError';\n this.code = code;\n this.expected = expected;\n this.hint = hint;\n this.detail = detail;\n }\n}\n\n/** Construct a structured image error while preserving its code/detail pair. */\nexport function imageError<C extends ImageErrorCode>(\n detail: ImageErrorDetailFor<C>,\n): ImageErrorFor<C> {\n return new ImageErrorImpl<C>(detail);\n}\n\nexport { IMAGE_ERROR_EXPECTED };\n","import type { ImageError } from '@forgeax/engine-types';\nimport { imageError } from './errors.js';\nimport type { Result } from './result.js';\nimport { err, ok } from './result.js';\n\n/**\n * Decoded HDR image POD.\n *\n * `data` is an interleaved RGBA Float32Array (4 floats per pixel, row-major).\n * Color space is always linear (RGBE is radiance).\n */\nexport interface HdrDecoded {\n readonly width: number;\n readonly height: number;\n readonly data: Float32Array;\n}\n\n// ASCII code points\nconst LF = 0x0a;\n\n/**\n * Decode a Radiance RGBE (.hdr) byte stream into linear RGBA float pixels.\n *\n * Steps per research F-6:\n * 1. Parse ASCII header: magic (#?RADIANCE), FORMAT=32-bit_rle_rgbe,\n * resolution line (-Y height +X width).\n * 2. Decode per-scanline new-RLE pixel data: 4 independent channel runs.\n * 3. Convert RGBE to float: if E==0 -> 0; else f=2^(E-136), R=(Rm+0.5)*f.\n * 4. Output as interleaved RGBA Float32Array (alpha=1.0).\n *\n * Old-RLE scanlines (prefix not matching 0x02,0x02,hi,lo with correct width)\n * return image-hdr-decode-failed.\n */\nexport function decodeHdr(bytes: Uint8Array): Result<HdrDecoded, ImageError> {\n let pos = 0;\n\n // Step 1a: magic -- must start with \"#?RADIANCE\" or \"#?RGBE\"\n if (bytes.length < 11) {\n return err(hdrDecodeError('file too short for Radiance HDR header'));\n }\n const magic = String.fromCharCode(...bytes.subarray(0, 11));\n if (magic !== '#?RADIANCE\\n' && magic !== '#?RGBE\\n') {\n return err(\n hdrDecodeError('missing or invalid Radiance HDR magic; expected #?RADIANCE or #?RGBE'),\n );\n }\n pos = 11;\n\n // Step 1b: key=value lines until empty line\n let formatFound = false;\n while (pos < bytes.length) {\n const lineEnd = findByte(bytes, LF, pos);\n if (lineEnd === -1) return err(hdrDecodeError('header truncated before empty line'));\n const line = asciiSubstring(bytes, pos, lineEnd);\n pos = lineEnd + 1;\n if (line === '') break;\n if (line.startsWith('FORMAT=')) {\n const val = line.slice(7);\n if (val === '32-bit_rle_rgbe') {\n formatFound = true;\n }\n }\n }\n if (!formatFound) {\n return err(hdrDecodeError('missing or unsupported FORMAT; expected FORMAT=32-bit_rle_rgbe'));\n }\n\n // Step 1c: resolution line (-Y height +X width)\n if (pos >= bytes.length) return err(hdrDecodeError('missing resolution line'));\n const resLineEnd = findByte(bytes, LF, pos);\n if (resLineEnd === -1) return err(hdrDecodeError('resolution line truncated'));\n const resLine = asciiSubstring(bytes, pos, resLineEnd);\n pos = resLineEnd + 1;\n const resMatch = /^-Y\\s+(\\d+)\\s+\\+X\\s+(\\d+)\\s*$/.exec(resLine);\n if (resMatch === null) {\n return err(\n hdrDecodeError(`unexpected resolution line format: \"${resLine}\"; expected \"-Y H +X W\"`),\n );\n }\n const height = Number(resMatch[1]);\n const width = Number(resMatch[2]);\n if (height === undefined || width === undefined || height <= 0 || width <= 0) {\n return err(hdrDecodeError(`invalid dimensions: ${width}x${height}`));\n }\n\n // Step 2: decode per-scanline new-RLE pixel data\n const pixelCount = width * height;\n const rgbe = new Uint8Array(pixelCount * 4);\n const scanlineBytes = width * 4;\n\n for (let y = 0; y < height; y++) {\n if (pos + 4 > bytes.length) {\n return err(hdrDecodeError(`truncated at scanline ${y}: expected 4-byte prefix`));\n }\n const p0 = bytes[pos];\n const p1 = bytes[pos + 1];\n const pHi = bytes[pos + 2];\n const pLo = bytes[pos + 3];\n if (p0 === undefined || p1 === undefined || pHi === undefined || pLo === undefined) {\n return err(hdrDecodeError(`truncated at scanline ${y}`));\n }\n // biome-ignore lint/style/noNonNullAssertion: checked above\n const prefixWidth = (pHi! << 8) | pLo!;\n\n if (p0 === 0x02 && p1 === 0x02 && prefixWidth === width && width >= 8 && width <= 32767) {\n // New-RLE: 4 channels independently RLE-encoded, then interleaved\n const decoded = decodeNewRleScanline(bytes, pos + 4, width);\n if (decoded === null) {\n return err(hdrDecodeError(`RLE decode failed at scanline ${y}`));\n }\n // Copy into rgbe interleaved buffer\n const base = y * scanlineBytes;\n const channels = [decoded[0], decoded[1], decoded[2], decoded[3]];\n for (let x = 0; x < width; x++) {\n for (let ch = 0; ch < 4; ch++) {\n // biome-ignore lint/style/noNonNullAssertion: checked at allocation\n rgbe[base + x * 4 + ch] = channels[ch]![x]!;\n }\n }\n // Advance pos past the 4-byte prefix + the total RLE bytes consumed\n pos += 4 + decoded.totalBytes;\n } else {\n // Old-RLE: not supported\n return err(\n hdrDecodeError(\n 'old-RLE format is not supported; only new-RLE (32-bit_rle_rgbe) is accepted',\n ),\n );\n }\n }\n\n // Step 3: RGBE to float\n const out = new Float32Array(pixelCount * 4);\n for (let i = 0; i < pixelCount; i++) {\n const base = i * 4;\n // biome-ignore lint/style/noNonNullAssertion: checked at allocation\n const r = rgbe[base]!;\n // biome-ignore lint/style/noNonNullAssertion: checked at allocation\n const g = rgbe[base + 1]!;\n // biome-ignore lint/style/noNonNullAssertion: checked at allocation\n const b = rgbe[base + 2]!;\n // biome-ignore lint/style/noNonNullAssertion: checked at allocation\n const e = rgbe[base + 3]!;\n out[base + 3] = 1.0;\n\n if (e === 0) {\n out[base] = 0;\n out[base + 1] = 0;\n out[base + 2] = 0;\n } else {\n // f = 2^(E - 136) = ldexp(1.0, E - 128 - 8)\n // Equivalent: ldexp(1.0 / 256.0, E - 128)\n // But simpler: const f = (1.0 / 256.0) * Math.pow(2, e - 128);\n // Using ldexp: Math.pow(2, e - 136)\n const f = 2 ** (e - 136);\n out[base] = (r + 0.5) * f;\n out[base + 1] = (g + 0.5) * f;\n out[base + 2] = (b + 0.5) * f;\n }\n }\n\n return ok({ width, height, data: out });\n}\n\ninterface DecodedScanline {\n /** 4 channels, each width bytes */\n readonly 0: Uint8Array;\n readonly 1: Uint8Array;\n readonly 2: Uint8Array;\n readonly 3: Uint8Array;\n readonly totalBytes: number;\n}\n\n/**\n * Decode one scanline of new-RLE data into 4 channel arrays.\n * Returns null on failure (data underrun).\n */\nfunction decodeNewRleScanline(\n bytes: Uint8Array,\n start: number,\n width: number,\n): DecodedScanline | null {\n const channels: Uint8Array[] = [];\n let cursor = start;\n\n for (let ch = 0; ch < 4; ch++) {\n const data = new Uint8Array(width);\n let x = 0;\n while (x < width) {\n if (cursor >= bytes.length) return null;\n // biome-ignore lint/style/noNonNullAssertion: checked above\n const code = bytes[cursor]!;\n cursor++;\n if (code > 128) {\n // RLE run: next byte repeated (code - 128) times\n const count = code - 128;\n if (cursor >= bytes.length || x + count > width) return null;\n // biome-ignore lint/style/noNonNullAssertion: checked above\n const val = bytes[cursor]!;\n cursor++;\n data.fill(val, x, x + count);\n x += count;\n } else {\n // Literal run: next `code` bytes copied verbatim\n if (code === 0) continue;\n if (cursor + code > bytes.length || x + code > width) return null;\n for (let k = 0; k < code; k++) {\n // biome-ignore lint/style/noNonNullAssertion: checked above\n data[x + k] = bytes[cursor + k]!;\n }\n cursor += code;\n x += code;\n }\n }\n channels.push(data);\n }\n\n const ch0 = channels[0];\n const ch1 = channels[1];\n const ch2 = channels[2];\n const ch3 = channels[3];\n if (ch0 === undefined || ch1 === undefined || ch2 === undefined || ch3 === undefined) {\n return null; // channels should always have 4 entries\n }\n return {\n 0: ch0,\n 1: ch1,\n 2: ch2,\n 3: ch3,\n totalBytes: cursor - start,\n };\n}\n\nfunction findByte(bytes: Uint8Array, target: number, start: number): number {\n for (let i = start; i < bytes.length; i++) {\n if (bytes[i] === target) return i;\n }\n return -1;\n}\n\nfunction asciiSubstring(bytes: Uint8Array, start: number, end: number): string {\n let s = '';\n for (let i = start; i < end; i++) {\n // biome-ignore lint/style/noNonNullAssertion: in bounds\n s += String.fromCharCode(bytes[i]!);\n }\n return s;\n}\n\nfunction hdrDecodeError(reason: string): ImageError {\n return imageError({\n code: 'image-hdr-decode-failed',\n reason,\n });\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import type { DecodedImage, ImageColorSpace, ImageError } from '@forgeax/engine-types';
2
+ import type { Result } from './result.js';
3
+ /**
4
+ * Browser image decoder (plan-strategy section 3.3 + section 2.4 D Open Q-3).
5
+ *
6
+ * Uses `createImageBitmap(blob, { colorSpaceConversion: 'none' })` to keep
7
+ * the bytes in their authored color space (sRGB / linear); the runtime
8
+ * uploadTexture entry asserts `format <-> colorSpace` consistency at GPU
9
+ * upload time (plan-strategy section 2.5 D Open Q-4 (c)).
10
+ *
11
+ * Pixel readback uses an offscreen 2D canvas + `getImageData`; AI users
12
+ * never call this directly -- it is the browser-mode counterpart of
13
+ * `parseImage` (Node-mode upng / jpeg-js path) consumed by future M2b
14
+ * vite-plugin overlay paths and direct browser-mode loaders. The Node
15
+ * decoder remains the SSOT for parseImage; this file is the browser
16
+ * fallback when running inside vitest browser mode or the Vite dev server.
17
+ */
18
+ export declare function decodeImageInBrowser(bytes: Uint8Array, mime: 'image/png' | 'image/jpeg', opts?: {
19
+ colorSpace?: ImageColorSpace;
20
+ mipmap?: boolean;
21
+ }): Promise<Result<DecodedImage, ImageError>>;
22
+ //# sourceMappingURL=image-decoder-browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-decoder-browser.d.ts","sourceRoot":"","sources":["../src/image-decoder-browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEvF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,WAAW,GAAG,YAAY,EAChC,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,eAAe,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5D,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CA+D3C"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Local widening of the upng-js dynamic-import surface (the package ships
3
+ * without a usable @types entry; the d.ts in image-decoders.d.ts only adds
4
+ * the module declaration). Lists the two functions consumed by the Node
5
+ * decoder path; widening here keeps the import site free of `as any` casts
6
+ * (charter P3 explicit failure -- structural typing > escape hatches).
7
+ */
8
+ export interface UpngModule {
9
+ decode: (bytes: Uint8Array | ArrayBuffer) => {
10
+ width: number;
11
+ height: number;
12
+ depth: number;
13
+ ctype: number;
14
+ data: Uint8Array;
15
+ frames?: unknown[];
16
+ };
17
+ toRGBA8: (img: {
18
+ width: number;
19
+ height: number;
20
+ data: Uint8Array;
21
+ }) => ArrayBuffer[];
22
+ }
23
+ /**
24
+ * Local widening of the jpeg-js dynamic-import surface. Mirrors the subset
25
+ * used by the Node decoder; jpeg-js has @types/jpeg-js but we keep a local
26
+ * shape so the d.ts ambient declaration stays the SSOT for runtime resolution
27
+ * (charter P5 producer / consumer split).
28
+ */
29
+ export interface JpegModule {
30
+ decode: (bytes: Uint8Array | ArrayBuffer, opts?: {
31
+ useTArray?: boolean;
32
+ formatAsRGBA?: boolean;
33
+ }) => {
34
+ width: number;
35
+ height: number;
36
+ data: Uint8Array;
37
+ };
38
+ }
39
+ /**
40
+ * Lazy-load the upng-js Node decoder module. Browser bundlers tree-shake
41
+ * this dynamic import out when only the createImageBitmap path is reached
42
+ * at runtime; tsup external keeps the package name from being inlined.
43
+ */
44
+ export declare function loadUpng(): Promise<UpngModule>;
45
+ /**
46
+ * Lazy-load the jpeg-js Node decoder module. Same tree-shake guarantee as
47
+ * loadUpng -- browser bundles never reach this path.
48
+ */
49
+ export declare function loadJpeg(): Promise<JpegModule>;
50
+ //# sourceMappingURL=image-decoder-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-decoder-node.d.ts","sourceRoot":"","sources":["../src/image-decoder-node.ts"],"names":[],"mappings":"AAaA;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,KAAK;QAC3C,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,UAAU,CAAC;QACjB,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;KACpB,CAAC;IACF,OAAO,EAAE,CAAC,GAAG,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,CAAA;KAAE,KAAK,WAAW,EAAE,CAAC;CACtF;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,CACN,KAAK,EAAE,UAAU,GAAG,WAAW,EAC/B,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,KACnD;QACH,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,UAAU,CAAC;KAClB,CAAC;CACH;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,CAGpD;AAED;;;GAGG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,CAGpD"}
@@ -0,0 +1,15 @@
1
+ import type { Importer } from '@forgeax/engine-types';
2
+ /**
3
+ * The image {@link Importer}. Register it into an `ImporterRegistry` so the
4
+ * import runner dispatches `meta.importer === 'image'` sidecars here.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { ImporterRegistry } from '@forgeax/engine-import';
9
+ * import { imageImporter } from '@forgeax/engine-image/image-importer';
10
+ * const importers = new ImporterRegistry();
11
+ * importers.register(imageImporter);
12
+ * ```
13
+ */
14
+ export declare const imageImporter: Importer;
15
+ //# sourceMappingURL=image-importer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-importer.d.ts","sourceRoot":"","sources":["../src/image-importer.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAKV,QAAQ,EAGT,MAAM,uBAAuB,CAAC;AAitB/B;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,EAAE,QAG3B,CAAC"}