@carbonenginejs/runtime 0.1.0-alpha.4 → 0.1.0-alpha.5

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 (384) hide show
  1. package/dist/global/blue/BlueClasses.js +200 -0
  2. package/dist/global/blue/BlueClasses.js.map +1 -0
  3. package/dist/global/blue/IBlueClasses.js +79 -0
  4. package/dist/global/blue/IBlueClasses.js.map +1 -0
  5. package/dist/global/blue/IBlueDynamicResourceConstructor.js +16 -0
  6. package/dist/global/blue/IBlueDynamicResourceConstructor.js.map +1 -1
  7. package/dist/global/blue/blue.js +8 -2
  8. package/dist/global/blue/blue.js.map +1 -1
  9. package/dist/global/blue/index.js +2 -0
  10. package/dist/global/blue/index.js.map +1 -1
  11. package/dist/global/consts/index.js +0 -1
  12. package/dist/global/consts/index.js.map +1 -1
  13. package/dist/global/consts/renderContext/formats.js +26 -25
  14. package/dist/global/consts/renderContext/formats.js.map +1 -1
  15. package/dist/{trinityal/Tr2BitmapDimensions.js → global/imageio/BitmapDimensions.js} +19 -15
  16. package/dist/global/imageio/BitmapDimensions.js.map +1 -0
  17. package/dist/global/imageio/Cutout.js +28 -0
  18. package/dist/global/imageio/Cutout.js.map +1 -0
  19. package/dist/global/imageio/HostBitmap.js +1106 -0
  20. package/dist/global/imageio/HostBitmap.js.map +1 -0
  21. package/dist/global/imageio/ImageIOResult.js +99 -0
  22. package/dist/global/imageio/ImageIOResult.js.map +1 -0
  23. package/dist/global/imageio/ImageUtility.js +205 -0
  24. package/dist/global/imageio/ImageUtility.js.map +1 -0
  25. package/dist/global/imageio/LoadParameters.js +86 -0
  26. package/dist/global/imageio/LoadParameters.js.map +1 -0
  27. package/dist/global/imageio/Metadata.js +22 -0
  28. package/dist/global/imageio/Metadata.js.map +1 -0
  29. package/dist/global/imageio/index.js +8 -0
  30. package/dist/global/{consts/webgpu → imageio}/index.js.map +1 -1
  31. package/dist/global/index.js +2 -1
  32. package/dist/global/index.js.map +1 -1
  33. package/dist/global/math/color.js +1 -1
  34. package/dist/global/math/color.js.map +1 -1
  35. package/dist/global/schema/CjsSchema.js +8 -0
  36. package/dist/global/schema/CjsSchema.js.map +1 -1
  37. package/dist/index.js +12 -4
  38. package/dist/index.js.map +1 -1
  39. package/dist/resource/CjsResMan.js +47 -7
  40. package/dist/resource/CjsResMan.js.map +1 -1
  41. package/dist/resource/Tr2LightProfileRes.js +37 -0
  42. package/dist/resource/Tr2LightProfileRes.js.map +1 -1
  43. package/dist/resource/format/CjsByteWriter.js +46 -46
  44. package/dist/resource/format/CjsByteWriter.js.map +1 -1
  45. package/dist/resource/format/CjsFormat.js +7 -8
  46. package/dist/resource/format/CjsFormat.js.map +1 -1
  47. package/dist/resource/format/CjsFormatStore.js +8 -8
  48. package/dist/resource/format/CjsFormatStore.js.map +1 -1
  49. package/dist/resource/format/CjsGeometryFormat.js +114 -0
  50. package/dist/resource/format/CjsGeometryFormat.js.map +1 -0
  51. package/dist/resource/format/CjsImageFormat.js +282 -0
  52. package/dist/resource/format/CjsImageFormat.js.map +1 -0
  53. package/dist/resource/format/CjsResourceProbe.js +12 -48
  54. package/dist/resource/format/CjsResourceProbe.js.map +1 -1
  55. package/dist/resource/format/CjsStringTable.js +37 -37
  56. package/dist/resource/format/CjsStringTable.js.map +1 -1
  57. package/dist/resource/format/carbonEffect/CjsCarbonEffectReader.js +10 -10
  58. package/dist/resource/format/carbonEffect/CjsCarbonEffectReader.js.map +1 -1
  59. package/dist/resource/format/carbonEffect/CjsCarbonEffectWriter.js +37 -37
  60. package/dist/resource/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -1
  61. package/dist/resource/format/carbonEffect/carbonEffectBackendBlock.js +35 -7
  62. package/dist/resource/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
  63. package/dist/resource/format/index.js +3 -1
  64. package/dist/resource/format/index.js.map +1 -1
  65. package/dist/resource/formats/black/CjsBlackFormat.js +130 -137
  66. package/dist/resource/formats/black/CjsBlackFormat.js.map +1 -1
  67. package/dist/resource/formats/bnk/CjsBnkFormat.js +12 -19
  68. package/dist/resource/formats/bnk/CjsBnkFormat.js.map +1 -1
  69. package/dist/resource/formats/bnk/core/helpers.js +1 -3
  70. package/dist/resource/formats/bnk/core/helpers.js.map +1 -1
  71. package/dist/resource/formats/cmf/CjsCmfFormat.js +19 -82
  72. package/dist/resource/formats/cmf/CjsCmfFormat.js.map +1 -1
  73. package/dist/resource/formats/cmf/core/constants.js +1 -2
  74. package/dist/resource/formats/cmf/core/constants.js.map +1 -1
  75. package/dist/resource/formats/{stl/core/targets.js → cmf/core/flatShared.js} +9 -8
  76. package/dist/resource/formats/cmf/core/flatShared.js.map +1 -0
  77. package/dist/resource/formats/cmf/core/helpers.js +13 -13
  78. package/dist/resource/formats/cmf/core/helpers.js.map +1 -1
  79. package/dist/resource/formats/cmf/core/writer.js +24 -24
  80. package/dist/resource/formats/cmf/core/writer.js.map +1 -1
  81. package/dist/resource/formats/dds/CjsDdsFormat.js +134 -17
  82. package/dist/resource/formats/dds/CjsDdsFormat.js.map +1 -1
  83. package/dist/resource/formats/dds/core/helpers.js +125 -40
  84. package/dist/resource/formats/dds/core/helpers.js.map +1 -1
  85. package/dist/resource/formats/dxbc/CjsDxbcFormat.js +14 -16
  86. package/dist/resource/formats/dxbc/CjsDxbcFormat.js.map +1 -1
  87. package/dist/resource/formats/dxbc/core/{container.js → DxbcContainer.js} +2 -2
  88. package/dist/resource/formats/dxbc/core/DxbcContainer.js.map +1 -0
  89. package/dist/resource/formats/dxbc/core/{errors.js → DxbcReadError.js} +1 -1
  90. package/dist/resource/formats/dxbc/core/DxbcReadError.js.map +1 -0
  91. package/dist/resource/formats/dxbc/core/DxbcReader.js +1 -1
  92. package/dist/resource/formats/dxbc/core/DxbcReader.js.map +1 -1
  93. package/dist/resource/formats/dxbc/core/{program.js → DxbcShaderProgram.js} +2 -2
  94. package/dist/resource/formats/dxbc/core/DxbcShaderProgram.js.map +1 -0
  95. package/dist/resource/formats/dxbc/core/{signature.js → DxbcSignatureChunk.js} +2 -2
  96. package/dist/resource/formats/dxbc/core/DxbcSignatureChunk.js.map +1 -0
  97. package/dist/resource/formats/dxbc/core/decoder.js +2 -2
  98. package/dist/resource/formats/dxbc/core/decoder.js.map +1 -1
  99. package/dist/resource/formats/dxbc/core/helpers.js +3 -3
  100. package/dist/resource/formats/dxbc/core/helpers.js.map +1 -1
  101. package/dist/resource/formats/fbx/CjsFbxFormat.js +18 -20
  102. package/dist/resource/formats/fbx/CjsFbxFormat.js.map +1 -1
  103. package/dist/resource/formats/flac/CjsFlacFormat.js +7 -13
  104. package/dist/resource/formats/flac/CjsFlacFormat.js.map +1 -1
  105. package/dist/resource/formats/fsd/32/CjsFsd32Format.js +29 -29
  106. package/dist/resource/formats/fsd/32/CjsFsd32Format.js.map +1 -1
  107. package/dist/resource/formats/fsd/64/CjsFsd64Format.js +3 -3
  108. package/dist/resource/formats/fsd/64/CjsFsd64Format.js.map +1 -1
  109. package/dist/resource/formats/fsd/64/core/CjsFsd64Binary.js +23 -23
  110. package/dist/resource/formats/fsd/64/core/CjsFsd64Binary.js.map +1 -1
  111. package/dist/resource/formats/fsd/64/core/CjsFsd64Reader.js +8 -8
  112. package/dist/resource/formats/fsd/64/core/CjsFsd64Reader.js.map +1 -1
  113. package/dist/resource/formats/fsd/CjsFsdFormat.js +23 -23
  114. package/dist/resource/formats/fsd/CjsFsdFormat.js.map +1 -1
  115. package/dist/resource/formats/gif/CjsGifFormat.js +24 -15
  116. package/dist/resource/formats/gif/CjsGifFormat.js.map +1 -1
  117. package/dist/resource/formats/gltf/CjsGltfFormat.js +33 -98
  118. package/dist/resource/formats/gltf/CjsGltfFormat.js.map +1 -1
  119. package/dist/resource/formats/gltf/core/helpers.js +3 -12
  120. package/dist/resource/formats/gltf/core/helpers.js.map +1 -1
  121. package/dist/resource/formats/gr2/CjsGr2Format.js +27 -91
  122. package/dist/resource/formats/gr2/CjsGr2Format.js.map +1 -1
  123. package/dist/resource/formats/hlsl/CjsHlslFormat.js +22 -25
  124. package/dist/resource/formats/hlsl/CjsHlslFormat.js.map +1 -1
  125. package/dist/resource/formats/hlsl/core/carbonDescriptionToRuntime.js +1 -1
  126. package/dist/resource/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -1
  127. package/dist/resource/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js +3 -3
  128. package/dist/resource/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js.map +1 -1
  129. package/dist/resource/formats/ies/CjsIESFormat.js +29 -29
  130. package/dist/resource/formats/ies/CjsIESFormat.js.map +1 -1
  131. package/dist/resource/formats/jpeg/CjsJpegFormat.js +24 -15
  132. package/dist/resource/formats/jpeg/CjsJpegFormat.js.map +1 -1
  133. package/dist/resource/formats/jpeg/core/helpers.js +3 -5
  134. package/dist/resource/formats/jpeg/core/helpers.js.map +1 -1
  135. package/dist/resource/formats/jpeg/core/jpeg.js +58 -58
  136. package/dist/resource/formats/jpeg/core/jpeg.js.map +1 -1
  137. package/dist/resource/formats/jsonl/CjsJsonlFormat.js +3 -3
  138. package/dist/resource/formats/jsonl/CjsJsonlFormat.js.map +1 -1
  139. package/dist/resource/formats/mp3/CjsMp3Format.js +7 -14
  140. package/dist/resource/formats/mp3/CjsMp3Format.js.map +1 -1
  141. package/dist/resource/formats/mp3/core/helpers.js +3 -5
  142. package/dist/resource/formats/mp3/core/helpers.js.map +1 -1
  143. package/dist/resource/formats/mp4/CjsMp4Format.js +7 -13
  144. package/dist/resource/formats/mp4/CjsMp4Format.js.map +1 -1
  145. package/dist/resource/formats/mp4/core/helpers.js +3 -5
  146. package/dist/resource/formats/mp4/core/helpers.js.map +1 -1
  147. package/dist/resource/formats/obj/CjsObjFormat.js +92 -157
  148. package/dist/resource/formats/obj/CjsObjFormat.js.map +1 -1
  149. package/dist/resource/formats/obj/core/helpers.js +5 -113
  150. package/dist/resource/formats/obj/core/helpers.js.map +1 -1
  151. package/dist/resource/formats/ogg/CjsOggFormat.js +7 -14
  152. package/dist/resource/formats/ogg/CjsOggFormat.js.map +1 -1
  153. package/dist/resource/formats/pickle/CjsPickleFormat.js +7 -12
  154. package/dist/resource/formats/pickle/CjsPickleFormat.js.map +1 -1
  155. package/dist/resource/formats/pickle/core/CjsPickleProtocol0Reader.js +7 -7
  156. package/dist/resource/formats/pickle/core/CjsPickleProtocol0Reader.js.map +1 -1
  157. package/dist/resource/formats/pickle/core/CjsPickleProtocol4Reader.js +7 -7
  158. package/dist/resource/formats/pickle/core/CjsPickleProtocol4Reader.js.map +1 -1
  159. package/dist/resource/formats/png/CjsPngFormat.js +40 -15
  160. package/dist/resource/formats/png/CjsPngFormat.js.map +1 -1
  161. package/dist/resource/formats/png/core/helpers.js +4 -6
  162. package/dist/resource/formats/png/core/helpers.js.map +1 -1
  163. package/dist/resource/formats/red/CjsRedFormat.js +22 -28
  164. package/dist/resource/formats/red/CjsRedFormat.js.map +1 -1
  165. package/dist/resource/formats/schemabound/CjsSchemaBoundFormat.js +3 -7
  166. package/dist/resource/formats/schemabound/CjsSchemaBoundFormat.js.map +1 -1
  167. package/dist/resource/formats/schemabound/core/schemaBoundValues.js +5 -0
  168. package/dist/resource/formats/schemabound/core/schemaBoundValues.js.map +1 -1
  169. package/dist/resource/formats/sqlite/CjsSqliteFormat.js +4 -9
  170. package/dist/resource/formats/sqlite/CjsSqliteFormat.js.map +1 -1
  171. package/dist/resource/formats/static/CjsStaticFormat.js +4 -4
  172. package/dist/resource/formats/static/CjsStaticFormat.js.map +1 -1
  173. package/dist/resource/formats/stl/CjsStlFormat.js +39 -104
  174. package/dist/resource/formats/stl/CjsStlFormat.js.map +1 -1
  175. package/dist/resource/formats/stl/core/helpers.js +5 -19
  176. package/dist/resource/formats/stl/core/helpers.js.map +1 -1
  177. package/dist/resource/formats/tga/CjsTgaFormat.js +26 -15
  178. package/dist/resource/formats/tga/CjsTgaFormat.js.map +1 -1
  179. package/dist/resource/formats/tga/core/helpers.js +3 -5
  180. package/dist/resource/formats/tga/core/helpers.js.map +1 -1
  181. package/dist/resource/formats/vta/CjsVtaFormat.js +8 -15
  182. package/dist/resource/formats/vta/CjsVtaFormat.js.map +1 -1
  183. package/dist/resource/formats/wav/CjsWavFormat.js +7 -14
  184. package/dist/resource/formats/wav/CjsWavFormat.js.map +1 -1
  185. package/dist/resource/formats/wav/core/helpers.js +3 -5
  186. package/dist/resource/formats/wav/core/helpers.js.map +1 -1
  187. package/dist/resource/formats/webgl/CjsWebglFormat.js +103 -105
  188. package/dist/resource/formats/webgl/CjsWebglFormat.js.map +1 -1
  189. package/dist/resource/formats/webgl/core/{errors.js → WebglReadError.js} +1 -1
  190. package/dist/resource/formats/webgl/core/WebglReadError.js.map +1 -0
  191. package/dist/resource/formats/webgl/core/effectPackage.js +1 -1
  192. package/dist/resource/formats/webgl/core/effectPackage.js.map +1 -1
  193. package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js +3 -3
  194. package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
  195. package/dist/resource/formats/webgl/core/glsl/{DxbcGlslHelpers.js → DxbcGlslHelperRegistry.js} +2 -2
  196. package/dist/resource/formats/webgl/core/glsl/DxbcGlslHelperRegistry.js.map +1 -0
  197. package/dist/resource/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js +1 -1
  198. package/dist/resource/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js.map +1 -1
  199. package/dist/resource/formats/webgl/core/glslBackendBlock.js +1 -1
  200. package/dist/resource/formats/webgl/core/glslBackendBlock.js.map +1 -1
  201. package/dist/resource/formats/webgl/core/helpers.js.map +1 -1
  202. package/dist/resource/formats/webgpu/CjsWebgpuFormat.js +28 -29
  203. package/dist/resource/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
  204. package/dist/resource/formats/webgpu/core/{errors.js → WebgpuReadError.js} +1 -1
  205. package/dist/resource/formats/webgpu/core/WebgpuReadError.js.map +1 -0
  206. package/dist/resource/formats/webgpu/core/carbonWebgpu/validateContainer.js +1 -1
  207. package/dist/resource/formats/webgpu/core/carbonWebgpu/validateContainer.js.map +1 -1
  208. package/dist/resource/formats/webgpu/core/helpers.js +1 -1
  209. package/dist/resource/formats/webgpu/core/helpers.js.map +1 -1
  210. package/dist/resource/formats/webgpu/core/ir/lowerDxbcToIr.js +1 -1
  211. package/dist/resource/formats/webgpu/core/ir/lowerDxbcToIr.js.map +1 -1
  212. package/dist/resource/formats/webgpu/core/wgsl/buildWgslSet.js +18 -6
  213. package/dist/resource/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -1
  214. package/dist/resource/formats/webgpu/core/wgsl/lowerBindingLayout.js +39 -13
  215. package/dist/resource/formats/webgpu/core/wgsl/lowerBindingLayout.js.map +1 -1
  216. package/dist/resource/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js +16 -14
  217. package/dist/resource/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js.map +1 -1
  218. package/dist/resource/formats/webm/CjsWebmFormat.js +8 -13
  219. package/dist/resource/formats/webm/CjsWebmFormat.js.map +1 -1
  220. package/dist/resource/formats/webm/core/helpers.js +3 -5
  221. package/dist/resource/formats/webm/core/helpers.js.map +1 -1
  222. package/dist/resource/formats/webp/CjsWebpFormat.js +8 -12
  223. package/dist/resource/formats/webp/CjsWebpFormat.js.map +1 -1
  224. package/dist/resource/formats/wem/CjsWemFormat.js +9 -17
  225. package/dist/resource/formats/wem/CjsWemFormat.js.map +1 -1
  226. package/dist/resource/formats/wem/core/bitStream.js +35 -35
  227. package/dist/resource/formats/wem/core/bitStream.js.map +1 -1
  228. package/dist/resource/formats/wem/core/helpers.js +1 -3
  229. package/dist/resource/formats/wem/core/helpers.js.map +1 -1
  230. package/dist/resource/formats/yaml/CjsYamlFormat.js +28 -37
  231. package/dist/resource/formats/yaml/CjsYamlFormat.js.map +1 -1
  232. package/dist/resource/imageio/ImageIO.js +142 -0
  233. package/dist/resource/imageio/ImageIO.js.map +1 -0
  234. package/dist/resource/imageio/index.js +17 -0
  235. package/dist/resource/imageio/index.js.map +1 -0
  236. package/dist/resource/index.js +7 -0
  237. package/dist/resource/index.js.map +1 -1
  238. package/dist/resource/shader/reflection/Tr2EffectResource.js +24 -2
  239. package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
  240. package/dist/resource/shader/reflection/Tr2Pass.js +76 -5
  241. package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
  242. package/dist/resource/texture/CjsTextureArrayConstructor.js +97 -0
  243. package/dist/resource/texture/CjsTextureArrayConstructor.js.map +1 -0
  244. package/dist/resource/texture/CjsTexturePackConstructor.js +160 -0
  245. package/dist/resource/texture/CjsTexturePackConstructor.js.map +1 -0
  246. package/dist/resource/texture/CjsTexturePipelineStepArray.js +72 -0
  247. package/dist/resource/texture/CjsTexturePipelineStepArray.js.map +1 -0
  248. package/dist/resource/texture/CjsTexturePipelineStepConvert.js +73 -0
  249. package/dist/resource/texture/CjsTexturePipelineStepConvert.js.map +1 -0
  250. package/dist/resource/texture/CjsTexturePipelineStepPack.js +71 -0
  251. package/dist/resource/texture/CjsTexturePipelineStepPack.js.map +1 -0
  252. package/dist/resource/texture/CjsTexturePipelineStepResize.js +123 -0
  253. package/dist/resource/texture/CjsTexturePipelineStepResize.js.map +1 -0
  254. package/dist/resource/texture/SolidColorTextureConstructor.js +11 -1
  255. package/dist/resource/texture/SolidColorTextureConstructor.js.map +1 -1
  256. package/dist/resource/texture/Tr2ImageRes.js +100 -68
  257. package/dist/resource/texture/Tr2ImageRes.js.map +1 -1
  258. package/dist/resource/texture/Tr2TexturePipeline.js +45 -25
  259. package/dist/resource/texture/Tr2TexturePipeline.js.map +1 -1
  260. package/dist/resource/texture/Tr2TexturePipelineStepCompress.js +34 -1
  261. package/dist/resource/texture/Tr2TexturePipelineStepCompress.js.map +1 -1
  262. package/dist/resource/texture/Tr2TexturePipelineStepGenerateMips.js +30 -3
  263. package/dist/resource/texture/Tr2TexturePipelineStepGenerateMips.js.map +1 -1
  264. package/dist/resource/texture/Tr2TexturePipelineStepLimitSize.js +81 -1
  265. package/dist/resource/texture/Tr2TexturePipelineStepLimitSize.js.map +1 -1
  266. package/dist/resource/texture/Tr2TexturePipelineStepLoad.js +36 -1
  267. package/dist/resource/texture/Tr2TexturePipelineStepLoad.js.map +1 -1
  268. package/dist/resource/texture/Tr2TexturePipelineStepPack.js +146 -24
  269. package/dist/resource/texture/Tr2TexturePipelineStepPack.js.map +1 -1
  270. package/dist/resource/texture/TriTextureRes.js +151 -29
  271. package/dist/resource/texture/TriTextureRes.js.map +1 -1
  272. package/dist/resource/texture/index.js +7 -0
  273. package/dist/resource/texture/index.js.map +1 -1
  274. package/dist/resource/texture/registerTextureResources.js +83 -0
  275. package/dist/resource/texture/registerTextureResources.js.map +1 -0
  276. package/dist/resource/texture/solidColorTexture.js +10 -19
  277. package/dist/resource/texture/solidColorTexture.js.map +1 -1
  278. package/dist/sof/EveSOF.js +39 -7
  279. package/dist/sof/EveSOF.js.map +1 -1
  280. package/dist/trinity/core/Tr2GpuResourcePool/Tr2GpuResourcePool.js +2 -2
  281. package/dist/trinity/core/Tr2GpuResourcePool/Tr2GpuResourcePool.js.map +1 -1
  282. package/dist/trinity/core/Tr2ImageIOHelpers.js +80 -17
  283. package/dist/trinity/core/Tr2ImageIOHelpers.js.map +1 -1
  284. package/dist/trinity/core/Tr2RenderUtils.js +1 -1
  285. package/dist/trinity/core/Tr2TextureArray/Tr2TextureArray.js +49 -62
  286. package/dist/trinity/core/Tr2TextureArray/Tr2TextureArray.js.map +1 -1
  287. package/dist/trinity/core/Tr2TextureReference.js +114 -0
  288. package/dist/trinity/core/Tr2TextureReference.js.map +1 -0
  289. package/dist/trinity/core/device/Tr2DepthStencil.js +2 -2
  290. package/dist/trinity/core/device/Tr2DepthStencil.js.map +1 -1
  291. package/dist/trinity/core/device/Tr2RingBuffer/Tr2RingBuffer.js +1 -1
  292. package/dist/trinity/core/index.js +1 -0
  293. package/dist/trinity/core/index.js.map +1 -1
  294. package/dist/trinity/core/lighting/Tr2LightManager.js +5 -4
  295. package/dist/trinity/core/lighting/Tr2LightManager.js.map +1 -1
  296. package/dist/trinity/core/procedural/GradientTextureConstructor.js +5 -4
  297. package/dist/trinity/core/procedural/GradientTextureConstructor.js.map +1 -1
  298. package/dist/trinity/core/procedural/gradientTexture.js +10 -13
  299. package/dist/trinity/core/procedural/gradientTexture.js.map +1 -1
  300. package/dist/trinity/core/volumetrics/Tr2VolumetricsRenderer.js +1 -1
  301. package/dist/trinity/core/volumetrics/Tr2VolumetricsRenderer.js.map +1 -1
  302. package/dist/trinity/eve/EveImpactOverlay.js +102 -50
  303. package/dist/trinity/eve/EveImpactOverlay.js.map +1 -1
  304. package/dist/trinity/eve/EveModularObjectModifier.js +9 -18
  305. package/dist/trinity/eve/EveModularObjectModifier.js.map +1 -1
  306. package/dist/trinity/eve/attachment/turrets/EveTurretSet.js +175 -157
  307. package/dist/trinity/eve/attachment/turrets/EveTurretSet.js.map +1 -1
  308. package/dist/trinity/eve/attachment/turrets/EveTurretTarget.js +100 -83
  309. package/dist/trinity/eve/attachment/turrets/EveTurretTarget.js.map +1 -1
  310. package/dist/trinity/eve/child/EveChildInstancedMeshes/EveChildInstancedMesh.js +26 -20
  311. package/dist/trinity/eve/child/EveChildInstancedMeshes/EveChildInstancedMesh.js.map +1 -1
  312. package/dist/trinity/eve/child/EveChildInstancedMeshes/EveChildInstancedMeshes.js +368 -179
  313. package/dist/trinity/eve/child/EveChildInstancedMeshes/EveChildInstancedMeshes.js.map +1 -1
  314. package/dist/trinity/eve/child/EveChildMesh.js +242 -234
  315. package/dist/trinity/eve/child/EveChildMesh.js.map +1 -1
  316. package/dist/trinity/eve/child/EveChildTurret.js +57 -16
  317. package/dist/trinity/eve/child/EveChildTurret.js.map +1 -1
  318. package/dist/trinity/eve/child/EveSpaceObjectChild.js +28 -1
  319. package/dist/trinity/eve/child/EveSpaceObjectChild.js.map +1 -1
  320. package/dist/trinity/eve/index.js +2 -2
  321. package/dist/trinity/eve/overlays/EveDamageOverlay.js +5 -1
  322. package/dist/trinity/eve/overlays/EveDamageOverlay.js.map +1 -1
  323. package/dist/trinity/eve/scene/EveSpaceScene.js +234 -233
  324. package/dist/trinity/eve/scene/EveSpaceScene.js.map +1 -1
  325. package/dist/trinity/eve/scene/EveSpaceSceneRenderDriver.js +2 -0
  326. package/dist/trinity/eve/scene/EveSpaceSceneRenderDriver.js.map +1 -1
  327. package/dist/trinity/eve/spaceObject/EveSpaceObject2.js +492 -437
  328. package/dist/trinity/eve/spaceObject/EveSpaceObject2.js.map +1 -1
  329. package/dist/trinity/generated/index.js +0 -1
  330. package/dist/trinity/generated/index.js.map +1 -1
  331. package/dist/trinity/generated/trinityCore/index.js +0 -1
  332. package/dist/trinity/generated/trinityCore/index.js.map +1 -1
  333. package/dist/trinity/index.js +3 -3
  334. package/dist/trinity/particle/emitter/Tr2GpuSharedEmitter.js +10 -1
  335. package/dist/trinity/particle/emitter/Tr2GpuSharedEmitter.js.map +1 -1
  336. package/dist/trinity/shader/Tr2DataTextureManager.js +152 -66
  337. package/dist/trinity/shader/Tr2DataTextureManager.js.map +1 -1
  338. package/dist/trinity/shader/Tr2Material.js +1 -1
  339. package/dist/trinityal/Tr2HalHelperStructures/Tr2TextureSubresource.js +5 -5
  340. package/dist/trinityal/Tr2HalHelperStructures/Tr2TextureSubresource.js.map +1 -1
  341. package/dist/trinityal/index.js +1 -1
  342. package/dist/trinityal/stub/Tr2RenderContextALStub/Tr2RenderContextALStub.js +2 -2
  343. package/dist/trinityal/stub/Tr2RenderContextALStub/Tr2RenderContextALStub.js.map +1 -1
  344. package/dist/trinityal/stub/Tr2SwapChainALStub.js +45 -45
  345. package/dist/trinityal/stub/Tr2SwapChainALStub.js.map +1 -1
  346. package/dist/trinityal/stub/Tr2TextureALStub.js +170 -170
  347. package/dist/trinityal/stub/Tr2TextureALStub.js.map +1 -1
  348. package/dist/trinityal/webgpu/CjsWebgpuDevice.js +234 -164
  349. package/dist/trinityal/webgpu/CjsWebgpuDevice.js.map +1 -1
  350. package/dist/trinityal/webgpu/CjsWebgpuRenderContextAL.js +7 -0
  351. package/dist/trinityal/webgpu/CjsWebgpuRenderContextAL.js.map +1 -1
  352. package/dist/trinityal/webgpu/CjsWebgpuTextureAL.js +78 -14
  353. package/dist/trinityal/webgpu/CjsWebgpuTextureAL.js.map +1 -1
  354. package/dist/trinityal/webgpu/core/CjsWebgpuUtils.js +94 -0
  355. package/dist/trinityal/webgpu/core/CjsWebgpuUtils.js.map +1 -0
  356. package/dist/trinityal/webgpu/internal.js +1 -0
  357. package/dist/trinityal/webgpu/internal.js.map +1 -1
  358. package/docs/global/reference/classes/README.md +90 -0
  359. package/docs/resource/concepts/format-capabilities.md +3 -3
  360. package/docs/resource/formats/README.md +1 -1
  361. package/docs/resource/reference/classes/core.md +31 -1
  362. package/docs/resource/reference/classes/formats.md +7 -7
  363. package/docs/resource/reference/classes/resources.md +76 -16
  364. package/docs/trinity/reference/classes/generated.md +0 -10
  365. package/docs/trinity/reference/classes/trinity-core.md +1692 -1682
  366. package/docs/trinityal/reference/classes/README.md +0 -10
  367. package/docs/trinityal/webgpu/reference/classes/README.md +276 -266
  368. package/package.json +4 -3
  369. package/dist/global/consts/webgpu/index.js +0 -2
  370. package/dist/global/consts/webgpu/textureFormats.js +0 -180
  371. package/dist/global/consts/webgpu/textureFormats.js.map +0 -1
  372. package/dist/resource/formats/dxbc/core/container.js.map +0 -1
  373. package/dist/resource/formats/dxbc/core/errors.js.map +0 -1
  374. package/dist/resource/formats/dxbc/core/program.js.map +0 -1
  375. package/dist/resource/formats/dxbc/core/signature.js.map +0 -1
  376. package/dist/resource/formats/stl/core/targets.js.map +0 -1
  377. package/dist/resource/formats/webgl/core/errors.js.map +0 -1
  378. package/dist/resource/formats/webgl/core/glsl/DxbcGlslHelpers.js.map +0 -1
  379. package/dist/resource/formats/webgpu/core/errors.js.map +0 -1
  380. package/dist/resource/texture/texturePipelineBehavior.js +0 -332
  381. package/dist/resource/texture/texturePipelineBehavior.js.map +0 -1
  382. package/dist/trinity/generated/trinityCore/Tr2TextureReference.js +0 -40
  383. package/dist/trinity/generated/trinityCore/Tr2TextureReference.js.map +0 -1
  384. package/dist/trinityal/Tr2BitmapDimensions.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"CjsJpegFormat.js","sources":["../../../../../src/resource/formats/jpeg/CjsJpegFormat.js"],"sourcesContent":["import { asUint8Array } from \"#utils/bytes\";\nimport { CjsFormat } from \"../../format/CjsFormat.js\";\nimport {\n DEFAULT_VALUES,\n OUTPUT_IMAGE,\n OUTPUT_JSON,\n OUTPUT_RAW,\n OUTPUT_RGBA,\n inspectWithValues,\n isJPEG,\n isJPG,\n probeSupportWithValues,\n normalizeValues,\n readWithValues,\n toJsonValue\n} from \"./core/helpers.js\";\nimport { encodeJpeg } from \"./core/writer.js\";\n\nconst FORMAT_NAME = \"CjsJpegFormat\";\n\n/**\n * JPEG format profile that inspects marker and header metadata and reads\n * baseline JPEG bytes into raw, debug JSON, or RGBA payloads through the\n * in-project baseline decoder.\n */\nexport class CjsJpegFormat extends CjsFormat\n{\n #values = DEFAULT_VALUES;\n\n /**\n * Create a reusable JPEG format profile.\n *\n * @param {object} [options] Default read/inspect options.\n */\n constructor(options = {})\n {\n super();\n this.SetValues(options);\n }\n\n /**\n * Merge options into this profile.\n *\n * @param {object} [options] Values to merge.\n * @returns {CjsJpegFormat} This format profile.\n */\n SetValues(options = {})\n {\n this.#values = normalizeValues(this.#values, { inputType: \"jpeg\", ...options }, FORMAT_NAME);\n return this;\n }\n\n /**\n * Get normalized profile values with optional per-call overrides.\n *\n * @param {object} [options] Per-call values.\n * @returns {object} Normalized read values.\n */\n GetValues(options = {})\n {\n return normalizeValues(this.#values, { inputType: \"jpeg\", ...options }, FORMAT_NAME);\n }\n\n /**\n * Read JPEG bytes with this profile.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input JPEG bytes.\n * @param {object} [options] Per-call values.\n * @returns {object} GPU-free raw/debug payload for the selected emit target.\n */\n Read(input, options = {})\n {\n return readWithValues(input, this.GetValues(options), \"jpeg\");\n }\n\n /**\n * Read JPEG bytes asynchronously with this profile.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input JPEG bytes.\n * @param {object} [options] Per-call values.\n * @returns {Promise<object>} GPU-free raw/debug payload for the selected emit target.\n */\n async ReadAsync(input, options = {})\n {\n return this.Read(input, options);\n }\n\n /**\n * Write a normalized RGBA payload as baseline JPEG bytes.\n *\n * The counterpart of the `rgba` emit target, and it takes exactly what that\n * produces - so any image format in this package converts to JPEG through\n * its own reader and this writer, with no canvas and no second library.\n *\n * @param {object} payload `{ width, height, data }`, as the image formats\n * emit for `rgba`; `strideBytes` and `origin` are honoured when present.\n * @param {object} [options] `quality` 0..1 and `subsampling`.\n * @returns {Uint8Array} JPEG bytes.\n */\n Write(payload, options = {})\n {\n return encodeJpeg(payload, options);\n }\n\n /**\n * Inspect JPEG bytes without decoding image data.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input JPEG bytes.\n * @param {object} [options] Per-call values.\n * @returns {object} JPEG marker/header metadata.\n */\n Inspect(input, options = {})\n {\n return inspectWithValues(input, this.GetValues(options), \"jpeg\");\n }\n\n /**\n * Convert format output into JSON-compatible debug data.\n *\n * @param {any} value Format output.\n * @returns {any} JSON-compatible value.\n */\n ToJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * One-shot JPEG read.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input JPEG bytes.\n * @param {object} [options] Read options.\n * @returns {object} GPU-free raw/debug payload for the selected emit target.\n */\n static read(input, options = {})\n {\n return readWithValues(input, normalizeValues(DEFAULT_VALUES, { inputType: \"jpeg\", ...options }, FORMAT_NAME), \"jpeg\");\n }\n\n /**\n * One-shot asynchronous JPEG read.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input JPEG bytes.\n * @param {object} [options] Read options.\n * @returns {Promise<object>} GPU-free raw/debug payload for the selected emit target.\n */\n static async readAsync(input, options = {})\n {\n return CjsJpegFormat.read(input, options);\n }\n\n /**\n * One-shot JPEG write from a normalized RGBA payload.\n *\n * @param {object} payload `{ width, height, data }` as emitted for `rgba`.\n * @param {object} [options] `quality` 0..1 and `subsampling`.\n * @returns {Uint8Array} JPEG bytes.\n */\n static write(payload, options = {})\n {\n return encodeJpeg(payload, options);\n }\n\n /**\n * One-shot JPEG inspection.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input JPEG bytes.\n * @param {object} [options] Inspect options.\n * @returns {object} JPEG marker/header metadata.\n */\n static inspect(input, options = {})\n {\n return inspectWithValues(input, normalizeValues(DEFAULT_VALUES, { inputType: \"jpeg\", ...options }, FORMAT_NAME), \"jpeg\");\n }\n\n /**\n * One-shot JPEG support probe.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input JPEG bytes.\n * @param {object} [options] Probe options.\n * @returns {object} Support/probe report.\n */\n static probeSupport(input, options = {})\n {\n return probeSupportWithValues(input, normalizeValues(DEFAULT_VALUES, { inputType: \"jpeg\", ...options }, FORMAT_NAME), \"jpeg\");\n }\n\n /**\n * Convert format output into JSON-compatible debug data.\n *\n * @param {any} value Format output.\n * @returns {any} JSON-compatible value.\n */\n static toJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Test whether bytes look like a JPEG file.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Candidate JPEG bytes.\n * @returns {boolean} True when a JPEG SOI marker is present.\n */\n static isJPEG(input)\n {\n try\n {\n return isJPEG(asUint8Array(input, \"Image input\"));\n }\n catch\n {\n return false;\n }\n }\n\n /**\n * Test whether bytes look like a JPG/JPEG file.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Candidate JPG bytes.\n * @returns {boolean} True when a JPEG SOI marker is present.\n */\n static isJPG(input)\n {\n try\n {\n return isJPG(asUint8Array(input, \"Image input\"));\n }\n catch\n {\n return false;\n }\n }\n\n /**\n * Emit targets for this format (canonical frozen enum).\n */\n static Output = Object.freeze({\n IMAGE: OUTPUT_IMAGE,\n RGBA: OUTPUT_RGBA,\n RAW: OUTPUT_RAW,\n JSON: OUTPUT_JSON\n });\n static OUTPUT_JPEG_JSON = \"jpegJson\";\n static id = \"jpeg\";\n static mediaTypes = Object.freeze([ \"image\" ]);\n static inputs = CjsFormat.defineInputs({\n rgba: { default: true, lossy: true, options: [ \"quality\", \"subsampling\" ] }\n });\n\n static outputs = CjsFormat.defineOutputs({\n image: { decoded: true, probes: [ \"image\", \"rgba\" ] },\n rgba: { decoded: true },\n jpegJson: { role: \"debug\", probes: [ \"jpegJson\", \"raw\" ] },\n raw: { role: \"debug\", default: true, passthrough: true }\n });\n static extensions = Object.freeze([ \".jpg\", \".jpeg\" ]);\n}\n\nexport default CjsJpegFormat;\n"],"names":["FORMAT_NAME","CjsJpegFormat","CjsFormat","DEFAULT_VALUES","constructor","options","SetValues","normalizeValues","inputType","GetValues","Read","input","readWithValues","ReadAsync","Write","payload","encodeJpeg","Inspect","inspectWithValues","ToJSON","value","toJsonValue","read","readAsync","write","inspect","probeSupport","probeSupportWithValues","toJSON","isJPEG","asUint8Array","isJPG","Output","Object","freeze","IMAGE","OUTPUT_IMAGE","RGBA","OUTPUT_RGBA","RAW","OUTPUT_RAW","JSON","OUTPUT_JSON","OUTPUT_JPEG_JSON","id","mediaTypes","inputs","defineInputs","rgba","default","lossy","outputs","defineOutputs","image","decoded","probes","jpegJson","role","raw","passthrough","extensions"],"mappings":";;;;;;;AAkBA,MAAMA,WAAW,GAAG,eAAe;;AAEnC;AACA;AACA;AACA;AACA;AACO,MAAMC,aAAa,SAASC,SAAS,CAC5C;EACI,OAAO,GAAGC,cAAc;;AAExB;AACJ;AACA;AACA;AACA;AACIC,EAAAA,WAAWA,CAACC,OAAO,GAAG,EAAE,EACxB;AACI,IAAA,KAAK,EAAE;AACP,IAAA,IAAI,CAACC,SAAS,CAACD,OAAO,CAAC;AAC3B,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACA;AACIC,EAAAA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AC;AAEF,EAAA,OAAO8C,OAAO,GAAGjD,SAAS,CAACkD,aAAa,CAAC;AACrCC,IAAAA,KAAK,EAAE;AAAEC,MAAAA,OAAO,EAAE,IAAI;AAAEC,MAAAA,MAAM,EAAE,CAAE,OAAO,EAAE,MAAM;KAAI;AACrDP,IAAAA,IAAI,EAAE;AAAEM,MAAAA,OAAO,EAAE;KAAM;AACvBE,IAAAA,QAAQ,EAAE;AAAEC,MAAAA,IAAI,EAAE,OAAO;AAAEF,MAAAA,MAAM,EAAE,CAAE,UAAU,EAAE,KAAK;KAAI;AAC1DG,IAAAA,GAAG,EAAE;AAAED,MAAAA,IAAI,EAAE,OAAO;AAAER,MAAAA,OAAO,EAAE,IAAI;AAAEU,MAAAA,WAAW,EAAE;AAAK;AAC3D,GAAC,CAAC;EACF,OAAOC,UAAU,GAAG3B,MAAM,CAACC,MAAM,CAAC,CAAE,MAAM,EAAE,OAAO,CAAE,CAAC;AAC1D;;;;"}
1
+ {"version":3,"file":"CjsJpegFormat.js","sources":["../../../../../src/resource/formats/jpeg/CjsJpegFormat.js"],"sourcesContent":["import { asUint8Array } from \"#utils/bytes\";\nimport { CjsFormat } from \"../../format/CjsFormat.js\";\nimport { CjsImageFormat } from \"../../format/CjsImageFormat.js\";\nimport {\n DEFAULT_VALUES,\n OUTPUT_IMAGE,\n OUTPUT_JSON,\n OUTPUT_RAW,\n OUTPUT_RGBA,\n inspectWithValues,\n isJPEG,\n isJPG,\n probeSupportWithValues,\n normalizeValues,\n readWithValues,\n toJsonValue\n} from \"./core/helpers.js\";\nimport { encodeJpeg } from \"./core/writer.js\";\n\nconst FORMAT_NAME = \"CjsJpegFormat\";\n\n/**\n * JPEG format profile that inspects marker and header metadata and reads\n * baseline JPEG bytes into raw, debug JSON, or RGBA payloads through the\n * in-project baseline decoder.\n */\nexport class CjsJpegFormat extends CjsImageFormat\n{\n _values = DEFAULT_VALUES;\n\n /**\n * Create a reusable JPEG format profile.\n *\n * @param {object} [options] Default read/inspect options.\n */\n constructor(options = {})\n {\n super();\n this.SetValues(options);\n }\n\n /**\n * Merge options into this profile.\n *\n * @param {object} [options] Values to merge.\n * @returns {CjsJpegFormat} This format profile.\n */\n SetValues(options = {})\n {\n this._values = normalizeValues(this._values, { inputType: \"jpeg\", ...options }, FORMAT_NAME);\n return this;\n }\n\n /**\n * Get normalized profile values with optional per-call overrides.\n *\n * @param {object} [options] Per-call values.\n * @returns {object} Normalized read values.\n */\n GetValues(options = {})\n {\n return normalizeValues(this._values, { inputType: \"jpeg\", ...options }, FORMAT_NAME);\n }\n\n /**\n * Read JPEG bytes with this profile.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input JPEG bytes.\n * @param {object} [options] Per-call values.\n * @returns {object} GPU-free raw/debug payload for the selected emit target.\n */\n Read(input, options = {})\n {\n return readWithValues(input, this.GetValues(options), \"jpeg\");\n }\n\n /**\n * Read JPEG bytes asynchronously with this profile.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input JPEG bytes.\n * @param {object} [options] Per-call values.\n * @returns {Promise<object>} GPU-free raw/debug payload for the selected emit target.\n */\n async ReadAsync(input, options = {})\n {\n return this.Read(input, options);\n }\n\n /**\n * Write a normalized RGBA payload as baseline JPEG bytes.\n *\n * The counterpart of the `rgba` emit target, and it takes exactly what that\n * produces - so any image format in this package converts to JPEG through\n * its own reader and this writer, with no canvas and no second library.\n *\n * @param {object} payload `{ width, height, data }`, as the image formats\n * emit for `rgba`; `strideBytes` and `origin` are honoured when present.\n * @param {object} [options] `quality` 0..1 and `subsampling`.\n * @returns {Uint8Array} JPEG bytes.\n */\n Write(payload, options = {})\n {\n return encodeJpeg(payload, options);\n }\n\n /**\n * Inspect JPEG bytes without decoding image data.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input JPEG bytes.\n * @param {object} [options] Per-call values.\n * @returns {object} JPEG marker/header metadata.\n */\n Inspect(input, options = {})\n {\n return inspectWithValues(input, this.GetValues(options), \"jpeg\");\n }\n\n /**\n * Convert format output into JSON-compatible debug data.\n *\n * @param {any} value Format output.\n * @returns {any} JSON-compatible value.\n */\n ToJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * One-shot JPEG read.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input JPEG bytes.\n * @param {object} [options] Read options.\n * @returns {object} GPU-free raw/debug payload for the selected emit target.\n */\n static read(input, options = {})\n {\n return readWithValues(input, normalizeValues(DEFAULT_VALUES, { inputType: \"jpeg\", ...options }, FORMAT_NAME), \"jpeg\");\n }\n\n /**\n * One-shot asynchronous JPEG read.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input JPEG bytes.\n * @param {object} [options] Read options.\n * @returns {Promise<object>} GPU-free raw/debug payload for the selected emit target.\n */\n static async readAsync(input, options = {})\n {\n return CjsJpegFormat.read(input, options);\n }\n\n /**\n * One-shot JPEG write from a normalized RGBA payload.\n *\n * @param {object} payload `{ width, height, data }` as emitted for `rgba`.\n * @param {object} [options] `quality` 0..1 and `subsampling`.\n * @returns {Uint8Array} JPEG bytes.\n */\n static write(payload, options = {})\n {\n return encodeJpeg(payload, options);\n }\n\n /**\n * One-shot JPEG inspection.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input JPEG bytes.\n * @param {object} [options] Inspect options.\n * @returns {object} JPEG marker/header metadata.\n */\n static inspect(input, options = {})\n {\n return inspectWithValues(input, normalizeValues(DEFAULT_VALUES, { inputType: \"jpeg\", ...options }, FORMAT_NAME), \"jpeg\");\n }\n\n /**\n * One-shot JPEG support probe.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input JPEG bytes.\n * @param {object} [options] Probe options.\n * @returns {object} Support/probe report.\n */\n static probeSupport(input, options = {})\n {\n return probeSupportWithValues(input, normalizeValues(DEFAULT_VALUES, { inputType: \"jpeg\", ...options }, FORMAT_NAME), \"jpeg\");\n }\n\n /**\n * Convert format output into JSON-compatible debug data.\n *\n * @param {any} value Format output.\n * @returns {any} JSON-compatible value.\n */\n static toJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Test whether bytes look like a JPEG file.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Candidate JPEG bytes.\n * @returns {boolean} True when a JPEG SOI marker is present.\n */\n static isJPEG(input)\n {\n try\n {\n return isJPEG(asUint8Array(input, \"Image input\"));\n }\n catch\n {\n return false;\n }\n }\n\n /**\n * Test whether bytes look like a JPG/JPEG file.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Candidate JPG bytes.\n * @returns {boolean} True when a JPEG SOI marker is present.\n */\n static isJPG(input)\n {\n try\n {\n return isJPG(asUint8Array(input, \"Image input\"));\n }\n catch\n {\n return false;\n }\n }\n\n /**\n * Emit targets for this format (canonical frozen enum).\n */\n static id = \"CjsJpegFormat\";\n static mediaTypes = [ \"image\" ];\n static inputs = CjsFormat.defineInputs({\n rgba: { default: true, lossy: true, options: [ \"quality\", \"subsampling\" ] }\n });\n\n static outputs = CjsFormat.defineOutputs({\n image: { decoded: true, probes: [ \"image\", \"rgba\" ] },\n rgba: { decoded: true },\n jpegJson: { role: \"debug\", probes: [ \"jpegJson\", \"raw\" ] },\n raw: { role: \"debug\", default: true, passthrough: true }\n });\n /**\n * Fill a HostBitmap through this format's RGBA8 output, for Carbon's ImageIO\n * registry (`CjsJpegFormat.carbon`). See CjsImageFormat.readImageFromRgbaPayload.\n *\n * @param {Uint8Array|ArrayBuffer} input Image bytes.\n * @param {object} _loadParameters Load parameters; a single-mip image skips nothing.\n * @param {object} bitmap Destination HostBitmap.\n * @param {object|null} [metadata] Optional Metadata out.\n * @returns {object} ImageIOResult.\n */\n static readImageNative(input, _loadParameters, bitmap, metadata = null)\n {\n return this.readImageFromRgbaPayload(this.read(input, { emit: \"rgba\" }), bitmap, metadata);\n }\n\n static extensions = [ \".jpg\", \".jpeg\" ];\n}\n\nexport default CjsJpegFormat;\n"],"names":["FORMAT_NAME","CjsJpegFormat","CjsImageFormat","_values","DEFAULT_VALUES","constructor","options","SetValues","normalizeValues","inputType","GetValues","Read","input","readWithValues","ReadAsync","Write","payload","encodeJpeg","Inspect","inspectWithValues","ToJSON","value","toJsonValue","read","readAsync","write","inspect","probeSupport","probeSupportWithValues","toJSON","isJPEG","asUint8Array","isJPG","id","mediaTypes","inputs","CjsFormat","defineInputs","rgba","default","lossy","outputs","defineOutputs","image","decoded","probes","jpegJson","role","raw","passthrough","readImageNative","_loadParameters","bitmap","metadata","readImageFromRgbaPayload","emit","extensions"],"mappings":";;;;;;;;AAmBA,MAAMA,WAAW,GAAG,eAAe;;AAEnC;AACA;AACA;AACA;AACA;AACO,MAAMC,aAAa,SAASC,cAAc,CACjD;AACIC,EAAAA,OAAO,GAAGC,cAAc;;AAExB;AACJ;AACA;AACA;AACA;AACIC,EAAAA,WAAWA,CAACC,OAAO,GAAG,EAAE,EACxB;AACI,IAAA,KAAK,EAAE;AACP,IAAA,IAAI,CAACC,SAAS,CAACD,OAAO,CAAC;AAC3B,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACA;AACIC,EAAAA,SAASA,CAACD,OAAO,GAAG,EAAE,EACtB;IACI,IAAI,CAACH,OAAO,GAAGK,eAAe,CAAC,IAAI,CAACL,OAAO,EAAE;AAAEM,MAAAA,SAAS,EAAE,MAAM;MAAE,GAAGH;KAAS,EAAEN,WAAW,CAAC;AAC5F,IAAA,OAAO,IAAI;AACf,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACA;AACIU,EAAAA,SAASA,CAACJ,OAAO,GAAG,EAAE,EACtB;AACI,IAAA,OAAOE,eAAe,CAAC,IAAI,CAACL,OAAO,EAAE;AAAEM,MAAAA,SAAS,EAAE,MAAM;MAAE,GAAGH;KAAS,EAAEN,WAAW,CAAC;AACxF,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACIW,EAAAA,IAAIA,CAACC,KAAK,EAAEN,OAAO,GAAG,EAAE,EACxB;AACI,IAAA,OAAOO,cAAc,CAACD,KAAK,EAAE,IAAI,CAACF,SAAS,CAACJ,OAAO,CAAC,EAA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@@ -5,7 +5,6 @@ import { canDecodeJpeg, decodeJpegToRgba } from './jpeg.js';
5
5
  const OUTPUT_IMAGE = "image";
6
6
  const OUTPUT_RGBA = "rgba";
7
7
  const OUTPUT_RAW = "raw";
8
- const OUTPUT_JSON = "json";
9
8
  const DEFAULT_VALUES = Object.freeze({
10
9
  emit: OUTPUT_RAW,
11
10
  inputType: "",
@@ -44,8 +43,7 @@ function normalizeInputType(inputType) {
44
43
  /** Normalizes the requested output representation for the JPEG format reader. */
45
44
  function normalizeEmit(emit, inputType, readerName) {
46
45
  if (emit === undefined || emit === null) return OUTPUT_RAW;
47
- if (emit === OUTPUT_JSON && inputType) return DEBUG_OUTPUTS[inputType] || OUTPUT_JSON;
48
- if ([OUTPUT_IMAGE, OUTPUT_RGBA, OUTPUT_RAW, OUTPUT_JSON].includes(emit)) return emit;
46
+ if ([OUTPUT_IMAGE, OUTPUT_RGBA, OUTPUT_RAW].includes(emit)) return emit;
49
47
  if (Object.values(DEBUG_OUTPUTS).includes(emit)) return emit;
50
48
  throw new TypeError(`${readerName}: unknown emit value ${JSON.stringify(emit)}`);
51
49
  }
@@ -124,7 +122,7 @@ function readWithValues(input, values = DEFAULT_VALUES, expectedType = "") {
124
122
  bytes
125
123
  };
126
124
  }
127
- if (values.emit === OUTPUT_JSON || values.emit === DEBUG_OUTPUTS[metadata.sourceFormat]) {
125
+ if (values.emit === DEBUG_OUTPUTS[metadata.sourceFormat]) {
128
126
  return metadata;
129
127
  }
130
128
  if ((values.emit === OUTPUT_RGBA || values.emit === OUTPUT_IMAGE) && metadata.sourceFormat === "jpeg") {
@@ -244,5 +242,5 @@ function ascii(bytes, offset, length) {
244
242
  return String.fromCharCode(...bytes.subarray(offset, offset + length));
245
243
  }
246
244
 
247
- export { DEFAULT_VALUES, OUTPUT_IMAGE, OUTPUT_JSON, OUTPUT_RAW, OUTPUT_RGBA, inspectBytes, inspectWithValues, isJPEG, isJPG, normalizeEmit, normalizeInputType, normalizeValues, probeSupportWithValues, readWithValues };
245
+ export { DEFAULT_VALUES, OUTPUT_IMAGE, OUTPUT_RAW, OUTPUT_RGBA, inspectBytes, inspectWithValues, isJPEG, isJPG, normalizeEmit, normalizeInputType, normalizeValues, probeSupportWithValues, readWithValues };
248
246
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sources":["../../../../../../src/resource/formats/jpeg/core/helpers.js"],"sourcesContent":["import { toJsonWithByteSummary as toJsonValue } from \"../../../format/jsonPolicies.js\";\nimport { capitalizeFormatId, foreignImageRecord, identifyImageBytes, imageMimeType, isJPEG, rawVariant } from \"../../../format/imageSignatures.js\";\n\n// The container sniffer is shared; re-exported because the format class\n// imports it from this module.\nexport { isJPEG };\nimport { asUint8Array, readU16BE, readU16LE, readU32BE, readU32LE } from \"#utils/bytes\";\nexport const OUTPUT_IMAGE = \"image\";\nexport const OUTPUT_TEXTURE = \"texture\";\nexport const OUTPUT_RGBA = \"rgba\";\nexport const OUTPUT_RAW = \"raw\";\nexport const OUTPUT_JSON = \"json\";\n\nimport { canDecodeJpeg, decodeJpegToRgba } from \"./jpeg.js\";\n\nexport const DEFAULT_VALUES = Object.freeze({\n emit: OUTPUT_RAW,\n inputType: \"\",\n source: \"\"\n});\n\nconst DEBUG_OUTPUTS = Object.freeze({\n png: \"pngJson\",\n jpeg: \"jpegJson\",\n jpg: \"jpegJson\",\n tga: \"tgaJson\",\n dds: \"ddsJson\"\n});\n\n\n/**\n * Normalizes reader options against their supported defaults for the JPEG format\n * reader.\n */\nexport function normalizeValues(base = DEFAULT_VALUES, options = {}, readerName = \"CjsImageFormat\")\n{\n const values = { ...DEFAULT_VALUES, ...(base || {}), ...(options || {}) };\n values.inputType = normalizeInputType(values.inputType);\n values.emit = normalizeEmit(values.emit, values.inputType, readerName);\n return values;\n}\n\n/** Normalizes the requested input representation for the JPEG format reader. */\nexport function normalizeInputType(inputType)\n{\n if (!inputType) return \"\";\n const value = String(inputType).replace(/^\\./u, \"\").toLowerCase();\n return value === \"jpg\" ? \"jpeg\" : value;\n}\n\n/** Normalizes the requested output representation for the JPEG format reader. */\nexport function normalizeEmit(emit, inputType, readerName)\n{\n if (emit === undefined || emit === null) return OUTPUT_RAW;\n if (emit === OUTPUT_JSON && inputType) return DEBUG_OUTPUTS[inputType] || OUTPUT_JSON;\n if ([ OUTPUT_IMAGE, OUTPUT_RGBA, OUTPUT_RAW, OUTPUT_JSON ].includes(emit)) return emit;\n if (Object.values(DEBUG_OUTPUTS).includes(emit)) return emit;\n throw new TypeError(`${readerName}: unknown emit value ${JSON.stringify(emit)}`);\n}\n\n/** Returns a byte view over the supplied binary input for the JPEG format reader. */\n/** Inspects input using normalized format options for the JPEG format reader. */\nexport function inspectWithValues(input, values = DEFAULT_VALUES, expectedType = \"\")\n{\n const bytes = asUint8Array(input, \"Image input\");\n const detected = inspectBytes(bytes);\n const sourceFormat = expectedType || values.inputType || detected.sourceFormat;\n\n if (expectedType && detected.sourceFormat && detected.sourceFormat !== expectedType)\n {\n throw new TypeError(`CjsFormat${capitalizeFormatId(expectedType)}: expected ${expectedType}, got ${detected.sourceFormat}`);\n }\n\n return {\n payloadType: sourceFormat === \"dds\" ? \"texture\" : \"image\",\n mediaTypes: sourceFormat === \"dds\" ? [ \"texture\", \"image\" ] : [ \"image\" ],\n sourceFormat,\n byteLength: bytes.byteLength,\n ...detected\n };\n}\n\n/**\n * Reports whether input is supported under normalized format options for the\n * JPEG format reader.\n */\nexport function probeSupportWithValues(input, values = DEFAULT_VALUES, expectedType = \"\")\n{\n try\n {\n const metadata = inspectWithValues(input, values, expectedType);\n const canDecode = metadata.sourceFormat === \"jpeg\" && canDecodeJpeg(metadata);\n const variants = [\n { kind: \"rgba\", payloadType: \"rgba\", codec: \"rgba8unorm\", supported: canDecode, reason: canDecode ? \"\" : jpegDecodeReason(metadata)},\n rawVariant(metadata)\n ];\n\n return {\n format: metadata.sourceFormat,\n source: values.source || \"buffer\",\n supported: metadata.sourceFormat ? (variants.some(variant => variant.supported && variant.kind === \"rgba\") ? \"full\" : \"partial\") : \"none\",\n confidence: metadata.sourceFormat ? 1 : 0,\n preferredOutput: variants.find(v => v.supported)?.kind || \"\",\n reason: metadata.sourceFormat ? \"Container/header recognized.\" : \"Unrecognized image format.\",\n metadata,\n variants,\n warnings: [],\n errors: []\n };\n }\n catch (error)\n {\n return {\n format: expectedType || values.inputType || \"\",\n source: values.source || \"buffer\",\n supported: \"none\",\n confidence: 0,\n preferredOutput: \"\",\n reason: error.message,\n metadata: null,\n variants: [],\n warnings: [],\n errors: [ error.message ]\n };\n }\n}\n\n/** Reads input using normalized format options for the JPEG format reader. */\nexport function readWithValues(input, values = DEFAULT_VALUES, expectedType = \"\")\n{\n const bytes = asUint8Array(input, \"Image input\");\n const metadata = inspectWithValues(bytes, values, expectedType);\n\n if (values.emit === OUTPUT_RAW)\n {\n return {\n payloadType: \"raw\",\n sourceFormat: metadata.sourceFormat,\n mimeType: imageMimeType(metadata.sourceFormat),\n metadata,\n bytes\n };\n }\n\n if (values.emit === OUTPUT_JSON || values.emit === DEBUG_OUTPUTS[metadata.sourceFormat])\n {\n return metadata;\n }\n\n if ((values.emit === OUTPUT_RGBA || values.emit === OUTPUT_IMAGE) && metadata.sourceFormat === \"jpeg\")\n {\n if (!canDecodeJpeg(metadata))\n {\n const error = new Error(`jpeg: ${jpegDecodeReason(metadata)}`);\n error.code = \"CJS_FORMAT_OUTPUT_NOT_SUPPORTED\";\n throw error;\n }\n return decodeJpegToRgba(bytes, metadata);\n }\n\n const error = new Error(`${metadata.sourceFormat}: emit \"${values.emit}\" is not implemented yet`);\n error.code = \"CJS_FORMAT_OUTPUT_NOT_IMPLEMENTED\";\n error.sourceFormat = metadata.sourceFormat;\n error.emit = values.emit;\n throw error;\n}\n\n\n\n/** Converts a parsed payload into a JSON-safe value for the JPEG format reader. */\n/** The shared JSON policy for this reader, under the name its callers use. */\nexport { toJsonValue };\n\n/**\n * Inspects the supplied bytes without decoding their payload for the JPEG format\n * reader.\n */\nexport function inspectBytes(bytes)\n{\n const sourceFormat = identifyImageBytes(bytes);\n return sourceFormat === \"jpeg\" ? inspectJPEG(bytes) : foreignImageRecord(sourceFormat);\n}\n\n\n\n/**\n * Reports whether the supplied bytes begin with a JPEG signature accepted as JPG\n * for the JPEG format reader.\n */\nexport function isJPG(bytes)\n{\n return isJPEG(bytes);\n}\n\n\n\n\nfunction inspectJPEG(bytes)\n{\n let offset = 2;\n let frame = null;\n const summary = {\n appMarkerCount: 0,\n commentCount: 0,\n hasExif: false,\n hasIccProfile: false\n };\n while (offset + 9 < bytes.byteLength)\n {\n if (bytes[offset] !== 0xff)\n {\n offset++;\n continue;\n }\n const marker = bytes[offset + 1], length = readU16BE(bytes, offset + 2);\n const dataStart = offset + 4;\n const dataEnd = offset + 2 + length;\n if (marker >= 0xe0 && marker <= 0xef)\n {\n summary.appMarkerCount++;\n if (marker === 0xe1 && ascii(bytes, dataStart, Math.min(6, dataEnd - dataStart)) === \"Exif\\0\\0\") summary.hasExif = true;\n if (marker === 0xe2 && ascii(bytes, dataStart, Math.min(12, dataEnd - dataStart)) === \"ICC_PROFILE\\0\") summary.hasIccProfile = true;\n }\n else if (marker === 0xfe)\n {\n summary.commentCount++;\n }\n if ([ 0xc0, 0xc1, 0xc2, 0xc3 ].includes(marker))\n {\n frame = {\n sourceFormat: \"jpeg\",\n width: readU16BE(bytes, offset + 7),\n height: readU16BE(bytes, offset + 5),\n channels: bytes[offset + 9],\n components: bytes[offset + 9],\n precision: bytes[offset + 4],\n marker,\n progressive: marker === 0xc2 || marker === 0xc3,\n pixelFormat: \"jpeg-ycbcr\",\n isCompressed: true\n };\n }\n if (marker === 0xda && frame)\n {\n const scanStart = offset + 4;\n const scanComponents = bytes[scanStart];\n const spectralStart = bytes[scanStart + 1 + scanComponents * 2];\n const spectralEnd = bytes[scanStart + 2 + scanComponents * 2];\n const successive = bytes[scanStart + 3 + scanComponents * 2];\n return {\n ...frame,\n ...summary,\n scanComponents,\n spectralStart,\n spectralEnd,\n successive,\n progressive: frame.progressive || spectralStart !== 0 || spectralEnd !== 63 || successive !== 0\n };\n }\n offset += Math.max(length + 2, 2);\n }\n return frame ? { ...frame, ...summary } : { sourceFormat: \"jpeg\", width: 0, height: 0, channels: 0, pixelFormat: \"jpeg\", isCompressed: true, ...summary };\n}\n\nfunction jpegDecodeReason(metadata)\n{\n if (metadata.sourceFormat !== \"jpeg\") return `${metadata.sourceFormat.toUpperCase()} RGBA decode is not implemented yet.`;\n if (metadata.progressive) return \"Progressive JPEG software decode is not implemented yet.\";\n if (metadata.marker !== undefined && metadata.marker !== 0xc0 && metadata.marker !== 0xc1)\n {\n return \"Only sequential baseline JPEG frames are supported by the software decoder.\";\n }\n if (metadata.precision !== undefined && metadata.precision !== 8)\n {\n return `JPEG sample precision ${metadata.precision} is not supported by the software decoder.`;\n }\n if (metadata.components > 3) return \"CMYK/YCCK JPEG software decode is not implemented yet.\";\n return \"JPEG baseline frame metadata is incomplete or unsupported.\";\n}\n\n\n\n\nfunction ascii(bytes, offset, length)\n{\n return String.fromCharCode(...bytes.subarray(offset, offset + length));\n}\n\n\n"],"names":["OUTPUT_IMAGE","OUTPUT_RGBA","OUTPUT_RAW","OUTPUT_JSON","DEFAULT_VALUES","Object","freeze","emit","inputType","source","DEBUG_OUTPUTS","png","jpeg","jpg","tga","dds","normalizeValues","base","options","readerName","values","normalizeInputType","normalizeEmit","value","String","replace","toLowerCase","undefined","includes","TypeError","JSON","stringify","inspectWithValues","input","expectedType","bytes","asUint8Array","detected","inspectBytes","sourceFormat","capitalizeFormatId","payloadType","mediaTypes","byteLength","probeSupportWithValues","metadata","canDecode","canDecodeJpeg","variants","kind","codec","supported","reason","jpegDecodeReason","rawVariant","format","some","variant","confidence","preferredOutput","find","v","warnings","errors","error","message","readWithValues","mimeType","imageMimeType","Error","code","decodeJpegToRgba","identifyImageBytes","inspectJPEG","foreignImageRecord","isJPG","isJPEG","offset","frame","summary","appMarkerCount","commentCount","hasExif","hasIccProfile","marker","length","readU16BE","dataStart","dataEnd","ascii","Math","min","width","height","channels","components","precision","progressive","pixelFormat","isCompressed","scanStart","scanComponents","spectralStart","spectralEnd","successive","max","toUpperCase","fromCharCode","subarray"],"mappings":";;;;AAOO,MAAMA,YAAY,GAAG;AAErB,MAAMC,WAAW,GAAG;AACpB,MAAMC,UAAU,GAAG;AACnB,MAAMC,WAAW,GAAG;MAIdC,cAAc,GAAGC,MAAM,CAACC,MAAM,CAAC;AACxCC,EAAAA,IAAI,EAAEL,UAAU;AAChBM,EAAAA,SAAS,EAAE,EAAE;AACbC,EAAAA,MAAM,EAAE;AACZ,CAAC;AAED,MAAMC,aAAa,GAAGL,MAAM,CAACC,MAAM,CAAC;AAChCK,EAAAA,GAAG,EAAE,SAAS;AACdC,EAAAA,IAAI,EAAE,UAAU;AAChBC,EAAAA,GAAG,EAAE,UAAU;AACfC,EAAAA,GAAG,EAAE,SAAS;AACdC,EAAAA,GAAG,EAAE;AACT,CAAC,CAAC;;AAGF;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAACC,IAAI,GAAGb,cAAc,EAAEc,OAAO,GAAG,EAAE,EAAEC,UAAU,GAAG,gBAAgB,EAClG;AACI,EAAA,MAAMC,MAAM,GAAG;AAAE,IAAA,GAAGhB,cAAc;AAAE,IAAA,IAAIa,IAAI,IAAI,EAAE,CAAC;IAAE,IAAIC,OAAO,IAAI,EAAE;GAAG;EACzEE,MAAM,CAACZ,SAAS,GAAGa,kBAAkB,CAACD,MAAM,CAACZ,SAAS,CAAC;AACvDY,EAAAA,MAAM,CAACb,IAAI,GAAGe,aAAa,CAACF,MAAM,CAACb,IAAI,EAAEa,MAAM,CAACZ,SAAS,EAAEW,UAAU,CAAC;AACtE,EAAA,OAAOC,MAAM;AACjB;;AAEA;AACO,SAASC,kBAAkBA,CAACb,SAAS,EAC5C;AACI,EAAA,IAAI,CAACA,SAAS,EAAE,OAAO,EAAE;AACzB,EAAA,MAAMe,KAAK,GAAGC,MAAM,CAAChB,SAA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AAA;EACA,IAAIvC,QAAQ,CAACmD,SAAS,KAAKrE,SAAS,IAAIkB,QAAQ,CAACmD,SAAS,KAAK,CAAC,EAChE;AACI,IAAA,OAAO,CAAA,sBAAA,EAAyBnD,QAAQ,CAACmD,SAAS,CAAA,0CAAA,CAA4C;AAClG,EAAA;AACA,EAAA,IAAInD,QAAQ,CAACkD,UAAU,GAAG,CAAC,EAAE,OAAO,wDAAwD;AAC5F,EAAA,OAAO,4DAA4D;AACvE;AAKA,SAASN,KAAKA,CAACtD,KAAK,EAAE0C,MAAM,EAAEQ,MAAM,EACpC;AACI,EAAA,OAAO7D,MAAM,CAACmF,YAAY,CAAC,GAAGxE,KAAK,CAACyE,QAAQ,CAAC/B,MAAM,EAAEA,MAAM,GAAGQ,MAAM,CAAC,CAAC;AAC1E;;;;"}
1
+ {"version":3,"file":"helpers.js","sources":["../../../../../../src/resource/formats/jpeg/core/helpers.js"],"sourcesContent":["import { toJsonWithByteSummary as toJsonValue } from \"../../../format/jsonPolicies.js\";\nimport { capitalizeFormatId, foreignImageRecord, identifyImageBytes, imageMimeType, isJPEG, rawVariant } from \"../../../format/imageSignatures.js\";\n\n// The container sniffer is shared; re-exported because the format class\n// imports it from this module.\nexport { isJPEG };\nimport { asUint8Array, readU16BE, readU16LE, readU32BE, readU32LE } from \"#utils/bytes\";\nexport const OUTPUT_IMAGE = \"image\";\nexport const OUTPUT_TEXTURE = \"texture\";\nexport const OUTPUT_RGBA = \"rgba\";\nexport const OUTPUT_RAW = \"raw\";\nexport const OUTPUT_JSON = \"json\";\n\nimport { canDecodeJpeg, decodeJpegToRgba } from \"./jpeg.js\";\n\nexport const DEFAULT_VALUES = Object.freeze({\n emit: OUTPUT_RAW,\n inputType: \"\",\n source: \"\"\n});\n\nconst DEBUG_OUTPUTS = Object.freeze({\n png: \"pngJson\",\n jpeg: \"jpegJson\",\n jpg: \"jpegJson\",\n tga: \"tgaJson\",\n dds: \"ddsJson\"\n});\n\n\n/**\n * Normalizes reader options against their supported defaults for the JPEG format\n * reader.\n */\nexport function normalizeValues(base = DEFAULT_VALUES, options = {}, readerName = \"CjsImageFormat\")\n{\n const values = { ...DEFAULT_VALUES, ...(base || {}), ...(options || {}) };\n values.inputType = normalizeInputType(values.inputType);\n values.emit = normalizeEmit(values.emit, values.inputType, readerName);\n return values;\n}\n\n/** Normalizes the requested input representation for the JPEG format reader. */\nexport function normalizeInputType(inputType)\n{\n if (!inputType) return \"\";\n const value = String(inputType).replace(/^\\./u, \"\").toLowerCase();\n return value === \"jpg\" ? \"jpeg\" : value;\n}\n\n/** Normalizes the requested output representation for the JPEG format reader. */\nexport function normalizeEmit(emit, inputType, readerName)\n{\n if (emit === undefined || emit === null) return OUTPUT_RAW;\n if ([ OUTPUT_IMAGE, OUTPUT_RGBA, OUTPUT_RAW].includes(emit)) return emit;\n if (Object.values(DEBUG_OUTPUTS).includes(emit)) return emit;\n throw new TypeError(`${readerName}: unknown emit value ${JSON.stringify(emit)}`);\n}\n\n/** Returns a byte view over the supplied binary input for the JPEG format reader. */\n/** Inspects input using normalized format options for the JPEG format reader. */\nexport function inspectWithValues(input, values = DEFAULT_VALUES, expectedType = \"\")\n{\n const bytes = asUint8Array(input, \"Image input\");\n const detected = inspectBytes(bytes);\n const sourceFormat = expectedType || values.inputType || detected.sourceFormat;\n\n if (expectedType && detected.sourceFormat && detected.sourceFormat !== expectedType)\n {\n throw new TypeError(`CjsFormat${capitalizeFormatId(expectedType)}: expected ${expectedType}, got ${detected.sourceFormat}`);\n }\n\n return {\n payloadType: sourceFormat === \"dds\" ? \"texture\" : \"image\",\n mediaTypes: sourceFormat === \"dds\" ? [ \"texture\", \"image\" ] : [ \"image\" ],\n sourceFormat,\n byteLength: bytes.byteLength,\n ...detected\n };\n}\n\n/**\n * Reports whether input is supported under normalized format options for the\n * JPEG format reader.\n */\nexport function probeSupportWithValues(input, values = DEFAULT_VALUES, expectedType = \"\")\n{\n try\n {\n const metadata = inspectWithValues(input, values, expectedType);\n const canDecode = metadata.sourceFormat === \"jpeg\" && canDecodeJpeg(metadata);\n const variants = [\n { kind: \"rgba\", payloadType: \"rgba\", codec: \"rgba8unorm\", supported: canDecode, reason: canDecode ? \"\" : jpegDecodeReason(metadata)},\n rawVariant(metadata)\n ];\n\n return {\n format: metadata.sourceFormat,\n source: values.source || \"buffer\",\n supported: metadata.sourceFormat ? (variants.some(variant => variant.supported && variant.kind === \"rgba\") ? \"full\" : \"partial\") : \"none\",\n confidence: metadata.sourceFormat ? 1 : 0,\n preferredOutput: variants.find(v => v.supported)?.kind || \"\",\n reason: metadata.sourceFormat ? \"Container/header recognized.\" : \"Unrecognized image format.\",\n metadata,\n variants,\n warnings: [],\n errors: []\n };\n }\n catch (error)\n {\n return {\n format: expectedType || values.inputType || \"\",\n source: values.source || \"buffer\",\n supported: \"none\",\n confidence: 0,\n preferredOutput: \"\",\n reason: error.message,\n metadata: null,\n variants: [],\n warnings: [],\n errors: [ error.message ]\n };\n }\n}\n\n/** Reads input using normalized format options for the JPEG format reader. */\nexport function readWithValues(input, values = DEFAULT_VALUES, expectedType = \"\")\n{\n const bytes = asUint8Array(input, \"Image input\");\n const metadata = inspectWithValues(bytes, values, expectedType);\n\n if (values.emit === OUTPUT_RAW)\n {\n return {\n payloadType: \"raw\",\n sourceFormat: metadata.sourceFormat,\n mimeType: imageMimeType(metadata.sourceFormat),\n metadata,\n bytes\n };\n }\n\n if (values.emit === DEBUG_OUTPUTS[metadata.sourceFormat])\n {\n return metadata;\n }\n\n if ((values.emit === OUTPUT_RGBA || values.emit === OUTPUT_IMAGE) && metadata.sourceFormat === \"jpeg\")\n {\n if (!canDecodeJpeg(metadata))\n {\n const error = new Error(`jpeg: ${jpegDecodeReason(metadata)}`);\n error.code = \"CJS_FORMAT_OUTPUT_NOT_SUPPORTED\";\n throw error;\n }\n return decodeJpegToRgba(bytes, metadata);\n }\n\n const error = new Error(`${metadata.sourceFormat}: emit \"${values.emit}\" is not implemented yet`);\n error.code = \"CJS_FORMAT_OUTPUT_NOT_IMPLEMENTED\";\n error.sourceFormat = metadata.sourceFormat;\n error.emit = values.emit;\n throw error;\n}\n\n\n\n/** Converts a parsed payload into a JSON-safe value for the JPEG format reader. */\n/** The shared JSON policy for this reader, under the name its callers use. */\nexport { toJsonValue };\n\n/**\n * Inspects the supplied bytes without decoding their payload for the JPEG format\n * reader.\n */\nexport function inspectBytes(bytes)\n{\n const sourceFormat = identifyImageBytes(bytes);\n return sourceFormat === \"jpeg\" ? inspectJPEG(bytes) : foreignImageRecord(sourceFormat);\n}\n\n\n\n/**\n * Reports whether the supplied bytes begin with a JPEG signature accepted as JPG\n * for the JPEG format reader.\n */\nexport function isJPG(bytes)\n{\n return isJPEG(bytes);\n}\n\n\n\n\nfunction inspectJPEG(bytes)\n{\n let offset = 2;\n let frame = null;\n const summary = {\n appMarkerCount: 0,\n commentCount: 0,\n hasExif: false,\n hasIccProfile: false\n };\n while (offset + 9 < bytes.byteLength)\n {\n if (bytes[offset] !== 0xff)\n {\n offset++;\n continue;\n }\n const marker = bytes[offset + 1], length = readU16BE(bytes, offset + 2);\n const dataStart = offset + 4;\n const dataEnd = offset + 2 + length;\n if (marker >= 0xe0 && marker <= 0xef)\n {\n summary.appMarkerCount++;\n if (marker === 0xe1 && ascii(bytes, dataStart, Math.min(6, dataEnd - dataStart)) === \"Exif\\0\\0\") summary.hasExif = true;\n if (marker === 0xe2 && ascii(bytes, dataStart, Math.min(12, dataEnd - dataStart)) === \"ICC_PROFILE\\0\") summary.hasIccProfile = true;\n }\n else if (marker === 0xfe)\n {\n summary.commentCount++;\n }\n if ([ 0xc0, 0xc1, 0xc2, 0xc3 ].includes(marker))\n {\n frame = {\n sourceFormat: \"jpeg\",\n width: readU16BE(bytes, offset + 7),\n height: readU16BE(bytes, offset + 5),\n channels: bytes[offset + 9],\n components: bytes[offset + 9],\n precision: bytes[offset + 4],\n marker,\n progressive: marker === 0xc2 || marker === 0xc3,\n pixelFormat: \"jpeg-ycbcr\",\n isCompressed: true\n };\n }\n if (marker === 0xda && frame)\n {\n const scanStart = offset + 4;\n const scanComponents = bytes[scanStart];\n const spectralStart = bytes[scanStart + 1 + scanComponents * 2];\n const spectralEnd = bytes[scanStart + 2 + scanComponents * 2];\n const successive = bytes[scanStart + 3 + scanComponents * 2];\n return {\n ...frame,\n ...summary,\n scanComponents,\n spectralStart,\n spectralEnd,\n successive,\n progressive: frame.progressive || spectralStart !== 0 || spectralEnd !== 63 || successive !== 0\n };\n }\n offset += Math.max(length + 2, 2);\n }\n return frame ? { ...frame, ...summary } : { sourceFormat: \"jpeg\", width: 0, height: 0, channels: 0, pixelFormat: \"jpeg\", isCompressed: true, ...summary };\n}\n\nfunction jpegDecodeReason(metadata)\n{\n if (metadata.sourceFormat !== \"jpeg\") return `${metadata.sourceFormat.toUpperCase()} RGBA decode is not implemented yet.`;\n if (metadata.progressive) return \"Progressive JPEG software decode is not implemented yet.\";\n if (metadata.marker !== undefined && metadata.marker !== 0xc0 && metadata.marker !== 0xc1)\n {\n return \"Only sequential baseline JPEG frames are supported by the software decoder.\";\n }\n if (metadata.precision !== undefined && metadata.precision !== 8)\n {\n return `JPEG sample precision ${metadata.precision} is not supported by the software decoder.`;\n }\n if (metadata.components > 3) return \"CMYK/YCCK JPEG software decode is not implemented yet.\";\n return \"JPEG baseline frame metadata is incomplete or unsupported.\";\n}\n\n\n\n\nfunction ascii(bytes, offset, length)\n{\n return String.fromCharCode(...bytes.subarray(offset, offset + length));\n}\n\n\n"],"names":["OUTPUT_IMAGE","OUTPUT_RGBA","OUTPUT_RAW","DEFAULT_VALUES","Object","freeze","emit","inputType","source","DEBUG_OUTPUTS","png","jpeg","jpg","tga","dds","normalizeValues","base","options","readerName","values","normalizeInputType","normalizeEmit","value","String","replace","toLowerCase","undefined","includes","TypeError","JSON","stringify","inspectWithValues","input","expectedType","bytes","asUint8Array","detected","inspectBytes","sourceFormat","capitalizeFormatId","payloadType","mediaTypes","byteLength","probeSupportWithValues","metadata","canDecode","canDecodeJpeg","variants","kind","codec","supported","reason","jpegDecodeReason","rawVariant","format","some","variant","confidence","preferredOutput","find","v","warnings","errors","error","message","readWithValues","mimeType","imageMimeType","Error","code","decodeJpegToRgba","identifyImageBytes","inspectJPEG","foreignImageRecord","isJPG","isJPEG","offset","frame","summary","appMarkerCount","commentCount","hasExif","hasIccProfile","marker","length","readU16BE","dataStart","dataEnd","ascii","Math","min","width","height","channels","components","precision","progressive","pixelFormat","isCompressed","scanStart","scanComponents","spectralStart","spectralEnd","successive","max","toUpperCase","fromCharCode","subarray"],"mappings":";;;;AAOO,MAAMA,YAAY,GAAG;AAErB,MAAMC,WAAW,GAAG;AACpB,MAAMC,UAAU,GAAG;MAKbC,cAAc,GAAGC,MAAM,CAACC,MAAM,CAAC;AACxCC,EAAAA,IAAI,EAAEJ,UAAU;AAChBK,EAAAA,SAAS,EAAE,EAAE;AACbC,EAAAA,MAAM,EAAE;AACZ,CAAC;AAED,MAAMC,aAAa,GAAGL,MAAM,CAACC,MAAM,CAAC;AAChCK,EAAAA,GAAG,EAAE,SAAS;AACdC,EAAAA,IAAI,EAAE,UAAU;AAChBC,EAAAA,GAAG,EAAE,UAAU;AACfC,EAAAA,GAAG,EAAE,SAAS;AACdC,EAAAA,GAAG,EAAE;AACT,CAAC,CAAC;;AAGF;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAACC,IAAI,GAAGb,cAAc,EAAEc,OAAO,GAAG,EAAE,EAAEC,UAAU,GAAG,gBAAgB,EAClG;AACI,EAAA,MAAMC,MAAM,GAAG;AAAE,IAAA,GAAGhB,cAAc;AAAE,IAAA,IAAIa,IAAI,IAAI,EAAE,CAAC;IAAE,IAAIC,OAAO,IAAI,EAAE;GAAG;EACzEE,MAAM,CAACZ,SAAS,GAAGa,kBAAkB,CAACD,MAAM,CAACZ,SAAS,CAAC;AACvDY,EAAAA,MAAM,CAACb,IAAI,GAAGe,aAAa,CAACF,MAAM,CAACb,IAAI,EAAEa,MAAM,CAACZ,SAAS,EAAEW,UAAU,CAA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,6EAA6E;AACxF,EAAA;EACA,IAAIvC,QAAQ,CAACmD,SAAS,KAAKrE,SAAS,IAAIkB,QAAQ,CAACmD,SAAS,KAAK,CAAC,EAChE;AACI,IAAA,OAAO,CAAA,sBAAA,EAAyBnD,QAAQ,CAACmD,SAAS,CAAA,0CAAA,CAA4C;AAClG,EAAA;AACA,EAAA,IAAInD,QAAQ,CAACkD,UAAU,GAAG,CAAC,EAAE,OAAO,wDAAwD;AAC5F,EAAA,OAAO,4DAA4D;AACvE;AAKA,SAASN,KAAKA,CAACtD,KAAK,EAAE0C,MAAM,EAAEQ,MAAM,EACpC;AACI,EAAA,OAAO7D,MAAM,CAACmF,YAAY,CAAC,GAAGxE,KAAK,CAACyE,QAAQ,CAAC/B,MAAM,EAAEA,MAAM,GAAGQ,MAAM,CAAC,CAAC;AAC1E;;;;"}
@@ -63,17 +63,17 @@ function canDecodeJpeg(metadata = {}) {
63
63
  * and Huffman tables, and entropy-coded scans into RGBA pixels.
64
64
  */
65
65
  class BaselineJpegDecoder {
66
- #bytes;
67
- #offset = 0;
68
- #quantization = new Map();
69
- #huffman = new Map();
70
- #frame = null;
71
- #scan = null;
72
- #restartInterval = 0;
66
+ _bytes;
67
+ _offset = 0;
68
+ _quantization = new Map();
69
+ _huffman = new Map();
70
+ _frame = null;
71
+ _scan = null;
72
+ _restartInterval = 0;
73
73
 
74
74
  /** Creates a BaselineJpegDecoder with caller-provided initial state. */
75
75
  constructor(bytes) {
76
- this.#bytes = bytes;
76
+ this._bytes = bytes;
77
77
  }
78
78
 
79
79
  /**
@@ -82,7 +82,7 @@ class BaselineJpegDecoder {
82
82
  */
83
83
  decode() {
84
84
  this.readMarker(0xd8);
85
- while (this.#offset < this.#bytes.length) {
85
+ while (this._offset < this._bytes.length) {
86
86
  const marker = this.nextMarker();
87
87
  if (marker === 0xd9) break;
88
88
  if (marker === 0xda) {
@@ -132,9 +132,9 @@ class BaselineJpegDecoder {
132
132
  list.push(component);
133
133
  }
134
134
  const consumed = 8 + components * 3;
135
- if (length !== consumed) this.#offset += Math.max(0, length - consumed);
135
+ if (length !== consumed) this._offset += Math.max(0, length - consumed);
136
136
  if (marker === 0xc2) throw new Error("jpeg: progressive scans are not supported by the software decoder");
137
- this.#frame = {
137
+ this._frame = {
138
138
  width,
139
139
  height,
140
140
  precision,
@@ -149,17 +149,17 @@ class BaselineJpegDecoder {
149
149
  * decoder.
150
150
  */
151
151
  readQuantizationTables() {
152
- const end = this.#offset + this.readU16() - 2;
153
- while (this.#offset < end) {
152
+ const end = this._offset + this.readU16() - 2;
153
+ while (this._offset < end) {
154
154
  const info = this.readU8();
155
155
  const precision = info >>> 4;
156
156
  const id = info & 0x0f;
157
157
  if (precision > 1) throw new Error("jpeg: unsupported 16-bit quantization table");
158
158
  const table = new Uint16Array(64);
159
159
  for (let i = 0; i < 64; i++) table[ZIGZAG[i]] = precision ? this.readU16() : this.readU8();
160
- this.#quantization.set(id, table);
160
+ this._quantization.set(id, table);
161
161
  }
162
- this.#offset = end;
162
+ this._offset = end;
163
163
  }
164
164
 
165
165
  /**
@@ -167,8 +167,8 @@ class BaselineJpegDecoder {
167
167
  * JPEG decoder.
168
168
  */
169
169
  readHuffmanTables() {
170
- const end = this.#offset + this.readU16() - 2;
171
- while (this.#offset < end) {
170
+ const end = this._offset + this.readU16() - 2;
171
+ while (this._offset < end) {
172
172
  const info = this.readU8();
173
173
  const table = new Array(17).fill(null).map(() => []);
174
174
  const counts = [];
@@ -179,17 +179,17 @@ class BaselineJpegDecoder {
179
179
  for (let i = 0; i < counts[length - 1]; i++) {
180
180
  table[length].push({
181
181
  code,
182
- value: this.#bytes[this.#offset + valueIndex]
182
+ value: this._bytes[this._offset + valueIndex]
183
183
  });
184
184
  valueIndex++;
185
185
  code++;
186
186
  }
187
187
  code <<= 1;
188
188
  }
189
- this.#offset += valueIndex;
190
- this.#huffman.set(`${info >>> 4}:${info & 0x0f}`, table);
189
+ this._offset += valueIndex;
190
+ this._huffman.set(`${info >>> 4}:${info & 0x0f}`, table);
191
191
  }
192
- this.#offset = end;
192
+ this._offset = end;
193
193
  }
194
194
 
195
195
  /**
@@ -199,7 +199,7 @@ class BaselineJpegDecoder {
199
199
  readRestartInterval() {
200
200
  const length = this.readU16();
201
201
  if (length !== 4) throw new Error("jpeg: invalid restart interval segment");
202
- this.#restartInterval = this.readU16();
202
+ this._restartInterval = this.readU16();
203
203
  }
204
204
 
205
205
  /**
@@ -209,8 +209,8 @@ class BaselineJpegDecoder {
209
209
  readScanHeader() {
210
210
  const length = this.readU16();
211
211
  const count = this.readU8();
212
- if (!this.#frame || count !== this.#frame.components.length) throw new Error("jpeg: unsupported scan component count");
213
- const byId = new Map(this.#frame.components.map(component => [component.id, component]));
212
+ if (!this._frame || count !== this._frame.components.length) throw new Error("jpeg: unsupported scan component count");
213
+ const byId = new Map(this._frame.components.map(component => [component.id, component]));
214
214
  for (let i = 0; i < count; i++) {
215
215
  const id = this.readU8();
216
216
  const tables = this.readU8();
@@ -226,8 +226,8 @@ class BaselineJpegDecoder {
226
226
  throw new Error("jpeg: progressive or non-sequential scan is not supported");
227
227
  }
228
228
  const consumed = 6 + count * 2;
229
- if (length !== consumed) this.#offset += Math.max(0, length - consumed);
230
- this.#scan = {
229
+ if (length !== consumed) this._offset += Math.max(0, length - consumed);
230
+ this._scan = {
231
231
  byId
232
232
  };
233
233
  }
@@ -237,7 +237,7 @@ class BaselineJpegDecoder {
237
237
  * pixels for the JPEG decoder.
238
238
  */
239
239
  decodeScan() {
240
- const frame = this.#frame;
240
+ const frame = this._frame;
241
241
  const mcuWidth = 8 * frame.maxH;
242
242
  const mcuHeight = 8 * frame.maxV;
243
243
  const mcuColumns = Math.ceil(frame.width / mcuWidth);
@@ -247,7 +247,7 @@ class BaselineJpegDecoder {
247
247
  component.planeHeight = mcuRows * component.v * 8;
248
248
  component.plane = new Uint8Array(component.planeWidth * component.planeHeight);
249
249
  }
250
- const reader = new EntropyReader(this.#bytes, this.#offset);
250
+ const reader = new EntropyReader(this._bytes, this._offset);
251
251
  let mcuIndex = 0;
252
252
  for (let row = 0; row < mcuRows; row++) {
253
253
  for (let column = 0; column < mcuColumns; column++) {
@@ -262,7 +262,7 @@ class BaselineJpegDecoder {
262
262
  }
263
263
  }
264
264
  mcuIndex++;
265
- if (this.#restartInterval && mcuIndex % this.#restartInterval === 0 && mcuIndex < mcuColumns * mcuRows) {
265
+ if (this._restartInterval && mcuIndex % this._restartInterval === 0 && mcuIndex < mcuColumns * mcuRows) {
266
266
  reader.align();
267
267
  reader.consumeRestart();
268
268
  for (const component of frame.components) component.previousDc = 0;
@@ -301,9 +301,9 @@ class BaselineJpegDecoder {
301
301
  * for the JPEG decoder.
302
302
  */
303
303
  decodeBlock(reader, component) {
304
- const quantization = this.#quantization.get(component.quantizationId);
305
- const dcTable = this.#huffman.get(`0:${component.dc}`);
306
- const acTable = this.#huffman.get(`1:${component.ac}`);
304
+ const quantization = this._quantization.get(component.quantizationId);
305
+ const dcTable = this._huffman.get(`0:${component.dc}`);
306
+ const acTable = this._huffman.get(`1:${component.ac}`);
307
307
  if (!quantization || !dcTable || !acTable) throw new Error("jpeg: missing quantization or Huffman table");
308
308
  const coefficients = new Int32Array(64);
309
309
  const category = decodeHuffman(reader, dcTable);
@@ -332,8 +332,8 @@ class BaselineJpegDecoder {
332
332
  * decoder.
333
333
  */
334
334
  readU8() {
335
- if (this.#offset >= this.#bytes.length) throw new Error("jpeg: unexpected end of input");
336
- return this.#bytes[this.#offset++];
335
+ if (this._offset >= this._bytes.length) throw new Error("jpeg: unexpected end of input");
336
+ return this._bytes[this._offset++];
337
337
  }
338
338
 
339
339
  /**
@@ -353,12 +353,12 @@ class BaselineJpegDecoder {
353
353
 
354
354
  /** Scans forward to the next valid JPEG marker byte for the JPEG decoder. */
355
355
  nextMarker() {
356
- while (this.#offset < this.#bytes.length && this.#bytes[this.#offset++] !== 0xff) {
356
+ while (this._offset < this._bytes.length && this._bytes[this._offset++] !== 0xff) {
357
357
  // Scan forward to the next marker prefix.
358
358
  }
359
- while (this.#offset < this.#bytes.length && this.#bytes[this.#offset] === 0xff) this.#offset++;
360
- if (this.#offset >= this.#bytes.length) throw new Error("jpeg: unexpected end while reading marker");
361
- return this.#bytes[this.#offset++];
359
+ while (this._offset < this._bytes.length && this._bytes[this._offset] === 0xff) this._offset++;
360
+ if (this._offset >= this._bytes.length) throw new Error("jpeg: unexpected end while reading marker");
361
+ return this._bytes[this._offset++];
362
362
  }
363
363
 
364
364
  /**
@@ -367,8 +367,8 @@ class BaselineJpegDecoder {
367
367
  */
368
368
  skipSegment() {
369
369
  const length = this.readU16();
370
- if (length < 2 || this.#offset + length - 2 > this.#bytes.length) throw new Error("jpeg: invalid segment length");
371
- this.#offset += length - 2;
370
+ if (length < 2 || this._offset + length - 2 > this._bytes.length) throw new Error("jpeg: invalid segment length");
371
+ this._offset += length - 2;
372
372
  }
373
373
  }
374
374
 
@@ -377,39 +377,39 @@ class BaselineJpegDecoder {
377
377
  * and restart markers for the baseline decoder.
378
378
  */
379
379
  class EntropyReader {
380
- #bytes;
381
- #offset;
382
- #buffer = 0;
383
- #bits = 0;
384
- #marker = null;
380
+ _bytes;
381
+ _offset;
382
+ _buffer = 0;
383
+ _bits = 0;
384
+ _marker = null;
385
385
 
386
386
  /**
387
387
  * Creates a EntropyReader over caller-provided JPEG bytes and reader
388
388
  * options.
389
389
  */
390
390
  constructor(bytes, offset) {
391
- this.#bytes = bytes;
392
- this.#offset = offset;
391
+ this._bytes = bytes;
392
+ this._offset = offset;
393
393
  }
394
394
 
395
395
  /** Reads one entropy-coded bit for the JPEG binary reader. */
396
396
  readBit() {
397
- if (!this.#bits) {
398
- let value = this.#bytes[this.#offset++];
397
+ if (!this._bits) {
398
+ let value = this._bytes[this._offset++];
399
399
  if (value === 0xff) {
400
- while (this.#bytes[this.#offset] === 0xff) this.#offset++;
401
- const marker = this.#bytes[this.#offset++];
400
+ while (this._bytes[this._offset] === 0xff) this._offset++;
401
+ const marker = this._bytes[this._offset++];
402
402
  if (marker !== 0x00) {
403
- this.#marker = marker;
403
+ this._marker = marker;
404
404
  throw new Error("jpeg: unexpected marker in entropy data");
405
405
  }
406
406
  value = 0xff;
407
407
  }
408
408
  if (value === undefined) throw new Error("jpeg: unexpected end in entropy data");
409
- this.#buffer = value;
410
- this.#bits = 8;
409
+ this._buffer = value;
410
+ this._bits = 8;
411
411
  }
412
- return this.#buffer >>> --this.#bits & 1;
412
+ return this._buffer >>> --this._bits & 1;
413
413
  }
414
414
 
415
415
  /**
@@ -427,7 +427,7 @@ class EntropyReader {
427
427
  * reader.
428
428
  */
429
429
  align() {
430
- this.#bits = 0;
430
+ this._bits = 0;
431
431
  }
432
432
 
433
433
  /**
@@ -435,8 +435,8 @@ class EntropyReader {
435
435
  * reader.
436
436
  */
437
437
  consumeRestart() {
438
- while (this.#bytes[this.#offset] === 0xff) this.#offset++;
439
- const marker = this.#bytes[this.#offset++];
438
+ while (this._bytes[this._offset] === 0xff) this._offset++;
439
+ const marker = this._bytes[this._offset++];
440
440
  if (marker < 0xd0 || marker > 0xd7) throw new Error("jpeg: missing restart marker");
441
441
  }
442
442
  }