@carbonenginejs/runtime 0.1.0-alpha.4 → 0.1.0-alpha.5
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/dist/global/blue/BlueClasses.js +200 -0
- package/dist/global/blue/BlueClasses.js.map +1 -0
- package/dist/global/blue/IBlueClasses.js +79 -0
- package/dist/global/blue/IBlueClasses.js.map +1 -0
- package/dist/global/blue/IBlueDynamicResourceConstructor.js +16 -0
- package/dist/global/blue/IBlueDynamicResourceConstructor.js.map +1 -1
- package/dist/global/blue/blue.js +8 -2
- package/dist/global/blue/blue.js.map +1 -1
- package/dist/global/blue/index.js +2 -0
- package/dist/global/blue/index.js.map +1 -1
- package/dist/global/consts/index.js +0 -1
- package/dist/global/consts/index.js.map +1 -1
- package/dist/global/consts/renderContext/formats.js +26 -25
- package/dist/global/consts/renderContext/formats.js.map +1 -1
- package/dist/{trinityal/Tr2BitmapDimensions.js → global/imageio/BitmapDimensions.js} +19 -15
- package/dist/global/imageio/BitmapDimensions.js.map +1 -0
- package/dist/global/imageio/Cutout.js +28 -0
- package/dist/global/imageio/Cutout.js.map +1 -0
- package/dist/global/imageio/HostBitmap.js +1106 -0
- package/dist/global/imageio/HostBitmap.js.map +1 -0
- package/dist/global/imageio/ImageIOResult.js +99 -0
- package/dist/global/imageio/ImageIOResult.js.map +1 -0
- package/dist/global/imageio/ImageUtility.js +205 -0
- package/dist/global/imageio/ImageUtility.js.map +1 -0
- package/dist/global/imageio/LoadParameters.js +86 -0
- package/dist/global/imageio/LoadParameters.js.map +1 -0
- package/dist/global/imageio/Metadata.js +22 -0
- package/dist/global/imageio/Metadata.js.map +1 -0
- package/dist/global/imageio/index.js +8 -0
- package/dist/global/{consts/webgpu → imageio}/index.js.map +1 -1
- package/dist/global/index.js +2 -1
- package/dist/global/index.js.map +1 -1
- package/dist/global/math/color.js +1 -1
- package/dist/global/math/color.js.map +1 -1
- package/dist/global/schema/CjsSchema.js +8 -0
- package/dist/global/schema/CjsSchema.js.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/resource/CjsResMan.js +47 -7
- package/dist/resource/CjsResMan.js.map +1 -1
- package/dist/resource/Tr2LightProfileRes.js +37 -0
- package/dist/resource/Tr2LightProfileRes.js.map +1 -1
- package/dist/resource/format/CjsByteWriter.js +46 -46
- package/dist/resource/format/CjsByteWriter.js.map +1 -1
- package/dist/resource/format/CjsFormat.js +7 -8
- package/dist/resource/format/CjsFormat.js.map +1 -1
- package/dist/resource/format/CjsFormatStore.js +8 -8
- package/dist/resource/format/CjsFormatStore.js.map +1 -1
- package/dist/resource/format/CjsGeometryFormat.js +114 -0
- package/dist/resource/format/CjsGeometryFormat.js.map +1 -0
- package/dist/resource/format/CjsImageFormat.js +282 -0
- package/dist/resource/format/CjsImageFormat.js.map +1 -0
- package/dist/resource/format/CjsResourceProbe.js +12 -48
- package/dist/resource/format/CjsResourceProbe.js.map +1 -1
- package/dist/resource/format/CjsStringTable.js +37 -37
- package/dist/resource/format/CjsStringTable.js.map +1 -1
- package/dist/resource/format/carbonEffect/CjsCarbonEffectReader.js +10 -10
- package/dist/resource/format/carbonEffect/CjsCarbonEffectReader.js.map +1 -1
- package/dist/resource/format/carbonEffect/CjsCarbonEffectWriter.js +37 -37
- package/dist/resource/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -1
- package/dist/resource/format/carbonEffect/carbonEffectBackendBlock.js +35 -7
- package/dist/resource/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
- package/dist/resource/format/index.js +3 -1
- package/dist/resource/format/index.js.map +1 -1
- package/dist/resource/formats/black/CjsBlackFormat.js +130 -137
- package/dist/resource/formats/black/CjsBlackFormat.js.map +1 -1
- package/dist/resource/formats/bnk/CjsBnkFormat.js +12 -19
- package/dist/resource/formats/bnk/CjsBnkFormat.js.map +1 -1
- package/dist/resource/formats/bnk/core/helpers.js +1 -3
- package/dist/resource/formats/bnk/core/helpers.js.map +1 -1
- package/dist/resource/formats/cmf/CjsCmfFormat.js +19 -82
- package/dist/resource/formats/cmf/CjsCmfFormat.js.map +1 -1
- package/dist/resource/formats/cmf/core/constants.js +1 -2
- package/dist/resource/formats/cmf/core/constants.js.map +1 -1
- package/dist/resource/formats/{stl/core/targets.js → cmf/core/flatShared.js} +9 -8
- package/dist/resource/formats/cmf/core/flatShared.js.map +1 -0
- package/dist/resource/formats/cmf/core/helpers.js +13 -13
- package/dist/resource/formats/cmf/core/helpers.js.map +1 -1
- package/dist/resource/formats/cmf/core/writer.js +24 -24
- package/dist/resource/formats/cmf/core/writer.js.map +1 -1
- package/dist/resource/formats/dds/CjsDdsFormat.js +134 -17
- package/dist/resource/formats/dds/CjsDdsFormat.js.map +1 -1
- package/dist/resource/formats/dds/core/helpers.js +125 -40
- package/dist/resource/formats/dds/core/helpers.js.map +1 -1
- package/dist/resource/formats/dxbc/CjsDxbcFormat.js +14 -16
- package/dist/resource/formats/dxbc/CjsDxbcFormat.js.map +1 -1
- package/dist/resource/formats/dxbc/core/{container.js → DxbcContainer.js} +2 -2
- package/dist/resource/formats/dxbc/core/DxbcContainer.js.map +1 -0
- package/dist/resource/formats/dxbc/core/{errors.js → DxbcReadError.js} +1 -1
- package/dist/resource/formats/dxbc/core/DxbcReadError.js.map +1 -0
- package/dist/resource/formats/dxbc/core/DxbcReader.js +1 -1
- package/dist/resource/formats/dxbc/core/DxbcReader.js.map +1 -1
- package/dist/resource/formats/dxbc/core/{program.js → DxbcShaderProgram.js} +2 -2
- package/dist/resource/formats/dxbc/core/DxbcShaderProgram.js.map +1 -0
- package/dist/resource/formats/dxbc/core/{signature.js → DxbcSignatureChunk.js} +2 -2
- package/dist/resource/formats/dxbc/core/DxbcSignatureChunk.js.map +1 -0
- package/dist/resource/formats/dxbc/core/decoder.js +2 -2
- package/dist/resource/formats/dxbc/core/decoder.js.map +1 -1
- package/dist/resource/formats/dxbc/core/helpers.js +3 -3
- package/dist/resource/formats/dxbc/core/helpers.js.map +1 -1
- package/dist/resource/formats/fbx/CjsFbxFormat.js +18 -20
- package/dist/resource/formats/fbx/CjsFbxFormat.js.map +1 -1
- package/dist/resource/formats/flac/CjsFlacFormat.js +7 -13
- package/dist/resource/formats/flac/CjsFlacFormat.js.map +1 -1
- package/dist/resource/formats/fsd/32/CjsFsd32Format.js +29 -29
- package/dist/resource/formats/fsd/32/CjsFsd32Format.js.map +1 -1
- package/dist/resource/formats/fsd/64/CjsFsd64Format.js +3 -3
- package/dist/resource/formats/fsd/64/CjsFsd64Format.js.map +1 -1
- package/dist/resource/formats/fsd/64/core/CjsFsd64Binary.js +23 -23
- package/dist/resource/formats/fsd/64/core/CjsFsd64Binary.js.map +1 -1
- package/dist/resource/formats/fsd/64/core/CjsFsd64Reader.js +8 -8
- package/dist/resource/formats/fsd/64/core/CjsFsd64Reader.js.map +1 -1
- package/dist/resource/formats/fsd/CjsFsdFormat.js +23 -23
- package/dist/resource/formats/fsd/CjsFsdFormat.js.map +1 -1
- package/dist/resource/formats/gif/CjsGifFormat.js +24 -15
- package/dist/resource/formats/gif/CjsGifFormat.js.map +1 -1
- package/dist/resource/formats/gltf/CjsGltfFormat.js +33 -98
- package/dist/resource/formats/gltf/CjsGltfFormat.js.map +1 -1
- package/dist/resource/formats/gltf/core/helpers.js +3 -12
- package/dist/resource/formats/gltf/core/helpers.js.map +1 -1
- package/dist/resource/formats/gr2/CjsGr2Format.js +27 -91
- package/dist/resource/formats/gr2/CjsGr2Format.js.map +1 -1
- package/dist/resource/formats/hlsl/CjsHlslFormat.js +22 -25
- package/dist/resource/formats/hlsl/CjsHlslFormat.js.map +1 -1
- package/dist/resource/formats/hlsl/core/carbonDescriptionToRuntime.js +1 -1
- package/dist/resource/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -1
- package/dist/resource/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js +3 -3
- package/dist/resource/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js.map +1 -1
- package/dist/resource/formats/ies/CjsIESFormat.js +29 -29
- package/dist/resource/formats/ies/CjsIESFormat.js.map +1 -1
- package/dist/resource/formats/jpeg/CjsJpegFormat.js +24 -15
- package/dist/resource/formats/jpeg/CjsJpegFormat.js.map +1 -1
- package/dist/resource/formats/jpeg/core/helpers.js +3 -5
- package/dist/resource/formats/jpeg/core/helpers.js.map +1 -1
- package/dist/resource/formats/jpeg/core/jpeg.js +58 -58
- package/dist/resource/formats/jpeg/core/jpeg.js.map +1 -1
- package/dist/resource/formats/jsonl/CjsJsonlFormat.js +3 -3
- package/dist/resource/formats/jsonl/CjsJsonlFormat.js.map +1 -1
- package/dist/resource/formats/mp3/CjsMp3Format.js +7 -14
- package/dist/resource/formats/mp3/CjsMp3Format.js.map +1 -1
- package/dist/resource/formats/mp3/core/helpers.js +3 -5
- package/dist/resource/formats/mp3/core/helpers.js.map +1 -1
- package/dist/resource/formats/mp4/CjsMp4Format.js +7 -13
- package/dist/resource/formats/mp4/CjsMp4Format.js.map +1 -1
- package/dist/resource/formats/mp4/core/helpers.js +3 -5
- package/dist/resource/formats/mp4/core/helpers.js.map +1 -1
- package/dist/resource/formats/obj/CjsObjFormat.js +92 -157
- package/dist/resource/formats/obj/CjsObjFormat.js.map +1 -1
- package/dist/resource/formats/obj/core/helpers.js +5 -113
- package/dist/resource/formats/obj/core/helpers.js.map +1 -1
- package/dist/resource/formats/ogg/CjsOggFormat.js +7 -14
- package/dist/resource/formats/ogg/CjsOggFormat.js.map +1 -1
- package/dist/resource/formats/pickle/CjsPickleFormat.js +7 -12
- package/dist/resource/formats/pickle/CjsPickleFormat.js.map +1 -1
- package/dist/resource/formats/pickle/core/CjsPickleProtocol0Reader.js +7 -7
- package/dist/resource/formats/pickle/core/CjsPickleProtocol0Reader.js.map +1 -1
- package/dist/resource/formats/pickle/core/CjsPickleProtocol4Reader.js +7 -7
- package/dist/resource/formats/pickle/core/CjsPickleProtocol4Reader.js.map +1 -1
- package/dist/resource/formats/png/CjsPngFormat.js +40 -15
- package/dist/resource/formats/png/CjsPngFormat.js.map +1 -1
- package/dist/resource/formats/png/core/helpers.js +4 -6
- package/dist/resource/formats/png/core/helpers.js.map +1 -1
- package/dist/resource/formats/red/CjsRedFormat.js +22 -28
- package/dist/resource/formats/red/CjsRedFormat.js.map +1 -1
- package/dist/resource/formats/schemabound/CjsSchemaBoundFormat.js +3 -7
- package/dist/resource/formats/schemabound/CjsSchemaBoundFormat.js.map +1 -1
- package/dist/resource/formats/schemabound/core/schemaBoundValues.js +5 -0
- package/dist/resource/formats/schemabound/core/schemaBoundValues.js.map +1 -1
- package/dist/resource/formats/sqlite/CjsSqliteFormat.js +4 -9
- package/dist/resource/formats/sqlite/CjsSqliteFormat.js.map +1 -1
- package/dist/resource/formats/static/CjsStaticFormat.js +4 -4
- package/dist/resource/formats/static/CjsStaticFormat.js.map +1 -1
- package/dist/resource/formats/stl/CjsStlFormat.js +39 -104
- package/dist/resource/formats/stl/CjsStlFormat.js.map +1 -1
- package/dist/resource/formats/stl/core/helpers.js +5 -19
- package/dist/resource/formats/stl/core/helpers.js.map +1 -1
- package/dist/resource/formats/tga/CjsTgaFormat.js +26 -15
- package/dist/resource/formats/tga/CjsTgaFormat.js.map +1 -1
- package/dist/resource/formats/tga/core/helpers.js +3 -5
- package/dist/resource/formats/tga/core/helpers.js.map +1 -1
- package/dist/resource/formats/vta/CjsVtaFormat.js +8 -15
- package/dist/resource/formats/vta/CjsVtaFormat.js.map +1 -1
- package/dist/resource/formats/wav/CjsWavFormat.js +7 -14
- package/dist/resource/formats/wav/CjsWavFormat.js.map +1 -1
- package/dist/resource/formats/wav/core/helpers.js +3 -5
- package/dist/resource/formats/wav/core/helpers.js.map +1 -1
- package/dist/resource/formats/webgl/CjsWebglFormat.js +103 -105
- package/dist/resource/formats/webgl/CjsWebglFormat.js.map +1 -1
- package/dist/resource/formats/webgl/core/{errors.js → WebglReadError.js} +1 -1
- package/dist/resource/formats/webgl/core/WebglReadError.js.map +1 -0
- package/dist/resource/formats/webgl/core/effectPackage.js +1 -1
- package/dist/resource/formats/webgl/core/effectPackage.js.map +1 -1
- package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js +3 -3
- package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
- package/dist/resource/formats/webgl/core/glsl/{DxbcGlslHelpers.js → DxbcGlslHelperRegistry.js} +2 -2
- package/dist/resource/formats/webgl/core/glsl/DxbcGlslHelperRegistry.js.map +1 -0
- package/dist/resource/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js +1 -1
- package/dist/resource/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js.map +1 -1
- package/dist/resource/formats/webgl/core/glslBackendBlock.js +1 -1
- package/dist/resource/formats/webgl/core/glslBackendBlock.js.map +1 -1
- package/dist/resource/formats/webgl/core/helpers.js.map +1 -1
- package/dist/resource/formats/webgpu/CjsWebgpuFormat.js +28 -29
- package/dist/resource/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
- package/dist/resource/formats/webgpu/core/{errors.js → WebgpuReadError.js} +1 -1
- package/dist/resource/formats/webgpu/core/WebgpuReadError.js.map +1 -0
- package/dist/resource/formats/webgpu/core/carbonWebgpu/validateContainer.js +1 -1
- package/dist/resource/formats/webgpu/core/carbonWebgpu/validateContainer.js.map +1 -1
- package/dist/resource/formats/webgpu/core/helpers.js +1 -1
- package/dist/resource/formats/webgpu/core/helpers.js.map +1 -1
- package/dist/resource/formats/webgpu/core/ir/lowerDxbcToIr.js +1 -1
- package/dist/resource/formats/webgpu/core/ir/lowerDxbcToIr.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/buildWgslSet.js +18 -6
- package/dist/resource/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/lowerBindingLayout.js +39 -13
- package/dist/resource/formats/webgpu/core/wgsl/lowerBindingLayout.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js +16 -14
- package/dist/resource/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js.map +1 -1
- package/dist/resource/formats/webm/CjsWebmFormat.js +8 -13
- package/dist/resource/formats/webm/CjsWebmFormat.js.map +1 -1
- package/dist/resource/formats/webm/core/helpers.js +3 -5
- package/dist/resource/formats/webm/core/helpers.js.map +1 -1
- package/dist/resource/formats/webp/CjsWebpFormat.js +8 -12
- package/dist/resource/formats/webp/CjsWebpFormat.js.map +1 -1
- package/dist/resource/formats/wem/CjsWemFormat.js +9 -17
- package/dist/resource/formats/wem/CjsWemFormat.js.map +1 -1
- package/dist/resource/formats/wem/core/bitStream.js +35 -35
- package/dist/resource/formats/wem/core/bitStream.js.map +1 -1
- package/dist/resource/formats/wem/core/helpers.js +1 -3
- package/dist/resource/formats/wem/core/helpers.js.map +1 -1
- package/dist/resource/formats/yaml/CjsYamlFormat.js +28 -37
- package/dist/resource/formats/yaml/CjsYamlFormat.js.map +1 -1
- package/dist/resource/imageio/ImageIO.js +142 -0
- package/dist/resource/imageio/ImageIO.js.map +1 -0
- package/dist/resource/imageio/index.js +17 -0
- package/dist/resource/imageio/index.js.map +1 -0
- package/dist/resource/index.js +7 -0
- package/dist/resource/index.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectResource.js +24 -2
- package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2Pass.js +76 -5
- package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
- package/dist/resource/texture/CjsTextureArrayConstructor.js +97 -0
- package/dist/resource/texture/CjsTextureArrayConstructor.js.map +1 -0
- package/dist/resource/texture/CjsTexturePackConstructor.js +160 -0
- package/dist/resource/texture/CjsTexturePackConstructor.js.map +1 -0
- package/dist/resource/texture/CjsTexturePipelineStepArray.js +72 -0
- package/dist/resource/texture/CjsTexturePipelineStepArray.js.map +1 -0
- package/dist/resource/texture/CjsTexturePipelineStepConvert.js +73 -0
- package/dist/resource/texture/CjsTexturePipelineStepConvert.js.map +1 -0
- package/dist/resource/texture/CjsTexturePipelineStepPack.js +71 -0
- package/dist/resource/texture/CjsTexturePipelineStepPack.js.map +1 -0
- package/dist/resource/texture/CjsTexturePipelineStepResize.js +123 -0
- package/dist/resource/texture/CjsTexturePipelineStepResize.js.map +1 -0
- package/dist/resource/texture/SolidColorTextureConstructor.js +11 -1
- package/dist/resource/texture/SolidColorTextureConstructor.js.map +1 -1
- package/dist/resource/texture/Tr2ImageRes.js +100 -68
- package/dist/resource/texture/Tr2ImageRes.js.map +1 -1
- package/dist/resource/texture/Tr2TexturePipeline.js +45 -25
- package/dist/resource/texture/Tr2TexturePipeline.js.map +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepCompress.js +34 -1
- package/dist/resource/texture/Tr2TexturePipelineStepCompress.js.map +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepGenerateMips.js +30 -3
- package/dist/resource/texture/Tr2TexturePipelineStepGenerateMips.js.map +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepLimitSize.js +81 -1
- package/dist/resource/texture/Tr2TexturePipelineStepLimitSize.js.map +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepLoad.js +36 -1
- package/dist/resource/texture/Tr2TexturePipelineStepLoad.js.map +1 -1
- package/dist/resource/texture/Tr2TexturePipelineStepPack.js +146 -24
- package/dist/resource/texture/Tr2TexturePipelineStepPack.js.map +1 -1
- package/dist/resource/texture/TriTextureRes.js +151 -29
- package/dist/resource/texture/TriTextureRes.js.map +1 -1
- package/dist/resource/texture/index.js +7 -0
- package/dist/resource/texture/index.js.map +1 -1
- package/dist/resource/texture/registerTextureResources.js +83 -0
- package/dist/resource/texture/registerTextureResources.js.map +1 -0
- package/dist/resource/texture/solidColorTexture.js +10 -19
- package/dist/resource/texture/solidColorTexture.js.map +1 -1
- package/dist/sof/EveSOF.js +39 -7
- package/dist/sof/EveSOF.js.map +1 -1
- package/dist/trinity/core/Tr2GpuResourcePool/Tr2GpuResourcePool.js +2 -2
- package/dist/trinity/core/Tr2GpuResourcePool/Tr2GpuResourcePool.js.map +1 -1
- package/dist/trinity/core/Tr2ImageIOHelpers.js +80 -17
- package/dist/trinity/core/Tr2ImageIOHelpers.js.map +1 -1
- package/dist/trinity/core/Tr2RenderUtils.js +1 -1
- package/dist/trinity/core/Tr2TextureArray/Tr2TextureArray.js +49 -62
- package/dist/trinity/core/Tr2TextureArray/Tr2TextureArray.js.map +1 -1
- package/dist/trinity/core/Tr2TextureReference.js +114 -0
- package/dist/trinity/core/Tr2TextureReference.js.map +1 -0
- package/dist/trinity/core/device/Tr2DepthStencil.js +2 -2
- package/dist/trinity/core/device/Tr2DepthStencil.js.map +1 -1
- package/dist/trinity/core/device/Tr2RingBuffer/Tr2RingBuffer.js +1 -1
- package/dist/trinity/core/index.js +1 -0
- package/dist/trinity/core/index.js.map +1 -1
- package/dist/trinity/core/lighting/Tr2LightManager.js +5 -4
- package/dist/trinity/core/lighting/Tr2LightManager.js.map +1 -1
- package/dist/trinity/core/procedural/GradientTextureConstructor.js +5 -4
- package/dist/trinity/core/procedural/GradientTextureConstructor.js.map +1 -1
- package/dist/trinity/core/procedural/gradientTexture.js +10 -13
- package/dist/trinity/core/procedural/gradientTexture.js.map +1 -1
- package/dist/trinity/core/volumetrics/Tr2VolumetricsRenderer.js +1 -1
- package/dist/trinity/core/volumetrics/Tr2VolumetricsRenderer.js.map +1 -1
- package/dist/trinity/eve/EveImpactOverlay.js +102 -50
- package/dist/trinity/eve/EveImpactOverlay.js.map +1 -1
- package/dist/trinity/eve/EveModularObjectModifier.js +9 -18
- package/dist/trinity/eve/EveModularObjectModifier.js.map +1 -1
- package/dist/trinity/eve/attachment/turrets/EveTurretSet.js +175 -157
- package/dist/trinity/eve/attachment/turrets/EveTurretSet.js.map +1 -1
- package/dist/trinity/eve/attachment/turrets/EveTurretTarget.js +100 -83
- package/dist/trinity/eve/attachment/turrets/EveTurretTarget.js.map +1 -1
- package/dist/trinity/eve/child/EveChildInstancedMeshes/EveChildInstancedMesh.js +26 -20
- package/dist/trinity/eve/child/EveChildInstancedMeshes/EveChildInstancedMesh.js.map +1 -1
- package/dist/trinity/eve/child/EveChildInstancedMeshes/EveChildInstancedMeshes.js +368 -179
- package/dist/trinity/eve/child/EveChildInstancedMeshes/EveChildInstancedMeshes.js.map +1 -1
- package/dist/trinity/eve/child/EveChildMesh.js +242 -234
- package/dist/trinity/eve/child/EveChildMesh.js.map +1 -1
- package/dist/trinity/eve/child/EveChildTurret.js +57 -16
- package/dist/trinity/eve/child/EveChildTurret.js.map +1 -1
- package/dist/trinity/eve/child/EveSpaceObjectChild.js +28 -1
- package/dist/trinity/eve/child/EveSpaceObjectChild.js.map +1 -1
- package/dist/trinity/eve/index.js +2 -2
- package/dist/trinity/eve/overlays/EveDamageOverlay.js +5 -1
- package/dist/trinity/eve/overlays/EveDamageOverlay.js.map +1 -1
- package/dist/trinity/eve/scene/EveSpaceScene.js +234 -233
- package/dist/trinity/eve/scene/EveSpaceScene.js.map +1 -1
- package/dist/trinity/eve/scene/EveSpaceSceneRenderDriver.js +2 -0
- package/dist/trinity/eve/scene/EveSpaceSceneRenderDriver.js.map +1 -1
- package/dist/trinity/eve/spaceObject/EveSpaceObject2.js +492 -437
- package/dist/trinity/eve/spaceObject/EveSpaceObject2.js.map +1 -1
- package/dist/trinity/generated/index.js +0 -1
- package/dist/trinity/generated/index.js.map +1 -1
- package/dist/trinity/generated/trinityCore/index.js +0 -1
- package/dist/trinity/generated/trinityCore/index.js.map +1 -1
- package/dist/trinity/index.js +3 -3
- package/dist/trinity/particle/emitter/Tr2GpuSharedEmitter.js +10 -1
- package/dist/trinity/particle/emitter/Tr2GpuSharedEmitter.js.map +1 -1
- package/dist/trinity/shader/Tr2DataTextureManager.js +152 -66
- package/dist/trinity/shader/Tr2DataTextureManager.js.map +1 -1
- package/dist/trinity/shader/Tr2Material.js +1 -1
- package/dist/trinityal/Tr2HalHelperStructures/Tr2TextureSubresource.js +5 -5
- package/dist/trinityal/Tr2HalHelperStructures/Tr2TextureSubresource.js.map +1 -1
- package/dist/trinityal/index.js +1 -1
- package/dist/trinityal/stub/Tr2RenderContextALStub/Tr2RenderContextALStub.js +2 -2
- package/dist/trinityal/stub/Tr2RenderContextALStub/Tr2RenderContextALStub.js.map +1 -1
- package/dist/trinityal/stub/Tr2SwapChainALStub.js +45 -45
- package/dist/trinityal/stub/Tr2SwapChainALStub.js.map +1 -1
- package/dist/trinityal/stub/Tr2TextureALStub.js +170 -170
- package/dist/trinityal/stub/Tr2TextureALStub.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuDevice.js +234 -164
- package/dist/trinityal/webgpu/CjsWebgpuDevice.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuRenderContextAL.js +7 -0
- package/dist/trinityal/webgpu/CjsWebgpuRenderContextAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuTextureAL.js +78 -14
- package/dist/trinityal/webgpu/CjsWebgpuTextureAL.js.map +1 -1
- package/dist/trinityal/webgpu/core/CjsWebgpuUtils.js +94 -0
- package/dist/trinityal/webgpu/core/CjsWebgpuUtils.js.map +1 -0
- package/dist/trinityal/webgpu/internal.js +1 -0
- package/dist/trinityal/webgpu/internal.js.map +1 -1
- package/docs/global/reference/classes/README.md +90 -0
- package/docs/resource/concepts/format-capabilities.md +3 -3
- package/docs/resource/formats/README.md +1 -1
- package/docs/resource/reference/classes/core.md +31 -1
- package/docs/resource/reference/classes/formats.md +7 -7
- package/docs/resource/reference/classes/resources.md +76 -16
- package/docs/trinity/reference/classes/generated.md +0 -10
- package/docs/trinity/reference/classes/trinity-core.md +1692 -1682
- package/docs/trinityal/reference/classes/README.md +0 -10
- package/docs/trinityal/webgpu/reference/classes/README.md +276 -266
- package/package.json +4 -3
- package/dist/global/consts/webgpu/index.js +0 -2
- package/dist/global/consts/webgpu/textureFormats.js +0 -180
- package/dist/global/consts/webgpu/textureFormats.js.map +0 -1
- package/dist/resource/formats/dxbc/core/container.js.map +0 -1
- package/dist/resource/formats/dxbc/core/errors.js.map +0 -1
- package/dist/resource/formats/dxbc/core/program.js.map +0 -1
- package/dist/resource/formats/dxbc/core/signature.js.map +0 -1
- package/dist/resource/formats/stl/core/targets.js.map +0 -1
- package/dist/resource/formats/webgl/core/errors.js.map +0 -1
- package/dist/resource/formats/webgl/core/glsl/DxbcGlslHelpers.js.map +0 -1
- package/dist/resource/formats/webgpu/core/errors.js.map +0 -1
- package/dist/resource/texture/texturePipelineBehavior.js +0 -332
- package/dist/resource/texture/texturePipelineBehavior.js.map +0 -1
- package/dist/trinity/generated/trinityCore/Tr2TextureReference.js +0 -40
- package/dist/trinity/generated/trinityCore/Tr2TextureReference.js.map +0 -1
- package/dist/trinityal/Tr2BitmapDimensions.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CjsFormat } from '../../format/CjsFormat.js';
|
|
2
2
|
import { CLASS_KEYS } from './core/schema.js';
|
|
3
|
-
import { DEFAULT_VALUES, normalizeValues, validateClassKey, validateClass, toJsonValue, OUTPUT_RUNTIME, OUTPUT_RAW, copyReaderOptions
|
|
3
|
+
import { DEFAULT_VALUES, normalizeValues, validateClassKey, validateClass, toJsonValue, OUTPUT_RUNTIME, OUTPUT_RAW, copyReaderOptions } from './core/helpers.js';
|
|
4
4
|
import { CjsRedReader } from './core/CjsRedReader.js';
|
|
5
5
|
import { classes } from '../black/core/blackDefinitions.js';
|
|
6
6
|
|
|
@@ -11,7 +11,7 @@ const FORMAT_NAME = "CjsRedFormat";
|
|
|
11
11
|
*
|
|
12
12
|
* Reads Red data - a type-discriminated, self-referential YAML object graph -
|
|
13
13
|
* and emits a compact public payload by default, a neutral raw graph, or
|
|
14
|
-
* caller-supplied runtime classes through the runtime global hydration adapter.
|
|
14
|
+
* caller-supplied runtime classes through the runtime global hydration adapter.
|
|
15
15
|
* With payload IDs enabled, repeated sequences and typed tables use an
|
|
16
16
|
* ID-bearing object around a configurable `payloadValuesField` (default
|
|
17
17
|
* `_values`); unique sequences remain arrays. Active payload marker names must
|
|
@@ -21,10 +21,10 @@ const FORMAT_NAME = "CjsRedFormat";
|
|
|
21
21
|
* cyclic result in that mode is intentionally not JSON-serializable.
|
|
22
22
|
*/
|
|
23
23
|
class CjsRedFormat extends CjsFormat {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
_emit = DEFAULT_VALUES.emit;
|
|
25
|
+
_schema = DEFAULT_VALUES.schema;
|
|
26
|
+
_readerOptions = {};
|
|
27
|
+
_classes = {};
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Create a reusable format profile.
|
|
@@ -42,10 +42,10 @@ class CjsRedFormat extends CjsFormat {
|
|
|
42
42
|
*/
|
|
43
43
|
SetValues(options = {}) {
|
|
44
44
|
const values = normalizeValues(this.GetValues(), options, CLASS_KEYS, FORMAT_NAME);
|
|
45
|
-
this
|
|
46
|
-
this
|
|
47
|
-
this
|
|
48
|
-
this
|
|
45
|
+
this._emit = values.emit;
|
|
46
|
+
this._schema = values.schema;
|
|
47
|
+
this._classes = values.classes;
|
|
48
|
+
this._readerOptions = CjsRedFormat.copyReaderOptions(values);
|
|
49
49
|
return this;
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -57,10 +57,10 @@ class CjsRedFormat extends CjsFormat {
|
|
|
57
57
|
GetValues(options = {}) {
|
|
58
58
|
return normalizeValues({
|
|
59
59
|
...DEFAULT_VALUES,
|
|
60
|
-
emit: this
|
|
61
|
-
schema: this
|
|
62
|
-
...this
|
|
63
|
-
classes: this
|
|
60
|
+
emit: this._emit,
|
|
61
|
+
schema: this._schema,
|
|
62
|
+
...this._readerOptions,
|
|
63
|
+
classes: this._classes
|
|
64
64
|
}, options, CLASS_KEYS, FORMAT_NAME);
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -84,12 +84,12 @@ class CjsRedFormat extends CjsFormat {
|
|
|
84
84
|
SetClass(type, Class) {
|
|
85
85
|
validateClassKey(CLASS_KEYS, type, FORMAT_NAME);
|
|
86
86
|
if (Class === null || Class === undefined) {
|
|
87
|
-
delete this
|
|
87
|
+
delete this._classes[type];
|
|
88
88
|
return this;
|
|
89
89
|
}
|
|
90
90
|
validateClass(CLASS_KEYS, type, Class, FORMAT_NAME);
|
|
91
|
-
this
|
|
92
|
-
...this
|
|
91
|
+
this._classes = {
|
|
92
|
+
...this._classes,
|
|
93
93
|
[type]: Class
|
|
94
94
|
};
|
|
95
95
|
return this;
|
|
@@ -102,7 +102,7 @@ class CjsRedFormat extends CjsFormat {
|
|
|
102
102
|
*/
|
|
103
103
|
GetClass(type) {
|
|
104
104
|
validateClassKey(CLASS_KEYS, type, FORMAT_NAME);
|
|
105
|
-
return this
|
|
105
|
+
return this._classes[type];
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
/**
|
|
@@ -244,17 +244,11 @@ class CjsRedFormat extends CjsFormat {
|
|
|
244
244
|
/**
|
|
245
245
|
* Emit targets for this format (canonical frozen enum).
|
|
246
246
|
*/
|
|
247
|
-
static
|
|
248
|
-
JSON: OUTPUT_JSON,
|
|
249
|
-
PAYLOAD: OUTPUT_PAYLOAD,
|
|
250
|
-
RUNTIME: OUTPUT_RUNTIME,
|
|
251
|
-
RAW: OUTPUT_RAW
|
|
252
|
-
});
|
|
253
|
-
static CLASS_KEYS = CLASS_KEYS;
|
|
247
|
+
static classKeys = CLASS_KEYS;
|
|
254
248
|
static schema = classes;
|
|
255
|
-
static id = "
|
|
256
|
-
static extensions =
|
|
257
|
-
static mediaTypes =
|
|
249
|
+
static id = "CjsRedFormat";
|
|
250
|
+
static extensions = [".red"];
|
|
251
|
+
static mediaTypes = ["data"];
|
|
258
252
|
static outputs = CjsFormat.defineOutputs({
|
|
259
253
|
json: {
|
|
260
254
|
default: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CjsRedFormat.js","sources":["../../../../../src/resource/formats/red/CjsRedFormat.js"],"sourcesContent":["import { CjsFormat } from \"../../format/CjsFormat.js\";\r\nimport { CLASS_KEYS } from \"./core/schema.js\";\r\nimport {\r\n DEFAULT_VALUES,\r\n OUTPUT_JSON,\r\n OUTPUT_PAYLOAD,\r\n OUTPUT_RAW,\r\n OUTPUT_RUNTIME,\r\n copyReaderOptions,\r\n normalizeValues,\r\n toJsonValue,\r\n validateClass,\r\n validateClassKey\r\n} from \"./core/helpers.js\";\r\nimport { CjsRedReader } from \"./core/CjsRedReader.js\";\r\nimport blackDefinitions from \"./core/blackDefinitions.js\";\r\n\r\nconst FORMAT_NAME = \"CjsRedFormat\";\r\n\r\n/**\r\n * CarbonEngineJS-facing Red format profile.\r\n *\r\n * Reads Red data - a type-discriminated, self-referential YAML object graph -\r\n * and emits a compact public payload by default, a neutral raw graph, or\r\n * caller-supplied runtime classes through the runtime global hydration adapter.\n * With payload IDs enabled, repeated sequences and typed tables use an\r\n * ID-bearing object around a configurable `payloadValuesField` (default\r\n * `_values`); unique sequences remain arrays. Active payload marker names must\r\n * be distinct non-empty strings, and authored fields that collide with them\r\n * are rejected. Remap the markers to preserve authored underscore fields.\r\n * Disabling the reference marker preserves actual JavaScript identity; a\r\n * cyclic result in that mode is intentionally not JSON-serializable.\r\n */\r\nexport class CjsRedFormat extends CjsFormat\r\n{\r\n\r\n #emit = DEFAULT_VALUES.emit;\r\n #schema = DEFAULT_VALUES.schema;\r\n #readerOptions = {};\r\n #classes = {};\r\n\r\n /**\r\n * Create a reusable format profile.\r\n * @param {object} [options] Default format values.\r\n */\r\n constructor(options = {})\r\n {\r\n super();\r\n this.SetValues(options);\r\n }\r\n\r\n /**\r\n * Set format values for this reusable profile.\r\n * @param {object} [options] Values to merge into the profile.\r\n * @returns {CjsRedFormat} This format profile.\r\n */\r\n SetValues(options = {})\r\n {\r\n const values = normalizeValues(this.GetValues(), options, CLASS_KEYS, FORMAT_NAME);\r\n this.#emit = values.emit;\r\n this.#schema = values.schema;\r\n this.#classes = values.classes;\r\n this.#readerOptions = CjsRedFormat.copyReaderOptions(values);\r\n return this;\r\n }\r\n\r\n /**\r\n * Get this profile's current values, optionally with per-call overrides.\r\n * @param {object} [options] Optional values to merge into a copy.\r\n * @returns {object} A copy of the effective values.\r\n */\r\n GetValues(options = {})\r\n {\r\n return normalizeValues({\r\n ...DEFAULT_VALUES,\r\n emit: this.#emit,\r\n schema: this.#schema,\r\n ...this.#readerOptions,\r\n classes: this.#classes\r\n }, options, CLASS_KEYS, FORMAT_NAME);\r\n }\r\n\r\n /**\r\n * Set multiple node-class constructors for this profile.\r\n * @param {object} [classes] Map of Red type names to constructors.\r\n * @returns {CjsRedFormat} This format profile.\r\n */\r\n SetClasses(classes = {})\r\n {\r\n return this.SetValues({ classes });\r\n }\r\n\r\n /**\r\n * Set one node-class constructor for this profile.\r\n * @param {string} type Red type name.\r\n * @param {Function|null|undefined} Class Constructor to use, or nullish to delete.\r\n * @returns {CjsRedFormat} This format profile.\r\n */\r\n SetClass(type, Class)\r\n {\r\n validateClassKey(CLASS_KEYS, type, FORMAT_NAME);\r\n if (Class === null || Class === undefined)\r\n {\r\n delete this.#classes[type];\r\n return this;\r\n }\r\n\r\n validateClass(CLASS_KEYS, type, Class, FORMAT_NAME);\r\n this.#classes = { ...this.#classes, [type]: Class };\r\n return this;\r\n }\r\n\r\n /**\r\n * Get a configured node-class constructor.\r\n * @param {string} type Red type name.\r\n * @returns {Function|undefined} The registered constructor, if any.\r\n */\r\n GetClass(type)\r\n {\r\n validateClassKey(CLASS_KEYS, type, FORMAT_NAME);\r\n return this.#classes[type];\r\n }\r\n\r\n /**\r\n * Whether this profile has a constructor registered for a Red type.\r\n * @param {string} type Red type name.\r\n * @returns {boolean}\r\n */\r\n HasClass(type)\r\n {\r\n return !!this.GetClass(type);\r\n }\r\n\r\n /**\r\n * Read Red data with this profile's values.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Per-call value overrides.\r\n * @returns {object} Public payload output by default.\r\n */\r\n Read(input, options = {})\r\n {\r\n return CjsRedFormat.read(input, this.GetValues(options));\r\n }\r\n\r\n /**\r\n * Read Red data as compact public payload data.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Per-call value overrides.\r\n * @returns {object} Public payload output.\r\n */\r\n ReadPayload(input, options = {})\r\n {\r\n return CjsRedFormat.readPayload(input, this.GetValues(options));\r\n }\r\n\r\n /**\r\n * Read Red data as runtime objects or plain source-shaped objects.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Per-call value overrides.\r\n * @returns {object} Runtime read result.\r\n */\r\n ReadRuntime(input, options = {})\r\n {\r\n return CjsRedFormat.readRuntime(input, this.GetValues(options));\r\n }\r\n\r\n /**\r\n * Read Red data as the cleaned raw object graph (metadata stripped, typed\r\n * tables decoded, shared references preserved by identity).\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Per-call value overrides.\r\n * @returns {*} Raw object graph.\r\n */\r\n ReadRaw(input, options = {})\r\n {\r\n return CjsRedFormat.readRaw(input, this.GetValues(options));\r\n }\r\n\r\n /**\r\n * Inspect Red data with this profile's values.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Per-call value overrides.\r\n * @returns {object} Plain summary data.\r\n */\r\n Inspect(input, options = {})\r\n {\r\n return CjsRedFormat.inspect(input, this.GetValues(options));\r\n }\r\n\r\n /**\r\n * Convert format output to JSON-compatible data.\r\n * @param {any} value Format output to convert.\r\n * @returns {any} Plain JSON-compatible data.\r\n */\r\n ToJSON(value)\r\n {\r\n return toJsonValue(value);\r\n }\r\n\r\n /**\r\n * Static one-shot read. Static methods use camelCase by convention.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Format values.\r\n * @returns {object} Format output.\r\n */\r\n static read(input, options = {})\r\n {\r\n const values = normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME);\r\n if (values.emit === OUTPUT_RUNTIME) return CjsRedFormat.readRuntime(input, values);\r\n if (values.emit === OUTPUT_RAW) return CjsRedFormat.readRaw(input, values);\r\n return CjsRedFormat.readPayload(input, values);\r\n }\r\n\r\n /**\r\n * Static one-shot public payload read.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Format values.\r\n * @returns {object} Public payload output.\r\n */\r\n static readPayload(input, options = {})\r\n {\r\n return new CjsRedReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).ReadPayload();\r\n }\r\n\r\n /**\r\n * Static one-shot runtime read.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Format values.\r\n * @returns {object} Runtime read result.\r\n */\r\n static readRuntime(input, options = {})\r\n {\r\n return new CjsRedReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).ReadRuntime();\r\n }\r\n\r\n /**\r\n * Static one-shot raw read.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Format values.\r\n * @returns {*} Raw object graph.\r\n */\r\n static readRaw(input, options = {})\r\n {\r\n return new CjsRedReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).ReadRaw();\r\n }\r\n\r\n /**\r\n * Static one-shot inspection.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Format values.\r\n * @returns {object} Plain summary data.\r\n */\r\n static inspect(input, options = {})\r\n {\r\n return new CjsRedReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).Inspect();\r\n }\r\n\r\n /**\r\n * Static JSON-compatible conversion.\r\n * @param {any} value Format output to convert.\r\n * @returns {any} Plain JSON-compatible data.\r\n */\r\n static toJSON(value)\r\n {\r\n return toJsonValue(value);\r\n }\r\n\r\n /** Provides the one-shot RED copy reader options helper entry point. */\r\n static copyReaderOptions(values)\r\n {\r\n return copyReaderOptions(values);\r\n }\r\n\r\n /**\r\n * Emit targets for this format (canonical frozen enum).\r\n */\r\n static Output = Object.freeze({\r\n JSON: OUTPUT_JSON,\r\n PAYLOAD: OUTPUT_PAYLOAD,\r\n RUNTIME: OUTPUT_RUNTIME,\r\n RAW: OUTPUT_RAW\r\n });\r\n static CLASS_KEYS = CLASS_KEYS;\r\n static schema = blackDefinitions;\r\n static id = \"red\";\r\n static extensions = Object.freeze([ \".red\" ]);\r\n static mediaTypes = Object.freeze([ \"data\" ]);\r\n static outputs = CjsFormat.defineOutputs({\r\n json: { default: true, decoded: true },\r\n payload: { decoded: true },\r\n runtime: { decoded: true },\r\n raw: { role: \"debug\", decoded: true }\r\n });\r\n\r\n}\r\n\r\nexport default CjsRedFormat;\r\n"],"names":["FORMAT_NAME","CjsRedFormat","CjsFormat","DEFAULT_VALUES","emit","schema","constructor","options","SetValues","values","normalizeValues","GetValues","CLASS_KEYS","classes","copyReaderOptions","SetClasses","SetClass","type","Class","validateClassKey","undefined","validateClass","GetClass","HasClass","Read","input","read","ReadPayload","readPayload","ReadRuntime","readRuntime","ReadRaw","readRaw","Inspect","inspect","ToJSON","value","toJsonValue","OUTPUT_RUNTIME","OUTPUT_RAW","CjsRedReader","toJSON","Output","Object","freeze","JSON","OUTPUT_JSON","PAYLOAD","OUTPUT_PAYLOAD","RUNTIME","RAW","blackDefinitions","id","extensions","mediaTypes","outputs","defineOutputs","json","default","decoded","payload","runtime","raw","role"],"mappings":";;;;;;AAiBA,MAAMA,WAAW,GAAG,cAAc;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,YAAY,SAASC,SAAS,CAC3C;AAEI,EAAA,KAAK,GAAGC,cAAc,CAACC,IAAI;AAC3B,EAAA,OAAO,GAAGD,cAAc,CAACE,MAAM;EAC/B,cAAc,GAAG,EAAE;EACnB,QAAQ,GAAG,EAAE;;AAEb;AACJ;AACA;AACA;AACIC,EAAAA,WAAWA,CAACC,OAAO,GAAG,EAAE,EACxB;AACI,IAAA,KAAK,EAAE;AACP,IAAA,IAAI,CAACC,SAAS,CAACD,OAAO,CAAC;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G,EAAEX;AACT,GAAC,CAAC;EACF,OAAO3B,UAAU,GAAGA,UAAU;EAC9B,OAAOP,MAAM,GAAG8C,OAAgB;EAChC,OAAOC,EAAE,GAAG,KAAK;EACjB,OAAOC,UAAU,GAAGV,MAAM,CAACC,MAAM,CAAC,CAAE,MAAM,CAAE,CAAC;EAC7C,OAAOU,UAAU,GAAGX,MAAM,CAACC,MAAM,CAAC,CAAE,MAAM,CAAE,CAAC;AAC7C,EAAA,OAAOW,OAAO,GAAGrD,SAAS,CAACsD,aAAa,CAAC;AACrCC,IAAAA,IAAI,EAAE;AAAEC,MAAAA,OAAO,EAAE,IAAI;AAAEC,MAAAA,OAAO,EAAE;KAAM;AACtCC,IAAAA,OAAO,EAAE;AAAED,MAAAA,OAAO,EAAE;KAAM;AAC1BE,IAAAA,OAAO,EAAE;AAAEF,MAAAA,OAAO,EAAE;KAAM;AAC1BG,IAAAA,GAAG,EAAE;AAAEC,MAAAA,IAAI,EAAE,OAAO;AAAEJ,MAAAA,OAAO,EAAE;AAAK;AACxC,GAAC,CAAC;AAEN;;;;"}
|
|
1
|
+
{"version":3,"file":"CjsRedFormat.js","sources":["../../../../../src/resource/formats/red/CjsRedFormat.js"],"sourcesContent":["import { CjsFormat } from \"../../format/CjsFormat.js\";\r\nimport { CLASS_KEYS } from \"./core/schema.js\";\r\nimport {\r\n DEFAULT_VALUES,\r\n OUTPUT_JSON,\r\n OUTPUT_PAYLOAD,\r\n OUTPUT_RAW,\r\n OUTPUT_RUNTIME,\r\n copyReaderOptions,\r\n normalizeValues,\r\n toJsonValue,\r\n validateClass,\r\n validateClassKey\r\n} from \"./core/helpers.js\";\r\nimport { CjsRedReader } from \"./core/CjsRedReader.js\";\r\nimport blackDefinitions from \"./core/blackDefinitions.js\";\r\n\r\nconst FORMAT_NAME = \"CjsRedFormat\";\r\n\r\n/**\r\n * CarbonEngineJS-facing Red format profile.\r\n *\r\n * Reads Red data - a type-discriminated, self-referential YAML object graph -\r\n * and emits a compact public payload by default, a neutral raw graph, or\r\n * caller-supplied runtime classes through the runtime global hydration adapter.\r\n * With payload IDs enabled, repeated sequences and typed tables use an\r\n * ID-bearing object around a configurable `payloadValuesField` (default\r\n * `_values`); unique sequences remain arrays. Active payload marker names must\r\n * be distinct non-empty strings, and authored fields that collide with them\r\n * are rejected. Remap the markers to preserve authored underscore fields.\r\n * Disabling the reference marker preserves actual JavaScript identity; a\r\n * cyclic result in that mode is intentionally not JSON-serializable.\r\n */\r\nexport class CjsRedFormat extends CjsFormat\r\n{\r\n\r\n _emit = DEFAULT_VALUES.emit;\r\n _schema = DEFAULT_VALUES.schema;\r\n _readerOptions = {};\r\n _classes = {};\r\n\r\n /**\r\n * Create a reusable format profile.\r\n * @param {object} [options] Default format values.\r\n */\r\n constructor(options = {})\r\n {\r\n super();\r\n this.SetValues(options);\r\n }\r\n\r\n /**\r\n * Set format values for this reusable profile.\r\n * @param {object} [options] Values to merge into the profile.\r\n * @returns {CjsRedFormat} This format profile.\r\n */\r\n SetValues(options = {})\r\n {\r\n const values = normalizeValues(this.GetValues(), options, CLASS_KEYS, FORMAT_NAME);\r\n this._emit = values.emit;\r\n this._schema = values.schema;\r\n this._classes = values.classes;\r\n this._readerOptions = CjsRedFormat.copyReaderOptions(values);\r\n return this;\r\n }\r\n\r\n /**\r\n * Get this profile's current values, optionally with per-call overrides.\r\n * @param {object} [options] Optional values to merge into a copy.\r\n * @returns {object} A copy of the effective values.\r\n */\r\n GetValues(options = {})\r\n {\r\n return normalizeValues({\r\n ...DEFAULT_VALUES,\r\n emit: this._emit,\r\n schema: this._schema,\r\n ...this._readerOptions,\r\n classes: this._classes\r\n }, options, CLASS_KEYS, FORMAT_NAME);\r\n }\r\n\r\n /**\r\n * Set multiple node-class constructors for this profile.\r\n * @param {object} [classes] Map of Red type names to constructors.\r\n * @returns {CjsRedFormat} This format profile.\r\n */\r\n SetClasses(classes = {})\r\n {\r\n return this.SetValues({ classes });\r\n }\r\n\r\n /**\r\n * Set one node-class constructor for this profile.\r\n * @param {string} type Red type name.\r\n * @param {Function|null|undefined} Class Constructor to use, or nullish to delete.\r\n * @returns {CjsRedFormat} This format profile.\r\n */\r\n SetClass(type, Class)\r\n {\r\n validateClassKey(CLASS_KEYS, type, FORMAT_NAME);\r\n if (Class === null || Class === undefined)\r\n {\r\n delete this._classes[type];\r\n return this;\r\n }\r\n\r\n validateClass(CLASS_KEYS, type, Class, FORMAT_NAME);\r\n this._classes = { ...this._classes, [type]: Class };\r\n return this;\r\n }\r\n\r\n /**\r\n * Get a configured node-class constructor.\r\n * @param {string} type Red type name.\r\n * @returns {Function|undefined} The registered constructor, if any.\r\n */\r\n GetClass(type)\r\n {\r\n validateClassKey(CLASS_KEYS, type, FORMAT_NAME);\r\n return this._classes[type];\r\n }\r\n\r\n /**\r\n * Whether this profile has a constructor registered for a Red type.\r\n * @param {string} type Red type name.\r\n * @returns {boolean}\r\n */\r\n HasClass(type)\r\n {\r\n return !!this.GetClass(type);\r\n }\r\n\r\n /**\r\n * Read Red data with this profile's values.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Per-call value overrides.\r\n * @returns {object} Public payload output by default.\r\n */\r\n Read(input, options = {})\r\n {\r\n return CjsRedFormat.read(input, this.GetValues(options));\r\n }\r\n\r\n /**\r\n * Read Red data as compact public payload data.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Per-call value overrides.\r\n * @returns {object} Public payload output.\r\n */\r\n ReadPayload(input, options = {})\r\n {\r\n return CjsRedFormat.readPayload(input, this.GetValues(options));\r\n }\r\n\r\n /**\r\n * Read Red data as runtime objects or plain source-shaped objects.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Per-call value overrides.\r\n * @returns {object} Runtime read result.\r\n */\r\n ReadRuntime(input, options = {})\r\n {\r\n return CjsRedFormat.readRuntime(input, this.GetValues(options));\r\n }\r\n\r\n /**\r\n * Read Red data as the cleaned raw object graph (metadata stripped, typed\r\n * tables decoded, shared references preserved by identity).\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Per-call value overrides.\r\n * @returns {*} Raw object graph.\r\n */\r\n ReadRaw(input, options = {})\r\n {\r\n return CjsRedFormat.readRaw(input, this.GetValues(options));\r\n }\r\n\r\n /**\r\n * Inspect Red data with this profile's values.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Per-call value overrides.\r\n * @returns {object} Plain summary data.\r\n */\r\n Inspect(input, options = {})\r\n {\r\n return CjsRedFormat.inspect(input, this.GetValues(options));\r\n }\r\n\r\n /**\r\n * Convert format output to JSON-compatible data.\r\n * @param {any} value Format output to convert.\r\n * @returns {any} Plain JSON-compatible data.\r\n */\r\n ToJSON(value)\r\n {\r\n return toJsonValue(value);\r\n }\r\n\r\n /**\r\n * Static one-shot read. Static methods use camelCase by convention.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Format values.\r\n * @returns {object} Format output.\r\n */\r\n static read(input, options = {})\r\n {\r\n const values = normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME);\r\n if (values.emit === OUTPUT_RUNTIME) return CjsRedFormat.readRuntime(input, values);\r\n if (values.emit === OUTPUT_RAW) return CjsRedFormat.readRaw(input, values);\r\n return CjsRedFormat.readPayload(input, values);\r\n }\r\n\r\n /**\r\n * Static one-shot public payload read.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Format values.\r\n * @returns {object} Public payload output.\r\n */\r\n static readPayload(input, options = {})\r\n {\r\n return new CjsRedReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).ReadPayload();\r\n }\r\n\r\n /**\r\n * Static one-shot runtime read.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Format values.\r\n * @returns {object} Runtime read result.\r\n */\r\n static readRuntime(input, options = {})\r\n {\r\n return new CjsRedReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).ReadRuntime();\r\n }\r\n\r\n /**\r\n * Static one-shot raw read.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Format values.\r\n * @returns {*} Raw object graph.\r\n */\r\n static readRaw(input, options = {})\r\n {\r\n return new CjsRedReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).ReadRaw();\r\n }\r\n\r\n /**\r\n * Static one-shot inspection.\r\n * @param {unknown} input Parsed Red object or YAML string.\r\n * @param {object} [options] Format values.\r\n * @returns {object} Plain summary data.\r\n */\r\n static inspect(input, options = {})\r\n {\r\n return new CjsRedReader(input, normalizeValues(DEFAULT_VALUES, options, CLASS_KEYS, FORMAT_NAME)).Inspect();\r\n }\r\n\r\n /**\r\n * Static JSON-compatible conversion.\r\n * @param {any} value Format output to convert.\r\n * @returns {any} Plain JSON-compatible data.\r\n */\r\n static toJSON(value)\r\n {\r\n return toJsonValue(value);\r\n }\r\n\r\n /** Provides the one-shot RED copy reader options helper entry point. */\r\n static copyReaderOptions(values)\r\n {\r\n return copyReaderOptions(values);\r\n }\r\n\r\n /**\r\n * Emit targets for this format (canonical frozen enum).\r\n */\r\n static classKeys = CLASS_KEYS;\r\n static schema = blackDefinitions;\r\n static id = \"CjsRedFormat\";\r\n static extensions = [ \".red\" ];\r\n static mediaTypes = [ \"data\" ];\r\n static outputs = CjsFormat.defineOutputs({\r\n json: { default: true, decoded: true },\r\n payload: { decoded: true },\r\n runtime: { decoded: true },\r\n raw: { role: \"debug\", decoded: true }\r\n });\r\n\r\n}\r\n\r\nexport default CjsRedFormat;\r\n"],"names":["FORMAT_NAME","CjsRedFormat","CjsFormat","_emit","DEFAULT_VALUES","emit","_schema","schema","_readerOptions","_classes","constructor","options","SetValues","values","normalizeValues","GetValues","CLASS_KEYS","classes","copyReaderOptions","SetClasses","SetClass","type","Class","validateClassKey","undefined","validateClass","GetClass","HasClass","Read","input","read","ReadPayload","readPayload","ReadRuntime","readRuntime","ReadRaw","readRaw","Inspect","inspect","ToJSON","value","toJsonValue","OUTPUT_RUNTIME","OUTPUT_RAW","CjsRedReader","toJSON","classKeys","blackDefinitions","id","extensions","mediaTypes","outputs","defineOutputs","json","default","decoded","payload","runtime","raw","role"],"mappings":";;;;;;AAiBA,MAAMA,WAAW,GAAG,cAAc;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,YAAY,SAASC,SAAS,CAC3C;EAEIC,KAAK,GAAGC,cAAc,CAACC,IAAI;EAC3BC,OAAO,GAAGF,cAAc,CAACG,MAAM;EAC/BC,cAAc,GAAG,EAAE;EACnBC,QAAQ,GAAG,EAAE;;AAEb;AACJ;AACA;AACA;AACIC,EAAAA,WAAWA,CAACC,OAAO,GAAG,EAAE,EACxB;AACI,IAAA,KAAK,EAAE;AACP,IAAA,IAAI,CAACC,SAAS,CAACD,OAAO,CAAC;AAC3B,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACIC,EAAAA,SAASA,CAACD,OAAO,GAAG,EAAE,EACtB;AACI,IAAA,MAAME,MAAM,GAAGC,eAAe,CAAC,IAAI,CAACC,SAAS,EAAE,EAAEJ,OAAO,EAAEK,UAAU,EAAEhB,WAAW,CAAC;AAClF,IAAA,IAAI,CAACG,KAAK,GAAGU,MAAM,CAACR,IAAI;AACxB,IAAA,IAAI,CAACC,OAAO,GAAGO,MAAM,CAACN,MAAM;AAC5B,IAAA,IAAI,CAACE,QAAQ,GAAGI,MAAM,CAACI,OAAO;IAC9B,IAAI,CAACT,cAAc,GAAGP,YAAY,CAACiB,iBAAiB,CAACL,MAAM,CAAC;AAC5D,IAAA,OAAO,IAAI;AACf,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACIE,EAAAA,SAASA,CAACJ,OAAO,GAAG,EAAE,EACtB;AACI,IAAA,OAAOG,eAAe,CAAC;AACnB,MAAA,GAAGV,cAAc;MACjBC,IAAI,EAAE,IAAI,CAACF,KA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AACI,IAAA,OAAO,IAAIiC,YAAY,CAACf,KAAK,EAAEf,eAAe,CAACV,cAAc,EAAEO,OAAO,EAAEK,UAAU,EAAEhB,WAAW,CAAC,CAAC,CAACqC,OAAO,EAAE;AAC/G,EAAA;;AAEA;AACJ;AACA;AACA;AACA;EACI,OAAOQ,MAAMA,CAACL,KAAK,EACnB;IACI,OAAOC,WAAW,CAACD,KAAK,CAAC;AAC7B,EAAA;;AAEA;EACA,OAAOtB,iBAAiBA,CAACL,MAAM,EAC/B;IACI,OAAOK,iBAAiB,CAACL,MAAM,CAAC;AACpC,EAAA;;AAEA;AACJ;AACA;EACI,OAAOiC,SAAS,GAAG9B,UAAU;EAC7B,OAAOT,MAAM,GAAGwC,OAAgB;EAChC,OAAOC,EAAE,GAAG,cAAc;AAC1B,EAAA,OAAOC,UAAU,GAAG,CAAE,MAAM,CAAE;AAC9B,EAAA,OAAOC,UAAU,GAAG,CAAE,MAAM,CAAE;AAC9B,EAAA,OAAOC,OAAO,GAAGjD,SAAS,CAACkD,aAAa,CAAC;AACrCC,IAAAA,IAAI,EAAE;AAAEC,MAAAA,OAAO,EAAE,IAAI;AAAEC,MAAAA,OAAO,EAAE;KAAM;AACtCC,IAAAA,OAAO,EAAE;AAAED,MAAAA,OAAO,EAAE;KAAM;AAC1BE,IAAAA,OAAO,EAAE;AAAEF,MAAAA,OAAO,EAAE;KAAM;AAC1BG,IAAAA,GAAG,EAAE;AAAEC,MAAAA,IAAI,EAAE,OAAO;AAAEJ,MAAAA,OAAO,EAAE;AAAK;AACxC,GAAC,CAAC;AAEN;;;;"}
|
|
@@ -169,13 +169,9 @@ class CjsSchemaBoundFormat extends CjsFormat {
|
|
|
169
169
|
}
|
|
170
170
|
return Resolve(parsed);
|
|
171
171
|
}
|
|
172
|
-
static
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
});
|
|
176
|
-
static id = "schemabound";
|
|
177
|
-
static extensions = Object.freeze([".static"]);
|
|
178
|
-
static mediaTypes = Object.freeze(["data"]);
|
|
172
|
+
static id = "CjsSchemaBoundFormat";
|
|
173
|
+
static extensions = [".static"];
|
|
174
|
+
static mediaTypes = ["data"];
|
|
179
175
|
static outputs = CjsFormat.defineOutputs({
|
|
180
176
|
json: {
|
|
181
177
|
default: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CjsSchemaBoundFormat.js","sources":["../../../../../src/resource/formats/schemabound/CjsSchemaBoundFormat.js"],"sourcesContent":["import { CjsFormat } from \"../../format/CjsFormat.js\";\r\nimport { CjsYamlFormat } from \"../yaml/index.js\";\r\nimport { ReadValue } from \"./core/schemaBoundValues.js\";\r\nimport { SchemaBoundError } from \"./core/schemaBoundErrors.js\";\r\n\r\nconst OUTPUT_JSON = \"json\";\r\nconst OUTPUT_PAYLOAD = \"payload\";\r\nconst ROOT_TYPES = new Set([ \"dict\", \"list\", \"object\" ]);\r\n\r\n/**\r\n * Reads a container whose layout lives in a separate schema.\r\n *\r\n * This is the third of the three families that share the `.static` extension,\r\n * and the one an extension check is least able to help with: the bytes carry no\r\n * signature, no version and no self-description. What they carry is a payload\r\n * whose every field position, width and meaning is stated in a sibling `.schema`\r\n * document — so the schema is not a hint here, it is the reader.\r\n *\r\n * That makes this the opposite of the hash-identified containers, where the\r\n * header names a layout it does not describe and the layout has to be derived\r\n * and pinned per dataset. Nothing needs deriving for this family. Supply the\r\n * schema and the bytes decode.\r\n *\r\n * **The schema is required and there is no default.** Given the wrong schema\r\n * these bytes decode into plausible nonsense rather than failing, because there\r\n * is nothing in them to disagree with. Pair each payload with the `.schema`\r\n * that shipped beside it.\r\n *\r\n * Read {@link CjsSchemaBoundFormat.read} before writing anything that walks the\r\n * result: a record's variable section changes length from record to record, and\r\n * a decoder written around a constant stride will read the first record\r\n * correctly and everything after it wrongly.\r\n */\r\nexport class CjsSchemaBoundFormat extends CjsFormat {\r\n\r\n /**\r\n * Reports whether a schema can drive this reader.\r\n *\r\n * The question is about the schema, never the payload. These containers have\r\n * no signature to test, so claiming to recognize the bytes would be a claim\r\n * this format cannot support - and `CjsStaticFormat` already answers which\r\n * family a `.static` file belongs to.\r\n *\r\n * @param {object|Uint8Array|ArrayBuffer|string} schema Schema document or its bytes.\r\n * @returns {boolean} True when the schema has a root this reader understands.\r\n */\r\n static is(input, options = null) {\r\n try {\r\n return ROOT_TYPES.has(this.schema(options?.schema ?? input).type);\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Reports whether this format can read a payload described by a schema.\r\n *\r\n * @param {object|Uint8Array|ArrayBuffer|string} schema Schema document or its bytes.\r\n * @param {object} [options] Probe options.\r\n * @returns {object} Resource probe.\r\n */\r\n static probeSupport(input, options = null) {\r\n const usable = this.is(input, options);\r\n return {\r\n format: this.id,\r\n source: options?.source || \"buffer\",\r\n recognized: usable,\r\n supported: usable,\r\n preferredOutput: usable ? OUTPUT_JSON : \"\",\r\n reason: usable\r\n ? \"The supplied schema declares a root this reader can decode.\"\r\n : \"A readable companion schema was not supplied.\",\r\n variants: [\r\n { kind: OUTPUT_JSON, supported: usable },\r\n { kind: OUTPUT_PAYLOAD, supported: usable }\r\n ],\r\n metadata: usable ? this.inspect(input, options) : {\r\n family: this.id,\r\n requiresSchema: true,\r\n decodable: false\r\n }\r\n };\r\n }\r\n\r\n /** Return schema and payload facts without decoding the payload. */\r\n static inspect(input, options = null) {\r\n const schema = this.schema(options?.schema ?? input);\r\n return {\r\n family: this.id,\r\n rootType: schema.type,\r\n requiresSchema: true,\r\n decodable: ROOT_TYPES.has(schema.type),\r\n byteLength: options?.schema === undefined ? null : Normalize(input).byteLength\r\n };\r\n }\r\n\r\n /**\r\n * Reads a container against its schema.\r\n *\r\n * The whole payload decodes in one pass. Three properties are worth knowing\r\n * before relying on the result:\r\n *\r\n * - **A keyed container's index is at the end.** Nothing at the front points\r\n * at it; it is found by reading the last four bytes as the index's own size.\r\n * - **Record offsets are relative to the four-byte header**, not to the file.\r\n * Decoding from the file start reads one field early, which looks like a\r\n * wrong layout rather than a wrong base.\r\n * - **The per-record offset table varies in length.** An optional attribute\r\n * that is absent occupies no slot, so consecutive records hold their\r\n * variable data at different distances from their own start.\r\n *\r\n * An absent optional takes the default its schema declares. Where none is\r\n * declared the attribute is left off the record entirely, which is what the\r\n * published static data exports show for those same rows.\r\n *\r\n * @param {Uint8Array|ArrayBuffer} input Container bytes.\r\n * @param {object} options Read options.\r\n * @param {object|Uint8Array|ArrayBuffer|string} options.schema The sibling schema.\r\n * @param {string} [options.output] `json` or `payload`.\r\n * @returns {object|Array} The decoded container.\r\n */\r\n static read(input, options = {}) {\r\n const bytes = Normalize(input);\r\n const schema = this.schema(options.schema);\r\n\r\n if (!ROOT_TYPES.has(schema.type)) {\r\n throw SchemaBoundError(`A container's root must be a dict, list or object, not ${schema.type}.`);\r\n }\r\n\r\n const context = {\r\n bytes,\r\n view: new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)\r\n };\r\n const decoded = ReadValue(context, 0, schema).value;\r\n\r\n const output = options.emit ?? options.output ?? OUTPUT_JSON;\r\n return output === OUTPUT_PAYLOAD ? decoded : ToJSON(decoded);\r\n }\r\n\r\n /** Reads to plain JSON-compatible values. */\r\n static readJSON(input, options = {}) {\r\n return this.read(input, { ...options, output: OUTPUT_JSON });\r\n }\r\n\r\n /** Reads with wide integers left as `BigInt`. */\r\n static readPayload(input, options = {}) {\r\n return this.read(input, { ...options, output: OUTPUT_PAYLOAD });\r\n }\r\n\r\n /**\r\n * Parses a schema document, accepting YAML bytes, YAML text or a parsed object.\r\n *\r\n * @param {object|Uint8Array|ArrayBuffer|string} schema Schema in any accepted form.\r\n * @returns {object} The parsed schema.\r\n */\r\n static schema(schema) {\r\n if (!schema) {\r\n throw SchemaBoundError(\"This format cannot read a container without its schema.\");\r\n }\r\n\r\n if (typeof schema === \"object\" && !ArrayBuffer.isView(schema) && !(schema instanceof ArrayBuffer)) {\r\n return schema;\r\n }\r\n\r\n const parsed = CjsYamlFormat.read(typeof schema === \"string\" ? schema : Normalize(schema));\r\n\r\n if (!parsed || typeof parsed !== \"object\") {\r\n throw SchemaBoundError(\"A schema must parse to a mapping.\");\r\n }\r\n\r\n return Resolve(parsed);\r\n }\r\n\r\n static Output = Object.freeze({ JSON: OUTPUT_JSON, PAYLOAD: OUTPUT_PAYLOAD });\r\n\r\n static id = \"schemabound\";\r\n static extensions = Object.freeze([ \".static\" ]);\r\n static mediaTypes = Object.freeze([ \"data\" ]);\r\n static outputs = CjsFormat.defineOutputs({\r\n json: { default: true, decoded: true },\r\n payload: { decoded: true }\r\n });\r\n}\r\n\r\n/**\r\n * Rejoins YAML anchors and aliases into the graph they describe.\r\n *\r\n * These schemas share repeated declarations by anchor - a container with two\r\n * coordinates writes the vector's component aliases once - and the YAML reader\r\n * reports that sharing as `$yamlId` and `$yamlRef` markers rather than\r\n * duplicating the node. Left alone, `$yamlId` reads as one more component and\r\n * `$yamlRef` as a declaration with no fields at all.\r\n *\r\n * @param {*} value Parsed schema, or any part of one.\r\n * @returns {*} The same schema with anchors resolved and markers removed.\r\n */\r\nfunction Resolve(value) {\r\n const anchors = new Map();\r\n\r\n const walk = node => {\r\n if (Array.isArray(node)) return node.map(walk);\r\n\r\n if (!node || typeof node !== \"object\") return node;\r\n\r\n if (Object.hasOwn(node, \"$yamlRef\")) {\r\n const target = anchors.get(node.$yamlRef);\r\n\r\n if (!target) {\r\n throw SchemaBoundError(`The schema refers to an anchor it never declares: ${node.$yamlRef}.`);\r\n }\r\n\r\n return target;\r\n }\r\n\r\n const result = {};\r\n const id = node.$yamlId;\r\n\r\n if (id !== undefined) anchors.set(id, result);\r\n\r\n for (const [ key, member ] of Object.entries(node)) {\r\n if (key !== \"$yamlId\") result[key] = walk(member);\r\n }\r\n\r\n return result;\r\n };\r\n\r\n return walk(value);\r\n}\r\n\r\n/** Converts decoded values to something `JSON.stringify` keeps losslessly. */\r\nfunction ToJSON(value) {\r\n if (typeof value === \"bigint\") return value.toString(10);\r\n\r\n if (Array.isArray(value)) return value.map(ToJSON);\r\n\r\n if (value && typeof value === \"object\") {\r\n const result = {};\r\n\r\n for (const [ key, member ] of Object.entries(value)) result[key] = ToJSON(member);\r\n\r\n return result;\r\n }\r\n\r\n return value;\r\n}\r\n\r\n/** Accepts the byte forms every other format here accepts. */\r\nfunction Normalize(input) {\r\n if (input instanceof Uint8Array) return input;\r\n\r\n if (input instanceof ArrayBuffer) return new Uint8Array(input);\r\n\r\n if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\r\n\r\n throw SchemaBoundError(\"A schema-bound container must be supplied as bytes.\");\r\n}\r\n\r\nexport default CjsSchemaBoundFormat;\r\n"],"names":["OUTPUT_JSON","OUTPUT_PAYLOAD","ROOT_TYPES","Set","CjsSchemaBoundFormat","CjsFormat","is","input","options","has","schema","type","probeSupport","usable","format","id","source","recognized","supported","preferredOutput","reason","variants","kind","metadata","inspect","family","requiresSchema","decodable","rootType","byteLength","undefined","Normalize","read","bytes","SchemaBoundError","context","view","DataView","buffer","byteOffset","decoded","ReadValue","value","output","emit","ToJSON","readJSON","readPayload","ArrayBuffer","isView","parsed","CjsYamlFormat","Resolve","Output","Object","freeze","JSON","PAYLOAD","extensions","mediaTypes","outputs","defineOutputs","json","default","payload","anchors","Map","walk","node","Array","isArray","map","hasOwn","target","get","$yamlRef","result","$yamlId","set","key","member","entries","toString","Uint8Array"],"mappings":";;;;;AAKA,MAAMA,WAAW,GAAG,MAAM;AAC1B,MAAMC,cAAc,GAAG,SAAS;AAChC,MAAMC,UAAU,GAAG,IAAIC,GAAG,CAAC,CAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAE,CAAC;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,oBAAoB,SAASC,SAAS,CAAC;AAElD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE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AAW,CAACC,MAAM,CAAC1C,KAAK,CAAC,EAAE,OAAO,IAAI4E,UAAU,CAAC5E,KAAK,CAAC+B,MAAM,EAAE/B,KAAK,CAACgC,UAAU,EAAEhC,KAAK,CAACsB,UAAU,CAAC;EAEtG,MAAMK,gBAAgB,CAAC,qDAAqD,CAAC;AAC/E;;;;"}
|
|
1
|
+
{"version":3,"file":"CjsSchemaBoundFormat.js","sources":["../../../../../src/resource/formats/schemabound/CjsSchemaBoundFormat.js"],"sourcesContent":["import { CjsFormat } from \"../../format/CjsFormat.js\";\r\nimport { CjsYamlFormat } from \"../yaml/index.js\";\r\nimport { ReadValue } from \"./core/schemaBoundValues.js\";\r\nimport { SchemaBoundError } from \"./core/schemaBoundErrors.js\";\r\n\r\nconst OUTPUT_JSON = \"json\";\r\nconst OUTPUT_PAYLOAD = \"payload\";\r\nconst ROOT_TYPES = new Set([ \"dict\", \"list\", \"object\" ]);\r\n\r\n/**\r\n * Reads a container whose layout lives in a separate schema.\r\n *\r\n * This is the third of the three families that share the `.static` extension,\r\n * and the one an extension check is least able to help with: the bytes carry no\r\n * signature, no version and no self-description. What they carry is a payload\r\n * whose every field position, width and meaning is stated in a sibling `.schema`\r\n * document — so the schema is not a hint here, it is the reader.\r\n *\r\n * That makes this the opposite of the hash-identified containers, where the\r\n * header names a layout it does not describe and the layout has to be derived\r\n * and pinned per dataset. Nothing needs deriving for this family. Supply the\r\n * schema and the bytes decode.\r\n *\r\n * **The schema is required and there is no default.** Given the wrong schema\r\n * these bytes decode into plausible nonsense rather than failing, because there\r\n * is nothing in them to disagree with. Pair each payload with the `.schema`\r\n * that shipped beside it.\r\n *\r\n * Read {@link CjsSchemaBoundFormat.read} before writing anything that walks the\r\n * result: a record's variable section changes length from record to record, and\r\n * a decoder written around a constant stride will read the first record\r\n * correctly and everything after it wrongly.\r\n */\r\nexport class CjsSchemaBoundFormat extends CjsFormat {\r\n\r\n /**\r\n * Reports whether a schema can drive this reader.\r\n *\r\n * The question is about the schema, never the payload. These containers have\r\n * no signature to test, so claiming to recognize the bytes would be a claim\r\n * this format cannot support - and `CjsStaticFormat` already answers which\r\n * family a `.static` file belongs to.\r\n *\r\n * @param {object|Uint8Array|ArrayBuffer|string} schema Schema document or its bytes.\r\n * @returns {boolean} True when the schema has a root this reader understands.\r\n */\r\n static is(input, options = null) {\r\n try {\r\n return ROOT_TYPES.has(this.schema(options?.schema ?? input).type);\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Reports whether this format can read a payload described by a schema.\r\n *\r\n * @param {object|Uint8Array|ArrayBuffer|string} schema Schema document or its bytes.\r\n * @param {object} [options] Probe options.\r\n * @returns {object} Resource probe.\r\n */\r\n static probeSupport(input, options = null) {\r\n const usable = this.is(input, options);\r\n return {\r\n format: this.id,\r\n source: options?.source || \"buffer\",\r\n recognized: usable,\r\n supported: usable,\r\n preferredOutput: usable ? OUTPUT_JSON : \"\",\r\n reason: usable\r\n ? \"The supplied schema declares a root this reader can decode.\"\r\n : \"A readable companion schema was not supplied.\",\r\n variants: [\r\n { kind: OUTPUT_JSON, supported: usable },\r\n { kind: OUTPUT_PAYLOAD, supported: usable }\r\n ],\r\n metadata: usable ? this.inspect(input, options) : {\r\n family: this.id,\r\n requiresSchema: true,\r\n decodable: false\r\n }\r\n };\r\n }\r\n\r\n /** Return schema and payload facts without decoding the payload. */\r\n static inspect(input, options = null) {\r\n const schema = this.schema(options?.schema ?? input);\r\n return {\r\n family: this.id,\r\n rootType: schema.type,\r\n requiresSchema: true,\r\n decodable: ROOT_TYPES.has(schema.type),\r\n byteLength: options?.schema === undefined ? null : Normalize(input).byteLength\r\n };\r\n }\r\n\r\n /**\r\n * Reads a container against its schema.\r\n *\r\n * The whole payload decodes in one pass. Three properties are worth knowing\r\n * before relying on the result:\r\n *\r\n * - **A keyed container's index is at the end.** Nothing at the front points\r\n * at it; it is found by reading the last four bytes as the index's own size.\r\n * - **Record offsets are relative to the four-byte header**, not to the file.\r\n * Decoding from the file start reads one field early, which looks like a\r\n * wrong layout rather than a wrong base.\r\n * - **The per-record offset table varies in length.** An optional attribute\r\n * that is absent occupies no slot, so consecutive records hold their\r\n * variable data at different distances from their own start.\r\n *\r\n * An absent optional takes the default its schema declares. Where none is\r\n * declared the attribute is left off the record entirely, which is what the\r\n * published static data exports show for those same rows.\r\n *\r\n * @param {Uint8Array|ArrayBuffer} input Container bytes.\r\n * @param {object} options Read options.\r\n * @param {object|Uint8Array|ArrayBuffer|string} options.schema The sibling schema.\r\n * @param {string} [options.output] `json` or `payload`.\r\n * @returns {object|Array} The decoded container.\r\n */\r\n static read(input, options = {}) {\r\n const bytes = Normalize(input);\r\n const schema = this.schema(options.schema);\r\n\r\n if (!ROOT_TYPES.has(schema.type)) {\r\n throw SchemaBoundError(`A container's root must be a dict, list or object, not ${schema.type}.`);\r\n }\r\n\r\n const context = {\r\n bytes,\r\n view: new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)\r\n };\r\n const decoded = ReadValue(context, 0, schema).value;\r\n\r\n const output = options.emit ?? options.output ?? OUTPUT_JSON;\r\n return output === OUTPUT_PAYLOAD ? decoded : ToJSON(decoded);\r\n }\r\n\r\n /** Reads to plain JSON-compatible values. */\r\n static readJSON(input, options = {}) {\r\n return this.read(input, { ...options, output: OUTPUT_JSON });\r\n }\r\n\r\n /** Reads with wide integers left as `BigInt`. */\r\n static readPayload(input, options = {}) {\r\n return this.read(input, { ...options, output: OUTPUT_PAYLOAD });\r\n }\r\n\r\n /**\r\n * Parses a schema document, accepting YAML bytes, YAML text or a parsed object.\r\n *\r\n * @param {object|Uint8Array|ArrayBuffer|string} schema Schema in any accepted form.\r\n * @returns {object} The parsed schema.\r\n */\r\n static schema(schema) {\r\n if (!schema) {\r\n throw SchemaBoundError(\"This format cannot read a container without its schema.\");\r\n }\r\n\r\n if (typeof schema === \"object\" && !ArrayBuffer.isView(schema) && !(schema instanceof ArrayBuffer)) {\r\n return schema;\r\n }\r\n\r\n const parsed = CjsYamlFormat.read(typeof schema === \"string\" ? schema : Normalize(schema));\r\n\r\n if (!parsed || typeof parsed !== \"object\") {\r\n throw SchemaBoundError(\"A schema must parse to a mapping.\");\r\n }\r\n\r\n return Resolve(parsed);\r\n }\r\n\r\n static id = \"CjsSchemaBoundFormat\";\r\n static extensions = [ \".static\" ];\r\n static mediaTypes = [ \"data\" ];\r\n static outputs = CjsFormat.defineOutputs({\r\n json: { default: true, decoded: true },\r\n payload: { decoded: true }\r\n });\r\n\r\n}\r\n\r\n/**\r\n * Rejoins YAML anchors and aliases into the graph they describe.\r\n *\r\n * These schemas share repeated declarations by anchor - a container with two\r\n * coordinates writes the vector's component aliases once - and the YAML reader\r\n * reports that sharing as `$yamlId` and `$yamlRef` markers rather than\r\n * duplicating the node. Left alone, `$yamlId` reads as one more component and\r\n * `$yamlRef` as a declaration with no fields at all.\r\n *\r\n * @param {*} value Parsed schema, or any part of one.\r\n * @returns {*} The same schema with anchors resolved and markers removed.\r\n */\r\nfunction Resolve(value) {\r\n const anchors = new Map();\r\n\r\n const walk = node => {\r\n if (Array.isArray(node)) return node.map(walk);\r\n\r\n if (!node || typeof node !== \"object\") return node;\r\n\r\n if (Object.hasOwn(node, \"$yamlRef\")) {\r\n const target = anchors.get(node.$yamlRef);\r\n\r\n if (!target) {\r\n throw SchemaBoundError(`The schema refers to an anchor it never declares: ${node.$yamlRef}.`);\r\n }\r\n\r\n return target;\r\n }\r\n\r\n const result = {};\r\n const id = node.$yamlId;\r\n\r\n if (id !== undefined) anchors.set(id, result);\r\n\r\n for (const [ key, member ] of Object.entries(node)) {\r\n if (key !== \"$yamlId\") result[key] = walk(member);\r\n }\r\n\r\n return result;\r\n };\r\n\r\n return walk(value);\r\n}\r\n\r\n/** Converts decoded values to something `JSON.stringify` keeps losslessly. */\r\nfunction ToJSON(value) {\r\n if (typeof value === \"bigint\") return value.toString(10);\r\n\r\n if (Array.isArray(value)) return value.map(ToJSON);\r\n\r\n if (value && typeof value === \"object\") {\r\n const result = {};\r\n\r\n for (const [ key, member ] of Object.entries(value)) result[key] = ToJSON(member);\r\n\r\n return result;\r\n }\r\n\r\n return value;\r\n}\r\n\r\n/** Accepts the byte forms every other format here accepts. */\r\nfunction Normalize(input) {\r\n if (input instanceof Uint8Array) return input;\r\n\r\n if (input instanceof ArrayBuffer) return new Uint8Array(input);\r\n\r\n if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\r\n\r\n throw SchemaBoundError(\"A schema-bound container must be supplied as bytes.\");\r\n}\r\n\r\nexport default CjsSchemaBoundFormat;\r\n"],"names":["OUTPUT_JSON","OUTPUT_PAYLOAD","ROOT_TYPES","Set","CjsSchemaBoundFormat","CjsFormat","is","input","options","has","schema","type","probeSupport","usable","format","id","source","recognized","supported","preferredOutput","reason","variants","kind","metadata","inspect","family","requiresSchema","decodable","rootType","byteLength","undefined","Normalize","read","bytes","SchemaBoundError","context","view","DataView","buffer","byteOffset","decoded","ReadValue","value","output","emit","ToJSON","readJSON","readPayload","ArrayBuffer","isView","parsed","CjsYamlFormat","Resolve","extensions","mediaTypes","outputs","defineOutputs","json","default","payload","anchors","Map","walk","node","Array","isArray","map","Object","hasOwn","target","get","$yamlRef","result","$yamlId","set","key","member","entries","toString","Uint8Array"],"mappings":";;;;;AAKA,MAAMA,WAAW,GAAG,MAAM;AAC1B,MAAMC,cAAc,GAAG,SAAS;AAChC,MAAMC,UAAU,GAAG,IAAIC,GAAG,CAAC,CAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAE,CAAC;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,oBAAoB,SAASC,SAAS,CAAC;AAElD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOC,EAAEA,CAACC,KAAK,EAAEC,OAAO,GAAG,IAAI,EAAE;IAC/B,I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graphicID":
|
|
33
33
|
case "iconID":
|
|
34
34
|
case "fsdReference":
|
|
35
|
+
// `typeListID` names a row in a type-list table. Frontier declares it in the
|
|
36
|
+
// embedded schema of `solarsystemcontent.static` (field
|
|
37
|
+
// `constructableTypeListID`, alongside `graphicID` in the same node shape);
|
|
38
|
+
// Tranquility has no such type, which is why it went unseen.
|
|
39
|
+
case "typeListID":
|
|
35
40
|
return ReadInt(context, offset, {
|
|
36
41
|
size: node.size ?? 4,
|
|
37
42
|
min: 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaBoundValues.js","sources":["../../../../../../src/resource/formats/schemabound/core/schemaBoundValues.js"],"sourcesContent":["import { SchemaBoundError } from \"./schemaBoundErrors.js\";\r\n\r\nconst TEXT = new TextDecoder(\"utf-8\");\r\n\r\n/**\r\n * Decodes one value of any schema type, and reports how many bytes it spanned.\r\n *\r\n * Every type answers both questions through this one function because the\r\n * container mixes them: a list's items may be fixed, in which case the schema\r\n * states the stride, or variable, in which case the only way to find item `n+1`\r\n * is to have finished reading item `n`.\r\n *\r\n * @param {object} context Reader context: `view`, `bytes` and `options`.\r\n * @param {number} offset Absolute byte offset of the value.\r\n * @param {object} node The schema node describing the value.\r\n * @returns {{value: *, size: number}} Decoded value and the bytes it occupied.\r\n */\r\nexport function ReadValue(context, offset, node) {\r\n switch (node.type) {\r\n case \"int\": return ReadInt(context, offset, node);\r\n // Identifier types. Each is a four-byte unsigned integer that names a row in\r\n // another table, and the schema states the meaning rather than the width -\r\n // `factionID` and one or two others declare no size at all. Keeping them\r\n // named here rather than folding them into `int` is what lets a consumer see\r\n // that a number is a key.\r\n case \"localizationID\": case \"typeID\": case \"factionID\": case \"groupID\":\r\n case \"categoryID\": case \"graphicID\": case \"iconID\": case \"fsdReference\":\r\n return ReadInt(context, offset, { size: node.size ?? 4, min: 0 });\r\n case \"float\": return ReadFloat(context, offset, node);\r\n case \"bool\": return { value: context.view.getUint8(offset) !== 0, size: node.size ?? 1 };\r\n case \"enum\": return ReadEnum(context, offset, node);\r\n case \"vector2\": return ReadVector(context, offset, node, 2);\r\n case \"vector3\": return ReadVector(context, offset, node, 3);\r\n // `unicode` is the same framing as `string`; the distinction is Python's,\r\n // and both arrive as a byte length followed by UTF-8.\r\n case \"string\": case \"resPath\": case \"unicode\": return ReadString(context, offset);\r\n case \"list\": return ReadList(context, offset, node);\r\n case \"dict\": return ReadDict(context, offset, node);\r\n case \"object\": return ReadObject(context, offset, node);\r\n default:\r\n throw SchemaBoundError(`The schema declares a type this reader does not know: ${node.type}.`, {\r\n schemaType: node.type\r\n });\r\n }\r\n}\r\n\r\n/** Reads a 1, 2, 4 or 8 byte integer, signed only when the schema allows it. */\r\nfunction ReadInt(context, offset, node) {\r\n const size = node.size ?? 4;\r\n // `min: 0` is the schema's own statement that the field cannot go negative,\r\n // and it is the only signedness information there is.\r\n const unsigned = typeof node.min === \"number\" && node.min >= 0;\r\n const view = context.view;\r\n\r\n switch (size) {\r\n case 1: return { value: unsigned ? view.getUint8(offset) : view.getInt8(offset), size };\r\n case 2: return { value: unsigned ? view.getUint16(offset, true) : view.getInt16(offset, true), size };\r\n case 4: return { value: unsigned ? view.getUint32(offset, true) : view.getInt32(offset, true), size };\r\n case 8: return { value: Narrow(unsigned ? view.getBigUint64(offset, true) : view.getBigInt64(offset, true)), size };\r\n default:\r\n throw SchemaBoundError(`An integer of ${size} bytes is not a width this container uses.`);\r\n }\r\n}\r\n\r\n/** Returns a wide integer as a Number when that is lossless, else a BigInt. */\r\nfunction Narrow(value) {\r\n return value >= -9007199254740991n && value <= 9007199254740991n ? Number(value) : value;\r\n}\r\n\r\n/** Reads a single or double precision float. */\r\nfunction ReadFloat(context, offset, node) {\r\n const size = node.size ?? 4;\r\n\r\n if (size === 8) return { value: context.view.getFloat64(offset, true), size };\r\n if (size === 4) return { value: context.view.getFloat32(offset, true), size };\r\n\r\n throw SchemaBoundError(`A float of ${size} bytes is not a width this container uses.`);\r\n}\r\n\r\n/**\r\n * Reads an enumeration, as its number or its name.\r\n *\r\n * `readEnumValue` is the schema saying the stored number is the meaning; without\r\n * it the name is. A number with no name is returned as the number rather than\r\n * dropped, because an unnamed member is data the client still stored.\r\n */\r\nfunction ReadEnum(context, offset, node) {\r\n const { value, size } = ReadInt(context, offset, { size: node.size ?? 1, min: 0 });\r\n\r\n if (node.readEnumValue === true || !node.values) return { value, size };\r\n\r\n for (const [ name, member ] of Object.entries(node.values)) {\r\n if (member === value) return { value: name, size };\r\n }\r\n\r\n return { value, size };\r\n}\r\n\r\n/** Reads a fixed-length vector into the component names the schema aliases. */\r\nfunction ReadVector(context, offset, node, components) {\r\n const wide = (node.precision ?? \"double\") === \"double\";\r\n const width = wide ? 8 : 4;\r\n const read = index => wide\r\n ? context.view.getFloat64(offset + index * width, true)\r\n : context.view.getFloat32(offset + index * width, true);\r\n const aliases = node.aliases ?? DEFAULT_COMPONENTS[components];\r\n const value = {};\r\n\r\n for (const [ name, index ] of Object.entries(aliases)) value[name] = read(index);\r\n\r\n return { value, size: node.size ?? width * components };\r\n}\r\n\r\nconst DEFAULT_COMPONENTS = { 2: { x: 0, y: 1 }, 3: { x: 0, y: 1, z: 2 } };\r\n\r\n/** Reads a length-prefixed UTF-8 string; `resPath` is the same shape. */\r\nfunction ReadString(context, offset) {\r\n const length = context.view.getUint32(offset, true);\r\n const start = offset + 4;\r\n\r\n return {\r\n value: TEXT.decode(context.bytes.subarray(start, start + length)),\r\n size: 4 + length\r\n };\r\n}\r\n\r\n/**\r\n * Reads a count-prefixed list.\r\n *\r\n * A list has two framings and the schema says which: `fixedItemSize` means the\r\n * items are packed one after another at that stride, and its absence means they\r\n * are variable, so the count is followed by one `uint32` per item. Those offsets\r\n * are relative to the start of the list.\r\n */\r\nfunction ReadList(context, offset, node) {\r\n const view = context.view;\r\n const count = view.getUint32(offset, true);\r\n const items = [];\r\n\r\n if (node.fixedItemSize === undefined) {\r\n let end = offset + 4 + count * 4;\r\n\r\n for (let index = 0; index < count; index += 1) {\r\n const at = offset + view.getUint32(offset + 4 + index * 4, true);\r\n const item = ReadValue(context, at, node.itemTypes);\r\n\r\n items.push(item.value);\r\n end = Math.max(end, at + item.size);\r\n }\r\n\r\n return { value: items, size: end - offset };\r\n }\r\n\r\n let cursor = offset + 4;\r\n\r\n for (let index = 0; index < count; index += 1) {\r\n items.push(ReadValue(context, cursor, node.itemTypes).value);\r\n cursor += node.fixedItemSize;\r\n }\r\n\r\n return { value: items, size: cursor - offset };\r\n}\r\n\r\n/**\r\n * Reads a keyed map.\r\n *\r\n * The framing is the same at the root of a container and nested inside one\r\n * record: a `uint32` of everything that follows, the values, then the key\r\n * footer, then a `uint32` of the footer's own size. **The footer is found from\r\n * the end, never from the front** — nothing at the front points at it.\r\n *\r\n * Each footer entry carries a key and an offset, and that offset is relative to\r\n * the end of the leading `uint32`, not to the file and not to the value region.\r\n */\r\nfunction ReadDict(context, offset, node) {\r\n const view = context.view;\r\n const total = view.getUint32(offset, true);\r\n const base = offset + 4;\r\n const end = base + total;\r\n const footerSize = view.getUint32(end - 4, true);\r\n const footerStart = end - 4 - footerSize;\r\n\r\n if (footerStart < base) {\r\n throw SchemaBoundError(\"The key footer does not fit inside the container.\", { footerStart, base });\r\n }\r\n\r\n const value = {};\r\n\r\n // The footer is an ordinary list, and it uses both of the list framings: a\r\n // list of integer keys is fixed-stride, a list of string keys is not.\r\n for (const entry of ReadList(context, footerStart, node.keyFooter).value) {\r\n value[entry.key] = ReadValue(context, base + entry.offset, node.valueTypes).value;\r\n }\r\n\r\n return { value, size: 4 + total };\r\n}\r\n\r\n/**\r\n * Reads a record.\r\n *\r\n * Fixed attributes sit at the offsets the schema names. Everything in\r\n * `attributesWithVariableOffsets` is reached through a table that follows the\r\n * fixed part, and **that table's length changes from record to record**: an\r\n * optional attribute whose presence bit is clear takes no slot in it. A reader\r\n * that assumes a constant stride decodes the first record correctly and then\r\n * drifts, which is the single most misleading property of this format.\r\n */\r\nfunction ReadObject(context, offset, node) {\r\n const attributes = node.attributes ?? {};\r\n const variable = node.attributesWithVariableOffsets ?? [];\r\n const decoded = new Map();\r\n let size = node.size ?? node.endOfFixedSizeData ?? 0;\r\n\r\n for (const [ name, at ] of Object.entries(node.constantAttributeOffsets ?? {})) {\r\n decoded.set(name, ReadValue(context, offset + at, Attribute(attributes, name)).value);\r\n }\r\n\r\n if (variable.length) {\r\n const lookups = node.optionalValueLookups ?? {};\r\n const view = context.view;\r\n // The presence bitfield is written whenever a record has a variable section\r\n // at all, including where nothing in it is optional and the field is\r\n // therefore always zero. It is the offset table that shrinks, never this.\r\n const bits = view.getBigUint64(offset + node.endOfFixedSizeData, true);\r\n const table = offset + node.endOfFixedSizeData + 8;\r\n const present = variable.filter(name => {\r\n const attribute = Attribute(attributes, name);\r\n\r\n return !attribute.isOptional || (bits & BigInt(lookups[name] ?? 0)) !== 0n;\r\n });\r\n const data = table + present.length * 4;\r\n let end = data;\r\n\r\n present.forEach((name, index) => {\r\n const at = data + view.getUint32(table + index * 4, true);\r\n const read = ReadValue(context, at, Attribute(attributes, name));\r\n\r\n decoded.set(name, read.value);\r\n end = Math.max(end, at + read.size);\r\n });\r\n\r\n for (const name of variable) {\r\n const attribute = Attribute(attributes, name);\r\n\r\n // An absent optional takes the value the schema declares for it. Where no\r\n // default is declared the attribute is simply not part of this record -\r\n // which is what the published exports show for these same rows.\r\n if (!decoded.has(name) && Object.hasOwn(attribute, \"default\")) {\r\n decoded.set(name, attribute.default);\r\n }\r\n }\r\n\r\n size = end - offset;\r\n }\r\n\r\n // Declaration order, not the order the two passes above happened to fill.\r\n const value = {};\r\n\r\n for (const name of Object.keys(attributes)) {\r\n if (decoded.has(name)) value[name] = decoded.get(name);\r\n }\r\n\r\n return { value, size };\r\n}\r\n\r\n/** Looks up an attribute, naming the schema rather than failing on undefined. */\r\nfunction Attribute(attributes, name) {\r\n const attribute = attributes[name];\r\n\r\n if (!attribute) {\r\n throw SchemaBoundError(`The schema offsets an attribute it never declares: ${name}.`, {\r\n attribute: name\r\n });\r\n }\r\n\r\n return attribute;\r\n}\r\n\r\nexport default ReadValue;\r\n"],"names":["TEXT","TextDecoder","ReadValue","context","offset","node","type","ReadInt","size","min","ReadFloat","value","view","getUint8","ReadEnum","ReadVector","ReadString","ReadList","ReadDict","ReadObject","SchemaBoundError","schemaType","unsigned","getInt8","getUint16","getInt16","getUint32","getInt32","Narrow","getBigUint64","getBigInt64","Number","getFloat64","getFloat32","readEnumValue","values","name","member","Object","entries","components","wide","precision","width","read","index","aliases","DEFAULT_COMPONENTS","x","y","z","length","start","decode","bytes","subarray","count","items","fixedItemSize","undefined","end","at","item","itemTypes","push","Math","max","cursor","total","base","footerSize","footerStart","entry","keyFooter","key","valueTypes","attributes","variable","attributesWithVariableOffsets","decoded","Map","endOfFixedSizeData","constantAttributeOffsets","set","Attribute","lookups","optionalValueLookups","bits","table","present","filter","attribute","isOptional","BigInt","data","forEach","has","hasOwn","default","keys","get"],"mappings":";;AAEA,MAAMA,IAAI,GAAG,IAAIC,WAAW,CAAC,OAAO,CAAC;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAACC,OAAO,EAAEC,MAAM,EAAEC,IAAI,EAAE;EAC/C,QAAQA,IAAI,CAACC,IAAI;AACf,IAAA,KAAK,KAAK;AAAE,MAAA,OAAOC,OAAO,CAACJ,OAAO,EAAEC,MAAM,EAAEC,IAAI,CAAC;AACjD;AACA;AACA;AACA;AACA;AACA,IAAA,KAAK,gBAAgB;AAAE,IAAA,KAAK,QAAQ;AAAE,IAAA,KAAK,WAAW;AAAE,IAAA,KAAK,SAAS;AACtE,IAAA,KAAK,YAAY;AAAE,IAAA,KAAK,WAAW;AAAE,IAAA,KAAK,QAAQ;AAAE,IAAA,KAAK,cAAc;AACrE,MAAA,OAAOE,OAAO,CAACJ,OAAO,EAAEC,MAAM,EAAE;AAAEI,QAAAA,IAAI,EAAEH,IAAI,CAACG,IAAI,IAAI,CAAC;AAA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ACpC,IAAI,CAAC;AACrC,IAAA,CAAC,CAAC;AAEF,IAAA,KAAK,MAAM4B,IAAI,IAAIyC,QAAQ,EAAE;AAC3B,MAAA,MAAMc,SAAS,GAAGP,SAAS,CAACR,UAAU,EAAExC,IAAI,CAAC;;AAE7C;AACA;AACA;AACA,MAAA,IAAI,CAAC2C,OAAO,CAACiB,GAAG,CAAC5D,IAAI,CAAC,IAAIE,MAAM,CAAC2D,MAAM,CAACN,SAAS,EAAE,SAAS,CAAC,EAAE;QAC7DZ,OAAO,CAACI,GAAG,CAAC/C,IAAI,EAAEuD,SAAS,CAACO,OAAO,CAAC;AACtC,MAAA;AACF,IAAA;IAEA1F,IAAI,GAAGoD,GAAG,GAAGxD,MAAM;AACrB,EAAA;;AAEA;EACA,MAAMO,KAAK,GAAG,EAAE;EAEhB,KAAK,MAAMyB,IAAI,IAAIE,MAAM,CAAC6D,IAAI,CAACvB,UAAU,CAAC,EAAE;AAC1C,IAAA,IAAIG,OAAO,CAACiB,GAAG,CAAC5D,IAAI,CAAC,EAAEzB,KAAK,CAACyB,IAAI,CAAC,GAAG2C,OAAO,CAACqB,GAAG,CAAChE,IAAI,CAAC;AACxD,EAAA;EAEA,OAAO;IAAEzB,KAAK;AAAEH,IAAAA;GAAM;AACxB;;AAEA;AACA,SAAS4E,SAASA,CAACR,UAAU,EAAExC,IAAI,EAAE;AACnC,EAAA,MAAMuD,SAAS,GAAGf,UAAU,CAACxC,IAAI,CAAC;EAElC,IAAI,CAACuD,SAAS,EAAE;AACd,IAAA,MAAMvE,gBAAgB,CAAC,CAAA,mDAAA,EAAsDgB,IAAI,GAAG,EAAE;AACpFuD,MAAAA,SAAS,EAAEvD;AACb,KAAC,CAAC;AACJ,EAAA;AAEA,EAAA,OAAOuD,SAAS;AAClB;;;;"}
|
|
1
|
+
{"version":3,"file":"schemaBoundValues.js","sources":["../../../../../../src/resource/formats/schemabound/core/schemaBoundValues.js"],"sourcesContent":["import { SchemaBoundError } from \"./schemaBoundErrors.js\";\r\n\r\nconst TEXT = new TextDecoder(\"utf-8\");\r\n\r\n/**\r\n * Decodes one value of any schema type, and reports how many bytes it spanned.\r\n *\r\n * Every type answers both questions through this one function because the\r\n * container mixes them: a list's items may be fixed, in which case the schema\r\n * states the stride, or variable, in which case the only way to find item `n+1`\r\n * is to have finished reading item `n`.\r\n *\r\n * @param {object} context Reader context: `view`, `bytes` and `options`.\r\n * @param {number} offset Absolute byte offset of the value.\r\n * @param {object} node The schema node describing the value.\r\n * @returns {{value: *, size: number}} Decoded value and the bytes it occupied.\r\n */\r\nexport function ReadValue(context, offset, node) {\r\n switch (node.type) {\r\n case \"int\": return ReadInt(context, offset, node);\r\n // Identifier types. Each is a four-byte unsigned integer that names a row in\r\n // another table, and the schema states the meaning rather than the width -\r\n // `factionID` and one or two others declare no size at all. Keeping them\r\n // named here rather than folding them into `int` is what lets a consumer see\r\n // that a number is a key.\r\n case \"localizationID\": case \"typeID\": case \"factionID\": case \"groupID\":\r\n case \"categoryID\": case \"graphicID\": case \"iconID\": case \"fsdReference\":\r\n // `typeListID` names a row in a type-list table. Frontier declares it in the\r\n // embedded schema of `solarsystemcontent.static` (field\r\n // `constructableTypeListID`, alongside `graphicID` in the same node shape);\r\n // Tranquility has no such type, which is why it went unseen.\r\n case \"typeListID\":\r\n return ReadInt(context, offset, { size: node.size ?? 4, min: 0 });\r\n case \"float\": return ReadFloat(context, offset, node);\r\n case \"bool\": return { value: context.view.getUint8(offset) !== 0, size: node.size ?? 1 };\r\n case \"enum\": return ReadEnum(context, offset, node);\r\n case \"vector2\": return ReadVector(context, offset, node, 2);\r\n case \"vector3\": return ReadVector(context, offset, node, 3);\r\n // `unicode` is the same framing as `string`; the distinction is Python's,\r\n // and both arrive as a byte length followed by UTF-8.\r\n case \"string\": case \"resPath\": case \"unicode\": return ReadString(context, offset);\r\n case \"list\": return ReadList(context, offset, node);\r\n case \"dict\": return ReadDict(context, offset, node);\r\n case \"object\": return ReadObject(context, offset, node);\r\n default:\r\n throw SchemaBoundError(`The schema declares a type this reader does not know: ${node.type}.`, {\r\n schemaType: node.type\r\n });\r\n }\r\n}\r\n\r\n/** Reads a 1, 2, 4 or 8 byte integer, signed only when the schema allows it. */\r\nfunction ReadInt(context, offset, node) {\r\n const size = node.size ?? 4;\r\n // `min: 0` is the schema's own statement that the field cannot go negative,\r\n // and it is the only signedness information there is.\r\n const unsigned = typeof node.min === \"number\" && node.min >= 0;\r\n const view = context.view;\r\n\r\n switch (size) {\r\n case 1: return { value: unsigned ? view.getUint8(offset) : view.getInt8(offset), size };\r\n case 2: return { value: unsigned ? view.getUint16(offset, true) : view.getInt16(offset, true), size };\r\n case 4: return { value: unsigned ? view.getUint32(offset, true) : view.getInt32(offset, true), size };\r\n case 8: return { value: Narrow(unsigned ? view.getBigUint64(offset, true) : view.getBigInt64(offset, true)), size };\r\n default:\r\n throw SchemaBoundError(`An integer of ${size} bytes is not a width this container uses.`);\r\n }\r\n}\r\n\r\n/** Returns a wide integer as a Number when that is lossless, else a BigInt. */\r\nfunction Narrow(value) {\r\n return value >= -9007199254740991n && value <= 9007199254740991n ? Number(value) : value;\r\n}\r\n\r\n/** Reads a single or double precision float. */\r\nfunction ReadFloat(context, offset, node) {\r\n const size = node.size ?? 4;\r\n\r\n if (size === 8) return { value: context.view.getFloat64(offset, true), size };\r\n if (size === 4) return { value: context.view.getFloat32(offset, true), size };\r\n\r\n throw SchemaBoundError(`A float of ${size} bytes is not a width this container uses.`);\r\n}\r\n\r\n/**\r\n * Reads an enumeration, as its number or its name.\r\n *\r\n * `readEnumValue` is the schema saying the stored number is the meaning; without\r\n * it the name is. A number with no name is returned as the number rather than\r\n * dropped, because an unnamed member is data the client still stored.\r\n */\r\nfunction ReadEnum(context, offset, node) {\r\n const { value, size } = ReadInt(context, offset, { size: node.size ?? 1, min: 0 });\r\n\r\n if (node.readEnumValue === true || !node.values) return { value, size };\r\n\r\n for (const [ name, member ] of Object.entries(node.values)) {\r\n if (member === value) return { value: name, size };\r\n }\r\n\r\n return { value, size };\r\n}\r\n\r\n/** Reads a fixed-length vector into the component names the schema aliases. */\r\nfunction ReadVector(context, offset, node, components) {\r\n const wide = (node.precision ?? \"double\") === \"double\";\r\n const width = wide ? 8 : 4;\r\n const read = index => wide\r\n ? context.view.getFloat64(offset + index * width, true)\r\n : context.view.getFloat32(offset + index * width, true);\r\n const aliases = node.aliases ?? DEFAULT_COMPONENTS[components];\r\n const value = {};\r\n\r\n for (const [ name, index ] of Object.entries(aliases)) value[name] = read(index);\r\n\r\n return { value, size: node.size ?? width * components };\r\n}\r\n\r\nconst DEFAULT_COMPONENTS = { 2: { x: 0, y: 1 }, 3: { x: 0, y: 1, z: 2 } };\r\n\r\n/** Reads a length-prefixed UTF-8 string; `resPath` is the same shape. */\r\nfunction ReadString(context, offset) {\r\n const length = context.view.getUint32(offset, true);\r\n const start = offset + 4;\r\n\r\n return {\r\n value: TEXT.decode(context.bytes.subarray(start, start + length)),\r\n size: 4 + length\r\n };\r\n}\r\n\r\n/**\r\n * Reads a count-prefixed list.\r\n *\r\n * A list has two framings and the schema says which: `fixedItemSize` means the\r\n * items are packed one after another at that stride, and its absence means they\r\n * are variable, so the count is followed by one `uint32` per item. Those offsets\r\n * are relative to the start of the list.\r\n */\r\nfunction ReadList(context, offset, node) {\r\n const view = context.view;\r\n const count = view.getUint32(offset, true);\r\n const items = [];\r\n\r\n if (node.fixedItemSize === undefined) {\r\n let end = offset + 4 + count * 4;\r\n\r\n for (let index = 0; index < count; index += 1) {\r\n const at = offset + view.getUint32(offset + 4 + index * 4, true);\r\n const item = ReadValue(context, at, node.itemTypes);\r\n\r\n items.push(item.value);\r\n end = Math.max(end, at + item.size);\r\n }\r\n\r\n return { value: items, size: end - offset };\r\n }\r\n\r\n let cursor = offset + 4;\r\n\r\n for (let index = 0; index < count; index += 1) {\r\n items.push(ReadValue(context, cursor, node.itemTypes).value);\r\n cursor += node.fixedItemSize;\r\n }\r\n\r\n return { value: items, size: cursor - offset };\r\n}\r\n\r\n/**\r\n * Reads a keyed map.\r\n *\r\n * The framing is the same at the root of a container and nested inside one\r\n * record: a `uint32` of everything that follows, the values, then the key\r\n * footer, then a `uint32` of the footer's own size. **The footer is found from\r\n * the end, never from the front** — nothing at the front points at it.\r\n *\r\n * Each footer entry carries a key and an offset, and that offset is relative to\r\n * the end of the leading `uint32`, not to the file and not to the value region.\r\n */\r\nfunction ReadDict(context, offset, node) {\r\n const view = context.view;\r\n const total = view.getUint32(offset, true);\r\n const base = offset + 4;\r\n const end = base + total;\r\n const footerSize = view.getUint32(end - 4, true);\r\n const footerStart = end - 4 - footerSize;\r\n\r\n if (footerStart < base) {\r\n throw SchemaBoundError(\"The key footer does not fit inside the container.\", { footerStart, base });\r\n }\r\n\r\n const value = {};\r\n\r\n // The footer is an ordinary list, and it uses both of the list framings: a\r\n // list of integer keys is fixed-stride, a list of string keys is not.\r\n for (const entry of ReadList(context, footerStart, node.keyFooter).value) {\r\n value[entry.key] = ReadValue(context, base + entry.offset, node.valueTypes).value;\r\n }\r\n\r\n return { value, size: 4 + total };\r\n}\r\n\r\n/**\r\n * Reads a record.\r\n *\r\n * Fixed attributes sit at the offsets the schema names. Everything in\r\n * `attributesWithVariableOffsets` is reached through a table that follows the\r\n * fixed part, and **that table's length changes from record to record**: an\r\n * optional attribute whose presence bit is clear takes no slot in it. A reader\r\n * that assumes a constant stride decodes the first record correctly and then\r\n * drifts, which is the single most misleading property of this format.\r\n */\r\nfunction ReadObject(context, offset, node) {\r\n const attributes = node.attributes ?? {};\r\n const variable = node.attributesWithVariableOffsets ?? [];\r\n const decoded = new Map();\r\n let size = node.size ?? node.endOfFixedSizeData ?? 0;\r\n\r\n for (const [ name, at ] of Object.entries(node.constantAttributeOffsets ?? {})) {\r\n decoded.set(name, ReadValue(context, offset + at, Attribute(attributes, name)).value);\r\n }\r\n\r\n if (variable.length) {\r\n const lookups = node.optionalValueLookups ?? {};\r\n const view = context.view;\r\n // The presence bitfield is written whenever a record has a variable section\r\n // at all, including where nothing in it is optional and the field is\r\n // therefore always zero. It is the offset table that shrinks, never this.\r\n const bits = view.getBigUint64(offset + node.endOfFixedSizeData, true);\r\n const table = offset + node.endOfFixedSizeData + 8;\r\n const present = variable.filter(name => {\r\n const attribute = Attribute(attributes, name);\r\n\r\n return !attribute.isOptional || (bits & BigInt(lookups[name] ?? 0)) !== 0n;\r\n });\r\n const data = table + present.length * 4;\r\n let end = data;\r\n\r\n present.forEach((name, index) => {\r\n const at = data + view.getUint32(table + index * 4, true);\r\n const read = ReadValue(context, at, Attribute(attributes, name));\r\n\r\n decoded.set(name, read.value);\r\n end = Math.max(end, at + read.size);\r\n });\r\n\r\n for (const name of variable) {\r\n const attribute = Attribute(attributes, name);\r\n\r\n // An absent optional takes the value the schema declares for it. Where no\r\n // default is declared the attribute is simply not part of this record -\r\n // which is what the published exports show for these same rows.\r\n if (!decoded.has(name) && Object.hasOwn(attribute, \"default\")) {\r\n decoded.set(name, attribute.default);\r\n }\r\n }\r\n\r\n size = end - offset;\r\n }\r\n\r\n // Declaration order, not the order the two passes above happened to fill.\r\n const value = {};\r\n\r\n for (const name of Object.keys(attributes)) {\r\n if (decoded.has(name)) value[name] = decoded.get(name);\r\n }\r\n\r\n return { value, size };\r\n}\r\n\r\n/** Looks up an attribute, naming the schema rather than failing on undefined. */\r\nfunction Attribute(attributes, name) {\r\n const attribute = attributes[name];\r\n\r\n if (!attribute) {\r\n throw SchemaBoundError(`The schema offsets an attribute it never declares: ${name}.`, {\r\n attribute: name\r\n });\r\n }\r\n\r\n return attribute;\r\n}\r\n\r\nexport default ReadValue;\r\n"],"names":["TEXT","TextDecoder","ReadValue","context","offset","node","type","ReadInt","size","min","ReadFloat","value","view","getUint8","ReadEnum","ReadVector","ReadString","ReadList","ReadDict","ReadObject","SchemaBoundError","schemaType","unsigned","getInt8","getUint16","getInt16","getUint32","getInt32","Narrow","getBigUint64","getBigInt64","Number","getFloat64","getFloat32","readEnumValue","values","name","member","Object","entries","components","wide","precision","width","read","index","aliases","DEFAULT_COMPONENTS","x","y","z","length","start","decode","bytes","subarray","count","items","fixedItemSize","undefined","end","at","item","itemTypes","push","Math","max","cursor","total","base","footerSize","footerStart","entry","keyFooter","key","valueTypes","attributes","variable","attributesWithVariableOffsets","decoded","Map","endOfFixedSizeData","constantAttributeOffsets","set","Attribute","lookups","optionalValueLookups","bits","table","present","filter","attribute","isOptional","BigInt","data","forEach","has","hasOwn","default","keys","get"],"mappings":";;AAEA,MAAMA,IAAI,GAAG,IAAIC,WAAW,CAAC,OAAO,CAAC;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAACC,OAAO,EAAEC,MAAM,EAAEC,IAAI,EAAE;EAC/C,QAAQA,IAAI,CAACC,IAAI;AACf,IAAA,KAAK,KAAK;AAAE,MAAA,OAAOC,OAAO,CAACJ,OAAO,EAAEC,MAAM,EAAEC,IAAI,CAAC;AACjD;AACA;AACA;AACA;AACA;AACA,IAAA,KAAK,gBAAgB;AAAE,IAAA,KAAK,QAAQ;AAAE,IAAA,KAAK,WAAW;AAAE,IAAA,KAAK,SAAS;AACtE,IAAA,KAAK,YAAY;AAAE,IAAA,KAAK,WAAW;AAAE,IAAA,KAAK,QAAQ;AAAE,IAAA,KAAK,cAAc;AACvE;AACA;AACA;AACA;AACA,IAAA,KAAK,YAAY;AACf,MAAA,OAAOE,OAAO,CAACJ,OAAO,EAAEC,MAAM,EAAE;AAAEI,QAAAA,IAAI,EAAEH,IAAI,CAACG,IAAI,IAAI,CAAC;AAAEC,QAAAA,GAAG,EAAE;AAAE,OAAC,CAAC;AACnE,IAAA,KAAK,OAAO;AAAE,MAAA,OAAOC,SAAS,CAACP,OAAO,EAAEC,MAAM,EAAEC,IAAI,CAAC;AACrD,IAAA,KAAK,MAAM;MAAE,OAAO;QAAEM,KAAK,EAAER,OAAO,CAACS,IAAI,CAACC,QAAQ,CAACT,MAAM,CAAC,KAAK,CAAC;AAAEI,QAAAA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AC2D,MAAM,CAACN,SAAS,EAAE,SAAS,CAAC,EAAE;QAC7DZ,OAAO,CAACI,GAAG,CAAC/C,IAAI,EAAEuD,SAAS,CAACO,OAAO,CAAC;AACtC,MAAA;AACF,IAAA;IAEA1F,IAAI,GAAGoD,GAAG,GAAGxD,MAAM;AACrB,EAAA;;AAEA;EACA,MAAMO,KAAK,GAAG,EAAE;EAEhB,KAAK,MAAMyB,IAAI,IAAIE,MAAM,CAAC6D,IAAI,CAACvB,UAAU,CAAC,EAAE;AAC1C,IAAA,IAAIG,OAAO,CAACiB,GAAG,CAAC5D,IAAI,CAAC,EAAEzB,KAAK,CAACyB,IAAI,CAAC,GAAG2C,OAAO,CAACqB,GAAG,CAAChE,IAAI,CAAC;AACxD,EAAA;EAEA,OAAO;IAAEzB,KAAK;AAAEH,IAAAA;GAAM;AACxB;;AAEA;AACA,SAAS4E,SAASA,CAACR,UAAU,EAAExC,IAAI,EAAE;AACnC,EAAA,MAAMuD,SAAS,GAAGf,UAAU,CAACxC,IAAI,CAAC;EAElC,IAAI,CAACuD,SAAS,EAAE;AACd,IAAA,MAAMvE,gBAAgB,CAAC,CAAA,mDAAA,EAAsDgB,IAAI,GAAG,EAAE;AACpFuD,MAAAA,SAAS,EAAEvD;AACb,KAAC,CAAC;AACJ,EAAA;AAEA,EAAA,OAAOuD,SAAS;AAClB;;;;"}
|
|
@@ -22,7 +22,7 @@ const MASTER_ROOT_PAGE = 1;
|
|
|
22
22
|
* them are here. Index b-tree pages are never visited: an index holds no data a
|
|
23
23
|
* table scan does not already produce.
|
|
24
24
|
*
|
|
25
|
-
* It exists because the runtime resource layer is browser-safe and ships no SQLite
|
|
25
|
+
* It exists because the runtime resource layer is browser-safe and ships no SQLite
|
|
26
26
|
* engine, so `.static` containers of the SQLite family previously needed a
|
|
27
27
|
* driver injected by the caller — which meant Node, and in practice the
|
|
28
28
|
* experimental `node:sqlite`. Nothing here touches a filesystem or a binding.
|
|
@@ -163,14 +163,9 @@ class CjsSqliteFormat extends CjsFormat {
|
|
|
163
163
|
const bytes = Normalize(input);
|
|
164
164
|
return ReadMaster(bytes, ReadHeader(bytes)).filter(entry => entry.type === "table");
|
|
165
165
|
}
|
|
166
|
-
static
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
RAW: OUTPUT_RAW
|
|
170
|
-
});
|
|
171
|
-
static id = "sqlite";
|
|
172
|
-
static extensions = Object.freeze([".sqlite", ".db", ".sqlite3"]);
|
|
173
|
-
static mediaTypes = Object.freeze(["data"]);
|
|
166
|
+
static id = "CjsSqliteFormat";
|
|
167
|
+
static extensions = [".sqlite", ".db", ".sqlite3"];
|
|
168
|
+
static mediaTypes = ["data"];
|
|
174
169
|
static outputs = CjsFormat.defineOutputs({
|
|
175
170
|
json: {
|
|
176
171
|
default: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CjsSqliteFormat.js","sources":["../../../../../src/resource/formats/sqlite/CjsSqliteFormat.js"],"sourcesContent":["import { CjsFormat } from \"../../format/CjsFormat.js\";\r\nimport { ReadColumns } from \"./core/sqliteSchema.js\";\r\nimport { ReadHeader, TableRows } from \"./core/sqlitePages.js\";\r\nimport { ReadRecord, SqliteError } from \"./core/sqliteRecords.js\";\r\n\r\nconst OUTPUT_JSON = \"json\";\r\nconst OUTPUT_PAYLOAD = \"payload\";\r\nconst OUTPUT_RAW = \"raw\";\r\nconst MASTER_ROOT_PAGE = 1;\r\n\r\n/**\r\n * Reads a SQLite 3 container as data.\r\n *\r\n * **This is a reader, not a database.** It accepts no SQL and runs no queries.\r\n * It returns the tables a container holds and every row of them, because that\r\n * is the whole of what this organization does with a SQLite file: the client's\r\n * `.static` containers and the prepared static data export are both opened,\r\n * scanned once, and closed.\r\n *\r\n * That scope is what makes it small. A query planner, an index walker, writing,\r\n * journalling and transactions are most of SQLite and none of this, so none of\r\n * them are here. Index b-tree pages are never visited: an index holds no data a\r\n * table scan does not already produce.\r\n *\r\n * It exists because the runtime resource layer is browser-safe and ships no SQLite\n * engine, so `.static` containers of the SQLite family previously needed a\r\n * driver injected by the caller — which meant Node, and in practice the\r\n * experimental `node:sqlite`. Nothing here touches a filesystem or a binding.\r\n *\r\n * Values map as the format defines them: NULL, integers, doubles, text decoded\r\n * with the database's own encoding, and blobs as `Uint8Array`. An integer wider\r\n * than `Number.MAX_SAFE_INTEGER` is returned as a `BigInt` rather than silently\r\n * rounded.\r\n */\r\nexport class CjsSqliteFormat extends CjsFormat {\r\n\r\n /**\r\n * Reports whether bytes are a SQLite container, by signature.\r\n *\r\n * @param {Uint8Array|ArrayBuffer} input Candidate bytes.\r\n * @returns {boolean} True when the header signature matches.\r\n */\r\n static is(input) {\r\n try {\r\n ReadHeader(Normalize(input));\r\n\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Reports whether these bytes are a SQLite container, on the signature.\r\n *\r\n * The signature is the whole claim: the header either says\r\n * `SQLite format 3` or it does not, so this is verified by content rather\r\n * than inferred from a name — which matters because `.static` carries three\r\n * unrelated families and the extension proves nothing.\r\n *\r\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\r\n * @param {object} [options] Probe options.\r\n * @returns {object} Resource probe.\r\n */\r\n static probeSupport(input, options = null) {\r\n const recognized = this.is(input);\r\n return {\r\n format: this.id,\r\n source: options?.source || \"buffer\",\r\n recognized,\r\n supported: recognized,\r\n preferredOutput: recognized ? OUTPUT_JSON : \"\",\r\n reason: recognized\r\n ? \"Recognized a SQLite 3 container.\"\r\n : \"The header signature is not SQLite 3.\",\r\n variants: [\r\n { kind: OUTPUT_JSON, supported: recognized },\r\n { kind: OUTPUT_PAYLOAD, supported: recognized },\r\n { kind: OUTPUT_RAW, supported: recognized }\r\n ],\r\n metadata: recognized ? this.inspect(input) : { family: this.id, decodable: false }\r\n };\r\n }\r\n\r\n /** Return header facts without reading table rows. */\r\n static inspect(input) {\r\n const header = ReadHeader(Normalize(input));\r\n return { family: this.id, decodable: true, header };\r\n }\r\n\r\n /**\r\n * Reads every table and row.\r\n *\r\n * @param {Uint8Array|ArrayBuffer} input Container bytes.\r\n * @param {object} [options] Read options.\r\n * @param {string} [options.output] `json`, `payload` or `raw`.\r\n * @param {string[]} [options.tables] Read only these tables.\r\n * @returns {object} Tables keyed by name, each an array of row objects.\r\n */\r\n static read(input, options = {}) {\r\n const output = options.emit ?? options.output ?? OUTPUT_JSON;\r\n const bytes = Normalize(input);\r\n const header = ReadHeader(bytes);\r\n const schema = ReadMaster(bytes, header);\r\n\r\n if (output === OUTPUT_RAW) {\r\n return { header, schema };\r\n }\r\n\r\n const wanted = options.tables ? new Set(options.tables) : null;\r\n const tables = {};\r\n\r\n for (const entry of schema) {\r\n if (entry.type !== \"table\" || (wanted && !wanted.has(entry.name))) {\r\n continue;\r\n }\r\n\r\n // A table with no root page holds nothing: a view, or WITHOUT ROWID.\r\n tables[entry.name] = entry.rootPage\r\n ? ReadTable(bytes, header, entry, output === OUTPUT_JSON)\r\n : [];\r\n }\r\n\r\n return tables;\r\n }\r\n\r\n /** Reads to plain JSON-compatible values, converting blobs to arrays. */\r\n static readJSON(input, options = {}) {\r\n return this.read(input, { ...options, output: OUTPUT_JSON });\r\n }\r\n\r\n /** Reads with blobs left as `Uint8Array` and wide integers as `BigInt`. */\r\n static readPayload(input, options = {}) {\r\n return this.read(input, { ...options, output: OUTPUT_PAYLOAD });\r\n }\r\n\r\n /** Returns the parsed header and `sqlite_master` entries, decoding no rows. */\r\n static readRaw(input, options = {}) {\r\n return this.read(input, { ...options, output: OUTPUT_RAW });\r\n }\r\n\r\n /**\r\n * Lists the tables a container holds, without reading their rows.\r\n *\r\n * @param {Uint8Array|ArrayBuffer} input Container bytes.\r\n * @returns {Array<object>} One entry per table.\r\n */\r\n static tables(input) {\r\n const bytes = Normalize(input);\r\n\r\n return ReadMaster(bytes, ReadHeader(bytes)).filter(entry => entry.type === \"table\");\r\n }\r\n\r\n static Output = Object.freeze({\r\n JSON: OUTPUT_JSON,\r\n PAYLOAD: OUTPUT_PAYLOAD,\r\n RAW: OUTPUT_RAW\r\n });\r\n\r\n static id = \"sqlite\";\r\n static extensions = Object.freeze([ \".sqlite\", \".db\", \".sqlite3\" ]);\r\n static mediaTypes = Object.freeze([ \"data\" ]);\r\n static outputs = CjsFormat.defineOutputs({\r\n json: { default: true, decoded: true },\r\n payload: { decoded: true },\r\n raw: { role: \"debug\", decoded: true }\r\n });\r\n}\r\n\r\n/** Reads `sqlite_master`, which is always the table b-tree rooted at page 1. */\r\nfunction ReadMaster(bytes, header) {\r\n const entries = [];\r\n\r\n for (const row of TableRows(bytes, header, MASTER_ROOT_PAGE)) {\r\n const [ type, name, tableName, rootPage, sql ] = ReadRecord(row.payload, header.encoding);\r\n\r\n entries.push({\r\n type: String(type ?? \"\"),\r\n name: String(name ?? \"\"),\r\n tableName: String(tableName ?? \"\"),\r\n rootPage: Number(rootPage ?? 0),\r\n sql: sql === null || sql === undefined ? \"\" : String(sql)\r\n });\r\n }\r\n\r\n return entries;\r\n}\r\n\r\n/** Reads one table's rows as objects, named from its `CREATE TABLE` text. */\r\nfunction ReadTable(bytes, header, entry, json) {\r\n const { names, rowidAlias } = ReadColumns(entry.sql);\r\n const rows = [];\r\n\r\n for (const row of TableRows(bytes, header, entry.rootPage)) {\r\n const values = ReadRecord(row.payload, header.encoding);\r\n const record = {};\r\n\r\n for (let index = 0; index < values.length; index += 1) {\r\n // Positional names keep a row readable when the statement could not be\r\n // parsed, rather than dropping columns that certainly hold data.\r\n const name = names[index] ?? `column${index}`;\r\n const value = index === rowidAlias && values[index] === null ? row.rowid : values[index];\r\n\r\n record[name] = json ? ToJSON(value) : value;\r\n }\r\n\r\n rows.push(record);\r\n }\r\n\r\n return rows;\r\n}\r\n\r\n/** Converts a decoded value to something `JSON.stringify` keeps losslessly. */\r\nfunction ToJSON(value) {\r\n if (value instanceof Uint8Array) {\r\n return Array.from(value);\r\n }\r\n\r\n // A BigInt has no JSON form; a decimal string keeps every digit.\r\n return typeof value === \"bigint\" ? value.toString(10) : value;\r\n}\r\n\r\n/** Accepts the byte forms every other format here accepts. */\r\nfunction Normalize(input) {\r\n if (input instanceof Uint8Array) {\r\n return input;\r\n }\r\n\r\n if (input instanceof ArrayBuffer) {\r\n return new Uint8Array(input);\r\n }\r\n\r\n if (ArrayBuffer.isView(input)) {\r\n return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\r\n }\r\n\r\n throw SqliteError(\"A SQLite container must be supplied as bytes.\");\r\n}\r\n\r\nexport default CjsSqliteFormat;\r\n"],"names":["OUTPUT_JSON","OUTPUT_PAYLOAD","OUTPUT_RAW","MASTER_ROOT_PAGE","CjsSqliteFormat","CjsFormat","is","input","ReadHeader","Normalize","probeSupport","options","recognized","format","id","source","supported","preferredOutput","reason","variants","kind","metadata","inspect","family","decodable","header","read","output","emit","bytes","schema","ReadMaster","wanted","tables","Set","entry","type","has","name","rootPage","ReadTable","readJSON","readPayload","readRaw","filter","Output","Object","freeze","JSON","PAYLOAD","RAW","extensions","mediaTypes","outputs","defineOutputs","json","default","decoded","payload","raw","role","entries","row","TableRows","tableName","sql","ReadRecord","encoding","push","String","Number","undefined","names","rowidAlias","ReadColumns","rows","values","record","index","length","value","rowid","ToJSON","Uint8Array","Array","from","toString","ArrayBuffer","isView","buffer","byteOffset","byteLength","SqliteError"],"mappings":";;;;;AAKA,MAAMA,WAAW,GAAG,MAAM;AAC1B,MAAMC,cAAc,GAAG,SAAS;AAChC,MAAMC,UAAU,GAAG,KAAK;AACxB,MAAMC,gBAAgB,GAAG,CAAC;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,eAAe,SAASC,SAAS,CAAC;AAE7C;AACF;AACA;AACA;AACA;AACA;EACE,OAAOC,EAAEA,CAACC,KAAK,EAAE;IACf,IAAI;AACFC,MAAAA,UAAU,CAACC,SAAS,CAACF,KAAK,CAAC,CAAC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E,UAAU,EAAE;AAC/B,IAAA,OAAO5E,KAAK;AACd,EAAA;EAEA,IAAIA,KAAK,YAAYgF,WAAW,EAAE;AAChC,IAAA,OAAO,IAAIJ,UAAU,CAAC5E,KAAK,CAAC;AAC9B,EAAA;AAEA,EAAA,IAAIgF,WAAW,CAACC,MAAM,CAACjF,KAAK,CAAC,EAAE;AAC7B,IAAA,OAAO,IAAI4E,UAAU,CAAC5E,KAAK,CAACkF,MAAM,EAAElF,KAAK,CAACmF,UAAU,EAAEnF,KAAK,CAACoF,UAAU,CAAC;AACzE,EAAA;EAEA,MAAMC,WAAW,CAAC,+CAA+C,CAAC;AACpE;;;;"}
|
|
1
|
+
{"version":3,"file":"CjsSqliteFormat.js","sources":["../../../../../src/resource/formats/sqlite/CjsSqliteFormat.js"],"sourcesContent":["import { CjsFormat } from \"../../format/CjsFormat.js\";\r\nimport { ReadColumns } from \"./core/sqliteSchema.js\";\r\nimport { ReadHeader, TableRows } from \"./core/sqlitePages.js\";\r\nimport { ReadRecord, SqliteError } from \"./core/sqliteRecords.js\";\r\n\r\nconst OUTPUT_JSON = \"json\";\r\nconst OUTPUT_PAYLOAD = \"payload\";\r\nconst OUTPUT_RAW = \"raw\";\r\nconst MASTER_ROOT_PAGE = 1;\r\n\r\n/**\r\n * Reads a SQLite 3 container as data.\r\n *\r\n * **This is a reader, not a database.** It accepts no SQL and runs no queries.\r\n * It returns the tables a container holds and every row of them, because that\r\n * is the whole of what this organization does with a SQLite file: the client's\r\n * `.static` containers and the prepared static data export are both opened,\r\n * scanned once, and closed.\r\n *\r\n * That scope is what makes it small. A query planner, an index walker, writing,\r\n * journalling and transactions are most of SQLite and none of this, so none of\r\n * them are here. Index b-tree pages are never visited: an index holds no data a\r\n * table scan does not already produce.\r\n *\r\n * It exists because the runtime resource layer is browser-safe and ships no SQLite\r\n * engine, so `.static` containers of the SQLite family previously needed a\r\n * driver injected by the caller — which meant Node, and in practice the\r\n * experimental `node:sqlite`. Nothing here touches a filesystem or a binding.\r\n *\r\n * Values map as the format defines them: NULL, integers, doubles, text decoded\r\n * with the database's own encoding, and blobs as `Uint8Array`. An integer wider\r\n * than `Number.MAX_SAFE_INTEGER` is returned as a `BigInt` rather than silently\r\n * rounded.\r\n */\r\nexport class CjsSqliteFormat extends CjsFormat {\r\n\r\n /**\r\n * Reports whether bytes are a SQLite container, by signature.\r\n *\r\n * @param {Uint8Array|ArrayBuffer} input Candidate bytes.\r\n * @returns {boolean} True when the header signature matches.\r\n */\r\n static is(input) {\r\n try {\r\n ReadHeader(Normalize(input));\r\n\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Reports whether these bytes are a SQLite container, on the signature.\r\n *\r\n * The signature is the whole claim: the header either says\r\n * `SQLite format 3` or it does not, so this is verified by content rather\r\n * than inferred from a name — which matters because `.static` carries three\r\n * unrelated families and the extension proves nothing.\r\n *\r\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\r\n * @param {object} [options] Probe options.\r\n * @returns {object} Resource probe.\r\n */\r\n static probeSupport(input, options = null) {\r\n const recognized = this.is(input);\r\n return {\r\n format: this.id,\r\n source: options?.source || \"buffer\",\r\n recognized,\r\n supported: recognized,\r\n preferredOutput: recognized ? OUTPUT_JSON : \"\",\r\n reason: recognized\r\n ? \"Recognized a SQLite 3 container.\"\r\n : \"The header signature is not SQLite 3.\",\r\n variants: [\r\n { kind: OUTPUT_JSON, supported: recognized },\r\n { kind: OUTPUT_PAYLOAD, supported: recognized },\r\n { kind: OUTPUT_RAW, supported: recognized }\r\n ],\r\n metadata: recognized ? this.inspect(input) : { family: this.id, decodable: false }\r\n };\r\n }\r\n\r\n /** Return header facts without reading table rows. */\r\n static inspect(input) {\r\n const header = ReadHeader(Normalize(input));\r\n return { family: this.id, decodable: true, header };\r\n }\r\n\r\n /**\r\n * Reads every table and row.\r\n *\r\n * @param {Uint8Array|ArrayBuffer} input Container bytes.\r\n * @param {object} [options] Read options.\r\n * @param {string} [options.output] `json`, `payload` or `raw`.\r\n * @param {string[]} [options.tables] Read only these tables.\r\n * @returns {object} Tables keyed by name, each an array of row objects.\r\n */\r\n static read(input, options = {}) {\r\n const output = options.emit ?? options.output ?? OUTPUT_JSON;\r\n const bytes = Normalize(input);\r\n const header = ReadHeader(bytes);\r\n const schema = ReadMaster(bytes, header);\r\n\r\n if (output === OUTPUT_RAW) {\r\n return { header, schema };\r\n }\r\n\r\n const wanted = options.tables ? new Set(options.tables) : null;\r\n const tables = {};\r\n\r\n for (const entry of schema) {\r\n if (entry.type !== \"table\" || (wanted && !wanted.has(entry.name))) {\r\n continue;\r\n }\r\n\r\n // A table with no root page holds nothing: a view, or WITHOUT ROWID.\r\n tables[entry.name] = entry.rootPage\r\n ? ReadTable(bytes, header, entry, output === OUTPUT_JSON)\r\n : [];\r\n }\r\n\r\n return tables;\r\n }\r\n\r\n /** Reads to plain JSON-compatible values, converting blobs to arrays. */\r\n static readJSON(input, options = {}) {\r\n return this.read(input, { ...options, output: OUTPUT_JSON });\r\n }\r\n\r\n /** Reads with blobs left as `Uint8Array` and wide integers as `BigInt`. */\r\n static readPayload(input, options = {}) {\r\n return this.read(input, { ...options, output: OUTPUT_PAYLOAD });\r\n }\r\n\r\n /** Returns the parsed header and `sqlite_master` entries, decoding no rows. */\r\n static readRaw(input, options = {}) {\r\n return this.read(input, { ...options, output: OUTPUT_RAW });\r\n }\r\n\r\n /**\r\n * Lists the tables a container holds, without reading their rows.\r\n *\r\n * @param {Uint8Array|ArrayBuffer} input Container bytes.\r\n * @returns {Array<object>} One entry per table.\r\n */\r\n static tables(input) {\r\n const bytes = Normalize(input);\r\n\r\n return ReadMaster(bytes, ReadHeader(bytes)).filter(entry => entry.type === \"table\");\r\n }\r\n\r\n\r\n static id = \"CjsSqliteFormat\";\r\n static extensions = [ \".sqlite\", \".db\", \".sqlite3\" ];\r\n static mediaTypes = [ \"data\" ];\r\n static outputs = CjsFormat.defineOutputs({\r\n json: { default: true, decoded: true },\r\n payload: { decoded: true },\r\n raw: { role: \"debug\", decoded: true }\r\n });\r\n}\r\n\r\n/** Reads `sqlite_master`, which is always the table b-tree rooted at page 1. */\r\nfunction ReadMaster(bytes, header) {\r\n const entries = [];\r\n\r\n for (const row of TableRows(bytes, header, MASTER_ROOT_PAGE)) {\r\n const [ type, name, tableName, rootPage, sql ] = ReadRecord(row.payload, header.encoding);\r\n\r\n entries.push({\r\n type: String(type ?? \"\"),\r\n name: String(name ?? \"\"),\r\n tableName: String(tableName ?? \"\"),\r\n rootPage: Number(rootPage ?? 0),\r\n sql: sql === null || sql === undefined ? \"\" : String(sql)\r\n });\r\n }\r\n\r\n return entries;\r\n}\r\n\r\n/** Reads one table's rows as objects, named from its `CREATE TABLE` text. */\r\nfunction ReadTable(bytes, header, entry, json) {\r\n const { names, rowidAlias } = ReadColumns(entry.sql);\r\n const rows = [];\r\n\r\n for (const row of TableRows(bytes, header, entry.rootPage)) {\r\n const values = ReadRecord(row.payload, header.encoding);\r\n const record = {};\r\n\r\n for (let index = 0; index < values.length; index += 1) {\r\n // Positional names keep a row readable when the statement could not be\r\n // parsed, rather than dropping columns that certainly hold data.\r\n const name = names[index] ?? `column${index}`;\r\n const value = index === rowidAlias && values[index] === null ? row.rowid : values[index];\r\n\r\n record[name] = json ? ToJSON(value) : value;\r\n }\r\n\r\n rows.push(record);\r\n }\r\n\r\n return rows;\r\n}\r\n\r\n/** Converts a decoded value to something `JSON.stringify` keeps losslessly. */\r\nfunction ToJSON(value) {\r\n if (value instanceof Uint8Array) {\r\n return Array.from(value);\r\n }\r\n\r\n // A BigInt has no JSON form; a decimal string keeps every digit.\r\n return typeof value === \"bigint\" ? value.toString(10) : value;\r\n}\r\n\r\n/** Accepts the byte forms every other format here accepts. */\r\nfunction Normalize(input) {\r\n if (input instanceof Uint8Array) {\r\n return input;\r\n }\r\n\r\n if (input instanceof ArrayBuffer) {\r\n return new Uint8Array(input);\r\n }\r\n\r\n if (ArrayBuffer.isView(input)) {\r\n return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\r\n }\r\n\r\n throw SqliteError(\"A SQLite container must be supplied as bytes.\");\r\n}\r\n\r\nexport default CjsSqliteFormat;\r\n"],"names":["OUTPUT_JSON","OUTPUT_PAYLOAD","OUTPUT_RAW","MASTER_ROOT_PAGE","CjsSqliteFormat","CjsFormat","is","input","ReadHeader","Normalize","probeSupport","options","recognized","format","id","source","supported","preferredOutput","reason","variants","kind","metadata","inspect","family","decodable","header","read","output","emit","bytes","schema","ReadMaster","wanted","tables","Set","entry","type","has","name","rootPage","ReadTable","readJSON","readPayload","readRaw","filter","extensions","mediaTypes","outputs","defineOutputs","json","default","decoded","payload","raw","role","entries","row","TableRows","tableName","sql","ReadRecord","encoding","push","String","Number","undefined","names","rowidAlias","ReadColumns","rows","values","record","index","length","value","rowid","ToJSON","Uint8Array","Array","from","toString","ArrayBuffer","isView","buffer","byteOffset","byteLength","SqliteError"],"mappings":";;;;;AAKA,MAAMA,WAAW,GAAG,MAAM;AAC1B,MAAMC,cAAc,GAAG,SAAS;AAChC,MAAMC,UAAU,GAAG,KAAK;AACxB,MAAMC,gBAAgB,GAAG,CAAC;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,eAAe,SAASC,SAAS,CAAC;AAE7C;AACF;AACA;AACA;AACA;AACA;EACE,OAAOC,EAAEA,CAACC,KAAK,EAAE;IACf,IAAI;AACFC,MAAAA,UAAU,CAACC,SAAS,CAACF,KAAK,CAAC,CAAC;AAE5B,MAAA,OAAO,IAAI;AACb,IAAA,CAAC,CAAC,MAAM;AACN,MAAA,OAAO,KAAK;AACd,IAAA;AACF,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOG,YAAYA,CAACH,KAAK,EAAEI,OAAO,GAAG,IAAI,EAAE;AACzC,IAAA,MA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e(bytes);
|
|
138
138
|
return bytes.subarray(detected.payloadOffset);
|
|
139
139
|
}
|
|
140
|
-
static id = "
|
|
141
|
-
static extensions =
|
|
142
|
-
static mediaTypes =
|
|
143
|
-
static outputs =
|
|
140
|
+
static id = "CjsStaticFormat";
|
|
141
|
+
static extensions = [".static"];
|
|
142
|
+
static mediaTypes = ["data"];
|
|
143
|
+
static outputs = {};
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
146
|
* The extension is the only input this format claims.
|