@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,221 @@
1
+ import { DEFAULT_VALUES, normalizeValues, readWithValues, inspectWithValues, buildPackage, emitGlslWithOptions, toJsonValue, isCewg, OUTPUT_JSON, OUTPUT_RAW } from './core/helpers.js';
2
+ import { buildEffectPackage } from './core/effectPackage.js';
3
+
4
+ /**
5
+ * Exposed CarbonEngineJS-facing WebGL format class.
6
+ *
7
+ * Keep this file small and reviewable: CEWG container parsing lives under
8
+ * src/core/cewg (internal parsing machinery, not part of this package's
9
+ * public surface); the DXBC-to-GLSL ES 3.00 emitter lives under
10
+ * src/core/glsl; input/option normalization and the shared read/build/emit
11
+ * paths live in src/core/helpers.js.
12
+ */
13
+
14
+ const FORMAT_NAME = "CjsWebglFormat";
15
+
16
+ /**
17
+ * CarbonEngineJS-facing format surface for `.cewg` WebGL shader packages, and
18
+ * a DXBC -> GLSL ES 3.00 emitter for the WebGL2 vertex/pixel/map-style-compute
19
+ * stages ccpwgl targets.
20
+ *
21
+ * The Cjs prefix marks this as a JavaScript format/construction boundary.
22
+ * CEWG is a CarbonEngineJS-invented container format (flat four-byte-tagged
23
+ * chunks: `INFO`/`META`/`GLSL`/...), not a Microsoft or CCP one. `Read`
24
+ * parses a package to plain JSON by default (`emit: "raw"` exposes the live
25
+ * `CewgPackage` instance instead); `Inspect` is a cheap chunk/shader-count
26
+ * summary; `Build` assembles package bytes from chunk payloads; `EmitGlsl`
27
+ * translates one DXBC vertex/pixel/map-style-compute stage to GLSL ES 3.00.
28
+ */
29
+ class CjsWebglFormat {
30
+ #emit = DEFAULT_VALUES.emit;
31
+ #source = DEFAULT_VALUES.source;
32
+
33
+ /**
34
+ * Create a reusable format profile.
35
+ *
36
+ * @param {object} [options] Default format values.
37
+ */
38
+ constructor(options = {}) {
39
+ this.SetValues(options);
40
+ }
41
+
42
+ /**
43
+ * Set format values for this reusable profile.
44
+ *
45
+ * @param {object} [options] Values to merge into the profile.
46
+ * @returns {CjsWebglFormat} This format profile.
47
+ */
48
+ SetValues(options = {}) {
49
+ const values = normalizeValues(this.GetValues(), options, FORMAT_NAME);
50
+ this.#emit = values.emit;
51
+ this.#source = values.source;
52
+ return this;
53
+ }
54
+
55
+ /**
56
+ * Get this profile's current values, optionally with per-call overrides.
57
+ *
58
+ * @param {object} [options] Optional values to merge into a copy.
59
+ * @returns {object} A copy of the effective values.
60
+ */
61
+ GetValues(options = {}) {
62
+ return normalizeValues({
63
+ emit: this.#emit,
64
+ source: this.#source
65
+ }, options, FORMAT_NAME);
66
+ }
67
+
68
+ /**
69
+ * Read a CEWG package with this profile's values.
70
+ *
71
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.
72
+ * @param {object} [options] Per-call value overrides.
73
+ * @returns {object} Plain JSON data, or the raw CewgPackage instance when emit is "raw".
74
+ */
75
+ Read(input, options = {}) {
76
+ return readWithValues(input, this.GetValues(options));
77
+ }
78
+
79
+ /**
80
+ * Inspect a CEWG package without building the full JSON shape.
81
+ *
82
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.
83
+ * @param {object} [options] Per-call value overrides.
84
+ * @returns {object} Plain summary data.
85
+ */
86
+ Inspect(input, options = {}) {
87
+ return inspectWithValues(input, this.GetValues(options));
88
+ }
89
+
90
+ /**
91
+ * Assembles a CEWG package from ordered chunk payloads.
92
+ *
93
+ * @param {Array<[string, string|object|Uint8Array|ArrayBuffer|ArrayBufferView]>} chunks Ordered package chunks.
94
+ * @returns {Uint8Array} Package bytes.
95
+ */
96
+ Build(chunks) {
97
+ return buildPackage(chunks);
98
+ }
99
+
100
+ /**
101
+ * Translates one DXBC vertex/pixel/map-style-compute stage into GLSL ES 3.00.
102
+ *
103
+ * @param {ArrayBuffer|ArrayBufferView|Uint8Array} dxbcBytes DXBC container bytes.
104
+ * @param {object} [options] Combined ccpwgl-profile/emit options. See {@link CjsWebglFormat.emitGlsl}.
105
+ * @returns {object} GLSL text plus the IO contract the packaging layer records.
106
+ */
107
+ EmitGlsl(dxbcBytes, options = {}) {
108
+ return emitGlslWithOptions(dxbcBytes, options);
109
+ }
110
+
111
+ /**
112
+ * Builds a complete CEWG package from compiled Tr2 effect bytes.
113
+ *
114
+ * @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.
115
+ * @param {object} [options] Selection, provenance, and emitter policy.
116
+ * @returns {object} Package bytes plus inspection and qualification records.
117
+ */
118
+ BuildEffect(input, options = {}) {
119
+ return buildEffectPackage(input, options);
120
+ }
121
+
122
+ /**
123
+ * Instance JSON-compatible conversion.
124
+ *
125
+ * @param {any} value Format output to convert.
126
+ * @returns {any} Plain JSON-compatible data.
127
+ */
128
+ ToJSON(value) {
129
+ return toJsonValue(value);
130
+ }
131
+
132
+ /**
133
+ * Static payload sniff. Static methods use camelCase by convention.
134
+ *
135
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate bytes.
136
+ * @returns {boolean} True when the payload starts with the CEWG magic.
137
+ */
138
+ static isCewg(input) {
139
+ return isCewg(input);
140
+ }
141
+
142
+ /**
143
+ * Static one-shot read.
144
+ *
145
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.
146
+ * @param {object} [options] Format values.
147
+ * @returns {object} Plain JSON data, or the raw CewgPackage instance when emit is "raw".
148
+ */
149
+ static read(input, options = {}) {
150
+ return readWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));
151
+ }
152
+
153
+ /**
154
+ * Static one-shot inspection.
155
+ *
156
+ * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.
157
+ * @param {object} [options] Format values.
158
+ * @returns {object} Plain summary data.
159
+ */
160
+ static inspect(input, options = {}) {
161
+ return inspectWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));
162
+ }
163
+
164
+ /**
165
+ * Static one-shot package build.
166
+ *
167
+ * @param {Array<[string, string|object|Uint8Array|ArrayBuffer|ArrayBufferView]>} chunks Ordered package chunks.
168
+ * @returns {Uint8Array} Package bytes.
169
+ */
170
+ static build(chunks) {
171
+ return buildPackage(chunks);
172
+ }
173
+
174
+ /**
175
+ * Static one-shot DXBC-to-GLSL emission.
176
+ *
177
+ * @param {ArrayBuffer|ArrayBufferView|Uint8Array} dxbcBytes DXBC container bytes.
178
+ * @param {object} [options] Combined ccpwgl-profile/emit options: `constantBufferStyle`
179
+ * (`"array"` (default) uniform `vec4[]` for ccpwgl's uniform4fv path, or `"std140"`),
180
+ * `pixelConstantBufferRemap` (default `{ 0: 7 }`, pixel-stage cb slot renames),
181
+ * `samplerName(register, stageName)` (naming function), `vertexStructuredCapacity`
182
+ * (default 69, bone-array element capacity), `dataTextureWidth` (default 2048),
183
+ * `pairVaryings` (per-call varying zero-fill list), `source` (per-call error-detail name).
184
+ * @returns {object} GLSL text plus the IO contract the packaging layer records.
185
+ */
186
+ static emitGlsl(dxbcBytes, options = {}) {
187
+ return emitGlslWithOptions(dxbcBytes, options);
188
+ }
189
+
190
+ /**
191
+ * Static whole-effect CEWG builder.
192
+ *
193
+ * @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.
194
+ * @param {object} [options] Selection, provenance, and emitter policy.
195
+ * @returns {object} Package bytes plus inspection and qualification records.
196
+ */
197
+ static buildEffect(input, options = {}) {
198
+ return buildEffectPackage(input, options);
199
+ }
200
+
201
+ /**
202
+ * Static JSON-compatible conversion.
203
+ *
204
+ * @param {any} value Format output to convert.
205
+ * @returns {any} Plain JSON-compatible data.
206
+ */
207
+ static toJSON(value) {
208
+ return toJsonValue(value);
209
+ }
210
+ static OUTPUT_JSON = OUTPUT_JSON;
211
+ static OUTPUT_RAW = OUTPUT_RAW;
212
+ static type = Object.freeze(["shader"]);
213
+ static mediaTypes = Object.freeze(["shader"]);
214
+ static inputTypes = Object.freeze(["cewg"]);
215
+ static outputTypes = Object.freeze([OUTPUT_JSON]);
216
+ static debugOutputTypes = Object.freeze([OUTPUT_RAW]);
217
+ static packageVersion = "0.2.0";
218
+ }
219
+
220
+ export { CjsWebglFormat, CjsWebglFormat as default };
221
+ //# sourceMappingURL=CjsWebglFormat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CjsWebglFormat.js","sources":["../../../../src/formats/webgl/CjsWebglFormat.js"],"sourcesContent":["/**\n * Exposed CarbonEngineJS-facing WebGL format class.\n *\n * Keep this file small and reviewable: CEWG container parsing lives under\n * src/core/cewg (internal parsing machinery, not part of this package's\n * public surface); the DXBC-to-GLSL ES 3.00 emitter lives under\n * src/core/glsl; input/option normalization and the shared read/build/emit\n * paths live in src/core/helpers.js.\n */\n\nimport {\n DEFAULT_VALUES,\n OUTPUT_JSON,\n OUTPUT_RAW,\n buildPackage,\n emitGlslWithOptions,\n inspectWithValues,\n isCewg,\n normalizeValues,\n readWithValues,\n toJsonValue\n} from \"./core/helpers.js\";\nimport { buildEffectPackage } from \"./core/effectPackage.js\";\n\nconst FORMAT_NAME = \"CjsWebglFormat\";\n\n/**\n * CarbonEngineJS-facing format surface for `.cewg` WebGL shader packages, and\n * a DXBC -> GLSL ES 3.00 emitter for the WebGL2 vertex/pixel/map-style-compute\n * stages ccpwgl targets.\n *\n * The Cjs prefix marks this as a JavaScript format/construction boundary.\n * CEWG is a CarbonEngineJS-invented container format (flat four-byte-tagged\n * chunks: `INFO`/`META`/`GLSL`/...), not a Microsoft or CCP one. `Read`\n * parses a package to plain JSON by default (`emit: \"raw\"` exposes the live\n * `CewgPackage` instance instead); `Inspect` is a cheap chunk/shader-count\n * summary; `Build` assembles package bytes from chunk payloads; `EmitGlsl`\n * translates one DXBC vertex/pixel/map-style-compute stage to GLSL ES 3.00.\n */\nexport class CjsWebglFormat\n{\n\n #emit = DEFAULT_VALUES.emit;\n #source = DEFAULT_VALUES.source;\n\n /**\n * Create a reusable format profile.\n *\n * @param {object} [options] Default format values.\n */\n constructor(options = {})\n {\n this.SetValues(options);\n }\n\n /**\n * Set format values for this reusable profile.\n *\n * @param {object} [options] Values to merge into the profile.\n * @returns {CjsWebglFormat} This format profile.\n */\n SetValues(options = {})\n {\n const values = normalizeValues(this.GetValues(), options, FORMAT_NAME);\n\n this.#emit = values.emit;\n this.#source = values.source;\n\n return this;\n }\n\n /**\n * Get this profile's current values, optionally with per-call overrides.\n *\n * @param {object} [options] Optional values to merge into a copy.\n * @returns {object} A copy of the effective values.\n */\n GetValues(options = {})\n {\n return normalizeValues({\n emit: this.#emit,\n source: this.#source\n }, options, FORMAT_NAME);\n }\n\n /**\n * Read a CEWG package with this profile's values.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Plain JSON data, or the raw CewgPackage instance when emit is \"raw\".\n */\n Read(input, options = {})\n {\n return readWithValues(input, this.GetValues(options));\n }\n\n /**\n * Inspect a CEWG package without building the full JSON shape.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.\n * @param {object} [options] Per-call value overrides.\n * @returns {object} Plain summary data.\n */\n Inspect(input, options = {})\n {\n return inspectWithValues(input, this.GetValues(options));\n }\n\n /**\n * Assembles a CEWG package from ordered chunk payloads.\n *\n * @param {Array<[string, string|object|Uint8Array|ArrayBuffer|ArrayBufferView]>} chunks Ordered package chunks.\n * @returns {Uint8Array} Package bytes.\n */\n Build(chunks)\n {\n return buildPackage(chunks);\n }\n\n /**\n * Translates one DXBC vertex/pixel/map-style-compute stage into GLSL ES 3.00.\n *\n * @param {ArrayBuffer|ArrayBufferView|Uint8Array} dxbcBytes DXBC container bytes.\n * @param {object} [options] Combined ccpwgl-profile/emit options. See {@link CjsWebglFormat.emitGlsl}.\n * @returns {object} GLSL text plus the IO contract the packaging layer records.\n */\n EmitGlsl(dxbcBytes, options = {})\n {\n return emitGlslWithOptions(dxbcBytes, options);\n }\n\n /**\n * Builds a complete CEWG package from compiled Tr2 effect bytes.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.\n * @param {object} [options] Selection, provenance, and emitter policy.\n * @returns {object} Package bytes plus inspection and qualification records.\n */\n BuildEffect(input, options = {})\n {\n return buildEffectPackage(input, options);\n }\n\n /**\n * Instance JSON-compatible conversion.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n ToJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Static payload sniff. Static methods use camelCase by convention.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input Candidate bytes.\n * @returns {boolean} True when the payload starts with the CEWG magic.\n */\n static isCewg(input)\n {\n return isCewg(input);\n }\n\n /**\n * Static one-shot read.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.\n * @param {object} [options] Format values.\n * @returns {object} Plain JSON data, or the raw CewgPackage instance when emit is \"raw\".\n */\n static read(input, options = {})\n {\n return readWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\n }\n\n /**\n * Static one-shot inspection.\n *\n * @param {Uint8Array|ArrayBuffer|Buffer|DataView} input CEWG package bytes.\n * @param {object} [options] Format values.\n * @returns {object} Plain summary data.\n */\n static inspect(input, options = {})\n {\n return inspectWithValues(input, normalizeValues(DEFAULT_VALUES, options, FORMAT_NAME));\n }\n\n /**\n * Static one-shot package build.\n *\n * @param {Array<[string, string|object|Uint8Array|ArrayBuffer|ArrayBufferView]>} chunks Ordered package chunks.\n * @returns {Uint8Array} Package bytes.\n */\n static build(chunks)\n {\n return buildPackage(chunks);\n }\n\n /**\n * Static one-shot DXBC-to-GLSL emission.\n *\n * @param {ArrayBuffer|ArrayBufferView|Uint8Array} dxbcBytes DXBC container bytes.\n * @param {object} [options] Combined ccpwgl-profile/emit options: `constantBufferStyle`\n * (`\"array\"` (default) uniform `vec4[]` for ccpwgl's uniform4fv path, or `\"std140\"`),\n * `pixelConstantBufferRemap` (default `{ 0: 7 }`, pixel-stage cb slot renames),\n * `samplerName(register, stageName)` (naming function), `vertexStructuredCapacity`\n * (default 69, bone-array element capacity), `dataTextureWidth` (default 2048),\n * `pairVaryings` (per-call varying zero-fill list), `source` (per-call error-detail name).\n * @returns {object} GLSL text plus the IO contract the packaging layer records.\n */\n static emitGlsl(dxbcBytes, options = {})\n {\n return emitGlslWithOptions(dxbcBytes, options);\n }\n\n /**\n * Static whole-effect CEWG builder.\n *\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView} input Compiled effect bytes.\n * @param {object} [options] Selection, provenance, and emitter policy.\n * @returns {object} Package bytes plus inspection and qualification records.\n */\n static buildEffect(input, options = {})\n {\n return buildEffectPackage(input, options);\n }\n\n /**\n * Static JSON-compatible conversion.\n *\n * @param {any} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n static toJSON(value)\n {\n return toJsonValue(value);\n }\n\n static OUTPUT_JSON = OUTPUT_JSON;\n static OUTPUT_RAW = OUTPUT_RAW;\n static type = Object.freeze([ \"shader\" ]);\n static mediaTypes = Object.freeze([ \"shader\" ]);\n static inputTypes = Object.freeze([ \"cewg\" ]);\n static outputTypes = Object.freeze([ OUTPUT_JSON ]);\n static debugOutputTypes = Object.freeze([ OUTPUT_RAW ]);\n static packageVersion = \"0.2.0\";\n\n}\n\nexport default CjsWebglFormat;\n"],"names":["FORMAT_NAME","CjsWebglFormat","DEFAULT_VALUES","emit","source","constructor","options","SetValues","values","normalizeValues","GetValues","Read","input","readWithValues","Inspect","inspectWithValues","Build","chunks","buildPackage","EmitGlsl","dxbcBytes","emitGlslWithOptions","BuildEffect","buildEffectPackage","ToJSON","value","toJsonValue","isCewg","read","inspect","build","emitGlsl","buildEffect","toJSON","OUTPUT_JSON","OUTPUT_RAW","type","Object","freeze","mediaTypes","inputTypes","outputTypes","debugOutputTypes","packageVersion"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA,MAAMA,WAAW,GAAG,gBAAgB;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,cAAc,CAC3B;AAEI,EAAA,KAAK,GAAGC,cAAc,CAACC,IAAI;AAC3B,EAAA,OAAO,GAAGD,cAAc,CAACE,MAAM;;AAE/B;AACJ;AACA;AACA;AACA;AACIC,EAAAA,WAAWA,CAACC,OAAO,GAAG,EAAE,EACxB;AACI,IAAA,IAAI,CAACC,SAAS,CAACD,OAAO,CAAC;AAC3B,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACA;AACIC,EAAAA,SAASA,CAACD,OAAO,GAAG,EAAE,E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ACX,KAAK,EAAEN,OAAO,CAAC;AAC7C,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACA;EACI,OAAO2B,MAAMA,CAACR,KAAK,EACnB;IACI,OAAOC,WAAW,CAACD,KAAK,CAAC;AAC7B,EAAA;EAEA,OAAOS,WAAW,GAAGA,WAAW;EAChC,OAAOC,UAAU,GAAGA,UAAU;EAC9B,OAAOC,IAAI,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAE,QAAQ,CAAE,CAAC;EACzC,OAAOC,UAAU,GAAGF,MAAM,CAACC,MAAM,CAAC,CAAE,QAAQ,CAAE,CAAC;EAC/C,OAAOE,UAAU,GAAGH,MAAM,CAACC,MAAM,CAAC,CAAE,MAAM,CAAE,CAAC;EAC7C,OAAOG,WAAW,GAAGJ,MAAM,CAACC,MAAM,CAAC,CAAEJ,WAAW,CAAE,CAAC;EACnD,OAAOQ,gBAAgB,GAAGL,MAAM,CAACC,MAAM,CAAC,CAAEH,UAAU,CAAE,CAAC;EACvD,OAAOQ,cAAc,GAAG,OAAO;AAEnC;;;;"}
@@ -0,0 +1,339 @@
1
+ import { asUint8Array, WebglReader } from './binary.js';
2
+ import { sha256Bytes } from '../../../../format/effect/sha256.js';
3
+ import { hydrateEffectReflectionForPermutation } from '../../../../format/effect/effectReflectionPackage.js';
4
+
5
+ const CEWG_MAGIC = "CEWG";
6
+ const CEWG_FORMAT = "CEWG";
7
+ const CEWG_VERSION = 1;
8
+ const textDecoder = new TextDecoder("utf-8", {
9
+ fatal: false
10
+ });
11
+ const jsonTextDecoder = new TextDecoder("utf-8", {
12
+ fatal: true
13
+ });
14
+ const validatedEffectReflectionPackages = new WeakSet();
15
+
16
+ /**
17
+ * Reader for CarbonEngineJS CEWG shader packages emitted by `hlsl2webgl`.
18
+ */
19
+ class CewgPackage {
20
+ /**
21
+ * Creates an empty package reader.
22
+ */
23
+ constructor() {
24
+ this.version = 0;
25
+ this.chunks = [];
26
+ this.chunkMap = new Map();
27
+ this.jsonCache = new Map();
28
+ this.reflectionBlobIndex = null;
29
+ this.readError = null;
30
+ this.sourcePath = "";
31
+ }
32
+
33
+ /**
34
+ * Reads a CEWG package from bytes.
35
+ *
36
+ * @param {ArrayBuffer|ArrayBufferView|Uint8Array} source CEWG binary bytes.
37
+ * @param {object} [options] Read options.
38
+ * @param {string} [options.sourcePath] Source path for diagnostics.
39
+ * @returns {boolean} True when the package was decoded.
40
+ */
41
+ Read(source, options = {}) {
42
+ validatedEffectReflectionPackages.delete(this);
43
+ this.version = 0;
44
+ this.chunks = [];
45
+ this.chunkMap = new Map();
46
+ this.jsonCache = new Map();
47
+ this.reflectionBlobIndex = null;
48
+ this.readError = null;
49
+ this.sourcePath = options.sourcePath || "";
50
+ try {
51
+ const bytes = asUint8Array(source);
52
+ const stream = new WebglReader(bytes, {
53
+ source: this.sourcePath || "CEWG"
54
+ });
55
+ const magic = decodeAscii(stream.readRaw(CEWG_MAGIC.length));
56
+ if (magic !== CEWG_MAGIC) {
57
+ throw new Error(`Invalid CEWG magic "${magic}"`);
58
+ }
59
+ this.version = stream.readUint32();
60
+ if (this.version !== CEWG_VERSION) {
61
+ throw new Error(`Unsupported CEWG version ${this.version}`);
62
+ }
63
+ const chunkCount = stream.readUint32();
64
+ for (let index = 0; index < chunkCount; index += 1) {
65
+ const tag = decodeAscii(stream.readRaw(4));
66
+ validateChunkTag(tag);
67
+ if (this.chunkMap.has(tag)) {
68
+ throw new Error(`CEWG package contains duplicate chunk tag ${tag}`);
69
+ }
70
+ const size = stream.readUint32();
71
+ const offset = stream.offset;
72
+ const chunkBytes = stream.readRaw(size);
73
+ const chunk = {
74
+ tag,
75
+ size,
76
+ offset,
77
+ bytes: chunkBytes
78
+ };
79
+ this.chunks.push(chunk);
80
+ this.chunkMap.set(tag, chunk);
81
+ }
82
+ if (stream.remaining !== 0) {
83
+ throw new Error(`CEWG package has ${stream.remaining} trailing bytes`);
84
+ }
85
+ return true;
86
+ } catch (error) {
87
+ this.readError = error;
88
+ this.chunks = [];
89
+ this.chunkMap = new Map();
90
+ this.jsonCache = new Map();
91
+ this.reflectionBlobIndex = null;
92
+ return false;
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Reports whether the package decoded successfully.
98
+ *
99
+ * @returns {boolean} True when no read error is present.
100
+ */
101
+ IsGood() {
102
+ return !this.readError && this.version === CEWG_VERSION;
103
+ }
104
+
105
+ /**
106
+ * Gets a chunk by four-character tag.
107
+ *
108
+ * @param {string} tag Chunk tag.
109
+ * @returns {{tag:string,size:number,offset:number,bytes:Uint8Array}|null} Chunk record.
110
+ */
111
+ GetChunk(tag) {
112
+ return this.chunkMap.get(tag) || null;
113
+ }
114
+
115
+ /**
116
+ * Decodes a text chunk.
117
+ *
118
+ * @param {string} tag Chunk tag.
119
+ * @returns {string|null} Decoded text, or null when absent.
120
+ */
121
+ GetText(tag) {
122
+ const chunk = this.GetChunk(tag);
123
+ return chunk ? textDecoder.decode(chunk.bytes) : null;
124
+ }
125
+
126
+ /**
127
+ * Decodes a JSON chunk.
128
+ *
129
+ * @param {string} tag Chunk tag.
130
+ * @returns {object|null} Parsed JSON, or null when absent.
131
+ */
132
+ GetJson(tag) {
133
+ return cloneJson(getCachedJson(this, tag));
134
+ }
135
+
136
+ /**
137
+ * Gets translator summary metadata from the `INFO` chunk.
138
+ *
139
+ * @returns {object|null} Info JSON.
140
+ */
141
+ get info() {
142
+ return this.GetJson("INFO");
143
+ }
144
+
145
+ /**
146
+ * Gets caller-provided Carbon metadata from the `META` chunk.
147
+ *
148
+ * @returns {object|null} Metadata JSON.
149
+ */
150
+ get metadata() {
151
+ return this.GetJson("META");
152
+ }
153
+
154
+ /**
155
+ * Gets the complete source permutation graph when present.
156
+ *
157
+ * @returns {object|null} Parsed permutation graph.
158
+ */
159
+ get permutationGraph() {
160
+ return this.GetJson("PGRF");
161
+ }
162
+
163
+ /**
164
+ * Gets complete source effect reflection when present.
165
+ *
166
+ * @returns {object|null} Parsed reflection document.
167
+ */
168
+ get reflection() {
169
+ return this.GetJson("RFLX");
170
+ }
171
+
172
+ /**
173
+ * Gets the raw reflection blob store when present.
174
+ *
175
+ * @returns {Uint8Array|null} RBLB bytes.
176
+ */
177
+ get reflectionBlobBytes() {
178
+ return this.GetChunk("RBLB")?.bytes ?? null;
179
+ }
180
+
181
+ /**
182
+ * Copies one reflected byte payload by blob key or exact reference.
183
+ *
184
+ * @param {string|object} value Blob key or exact RFLX byte-reference object.
185
+ * @returns {Uint8Array|null} Owned payload bytes, or null when unavailable.
186
+ */
187
+ GetReflectionBlob(value) {
188
+ const key = typeof value === "string" ? value : value?.blobKey;
189
+ if (!this.reflectionBlobIndex) {
190
+ this.reflectionBlobIndex = new Map((getCachedJson(this, "RFLX")?.blobStore?.blobs ?? []).map(entry => [entry.blobKey, entry]));
191
+ }
192
+ const entry = this.reflectionBlobIndex.get(key);
193
+ const bytes = this.reflectionBlobBytes;
194
+ if (!entry || !bytes) return null;
195
+ if (typeof value !== "string" && (!value || value.offset !== entry.offset || value.byteLength !== entry.byteLength || value.sha256 !== entry.sha256)) {
196
+ return null;
197
+ }
198
+ const end = entry.offset + entry.byteLength;
199
+ if (!Number.isSafeInteger(entry.offset) || entry.offset < 0 || !Number.isSafeInteger(entry.byteLength) || entry.byteLength < 0 || end > bytes.byteLength || sha256Bytes(bytes.subarray(entry.offset, end)) !== entry.sha256) {
200
+ return null;
201
+ }
202
+ return Uint8Array.from(bytes.subarray(entry.offset, end));
203
+ }
204
+
205
+ /**
206
+ * Gets fully hydrated portable source reflection for one permutation.
207
+ *
208
+ * Every reflected byte field is returned as a fresh owned `Uint8Array`.
209
+ *
210
+ * @param {number} [permutationIndex] Exact PGRF permutation index.
211
+ * @returns {object|null} Validated portable reflection, or null when absent.
212
+ */
213
+ GetPortableEffectReflection(permutationIndex) {
214
+ if (!validatedEffectReflectionPackages.has(this)) return null;
215
+ const reflection = getCachedJson(this, "RFLX");
216
+ const permutationGraph = getCachedJson(this, "PGRF");
217
+ if (!reflection || !permutationGraph) return null;
218
+ const selectedIndex = permutationIndex ?? getCachedJson(this, "INFO")?.defaultPermutationIndex ?? 0;
219
+ return hydrateEffectReflectionForPermutation(reflection, permutationGraph, selectedIndex, reference => this.GetReflectionBlob(reference));
220
+ }
221
+
222
+ /**
223
+ * Gets translated GLSL source from the `GLSL` chunk.
224
+ *
225
+ * @returns {string|null} GLSL source.
226
+ */
227
+ get glsl() {
228
+ return this.GetText("GLSL");
229
+ }
230
+
231
+ /**
232
+ * Gets translated GLSL metadata when the `GLSL` chunk contains JSON.
233
+ *
234
+ * Whole-effect packages store a JSON stage set in this chunk; single-stage
235
+ * packages store raw GLSL text and return null here.
236
+ *
237
+ * @returns {object|null} Parsed GLSL stage set, or null for raw source.
238
+ */
239
+ get glslJson() {
240
+ try {
241
+ return this.GetJson("GLSL");
242
+ } catch {
243
+ return null;
244
+ }
245
+ }
246
+
247
+ /**
248
+ * Gets original DXBC bytes when present.
249
+ *
250
+ * @returns {Uint8Array|null} DXBC bytes.
251
+ */
252
+ get dxbc() {
253
+ return this.GetChunk("DXBC")?.bytes || null;
254
+ }
255
+
256
+ /**
257
+ * Returns a JSON-safe package summary.
258
+ *
259
+ * @returns {object} Serializable summary.
260
+ */
261
+ toJSON() {
262
+ return {
263
+ format: CEWG_FORMAT,
264
+ version: this.version,
265
+ sourcePath: this.sourcePath,
266
+ chunks: this.chunks.map(chunk => ({
267
+ tag: chunk.tag,
268
+ size: chunk.size,
269
+ offset: chunk.offset
270
+ })),
271
+ readError: this.readError ? {
272
+ name: this.readError.name,
273
+ message: this.readError.message
274
+ } : null
275
+ };
276
+ }
277
+ }
278
+
279
+ /**
280
+ * Marks one package as having passed the canonical v3 reflection envelope.
281
+ *
282
+ * This is intentionally an internal deep import rather than package-root API.
283
+ *
284
+ * @param {CewgPackage} pkg Validated package reader.
285
+ * @returns {void}
286
+ */
287
+ function markEffectReflectionValidated(pkg) {
288
+ validatedEffectReflectionPackages.add(pkg);
289
+ }
290
+
291
+ /**
292
+ * Decode and cache one private JSON document.
293
+ *
294
+ * @param {CewgPackage} pkg Package reader.
295
+ * @param {string} tag Chunk tag.
296
+ * @returns {object|null} Private parsed JSON, or null when absent.
297
+ */
298
+ function getCachedJson(pkg, tag) {
299
+ if (!pkg.jsonCache.has(tag)) {
300
+ const chunk = pkg.GetChunk(tag);
301
+ pkg.jsonCache.set(tag, chunk ? JSON.parse(jsonTextDecoder.decode(chunk.bytes)) : null);
302
+ }
303
+ return pkg.jsonCache.get(tag);
304
+ }
305
+
306
+ /**
307
+ * Copy JSON-compatible data without reparsing its source chunk.
308
+ *
309
+ * @param {any} value Cached JSON value.
310
+ * @returns {any} Structurally independent JSON value.
311
+ */
312
+ function cloneJson(value) {
313
+ if (Array.isArray(value)) return value.map(cloneJson);
314
+ if (value && typeof value === "object") {
315
+ return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, cloneJson(entry)]));
316
+ }
317
+ return value;
318
+ }
319
+ function validateChunkTag(tag) {
320
+ if (typeof tag !== "string" || tag.length !== 4 || [...tag].some(character => {
321
+ const code = character.charCodeAt(0);
322
+ return code < 0x21 || code > 0x7e;
323
+ })) {
324
+ throw new Error(`Invalid CEWG chunk tag ${JSON.stringify(tag)}`);
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Decodes an ASCII four-character code.
330
+ *
331
+ * @param {Uint8Array} bytes Four-byte tag payload.
332
+ * @returns {string} ASCII string.
333
+ */
334
+ function decodeAscii(bytes) {
335
+ return String.fromCharCode(...bytes);
336
+ }
337
+
338
+ export { CewgPackage, markEffectReflectionValidated };
339
+ //# sourceMappingURL=CewgPackage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CewgPackage.js","sources":["../../../../../../src/formats/webgl/core/cewg/CewgPackage.js"],"sourcesContent":["import { WebglReader, asUint8Array } from \"./binary.js\";\nimport { sha256Bytes } from \"../../../../format/effect/sha256.js\";\nimport {\n hydrateEffectReflectionForPermutation\n} from \"../../../../format/effect/effectReflectionPackage.js\";\n\nconst CEWG_MAGIC = \"CEWG\";\nconst CEWG_FORMAT = \"CEWG\";\nconst CEWG_VERSION = 1;\nconst textDecoder = new TextDecoder(\"utf-8\", { fatal: false });\nconst jsonTextDecoder = new TextDecoder(\"utf-8\", { fatal: true });\nconst validatedEffectReflectionPackages = new WeakSet();\n\n/**\n * Reader for CarbonEngineJS CEWG shader packages emitted by `hlsl2webgl`.\n */\nexport class CewgPackage\n{\n /**\n * Creates an empty package reader.\n */\n constructor()\n {\n this.version = 0;\n this.chunks = [];\n this.chunkMap = new Map();\n this.jsonCache = new Map();\n this.reflectionBlobIndex = null;\n this.readError = null;\n this.sourcePath = \"\";\n }\n\n /**\n * Reads a CEWG package from bytes.\n *\n * @param {ArrayBuffer|ArrayBufferView|Uint8Array} source CEWG binary bytes.\n * @param {object} [options] Read options.\n * @param {string} [options.sourcePath] Source path for diagnostics.\n * @returns {boolean} True when the package was decoded.\n */\n Read(source, options = {})\n {\n validatedEffectReflectionPackages.delete(this);\n this.version = 0;\n this.chunks = [];\n this.chunkMap = new Map();\n this.jsonCache = new Map();\n this.reflectionBlobIndex = null;\n this.readError = null;\n this.sourcePath = options.sourcePath || \"\";\n\n try\n {\n const bytes = asUint8Array(source);\n const stream = new WebglReader(bytes, { source: this.sourcePath || \"CEWG\" });\n const magic = decodeAscii(stream.readRaw(CEWG_MAGIC.length));\n if (magic !== CEWG_MAGIC)\n {\n throw new Error(`Invalid CEWG magic \"${magic}\"`);\n }\n\n this.version = stream.readUint32();\n if (this.version !== CEWG_VERSION)\n {\n throw new Error(`Unsupported CEWG version ${this.version}`);\n }\n\n const chunkCount = stream.readUint32();\n for (let index = 0; index < chunkCount; index += 1)\n {\n const tag = decodeAscii(stream.readRaw(4));\n validateChunkTag(tag);\n if (this.chunkMap.has(tag))\n {\n throw new Error(`CEWG package contains duplicate chunk tag ${tag}`);\n }\n const size = stream.readUint32();\n const offset = stream.offset;\n const chunkBytes = stream.readRaw(size);\n const chunk = {\n tag,\n size,\n offset,\n bytes: chunkBytes\n };\n this.chunks.push(chunk);\n this.chunkMap.set(tag, chunk);\n }\n\n if (stream.remaining !== 0)\n {\n throw new Error(`CEWG package has ${stream.remaining} trailing bytes`);\n }\n\n return true;\n }\n catch (error)\n {\n this.readError = error;\n this.chunks = [];\n this.chunkMap = new Map();\n this.jsonCache = new Map();\n this.reflectionBlobIndex = null;\n return false;\n }\n }\n\n /**\n * Reports whether the package decoded successfully.\n *\n * @returns {boolean} True when no read error is present.\n */\n IsGood()\n {\n return !this.readError && this.version === CEWG_VERSION;\n }\n\n /**\n * Gets a chunk by four-character tag.\n *\n * @param {string} tag Chunk tag.\n * @returns {{tag:string,size:number,offset:number,bytes:Uint8Array}|null} Chunk record.\n */\n GetChunk(tag)\n {\n return this.chunkMap.get(tag) || null;\n }\n\n /**\n * Decodes a text chunk.\n *\n * @param {string} tag Chunk tag.\n * @returns {string|null} Decoded text, or null when absent.\n */\n GetText(tag)\n {\n const chunk = this.GetChunk(tag);\n return chunk ? textDecoder.decode(chunk.bytes) : null;\n }\n\n /**\n * Decodes a JSON chunk.\n *\n * @param {string} tag Chunk tag.\n * @returns {object|null} Parsed JSON, or null when absent.\n */\n GetJson(tag)\n {\n return cloneJson(getCachedJson(this, tag));\n }\n\n /**\n * Gets translator summary metadata from the `INFO` chunk.\n *\n * @returns {object|null} Info JSON.\n */\n get info()\n {\n return this.GetJson(\"INFO\");\n }\n\n /**\n * Gets caller-provided Carbon metadata from the `META` chunk.\n *\n * @returns {object|null} Metadata JSON.\n */\n get metadata()\n {\n return this.GetJson(\"META\");\n }\n\n /**\n * Gets the complete source permutation graph when present.\n *\n * @returns {object|null} Parsed permutation graph.\n */\n get permutationGraph()\n {\n return this.GetJson(\"PGRF\");\n }\n\n /**\n * Gets complete source effect reflection when present.\n *\n * @returns {object|null} Parsed reflection document.\n */\n get reflection()\n {\n return this.GetJson(\"RFLX\");\n }\n\n /**\n * Gets the raw reflection blob store when present.\n *\n * @returns {Uint8Array|null} RBLB bytes.\n */\n get reflectionBlobBytes()\n {\n return this.GetChunk(\"RBLB\")?.bytes ?? null;\n }\n\n /**\n * Copies one reflected byte payload by blob key or exact reference.\n *\n * @param {string|object} value Blob key or exact RFLX byte-reference object.\n * @returns {Uint8Array|null} Owned payload bytes, or null when unavailable.\n */\n GetReflectionBlob(value)\n {\n const key = typeof value === \"string\" ? value : value?.blobKey;\n if (!this.reflectionBlobIndex)\n {\n this.reflectionBlobIndex = new Map(\n (getCachedJson(this, \"RFLX\")?.blobStore?.blobs ?? []).map((entry) => [\n entry.blobKey,\n entry\n ])\n );\n }\n const entry = this.reflectionBlobIndex.get(key);\n const bytes = this.reflectionBlobBytes;\n if (!entry || !bytes) return null;\n if (typeof value !== \"string\"\n && (!value\n || value.offset !== entry.offset\n || value.byteLength !== entry.byteLength\n || value.sha256 !== entry.sha256))\n {\n return null;\n }\n const end = entry.offset + entry.byteLength;\n if (!Number.isSafeInteger(entry.offset) || entry.offset < 0\n || !Number.isSafeInteger(entry.byteLength) || entry.byteLength < 0\n || end > bytes.byteLength\n || sha256Bytes(bytes.subarray(entry.offset, end)) !== entry.sha256)\n {\n return null;\n }\n return Uint8Array.from(bytes.subarray(entry.offset, end));\n }\n\n /**\n * Gets fully hydrated portable source reflection for one permutation.\n *\n * Every reflected byte field is returned as a fresh owned `Uint8Array`.\n *\n * @param {number} [permutationIndex] Exact PGRF permutation index.\n * @returns {object|null} Validated portable reflection, or null when absent.\n */\n GetPortableEffectReflection(permutationIndex)\n {\n if (!validatedEffectReflectionPackages.has(this)) return null;\n const reflection = getCachedJson(this, \"RFLX\");\n const permutationGraph = getCachedJson(this, \"PGRF\");\n if (!reflection || !permutationGraph) return null;\n const selectedIndex = permutationIndex\n ?? getCachedJson(this, \"INFO\")?.defaultPermutationIndex\n ?? 0;\n return hydrateEffectReflectionForPermutation(\n reflection,\n permutationGraph,\n selectedIndex,\n (reference) => this.GetReflectionBlob(reference)\n );\n }\n\n /**\n * Gets translated GLSL source from the `GLSL` chunk.\n *\n * @returns {string|null} GLSL source.\n */\n get glsl()\n {\n return this.GetText(\"GLSL\");\n }\n\n /**\n * Gets translated GLSL metadata when the `GLSL` chunk contains JSON.\n *\n * Whole-effect packages store a JSON stage set in this chunk; single-stage\n * packages store raw GLSL text and return null here.\n *\n * @returns {object|null} Parsed GLSL stage set, or null for raw source.\n */\n get glslJson()\n {\n try\n {\n return this.GetJson(\"GLSL\");\n }\n catch\n {\n return null;\n }\n }\n\n /**\n * Gets original DXBC bytes when present.\n *\n * @returns {Uint8Array|null} DXBC bytes.\n */\n get dxbc()\n {\n return this.GetChunk(\"DXBC\")?.bytes || null;\n }\n\n /**\n * Returns a JSON-safe package summary.\n *\n * @returns {object} Serializable summary.\n */\n toJSON()\n {\n return {\n format: CEWG_FORMAT,\n version: this.version,\n sourcePath: this.sourcePath,\n chunks: this.chunks.map((chunk) => ({\n tag: chunk.tag,\n size: chunk.size,\n offset: chunk.offset\n })),\n readError: this.readError ? {\n name: this.readError.name,\n message: this.readError.message\n } : null\n };\n }\n}\n\n/**\n * Marks one package as having passed the canonical v3 reflection envelope.\n *\n * This is intentionally an internal deep import rather than package-root API.\n *\n * @param {CewgPackage} pkg Validated package reader.\n * @returns {void}\n */\nexport function markEffectReflectionValidated(pkg)\n{\n validatedEffectReflectionPackages.add(pkg);\n}\n\n/**\n * Decode and cache one private JSON document.\n *\n * @param {CewgPackage} pkg Package reader.\n * @param {string} tag Chunk tag.\n * @returns {object|null} Private parsed JSON, or null when absent.\n */\nfunction getCachedJson(pkg, tag)\n{\n if (!pkg.jsonCache.has(tag))\n {\n const chunk = pkg.GetChunk(tag);\n pkg.jsonCache.set(\n tag,\n chunk ? JSON.parse(jsonTextDecoder.decode(chunk.bytes)) : null\n );\n }\n return pkg.jsonCache.get(tag);\n}\n\n/**\n * Copy JSON-compatible data without reparsing its source chunk.\n *\n * @param {any} value Cached JSON value.\n * @returns {any} Structurally independent JSON value.\n */\nfunction cloneJson(value)\n{\n if (Array.isArray(value)) return value.map(cloneJson);\n if (value && typeof value === \"object\")\n {\n return Object.fromEntries(Object.entries(value).map(([ key, entry ]) => [\n key,\n cloneJson(entry)\n ]));\n }\n return value;\n}\n\nfunction validateChunkTag(tag)\n{\n if (typeof tag !== \"string\"\n || tag.length !== 4\n || [ ...tag ].some((character) =>\n {\n const code = character.charCodeAt(0);\n return code < 0x21 || code > 0x7e;\n }))\n {\n throw new Error(`Invalid CEWG chunk tag ${JSON.stringify(tag)}`);\n }\n}\n\n/**\n * Decodes an ASCII four-character code.\n *\n * @param {Uint8Array} bytes Four-byte tag payload.\n * @returns {string} ASCII string.\n */\nfunction decodeAscii(bytes)\n{\n return String.fromCharCode(...bytes);\n}\n"],"names":["CEWG_MAGIC","CEWG_FORMAT","CEWG_VERSION","textDecoder","TextDecoder","fatal","jsonTextDecoder","validatedEffectReflectionPackages","WeakSet","CewgPackage","constructor","version","chunks","chunkMap","Map","jsonCache","reflectionBlobIndex","readError","sourcePath","Read","source","options","delete","bytes","asUint8Array","stream","WebglReader","magic","decodeAscii","readRaw","length","Error","readUint32","chunkCount","index","tag","validateChunkTag","has","size","offset","chunkBytes","chunk","push","set","remaining","error","IsGood","GetChunk","get","GetText","decode","GetJson","cloneJson","getCachedJson","info","metadata","permutationGraph","reflection","reflectionBlobBytes","GetReflectionBlob","value","key","blobKey","blobStore","blobs","map","entry","byteLength","sha256","end","Number","isSafeInteger","sha256Bytes","subarray","Uint8Array","from","GetPortableEffectReflection","permutationIndex","selectedIndex","defaultPermutationIndex","hydrateEffectReflectionForPermutation","reference","glsl","glslJson","dxbc","toJSON","format","name","message","markEffectReflectionValidated","pkg","add","JSON","parse","Array","isArray","Object","fromEntries","entries","some","character","code","charCodeAt","stringify","String","fromCharCode"],"mappings":";;;;AAMA,MAAMA,UAAU,GAAG,MAAM;AACzB,MAAMC,WAAW,GAAG,MAAM;AAC1B,MAAMC,YAAY,GAAG,CAAC;AACtB,MAAMC,WAAW,GAAG,IAAIC,WAAW,CAAC,OAAO,EAAE;AAAEC,EAAAA,KAAK,EAAE;A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