@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":"CjsStaticFormat.js","sources":["../../../../../src/resource/formats/static/CjsStaticFormat.js"],"sourcesContent":["import { CjsFormat } from \"../../format/CjsFormat.js\";\n\nconst SQLITE_SIGNATURE = \"SQLite format 3\\0\";\nconst PICKLE_PREFIX_BYTES = 4;\n\n/** Container families found behind the single `.static` extension. */\nexport const CJS_STATIC_FAMILIES = Object.freeze({\n SQLITE: \"sqlite\",\n PICKLE: \"pickle\",\n UNKNOWN: \"unknown\"\n});\n\n/**\n * Identifies which container a client `.static` file actually holds.\n *\n * The extension names a role, not a format. Three unrelated containers ship\n * under it, and each fails in its own way when guessed at:\n *\n * - **SQLite 3** — a `cache(key, value, time)` plus `indexes(key, value)`\n * database whose values are JSON documents. `CjsSqliteFormat` reads it.\n * - **Embedded schema** — a four-byte little-endian SCHEMA LENGTH followed by\n * that schema as a protocol-0 pickle, and then a payload. The prefix is not a\n * wrapper to skip: slice `[4, 4 + length)` for the schema and give the rest\n * to `CjsSchemaBoundFormat`. All 25 of these name one global,\n * `collections.OrderedDict`, which the pickle reader rebuilds as plain data.\n * - **Schema-bound** — a binary record container whose `.schema` companion is\n * YAML describing its own layout: attribute sizes and types, optional flags,\n * lists with a fixed item size, vectors with a precision, and a key footer of\n * key-to-offset pairs. Nothing needs deriving, because the build ships the\n * layout. Six datasets are stored this way - the map skeleton of regions,\n * constellations and systems. `CjsSchemaBoundFormat` reads it, given that\n * companion, and reads the embedded-schema family above from the same code.\n *\n * Detection is signature-based and never executes or trusts file names.\n *\n * **This class identifies and does not decode.** It reports the family, the\n * payload offset and what is still missing; the caller takes that answer to the\n * format that owns the family. It carried a `read()` that dispatched to\n * `CjsPickleFormat` and `CjsSqliteFormat` until 2026-08-15, which made an\n * identification format the routing table for two others and put the decision\n * about what to decode in the wrong place. Nothing outside its own tests ever\n * called it.\n */\nexport class CjsStaticFormat extends CjsFormat\n{\n\n /**\n * Report which family a container holds, on the declaration seam.\n *\n * `.static` declares nothing: the extension names a role and every family\n * wears it. The signature is therefore the only claim there is, which is why\n * this format reads it here rather than trusting a name.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @param {object} [options] Probe options.\n * @returns {CjsResourceProbe} Declaration-derived probe.\n */\n static probeSupport(input, options = null)\n {\n const detected = this.describe(input);\n return {\n format: this.id,\n source: options?.source || \"buffer\",\n recognized: detected.family !== CJS_STATIC_FAMILIES.UNKNOWN,\n supported: false,\n reason: detected.reason ?? `Recognized a ${detected.family} container.`,\n metadata: detected\n };\n }\n\n /**\n * Alias for canonical naming.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @param {object} [options] Probe options.\n * @returns {CjsResourceProbe} Declaration-derived probe.\n */\n static inspect(input, options = null)\n {\n void options;\n return this.describe(input);\n }\n\n /**\n * Describe one container without decoding it or building a probe.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @returns {object} Family, payload offset, and whether this package decodes it.\n */\n static describe(input)\n {\n const bytes = Normalize(input);\n\n if (MatchesSqlite(bytes))\n {\n return {\n family: CJS_STATIC_FAMILIES.SQLITE,\n byteLength: bytes.byteLength,\n payloadOffset: 0,\n prefix: null,\n // Decodable outright since CjsSqliteFormat landed. This reported\n // `requires: \"sqlite\"` while a caller had to supply an engine, and was\n // the example behind the argument that a capability can depend on the\n // caller's environment - an argument that now needs a different one.\n decodable: true,\n requires: null,\n reason: \"Recognized a SQLite container.\"\n };\n }\n\n if (MatchesPickle(bytes))\n {\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n\n return {\n family: CJS_STATIC_FAMILIES.PICKLE,\n byteLength: bytes.byteLength,\n payloadOffset: PICKLE_PREFIX_BYTES,\n prefix: view.getUint32(0, true),\n decodable: true,\n requires: null,\n reason: null\n };\n }\n\n return {\n family: CJS_STATIC_FAMILIES.UNKNOWN,\n byteLength: bytes.byteLength,\n payloadOffset: 0,\n prefix: null,\n decodable: false,\n requires: \"schema\",\n // `decodable` is this format's own answer, and it stays false: these bytes\n // carry nothing to identify, so the family is an inference from the absence\n // of the other two signatures rather than a reading. `requires` names what\n // closes that gap - with the companion, CjsSchemaBoundFormat decodes it.\n reason: \"No signature. A schema-bound container needs its .schema companion, \"\n + \"which is YAML describing the layout. CjsSchemaBoundFormat reads it from there.\"\n };\n }\n\n /**\n * Return the decodable payload for a container, without its wrapper.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @returns {Uint8Array} Payload bytes.\n */\n static payload(input)\n {\n const bytes = Normalize(input);\n const detected = this.describe(bytes);\n\n return bytes.subarray(detected.payloadOffset);\n }\n\n\n static id = \"static\";\n static extensions = Object.freeze([ \".static\" ]);\n static mediaTypes = Object.freeze([ \"data\" ]);\n static outputs = Object.freeze({});\n\n /**\n * The extension is the only input this format claims.\n *\n * Naming the three families here would be a lie in the other direction: a\n * caller cannot hand this format \"a pickle\" or \"a sqlite\" and expect it to\n * route, because the whole point of the class is that `.static` declares\n * nothing and the signature has to be read. The family belongs in\n * `describe()`, which measures it, not in a static that asserts it.\n */\n\n}\n\nfunction MatchesSqlite(bytes)\n{\n if (bytes.byteLength < SQLITE_SIGNATURE.length) return false;\n\n for (let index = 0; index < SQLITE_SIGNATURE.length; index++)\n {\n if (bytes[index] !== SQLITE_SIGNATURE.charCodeAt(index)) return false;\n }\n\n return true;\n}\n\nfunction MatchesPickle(bytes)\n{\n // A protocol-0 pickle opens a container then names it: \"(dp1\\n\" or \"(lp1\\n\".\n if (bytes.byteLength < PICKLE_PREFIX_BYTES + 3) return false;\n if (bytes[PICKLE_PREFIX_BYTES] !== 0x28) return false;\n\n const kind = bytes[PICKLE_PREFIX_BYTES + 1];\n\n return kind === 0x64 || kind === 0x6c;\n}\n\nfunction Normalize(input)\n{\n if (input instanceof ArrayBuffer) return new Uint8Array(input);\n\n if (ArrayBuffer.isView(input))\n {\n return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n }\n\n const error = new TypeError(\"A .static container must be an ArrayBuffer or a view over one.\");\n\n error.code = \"CJS_STATIC_FORMAT_INPUT_INVALID\";\n throw error;\n}\n"],"names":["SQLITE_SIGNATURE","PICKLE_PREFIX_BYTES","CJS_STATIC_FAMILIES","Object","freeze","SQLITE","PICKLE","UNKNOWN","CjsStaticFormat","CjsFormat","probeSupport","input","options","detected","describe","format","id","source","recognized","family","supported","reason","metadata","inspect","bytes","Normalize","MatchesSqlite","byteLength","payloadOffset","prefix","decodable","requires","MatchesPickle","view","DataView","buffer","byteOffset","getUint32","payload","subarray","extensions","mediaTypes","outputs","length","index","charCodeAt","kind","ArrayBuffer","Uint8Array","isView","error","TypeError","code"],"mappings":";;AAEA,MAAMA,gBAAgB,GAAG,mBAAmB;AAC5C,MAAMC,mBAAmB,GAAG,CAAC;;AAE7B;MACaC,mBAAmB,GAAGC,MAAM,CAACC,MAAM,CAAC;AAC/CC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,OAAO,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,eAAe,SAASC,SAAS,CAC9C;AAEE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOC,YAAYA,CAACC,KAAK,EAAEC,OAAO,GAAG,IAAI,EACzC;AACE,IAAA,MAAMC,QAAQ,GAAG,IAAI,CAACC,QAAQ,CAACH,KAAK,CAAC;IACrC,OAAO;MACLI,MAAM,EAAE,IAAI,CAACC,EAAE;AACfC,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G,CAAC,EAAEA,KAAK,GAAG5C,gBAAgB,CAAC2C,MAAM,EAAEC,KAAK,EAAE,EAC5D;AACE,IAAA,IAAIpB,KAAK,CAACoB,KAAK,CAAC,KAAK5C,gBAAgB,CAAC6C,UAAU,CAACD,KAAK,CAAC,EAAE,OAAO,KAAK;AACvE,EAAA;AAEA,EAAA,OAAO,IAAI;AACb;AAEA,SAASZ,aAAaA,CAACR,KAAK,EAC5B;AACE;EACA,IAAIA,KAAK,CAACG,UAAU,GAAG1B,mBAAmB,GAAG,CAAC,EAAE,OAAO,KAAK;EAC5D,IAAIuB,KAAK,CAACvB,mBAAmB,CAAC,KAAK,IAAI,EAAE,OAAO,KAAK;AAErD,EAAA,MAAM6C,IAAI,GAAGtB,KAAK,CAACvB,mBAAmB,GAAG,CAAC,CAAC;AAE3C,EAAA,OAAO6C,IAAI,KAAK,IAAI,IAAIA,IAAI,KAAK,IAAI;AACvC;AAEA,SAASrB,SAASA,CAACd,KAAK,EACxB;EACE,IAAIA,KAAK,YAAYoC,WAAW,EAAE,OAAO,IAAIC,UAAU,CAACrC,KAAK,CAAC;AAE9D,EAAA,IAAIoC,WAAW,CAACE,MAAM,CAACtC,KAAK,CAAC,EAC7B;AACE,IAAA,OAAO,IAAIqC,UAAU,CAACrC,KAAK,CAACwB,MAAM,EAAExB,KAAK,CAACyB,UAAU,EAAEzB,KAAK,CAACgB,UAAU,CAAC;AACzE,EAAA;AAEA,EAAA,MAAMuB,KAAK,GAAG,IAAIC,SAAS,CAAC,gEAAgE,CAAC;EAE7FD,KAAK,CAACE,IAAI,GAAG,iCAAiC;AAC9C,EAAA,MAAMF,KAAK;AACb;;;;"}
1
+ {"version":3,"file":"CjsStaticFormat.js","sources":["../../../../../src/resource/formats/static/CjsStaticFormat.js"],"sourcesContent":["import { CjsFormat } from \"../../format/CjsFormat.js\";\n\nconst SQLITE_SIGNATURE = \"SQLite format 3\\0\";\nconst PICKLE_PREFIX_BYTES = 4;\n\n/** Container families found behind the single `.static` extension. */\nexport const CJS_STATIC_FAMILIES = Object.freeze({\n SQLITE: \"sqlite\",\n PICKLE: \"pickle\",\n UNKNOWN: \"unknown\"\n});\n\n/**\n * Identifies which container a client `.static` file actually holds.\n *\n * The extension names a role, not a format. Three unrelated containers ship\n * under it, and each fails in its own way when guessed at:\n *\n * - **SQLite 3** — a `cache(key, value, time)` plus `indexes(key, value)`\n * database whose values are JSON documents. `CjsSqliteFormat` reads it.\n * - **Embedded schema** — a four-byte little-endian SCHEMA LENGTH followed by\n * that schema as a protocol-0 pickle, and then a payload. The prefix is not a\n * wrapper to skip: slice `[4, 4 + length)` for the schema and give the rest\n * to `CjsSchemaBoundFormat`. All 25 of these name one global,\n * `collections.OrderedDict`, which the pickle reader rebuilds as plain data.\n * - **Schema-bound** — a binary record container whose `.schema` companion is\n * YAML describing its own layout: attribute sizes and types, optional flags,\n * lists with a fixed item size, vectors with a precision, and a key footer of\n * key-to-offset pairs. Nothing needs deriving, because the build ships the\n * layout. Six datasets are stored this way - the map skeleton of regions,\n * constellations and systems. `CjsSchemaBoundFormat` reads it, given that\n * companion, and reads the embedded-schema family above from the same code.\n *\n * Detection is signature-based and never executes or trusts file names.\n *\n * **This class identifies and does not decode.** It reports the family, the\n * payload offset and what is still missing; the caller takes that answer to the\n * format that owns the family. It carried a `read()` that dispatched to\n * `CjsPickleFormat` and `CjsSqliteFormat` until 2026-08-15, which made an\n * identification format the routing table for two others and put the decision\n * about what to decode in the wrong place. Nothing outside its own tests ever\n * called it.\n */\nexport class CjsStaticFormat extends CjsFormat\n{\n\n /**\n * Report which family a container holds, on the declaration seam.\n *\n * `.static` declares nothing: the extension names a role and every family\n * wears it. The signature is therefore the only claim there is, which is why\n * this format reads it here rather than trusting a name.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @param {object} [options] Probe options.\n * @returns {CjsResourceProbe} Declaration-derived probe.\n */\n static probeSupport(input, options = null)\n {\n const detected = this.describe(input);\n return {\n format: this.id,\n source: options?.source || \"buffer\",\n recognized: detected.family !== CJS_STATIC_FAMILIES.UNKNOWN,\n supported: false,\n reason: detected.reason ?? `Recognized a ${detected.family} container.`,\n metadata: detected\n };\n }\n\n /**\n * Alias for canonical naming.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @param {object} [options] Probe options.\n * @returns {CjsResourceProbe} Declaration-derived probe.\n */\n static inspect(input, options = null)\n {\n void options;\n return this.describe(input);\n }\n\n /**\n * Describe one container without decoding it or building a probe.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @returns {object} Family, payload offset, and whether this package decodes it.\n */\n static describe(input)\n {\n const bytes = Normalize(input);\n\n if (MatchesSqlite(bytes))\n {\n return {\n family: CJS_STATIC_FAMILIES.SQLITE,\n byteLength: bytes.byteLength,\n payloadOffset: 0,\n prefix: null,\n // Decodable outright since CjsSqliteFormat landed. This reported\n // `requires: \"sqlite\"` while a caller had to supply an engine, and was\n // the example behind the argument that a capability can depend on the\n // caller's environment - an argument that now needs a different one.\n decodable: true,\n requires: null,\n reason: \"Recognized a SQLite container.\"\n };\n }\n\n if (MatchesPickle(bytes))\n {\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n\n return {\n family: CJS_STATIC_FAMILIES.PICKLE,\n byteLength: bytes.byteLength,\n payloadOffset: PICKLE_PREFIX_BYTES,\n prefix: view.getUint32(0, true),\n decodable: true,\n requires: null,\n reason: null\n };\n }\n\n return {\n family: CJS_STATIC_FAMILIES.UNKNOWN,\n byteLength: bytes.byteLength,\n payloadOffset: 0,\n prefix: null,\n decodable: false,\n requires: \"schema\",\n // `decodable` is this format's own answer, and it stays false: these bytes\n // carry nothing to identify, so the family is an inference from the absence\n // of the other two signatures rather than a reading. `requires` names what\n // closes that gap - with the companion, CjsSchemaBoundFormat decodes it.\n reason: \"No signature. A schema-bound container needs its .schema companion, \"\n + \"which is YAML describing the layout. CjsSchemaBoundFormat reads it from there.\"\n };\n }\n\n /**\n * Return the decodable payload for a container, without its wrapper.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @returns {Uint8Array} Payload bytes.\n */\n static payload(input)\n {\n const bytes = Normalize(input);\n const detected = this.describe(bytes);\n\n return bytes.subarray(detected.payloadOffset);\n }\n\n\n static id = \"CjsStaticFormat\";\n static extensions = [ \".static\" ];\n static mediaTypes = [ \"data\" ];\n static outputs = {};\n\n /**\n * The extension is the only input this format claims.\n *\n * Naming the three families here would be a lie in the other direction: a\n * caller cannot hand this format \"a pickle\" or \"a sqlite\" and expect it to\n * route, because the whole point of the class is that `.static` declares\n * nothing and the signature has to be read. The family belongs in\n * `describe()`, which measures it, not in a static that asserts it.\n */\n\n}\n\nfunction MatchesSqlite(bytes)\n{\n if (bytes.byteLength < SQLITE_SIGNATURE.length) return false;\n\n for (let index = 0; index < SQLITE_SIGNATURE.length; index++)\n {\n if (bytes[index] !== SQLITE_SIGNATURE.charCodeAt(index)) return false;\n }\n\n return true;\n}\n\nfunction MatchesPickle(bytes)\n{\n // A protocol-0 pickle opens a container then names it: \"(dp1\\n\" or \"(lp1\\n\".\n if (bytes.byteLength < PICKLE_PREFIX_BYTES + 3) return false;\n if (bytes[PICKLE_PREFIX_BYTES] !== 0x28) return false;\n\n const kind = bytes[PICKLE_PREFIX_BYTES + 1];\n\n return kind === 0x64 || kind === 0x6c;\n}\n\nfunction Normalize(input)\n{\n if (input instanceof ArrayBuffer) return new Uint8Array(input);\n\n if (ArrayBuffer.isView(input))\n {\n return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n }\n\n const error = new TypeError(\"A .static container must be an ArrayBuffer or a view over one.\");\n\n error.code = \"CJS_STATIC_FORMAT_INPUT_INVALID\";\n throw error;\n}\n"],"names":["SQLITE_SIGNATURE","PICKLE_PREFIX_BYTES","CJS_STATIC_FAMILIES","Object","freeze","SQLITE","PICKLE","UNKNOWN","CjsStaticFormat","CjsFormat","probeSupport","input","options","detected","describe","format","id","source","recognized","family","supported","reason","metadata","inspect","bytes","Normalize","MatchesSqlite","byteLength","payloadOffset","prefix","decodable","requires","MatchesPickle","view","DataView","buffer","byteOffset","getUint32","payload","subarray","extensions","mediaTypes","outputs","length","index","charCodeAt","kind","ArrayBuffer","Uint8Array","isView","error","TypeError","code"],"mappings":";;AAEA,MAAMA,gBAAgB,GAAG,mBAAmB;AAC5C,MAAMC,mBAAmB,GAAG,CAAC;;AAE7B;MACaC,mBAAmB,GAAGC,MAAM,CAACC,MAAM,CAAC;AAC/CC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,OAAO,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,eAAe,SAASC,SAAS,CAC9C;AAEE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOC,YAAYA,CAACC,KAAK,EAAEC,OAAO,GAAG,IAAI,EACzC;AACE,IAAA,MAAMC,QAAQ,GAAG,IAAI,CAACC,QAAQ,CAACH,KAAK,CAAC;IACrC,OAAO;MACLI,MAAM,EAAE,IAAI,CAACC,EAAE;AACfC,MAAAA,MAAM,EAAEL,OAAO,EAAEK,MAAM,IAAI,QAAQ;AACnCC,MAAAA,UAAU,EAAEL,QAAQ,CAACM,MAAM,KAAKjB,mBAAmB,CAACK,OAAO;AAC3Da,MAAAA,SAAS,EAAE,KAAK;MAChBC,MAAM,EAAER,QAAQ,CAACQ,MAAM,IAAI,CAAA,aAAA,EAAgBR,QAAQ,CAACM,MAAM,CAAA,WAAA,CAAa;AACvEG,MAAAA,QAAQ,EAAET;KACX;AACH,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOU,OAAOA,CAACZ,KAAK,EAAEC,OAAO,GAAG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AG,CAAC,CAAC;AAE3C,EAAA,OAAO6C,IAAI,KAAK,IAAI,IAAIA,IAAI,KAAK,IAAI;AACvC;AAEA,SAASrB,SAASA,CAACd,KAAK,EACxB;EACE,IAAIA,KAAK,YAAYoC,WAAW,EAAE,OAAO,IAAIC,UAAU,CAACrC,KAAK,CAAC;AAE9D,EAAA,IAAIoC,WAAW,CAACE,MAAM,CAACtC,KAAK,CAAC,EAC7B;AACE,IAAA,OAAO,IAAIqC,UAAU,CAACrC,KAAK,CAACwB,MAAM,EAAExB,KAAK,CAACyB,UAAU,EAAEzB,KAAK,CAACgB,UAAU,CAAC;AACzE,EAAA;AAEA,EAAA,MAAMuB,KAAK,GAAG,IAAIC,SAAS,CAAC,gEAAgE,CAAC;EAE7FD,KAAK,CAACE,IAAI,GAAG,iCAAiC;AAC9C,EAAA,MAAMF,KAAK;AACb;;;;"}
@@ -1,5 +1,6 @@
1
1
  import { CjsFormat } from '../../format/CjsFormat.js';
2
- import { DEFAULT_VALUES, normalizeValues, validateClassKey, validateClass, readWithValues, writeWithValues, inspectWithValues, OUTPUT_CMF, OUTPUT_GR2, OUTPUT_SHARED, OUTPUT_STL_JSON, OUTPUT_JSON, CLASS_KEYS } from './core/helpers.js';
2
+ import { CjsGeometryFormat } from '../../format/CjsGeometryFormat.js';
3
+ import { DEFAULT_VALUES, normalizeValues, readWithValues, writeWithValues, inspectWithValues, CLASS_KEYS } from './core/helpers.js';
3
4
  import { toJsonWithArrayValues } from '../../format/jsonPolicies.js';
4
5
  import { isStl, isBinaryStl } from './core/stl.js';
5
6
 
@@ -47,18 +48,18 @@ const FORMAT_NAME = "CjsStlFormat";
47
48
  * STL is a triangle-only import/export format; the JSON contract is the shared
48
49
  * CarbonEngineJS mesh schema.
49
50
  */
50
- class CjsStlFormat extends CjsFormat {
51
- #emit = DEFAULT_VALUES.emit;
52
- #source = DEFAULT_VALUES.source;
53
- #binary = DEFAULT_VALUES.binary;
54
- #solidName = DEFAULT_VALUES.solidName;
55
- #scale = DEFAULT_VALUES.scale;
56
- #recalculateNormals = DEFAULT_VALUES.recalculateNormals;
57
- #weldVertices = DEFAULT_VALUES.weldVertices;
58
- #weldTolerance = DEFAULT_VALUES.weldTolerance;
59
- #skipDegenerate = DEFAULT_VALUES.skipDegenerate;
60
- #requireWatertight = DEFAULT_VALUES.requireWatertight;
61
- #classes = DEFAULT_VALUES.classes;
51
+ class CjsStlFormat extends CjsGeometryFormat {
52
+ _emit = DEFAULT_VALUES.emit;
53
+ _source = DEFAULT_VALUES.source;
54
+ _binary = DEFAULT_VALUES.binary;
55
+ _solidName = DEFAULT_VALUES.solidName;
56
+ _scale = DEFAULT_VALUES.scale;
57
+ _recalculateNormals = DEFAULT_VALUES.recalculateNormals;
58
+ _weldVertices = DEFAULT_VALUES.weldVertices;
59
+ _weldTolerance = DEFAULT_VALUES.weldTolerance;
60
+ _skipDegenerate = DEFAULT_VALUES.skipDegenerate;
61
+ _requireWatertight = DEFAULT_VALUES.requireWatertight;
62
+ _classes = DEFAULT_VALUES.classes;
62
63
 
63
64
  /**
64
65
  * Create a reusable format profile.
@@ -83,17 +84,17 @@ class CjsStlFormat extends CjsFormat {
83
84
  */
84
85
  SetValues(options = {}) {
85
86
  const values = normalizeValues(this.GetValues(), options, FORMAT_NAME);
86
- this.#emit = values.emit;
87
- this.#source = values.source;
88
- this.#binary = values.binary;
89
- this.#solidName = values.solidName;
90
- this.#scale = values.scale;
91
- this.#recalculateNormals = values.recalculateNormals;
92
- this.#weldVertices = values.weldVertices;
93
- this.#weldTolerance = values.weldTolerance;
94
- this.#skipDegenerate = values.skipDegenerate;
95
- this.#requireWatertight = values.requireWatertight;
96
- this.#classes = values.classes;
87
+ this._emit = values.emit;
88
+ this._source = values.source;
89
+ this._binary = values.binary;
90
+ this._solidName = values.solidName;
91
+ this._scale = values.scale;
92
+ this._recalculateNormals = values.recalculateNormals;
93
+ this._weldVertices = values.weldVertices;
94
+ this._weldTolerance = values.weldTolerance;
95
+ this._skipDegenerate = values.skipDegenerate;
96
+ this._requireWatertight = values.requireWatertight;
97
+ this._classes = values.classes;
97
98
  return this;
98
99
  }
99
100
 
@@ -106,78 +107,20 @@ class CjsStlFormat extends CjsFormat {
106
107
  */
107
108
  GetValues(options = {}) {
108
109
  return normalizeValues({
109
- emit: this.#emit,
110
- source: this.#source,
111
- binary: this.#binary,
112
- solidName: this.#solidName,
113
- scale: this.#scale,
114
- recalculateNormals: this.#recalculateNormals,
115
- weldVertices: this.#weldVertices,
116
- weldTolerance: this.#weldTolerance,
117
- skipDegenerate: this.#skipDegenerate,
118
- requireWatertight: this.#requireWatertight,
119
- classes: this.#classes
110
+ emit: this._emit,
111
+ source: this._source,
112
+ binary: this._binary,
113
+ solidName: this._solidName,
114
+ scale: this._scale,
115
+ recalculateNormals: this._recalculateNormals,
116
+ weldVertices: this._weldVertices,
117
+ weldTolerance: this._weldTolerance,
118
+ skipDegenerate: this._skipDegenerate,
119
+ requireWatertight: this._requireWatertight,
120
+ classes: this._classes
120
121
  }, options, FORMAT_NAME);
121
122
  }
122
123
 
123
- /**
124
- * Set multiple node-class constructors for this profile.
125
- *
126
- * @param {object} [classes] Map of node class keys to constructors.
127
- * @returns {CjsStlFormat} This format profile.
128
- */
129
- SetClasses(classes = {}) {
130
- return this.SetValues({
131
- classes
132
- });
133
- }
134
-
135
- /**
136
- * Set one node-class constructor for this profile.
137
- *
138
- * @param {string} type Node class key.
139
- * @param {Function|null|undefined} Class Constructor to use, or nullish to delete.
140
- * @returns {CjsStlFormat} This format profile.
141
- */
142
- SetClass(type, Class) {
143
- if (Class === null || Class === undefined) {
144
- validateClassKey(type, FORMAT_NAME);
145
- const classes = {
146
- ...this.#classes
147
- };
148
- delete classes[type];
149
- this.#classes = classes;
150
- return this;
151
- }
152
- validateClass(type, Class, FORMAT_NAME);
153
- return this.SetValues({
154
- classes: {
155
- [type]: Class
156
- }
157
- });
158
- }
159
-
160
- /**
161
- * Get a configured node-class constructor.
162
- *
163
- * @param {string} type Node class key.
164
- * @returns {Function|undefined} The registered constructor, if any.
165
- */
166
- GetClass(type) {
167
- validateClassKey(type, FORMAT_NAME);
168
- return this.#classes[type];
169
- }
170
-
171
- /**
172
- * Whether this format profile has a constructor registered for a node class key.
173
- *
174
- * @param {string} type Node class key.
175
- * @returns {boolean} True when a constructor is registered.
176
- */
177
- HasClass(type) {
178
- return !!this.GetClass(type);
179
- }
180
-
181
124
  /**
182
125
  * Read STL text/bytes with this profile's values.
183
126
  *
@@ -297,16 +240,8 @@ class CjsStlFormat extends CjsFormat {
297
240
  /**
298
241
  * Emit targets for this format (canonical frozen enum).
299
242
  */
300
- static Output = Object.freeze({
301
- JSON: OUTPUT_JSON,
302
- STL_JSON: OUTPUT_STL_JSON,
303
- SHARED: OUTPUT_SHARED,
304
- GR2: OUTPUT_GR2,
305
- CMF: OUTPUT_CMF
306
- });
307
- static CLASS_KEYS = CLASS_KEYS;
308
- static id = "stl";
309
- static mediaTypes = Object.freeze(["geometry"]);
243
+ static classKeys = CLASS_KEYS;
244
+ static id = "CjsStlFormat";
310
245
  // STL takes the shared geometry root directly rather than going through
311
246
  // CMF, because it carries triangles and nothing else worth preserving.
312
247
  // Lossless for what STL can represent; everything else was never in scope.
@@ -337,7 +272,7 @@ class CjsStlFormat extends CjsFormat {
337
272
  decoded: true
338
273
  }
339
274
  });
340
- static extensions = Object.freeze([".stl"]);
275
+ static extensions = [".stl"];
341
276
  }
342
277
 
343
278
  export { CjsStlFormat, CjsStlFormat as default };
@@ -1 +1 @@
1
- {"version":3,"file":"CjsStlFormat.js","sources":["../../../../../src/resource/formats/stl/CjsStlFormat.js"],"sourcesContent":["import { CjsFormat } from \"../../format/CjsFormat.js\";\n/**\n * Exposed CarbonEngineJS-facing STL format class.\n *\n * Keep this file small and reviewable: STL parsing, writing, printability\n * inspection, option normalization, and JSON hydration live under src/core.\n */\n\nimport {\n CLASS_KEYS,\n DEFAULT_VALUES,\n OUTPUT_CMF,\n OUTPUT_GR2,\n OUTPUT_JSON,\n OUTPUT_SHARED,\n OUTPUT_STL_JSON,\n inspectWithValues,\n isBinaryStl,\n isStl,\n normalizeValues,\n readWithValues,\n toJsonValue,\n validateClass,\n validateClassKey,\n writeWithValues\n} from \"./core/helpers.js\";\n\nconst FORMAT_NAME = \"CjsStlFormat\";\n\n/**\n * Shared mesh accepted by the STL writer. STL exports only `vertex.position`\n * and triangular `indices[].faces`; all other shared channels are ignored.\n *\n * @typedef {object} CjsStlSharedMesh\n * @property {string} [name] Diagnostic mesh name; `solidName` controls the STL header.\n * @property {{position: ArrayLike<number>, normal?: ArrayLike<number>}} vertex Shared vertex channels.\n * @property {Array<{name?: string, faces: ArrayLike<number>}>} indices Triangle index groups.\n */\n\n/**\n * Shared geometry root accepted by the STL writer.\n *\n * @typedef {object} CjsStlSharedRoot\n * @property {Array<CjsStlSharedMesh>} meshes Meshes flattened into one STL solid.\n * @property {string} [grannyFileSource] Optional source label used by inspection.\n */\n\n/**\n * Reusable STL read, write, and inspection options.\n *\n * @typedef {object} CjsStlFormatOptions\n * @property {\"shared\"|\"stlJson\"|\"json\"|\"gr2\"|\"cmf\"} [emit=\"stlJson\"] Read output contract.\n * @property {string} [source=\"memory\"] Source label stored in read/inspection output.\n * @property {boolean} [binary=true] Whether writes return binary bytes instead of ASCII text.\n * @property {string} [solidName=\"carbonenginejs\"] Sanitized ASCII solid name and binary header label.\n * @property {number} [scale=1] Positive finite multiplier applied to exported positions.\n * @property {boolean} [recalculateNormals=true] Derive facet normals from winding instead of vertex normals.\n * @property {boolean} [weldVertices=false] Weld equal positions while reading STL.\n * @property {number} [weldTolerance=1e-5] Non-negative read/inspection position tolerance.\n * @property {boolean} [skipDegenerate=true] Omit degenerate shared triangles during writes.\n * @property {boolean} [requireWatertight=false] Reject writes with printability topology issues.\n * @property {Record<string, Function>} [classes] Caller constructors used for read hydration.\n */\n\n/**\n * CarbonEngineJS-facing STL format surface.\n *\n * The Cjs prefix marks this as a JavaScript format/construction boundary.\n * STL is a triangle-only import/export format; the JSON contract is the shared\n * CarbonEngineJS mesh schema.\n */\nexport class CjsStlFormat extends CjsFormat\n{\n\n #emit = DEFAULT_VALUES.emit;\n #source = DEFAULT_VALUES.source;\n #binary = DEFAULT_VALUES.binary;\n #solidName = DEFAULT_VALUES.solidName;\n #scale = DEFAULT_VALUES.scale;\n #recalculateNormals = DEFAULT_VALUES.recalculateNormals;\n #weldVertices = DEFAULT_VALUES.weldVertices;\n #weldTolerance = DEFAULT_VALUES.weldTolerance;\n #skipDegenerate = DEFAULT_VALUES.skipDegenerate;\n #requireWatertight = DEFAULT_VALUES.requireWatertight;\n #classes = DEFAULT_VALUES.classes;\n\n /**\n * Create a reusable format profile.\n *\n * The instance stores only normalized options; each `Read`, `Write`, or\n * `Inspect` call may provide non-mutating overrides.\n *\n * @param {CjsStlFormatOptions} [options={}] Default format values.\n * @throws {TypeError} If an option, output mode, numeric value, or class map is invalid.\n */\n constructor(options = {})\n {\n super();\n this.SetValues(options);\n }\n\n /**\n * Set format values for this reusable profile.\n *\n * @param {CjsStlFormatOptions} [options={}] Values to merge into the profile.\n * @returns {CjsStlFormat} This format profile.\n * @throws {TypeError} If an option, output mode, numeric value, or class map is invalid.\n */\n SetValues(options = {})\n {\n const values = normalizeValues(this.GetValues(), options, FORMAT_NAME);\n\n this.#emit = values.emit;\n this.#source = values.source;\n this.#binary = values.binary;\n this.#solidName = values.solidName;\n this.#scale = values.scale;\n this.#recalculateNormals = values.recalculateNormals;\n this.#weldVertices = values.weldVertices;\n this.#weldTolerance = values.weldTolerance;\n this.#skipDegenerate = values.skipDegenerate;\n this.#requireWatertight = values.requireWatertight;\n this.#classes = values.classes;\n\n return this;\n }\n\n /**\n * Get this profile's current values, optionally with per-call overrides.\n *\n * @param {CjsStlFormatOptions} [options={}] Optional values to merge into a copy.\n * @returns {CjsStlFormatOptions} A validated copy of the effective values.\n * @throws {TypeError} If an override is invalid.\n */\n GetValues(options = {})\n {\n return normalizeValues({\n emit: this.#emit,\n source: this.#source,\n binary: this.#binary,\n solidName: this.#solidName,\n scale: this.#scale,\n recalculateNormals: this.#recalculateNormals,\n weldVertices: this.#weldVertices,\n weldTolerance: this.#weldTolerance,\n skipDegenerate: this.#skipDegenerate,\n requireWatertight: this.#requireWatertight,\n classes: this.#classes\n }, options, FORMAT_NAME);\n }\n\n /**\n * Set multiple node-class constructors for this profile.\n *\n * @param {object} [classes] Map of node class keys to constructors.\n * @returns {CjsStlFormat} This format profile.\n */\n SetClasses(classes = {})\n {\n return this.SetValues({ classes });\n }\n\n /**\n * Set one node-class constructor for this profile.\n *\n * @param {string} type Node class key.\n * @param {Function|null|undefined} Class Constructor to use, or nullish to delete.\n * @returns {CjsStlFormat} This format profile.\n */\n SetClass(type, Class)\n {\n if (Class === null || Class === undefined)\n {\n validateClassKey(type, FORMAT_NAME);\n const classes = { ...this.#classes };\n delete classes[type];\n this.#classes = classes;\n return this;\n }\n\n validateClass(type, Class, FORMAT_NAME);\n return this.SetValues({ classes: { [type]: Class } });\n }\n\n /**\n * Get a configured node-class constructor.\n *\n * @param {string} type Node class key.\n * @returns {Function|undefined} The registered constructor, if any.\n */\n GetClass(type)\n {\n validateClassKey(type, FORMAT_NAME);\n return this.#classes[type];\n }\n\n /**\n * Whether this format profile has a constructor registered for a node class key.\n *\n * @param {string} type Node class key.\n * @returns {boolean} True when a constructor is registered.\n */\n HasClass(type)\n {\n return !!this.GetClass(type);\n }\n\n /**\n * Read STL text/bytes with this profile's values.\n *\n * @param {string|Uint8Array|ArrayBuffer|DataView} input STL text or bytes.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} The shared CarbonEngineJS JSON mesh schema.\n */\n Read(input, options = {})\n {\n return readWithValues(this, input, this.GetValues(options));\n }\n\n /**\n * Write shared JSON geometry as STL with this profile's values.\n *\n * Multiple meshes and index groups are flattened in encounter order because\n * STL has no portable material or scene hierarchy. Degenerate triangles are\n * skipped by default. Binary output validates that every coordinate is\n * representable as float32 rather than silently writing infinities.\n *\n * @param {CjsStlSharedRoot|CjsStlSharedMesh} input Shared JSON root or mesh.\n * @param {CjsStlFormatOptions} [options={}] Per-call writer overrides.\n * @returns {string|Uint8Array} ASCII STL text or binary STL bytes.\n * @throws {TypeError|RangeError|Error} If geometry, indices, coordinates, topology, or options are invalid.\n */\n Write(input, options = {})\n {\n return writeWithValues(input, this.GetValues(options));\n }\n\n /**\n * Inspect STL text/bytes or shared JSON geometry for printability blockers.\n *\n * @param {any} input STL text/bytes or shared JSON root/mesh.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Plain printability report.\n */\n Inspect(input, options = {})\n {\n return inspectWithValues(input, this.GetValues(options));\n }\n\n /**\n * Convert format output to JSON-compatible data.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n ToJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Static one-shot read. Static methods use camelCase by convention.\n *\n * @param {string|Uint8Array|ArrayBuffer|DataView} input STL text or bytes.\n * @param {object} [options] Format values.\n * @returns {object} The shared CarbonEngineJS JSON mesh schema.\n */\n static read(input, options = {})\n {\n return readWithValues(CjsStlFormat, input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\n }\n\n /**\n * Static one-shot write.\n *\n * The call is one-shot and does not mutate `input`. Multiple meshes and\n * index groups are flattened into a single STL solid in encounter order.\n *\n * @param {CjsStlSharedRoot|CjsStlSharedMesh} input Shared JSON root or mesh.\n * @param {CjsStlFormatOptions} [options={}] Writer values.\n * @returns {string|Uint8Array} ASCII STL text or binary STL bytes.\n * @throws {TypeError|RangeError|Error} If geometry, indices, coordinates, topology, or options are invalid.\n */\n static write(input, options = {})\n {\n return writeWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\n }\n\n /**\n * Static one-shot inspection.\n *\n * @param {any} input STL text/bytes or shared JSON root/mesh.\n * @param {object} [options] Format values.\n * @returns {object} Plain printability report.\n */\n static inspect(input, options = {})\n {\n return inspectWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\n }\n\n /**\n * Static JSON-compatible conversion.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n static toJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Cheap sniff for STL-like input.\n *\n * @param {string|Uint8Array|ArrayBuffer|DataView} input Candidate STL input.\n * @returns {boolean} True when input looks like STL.\n */\n static isStl(input)\n {\n return isStl(input);\n }\n\n /**\n * Check whether byte-like input has an exact binary STL layout.\n *\n * @param {string|Uint8Array|ArrayBuffer|DataView} input Candidate STL input.\n * @returns {boolean} True when input is binary STL bytes.\n */\n static isBinaryStl(input)\n {\n return isBinaryStl(input);\n }\n\n /**\n * Emit targets for this format (canonical frozen enum).\n */\n static Output = Object.freeze({\n JSON: OUTPUT_JSON,\n STL_JSON: OUTPUT_STL_JSON,\n SHARED: OUTPUT_SHARED,\n GR2: OUTPUT_GR2,\n CMF: OUTPUT_CMF\n });\n static CLASS_KEYS = CLASS_KEYS;\n static id = \"stl\";\n static mediaTypes = Object.freeze([ \"geometry\" ]);\n // STL takes the shared geometry root directly rather than going through\n // CMF, because it carries triangles and nothing else worth preserving.\n // Lossless for what STL can represent; everything else was never in scope.\n static inputs = CjsFormat.defineInputs({\n shared: { default: true, payloadType: \"geometry\", options: [ \"binary\", \"solidName\", \"scale\", \"recalculateNormals\", \"weldVertices\" ] }\n });\n\n static outputs = CjsFormat.defineOutputs({\n shared: { decoded: true },\n gr2: { decoded: true },\n cmf: { decoded: true },\n json: { role: \"debug\", decoded: true },\n stlJson: { role: \"debug\", default: true, decoded: true }\n });\n static extensions = Object.freeze([ \".stl\" ]);\n\n}\n\nexport default CjsStlFormat;\n"],"names":["FORMAT_NAME","CjsStlFormat","CjsFormat","DEFAULT_VALUES","emit","source","binary","solidName","scale","recalculateNormals","weldVertices","weldTolerance","skipDegenerate","requireWatertight","classes","constructor","options","SetValues","values","normalizeValues","GetValues","SetClasses","SetClass","type","Class","undefined","validateClassKey","validateClass","GetClass","HasClass","Read","input","readWithValues","Write","writeWithValues","Inspect","inspectWithValues","ToJSON","value","toJsonValue","read","write","inspect","toJSON","isStl","isBinaryStl","Output","Object","freeze","JSON","OUTPUT_JSON","STL_JSON","OUTPUT_STL_JSON","SHARED","OUTPUT_SHARED","GR2","OUTPUT_GR2","CMF","OUTPUT_CMF","CLASS_KEYS","id","mediaTypes","inputs","defineInputs","shared","default","payloadType","outputs","defineOutputs","decoded","gr2","cmf","json","role","stlJson","extensions"],"mappings":";;;;;AA2BA,MAAMA,WAAW,GAAG,cAAc;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,YAAY,SAASC,SAAS,CAC3C;AAEI,EAAA,KAAK,GAAGC,cAAc,CAACC,IAAI;AAC3B,EAAA,OAAO,GAAGD,cAAc,CAACE,MAAM;AAC/B,EAAA,OAAO,GAAGF,cAAc,CAACG,MAAM;AAC/B,EAAA,UAAU,GAAGH,cAAc,CAACI,SAAS;AACrC,EAAA,MAAM,GAAGJ,cAAc,CAACK,KAAK;AAC7B,EAAA,mBAAmB,GAAGL,cAAc,CAACM,kBAAkB;AACvD,EAAA,aAAa,GAAGN,cAAc,CAACO,YAAY;AAC3C,EAAA,cAAc,GAAGP,cAAc,CAACQ,aAAa;AAC7C,EAAA,eAAe,GAAGR,cAAc,CAACS,cAAc;AAC/C,EAAA,kBAAkB,GAAGT,cAAc,CAACU,iBAAiB;AACrD,EAAA,QAAQ,GAAGV,cAAc,CAACW,OAAO;;AAEjC;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACIC,EAAAA,WAAWA,CAACC,OAAO,GAAG,EAAE,EACxB;AACI,IAAA,KAAK,EAAE;AACP,IAAA,IAAI,CAACC,SAAS,CAACD,OAAO,CAAC;AA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O,EAAE,IAAI;AAAEC,MAAAA,WAAW,EAAE,UAAU;MAAElD,OAAO,EAAE,CAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,oBAAoB,EAAE,cAAc;AAAG;AACxI,GAAC,CAAC;AAEF,EAAA,OAAOmD,OAAO,GAAGjE,SAAS,CAACkE,aAAa,CAAC;AACrCJ,IAAAA,MAAM,EAAE;AAAEK,MAAAA,OAAO,EAAE;KAAM;AACzBC,IAAAA,GAAG,EAAE;AAAED,MAAAA,OAAO,EAAE;KAAM;AACtBE,IAAAA,GAAG,EAAE;AAAEF,MAAAA,OAAO,EAAE;KAAM;AACtBG,IAAAA,IAAI,EAAE;AAAEC,MAAAA,IAAI,EAAE,OAAO;AAAEJ,MAAAA,OAAO,EAAE;KAAM;AACtCK,IAAAA,OAAO,EAAE;AAAED,MAAAA,IAAI,EAAE,OAAO;AAAER,MAAAA,OAAO,EAAE,IAAI;AAAEI,MAAAA,OAAO,EAAE;AAAK;AAC3D,GAAC,CAAC;EACF,OAAOM,UAAU,GAAG5B,MAAM,CAACC,MAAM,CAAC,CAAE,MAAM,CAAE,CAAC;AAEjD;;;;"}
1
+ {"version":3,"file":"CjsStlFormat.js","sources":["../../../../../src/resource/formats/stl/CjsStlFormat.js"],"sourcesContent":["import { CjsFormat } from \"../../format/CjsFormat.js\";\nimport { CjsGeometryFormat } from \"../../format/CjsGeometryFormat.js\";\n/**\n * Exposed CarbonEngineJS-facing STL format class.\n *\n * Keep this file small and reviewable: STL parsing, writing, printability\n * inspection, option normalization, and JSON hydration live under src/core.\n */\n\nimport {\n CLASS_KEYS,\n DEFAULT_VALUES,\n OUTPUT_CMF,\n OUTPUT_GR2,\n OUTPUT_JSON,\n OUTPUT_SHARED,\n OUTPUT_STL_JSON,\n inspectWithValues,\n isBinaryStl,\n isStl,\n normalizeValues,\n readWithValues,\n toJsonValue,\n writeWithValues\n} from \"./core/helpers.js\";\n\nconst FORMAT_NAME = \"CjsStlFormat\";\n\n/**\n * Shared mesh accepted by the STL writer. STL exports only `vertex.position`\n * and triangular `indices[].faces`; all other shared channels are ignored.\n *\n * @typedef {object} CjsStlSharedMesh\n * @property {string} [name] Diagnostic mesh name; `solidName` controls the STL header.\n * @property {{position: ArrayLike<number>, normal?: ArrayLike<number>}} vertex Shared vertex channels.\n * @property {Array<{name?: string, faces: ArrayLike<number>}>} indices Triangle index groups.\n */\n\n/**\n * Shared geometry root accepted by the STL writer.\n *\n * @typedef {object} CjsStlSharedRoot\n * @property {Array<CjsStlSharedMesh>} meshes Meshes flattened into one STL solid.\n * @property {string} [grannyFileSource] Optional source label used by inspection.\n */\n\n/**\n * Reusable STL read, write, and inspection options.\n *\n * @typedef {object} CjsStlFormatOptions\n * @property {\"shared\"|\"stlJson\"|\"json\"|\"gr2\"|\"cmf\"} [emit=\"stlJson\"] Read output contract.\n * @property {string} [source=\"memory\"] Source label stored in read/inspection output.\n * @property {boolean} [binary=true] Whether writes return binary bytes instead of ASCII text.\n * @property {string} [solidName=\"carbonenginejs\"] Sanitized ASCII solid name and binary header label.\n * @property {number} [scale=1] Positive finite multiplier applied to exported positions.\n * @property {boolean} [recalculateNormals=true] Derive facet normals from winding instead of vertex normals.\n * @property {boolean} [weldVertices=false] Weld equal positions while reading STL.\n * @property {number} [weldTolerance=1e-5] Non-negative read/inspection position tolerance.\n * @property {boolean} [skipDegenerate=true] Omit degenerate shared triangles during writes.\n * @property {boolean} [requireWatertight=false] Reject writes with printability topology issues.\n * @property {Record<string, Function>} [classes] Caller constructors used for read hydration.\n */\n\n/**\n * CarbonEngineJS-facing STL format surface.\n *\n * The Cjs prefix marks this as a JavaScript format/construction boundary.\n * STL is a triangle-only import/export format; the JSON contract is the shared\n * CarbonEngineJS mesh schema.\n */\nexport class CjsStlFormat extends CjsGeometryFormat\n{\n\n _emit = DEFAULT_VALUES.emit;\n _source = DEFAULT_VALUES.source;\n _binary = DEFAULT_VALUES.binary;\n _solidName = DEFAULT_VALUES.solidName;\n _scale = DEFAULT_VALUES.scale;\n _recalculateNormals = DEFAULT_VALUES.recalculateNormals;\n _weldVertices = DEFAULT_VALUES.weldVertices;\n _weldTolerance = DEFAULT_VALUES.weldTolerance;\n _skipDegenerate = DEFAULT_VALUES.skipDegenerate;\n _requireWatertight = DEFAULT_VALUES.requireWatertight;\n _classes = DEFAULT_VALUES.classes;\n\n /**\n * Create a reusable format profile.\n *\n * The instance stores only normalized options; each `Read`, `Write`, or\n * `Inspect` call may provide non-mutating overrides.\n *\n * @param {CjsStlFormatOptions} [options={}] Default format values.\n * @throws {TypeError} If an option, output mode, numeric value, or class map is invalid.\n */\n constructor(options = {})\n {\n super();\n this.SetValues(options);\n }\n\n /**\n * Set format values for this reusable profile.\n *\n * @param {CjsStlFormatOptions} [options={}] Values to merge into the profile.\n * @returns {CjsStlFormat} This format profile.\n * @throws {TypeError} If an option, output mode, numeric value, or class map is invalid.\n */\n SetValues(options = {})\n {\n const values = normalizeValues(this.GetValues(), options, FORMAT_NAME);\n\n this._emit = values.emit;\n this._source = values.source;\n this._binary = values.binary;\n this._solidName = values.solidName;\n this._scale = values.scale;\n this._recalculateNormals = values.recalculateNormals;\n this._weldVertices = values.weldVertices;\n this._weldTolerance = values.weldTolerance;\n this._skipDegenerate = values.skipDegenerate;\n this._requireWatertight = values.requireWatertight;\n this._classes = values.classes;\n\n return this;\n }\n\n /**\n * Get this profile's current values, optionally with per-call overrides.\n *\n * @param {CjsStlFormatOptions} [options={}] Optional values to merge into a copy.\n * @returns {CjsStlFormatOptions} A validated copy of the effective values.\n * @throws {TypeError} If an override is invalid.\n */\n GetValues(options = {})\n {\n return normalizeValues({\n emit: this._emit,\n source: this._source,\n binary: this._binary,\n solidName: this._solidName,\n scale: this._scale,\n recalculateNormals: this._recalculateNormals,\n weldVertices: this._weldVertices,\n weldTolerance: this._weldTolerance,\n skipDegenerate: this._skipDegenerate,\n requireWatertight: this._requireWatertight,\n classes: this._classes\n }, options, FORMAT_NAME);\n }\n\n /**\n * Read STL text/bytes with this profile's values.\n *\n * @param {string|Uint8Array|ArrayBuffer|DataView} input STL text or bytes.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} The shared CarbonEngineJS JSON mesh schema.\n */\n Read(input, options = {})\n {\n return readWithValues(this, input, this.GetValues(options));\n }\n\n /**\n * Write shared JSON geometry as STL with this profile's values.\n *\n * Multiple meshes and index groups are flattened in encounter order because\n * STL has no portable material or scene hierarchy. Degenerate triangles are\n * skipped by default. Binary output validates that every coordinate is\n * representable as float32 rather than silently writing infinities.\n *\n * @param {CjsStlSharedRoot|CjsStlSharedMesh} input Shared JSON root or mesh.\n * @param {CjsStlFormatOptions} [options={}] Per-call writer overrides.\n * @returns {string|Uint8Array} ASCII STL text or binary STL bytes.\n * @throws {TypeError|RangeError|Error} If geometry, indices, coordinates, topology, or options are invalid.\n */\n Write(input, options = {})\n {\n return writeWithValues(input, this.GetValues(options));\n }\n\n /**\n * Inspect STL text/bytes or shared JSON geometry for printability blockers.\n *\n * @param {any} input STL text/bytes or shared JSON root/mesh.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Plain printability report.\n */\n Inspect(input, options = {})\n {\n return inspectWithValues(input, this.GetValues(options));\n }\n\n /**\n * Convert format output to JSON-compatible data.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n ToJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Static one-shot read. Static methods use camelCase by convention.\n *\n * @param {string|Uint8Array|ArrayBuffer|DataView} input STL text or bytes.\n * @param {object} [options] Format values.\n * @returns {object} The shared CarbonEngineJS JSON mesh schema.\n */\n static read(input, options = {})\n {\n return readWithValues(CjsStlFormat, input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\n }\n\n /**\n * Static one-shot write.\n *\n * The call is one-shot and does not mutate `input`. Multiple meshes and\n * index groups are flattened into a single STL solid in encounter order.\n *\n * @param {CjsStlSharedRoot|CjsStlSharedMesh} input Shared JSON root or mesh.\n * @param {CjsStlFormatOptions} [options={}] Writer values.\n * @returns {string|Uint8Array} ASCII STL text or binary STL bytes.\n * @throws {TypeError|RangeError|Error} If geometry, indices, coordinates, topology, or options are invalid.\n */\n static write(input, options = {})\n {\n return writeWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\n }\n\n /**\n * Static one-shot inspection.\n *\n * @param {any} input STL text/bytes or shared JSON root/mesh.\n * @param {object} [options] Format values.\n * @returns {object} Plain printability report.\n */\n static inspect(input, options = {})\n {\n return inspectWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\n }\n\n /**\n * Static JSON-compatible conversion.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n static toJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Cheap sniff for STL-like input.\n *\n * @param {string|Uint8Array|ArrayBuffer|DataView} input Candidate STL input.\n * @returns {boolean} True when input looks like STL.\n */\n static isStl(input)\n {\n return isStl(input);\n }\n\n /**\n * Check whether byte-like input has an exact binary STL layout.\n *\n * @param {string|Uint8Array|ArrayBuffer|DataView} input Candidate STL input.\n * @returns {boolean} True when input is binary STL bytes.\n */\n static isBinaryStl(input)\n {\n return isBinaryStl(input);\n }\n\n /**\n * Emit targets for this format (canonical frozen enum).\n */\n static classKeys = CLASS_KEYS;\n static id = \"CjsStlFormat\";\n // STL takes the shared geometry root directly rather than going through\n // CMF, because it carries triangles and nothing else worth preserving.\n // Lossless for what STL can represent; everything else was never in scope.\n static inputs = CjsFormat.defineInputs({\n shared: { default: true, payloadType: \"geometry\", options: [ \"binary\", \"solidName\", \"scale\", \"recalculateNormals\", \"weldVertices\" ] }\n });\n\n static outputs = CjsFormat.defineOutputs({\n shared: { decoded: true },\n gr2: { decoded: true },\n cmf: { decoded: true },\n json: { role: \"debug\", decoded: true },\n stlJson: { role: \"debug\", default: true, decoded: true }\n });\n static extensions = [ \".stl\" ];\n\n}\n\nexport default CjsStlFormat;\n"],"names":["FORMAT_NAME","CjsStlFormat","CjsGeometryFormat","_emit","DEFAULT_VALUES","emit","_source","source","_binary","binary","_solidName","solidName","_scale","scale","_recalculateNormals","recalculateNormals","_weldVertices","weldVertices","_weldTolerance","weldTolerance","_skipDegenerate","skipDegenerate","_requireWatertight","requireWatertight","_classes","classes","constructor","options","SetValues","values","normalizeValues","GetValues","Read","input","readWithValues","Write","writeWithValues","Inspect","inspectWithValues","ToJSON","value","toJsonValue","read","write","inspect","toJSON","isStl","isBinaryStl","classKeys","CLASS_KEYS","id","inputs","CjsFormat","defineInputs","shared","default","payloadType","outputs","defineOutputs","decoded","gr2","cmf","json","role","stlJson","extensions"],"mappings":";;;;;;AA0BA,MAAMA,WAAW,GAAG,cAAc;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,YAAY,SAASC,iBAAiB,CACnD;EAEIC,KAAK,GAAGC,cAAc,CAACC,IAAI;EAC3BC,OAAO,GAAGF,cAAc,CAACG,MAAM;EAC/BC,OAAO,GAAGJ,cAAc,CAACK,MAAM;EAC/BC,UAAU,GAAGN,cAAc,CAACO,SAAS;EACrCC,MAAM,GAAGR,cAAc,CAACS,KAAK;EAC7BC,mBAAmB,GAAGV,cAAc,CAACW,kBAAkB;EACvDC,aAAa,GAAGZ,cAAc,CAACa,YAAY;EAC3CC,cAAc,GAAGd,cAAc,CAACe,aAAa;EAC7CC,eAAe,GAAGhB,cAAc,CAACiB,cAAc;EAC/CC,kBAAkB,GAAGlB,cAAc,CAACmB,iBAAiB;EACrDC,QAAQ,GAAGpB,cAAc,CAACqB,OAAO;;AAEjC;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACIC,EAAAA,WAAWA,CAACC,OAAO,GAAG,EAAE,EACxB;AACI,IAAA,KAAK,E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8B,OAAO,GAAGL,SAAS,CAACM,aAAa,CAAC;AACrCJ,IAAAA,MAAM,EAAE;AAAEK,MAAAA,OAAO,EAAE;KAAM;AACzBC,IAAAA,GAAG,EAAE;AAAED,MAAAA,OAAO,EAAE;KAAM;AACtBE,IAAAA,GAAG,EAAE;AAAEF,MAAAA,OAAO,EAAE;KAAM;AACtBG,IAAAA,IAAI,EAAE;AAAEC,MAAAA,IAAI,EAAE,OAAO;AAAEJ,MAAAA,OAAO,EAAE;KAAM;AACtCK,IAAAA,OAAO,EAAE;AAAED,MAAAA,IAAI,EAAE,OAAO;AAAER,MAAAA,OAAO,EAAE,IAAI;AAAEI,MAAAA,OAAO,EAAE;AAAK;AAC3D,GAAC,CAAC;AACF,EAAA,OAAOM,UAAU,GAAG,CAAE,MAAM,CAAE;AAElC;;;;"}
@@ -1,6 +1,7 @@
1
+ import { CjsGeometryFormat } from '../../../format/CjsGeometryFormat.js';
1
2
  import { hydrateJson } from './json.js';
2
- import { buildCmfFromShared } from './targets.js';
3
3
  import { GR2_CLASS_KEYS, CMF_CLASS_KEYS } from '../../cmf/core/constants.js';
4
+ import { buildCmfFromFlatShared } from '../../cmf/core/flatShared.js';
4
5
  import { hydrateCmf } from '../../cmf/core/utils/hydration.js';
5
6
  import { parseStl, trianglesToJson, jsonToTriangles, inspectTriangles, writeBinaryStl, writeAsciiStl, trianglesFromInput } from './stl.js';
6
7
  export { isBinaryStl, isStl, toText } from './stl.js';
@@ -49,18 +50,6 @@ function validateNumber(name, value, readerName, {
49
50
  return value;
50
51
  }
51
52
 
52
- /**
53
- * Validate a `classes` node key against {@link CLASS_KEYS}.
54
- *
55
- * @param {string} key Candidate node key.
56
- * @param {string} [readerName] Format name used in thrown errors.
57
- */
58
- function validateClassKey(key, readerName = "CjsStlFormat") {
59
- if (!CLASS_KEYS.includes(key)) {
60
- throw new Error(`${readerName}: unknown class key ${JSON.stringify(key)}; expected one of ${CLASS_KEYS.join(", ")}`);
61
- }
62
- }
63
-
64
53
  /**
65
54
  * Validate a single `classes` entry.
66
55
  *
@@ -69,10 +58,7 @@ function validateClassKey(key, readerName = "CjsStlFormat") {
69
58
  * @param {string} [readerName] Format name used in thrown errors.
70
59
  */
71
60
  function validateClass(key, Class, readerName = "CjsStlFormat") {
72
- validateClassKey(key, readerName);
73
- if (typeof Class !== "function") {
74
- throw new TypeError(`${readerName}: class ${JSON.stringify(key)} must be a constructor`);
75
- }
61
+ CjsGeometryFormat.validateClass(key, Class, CLASS_KEYS, readerName);
76
62
  }
77
63
  function mergeClasses(base, classes, readerName) {
78
64
  if (!classes || typeof classes !== "object") {
@@ -168,7 +154,7 @@ function readWithValues(format, input, values) {
168
154
  const parsed = parseStl(input);
169
155
  const json = trianglesToJson(parsed.triangles, values, parsed);
170
156
  if (values.emit === OUTPUT_CMF) {
171
- return hydrateCmf(buildCmfFromShared(json), values.classes, {
157
+ return hydrateCmf(buildCmfFromFlatShared(json), values.classes, {
172
158
  source: values.source
173
159
  }, "CjsStlFormat CMF");
174
160
  }
@@ -218,5 +204,5 @@ function inspectWithValues(input, values) {
218
204
  return inspectTriangles(source.triangles, values, source);
219
205
  }
220
206
 
221
- export { CLASS_KEYS, DEFAULT_VALUES, GR2_CLASS_KEYS, OUTPUT_CMF, OUTPUT_GR2, OUTPUT_JSON, OUTPUT_SHARED, OUTPUT_STL_JSON, inspectWithValues, normalizeValues, readWithValues, validateClass, validateClassKey, writeWithValues };
207
+ export { CLASS_KEYS, DEFAULT_VALUES, GR2_CLASS_KEYS, OUTPUT_CMF, OUTPUT_GR2, OUTPUT_JSON, OUTPUT_SHARED, OUTPUT_STL_JSON, inspectWithValues, normalizeValues, readWithValues, validateClass, writeWithValues };
222
208
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sources":["../../../../../../src/resource/formats/stl/core/helpers.js"],"sourcesContent":["/**\n * Internal pipeline glue for CjsStlFormat.\n */\n\nimport { toJsonWithArrayValues as toJsonValue } from \"../../../format/jsonPolicies.js\";\nimport { hydrateJson } from \"./json.js\";\nimport { buildCmfFromShared, CMF_CLASS_KEYS } from \"./targets.js\";\nimport { GR2_CLASS_KEYS } from \"../../cmf/core/constants.js\";\nimport { hydrateCmf } from \"../../cmf/core/utils/hydration.js\";\nimport {\n inspectTriangles,\n isBinaryStl,\n isStl,\n jsonToTriangles,\n parseStl,\n toText,\n trianglesFromInput,\n trianglesToJson,\n writeAsciiStl,\n writeBinaryStl\n} from \"./stl.js\";\n\nexport { GR2_CLASS_KEYS };\n\nexport const CLASS_KEYS = Object.freeze(Array.from(new Set([\n ...GR2_CLASS_KEYS,\n ...CMF_CLASS_KEYS\n])));\n\nexport { isBinaryStl, isStl, toText };\n\nexport const OUTPUT_JSON = \"json\";\nexport const OUTPUT_STL_JSON = \"stlJson\";\nexport const OUTPUT_SHARED = \"shared\";\nexport const OUTPUT_GR2 = \"gr2\";\nexport const OUTPUT_CMF = \"cmf\";\n\nexport const DEFAULT_VALUES = Object.freeze({\n emit: OUTPUT_STL_JSON,\n source: \"memory\",\n binary: true,\n solidName: \"carbonenginejs\",\n scale: 1,\n recalculateNormals: true,\n weldVertices: false,\n weldTolerance: 1e-5,\n skipDegenerate: true,\n requireWatertight: false,\n classes: Object.freeze({})\n});\n\nconst OPTION_KEYS = new Set([\n \"emit\",\n \"source\",\n \"binary\",\n \"solidName\",\n \"scale\",\n \"recalculateNormals\",\n \"weldVertices\",\n \"weldTolerance\",\n \"skipDegenerate\",\n \"requireWatertight\",\n \"classes\"\n]);\n\nfunction validateBoolean(name, value, readerName)\n{\n if (typeof value === \"boolean\") return value;\n throw new TypeError(`${readerName}: ${name} must be true or false`);\n}\n\nfunction validateNumber(name, value, readerName, { minExclusive = null, minInclusive = null } = {})\n{\n if (typeof value !== \"number\" || !Number.isFinite(value))\n {\n throw new TypeError(`${readerName}: ${name} must be a finite number`);\n }\n if (minExclusive !== null && value <= minExclusive)\n {\n throw new TypeError(`${readerName}: ${name} must be greater than ${minExclusive}`);\n }\n if (minInclusive !== null && value < minInclusive)\n {\n throw new TypeError(`${readerName}: ${name} must be at least ${minInclusive}`);\n }\n return value;\n}\n\n/**\n * Validate a `classes` node key against {@link CLASS_KEYS}.\n *\n * @param {string} key Candidate node key.\n * @param {string} [readerName] Format name used in thrown errors.\n */\nexport function validateClassKey(key, readerName = \"CjsStlFormat\")\n{\n if (!CLASS_KEYS.includes(key))\n {\n throw new Error(`${readerName}: unknown class key ${JSON.stringify(key)}; expected one of ${CLASS_KEYS.join(\", \")}`);\n }\n}\n\n/**\n * Validate a single `classes` entry.\n *\n * @param {string} key Node key.\n * @param {Function} Class Candidate constructor.\n * @param {string} [readerName] Format name used in thrown errors.\n */\nexport function validateClass(key, Class, readerName = \"CjsStlFormat\")\n{\n validateClassKey(key, readerName);\n if (typeof Class !== \"function\")\n {\n throw new TypeError(`${readerName}: class ${JSON.stringify(key)} must be a constructor`);\n }\n}\n\nfunction mergeClasses(base, classes, readerName)\n{\n if (!classes || typeof classes !== \"object\")\n {\n throw new TypeError(`${readerName}: classes option must be an object`);\n }\n\n const next = { ...base };\n for (const [ key, Class ] of Object.entries(classes))\n {\n if (Class === null || Class === undefined)\n {\n delete next[key];\n continue;\n }\n validateClass(key, Class, readerName);\n next[key] = Class;\n }\n return next;\n}\n\nfunction sanitizeName(value)\n{\n if (typeof value !== \"string\" || !value.trim()) return DEFAULT_VALUES.solidName;\n return value.trim();\n}\n\n/**\n * Merge format values over a base set and validate them.\n *\n * @param {object} base Current values.\n * @param {object} [options] Values to merge in.\n * @param {string} [readerName] Format name used in error messages.\n * @returns {object} A validated copy of the merged values.\n */\nexport function normalizeValues(base, options = {}, readerName = \"CjsStlFormat\")\n{\n if (!options || typeof options !== \"object\")\n {\n throw new TypeError(`${readerName}: options must be an object`);\n }\n for (const key of Object.keys(options))\n {\n if (!OPTION_KEYS.has(key))\n {\n throw new TypeError(`${readerName}: unknown option ${JSON.stringify(key)}`);\n }\n }\n\n const values = { ...base, ...options };\n const emit = normalizeEmit(values.emit, readerName);\n const classes = Object.prototype.hasOwnProperty.call(options, \"classes\")\n ? mergeClasses(base.classes || {}, options.classes, readerName)\n : { ...(base.classes || {}) };\n if ((emit === OUTPUT_GR2 || emit === OUTPUT_CMF) && !hasClasses(classes))\n {\n throw new TypeError(`${readerName}: emit \"${emit}\" requires explicit classes`);\n }\n if (typeof values.source !== \"string\" || !values.source)\n {\n values.source = DEFAULT_VALUES.source;\n }\n\n return {\n emit,\n source: values.source,\n binary: validateBoolean(\"binary\", values.binary, readerName),\n solidName: sanitizeName(values.solidName),\n scale: validateNumber(\"scale\", values.scale, readerName, { minExclusive: 0 }),\n recalculateNormals: validateBoolean(\"recalculateNormals\", values.recalculateNormals, readerName),\n weldVertices: validateBoolean(\"weldVertices\", values.weldVertices, readerName),\n weldTolerance: validateNumber(\"weldTolerance\", values.weldTolerance, readerName, { minInclusive: 0 }),\n skipDegenerate: validateBoolean(\"skipDegenerate\", values.skipDegenerate, readerName),\n requireWatertight: validateBoolean(\"requireWatertight\", values.requireWatertight, readerName),\n classes\n };\n}\n\nfunction normalizeEmit(emit, readerName)\n{\n if (emit === undefined || emit === null || emit === OUTPUT_JSON || emit === OUTPUT_STL_JSON || emit === OUTPUT_SHARED)\n {\n return OUTPUT_STL_JSON;\n }\n if (emit === OUTPUT_GR2 || emit === OUTPUT_CMF) return emit;\n throw new TypeError(`${readerName}: emit must be \"${OUTPUT_SHARED}\", \"${OUTPUT_STL_JSON}\", \"${OUTPUT_GR2}\", or \"${OUTPUT_CMF}\", got ${JSON.stringify(emit)}`);\n}\n\nfunction hasClasses(classes)\n{\n return !!classes && Object.values(classes).some((Class) => typeof Class === \"function\");\n}\n\n/**\n * Read STL text/bytes and return the shared JSON schema.\n *\n * @param {object|Function} format Format instance or constructor.\n * @param {string|Uint8Array|ArrayBuffer|DataView} input STL text or bytes.\n * @param {object} values Normalized format values.\n * @returns {object} Shared JSON graph.\n */\nexport function readWithValues(format, input, values)\n{\n void format;\n const parsed = parseStl(input);\n const json = trianglesToJson(parsed.triangles, values, parsed);\n if (values.emit === OUTPUT_CMF)\n {\n return hydrateCmf(\n buildCmfFromShared(json),\n values.classes,\n { source: values.source },\n \"CjsStlFormat CMF\"\n );\n }\n return hydrateJson(json, { classes: values.classes, source: values.source });\n}\n\n/**\n * Write the shared JSON geometry schema to STL.\n * The input is read-only. Meshes and index groups are flattened by\n * {@link jsonToTriangles}; optional topology enforcement runs against that\n * exact scaled triangle stream before encoding begins.\n *\n * @param {object} input Shared JSON root or mesh.\n * @param {object} values Normalized format values.\n * @returns {string|Uint8Array} ASCII STL text or binary STL bytes.\n * @throws {TypeError|RangeError|Error} If geometry, numeric values, indices, topology, or binary range are invalid.\n */\nexport function writeWithValues(input, values)\n{\n const triangles = jsonToTriangles(input, values);\n if (!triangles.length)\n {\n throw new Error(\"CjsStlFormat: write input did not produce any triangles\");\n }\n\n if (values.requireWatertight)\n {\n const report = inspectTriangles(triangles, values, { format: \"json\", source: input.grannyFileSource || values.source });\n if (!report.printable)\n {\n throw new Error(`CjsStlFormat: requireWatertight failed (${report.issues.map(issue => issue.key).join(\", \")})`);\n }\n }\n\n return values.binary\n ? writeBinaryStl(triangles, values.solidName)\n : writeAsciiStl(triangles, values.solidName);\n}\n\n/**\n * Inspect STL or shared JSON geometry without class hydration.\n *\n * @param {any} input STL text/bytes or shared JSON.\n * @param {object} values Normalized format values.\n * @returns {object} Plain printability report.\n */\nexport function inspectWithValues(input, values)\n{\n const source = trianglesFromInput(input, values);\n return inspectTriangles(source.triangles, values, source);\n}\n\n/**\n * Convert format output to plain JSON-compatible data.\n *\n * @param {any} value Format output.\n * @returns {any} JSON-compatible value.\n */\n/** The shared JSON policy for this reader, under the name its callers use. */\nexport { toJsonValue };\n\n"],"names":["CLASS_KEYS","Object","freeze","Array","from","Set","GR2_CLASS_KEYS","CMF_CLASS_KEYS","OUTPUT_JSON","OUTPUT_STL_JSON","OUTPUT_SHARED","OUTPUT_GR2","OUTPUT_CMF","DEFAULT_VALUES","emit","source","binary","solidName","scale","recalculateNormals","weldVertices","weldTolerance","skipDegenerate","requireWatertight","classes","OPTION_KEYS","validateBoolean","name","value","readerName","TypeError","validateNumber","minExclusive","minInclusive","Number","isFinite","validateClassKey","key","includes","Error","JSON","stringify","join","validateClass","Class","mergeClasses","base","next","entries","undefined","sanitizeName","trim","normalizeValues","options","keys","has","values","normalizeEmit","prototype","hasOwnProperty","call","hasClasses","some","readWithValues","format","input","parsed","parseStl","json","trianglesToJson","triangles","hydrateCmf","buildCmfFromShared","hydrateJson","writeWithValues","jsonToTriangles","length","report","inspectTriangles","grannyFileSource","printable","issues","map","issue","writeBinaryStl","writeAsciiStl","inspectWithValues","trianglesFromInput"],"mappings":";;;;;;;AAAA;AACA;AACA;;AAsBO,MAAMA,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACC,KAAK,CAACC,IAAI,CAAC,IAAIC,GAAG,CAAC,CACvD,GAAGC,cAAc,EACjB,GAAGC,cAAc,CACpB,CAAC,CAAC;AAII,MAAMC,WAAW,GAAG;AACpB,MAAMC,eAAe,GAAG;AACxB,MAAMC,aAAa,GAAG;AACtB,MAAMC,UAAU,GAAG;AACnB,MAAMC,UAAU,GAAG;MAEbC,cAAc,GAAGZ,MAAM,CAACC,MAAM,CAAC;AACxCY,EAAAA,IAAI,EAAEL,eAAe;AACrBM,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,MAAM,EAAE,IAAI;AACZC,EAAAA,SAAS,EAAE,gBAAgB;AAC3BC,EAAAA,KAAK,EAAE,CAAC;AACRC,EAAAA,kBAAkB,EAAE,IAAI;AACxBC,EAAAA,YAAY,EAAE,KAAK;AACnBC,EAAAA,aAAa,EAAE,IAAI;AACnBC,EAAAA,cAAc,EAAE,IAAI;AACpBC,EAAAA,iBAAiB,EAAE,KAAK;AACxBC,EAAAA,OAAO,EAAEvB,MAAM,CAACC,MAAM,CAAC,EAAE;AAC7B,CAAC;AAED,MAAMuB,WAAW,GAAG,IAAIpB,GAAG,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,CAACtB,KAAK,EAAET,MAAM,CAAC;EAChD,OAAOsB,gBAAgB,CAAC/D,MAAM,CAACuD,SAAS,EAAEd,MAAM,EAAEzC,MAAM,CAAC;AAC7D;;;;"}
1
+ {"version":3,"file":"helpers.js","sources":["../../../../../../src/resource/formats/stl/core/helpers.js"],"sourcesContent":["/**\n * Internal pipeline glue for CjsStlFormat.\n */\n\nimport { CjsGeometryFormat } from \"../../../format/CjsGeometryFormat.js\";\nimport { toJsonWithArrayValues as toJsonValue } from \"../../../format/jsonPolicies.js\";\nimport { hydrateJson } from \"./json.js\";\nimport { buildCmfFromShared, CMF_CLASS_KEYS } from \"./targets.js\";\nimport { GR2_CLASS_KEYS } from \"../../cmf/core/constants.js\";\nimport { hydrateCmf } from \"../../cmf/core/utils/hydration.js\";\nimport {\n inspectTriangles,\n isBinaryStl,\n isStl,\n jsonToTriangles,\n parseStl,\n toText,\n trianglesFromInput,\n trianglesToJson,\n writeAsciiStl,\n writeBinaryStl\n} from \"./stl.js\";\n\nexport { GR2_CLASS_KEYS };\n\nexport const CLASS_KEYS = Object.freeze(Array.from(new Set([\n ...GR2_CLASS_KEYS,\n ...CMF_CLASS_KEYS\n])));\n\nexport { isBinaryStl, isStl, toText };\n\nexport const OUTPUT_JSON = \"json\";\nexport const OUTPUT_STL_JSON = \"stlJson\";\nexport const OUTPUT_SHARED = \"shared\";\nexport const OUTPUT_GR2 = \"gr2\";\nexport const OUTPUT_CMF = \"cmf\";\n\nexport const DEFAULT_VALUES = Object.freeze({\n emit: OUTPUT_STL_JSON,\n source: \"memory\",\n binary: true,\n solidName: \"carbonenginejs\",\n scale: 1,\n recalculateNormals: true,\n weldVertices: false,\n weldTolerance: 1e-5,\n skipDegenerate: true,\n requireWatertight: false,\n classes: Object.freeze({})\n});\n\nconst OPTION_KEYS = new Set([\n \"emit\",\n \"source\",\n \"binary\",\n \"solidName\",\n \"scale\",\n \"recalculateNormals\",\n \"weldVertices\",\n \"weldTolerance\",\n \"skipDegenerate\",\n \"requireWatertight\",\n \"classes\"\n]);\n\nfunction validateBoolean(name, value, readerName)\n{\n if (typeof value === \"boolean\") return value;\n throw new TypeError(`${readerName}: ${name} must be true or false`);\n}\n\nfunction validateNumber(name, value, readerName, { minExclusive = null, minInclusive = null } = {})\n{\n if (typeof value !== \"number\" || !Number.isFinite(value))\n {\n throw new TypeError(`${readerName}: ${name} must be a finite number`);\n }\n if (minExclusive !== null && value <= minExclusive)\n {\n throw new TypeError(`${readerName}: ${name} must be greater than ${minExclusive}`);\n }\n if (minInclusive !== null && value < minInclusive)\n {\n throw new TypeError(`${readerName}: ${name} must be at least ${minInclusive}`);\n }\n return value;\n}\n\n/**\n * Validate a `classes` node key against {@link CLASS_KEYS}.\n *\n * @param {string} key Candidate node key.\n * @param {string} [readerName] Format name used in thrown errors.\n */\nexport function validateClassKey(key, readerName = \"CjsStlFormat\")\n{\n CjsGeometryFormat.validateClassKey(key, CLASS_KEYS, readerName);\n}\n\n/**\n * Validate a single `classes` entry.\n *\n * @param {string} key Node key.\n * @param {Function} Class Candidate constructor.\n * @param {string} [readerName] Format name used in thrown errors.\n */\nexport function validateClass(key, Class, readerName = \"CjsStlFormat\")\n{\n CjsGeometryFormat.validateClass(key, Class, CLASS_KEYS, readerName);\n}\n\nfunction mergeClasses(base, classes, readerName)\n{\n if (!classes || typeof classes !== \"object\")\n {\n throw new TypeError(`${readerName}: classes option must be an object`);\n }\n\n const next = { ...base };\n for (const [ key, Class ] of Object.entries(classes))\n {\n if (Class === null || Class === undefined)\n {\n delete next[key];\n continue;\n }\n validateClass(key, Class, readerName);\n next[key] = Class;\n }\n return next;\n}\n\nfunction sanitizeName(value)\n{\n if (typeof value !== \"string\" || !value.trim()) return DEFAULT_VALUES.solidName;\n return value.trim();\n}\n\n/**\n * Merge format values over a base set and validate them.\n *\n * @param {object} base Current values.\n * @param {object} [options] Values to merge in.\n * @param {string} [readerName] Format name used in error messages.\n * @returns {object} A validated copy of the merged values.\n */\nexport function normalizeValues(base, options = {}, readerName = \"CjsStlFormat\")\n{\n if (!options || typeof options !== \"object\")\n {\n throw new TypeError(`${readerName}: options must be an object`);\n }\n for (const key of Object.keys(options))\n {\n if (!OPTION_KEYS.has(key))\n {\n throw new TypeError(`${readerName}: unknown option ${JSON.stringify(key)}`);\n }\n }\n\n const values = { ...base, ...options };\n const emit = normalizeEmit(values.emit, readerName);\n const classes = Object.prototype.hasOwnProperty.call(options, \"classes\")\n ? mergeClasses(base.classes || {}, options.classes, readerName)\n : { ...(base.classes || {}) };\n if ((emit === OUTPUT_GR2 || emit === OUTPUT_CMF) && !hasClasses(classes))\n {\n throw new TypeError(`${readerName}: emit \"${emit}\" requires explicit classes`);\n }\n if (typeof values.source !== \"string\" || !values.source)\n {\n values.source = DEFAULT_VALUES.source;\n }\n\n return {\n emit,\n source: values.source,\n binary: validateBoolean(\"binary\", values.binary, readerName),\n solidName: sanitizeName(values.solidName),\n scale: validateNumber(\"scale\", values.scale, readerName, { minExclusive: 0 }),\n recalculateNormals: validateBoolean(\"recalculateNormals\", values.recalculateNormals, readerName),\n weldVertices: validateBoolean(\"weldVertices\", values.weldVertices, readerName),\n weldTolerance: validateNumber(\"weldTolerance\", values.weldTolerance, readerName, { minInclusive: 0 }),\n skipDegenerate: validateBoolean(\"skipDegenerate\", values.skipDegenerate, readerName),\n requireWatertight: validateBoolean(\"requireWatertight\", values.requireWatertight, readerName),\n classes\n };\n}\n\nfunction normalizeEmit(emit, readerName)\n{\n if (emit === undefined || emit === null || emit === OUTPUT_JSON || emit === OUTPUT_STL_JSON || emit === OUTPUT_SHARED)\n {\n return OUTPUT_STL_JSON;\n }\n if (emit === OUTPUT_GR2 || emit === OUTPUT_CMF) return emit;\n throw new TypeError(`${readerName}: emit must be \"${OUTPUT_SHARED}\", \"${OUTPUT_STL_JSON}\", \"${OUTPUT_GR2}\", or \"${OUTPUT_CMF}\", got ${JSON.stringify(emit)}`);\n}\n\nfunction hasClasses(classes)\n{\n return !!classes && Object.values(classes).some((Class) => typeof Class === \"function\");\n}\n\n/**\n * Read STL text/bytes and return the shared JSON schema.\n *\n * @param {object|Function} format Format instance or constructor.\n * @param {string|Uint8Array|ArrayBuffer|DataView} input STL text or bytes.\n * @param {object} values Normalized format values.\n * @returns {object} Shared JSON graph.\n */\nexport function readWithValues(format, input, values)\n{\n void format;\n const parsed = parseStl(input);\n const json = trianglesToJson(parsed.triangles, values, parsed);\n if (values.emit === OUTPUT_CMF)\n {\n return hydrateCmf(\n buildCmfFromShared(json),\n values.classes,\n { source: values.source },\n \"CjsStlFormat CMF\"\n );\n }\n return hydrateJson(json, { classes: values.classes, source: values.source });\n}\n\n/**\n * Write the shared JSON geometry schema to STL.\n * The input is read-only. Meshes and index groups are flattened by\n * {@link jsonToTriangles}; optional topology enforcement runs against that\n * exact scaled triangle stream before encoding begins.\n *\n * @param {object} input Shared JSON root or mesh.\n * @param {object} values Normalized format values.\n * @returns {string|Uint8Array} ASCII STL text or binary STL bytes.\n * @throws {TypeError|RangeError|Error} If geometry, numeric values, indices, topology, or binary range are invalid.\n */\nexport function writeWithValues(input, values)\n{\n const triangles = jsonToTriangles(input, values);\n if (!triangles.length)\n {\n throw new Error(\"CjsStlFormat: write input did not produce any triangles\");\n }\n\n if (values.requireWatertight)\n {\n const report = inspectTriangles(triangles, values, { format: \"json\", source: input.grannyFileSource || values.source });\n if (!report.printable)\n {\n throw new Error(`CjsStlFormat: requireWatertight failed (${report.issues.map(issue => issue.key).join(\", \")})`);\n }\n }\n\n return values.binary\n ? writeBinaryStl(triangles, values.solidName)\n : writeAsciiStl(triangles, values.solidName);\n}\n\n/**\n * Inspect STL or shared JSON geometry without class hydration.\n *\n * @param {any} input STL text/bytes or shared JSON.\n * @param {object} values Normalized format values.\n * @returns {object} Plain printability report.\n */\nexport function inspectWithValues(input, values)\n{\n const source = trianglesFromInput(input, values);\n return inspectTriangles(source.triangles, values, source);\n}\n\n/**\n * Convert format output to plain JSON-compatible data.\n *\n * @param {any} value Format output.\n * @returns {any} JSON-compatible value.\n */\n/** The shared JSON policy for this reader, under the name its callers use. */\nexport { toJsonValue };\n\n"],"names":["CLASS_KEYS","Object","freeze","Array","from","Set","GR2_CLASS_KEYS","CMF_CLASS_KEYS","OUTPUT_JSON","OUTPUT_STL_JSON","OUTPUT_SHARED","OUTPUT_GR2","OUTPUT_CMF","DEFAULT_VALUES","emit","source","binary","solidName","scale","recalculateNormals","weldVertices","weldTolerance","skipDegenerate","requireWatertight","classes","OPTION_KEYS","validateBoolean","name","value","readerName","TypeError","validateNumber","minExclusive","minInclusive","Number","isFinite","validateClass","key","Class","CjsGeometryFormat","mergeClasses","base","next","entries","undefined","sanitizeName","trim","normalizeValues","options","keys","has","JSON","stringify","values","normalizeEmit","prototype","hasOwnProperty","call","hasClasses","some","readWithValues","format","input","parsed","parseStl","json","trianglesToJson","triangles","hydrateCmf","buildCmfFromShared","hydrateJson","writeWithValues","jsonToTriangles","length","Error","report","inspectTriangles","grannyFileSource","printable","issues","map","issue","join","writeBinaryStl","writeAsciiStl","inspectWithValues","trianglesFromInput"],"mappings":";;;;;;;;AAAA;AACA;AACA;;AAuBO,MAAMA,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACC,KAAK,CAACC,IAAI,CAAC,IAAIC,GAAG,CAAC,CACvD,GAAGC,cAAc,EACjB,GAAGC,cAAc,CACpB,CAAC,CAAC;AAII,MAAMC,WAAW,GAAG;AACpB,MAAMC,eAAe,GAAG;AACxB,MAAMC,aAAa,GAAG;AACtB,MAAMC,UAAU,GAAG;AACnB,MAAMC,UAAU,GAAG;MAEbC,cAAc,GAAGZ,MAAM,CAACC,MAAM,CAAC;AACxCY,EAAAA,IAAI,EAAEL,eAAe;AACrBM,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,MAAM,EAAE,IAAI;AACZC,EAAAA,SAAS,EAAE,gBAAgB;AAC3BC,EAAAA,KAAK,EAAE,CAAC;AACRC,EAAAA,kBAAkB,EAAE,IAAI;AACxBC,EAAAA,YAAY,EAAE,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AACV,KAAK,EAAET,MAAM,CAAC;AAChD,EAAA,IAAI,CAACc,SAAS,CAACM,MAAM,EACrB;AACI,IAAA,MAAM,IAAIC,KAAK,CAAC,yDAAyD,CAAC;AAC9E,EAAA;EAEA,IAAIrB,MAAM,CAAC9B,iBAAiB,EAC5B;AACI,IAAA,MAAMoD,MAAM,GAAGC,gBAAgB,CAACT,SAAS,EAAEd,MAAM,EAAE;AAAEQ,MAAAA,MAAM,EAAE,MAAM;AAAE9C,MAAAA,MAAM,EAAE+C,KAAK,CAACe,gBAAgB,IAAIxB,MAAM,CAACtC;AAAO,KAAC,CAAC;AACvH,IAAA,IAAI,CAAC4D,MAAM,CAACG,SAAS,EACrB;MACI,MAAM,IAAIJ,KAAK,CAAC,CAAA,wCAAA,EAA2CC,MAAM,CAACI,MAAM,CAACC,GAAG,CAACC,KAAK,IAAIA,KAAK,CAAC5C,GAAG,CAAC,CAAC6C,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG,CAAC;AACnH,IAAA;AACJ,EAAA;EAEA,OAAO7B,MAAM,CAACrC,MAAM,GACdmE,cAAc,CAAChB,SAAS,EAAEd,MAAM,CAACpC,SAAS,CAAC,GAC3CmE,aAAa,CAACjB,SAAS,EAAEd,MAAM,CAACpC,SAAS,CAAC;AACpD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASoE,iBAAiBA,CAACvB,KAAK,EAAET,MAAM,EAC/C;AACI,EAAA,MAAMtC,MAAM,GAAGuE,kBAAkB,CAACxB,KAAK,EAAET,MAAM,CAAC;EAChD,OAAOuB,gBAAgB,CAAC7D,MAAM,CAACoD,SAAS,EAAEd,MAAM,EAAEtC,MAAM,CAAC;AAC7D;;;;"}
@@ -1,6 +1,7 @@
1
1
  import { asUint8Array } from '#utils/bytes';
2
2
  import { CjsFormat } from '../../format/CjsFormat.js';
3
- import { DEFAULT_VALUES, normalizeValues, readWithValues, inspectWithValues, probeSupportWithValues, OUTPUT_JSON, OUTPUT_RAW, OUTPUT_RGBA, OUTPUT_IMAGE } from './core/helpers.js';
3
+ import { CjsImageFormat } from '../../format/CjsImageFormat.js';
4
+ import { DEFAULT_VALUES, normalizeValues, readWithValues, inspectWithValues, probeSupportWithValues } from './core/helpers.js';
4
5
  import { encodeTga } from './core/writer.js';
5
6
  import { toJsonWithByteSummary } from '../../format/jsonPolicies.js';
6
7
  import { isTGA } from '../../format/imageSignatures.js';
@@ -11,8 +12,8 @@ const FORMAT_NAME = "CjsTgaFormat";
11
12
  * TGA format profile that inspects header metadata and reads TGA bytes into
12
13
  * raw, debug JSON, or decoded RGBA image payloads.
13
14
  */
14
- class CjsTgaFormat extends CjsFormat {
15
- #values = DEFAULT_VALUES;
15
+ class CjsTgaFormat extends CjsImageFormat {
16
+ _values = DEFAULT_VALUES;
16
17
 
17
18
  /**
18
19
  * One-shot TGA write from a normalized RGBA payload.
@@ -53,7 +54,7 @@ class CjsTgaFormat extends CjsFormat {
53
54
  * @returns {CjsTgaFormat} This format profile.
54
55
  */
55
56
  SetValues(options = {}) {
56
- this.#values = normalizeValues(this.#values, {
57
+ this._values = normalizeValues(this._values, {
57
58
  inputType: "tga",
58
59
  ...options
59
60
  }, FORMAT_NAME);
@@ -67,7 +68,7 @@ class CjsTgaFormat extends CjsFormat {
67
68
  * @returns {object} Normalized read values.
68
69
  */
69
70
  GetValues(options = {}) {
70
- return normalizeValues(this.#values, {
71
+ return normalizeValues(this._values, {
71
72
  inputType: "tga",
72
73
  ...options
73
74
  }, FORMAT_NAME);
@@ -196,15 +197,9 @@ class CjsTgaFormat extends CjsFormat {
196
197
  /**
197
198
  * Emit targets for this format (canonical frozen enum).
198
199
  */
199
- static Output = Object.freeze({
200
- IMAGE: OUTPUT_IMAGE,
201
- RGBA: OUTPUT_RGBA,
202
- RAW: OUTPUT_RAW,
203
- JSON: OUTPUT_JSON
204
- });
205
- static OUTPUT_TGA_JSON = "tgaJson";
206
- static id = "tga";
207
- static mediaTypes = Object.freeze(["image"]);
200
+
201
+ static id = "CjsTgaFormat";
202
+ static mediaTypes = ["image"];
208
203
  static inputs = CjsFormat.defineInputs({
209
204
  rgba: {
210
205
  default: true,
@@ -229,7 +224,23 @@ class CjsTgaFormat extends CjsFormat {
229
224
  passthrough: true
230
225
  }
231
226
  });
232
- static extensions = Object.freeze([".tga"]);
227
+
228
+ /**
229
+ * Fill a HostBitmap through this format's RGBA8 output, for Carbon's ImageIO
230
+ * registry (`CjsTgaFormat.carbon`). See CjsImageFormat.readImageFromRgbaPayload.
231
+ *
232
+ * @param {Uint8Array|ArrayBuffer} input Image bytes.
233
+ * @param {object} _loadParameters Load parameters; a single-mip image skips nothing.
234
+ * @param {object} bitmap Destination HostBitmap.
235
+ * @param {object|null} [metadata] Optional Metadata out.
236
+ * @returns {object} ImageIOResult.
237
+ */
238
+ static readImageNative(input, _loadParameters, bitmap, metadata = null) {
239
+ return this.readImageFromRgbaPayload(this.read(input, {
240
+ emit: "rgba"
241
+ }), bitmap, metadata);
242
+ }
243
+ static extensions = [".tga"];
233
244
  }
234
245
 
235
246
  export { CjsTgaFormat };
@@ -1 +1 @@
1
- {"version":3,"file":"CjsTgaFormat.js","sources":["../../../../../src/resource/formats/tga/CjsTgaFormat.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 probeSupportWithValues,\n isTGA,\n normalizeValues,\n readWithValues,\n toJsonValue\n} from \"./core/helpers.js\";\nimport { encodeTga } from \"./core/writer.js\";\n\nconst FORMAT_NAME = \"CjsTgaFormat\";\n\n/**\n * TGA format profile that inspects header metadata and reads TGA bytes into\n * raw, debug JSON, or decoded RGBA image payloads.\n */\nexport class CjsTgaFormat extends CjsFormat\n{\n #values = DEFAULT_VALUES;\n\n /**\n * One-shot TGA write from a normalized RGBA payload.\n *\n * @param {object} payload As emitted for `rgba`.\n * @param {object} [options] `compress` for run-length encoding.\n * @returns {Uint8Array} TGA bytes.\n */\n static write(payload, options = {})\n {\n return encodeTga(payload, options);\n }\n\n /**\n * Write a normalized RGBA payload as TGA bytes.\n *\n * @param {object} payload As emitted for `rgba`.\n * @param {object} [options] `compress` for run-length encoding.\n * @returns {Uint8Array} TGA bytes.\n */\n Write(payload, options = {})\n {\n return encodeTga(payload, options);\n }\n\n /**\n * Create a reusable TGA 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 {CjsTgaFormat} This format profile.\n */\n SetValues(options = {})\n {\n this.#values = normalizeValues(this.#values, { inputType: \"tga\", ...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: \"tga\", ...options }, FORMAT_NAME);\n }\n\n /**\n * Read TGA bytes with this profile.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input TGA bytes.\n * @param {object} [options] Per-call values.\n * @returns {object} GPU-free raw/debug/RGBA payload for the selected emit target.\n */\n Read(input, options = {})\n {\n return readWithValues(input, this.GetValues(options), \"tga\");\n }\n\n /**\n * Read TGA bytes asynchronously with this profile.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input TGA bytes.\n * @param {object} [options] Per-call values.\n * @returns {Promise<object>} GPU-free raw/debug/RGBA payload for the selected emit target.\n */\n async ReadAsync(input, options = {})\n {\n return this.Read(input, options);\n }\n\n /**\n * Inspect TGA bytes without decoding full image data.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input TGA bytes.\n * @param {object} [options] Per-call values.\n * @returns {object} TGA header metadata.\n */\n Inspect(input, options = {})\n {\n return inspectWithValues(input, this.GetValues(options), \"tga\");\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 TGA read.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input TGA bytes.\n * @param {object} [options] Read options.\n * @returns {object} GPU-free raw/debug/RGBA payload for the selected emit target.\n */\n static read(input, options = {})\n {\n return readWithValues(input, normalizeValues(DEFAULT_VALUES, { inputType: \"tga\", ...options }, FORMAT_NAME), \"tga\");\n }\n\n /**\n * One-shot asynchronous TGA read.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input TGA bytes.\n * @param {object} [options] Read options.\n * @returns {Promise<object>} GPU-free raw/debug/RGBA payload for the selected emit target.\n */\n static async readAsync(input, options = {})\n {\n return CjsTgaFormat.read(input, options);\n }\n\n /**\n * One-shot TGA inspection.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input TGA bytes.\n * @param {object} [options] Inspect options.\n * @returns {object} TGA header metadata.\n */\n static inspect(input, options = {})\n {\n return inspectWithValues(input, normalizeValues(DEFAULT_VALUES, { inputType: \"tga\", ...options }, FORMAT_NAME), \"tga\");\n }\n\n /**\n * One-shot TGA support probe.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input TGA 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: \"tga\", ...options }, FORMAT_NAME), \"tga\");\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 TGA file.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Candidate TGA bytes.\n * @returns {boolean} True when the TGA header looks valid.\n */\n static isTGA(input)\n {\n try\n {\n return isTGA(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\n static OUTPUT_TGA_JSON = \"tgaJson\";\n\n static id = \"tga\";\n\n static mediaTypes = Object.freeze([ \"image\" ]);\n\n static inputs = CjsFormat.defineInputs({\n rgba: { default: true, options: [ \"compress\" ] }\n });\n\n static outputs = CjsFormat.defineOutputs({\n\n image: { decoded: true, probes: [ \"image\", \"rgba\" ] },\n\n rgba: { decoded: true },\n\n tgaJson: { role: \"debug\", probes: [ \"tgaJson\", \"raw\" ] },\n\n raw: { role: \"debug\", default: true, passthrough: true }\n\n });\n\n static extensions = Object.freeze([ \".tga\" ]);\n}\n\nexport default CjsTgaFormat;\n"],"names":["FORMAT_NAME","CjsTgaFormat","CjsFormat","DEFAULT_VALUES","write","payload","options","encodeTga","Write","constructor","SetValues","normalizeValues","inputType","GetValues","Read","input","readWithValues","ReadAsync","Inspect","inspectWithValues","ToJSON","value","toJsonValue","read","readAsync","inspect","probeSupport","probeSupportWithValues","toJSON","isTGA","asUint8Array","Output","Object","freeze","IMAGE","OUTPUT_IMAGE","RGBA","OUTPUT_RGBA","RAW","OUTPUT_RAW","JSON","OUTPUT_JSON","OUTPUT_TGA_JSON","id","mediaTypes","inputs","defineInputs","rgba","default","outputs","defineOutputs","image","decoded","probes","tgaJson","role","raw","passthrough","extensions"],"mappings":";;;;;;;AAiBA,MAAMA,WAAW,GAAG,cAAc;;AAElC;AACA;AACA;AACA;AACO,MAAMC,YAAY,SAASC,SAAS,CAC3C;EACI,OAAO,GAAGC,cAAc;;AAExB;AACJ;AACA;AACA;AACA;AACA;AACA;EACI,OAAOC,KAAKA,CAACC,OAAO,EAAEC,OAAO,GAAG,EAAE,EAClC;AACI,IAAA,OAAOC,SAAS,CAACF,OAAO,EAAEC,OAAO,CAAC;AACtC,EAAA;;AAEA;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AAO;AAAEF,MAAAA,MAAM,EAAE,CAAE,SAAS,EAAE,KAAK;KAAI;AAExDG,IAAAA,GAAG,EAAE;AAAED,MAAAA,IAAI,EAAE,OAAO;AAAEP,MAAAA,OAAO,EAAE,IAAI;AAAES,MAAAA,WAAW,EAAE;AAAK;AAE3D,GAAC,CAAC;EAEF,OAAOC,UAAU,GAAG1B,MAAM,CAACC,MAAM,CAAC,CAAE,MAAM,CAAE,CAAC;AACjD;;;;"}
1
+ {"version":3,"file":"CjsTgaFormat.js","sources":["../../../../../src/resource/formats/tga/CjsTgaFormat.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 probeSupportWithValues,\n isTGA,\n normalizeValues,\n readWithValues,\n toJsonValue\n} from \"./core/helpers.js\";\nimport { encodeTga } from \"./core/writer.js\";\n\nconst FORMAT_NAME = \"CjsTgaFormat\";\n\n/**\n * TGA format profile that inspects header metadata and reads TGA bytes into\n * raw, debug JSON, or decoded RGBA image payloads.\n */\nexport class CjsTgaFormat extends CjsImageFormat\n{\n _values = DEFAULT_VALUES;\n\n /**\n * One-shot TGA write from a normalized RGBA payload.\n *\n * @param {object} payload As emitted for `rgba`.\n * @param {object} [options] `compress` for run-length encoding.\n * @returns {Uint8Array} TGA bytes.\n */\n static write(payload, options = {})\n {\n return encodeTga(payload, options);\n }\n\n /**\n * Write a normalized RGBA payload as TGA bytes.\n *\n * @param {object} payload As emitted for `rgba`.\n * @param {object} [options] `compress` for run-length encoding.\n * @returns {Uint8Array} TGA bytes.\n */\n Write(payload, options = {})\n {\n return encodeTga(payload, options);\n }\n\n /**\n * Create a reusable TGA 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 {CjsTgaFormat} This format profile.\n */\n SetValues(options = {})\n {\n this._values = normalizeValues(this._values, { inputType: \"tga\", ...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: \"tga\", ...options }, FORMAT_NAME);\n }\n\n /**\n * Read TGA bytes with this profile.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input TGA bytes.\n * @param {object} [options] Per-call values.\n * @returns {object} GPU-free raw/debug/RGBA payload for the selected emit target.\n */\n Read(input, options = {})\n {\n return readWithValues(input, this.GetValues(options), \"tga\");\n }\n\n /**\n * Read TGA bytes asynchronously with this profile.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input TGA bytes.\n * @param {object} [options] Per-call values.\n * @returns {Promise<object>} GPU-free raw/debug/RGBA payload for the selected emit target.\n */\n async ReadAsync(input, options = {})\n {\n return this.Read(input, options);\n }\n\n /**\n * Inspect TGA bytes without decoding full image data.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input TGA bytes.\n * @param {object} [options] Per-call values.\n * @returns {object} TGA header metadata.\n */\n Inspect(input, options = {})\n {\n return inspectWithValues(input, this.GetValues(options), \"tga\");\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 TGA read.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input TGA bytes.\n * @param {object} [options] Read options.\n * @returns {object} GPU-free raw/debug/RGBA payload for the selected emit target.\n */\n static read(input, options = {})\n {\n return readWithValues(input, normalizeValues(DEFAULT_VALUES, { inputType: \"tga\", ...options }, FORMAT_NAME), \"tga\");\n }\n\n /**\n * One-shot asynchronous TGA read.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input TGA bytes.\n * @param {object} [options] Read options.\n * @returns {Promise<object>} GPU-free raw/debug/RGBA payload for the selected emit target.\n */\n static async readAsync(input, options = {})\n {\n return CjsTgaFormat.read(input, options);\n }\n\n /**\n * One-shot TGA inspection.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input TGA bytes.\n * @param {object} [options] Inspect options.\n * @returns {object} TGA header metadata.\n */\n static inspect(input, options = {})\n {\n return inspectWithValues(input, normalizeValues(DEFAULT_VALUES, { inputType: \"tga\", ...options }, FORMAT_NAME), \"tga\");\n }\n\n /**\n * One-shot TGA support probe.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input TGA 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: \"tga\", ...options }, FORMAT_NAME), \"tga\");\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 TGA file.\n *\n * @param {Uint8Array|ArrayBuffer|DataView} input Candidate TGA bytes.\n * @returns {boolean} True when the TGA header looks valid.\n */\n static isTGA(input)\n {\n try\n {\n return isTGA(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\n\n static id = \"CjsTgaFormat\";\n\n static mediaTypes = [ \"image\" ];\n\n static inputs = CjsFormat.defineInputs({\n rgba: { default: true, options: [ \"compress\" ] }\n });\n\n static outputs = CjsFormat.defineOutputs({\n\n image: { decoded: true, probes: [ \"image\", \"rgba\" ] },\n\n rgba: { decoded: true },\n\n tgaJson: { role: \"debug\", probes: [ \"tgaJson\", \"raw\" ] },\n\n raw: { role: \"debug\", default: true, passthrough: true }\n\n });\n\n /**\n * Fill a HostBitmap through this format's RGBA8 output, for Carbon's ImageIO\n * registry (`CjsTgaFormat.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 = [ \".tga\" ];\n}\n\nexport default CjsTgaFormat;\n"],"names":["FORMAT_NAME","CjsTgaFormat","CjsImageFormat","_values","DEFAULT_VALUES","write","payload","options","encodeTga","Write","constructor","SetValues","normalizeValues","inputType","GetValues","Read","input","readWithValues","ReadAsync","Inspect","inspectWithValues","ToJSON","value","toJsonValue","read","readAsync","inspect","probeSupport","probeSupportWithValues","toJSON","isTGA","asUint8Array","id","mediaTypes","inputs","CjsFormat","defineInputs","rgba","default","outputs","defineOutputs","image","decoded","probes","tgaJson","role","raw","passthrough","readImageNative","_loadParameters","bitmap","metadata","readImageFromRgbaPayload","emit","extensions"],"mappings":";;;;;;;;AAkBA,MAAMA,WAAW,GAAG,cAAc;;AAElC;AACA;AACA;AACA;AACO,MAAMC,YAAY,SAASC,cAAc,CAChD;AACIC,EAAAA,OAAO,GAAGC,cAAc;;AAExB;AACJ;AACA;AACA;AACA;AACA;AACA;EACI,OAAOC,KAAKA,CAACC,OAAO,EAAEC,OAAO,GAAG,EAAE,EAClC;AACI,IAAA,OAAOC,SAAS,CAACF,OAAO,EAAEC,OAAO,CAAC;AACtC,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACIE,EAAAA,KAAKA,CAACH,OAAO,EAAEC,OAAO,GAAG,EAAE,EAC3B;AACI,IAAA,OAAOC,SAAS,CAACF,OAAO,EAAEC,OAAO,CAAC;AACtC,EAAA;;AAEA;AACJ;AACA;AAC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