@carbonenginejs/runtime-resource 0.1.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/FORMAT-PROVENANCE.md +155 -135
  2. package/LICENSE +21 -21
  3. package/NOTICE +29 -29
  4. package/README.md +548 -241
  5. package/dist/CjsMotherLode.js +1271 -56
  6. package/dist/CjsMotherLode.js.map +1 -1
  7. package/dist/CjsResMan.js +3005 -740
  8. package/dist/CjsResMan.js.map +1 -1
  9. package/dist/CjsResManQueue.js +214 -214
  10. package/dist/CjsResource.js +566 -366
  11. package/dist/CjsResource.js.map +1 -1
  12. package/dist/CjsResourceSource.js +59 -59
  13. package/dist/_virtual/_rollupPluginBabelHelpers.js +153 -153
  14. package/dist/format/CjsBlueReader.js +269 -0
  15. package/dist/format/CjsBlueReader.js.map +1 -0
  16. package/dist/format/CjsFormat.js +192 -178
  17. package/dist/format/CjsFormat.js.map +1 -1
  18. package/dist/format/CjsReader.js +18 -0
  19. package/dist/format/CjsReader.js.map +1 -0
  20. package/dist/format/CjsResourceProbe.js +277 -269
  21. package/dist/format/CjsResourceProbe.js.map +1 -1
  22. package/dist/format/payloadContract.js +173 -173
  23. package/dist/formats/black/CjsBlackFormat.js +278 -272
  24. package/dist/formats/black/CjsBlackFormat.js.map +1 -1
  25. package/dist/formats/black/core/CjsBlackBinaryReader.js +153 -153
  26. package/dist/formats/black/core/CjsBlackPropertyReaders.js +382 -382
  27. package/dist/formats/black/core/CjsBlackReader.js +639 -760
  28. package/dist/formats/black/core/CjsBlackReader.js.map +1 -1
  29. package/dist/formats/black/core/CjsBlackSchemaRegistry.js +433 -433
  30. package/dist/formats/black/core/black-schema-v1-2026-07-11.json.js +4 -4
  31. package/dist/formats/black/core/blackConstants.js +7 -7
  32. package/dist/formats/black/core/blackDefinitions.js +10 -10
  33. package/dist/formats/black/core/blackEnums.js +6 -6
  34. package/dist/formats/black/core/blackSchema.js +3 -3
  35. package/dist/formats/black/core/blackVersion.js +22 -22
  36. package/dist/formats/black/core/helpers.js +182 -182
  37. package/dist/formats/black/core/schema.js +4 -4
  38. package/dist/formats/black/index.js +2 -2
  39. package/dist/formats/bnk/CjsBnkFormat.js +238 -245
  40. package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
  41. package/dist/formats/bnk/core/graph.js +140 -0
  42. package/dist/formats/bnk/core/graph.js.map +1 -0
  43. package/dist/formats/bnk/core/helpers.js +409 -354
  44. package/dist/formats/bnk/core/helpers.js.map +1 -1
  45. package/dist/formats/bnk/core/musicNodes.js +521 -0
  46. package/dist/formats/bnk/core/musicNodes.js.map +1 -0
  47. package/dist/formats/bnk/core/soundbanksInfo.js +246 -246
  48. package/dist/formats/bnk/index.js +2 -3
  49. package/dist/formats/bnk/index.js.map +1 -1
  50. package/dist/formats/cmf/CjsCmfFormat.js +497 -491
  51. package/dist/formats/cmf/CjsCmfFormat.js.map +1 -1
  52. package/dist/formats/cmf/core/binary.js +118 -118
  53. package/dist/formats/cmf/core/buffers.js +233 -233
  54. package/dist/formats/cmf/core/constants.js +47 -47
  55. package/dist/formats/cmf/core/gr2Anim.js +453 -453
  56. package/dist/formats/cmf/core/helpers.js +287 -287
  57. package/dist/formats/cmf/core/pack.js +276 -276
  58. package/dist/formats/cmf/core/schema.js +364 -364
  59. package/dist/formats/cmf/core/shared.js +268 -268
  60. package/dist/formats/cmf/core/writer.js +517 -517
  61. package/dist/formats/cmf/index.js +2 -2
  62. package/dist/formats/dds/CjsDdsFormat.js +193 -187
  63. package/dist/formats/dds/CjsDdsFormat.js.map +1 -1
  64. package/dist/formats/dds/core/bc6h.js +288 -0
  65. package/dist/formats/dds/core/bc6h.js.map +1 -0
  66. package/dist/formats/dds/core/bc7.js +251 -0
  67. package/dist/formats/dds/core/bc7.js.map +1 -0
  68. package/dist/formats/dds/core/helpers.js +815 -812
  69. package/dist/formats/dds/core/helpers.js.map +1 -1
  70. package/dist/formats/dds/index.js +2 -2
  71. package/dist/formats/fbx/CjsFbxFormat.js +266 -260
  72. package/dist/formats/fbx/CjsFbxFormat.js.map +1 -1
  73. package/dist/formats/fbx/core/helpers.js +3901 -3901
  74. package/dist/formats/fbx/index.js +2 -2
  75. package/dist/formats/flac/CjsFlacFormat.js +87 -81
  76. package/dist/formats/flac/CjsFlacFormat.js.map +1 -1
  77. package/dist/formats/flac/core/helpers.js +295 -295
  78. package/dist/formats/flac/index.js +2 -2
  79. package/dist/formats/gif/CjsGifFormat.js +87 -81
  80. package/dist/formats/gif/CjsGifFormat.js.map +1 -1
  81. package/dist/formats/gif/core/helpers.js +360 -360
  82. package/dist/formats/gif/index.js +2 -2
  83. package/dist/formats/gltf/CjsGltfFormat.js +290 -284
  84. package/dist/formats/gltf/CjsGltfFormat.js.map +1 -1
  85. package/dist/formats/gltf/core/helpers.js +292 -292
  86. package/dist/formats/gltf/core/json.js +79 -79
  87. package/dist/formats/gltf/core/parser.js +666 -666
  88. package/dist/formats/gltf/core/targets.js +163 -163
  89. package/dist/formats/gltf/index.js +2 -2
  90. package/dist/formats/index.js +23 -23
  91. package/dist/formats/jpeg/CjsJpegFormat.js +206 -200
  92. package/dist/formats/jpeg/CjsJpegFormat.js.map +1 -1
  93. package/dist/formats/jpeg/core/helpers.js +350 -350
  94. package/dist/formats/jpeg/core/jpeg.js +377 -377
  95. package/dist/formats/jpeg/index.js +2 -2
  96. package/dist/formats/mp3/CjsMp3Format.js +192 -186
  97. package/dist/formats/mp3/CjsMp3Format.js.map +1 -1
  98. package/dist/formats/mp3/core/helpers.js +338 -338
  99. package/dist/formats/mp3/index.js +2 -2
  100. package/dist/formats/mp4/CjsMp4Format.js +191 -185
  101. package/dist/formats/mp4/CjsMp4Format.js.map +1 -1
  102. package/dist/formats/mp4/core/helpers.js +449 -449
  103. package/dist/formats/mp4/index.js +2 -2
  104. package/dist/formats/obj/CjsObjFormat.js +253 -247
  105. package/dist/formats/obj/CjsObjFormat.js.map +1 -1
  106. package/dist/formats/obj/core/helpers.js +573 -573
  107. package/dist/formats/obj/core/json.js +64 -64
  108. package/dist/formats/obj/core/parser.js +321 -321
  109. package/dist/formats/obj/index.js +2 -2
  110. package/dist/formats/ogg/CjsOggFormat.js +88 -82
  111. package/dist/formats/ogg/CjsOggFormat.js.map +1 -1
  112. package/dist/formats/ogg/core/helpers.js +387 -387
  113. package/dist/formats/ogg/core/imdct.js +178 -178
  114. package/dist/formats/ogg/core/vorbis.js +999 -999
  115. package/dist/formats/ogg/index.js +2 -2
  116. package/dist/formats/png/CjsPngFormat.js +195 -189
  117. package/dist/formats/png/CjsPngFormat.js.map +1 -1
  118. package/dist/formats/png/core/helpers.js +583 -583
  119. package/dist/formats/png/index.js +2 -2
  120. package/dist/formats/red/CjsRedFormat.js +261 -247
  121. package/dist/formats/red/CjsRedFormat.js.map +1 -1
  122. package/dist/formats/red/core/CjsRedReader.js +194 -201
  123. package/dist/formats/red/core/CjsRedReader.js.map +1 -1
  124. package/dist/formats/red/core/blackDefinitions.js +3 -3
  125. package/dist/formats/red/core/helpers.js +139 -136
  126. package/dist/formats/red/core/helpers.js.map +1 -1
  127. package/dist/formats/red/core/redGraph.js +68 -68
  128. package/dist/formats/red/core/schema.js +4 -4
  129. package/dist/formats/red/index.js +2 -2
  130. package/dist/formats/stl/CjsStlFormat.js +365 -304
  131. package/dist/formats/stl/CjsStlFormat.js.map +1 -1
  132. package/dist/formats/stl/core/helpers.js +261 -257
  133. package/dist/formats/stl/core/helpers.js.map +1 -1
  134. package/dist/formats/stl/core/json.js +51 -51
  135. package/dist/formats/stl/core/stl.js +629 -544
  136. package/dist/formats/stl/core/stl.js.map +1 -1
  137. package/dist/formats/stl/core/targets.js +163 -163
  138. package/dist/formats/stl/index.js +2 -2
  139. package/dist/formats/tga/CjsTgaFormat.js +192 -186
  140. package/dist/formats/tga/CjsTgaFormat.js.map +1 -1
  141. package/dist/formats/tga/core/helpers.js +446 -446
  142. package/dist/formats/tga/index.js +2 -2
  143. package/dist/formats/wav/CjsWavFormat.js +192 -186
  144. package/dist/formats/wav/CjsWavFormat.js.map +1 -1
  145. package/dist/formats/wav/core/helpers.js +328 -328
  146. package/dist/formats/wav/index.js +2 -2
  147. package/dist/formats/webm/CjsWebmFormat.js +191 -185
  148. package/dist/formats/webm/CjsWebmFormat.js.map +1 -1
  149. package/dist/formats/webm/core/helpers.js +537 -537
  150. package/dist/formats/webm/index.js +2 -2
  151. package/dist/formats/webp/CjsWebpFormat.js +86 -80
  152. package/dist/formats/webp/CjsWebpFormat.js.map +1 -1
  153. package/dist/formats/webp/core/helpers.js +214 -214
  154. package/dist/formats/webp/index.js +2 -2
  155. package/dist/formats/wem/CjsWemFormat.js +241 -197
  156. package/dist/formats/wem/CjsWemFormat.js.map +1 -1
  157. package/dist/formats/wem/core/bitStream.js +259 -259
  158. package/dist/formats/wem/core/codebookLibrary.js +164 -164
  159. package/dist/formats/wem/core/helpers.js +417 -336
  160. package/dist/formats/wem/core/helpers.js.map +1 -1
  161. package/dist/formats/wem/core/packedCodebooksAotuv603.js +30 -30
  162. package/dist/formats/wem/core/ptadpcm.js +77 -0
  163. package/dist/formats/wem/core/ptadpcm.js.map +1 -0
  164. package/dist/formats/wem/core/resolve.js +121 -0
  165. package/dist/formats/wem/core/resolve.js.map +1 -0
  166. package/dist/formats/wem/core/wemToOgg.js +485 -485
  167. package/dist/formats/wem/index.js +2 -2
  168. package/dist/formats/yaml/CjsYamlFormat.js +83 -77
  169. package/dist/formats/yaml/CjsYamlFormat.js.map +1 -1
  170. package/dist/formats/yaml/core/CjsYamlReader.js +305 -304
  171. package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -1
  172. package/dist/formats/yaml/core/helpers.js +160 -160
  173. package/dist/formats/yaml/index.js +2 -2
  174. package/dist/index.js +48 -52
  175. package/dist/index.js.map +1 -1
  176. package/dist/resourcePath.js +18 -18
  177. package/dist/resourceStates.js +9 -9
  178. package/dist/{generated/resources → resources}/AudioGeometryResData.js +47 -47
  179. package/dist/resources/AudioGeometryResData.js.map +1 -0
  180. package/dist/{generated/resources → resources}/GStateBindingCallbackData.js +31 -31
  181. package/dist/resources/GStateBindingCallbackData.js.map +1 -0
  182. package/dist/{generated/resources → resources}/MeshDecalData.js +37 -37
  183. package/dist/resources/MeshDecalData.js.map +1 -0
  184. package/dist/{generated/resources → resources}/MeshDecalLodData.js +34 -34
  185. package/dist/resources/MeshDecalLodData.js.map +1 -0
  186. package/dist/resources/Tr2EffectRes.js +71 -71
  187. package/dist/resources/Tr2GrannyIntersectionResult.js +60 -0
  188. package/dist/resources/Tr2GrannyIntersectionResult.js.map +1 -0
  189. package/dist/resources/Tr2GrannyStateRes.js +44 -44
  190. package/dist/resources/Tr2ImageRes.js +114 -114
  191. package/dist/resources/Tr2LightProfileRes.js +40 -40
  192. package/dist/{generated/resources → resources}/Tr2MaterialArea.js +34 -34
  193. package/dist/resources/Tr2MaterialArea.js.map +1 -0
  194. package/dist/{generated/resources → resources}/Tr2MaterialMesh.js +31 -31
  195. package/dist/resources/Tr2MaterialMesh.js.map +1 -0
  196. package/dist/{generated/resources → resources}/Tr2MaterialRes.js +34 -34
  197. package/dist/resources/Tr2MaterialRes.js.map +1 -0
  198. package/dist/{generated/resources → resources}/Tr2ShaderPermutation.js +43 -43
  199. package/dist/resources/Tr2ShaderPermutation.js.map +1 -0
  200. package/dist/{generated/resources → resources}/Tr2TextureLodManager.js +100 -60
  201. package/dist/resources/Tr2TextureLodManager.js.map +1 -0
  202. package/dist/{generated/resources → resources}/Tr2TextureLodUpdateRequest.js +37 -37
  203. package/dist/resources/Tr2TextureLodUpdateRequest.js.map +1 -0
  204. package/dist/{generated/resources → resources}/Tr2TexturePackChannel.js +37 -37
  205. package/dist/resources/Tr2TexturePackChannel.js.map +1 -0
  206. package/dist/resources/Tr2TexturePipeline.js +68 -0
  207. package/dist/resources/Tr2TexturePipeline.js.map +1 -0
  208. package/dist/{generated/resources → resources}/Tr2TexturePipelineParams.js +34 -34
  209. package/dist/resources/Tr2TexturePipelineParams.js.map +1 -0
  210. package/dist/{generated/resources → resources}/Tr2TexturePipelineStepCompress.js +40 -40
  211. package/dist/resources/Tr2TexturePipelineStepCompress.js.map +1 -0
  212. package/dist/{generated/resources → resources}/Tr2TexturePipelineStepLimitSize.js +34 -34
  213. package/dist/resources/Tr2TexturePipelineStepLimitSize.js.map +1 -0
  214. package/dist/{generated/resources → resources}/Tr2TexturePipelineStepLoad.js +31 -31
  215. package/dist/resources/Tr2TexturePipelineStepLoad.js.map +1 -0
  216. package/dist/{generated/resources → resources}/Tr2TexturePipelineStepPack.js +43 -43
  217. package/dist/resources/Tr2TexturePipelineStepPack.js.map +1 -0
  218. package/dist/resources/TriGeometryRes.js +239 -216
  219. package/dist/resources/TriGeometryRes.js.map +1 -1
  220. package/dist/{generated/resources → resources}/TriGeometryResAreaData.js +59 -59
  221. package/dist/resources/TriGeometryResAreaData.js.map +1 -0
  222. package/dist/{generated/resources → resources}/TriGeometryResJointData.js +38 -38
  223. package/dist/resources/TriGeometryResJointData.js.map +1 -0
  224. package/dist/{generated/resources → resources}/TriGeometryResLodData.js +88 -88
  225. package/dist/resources/TriGeometryResLodData.js.map +1 -0
  226. package/dist/{generated/resources → resources}/TriGeometryResMeshData.js +63 -63
  227. package/dist/resources/TriGeometryResMeshData.js.map +1 -0
  228. package/dist/{generated/resources → resources}/TriGeometryResSkeletonData.js +34 -34
  229. package/dist/resources/TriGeometryResSkeletonData.js.map +1 -0
  230. package/dist/resources/TriGrannyRes.js +43 -43
  231. package/dist/{generated/resources → resources}/TriJointBinding.js +38 -38
  232. package/dist/resources/TriJointBinding.js.map +1 -0
  233. package/dist/{generated/resources → resources}/TriMorphTargetGeometryConstants.js +46 -46
  234. package/dist/resources/TriMorphTargetGeometryConstants.js.map +1 -0
  235. package/dist/{generated/resources → resources}/TriRtGeometryConstants.js +88 -88
  236. package/dist/resources/TriRtGeometryConstants.js.map +1 -0
  237. package/dist/resources/TriTextureRes.js +304 -304
  238. package/dist/{generated/resources → resources}/enums.js +18 -18
  239. package/dist/resources/enums.js.map +1 -0
  240. package/dist/resources/resourceBoundary.js +47 -47
  241. package/dist/resources/texturePipelineBehavior.js +320 -0
  242. package/dist/resources/texturePipelineBehavior.js.map +1 -0
  243. package/dist/texture/CjsTextureArrayRes.js +406 -406
  244. package/dist/texture/CjsTextureParameterProxy.js +133 -133
  245. package/format-notices/black/LICENSE +21 -21
  246. package/format-notices/black/NOTICE +47 -47
  247. package/format-notices/bnk/LICENSE +21 -21
  248. package/format-notices/bnk/NOTICE +20 -17
  249. package/format-notices/cmf/LICENSE +21 -21
  250. package/format-notices/cmf/NOTICE +36 -36
  251. package/format-notices/dds/LICENSE +21 -21
  252. package/format-notices/dds/NOTICE +14 -14
  253. package/format-notices/fbx/LICENSE +21 -21
  254. package/format-notices/fbx/NOTICE +14 -14
  255. package/format-notices/flac/LICENSE +21 -21
  256. package/format-notices/flac/NOTICE +14 -14
  257. package/format-notices/gif/LICENSE +21 -21
  258. package/format-notices/gif/NOTICE +14 -14
  259. package/format-notices/gltf/LICENSE +21 -21
  260. package/format-notices/gltf/NOTICE +27 -27
  261. package/format-notices/jpeg/LICENSE +21 -21
  262. package/format-notices/jpeg/NOTICE +14 -14
  263. package/format-notices/mp3/LICENSE +21 -21
  264. package/format-notices/mp3/NOTICE +14 -14
  265. package/format-notices/mp4/LICENSE +21 -21
  266. package/format-notices/mp4/NOTICE +14 -14
  267. package/format-notices/obj/LICENSE +21 -21
  268. package/format-notices/obj/NOTICE +26 -26
  269. package/format-notices/ogg/LICENSE +21 -21
  270. package/format-notices/ogg/NOTICE +28 -28
  271. package/format-notices/png/LICENSE +21 -21
  272. package/format-notices/png/NOTICE +14 -14
  273. package/format-notices/red/LICENSE +21 -21
  274. package/format-notices/red/NOTICE +31 -31
  275. package/format-notices/stl/LICENSE +21 -21
  276. package/format-notices/stl/NOTICE +21 -21
  277. package/format-notices/tga/LICENSE +21 -21
  278. package/format-notices/tga/NOTICE +14 -14
  279. package/format-notices/wav/LICENSE +21 -21
  280. package/format-notices/wav/NOTICE +14 -14
  281. package/format-notices/webm/LICENSE +21 -21
  282. package/format-notices/webm/NOTICE +14 -14
  283. package/format-notices/webp/LICENSE +21 -21
  284. package/format-notices/webp/NOTICE +14 -14
  285. package/format-notices/wem/LICENSE +57 -57
  286. package/format-notices/wem/NOTICE +33 -33
  287. package/format-notices/yaml/LICENSE +21 -21
  288. package/format-notices/yaml/NOTICE +44 -44
  289. package/package.json +51 -51
  290. package/resource-lifecycle.md +679 -487
  291. package/dist/generated/resources/AudioGeometryResData.js.map +0 -1
  292. package/dist/generated/resources/CmfVertexReader.js +0 -46
  293. package/dist/generated/resources/CmfVertexReader.js.map +0 -1
  294. package/dist/generated/resources/GStateBindingCallbackData.js.map +0 -1
  295. package/dist/generated/resources/MeshDecalData.js.map +0 -1
  296. package/dist/generated/resources/MeshDecalLodData.js.map +0 -1
  297. package/dist/generated/resources/Tr2AsyncSave.js +0 -46
  298. package/dist/generated/resources/Tr2AsyncSave.js.map +0 -1
  299. package/dist/generated/resources/Tr2CmfContents.js +0 -37
  300. package/dist/generated/resources/Tr2CmfContents.js.map +0 -1
  301. package/dist/generated/resources/Tr2GrannyIntersectionResult.js +0 -58
  302. package/dist/generated/resources/Tr2GrannyIntersectionResult.js.map +0 -1
  303. package/dist/generated/resources/Tr2LoadPrepareFence.js +0 -37
  304. package/dist/generated/resources/Tr2LoadPrepareFence.js.map +0 -1
  305. package/dist/generated/resources/Tr2MaterialArea.js.map +0 -1
  306. package/dist/generated/resources/Tr2MaterialMesh.js.map +0 -1
  307. package/dist/generated/resources/Tr2MaterialRes.js.map +0 -1
  308. package/dist/generated/resources/Tr2ShaderPermutation.js.map +0 -1
  309. package/dist/generated/resources/Tr2TextureLodManager.js.map +0 -1
  310. package/dist/generated/resources/Tr2TextureLodUpdateRequest.js.map +0 -1
  311. package/dist/generated/resources/Tr2TexturePackChannel.js.map +0 -1
  312. package/dist/generated/resources/Tr2TexturePipeline.js +0 -44
  313. package/dist/generated/resources/Tr2TexturePipeline.js.map +0 -1
  314. package/dist/generated/resources/Tr2TexturePipelineParams.js.map +0 -1
  315. package/dist/generated/resources/Tr2TexturePipelineStepCompress.js.map +0 -1
  316. package/dist/generated/resources/Tr2TexturePipelineStepLimitSize.js.map +0 -1
  317. package/dist/generated/resources/Tr2TexturePipelineStepLoad.js.map +0 -1
  318. package/dist/generated/resources/Tr2TexturePipelineStepPack.js.map +0 -1
  319. package/dist/generated/resources/TriGeometryResAreaData.js.map +0 -1
  320. package/dist/generated/resources/TriGeometryResJointData.js.map +0 -1
  321. package/dist/generated/resources/TriGeometryResLodData.js.map +0 -1
  322. package/dist/generated/resources/TriGeometryResMeshData.js.map +0 -1
  323. package/dist/generated/resources/TriGeometryResSkeletonData.js.map +0 -1
  324. package/dist/generated/resources/TriJointBinding.js.map +0 -1
  325. package/dist/generated/resources/TriMorphTargetGeometryConstants.js.map +0 -1
  326. package/dist/generated/resources/TriRtGeometryConstants.js.map +0 -1
  327. package/dist/generated/resources/enums.js.map +0 -1
  328. package/dist/generated/resources/index.js +0 -32
  329. package/dist/generated/resources/index.js.map +0 -1
@@ -1,47 +1,47 @@
1
- function ResourceBoundaryError(className, methodName, reason) {
2
- const error = new Error(`${className}.${methodName} is owned by engine adapters in CarbonEngineJS. ${reason || ""}`.trim());
3
- error.code = "CJS_RESOURCE_ENGINE_BOUNDARY";
4
- error.className = className;
5
- error.methodName = methodName;
6
- return error;
7
- }
8
- function CarbonStubError(className, methodName, reason) {
9
- const error = new Error(`${className}.${methodName} is a CarbonEngineJS resource stub and is not implemented yet. ${reason || ""}`.trim());
10
- error.code = "CJS_RESOURCE_NOT_IMPLEMENTED";
11
- error.className = className;
12
- error.methodName = methodName;
13
- return error;
14
- }
15
- function ResourcePayloadError(className, reason, field = "", cause = null) {
16
- const location = field ? `${className} payload.${field}` : `${className} payload`;
17
- const error = new TypeError(`${location} is invalid. ${reason || ""}`.trim());
18
- error.code = "CJS_RESOURCE_PAYLOAD_INVALID";
19
- error.className = className;
20
- error.field = field;
21
- if (cause) error.cause = cause;
22
- return error;
23
- }
24
- function AssertResourcePayloadObject(className, payload) {
25
- if (!payload || typeof payload !== "object" || Array.isArray(payload) || payload instanceof ArrayBuffer || ArrayBuffer.isView(payload)) {
26
- throw ResourcePayloadError(className, "Expected a plain payload object.");
27
- }
28
- return payload;
29
- }
30
- function AssertResourcePayloadArray(className, payload, field) {
31
- if (!Array.isArray(payload[field])) {
32
- throw ResourcePayloadError(className, "Expected an array.", field);
33
- }
34
- return payload[field];
35
- }
36
- function ValidateResourcePayload(className, payload, validator) {
37
- AssertResourcePayloadObject(className, payload);
38
- try {
39
- return validator(payload);
40
- } catch (cause) {
41
- if (cause?.code === "CJS_RESOURCE_PAYLOAD_INVALID") throw cause;
42
- throw ResourcePayloadError(className, cause?.message || "Validation failed.", "", cause);
43
- }
44
- }
45
-
46
- export { AssertResourcePayloadArray, AssertResourcePayloadObject, CarbonStubError, ResourceBoundaryError, ResourcePayloadError, ValidateResourcePayload };
47
- //# sourceMappingURL=resourceBoundary.js.map
1
+ function ResourceBoundaryError(className, methodName, reason) {
2
+ const error = new Error(`${className}.${methodName} is owned by engine adapters in CarbonEngineJS. ${reason || ""}`.trim());
3
+ error.code = "CJS_RESOURCE_ENGINE_BOUNDARY";
4
+ error.className = className;
5
+ error.methodName = methodName;
6
+ return error;
7
+ }
8
+ function CarbonStubError(className, methodName, reason) {
9
+ const error = new Error(`${className}.${methodName} is a CarbonEngineJS resource stub and is not implemented yet. ${reason || ""}`.trim());
10
+ error.code = "CJS_RESOURCE_NOT_IMPLEMENTED";
11
+ error.className = className;
12
+ error.methodName = methodName;
13
+ return error;
14
+ }
15
+ function ResourcePayloadError(className, reason, field = "", cause = null) {
16
+ const location = field ? `${className} payload.${field}` : `${className} payload`;
17
+ const error = new TypeError(`${location} is invalid. ${reason || ""}`.trim());
18
+ error.code = "CJS_RESOURCE_PAYLOAD_INVALID";
19
+ error.className = className;
20
+ error.field = field;
21
+ if (cause) error.cause = cause;
22
+ return error;
23
+ }
24
+ function AssertResourcePayloadObject(className, payload) {
25
+ if (!payload || typeof payload !== "object" || Array.isArray(payload) || payload instanceof ArrayBuffer || ArrayBuffer.isView(payload)) {
26
+ throw ResourcePayloadError(className, "Expected a plain payload object.");
27
+ }
28
+ return payload;
29
+ }
30
+ function AssertResourcePayloadArray(className, payload, field) {
31
+ if (!Array.isArray(payload[field])) {
32
+ throw ResourcePayloadError(className, "Expected an array.", field);
33
+ }
34
+ return payload[field];
35
+ }
36
+ function ValidateResourcePayload(className, payload, validator) {
37
+ AssertResourcePayloadObject(className, payload);
38
+ try {
39
+ return validator(payload);
40
+ } catch (cause) {
41
+ if (cause?.code === "CJS_RESOURCE_PAYLOAD_INVALID") throw cause;
42
+ throw ResourcePayloadError(className, cause?.message || "Validation failed.", "", cause);
43
+ }
44
+ }
45
+
46
+ export { AssertResourcePayloadArray, AssertResourcePayloadObject, CarbonStubError, ResourceBoundaryError, ResourcePayloadError, ValidateResourcePayload };
47
+ //# sourceMappingURL=resourceBoundary.js.map
@@ -0,0 +1,320 @@
1
+ import { validateRgbaPayload } from '../format/payloadContract.js';
2
+ import { PixelFormat as PixelFormat$1 } from '@carbonenginejs/runtime-const/graphics';
3
+ import { PixelFormat } from '@carbonenginejs/runtime-const/render-context';
4
+
5
+ // Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipeline.cpp
6
+ // Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLoad.cpp
7
+ // Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLimitSize.cpp
8
+ // Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepCompress.cpp
9
+ // Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack.cpp
10
+ const STEP_LOAD = "Tr2TexturePipelineStepLoad";
11
+ const STEP_LIMIT_SIZE = "Tr2TexturePipelineStepLimitSize";
12
+ const STEP_COMPRESS = "Tr2TexturePipelineStepCompress";
13
+ const STEP_PACK = "Tr2TexturePipelineStepPack";
14
+ const PACK_FORMATS = new Set([PixelFormat.PIXEL_FORMAT_R8_UNORM, PixelFormat.PIXEL_FORMAT_B8G8R8A8_UNORM, PixelFormat.PIXEL_FORMAT_B8G8R8X8_UNORM]);
15
+
16
+ /**
17
+ * Collect Carbon texture-pipeline dependencies in std::set-equivalent order.
18
+ *
19
+ * @param {object[]} steps Pipeline steps.
20
+ * @returns {string[]} Sorted unique resource paths.
21
+ */
22
+ function GetTexturePipelineDependencies(steps) {
23
+ const dependencies = new Set();
24
+ for (const step of AssertSteps(steps)) {
25
+ const name = StepName(step);
26
+ if (name === STEP_LOAD) {
27
+ AddDependency(dependencies, step.path);
28
+ } else if (name === STEP_PACK) {
29
+ AddDependency(dependencies, step.r?.path);
30
+ AddDependency(dependencies, step.g?.path);
31
+ AddDependency(dependencies, step.b?.path);
32
+ AddDependency(dependencies, step.a?.path);
33
+ }
34
+ }
35
+ return [...dependencies].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
36
+ }
37
+
38
+ /**
39
+ * Execute the maintained JavaScript form of Carbon's CPU bitmap pipeline.
40
+ *
41
+ * @param {object[]} steps Pipeline steps.
42
+ * @param {{maxWidth:number,maxHeight:number}} params Caller size limits.
43
+ * @param {object|null} options Input resolution options.
44
+ * @returns {Promise<object>} Canonical RGBA payload.
45
+ */
46
+ async function ExecuteTexturePipeline(steps, params, options = null) {
47
+ const list = AssertSteps(steps);
48
+ if (!list.length) {
49
+ throw PipelineError("CJS_TEXTURE_PIPELINE_NO_STEPS", "Tr2TexturePipeline has no steps.");
50
+ }
51
+ const limits = {
52
+ maxWidth: AssertLimit(params?.maxWidth, "maxWidth"),
53
+ maxHeight: AssertLimit(params?.maxHeight, "maxHeight")
54
+ };
55
+ const settings = NormalizeOptions(options);
56
+ const inputs = new Map();
57
+ for (const path of GetTexturePipelineDependencies(list)) {
58
+ inputs.set(path, await ResolveInput(path, settings));
59
+ }
60
+ let bitmap = null;
61
+ for (const step of list) {
62
+ const name = StepName(step);
63
+ if (name === STEP_LOAD) {
64
+ bitmap = CloneBitmap(RequireInput(inputs, step.path));
65
+ } else if (name === STEP_LIMIT_SIZE) {
66
+ bitmap = LimitBitmap(RequireBitmap(bitmap), CombineLimits(step, limits));
67
+ } else if (name === STEP_COMPRESS) {
68
+ // Carbon's current implementation validates the bitmap and otherwise
69
+ // performs no compression work.
70
+ RequireBitmap(bitmap);
71
+ } else if (name === STEP_PACK) {
72
+ bitmap = PackBitmap(step, inputs);
73
+ } else {
74
+ throw PipelineError("CJS_TEXTURE_PIPELINE_STEP_UNSUPPORTED", `Unsupported texture pipeline step: ${name || "unknown"}.`);
75
+ }
76
+ }
77
+ bitmap = LimitBitmap(RequireBitmap(bitmap), limits);
78
+ return ToPayload(bitmap);
79
+ }
80
+ function AssertSteps(steps) {
81
+ if (!Array.isArray(steps)) {
82
+ throw new TypeError("Tr2TexturePipeline.steps must be an array.");
83
+ }
84
+ return steps;
85
+ }
86
+ function AssertLimit(value, name) {
87
+ if (!Number.isSafeInteger(value) || value < 0) {
88
+ throw new TypeError(`Tr2TexturePipeline ${name} must be a non-negative safe integer.`);
89
+ }
90
+ return value;
91
+ }
92
+ function NormalizeOptions(options) {
93
+ if (options === null || options === undefined) {
94
+ return {};
95
+ }
96
+ if (!options || typeof options !== "object" || Array.isArray(options)) {
97
+ throw new TypeError("Tr2TexturePipeline options must be an object or null.");
98
+ }
99
+ if (options.load !== undefined && typeof options.load !== "function") {
100
+ throw new TypeError("Tr2TexturePipeline options.load must be a function.");
101
+ }
102
+ if (options.resMan !== undefined && typeof options.resMan?.GetObject !== "function") {
103
+ throw new TypeError("Tr2TexturePipeline options.resMan must provide GetObject().");
104
+ }
105
+ return options;
106
+ }
107
+ async function ResolveInput(path, options) {
108
+ let value;
109
+ if (options.inputs instanceof Map) {
110
+ value = options.inputs.get(path);
111
+ } else if (options.inputs && typeof options.inputs === "object") {
112
+ value = options.inputs[path];
113
+ }
114
+ if (value === undefined && options.load) {
115
+ value = await options.load(path);
116
+ }
117
+ if (value === undefined && options.resMan) {
118
+ value = await options.resMan.GetObject(path, {
119
+ ...(options.resourceOptions || {}),
120
+ requirement: "image",
121
+ emit: "rgba"
122
+ });
123
+ }
124
+ if (value === undefined) {
125
+ throw PipelineError("CJS_TEXTURE_PIPELINE_INPUT_MISSING", `No texture pipeline input was provided for ${path}.`);
126
+ }
127
+ const payload = typeof value?.GetPayload === "function" ? value.GetPayload() : value;
128
+ validateRgbaPayload(payload);
129
+ if (payload.pixelFormat !== PixelFormat$1.RGBA8_UNORM) {
130
+ throw PipelineError("CJS_TEXTURE_PIPELINE_FORMAT_UNSUPPORTED", `Texture pipeline input ${path} must use rgba8unorm.`);
131
+ }
132
+ return FromPayload(payload);
133
+ }
134
+ function FromPayload(payload) {
135
+ const data = new Uint8Array(payload.width * payload.height * 4);
136
+ for (let y = 0; y < payload.height; y++) {
137
+ const sourceOffset = y * payload.strideBytes;
138
+ const targetOffset = y * payload.width * 4;
139
+ data.set(payload.data.subarray(sourceOffset, sourceOffset + payload.width * 4), targetOffset);
140
+ }
141
+ return {
142
+ width: payload.width,
143
+ height: payload.height,
144
+ data,
145
+ sourceFormat: payload.sourceFormat || "rgba",
146
+ colorSpace: payload.colorSpace,
147
+ alphaMode: payload.alphaMode,
148
+ metadata: payload.metadata || null
149
+ };
150
+ }
151
+ function ToPayload(bitmap) {
152
+ return {
153
+ payloadType: "rgba",
154
+ sourceFormat: bitmap.sourceFormat || "texture-pipeline",
155
+ width: bitmap.width,
156
+ height: bitmap.height,
157
+ pixelFormat: PixelFormat$1.RGBA8_UNORM,
158
+ data: bitmap.data,
159
+ strideBytes: bitmap.width * 4,
160
+ origin: "top-left",
161
+ colorSpace: bitmap.colorSpace || "unknown",
162
+ alphaMode: bitmap.alphaMode || "unknown",
163
+ ...(bitmap.metadata ? {
164
+ metadata: bitmap.metadata
165
+ } : {})
166
+ };
167
+ }
168
+ function CloneBitmap(bitmap) {
169
+ return {
170
+ ...bitmap,
171
+ data: new Uint8Array(bitmap.data),
172
+ metadata: bitmap.metadata && typeof bitmap.metadata === "object" ? {
173
+ ...bitmap.metadata
174
+ } : bitmap.metadata
175
+ };
176
+ }
177
+ function CombineLimits(step, params) {
178
+ return {
179
+ maxWidth: TightestLimit(AssertLimit(step.maxWidth ?? 0, "step.maxWidth"), params.maxWidth),
180
+ maxHeight: TightestLimit(AssertLimit(step.maxHeight ?? 0, "step.maxHeight"), params.maxHeight)
181
+ };
182
+ }
183
+ function TightestLimit(first, second) {
184
+ if (!first) return second;
185
+ if (!second) return first;
186
+ return Math.min(first, second);
187
+ }
188
+ function LimitBitmap(bitmap, limits) {
189
+ let result = bitmap;
190
+ while (limits.maxWidth && result.width > limits.maxWidth || limits.maxHeight && result.height > limits.maxHeight) {
191
+ result = Downsample2x2(result);
192
+ }
193
+ return result;
194
+ }
195
+ function Downsample2x2(bitmap) {
196
+ const width = Math.max(1, Math.floor(bitmap.width / 2));
197
+ const height = Math.max(1, Math.floor(bitmap.height / 2));
198
+ const data = new Uint8Array(width * height * 4);
199
+ for (let y = 0; y < height; y++) {
200
+ for (let x = 0; x < width; x++) {
201
+ const counts = [0, 0, 0, 0];
202
+ let samples = 0;
203
+ for (let oy = 0; oy < 2; oy++) {
204
+ for (let ox = 0; ox < 2; ox++) {
205
+ const sourceX = Math.min(bitmap.width - 1, x * 2 + ox);
206
+ const sourceY = Math.min(bitmap.height - 1, y * 2 + oy);
207
+ const source = (sourceY * bitmap.width + sourceX) * 4;
208
+ for (let channel = 0; channel < 4; channel++) {
209
+ counts[channel] += bitmap.data[source + channel];
210
+ }
211
+ samples++;
212
+ }
213
+ }
214
+ const target = (y * width + x) * 4;
215
+ for (let channel = 0; channel < 4; channel++) {
216
+ data[target + channel] = Math.round(counts[channel] / samples);
217
+ }
218
+ }
219
+ }
220
+ return {
221
+ ...bitmap,
222
+ width,
223
+ height,
224
+ data
225
+ };
226
+ }
227
+ function PackBitmap(step, inputs) {
228
+ // The generated schema records the enum's zero value, while Carbon's
229
+ // constructor initializes this step to B8G8R8A8_UNORM.
230
+ const format = step.format === PixelFormat.PIXEL_FORMAT_UNKNOWN ? PixelFormat.PIXEL_FORMAT_B8G8R8A8_UNORM : step.format;
231
+ if (!PACK_FORMATS.has(format)) {
232
+ throw PipelineError("CJS_TEXTURE_PIPELINE_FORMAT_UNSUPPORTED", `Unsupported Carbon pack pixel format: ${String(format)}.`);
233
+ }
234
+ const descriptors = [step.r, step.g, step.b, step.a];
235
+ const sources = descriptors.map(channel => channel?.path ? RequireInput(inputs, channel.path) : null);
236
+ const first = sources.find(Boolean);
237
+ const width = first?.width || 4;
238
+ const height = first?.height || 4;
239
+ for (const source of sources) {
240
+ if (source && (source.width !== width || source.height !== height)) {
241
+ throw PipelineError("CJS_TEXTURE_PIPELINE_SIZE_MISMATCH", "Texture pipeline pack inputs must have identical dimensions.");
242
+ }
243
+ }
244
+ const data = new Uint8Array(width * height * 4);
245
+ const isR8 = format === PixelFormat.PIXEL_FORMAT_R8_UNORM;
246
+ const isX8 = format === PixelFormat.PIXEL_FORMAT_B8G8R8X8_UNORM;
247
+ for (let pixel = 0; pixel < width * height; pixel++) {
248
+ const values = descriptors.map((channel, index) => ReadPackChannel(sources[index], channel, pixel));
249
+ const target = pixel * 4;
250
+ if (isR8) {
251
+ data[target] = values[0];
252
+ data[target + 3] = 255;
253
+ } else {
254
+ data[target] = values[0];
255
+ data[target + 1] = values[1];
256
+ data[target + 2] = values[2];
257
+ data[target + 3] = isX8 ? 255 : values[3];
258
+ }
259
+ }
260
+ return {
261
+ width,
262
+ height,
263
+ data,
264
+ sourceFormat: "texture-pipeline",
265
+ colorSpace: first?.colorSpace || "unknown",
266
+ alphaMode: isX8 || isR8 ? "opaque" : "unknown",
267
+ metadata: {
268
+ carbonPixelFormat: format
269
+ }
270
+ };
271
+ }
272
+ function ReadPackChannel(source, descriptor, pixel) {
273
+ if (!source) {
274
+ return AssertByte(descriptor?.fill ?? 0, "fill");
275
+ }
276
+ const channel = AssertByte(descriptor?.channel ?? 0, "channel");
277
+ if (channel > 3) {
278
+ throw new RangeError("Tr2TexturePackChannel.channel must be between 0 and 3.");
279
+ }
280
+ // Carbon's exposed chooser encodes RED=2 and BLUE=0 for BGRA host
281
+ // bitmaps. Translate those values to this package's canonical RGBA input.
282
+ const rgbaChannel = channel === 0 ? 2 : channel === 2 ? 0 : channel;
283
+ return source.data[pixel * 4 + rgbaChannel];
284
+ }
285
+ function AssertByte(value, name) {
286
+ if (!Number.isInteger(value) || value < 0 || value > 255) {
287
+ throw new RangeError(`Tr2TexturePackChannel.${name} must be an integer from 0 to 255.`);
288
+ }
289
+ return value;
290
+ }
291
+ function RequireInput(inputs, path) {
292
+ const value = inputs.get(String(path || ""));
293
+ if (!value) {
294
+ throw PipelineError("CJS_TEXTURE_PIPELINE_INPUT_MISSING", `Texture pipeline input is unavailable: ${String(path || "")}.`);
295
+ }
296
+ return value;
297
+ }
298
+ function RequireBitmap(bitmap) {
299
+ if (!bitmap) {
300
+ throw PipelineError("CJS_TEXTURE_PIPELINE_BITMAP_INVALID", "Texture pipeline step requires a valid input bitmap.");
301
+ }
302
+ return bitmap;
303
+ }
304
+ function AddDependency(dependencies, value) {
305
+ const path = String(value || "");
306
+ if (path) {
307
+ dependencies.add(path);
308
+ }
309
+ }
310
+ function StepName(step) {
311
+ return step?.constructor?.name || step?.className || "";
312
+ }
313
+ function PipelineError(code, message) {
314
+ const error = new Error(message);
315
+ error.code = code;
316
+ return error;
317
+ }
318
+
319
+ export { ExecuteTexturePipeline, GetTexturePipelineDependencies };
320
+ //# sourceMappingURL=texturePipelineBehavior.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"texturePipelineBehavior.js","sources":["../../../src/resources/texturePipelineBehavior.js"],"sourcesContent":["// Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipeline.cpp\r\n// Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLoad.cpp\r\n// Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLimitSize.cpp\r\n// Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepCompress.cpp\r\n// Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack.cpp\r\nimport { validateRgbaPayload } from \"../format/payloadContract.js\";\r\nimport { PixelFormat as PayloadPixelFormat } from \"@carbonenginejs/runtime-const/graphics\";\r\nimport { PixelFormat as CarbonPixelFormat } from \"@carbonenginejs/runtime-const/render-context\";\r\n\r\nconst STEP_LOAD = \"Tr2TexturePipelineStepLoad\";\r\nconst STEP_LIMIT_SIZE = \"Tr2TexturePipelineStepLimitSize\";\r\nconst STEP_COMPRESS = \"Tr2TexturePipelineStepCompress\";\r\nconst STEP_PACK = \"Tr2TexturePipelineStepPack\";\r\nconst PACK_FORMATS = new Set([\r\n CarbonPixelFormat.PIXEL_FORMAT_R8_UNORM,\r\n CarbonPixelFormat.PIXEL_FORMAT_B8G8R8A8_UNORM,\r\n CarbonPixelFormat.PIXEL_FORMAT_B8G8R8X8_UNORM\r\n]);\r\n\r\n/**\r\n * Collect Carbon texture-pipeline dependencies in std::set-equivalent order.\r\n *\r\n * @param {object[]} steps Pipeline steps.\r\n * @returns {string[]} Sorted unique resource paths.\r\n */\r\nexport function GetTexturePipelineDependencies(steps)\r\n{\r\n const dependencies = new Set();\r\n for (const step of AssertSteps(steps))\r\n {\r\n const name = StepName(step);\r\n if (name === STEP_LOAD)\r\n {\r\n AddDependency(dependencies, step.path);\r\n }\r\n else if (name === STEP_PACK)\r\n {\r\n AddDependency(dependencies, step.r?.path);\r\n AddDependency(dependencies, step.g?.path);\r\n AddDependency(dependencies, step.b?.path);\r\n AddDependency(dependencies, step.a?.path);\r\n }\r\n }\r\n return [ ...dependencies ].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);\r\n}\r\n\r\n/**\r\n * Execute the maintained JavaScript form of Carbon's CPU bitmap pipeline.\r\n *\r\n * @param {object[]} steps Pipeline steps.\r\n * @param {{maxWidth:number,maxHeight:number}} params Caller size limits.\r\n * @param {object|null} options Input resolution options.\r\n * @returns {Promise<object>} Canonical RGBA payload.\r\n */\r\nexport async function ExecuteTexturePipeline(steps, params, options = null)\r\n{\r\n const list = AssertSteps(steps);\r\n if (!list.length)\r\n {\r\n throw PipelineError(\"CJS_TEXTURE_PIPELINE_NO_STEPS\", \"Tr2TexturePipeline has no steps.\");\r\n }\r\n const limits = {\r\n maxWidth: AssertLimit(params?.maxWidth, \"maxWidth\"),\r\n maxHeight: AssertLimit(params?.maxHeight, \"maxHeight\")\r\n };\r\n const settings = NormalizeOptions(options);\r\n const inputs = new Map();\r\n for (const path of GetTexturePipelineDependencies(list))\r\n {\r\n inputs.set(path, await ResolveInput(path, settings));\r\n }\r\n\r\n let bitmap = null;\r\n for (const step of list)\r\n {\r\n const name = StepName(step);\r\n if (name === STEP_LOAD)\r\n {\r\n bitmap = CloneBitmap(RequireInput(inputs, step.path));\r\n }\r\n else if (name === STEP_LIMIT_SIZE)\r\n {\r\n bitmap = LimitBitmap(RequireBitmap(bitmap), CombineLimits(step, limits));\r\n }\r\n else if (name === STEP_COMPRESS)\r\n {\r\n // Carbon's current implementation validates the bitmap and otherwise\r\n // performs no compression work.\r\n RequireBitmap(bitmap);\r\n }\r\n else if (name === STEP_PACK)\r\n {\r\n bitmap = PackBitmap(step, inputs);\r\n }\r\n else\r\n {\r\n throw PipelineError(\r\n \"CJS_TEXTURE_PIPELINE_STEP_UNSUPPORTED\",\r\n `Unsupported texture pipeline step: ${name || \"unknown\"}.`\r\n );\r\n }\r\n }\r\n\r\n bitmap = LimitBitmap(RequireBitmap(bitmap), limits);\r\n return ToPayload(bitmap);\r\n}\r\n\r\nfunction AssertSteps(steps)\r\n{\r\n if (!Array.isArray(steps))\r\n {\r\n throw new TypeError(\"Tr2TexturePipeline.steps must be an array.\");\r\n }\r\n return steps;\r\n}\r\n\r\nfunction AssertLimit(value, name)\r\n{\r\n if (!Number.isSafeInteger(value) || value < 0)\r\n {\r\n throw new TypeError(`Tr2TexturePipeline ${name} must be a non-negative safe integer.`);\r\n }\r\n return value;\r\n}\r\n\r\nfunction NormalizeOptions(options)\r\n{\r\n if (options === null || options === undefined)\r\n {\r\n return {};\r\n }\r\n if (!options || typeof options !== \"object\" || Array.isArray(options))\r\n {\r\n throw new TypeError(\"Tr2TexturePipeline options must be an object or null.\");\r\n }\r\n if (options.load !== undefined && typeof options.load !== \"function\")\r\n {\r\n throw new TypeError(\"Tr2TexturePipeline options.load must be a function.\");\r\n }\r\n if (options.resMan !== undefined && typeof options.resMan?.GetObject !== \"function\")\r\n {\r\n throw new TypeError(\"Tr2TexturePipeline options.resMan must provide GetObject().\");\r\n }\r\n return options;\r\n}\r\n\r\nasync function ResolveInput(path, options)\r\n{\r\n let value;\r\n if (options.inputs instanceof Map)\r\n {\r\n value = options.inputs.get(path);\r\n }\r\n else if (options.inputs && typeof options.inputs === \"object\")\r\n {\r\n value = options.inputs[path];\r\n }\r\n if (value === undefined && options.load)\r\n {\r\n value = await options.load(path);\r\n }\r\n if (value === undefined && options.resMan)\r\n {\r\n value = await options.resMan.GetObject(path, {\r\n ...(options.resourceOptions || {}),\r\n requirement: \"image\",\r\n emit: \"rgba\"\r\n });\r\n }\r\n if (value === undefined)\r\n {\r\n throw PipelineError(\r\n \"CJS_TEXTURE_PIPELINE_INPUT_MISSING\",\r\n `No texture pipeline input was provided for ${path}.`\r\n );\r\n }\r\n const payload = typeof value?.GetPayload === \"function\" ? value.GetPayload() : value;\r\n validateRgbaPayload(payload);\r\n if (payload.pixelFormat !== PayloadPixelFormat.RGBA8_UNORM)\r\n {\r\n throw PipelineError(\r\n \"CJS_TEXTURE_PIPELINE_FORMAT_UNSUPPORTED\",\r\n `Texture pipeline input ${path} must use rgba8unorm.`\r\n );\r\n }\r\n return FromPayload(payload);\r\n}\r\n\r\nfunction FromPayload(payload)\r\n{\r\n const data = new Uint8Array(payload.width * payload.height * 4);\r\n for (let y = 0; y < payload.height; y++)\r\n {\r\n const sourceOffset = y * payload.strideBytes;\r\n const targetOffset = y * payload.width * 4;\r\n data.set(payload.data.subarray(sourceOffset, sourceOffset + payload.width * 4), targetOffset);\r\n }\r\n return {\r\n width: payload.width,\r\n height: payload.height,\r\n data,\r\n sourceFormat: payload.sourceFormat || \"rgba\",\r\n colorSpace: payload.colorSpace,\r\n alphaMode: payload.alphaMode,\r\n metadata: payload.metadata || null\r\n };\r\n}\r\n\r\nfunction ToPayload(bitmap)\r\n{\r\n return {\r\n payloadType: \"rgba\",\r\n sourceFormat: bitmap.sourceFormat || \"texture-pipeline\",\r\n width: bitmap.width,\r\n height: bitmap.height,\r\n pixelFormat: PayloadPixelFormat.RGBA8_UNORM,\r\n data: bitmap.data,\r\n strideBytes: bitmap.width * 4,\r\n origin: \"top-left\",\r\n colorSpace: bitmap.colorSpace || \"unknown\",\r\n alphaMode: bitmap.alphaMode || \"unknown\",\r\n ...(bitmap.metadata ? { metadata: bitmap.metadata } : {})\r\n };\r\n}\r\n\r\nfunction CloneBitmap(bitmap)\r\n{\r\n return {\r\n ...bitmap,\r\n data: new Uint8Array(bitmap.data),\r\n metadata: bitmap.metadata && typeof bitmap.metadata === \"object\"\r\n ? { ...bitmap.metadata }\r\n : bitmap.metadata\r\n };\r\n}\r\n\r\nfunction CombineLimits(step, params)\r\n{\r\n return {\r\n maxWidth: TightestLimit(AssertLimit(step.maxWidth ?? 0, \"step.maxWidth\"), params.maxWidth),\r\n maxHeight: TightestLimit(AssertLimit(step.maxHeight ?? 0, \"step.maxHeight\"), params.maxHeight)\r\n };\r\n}\r\n\r\nfunction TightestLimit(first, second)\r\n{\r\n if (!first) return second;\r\n if (!second) return first;\r\n return Math.min(first, second);\r\n}\r\n\r\nfunction LimitBitmap(bitmap, limits)\r\n{\r\n let result = bitmap;\r\n while ((limits.maxWidth && result.width > limits.maxWidth)\r\n || (limits.maxHeight && result.height > limits.maxHeight))\r\n {\r\n result = Downsample2x2(result);\r\n }\r\n return result;\r\n}\r\n\r\nfunction Downsample2x2(bitmap)\r\n{\r\n const width = Math.max(1, Math.floor(bitmap.width / 2));\r\n const height = Math.max(1, Math.floor(bitmap.height / 2));\r\n const data = new Uint8Array(width * height * 4);\r\n for (let y = 0; y < height; y++)\r\n {\r\n for (let x = 0; x < width; x++)\r\n {\r\n const counts = [ 0, 0, 0, 0 ];\r\n let samples = 0;\r\n for (let oy = 0; oy < 2; oy++)\r\n {\r\n for (let ox = 0; ox < 2; ox++)\r\n {\r\n const sourceX = Math.min(bitmap.width - 1, x * 2 + ox);\r\n const sourceY = Math.min(bitmap.height - 1, y * 2 + oy);\r\n const source = (sourceY * bitmap.width + sourceX) * 4;\r\n for (let channel = 0; channel < 4; channel++)\r\n {\r\n counts[channel] += bitmap.data[source + channel];\r\n }\r\n samples++;\r\n }\r\n }\r\n const target = (y * width + x) * 4;\r\n for (let channel = 0; channel < 4; channel++)\r\n {\r\n data[target + channel] = Math.round(counts[channel] / samples);\r\n }\r\n }\r\n }\r\n return { ...bitmap, width, height, data };\r\n}\r\n\r\nfunction PackBitmap(step, inputs)\r\n{\r\n // The generated schema records the enum's zero value, while Carbon's\r\n // constructor initializes this step to B8G8R8A8_UNORM.\r\n const format = step.format === CarbonPixelFormat.PIXEL_FORMAT_UNKNOWN\r\n ? CarbonPixelFormat.PIXEL_FORMAT_B8G8R8A8_UNORM\r\n : step.format;\r\n if (!PACK_FORMATS.has(format))\r\n {\r\n throw PipelineError(\r\n \"CJS_TEXTURE_PIPELINE_FORMAT_UNSUPPORTED\",\r\n `Unsupported Carbon pack pixel format: ${String(format)}.`\r\n );\r\n }\r\n const descriptors = [ step.r, step.g, step.b, step.a ];\r\n const sources = descriptors.map(channel => channel?.path\r\n ? RequireInput(inputs, channel.path)\r\n : null);\r\n const first = sources.find(Boolean);\r\n const width = first?.width || 4;\r\n const height = first?.height || 4;\r\n for (const source of sources)\r\n {\r\n if (source && (source.width !== width || source.height !== height))\r\n {\r\n throw PipelineError(\r\n \"CJS_TEXTURE_PIPELINE_SIZE_MISMATCH\",\r\n \"Texture pipeline pack inputs must have identical dimensions.\"\r\n );\r\n }\r\n }\r\n\r\n const data = new Uint8Array(width * height * 4);\r\n const isR8 = format === CarbonPixelFormat.PIXEL_FORMAT_R8_UNORM;\r\n const isX8 = format === CarbonPixelFormat.PIXEL_FORMAT_B8G8R8X8_UNORM;\r\n for (let pixel = 0; pixel < width * height; pixel++)\r\n {\r\n const values = descriptors.map((channel, index) => ReadPackChannel(\r\n sources[index],\r\n channel,\r\n pixel\r\n ));\r\n const target = pixel * 4;\r\n if (isR8)\r\n {\r\n data[target] = values[0];\r\n data[target + 3] = 255;\r\n }\r\n else\r\n {\r\n data[target] = values[0];\r\n data[target + 1] = values[1];\r\n data[target + 2] = values[2];\r\n data[target + 3] = isX8 ? 255 : values[3];\r\n }\r\n }\r\n return {\r\n width,\r\n height,\r\n data,\r\n sourceFormat: \"texture-pipeline\",\r\n colorSpace: first?.colorSpace || \"unknown\",\r\n alphaMode: isX8 || isR8 ? \"opaque\" : \"unknown\",\r\n metadata: { carbonPixelFormat: format }\r\n };\r\n}\r\n\r\nfunction ReadPackChannel(source, descriptor, pixel)\r\n{\r\n if (!source)\r\n {\r\n return AssertByte(descriptor?.fill ?? 0, \"fill\");\r\n }\r\n const channel = AssertByte(descriptor?.channel ?? 0, \"channel\");\r\n if (channel > 3)\r\n {\r\n throw new RangeError(\"Tr2TexturePackChannel.channel must be between 0 and 3.\");\r\n }\r\n // Carbon's exposed chooser encodes RED=2 and BLUE=0 for BGRA host\r\n // bitmaps. Translate those values to this package's canonical RGBA input.\r\n const rgbaChannel = channel === 0 ? 2 : channel === 2 ? 0 : channel;\r\n return source.data[pixel * 4 + rgbaChannel];\r\n}\r\n\r\nfunction AssertByte(value, name)\r\n{\r\n if (!Number.isInteger(value) || value < 0 || value > 255)\r\n {\r\n throw new RangeError(`Tr2TexturePackChannel.${name} must be an integer from 0 to 255.`);\r\n }\r\n return value;\r\n}\r\n\r\nfunction RequireInput(inputs, path)\r\n{\r\n const value = inputs.get(String(path || \"\"));\r\n if (!value)\r\n {\r\n throw PipelineError(\r\n \"CJS_TEXTURE_PIPELINE_INPUT_MISSING\",\r\n `Texture pipeline input is unavailable: ${String(path || \"\")}.`\r\n );\r\n }\r\n return value;\r\n}\r\n\r\nfunction RequireBitmap(bitmap)\r\n{\r\n if (!bitmap)\r\n {\r\n throw PipelineError(\r\n \"CJS_TEXTURE_PIPELINE_BITMAP_INVALID\",\r\n \"Texture pipeline step requires a valid input bitmap.\"\r\n );\r\n }\r\n return bitmap;\r\n}\r\n\r\nfunction AddDependency(dependencies, value)\r\n{\r\n const path = String(value || \"\");\r\n if (path)\r\n {\r\n dependencies.add(path);\r\n }\r\n}\r\n\r\nfunction StepName(step)\r\n{\r\n return step?.constructor?.name || step?.className || \"\";\r\n}\r\n\r\nfunction PipelineError(code, message)\r\n{\r\n const error = new Error(message);\r\n error.code = code;\r\n return error;\r\n}\r\n"],"names":["STEP_LOAD","STEP_LIMIT_SIZE","STEP_COMPRESS","STEP_PACK","PACK_FORMATS","Set","CarbonPixelFormat","PIXEL_FORMAT_R8_UNORM","PIXEL_FORMAT_B8G8R8A8_UNORM","PIXEL_FORMAT_B8G8R8X8_UNORM","GetTexturePipelineDependencies","steps","dependencies","step","AssertSteps","name","StepName","AddDependency","path","r","g","b","a","sort","ExecuteTexturePipeline","params","options","list","length","PipelineError","limits","maxWidth","AssertLimit","maxHeight","settings","NormalizeOptions","inputs","Map","set","ResolveInput","bitmap","CloneBitmap","RequireInput","LimitBitmap","RequireBitmap","CombineLimits","PackBitmap","ToPayload","Array","isArray","TypeError","value","Number","isSafeInteger","undefined","load","resMan","GetObject","get","resourceOptions","requirement","emit","payload","GetPayload","validateRgbaPayload","pixelFormat","PayloadPixelFormat","RGBA8_UNORM","FromPayload","data","Uint8Array","width","height","y","sourceOffset","strideBytes","targetOffset","subarray","sourceFormat","colorSpace","alphaMode","metadata","payloadType","origin","TightestLimit","first","second","Math","min","result","Downsample2x2","max","floor","x","counts","samples","oy","ox","sourceX","sourceY","source","channel","target","round","format","PIXEL_FORMAT_UNKNOWN","has","String","descriptors","sources","map","find","Boolean","isR8","isX8","pixel","values","index","ReadPackChannel","carbonPixelFormat","descriptor","AssertByte","fill","RangeError","rgbaChannel","isInteger","add","constructor","className","code","message","error","Error"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AAKA,MAAMA,SAAS,GAAG,4BAA4B;AAC9C,MAAMC,eAAe,GAAG,iCAAiC;AACzD,MAAMC,aAAa,GAAG,gCAAgC;AACtD,MAAMC,SAAS,GAAG,4BAA4B;AAC9C,MAAMC,YAAY,GAAG,IAAIC,GAAG,CAAC,CAC3BC,WAAiB,CAACC,qBAAqB,EACvCD,WAAiB,CAACE,2BAA2B,EAC7CF,WAAiB,CAACG,2BAA2B,CAC9C,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,8BAA8BA,CAACC,KAAK,EACpD;AACE,EAAA,MAAMC,YAAY,GAAG,IAAIP,GAAG,EAAE;AAC9B,EAAA,KAAK,MAAMQ,IAAI,IAAIC,WAAW,CAACH,KAAK,CAAC,EACrC;AACE,IAAA,MAAMI,IAAI,GAAGC,QAAQ,CAACH,IAAI,CAAC;IAC3B,IAAIE,IAAI,KAAKf,SAAS,EACtB;AACEiB,MAAAA,aAAa,CAACL,YAAY,EAAEC,IAAI,CAACK,IAAI,CAAC;AACxC,IAAA,CAAC,MACI,IAAIH,IAAI,KAAKZ,SAAS,EAC3B;MACEc,aAAa,CAACL,YAAY,EAAEC,IAAI,CAACM,CAAC,EAAED,IAAI,CAAC;MACzCD,aAAa,CAACL,YAAY,EAAEC,IAAI,CAACO,CAAC,EAAEF,IAAI,CAAC;MACzCD,aAAa,CAACL,YAAY,EAAEC,IAAI,CAACQ,CAAC,EAAEH,IAAI,CAAC;MACzCD,aAAa,CAACL,YAAY,EAAEC,IAAI,CAACS,CAAC,EAAEJ,IAAI,CAAC;AAC3C,IAAA;AACF,EAAA;EACA,OAA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