@carbonenginejs/runtime-resource 0.9.1 → 0.10.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 (332) hide show
  1. package/NOTICE +3 -2
  2. package/README.md +47 -6
  3. package/dist/CjsMotherLode.js +88 -88
  4. package/dist/CjsMotherLode.js.map +1 -1
  5. package/dist/CjsResMan.js +718 -229
  6. package/dist/CjsResMan.js.map +1 -1
  7. package/dist/CjsResManFetchProvider.js +94 -0
  8. package/dist/CjsResManFetchProvider.js.map +1 -0
  9. package/dist/{CjsResManQueue.js → CjsResManWorkQueue.js} +112 -25
  10. package/dist/CjsResManWorkQueue.js.map +1 -0
  11. package/dist/format/CjsBlueReader.js +91 -2
  12. package/dist/format/CjsBlueReader.js.map +1 -1
  13. package/dist/format/CjsFormat.js +47 -21
  14. package/dist/format/CjsFormat.js.map +1 -1
  15. package/dist/format/CjsReader.js +4 -0
  16. package/dist/format/CjsReader.js.map +1 -1
  17. package/dist/format/CjsResourceProbe.js +4 -2
  18. package/dist/format/CjsResourceProbe.js.map +1 -1
  19. package/dist/format/payloadContract.js +20 -0
  20. package/dist/format/payloadContract.js.map +1 -1
  21. package/dist/formats/black/CjsBlackFormat.js +15 -1
  22. package/dist/formats/black/CjsBlackFormat.js.map +1 -1
  23. package/dist/formats/black/core/CjsBlackBinaryReader.js +103 -0
  24. package/dist/formats/black/core/CjsBlackBinaryReader.js.map +1 -1
  25. package/dist/formats/black/core/CjsBlackPropertyReaders.js +62 -1
  26. package/dist/formats/black/core/CjsBlackPropertyReaders.js.map +1 -1
  27. package/dist/formats/black/core/CjsBlackReader.js +127 -2
  28. package/dist/formats/black/core/CjsBlackReader.js.map +1 -1
  29. package/dist/formats/black/core/CjsBlackSchemaRegistry.js +103 -0
  30. package/dist/formats/black/core/CjsBlackSchemaRegistry.js.map +1 -1
  31. package/dist/formats/black/core/helpers.js +17 -0
  32. package/dist/formats/black/core/helpers.js.map +1 -1
  33. package/dist/formats/bnk/CjsBnkFormat.js +8 -0
  34. package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
  35. package/dist/formats/bnk/core/helpers.js +20 -0
  36. package/dist/formats/bnk/core/helpers.js.map +1 -1
  37. package/dist/formats/bnk/core/musicNodes.js +40 -3
  38. package/dist/formats/bnk/core/musicNodes.js.map +1 -1
  39. package/dist/formats/bnk/core/soundbanksInfo.js +2 -0
  40. package/dist/formats/bnk/core/soundbanksInfo.js.map +1 -1
  41. package/dist/formats/cmf/core/binary.js +71 -0
  42. package/dist/formats/cmf/core/binary.js.map +1 -1
  43. package/dist/formats/cmf/core/buffers.js +4 -0
  44. package/dist/formats/cmf/core/buffers.js.map +1 -1
  45. package/dist/formats/cmf/core/helpers.js +31 -0
  46. package/dist/formats/cmf/core/helpers.js.map +1 -1
  47. package/dist/formats/cmf/core/schema.js +10 -0
  48. package/dist/formats/cmf/core/schema.js.map +1 -1
  49. package/dist/formats/cmf/core/shared.js +9 -0
  50. package/dist/formats/cmf/core/shared.js.map +1 -1
  51. package/dist/formats/cmf/core/writer.js +54 -0
  52. package/dist/formats/cmf/core/writer.js.map +1 -1
  53. package/dist/formats/dds/core/bc6h.js +10 -0
  54. package/dist/formats/dds/core/bc6h.js.map +1 -1
  55. package/dist/formats/dds/core/bc7.js +16 -0
  56. package/dist/formats/dds/core/bc7.js.map +1 -1
  57. package/dist/formats/dds/core/helpers.js +47 -0
  58. package/dist/formats/dds/core/helpers.js.map +1 -1
  59. package/dist/formats/fbx/core/helpers.js +22 -1
  60. package/dist/formats/fbx/core/helpers.js.map +1 -1
  61. package/dist/formats/flac/CjsFlacFormat.js +49 -0
  62. package/dist/formats/flac/CjsFlacFormat.js.map +1 -1
  63. package/dist/formats/flac/core/helpers.js +20 -0
  64. package/dist/formats/flac/core/helpers.js.map +1 -1
  65. package/dist/formats/gif/CjsGifFormat.js +49 -0
  66. package/dist/formats/gif/CjsGifFormat.js.map +1 -1
  67. package/dist/formats/gif/core/helpers.js +20 -0
  68. package/dist/formats/gif/core/helpers.js.map +1 -1
  69. package/dist/formats/gltf/core/helpers.js +18 -3
  70. package/dist/formats/gltf/core/helpers.js.map +1 -1
  71. package/dist/formats/gltf/core/parser.js +13 -0
  72. package/dist/formats/gltf/core/parser.js.map +1 -1
  73. package/dist/formats/gltf/core/targets.js +10 -0
  74. package/dist/formats/gltf/core/targets.js.map +1 -1
  75. package/dist/formats/gr2/core/bitknit2.js +2 -0
  76. package/dist/formats/gr2/core/bitknit2.js.map +1 -1
  77. package/dist/formats/gr2/core/helpers.js +20 -0
  78. package/dist/formats/gr2/core/helpers.js.map +1 -1
  79. package/dist/formats/gr2/core/tangents.js +9 -9
  80. package/dist/formats/gr2/core/tangents.js.map +1 -1
  81. package/dist/formats/gr2/core/targets.js +10 -0
  82. package/dist/formats/gr2/core/targets.js.map +1 -1
  83. package/dist/formats/index.js +4 -4
  84. package/dist/formats/jpeg/core/helpers.js +52 -0
  85. package/dist/formats/jpeg/core/helpers.js.map +1 -1
  86. package/dist/formats/jpeg/core/jpeg.js +93 -0
  87. package/dist/formats/jpeg/core/jpeg.js.map +1 -1
  88. package/dist/formats/mp3/core/helpers.js +37 -0
  89. package/dist/formats/mp3/core/helpers.js.map +1 -1
  90. package/dist/formats/mp4/core/helpers.js +35 -0
  91. package/dist/formats/mp4/core/helpers.js.map +1 -1
  92. package/dist/formats/obj/core/helpers.js +2 -2
  93. package/dist/formats/obj/core/helpers.js.map +1 -1
  94. package/dist/formats/ogg/CjsOggFormat.js +49 -0
  95. package/dist/formats/ogg/CjsOggFormat.js.map +1 -1
  96. package/dist/formats/ogg/core/helpers.js +23 -0
  97. package/dist/formats/ogg/core/helpers.js.map +1 -1
  98. package/dist/formats/ogg/core/vorbis.js +13 -0
  99. package/dist/formats/ogg/core/vorbis.js.map +1 -1
  100. package/dist/formats/png/core/helpers.js +52 -0
  101. package/dist/formats/png/core/helpers.js.map +1 -1
  102. package/dist/formats/red/CjsRedFormat.js +3 -1
  103. package/dist/formats/red/CjsRedFormat.js.map +1 -1
  104. package/dist/formats/red/core/CjsRedReader.js +52 -0
  105. package/dist/formats/red/core/CjsRedReader.js.map +1 -1
  106. package/dist/formats/red/core/helpers.js +19 -0
  107. package/dist/formats/red/core/helpers.js.map +1 -1
  108. package/dist/formats/stl/core/stl.js +10 -2
  109. package/dist/formats/stl/core/stl.js.map +1 -1
  110. package/dist/formats/stl/core/targets.js +10 -0
  111. package/dist/formats/stl/core/targets.js.map +1 -1
  112. package/dist/formats/tga/core/helpers.js +47 -0
  113. package/dist/formats/tga/core/helpers.js.map +1 -1
  114. package/dist/formats/wav/core/helpers.js +37 -0
  115. package/dist/formats/wav/core/helpers.js.map +1 -1
  116. package/dist/formats/webm/core/helpers.js +35 -0
  117. package/dist/formats/webm/core/helpers.js.map +1 -1
  118. package/dist/formats/webp/CjsWebpFormat.js +49 -0
  119. package/dist/formats/webp/CjsWebpFormat.js.map +1 -1
  120. package/dist/formats/webp/core/helpers.js +23 -0
  121. package/dist/formats/webp/core/helpers.js.map +1 -1
  122. package/dist/formats/wem/CjsWemFormat.js +8 -0
  123. package/dist/formats/wem/CjsWemFormat.js.map +1 -1
  124. package/dist/formats/wem/core/bitStream.js +2 -0
  125. package/dist/formats/wem/core/bitStream.js.map +1 -1
  126. package/dist/formats/wem/core/helpers.js +20 -0
  127. package/dist/formats/wem/core/helpers.js.map +1 -1
  128. package/dist/formats/yaml/CjsYamlFormat.js +45 -0
  129. package/dist/formats/yaml/CjsYamlFormat.js.map +1 -1
  130. package/dist/formats/yaml/core/CjsYamlReader.js +91 -0
  131. package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -1
  132. package/dist/formats/yaml/core/helpers.js +10 -0
  133. package/dist/formats/yaml/core/helpers.js.map +1 -1
  134. package/dist/index.js +57 -44
  135. package/dist/index.js.map +1 -1
  136. package/dist/{CjsResource.js → resource/CjsResource.js} +234 -19
  137. package/dist/resource/CjsResource.js.map +1 -0
  138. package/dist/{resources → resource}/Tr2LightProfileRes.js +5 -4
  139. package/dist/resource/Tr2LightProfileRes.js.map +1 -0
  140. package/dist/{resources → resource/audio}/AudioGeometryResData.js +4 -4
  141. package/dist/resource/audio/AudioGeometryResData.js.map +1 -0
  142. package/dist/resource/audio/CjsAudioBufferRes.js +86 -0
  143. package/dist/resource/audio/CjsAudioBufferRes.js.map +1 -0
  144. package/dist/resource/audio/CjsAudioRes.js +213 -0
  145. package/dist/resource/audio/CjsAudioRes.js.map +1 -0
  146. package/dist/resource/audio/index.js +4 -0
  147. package/dist/resource/audio/index.js.map +1 -0
  148. package/dist/{resources → resource/geometry}/MeshDecalData.js +3 -3
  149. package/dist/resource/geometry/MeshDecalData.js.map +1 -0
  150. package/dist/{resources → resource/geometry}/MeshDecalLodData.js +3 -3
  151. package/dist/resource/geometry/MeshDecalLodData.js.map +1 -0
  152. package/dist/resource/geometry/TriGeometryRes.js +656 -0
  153. package/dist/resource/geometry/TriGeometryRes.js.map +1 -0
  154. package/dist/{resources → resource/geometry}/TriGeometryResAreaData.js +4 -4
  155. package/dist/resource/geometry/TriGeometryResAreaData.js.map +1 -0
  156. package/dist/{resources → resource/geometry}/TriGeometryResJointData.js +4 -4
  157. package/dist/resource/geometry/TriGeometryResJointData.js.map +1 -0
  158. package/dist/{resources → resource/geometry}/TriGeometryResLodData.js +3 -3
  159. package/dist/resource/geometry/TriGeometryResLodData.js.map +1 -0
  160. package/dist/{resources → resource/geometry}/TriGeometryResMeshData.js +5 -5
  161. package/dist/resource/geometry/TriGeometryResMeshData.js.map +1 -0
  162. package/dist/{resources → resource/geometry}/TriGeometryResSkeletonData.js +3 -3
  163. package/dist/resource/geometry/TriGeometryResSkeletonData.js.map +1 -0
  164. package/dist/{resources → resource/geometry}/TriJointBinding.js +4 -4
  165. package/dist/resource/geometry/TriJointBinding.js.map +1 -0
  166. package/dist/{resources → resource/geometry}/TriMorphTargetGeometryConstants.js +3 -3
  167. package/dist/resource/geometry/TriMorphTargetGeometryConstants.js.map +1 -0
  168. package/dist/{resources → resource/geometry}/TriRtGeometryConstants.js +3 -3
  169. package/dist/resource/geometry/TriRtGeometryConstants.js.map +1 -0
  170. package/dist/{resources → resource/geometry/granny}/GStateBindingCallbackData.js +3 -3
  171. package/dist/resource/geometry/granny/GStateBindingCallbackData.js.map +1 -0
  172. package/dist/{resources → resource/geometry/granny}/Tr2GrannyIntersectionResult.js +5 -5
  173. package/dist/resource/geometry/granny/Tr2GrannyIntersectionResult.js.map +1 -0
  174. package/dist/{resources → resource/geometry/granny}/Tr2GrannyStateRes.js +7 -6
  175. package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -0
  176. package/dist/{resources → resource/geometry/granny}/TriGrannyRes.js +7 -6
  177. package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -0
  178. package/dist/{resources → resource/geometry/granny}/enums.js +1 -9
  179. package/dist/resource/geometry/granny/enums.js.map +1 -0
  180. package/dist/resource/geometry/granny/index.js +6 -0
  181. package/dist/resource/geometry/granny/index.js.map +1 -0
  182. package/dist/resource/geometry/index.js +17 -0
  183. package/dist/resource/geometry/index.js.map +1 -0
  184. package/dist/resource/index.js +52 -0
  185. package/dist/resource/index.js.map +1 -0
  186. package/dist/resource/resourceBoundary.js +64 -0
  187. package/dist/resource/resourceBoundary.js.map +1 -0
  188. package/dist/resource/shader/Tr2EffectRes.js +420 -0
  189. package/dist/resource/shader/Tr2EffectRes.js.map +1 -0
  190. package/dist/{resources → resource/shader}/Tr2MaterialArea.js +11 -6
  191. package/dist/resource/shader/Tr2MaterialArea.js.map +1 -0
  192. package/dist/{resources → resource/shader}/Tr2MaterialMesh.js +10 -5
  193. package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -0
  194. package/dist/{resources → resource/shader}/Tr2MaterialRes.js +12 -6
  195. package/dist/resource/shader/Tr2MaterialRes.js.map +1 -0
  196. package/dist/resource/shader/Tr2Shader.js +250 -0
  197. package/dist/resource/shader/Tr2Shader.js.map +1 -0
  198. package/dist/{resources → resource/shader}/Tr2ShaderPermutation.js +15 -9
  199. package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -0
  200. package/dist/resource/shader/index.js +17 -0
  201. package/dist/resource/shader/index.js.map +1 -0
  202. package/dist/resource/shader/portable.js +33 -0
  203. package/dist/resource/shader/portable.js.map +1 -0
  204. package/dist/resource/shader/portableValidation.js +461 -0
  205. package/dist/resource/shader/portableValidation.js.map +1 -0
  206. package/dist/resource/shader/reflection/Tr2EffectConstant.js +100 -0
  207. package/dist/resource/shader/reflection/Tr2EffectConstant.js.map +1 -0
  208. package/dist/resource/shader/reflection/Tr2EffectDefine.js +34 -0
  209. package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -0
  210. package/dist/resource/shader/reflection/Tr2EffectDescription.js +113 -0
  211. package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -0
  212. package/dist/resource/shader/reflection/Tr2EffectLibrary.js +141 -0
  213. package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -0
  214. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +107 -0
  215. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -0
  216. package/dist/resource/shader/reflection/Tr2EffectResource.js +90 -0
  217. package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -0
  218. package/dist/resource/shader/reflection/Tr2EffectStageInput.js +235 -0
  219. package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -0
  220. package/dist/resource/shader/reflection/Tr2EffectTechnique.js +71 -0
  221. package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -0
  222. package/dist/resource/shader/reflection/Tr2Pass.js +111 -0
  223. package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -0
  224. package/dist/resource/shader/sampler/Tr2SamplerSetup.js +80 -0
  225. package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -0
  226. package/dist/{texture → resource/texture}/CjsTextureArrayRes.js +84 -7
  227. package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -0
  228. package/dist/{texture/CjsTextureParameterProxy.js → resource/texture/CjsTextureArrayResParameterProxy.js} +57 -11
  229. package/dist/resource/texture/CjsTextureArrayResParameterProxy.js.map +1 -0
  230. package/dist/{resources → resource/texture}/Tr2ImageRes.js +7 -5
  231. package/dist/resource/texture/Tr2ImageRes.js.map +1 -0
  232. package/dist/{resources → resource/texture}/Tr2TextureLodManager.js +5 -3
  233. package/dist/resource/texture/Tr2TextureLodManager.js.map +1 -0
  234. package/dist/{resources → resource/texture}/Tr2TextureLodUpdateRequest.js +3 -3
  235. package/dist/resource/texture/Tr2TextureLodUpdateRequest.js.map +1 -0
  236. package/dist/{resources → resource/texture}/Tr2TexturePackChannel.js +3 -3
  237. package/dist/resource/texture/Tr2TexturePackChannel.js.map +1 -0
  238. package/dist/{resources → resource/texture}/Tr2TexturePipeline.js +8 -6
  239. package/dist/resource/texture/Tr2TexturePipeline.js.map +1 -0
  240. package/dist/{resources → resource/texture}/Tr2TexturePipelineParams.js +3 -3
  241. package/dist/resource/texture/Tr2TexturePipelineParams.js.map +1 -0
  242. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepCompress.js +3 -3
  243. package/dist/resource/texture/Tr2TexturePipelineStepCompress.js.map +1 -0
  244. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepGenerateMips.js +3 -3
  245. package/dist/resource/texture/Tr2TexturePipelineStepGenerateMips.js.map +1 -0
  246. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepLimitSize.js +3 -3
  247. package/dist/resource/texture/Tr2TexturePipelineStepLimitSize.js.map +1 -0
  248. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepLoad.js +3 -3
  249. package/dist/resource/texture/Tr2TexturePipelineStepLoad.js.map +1 -0
  250. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepPack.js +3 -3
  251. package/dist/resource/texture/Tr2TexturePipelineStepPack.js.map +1 -0
  252. package/dist/{resources → resource/texture}/TriTextureRes.js +43 -27
  253. package/dist/resource/texture/TriTextureRes.js.map +1 -0
  254. package/dist/resource/texture/index.js +15 -0
  255. package/dist/resource/texture/index.js.map +1 -0
  256. package/dist/{resources → resource/texture}/texturePipelineBehavior.js +61 -61
  257. package/dist/resource/texture/texturePipelineBehavior.js.map +1 -0
  258. package/dist/worker/CjsResManMainThreadLoader.js +87 -0
  259. package/dist/worker/CjsResManMainThreadLoader.js.map +1 -0
  260. package/dist/worker/CjsResManWorker.js +217 -0
  261. package/dist/worker/CjsResManWorker.js.map +1 -0
  262. package/dist/worker/CjsResManWorkerLoader.js +434 -0
  263. package/dist/worker/CjsResManWorkerLoader.js.map +1 -0
  264. package/dist/worker/protocol.js +12 -0
  265. package/dist/worker/protocol.js.map +1 -0
  266. package/docs/README.md +18 -5
  267. package/docs/architecture.md +40 -17
  268. package/docs/concepts/resource-lifecycle.md +2 -1
  269. package/docs/formats/README.md +4 -0
  270. package/docs/reference/classes/README.md +6 -4
  271. package/docs/reference/classes/audio.md +30 -0
  272. package/docs/reference/classes/core.md +31 -11
  273. package/docs/reference/classes/formats.md +1 -1
  274. package/docs/reference/classes/resources.md +151 -41
  275. package/docs/reference/classes/texture.md +7 -7
  276. package/docs/reference/events.md +1 -1
  277. package/docs/reference/motherlode-cache.md +17 -0
  278. package/docs/reference/queues.md +9 -1
  279. package/docs/reference/workers.md +135 -0
  280. package/docs/roadmap.md +27 -1
  281. package/format-notices/black/NOTICE +1 -1
  282. package/package.json +9 -4
  283. package/dist/CjsResManQueue.js.map +0 -1
  284. package/dist/CjsResource.js.map +0 -1
  285. package/dist/CjsResourceSource.js +0 -68
  286. package/dist/CjsResourceSource.js.map +0 -1
  287. package/dist/resourcePath.js +0 -18
  288. package/dist/resourcePath.js.map +0 -1
  289. package/dist/resourceStates.js +0 -9
  290. package/dist/resourceStates.js.map +0 -1
  291. package/dist/resources/AudioGeometryResData.js.map +0 -1
  292. package/dist/resources/GStateBindingCallbackData.js.map +0 -1
  293. package/dist/resources/MeshDecalData.js.map +0 -1
  294. package/dist/resources/MeshDecalLodData.js.map +0 -1
  295. package/dist/resources/Tr2EffectRes.js +0 -71
  296. package/dist/resources/Tr2EffectRes.js.map +0 -1
  297. package/dist/resources/Tr2GrannyIntersectionResult.js.map +0 -1
  298. package/dist/resources/Tr2GrannyStateRes.js.map +0 -1
  299. package/dist/resources/Tr2ImageRes.js.map +0 -1
  300. package/dist/resources/Tr2LightProfileRes.js.map +0 -1
  301. package/dist/resources/Tr2MaterialArea.js.map +0 -1
  302. package/dist/resources/Tr2MaterialMesh.js.map +0 -1
  303. package/dist/resources/Tr2MaterialRes.js.map +0 -1
  304. package/dist/resources/Tr2ShaderPermutation.js.map +0 -1
  305. package/dist/resources/Tr2TextureLodManager.js.map +0 -1
  306. package/dist/resources/Tr2TextureLodUpdateRequest.js.map +0 -1
  307. package/dist/resources/Tr2TexturePackChannel.js.map +0 -1
  308. package/dist/resources/Tr2TexturePipeline.js.map +0 -1
  309. package/dist/resources/Tr2TexturePipelineParams.js.map +0 -1
  310. package/dist/resources/Tr2TexturePipelineStepCompress.js.map +0 -1
  311. package/dist/resources/Tr2TexturePipelineStepGenerateMips.js.map +0 -1
  312. package/dist/resources/Tr2TexturePipelineStepLimitSize.js.map +0 -1
  313. package/dist/resources/Tr2TexturePipelineStepLoad.js.map +0 -1
  314. package/dist/resources/Tr2TexturePipelineStepPack.js.map +0 -1
  315. package/dist/resources/TriGeometryRes.js +0 -239
  316. package/dist/resources/TriGeometryRes.js.map +0 -1
  317. package/dist/resources/TriGeometryResAreaData.js.map +0 -1
  318. package/dist/resources/TriGeometryResJointData.js.map +0 -1
  319. package/dist/resources/TriGeometryResLodData.js.map +0 -1
  320. package/dist/resources/TriGeometryResMeshData.js.map +0 -1
  321. package/dist/resources/TriGeometryResSkeletonData.js.map +0 -1
  322. package/dist/resources/TriGrannyRes.js.map +0 -1
  323. package/dist/resources/TriJointBinding.js.map +0 -1
  324. package/dist/resources/TriMorphTargetGeometryConstants.js.map +0 -1
  325. package/dist/resources/TriRtGeometryConstants.js.map +0 -1
  326. package/dist/resources/TriTextureRes.js.map +0 -1
  327. package/dist/resources/enums.js.map +0 -1
  328. package/dist/resources/resourceBoundary.js +0 -47
  329. package/dist/resources/resourceBoundary.js.map +0 -1
  330. package/dist/resources/texturePipelineBehavior.js.map +0 -1
  331. package/dist/texture/CjsTextureArrayRes.js.map +0 -1
  332. package/dist/texture/CjsTextureParameterProxy.js.map +0 -1
@@ -1,6 +1,6 @@
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';
1
+ import { validateRgbaPayload } from '../../format/payloadContract.js';
2
+ import { PixelFormat as PixelFormat$1 } from '@carbonenginejs/runtime-utils/graphics';
3
+ import { PixelFormat } from '@carbonenginejs/runtime-utils/render-context';
4
4
 
5
5
  // Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipeline.cpp
6
6
  // Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLoad.cpp
@@ -19,17 +19,17 @@ const PACK_FORMATS = new Set([PixelFormat.PIXEL_FORMAT_R8_UNORM, PixelFormat.PIX
19
19
  * @param {object[]} steps Pipeline steps.
20
20
  * @returns {string[]} Sorted unique resource paths.
21
21
  */
22
- function GetTexturePipelineDependencies(steps) {
22
+ function getTexturePipelineDependencies(steps) {
23
23
  const dependencies = new Set();
24
- for (const step of AssertSteps(steps)) {
25
- const name = StepName(step);
24
+ for (const step of assertSteps(steps)) {
25
+ const name = stepName(step);
26
26
  if (name === STEP_LOAD) {
27
- AddDependency(dependencies, step.path);
27
+ addDependency(dependencies, step.path);
28
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);
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
33
  }
34
34
  }
35
35
  return [...dependencies].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
@@ -43,53 +43,53 @@ function GetTexturePipelineDependencies(steps) {
43
43
  * @param {object|null} options Input resolution options.
44
44
  * @returns {Promise<object>} Canonical RGBA payload.
45
45
  */
46
- async function ExecuteTexturePipeline(steps, params, options = null) {
47
- const list = AssertSteps(steps);
46
+ async function executeTexturePipeline(steps, params, options = null) {
47
+ const list = assertSteps(steps);
48
48
  if (!list.length) {
49
- throw PipelineError("CJS_TEXTURE_PIPELINE_NO_STEPS", "Tr2TexturePipeline has no steps.");
49
+ throw pipelineError("CJS_TEXTURE_PIPELINE_NO_STEPS", "Tr2TexturePipeline has no steps.");
50
50
  }
51
51
  const limits = {
52
- maxWidth: AssertLimit(params?.maxWidth, "maxWidth"),
53
- maxHeight: AssertLimit(params?.maxHeight, "maxHeight")
52
+ maxWidth: assertLimit(params?.maxWidth, "maxWidth"),
53
+ maxHeight: assertLimit(params?.maxHeight, "maxHeight")
54
54
  };
55
- const settings = NormalizeOptions(options);
55
+ const settings = normalizeOptions(options);
56
56
  const inputs = new Map();
57
- for (const path of GetTexturePipelineDependencies(list)) {
58
- inputs.set(path, await ResolveInput(path, settings));
57
+ for (const path of getTexturePipelineDependencies(list)) {
58
+ inputs.set(path, await resolveInput(path, settings));
59
59
  }
60
60
  let bitmap = null;
61
61
  for (const step of list) {
62
- const name = StepName(step);
62
+ const name = stepName(step);
63
63
  if (name === STEP_LOAD) {
64
- bitmap = CloneBitmap(RequireInput(inputs, step.path));
64
+ bitmap = cloneBitmap(requireInput(inputs, step.path));
65
65
  } else if (name === STEP_LIMIT_SIZE) {
66
- bitmap = LimitBitmap(RequireBitmap(bitmap), CombineLimits(step, limits));
66
+ bitmap = limitBitmap(requireBitmap(bitmap), combineLimits(step, limits));
67
67
  } else if (name === STEP_COMPRESS) {
68
68
  // Carbon's current implementation validates the bitmap and otherwise
69
69
  // performs no compression work.
70
- RequireBitmap(bitmap);
70
+ requireBitmap(bitmap);
71
71
  } else if (name === STEP_PACK) {
72
- bitmap = PackBitmap(step, inputs);
72
+ bitmap = packBitmap(step, inputs);
73
73
  } else {
74
- throw PipelineError("CJS_TEXTURE_PIPELINE_STEP_UNSUPPORTED", `Unsupported texture pipeline step: ${name || "unknown"}.`);
74
+ throw pipelineError("CJS_TEXTURE_PIPELINE_STEP_UNSUPPORTED", `Unsupported texture pipeline step: ${name || "unknown"}.`);
75
75
  }
76
76
  }
77
- bitmap = LimitBitmap(RequireBitmap(bitmap), limits);
78
- return ToPayload(bitmap);
77
+ bitmap = limitBitmap(requireBitmap(bitmap), limits);
78
+ return toPayload(bitmap);
79
79
  }
80
- function AssertSteps(steps) {
80
+ function assertSteps(steps) {
81
81
  if (!Array.isArray(steps)) {
82
82
  throw new TypeError("Tr2TexturePipeline.steps must be an array.");
83
83
  }
84
84
  return steps;
85
85
  }
86
- function AssertLimit(value, name) {
86
+ function assertLimit(value, name) {
87
87
  if (!Number.isSafeInteger(value) || value < 0) {
88
88
  throw new TypeError(`Tr2TexturePipeline ${name} must be a non-negative safe integer.`);
89
89
  }
90
90
  return value;
91
91
  }
92
- function NormalizeOptions(options) {
92
+ function normalizeOptions(options) {
93
93
  if (options === null || options === undefined) {
94
94
  return {};
95
95
  }
@@ -104,7 +104,7 @@ function NormalizeOptions(options) {
104
104
  }
105
105
  return options;
106
106
  }
107
- async function ResolveInput(path, options) {
107
+ async function resolveInput(path, options) {
108
108
  let value;
109
109
  if (options.inputs instanceof Map) {
110
110
  value = options.inputs.get(path);
@@ -122,16 +122,16 @@ async function ResolveInput(path, options) {
122
122
  });
123
123
  }
124
124
  if (value === undefined) {
125
- throw PipelineError("CJS_TEXTURE_PIPELINE_INPUT_MISSING", `No texture pipeline input was provided for ${path}.`);
125
+ throw pipelineError("CJS_TEXTURE_PIPELINE_INPUT_MISSING", `No texture pipeline input was provided for ${path}.`);
126
126
  }
127
127
  const payload = typeof value?.GetPayload === "function" ? value.GetPayload() : value;
128
128
  validateRgbaPayload(payload);
129
129
  if (payload.pixelFormat !== PixelFormat$1.RGBA8_UNORM) {
130
- throw PipelineError("CJS_TEXTURE_PIPELINE_FORMAT_UNSUPPORTED", `Texture pipeline input ${path} must use rgba8unorm.`);
130
+ throw pipelineError("CJS_TEXTURE_PIPELINE_FORMAT_UNSUPPORTED", `Texture pipeline input ${path} must use rgba8unorm.`);
131
131
  }
132
- return FromPayload(payload);
132
+ return fromPayload(payload);
133
133
  }
134
- function FromPayload(payload) {
134
+ function fromPayload(payload) {
135
135
  const data = new Uint8Array(payload.width * payload.height * 4);
136
136
  for (let y = 0; y < payload.height; y++) {
137
137
  const sourceOffset = y * payload.strideBytes;
@@ -148,7 +148,7 @@ function FromPayload(payload) {
148
148
  metadata: payload.metadata || null
149
149
  };
150
150
  }
151
- function ToPayload(bitmap) {
151
+ function toPayload(bitmap) {
152
152
  return {
153
153
  payloadType: "rgba",
154
154
  sourceFormat: bitmap.sourceFormat || "texture-pipeline",
@@ -165,7 +165,7 @@ function ToPayload(bitmap) {
165
165
  } : {})
166
166
  };
167
167
  }
168
- function CloneBitmap(bitmap) {
168
+ function cloneBitmap(bitmap) {
169
169
  return {
170
170
  ...bitmap,
171
171
  data: new Uint8Array(bitmap.data),
@@ -174,25 +174,25 @@ function CloneBitmap(bitmap) {
174
174
  } : bitmap.metadata
175
175
  };
176
176
  }
177
- function CombineLimits(step, params) {
177
+ function combineLimits(step, params) {
178
178
  return {
179
- maxWidth: TightestLimit(AssertLimit(step.maxWidth ?? 0, "step.maxWidth"), params.maxWidth),
180
- maxHeight: TightestLimit(AssertLimit(step.maxHeight ?? 0, "step.maxHeight"), params.maxHeight)
179
+ maxWidth: tightestLimit(assertLimit(step.maxWidth ?? 0, "step.maxWidth"), params.maxWidth),
180
+ maxHeight: tightestLimit(assertLimit(step.maxHeight ?? 0, "step.maxHeight"), params.maxHeight)
181
181
  };
182
182
  }
183
- function TightestLimit(first, second) {
183
+ function tightestLimit(first, second) {
184
184
  if (!first) return second;
185
185
  if (!second) return first;
186
186
  return Math.min(first, second);
187
187
  }
188
- function LimitBitmap(bitmap, limits) {
188
+ function limitBitmap(bitmap, limits) {
189
189
  let result = bitmap;
190
190
  while (limits.maxWidth && result.width > limits.maxWidth || limits.maxHeight && result.height > limits.maxHeight) {
191
- result = Downsample2x2(result);
191
+ result = downsample2x2(result);
192
192
  }
193
193
  return result;
194
194
  }
195
- function Downsample2x2(bitmap) {
195
+ function downsample2x2(bitmap) {
196
196
  const width = Math.max(1, Math.floor(bitmap.width / 2));
197
197
  const height = Math.max(1, Math.floor(bitmap.height / 2));
198
198
  const data = new Uint8Array(width * height * 4);
@@ -224,28 +224,28 @@ function Downsample2x2(bitmap) {
224
224
  data
225
225
  };
226
226
  }
227
- function PackBitmap(step, inputs) {
227
+ function packBitmap(step, inputs) {
228
228
  // The generated schema records the enum's zero value, while Carbon's
229
229
  // constructor initializes this step to B8G8R8A8_UNORM.
230
230
  const format = step.format === PixelFormat.PIXEL_FORMAT_UNKNOWN ? PixelFormat.PIXEL_FORMAT_B8G8R8A8_UNORM : step.format;
231
231
  if (!PACK_FORMATS.has(format)) {
232
- throw PipelineError("CJS_TEXTURE_PIPELINE_FORMAT_UNSUPPORTED", `Unsupported Carbon pack pixel format: ${String(format)}.`);
232
+ throw pipelineError("CJS_TEXTURE_PIPELINE_FORMAT_UNSUPPORTED", `Unsupported Carbon pack pixel format: ${String(format)}.`);
233
233
  }
234
234
  const descriptors = [step.r, step.g, step.b, step.a];
235
- const sources = descriptors.map(channel => channel?.path ? RequireInput(inputs, channel.path) : null);
235
+ const sources = descriptors.map(channel => channel?.path ? requireInput(inputs, channel.path) : null);
236
236
  const first = sources.find(Boolean);
237
237
  const width = first?.width || 4;
238
238
  const height = first?.height || 4;
239
239
  for (const source of sources) {
240
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.");
241
+ throw pipelineError("CJS_TEXTURE_PIPELINE_SIZE_MISMATCH", "Texture pipeline pack inputs must have identical dimensions.");
242
242
  }
243
243
  }
244
244
  const data = new Uint8Array(width * height * 4);
245
245
  const isR8 = format === PixelFormat.PIXEL_FORMAT_R8_UNORM;
246
246
  const isX8 = format === PixelFormat.PIXEL_FORMAT_B8G8R8X8_UNORM;
247
247
  for (let pixel = 0; pixel < width * height; pixel++) {
248
- const values = descriptors.map((channel, index) => ReadPackChannel(sources[index], channel, pixel));
248
+ const values = descriptors.map((channel, index) => readPackChannel(sources[index], channel, pixel));
249
249
  const target = pixel * 4;
250
250
  if (isR8) {
251
251
  data[target] = values[0];
@@ -269,11 +269,11 @@ function PackBitmap(step, inputs) {
269
269
  }
270
270
  };
271
271
  }
272
- function ReadPackChannel(source, descriptor, pixel) {
272
+ function readPackChannel(source, descriptor, pixel) {
273
273
  if (!source) {
274
- return AssertByte(descriptor?.fill ?? 0, "fill");
274
+ return assertByte(descriptor?.fill ?? 0, "fill");
275
275
  }
276
- const channel = AssertByte(descriptor?.channel ?? 0, "channel");
276
+ const channel = assertByte(descriptor?.channel ?? 0, "channel");
277
277
  if (channel > 3) {
278
278
  throw new RangeError("Tr2TexturePackChannel.channel must be between 0 and 3.");
279
279
  }
@@ -282,39 +282,39 @@ function ReadPackChannel(source, descriptor, pixel) {
282
282
  const rgbaChannel = channel === 0 ? 2 : channel === 2 ? 0 : channel;
283
283
  return source.data[pixel * 4 + rgbaChannel];
284
284
  }
285
- function AssertByte(value, name) {
285
+ function assertByte(value, name) {
286
286
  if (!Number.isInteger(value) || value < 0 || value > 255) {
287
287
  throw new RangeError(`Tr2TexturePackChannel.${name} must be an integer from 0 to 255.`);
288
288
  }
289
289
  return value;
290
290
  }
291
- function RequireInput(inputs, path) {
291
+ function requireInput(inputs, path) {
292
292
  const value = inputs.get(String(path || ""));
293
293
  if (!value) {
294
- throw PipelineError("CJS_TEXTURE_PIPELINE_INPUT_MISSING", `Texture pipeline input is unavailable: ${String(path || "")}.`);
294
+ throw pipelineError("CJS_TEXTURE_PIPELINE_INPUT_MISSING", `Texture pipeline input is unavailable: ${String(path || "")}.`);
295
295
  }
296
296
  return value;
297
297
  }
298
- function RequireBitmap(bitmap) {
298
+ function requireBitmap(bitmap) {
299
299
  if (!bitmap) {
300
- throw PipelineError("CJS_TEXTURE_PIPELINE_BITMAP_INVALID", "Texture pipeline step requires a valid input bitmap.");
300
+ throw pipelineError("CJS_TEXTURE_PIPELINE_BITMAP_INVALID", "Texture pipeline step requires a valid input bitmap.");
301
301
  }
302
302
  return bitmap;
303
303
  }
304
- function AddDependency(dependencies, value) {
304
+ function addDependency(dependencies, value) {
305
305
  const path = String(value || "");
306
306
  if (path) {
307
307
  dependencies.add(path);
308
308
  }
309
309
  }
310
- function StepName(step) {
310
+ function stepName(step) {
311
311
  return step?.constructor?.name || step?.className || "";
312
312
  }
313
- function PipelineError(code, message) {
313
+ function pipelineError(code, message) {
314
314
  const error = new Error(message);
315
315
  error.code = code;
316
316
  return error;
317
317
  }
318
318
 
319
- export { ExecuteTexturePipeline, GetTexturePipelineDependencies };
319
+ export { executeTexturePipeline, getTexturePipelineDependencies };
320
320
  //# sourceMappingURL=texturePipelineBehavior.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"texturePipelineBehavior.js","sources":["../../../../src/resource/texture/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\";\nimport { PixelFormat as PayloadPixelFormat } from \"@carbonenginejs/runtime-utils/graphics\";\r\nimport { PixelFormat as CarbonPixelFormat } from \"@carbonenginejs/runtime-utils/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,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C5C,IAAI,CAACiC,KAAK,EACV;AACE,IAAA,MAAMtB,aAAa,CACjB,oCAAoC,EACpC,CAAA,uCAAA,EAA0C8E,MAAM,CAACzF,IAAI,IAAI,EAAE,CAAC,CAAA,CAAA,CAC9D,CAAC;AACH,EAAA;AACA,EAAA,OAAOiC,KAAK;AACd;AAEA,SAASP,aAAaA,CAACJ,MAAM,EAC7B;EACE,IAAI,CAACA,MAAM,EACX;AACE,IAAA,MAAMX,aAAa,CACjB,qCAAqC,EACrC,sDACF,CAAC;AACH,EAAA;AACA,EAAA,OAAOW,MAAM;AACf;AAEA,SAASvB,aAAaA,CAACL,YAAY,EAAEuC,KAAK,EAC1C;AACE,EAAA,MAAMjC,IAAI,GAAGyF,MAAM,CAACxD,KAAK,IAAI,EAAE,CAAC;AAChC,EAAA,IAAIjC,IAAI,EACR;AACEN,IAAAA,YAAY,CAACkH,GAAG,CAAC5G,IAAI,CAAC;AACxB,EAAA;AACF;AAEA,SAASF,QAAQA,CAACH,IAAI,EACtB;EACE,OAAOA,IAAI,EAAEkH,WAAW,EAAEhH,IAAI,IAAIF,IAAI,EAAEmH,SAAS,IAAI,EAAE;AACzD;AAEA,SAASnG,aAAaA,CAACoG,IAAI,EAAEC,OAAO,EACpC;AACE,EAAA,MAAMC,KAAK,GAAG,IAAIC,KAAK,CAACF,OAAO,CAAC;EAChCC,KAAK,CAACF,IAAI,GAAGA,IAAI;AACjB,EAAA,OAAOE,KAAK;AACd;;;;"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Direct execution strategy that reads through a structural source and invokes registered format facades on the caller thread.
3
+ *
4
+ * It is used when no browser worker is selected or when a source or format
5
+ * does not declare a worker-safe operation.
6
+ */
7
+ class CjsResManMainThreadLoader {
8
+ /**
9
+ * Read through an injected resource source.
10
+ *
11
+ * @param {object|Function} source Source exposing `Read(path, options)`.
12
+ * @param {string} path Normalized resource path.
13
+ * @param {object} [options={}] Source read options.
14
+ * @returns {*} Source result or promise.
15
+ */
16
+ Read(source, path, options = {}) {
17
+ assertResourceSource(source);
18
+ return source.Read(path, options);
19
+ }
20
+
21
+ /**
22
+ * Main-thread loaders never claim worker execution.
23
+ *
24
+ * @returns {false}
25
+ */
26
+ CanReadFormat() {
27
+ return false;
28
+ }
29
+
30
+ /**
31
+ * Execute one normalized format read on the current thread.
32
+ *
33
+ * @param {object} descriptor Registered format descriptor.
34
+ * @param {*} input Reader input.
35
+ * @param {object} [formatOptions={}] Normalized format options.
36
+ * @returns {Promise<*>} Format result.
37
+ */
38
+ ReadFormat(descriptor, input, formatOptions = {}) {
39
+ return readFormatOnCurrentThread(descriptor, input, formatOptions);
40
+ }
41
+
42
+ /**
43
+ * Main-thread execution owns no pending worker requests.
44
+ *
45
+ * @returns {0}
46
+ */
47
+ GetPendingCount() {
48
+ return 0;
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Invoke a format facade without crossing a worker boundary.
54
+ *
55
+ * @param {object} descriptor Registered format descriptor.
56
+ * @param {*} input Reader input.
57
+ * @param {object} formatOptions Normalized format options.
58
+ * @returns {Promise<*>} Reader result.
59
+ */
60
+ function readFormatOnCurrentThread(descriptor, input, formatOptions = {}) {
61
+ const Format = descriptor?.Format;
62
+ if (typeof Format !== "function") {
63
+ throw new TypeError("Resource format descriptor requires a Format class.");
64
+ }
65
+ if (typeof Format.readAsync === "function") {
66
+ return Format.readAsync(input, formatOptions);
67
+ }
68
+ if (typeof Format.read === "function") {
69
+ return Format.read(input, formatOptions);
70
+ }
71
+ const reader = new Format(formatOptions);
72
+ if (typeof reader.ReadAsync === "function") {
73
+ return reader.ReadAsync(input, formatOptions);
74
+ }
75
+ if (typeof reader.Read === "function") {
76
+ return reader.Read(input, formatOptions);
77
+ }
78
+ throw new TypeError(`${Format.name} does not expose a read operation.`);
79
+ }
80
+ function assertResourceSource(source) {
81
+ if (!source || typeof source !== "object" && typeof source !== "function" || typeof source.Read !== "function") {
82
+ throw new TypeError("Resource source must provide Read(path, options).");
83
+ }
84
+ }
85
+
86
+ export { CjsResManMainThreadLoader };
87
+ //# sourceMappingURL=CjsResManMainThreadLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CjsResManMainThreadLoader.js","sources":["../../../src/worker/CjsResManMainThreadLoader.js"],"sourcesContent":["/**\n * Direct execution strategy that reads through a structural source and invokes registered format facades on the caller thread.\n *\n * It is used when no browser worker is selected or when a source or format\n * does not declare a worker-safe operation.\n */\nexport class CjsResManMainThreadLoader\n{\n /**\n * Read through an injected resource source.\n *\n * @param {object|Function} source Source exposing `Read(path, options)`.\n * @param {string} path Normalized resource path.\n * @param {object} [options={}] Source read options.\n * @returns {*} Source result or promise.\n */\n Read(source, path, options = {})\n {\n assertResourceSource(source);\n return source.Read(path, options);\n }\n\n /**\n * Main-thread loaders never claim worker execution.\n *\n * @returns {false}\n */\n CanReadFormat()\n {\n return false;\n }\n\n /**\n * Execute one normalized format read on the current thread.\n *\n * @param {object} descriptor Registered format descriptor.\n * @param {*} input Reader input.\n * @param {object} [formatOptions={}] Normalized format options.\n * @returns {Promise<*>} Format result.\n */\n ReadFormat(descriptor, input, formatOptions = {})\n {\n return readFormatOnCurrentThread(descriptor, input, formatOptions);\n }\n\n /**\n * Main-thread execution owns no pending worker requests.\n *\n * @returns {0}\n */\n GetPendingCount()\n {\n return 0;\n }\n}\n\n/**\n * Invoke a format facade without crossing a worker boundary.\n *\n * @param {object} descriptor Registered format descriptor.\n * @param {*} input Reader input.\n * @param {object} formatOptions Normalized format options.\n * @returns {Promise<*>} Reader result.\n */\nfunction readFormatOnCurrentThread(\n descriptor,\n input,\n formatOptions = {}\n)\n{\n const Format = descriptor?.Format;\n\n if (typeof Format !== \"function\")\n {\n throw new TypeError(\"Resource format descriptor requires a Format class.\");\n }\n if (typeof Format.readAsync === \"function\")\n {\n return Format.readAsync(input, formatOptions);\n }\n if (typeof Format.read === \"function\")\n {\n return Format.read(input, formatOptions);\n }\n\n const reader = new Format(formatOptions);\n\n if (typeof reader.ReadAsync === \"function\")\n {\n return reader.ReadAsync(input, formatOptions);\n }\n if (typeof reader.Read === \"function\")\n {\n return reader.Read(input, formatOptions);\n }\n\n throw new TypeError(`${Format.name} does not expose a read operation.`);\n}\n\nfunction assertResourceSource(source)\n{\n if (!source || (typeof source !== \"object\" && typeof source !== \"function\")\n || typeof source.Read !== \"function\")\n {\n throw new TypeError(\"Resource source must provide Read(path, options).\");\n }\n}\n"],"names":["CjsResManMainThreadLoader","Read","source","path","options","assertResourceSource","CanReadFormat","ReadFormat","descriptor","input","formatOptions","readFormatOnCurrentThread","GetPendingCount","Format","TypeError","readAsync","read","reader","ReadAsync","name"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,yBAAyB,CACtC;AACE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,IAAIA,CAACC,MAAM,EAAEC,IAAI,EAAEC,OAAO,GAAG,EAAE,EAC/B;IACEC,oBAAoB,CAACH,MAAM,CAAC;AAC5B,IAAA,OAAOA,MAAM,CAACD,IAAI,CAACE,IAAI,EAAEC,OAAO,CAAC;AACnC,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACEE,EAAAA,aAAaA,GACb;AACE,IAAA,OAAO,KAAK;AACd,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,UAAUA,CAACC,UAAU,EAAEC,KAAK,EAAEC,aAAa,GAAG,EAAE,EAChD;AACE,IAAA,OAAOC,yBAAyB,CAACH,UAAU,EAAEC,KAAK,EAAEC,aAAa,CAAC;AACpE,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACEE,EAAAA,eAAeA,GACf;AACE,IAAA,OAAO,CAAC;AACV,EAAA;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASD,yBAAyBA,CAChCH,UAAU,EACVC,KAAK,EACLC,aAAa,GAAG,EAAE,EAEpB;AACE,EAAA,MAAMG,MAAM,GAAGL,UAAU,EAAEK,MAAM;AAEjC,EAAA,IAAI,OAAOA,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