@carbonenginejs/runtime-resource 0.1.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 (372) hide show
  1. package/FORMAT-PROVENANCE.md +135 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE +29 -0
  4. package/README.md +241 -0
  5. package/dist/CjsMotherLode.js +56 -0
  6. package/dist/CjsMotherLode.js.map +1 -0
  7. package/dist/CjsResMan.js +740 -0
  8. package/dist/CjsResMan.js.map +1 -0
  9. package/dist/CjsResManQueue.js +214 -0
  10. package/dist/CjsResManQueue.js.map +1 -0
  11. package/dist/CjsResource.js +366 -0
  12. package/dist/CjsResource.js.map +1 -0
  13. package/dist/CjsResourceSource.js +59 -0
  14. package/dist/CjsResourceSource.js.map +1 -0
  15. package/dist/_virtual/_rollupPluginBabelHelpers.js +153 -0
  16. package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  17. package/dist/format/CjsFormat.js +178 -0
  18. package/dist/format/CjsFormat.js.map +1 -0
  19. package/dist/format/CjsResourceProbe.js +269 -0
  20. package/dist/format/CjsResourceProbe.js.map +1 -0
  21. package/dist/format/payloadContract.js +173 -0
  22. package/dist/format/payloadContract.js.map +1 -0
  23. package/dist/formats/black/CjsBlackFormat.js +272 -0
  24. package/dist/formats/black/CjsBlackFormat.js.map +1 -0
  25. package/dist/formats/black/core/CjsBlackBinaryReader.js +153 -0
  26. package/dist/formats/black/core/CjsBlackBinaryReader.js.map +1 -0
  27. package/dist/formats/black/core/CjsBlackPropertyReaders.js +382 -0
  28. package/dist/formats/black/core/CjsBlackPropertyReaders.js.map +1 -0
  29. package/dist/formats/black/core/CjsBlackReader.js +760 -0
  30. package/dist/formats/black/core/CjsBlackReader.js.map +1 -0
  31. package/dist/formats/black/core/CjsBlackSchemaRegistry.js +433 -0
  32. package/dist/formats/black/core/CjsBlackSchemaRegistry.js.map +1 -0
  33. package/dist/formats/black/core/black-schema-v1-2026-07-11.json.js +4 -0
  34. package/dist/formats/black/core/black-schema-v1-2026-07-11.json.js.map +1 -0
  35. package/dist/formats/black/core/blackConstants.js +7 -0
  36. package/dist/formats/black/core/blackConstants.js.map +1 -0
  37. package/dist/formats/black/core/blackDefinitions.js +10 -0
  38. package/dist/formats/black/core/blackDefinitions.js.map +1 -0
  39. package/dist/formats/black/core/blackEnums.js +6 -0
  40. package/dist/formats/black/core/blackEnums.js.map +1 -0
  41. package/dist/formats/black/core/blackSchema.js +3 -0
  42. package/dist/formats/black/core/blackSchema.js.map +1 -0
  43. package/dist/formats/black/core/blackVersion.js +22 -0
  44. package/dist/formats/black/core/blackVersion.js.map +1 -0
  45. package/dist/formats/black/core/helpers.js +182 -0
  46. package/dist/formats/black/core/helpers.js.map +1 -0
  47. package/dist/formats/black/core/schema.js +4 -0
  48. package/dist/formats/black/core/schema.js.map +1 -0
  49. package/dist/formats/black/index.js +2 -0
  50. package/dist/formats/black/index.js.map +1 -0
  51. package/dist/formats/bnk/CjsBnkFormat.js +245 -0
  52. package/dist/formats/bnk/CjsBnkFormat.js.map +1 -0
  53. package/dist/formats/bnk/core/helpers.js +354 -0
  54. package/dist/formats/bnk/core/helpers.js.map +1 -0
  55. package/dist/formats/bnk/core/soundbanksInfo.js +246 -0
  56. package/dist/formats/bnk/core/soundbanksInfo.js.map +1 -0
  57. package/dist/formats/bnk/index.js +3 -0
  58. package/dist/formats/bnk/index.js.map +1 -0
  59. package/dist/formats/cmf/CjsCmfFormat.js +491 -0
  60. package/dist/formats/cmf/CjsCmfFormat.js.map +1 -0
  61. package/dist/formats/cmf/core/binary.js +118 -0
  62. package/dist/formats/cmf/core/binary.js.map +1 -0
  63. package/dist/formats/cmf/core/buffers.js +233 -0
  64. package/dist/formats/cmf/core/buffers.js.map +1 -0
  65. package/dist/formats/cmf/core/constants.js +47 -0
  66. package/dist/formats/cmf/core/constants.js.map +1 -0
  67. package/dist/formats/cmf/core/gr2Anim.js +453 -0
  68. package/dist/formats/cmf/core/gr2Anim.js.map +1 -0
  69. package/dist/formats/cmf/core/helpers.js +287 -0
  70. package/dist/formats/cmf/core/helpers.js.map +1 -0
  71. package/dist/formats/cmf/core/pack.js +276 -0
  72. package/dist/formats/cmf/core/pack.js.map +1 -0
  73. package/dist/formats/cmf/core/schema.js +364 -0
  74. package/dist/formats/cmf/core/schema.js.map +1 -0
  75. package/dist/formats/cmf/core/shared.js +268 -0
  76. package/dist/formats/cmf/core/shared.js.map +1 -0
  77. package/dist/formats/cmf/core/writer.js +517 -0
  78. package/dist/formats/cmf/core/writer.js.map +1 -0
  79. package/dist/formats/cmf/index.js +2 -0
  80. package/dist/formats/cmf/index.js.map +1 -0
  81. package/dist/formats/dds/CjsDdsFormat.js +187 -0
  82. package/dist/formats/dds/CjsDdsFormat.js.map +1 -0
  83. package/dist/formats/dds/core/helpers.js +812 -0
  84. package/dist/formats/dds/core/helpers.js.map +1 -0
  85. package/dist/formats/dds/index.js +2 -0
  86. package/dist/formats/dds/index.js.map +1 -0
  87. package/dist/formats/fbx/CjsFbxFormat.js +260 -0
  88. package/dist/formats/fbx/CjsFbxFormat.js.map +1 -0
  89. package/dist/formats/fbx/core/helpers.js +3901 -0
  90. package/dist/formats/fbx/core/helpers.js.map +1 -0
  91. package/dist/formats/fbx/index.js +2 -0
  92. package/dist/formats/fbx/index.js.map +1 -0
  93. package/dist/formats/flac/CjsFlacFormat.js +81 -0
  94. package/dist/formats/flac/CjsFlacFormat.js.map +1 -0
  95. package/dist/formats/flac/core/helpers.js +295 -0
  96. package/dist/formats/flac/core/helpers.js.map +1 -0
  97. package/dist/formats/flac/index.js +2 -0
  98. package/dist/formats/flac/index.js.map +1 -0
  99. package/dist/formats/gif/CjsGifFormat.js +81 -0
  100. package/dist/formats/gif/CjsGifFormat.js.map +1 -0
  101. package/dist/formats/gif/core/helpers.js +360 -0
  102. package/dist/formats/gif/core/helpers.js.map +1 -0
  103. package/dist/formats/gif/index.js +2 -0
  104. package/dist/formats/gif/index.js.map +1 -0
  105. package/dist/formats/gltf/CjsGltfFormat.js +284 -0
  106. package/dist/formats/gltf/CjsGltfFormat.js.map +1 -0
  107. package/dist/formats/gltf/core/helpers.js +292 -0
  108. package/dist/formats/gltf/core/helpers.js.map +1 -0
  109. package/dist/formats/gltf/core/json.js +79 -0
  110. package/dist/formats/gltf/core/json.js.map +1 -0
  111. package/dist/formats/gltf/core/parser.js +666 -0
  112. package/dist/formats/gltf/core/parser.js.map +1 -0
  113. package/dist/formats/gltf/core/targets.js +163 -0
  114. package/dist/formats/gltf/core/targets.js.map +1 -0
  115. package/dist/formats/gltf/index.js +2 -0
  116. package/dist/formats/gltf/index.js.map +1 -0
  117. package/dist/formats/index.js +23 -0
  118. package/dist/formats/index.js.map +1 -0
  119. package/dist/formats/jpeg/CjsJpegFormat.js +200 -0
  120. package/dist/formats/jpeg/CjsJpegFormat.js.map +1 -0
  121. package/dist/formats/jpeg/core/helpers.js +350 -0
  122. package/dist/formats/jpeg/core/helpers.js.map +1 -0
  123. package/dist/formats/jpeg/core/jpeg.js +377 -0
  124. package/dist/formats/jpeg/core/jpeg.js.map +1 -0
  125. package/dist/formats/jpeg/index.js +2 -0
  126. package/dist/formats/jpeg/index.js.map +1 -0
  127. package/dist/formats/mp3/CjsMp3Format.js +186 -0
  128. package/dist/formats/mp3/CjsMp3Format.js.map +1 -0
  129. package/dist/formats/mp3/core/helpers.js +338 -0
  130. package/dist/formats/mp3/core/helpers.js.map +1 -0
  131. package/dist/formats/mp3/index.js +2 -0
  132. package/dist/formats/mp3/index.js.map +1 -0
  133. package/dist/formats/mp4/CjsMp4Format.js +185 -0
  134. package/dist/formats/mp4/CjsMp4Format.js.map +1 -0
  135. package/dist/formats/mp4/core/helpers.js +449 -0
  136. package/dist/formats/mp4/core/helpers.js.map +1 -0
  137. package/dist/formats/mp4/index.js +2 -0
  138. package/dist/formats/mp4/index.js.map +1 -0
  139. package/dist/formats/obj/CjsObjFormat.js +247 -0
  140. package/dist/formats/obj/CjsObjFormat.js.map +1 -0
  141. package/dist/formats/obj/core/helpers.js +573 -0
  142. package/dist/formats/obj/core/helpers.js.map +1 -0
  143. package/dist/formats/obj/core/json.js +64 -0
  144. package/dist/formats/obj/core/json.js.map +1 -0
  145. package/dist/formats/obj/core/parser.js +321 -0
  146. package/dist/formats/obj/core/parser.js.map +1 -0
  147. package/dist/formats/obj/index.js +2 -0
  148. package/dist/formats/obj/index.js.map +1 -0
  149. package/dist/formats/ogg/CjsOggFormat.js +82 -0
  150. package/dist/formats/ogg/CjsOggFormat.js.map +1 -0
  151. package/dist/formats/ogg/core/helpers.js +387 -0
  152. package/dist/formats/ogg/core/helpers.js.map +1 -0
  153. package/dist/formats/ogg/core/imdct.js +178 -0
  154. package/dist/formats/ogg/core/imdct.js.map +1 -0
  155. package/dist/formats/ogg/core/vorbis.js +999 -0
  156. package/dist/formats/ogg/core/vorbis.js.map +1 -0
  157. package/dist/formats/ogg/index.js +2 -0
  158. package/dist/formats/ogg/index.js.map +1 -0
  159. package/dist/formats/png/CjsPngFormat.js +189 -0
  160. package/dist/formats/png/CjsPngFormat.js.map +1 -0
  161. package/dist/formats/png/core/helpers.js +583 -0
  162. package/dist/formats/png/core/helpers.js.map +1 -0
  163. package/dist/formats/png/index.js +2 -0
  164. package/dist/formats/png/index.js.map +1 -0
  165. package/dist/formats/red/CjsRedFormat.js +247 -0
  166. package/dist/formats/red/CjsRedFormat.js.map +1 -0
  167. package/dist/formats/red/core/CjsRedReader.js +201 -0
  168. package/dist/formats/red/core/CjsRedReader.js.map +1 -0
  169. package/dist/formats/red/core/blackDefinitions.js +3 -0
  170. package/dist/formats/red/core/blackDefinitions.js.map +1 -0
  171. package/dist/formats/red/core/helpers.js +136 -0
  172. package/dist/formats/red/core/helpers.js.map +1 -0
  173. package/dist/formats/red/core/redGraph.js +68 -0
  174. package/dist/formats/red/core/redGraph.js.map +1 -0
  175. package/dist/formats/red/core/schema.js +4 -0
  176. package/dist/formats/red/core/schema.js.map +1 -0
  177. package/dist/formats/red/index.js +2 -0
  178. package/dist/formats/red/index.js.map +1 -0
  179. package/dist/formats/stl/CjsStlFormat.js +304 -0
  180. package/dist/formats/stl/CjsStlFormat.js.map +1 -0
  181. package/dist/formats/stl/core/helpers.js +257 -0
  182. package/dist/formats/stl/core/helpers.js.map +1 -0
  183. package/dist/formats/stl/core/json.js +51 -0
  184. package/dist/formats/stl/core/json.js.map +1 -0
  185. package/dist/formats/stl/core/stl.js +544 -0
  186. package/dist/formats/stl/core/stl.js.map +1 -0
  187. package/dist/formats/stl/core/targets.js +163 -0
  188. package/dist/formats/stl/core/targets.js.map +1 -0
  189. package/dist/formats/stl/index.js +2 -0
  190. package/dist/formats/stl/index.js.map +1 -0
  191. package/dist/formats/tga/CjsTgaFormat.js +186 -0
  192. package/dist/formats/tga/CjsTgaFormat.js.map +1 -0
  193. package/dist/formats/tga/core/helpers.js +446 -0
  194. package/dist/formats/tga/core/helpers.js.map +1 -0
  195. package/dist/formats/tga/index.js +2 -0
  196. package/dist/formats/tga/index.js.map +1 -0
  197. package/dist/formats/wav/CjsWavFormat.js +186 -0
  198. package/dist/formats/wav/CjsWavFormat.js.map +1 -0
  199. package/dist/formats/wav/core/helpers.js +328 -0
  200. package/dist/formats/wav/core/helpers.js.map +1 -0
  201. package/dist/formats/wav/index.js +2 -0
  202. package/dist/formats/wav/index.js.map +1 -0
  203. package/dist/formats/webm/CjsWebmFormat.js +185 -0
  204. package/dist/formats/webm/CjsWebmFormat.js.map +1 -0
  205. package/dist/formats/webm/core/helpers.js +537 -0
  206. package/dist/formats/webm/core/helpers.js.map +1 -0
  207. package/dist/formats/webm/index.js +2 -0
  208. package/dist/formats/webm/index.js.map +1 -0
  209. package/dist/formats/webp/CjsWebpFormat.js +80 -0
  210. package/dist/formats/webp/CjsWebpFormat.js.map +1 -0
  211. package/dist/formats/webp/core/helpers.js +214 -0
  212. package/dist/formats/webp/core/helpers.js.map +1 -0
  213. package/dist/formats/webp/index.js +2 -0
  214. package/dist/formats/webp/index.js.map +1 -0
  215. package/dist/formats/wem/CjsWemFormat.js +197 -0
  216. package/dist/formats/wem/CjsWemFormat.js.map +1 -0
  217. package/dist/formats/wem/core/bitStream.js +259 -0
  218. package/dist/formats/wem/core/bitStream.js.map +1 -0
  219. package/dist/formats/wem/core/codebookLibrary.js +164 -0
  220. package/dist/formats/wem/core/codebookLibrary.js.map +1 -0
  221. package/dist/formats/wem/core/helpers.js +336 -0
  222. package/dist/formats/wem/core/helpers.js.map +1 -0
  223. package/dist/formats/wem/core/packedCodebooksAotuv603.js +30 -0
  224. package/dist/formats/wem/core/packedCodebooksAotuv603.js.map +1 -0
  225. package/dist/formats/wem/core/wemToOgg.js +485 -0
  226. package/dist/formats/wem/core/wemToOgg.js.map +1 -0
  227. package/dist/formats/wem/index.js +2 -0
  228. package/dist/formats/wem/index.js.map +1 -0
  229. package/dist/formats/yaml/CjsYamlFormat.js +77 -0
  230. package/dist/formats/yaml/CjsYamlFormat.js.map +1 -0
  231. package/dist/formats/yaml/core/CjsYamlReader.js +304 -0
  232. package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -0
  233. package/dist/formats/yaml/core/helpers.js +160 -0
  234. package/dist/formats/yaml/core/helpers.js.map +1 -0
  235. package/dist/formats/yaml/index.js +2 -0
  236. package/dist/formats/yaml/index.js.map +1 -0
  237. package/dist/generated/resources/AudioGeometryResData.js +47 -0
  238. package/dist/generated/resources/AudioGeometryResData.js.map +1 -0
  239. package/dist/generated/resources/CmfVertexReader.js +46 -0
  240. package/dist/generated/resources/CmfVertexReader.js.map +1 -0
  241. package/dist/generated/resources/GStateBindingCallbackData.js +31 -0
  242. package/dist/generated/resources/GStateBindingCallbackData.js.map +1 -0
  243. package/dist/generated/resources/MeshDecalData.js +37 -0
  244. package/dist/generated/resources/MeshDecalData.js.map +1 -0
  245. package/dist/generated/resources/MeshDecalLodData.js +34 -0
  246. package/dist/generated/resources/MeshDecalLodData.js.map +1 -0
  247. package/dist/generated/resources/Tr2AsyncSave.js +46 -0
  248. package/dist/generated/resources/Tr2AsyncSave.js.map +1 -0
  249. package/dist/generated/resources/Tr2CmfContents.js +37 -0
  250. package/dist/generated/resources/Tr2CmfContents.js.map +1 -0
  251. package/dist/generated/resources/Tr2GrannyIntersectionResult.js +58 -0
  252. package/dist/generated/resources/Tr2GrannyIntersectionResult.js.map +1 -0
  253. package/dist/generated/resources/Tr2LoadPrepareFence.js +37 -0
  254. package/dist/generated/resources/Tr2LoadPrepareFence.js.map +1 -0
  255. package/dist/generated/resources/Tr2MaterialArea.js +34 -0
  256. package/dist/generated/resources/Tr2MaterialArea.js.map +1 -0
  257. package/dist/generated/resources/Tr2MaterialMesh.js +31 -0
  258. package/dist/generated/resources/Tr2MaterialMesh.js.map +1 -0
  259. package/dist/generated/resources/Tr2MaterialRes.js +34 -0
  260. package/dist/generated/resources/Tr2MaterialRes.js.map +1 -0
  261. package/dist/generated/resources/Tr2ShaderPermutation.js +43 -0
  262. package/dist/generated/resources/Tr2ShaderPermutation.js.map +1 -0
  263. package/dist/generated/resources/Tr2TextureLodManager.js +60 -0
  264. package/dist/generated/resources/Tr2TextureLodManager.js.map +1 -0
  265. package/dist/generated/resources/Tr2TextureLodUpdateRequest.js +37 -0
  266. package/dist/generated/resources/Tr2TextureLodUpdateRequest.js.map +1 -0
  267. package/dist/generated/resources/Tr2TexturePackChannel.js +37 -0
  268. package/dist/generated/resources/Tr2TexturePackChannel.js.map +1 -0
  269. package/dist/generated/resources/Tr2TexturePipeline.js +44 -0
  270. package/dist/generated/resources/Tr2TexturePipeline.js.map +1 -0
  271. package/dist/generated/resources/Tr2TexturePipelineParams.js +34 -0
  272. package/dist/generated/resources/Tr2TexturePipelineParams.js.map +1 -0
  273. package/dist/generated/resources/Tr2TexturePipelineStepCompress.js +40 -0
  274. package/dist/generated/resources/Tr2TexturePipelineStepCompress.js.map +1 -0
  275. package/dist/generated/resources/Tr2TexturePipelineStepLimitSize.js +34 -0
  276. package/dist/generated/resources/Tr2TexturePipelineStepLimitSize.js.map +1 -0
  277. package/dist/generated/resources/Tr2TexturePipelineStepLoad.js +31 -0
  278. package/dist/generated/resources/Tr2TexturePipelineStepLoad.js.map +1 -0
  279. package/dist/generated/resources/Tr2TexturePipelineStepPack.js +43 -0
  280. package/dist/generated/resources/Tr2TexturePipelineStepPack.js.map +1 -0
  281. package/dist/generated/resources/TriGeometryResAreaData.js +59 -0
  282. package/dist/generated/resources/TriGeometryResAreaData.js.map +1 -0
  283. package/dist/generated/resources/TriGeometryResJointData.js +38 -0
  284. package/dist/generated/resources/TriGeometryResJointData.js.map +1 -0
  285. package/dist/generated/resources/TriGeometryResLodData.js +88 -0
  286. package/dist/generated/resources/TriGeometryResLodData.js.map +1 -0
  287. package/dist/generated/resources/TriGeometryResMeshData.js +63 -0
  288. package/dist/generated/resources/TriGeometryResMeshData.js.map +1 -0
  289. package/dist/generated/resources/TriGeometryResSkeletonData.js +34 -0
  290. package/dist/generated/resources/TriGeometryResSkeletonData.js.map +1 -0
  291. package/dist/generated/resources/TriJointBinding.js +38 -0
  292. package/dist/generated/resources/TriJointBinding.js.map +1 -0
  293. package/dist/generated/resources/TriMorphTargetGeometryConstants.js +46 -0
  294. package/dist/generated/resources/TriMorphTargetGeometryConstants.js.map +1 -0
  295. package/dist/generated/resources/TriRtGeometryConstants.js +88 -0
  296. package/dist/generated/resources/TriRtGeometryConstants.js.map +1 -0
  297. package/dist/generated/resources/enums.js +18 -0
  298. package/dist/generated/resources/enums.js.map +1 -0
  299. package/dist/generated/resources/index.js +32 -0
  300. package/dist/generated/resources/index.js.map +1 -0
  301. package/dist/index.js +52 -0
  302. package/dist/index.js.map +1 -0
  303. package/dist/resourcePath.js +18 -0
  304. package/dist/resourcePath.js.map +1 -0
  305. package/dist/resourceStates.js +9 -0
  306. package/dist/resourceStates.js.map +1 -0
  307. package/dist/resources/Tr2EffectRes.js +71 -0
  308. package/dist/resources/Tr2EffectRes.js.map +1 -0
  309. package/dist/resources/Tr2GrannyStateRes.js +44 -0
  310. package/dist/resources/Tr2GrannyStateRes.js.map +1 -0
  311. package/dist/resources/Tr2ImageRes.js +114 -0
  312. package/dist/resources/Tr2ImageRes.js.map +1 -0
  313. package/dist/resources/Tr2LightProfileRes.js +40 -0
  314. package/dist/resources/Tr2LightProfileRes.js.map +1 -0
  315. package/dist/resources/TriGeometryRes.js +216 -0
  316. package/dist/resources/TriGeometryRes.js.map +1 -0
  317. package/dist/resources/TriGrannyRes.js +43 -0
  318. package/dist/resources/TriGrannyRes.js.map +1 -0
  319. package/dist/resources/TriTextureRes.js +304 -0
  320. package/dist/resources/TriTextureRes.js.map +1 -0
  321. package/dist/resources/resourceBoundary.js +47 -0
  322. package/dist/resources/resourceBoundary.js.map +1 -0
  323. package/dist/texture/CjsTextureArrayRes.js +406 -0
  324. package/dist/texture/CjsTextureArrayRes.js.map +1 -0
  325. package/dist/texture/CjsTextureParameterProxy.js +133 -0
  326. package/dist/texture/CjsTextureParameterProxy.js.map +1 -0
  327. package/format-notices/black/LICENSE +21 -0
  328. package/format-notices/black/NOTICE +47 -0
  329. package/format-notices/bnk/LICENSE +21 -0
  330. package/format-notices/bnk/NOTICE +17 -0
  331. package/format-notices/cmf/LICENSE +21 -0
  332. package/format-notices/cmf/NOTICE +36 -0
  333. package/format-notices/dds/LICENSE +21 -0
  334. package/format-notices/dds/NOTICE +14 -0
  335. package/format-notices/fbx/LICENSE +21 -0
  336. package/format-notices/fbx/NOTICE +14 -0
  337. package/format-notices/flac/LICENSE +21 -0
  338. package/format-notices/flac/NOTICE +14 -0
  339. package/format-notices/gif/LICENSE +21 -0
  340. package/format-notices/gif/NOTICE +14 -0
  341. package/format-notices/gltf/LICENSE +21 -0
  342. package/format-notices/gltf/NOTICE +27 -0
  343. package/format-notices/jpeg/LICENSE +21 -0
  344. package/format-notices/jpeg/NOTICE +14 -0
  345. package/format-notices/mp3/LICENSE +21 -0
  346. package/format-notices/mp3/NOTICE +14 -0
  347. package/format-notices/mp4/LICENSE +21 -0
  348. package/format-notices/mp4/NOTICE +14 -0
  349. package/format-notices/obj/LICENSE +21 -0
  350. package/format-notices/obj/NOTICE +26 -0
  351. package/format-notices/ogg/LICENSE +21 -0
  352. package/format-notices/ogg/NOTICE +28 -0
  353. package/format-notices/png/LICENSE +21 -0
  354. package/format-notices/png/NOTICE +14 -0
  355. package/format-notices/red/LICENSE +21 -0
  356. package/format-notices/red/NOTICE +31 -0
  357. package/format-notices/stl/LICENSE +21 -0
  358. package/format-notices/stl/NOTICE +21 -0
  359. package/format-notices/tga/LICENSE +21 -0
  360. package/format-notices/tga/NOTICE +14 -0
  361. package/format-notices/wav/LICENSE +21 -0
  362. package/format-notices/wav/NOTICE +14 -0
  363. package/format-notices/webm/LICENSE +21 -0
  364. package/format-notices/webm/NOTICE +14 -0
  365. package/format-notices/webp/LICENSE +21 -0
  366. package/format-notices/webp/NOTICE +14 -0
  367. package/format-notices/wem/LICENSE +57 -0
  368. package/format-notices/wem/NOTICE +33 -0
  369. package/format-notices/yaml/LICENSE +21 -0
  370. package/format-notices/yaml/NOTICE +44 -0
  371. package/package.json +51 -0
  372. package/resource-lifecycle.md +487 -0
@@ -0,0 +1,487 @@
1
+ # Runtime Resource Lifecycle
2
+
3
+ This note records how Carbon/ccpwgl resource loading maps to
4
+ `runtime-resource`.
5
+
6
+ ## Carbon and ccpwgl
7
+
8
+ Carbon's resource model separates load from prepare. The source schemas expose
9
+ resource classes through `BlueAsyncRes`, and Carbon notes distinguish background
10
+ load work from main-thread/device prepare work.
11
+
12
+ ccpwgl makes that split visible in `Tw2Resource`:
13
+
14
+ ```text
15
+ NO_INIT -> REQUESTED -> LOADED -> PREPARED
16
+ ```
17
+
18
+ Additional terminal or cleanup states include `ERROR`, `UNLOADED`, and `PURGED`.
19
+
20
+ The important behavior is:
21
+
22
+ - `Tw2ResMan.LoadResource()` requests a resource.
23
+ - The raw fetch resolves.
24
+ - `Tw2Resource.OnLoaded()` marks bytes or source data as loaded.
25
+ - The resource is queued for prepare.
26
+ - The manager tick later calls `res.Prepare(data)`.
27
+ - The concrete resource calls `OnPrepared()` after prepare work succeeds.
28
+
29
+ Some ccpwgl concrete `Prepare()` implementations also create WebGL objects.
30
+ That is a historical engine/runtime coupling, not the boundary we want in
31
+ CarbonEngineJS.
32
+
33
+ ## CarbonEngineJS
34
+
35
+ `runtime-resource` owns the GPU-free half:
36
+
37
+ ```text
38
+ EMPTY -> REQUESTED/LOADING -> LOADED
39
+ ```
40
+
41
+ Engine adapters own device realization:
42
+
43
+ ```text
44
+ LOADED -> PREPARING -> PREPARED
45
+ ```
46
+
47
+ Current state meanings:
48
+
49
+ - `EMPTY`: resource identity exists, but no payload has been read.
50
+ - `REQUESTED`: the resource is waiting on a queued or shared source load.
51
+ - `LOADING`: source bytes are available and staged object preparation is active.
52
+ - `LOADED`: CPU payload or hydrated object graph exists.
53
+ - `PREPARING`: an engine adapter is realizing backend-owned resources.
54
+ - `PREPARED`: preparation completed successfully and the resource is usable.
55
+ - `FAILED`: load or prepare failed.
56
+ - `UNLOADED`: resource payload was released.
57
+ - `PURGED`: resource was purged from active ownership.
58
+
59
+ `CjsResMan.LoadObject()` now queues one deduplicated background source operation
60
+ per source/path and limits active source operations with `maxConcurrentLoads`.
61
+ After bytes arrive, object construction is split into separate main-queue
62
+ items:
63
+
64
+ ```text
65
+ read -> registered/requested prepare stage 1 -> stage 2 -> ... -> publish
66
+ ```
67
+
68
+ `maxPrepareTime` limits seconds spent starting synchronous main-queue work in
69
+ one pump, and `maxPrepareItemsPerTick` can add a count limit. Promise-returning
70
+ stages remain in flight without blocking the JavaScript event loop. Publication
71
+ moves the resource to `LOADED`, then stops. It must not mark the resource
72
+ `PREPARED` or `GOOD` unless an explicitly supplied preparation stage has
73
+ actually completed backend realization and marked it accordingly.
74
+
75
+ Named pipelines are registration/configuration, not capability policy.
76
+ `CjsLibrary` or a direct caller determines the required output and selects a
77
+ registered `preparePipeline`; `CjsResMan` executes the supplied stages without
78
+ probing device support. Per-request `prepareStages` are explicit overrides.
79
+
80
+ The Blue method names remain the public queue vocabulary: `AddToQueue`,
81
+ `CancelFromQueue`, `GetNextIdForQueue`, `PumpMainThreadQueue`, `PauseQueue`,
82
+ `ResumeQueue`, `GetPendingLoads`, and `GetPendingPrepares`. `Update()`/`Tick()`
83
+ pump queues. `Wait()` provides a method-level fence until both queues become
84
+ idle, rather than introducing a runtime fence resource.
85
+
86
+ ## CjsLibrary resource-path workflow
87
+
88
+ The normal direct resource-path flow is:
89
+
90
+ ```text
91
+ Application / runtime object
92
+ |
93
+ | requests "res:/model/ship.gr2"
94
+ | with optional per-request overrides
95
+ v
96
+ +-----------------------------------------------+
97
+ | CjsLibrary |
98
+ | |
99
+ | - starts from registered default behavior |
100
+ | - considers registered capability reports |
101
+ | - chooses requirement / emit / pipeline |
102
+ | - applies explicit request overrides |
103
+ +-----------------------------------------------+
104
+ |
105
+ | path + resolved request options
106
+ v
107
+ +-----------------------------------------------+
108
+ | CjsResMan.GetResource(path, options) |
109
+ | |
110
+ | - normalize path and extension |
111
+ | - calculate requested resource variant |
112
+ +-----------------------------------------------+
113
+ |
114
+ v
115
+ +-----------------------------------------------+
116
+ | CjsMotherLode.Lookup(path, variant) |
117
+ +-----------------------------------------------+
118
+ |
119
+ +--- cache hit ------------------------------+
120
+ | |
121
+ | reuse the CjsResource and any active |
122
+ | load/build operation |
123
+ | |
124
+ `--- cache miss -----------------------------+
125
+ | |
126
+ | resolve class from requirement |
127
+ | construct + Initialize() |
128
+ | insert into CjsMotherLode |
129
+ v |
130
+ new CjsResource -------------------------------+
131
+ |
132
+ | Ready() / GetObject()
133
+ v
134
+ +===============================================+
135
+ | BACKGROUND LOAD QUEUE |
136
+ | |
137
+ | - mark resource REQUESTED |
138
+ | - share one source operation per source/path |
139
+ | - obey maxConcurrentLoads |
140
+ | - source.Read(path) |
141
+ +===============================================+
142
+ |
143
+ | source bytes
144
+ v
145
+ +===============================================+
146
+ | MAIN PREPARE QUEUE |
147
+ | |
148
+ | every box below is a separately budgeted item |
149
+ +===============================================+
150
+ |
151
+ v
152
+ +-----------------------------------------------+
153
+ | Read stage |
154
+ | |
155
+ | registered object loader for extension? |
156
+ | yes -> call it |
157
+ | no -> resolve registered format by |
158
+ | extension + request options |
159
+ +-----------------------------------------------+
160
+ |
161
+ | plain payload / hydrated object
162
+ v
163
+ +-----------------------------------------------+
164
+ | Optional configured prepare stages |
165
+ | |
166
+ | stage 1 -> stage 2 -> ... |
167
+ | examples: normalize, convert, adapt |
168
+ +-----------------------------------------------+
169
+ |
170
+ | no configured stages skips this box
171
+ v
172
+ +-----------------------------------------------+
173
+ | Publish stage |
174
+ | |
175
+ | semantic resource -> SetPayload(payload) |
176
+ | generic resource -> resource.object = value |
177
+ +-----------------------------------------------+
178
+ |
179
+ +--- validation failure --------------------+
180
+ | |
181
+ | resource -> FAILED |
182
+ | Ready() rejects |
183
+ | |
184
+ `--- publication succeeds -----------------+
185
+ |
186
+ | resource -> LOADED
187
+ v
188
+ CjsLibrary returns
189
+ the built CjsResource/object
190
+ ```
191
+
192
+ Device realization is a separate continuation selected outside ResMan:
193
+
194
+ ```text
195
+ CjsResource LOADED
196
+ |
197
+ | selected engine adapter
198
+ v
199
+ PREPARING -> attach opaque adapter resource -> PREPARED
200
+ ```
201
+
202
+ With no named or direct prepare stages, the main queue reduces to:
203
+
204
+ ```text
205
+ extension object-loader/format read -> validate -> publish
206
+ ```
207
+
208
+ ## Texture Array Generations
209
+
210
+ `CjsTextureArrayRes` is a derived multi-source resource with an explicit
211
+ requested/prepared revision boundary:
212
+
213
+ ```text
214
+ proxy/source change
215
+ -> requested revision + dirty layer
216
+ -> one scheduled next-frame snapshot
217
+ -> consumed/in-flight request
218
+ -> adapter candidate preparation
219
+ -> guarded adapter + prepared-revision publication
220
+ ```
221
+
222
+ `ConsumeUpdateRequest()` produces an immutable snapshot and marks that revision
223
+ in flight. A current consumed revision may be completed through
224
+ `CommitPreparedAdapterRevision()`, failed through `FailUpdateRequest()`, or
225
+ returned to the queue through `RetryUpdateRequest()`. Commit-before-consume and
226
+ stale commits are rejected; rejected candidate allocations are destroyed by
227
+ default.
228
+
229
+ Publication installs the adapter allocation and prepared revision before
230
+ completion events run. The result returns the displaced allocation to the
231
+ adapter owner for post-publication destruction. A reentrant source change may
232
+ therefore request a newer revision without allowing stale completion to replace
233
+ it. The previous prepared allocation and `IsGood()` remain usable while a
234
+ replacement is pending or if replacement preparation fails.
235
+
236
+ `Ready()` is specialized for this derived resource: it resolves when the
237
+ generation requested at call time has been published, rather than delegating
238
+ to a single-source object loader. Initial preparation failure rejects it.
239
+
240
+ Logical paths and resolved sources are independent. Attaching a redirected or
241
+ LOD-specific source does not rewrite persistence. `TouchLayer()` represents an
242
+ in-place source revision, and `HandleAdapterLoss()` invalidates the complete
243
+ topology after destroying an unusable adapter allocation. Topology snapshots
244
+ report an explicit `topologyChanged` flag and contain only valid current dirty
245
+ layer indices.
246
+
247
+ ## Remaining Runtime Manager Work
248
+
249
+ The first load/prepare queue slice is implemented. `CjsResMan` and
250
+ `CjsMotherLode` still do not cover several browser/runtime concerns that
251
+ ccpwgl handles:
252
+
253
+ - prepare priority and starvation policy
254
+ - cancellation/abort propagation for work that has already started
255
+ - queue-time and stage-time telemetry
256
+ - `KeepAlive()` style active-frame updates
257
+ - automatic purge windows for inactive resources
258
+ - reload policy
259
+ - browser-aware source behavior such as fetch response type selection
260
+
261
+ ## Memory Retention and Purging
262
+
263
+ ccpwgl keeps every resource in `Tw2MotherLode` until it is explicitly cleared or
264
+ auto-purged. Each resource has:
265
+
266
+ - `activeFrame`: last frame the resource was considered in use.
267
+ - `doNotPurge`: a lock counter/flag for resources that must stay resident.
268
+ - `KeepAlive()`: updates `activeFrame` and reloads an unloaded/purged resource
269
+ if it is touched again.
270
+
271
+ The manager advances an `activeFrame` counter on a cadence, and
272
+ `Tw2MotherLode.PurgeInactive()` unloads resources whose `activeFrame` is old
273
+ enough. It then marks them purged and removes them from the cache. In ccpwgl,
274
+ `IsGood()` also calls `KeepAlive()`, so many read/check paths implicitly keep
275
+ resources resident.
276
+
277
+ That model works for ccpwgl, but CarbonEngineJS should be more explicit:
278
+
279
+ - `IsGood()`, `IsPrepared()`, and `HasLoaded()` should stay pure state checks.
280
+ - `KeepAlive()` or `Touch()` should be the explicit liveness operation.
281
+ - `Lock()` / `Unlock()` should prevent automatic purge, probably with a lock
282
+ count rather than a boolean.
283
+ - resources should track `lastUsedFrame` or `lastUsedTime`, not rely on boolean
284
+ state alone.
285
+ - `CjsMotherLode` should support purge scanning without forcing all resources to
286
+ be held forever by accidental cache references.
287
+ - `Unload()` should release engine adapter resources and optionally CPU payloads.
288
+ - `Purge()` should remove the resource from the cache after unload/cleanup.
289
+
290
+ The JS/browser split adds one more axis that ccpwgl blurs: CPU payload memory and
291
+ GPU/device memory are different budgets. A large decoded image, geometry buffer,
292
+ or shader graph can be expensive even before an engine adapter prepares it.
293
+ Runtime-resource should therefore support separate retention policy for:
294
+
295
+ - resource identity: path, extension, state, error summary, lightweight metadata.
296
+ - CPU payload: plain reader/converter objects, hydrated object graphs, decoded
297
+ typed arrays.
298
+ - adapter payload: WebGL/WebGPU textures, buffers, shader modules, pipelines.
299
+
300
+ A sane default would keep resource identity and lightweight metadata while
301
+ allowing CPU payloads and adapter payloads to be released independently. Engine
302
+ adapters should own adapter-resource destruction, but `runtime-resource` can
303
+ provide lifecycle hooks and opaque adapter slots so the adapter has a consistent
304
+ place to clean up.
305
+
306
+ ### Payload Retention Contract
307
+
308
+ Reader and converter outputs are plain transient payload objects, not resource
309
+ classes or DTO models. A payload may contain more decoded data than a particular
310
+ resource or engine adapter needs. Each concrete resource validates the fields
311
+ it requires before publishing the payload and retains the scalars and references
312
+ it needs. An adapter may retain additional references in adapter-owned state.
313
+ Referencing payload-owned typed arrays is valid and preferable to copying them
314
+ merely to change ownership.
315
+
316
+ The lifecycle treats resource residency and payload residency independently:
317
+
318
+ ```text
319
+ resource.KeepAlive()
320
+ -> renew resource/cache residency
321
+
322
+ resource.KeepPayloadAlive()
323
+ -> renew the attached payload lease
324
+
325
+ resource.ReleasePayload()
326
+ -> explicitly release the full payload reference
327
+ ```
328
+
329
+ `ReleasePayload()` is implemented; `KeepPayloadAlive()` remains target
330
+ behavior. `GetPayload()` and `HasPayload()` are pure queries; reading the payload
331
+ must not implicitly renew its lease.
332
+
333
+ The processor preparing a resource decides when the full payload can be
334
+ released:
335
+
336
+ ```text
337
+ format reader -> plain payload -> resource validation + adapter prepare
338
+ |
339
+ +-> resource retains required values/references
340
+ +-> adapter retains adapter-specific state/references
341
+ +-> release payload after successful preparation
342
+ `-> or renew its lease for deferred/further work
343
+ ```
344
+
345
+ A time-based lease is a fallback against abandoned payloads. An owner performing
346
+ deferred work can renew the lease. If the payload has expired and is required
347
+ again, the manager reloads the source and reconstructs it. Dynamic or
348
+ non-reloadable resources must retain or be able to recreate any payload they
349
+ still require.
350
+
351
+ Payload references are shared read-only by default. Preparing WebGL and WebGPU
352
+ adapters side by side should normally pass the same payload to both consumers
353
+ and retain it until both have finished. Copying is an explicit consumer
354
+ operation, justified when a consumer must mutate data, transfer and detach an
355
+ `ArrayBuffer`, or retain an independently writable snapshot. The consumer
356
+ should copy only the fields it requires; runtime-resource should not
357
+ automatically deep-clone entire payload or typed-array bundles. Any full-copy
358
+ operation should be format-aware rather than a generic resource-side clone.
359
+
360
+ Open design questions:
361
+
362
+ - Should `Unload()` drop only adapter payloads by default, or CPU payloads too?
363
+ - Should there be explicit `UnloadAdapterResources()`, `UnloadPayload()`, and
364
+ `Purge()` phases?
365
+ - Should loaded CPU payloads have a byte-size estimate so the purge policy can
366
+ be memory-budget based instead of only time/frame based?
367
+ - Should manually attached/dynamic resources default to locked, like ccpwgl's
368
+ manual shader resources use `doNotPurge`?
369
+ - Should `KeepAlive()` reload purged resources, or should reload be an explicit
370
+ `Reload()` call to avoid surprising browser/network work?
371
+
372
+ ccpwgl's raw event emitter shape is useful. The part we should not copy is the
373
+ separate resource notification/callback compatibility layer that sits beside
374
+ events. CarbonEngineJS exposes one small event-emitter API and avoids short
375
+ generic names such as `On`, `Once`, `Off`, and `Emit` on Carbon-shaped classes.
376
+ `CjsEventEmitter` is a separate base class so non-model runtime services can
377
+ extend it without extending `CjsModel`; `CjsResMan` already uses that path.
378
+
379
+ The API stays deliberately direct:
380
+
381
+ - `AddEvents(events)`
382
+ - `OnEvent(eventName, listener, source?)`
383
+ - `OnceEvent(eventName, listener, source?)`
384
+ - `OffEvent(eventName = "*", listener?, source?)`
385
+ - `EmitEvent(eventName, ...args)`
386
+ - `HasEvent(eventName = "*", listener?, source?)`
387
+ - `ClearEvent(eventName = "*")`
388
+ - `GetEventNames()` and `GetEventListenerCount(eventName = "*")`
389
+
390
+ The optional `source` is the callback's `this` value and an explicit matching
391
+ identity for removal. Mutating event methods return the emitter for chaining.
392
+ There are no listener scopes, subscription handles, owner-side `ListenTo()`
393
+ helpers, or parallel resource notification callbacks.
394
+
395
+ Event names are normalized to lowercase and dispatched by exact match. Resource
396
+ classes may emit their own state or domain events, but the emitter does not
397
+ invent a resource lifecycle contract.
398
+
399
+ Event memory rules matter as much as event names. Event storage is the optional
400
+ `events` member of the emitter's non-enumerable `__state` object. It is created
401
+ only when the first listener is registered and deleted when the last record is
402
+ removed. That does not make listeners weak. As long as an emitter is reachable,
403
+ its event map strongly references listener functions and sources, and those
404
+ listeners can keep whole scene/resource graphs alive.
405
+
406
+ CarbonEngineJS event emitters should therefore follow these rules:
407
+
408
+ - `OnceEvent()` should remove the listener before or immediately after the first
409
+ callback, even if the callback throws.
410
+ - `OffEvent(eventName, listener, source)` must remove the exact listener/source
411
+ entry.
412
+ - an external party that no longer observes a target must call `OffEvent()`;
413
+ `target.OffEvent("*", null, source)` removes all of that source's records.
414
+ - `Unload()` and `Purge()` are resource state/cache operations, not an implied
415
+ listener-destruction lifecycle.
416
+ - `OnEvent()` returns the emitter, ccpwgl-style. It does not return unsubscribe
417
+ closures because those closures create another reference path.
418
+ - event payload history is not stored.
419
+ - we should prefer deterministic cleanup over `WeakRef`/`FinalizationRegistry`;
420
+ those can help diagnostics, but they are not a lifecycle contract.
421
+
422
+ The target is "easy to debug, hard to leak": clear ownership of who subscribed,
423
+ who unsubscribes, and which cleanup phase clears all remaining listeners.
424
+
425
+ The event data model is deliberately small:
426
+
427
+ ```text
428
+ emitter.__state (non-enumerable, allocated only when some subsystem needs it)
429
+ events -> eventName -> Set<listenerRecord>
430
+
431
+ listenerRecord
432
+ emitter
433
+ eventName
434
+ listener
435
+ source
436
+ once
437
+ ```
438
+
439
+ The event map is allocated only when the first listener is registered. If the
440
+ emitter becomes unreachable, its state and event records can be collected with
441
+ it. While the emitter remains reachable, listener functions and sources are
442
+ strongly retained until `OffEvent()`, `ClearEvent()`, once dispatch, or emitter
443
+ collection. Multiple listeners on the same event are allowed because each event
444
+ bucket is a set of records. A raw `CjsEventEmitter` does not gain model-owned
445
+ `dirty` or `rebuild` state.
446
+
447
+ This is as far as the event system should go for now:
448
+
449
+ - lowercase exact event names only.
450
+ - no wildcard listener dispatch.
451
+ - wildcard names are accepted only by lookup and cleanup methods.
452
+ - no listener scope or subscription-object layer.
453
+ - no separate resource notification/callback compatibility layer.
454
+ - no `family.event` or ancestor routing.
455
+ - no event history by default.
456
+ - no global master event manager.
457
+ - debugging introspection should stay limited to counts and names unless a real
458
+ use case appears.
459
+
460
+ `CjsModel` has dirty-state helpers (`MarkDirty`, `ClearDirty`, `ConsumeDirty`,
461
+ `GetDirtyNotifications`) for model invalidation. `SetValues()` compares incoming
462
+ values with the current field values and only marks dirty when a value actually
463
+ changes. A plain `MarkDirty()` means broad dirty invalidation; it does not request
464
+ a rebuild. Deferred rebuild reasons belong to the independent
465
+ `model.__state.rebuild` set. This is not a resource lifecycle event system.
466
+ Resource lifecycle events should therefore remain a resource/resman concern.
467
+
468
+ ## Why We Diverge
469
+
470
+ The Carbon and ccpwgl resource classes live inside an engine that can prepare
471
+ GPU objects directly. CarbonEngineJS keeps the format/resource layer reusable by
472
+ stopping before GPU work:
473
+
474
+ - `runtime-resource` selects and runs registered non-shader readers, then can
475
+ directly hydrate the requested runtime class or return another requested
476
+ outcome.
477
+ - `runtime-resource` stores lifecycle state, cache entries, and loaded object
478
+ payloads. Plain reader results are normally transient prepare inputs; the
479
+ resource or adapter retains only what it requires, by reference or by
480
+ explicit copy.
481
+ - Frozen standalone non-shader `format-*` packages remain compatibility
482
+ distributions. GR2 and all shader formats remain separate packages for now.
483
+ - engine packages create WebGL/WebGPU textures, buffers, shader modules,
484
+ pipelines, and bind groups from loaded resources.
485
+
486
+ This gives us the Carbon lifecycle shape without forcing WebGL/WebGPU imports or
487
+ device decisions into `runtime-resource`.