@carbonenginejs/runtime-resource 0.9.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +3 -2
- package/README.md +47 -6
- package/dist/CjsMotherLode.js +88 -88
- package/dist/CjsMotherLode.js.map +1 -1
- package/dist/CjsResMan.js +717 -228
- package/dist/CjsResMan.js.map +1 -1
- package/dist/CjsResManFetchProvider.js +94 -0
- package/dist/CjsResManFetchProvider.js.map +1 -0
- package/dist/{CjsResManQueue.js → CjsResManWorkQueue.js} +112 -25
- package/dist/CjsResManWorkQueue.js.map +1 -0
- package/dist/format/CjsBlueReader.js +89 -0
- package/dist/format/CjsBlueReader.js.map +1 -1
- package/dist/format/CjsFormat.js +42 -16
- package/dist/format/CjsFormat.js.map +1 -1
- package/dist/format/CjsReader.js +4 -0
- package/dist/format/CjsReader.js.map +1 -1
- package/dist/format/CjsResourceProbe.js +2 -0
- package/dist/format/CjsResourceProbe.js.map +1 -1
- package/dist/format/effect/effectPermutationGraph.js +257 -0
- package/dist/format/effect/effectPermutationGraph.js.map +1 -0
- package/dist/format/effect/effectReflectionPackage.js +636 -0
- package/dist/format/effect/effectReflectionPackage.js.map +1 -0
- package/dist/format/effect/sha256.js +114 -0
- package/dist/format/effect/sha256.js.map +1 -0
- package/dist/format/payloadContract.js +20 -0
- package/dist/format/payloadContract.js.map +1 -1
- package/dist/formats/black/CjsBlackFormat.js +15 -1
- package/dist/formats/black/CjsBlackFormat.js.map +1 -1
- package/dist/formats/black/core/CjsBlackBinaryReader.js +103 -0
- package/dist/formats/black/core/CjsBlackBinaryReader.js.map +1 -1
- package/dist/formats/black/core/CjsBlackPropertyReaders.js +61 -0
- package/dist/formats/black/core/CjsBlackPropertyReaders.js.map +1 -1
- package/dist/formats/black/core/CjsBlackReader.js +125 -0
- package/dist/formats/black/core/CjsBlackReader.js.map +1 -1
- package/dist/formats/black/core/CjsBlackSchemaRegistry.js +103 -0
- package/dist/formats/black/core/CjsBlackSchemaRegistry.js.map +1 -1
- package/dist/formats/black/core/helpers.js +17 -0
- package/dist/formats/black/core/helpers.js.map +1 -1
- package/dist/formats/bnk/CjsBnkFormat.js +8 -0
- package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
- package/dist/formats/bnk/core/helpers.js +20 -0
- package/dist/formats/bnk/core/helpers.js.map +1 -1
- package/dist/formats/bnk/core/musicNodes.js +40 -3
- package/dist/formats/bnk/core/musicNodes.js.map +1 -1
- package/dist/formats/bnk/core/soundbanksInfo.js +2 -0
- package/dist/formats/bnk/core/soundbanksInfo.js.map +1 -1
- package/dist/formats/cmf/core/binary.js +71 -0
- package/dist/formats/cmf/core/binary.js.map +1 -1
- package/dist/formats/cmf/core/buffers.js +4 -0
- package/dist/formats/cmf/core/buffers.js.map +1 -1
- package/dist/formats/cmf/core/helpers.js +31 -0
- package/dist/formats/cmf/core/helpers.js.map +1 -1
- package/dist/formats/cmf/core/schema.js +10 -0
- package/dist/formats/cmf/core/schema.js.map +1 -1
- package/dist/formats/cmf/core/shared.js +9 -0
- package/dist/formats/cmf/core/shared.js.map +1 -1
- package/dist/formats/cmf/core/writer.js +54 -0
- package/dist/formats/cmf/core/writer.js.map +1 -1
- package/dist/formats/dds/core/bc6h.js +10 -0
- package/dist/formats/dds/core/bc6h.js.map +1 -1
- package/dist/formats/dds/core/bc7.js +16 -0
- package/dist/formats/dds/core/bc7.js.map +1 -1
- package/dist/formats/dds/core/helpers.js +47 -0
- package/dist/formats/dds/core/helpers.js.map +1 -1
- package/dist/formats/dxbc/CjsDxbcFormat.js +142 -0
- package/dist/formats/dxbc/CjsDxbcFormat.js.map +1 -0
- package/dist/formats/dxbc/core/DxbcReader.js +266 -0
- package/dist/formats/dxbc/core/DxbcReader.js.map +1 -0
- package/dist/formats/dxbc/core/container.js +169 -0
- package/dist/formats/dxbc/core/container.js.map +1 -0
- package/dist/formats/dxbc/core/decoder.js +789 -0
- package/dist/formats/dxbc/core/decoder.js.map +1 -0
- package/dist/formats/dxbc/core/errors.js +19 -0
- package/dist/formats/dxbc/core/errors.js.map +1 -0
- package/dist/formats/dxbc/core/helpers.js +220 -0
- package/dist/formats/dxbc/core/helpers.js.map +1 -0
- package/dist/formats/dxbc/core/opcodes.js +45 -0
- package/dist/formats/dxbc/core/opcodes.js.map +1 -0
- package/dist/formats/dxbc/core/program.js +91 -0
- package/dist/formats/dxbc/core/program.js.map +1 -0
- package/dist/formats/dxbc/core/signature.js +172 -0
- package/dist/formats/dxbc/core/signature.js.map +1 -0
- package/dist/formats/dxbc/index.js +2 -0
- package/dist/formats/dxbc/index.js.map +1 -0
- package/dist/formats/fbx/core/helpers.js +21 -0
- package/dist/formats/fbx/core/helpers.js.map +1 -1
- package/dist/formats/flac/CjsFlacFormat.js +49 -0
- package/dist/formats/flac/CjsFlacFormat.js.map +1 -1
- package/dist/formats/flac/core/helpers.js +20 -0
- package/dist/formats/flac/core/helpers.js.map +1 -1
- package/dist/formats/gif/CjsGifFormat.js +49 -0
- package/dist/formats/gif/CjsGifFormat.js.map +1 -1
- package/dist/formats/gif/core/helpers.js +20 -0
- package/dist/formats/gif/core/helpers.js.map +1 -1
- package/dist/formats/gltf/core/helpers.js +15 -0
- package/dist/formats/gltf/core/helpers.js.map +1 -1
- package/dist/formats/gltf/core/parser.js +13 -0
- package/dist/formats/gltf/core/parser.js.map +1 -1
- package/dist/formats/gltf/core/targets.js +10 -0
- package/dist/formats/gltf/core/targets.js.map +1 -1
- package/dist/formats/gr2/core/bitknit2.js +2 -0
- package/dist/formats/gr2/core/bitknit2.js.map +1 -1
- package/dist/formats/gr2/core/helpers.js +20 -0
- package/dist/formats/gr2/core/helpers.js.map +1 -1
- package/dist/formats/gr2/core/targets.js +10 -0
- package/dist/formats/gr2/core/targets.js.map +1 -1
- package/dist/formats/hlsl/CjsHlslFormat.js +254 -0
- package/dist/formats/hlsl/CjsHlslFormat.js.map +1 -0
- package/dist/formats/hlsl/core/HlslBinaryUtils.js +15 -0
- package/dist/formats/hlsl/core/HlslBinaryUtils.js.map +1 -0
- package/dist/formats/hlsl/core/HlslEffectReadError.js +19 -0
- package/dist/formats/hlsl/core/HlslEffectReadError.js.map +1 -0
- package/dist/formats/hlsl/core/HlslEffectStateManager.js +130 -0
- package/dist/formats/hlsl/core/HlslEffectStateManager.js.map +1 -0
- package/dist/formats/hlsl/core/HlslReader.js +266 -0
- package/dist/formats/hlsl/core/HlslReader.js.map +1 -0
- package/dist/formats/hlsl/core/HlslRenderStateSetup.js +37 -0
- package/dist/formats/hlsl/core/HlslRenderStateSetup.js.map +1 -0
- package/dist/formats/hlsl/core/HlslResourceSetDescription.js +94 -0
- package/dist/formats/hlsl/core/HlslResourceSetDescription.js.map +1 -0
- package/dist/formats/hlsl/core/HlslShaderBytecode.js +44 -0
- package/dist/formats/hlsl/core/HlslShaderBytecode.js.map +1 -0
- package/dist/formats/hlsl/core/analysis.js +51 -0
- package/dist/formats/hlsl/core/analysis.js.map +1 -0
- package/dist/formats/hlsl/core/helpers.js +270 -0
- package/dist/formats/hlsl/core/helpers.js.map +1 -0
- package/dist/formats/hlsl/core/json.js +284 -0
- package/dist/formats/hlsl/core/json.js.map +1 -0
- package/dist/formats/hlsl/core/metadata.js +327 -0
- package/dist/formats/hlsl/core/metadata.js.map +1 -0
- package/dist/formats/hlsl/core/portableReflection.js +848 -0
- package/dist/formats/hlsl/core/portableReflection.js.map +1 -0
- package/dist/formats/hlsl/core/render-states.js +280 -0
- package/dist/formats/hlsl/core/render-states.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/HlslRenderContextEnum.js +43 -0
- package/dist/formats/hlsl/core/tr2/HlslRenderContextEnum.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +294 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslShaderPermutation.js +33 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslShaderPermutation.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js +416 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectBindingManifest.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectConstant.js +40 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectConstant.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js +742 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectDescription.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectLibrary.js +52 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectLibrary.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectParameterAnnotation.js +38 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectParameterAnnotation.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectResource.js +50 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectResource.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js +86 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectTechnique.js +31 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslEffectTechnique.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslPass.js +42 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslPass.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslSamplerDescription.js +55 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslSamplerDescription.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslSamplerSetup.js +29 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslSamplerSetup.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslShader.js +220 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslShader.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslShaderOption.js +30 -0
- package/dist/formats/hlsl/core/tr2/shader/HlslShaderOption.js.map +1 -0
- package/dist/formats/hlsl/index.js +2 -0
- package/dist/formats/hlsl/index.js.map +1 -0
- package/dist/formats/hlsl/portable.js +2 -0
- package/dist/formats/hlsl/portable.js.map +1 -0
- package/dist/formats/index.js +4 -0
- package/dist/formats/index.js.map +1 -1
- package/dist/formats/jpeg/core/helpers.js +52 -0
- package/dist/formats/jpeg/core/helpers.js.map +1 -1
- package/dist/formats/jpeg/core/jpeg.js +93 -0
- package/dist/formats/jpeg/core/jpeg.js.map +1 -1
- package/dist/formats/mp3/core/helpers.js +37 -0
- package/dist/formats/mp3/core/helpers.js.map +1 -1
- package/dist/formats/mp4/core/helpers.js +35 -0
- package/dist/formats/mp4/core/helpers.js.map +1 -1
- package/dist/formats/ogg/CjsOggFormat.js +49 -0
- package/dist/formats/ogg/CjsOggFormat.js.map +1 -1
- package/dist/formats/ogg/core/helpers.js +23 -0
- package/dist/formats/ogg/core/helpers.js.map +1 -1
- package/dist/formats/ogg/core/vorbis.js +13 -0
- package/dist/formats/ogg/core/vorbis.js.map +1 -1
- package/dist/formats/png/core/helpers.js +52 -0
- package/dist/formats/png/core/helpers.js.map +1 -1
- package/dist/formats/red/CjsRedFormat.js +2 -0
- package/dist/formats/red/CjsRedFormat.js.map +1 -1
- package/dist/formats/red/core/CjsRedReader.js +52 -0
- package/dist/formats/red/core/CjsRedReader.js.map +1 -1
- package/dist/formats/red/core/helpers.js +19 -0
- package/dist/formats/red/core/helpers.js.map +1 -1
- package/dist/formats/stl/core/stl.js +8 -0
- package/dist/formats/stl/core/stl.js.map +1 -1
- package/dist/formats/stl/core/targets.js +10 -0
- package/dist/formats/stl/core/targets.js.map +1 -1
- package/dist/formats/tga/core/helpers.js +47 -0
- package/dist/formats/tga/core/helpers.js.map +1 -1
- package/dist/formats/wav/core/helpers.js +37 -0
- package/dist/formats/wav/core/helpers.js.map +1 -1
- package/dist/formats/webgl/CjsWebglFormat.js +221 -0
- package/dist/formats/webgl/CjsWebglFormat.js.map +1 -0
- package/dist/formats/webgl/core/cewg/CewgPackage.js +339 -0
- package/dist/formats/webgl/core/cewg/CewgPackage.js.map +1 -0
- package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js +104 -0
- package/dist/formats/webgl/core/cewg/CewgPackageBuilder.js.map +1 -0
- package/dist/formats/webgl/core/cewg/binary.js +101 -0
- package/dist/formats/webgl/core/cewg/binary.js.map +1 -0
- package/dist/formats/webgl/core/cewgCompleteness.js +81 -0
- package/dist/formats/webgl/core/cewgCompleteness.js.map +1 -0
- package/dist/formats/webgl/core/effectPackage.js +789 -0
- package/dist/formats/webgl/core/effectPackage.js.map +1 -0
- package/dist/formats/webgl/core/effectPackageValidation.js +331 -0
- package/dist/formats/webgl/core/effectPackageValidation.js.map +1 -0
- package/dist/formats/webgl/core/errors.js +27 -0
- package/dist/formats/webgl/core/errors.js.map +1 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +2678 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslHelpers.js +89 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslHelpers.js.map +1 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js +428 -0
- package/dist/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js.map +1 -0
- package/dist/formats/webgl/core/helpers.js +306 -0
- package/dist/formats/webgl/core/helpers.js.map +1 -0
- package/dist/formats/webgl/index.js +2 -0
- package/dist/formats/webgl/index.js.map +1 -0
- package/dist/formats/webgpu/CjsWebgpuFormat.js +376 -0
- package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js +415 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js +100 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/binary.js +93 -0
- package/dist/formats/webgpu/core/cewgpu/binary.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/tags.js +17 -0
- package/dist/formats/webgpu/core/cewgpu/tags.js.map +1 -0
- package/dist/formats/webgpu/core/effectAnalysis.js +82 -0
- package/dist/formats/webgpu/core/effectAnalysis.js.map +1 -0
- package/dist/formats/webgpu/core/effectBackendBodySet.js +305 -0
- package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -0
- package/dist/formats/webgpu/core/effectPackageValidation.js +1078 -0
- package/dist/formats/webgpu/core/effectPackageValidation.js.map +1 -0
- package/dist/formats/webgpu/core/errors.js +20 -0
- package/dist/formats/webgpu/core/errors.js.map +1 -0
- package/dist/formats/webgpu/core/helpers.js +448 -0
- package/dist/formats/webgpu/core/helpers.js.map +1 -0
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +223 -0
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js.map +1 -0
- package/dist/formats/webgpu/core/ir/buildControlFlow.js +220 -0
- package/dist/formats/webgpu/core/ir/buildControlFlow.js.map +1 -0
- package/dist/formats/webgpu/core/ir/indexableTemps.js +137 -0
- package/dist/formats/webgpu/core/ir/indexableTemps.js.map +1 -0
- package/dist/formats/webgpu/core/ir/inferValueTypes.js +454 -0
- package/dist/formats/webgpu/core/ir/inferValueTypes.js.map +1 -0
- package/dist/formats/webgpu/core/ir/lowerDxbcToIr.js +494 -0
- package/dist/formats/webgpu/core/ir/lowerDxbcToIr.js.map +1 -0
- package/dist/formats/webgpu/core/ir/resolveRegisterFlow.js +177 -0
- package/dist/formats/webgpu/core/ir/resolveRegisterFlow.js.map +1 -0
- package/dist/formats/webgpu/core/ir/sourceLanes.js +61 -0
- package/dist/formats/webgpu/core/ir/sourceLanes.js.map +1 -0
- package/dist/formats/webgpu/core/packageEffect.js +300 -0
- package/dist/formats/webgpu/core/packageEffect.js.map +1 -0
- package/dist/formats/webgpu/core/packageEffectSelection.js +164 -0
- package/dist/formats/webgpu/core/packageEffectSelection.js.map +1 -0
- package/dist/formats/webgpu/core/packageMetadata.js +8 -0
- package/dist/formats/webgpu/core/packageMetadata.js.map +1 -0
- package/dist/formats/webgpu/core/schema.js +4 -0
- package/dist/formats/webgpu/core/schema.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +275 -0
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +182 -0
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +324 -0
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/emitWgsl.js +356 -0
- package/dist/formats/webgpu/core/wgsl/emitWgsl.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/hoistEscapingValues.js +77 -0
- package/dist/formats/webgpu/core/wgsl/hoistEscapingValues.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerBindingLayout.js +451 -0
- package/dist/formats/webgpu/core/wgsl/lowerBindingLayout.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +754 -0
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js +457 -0
- package/dist/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerFragmentProgram.js +1572 -0
- package/dist/formats/webgpu/core/wgsl/lowerFragmentProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerMergeHistogramsComputeProgram.js +659 -0
- package/dist/formats/webgpu/core/wgsl/lowerMergeHistogramsComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerParticleClearComputePrograms.js +734 -0
- package/dist/formats/webgpu/core/wgsl/lowerParticleClearComputePrograms.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerParticleEmitComputeProgram.js +583 -0
- package/dist/formats/webgpu/core/wgsl/lowerParticleEmitComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerSkinVerticesComputeProgram.js +621 -0
- package/dist/formats/webgpu/core/wgsl/lowerSkinVerticesComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortComputeProgram.js +824 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortInnerComputeProgram.js +697 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortInnerComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortStepComputeProgram.js +559 -0
- package/dist/formats/webgpu/core/wgsl/lowerSortStepComputeProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/lowerVertexProgram.js +1328 -0
- package/dist/formats/webgpu/core/wgsl/lowerVertexProgram.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/particleEmitSemanticDigest.js +110 -0
- package/dist/formats/webgpu/core/wgsl/particleEmitSemanticDigest.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/precisionControls.js +55 -0
- package/dist/formats/webgpu/core/wgsl/precisionControls.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js +758 -0
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/uniformity.js +78 -0
- package/dist/formats/webgpu/core/wgsl/uniformity.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/validateExactComputeIr.js +196 -0
- package/dist/formats/webgpu/core/wgsl/validateExactComputeIr.js.map +1 -0
- package/dist/formats/webgpu/core/wgsl/validateHandleOperand.js +37 -0
- package/dist/formats/webgpu/core/wgsl/validateHandleOperand.js.map +1 -0
- package/dist/formats/webgpu/index.js +2 -0
- package/dist/formats/webgpu/index.js.map +1 -0
- package/dist/formats/webm/core/helpers.js +35 -0
- package/dist/formats/webm/core/helpers.js.map +1 -1
- package/dist/formats/webp/CjsWebpFormat.js +49 -0
- package/dist/formats/webp/CjsWebpFormat.js.map +1 -1
- package/dist/formats/webp/core/helpers.js +23 -0
- package/dist/formats/webp/core/helpers.js.map +1 -1
- package/dist/formats/wem/CjsWemFormat.js +8 -0
- package/dist/formats/wem/CjsWemFormat.js.map +1 -1
- package/dist/formats/wem/core/bitStream.js +2 -0
- package/dist/formats/wem/core/bitStream.js.map +1 -1
- package/dist/formats/wem/core/helpers.js +20 -0
- package/dist/formats/wem/core/helpers.js.map +1 -1
- package/dist/formats/yaml/CjsYamlFormat.js +45 -0
- package/dist/formats/yaml/CjsYamlFormat.js.map +1 -1
- package/dist/formats/yaml/core/CjsYamlReader.js +91 -0
- package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -1
- package/dist/formats/yaml/core/helpers.js +10 -0
- package/dist/formats/yaml/core/helpers.js.map +1 -1
- package/dist/index.js +56 -43
- package/dist/index.js.map +1 -1
- package/dist/{CjsResource.js → resource/CjsResource.js} +232 -17
- package/dist/resource/CjsResource.js.map +1 -0
- package/dist/{resources → resource}/Tr2LightProfileRes.js +4 -3
- package/dist/resource/Tr2LightProfileRes.js.map +1 -0
- package/dist/{resources → resource/audio}/AudioGeometryResData.js +1 -1
- package/dist/resource/audio/AudioGeometryResData.js.map +1 -0
- package/dist/resource/audio/CjsAudioBufferRes.js +86 -0
- package/dist/resource/audio/CjsAudioBufferRes.js.map +1 -0
- package/dist/resource/audio/CjsAudioRes.js +213 -0
- package/dist/resource/audio/CjsAudioRes.js.map +1 -0
- package/dist/resource/audio/index.js +4 -0
- package/dist/resource/audio/index.js.map +1 -0
- package/dist/{resources → resource/geometry}/MeshDecalData.js +1 -1
- package/dist/resource/geometry/MeshDecalData.js.map +1 -0
- package/dist/{resources → resource/geometry}/MeshDecalLodData.js +1 -1
- package/dist/resource/geometry/MeshDecalLodData.js.map +1 -0
- package/dist/resource/geometry/TriGeometryRes.js +656 -0
- package/dist/resource/geometry/TriGeometryRes.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriGeometryResAreaData.js +1 -1
- package/dist/resource/geometry/TriGeometryResAreaData.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriGeometryResJointData.js +1 -1
- package/dist/resource/geometry/TriGeometryResJointData.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriGeometryResLodData.js +1 -1
- package/dist/resource/geometry/TriGeometryResLodData.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriGeometryResMeshData.js +1 -1
- package/dist/resource/geometry/TriGeometryResMeshData.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriGeometryResSkeletonData.js +1 -1
- package/dist/resource/geometry/TriGeometryResSkeletonData.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriJointBinding.js +1 -1
- package/dist/resource/geometry/TriJointBinding.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriMorphTargetGeometryConstants.js +1 -1
- package/dist/resource/geometry/TriMorphTargetGeometryConstants.js.map +1 -0
- package/dist/{resources → resource/geometry}/TriRtGeometryConstants.js +1 -1
- package/dist/resource/geometry/TriRtGeometryConstants.js.map +1 -0
- package/dist/{resources → resource/geometry/granny}/GStateBindingCallbackData.js +1 -1
- package/dist/resource/geometry/granny/GStateBindingCallbackData.js.map +1 -0
- package/dist/{resources → resource/geometry/granny}/Tr2GrannyIntersectionResult.js +1 -1
- package/dist/resource/geometry/granny/Tr2GrannyIntersectionResult.js.map +1 -0
- package/dist/{resources → resource/geometry/granny}/Tr2GrannyStateRes.js +6 -5
- package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -0
- package/dist/{resources → resource/geometry/granny}/TriGrannyRes.js +6 -5
- package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -0
- package/dist/{resources → resource/geometry/granny}/enums.js +1 -9
- package/dist/resource/geometry/granny/enums.js.map +1 -0
- package/dist/resource/geometry/granny/index.js +6 -0
- package/dist/resource/geometry/granny/index.js.map +1 -0
- package/dist/resource/geometry/index.js +17 -0
- package/dist/resource/geometry/index.js.map +1 -0
- package/dist/resource/index.js +52 -0
- package/dist/resource/index.js.map +1 -0
- package/dist/resource/resourceBoundary.js +64 -0
- package/dist/resource/resourceBoundary.js.map +1 -0
- package/dist/resource/shader/Tr2EffectRes.js +429 -0
- package/dist/resource/shader/Tr2EffectRes.js.map +1 -0
- package/dist/resource/shader/Tr2MaterialArea.js +34 -0
- package/dist/resource/shader/Tr2MaterialArea.js.map +1 -0
- package/dist/resource/shader/Tr2MaterialMesh.js +30 -0
- package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -0
- package/dist/resource/shader/Tr2MaterialRes.js +35 -0
- package/dist/resource/shader/Tr2MaterialRes.js.map +1 -0
- package/dist/resource/shader/Tr2Shader.js +256 -0
- package/dist/resource/shader/Tr2Shader.js.map +1 -0
- package/dist/resource/shader/Tr2ShaderPermutation.js +47 -0
- package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -0
- package/dist/resource/shader/index.js +17 -0
- package/dist/resource/shader/index.js.map +1 -0
- package/dist/resource/shader/portable.js +33 -0
- package/dist/resource/shader/portable.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectConstant.js +135 -0
- package/dist/resource/shader/reflection/Tr2EffectConstant.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectDefine.js +28 -0
- package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectDescription.js +107 -0
- package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js +145 -0
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +103 -0
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectResource.js +84 -0
- package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js +239 -0
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js +66 -0
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -0
- package/dist/resource/shader/reflection/Tr2Pass.js +109 -0
- package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -0
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js +75 -0
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -0
- package/dist/{texture → resource/texture}/CjsTextureArrayRes.js +83 -6
- package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -0
- package/dist/{texture/CjsTextureParameterProxy.js → resource/texture/CjsTextureArrayResParameterProxy.js} +56 -10
- package/dist/resource/texture/CjsTextureArrayResParameterProxy.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2ImageRes.js +6 -4
- package/dist/resource/texture/Tr2ImageRes.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TextureLodManager.js +3 -1
- package/dist/resource/texture/Tr2TextureLodManager.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TextureLodUpdateRequest.js +1 -1
- package/dist/resource/texture/Tr2TextureLodUpdateRequest.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePackChannel.js +1 -1
- package/dist/resource/texture/Tr2TexturePackChannel.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePipeline.js +6 -4
- package/dist/resource/texture/Tr2TexturePipeline.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePipelineParams.js +1 -1
- package/dist/resource/texture/Tr2TexturePipelineParams.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePipelineStepCompress.js +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepCompress.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePipelineStepGenerateMips.js +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepGenerateMips.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePipelineStepLimitSize.js +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepLimitSize.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePipelineStepLoad.js +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepLoad.js.map +1 -0
- package/dist/{resources → resource/texture}/Tr2TexturePipelineStepPack.js +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepPack.js.map +1 -0
- package/dist/{resources → resource/texture}/TriTextureRes.js +42 -26
- package/dist/resource/texture/TriTextureRes.js.map +1 -0
- package/dist/resource/texture/index.js +15 -0
- package/dist/resource/texture/index.js.map +1 -0
- package/dist/{resources → resource/texture}/texturePipelineBehavior.js +59 -59
- package/dist/resource/texture/texturePipelineBehavior.js.map +1 -0
- package/dist/worker/CjsResManMainThreadLoader.js +87 -0
- package/dist/worker/CjsResManMainThreadLoader.js.map +1 -0
- package/dist/worker/CjsResManWorker.js +217 -0
- package/dist/worker/CjsResManWorker.js.map +1 -0
- package/dist/worker/CjsResManWorkerLoader.js +434 -0
- package/dist/worker/CjsResManWorkerLoader.js.map +1 -0
- package/dist/worker/protocol.js +12 -0
- package/dist/worker/protocol.js.map +1 -0
- package/docs/README.md +16 -3
- package/docs/architecture.md +39 -16
- package/docs/concepts/resource-lifecycle.md +2 -1
- package/docs/formats/README.md +8 -0
- package/docs/formats/provenance.md +11 -3
- package/docs/reference/classes/README.md +6 -4
- package/docs/reference/classes/audio.md +30 -0
- package/docs/reference/classes/core.md +31 -11
- package/docs/reference/classes/formats.md +440 -0
- package/docs/reference/classes/resources.md +151 -41
- package/docs/reference/classes/texture.md +7 -7
- package/docs/reference/motherlode-cache.md +17 -0
- package/docs/reference/queues.md +9 -1
- package/docs/reference/workers.md +135 -0
- package/docs/roadmap.md +27 -1
- package/format-notices/dxbc/LICENSE +21 -0
- package/format-notices/dxbc/NOTICE +20 -0
- package/format-notices/hlsl/LICENSE +21 -0
- package/format-notices/hlsl/NOTICE +25 -0
- package/format-notices/webgl/LICENSE +21 -0
- package/format-notices/webgl/NOTICE +35 -0
- package/format-notices/webgpu/LICENSE +21 -0
- package/format-notices/webgpu/NOTICE +31 -0
- package/package.json +13 -1
- package/dist/CjsResManQueue.js.map +0 -1
- package/dist/CjsResource.js.map +0 -1
- package/dist/CjsResourceSource.js +0 -68
- package/dist/CjsResourceSource.js.map +0 -1
- package/dist/resourcePath.js +0 -18
- package/dist/resourcePath.js.map +0 -1
- package/dist/resourceStates.js +0 -9
- package/dist/resourceStates.js.map +0 -1
- package/dist/resources/AudioGeometryResData.js.map +0 -1
- package/dist/resources/GStateBindingCallbackData.js.map +0 -1
- package/dist/resources/MeshDecalData.js.map +0 -1
- package/dist/resources/MeshDecalLodData.js.map +0 -1
- package/dist/resources/Tr2EffectRes.js +0 -71
- package/dist/resources/Tr2EffectRes.js.map +0 -1
- package/dist/resources/Tr2GrannyIntersectionResult.js.map +0 -1
- package/dist/resources/Tr2GrannyStateRes.js.map +0 -1
- package/dist/resources/Tr2ImageRes.js.map +0 -1
- package/dist/resources/Tr2LightProfileRes.js.map +0 -1
- package/dist/resources/Tr2MaterialArea.js +0 -34
- package/dist/resources/Tr2MaterialArea.js.map +0 -1
- package/dist/resources/Tr2MaterialMesh.js +0 -31
- package/dist/resources/Tr2MaterialMesh.js.map +0 -1
- package/dist/resources/Tr2MaterialRes.js +0 -34
- package/dist/resources/Tr2MaterialRes.js.map +0 -1
- package/dist/resources/Tr2ShaderPermutation.js +0 -43
- package/dist/resources/Tr2ShaderPermutation.js.map +0 -1
- package/dist/resources/Tr2TextureLodManager.js.map +0 -1
- package/dist/resources/Tr2TextureLodUpdateRequest.js.map +0 -1
- package/dist/resources/Tr2TexturePackChannel.js.map +0 -1
- package/dist/resources/Tr2TexturePipeline.js.map +0 -1
- package/dist/resources/Tr2TexturePipelineParams.js.map +0 -1
- package/dist/resources/Tr2TexturePipelineStepCompress.js.map +0 -1
- package/dist/resources/Tr2TexturePipelineStepGenerateMips.js.map +0 -1
- package/dist/resources/Tr2TexturePipelineStepLimitSize.js.map +0 -1
- package/dist/resources/Tr2TexturePipelineStepLoad.js.map +0 -1
- package/dist/resources/Tr2TexturePipelineStepPack.js.map +0 -1
- package/dist/resources/TriGeometryRes.js +0 -239
- package/dist/resources/TriGeometryRes.js.map +0 -1
- package/dist/resources/TriGeometryResAreaData.js.map +0 -1
- package/dist/resources/TriGeometryResJointData.js.map +0 -1
- package/dist/resources/TriGeometryResLodData.js.map +0 -1
- package/dist/resources/TriGeometryResMeshData.js.map +0 -1
- package/dist/resources/TriGeometryResSkeletonData.js.map +0 -1
- package/dist/resources/TriGrannyRes.js.map +0 -1
- package/dist/resources/TriJointBinding.js.map +0 -1
- package/dist/resources/TriMorphTargetGeometryConstants.js.map +0 -1
- package/dist/resources/TriRtGeometryConstants.js.map +0 -1
- package/dist/resources/TriTextureRes.js.map +0 -1
- package/dist/resources/enums.js.map +0 -1
- package/dist/resources/resourceBoundary.js +0 -47
- package/dist/resources/resourceBoundary.js.map +0 -1
- package/dist/resources/texturePipelineBehavior.js.map +0 -1
- package/dist/texture/CjsTextureArrayRes.js.map +0 -1
- package/dist/texture/CjsTextureParameterProxy.js.map +0 -1
package/NOTICE
CHANGED
|
@@ -3,8 +3,9 @@ carbonenginejs/runtime-resource
|
|
|
3
3
|
|
|
4
4
|
Copyright (c) 2026 CarbonEngineJS contributors.
|
|
5
5
|
|
|
6
|
-
This package owns CarbonEngineJS resource lifecycle, format selection,
|
|
7
|
-
|
|
6
|
+
This package owns CarbonEngineJS resource lifecycle, format selection,
|
|
7
|
+
canonical GPU-free shader/reflection models, and the non-shader format
|
|
8
|
+
implementations listed under `format-notices/`.
|
|
8
9
|
|
|
9
10
|
CarbonEngine source material, format names, class names, and schema semantics
|
|
10
11
|
remain copyright their original CarbonEngine authors. Fenris Creations
|
package/README.md
CHANGED
|
@@ -4,10 +4,11 @@ CarbonEngineJS resource lifecycle, cache, format selection, source, and object
|
|
|
4
4
|
loading contracts — the GPU-free resource layer.
|
|
5
5
|
|
|
6
6
|
Use this package when you need Carbon-shaped resource loading (`res:/` paths,
|
|
7
|
-
requirement/emit selection, `Ready()`/`GetObject()`)
|
|
8
|
-
format readers
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
requirement/emit selection, `Ready()`/`GetObject()`), canonical GPU-free shader
|
|
8
|
+
reflection, or one of the bundled format readers without choosing a GPU
|
|
9
|
+
backend. It sits between format/resource providers and the engines that
|
|
10
|
+
realize prepared resources. It owns neither WebGL/WebGPU realization nor the
|
|
11
|
+
standalone shader parser/compiler packages.
|
|
11
12
|
|
|
12
13
|
## Install
|
|
13
14
|
|
|
@@ -21,11 +22,17 @@ Concrete formats are explicit tree-shakeable subpaths, never imported by the
|
|
|
21
22
|
package root:
|
|
22
23
|
|
|
23
24
|
```js
|
|
24
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
CjsResMan,
|
|
27
|
+
CjsResManFetchProvider
|
|
28
|
+
} from "@carbonenginejs/runtime-resource";
|
|
25
29
|
import { CjsMp4Format } from "@carbonenginejs/runtime-resource/formats/mp4";
|
|
26
30
|
|
|
27
31
|
const resMan = new CjsResMan().Register({
|
|
28
|
-
|
|
32
|
+
paths: {
|
|
33
|
+
res: "https://cdn.example.invalid/resources/"
|
|
34
|
+
},
|
|
35
|
+
source: new CjsResManFetchProvider(),
|
|
29
36
|
formats: [ CjsMp4Format ]
|
|
30
37
|
});
|
|
31
38
|
|
|
@@ -33,11 +40,45 @@ const resource = resMan.GetResource("res:/video/intro.mp4");
|
|
|
33
40
|
const video = await resource.Ready();
|
|
34
41
|
```
|
|
35
42
|
|
|
43
|
+
Browser consumers use worker-backed fetch and declared worker-safe format
|
|
44
|
+
readers by default, with deterministic main-thread fallback; see
|
|
45
|
+
[browser worker execution](docs/reference/workers.md).
|
|
46
|
+
|
|
47
|
+
Raw audio resource ownership is available from an explicit subpath:
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import {
|
|
51
|
+
CjsAudioBufferRes,
|
|
52
|
+
CjsAudioRes
|
|
53
|
+
} from "@carbonenginejs/runtime-resource/resource/audio";
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`CjsAudioRes` always represents one addressable audio file. Its backing may be
|
|
57
|
+
a complete loose file, an individually served response, or a window within a
|
|
58
|
+
shared `CjsAudioBufferRes` bank payload.
|
|
59
|
+
|
|
60
|
+
Canonical effect-resource and shader reflection classes are available from:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import {
|
|
64
|
+
Tr2EffectRes,
|
|
65
|
+
Tr2Shader
|
|
66
|
+
} from "@carbonenginejs/runtime-resource/resource/shader";
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`Tr2EffectRes` fail-closed validates complete permutation topology and portable
|
|
70
|
+
reflection, selects a package permutation, and hydrates it into a cached,
|
|
71
|
+
device-free `Tr2Shader`. Engines add programs, layouts, bindings, and other GPU
|
|
72
|
+
state.
|
|
73
|
+
|
|
36
74
|
## Documentation
|
|
37
75
|
|
|
38
76
|
- [Package documentation](docs/README.md)
|
|
39
77
|
- [Architecture and boundaries](docs/architecture.md)
|
|
40
78
|
- [Resource lifecycle concepts](docs/concepts/resource-lifecycle.md)
|
|
79
|
+
- [Browser worker execution](docs/reference/workers.md)
|
|
80
|
+
- [Audio resource classes](docs/reference/classes/audio.md)
|
|
81
|
+
- [Resource and shader-reflection classes](docs/reference/classes/resources.md)
|
|
41
82
|
- [Format subpaths](docs/formats/README.md)
|
|
42
83
|
- [Format ownership and fork provenance](docs/formats/provenance.md)
|
|
43
84
|
|
package/dist/CjsMotherLode.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeResourcePath } from '
|
|
1
|
+
import { normalizeResourcePath } from '@carbonenginejs/runtime-utils/path';
|
|
2
2
|
|
|
3
3
|
// Source: blue/include/IMotherLode.h
|
|
4
4
|
// Source: blue/src/MotherLode.h
|
|
@@ -150,7 +150,7 @@ class CjsMotherLode {
|
|
|
150
150
|
#cacheSize = DEFAULT_CACHE_SIZE;
|
|
151
151
|
#entries = new Map();
|
|
152
152
|
#nextCacheSequence = 1;
|
|
153
|
-
#now =
|
|
153
|
+
#now = defaultNow;
|
|
154
154
|
|
|
155
155
|
/**
|
|
156
156
|
* Create an active deterministic resource registry.
|
|
@@ -230,14 +230,14 @@ class CjsMotherLode {
|
|
|
230
230
|
*/
|
|
231
231
|
Insert(keyOrResource, resourceOrPath, optionsOrVariant = {}) {
|
|
232
232
|
if (!this.#active) {
|
|
233
|
-
throw
|
|
233
|
+
throw motherLodeInactiveError();
|
|
234
234
|
}
|
|
235
235
|
const {
|
|
236
236
|
key,
|
|
237
237
|
resource,
|
|
238
238
|
options
|
|
239
|
-
} =
|
|
240
|
-
|
|
239
|
+
} = normalizeInsertArguments(keyOrResource, resourceOrPath, optionsOrVariant);
|
|
240
|
+
assertResource(resource);
|
|
241
241
|
const existing = this.#entries.get(key) || null;
|
|
242
242
|
if (existing && existing.resource === resource) {
|
|
243
243
|
const updated = {
|
|
@@ -247,17 +247,17 @@ class CjsMotherLode {
|
|
|
247
247
|
this.#AssertRecordedBytesTotal(updated, existing);
|
|
248
248
|
this.#TouchRecord(updated, options);
|
|
249
249
|
Object.assign(existing, updated);
|
|
250
|
-
return
|
|
250
|
+
return freezeInsertResult(key, resource, false, false, null);
|
|
251
251
|
}
|
|
252
252
|
if (existing && options.replace === false) {
|
|
253
|
-
return
|
|
253
|
+
return freezeInsertResult(key, existing.resource, false, false, null);
|
|
254
254
|
}
|
|
255
255
|
const record = this.#CreateRecord(key, resource, options, existing);
|
|
256
256
|
if (existing) {
|
|
257
257
|
this.#CleanupRecord(existing, options, "replace", true);
|
|
258
258
|
}
|
|
259
259
|
this.#entries.set(key, record);
|
|
260
|
-
return
|
|
260
|
+
return freezeInsertResult(key, resource, true, Boolean(existing), existing?.resource || null);
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
/**
|
|
@@ -286,15 +286,15 @@ class CjsMotherLode {
|
|
|
286
286
|
*/
|
|
287
287
|
ReplaceExpected(key, expected, resource, options = {}) {
|
|
288
288
|
if (!this.#active) {
|
|
289
|
-
throw
|
|
289
|
+
throw motherLodeInactiveError();
|
|
290
290
|
}
|
|
291
|
-
const resolvedKey =
|
|
292
|
-
const policy =
|
|
291
|
+
const resolvedKey = normalizeResolvedKey(key);
|
|
292
|
+
const policy = normalizeOptions(options, "conditional replace");
|
|
293
293
|
if (policy.commitGuard !== undefined && typeof policy.commitGuard !== "function") {
|
|
294
294
|
throw new TypeError("CjsMotherLode conditional replace commitGuard must be a function.");
|
|
295
295
|
}
|
|
296
|
-
|
|
297
|
-
|
|
296
|
+
assertResource(expected);
|
|
297
|
+
assertResource(resource);
|
|
298
298
|
if (resource === expected) {
|
|
299
299
|
const error = new Error("CjsMotherLode conditional replacement requires a distinct resource.");
|
|
300
300
|
error.code = "CJS_MOTHERLODE_REPLACE_ALIAS";
|
|
@@ -302,7 +302,7 @@ class CjsMotherLode {
|
|
|
302
302
|
}
|
|
303
303
|
const existing = this.#entries.get(resolvedKey) || null;
|
|
304
304
|
if (!existing || existing.resource !== expected) {
|
|
305
|
-
return
|
|
305
|
+
return freezeConditionalReplaceResult(resolvedKey, false, existing?.resource || null, null);
|
|
306
306
|
}
|
|
307
307
|
const recordOptions = {
|
|
308
308
|
...policy,
|
|
@@ -315,10 +315,10 @@ class CjsMotherLode {
|
|
|
315
315
|
// Re-check after clock/metadata validation, then publish with no user code
|
|
316
316
|
// between the exact-record comparison and Map mutation.
|
|
317
317
|
if (policy.commitGuard && !policy.commitGuard() || this.#entries.get(resolvedKey) !== existing) {
|
|
318
|
-
return
|
|
318
|
+
return freezeConditionalReplaceResult(resolvedKey, false, this.#entries.get(resolvedKey)?.resource || null, null);
|
|
319
319
|
}
|
|
320
320
|
this.#entries.set(resolvedKey, record);
|
|
321
|
-
const result =
|
|
321
|
+
const result = freezeConditionalReplaceResult(resolvedKey, true, resource, expected);
|
|
322
322
|
try {
|
|
323
323
|
this.#CleanupRecord(existing, policy, "conditional replace");
|
|
324
324
|
} catch (cause) {
|
|
@@ -340,7 +340,7 @@ class CjsMotherLode {
|
|
|
340
340
|
* @throws {TypeError} If the identity cannot be normalized.
|
|
341
341
|
*/
|
|
342
342
|
HasKey(key, variant = undefined) {
|
|
343
|
-
return this.#entries.has(
|
|
343
|
+
return this.#entries.has(normalizeLookupKey(key, variant));
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
/**
|
|
@@ -353,7 +353,7 @@ class CjsMotherLode {
|
|
|
353
353
|
* @throws {TypeError} If the identity cannot be normalized.
|
|
354
354
|
*/
|
|
355
355
|
Lookup(key, variant = undefined) {
|
|
356
|
-
return this.#entries.get(
|
|
356
|
+
return this.#entries.get(normalizeLookupKey(key, variant))?.resource || null;
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
/**
|
|
@@ -372,7 +372,7 @@ class CjsMotherLode {
|
|
|
372
372
|
const {
|
|
373
373
|
resolvedKey,
|
|
374
374
|
options
|
|
375
|
-
} =
|
|
375
|
+
} = normalizeDeleteArguments(key, variantOrOptions, maybeOptions);
|
|
376
376
|
const record = this.#entries.get(resolvedKey);
|
|
377
377
|
if (!record) return false;
|
|
378
378
|
this.#entries.delete(resolvedKey);
|
|
@@ -391,7 +391,7 @@ class CjsMotherLode {
|
|
|
391
391
|
* @throws {AggregateError} If cleanup fails for one or more removed resources.
|
|
392
392
|
*/
|
|
393
393
|
DeleteAllVariants(path, options = {}) {
|
|
394
|
-
const normalizedPath =
|
|
394
|
+
const normalizedPath = normalizePath(path);
|
|
395
395
|
const prefix = `${normalizedPath}\u0000`;
|
|
396
396
|
const records = [];
|
|
397
397
|
for (const [key, record] of this.#entries) {
|
|
@@ -456,7 +456,7 @@ class CjsMotherLode {
|
|
|
456
456
|
const {
|
|
457
457
|
resolvedKey,
|
|
458
458
|
options
|
|
459
|
-
} =
|
|
459
|
+
} = normalizeActivityArguments(key, variantOrOptions, maybeOptions);
|
|
460
460
|
const record = this.#entries.get(resolvedKey);
|
|
461
461
|
if (!record) return null;
|
|
462
462
|
record.cached = false;
|
|
@@ -480,7 +480,7 @@ class CjsMotherLode {
|
|
|
480
480
|
const {
|
|
481
481
|
resolvedKey,
|
|
482
482
|
options
|
|
483
|
-
} =
|
|
483
|
+
} = normalizeActivityArguments(key, variantOrOptions, maybeOptions);
|
|
484
484
|
const record = this.#entries.get(resolvedKey);
|
|
485
485
|
if (!record) return null;
|
|
486
486
|
record.cached = false;
|
|
@@ -501,7 +501,7 @@ class CjsMotherLode {
|
|
|
501
501
|
* @throws {TypeError} If the identity cannot be normalized.
|
|
502
502
|
*/
|
|
503
503
|
Lock(key, variant = undefined) {
|
|
504
|
-
const record = this.#entries.get(
|
|
504
|
+
const record = this.#entries.get(normalizeLookupKey(key, variant));
|
|
505
505
|
if (!record) return 0;
|
|
506
506
|
record.lockCount += 1;
|
|
507
507
|
record.cached = false;
|
|
@@ -520,7 +520,7 @@ class CjsMotherLode {
|
|
|
520
520
|
* @throws {TypeError} If the identity cannot be normalized.
|
|
521
521
|
*/
|
|
522
522
|
Unlock(key, variant = undefined) {
|
|
523
|
-
const record = this.#entries.get(
|
|
523
|
+
const record = this.#entries.get(normalizeLookupKey(key, variant));
|
|
524
524
|
if (!record) return 0;
|
|
525
525
|
if (record.lockCount > 0) record.lockCount -= 1;
|
|
526
526
|
return record.lockCount;
|
|
@@ -545,7 +545,7 @@ class CjsMotherLode {
|
|
|
545
545
|
* @throws {AggregateError} If one or more cleanup, payload-release, or purge-state operations fail.
|
|
546
546
|
*/
|
|
547
547
|
PurgeInactive(options = {}) {
|
|
548
|
-
const policy =
|
|
548
|
+
const policy = normalizePurgeOptions(options, this.#activityFrame, this.#now);
|
|
549
549
|
this.#activityFrame = Math.max(this.#activityFrame, policy.frame);
|
|
550
550
|
const purgedKeys = [];
|
|
551
551
|
const payloadKeys = [];
|
|
@@ -556,7 +556,7 @@ class CjsMotherLode {
|
|
|
556
556
|
locked += 1;
|
|
557
557
|
continue;
|
|
558
558
|
}
|
|
559
|
-
if (
|
|
559
|
+
if (isInactive(record.lastUsedFrame, record.lastUsedTime, policy.frame, policy.time, policy.maxIdleFrames, policy.maxIdleMilliseconds)) {
|
|
560
560
|
try {
|
|
561
561
|
this.#CleanupRecord(record, policy, "purge inactive", true);
|
|
562
562
|
} catch (error) {
|
|
@@ -568,20 +568,20 @@ class CjsMotherLode {
|
|
|
568
568
|
try {
|
|
569
569
|
record.resource?.MarkPurged?.();
|
|
570
570
|
} catch (cause) {
|
|
571
|
-
errors.push(
|
|
571
|
+
errors.push(motherLodeCleanupError("mark purged", key, record.resource, cause));
|
|
572
572
|
}
|
|
573
573
|
continue;
|
|
574
574
|
}
|
|
575
|
-
if (policy.releasePayload !== false &&
|
|
575
|
+
if (policy.releasePayload !== false && hasOwnedPayload(record.resource) && isInactive(record.payloadLastUsedFrame, record.payloadLastUsedTime, policy.frame, policy.time, policy.payloadMaxIdleFrames, policy.payloadMaxIdleMilliseconds)) {
|
|
576
576
|
try {
|
|
577
577
|
record.resource.ReleasePayload();
|
|
578
578
|
payloadKeys.push(key);
|
|
579
579
|
} catch (cause) {
|
|
580
|
-
errors.push(
|
|
580
|
+
errors.push(motherLodeCleanupError("release inactive payload", key, record.resource, cause));
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
583
|
}
|
|
584
|
-
const result =
|
|
584
|
+
const result = freezePurgeResult(policy.frame, policy.time, purgedKeys, payloadKeys, locked);
|
|
585
585
|
if (errors.length) {
|
|
586
586
|
const error = new AggregateError(errors, "CjsMotherLode inactivity purge failed.");
|
|
587
587
|
error.code = "CJS_MOTHERLODE_PURGE_FAILED";
|
|
@@ -613,7 +613,7 @@ class CjsMotherLode {
|
|
|
613
613
|
* @throws {AggregateError} If cleanup or purge-state publication fails for one or more candidates.
|
|
614
614
|
*/
|
|
615
615
|
TrimCache(options = {}) {
|
|
616
|
-
const policy =
|
|
616
|
+
const policy = normalizeOptions(options, "cache trim");
|
|
617
617
|
const beforeBytes = this.#GetCacheBytes();
|
|
618
618
|
const evictedKeys = [];
|
|
619
619
|
const failedKeys = [];
|
|
@@ -641,13 +641,13 @@ class CjsMotherLode {
|
|
|
641
641
|
try {
|
|
642
642
|
record.resource?.MarkPurged?.();
|
|
643
643
|
} catch (cause) {
|
|
644
|
-
errors.push(
|
|
644
|
+
errors.push(motherLodeCleanupError("mark cache eviction purged", record.key, record.resource, cause));
|
|
645
645
|
failedKeys.push(record.key);
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
649
|
const afterBytes = this.#GetCacheBytes();
|
|
650
|
-
const result =
|
|
650
|
+
const result = freezeCacheTrimResult(this.#cacheSize, beforeBytes, afterBytes, evictedBytes, evictedKeys, failedKeys);
|
|
651
651
|
if (errors.length) {
|
|
652
652
|
const error = new AggregateError(errors, "CjsMotherLode cache trim failed.");
|
|
653
653
|
error.code = "CJS_MOTHERLODE_CACHE_TRIM_FAILED";
|
|
@@ -669,8 +669,8 @@ class CjsMotherLode {
|
|
|
669
669
|
* @throws {AggregateError} If enforcing the new budget cannot clean one or more cached entries.
|
|
670
670
|
*/
|
|
671
671
|
SetCacheSize(bytes, options = {}) {
|
|
672
|
-
|
|
673
|
-
const policy =
|
|
672
|
+
assertNonNegativeSafeInteger(bytes, "CjsMotherLode cache size");
|
|
673
|
+
const policy = normalizeOptions(options, "set cache size");
|
|
674
674
|
this.#cacheSize = bytes;
|
|
675
675
|
this.TrimCache(policy);
|
|
676
676
|
return this;
|
|
@@ -734,8 +734,8 @@ class CjsMotherLode {
|
|
|
734
734
|
cacheBytes += record.bytes;
|
|
735
735
|
}
|
|
736
736
|
if (record.lockCount > 0) locked += 1;
|
|
737
|
-
if (
|
|
738
|
-
const path = record.resource?.GetPath?.() || record.resource?.path ||
|
|
737
|
+
if (hasOwnedPayload(record.resource)) payloads += 1;
|
|
738
|
+
const path = record.resource?.GetPath?.() || record.resource?.path || getKeyPath(record.key);
|
|
739
739
|
if (path) paths.add(path);
|
|
740
740
|
const state = typeof record.resource?.state === "string" ? record.resource.state : "unknown";
|
|
741
741
|
states[state] = (states[state] || 0) + 1;
|
|
@@ -840,7 +840,7 @@ class CjsMotherLode {
|
|
|
840
840
|
*/
|
|
841
841
|
#UpdateRecord(record, options) {
|
|
842
842
|
if (options.bytes !== undefined) {
|
|
843
|
-
|
|
843
|
+
assertNonNegativeSafeInteger(options.bytes, "CjsMotherLode entry bytes");
|
|
844
844
|
record.bytes = options.bytes;
|
|
845
845
|
}
|
|
846
846
|
if (options.cacheable !== undefined) record.cacheable = Boolean(options.cacheable);
|
|
@@ -900,7 +900,7 @@ class CjsMotherLode {
|
|
|
900
900
|
*/
|
|
901
901
|
#TouchRecord(record, options) {
|
|
902
902
|
const frame = options.frame === undefined ? this.#activityFrame + 1 : options.frame;
|
|
903
|
-
|
|
903
|
+
assertNonNegativeSafeInteger(frame, "CjsMotherLode activity frame");
|
|
904
904
|
this.#activityFrame = Math.max(this.#activityFrame, frame);
|
|
905
905
|
record.lastUsedFrame = frame;
|
|
906
906
|
const time = options.time === undefined ? this.#now() : options.time;
|
|
@@ -924,18 +924,18 @@ class CjsMotherLode {
|
|
|
924
924
|
#CleanupRecord(record, options, operation, preserveOnFailure = false) {
|
|
925
925
|
let cleanupComplete = false;
|
|
926
926
|
try {
|
|
927
|
-
|
|
927
|
+
cleanupOwnedResource(record.resource, options);
|
|
928
928
|
cleanupComplete = true;
|
|
929
|
-
|
|
929
|
+
detachResourceLifecycle(record.resource);
|
|
930
930
|
} catch (cause) {
|
|
931
931
|
if (!preserveOnFailure && !cleanupComplete) {
|
|
932
932
|
try {
|
|
933
|
-
|
|
933
|
+
detachResourceLifecycle(record.resource);
|
|
934
934
|
} catch (detachCause) {
|
|
935
935
|
cause = new AggregateError([cause, detachCause], "Resource cleanup and detach failed.");
|
|
936
936
|
}
|
|
937
937
|
}
|
|
938
|
-
throw
|
|
938
|
+
throw motherLodeCleanupError(operation, record.key, record.resource, cause);
|
|
939
939
|
}
|
|
940
940
|
}
|
|
941
941
|
|
|
@@ -952,14 +952,14 @@ class CjsMotherLode {
|
|
|
952
952
|
const errors = [];
|
|
953
953
|
for (const record of records) {
|
|
954
954
|
try {
|
|
955
|
-
|
|
955
|
+
cleanupOwnedResource(record.resource, options);
|
|
956
956
|
} catch (cause) {
|
|
957
|
-
errors.push(
|
|
957
|
+
errors.push(motherLodeCleanupError(operation, record.key, record.resource, cause));
|
|
958
958
|
}
|
|
959
959
|
try {
|
|
960
|
-
|
|
960
|
+
detachResourceLifecycle(record.resource);
|
|
961
961
|
} catch (cause) {
|
|
962
|
-
errors.push(
|
|
962
|
+
errors.push(motherLodeCleanupError(`${operation} detach`, record.key, record.resource, cause));
|
|
963
963
|
}
|
|
964
964
|
}
|
|
965
965
|
if (errors.length) {
|
|
@@ -979,7 +979,7 @@ class CjsMotherLode {
|
|
|
979
979
|
* @throws {TypeError} If the path is empty/invalid or the variant contains a null byte.
|
|
980
980
|
*/
|
|
981
981
|
function getMotherLodeKey(path, variant = "") {
|
|
982
|
-
const normalizedPath =
|
|
982
|
+
const normalizedPath = normalizePath(path);
|
|
983
983
|
if (variant === null || variant === undefined || variant === "") return normalizedPath;
|
|
984
984
|
const normalizedVariant = String(variant);
|
|
985
985
|
if (normalizedVariant.includes("\u0000")) {
|
|
@@ -987,18 +987,18 @@ function getMotherLodeKey(path, variant = "") {
|
|
|
987
987
|
}
|
|
988
988
|
return `${normalizedPath}\u0000${normalizedVariant}`;
|
|
989
989
|
}
|
|
990
|
-
function
|
|
990
|
+
function normalizeInsertArguments(keyOrResource, resourceOrPath, optionsOrVariant) {
|
|
991
991
|
if (typeof keyOrResource === "string") {
|
|
992
992
|
return {
|
|
993
|
-
key:
|
|
993
|
+
key: normalizeResolvedKey(keyOrResource),
|
|
994
994
|
resource: resourceOrPath,
|
|
995
|
-
options:
|
|
995
|
+
options: normalizeOptions(optionsOrVariant, "insert")
|
|
996
996
|
};
|
|
997
997
|
}
|
|
998
998
|
const resource = keyOrResource;
|
|
999
999
|
const path = resourceOrPath ?? resource?.GetPath?.() ?? resource?.path;
|
|
1000
1000
|
const isOptions = optionsOrVariant && typeof optionsOrVariant === "object" && !Array.isArray(optionsOrVariant);
|
|
1001
|
-
const options = isOptions ?
|
|
1001
|
+
const options = isOptions ? normalizeOptions(optionsOrVariant, "insert") : {};
|
|
1002
1002
|
const variant = isOptions ? options.variant || "" : optionsOrVariant;
|
|
1003
1003
|
return {
|
|
1004
1004
|
key: getMotherLodeKey(path, variant),
|
|
@@ -1006,46 +1006,46 @@ function NormalizeInsertArguments(keyOrResource, resourceOrPath, optionsOrVarian
|
|
|
1006
1006
|
options
|
|
1007
1007
|
};
|
|
1008
1008
|
}
|
|
1009
|
-
function
|
|
1009
|
+
function normalizeDeleteArguments(key, variantOrOptions, maybeOptions) {
|
|
1010
1010
|
if (variantOrOptions && typeof variantOrOptions === "object" && !Array.isArray(variantOrOptions)) {
|
|
1011
1011
|
return {
|
|
1012
|
-
resolvedKey:
|
|
1013
|
-
options:
|
|
1012
|
+
resolvedKey: normalizeResolvedKey(key),
|
|
1013
|
+
options: normalizeOptions(variantOrOptions, "delete")
|
|
1014
1014
|
};
|
|
1015
1015
|
}
|
|
1016
1016
|
return {
|
|
1017
|
-
resolvedKey:
|
|
1018
|
-
options:
|
|
1017
|
+
resolvedKey: normalizeLookupKey(key, variantOrOptions),
|
|
1018
|
+
options: normalizeOptions(maybeOptions || {}, "delete")
|
|
1019
1019
|
};
|
|
1020
1020
|
}
|
|
1021
|
-
function
|
|
1021
|
+
function normalizeActivityArguments(key, variantOrOptions, maybeOptions) {
|
|
1022
1022
|
if (variantOrOptions && typeof variantOrOptions === "object" && !Array.isArray(variantOrOptions)) {
|
|
1023
1023
|
return {
|
|
1024
|
-
resolvedKey:
|
|
1025
|
-
options:
|
|
1024
|
+
resolvedKey: normalizeResolvedKey(key),
|
|
1025
|
+
options: normalizeOptions(variantOrOptions, "activity")
|
|
1026
1026
|
};
|
|
1027
1027
|
}
|
|
1028
1028
|
return {
|
|
1029
|
-
resolvedKey:
|
|
1030
|
-
options:
|
|
1029
|
+
resolvedKey: normalizeLookupKey(key, variantOrOptions),
|
|
1030
|
+
options: normalizeOptions(maybeOptions || {}, "activity")
|
|
1031
1031
|
};
|
|
1032
1032
|
}
|
|
1033
|
-
function
|
|
1034
|
-
return variant === undefined ?
|
|
1033
|
+
function normalizeLookupKey(key, variant) {
|
|
1034
|
+
return variant === undefined ? normalizeResolvedKey(key) : getMotherLodeKey(key, variant);
|
|
1035
1035
|
}
|
|
1036
|
-
function
|
|
1036
|
+
function normalizeResolvedKey(key) {
|
|
1037
1037
|
if (typeof key !== "string" || !key) {
|
|
1038
1038
|
throw new TypeError("CjsMotherLode requires a canonical string key.");
|
|
1039
1039
|
}
|
|
1040
1040
|
const separator = key.indexOf("\u0000");
|
|
1041
1041
|
return separator === -1 ? getMotherLodeKey(key) : getMotherLodeKey(key.slice(0, separator), key.slice(separator + 1));
|
|
1042
1042
|
}
|
|
1043
|
-
function
|
|
1043
|
+
function normalizePath(path) {
|
|
1044
1044
|
const normalizedPath = normalizeResourcePath(path);
|
|
1045
1045
|
if (!normalizedPath) throw new TypeError("CjsMotherLode requires a resource path.");
|
|
1046
1046
|
return normalizedPath;
|
|
1047
1047
|
}
|
|
1048
|
-
function
|
|
1048
|
+
function normalizeOptions(options, operation) {
|
|
1049
1049
|
if (options === null || options === undefined) return {};
|
|
1050
1050
|
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
1051
1051
|
throw new TypeError(`CjsMotherLode ${operation} options must be an object.`);
|
|
@@ -1061,20 +1061,20 @@ function NormalizeOptions(options, operation) {
|
|
|
1061
1061
|
* @param {() => number} now Registry clock.
|
|
1062
1062
|
* @returns {CjsMotherLodePurgeOptions & {frame: number, time: number}} Validated sweep policy.
|
|
1063
1063
|
*/
|
|
1064
|
-
function
|
|
1065
|
-
const policy =
|
|
1064
|
+
function normalizePurgeOptions(options, activityFrame, now) {
|
|
1065
|
+
const policy = normalizeOptions(options, "purge");
|
|
1066
1066
|
const frame = policy.frame === undefined ? activityFrame + 1 : policy.frame;
|
|
1067
|
-
|
|
1067
|
+
assertNonNegativeSafeInteger(frame, "CjsMotherLode purge frame");
|
|
1068
1068
|
const time = policy.time === undefined ? now() : policy.time;
|
|
1069
|
-
|
|
1069
|
+
assertNonNegativeFiniteNumber(time, "CjsMotherLode purge time");
|
|
1070
1070
|
for (const name of ["maxIdleFrames", "payloadMaxIdleFrames"]) {
|
|
1071
1071
|
if (policy[name] !== undefined) {
|
|
1072
|
-
|
|
1072
|
+
assertNonNegativeSafeInteger(policy[name], `CjsMotherLode ${name}`);
|
|
1073
1073
|
}
|
|
1074
1074
|
}
|
|
1075
1075
|
for (const name of ["maxIdleMilliseconds", "payloadMaxIdleMilliseconds"]) {
|
|
1076
1076
|
if (policy[name] !== undefined) {
|
|
1077
|
-
|
|
1077
|
+
assertNonNegativeFiniteNumber(policy[name], `CjsMotherLode ${name}`);
|
|
1078
1078
|
}
|
|
1079
1079
|
}
|
|
1080
1080
|
return {
|
|
@@ -1095,7 +1095,7 @@ function NormalizePurgeOptions(options, activityFrame, now) {
|
|
|
1095
1095
|
* @param {number|undefined} maxMilliseconds Optional millisecond limit.
|
|
1096
1096
|
* @returns {boolean} Whether at least one configured limit has elapsed.
|
|
1097
1097
|
*/
|
|
1098
|
-
function
|
|
1098
|
+
function isInactive(lastFrame, lastTime, frame, time, maxFrames, maxMilliseconds) {
|
|
1099
1099
|
const frameExpired = maxFrames !== undefined && frame >= lastFrame && frame - lastFrame >= maxFrames;
|
|
1100
1100
|
const timeExpired = maxMilliseconds !== undefined && time >= lastTime && time - lastTime >= maxMilliseconds;
|
|
1101
1101
|
return frameExpired || timeExpired;
|
|
@@ -1107,7 +1107,7 @@ function IsInactive(lastFrame, lastTime, frame, time, maxFrames, maxMilliseconds
|
|
|
1107
1107
|
* @param {object|Function} resource Candidate resource.
|
|
1108
1108
|
* @returns {boolean} Whether `ReleasePayload()` can remove an attached payload.
|
|
1109
1109
|
*/
|
|
1110
|
-
function
|
|
1110
|
+
function hasOwnedPayload(resource) {
|
|
1111
1111
|
return typeof resource?.HasPayload === "function" && typeof resource?.ReleasePayload === "function" && Boolean(resource.HasPayload());
|
|
1112
1112
|
}
|
|
1113
1113
|
|
|
@@ -1117,10 +1117,10 @@ function HasOwnedPayload(resource) {
|
|
|
1117
1117
|
* @param {object|Function} resource Removed resource.
|
|
1118
1118
|
* @returns {void}
|
|
1119
1119
|
*/
|
|
1120
|
-
function
|
|
1120
|
+
function detachResourceLifecycle(resource) {
|
|
1121
1121
|
resource?.SetLifecycleController?.(null);
|
|
1122
1122
|
}
|
|
1123
|
-
function
|
|
1123
|
+
function cleanupOwnedResource(resource, options) {
|
|
1124
1124
|
if (options.cleanup === false) return;
|
|
1125
1125
|
if (typeof options.cleanup === "function") {
|
|
1126
1126
|
options.cleanup(resource);
|
|
@@ -1147,12 +1147,12 @@ function CleanupOwnedResource(resource, options) {
|
|
|
1147
1147
|
throw errors.length === 1 ? errors[0] : new AggregateError(errors, "Resource cleanup failed.");
|
|
1148
1148
|
}
|
|
1149
1149
|
}
|
|
1150
|
-
function
|
|
1150
|
+
function assertResource(resource) {
|
|
1151
1151
|
if (typeof resource !== "object" && typeof resource !== "function" || resource === null) {
|
|
1152
1152
|
throw new TypeError("CjsMotherLode requires a resource object.");
|
|
1153
1153
|
}
|
|
1154
1154
|
}
|
|
1155
|
-
function
|
|
1155
|
+
function assertNonNegativeSafeInteger(value, label) {
|
|
1156
1156
|
if (!Number.isSafeInteger(value) || value < 0) {
|
|
1157
1157
|
throw new TypeError(`${label} must be a non-negative safe integer.`);
|
|
1158
1158
|
}
|
|
@@ -1165,12 +1165,12 @@ function AssertNonNegativeSafeInteger(value, label) {
|
|
|
1165
1165
|
* @param {string} label Error-message field name.
|
|
1166
1166
|
* @returns {void}
|
|
1167
1167
|
*/
|
|
1168
|
-
function
|
|
1168
|
+
function assertNonNegativeFiniteNumber(value, label) {
|
|
1169
1169
|
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
1170
1170
|
throw new TypeError(`${label} must be a non-negative finite number.`);
|
|
1171
1171
|
}
|
|
1172
1172
|
}
|
|
1173
|
-
function
|
|
1173
|
+
function freezeInsertResult(key, resource, inserted, replaced, displaced) {
|
|
1174
1174
|
return Object.freeze({
|
|
1175
1175
|
key,
|
|
1176
1176
|
resource,
|
|
@@ -1189,7 +1189,7 @@ function FreezeInsertResult(key, resource, inserted, replaced, displaced) {
|
|
|
1189
1189
|
* @param {object|Function|null} displaced Former owner when committed.
|
|
1190
1190
|
* @returns {CjsMotherLodeConditionalReplaceResult} Immutable replacement result.
|
|
1191
1191
|
*/
|
|
1192
|
-
function
|
|
1192
|
+
function freezeConditionalReplaceResult(key, committed, resource, displaced) {
|
|
1193
1193
|
return Object.freeze({
|
|
1194
1194
|
key,
|
|
1195
1195
|
committed,
|
|
@@ -1208,7 +1208,7 @@ function FreezeConditionalReplaceResult(key, committed, resource, displaced) {
|
|
|
1208
1208
|
* @param {number} locked Number of locked entries skipped.
|
|
1209
1209
|
* @returns {CjsMotherLodePurgeResult} Immutable sweep result.
|
|
1210
1210
|
*/
|
|
1211
|
-
function
|
|
1211
|
+
function freezePurgeResult(frame, time, purgedKeys, payloadKeys, locked) {
|
|
1212
1212
|
return Object.freeze({
|
|
1213
1213
|
frame,
|
|
1214
1214
|
time,
|
|
@@ -1231,7 +1231,7 @@ function FreezePurgeResult(frame, time, purgedKeys, payloadKeys, locked) {
|
|
|
1231
1231
|
* @param {string[]} failedKeys Candidate identities that reported failure.
|
|
1232
1232
|
* @returns {CjsMotherLodeCacheTrimResult} Immutable cache-housekeeping result.
|
|
1233
1233
|
*/
|
|
1234
|
-
function
|
|
1234
|
+
function freezeCacheTrimResult(cacheSize, beforeBytes, afterBytes, evictedBytes, evictedKeys, failedKeys) {
|
|
1235
1235
|
return Object.freeze({
|
|
1236
1236
|
cacheSize,
|
|
1237
1237
|
beforeBytes,
|
|
@@ -1244,12 +1244,12 @@ function FreezeCacheTrimResult(cacheSize, beforeBytes, afterBytes, evictedBytes,
|
|
|
1244
1244
|
failedKeys: Object.freeze(failedKeys)
|
|
1245
1245
|
});
|
|
1246
1246
|
}
|
|
1247
|
-
function
|
|
1247
|
+
function motherLodeInactiveError() {
|
|
1248
1248
|
const error = new Error("CjsMotherLode is shut down. Call Startup() before inserting resources.");
|
|
1249
1249
|
error.code = "CJS_MOTHERLODE_INACTIVE";
|
|
1250
1250
|
return error;
|
|
1251
1251
|
}
|
|
1252
|
-
function
|
|
1252
|
+
function motherLodeCleanupError(operation, key, resource, cause) {
|
|
1253
1253
|
const error = new Error(`CjsMotherLode ${operation} cleanup failed for ${key}.`, {
|
|
1254
1254
|
cause
|
|
1255
1255
|
});
|
|
@@ -1259,11 +1259,11 @@ function MotherLodeCleanupError(operation, key, resource, cause) {
|
|
|
1259
1259
|
error.resource = resource;
|
|
1260
1260
|
return error;
|
|
1261
1261
|
}
|
|
1262
|
-
function
|
|
1262
|
+
function getKeyPath(key) {
|
|
1263
1263
|
const separator = key.indexOf("\u0000");
|
|
1264
1264
|
return separator === -1 ? key : key.slice(0, separator);
|
|
1265
1265
|
}
|
|
1266
|
-
function
|
|
1266
|
+
function defaultNow() {
|
|
1267
1267
|
return Date.now();
|
|
1268
1268
|
}
|
|
1269
1269
|
|