@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 @@
1
+ {"version":3,"file":"CjsResMan.js","sources":["../../src/CjsResMan.js"],"sourcesContent":["import { CjsMotherLode } from \"./CjsMotherLode.js\";\nimport { CjsEventEmitter } from \"@carbonenginejs/core-types/model\";\nimport { CjsResource } from \"./CjsResource.js\";\nimport {\n CjsResManQueue,\n CjsResManWorkQueue,\n NormalizeCjsResManQueue\n} from \"./CjsResManQueue.js\";\nimport {\n getResourceExtension,\n normalizeResourceExtension,\n normalizeResourcePath\n} from \"./resourcePath.js\";\n\nexport class CjsResMan extends CjsEventEmitter\n{\n constructor(options = {}) {\n super();\n this.motherLode = new CjsMotherLode();\n this.source = null;\n this.resourceTypes = new Map();\n this.objectLoaders = new Map();\n this.formats = new Map();\n this.objectOperations = new WeakMap();\n this.sourceOperations = new WeakMap();\n this.queuedSourceOperations = new WeakMap();\n this.formatOperations = new WeakMap();\n this.preparePipelines = new Map();\n this.defaultPreparePipeline = \"\";\n this.maxConcurrentLoads = 8;\n this.maxPrepareTime = 0.005;\n this.maxPrepareItemsPerTick = 0;\n this.autoPumpMainThreadQueue = true;\n this.queueScheduler = DefaultQueueScheduler;\n this.urgentResourceLoads = false;\n this._backgroundPumpScheduled = false;\n this._mainThreadPumpScheduled = false;\n this._loadQueue = new CjsResManWorkQueue(CjsResManQueue.BACKGROUND, {\n concurrency: this.maxConcurrentLoads,\n onReady: () => this.ScheduleBackgroundQueue()\n });\n this._prepareQueue = new CjsResManWorkQueue(CjsResManQueue.MAIN, {\n concurrency: 1,\n onReady: () => this.ScheduleMainThreadQueue()\n });\n\n this.Register(options);\n }\n\n /**\n * Add or replace resource-manager configuration.\n *\n * The same options object can be forwarded unchanged by CjsLibrary. Format\n * classes continue to own their input extensions; resource types are keyed\n * by semantic requirements such as \"texture\", \"image\", or \"geometry\".\n */\n Register(options = {})\n {\n if (!options || typeof options !== \"object\" || Array.isArray(options))\n {\n throw new TypeError(\"CjsResMan.Register options must be an object.\");\n }\n\n if (Object.prototype.hasOwnProperty.call(options, \"motherLode\"))\n {\n this.motherLode = options.motherLode || new CjsMotherLode();\n }\n if (Object.prototype.hasOwnProperty.call(options, \"source\"))\n {\n this.SetSource(options.source);\n }\n if (Object.prototype.hasOwnProperty.call(options, \"maxConcurrentLoads\"))\n {\n AssertPositiveInteger(options.maxConcurrentLoads, \"maxConcurrentLoads\");\n this.maxConcurrentLoads = options.maxConcurrentLoads;\n this._loadQueue.SetConcurrency(this.maxConcurrentLoads);\n }\n if (Object.prototype.hasOwnProperty.call(options, \"maxPrepareTime\"))\n {\n AssertNonNegativeNumber(options.maxPrepareTime, \"maxPrepareTime\");\n this.maxPrepareTime = options.maxPrepareTime;\n }\n if (Object.prototype.hasOwnProperty.call(options, \"maxPrepareItemsPerTick\"))\n {\n AssertNonNegativeInteger(options.maxPrepareItemsPerTick, \"maxPrepareItemsPerTick\");\n this.maxPrepareItemsPerTick = options.maxPrepareItemsPerTick;\n }\n if (Object.prototype.hasOwnProperty.call(options, \"autoPumpMainThreadQueue\"))\n {\n this.autoPumpMainThreadQueue = Boolean(options.autoPumpMainThreadQueue);\n }\n if (Object.prototype.hasOwnProperty.call(options, \"queueScheduler\"))\n {\n if (options.queueScheduler !== null && typeof options.queueScheduler !== \"function\")\n {\n throw new TypeError(\"CjsResMan queueScheduler must be a function or null.\");\n }\n this.queueScheduler = options.queueScheduler || DefaultQueueScheduler;\n }\n if (Object.prototype.hasOwnProperty.call(options, \"urgentResourceLoads\"))\n {\n this.SetUrgentResourceLoads(options.urgentResourceLoads);\n }\n\n for (const [ name, entry ] of NormalizePreparePipelineEntries(options.preparePipelines))\n {\n const stages = Array.isArray(entry) ? entry : entry.stages;\n this.RegisterPreparePipeline(name, stages, {\n default: !Array.isArray(entry) && entry.default === true\n });\n }\n if (Object.prototype.hasOwnProperty.call(options, \"defaultPreparePipeline\"))\n {\n this.SetDefaultPreparePipeline(options.defaultPreparePipeline);\n }\n\n for (const entry of NormalizeRegistrationEntries(options.formats))\n {\n if (typeof entry === \"function\") this.RegisterFormat(entry);\n else this.RegisterFormat(entry.Format || entry.format, entry.defaults || {});\n }\n for (const entry of NormalizeRegistrationEntries(options.resourceTypes, true))\n {\n if (typeof entry === \"function\") this.RegisterResourceType(entry);\n else this.RegisterResourceType(entry.requirement || entry.payload || entry.key, entry.Constructor || entry.Resource || entry.resourceType, entry);\n }\n for (const [ ext, loader ] of Object.entries(options.objectLoaders || {}))\n {\n this.RegisterObjectLoader(ext, loader);\n }\n return this;\n }\n\n SetSource(source) {\n this.source = source || null;\n return this;\n }\n\n RegisterPreparePipeline(name, stages, options = {}) {\n const key = NormalizePipelineName(name);\n if (!key) throw new TypeError(\"CjsResMan.RegisterPreparePipeline requires a name.\");\n this.preparePipelines.set(key, Object.freeze(NormalizePrepareStages(stages)));\n if (options.default === true) this.defaultPreparePipeline = key;\n return this;\n }\n\n SetDefaultPreparePipeline(name = \"\") {\n const key = NormalizePipelineName(name);\n if (key && !this.preparePipelines.has(key)) {\n throw new Error(`Unknown CjsResMan prepare pipeline: ${key}`);\n }\n this.defaultPreparePipeline = key;\n return this;\n }\n\n GetPreparePipeline(name) {\n return [ ...(this.preparePipelines.get(NormalizePipelineName(name)) || []) ];\n }\n\n ResolvePrepareStages(options = {}) {\n const requested = options.preparePipeline ?? options.pipeline ?? this.defaultPreparePipeline;\n const key = NormalizePipelineName(requested);\n if (key && !this.preparePipelines.has(key)) {\n const error = new Error(`Unknown CjsResMan prepare pipeline: ${key}`);\n error.code = \"CJS_RESOURCE_PREPARE_PIPELINE_MISSING\";\n error.pipeline = key;\n throw error;\n }\n const stages = key ? this.GetPreparePipeline(key) : [];\n return [ ...stages, ...NormalizePrepareStages(options.prepareStages || []) ];\n }\n\n AddToQueue(queue, callback, context = null, flags = 0) {\n const task = this.QueueTask(queue, callback, context, { flags });\n task.promise.catch(error => {\n this.EmitEvent?.(\"queueerror\", this, task.queue, task.id, error);\n });\n return task.id;\n }\n\n CancelFromQueue(queue, id, reason = \"\") {\n return this.GetWorkQueue(queue).Cancel(id, reason);\n }\n\n GetNextIdForQueue(queue) {\n return this.GetWorkQueue(queue).GetNextId();\n }\n\n PumpMainThreadQueue(options = {}) {\n const urgent = options.urgent === true || this.urgentResourceLoads;\n const result = this._prepareQueue.Pump({\n maxItems: urgent ? 0 : (options.maxItems ?? this.maxPrepareItemsPerTick),\n maxTime: urgent ? 0 : (options.maxTime ?? this.maxPrepareTime) * 1000,\n now: options.now\n });\n if (result.queued > 0 && result.active === 0) this.ScheduleMainThreadQueue();\n return result.processed > 0;\n }\n\n PumpBackgroundQueue(options = {}) {\n const result = this._loadQueue.Pump({\n maxItems: options.maxItems ?? 0,\n maxTime: options.maxTime === undefined ? 0 : options.maxTime * 1000,\n now: options.now\n });\n return result.processed > 0;\n }\n\n PauseQueue(queue) {\n this.GetWorkQueue(queue).Pause();\n return this;\n }\n\n ResumeQueue(queue) {\n const name = NormalizeCjsResManQueue(queue);\n this.GetWorkQueue(name).Resume();\n if (name === CjsResManQueue.MAIN) this.ScheduleMainThreadQueue();\n else this.ScheduleBackgroundQueue();\n return this;\n }\n\n GetPendingLoads() {\n return this._loadQueue.GetPendingCount();\n }\n\n GetPendingPrepares() {\n return this._prepareQueue.GetPendingCount();\n }\n\n GetQueueStats(queue = null) {\n if (queue !== null && queue !== undefined) return this.GetWorkQueue(queue).GetStats();\n return Object.freeze({\n loads: this._loadQueue.GetStats(),\n prepares: this._prepareQueue.GetStats()\n });\n }\n\n SetUrgentResourceLoads(value) {\n this.urgentResourceLoads = Boolean(value);\n return this;\n }\n\n IsUrgentResourceLoads() {\n return this.urgentResourceLoads;\n }\n\n IsLoading() {\n return this.GetPendingLoads() + this.GetPendingPrepares() > 0;\n }\n\n Update(options = {}) {\n const loaded = this.PumpBackgroundQueue(options.background || {});\n const prepared = this.PumpMainThreadQueue(options.prepare || options);\n return loaded || prepared;\n }\n\n Tick(options = {}) {\n return this.Update(options);\n }\n\n async Wait(options = {}) {\n const yieldQueue = typeof options.yield === \"function\" ? options.yield : DefaultQueueYield;\n while (this.IsLoading()) {\n if (options.pump !== false) this.Update(options);\n await yieldQueue();\n }\n return this;\n }\n\n GetWorkQueue(queue) {\n return NormalizeCjsResManQueue(queue) === CjsResManQueue.MAIN\n ? this._prepareQueue\n : this._loadQueue;\n }\n\n QueueTask(queue, callback, context = null, metadata = null) {\n return this.GetWorkQueue(queue).Add(callback, context, metadata);\n }\n\n ScheduleBackgroundQueue() {\n if (this._backgroundPumpScheduled || this._loadQueue.IsPaused()) return this;\n this._backgroundPumpScheduled = true;\n Promise.resolve().then(() => {\n this._backgroundPumpScheduled = false;\n this.PumpBackgroundQueue();\n });\n return this;\n }\n\n ScheduleMainThreadQueue() {\n if (!this.autoPumpMainThreadQueue || this._mainThreadPumpScheduled || this._prepareQueue.IsPaused()) return this;\n this._mainThreadPumpScheduled = true;\n try {\n this.queueScheduler(() => {\n this._mainThreadPumpScheduled = false;\n this.PumpMainThreadQueue();\n });\n } catch (error) {\n this._mainThreadPumpScheduled = false;\n throw error;\n }\n return this;\n }\n\n RegisterResourceType(requirement, Constructor = null, options = {})\n {\n if (typeof requirement === \"function\")\n {\n options = Constructor && typeof Constructor === \"object\" ? Constructor : {};\n Constructor = requirement;\n requirement = options.requirement || options.payload || Constructor.payload;\n }\n\n const key = NormalizeRequirement(requirement);\n if (!key) throw new TypeError(\"CjsResMan.RegisterResourceType requires a semantic requirement.\");\n if (typeof Constructor !== \"function\")\n {\n throw new TypeError(\"CjsResMan.RegisterResourceType requires a constructor or factory.\");\n }\n\n this.resourceTypes.set(key, Constructor);\n for (const alias of options.aliases || [])\n {\n const aliasKey = NormalizeRequirement(alias);\n if (aliasKey) this.resourceTypes.set(aliasKey, Constructor);\n }\n return this;\n }\n\n RegisterObjectLoader(ext, loader) {\n const key = normalizeResourceExtension(ext);\n if (!key) throw new TypeError(\"CjsResMan.RegisterObjectLoader requires an extension.\");\n if (typeof loader !== \"function\") throw new TypeError(\"CjsResMan.RegisterObjectLoader requires a loader function.\");\n this.objectLoaders.set(key, loader);\n return this;\n }\n\n /**\n * Register a reusable format facade for each accepted input extension.\n * Multiple candidates may share an extension and are resolved by requested\n * output/media type or by their support probes.\n *\n * @param {Function} Format\n * @param {object} defaults\n * @returns {CjsResMan}\n */\n RegisterFormat(Format, defaults = {})\n {\n if (typeof Format !== \"function\")\n {\n throw new TypeError(\"CjsResMan.RegisterFormat requires a format class.\");\n }\n if (!Array.isArray(Format.inputTypes) || Format.inputTypes.length === 0)\n {\n throw new TypeError(`${Format.name || \"Format\"} must declare non-empty inputTypes.`);\n }\n\n const descriptor = Object.freeze({ Format, defaults: Object.freeze({ ...defaults }) });\n for (const inputType of Format.inputTypes)\n {\n const key = normalizeResourceExtension(inputType);\n if (!key) continue;\n const candidates = this.formats.get(key) || [];\n const next = candidates.filter(candidate => candidate.Format !== Format);\n next.push(descriptor);\n this.formats.set(key, next);\n }\n return this;\n }\n\n GetFormats(inputType)\n {\n return this.GetFormatDescriptors(inputType).map(descriptor => descriptor.Format);\n }\n\n ResolveFormat(inputType, options = {})\n {\n return this.ResolveFormatDescriptor(inputType, options).Format;\n }\n\n GetResource(path, options = {}) {\n const key = normalizeResourcePath(path);\n const variant = this.GetResourceVariant(options);\n const existing = this.motherLode.Lookup(key, variant);\n if (existing && options.reload !== true) return existing;\n\n const ext = normalizeResourceExtension(options.ext || getResourceExtension(key));\n const Constructor = this.ResolveResourceConstructor(options);\n const resource = this.CreateResource(Constructor, key, ext, options);\n this.motherLode.Insert(resource, key, variant);\n return resource;\n }\n\n GetObject(path, options = {})\n {\n const resource = this.GetResource(path, options);\n const existing = this.objectOperations.get(resource);\n if (existing)\n {\n return existing.promise;\n }\n\n const promise = this.QueueResourceObject(resource, options);\n this.objectOperations.set(resource, { promise });\n return promise;\n }\n\n LoadObject(path, options = {})\n {\n return this.GetObject(path, options);\n }\n\n FetchObject(path, options = {})\n {\n return this.GetObject(path, options);\n }\n\n async FetchResource(path, options = {})\n {\n const resource = this.GetResource(path, options);\n await resource.Ready(options);\n return resource;\n }\n\n Fetch(path, options = {})\n {\n return options.resource === true || options.requirement !== undefined || options.payload !== undefined\n ? this.FetchResource(path, options)\n : this.FetchObject(path, options);\n }\n\n async LoadResourceObject(resource, options)\n {\n resource.MarkLoading();\n\n try {\n const bytes = await this.ReadResource(resource.GetPath(), options);\n return await this.PrepareResourceObject(resource, bytes, options);\n } catch (error) {\n resource.SetError(error);\n throw error;\n }\n }\n\n QueueResourceObject(resource, options = {}) {\n resource.MarkRequested();\n const load = this.QueueReadResource(resource.GetPath(), options);\n\n return load\n .then(bytes => {\n resource.MarkLoading();\n return this.PrepareResourceObjectQueued(resource, bytes, options);\n })\n .catch(error => {\n resource.SetError(error);\n throw error;\n });\n }\n\n QueueReadResource(path, options = {}) {\n const source = options.source || this.source;\n if (!source || typeof source.Read !== \"function\") {\n return Promise.reject(new TypeError(\"CjsResMan requires a source with Read(path, options) to load objects.\"));\n }\n\n const key = normalizeResourcePath(path);\n if (options.reload === true || options.cacheSource === false) {\n return this.QueueTask(CjsResManQueue.BACKGROUND, () => this.ReadResource(key, options), source, {\n kind: \"load\",\n path: key\n }).promise;\n }\n\n let operations = this.queuedSourceOperations.get(source);\n if (!operations) {\n operations = new Map();\n this.queuedSourceOperations.set(source, operations);\n }\n\n const existing = operations.get(key);\n if (existing) return existing;\n\n const operation = this.QueueTask(CjsResManQueue.BACKGROUND, () => this.ReadResource(key, options), source, {\n kind: \"load\",\n path: key\n }).promise;\n operations.set(key, operation);\n operation.then(() => {\n if (operations.get(key) === operation) operations.delete(key);\n }, () => {\n if (operations.get(key) === operation) operations.delete(key);\n });\n return operation;\n }\n\n async PrepareResourceObject(resource, bytes, options = {}) {\n let object = await this.ReadResourceObjectPayload(resource, bytes, options);\n for (const stage of this.ResolvePrepareStages(options)) {\n const next = await stage.prepare(object, CreatePrepareContext(this, resource, bytes, options, stage.name));\n if (next !== undefined) object = next;\n }\n return this.PublishResourceObject(resource, object, options);\n }\n\n async PrepareResourceObjectQueued(resource, bytes, options = {}) {\n const stages = [\n Object.freeze({\n name: \"read\",\n prepare: () => this.ReadResourceObjectPayload(resource, bytes, options)\n }),\n ...this.ResolvePrepareStages(options),\n Object.freeze({\n name: \"publish\",\n prepare: object => this.PublishResourceObject(resource, object, options)\n })\n ];\n let object = bytes;\n\n for (const stage of stages) {\n const task = this.QueueTask(CjsResManQueue.MAIN, () =>\n stage.prepare(object, CreatePrepareContext(this, resource, bytes, options, stage.name)), resource, {\n kind: \"prepare\",\n stage: stage.name,\n path: resource.GetPath()\n });\n const next = await task.promise;\n if (next !== undefined) object = next;\n }\n return object;\n }\n\n async ReadResourceObjectPayload(resource, bytes, options = {}) {\n const explicitLoader = this.GetObjectLoader(resource.GetExt());\n if (explicitLoader) {\n return explicitLoader(bytes, CreatePrepareContext(this, resource, bytes, options, \"read\"));\n }\n\n const descriptor = this.ResolveFormatDescriptor(resource.GetExt(), {\n ...options,\n bytes\n });\n return this.ReadFormatOnce(resource, descriptor, bytes, options);\n }\n\n PublishResourceObject(resource, object, options = {}) {\n let result = object;\n if (resource.constructor !== CjsResource && typeof resource.SetPayload === \"function\") {\n resource.SetPayload(object, options);\n resource.object = resource;\n result = resource;\n }\n else {\n resource.object = object;\n }\n if (!resource.IsPrepared?.()) resource.MarkLoaded();\n return result;\n }\n\n async Prefetch(paths, options = {}) {\n const entries = Array.isArray(paths) ? paths : [paths];\n return Promise.all(entries.map(path => this.LoadObject(path, options)));\n }\n\n GetObjectLoader(ext) {\n return this.objectLoaders.get(normalizeResourceExtension(ext)) || null;\n }\n\n GetFormatDescriptors(inputType)\n {\n return [ ...(this.formats.get(normalizeResourceExtension(inputType)) || []) ];\n }\n\n ResolveFormatDescriptor(inputType, options = {})\n {\n const key = normalizeResourceExtension(inputType);\n let candidates = this.GetFormatDescriptors(key);\n\n if (options.format)\n {\n candidates = candidates.filter(({ Format }) => Format === options.format\n || Format.id === options.format\n || Format.name === options.format);\n }\n\n if (options.emit)\n {\n candidates = candidates.filter(({ Format }) => [\n ...(Format.outputTypes || []),\n ...(Format.debugOutputTypes || [])\n ].includes(options.emit));\n }\n\n if (options.mediaType)\n {\n candidates = candidates.filter(({ Format }) => (Format.mediaTypes || []).includes(options.mediaType));\n }\n\n if (candidates.length > 1 && options.bytes !== undefined)\n {\n const supported = candidates.filter(({ Format, defaults }) =>\n {\n if (typeof Format.isSupported !== \"function\") return false;\n const report = Format.isSupported(options.bytes, {\n ...defaults,\n ...(options.formatOptions || {})\n });\n return report && report.supported !== false;\n });\n if (supported.length === 1) candidates = supported;\n }\n\n if (candidates.length === 0)\n {\n const error = new Error(`No format registered for .${key}`);\n error.code = \"CJS_RESOURCE_FORMAT_MISSING\";\n error.ext = key;\n throw error;\n }\n\n if (candidates.length > 1)\n {\n const error = new Error(`Ambiguous formats registered for .${key}`);\n error.code = \"CJS_RESOURCE_FORMAT_AMBIGUOUS\";\n error.ext = key;\n error.formats = candidates.map(({ Format }) => Format.name);\n throw error;\n }\n\n return candidates[0];\n }\n\n async ReadFormat(descriptor, bytes, options = {})\n {\n const { Format, defaults } = descriptor;\n const formatOptions = {\n ...defaults,\n ...(options.formatOptions || {})\n };\n if (options.emit !== undefined) formatOptions.emit = options.emit;\n if (options.classes !== undefined) formatOptions.classes = options.classes;\n\n if (typeof Format.readAsync === \"function\")\n {\n return Format.readAsync(bytes, formatOptions);\n }\n if (typeof Format.read === \"function\")\n {\n return Format.read(bytes, formatOptions);\n }\n\n const reader = new Format(formatOptions);\n if (typeof reader.ReadAsync === \"function\")\n {\n return reader.ReadAsync(bytes, formatOptions);\n }\n if (typeof reader.Read === \"function\")\n {\n return reader.Read(bytes, formatOptions);\n }\n throw new TypeError(`${Format.name} does not expose a read operation.`);\n }\n\n Lookup(path, options = {}) {\n return this.motherLode.Lookup(path, this.GetResourceVariant(options));\n }\n\n Delete(path, options = null) {\n return options === null || options === undefined\n ? this.motherLode.DeleteAll(path)\n : this.motherLode.Delete(path, this.GetResourceVariant(options));\n }\n\n Clear() {\n this._loadQueue.Clear();\n this._prepareQueue.Clear();\n this.motherLode.Clear();\n this.objectOperations = new WeakMap();\n this.sourceOperations = new WeakMap();\n this.queuedSourceOperations = new WeakMap();\n this.formatOperations = new WeakMap();\n return this;\n }\n\n async ReadResource(path, options = {}) {\n const source = options.source || this.source;\n if (!source || typeof source.Read !== \"function\") {\n throw new TypeError(\"CjsResMan requires a source with Read(path, options) to load objects.\");\n }\n\n if (options.reload === true || options.cacheSource === false)\n {\n return source.Read(path, options);\n }\n\n let operations = this.sourceOperations.get(source);\n if (!operations)\n {\n operations = new Map();\n this.sourceOperations.set(source, operations);\n }\n\n const key = normalizeResourcePath(path);\n const existing = operations.get(key);\n if (existing) return existing;\n\n const operation = Promise.resolve().then(() => source.Read(path, options));\n operations.set(key, operation);\n operation.then(() =>\n {\n if (options.cacheSource !== true && operations.get(key) === operation) operations.delete(key);\n }, () =>\n {\n if (operations.get(key) === operation) operations.delete(key);\n });\n return operation;\n }\n\n CreateResource(Constructor, path, ext, options = {}) {\n const resource = new Constructor(options.values);\n if (!resource || typeof resource.Initialize !== \"function\") {\n throw new TypeError(\"Resource constructor must create a CjsResource-compatible object.\");\n }\n resource.Initialize(path, ext, NormalizeRequirement(options.requirement || options.payload || \"\"));\n if (typeof resource.SetObjectLoader === \"function\")\n {\n const identityOptions = GetIdentityOptions(options);\n resource.SetObjectLoader(loadOptions => this.GetObject(path, {\n ...identityOptions,\n ...loadOptions\n }));\n }\n return resource;\n }\n\n ResolveResourceConstructor(options = {})\n {\n const requested = NormalizeRequirement(options.requirement || options.payload);\n if (requested && this.resourceTypes.has(requested)) return this.resourceTypes.get(requested);\n\n const emitted = NormalizeRequirement(options.emit);\n if (emitted && this.resourceTypes.has(emitted)) return this.resourceTypes.get(emitted);\n\n return CjsResource;\n }\n\n GetResourceVariant(options = {})\n {\n const identity = GetIdentityOptions(options);\n return Object.keys(identity).length ? StableSerialize(identity) : \"\";\n }\n\n ReadFormatOnce(resource, descriptor, bytes, options = {})\n {\n const { Format } = descriptor;\n let operations = this.formatOperations.get(Format);\n if (!operations)\n {\n operations = new Map();\n this.formatOperations.set(Format, operations);\n }\n\n const key = `${resource.GetPath()}\\u0000${StableSerialize({\n emit: options.emit,\n mediaType: options.mediaType,\n classes: options.classes,\n formatOptions: options.formatOptions\n })}`;\n const existing = operations.get(key);\n if (existing) return existing;\n\n const operation = Promise.resolve().then(() => this.ReadFormat(descriptor, bytes, options));\n operations.set(key, operation);\n operation.then(() =>\n {\n if (options.cacheFormat !== true && operations.get(key) === operation) operations.delete(key);\n }, () =>\n {\n if (operations.get(key) === operation) operations.delete(key);\n });\n return operation;\n }\n}\n\nfunction StableSerialize(value, seen = new WeakSet())\n{\n if (value === undefined) return \"undefined\";\n if (value === null || typeof value === \"number\" || typeof value === \"boolean\") return JSON.stringify(value);\n if (typeof value === \"string\") return JSON.stringify(value);\n if (typeof value === \"function\") return `[Function:${value.name || \"anonymous\"}]`;\n if (ArrayBuffer.isView(value))\n {\n return `[${value.constructor.name}:${value.byteOffset}:${value.byteLength}]`;\n }\n if (value instanceof ArrayBuffer) return `[ArrayBuffer:${value.byteLength}]`;\n if (seen.has(value)) return \"[Circular]\";\n seen.add(value);\n if (Array.isArray(value)) return `[${value.map(entry => StableSerialize(entry, seen)).join(\",\")}]`;\n return `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${StableSerialize(value[key], seen)}`).join(\",\")}}`;\n}\n\nfunction GetIdentityOptions(options = {})\n{\n const identity = {};\n for (const key of [\n \"requirement\",\n \"payload\",\n \"emit\",\n \"mediaType\",\n \"format\",\n \"classes\",\n \"formatOptions\",\n \"pipeline\",\n \"preparePipeline\",\n \"prepareStages\"\n ])\n {\n if (options[key] !== undefined) identity[key] = options[key];\n }\n return identity;\n}\n\nfunction NormalizeRequirement(value)\n{\n return value === null || value === undefined\n ? \"\"\n : String(value).trim().toLowerCase();\n}\n\nfunction NormalizePipelineName(value)\n{\n return value === null || value === undefined\n ? \"\"\n : String(value).trim().toLowerCase();\n}\n\nfunction NormalizePrepareStages(value)\n{\n if (value === null || value === undefined) return [];\n const entries = Array.isArray(value) ? value : [ value ];\n return entries.map((entry, index) => {\n const prepare = typeof entry === \"function\"\n ? entry\n : entry?.prepare || entry?.run || entry?.handler;\n if (typeof prepare !== \"function\") {\n throw new TypeError(\"CjsResMan prepare stages require a function or prepare/run/handler method.\");\n }\n const name = typeof entry === \"function\"\n ? entry.name || `stage${index + 1}`\n : entry.name || prepare.name || `stage${index + 1}`;\n return Object.freeze({ name: String(name), prepare });\n });\n}\n\nfunction NormalizePreparePipelineEntries(value)\n{\n if (value === null || value === undefined) return [];\n if (value instanceof Map) return [ ...value.entries() ];\n if (typeof value !== \"object\" || Array.isArray(value)) {\n throw new TypeError(\"CjsResMan preparePipelines must be an object or Map.\");\n }\n return Object.entries(value);\n}\n\nfunction CreatePrepareContext(resMan, resource, bytes, options, stage)\n{\n return Object.freeze({\n ...options,\n stage,\n bytes,\n path: resource.GetPath(),\n ext: resource.GetExt(),\n resource,\n resMan\n });\n}\n\nfunction AssertPositiveInteger(value, name)\n{\n if (!Number.isInteger(value) || value < 1) {\n throw new TypeError(`CjsResMan ${name} must be a positive integer.`);\n }\n}\n\nfunction AssertNonNegativeInteger(value, name)\n{\n if (!Number.isInteger(value) || value < 0) {\n throw new TypeError(`CjsResMan ${name} must be a non-negative integer.`);\n }\n}\n\nfunction AssertNonNegativeNumber(value, name)\n{\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) {\n throw new TypeError(`CjsResMan ${name} must be a non-negative finite number.`);\n }\n}\n\nfunction DefaultQueueScheduler(callback)\n{\n return setTimeout(callback, 0);\n}\n\nfunction DefaultQueueYield()\n{\n return new Promise(resolve => setTimeout(resolve, 0));\n}\n\nfunction NormalizeRegistrationEntries(value, keyed = false)\n{\n if (value === null || value === undefined) return [];\n if (Array.isArray(value)) return value;\n if (typeof value === \"function\") return [ value ];\n if (typeof value !== \"object\")\n {\n throw new TypeError(\"CjsResMan registration collections must be arrays or objects.\");\n }\n\n if (value.Format || value.format || value.Constructor || value.Resource || value.resourceType)\n {\n return [ value ];\n }\n\n return Object.entries(value).map(([ key, entry ]) =>\n {\n if (!keyed) return typeof entry === \"function\" ? entry : { ...entry, key };\n return typeof entry === \"function\"\n ? { key, requirement: key, Constructor: entry }\n : { ...entry, key, requirement: entry.requirement || entry.payload || key };\n });\n}\n"],"names":["CjsResMan","CjsEventEmitter","constructor","options","motherLode","CjsMotherLode","source","resourceTypes","Map","objectLoaders","formats","objectOperations","WeakMap","sourceOperations","queuedSourceOperations","formatOperations","preparePipelines","defaultPreparePipeline","maxConcurrentLoads","maxPrepareTime","maxPrepareItemsPerTick","autoPumpMainThreadQueue","queueScheduler","DefaultQueueScheduler","urgentResourceLoads","_backgroundPumpScheduled","_mainThreadPumpScheduled","_loadQueue","CjsResManWorkQueue","CjsResManQueue","BACKGROUND","concurrency","onReady","ScheduleBackgroundQueue","_prepareQueue","MAIN","ScheduleMainThreadQueue","Register","Array","isArray","TypeError","Object","prototype","hasOwnProperty","call","SetSource","AssertPositiveInteger","SetConcurrency","AssertNonNegativeNumber","AssertNonNegativeInteger","Boolean","SetUrgentResourceLoads","name","entry","NormalizePreparePipelineEntries","stages","RegisterPreparePipeline","default","SetDefaultPreparePipeline","NormalizeRegistrationEntries","RegisterFormat","Format","format","defaults","RegisterResourceType","requirement","payload","key","Constructor","Resource","resourceType","ext","loader","entries","RegisterObjectLoader","NormalizePipelineName","set","freeze","NormalizePrepareStages","has","Error","GetPreparePipeline","get","ResolvePrepareStages","requested","preparePipeline","pipeline","error","code","prepareStages","AddToQueue","queue","callback","context","flags","task","QueueTask","promise","catch","EmitEvent","id","CancelFromQueue","reason","GetWorkQueue","Cancel","GetNextIdForQueue","GetNextId","PumpMainThreadQueue","urgent","result","Pump","maxItems","maxTime","now","queued","active","processed","PumpBackgroundQueue","undefined","PauseQueue","Pause","ResumeQueue","NormalizeCjsResManQueue","Resume","GetPendingLoads","GetPendingCount","GetPendingPrepares","GetQueueStats","GetStats","loads","prepares","value","IsUrgentResourceLoads","IsLoading","Update","loaded","background","prepared","prepare","Tick","Wait","yieldQueue","yield","DefaultQueueYield","pump","metadata","Add","IsPaused","Promise","resolve","then","NormalizeRequirement","alias","aliases","aliasKey","normalizeResourceExtension","inputTypes","length","descriptor","inputType","candidates","next","filter","candidate","push","GetFormats","GetFormatDescriptors","map","ResolveFormat","ResolveFormatDescriptor","GetResource","path","normalizeResourcePath","variant","GetResourceVariant","existing","Lookup","reload","getResourceExtension","ResolveResourceConstructor","resource","CreateResource","Insert","GetObject","QueueResourceObject","LoadObject","FetchObject","FetchResource","Ready","Fetch","LoadResourceObject","MarkLoading","bytes","ReadResource","GetPath","PrepareResourceObject","SetError","MarkRequested","load","QueueReadResource","PrepareResourceObjectQueued","Read","reject","cacheSource","kind","operations","operation","delete","object","ReadResourceObjectPayload","stage","CreatePrepareContext","PublishResourceObject","explicitLoader","GetObjectLoader","GetExt","ReadFormatOnce","CjsResource","SetPayload","IsPrepared","MarkLoaded","Prefetch","paths","all","emit","outputTypes","debugOutputTypes","includes","mediaType","mediaTypes","supported","isSupported","report","formatOptions","ReadFormat","classes","readAsync","read","reader","ReadAsync","Delete","DeleteAll","Clear","values","Initialize","SetObjectLoader","identityOptions","GetIdentityOptions","loadOptions","emitted","identity","keys","StableSerialize","cacheFormat","seen","WeakSet","JSON","stringify","ArrayBuffer","isView","byteOffset","byteLength","add","join","sort","String","trim","toLowerCase","index","run","handler","resMan","Number","isInteger","isFinite","setTimeout","keyed"],"mappings":";;;;;;AAcO,MAAMA,SAAS,SAASC,eAAe,CAC9C;AACEC,EAAAA,WAAWA,CAACC,OAAO,GAAG,EAAE,EAAE;AACxB,IAAA,KAAK,EAAE;AACP,IAAA,IAAI,CAACC,UAAU,GAAG,IAAIC,aAAa,EAAE;IACrC,IAAI,CAACC,MAAM,GAAG,IAAI;AAClB,IAAA,IAAI,CAACC,aAAa,GAAG,IAAIC,GAAG,EAAE;AAC9B,IAAA,IAAI,CAACC,aAAa,GAAG,IAAID,GAAG,EAAE;AAC9B,IAAA,IAAI,CAACE,OAAO,GAAG,IAAIF,GAAG,EAAE;AACxB,IAAA,IAAI,CAACG,gBAAgB,GAAG,IAAIC,OAAO,EAAE;AACrC,IAAA,IAAI,CAACC,gBAAgB,GAAG,IAAID,OAAO,EAAE;AACrC,IAAA,IAAI,CAACE,sBAAsB,GAAG,IAAIF,OAAO,EAAE;AAC3C,IAAA,IAAI,CAACG,gBAAgB,GAAG,IAAIH,OAAO,EAAE;AACrC,IAAA,IAAI,CAACI,gBAAgB,GAAG,IAAIR,GAAG,EAAE;IACjC,IAAI,CAACS,sBAAsB,GAAG,EAAE;IAChC,IAAI,CAACC,kBAAkB,GAAG,CAAC;IAC3B,IAAI,CAACC,cAAc,GAAG,KAAK;IAC3B,IAAI,CAACC,sBAAsB,GAAG,CAAC;IAC/B,IAAI,CAACC,uBAAuB,GAAG,IAAI;IACnC,IA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,GAAGA,KAAK;MAAEc,GAAG;MAAEF,WAAW,EAAEZ,KAAK,CAACY,WAAW,IAAIZ,KAAK,CAACa,OAAO,IAAIC;KAAK;AAC/E,EAAA,CAAC,CAAC;AACJ;;;;"}
@@ -0,0 +1,214 @@
1
+ const CjsResManQueue = Object.freeze({
2
+ MAIN: "main",
3
+ BACKGROUND: "background",
4
+ PREPARE: "main",
5
+ LOAD: "background"
6
+ });
7
+ function NormalizeCjsResManQueue(value) {
8
+ const name = String(value ?? "").trim().toLowerCase();
9
+ if (name === "main" || name === "prepare") return CjsResManQueue.MAIN;
10
+ if (name === "background" || name === "load") return CjsResManQueue.BACKGROUND;
11
+ throw new TypeError(`Unknown CjsResMan queue: ${value}`);
12
+ }
13
+ function CjsResManQueueCancelledError(queue, id, reason = "") {
14
+ const error = new Error(`CjsResMan ${queue} queue item ${id} was cancelled.${reason ? ` ${reason}` : ""}`);
15
+ error.code = "CJS_RESMAN_QUEUE_CANCELLED";
16
+ error.queue = queue;
17
+ error.id = id;
18
+ return error;
19
+ }
20
+
21
+ /**
22
+ * Small FIFO executor used internally by CjsResMan.
23
+ *
24
+ * Queue policy stays in the manager. This class only tracks ids, pause state,
25
+ * concurrency, cancellation, and sync/async completion.
26
+ */
27
+ class CjsResManWorkQueue {
28
+ #active = new Map();
29
+ #concurrency = 1;
30
+ #head = 0;
31
+ #items = [];
32
+ #name;
33
+ #nextId = 1;
34
+ #onReady;
35
+ #paused = false;
36
+ #queued = new Map();
37
+ constructor(name, options = {}) {
38
+ this.#name = NormalizeCjsResManQueue(name);
39
+ this.#onReady = typeof options.onReady === "function" ? options.onReady : null;
40
+ this.SetConcurrency(options.concurrency ?? 1);
41
+ }
42
+ SetConcurrency(value) {
43
+ if (!Number.isInteger(value) || value < 1) {
44
+ throw new TypeError("CjsResMan queue concurrency must be a positive integer.");
45
+ }
46
+ this.#concurrency = value;
47
+ this.#NotifyReady();
48
+ return this;
49
+ }
50
+ GetConcurrency() {
51
+ return this.#concurrency;
52
+ }
53
+ GetNextId() {
54
+ return this.#nextId;
55
+ }
56
+ GetQueuedCount() {
57
+ return this.#queued.size;
58
+ }
59
+ GetActiveCount() {
60
+ return this.#active.size;
61
+ }
62
+ GetPendingCount() {
63
+ return this.#queued.size + this.#active.size;
64
+ }
65
+ IsPaused() {
66
+ return this.#paused;
67
+ }
68
+ Add(callback, context = null, metadata = null) {
69
+ if (typeof callback !== "function") {
70
+ throw new TypeError("CjsResMan queue items require a callback.");
71
+ }
72
+ const id = this.#nextId++;
73
+ let resolve;
74
+ let reject;
75
+ const promise = new Promise((onResolve, onReject) => {
76
+ resolve = onResolve;
77
+ reject = onReject;
78
+ });
79
+ const item = {
80
+ id,
81
+ queue: this.#name,
82
+ callback,
83
+ context,
84
+ metadata,
85
+ promise,
86
+ resolve,
87
+ reject,
88
+ state: "queued"
89
+ };
90
+ this.#items.push(item);
91
+ this.#queued.set(id, item);
92
+ this.#NotifyReady();
93
+ return item;
94
+ }
95
+ Cancel(id, reason = "") {
96
+ const item = this.#queued.get(id);
97
+ if (!item) return false;
98
+ this.#queued.delete(id);
99
+ item.state = "cancelled";
100
+ item.reject(CjsResManQueueCancelledError(this.#name, id, reason));
101
+ this.#Compact();
102
+ return true;
103
+ }
104
+ Pause() {
105
+ this.#paused = true;
106
+ return this;
107
+ }
108
+ Resume() {
109
+ if (!this.#paused) return this;
110
+ this.#paused = false;
111
+ this.#NotifyReady();
112
+ return this;
113
+ }
114
+ Clear(reason = "Queue cleared.") {
115
+ const ids = [...this.#queued.keys()];
116
+ for (const id of ids) this.Cancel(id, reason);
117
+ this.#Compact(true);
118
+ return ids.length;
119
+ }
120
+ Pump(options = {}) {
121
+ const maxItems = NormalizeLimit(options.maxItems);
122
+ const maxTime = NormalizeLimit(options.maxTime);
123
+ const now = typeof options.now === "function" ? options.now : DefaultNow;
124
+ const startedAt = now();
125
+ let processed = 0;
126
+ if (!this.#paused) {
127
+ while (this.#active.size < this.#concurrency && processed < maxItems) {
128
+ const item = this.#TakeNext();
129
+ if (!item) break;
130
+ this.#Start(item);
131
+ processed++;
132
+ if (processed > 0 && now() - startedAt >= maxTime) break;
133
+ }
134
+ }
135
+ this.#Compact();
136
+ return Object.freeze({
137
+ processed,
138
+ queued: this.GetQueuedCount(),
139
+ active: this.GetActiveCount(),
140
+ pending: this.GetPendingCount(),
141
+ paused: this.#paused
142
+ });
143
+ }
144
+ GetStats() {
145
+ return Object.freeze({
146
+ name: this.#name,
147
+ nextId: this.#nextId,
148
+ concurrency: this.#concurrency,
149
+ queued: this.GetQueuedCount(),
150
+ active: this.GetActiveCount(),
151
+ pending: this.GetPendingCount(),
152
+ paused: this.#paused
153
+ });
154
+ }
155
+ #TakeNext() {
156
+ while (this.#head < this.#items.length) {
157
+ const item = this.#items[this.#head++];
158
+ if (item.state !== "queued") continue;
159
+ this.#queued.delete(item.id);
160
+ return item;
161
+ }
162
+ return null;
163
+ }
164
+ #Start(item) {
165
+ item.state = "active";
166
+ this.#active.set(item.id, item);
167
+ let result;
168
+ try {
169
+ result = item.callback.call(item.context, Object.freeze({
170
+ id: item.id,
171
+ queue: item.queue,
172
+ metadata: item.metadata
173
+ }));
174
+ } catch (error) {
175
+ this.#Settle(item, false, error);
176
+ return;
177
+ }
178
+ if (result && typeof result.then === "function") {
179
+ Promise.resolve(result).then(value => this.#Settle(item, true, value), error => this.#Settle(item, false, error));
180
+ return;
181
+ }
182
+ this.#Settle(item, true, result);
183
+ }
184
+ #Settle(item, didResolve, value) {
185
+ if (!this.#active.delete(item.id)) return;
186
+ item.state = didResolve ? "resolved" : "rejected";
187
+ if (didResolve) item.resolve(value);else item.reject(value);
188
+ this.#NotifyReady();
189
+ }
190
+ #Compact(force = false) {
191
+ if (force || this.#head > 256 && this.#head > this.#items.length * 0.5) {
192
+ this.#items = this.#items.slice(this.#head);
193
+ this.#head = 0;
194
+ }
195
+ }
196
+ #NotifyReady() {
197
+ if (this.#onReady && !this.#paused && this.GetQueuedCount() > 0) {
198
+ this.#onReady(this);
199
+ }
200
+ }
201
+ }
202
+ function NormalizeLimit(value) {
203
+ if (value === undefined || value === null || value === 0) return Number.POSITIVE_INFINITY;
204
+ if (typeof value !== "number" || Number.isNaN(value) || value < 0) {
205
+ throw new TypeError("CjsResMan queue limits must be non-negative numbers.");
206
+ }
207
+ return value;
208
+ }
209
+ function DefaultNow() {
210
+ return globalThis.performance?.now?.() ?? Date.now();
211
+ }
212
+
213
+ export { CjsResManQueue, CjsResManQueueCancelledError, CjsResManWorkQueue, NormalizeCjsResManQueue };
214
+ //# sourceMappingURL=CjsResManQueue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CjsResManQueue.js","sources":["../../src/CjsResManQueue.js"],"sourcesContent":["export const CjsResManQueue = Object.freeze({\n MAIN: \"main\",\n BACKGROUND: \"background\",\n PREPARE: \"main\",\n LOAD: \"background\"\n});\n\nexport function NormalizeCjsResManQueue(value) {\n const name = String(value ?? \"\").trim().toLowerCase();\n if (name === \"main\" || name === \"prepare\") return CjsResManQueue.MAIN;\n if (name === \"background\" || name === \"load\") return CjsResManQueue.BACKGROUND;\n throw new TypeError(`Unknown CjsResMan queue: ${value}`);\n}\n\nexport function CjsResManQueueCancelledError(queue, id, reason = \"\") {\n const error = new Error(`CjsResMan ${queue} queue item ${id} was cancelled.${reason ? ` ${reason}` : \"\"}`);\n error.code = \"CJS_RESMAN_QUEUE_CANCELLED\";\n error.queue = queue;\n error.id = id;\n return error;\n}\n\n/**\n * Small FIFO executor used internally by CjsResMan.\n *\n * Queue policy stays in the manager. This class only tracks ids, pause state,\n * concurrency, cancellation, and sync/async completion.\n */\nexport class CjsResManWorkQueue\n{\n #active = new Map();\n #concurrency = 1;\n #head = 0;\n #items = [];\n #name;\n #nextId = 1;\n #onReady;\n #paused = false;\n #queued = new Map();\n\n constructor(name, options = {}) {\n this.#name = NormalizeCjsResManQueue(name);\n this.#onReady = typeof options.onReady === \"function\" ? options.onReady : null;\n this.SetConcurrency(options.concurrency ?? 1);\n }\n\n SetConcurrency(value) {\n if (!Number.isInteger(value) || value < 1) {\n throw new TypeError(\"CjsResMan queue concurrency must be a positive integer.\");\n }\n this.#concurrency = value;\n this.#NotifyReady();\n return this;\n }\n\n GetConcurrency() {\n return this.#concurrency;\n }\n\n GetNextId() {\n return this.#nextId;\n }\n\n GetQueuedCount() {\n return this.#queued.size;\n }\n\n GetActiveCount() {\n return this.#active.size;\n }\n\n GetPendingCount() {\n return this.#queued.size + this.#active.size;\n }\n\n IsPaused() {\n return this.#paused;\n }\n\n Add(callback, context = null, metadata = null) {\n if (typeof callback !== \"function\") {\n throw new TypeError(\"CjsResMan queue items require a callback.\");\n }\n\n const id = this.#nextId++;\n let resolve;\n let reject;\n const promise = new Promise((onResolve, onReject) => {\n resolve = onResolve;\n reject = onReject;\n });\n const item = {\n id,\n queue: this.#name,\n callback,\n context,\n metadata,\n promise,\n resolve,\n reject,\n state: \"queued\"\n };\n\n this.#items.push(item);\n this.#queued.set(id, item);\n this.#NotifyReady();\n return item;\n }\n\n Cancel(id, reason = \"\") {\n const item = this.#queued.get(id);\n if (!item) return false;\n this.#queued.delete(id);\n item.state = \"cancelled\";\n item.reject(CjsResManQueueCancelledError(this.#name, id, reason));\n this.#Compact();\n return true;\n }\n\n Pause() {\n this.#paused = true;\n return this;\n }\n\n Resume() {\n if (!this.#paused) return this;\n this.#paused = false;\n this.#NotifyReady();\n return this;\n }\n\n Clear(reason = \"Queue cleared.\") {\n const ids = [ ...this.#queued.keys() ];\n for (const id of ids) this.Cancel(id, reason);\n this.#Compact(true);\n return ids.length;\n }\n\n Pump(options = {}) {\n const maxItems = NormalizeLimit(options.maxItems);\n const maxTime = NormalizeLimit(options.maxTime);\n const now = typeof options.now === \"function\" ? options.now : DefaultNow;\n const startedAt = now();\n let processed = 0;\n\n if (!this.#paused) {\n while (this.#active.size < this.#concurrency && processed < maxItems) {\n const item = this.#TakeNext();\n if (!item) break;\n this.#Start(item);\n processed++;\n if (processed > 0 && now() - startedAt >= maxTime) break;\n }\n }\n\n this.#Compact();\n return Object.freeze({\n processed,\n queued: this.GetQueuedCount(),\n active: this.GetActiveCount(),\n pending: this.GetPendingCount(),\n paused: this.#paused\n });\n }\n\n GetStats() {\n return Object.freeze({\n name: this.#name,\n nextId: this.#nextId,\n concurrency: this.#concurrency,\n queued: this.GetQueuedCount(),\n active: this.GetActiveCount(),\n pending: this.GetPendingCount(),\n paused: this.#paused\n });\n }\n\n #TakeNext() {\n while (this.#head < this.#items.length) {\n const item = this.#items[this.#head++];\n if (item.state !== \"queued\") continue;\n this.#queued.delete(item.id);\n return item;\n }\n return null;\n }\n\n #Start(item) {\n item.state = \"active\";\n this.#active.set(item.id, item);\n\n let result;\n try {\n result = item.callback.call(item.context, Object.freeze({\n id: item.id,\n queue: item.queue,\n metadata: item.metadata\n }));\n } catch (error) {\n this.#Settle(item, false, error);\n return;\n }\n\n if (result && typeof result.then === \"function\") {\n Promise.resolve(result).then(\n value => this.#Settle(item, true, value),\n error => this.#Settle(item, false, error)\n );\n return;\n }\n this.#Settle(item, true, result);\n }\n\n #Settle(item, didResolve, value) {\n if (!this.#active.delete(item.id)) return;\n item.state = didResolve ? \"resolved\" : \"rejected\";\n if (didResolve) item.resolve(value);\n else item.reject(value);\n this.#NotifyReady();\n }\n\n #Compact(force = false) {\n if (force || (this.#head > 256 && this.#head > this.#items.length * 0.5)) {\n this.#items = this.#items.slice(this.#head);\n this.#head = 0;\n }\n }\n\n #NotifyReady() {\n if (this.#onReady && !this.#paused && this.GetQueuedCount() > 0) {\n this.#onReady(this);\n }\n }\n}\n\nfunction NormalizeLimit(value) {\n if (value === undefined || value === null || value === 0) return Number.POSITIVE_INFINITY;\n if (typeof value !== \"number\" || Number.isNaN(value) || value < 0) {\n throw new TypeError(\"CjsResMan queue limits must be non-negative numbers.\");\n }\n return value;\n}\n\nfunction DefaultNow() {\n return globalThis.performance?.now?.() ?? Date.now();\n}\n"],"names":["CjsResManQueue","Object","freeze","MAIN","BACKGROUND","PREPARE","LOAD","NormalizeCjsResManQueue","value","name","String","trim","toLowerCase","TypeError","CjsResManQueueCancelledError","queue","id","reason","error","Error","code","CjsResManWorkQueue","Map","constructor","options","onReady","SetConcurrency","concurrency","Number","isInteger","GetConcurrency","GetNextId","GetQueuedCount","size","GetActiveCount","GetPendingCount","IsPaused","Add","callback","context","metadata","resolve","reject","promise","Promise","onResolve","onReject","item","state","push","set","Cancel","get","delete","Pause","Resume","Clear","ids","keys","length","Pump","maxItems","NormalizeLimit","maxTime","now","DefaultNow","startedAt","processed","queued","active","pending","paused","GetStats","nextId","#TakeNext","#Start","result","call","then","#Settle","didResolve","#Compact","force","slice","#NotifyReady","undefined","POSITIVE_INFINITY","isNaN","globalThis","performance","Date"],"mappings":"MAAaA,cAAc,GAAGC,MAAM,CAACC,MAAM,CAAC;AAC1CC,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,UAAU,EAAE,YAAY;AACxBC,EAAAA,OAAO,EAAE,MAAM;AACfC,EAAAA,IAAI,EAAE;AACR,CAAC;AAEM,SAASC,uBAAuBA,CAACC,KAAK,EAAE;AAC7C,EAAA,MAAMC,IAAI,GAAGC,MAAM,CAACF,KAAK,IAAI,EAAE,CAAC,CAACG,IAAI,EAAE,CAACC,WAAW,EAAE;EACrD,IAAIH,IAAI,KAAK,MAAM,IAAIA,IAAI,KAAK,SAAS,EAAE,OAAOT,cAAc,CAACG,IAAI;EACrE,IAAIM,IAAI,KAAK,YAAY,IAAIA,IAAI,KAAK,MAAM,EAAE,OAAOT,cAAc,CAACI,UAAU;AAC9E,EAAA,MAAM,IAAIS,SAAS,CAAC,CAAA,yBAAA,EAA4BL,KAAK,EAAE,CAAC;AAC1D;AAEO,SAASM,4BAA4BA,CAACC,KAAK,EAAEC,EAAE,EAAEC,MAAM,GAAG,EAAE,EAAE;AACnE,EAAA,MAAMC,KAAK,GAAG,IAAIC,KAAK,CAAC,CAAA,UAAA,EAAaJ,KAAK,CAAA,YAAA,EAAeC,EAAE,CAAA,eAAA,EAAkBC,M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