@carbonenginejs/runtime-resource 0.9.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/NOTICE +3 -2
  2. package/README.md +47 -6
  3. package/dist/CjsMotherLode.js +88 -88
  4. package/dist/CjsMotherLode.js.map +1 -1
  5. package/dist/CjsResMan.js +718 -229
  6. package/dist/CjsResMan.js.map +1 -1
  7. package/dist/CjsResManFetchProvider.js +94 -0
  8. package/dist/CjsResManFetchProvider.js.map +1 -0
  9. package/dist/{CjsResManQueue.js → CjsResManWorkQueue.js} +112 -25
  10. package/dist/CjsResManWorkQueue.js.map +1 -0
  11. package/dist/format/CjsBlueReader.js +91 -2
  12. package/dist/format/CjsBlueReader.js.map +1 -1
  13. package/dist/format/CjsFormat.js +47 -21
  14. package/dist/format/CjsFormat.js.map +1 -1
  15. package/dist/format/CjsReader.js +4 -0
  16. package/dist/format/CjsReader.js.map +1 -1
  17. package/dist/format/CjsResourceProbe.js +4 -2
  18. package/dist/format/CjsResourceProbe.js.map +1 -1
  19. package/dist/format/payloadContract.js +20 -0
  20. package/dist/format/payloadContract.js.map +1 -1
  21. package/dist/formats/black/CjsBlackFormat.js +15 -1
  22. package/dist/formats/black/CjsBlackFormat.js.map +1 -1
  23. package/dist/formats/black/core/CjsBlackBinaryReader.js +103 -0
  24. package/dist/formats/black/core/CjsBlackBinaryReader.js.map +1 -1
  25. package/dist/formats/black/core/CjsBlackPropertyReaders.js +62 -1
  26. package/dist/formats/black/core/CjsBlackPropertyReaders.js.map +1 -1
  27. package/dist/formats/black/core/CjsBlackReader.js +127 -2
  28. package/dist/formats/black/core/CjsBlackReader.js.map +1 -1
  29. package/dist/formats/black/core/CjsBlackSchemaRegistry.js +103 -0
  30. package/dist/formats/black/core/CjsBlackSchemaRegistry.js.map +1 -1
  31. package/dist/formats/black/core/helpers.js +17 -0
  32. package/dist/formats/black/core/helpers.js.map +1 -1
  33. package/dist/formats/bnk/CjsBnkFormat.js +8 -0
  34. package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
  35. package/dist/formats/bnk/core/helpers.js +20 -0
  36. package/dist/formats/bnk/core/helpers.js.map +1 -1
  37. package/dist/formats/bnk/core/musicNodes.js +40 -3
  38. package/dist/formats/bnk/core/musicNodes.js.map +1 -1
  39. package/dist/formats/bnk/core/soundbanksInfo.js +2 -0
  40. package/dist/formats/bnk/core/soundbanksInfo.js.map +1 -1
  41. package/dist/formats/cmf/core/binary.js +71 -0
  42. package/dist/formats/cmf/core/binary.js.map +1 -1
  43. package/dist/formats/cmf/core/buffers.js +4 -0
  44. package/dist/formats/cmf/core/buffers.js.map +1 -1
  45. package/dist/formats/cmf/core/helpers.js +31 -0
  46. package/dist/formats/cmf/core/helpers.js.map +1 -1
  47. package/dist/formats/cmf/core/schema.js +10 -0
  48. package/dist/formats/cmf/core/schema.js.map +1 -1
  49. package/dist/formats/cmf/core/shared.js +9 -0
  50. package/dist/formats/cmf/core/shared.js.map +1 -1
  51. package/dist/formats/cmf/core/writer.js +54 -0
  52. package/dist/formats/cmf/core/writer.js.map +1 -1
  53. package/dist/formats/dds/core/bc6h.js +10 -0
  54. package/dist/formats/dds/core/bc6h.js.map +1 -1
  55. package/dist/formats/dds/core/bc7.js +16 -0
  56. package/dist/formats/dds/core/bc7.js.map +1 -1
  57. package/dist/formats/dds/core/helpers.js +47 -0
  58. package/dist/formats/dds/core/helpers.js.map +1 -1
  59. package/dist/formats/fbx/core/helpers.js +22 -1
  60. package/dist/formats/fbx/core/helpers.js.map +1 -1
  61. package/dist/formats/flac/CjsFlacFormat.js +49 -0
  62. package/dist/formats/flac/CjsFlacFormat.js.map +1 -1
  63. package/dist/formats/flac/core/helpers.js +20 -0
  64. package/dist/formats/flac/core/helpers.js.map +1 -1
  65. package/dist/formats/gif/CjsGifFormat.js +49 -0
  66. package/dist/formats/gif/CjsGifFormat.js.map +1 -1
  67. package/dist/formats/gif/core/helpers.js +20 -0
  68. package/dist/formats/gif/core/helpers.js.map +1 -1
  69. package/dist/formats/gltf/core/helpers.js +18 -3
  70. package/dist/formats/gltf/core/helpers.js.map +1 -1
  71. package/dist/formats/gltf/core/parser.js +13 -0
  72. package/dist/formats/gltf/core/parser.js.map +1 -1
  73. package/dist/formats/gltf/core/targets.js +10 -0
  74. package/dist/formats/gltf/core/targets.js.map +1 -1
  75. package/dist/formats/gr2/core/bitknit2.js +2 -0
  76. package/dist/formats/gr2/core/bitknit2.js.map +1 -1
  77. package/dist/formats/gr2/core/helpers.js +20 -0
  78. package/dist/formats/gr2/core/helpers.js.map +1 -1
  79. package/dist/formats/gr2/core/tangents.js +9 -9
  80. package/dist/formats/gr2/core/tangents.js.map +1 -1
  81. package/dist/formats/gr2/core/targets.js +10 -0
  82. package/dist/formats/gr2/core/targets.js.map +1 -1
  83. package/dist/formats/index.js +4 -4
  84. package/dist/formats/jpeg/core/helpers.js +52 -0
  85. package/dist/formats/jpeg/core/helpers.js.map +1 -1
  86. package/dist/formats/jpeg/core/jpeg.js +93 -0
  87. package/dist/formats/jpeg/core/jpeg.js.map +1 -1
  88. package/dist/formats/mp3/core/helpers.js +37 -0
  89. package/dist/formats/mp3/core/helpers.js.map +1 -1
  90. package/dist/formats/mp4/core/helpers.js +35 -0
  91. package/dist/formats/mp4/core/helpers.js.map +1 -1
  92. package/dist/formats/obj/core/helpers.js +2 -2
  93. package/dist/formats/obj/core/helpers.js.map +1 -1
  94. package/dist/formats/ogg/CjsOggFormat.js +49 -0
  95. package/dist/formats/ogg/CjsOggFormat.js.map +1 -1
  96. package/dist/formats/ogg/core/helpers.js +23 -0
  97. package/dist/formats/ogg/core/helpers.js.map +1 -1
  98. package/dist/formats/ogg/core/vorbis.js +13 -0
  99. package/dist/formats/ogg/core/vorbis.js.map +1 -1
  100. package/dist/formats/png/core/helpers.js +52 -0
  101. package/dist/formats/png/core/helpers.js.map +1 -1
  102. package/dist/formats/red/CjsRedFormat.js +3 -1
  103. package/dist/formats/red/CjsRedFormat.js.map +1 -1
  104. package/dist/formats/red/core/CjsRedReader.js +52 -0
  105. package/dist/formats/red/core/CjsRedReader.js.map +1 -1
  106. package/dist/formats/red/core/helpers.js +19 -0
  107. package/dist/formats/red/core/helpers.js.map +1 -1
  108. package/dist/formats/stl/core/stl.js +10 -2
  109. package/dist/formats/stl/core/stl.js.map +1 -1
  110. package/dist/formats/stl/core/targets.js +10 -0
  111. package/dist/formats/stl/core/targets.js.map +1 -1
  112. package/dist/formats/tga/core/helpers.js +47 -0
  113. package/dist/formats/tga/core/helpers.js.map +1 -1
  114. package/dist/formats/wav/core/helpers.js +37 -0
  115. package/dist/formats/wav/core/helpers.js.map +1 -1
  116. package/dist/formats/webm/core/helpers.js +35 -0
  117. package/dist/formats/webm/core/helpers.js.map +1 -1
  118. package/dist/formats/webp/CjsWebpFormat.js +49 -0
  119. package/dist/formats/webp/CjsWebpFormat.js.map +1 -1
  120. package/dist/formats/webp/core/helpers.js +23 -0
  121. package/dist/formats/webp/core/helpers.js.map +1 -1
  122. package/dist/formats/wem/CjsWemFormat.js +8 -0
  123. package/dist/formats/wem/CjsWemFormat.js.map +1 -1
  124. package/dist/formats/wem/core/bitStream.js +2 -0
  125. package/dist/formats/wem/core/bitStream.js.map +1 -1
  126. package/dist/formats/wem/core/helpers.js +20 -0
  127. package/dist/formats/wem/core/helpers.js.map +1 -1
  128. package/dist/formats/yaml/CjsYamlFormat.js +45 -0
  129. package/dist/formats/yaml/CjsYamlFormat.js.map +1 -1
  130. package/dist/formats/yaml/core/CjsYamlReader.js +91 -0
  131. package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -1
  132. package/dist/formats/yaml/core/helpers.js +10 -0
  133. package/dist/formats/yaml/core/helpers.js.map +1 -1
  134. package/dist/index.js +57 -44
  135. package/dist/index.js.map +1 -1
  136. package/dist/{CjsResource.js → resource/CjsResource.js} +234 -19
  137. package/dist/resource/CjsResource.js.map +1 -0
  138. package/dist/{resources → resource}/Tr2LightProfileRes.js +5 -4
  139. package/dist/resource/Tr2LightProfileRes.js.map +1 -0
  140. package/dist/{resources → resource/audio}/AudioGeometryResData.js +4 -4
  141. package/dist/resource/audio/AudioGeometryResData.js.map +1 -0
  142. package/dist/resource/audio/CjsAudioBufferRes.js +86 -0
  143. package/dist/resource/audio/CjsAudioBufferRes.js.map +1 -0
  144. package/dist/resource/audio/CjsAudioRes.js +213 -0
  145. package/dist/resource/audio/CjsAudioRes.js.map +1 -0
  146. package/dist/resource/audio/index.js +4 -0
  147. package/dist/resource/audio/index.js.map +1 -0
  148. package/dist/{resources → resource/geometry}/MeshDecalData.js +3 -3
  149. package/dist/resource/geometry/MeshDecalData.js.map +1 -0
  150. package/dist/{resources → resource/geometry}/MeshDecalLodData.js +3 -3
  151. package/dist/resource/geometry/MeshDecalLodData.js.map +1 -0
  152. package/dist/resource/geometry/TriGeometryRes.js +656 -0
  153. package/dist/resource/geometry/TriGeometryRes.js.map +1 -0
  154. package/dist/{resources → resource/geometry}/TriGeometryResAreaData.js +4 -4
  155. package/dist/resource/geometry/TriGeometryResAreaData.js.map +1 -0
  156. package/dist/{resources → resource/geometry}/TriGeometryResJointData.js +4 -4
  157. package/dist/resource/geometry/TriGeometryResJointData.js.map +1 -0
  158. package/dist/{resources → resource/geometry}/TriGeometryResLodData.js +3 -3
  159. package/dist/resource/geometry/TriGeometryResLodData.js.map +1 -0
  160. package/dist/{resources → resource/geometry}/TriGeometryResMeshData.js +5 -5
  161. package/dist/resource/geometry/TriGeometryResMeshData.js.map +1 -0
  162. package/dist/{resources → resource/geometry}/TriGeometryResSkeletonData.js +3 -3
  163. package/dist/resource/geometry/TriGeometryResSkeletonData.js.map +1 -0
  164. package/dist/{resources → resource/geometry}/TriJointBinding.js +4 -4
  165. package/dist/resource/geometry/TriJointBinding.js.map +1 -0
  166. package/dist/{resources → resource/geometry}/TriMorphTargetGeometryConstants.js +3 -3
  167. package/dist/resource/geometry/TriMorphTargetGeometryConstants.js.map +1 -0
  168. package/dist/{resources → resource/geometry}/TriRtGeometryConstants.js +3 -3
  169. package/dist/resource/geometry/TriRtGeometryConstants.js.map +1 -0
  170. package/dist/{resources → resource/geometry/granny}/GStateBindingCallbackData.js +3 -3
  171. package/dist/resource/geometry/granny/GStateBindingCallbackData.js.map +1 -0
  172. package/dist/{resources → resource/geometry/granny}/Tr2GrannyIntersectionResult.js +5 -5
  173. package/dist/resource/geometry/granny/Tr2GrannyIntersectionResult.js.map +1 -0
  174. package/dist/{resources → resource/geometry/granny}/Tr2GrannyStateRes.js +7 -6
  175. package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -0
  176. package/dist/{resources → resource/geometry/granny}/TriGrannyRes.js +7 -6
  177. package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -0
  178. package/dist/{resources → resource/geometry/granny}/enums.js +1 -9
  179. package/dist/resource/geometry/granny/enums.js.map +1 -0
  180. package/dist/resource/geometry/granny/index.js +6 -0
  181. package/dist/resource/geometry/granny/index.js.map +1 -0
  182. package/dist/resource/geometry/index.js +17 -0
  183. package/dist/resource/geometry/index.js.map +1 -0
  184. package/dist/resource/index.js +52 -0
  185. package/dist/resource/index.js.map +1 -0
  186. package/dist/resource/resourceBoundary.js +64 -0
  187. package/dist/resource/resourceBoundary.js.map +1 -0
  188. package/dist/resource/shader/Tr2EffectRes.js +420 -0
  189. package/dist/resource/shader/Tr2EffectRes.js.map +1 -0
  190. package/dist/{resources → resource/shader}/Tr2MaterialArea.js +11 -6
  191. package/dist/resource/shader/Tr2MaterialArea.js.map +1 -0
  192. package/dist/{resources → resource/shader}/Tr2MaterialMesh.js +10 -5
  193. package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -0
  194. package/dist/{resources → resource/shader}/Tr2MaterialRes.js +12 -6
  195. package/dist/resource/shader/Tr2MaterialRes.js.map +1 -0
  196. package/dist/resource/shader/Tr2Shader.js +250 -0
  197. package/dist/resource/shader/Tr2Shader.js.map +1 -0
  198. package/dist/{resources → resource/shader}/Tr2ShaderPermutation.js +15 -9
  199. package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -0
  200. package/dist/resource/shader/index.js +17 -0
  201. package/dist/resource/shader/index.js.map +1 -0
  202. package/dist/resource/shader/portable.js +33 -0
  203. package/dist/resource/shader/portable.js.map +1 -0
  204. package/dist/resource/shader/portableValidation.js +461 -0
  205. package/dist/resource/shader/portableValidation.js.map +1 -0
  206. package/dist/resource/shader/reflection/Tr2EffectConstant.js +100 -0
  207. package/dist/resource/shader/reflection/Tr2EffectConstant.js.map +1 -0
  208. package/dist/resource/shader/reflection/Tr2EffectDefine.js +34 -0
  209. package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -0
  210. package/dist/resource/shader/reflection/Tr2EffectDescription.js +113 -0
  211. package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -0
  212. package/dist/resource/shader/reflection/Tr2EffectLibrary.js +141 -0
  213. package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -0
  214. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +107 -0
  215. package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -0
  216. package/dist/resource/shader/reflection/Tr2EffectResource.js +90 -0
  217. package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -0
  218. package/dist/resource/shader/reflection/Tr2EffectStageInput.js +235 -0
  219. package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -0
  220. package/dist/resource/shader/reflection/Tr2EffectTechnique.js +71 -0
  221. package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -0
  222. package/dist/resource/shader/reflection/Tr2Pass.js +111 -0
  223. package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -0
  224. package/dist/resource/shader/sampler/Tr2SamplerSetup.js +80 -0
  225. package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -0
  226. package/dist/{texture → resource/texture}/CjsTextureArrayRes.js +84 -7
  227. package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -0
  228. package/dist/{texture/CjsTextureParameterProxy.js → resource/texture/CjsTextureArrayResParameterProxy.js} +57 -11
  229. package/dist/resource/texture/CjsTextureArrayResParameterProxy.js.map +1 -0
  230. package/dist/{resources → resource/texture}/Tr2ImageRes.js +7 -5
  231. package/dist/resource/texture/Tr2ImageRes.js.map +1 -0
  232. package/dist/{resources → resource/texture}/Tr2TextureLodManager.js +5 -3
  233. package/dist/resource/texture/Tr2TextureLodManager.js.map +1 -0
  234. package/dist/{resources → resource/texture}/Tr2TextureLodUpdateRequest.js +3 -3
  235. package/dist/resource/texture/Tr2TextureLodUpdateRequest.js.map +1 -0
  236. package/dist/{resources → resource/texture}/Tr2TexturePackChannel.js +3 -3
  237. package/dist/resource/texture/Tr2TexturePackChannel.js.map +1 -0
  238. package/dist/{resources → resource/texture}/Tr2TexturePipeline.js +8 -6
  239. package/dist/resource/texture/Tr2TexturePipeline.js.map +1 -0
  240. package/dist/{resources → resource/texture}/Tr2TexturePipelineParams.js +3 -3
  241. package/dist/resource/texture/Tr2TexturePipelineParams.js.map +1 -0
  242. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepCompress.js +3 -3
  243. package/dist/resource/texture/Tr2TexturePipelineStepCompress.js.map +1 -0
  244. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepGenerateMips.js +3 -3
  245. package/dist/resource/texture/Tr2TexturePipelineStepGenerateMips.js.map +1 -0
  246. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepLimitSize.js +3 -3
  247. package/dist/resource/texture/Tr2TexturePipelineStepLimitSize.js.map +1 -0
  248. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepLoad.js +3 -3
  249. package/dist/resource/texture/Tr2TexturePipelineStepLoad.js.map +1 -0
  250. package/dist/{resources → resource/texture}/Tr2TexturePipelineStepPack.js +3 -3
  251. package/dist/resource/texture/Tr2TexturePipelineStepPack.js.map +1 -0
  252. package/dist/{resources → resource/texture}/TriTextureRes.js +43 -27
  253. package/dist/resource/texture/TriTextureRes.js.map +1 -0
  254. package/dist/resource/texture/index.js +15 -0
  255. package/dist/resource/texture/index.js.map +1 -0
  256. package/dist/{resources → resource/texture}/texturePipelineBehavior.js +61 -61
  257. package/dist/resource/texture/texturePipelineBehavior.js.map +1 -0
  258. package/dist/worker/CjsResManMainThreadLoader.js +87 -0
  259. package/dist/worker/CjsResManMainThreadLoader.js.map +1 -0
  260. package/dist/worker/CjsResManWorker.js +217 -0
  261. package/dist/worker/CjsResManWorker.js.map +1 -0
  262. package/dist/worker/CjsResManWorkerLoader.js +434 -0
  263. package/dist/worker/CjsResManWorkerLoader.js.map +1 -0
  264. package/dist/worker/protocol.js +12 -0
  265. package/dist/worker/protocol.js.map +1 -0
  266. package/docs/README.md +18 -5
  267. package/docs/architecture.md +40 -17
  268. package/docs/concepts/resource-lifecycle.md +2 -1
  269. package/docs/formats/README.md +4 -0
  270. package/docs/reference/classes/README.md +6 -4
  271. package/docs/reference/classes/audio.md +30 -0
  272. package/docs/reference/classes/core.md +31 -11
  273. package/docs/reference/classes/formats.md +1 -1
  274. package/docs/reference/classes/resources.md +151 -41
  275. package/docs/reference/classes/texture.md +7 -7
  276. package/docs/reference/events.md +1 -1
  277. package/docs/reference/motherlode-cache.md +17 -0
  278. package/docs/reference/queues.md +9 -1
  279. package/docs/reference/workers.md +135 -0
  280. package/docs/roadmap.md +27 -1
  281. package/format-notices/black/NOTICE +1 -1
  282. package/package.json +9 -4
  283. package/dist/CjsResManQueue.js.map +0 -1
  284. package/dist/CjsResource.js.map +0 -1
  285. package/dist/CjsResourceSource.js +0 -68
  286. package/dist/CjsResourceSource.js.map +0 -1
  287. package/dist/resourcePath.js +0 -18
  288. package/dist/resourcePath.js.map +0 -1
  289. package/dist/resourceStates.js +0 -9
  290. package/dist/resourceStates.js.map +0 -1
  291. package/dist/resources/AudioGeometryResData.js.map +0 -1
  292. package/dist/resources/GStateBindingCallbackData.js.map +0 -1
  293. package/dist/resources/MeshDecalData.js.map +0 -1
  294. package/dist/resources/MeshDecalLodData.js.map +0 -1
  295. package/dist/resources/Tr2EffectRes.js +0 -71
  296. package/dist/resources/Tr2EffectRes.js.map +0 -1
  297. package/dist/resources/Tr2GrannyIntersectionResult.js.map +0 -1
  298. package/dist/resources/Tr2GrannyStateRes.js.map +0 -1
  299. package/dist/resources/Tr2ImageRes.js.map +0 -1
  300. package/dist/resources/Tr2LightProfileRes.js.map +0 -1
  301. package/dist/resources/Tr2MaterialArea.js.map +0 -1
  302. package/dist/resources/Tr2MaterialMesh.js.map +0 -1
  303. package/dist/resources/Tr2MaterialRes.js.map +0 -1
  304. package/dist/resources/Tr2ShaderPermutation.js.map +0 -1
  305. package/dist/resources/Tr2TextureLodManager.js.map +0 -1
  306. package/dist/resources/Tr2TextureLodUpdateRequest.js.map +0 -1
  307. package/dist/resources/Tr2TexturePackChannel.js.map +0 -1
  308. package/dist/resources/Tr2TexturePipeline.js.map +0 -1
  309. package/dist/resources/Tr2TexturePipelineParams.js.map +0 -1
  310. package/dist/resources/Tr2TexturePipelineStepCompress.js.map +0 -1
  311. package/dist/resources/Tr2TexturePipelineStepGenerateMips.js.map +0 -1
  312. package/dist/resources/Tr2TexturePipelineStepLimitSize.js.map +0 -1
  313. package/dist/resources/Tr2TexturePipelineStepLoad.js.map +0 -1
  314. package/dist/resources/Tr2TexturePipelineStepPack.js.map +0 -1
  315. package/dist/resources/TriGeometryRes.js +0 -239
  316. package/dist/resources/TriGeometryRes.js.map +0 -1
  317. package/dist/resources/TriGeometryResAreaData.js.map +0 -1
  318. package/dist/resources/TriGeometryResJointData.js.map +0 -1
  319. package/dist/resources/TriGeometryResLodData.js.map +0 -1
  320. package/dist/resources/TriGeometryResMeshData.js.map +0 -1
  321. package/dist/resources/TriGeometryResSkeletonData.js.map +0 -1
  322. package/dist/resources/TriGrannyRes.js.map +0 -1
  323. package/dist/resources/TriJointBinding.js.map +0 -1
  324. package/dist/resources/TriMorphTargetGeometryConstants.js.map +0 -1
  325. package/dist/resources/TriRtGeometryConstants.js.map +0 -1
  326. package/dist/resources/TriTextureRes.js.map +0 -1
  327. package/dist/resources/enums.js.map +0 -1
  328. package/dist/resources/resourceBoundary.js +0 -47
  329. package/dist/resources/resourceBoundary.js.map +0 -1
  330. package/dist/resources/texturePipelineBehavior.js.map +0 -1
  331. package/dist/texture/CjsTextureArrayRes.js.map +0 -1
  332. package/dist/texture/CjsTextureParameterProxy.js.map +0 -1
@@ -0,0 +1,217 @@
1
+ import { Operation, Message } from './protocol.js';
2
+
3
+ /**
4
+ * Static browser-worker host that owns its operation/message vocabulary,
5
+ * executes clone-safe source and format operations, installs the message
6
+ * envelope, transfers owned buffers, and serializes failures for `CjsResMan`.
7
+ */
8
+ class CjsResManWorker {
9
+ /** Stable operations understood by the bundled resource module worker. */
10
+ static Operation = Operation;
11
+
12
+ /** Stable message kinds exchanged with the resource module worker. */
13
+ static Message = Message;
14
+
15
+ /**
16
+ * Execute one bundled resource worker operation.
17
+ *
18
+ * This method also permits deterministic non-browser tests and custom
19
+ * worker hosts without installing global message handlers.
20
+ *
21
+ * @param {string} operation Worker operation name.
22
+ * @param {*} payload Structured-cloneable operation payload.
23
+ * @param {object} [context={}] Optional fetch and abort context.
24
+ * @returns {Promise<*>} Operation result.
25
+ */
26
+ static async execute(operation, payload, context = {}) {
27
+ switch (operation) {
28
+ case Operation.FETCH:
29
+ return fetchResource(payload, context);
30
+ case Operation.FORMAT_READ:
31
+ return readFormat(payload);
32
+ default:
33
+ {
34
+ const error = new Error(`Unknown resource worker operation: ${operation}`);
35
+ error.code = "CJS_RESOURCE_WORKER_OPERATION_UNKNOWN";
36
+ error.operation = operation;
37
+ throw error;
38
+ }
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Install the ResMan message protocol on a Worker-compatible scope.
44
+ *
45
+ * @param {WorkerGlobalScope|object} scope Worker global.
46
+ * @returns {() => void} Uninstall callback.
47
+ */
48
+ static install(scope = globalThis) {
49
+ if (!scope || typeof scope.postMessage !== "function") {
50
+ throw new TypeError("Resource worker scope must provide postMessage.");
51
+ }
52
+ const controllers = new Map();
53
+ const onMessage = async event => {
54
+ const message = event?.data;
55
+ if (!message || typeof message !== "object") return;
56
+ if (message.type === Message.CANCEL) {
57
+ controllers.get(message.id)?.abort();
58
+ return;
59
+ }
60
+ if (message.type !== Message.EXECUTE) return;
61
+ const controller = typeof AbortController === "function" ? new AbortController() : null;
62
+ if (controller) controllers.set(message.id, controller);
63
+ try {
64
+ const result = await CjsResManWorker.execute(message.operation, message.payload, {
65
+ signal: controller?.signal
66
+ });
67
+ scope.postMessage({
68
+ type: Message.RESULT,
69
+ id: message.id,
70
+ ok: true,
71
+ result
72
+ }, CjsResManWorker.collectTransferables(result));
73
+ } catch (error) {
74
+ scope.postMessage({
75
+ type: Message.RESULT,
76
+ id: message.id,
77
+ ok: false,
78
+ error: CjsResManWorker.serializeError(error, message.operation)
79
+ });
80
+ } finally {
81
+ controllers.delete(message.id);
82
+ }
83
+ };
84
+ if (typeof scope.addEventListener === "function") {
85
+ scope.addEventListener("message", onMessage);
86
+ return () => scope.removeEventListener?.("message", onMessage);
87
+ }
88
+ const previous = scope.onmessage;
89
+ scope.onmessage = onMessage;
90
+ return () => {
91
+ if (scope.onmessage === onMessage) scope.onmessage = previous || null;
92
+ };
93
+ }
94
+
95
+ /**
96
+ * Collect unique transferable ArrayBuffers from a worker result.
97
+ *
98
+ * SharedArrayBuffer is intentionally excluded because it is shared rather
99
+ * than transferable.
100
+ *
101
+ * @param {*} value Result graph.
102
+ * @returns {ArrayBuffer[]} Transfer list.
103
+ */
104
+ static collectTransferables(value) {
105
+ const buffers = new Set();
106
+ const seen = new Set();
107
+ const visit = entry => {
108
+ if (entry === null || entry === undefined) return;
109
+ if (entry instanceof ArrayBuffer) {
110
+ buffers.add(entry);
111
+ return;
112
+ }
113
+ if (ArrayBuffer.isView(entry)) {
114
+ if (entry.buffer instanceof ArrayBuffer) buffers.add(entry.buffer);
115
+ return;
116
+ }
117
+ if (typeof entry !== "object" || seen.has(entry)) return;
118
+ seen.add(entry);
119
+ if (Array.isArray(entry)) {
120
+ for (const item of entry) visit(item);
121
+ return;
122
+ }
123
+ for (const item of Object.values(entry)) visit(item);
124
+ };
125
+ visit(value);
126
+ return [...buffers];
127
+ }
128
+
129
+ /**
130
+ * Convert an exception into a cloneable diagnostic.
131
+ *
132
+ * @param {*} value Failure value.
133
+ * @param {string} [operation] Operation name.
134
+ * @returns {object} Cloneable error data.
135
+ */
136
+ static serializeError(value, operation = undefined) {
137
+ return {
138
+ name: value?.name || "CjsResManWorkerError",
139
+ message: value?.message || String(value),
140
+ code: value?.code,
141
+ operation: value?.operation || operation,
142
+ path: value?.path,
143
+ status: value?.status,
144
+ statusText: value?.statusText
145
+ };
146
+ }
147
+ }
148
+ async function fetchResource(payload, context) {
149
+ if (!payload || typeof payload.url !== "string") {
150
+ throw new TypeError("Worker fetch requires a URL.");
151
+ }
152
+ const fetchImplementation = context.fetch || globalThis.fetch;
153
+ if (typeof fetchImplementation !== "function") {
154
+ throw new ReferenceError("Worker fetch is unavailable.");
155
+ }
156
+ const options = {
157
+ ...(payload.options || {}),
158
+ ...(context.signal ? {
159
+ signal: context.signal
160
+ } : {})
161
+ };
162
+ const response = await fetchImplementation(payload.url, options);
163
+ if (!response.ok) {
164
+ const error = new Error(`Resource fetch failed: ${response.status} ${response.statusText}`);
165
+ error.code = "CJS_RESOURCE_FETCH_FAILED";
166
+ error.path = payload.path;
167
+ error.status = response.status;
168
+ error.statusText = response.statusText;
169
+ throw error;
170
+ }
171
+ switch (payload.responseType || "arraybuffer") {
172
+ case "arraybuffer":
173
+ return response.arrayBuffer();
174
+ case "blob":
175
+ return response.blob();
176
+ case "json":
177
+ return response.json();
178
+ case "text":
179
+ return response.text();
180
+ default:
181
+ {
182
+ const error = new Error(`Unsupported worker fetch response type: ${payload.responseType}`);
183
+ error.code = "CJS_RESOURCE_WORKER_RESPONSE_TYPE";
184
+ throw error;
185
+ }
186
+ }
187
+ }
188
+ async function readFormat(payload) {
189
+ if (!payload || typeof payload.module !== "string" || payload.module === "") {
190
+ throw new TypeError("Worker format read requires a module URL.");
191
+ }
192
+ const module = await import(payload.module);
193
+ const Format = module[payload.exportName || "default"];
194
+ if (typeof Format !== "function") {
195
+ throw new TypeError(`Worker format export was not found: ${payload.exportName || "default"}`);
196
+ }
197
+ const options = payload.options || {};
198
+ if (typeof Format.readAsync === "function") {
199
+ return Format.readAsync(payload.input, options);
200
+ }
201
+ if (typeof Format.read === "function") {
202
+ return Format.read(payload.input, options);
203
+ }
204
+ const reader = new Format(options);
205
+ if (typeof reader.ReadAsync === "function") {
206
+ return reader.ReadAsync(payload.input, options);
207
+ }
208
+ if (typeof reader.Read === "function") {
209
+ return reader.Read(payload.input, options);
210
+ }
211
+ throw new TypeError(`${Format.name} does not expose a read operation.`);
212
+ }
213
+ const isWorkerScope = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
214
+ if (isWorkerScope) CjsResManWorker.install(globalThis);
215
+
216
+ export { CjsResManWorker };
217
+ //# sourceMappingURL=CjsResManWorker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CjsResManWorker.js","sources":["../../../src/worker/CjsResManWorker.js"],"sourcesContent":["import { Message, Operation } from \"./protocol.js\";\n\n/**\n * Static browser-worker host that owns its operation/message vocabulary,\n * executes clone-safe source and format operations, installs the message\n * envelope, transfers owned buffers, and serializes failures for `CjsResMan`.\n */\nexport class CjsResManWorker\n{\n /** Stable operations understood by the bundled resource module worker. */\n static Operation = Operation;\n\n /** Stable message kinds exchanged with the resource module worker. */\n static Message = Message;\n\n /**\n * Execute one bundled resource worker operation.\n *\n * This method also permits deterministic non-browser tests and custom\n * worker hosts without installing global message handlers.\n *\n * @param {string} operation Worker operation name.\n * @param {*} payload Structured-cloneable operation payload.\n * @param {object} [context={}] Optional fetch and abort context.\n * @returns {Promise<*>} Operation result.\n */\n static async execute(operation, payload, context = {})\n {\n switch (operation)\n {\n case Operation.FETCH:\n return fetchResource(payload, context);\n\n case Operation.FORMAT_READ:\n return readFormat(payload);\n\n default:\n {\n const error = new Error(`Unknown resource worker operation: ${operation}`);\n error.code = \"CJS_RESOURCE_WORKER_OPERATION_UNKNOWN\";\n error.operation = operation;\n throw error;\n }\n }\n }\n\n /**\n * Install the ResMan message protocol on a Worker-compatible scope.\n *\n * @param {WorkerGlobalScope|object} scope Worker global.\n * @returns {() => void} Uninstall callback.\n */\n static install(scope = globalThis)\n {\n if (!scope || typeof scope.postMessage !== \"function\")\n {\n throw new TypeError(\"Resource worker scope must provide postMessage.\");\n }\n const controllers = new Map();\n const onMessage = async event =>\n {\n const message = event?.data;\n if (!message || typeof message !== \"object\") return;\n\n if (message.type === Message.CANCEL)\n {\n controllers.get(message.id)?.abort();\n return;\n }\n if (message.type !== Message.EXECUTE) return;\n\n const controller = typeof AbortController === \"function\"\n ? new AbortController()\n : null;\n if (controller) controllers.set(message.id, controller);\n try\n {\n const result = await CjsResManWorker.execute(\n message.operation,\n message.payload,\n { signal: controller?.signal }\n );\n scope.postMessage({\n type: Message.RESULT,\n id: message.id,\n ok: true,\n result\n }, CjsResManWorker.collectTransferables(result));\n }\n catch (error)\n {\n scope.postMessage({\n type: Message.RESULT,\n id: message.id,\n ok: false,\n error: CjsResManWorker.serializeError(error, message.operation)\n });\n }\n finally\n {\n controllers.delete(message.id);\n }\n };\n\n if (typeof scope.addEventListener === \"function\")\n {\n scope.addEventListener(\"message\", onMessage);\n return () => scope.removeEventListener?.(\"message\", onMessage);\n }\n const previous = scope.onmessage;\n scope.onmessage = onMessage;\n return () =>\n {\n if (scope.onmessage === onMessage) scope.onmessage = previous || null;\n };\n }\n\n /**\n * Collect unique transferable ArrayBuffers from a worker result.\n *\n * SharedArrayBuffer is intentionally excluded because it is shared rather\n * than transferable.\n *\n * @param {*} value Result graph.\n * @returns {ArrayBuffer[]} Transfer list.\n */\n static collectTransferables(value)\n {\n const buffers = new Set();\n const seen = new Set();\n\n const visit = entry =>\n {\n if (entry === null || entry === undefined) return;\n if (entry instanceof ArrayBuffer)\n {\n buffers.add(entry);\n return;\n }\n if (ArrayBuffer.isView(entry))\n {\n if (entry.buffer instanceof ArrayBuffer) buffers.add(entry.buffer);\n return;\n }\n if (typeof entry !== \"object\" || seen.has(entry)) return;\n seen.add(entry);\n if (Array.isArray(entry))\n {\n for (const item of entry) visit(item);\n return;\n }\n for (const item of Object.values(entry)) visit(item);\n };\n\n visit(value);\n return [ ...buffers ];\n }\n\n /**\n * Convert an exception into a cloneable diagnostic.\n *\n * @param {*} value Failure value.\n * @param {string} [operation] Operation name.\n * @returns {object} Cloneable error data.\n */\n static serializeError(value, operation = undefined)\n {\n return {\n name: value?.name || \"CjsResManWorkerError\",\n message: value?.message || String(value),\n code: value?.code,\n operation: value?.operation || operation,\n path: value?.path,\n status: value?.status,\n statusText: value?.statusText\n };\n }\n}\n\nasync function fetchResource(payload, context) {\n if (!payload || typeof payload.url !== \"string\") {\n throw new TypeError(\"Worker fetch requires a URL.\");\n }\n const fetchImplementation = context.fetch || globalThis.fetch;\n if (typeof fetchImplementation !== \"function\") {\n throw new ReferenceError(\"Worker fetch is unavailable.\");\n }\n const options = {\n ...(payload.options || {}),\n ...(context.signal ? { signal: context.signal } : {})\n };\n const response = await fetchImplementation(payload.url, options);\n if (!response.ok) {\n const error = new Error(\n `Resource fetch failed: ${response.status} ${response.statusText}`\n );\n error.code = \"CJS_RESOURCE_FETCH_FAILED\";\n error.path = payload.path;\n error.status = response.status;\n error.statusText = response.statusText;\n throw error;\n }\n\n switch (payload.responseType || \"arraybuffer\") {\n case \"arraybuffer\":\n return response.arrayBuffer();\n case \"blob\":\n return response.blob();\n case \"json\":\n return response.json();\n case \"text\":\n return response.text();\n default: {\n const error = new Error(`Unsupported worker fetch response type: ${payload.responseType}`);\n error.code = \"CJS_RESOURCE_WORKER_RESPONSE_TYPE\";\n throw error;\n }\n }\n}\n\nasync function readFormat(payload) {\n if (!payload || typeof payload.module !== \"string\" || payload.module === \"\") {\n throw new TypeError(\"Worker format read requires a module URL.\");\n }\n const module = await import(payload.module);\n const Format = module[payload.exportName || \"default\"];\n if (typeof Format !== \"function\") {\n throw new TypeError(\n `Worker format export was not found: ${payload.exportName || \"default\"}`\n );\n }\n const options = payload.options || {};\n if (typeof Format.readAsync === \"function\") {\n return Format.readAsync(payload.input, options);\n }\n if (typeof Format.read === \"function\") {\n return Format.read(payload.input, options);\n }\n\n const reader = new Format(options);\n if (typeof reader.ReadAsync === \"function\") {\n return reader.ReadAsync(payload.input, options);\n }\n if (typeof reader.Read === \"function\") {\n return reader.Read(payload.input, options);\n }\n throw new TypeError(`${Format.name} does not expose a read operation.`);\n}\n\nconst isWorkerScope = typeof WorkerGlobalScope !== \"undefined\"\n && globalThis instanceof WorkerGlobalScope;\nif (isWorkerScope) CjsResManWorker.install(globalThis);\n"],"names":["CjsResManWorker","Operation","Message","execute","operation","payload","context","FETCH","fetchResource","FORMAT_READ","readFormat","error","Error","code","install","scope","globalThis","postMessage","TypeError","controllers","Map","onMessage","event","message","data","type","CANCEL","get","id","abort","EXECUTE","controller","AbortController","set","result","signal","RESULT","ok","collectTransferables","serializeError","delete","addEventListener","removeEventListener","previous","onmessage","value","buffers","Set","seen","visit","entry","undefined","ArrayBuffer","add","isView","buffer","has","Array","isArray","item","Object","values","name","String","path","status","statusText","url","fetchImplementation","fetch","ReferenceError","options","response","responseType","arrayBuffer","blob","json","text","module","Format","exportName","readAsync","input","read","reader","ReadAsync","Read","isWorkerScope","WorkerGlobalScope"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACO,MAAMA,eAAe,CAC5B;AACE;EACA,OAAOC,SAAS,GAAGA,SAAS;;AAE5B;EACA,OAAOC,OAAO,GAAGA,OAAO;;AAExB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,aAAaC,OAAOA,CAACC,SAAS,EAAEC,OAAO,EAAEC,OAAO,GAAG,EAAE,EACrD;AACE,IAAA,QAAQF,SAAS;MAEf,KAAKH,SAAS,CAACM,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K,UAAU,EAAE;IAChC,MAAM,IAAI7D,SAAS,CACjB,CAAA,oCAAA,EAAuCb,OAAO,CAAC2E,UAAU,IAAI,SAAS,CAAA,CACxE,CAAC;AACH,EAAA;AACA,EAAA,MAAMT,OAAO,GAAGlE,OAAO,CAACkE,OAAO,IAAI,EAAE;AACrC,EAAA,IAAI,OAAOQ,MAAM,CAACE,SAAS,KAAK,UAAU,EAAE;IAC1C,OAAOF,MAAM,CAACE,SAAS,CAAC5E,OAAO,CAAC6E,KAAK,EAAEX,OAAO,CAAC;AACjD,EAAA;AACA,EAAA,IAAI,OAAOQ,MAAM,CAACI,IAAI,KAAK,UAAU,EAAE;IACrC,OAAOJ,MAAM,CAACI,IAAI,CAAC9E,OAAO,CAAC6E,KAAK,EAAEX,OAAO,CAAC;AAC5C,EAAA;AAEA,EAAA,MAAMa,MAAM,GAAG,IAAIL,MAAM,CAACR,OAAO,CAAC;AAClC,EAAA,IAAI,OAAOa,MAAM,CAACC,SAAS,KAAK,UAAU,EAAE;IAC1C,OAAOD,MAAM,CAACC,SAAS,CAAChF,OAAO,CAAC6E,KAAK,EAAEX,OAAO,CAAC;AACjD,EAAA;AACA,EAAA,IAAI,OAAOa,MAAM,CAACE,IAAI,KAAK,UAAU,EAAE;IACrC,OAAOF,MAAM,CAACE,IAAI,CAACjF,OAAO,CAAC6E,KAAK,EAAEX,OAAO,CAAC;AAC5C,EAAA;EACA,MAAM,IAAIrD,SAAS,CAAC,CAAA,EAAG6D,MAAM,CAACjB,IAAI,oCAAoC,CAAC;AACzE;AAEA,MAAMyB,aAAa,GAAG,OAAOC,iBAAiB,KAAK,WAAW,IACzDxE,UAAU,YAAYwE,iBAAiB;AAC5C,IAAID,aAAa,EAAEvF,eAAe,CAACc,OAAO,CAACE,UAAU,CAAC;;;;"}
@@ -0,0 +1,434 @@
1
+ import { Operation, Message } from './protocol.js';
2
+ import { CjsResManMainThreadLoader } from './CjsResManMainThreadLoader.js';
3
+
4
+ const DEFAULT_WORKER_OPTIONS = Object.freeze({
5
+ type: "module",
6
+ name: "CjsResManWorker"
7
+ });
8
+
9
+ /**
10
+ * Browser module-worker strategy that correlates source/format requests, transfers owned buffers, propagates cancellation and fatal failure, and delegates unsupported operations to a main-thread loader.
11
+ *
12
+ * One module worker can overlap fetch requests and serializes synchronous
13
+ * reader work on its own event loop. Sources opt in through
14
+ * `CreateWorkerRequest(path, options)`. Formats opt in through a static
15
+ * `worker` declaration containing their module URL and export name.
16
+ */
17
+ class CjsResManWorkerLoader {
18
+ #boundError;
19
+ #boundMessage;
20
+ #nextId = 1;
21
+ #pending = new Map();
22
+
23
+ /**
24
+ * @param {object} [options={}] Worker construction and fallback options.
25
+ * @param {CjsResManMainThreadLoader|object} [options.fallback] Unsupported-operation fallback.
26
+ * @param {Worker|object} [options.worker] Existing Worker-compatible instance.
27
+ * @param {(url: string|URL, options: object) => Worker|object} [options.workerFactory] Worker factory.
28
+ * @param {string|URL} [options.workerUrl] Module worker entry URL.
29
+ * @param {object} [options.workerOptions] Options passed to the Worker constructor.
30
+ * @param {boolean} [options.enabled=true] Whether worker execution may be used.
31
+ */
32
+ constructor(options = {}) {
33
+ if (!options || typeof options !== "object" || Array.isArray(options)) {
34
+ throw new TypeError("CjsResManWorkerLoader options must be an object.");
35
+ }
36
+ this.fallback = options.fallback || new CjsResManMainThreadLoader();
37
+ assertResourceLoader(this.fallback, "fallback");
38
+ this.workerFactory = options.workerFactory || defaultWorkerFactory;
39
+ if (typeof this.workerFactory !== "function") {
40
+ throw new TypeError("CjsResManWorkerLoader workerFactory must be a function.");
41
+ }
42
+ this.workerUrl = options.workerUrl || new URL("./CjsResManWorker.js", import.meta.url);
43
+ this.workerOptions = Object.freeze({
44
+ ...DEFAULT_WORKER_OPTIONS,
45
+ ...(options.workerOptions || {})
46
+ });
47
+ this.enabled = options.enabled !== false;
48
+ this.failed = false;
49
+ this.worker = options.worker || null;
50
+ this.#boundMessage = event => this.#OnMessage(event);
51
+ this.#boundError = event => this.#OnError(event);
52
+ if (this.worker) this.#Attach(this.worker);
53
+ }
54
+
55
+ /**
56
+ * Enable and lazily create the configured worker.
57
+ *
58
+ * @param {string|URL} [workerUrl] Optional replacement worker URL.
59
+ * @returns {boolean} Whether a worker is ready.
60
+ */
61
+ Enable(workerUrl = this.workerUrl) {
62
+ this.enabled = true;
63
+ if (workerUrl !== undefined && workerUrl !== null) this.workerUrl = workerUrl;
64
+ if (this.worker) return true;
65
+ if (this.failed) return false;
66
+ try {
67
+ const worker = this.workerFactory(this.workerUrl, this.workerOptions);
68
+ if (!worker || typeof worker.postMessage !== "function") {
69
+ throw new TypeError("Worker factory did not return a Worker-compatible object.");
70
+ }
71
+ this.worker = worker;
72
+ this.#Attach(worker);
73
+ return true;
74
+ } catch {
75
+ this.worker = null;
76
+ this.failed = true;
77
+ return false;
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Stop worker use and reject every pending request.
83
+ *
84
+ * @param {*} [reason] Optional failure reason.
85
+ * @returns {CjsResManWorkerLoader} This loader.
86
+ */
87
+ Disable(reason = null) {
88
+ const worker = this.worker;
89
+ if (worker) {
90
+ this.#Detach(worker);
91
+ worker.terminate?.();
92
+ }
93
+ this.worker = null;
94
+ this.enabled = false;
95
+ this.failed = reason !== null && reason !== undefined;
96
+ if (this.#pending.size) {
97
+ const error = normalizeWorkerError(reason || createWorkerUnavailableError("Resource worker was disabled."));
98
+ for (const request of this.#pending.values()) {
99
+ cleanupPendingRequest(request);
100
+ request.reject(error);
101
+ }
102
+ this.#pending.clear();
103
+ }
104
+ return this;
105
+ }
106
+
107
+ /**
108
+ * Clear a previous creation/fatal failure so a later enable can retry.
109
+ *
110
+ * @returns {CjsResManWorkerLoader} This loader.
111
+ */
112
+ Reset() {
113
+ this.failed = false;
114
+ this.enabled = true;
115
+ return this;
116
+ }
117
+
118
+ /**
119
+ * Replace the unsupported-operation fallback.
120
+ *
121
+ * @param {CjsResManMainThreadLoader|object} fallback Loader exposing Read and ReadFormat.
122
+ * @returns {CjsResManWorkerLoader} This loader.
123
+ */
124
+ SetFallback(fallback) {
125
+ assertResourceLoader(fallback, "fallback");
126
+ this.fallback = fallback;
127
+ return this;
128
+ }
129
+
130
+ /**
131
+ * Report whether worker execution is configured and constructible.
132
+ *
133
+ * @returns {boolean}
134
+ */
135
+ IsAvailable() {
136
+ return this.enabled && (Boolean(this.worker) || this.Enable());
137
+ }
138
+
139
+ /**
140
+ * Read a source through its declared worker request, falling back when the
141
+ * source is not worker-aware or a worker cannot be created.
142
+ *
143
+ * @param {object|Function} source Source implementation.
144
+ * @param {string} path Normalized resource path.
145
+ * @param {object} [options={}] Source options.
146
+ * @returns {Promise<*>|*} Source result.
147
+ */
148
+ Read(source, path, options = {}) {
149
+ assertResourceSource(source);
150
+ if (typeof source.CreateWorkerRequest !== "function") {
151
+ return this.fallback.Read(source, path, options);
152
+ }
153
+ const request = normalizeWorkerRequest(source.CreateWorkerRequest(path, options));
154
+ if (!request || !this.IsAvailable()) {
155
+ return this.fallback.Read(source, path, options);
156
+ }
157
+ return this.Execute(request.operation, request.payload, {
158
+ signal: request.signal || options.signal,
159
+ transfer: request.transfer
160
+ });
161
+ }
162
+
163
+ /**
164
+ * Test whether a registered format can be safely dispatched to this worker.
165
+ *
166
+ * @param {object} descriptor Registered format descriptor.
167
+ * @param {object} [formatOptions={}] Normalized format options.
168
+ * @returns {boolean}
169
+ */
170
+ CanReadFormat(descriptor, formatOptions = {}) {
171
+ const declaration = normalizeFormatWorkerDeclaration(descriptor);
172
+ return Boolean(declaration && isWorkerFormatOutputSupported(declaration, formatOptions) && canCloneWorkerValue(formatOptions) && this.IsAvailable());
173
+ }
174
+
175
+ /**
176
+ * Execute a worker-safe format reader or use the main-thread fallback.
177
+ *
178
+ * Inputs are cloned by default so shared source-cache ownership is not
179
+ * detached. A format may explicitly declare `transferInput: true` when its
180
+ * caller guarantees exclusive ownership.
181
+ *
182
+ * @param {object} descriptor Registered format descriptor.
183
+ * @param {*} input Reader input.
184
+ * @param {object} [formatOptions={}] Normalized format options.
185
+ * @returns {Promise<*>} Format result.
186
+ */
187
+ ReadFormat(descriptor, input, formatOptions = {}) {
188
+ const declaration = normalizeFormatWorkerDeclaration(descriptor);
189
+ if (!declaration || !isWorkerFormatOutputSupported(declaration, formatOptions) || !canCloneWorkerValue(formatOptions) || !this.IsAvailable()) {
190
+ return this.fallback.ReadFormat(descriptor, input, formatOptions);
191
+ }
192
+ const transfer = declaration.transferInput ? getExclusiveInputTransferables(input) : [];
193
+ return this.Execute(Operation.FORMAT_READ, {
194
+ module: declaration.module,
195
+ exportName: declaration.exportName,
196
+ input,
197
+ options: formatOptions
198
+ }, {
199
+ transfer
200
+ });
201
+ }
202
+
203
+ /**
204
+ * Dispatch one operation using the stable worker message protocol.
205
+ *
206
+ * @param {string} operation Operation name.
207
+ * @param {*} payload Structured-cloneable operation payload.
208
+ * @param {object} [options={}] Transfer and cancellation options.
209
+ * @returns {Promise<*>} Worker result.
210
+ */
211
+ Execute(operation, payload, options = {}) {
212
+ if (typeof operation !== "string" || operation.trim() === "") {
213
+ return Promise.reject(new TypeError("Worker operation must be a non-empty string."));
214
+ }
215
+ if (!this.IsAvailable()) {
216
+ return Promise.reject(createWorkerUnavailableError());
217
+ }
218
+ const signal = options.signal || null;
219
+ if (signal?.aborted) return Promise.reject(createAbortError(signal.reason));
220
+ const id = this.#nextId++;
221
+ let resolve;
222
+ let reject;
223
+ const promise = new Promise((onResolve, onReject) => {
224
+ resolve = onResolve;
225
+ reject = onReject;
226
+ });
227
+ const request = {
228
+ id,
229
+ resolve,
230
+ reject,
231
+ signal,
232
+ onAbort: null
233
+ };
234
+ if (signal && typeof signal.addEventListener === "function") {
235
+ request.onAbort = () => {
236
+ if (!this.#pending.delete(id)) return;
237
+ cleanupPendingRequest(request);
238
+ try {
239
+ this.worker?.postMessage({
240
+ type: Message.CANCEL,
241
+ id
242
+ });
243
+ } catch {
244
+ // The local abort remains authoritative if the worker is already gone.
245
+ }
246
+ reject(createAbortError(signal.reason));
247
+ };
248
+ signal.addEventListener("abort", request.onAbort, {
249
+ once: true
250
+ });
251
+ }
252
+ this.#pending.set(id, request);
253
+ try {
254
+ this.worker.postMessage({
255
+ type: Message.EXECUTE,
256
+ id,
257
+ operation,
258
+ payload
259
+ }, normalizeTransferList(options.transfer));
260
+ } catch (error) {
261
+ this.#pending.delete(id);
262
+ cleanupPendingRequest(request);
263
+ reject(error);
264
+ }
265
+ return promise;
266
+ }
267
+
268
+ /**
269
+ * Return the number of unresolved worker requests.
270
+ *
271
+ * @returns {number}
272
+ */
273
+ GetPendingCount() {
274
+ return this.#pending.size;
275
+ }
276
+
277
+ /** Attach this loader's result and failure listeners to a worker. */
278
+ #Attach(worker) {
279
+ if (typeof worker.addEventListener === "function") {
280
+ worker.addEventListener("message", this.#boundMessage);
281
+ worker.addEventListener("error", this.#boundError);
282
+ worker.addEventListener("messageerror", this.#boundError);
283
+ } else {
284
+ worker.onmessage = this.#boundMessage;
285
+ worker.onerror = this.#boundError;
286
+ worker.onmessageerror = this.#boundError;
287
+ }
288
+ }
289
+
290
+ /** Detach this loader's result and failure listeners from a worker. */
291
+ #Detach(worker) {
292
+ if (typeof worker.removeEventListener === "function") {
293
+ worker.removeEventListener("message", this.#boundMessage);
294
+ worker.removeEventListener("error", this.#boundError);
295
+ worker.removeEventListener("messageerror", this.#boundError);
296
+ } else {
297
+ if (worker.onmessage === this.#boundMessage) worker.onmessage = null;
298
+ if (worker.onerror === this.#boundError) worker.onerror = null;
299
+ if (worker.onmessageerror === this.#boundError) worker.onmessageerror = null;
300
+ }
301
+ }
302
+
303
+ /** Settle the pending request identified by one worker result message. */
304
+ #OnMessage(event) {
305
+ const data = event?.data;
306
+ if (!data || data.type !== Message.RESULT) return;
307
+ const request = this.#pending.get(data.id);
308
+ if (!request) return;
309
+ this.#pending.delete(data.id);
310
+ cleanupPendingRequest(request);
311
+ if (data.ok) request.resolve(data.result);else request.reject(normalizeWorkerError(data.error));
312
+ }
313
+
314
+ /** Disable worker execution after a fatal worker or message failure. */
315
+ #OnError(event) {
316
+ const reason = event?.error || event || new Error("Resource worker failed.");
317
+ this.Disable(reason);
318
+ }
319
+ }
320
+ function assertResourceSource(source) {
321
+ if (!source || typeof source !== "object" && typeof source !== "function" || typeof source.Read !== "function") {
322
+ throw new TypeError("Resource source must provide Read(path, options).");
323
+ }
324
+ }
325
+ function assertResourceLoader(loader, name = "loader") {
326
+ if (!loader || typeof loader.Read !== "function" || typeof loader.ReadFormat !== "function") {
327
+ throw new TypeError(`CjsResManWorkerLoader ${name} must provide Read and ReadFormat.`);
328
+ }
329
+ }
330
+ function defaultWorkerFactory(url, options) {
331
+ if (typeof Worker === "undefined") {
332
+ throw new ReferenceError("Browser Worker is not available.");
333
+ }
334
+ return new Worker(url, options);
335
+ }
336
+ function normalizeWorkerRequest(request) {
337
+ if (request === null || request === undefined || request === false) return null;
338
+ if (!request || typeof request !== "object" || Array.isArray(request)) {
339
+ throw new TypeError("CreateWorkerRequest must return an object or null.");
340
+ }
341
+ if (typeof request.operation !== "string" || request.operation.trim() === "") {
342
+ throw new TypeError("Worker source request requires a non-empty operation.");
343
+ }
344
+ return {
345
+ operation: request.operation,
346
+ payload: request.payload,
347
+ signal: request.signal || null,
348
+ transfer: normalizeTransferList(request.transfer)
349
+ };
350
+ }
351
+ function normalizeFormatWorkerDeclaration(descriptor) {
352
+ const Format = descriptor?.Format;
353
+ const declaration = descriptor?.worker || Format?.worker;
354
+ if (!declaration) return null;
355
+ const value = typeof declaration === "string" ? {
356
+ module: declaration
357
+ } : declaration;
358
+ if (!value || typeof value !== "object" || !value.module) return null;
359
+ return Object.freeze({
360
+ module: String(value.module),
361
+ exportName: String(value.exportName || Format?.name || "default"),
362
+ outputTypes: Array.isArray(value.outputTypes) ? Object.freeze(value.outputTypes.map(String)) : null,
363
+ defaultOutput: value.defaultOutput === undefined ? undefined : String(value.defaultOutput),
364
+ transferInput: value.transferInput === true
365
+ });
366
+ }
367
+ function isWorkerFormatOutputSupported(declaration, formatOptions) {
368
+ if (!declaration.outputTypes) return true;
369
+ const output = formatOptions.emit ?? declaration.defaultOutput;
370
+ return output !== undefined && declaration.outputTypes.includes(String(output));
371
+ }
372
+ function normalizeTransferList(value) {
373
+ if (value === null || value === undefined) return [];
374
+ if (!Array.isArray(value)) {
375
+ throw new TypeError("Worker transfer list must be an array.");
376
+ }
377
+ return value;
378
+ }
379
+ function getExclusiveInputTransferables(input) {
380
+ if (input instanceof ArrayBuffer) return [input];
381
+ if (ArrayBuffer.isView(input) && input.byteOffset === 0 && input.byteLength === input.buffer.byteLength) {
382
+ return [input.buffer];
383
+ }
384
+ return [];
385
+ }
386
+ function canCloneWorkerValue(value, seen = new Set()) {
387
+ if (value === null || value === undefined) return true;
388
+ const type = typeof value;
389
+ if (type === "string" || type === "number" || type === "boolean" || type === "bigint") {
390
+ return true;
391
+ }
392
+ if (type !== "object") return false;
393
+ if (value instanceof ArrayBuffer || ArrayBuffer.isView(value) || value instanceof Date) {
394
+ return true;
395
+ }
396
+ if (seen.has(value)) return false;
397
+ seen.add(value);
398
+ if (Array.isArray(value)) {
399
+ return value.every(entry => canCloneWorkerValue(entry, seen));
400
+ }
401
+ const prototype = Object.getPrototypeOf(value);
402
+ if (prototype !== Object.prototype && prototype !== null) return false;
403
+ return Object.values(value).every(entry => canCloneWorkerValue(entry, seen));
404
+ }
405
+ function cleanupPendingRequest(request) {
406
+ if (request.signal && request.onAbort && typeof request.signal.removeEventListener === "function") {
407
+ request.signal.removeEventListener("abort", request.onAbort);
408
+ }
409
+ }
410
+ function createWorkerUnavailableError(message = "Resource worker is unavailable.") {
411
+ const error = new Error(message);
412
+ error.name = "CjsResManWorkerUnavailableError";
413
+ error.code = "CJS_RESOURCE_WORKER_UNAVAILABLE";
414
+ return error;
415
+ }
416
+ function createAbortError(reason) {
417
+ if (reason instanceof Error) return reason;
418
+ const error = new Error(reason === undefined ? "Resource worker request was aborted." : String(reason));
419
+ error.name = "AbortError";
420
+ error.code = "ABORT_ERR";
421
+ return error;
422
+ }
423
+ function normalizeWorkerError(value) {
424
+ if (value instanceof Error) return value;
425
+ const error = new Error(value?.message || "Resource worker operation failed.");
426
+ error.name = value?.name || "CjsResManWorkerError";
427
+ for (const key of ["code", "operation", "path", "status", "statusText"]) {
428
+ if (value?.[key] !== undefined) error[key] = value[key];
429
+ }
430
+ return error;
431
+ }
432
+
433
+ export { CjsResManWorkerLoader };
434
+ //# sourceMappingURL=CjsResManWorkerLoader.js.map