@carbonenginejs/runtime-resource 0.9.2 → 0.11.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 (544) 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 +717 -228
  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 +89 -0
  12. package/dist/format/CjsBlueReader.js.map +1 -1
  13. package/dist/format/CjsFormat.js +42 -16
  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 +2 -0
  18. package/dist/format/CjsResourceProbe.js.map +1 -1
  19. package/dist/format/effect/effectPermutationGraph.js +257 -0
  20. package/dist/format/effect/effectPermutationGraph.js.map +1 -0
  21. package/dist/format/effect/effectReflectionPackage.js +636 -0
  22. package/dist/format/effect/effectReflectionPackage.js.map +1 -0
  23. package/dist/format/effect/sha256.js +114 -0
  24. package/dist/format/effect/sha256.js.map +1 -0
  25. package/dist/format/payloadContract.js +20 -0
  26. package/dist/format/payloadContract.js.map +1 -1
  27. package/dist/formats/black/CjsBlackFormat.js +15 -1
  28. package/dist/formats/black/CjsBlackFormat.js.map +1 -1
  29. package/dist/formats/black/core/CjsBlackBinaryReader.js +103 -0
  30. package/dist/formats/black/core/CjsBlackBinaryReader.js.map +1 -1
  31. package/dist/formats/black/core/CjsBlackPropertyReaders.js +61 -0
  32. package/dist/formats/black/core/CjsBlackPropertyReaders.js.map +1 -1
  33. package/dist/formats/black/core/CjsBlackReader.js +125 -0
  34. package/dist/formats/black/core/CjsBlackReader.js.map +1 -1
  35. package/dist/formats/black/core/CjsBlackSchemaRegistry.js +103 -0
  36. package/dist/formats/black/core/CjsBlackSchemaRegistry.js.map +1 -1
  37. package/dist/formats/black/core/helpers.js +17 -0
  38. package/dist/formats/black/core/helpers.js.map +1 -1
  39. package/dist/formats/bnk/CjsBnkFormat.js +8 -0
  40. package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
  41. package/dist/formats/bnk/core/helpers.js +20 -0
  42. package/dist/formats/bnk/core/helpers.js.map +1 -1
  43. package/dist/formats/bnk/core/musicNodes.js +40 -3
  44. package/dist/formats/bnk/core/musicNodes.js.map +1 -1
  45. package/dist/formats/bnk/core/soundbanksInfo.js +2 -0
  46. package/dist/formats/bnk/core/soundbanksInfo.js.map +1 -1
  47. package/dist/formats/cmf/core/binary.js +71 -0
  48. package/dist/formats/cmf/core/binary.js.map +1 -1
  49. package/dist/formats/cmf/core/buffers.js +4 -0
  50. package/dist/formats/cmf/core/buffers.js.map +1 -1
  51. package/dist/formats/cmf/core/helpers.js +31 -0
  52. package/dist/formats/cmf/core/helpers.js.map +1 -1
  53. package/dist/formats/cmf/core/schema.js +10 -0
  54. package/dist/formats/cmf/core/schema.js.map +1 -1
  55. package/dist/formats/cmf/core/shared.js +9 -0
  56. package/dist/formats/cmf/core/shared.js.map +1 -1
  57. package/dist/formats/cmf/core/writer.js +54 -0
  58. package/dist/formats/cmf/core/writer.js.map +1 -1
  59. package/dist/formats/dds/core/bc6h.js +10 -0
  60. package/dist/formats/dds/core/bc6h.js.map +1 -1
  61. package/dist/formats/dds/core/bc7.js +16 -0
  62. package/dist/formats/dds/core/bc7.js.map +1 -1
  63. package/dist/formats/dds/core/helpers.js +47 -0
  64. package/dist/formats/dds/core/helpers.js.map +1 -1
  65. package/dist/formats/dxbc/CjsDxbcFormat.js +142 -0
  66. package/dist/formats/dxbc/CjsDxbcFormat.js.map +1 -0
  67. package/dist/formats/dxbc/core/DxbcReader.js +266 -0
  68. package/dist/formats/dxbc/core/DxbcReader.js.map +1 -0
  69. package/dist/formats/dxbc/core/container.js +169 -0
  70. package/dist/formats/dxbc/core/container.js.map +1 -0
  71. package/dist/formats/dxbc/core/decoder.js +789 -0
  72. package/dist/formats/dxbc/core/decoder.js.map +1 -0
  73. package/dist/formats/dxbc/core/errors.js +19 -0
  74. package/dist/formats/dxbc/core/errors.js.map +1 -0
  75. package/dist/formats/dxbc/core/helpers.js +220 -0
  76. package/dist/formats/dxbc/core/helpers.js.map +1 -0
  77. package/dist/formats/dxbc/core/opcodes.js +45 -0
  78. package/dist/formats/dxbc/core/opcodes.js.map +1 -0
  79. package/dist/formats/dxbc/core/program.js +91 -0
  80. package/dist/formats/dxbc/core/program.js.map +1 -0
  81. package/dist/formats/dxbc/core/signature.js +172 -0
  82. package/dist/formats/dxbc/core/signature.js.map +1 -0
  83. package/dist/formats/dxbc/index.js +2 -0
  84. package/dist/formats/dxbc/index.js.map +1 -0
  85. package/dist/formats/fbx/core/helpers.js +21 -0
  86. package/dist/formats/fbx/core/helpers.js.map +1 -1
  87. package/dist/formats/flac/CjsFlacFormat.js +49 -0
  88. package/dist/formats/flac/CjsFlacFormat.js.map +1 -1
  89. package/dist/formats/flac/core/helpers.js +20 -0
  90. package/dist/formats/flac/core/helpers.js.map +1 -1
  91. package/dist/formats/gif/CjsGifFormat.js +49 -0
  92. package/dist/formats/gif/CjsGifFormat.js.map +1 -1
  93. package/dist/formats/gif/core/helpers.js +20 -0
  94. package/dist/formats/gif/core/helpers.js.map +1 -1
  95. package/dist/formats/gltf/core/helpers.js +15 -0
  96. package/dist/formats/gltf/core/helpers.js.map +1 -1
  97. package/dist/formats/gltf/core/parser.js +13 -0
  98. package/dist/formats/gltf/core/parser.js.map +1 -1
  99. package/dist/formats/gltf/core/targets.js +10 -0
  100. package/dist/formats/gltf/core/targets.js.map +1 -1
  101. package/dist/formats/gr2/core/bitknit2.js +2 -0
  102. package/dist/formats/gr2/core/bitknit2.js.map +1 -1
  103. package/dist/formats/gr2/core/helpers.js +20 -0
  104. package/dist/formats/gr2/core/helpers.js.map +1 -1
  105. package/dist/formats/gr2/core/targets.js +10 -0
  106. package/dist/formats/gr2/core/targets.js.map +1 -1
  107. package/dist/formats/hlsl/CjsHlslFormat.js +254 -0
  108. package/dist/formats/hlsl/CjsHlslFormat.js.map +1 -0
  109. package/dist/formats/hlsl/core/HlslBinaryUtils.js +15 -0
  110. package/dist/formats/hlsl/core/HlslBinaryUtils.js.map +1 -0
  111. package/dist/formats/hlsl/core/HlslEffectReadError.js +19 -0
  112. package/dist/formats/hlsl/core/HlslEffectReadError.js.map +1 -0
  113. package/dist/formats/hlsl/core/HlslEffectStateManager.js +130 -0
  114. package/dist/formats/hlsl/core/HlslEffectStateManager.js.map +1 -0
  115. package/dist/formats/hlsl/core/HlslReader.js +266 -0
  116. package/dist/formats/hlsl/core/HlslReader.js.map +1 -0
  117. package/dist/formats/hlsl/core/HlslRenderStateSetup.js +37 -0
  118. package/dist/formats/hlsl/core/HlslRenderStateSetup.js.map +1 -0
  119. package/dist/formats/hlsl/core/HlslResourceSetDescription.js +94 -0
  120. package/dist/formats/hlsl/core/HlslResourceSetDescription.js.map +1 -0
  121. package/dist/formats/hlsl/core/HlslShaderBytecode.js +44 -0
  122. package/dist/formats/hlsl/core/HlslShaderBytecode.js.map +1 -0
  123. package/dist/formats/hlsl/core/analysis.js +51 -0
  124. package/dist/formats/hlsl/core/analysis.js.map +1 -0
  125. package/dist/formats/hlsl/core/helpers.js +270 -0
  126. package/dist/formats/hlsl/core/helpers.js.map +1 -0
  127. package/dist/formats/hlsl/core/json.js +284 -0
  128. package/dist/formats/hlsl/core/json.js.map +1 -0
  129. package/dist/formats/hlsl/core/metadata.js +327 -0
  130. package/dist/formats/hlsl/core/metadata.js.map +1 -0
  131. package/dist/formats/hlsl/core/portableReflection.js +848 -0
  132. package/dist/formats/hlsl/core/portableReflection.js.map +1 -0
  133. package/dist/formats/hlsl/core/render-states.js +280 -0
  134. package/dist/formats/hlsl/core/render-states.js.map +1 -0
  135. package/dist/formats/hlsl/core/tr2/HlslRenderContextEnum.js +43 -0
  136. package/dist/formats/hlsl/core/tr2/HlslRenderContextEnum.js.map +1 -0
  137. package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +294 -0
  138. package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -0
  139. package/dist/formats/hlsl/core/tr2/resources/HlslShaderPermutation.js +33 -0
  140. package/dist/formats/hlsl/core/tr2/resources/HlslShaderPermutation.js.map +1 -0
  141. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js +416 -0
  142. package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js.map +1 -0
  143. package/dist/formats/hlsl/core/tr2/shader/HlslEffectConstant.js +40 -0
  144. package/dist/formats/hlsl/core/tr2/shader/HlslEffectConstant.js.map +1 -0
  145. package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js +742 -0
  146. package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js.map +1 -0
  147. package/dist/formats/hlsl/core/tr2/shader/HlslEffectLibrary.js +52 -0
  148. package/dist/formats/hlsl/core/tr2/shader/HlslEffectLibrary.js.map +1 -0
  149. package/dist/formats/hlsl/core/tr2/shader/HlslEffectParameterAnnotation.js +38 -0
  150. package/dist/formats/hlsl/core/tr2/shader/HlslEffectParameterAnnotation.js.map +1 -0
  151. package/dist/formats/hlsl/core/tr2/shader/HlslEffectResource.js +50 -0
  152. package/dist/formats/hlsl/core/tr2/shader/HlslEffectResource.js.map +1 -0
  153. package/dist/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js +86 -0
  154. package/dist/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js.map +1 -0
  155. package/dist/formats/hlsl/core/tr2/shader/HlslEffectTechnique.js +31 -0
  156. package/dist/formats/hlsl/core/tr2/shader/HlslEffectTechnique.js.map +1 -0
  157. package/dist/formats/hlsl/core/tr2/shader/HlslPass.js +42 -0
  158. package/dist/formats/hlsl/core/tr2/shader/HlslPass.js.map +1 -0
  159. package/dist/formats/hlsl/core/tr2/shader/HlslSamplerDescription.js +55 -0
  160. package/dist/formats/hlsl/core/tr2/shader/HlslSamplerDescription.js.map +1 -0
  161. package/dist/formats/hlsl/core/tr2/shader/HlslSamplerSetup.js +29 -0
  162. package/dist/formats/hlsl/core/tr2/shader/HlslSamplerSetup.js.map +1 -0
  163. package/dist/formats/hlsl/core/tr2/shader/HlslShader.js +220 -0
  164. package/dist/formats/hlsl/core/tr2/shader/HlslShader.js.map +1 -0
  165. package/dist/formats/hlsl/core/tr2/shader/HlslShaderOption.js +30 -0
  166. package/dist/formats/hlsl/core/tr2/shader/HlslShaderOption.js.map +1 -0
  167. package/dist/formats/hlsl/index.js +2 -0
  168. package/dist/formats/hlsl/index.js.map +1 -0
  169. package/dist/formats/hlsl/portable.js +2 -0
  170. package/dist/formats/hlsl/portable.js.map +1 -0
  171. package/dist/formats/index.js +4 -0
  172. package/dist/formats/index.js.map +1 -1
  173. package/dist/formats/jpeg/core/helpers.js +52 -0
  174. package/dist/formats/jpeg/core/helpers.js.map +1 -1
  175. package/dist/formats/jpeg/core/jpeg.js +93 -0
  176. package/dist/formats/jpeg/core/jpeg.js.map +1 -1
  177. package/dist/formats/mp3/core/helpers.js +37 -0
  178. package/dist/formats/mp3/core/helpers.js.map +1 -1
  179. package/dist/formats/mp4/core/helpers.js +35 -0
  180. package/dist/formats/mp4/core/helpers.js.map +1 -1
  181. package/dist/formats/ogg/CjsOggFormat.js +49 -0
  182. package/dist/formats/ogg/CjsOggFormat.js.map +1 -1
  183. package/dist/formats/ogg/core/helpers.js +23 -0
  184. package/dist/formats/ogg/core/helpers.js.map +1 -1
  185. package/dist/formats/ogg/core/vorbis.js +13 -0
  186. package/dist/formats/ogg/core/vorbis.js.map +1 -1
  187. package/dist/formats/png/core/helpers.js +52 -0
  188. package/dist/formats/png/core/helpers.js.map +1 -1
  189. package/dist/formats/red/CjsRedFormat.js +2 -0
  190. package/dist/formats/red/CjsRedFormat.js.map +1 -1
  191. package/dist/formats/red/core/CjsRedReader.js +52 -0
  192. package/dist/formats/red/core/CjsRedReader.js.map +1 -1
  193. package/dist/formats/red/core/helpers.js +19 -0
  194. package/dist/formats/red/core/helpers.js.map +1 -1
  195. package/dist/formats/stl/core/stl.js +8 -0
  196. package/dist/formats/stl/core/stl.js.map +1 -1
  197. package/dist/formats/stl/core/targets.js +10 -0
  198. package/dist/formats/stl/core/targets.js.map +1 -1
  199. package/dist/formats/tga/core/helpers.js +47 -0
  200. package/dist/formats/tga/core/helpers.js.map +1 -1
  201. package/dist/formats/wav/core/helpers.js +37 -0
  202. package/dist/formats/wav/core/helpers.js.map +1 -1
  203. package/dist/formats/webgl/CjsWebglFormat.js +221 -0
  204. package/dist/formats/webgl/CjsWebglFormat.js.map +1 -0
  205. package/dist/formats/webgl/core/cewg/CewgPackage.js +339 -0
  206. package/dist/formats/webgl/core/cewg/CewgPackage.js.map +1 -0
  207. package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js +104 -0
  208. package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js.map +1 -0
  209. package/dist/formats/webgl/core/cewg/binary.js +101 -0
  210. package/dist/formats/webgl/core/cewg/binary.js.map +1 -0
  211. package/dist/formats/webgl/core/cewgCompleteness.js +81 -0
  212. package/dist/formats/webgl/core/cewgCompleteness.js.map +1 -0
  213. package/dist/formats/webgl/core/effectPackage.js +789 -0
  214. package/dist/formats/webgl/core/effectPackage.js.map +1 -0
  215. package/dist/formats/webgl/core/effectPackageValidation.js +331 -0
  216. package/dist/formats/webgl/core/effectPackageValidation.js.map +1 -0
  217. package/dist/formats/webgl/core/errors.js +27 -0
  218. package/dist/formats/webgl/core/errors.js.map +1 -0
  219. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +2678 -0
  220. package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -0
  221. package/dist/formats/webgl/core/glsl/DxbcGlslHelpers.js +89 -0
  222. package/dist/formats/webgl/core/glsl/DxbcGlslHelpers.js.map +1 -0
  223. package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js +428 -0
  224. package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js.map +1 -0
  225. package/dist/formats/webgl/core/helpers.js +306 -0
  226. package/dist/formats/webgl/core/helpers.js.map +1 -0
  227. package/dist/formats/webgl/index.js +2 -0
  228. package/dist/formats/webgl/index.js.map +1 -0
  229. package/dist/formats/webgpu/CjsWebgpuFormat.js +376 -0
  230. package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -0
  231. package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js +415 -0
  232. package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js.map +1 -0
  233. package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js +100 -0
  234. package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js.map +1 -0
  235. package/dist/formats/webgpu/core/cewgpu/binary.js +93 -0
  236. package/dist/formats/webgpu/core/cewgpu/binary.js.map +1 -0
  237. package/dist/formats/webgpu/core/cewgpu/tags.js +17 -0
  238. package/dist/formats/webgpu/core/cewgpu/tags.js.map +1 -0
  239. package/dist/formats/webgpu/core/effectAnalysis.js +82 -0
  240. package/dist/formats/webgpu/core/effectAnalysis.js.map +1 -0
  241. package/dist/formats/webgpu/core/effectBackendBodySet.js +305 -0
  242. package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -0
  243. package/dist/formats/webgpu/core/effectPackageValidation.js +1078 -0
  244. package/dist/formats/webgpu/core/effectPackageValidation.js.map +1 -0
  245. package/dist/formats/webgpu/core/errors.js +20 -0
  246. package/dist/formats/webgpu/core/errors.js.map +1 -0
  247. package/dist/formats/webgpu/core/helpers.js +448 -0
  248. package/dist/formats/webgpu/core/helpers.js.map +1 -0
  249. package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +223 -0
  250. package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js.map +1 -0
  251. package/dist/formats/webgpu/core/ir/buildControlFlow.js +220 -0
  252. package/dist/formats/webgpu/core/ir/buildControlFlow.js.map +1 -0
  253. package/dist/formats/webgpu/core/ir/indexableTemps.js +137 -0
  254. package/dist/formats/webgpu/core/ir/indexableTemps.js.map +1 -0
  255. package/dist/formats/webgpu/core/ir/inferValueTypes.js +454 -0
  256. package/dist/formats/webgpu/core/ir/inferValueTypes.js.map +1 -0
  257. package/dist/formats/webgpu/core/ir/lowerDxbcToIr.js +494 -0
  258. package/dist/formats/webgpu/core/ir/lowerDxbcToIr.js.map +1 -0
  259. package/dist/formats/webgpu/core/ir/resolveRegisterFlow.js +177 -0
  260. package/dist/formats/webgpu/core/ir/resolveRegisterFlow.js.map +1 -0
  261. package/dist/formats/webgpu/core/ir/sourceLanes.js +61 -0
  262. package/dist/formats/webgpu/core/ir/sourceLanes.js.map +1 -0
  263. package/dist/formats/webgpu/core/packageEffect.js +300 -0
  264. package/dist/formats/webgpu/core/packageEffect.js.map +1 -0
  265. package/dist/formats/webgpu/core/packageEffectSelection.js +164 -0
  266. package/dist/formats/webgpu/core/packageEffectSelection.js.map +1 -0
  267. package/dist/formats/webgpu/core/packageMetadata.js +8 -0
  268. package/dist/formats/webgpu/core/packageMetadata.js.map +1 -0
  269. package/dist/formats/webgpu/core/schema.js +4 -0
  270. package/dist/formats/webgpu/core/schema.js.map +1 -0
  271. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +275 -0
  272. package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -0
  273. package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +182 -0
  274. package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js.map +1 -0
  275. package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +324 -0
  276. package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -0
  277. package/dist/formats/webgpu/core/wgsl/emitWgsl.js +356 -0
  278. package/dist/formats/webgpu/core/wgsl/emitWgsl.js.map +1 -0
  279. package/dist/formats/webgpu/core/wgsl/hoistEscapingValues.js +77 -0
  280. package/dist/formats/webgpu/core/wgsl/hoistEscapingValues.js.map +1 -0
  281. package/dist/formats/webgpu/core/wgsl/lowerBindingLayout.js +451 -0
  282. package/dist/formats/webgpu/core/wgsl/lowerBindingLayout.js.map +1 -0
  283. package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +754 -0
  284. package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js.map +1 -0
  285. package/dist/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js +457 -0
  286. package/dist/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js.map +1 -0
  287. package/dist/formats/webgpu/core/wgsl/lowerFragmentProgram.js +1572 -0
  288. package/dist/formats/webgpu/core/wgsl/lowerFragmentProgram.js.map +1 -0
  289. package/dist/formats/webgpu/core/wgsl/lowerMergeHistogramsComputeProgram.js +659 -0
  290. package/dist/formats/webgpu/core/wgsl/lowerMergeHistogramsComputeProgram.js.map +1 -0
  291. package/dist/formats/webgpu/core/wgsl/lowerParticleClearComputePrograms.js +734 -0
  292. package/dist/formats/webgpu/core/wgsl/lowerParticleClearComputePrograms.js.map +1 -0
  293. package/dist/formats/webgpu/core/wgsl/lowerParticleEmitComputeProgram.js +583 -0
  294. package/dist/formats/webgpu/core/wgsl/lowerParticleEmitComputeProgram.js.map +1 -0
  295. package/dist/formats/webgpu/core/wgsl/lowerSkinVerticesComputeProgram.js +621 -0
  296. package/dist/formats/webgpu/core/wgsl/lowerSkinVerticesComputeProgram.js.map +1 -0
  297. package/dist/formats/webgpu/core/wgsl/lowerSortComputeProgram.js +824 -0
  298. package/dist/formats/webgpu/core/wgsl/lowerSortComputeProgram.js.map +1 -0
  299. package/dist/formats/webgpu/core/wgsl/lowerSortInnerComputeProgram.js +697 -0
  300. package/dist/formats/webgpu/core/wgsl/lowerSortInnerComputeProgram.js.map +1 -0
  301. package/dist/formats/webgpu/core/wgsl/lowerSortStepComputeProgram.js +559 -0
  302. package/dist/formats/webgpu/core/wgsl/lowerSortStepComputeProgram.js.map +1 -0
  303. package/dist/formats/webgpu/core/wgsl/lowerVertexProgram.js +1328 -0
  304. package/dist/formats/webgpu/core/wgsl/lowerVertexProgram.js.map +1 -0
  305. package/dist/formats/webgpu/core/wgsl/particleEmitSemanticDigest.js +110 -0
  306. package/dist/formats/webgpu/core/wgsl/particleEmitSemanticDigest.js.map +1 -0
  307. package/dist/formats/webgpu/core/wgsl/precisionControls.js +55 -0
  308. package/dist/formats/webgpu/core/wgsl/precisionControls.js.map +1 -0
  309. package/dist/formats/webgpu/core/wgsl/selectionPlans.js +758 -0
  310. package/dist/formats/webgpu/core/wgsl/selectionPlans.js.map +1 -0
  311. package/dist/formats/webgpu/core/wgsl/uniformity.js +78 -0
  312. package/dist/formats/webgpu/core/wgsl/uniformity.js.map +1 -0
  313. package/dist/formats/webgpu/core/wgsl/validateExactComputeIr.js +196 -0
  314. package/dist/formats/webgpu/core/wgsl/validateExactComputeIr.js.map +1 -0
  315. package/dist/formats/webgpu/core/wgsl/validateHandleOperand.js +37 -0
  316. package/dist/formats/webgpu/core/wgsl/validateHandleOperand.js.map +1 -0
  317. package/dist/formats/webgpu/index.js +2 -0
  318. package/dist/formats/webgpu/index.js.map +1 -0
  319. package/dist/formats/webm/core/helpers.js +35 -0
  320. package/dist/formats/webm/core/helpers.js.map +1 -1
  321. package/dist/formats/webp/CjsWebpFormat.js +49 -0
  322. package/dist/formats/webp/CjsWebpFormat.js.map +1 -1
  323. package/dist/formats/webp/core/helpers.js +23 -0
  324. package/dist/formats/webp/core/helpers.js.map +1 -1
  325. package/dist/formats/wem/CjsWemFormat.js +8 -0
  326. package/dist/formats/wem/CjsWemFormat.js.map +1 -1
  327. package/dist/formats/wem/core/bitStream.js +2 -0
  328. package/dist/formats/wem/core/bitStream.js.map +1 -1
  329. package/dist/formats/wem/core/helpers.js +20 -0
  330. package/dist/formats/wem/core/helpers.js.map +1 -1
  331. package/dist/formats/yaml/CjsYamlFormat.js +45 -0
  332. package/dist/formats/yaml/CjsYamlFormat.js.map +1 -1
  333. package/dist/formats/yaml/core/CjsYamlReader.js +91 -0
  334. package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -1
  335. package/dist/formats/yaml/core/helpers.js +10 -0
  336. package/dist/formats/yaml/core/helpers.js.map +1 -1
  337. package/dist/index.js +56 -43
  338. package/dist/index.js.map +1 -1
  339. package/dist/{CjsResource.js → resource/CjsResource.js} +232 -17
  340. package/dist/resource/CjsResource.js.map +1 -0
  341. package/dist/{resources → resource}/Tr2LightProfileRes.js +4 -3
  342. package/dist/resource/Tr2LightProfileRes.js.map +1 -0
  343. package/dist/{resources → resource/audio}/AudioGeometryResData.js +1 -1
  344. package/dist/resource/audio/AudioGeometryResData.js.map +1 -0
  345. package/dist/resource/audio/CjsAudioBufferRes.js +86 -0
  346. package/dist/resource/audio/CjsAudioBufferRes.js.map +1 -0
  347. package/dist/resource/audio/CjsAudioRes.js +213 -0
  348. package/dist/resource/audio/CjsAudioRes.js.map +1 -0
  349. package/dist/resource/audio/index.js +4 -0
  350. package/dist/resource/audio/index.js.map +1 -0
  351. package/dist/{resources → resource/geometry}/MeshDecalData.js +1 -1
  352. package/dist/resource/geometry/MeshDecalData.js.map +1 -0
  353. package/dist/{resources → resource/geometry}/MeshDecalLodData.js +1 -1
  354. package/dist/resource/geometry/MeshDecalLodData.js.map +1 -0
  355. package/dist/resource/geometry/TriGeometryRes.js +656 -0
  356. package/dist/resource/geometry/TriGeometryRes.js.map +1 -0
  357. package/dist/{resources → resource/geometry}/TriGeometryResAreaData.js +1 -1
  358. package/dist/resource/geometry/TriGeometryResAreaData.js.map +1 -0
  359. package/dist/{resources → resource/geometry}/TriGeometryResJointData.js +1 -1
  360. package/dist/resource/geometry/TriGeometryResJointData.js.map +1 -0
  361. package/dist/{resources → resource/geometry}/TriGeometryResLodData.js +1 -1
  362. package/dist/resource/geometry/TriGeometryResLodData.js.map +1 -0
  363. package/dist/{resources → resource/geometry}/TriGeometryResMeshData.js +1 -1
  364. package/dist/resource/geometry/TriGeometryResMeshData.js.map +1 -0
  365. package/dist/{resources → resource/geometry}/TriGeometryResSkeletonData.js +1 -1
  366. package/dist/resource/geometry/TriGeometryResSkeletonData.js.map +1 -0
  367. package/dist/{resources → resource/geometry}/TriJointBinding.js +1 -1
  368. package/dist/resource/geometry/TriJointBinding.js.map +1 -0
  369. package/dist/{resources → resource/geometry}/TriMorphTargetGeometryConstants.js +1 -1
  370. package/dist/resource/geometry/TriMorphTargetGeometryConstants.js.map +1 -0
  371. package/dist/{resources → resource/geometry}/TriRtGeometryConstants.js +1 -1
  372. package/dist/resource/geometry/TriRtGeometryConstants.js.map +1 -0
  373. package/dist/{resources → resource/geometry/granny}/GStateBindingCallbackData.js +1 -1
  374. package/dist/resource/geometry/granny/GStateBindingCallbackData.js.map +1 -0
  375. package/dist/{resources → resource/geometry/granny}/Tr2GrannyIntersectionResult.js +1 -1
  376. package/dist/resource/geometry/granny/Tr2GrannyIntersectionResult.js.map +1 -0
  377. package/dist/{resources → resource/geometry/granny}/Tr2GrannyStateRes.js +6 -5
  378. package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -0
  379. package/dist/{resources → resource/geometry/granny}/TriGrannyRes.js +6 -5
  380. package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -0
  381. package/dist/{resources → resource/geometry/granny}/enums.js +1 -9
  382. package/dist/resource/geometry/granny/enums.js.map +1 -0
  383. package/dist/resource/geometry/granny/index.js +6 -0
  384. package/dist/resource/geometry/granny/index.js.map +1 -0
  385. package/dist/resource/geometry/index.js +17 -0
  386. package/dist/resource/geometry/index.js.map +1 -0
  387. package/dist/resource/index.js +52 -0
  388. package/dist/resource/index.js.map +1 -0
  389. package/dist/resource/resourceBoundary.js +64 -0
  390. package/dist/resource/resourceBoundary.js.map +1 -0
  391. package/dist/resource/shader/Tr2EffectRes.js +429 -0
  392. package/dist/resource/shader/Tr2EffectRes.js.map +1 -0
  393. package/dist/resource/shader/Tr2MaterialArea.js +34 -0
  394. package/dist/resource/shader/Tr2MaterialArea.js.map +1 -0
  395. package/dist/resource/shader/Tr2MaterialMesh.js +30 -0
  396. package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -0
  397. package/dist/resource/shader/Tr2MaterialRes.js +35 -0
  398. package/dist/resource/shader/Tr2MaterialRes.js.map +1 -0
  399. package/dist/resource/shader/Tr2Shader.js +256 -0
  400. package/dist/resource/shader/Tr2Shader.js.map +1 -0
  401. package/dist/resource/shader/Tr2ShaderPermutation.js +47 -0
  402. package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -0
  403. package/dist/resource/shader/index.js +17 -0
  404. package/dist/resource/shader/index.js.map +1 -0
  405. package/dist/resource/shader/portable.js +33 -0
  406. package/dist/resource/shader/portable.js.map +1 -0
  407. package/dist/resource/shader/reflection/Tr2EffectConstant.js +135 -0
  408. package/dist/resource/shader/reflection/Tr2EffectConstant.js.map +1 -0
  409. package/dist/resource/shader/reflection/Tr2EffectDefine.js +28 -0
  410. package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -0
  411. package/dist/resource/shader/reflection/Tr2EffectDescription.js +107 -0
  412. package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -0
  413. package/dist/resource/shader/reflection/Tr2EffectLibrary.js +145 -0
  414. package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -0
  415. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +103 -0
  416. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -0
  417. package/dist/resource/shader/reflection/Tr2EffectResource.js +84 -0
  418. package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -0
  419. package/dist/resource/shader/reflection/Tr2EffectStageInput.js +239 -0
  420. package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -0
  421. package/dist/resource/shader/reflection/Tr2EffectTechnique.js +66 -0
  422. package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -0
  423. package/dist/resource/shader/reflection/Tr2Pass.js +109 -0
  424. package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -0
  425. package/dist/resource/shader/sampler/Tr2SamplerSetup.js +75 -0
  426. package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -0
  427. package/dist/{texture → resource/texture}/CjsTextureArrayRes.js +83 -6
  428. package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -0
  429. package/dist/{texture/CjsTextureParameterProxy.js → resource/texture/CjsTextureArrayResParameterProxy.js} +56 -10
  430. package/dist/resource/texture/CjsTextureArrayResParameterProxy.js.map +1 -0
  431. package/dist/{resources → resource/texture}/Tr2ImageRes.js +6 -4
  432. package/dist/resource/texture/Tr2ImageRes.js.map +1 -0
  433. package/dist/{resources → resource/texture}/Tr2TextureLodManager.js +3 -1
  434. package/dist/resource/texture/Tr2TextureLodManager.js.map +1 -0
  435. package/dist/{resources → resource/texture}/Tr2TextureLodUpdateRequest.js +1 -1
  436. package/dist/resource/texture/Tr2TextureLodUpdateRequest.js.map +1 -0
  437. package/dist/{resources → resource/texture}/Tr2TexturePackChannel.js +1 -1
  438. package/dist/resource/texture/Tr2TexturePackChannel.js.map +1 -0
  439. package/dist/{resources → resource/texture}/Tr2TexturePipeline.js +6 -4
  440. package/dist/resource/texture/Tr2TexturePipeline.js.map +1 -0
  441. package/dist/{resources → resource/texture}/Tr2TexturePipelineParams.js +1 -1
  442. package/dist/resource/texture/Tr2TexturePipelineParams.js.map +1 -0
  443. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepCompress.js +1 -1
  444. package/dist/resource/texture/Tr2TexturePipelineStepCompress.js.map +1 -0
  445. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepGenerateMips.js +1 -1
  446. package/dist/resource/texture/Tr2TexturePipelineStepGenerateMips.js.map +1 -0
  447. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepLimitSize.js +1 -1
  448. package/dist/resource/texture/Tr2TexturePipelineStepLimitSize.js.map +1 -0
  449. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepLoad.js +1 -1
  450. package/dist/resource/texture/Tr2TexturePipelineStepLoad.js.map +1 -0
  451. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepPack.js +1 -1
  452. package/dist/resource/texture/Tr2TexturePipelineStepPack.js.map +1 -0
  453. package/dist/{resources → resource/texture}/TriTextureRes.js +42 -26
  454. package/dist/resource/texture/TriTextureRes.js.map +1 -0
  455. package/dist/resource/texture/index.js +15 -0
  456. package/dist/resource/texture/index.js.map +1 -0
  457. package/dist/{resources → resource/texture}/texturePipelineBehavior.js +59 -59
  458. package/dist/resource/texture/texturePipelineBehavior.js.map +1 -0
  459. package/dist/worker/CjsResManMainThreadLoader.js +87 -0
  460. package/dist/worker/CjsResManMainThreadLoader.js.map +1 -0
  461. package/dist/worker/CjsResManWorker.js +217 -0
  462. package/dist/worker/CjsResManWorker.js.map +1 -0
  463. package/dist/worker/CjsResManWorkerLoader.js +434 -0
  464. package/dist/worker/CjsResManWorkerLoader.js.map +1 -0
  465. package/dist/worker/protocol.js +12 -0
  466. package/dist/worker/protocol.js.map +1 -0
  467. package/docs/README.md +16 -3
  468. package/docs/architecture.md +39 -16
  469. package/docs/concepts/resource-lifecycle.md +2 -1
  470. package/docs/formats/README.md +8 -0
  471. package/docs/formats/provenance.md +11 -3
  472. package/docs/reference/classes/README.md +6 -4
  473. package/docs/reference/classes/audio.md +30 -0
  474. package/docs/reference/classes/core.md +31 -11
  475. package/docs/reference/classes/formats.md +440 -0
  476. package/docs/reference/classes/resources.md +151 -41
  477. package/docs/reference/classes/texture.md +7 -7
  478. package/docs/reference/motherlode-cache.md +17 -0
  479. package/docs/reference/queues.md +9 -1
  480. package/docs/reference/workers.md +135 -0
  481. package/docs/roadmap.md +27 -1
  482. package/format-notices/dxbc/LICENSE +21 -0
  483. package/format-notices/dxbc/NOTICE +20 -0
  484. package/format-notices/hlsl/LICENSE +21 -0
  485. package/format-notices/hlsl/NOTICE +25 -0
  486. package/format-notices/webgl/LICENSE +21 -0
  487. package/format-notices/webgl/NOTICE +35 -0
  488. package/format-notices/webgpu/LICENSE +21 -0
  489. package/format-notices/webgpu/NOTICE +31 -0
  490. package/package.json +13 -1
  491. package/dist/CjsResManQueue.js.map +0 -1
  492. package/dist/CjsResource.js.map +0 -1
  493. package/dist/CjsResourceSource.js +0 -68
  494. package/dist/CjsResourceSource.js.map +0 -1
  495. package/dist/resourcePath.js +0 -18
  496. package/dist/resourcePath.js.map +0 -1
  497. package/dist/resourceStates.js +0 -9
  498. package/dist/resourceStates.js.map +0 -1
  499. package/dist/resources/AudioGeometryResData.js.map +0 -1
  500. package/dist/resources/GStateBindingCallbackData.js.map +0 -1
  501. package/dist/resources/MeshDecalData.js.map +0 -1
  502. package/dist/resources/MeshDecalLodData.js.map +0 -1
  503. package/dist/resources/Tr2EffectRes.js +0 -71
  504. package/dist/resources/Tr2EffectRes.js.map +0 -1
  505. package/dist/resources/Tr2GrannyIntersectionResult.js.map +0 -1
  506. package/dist/resources/Tr2GrannyStateRes.js.map +0 -1
  507. package/dist/resources/Tr2ImageRes.js.map +0 -1
  508. package/dist/resources/Tr2LightProfileRes.js.map +0 -1
  509. package/dist/resources/Tr2MaterialArea.js +0 -34
  510. package/dist/resources/Tr2MaterialArea.js.map +0 -1
  511. package/dist/resources/Tr2MaterialMesh.js +0 -31
  512. package/dist/resources/Tr2MaterialMesh.js.map +0 -1
  513. package/dist/resources/Tr2MaterialRes.js +0 -34
  514. package/dist/resources/Tr2MaterialRes.js.map +0 -1
  515. package/dist/resources/Tr2ShaderPermutation.js +0 -43
  516. package/dist/resources/Tr2ShaderPermutation.js.map +0 -1
  517. package/dist/resources/Tr2TextureLodManager.js.map +0 -1
  518. package/dist/resources/Tr2TextureLodUpdateRequest.js.map +0 -1
  519. package/dist/resources/Tr2TexturePackChannel.js.map +0 -1
  520. package/dist/resources/Tr2TexturePipeline.js.map +0 -1
  521. package/dist/resources/Tr2TexturePipelineParams.js.map +0 -1
  522. package/dist/resources/Tr2TexturePipelineStepCompress.js.map +0 -1
  523. package/dist/resources/Tr2TexturePipelineStepGenerateMips.js.map +0 -1
  524. package/dist/resources/Tr2TexturePipelineStepLimitSize.js.map +0 -1
  525. package/dist/resources/Tr2TexturePipelineStepLoad.js.map +0 -1
  526. package/dist/resources/Tr2TexturePipelineStepPack.js.map +0 -1
  527. package/dist/resources/TriGeometryRes.js +0 -239
  528. package/dist/resources/TriGeometryRes.js.map +0 -1
  529. package/dist/resources/TriGeometryResAreaData.js.map +0 -1
  530. package/dist/resources/TriGeometryResJointData.js.map +0 -1
  531. package/dist/resources/TriGeometryResLodData.js.map +0 -1
  532. package/dist/resources/TriGeometryResMeshData.js.map +0 -1
  533. package/dist/resources/TriGeometryResSkeletonData.js.map +0 -1
  534. package/dist/resources/TriGrannyRes.js.map +0 -1
  535. package/dist/resources/TriJointBinding.js.map +0 -1
  536. package/dist/resources/TriMorphTargetGeometryConstants.js.map +0 -1
  537. package/dist/resources/TriRtGeometryConstants.js.map +0 -1
  538. package/dist/resources/TriTextureRes.js.map +0 -1
  539. package/dist/resources/enums.js.map +0 -1
  540. package/dist/resources/resourceBoundary.js +0 -47
  541. package/dist/resources/resourceBoundary.js.map +0 -1
  542. package/dist/resources/texturePipelineBehavior.js.map +0 -1
  543. package/dist/texture/CjsTextureArrayRes.js.map +0 -1
  544. package/dist/texture/CjsTextureParameterProxy.js.map +0 -1
@@ -0,0 +1,51 @@
1
+ import { normalizeValues, DEFAULT_VALUES, readRaw } from './helpers.js';
2
+ import { resolveSelectedOptions } from './metadata.js';
3
+ import { HlslEffectBindingManifest } from './tr2/shader/HlslEffectBindingManifest.js';
4
+
5
+ /**
6
+ * Resolve one permutation to the raw effect/shader/manifest context that
7
+ * downstream translation tooling needs.
8
+ *
9
+ * This is intentionally an advanced helper: it returns internal graph objects
10
+ * rather than the stable JSON contract exposed by `CjsHlslFormat`.
11
+ *
12
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.
13
+ * @param {object} values Normalized format values.
14
+ * @returns {{effectRes: object, shader: object|null, selection: object, effectDescription: object|null, bindingManifest: HlslEffectBindingManifest|null}}
15
+ * Raw loaded effect data plus the resolved permutation context.
16
+ */
17
+ function analyzeEffectWithValues(input, values) {
18
+ const effectRes = readRaw(input, values);
19
+ const selection = resolveSelectedOptions(effectRes, values.permutation || []);
20
+ let shader = null;
21
+ try {
22
+ shader = effectRes.GetShader(values.permutation || []);
23
+ } catch {
24
+ shader = null;
25
+ }
26
+ const effectDescription = shader ? shader.GetEffectDescription() : null;
27
+ const bindingManifest = effectDescription ? HlslEffectBindingManifest.fromEffectDescription(effectDescription) : null;
28
+ return {
29
+ effectRes,
30
+ shader,
31
+ selection,
32
+ effectDescription,
33
+ bindingManifest
34
+ };
35
+ }
36
+
37
+ /**
38
+ * Advanced one-shot helper for tooling that needs one parse plus one binding
39
+ * manifest build without changing the stable reader emits.
40
+ *
41
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.
42
+ * @param {object} [options] Format values.
43
+ * @returns {{effectRes: object, shader: object|null, selection: object, effectDescription: object|null, bindingManifest: HlslEffectBindingManifest|null}}
44
+ * Raw loaded effect data plus the resolved permutation context.
45
+ */
46
+ function readEffectAnalysis(input, options = {}) {
47
+ return analyzeEffectWithValues(input, normalizeValues(DEFAULT_VALUES, options, "readEffectAnalysis"));
48
+ }
49
+
50
+ export { analyzeEffectWithValues, readEffectAnalysis };
51
+ //# sourceMappingURL=analysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analysis.js","sources":["../../../../../src/formats/hlsl/core/analysis.js"],"sourcesContent":["import { DEFAULT_VALUES, normalizeValues, readRaw } from \"./helpers.js\";\nimport { resolveSelectedOptions } from \"./metadata.js\";\nimport { HlslEffectBindingManifest } from \"./tr2/shader/HlslEffectBindingManifest.js\";\n\n/**\n * Resolve one permutation to the raw effect/shader/manifest context that\n * downstream translation tooling needs.\n *\n * This is intentionally an advanced helper: it returns internal graph objects\n * rather than the stable JSON contract exposed by `CjsHlslFormat`.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.\n * @param {object} values Normalized format values.\n * @returns {{effectRes: object, shader: object|null, selection: object, effectDescription: object|null, bindingManifest: HlslEffectBindingManifest|null}}\n * Raw loaded effect data plus the resolved permutation context.\n */\nexport function analyzeEffectWithValues(input, values)\n{\n const effectRes = readRaw(input, values);\n const selection = resolveSelectedOptions(effectRes, values.permutation || []);\n\n let shader = null;\n try\n {\n shader = effectRes.GetShader(values.permutation || []);\n }\n catch\n {\n shader = null;\n }\n\n const effectDescription = shader ? shader.GetEffectDescription() : null;\n const bindingManifest = effectDescription\n ? HlslEffectBindingManifest.fromEffectDescription(effectDescription)\n : null;\n\n return {\n effectRes,\n shader,\n selection,\n effectDescription,\n bindingManifest\n };\n}\n\n/**\n * Advanced one-shot helper for tooling that needs one parse plus one binding\n * manifest build without changing the stable reader emits.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.\n * @param {object} [options] Format values.\n * @returns {{effectRes: object, shader: object|null, selection: object, effectDescription: object|null, bindingManifest: HlslEffectBindingManifest|null}}\n * Raw loaded effect data plus the resolved permutation context.\n */\nexport function readEffectAnalysis(input, options = {})\n{\n return analyzeEffectWithValues(input, normalizeValues(DEFAULT_VALUES, options, \"readEffectAnalysis\"));\n}\n"],"names":["analyzeEffectWithValues","input","values","effectRes","readRaw","selection","resolveSelectedOptions","permutation","shader","GetShader","effectDescription","GetEffectDescription","bindingManifest","HlslEffectBindingManifest","fromEffectDescription","readEffectAnalysis","options","normalizeValues","DEFAULT_VALUES"],"mappings":";;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,uBAAuBA,CAACC,KAAK,EAAEC,MAAM,EACrD;AACI,EAAA,MAAMC,SAAS,GAAGC,OAAO,CAACH,KAAK,EAAEC,MAAM,CAAC;EACxC,MAAMG,SAAS,GAAGC,sBAAsB,CAACH,SAAS,EAAED,MAAM,CAACK,WAAW,IAAI,EAAE,CAAC;EAE7E,IAAIC,MAAM,GAAG,IAAI;EACjB,IACA;IACIA,MAAM,GAAGL,SAAS,CAACM,SAAS,CAACP,MAAM,CAACK,WAAW,IAAI,EAAE,CAAC;AAC1D,EAAA,CAAC,CACD,MACA;AACIC,IAAAA,MAAM,GAAG,IAAI;AACjB,EAAA;EAEA,MAAME,iBAAiB,GAAGF,MAAM,GAAGA,MAAM,CAACG,oBAAoB,EAAE,GAAG,IAAI;EACvE,MAAMC,eAAe,GAAGF,iBAAiB,GACnCG,yBAAyB,CAACC,qBAAqB,CAACJ,iBAAiB,CAAC,GAClE,IAAI;EAEV,OAAO;IACHP,SAAS;IACTK,MAAM;IACNH,SAAS;IACTK,iBAAiB;AACjBE,IAAAA;GACH;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,kBAAkBA,CAACd,KAAK,EAAEe,OAAO,GAAG,EAAE,EACtD;AACI,EAAA,OAAOhB,uBAAuB,CAACC,KAAK,EAAEgB,eAAe,CAACC,cAAc,EAAEF,OAAO,EAAE,oBAAoB,CAAC,CAAC;AACzG;;;;"}
@@ -0,0 +1,270 @@
1
+ import { HlslEffectReadError } from './HlslEffectReadError.js';
2
+ import { resolveSelectedOptions, emitEffectMetadata } from './metadata.js';
3
+ import { HlslEffectRes } from './tr2/resources/HlslEffectRes.js';
4
+ import { CLASS_KEYS, emitEffectJson } from './json.js';
5
+
6
+ /**
7
+ * Internal read-pipeline glue for CjsHlslFormat.
8
+ *
9
+ * Keeps the public class file small: input normalization, option/classes
10
+ * normalization, the shared read path used by both the instance and the
11
+ * static one-shots, and JSON conversion live here. The actual Tr2 effect
12
+ * container parser lives under src/core/tr2 (internal parsing machinery,
13
+ * not part of this package's public surface); this module wires bytes into
14
+ * that graph and, for `emit: "json"`, converts it via src/core/json.js into
15
+ * the documented plain-data shape.
16
+ */
17
+
18
+ const OUTPUT_JSON = "json";
19
+ const OUTPUT_RAW = "raw";
20
+ const OUTPUT_METADATA = "metadata";
21
+ const DEFAULT_VALUES = Object.freeze({
22
+ emit: OUTPUT_JSON,
23
+ source: "memory",
24
+ permutation: null,
25
+ classes: Object.freeze({})
26
+ });
27
+ const VALID_EMITS = new Set([OUTPUT_JSON, OUTPUT_RAW, OUTPUT_METADATA]);
28
+ const OPTION_KEYS = new Set(["emit", "source", "permutation", "classes"]);
29
+
30
+ /**
31
+ * Validate a `classes` node key against {@link CLASS_KEYS}.
32
+ *
33
+ * @param {string} key Candidate node key.
34
+ * @param {string} [readerName] Reader name used in the thrown error.
35
+ */
36
+ function validateClassKey(key, readerName = "CjsHlslFormat") {
37
+ if (!CLASS_KEYS.includes(key)) {
38
+ throw new Error(`${readerName}: unknown class key ${JSON.stringify(key)}; expected one of ${CLASS_KEYS.join(", ")}`);
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Validate a single `classes` entry: a known key mapped to a constructor.
44
+ *
45
+ * @param {string} key Node key.
46
+ * @param {Function} Class Candidate constructor.
47
+ * @param {string} [readerName] Reader name used in thrown errors.
48
+ */
49
+ function validateClass(key, Class, readerName = "CjsHlslFormat") {
50
+ validateClassKey(key, readerName);
51
+ if (typeof Class !== "function") {
52
+ throw new TypeError(`${readerName}: class ${JSON.stringify(key)} must be a constructor`);
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Merge and validate a `classes` map over a base map.
58
+ *
59
+ * @param {object} base Current classes map.
60
+ * @param {object} classes Incoming classes map to merge in.
61
+ * @param {string} readerName Reader name used in thrown errors.
62
+ * @returns {object} Merged, validated classes map.
63
+ */
64
+ function mergeClasses(base, classes, readerName) {
65
+ if (!classes || typeof classes !== "object") {
66
+ throw new TypeError(`${readerName}: classes option must be an object`);
67
+ }
68
+ const next = {
69
+ ...base
70
+ };
71
+ for (const [key, Class] of Object.entries(classes)) {
72
+ if (Class === null || Class === undefined) {
73
+ delete next[key];
74
+ continue;
75
+ }
76
+ validateClass(key, Class, readerName);
77
+ next[key] = Class;
78
+ }
79
+ return next;
80
+ }
81
+
82
+ /**
83
+ * Merge format values over a base set and validate them.
84
+ *
85
+ * @param {object} base Current values.
86
+ * @param {object} [options] Values to merge in.
87
+ * @param {string} [readerName] Reader name used in error messages.
88
+ * @returns {object} A validated copy of the merged values.
89
+ */
90
+ function normalizeValues(base, options = {}, readerName = "CjsHlslFormat") {
91
+ if (!options || typeof options !== "object") {
92
+ throw new TypeError(`${readerName}: options must be an object`);
93
+ }
94
+ for (const key of Object.keys(options)) {
95
+ if (!OPTION_KEYS.has(key)) {
96
+ throw new TypeError(`${readerName}: unknown option ${JSON.stringify(key)}`);
97
+ }
98
+ }
99
+ const values = {
100
+ ...base,
101
+ ...options
102
+ };
103
+ if (!VALID_EMITS.has(values.emit)) {
104
+ throw new TypeError(`${readerName}: emit must be one of ${Array.from(VALID_EMITS, emit => JSON.stringify(emit)).join(", ")}, got ${JSON.stringify(values.emit)}`);
105
+ }
106
+ if (typeof values.source !== "string" || !values.source) {
107
+ values.source = DEFAULT_VALUES.source;
108
+ }
109
+ values.classes = Object.prototype.hasOwnProperty.call(options, "classes") ? mergeClasses(base.classes || {}, options.classes, readerName) : {
110
+ ...(base.classes || {})
111
+ };
112
+ return {
113
+ emit: values.emit,
114
+ source: values.source,
115
+ permutation: values.permutation ?? null,
116
+ classes: values.classes
117
+ };
118
+ }
119
+
120
+ /**
121
+ * Normalize caller input into a Uint8Array of Tr2 effect bytes.
122
+ *
123
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.
124
+ * @returns {Uint8Array} The payload bytes.
125
+ */
126
+ function toBytes(input) {
127
+ if (input instanceof Uint8Array) return input;
128
+ if (typeof ArrayBuffer !== "undefined" && input instanceof ArrayBuffer) return new Uint8Array(input);
129
+ if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
130
+ throw new TypeError("CjsHlslFormat: input must be Tr2 effect bytes (Uint8Array, Buffer, DataView or ArrayBuffer)");
131
+ }
132
+
133
+ /**
134
+ * The shared read path used by the instance Read, Inspect, and the static
135
+ * one-shots: normalizes input bytes and loads a HlslEffectRes graph. This is
136
+ * internal parsing machinery — the documented public contract is the plain
137
+ * JSON shape produced by {@link readWithValues}, not this raw graph.
138
+ *
139
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.
140
+ * @param {object} values Normalized format values.
141
+ * @returns {HlslEffectRes} The loaded effect resource graph.
142
+ */
143
+ function readRaw(input, values) {
144
+ const bytes = toBytes(input);
145
+ const effect = new HlslEffectRes();
146
+ const ok = effect.DoLoad(bytes, {
147
+ source: values.source
148
+ });
149
+ if (!ok) {
150
+ throw new HlslEffectReadError(effect.loadError ? effect.loadError.message : "Failed to read Tr2 effect resource", {
151
+ source: values.source,
152
+ cause: effect.loadError || null
153
+ });
154
+ }
155
+ return effect;
156
+ }
157
+
158
+ /**
159
+ * Resolves one permutation's HlslShader from a loaded effect, tolerating
160
+ * bodies that fail to decode (returns null instead of throwing).
161
+ *
162
+ * @param {HlslEffectRes} effect Loaded effect resource graph.
163
+ * @param {object} values Normalized format values.
164
+ * @returns {object|null} Resolved HlslShader, or null.
165
+ */
166
+ function resolveShader(effect, values) {
167
+ try {
168
+ return effect.GetShader(values.permutation || []);
169
+ } catch {
170
+ return null;
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Shared read entry honouring the emit mode.
176
+ *
177
+ * `emit: "raw"` returns the live HlslEffectRes instance — internal,
178
+ * unstable, and not schema-guaranteed across versions. `emit: "json"`
179
+ * (the default) returns the documented plain-data effect graph, honouring
180
+ * `values.classes`.
181
+ *
182
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.
183
+ * @param {object} values Normalized format values.
184
+ * @returns {HlslEffectRes|object} The raw HlslEffectRes instance, or the documented JSON graph.
185
+ */
186
+ function readWithValues(input, values) {
187
+ const effect = readRaw(input, values);
188
+ if (values.emit === OUTPUT_RAW) return effect;
189
+ const shader = resolveShader(effect, values);
190
+ if (values.emit === OUTPUT_METADATA) {
191
+ const selection = resolveSelectedOptions(effect, values.permutation || []);
192
+ return emitEffectMetadata(effect, shader, selection);
193
+ }
194
+ return emitEffectJson(effect, shader, {
195
+ classes: values.classes
196
+ });
197
+ }
198
+
199
+ /**
200
+ * Cheap inspection: effect header facts plus the default permutation's
201
+ * technique names and stage counts, without a full JSON conversion of the
202
+ * decoded graph.
203
+ *
204
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.
205
+ * @param {object} values Normalized format values.
206
+ * @returns {object} Plain summary data.
207
+ */
208
+ function inspectWithValues(input, values) {
209
+ const effect = readRaw(input, values);
210
+ const summary = {
211
+ source: values.source,
212
+ version: effect.m_version,
213
+ compilerVersion: effect.m_compilerVersion,
214
+ isGood: effect.IsGood(),
215
+ permutationCount: effect.m_permutations.length,
216
+ bodyCount: effect.m_offsetCount,
217
+ effectName: null,
218
+ techniques: []
219
+ };
220
+ try {
221
+ const shader = effect.GetShader(values.permutation || []);
222
+ if (shader) {
223
+ const description = shader.GetEffectDescription();
224
+ summary.effectName = description.effectName || null;
225
+ summary.techniques = description.techniques.map(technique => ({
226
+ name: technique.name,
227
+ passCount: technique.passes.length,
228
+ stageCounts: technique.passes.map(pass => pass.stageInputs.filter(stage => stage && stage.m_exists).length)
229
+ }));
230
+ }
231
+ } catch (error) {
232
+ summary.inspectError = {
233
+ name: error.name,
234
+ message: error.message
235
+ };
236
+ }
237
+ return summary;
238
+ }
239
+
240
+ /**
241
+ * Deep-convert a value to plain JSON-compatible data. Typed arrays become
242
+ * plain number arrays; Maps/Sets become objects/arrays; class instances
243
+ * with toJSON are honoured.
244
+ *
245
+ * @param {any} value Value to convert.
246
+ * @returns {any} Plain data.
247
+ */
248
+ function toJsonValue(value) {
249
+ if (value === null || value === undefined) return value ?? null;
250
+ if (typeof value === "number" || typeof value === "string" || typeof value === "boolean") return value;
251
+ if (typeof value === "bigint") return value.toString();
252
+ if (ArrayBuffer.isView(value)) return Array.from(value);
253
+ if (Array.isArray(value)) return value.map(toJsonValue);
254
+ if (value instanceof Map) {
255
+ const out = {};
256
+ for (const [key, entry] of value) out[key] = toJsonValue(entry);
257
+ return out;
258
+ }
259
+ if (value instanceof Set) return Array.from(value, toJsonValue);
260
+ if (typeof value === "object") {
261
+ if (typeof value.toJSON === "function") return toJsonValue(value.toJSON());
262
+ const out = {};
263
+ for (const key of Object.keys(value)) out[key] = toJsonValue(value[key]);
264
+ return out;
265
+ }
266
+ return null;
267
+ }
268
+
269
+ export { CLASS_KEYS, DEFAULT_VALUES, HlslEffectReadError, OUTPUT_JSON, OUTPUT_METADATA, OUTPUT_RAW, inspectWithValues, normalizeValues, readRaw, readWithValues, toBytes, toJsonValue, validateClass, validateClassKey };
270
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sources":["../../../../../src/formats/hlsl/core/helpers.js"],"sourcesContent":["/**\n * Internal read-pipeline glue for CjsHlslFormat.\n *\n * Keeps the public class file small: input normalization, option/classes\n * normalization, the shared read path used by both the instance and the\n * static one-shots, and JSON conversion live here. The actual Tr2 effect\n * container parser lives under src/core/tr2 (internal parsing machinery,\n * not part of this package's public surface); this module wires bytes into\n * that graph and, for `emit: \"json\"`, converts it via src/core/json.js into\n * the documented plain-data shape.\n */\n\nimport { HlslEffectReadError } from \"./HlslEffectReadError.js\";\nimport {\n emitEffectMetadata,\n resolveSelectedOptions\n} from \"./metadata.js\";\nimport { HlslEffectRes } from \"./tr2/resources/HlslEffectRes.js\";\nimport { CLASS_KEYS, emitEffectJson } from \"./json.js\";\n\nexport const OUTPUT_JSON = \"json\";\nexport const OUTPUT_RAW = \"raw\";\nexport const OUTPUT_METADATA = \"metadata\";\n\nexport const DEFAULT_VALUES = Object.freeze({\n emit: OUTPUT_JSON,\n source: \"memory\",\n permutation: null,\n classes: Object.freeze({})\n});\n\nconst VALID_EMITS = new Set([ OUTPUT_JSON, OUTPUT_RAW, OUTPUT_METADATA ]);\nconst OPTION_KEYS = new Set([ \"emit\", \"source\", \"permutation\", \"classes\" ]);\n\n/**\n * Validate a `classes` node key against {@link CLASS_KEYS}.\n *\n * @param {string} key Candidate node key.\n * @param {string} [readerName] Reader name used in the thrown error.\n */\nexport function validateClassKey(key, readerName = \"CjsHlslFormat\")\n{\n if (!CLASS_KEYS.includes(key))\n {\n throw new Error(`${readerName}: unknown class key ${JSON.stringify(key)}; expected one of ${CLASS_KEYS.join(\", \")}`);\n }\n}\n\n/**\n * Validate a single `classes` entry: a known key mapped to a constructor.\n *\n * @param {string} key Node key.\n * @param {Function} Class Candidate constructor.\n * @param {string} [readerName] Reader name used in thrown errors.\n */\nexport function validateClass(key, Class, readerName = \"CjsHlslFormat\")\n{\n validateClassKey(key, readerName);\n if (typeof Class !== \"function\")\n {\n throw new TypeError(`${readerName}: class ${JSON.stringify(key)} must be a constructor`);\n }\n}\n\n/**\n * Merge and validate a `classes` map over a base map.\n *\n * @param {object} base Current classes map.\n * @param {object} classes Incoming classes map to merge in.\n * @param {string} readerName Reader name used in thrown errors.\n * @returns {object} Merged, validated classes map.\n */\nfunction mergeClasses(base, classes, readerName)\n{\n if (!classes || typeof classes !== \"object\")\n {\n throw new TypeError(`${readerName}: classes option must be an object`);\n }\n\n const next = { ...base };\n for (const [ key, Class ] of Object.entries(classes))\n {\n if (Class === null || Class === undefined)\n {\n delete next[key];\n continue;\n }\n validateClass(key, Class, readerName);\n next[key] = Class;\n }\n return next;\n}\n\n/**\n * Merge format values over a base set and validate them.\n *\n * @param {object} base Current values.\n * @param {object} [options] Values to merge in.\n * @param {string} [readerName] Reader name used in error messages.\n * @returns {object} A validated copy of the merged values.\n */\nexport function normalizeValues(base, options = {}, readerName = \"CjsHlslFormat\")\n{\n if (!options || typeof options !== \"object\")\n {\n throw new TypeError(`${readerName}: options must be an object`);\n }\n for (const key of Object.keys(options))\n {\n if (!OPTION_KEYS.has(key))\n {\n throw new TypeError(`${readerName}: unknown option ${JSON.stringify(key)}`);\n }\n }\n\n const values = { ...base, ...options };\n\n if (!VALID_EMITS.has(values.emit))\n {\n throw new TypeError(`${readerName}: emit must be one of ${Array.from(VALID_EMITS, (emit) => JSON.stringify(emit)).join(\", \")}, got ${JSON.stringify(values.emit)}`);\n }\n if (typeof values.source !== \"string\" || !values.source)\n {\n values.source = DEFAULT_VALUES.source;\n }\n values.classes = Object.prototype.hasOwnProperty.call(options, \"classes\")\n ? mergeClasses(base.classes || {}, options.classes, readerName)\n : { ...(base.classes || {}) };\n\n return {\n emit: values.emit,\n source: values.source,\n permutation: values.permutation ?? null,\n classes: values.classes\n };\n}\n\n/**\n * Normalize caller input into a Uint8Array of Tr2 effect bytes.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate payload.\n * @returns {Uint8Array} The payload bytes.\n */\nexport function toBytes(input)\n{\n if (input instanceof Uint8Array) return input;\n if (typeof ArrayBuffer !== \"undefined\" && input instanceof ArrayBuffer) return new Uint8Array(input);\n if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n throw new TypeError(\"CjsHlslFormat: input must be Tr2 effect bytes (Uint8Array, Buffer, DataView or ArrayBuffer)\");\n}\n\n/**\n * The shared read path used by the instance Read, Inspect, and the static\n * one-shots: normalizes input bytes and loads a HlslEffectRes graph. This is\n * internal parsing machinery — the documented public contract is the plain\n * JSON shape produced by {@link readWithValues}, not this raw graph.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.\n * @param {object} values Normalized format values.\n * @returns {HlslEffectRes} The loaded effect resource graph.\n */\nexport function readRaw(input, values)\n{\n const bytes = toBytes(input);\n const effect = new HlslEffectRes();\n const ok = effect.DoLoad(bytes, { source: values.source });\n\n if (!ok)\n {\n throw new HlslEffectReadError(\n effect.loadError ? effect.loadError.message : \"Failed to read Tr2 effect resource\",\n {\n source: values.source,\n cause: effect.loadError || null\n }\n );\n }\n\n return effect;\n}\n\n/**\n * Resolves one permutation's HlslShader from a loaded effect, tolerating\n * bodies that fail to decode (returns null instead of throwing).\n *\n * @param {HlslEffectRes} effect Loaded effect resource graph.\n * @param {object} values Normalized format values.\n * @returns {object|null} Resolved HlslShader, or null.\n */\nfunction resolveShader(effect, values)\n{\n try\n {\n return effect.GetShader(values.permutation || []);\n }\n catch\n {\n return null;\n }\n}\n\n/**\n * Shared read entry honouring the emit mode.\n *\n * `emit: \"raw\"` returns the live HlslEffectRes instance — internal,\n * unstable, and not schema-guaranteed across versions. `emit: \"json\"`\n * (the default) returns the documented plain-data effect graph, honouring\n * `values.classes`.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.\n * @param {object} values Normalized format values.\n * @returns {HlslEffectRes|object} The raw HlslEffectRes instance, or the documented JSON graph.\n */\nexport function readWithValues(input, values)\n{\n const effect = readRaw(input, values);\n if (values.emit === OUTPUT_RAW) return effect;\n\n const shader = resolveShader(effect, values);\n if (values.emit === OUTPUT_METADATA)\n {\n const selection = resolveSelectedOptions(effect, values.permutation || []);\n return emitEffectMetadata(effect, shader, selection);\n }\n\n return emitEffectJson(effect, shader, { classes: values.classes });\n}\n\n/**\n * Cheap inspection: effect header facts plus the default permutation's\n * technique names and stage counts, without a full JSON conversion of the\n * decoded graph.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Tr2 effect payload.\n * @param {object} values Normalized format values.\n * @returns {object} Plain summary data.\n */\nexport function inspectWithValues(input, values)\n{\n const effect = readRaw(input, values);\n\n const summary = {\n source: values.source,\n version: effect.m_version,\n compilerVersion: effect.m_compilerVersion,\n isGood: effect.IsGood(),\n permutationCount: effect.m_permutations.length,\n bodyCount: effect.m_offsetCount,\n effectName: null,\n techniques: []\n };\n\n try\n {\n const shader = effect.GetShader(values.permutation || []);\n if (shader)\n {\n const description = shader.GetEffectDescription();\n summary.effectName = description.effectName || null;\n summary.techniques = description.techniques.map((technique) => ({\n name: technique.name,\n passCount: technique.passes.length,\n stageCounts: technique.passes.map(\n (pass) => pass.stageInputs.filter((stage) => stage && stage.m_exists).length\n )\n }));\n }\n }\n catch (error)\n {\n summary.inspectError = { name: error.name, message: error.message };\n }\n\n return summary;\n}\n\n/**\n * Deep-convert a value to plain JSON-compatible data. Typed arrays become\n * plain number arrays; Maps/Sets become objects/arrays; class instances\n * with toJSON are honoured.\n *\n * @param {any} value Value to convert.\n * @returns {any} Plain data.\n */\nexport function toJsonValue(value)\n{\n if (value === null || value === undefined) return value ?? null;\n if (typeof value === \"number\" || typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"bigint\") return value.toString();\n if (ArrayBuffer.isView(value)) return Array.from(value);\n if (Array.isArray(value)) return value.map(toJsonValue);\n if (value instanceof Map)\n {\n const out = {};\n for (const [ key, entry ] of value) out[key] = toJsonValue(entry);\n return out;\n }\n if (value instanceof Set) return Array.from(value, toJsonValue);\n if (typeof value === \"object\")\n {\n if (typeof value.toJSON === \"function\") return toJsonValue(value.toJSON());\n const out = {};\n for (const key of Object.keys(value)) out[key] = toJsonValue(value[key]);\n return out;\n }\n return null;\n}\n\nexport { HlslEffectReadError };\nexport { CLASS_KEYS };\n"],"names":["OUTPUT_JSON","OUTPUT_RAW","OUTPUT_METADATA","DEFAULT_VALUES","Object","freeze","emit","source","permutation","classes","VALID_EMITS","Set","OPTION_KEYS","validateClassKey","key","readerName","CLASS_KEYS","includes","Error","JSON","stringify","join","validateClass","Class","TypeError","mergeClasses","base","next","entries","undefined","normalizeValues","options","keys","has","values","Array","from","prototype","hasOwnProperty","call","toBytes","input","Uint8Array","ArrayBuffer","isView","buffer","byteOffset","byteLength","readRaw","bytes","effect","HlslEffectRes","ok","DoLoad","HlslEffectReadError","loadError","message","cause","resolveShader","GetShader","readWithValues","shader","selection","resolveSelectedOptions","emitEffectMetadata","emitEffectJson","inspectWithValues","summary","version","m_version","compilerVersion","m_compilerVersion","isGood","IsGood","permutationCount","m_permutations","length","bodyCount","m_offsetCount","effectName","techniques","description","GetEffectDescription","map","technique","name","passCount","passes","stageCounts","pass","stageInputs","filter","stage","m_exists","error","inspectError","toJsonValue","value","toString","isArray","Map","out","entry","toJSON"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUO,MAAMA,WAAW,GAAG;AACpB,MAAMC,UAAU,GAAG;AACnB,MAAMC,eAAe,GAAG;MAElBC,cAAc,GAAGC,MAAM,CAACC,MAAM,CAAC;AACxCC,EAAAA,IAAI,EAAEN,WAAW;AACjBO,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,WAAW,EAAE,IAAI;AACjBC,EAAAA,OAAO,EAAEL,MAAM,CAACC,MAAM,CAAC,EAAE;AAC7B,CAAC;AAED,MAAMK,WAAW,GAAG,IAAIC,GAAG,CAAC,CAAEX,WAAW,EAAEC,UAAU,EAAEC,eAAe,CAAE,CAAC;AACzE,MAAMU,WAAW,GAAG,IAAID,GAAG,CAAC,CAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,CAAE,CAAC;;AAE3E;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAACC,GAAG,EAAEC,UAAU,GAAG,eAAe,EAClE;AACI,EAAA,IAAI,CAACC,UAAU,CAACC,QAAQ,CAACH,GAAG,CAAC,EAC7B;IACI,MAAM,IAAII,KAAK,CAAC,CAAA,EAAGH,UAAU,CAAA,oBAAA,EAAuBI,IAAI,CAACC,SAAS,CAACN,GAAG,CAAC,CAAA,kBAAA,EAAqBE,UAAU,CAACK,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AACxH,EAAA;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAACR,GAAG,EAAES,KAAK,EAAER,UAAU,GAAG,eAAe,EACtE;AACIF,EAAAA,gBA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@ -0,0 +1,284 @@
1
+ import { hlslShaderStageName } from './tr2/HlslRenderContextEnum.js';
2
+
3
+ /**
4
+ * Tr2 effect JSON emitter.
5
+ *
6
+ * Converts the internal HlslEffectRes/HlslShader graph (src/core/tr2, internal
7
+ * parsing machinery — not part of this package's public surface) into the
8
+ * plain, documented JSON shape that IS the public contract of this reader.
9
+ *
10
+ * `emitEffectJson(effect, shader, options)` returns a plain object whose key
11
+ * order mirrors the reader schema below. When `options.classes` is given,
12
+ * matching node kinds are instantiated and populated as class instances
13
+ * instead of plain object literals — an opt-in alternative to walking the
14
+ * returned JSON into application-specific classes by hand.
15
+ */
16
+
17
+
18
+ /**
19
+ * Node keys accepted by {@link emitEffectJson}'s `options.classes` map.
20
+ *
21
+ * Each key names one node shape in the emitted effect graph; the mapped
22
+ * constructor is instantiated with `new` and populated with that node's
23
+ * usual fields instead of a plain object literal.
24
+ *
25
+ * This is a first-pass hydration surface: it covers the top-level effect
26
+ * graph (the header, the default-permutation effect description, its
27
+ * techniques/passes/stage inputs, and per-stage constants/resources/
28
+ * samplers/bytecode). Nested detail that has no dedicated class key yet
29
+ * (shader libraries, parameter annotations, pipeline-input/register
30
+ * signatures) is still emitted as plain, JSON-compatible data.
31
+ */
32
+ const CLASS_KEYS = Object.freeze(["Root", "Permutation", "EffectDescription", "Technique", "Pass", "StageInput", "Constant", "Resource", "Sampler", "ShaderBytecode"]);
33
+
34
+ /**
35
+ * Instantiate and populate a node class, or return the plain props unchanged.
36
+ *
37
+ * @param {object} classes Opt-in node class map.
38
+ * @param {string} key Node key to look up in `classes`.
39
+ * @param {object} props Fields to populate onto the instance.
40
+ * @returns {object} A populated class instance, or `props` when no
41
+ * constructor is registered for `key`.
42
+ */
43
+ function build(classes, key, props) {
44
+ const Ctor = classes[key];
45
+ return Ctor ? Object.assign(new Ctor(), props) : props;
46
+ }
47
+
48
+ /**
49
+ * Emit one HlslShaderPermutation node.
50
+ *
51
+ * @param {object} permutation Decoded permutation axis.
52
+ * @param {object} classes Opt-in node class map.
53
+ * @returns {object} Emitted permutation record.
54
+ */
55
+ function emitPermutation(permutation, classes) {
56
+ return build(classes, "Permutation", {
57
+ name: permutation.name,
58
+ options: permutation.options.slice(),
59
+ defaultOption: permutation.defaultOption,
60
+ description: permutation.description,
61
+ type: permutation.type
62
+ });
63
+ }
64
+
65
+ /**
66
+ * Emit one HlslShaderBytecode node. Bytes are included as a plain number
67
+ * array (opaque payload; this package does not decode DXBC/HLSL bytecode).
68
+ *
69
+ * @param {object|null} bytecode Captured shader bytecode, or null.
70
+ * @param {object} classes Opt-in node class map.
71
+ * @returns {object|null} Emitted bytecode record, or null.
72
+ */
73
+ function emitShaderBytecode(bytecode, classes) {
74
+ if (!bytecode) return null;
75
+ return build(classes, "ShaderBytecode", {
76
+ stageType: bytecode.stageType,
77
+ stageName: bytecode.stageName,
78
+ shaderSize: bytecode.shaderSize,
79
+ stringTableOffset: bytecode.stringTableOffset,
80
+ effectName: bytecode.effectName,
81
+ bytes: Array.from(bytecode.bytes)
82
+ });
83
+ }
84
+
85
+ /**
86
+ * Emit one HlslEffectConstant node.
87
+ *
88
+ * @param {object} constant Decoded constant-buffer field metadata.
89
+ * @param {object} classes Opt-in node class map.
90
+ * @returns {object} Emitted constant record.
91
+ */
92
+ function emitConstant(constant, classes) {
93
+ return build(classes, "Constant", {
94
+ name: constant.name,
95
+ offset: constant.offset,
96
+ size: constant.size,
97
+ type: constant.type,
98
+ dimension: constant.dimension,
99
+ elements: constant.elements,
100
+ isSRGB: constant.isSRGB,
101
+ isAutoregister: constant.isAutoregister
102
+ });
103
+ }
104
+
105
+ /**
106
+ * Emit one HlslEffectResource (SRV or UAV) node.
107
+ *
108
+ * @param {number} registerIndex Shader register index.
109
+ * @param {object} resource Decoded resource metadata.
110
+ * @param {object} classes Opt-in node class map.
111
+ * @returns {object} Emitted resource record.
112
+ */
113
+ function emitResource(registerIndex, resource, classes) {
114
+ return build(classes, "Resource", {
115
+ registerIndex,
116
+ name: resource.name,
117
+ type: resource.type,
118
+ arrayElements: resource.arrayElements,
119
+ isSRGB: resource.isSRGB,
120
+ isAutoregister: resource.isAutoregister
121
+ });
122
+ }
123
+
124
+ /**
125
+ * Emit one HlslSamplerSetup node.
126
+ *
127
+ * @param {number} registerIndex Shader register index.
128
+ * @param {object} samplerSetup Decoded sampler setup (name + descriptor).
129
+ * @param {object} classes Opt-in node class map.
130
+ * @returns {object} Emitted sampler record.
131
+ */
132
+ function emitSampler(registerIndex, samplerSetup, classes) {
133
+ const sampler = samplerSetup.sampler || {};
134
+ return build(classes, "Sampler", {
135
+ registerIndex,
136
+ name: samplerSetup.name,
137
+ isDynamic: !!sampler.isDynamic,
138
+ comparison: !!sampler.comparison,
139
+ minFilter: sampler.minFilter,
140
+ magFilter: sampler.magFilter,
141
+ mipFilter: sampler.mipFilter,
142
+ addressU: sampler.addressU,
143
+ addressV: sampler.addressV,
144
+ addressW: sampler.addressW,
145
+ mipLODBias: sampler.mipLODBias,
146
+ maxAnisotropy: sampler.maxAnisotropy,
147
+ comparisonFunc: sampler.comparisonFunc,
148
+ borderColor: (sampler.borderColor || []).slice(),
149
+ minLOD: sampler.minLOD,
150
+ maxLOD: sampler.maxLOD
151
+ });
152
+ }
153
+
154
+ /**
155
+ * Emit one HlslEffectStageInput node, or null for stages absent from a pass.
156
+ *
157
+ * @param {object|undefined} stageInput Decoded stage input, if present.
158
+ * @param {number} stageType Trinity shader stage enum value.
159
+ * @param {object} classes Opt-in node class map.
160
+ * @returns {object|null} Emitted stage-input record, or null.
161
+ */
162
+ function emitStageInput(stageInput, stageType, classes) {
163
+ if (!stageInput || !stageInput.m_exists) return null;
164
+ const signature = stageInput.signature || {};
165
+ return build(classes, "StageInput", {
166
+ stageType,
167
+ stageName: hlslShaderStageName(stageType),
168
+ constants: (stageInput.constants || []).map(constant => emitConstant(constant, classes)),
169
+ resources: Array.from(stageInput.resources || [], ([registerIndex, resource]) => emitResource(registerIndex, resource, classes)),
170
+ samplers: Array.from(stageInput.samplers || [], ([registerIndex, sampler]) => emitSampler(registerIndex, sampler, classes)),
171
+ uavs: Array.from(stageInput.uavs || [], ([registerIndex, resource]) => emitResource(registerIndex, resource, classes)),
172
+ bytecode: emitShaderBytecode(stageInput.cjsShaderBytecode, classes),
173
+ signature: {
174
+ pipelineInputs: (signature.pipelineInputs || []).map(entry => ({
175
+ ...entry
176
+ })),
177
+ registers: (signature.registers || []).map(entry => ({
178
+ ...entry
179
+ })),
180
+ threadGroupSize: signature.threadGroupSize ? {
181
+ ...signature.threadGroupSize
182
+ } : null
183
+ }
184
+ });
185
+ }
186
+
187
+ /**
188
+ * Emit one HlslPass node.
189
+ *
190
+ * @param {object} pass Decoded technique pass.
191
+ * @param {object} classes Opt-in node class map.
192
+ * @returns {object} Emitted pass record.
193
+ */
194
+ function emitPass(pass, classes) {
195
+ return build(classes, "Pass", {
196
+ shaderTypeMask: pass.shaderTypeMask,
197
+ stageInputs: pass.stageInputs.map((stageInput, stageType) => emitStageInput(stageInput, stageType, classes)),
198
+ renderStates: pass.cjsRenderStateSetup ? pass.cjsRenderStateSetup.toJSON() : []
199
+ });
200
+ }
201
+
202
+ /**
203
+ * Emit one HlslEffectTechnique node.
204
+ *
205
+ * @param {object} technique Decoded technique.
206
+ * @param {object} classes Opt-in node class map.
207
+ * @returns {object} Emitted technique record.
208
+ */
209
+ function emitTechnique(technique, classes) {
210
+ return build(classes, "Technique", {
211
+ name: technique.name,
212
+ shaderTypeMask: technique.shaderTypeMask,
213
+ passes: technique.passes.map(pass => emitPass(pass, classes)),
214
+ // Shader-library (v14+ ray tracing) metadata has no dedicated class
215
+ // key yet; emitted as plain, JSON-compatible data.
216
+ libraries: technique.libraries.map(library => library?.toJSON?.() ?? library)
217
+ });
218
+ }
219
+
220
+ /**
221
+ * Serializes a map of parameter names to annotation arrays as plain data.
222
+ *
223
+ * @param {Map<string, object[]>} annotations Annotation map.
224
+ * @returns {object[]} JSON-safe annotation groups.
225
+ */
226
+ function emitAnnotations(annotations) {
227
+ return Array.from(annotations.entries(), ([name, entries]) => ({
228
+ name,
229
+ annotations: entries.map(entry => entry?.toJSON?.() ?? entry)
230
+ }));
231
+ }
232
+
233
+ /**
234
+ * Emit one HlslEffectDescription node: one resolved permutation's decoded
235
+ * techniques, passes, and stage metadata.
236
+ *
237
+ * @param {object} description Decoded effect description (`HlslShader.GetEffectDescription()`).
238
+ * @param {object} classes Opt-in node class map.
239
+ * @returns {object} Emitted effect-description record.
240
+ */
241
+ function emitEffectDescription(description, classes) {
242
+ return build(classes, "EffectDescription", {
243
+ version: description.version,
244
+ effectName: description.effectName,
245
+ techniques: description.techniques.map(technique => emitTechnique(technique, classes)),
246
+ annotations: emitAnnotations(description.annotations),
247
+ readError: description.readError ? {
248
+ name: description.readError.name,
249
+ message: description.readError.message
250
+ } : null
251
+ });
252
+ }
253
+
254
+ /**
255
+ * Convert a loaded HlslEffectRes (and, when resolvable, its default- or
256
+ * selected-permutation HlslShader) into the documented plain JSON shape.
257
+ *
258
+ * @param {object} effect Loaded HlslEffectRes instance.
259
+ * @param {object|null} shader Resolved HlslShader for one permutation, or null.
260
+ * @param {object} [options] Emission options.
261
+ * @param {object} [options.classes] Opt-in node class map. See {@link CLASS_KEYS}.
262
+ * @returns {object} Plain JSON-compatible effect graph, or a populated
263
+ * `classes.Root` instance when provided.
264
+ */
265
+ function emitEffectJson(effect, shader, options = {}) {
266
+ const {
267
+ classes = {}
268
+ } = options;
269
+ return build(classes, "Root", {
270
+ version: effect.m_version,
271
+ compilerVersion: effect.m_compilerVersion,
272
+ sourcePath: effect.sourcePath,
273
+ bodyCount: effect.m_offsetCount,
274
+ permutations: effect.m_permutations.map(permutation => emitPermutation(permutation, classes)),
275
+ effect: shader ? emitEffectDescription(shader.GetEffectDescription(), classes) : null,
276
+ loadError: effect.loadError ? {
277
+ name: effect.loadError.name,
278
+ message: effect.loadError.message
279
+ } : null
280
+ });
281
+ }
282
+
283
+ export { CLASS_KEYS, emitEffectJson };
284
+ //# sourceMappingURL=json.js.map