@carbonenginejs/runtime-resource 0.19.2 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +6 -0
- package/dist/CjsResMan.js +1374 -1318
- package/dist/CjsResMan.js.map +1 -1
- package/dist/format/CjsFormat.js +393 -164
- package/dist/format/CjsFormat.js.map +1 -1
- package/dist/format/CjsFormatStore.js +315 -0
- package/dist/format/CjsFormatStore.js.map +1 -0
- package/dist/format/CjsResourceProbe.js +66 -234
- package/dist/format/CjsResourceProbe.js.map +1 -1
- package/dist/format/payloadContract.js +47 -6
- package/dist/format/payloadContract.js.map +1 -1
- package/dist/formats/black/CjsBlackFormat.js +23 -6
- package/dist/formats/black/CjsBlackFormat.js.map +1 -1
- package/dist/formats/bnk/CjsBnkFormat.js +122 -120
- package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
- package/dist/formats/bnk/core/helpers.js +5 -15
- package/dist/formats/bnk/core/helpers.js.map +1 -1
- package/dist/formats/cmf/CjsCmfFormat.js +31 -14
- package/dist/formats/cmf/CjsCmfFormat.js.map +1 -1
- package/dist/formats/dds/CjsDdsFormat.js +29 -19
- package/dist/formats/dds/CjsDdsFormat.js.map +1 -1
- package/dist/formats/dds/core/helpers.js +4 -5
- package/dist/formats/dds/core/helpers.js.map +1 -1
- package/dist/formats/dxbc/CjsDxbcFormat.js +15 -13
- package/dist/formats/dxbc/CjsDxbcFormat.js.map +1 -1
- package/dist/formats/fbx/CjsFbxFormat.js +27 -19
- package/dist/formats/fbx/CjsFbxFormat.js.map +1 -1
- package/dist/formats/fbx/core/helpers.js +4 -4
- package/dist/formats/fbx/core/helpers.js.map +1 -1
- package/dist/formats/flac/CjsFlacFormat.js +19 -17
- package/dist/formats/flac/CjsFlacFormat.js.map +1 -1
- package/dist/formats/flac/core/helpers.js +5 -11
- package/dist/formats/flac/core/helpers.js.map +1 -1
- package/dist/formats/fsd/32/CjsFsd32Format.js +55 -0
- package/dist/formats/fsd/32/CjsFsd32Format.js.map +1 -0
- package/dist/formats/fsd/32/index.js +2 -0
- package/dist/formats/fsd/32/index.js.map +1 -0
- package/dist/formats/fsd/64/CjsFsd64Format.js +119 -0
- package/dist/formats/fsd/64/CjsFsd64Format.js.map +1 -0
- package/dist/formats/fsd/64/core/CjsFsd64Binary.js +393 -0
- package/dist/formats/fsd/64/core/CjsFsd64Binary.js.map +1 -0
- package/dist/formats/fsd/64/core/CjsFsd64Reader.js +138 -0
- package/dist/formats/fsd/64/core/CjsFsd64Reader.js.map +1 -0
- package/dist/formats/fsd/64/core/CjsFsd64SchemaDecoder.js +389 -0
- package/dist/formats/fsd/64/core/CjsFsd64SchemaDecoder.js.map +1 -0
- package/dist/formats/fsd/64/core/CjsFsd64SchemaReader.js +43 -0
- package/dist/formats/fsd/64/core/CjsFsd64SchemaReader.js.map +1 -0
- package/dist/formats/fsd/64/core/fsd64Records.js +60 -0
- package/dist/formats/fsd/64/core/fsd64Records.js.map +1 -0
- package/dist/formats/fsd/64/index.js +7 -0
- package/dist/formats/fsd/64/index.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64ReaderSetCharacterStaticData.js +33 -0
- package/dist/formats/fsd/64/readers/CjsFsd64ReaderSetCharacterStaticData.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaAgentTypes.js +35 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaAgentTypes.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaAgentsInSpace.js +50 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaAgentsInSpace.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaAncestries.js +75 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaAncestries.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaArchetypes.js +57 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaArchetypes.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaAudioMetadata.js +201 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaAudioMetadata.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaBloodlines.js +73 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaBloodlines.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCategories.js +53 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCategories.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCharacterAvatarBehaviors.js +44 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCharacterAvatarBehaviors.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCharacterColorLocations.js +38 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCharacterColorLocations.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCharacterColorNames.js +34 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCharacterColorNames.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCharacterModifierLocations.js +34 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCharacterModifierLocations.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCharacterPortraitResources.js +44 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCharacterPortraitResources.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCharacterResources.js +81 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCharacterResources.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCharacterSculptingLocations.js +34 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCharacterSculptingLocations.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCompressibleTypes.js +41 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCompressibleTypes.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaContrabandTypes.js +63 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaContrabandTypes.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaControlTowerResources.js +76 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaControlTowerResources.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCorporationActivities.js +38 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCorporationActivities.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCorporationRoleGroups.js +74 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCorporationRoleGroups.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCorporationRoles.js +59 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaCorporationRoles.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaDogmaAttributeCategories.js +46 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaDogmaAttributeCategories.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaDogmaAttributes.js +133 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaDogmaAttributes.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaDogmaEffects.js +236 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaDogmaEffects.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaDogmaUnits.js +60 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaDogmaUnits.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaDynamicItemAttributes.js +95 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaDynamicItemAttributes.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaEpicArcs.js +106 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaEpicArcs.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaExpertSystems.js +86 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaExpertSystems.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaFactions.js +117 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaFactions.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaGraphicIds.js +70 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaGraphicIds.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaGraphicMaterialSets.js +173 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaGraphicMaterialSets.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaGroups.js +77 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaGroups.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaIcons.js +62 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaIcons.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaMarketGroups.js +63 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaMarketGroups.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaMetaGroups.js +86 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaMetaGroups.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaNpcCorporationDivisions.js +72 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaNpcCorporationDivisions.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaNpcCorporations.js +326 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaNpcCorporations.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaPaperdolls.js +279 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaPaperdolls.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaRaces.js +64 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaRaces.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSchoolMap.js +40 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSchoolMap.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSchools.js +113 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSchools.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkillPlans.js +130 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkillPlans.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrComponentCategories.js +38 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrComponentCategories.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrComponentPointValues.js +45 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrComponentPointValues.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrComponentRarities.js +44 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrComponentRarities.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrComponents.js +163 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrComponents.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrSlotCategories.js +37 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrSlotCategories.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrSlotConfigurations.js +77 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrSlotConfigurations.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrSlotNames.js +37 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrSlotNames.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrSlots.js +74 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrSlots.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrTierThresholds.js +44 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaSkinrTierThresholds.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaStationOperations.js +120 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaStationOperations.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaStationServices.js +49 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaStationServices.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaTypeDogma.js +73 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaTypeDogma.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaTypeLists.js +122 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaTypeLists.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaTypeMaterials.js +83 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaTypeMaterials.js.map +1 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaTypes.js +194 -0
- package/dist/formats/fsd/64/readers/CjsFsd64SchemaTypes.js.map +1 -0
- package/dist/formats/fsd/64/readers/index.js +58 -0
- package/dist/formats/fsd/64/readers/index.js.map +1 -0
- package/dist/formats/fsd/CjsFsdFormat.js +62 -0
- package/dist/formats/fsd/CjsFsdFormat.js.map +1 -0
- package/dist/formats/fsd/index.js +9 -0
- package/dist/formats/fsd/index.js.map +1 -0
- package/dist/formats/gif/CjsGifFormat.js +26 -16
- package/dist/formats/gif/CjsGifFormat.js.map +1 -1
- package/dist/formats/gif/core/helpers.js +6 -18
- package/dist/formats/gif/core/helpers.js.map +1 -1
- package/dist/formats/gltf/CjsGltfFormat.js +25 -13
- package/dist/formats/gltf/CjsGltfFormat.js.map +1 -1
- package/dist/formats/gr2/CjsGr2Format.js +27 -6
- package/dist/formats/gr2/CjsGr2Format.js.map +1 -1
- package/dist/formats/hlsl/CjsHlslFormat.js +20 -16
- package/dist/formats/hlsl/CjsHlslFormat.js.map +1 -1
- package/dist/formats/hlsl/core/analysis.js +1 -1
- package/dist/formats/index.js +5 -0
- package/dist/formats/index.js.map +1 -1
- package/dist/formats/jpeg/CjsJpegFormat.js +26 -19
- package/dist/formats/jpeg/CjsJpegFormat.js.map +1 -1
- package/dist/formats/jpeg/core/helpers.js +6 -15
- package/dist/formats/jpeg/core/helpers.js.map +1 -1
- package/dist/formats/jpeg/core/jpeg.js +0 -3
- package/dist/formats/jpeg/core/jpeg.js.map +1 -1
- package/dist/formats/mp3/CjsMp3Format.js +19 -19
- package/dist/formats/mp3/CjsMp3Format.js.map +1 -1
- package/dist/formats/mp3/core/helpers.js +5 -11
- package/dist/formats/mp3/core/helpers.js.map +1 -1
- package/dist/formats/mp4/CjsMp4Format.js +20 -19
- package/dist/formats/mp4/CjsMp4Format.js.map +1 -1
- package/dist/formats/mp4/core/helpers.js +6 -15
- package/dist/formats/mp4/core/helpers.js.map +1 -1
- package/dist/formats/obj/CjsObjFormat.js +25 -12
- package/dist/formats/obj/CjsObjFormat.js.map +1 -1
- package/dist/formats/ogg/CjsOggFormat.js +26 -17
- package/dist/formats/ogg/CjsOggFormat.js.map +1 -1
- package/dist/formats/ogg/core/helpers.js +5 -16
- package/dist/formats/ogg/core/helpers.js.map +1 -1
- package/dist/formats/pickle/CjsPickleFormat.js +64 -5
- package/dist/formats/pickle/CjsPickleFormat.js.map +1 -1
- package/dist/formats/png/CjsPngFormat.js +28 -19
- package/dist/formats/png/CjsPngFormat.js.map +1 -1
- package/dist/formats/png/core/helpers.js +5 -14
- package/dist/formats/png/core/helpers.js.map +1 -1
- package/dist/formats/red/CjsRedFormat.js +19 -5
- package/dist/formats/red/CjsRedFormat.js.map +1 -1
- package/dist/formats/schemabound/CjsSchemaBoundFormat.js +48 -38
- package/dist/formats/schemabound/CjsSchemaBoundFormat.js.map +1 -1
- package/dist/formats/sqlite/CjsSqliteFormat.js +49 -41
- package/dist/formats/sqlite/CjsSqliteFormat.js.map +1 -1
- package/dist/formats/static/CjsStaticFormat.js +15 -57
- package/dist/formats/static/CjsStaticFormat.js.map +1 -1
- package/dist/formats/static/staticContainers.js +6 -6
- package/dist/formats/static/staticContainers.js.map +1 -1
- package/dist/formats/stl/CjsStlFormat.js +25 -12
- package/dist/formats/stl/CjsStlFormat.js.map +1 -1
- package/dist/formats/tga/CjsTgaFormat.js +26 -19
- package/dist/formats/tga/CjsTgaFormat.js.map +1 -1
- package/dist/formats/tga/core/helpers.js +7 -22
- package/dist/formats/tga/core/helpers.js.map +1 -1
- package/dist/formats/wav/CjsWavFormat.js +26 -19
- package/dist/formats/wav/CjsWavFormat.js.map +1 -1
- package/dist/formats/wav/core/helpers.js +7 -16
- package/dist/formats/wav/core/helpers.js.map +1 -1
- package/dist/formats/webgl/CjsWebglFormat.js +11 -13
- package/dist/formats/webgl/CjsWebglFormat.js.map +1 -1
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js +90 -12
- package/dist/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
- package/dist/formats/webgl/core/helpers.js +2 -2
- package/dist/formats/webgl/core/helpers.js.map +1 -1
- package/dist/formats/webgl/core/readGlslEffectContainer.js +8 -8
- package/dist/formats/webgl/core/readGlslEffectContainer.js.map +1 -1
- package/dist/formats/webgpu/CjsWebgpuFormat.js +11 -5
- package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
- package/dist/formats/webm/CjsWebmFormat.js +20 -19
- package/dist/formats/webm/CjsWebmFormat.js.map +1 -1
- package/dist/formats/webm/core/helpers.js +6 -15
- package/dist/formats/webm/core/helpers.js.map +1 -1
- package/dist/formats/webp/CjsWebpFormat.js +19 -17
- package/dist/formats/webp/CjsWebpFormat.js.map +1 -1
- package/dist/formats/webp/core/helpers.js +5 -11
- package/dist/formats/webp/core/helpers.js.map +1 -1
- package/dist/formats/wem/CjsWemFormat.js +128 -141
- package/dist/formats/wem/CjsWemFormat.js.map +1 -1
- package/dist/formats/wem/core/helpers.js +1 -114
- package/dist/formats/wem/core/helpers.js.map +1 -1
- package/dist/formats/wem/core/{resolve.js → probeCodecSupport.js} +11 -18
- package/dist/formats/wem/core/probeCodecSupport.js.map +1 -0
- package/dist/formats/yaml/CjsYamlFormat.js +20 -5
- package/dist/formats/yaml/CjsYamlFormat.js.map +1 -1
- package/dist/generated/index.js +2 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/resources/Tr2RaycastGeometryRes.js +34 -0
- package/dist/generated/resources/Tr2RaycastGeometryRes.js.map +1 -0
- package/dist/generated/resources/index.js +2 -0
- package/dist/generated/resources/index.js.map +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/resource/CjsResource.js +134 -0
- package/dist/resource/CjsResource.js.map +1 -1
- package/dist/resource/ResourceRequirement.js +42 -0
- package/dist/resource/ResourceRequirement.js.map +1 -0
- package/dist/resource/Tr2LightProfileRes.js +2 -1
- package/dist/resource/Tr2LightProfileRes.js.map +1 -1
- package/dist/resource/geometry/TriGeometryRes.js +34 -7
- package/dist/resource/geometry/TriGeometryRes.js.map +1 -1
- package/dist/resource/geometry/granny/Tr2GrannyStateRes.js +184 -7
- package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -1
- package/dist/resource/geometry/granny/TriGrannyRes.js +20 -8
- package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -1
- package/dist/resource/index.js +1 -0
- package/dist/resource/index.js.map +1 -1
- package/dist/resource/resourceBoundary.js +24 -1
- package/dist/resource/resourceBoundary.js.map +1 -1
- package/dist/resource/shader/Tr2EffectRes.js +2 -1
- package/dist/resource/shader/Tr2EffectRes.js.map +1 -1
- package/dist/resource/texture/CjsTextureArrayRes.js +2 -1
- package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -1
- package/dist/resource/texture/Tr2ImageRes.js +2 -1
- package/dist/resource/texture/Tr2ImageRes.js.map +1 -1
- package/dist/resource/texture/TriTextureRes.js +40 -2
- package/dist/resource/texture/TriTextureRes.js.map +1 -1
- package/docs/architecture.md +121 -116
- package/docs/concepts/format-capabilities.md +90 -0
- package/docs/formats/README.md +14 -6
- package/docs/formats/fsd.md +104 -0
- package/docs/formats/gr2.md +1 -1
- package/docs/formats/hlsl/reference/api.md +6 -4
- package/docs/formats/provenance.md +18 -0
- package/docs/formats/schemabound.md +10 -4
- package/docs/formats/static.md +26 -26
- package/docs/formats/webgpu/reference/api.md +4 -3
- package/docs/reference/classes/core.md +22 -2
- package/docs/reference/classes/formats.md +643 -1
- package/docs/reference/classes/resources.md +463 -453
- package/docs/reference/queues.md +205 -194
- package/docs/roadmap.md +14 -18
- package/format-notices/fsd/LICENSE +21 -0
- package/format-notices/fsd/NOTICE +11 -0
- package/package.json +70 -64
- package/dist/formats/wem/core/resolve.js.map +0 -1
- package/docs/concepts/format-type-resolution.md +0 -79
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CjsFormat } from '../../format/CjsFormat.js';
|
|
1
2
|
import { CjsYamlFormat } from '../yaml/CjsYamlFormat.js';
|
|
2
3
|
import { ReadValue } from './core/schemaBoundValues.js';
|
|
3
4
|
import { SchemaBoundError } from './core/schemaBoundErrors.js';
|
|
@@ -30,7 +31,7 @@ const ROOT_TYPES = new Set(["dict", "list", "object"]);
|
|
|
30
31
|
* a decoder written around a constant stride will read the first record
|
|
31
32
|
* correctly and everything after it wrongly.
|
|
32
33
|
*/
|
|
33
|
-
class CjsSchemaBoundFormat {
|
|
34
|
+
class CjsSchemaBoundFormat extends CjsFormat {
|
|
34
35
|
/**
|
|
35
36
|
* Reports whether a schema can drive this reader.
|
|
36
37
|
*
|
|
@@ -42,9 +43,9 @@ class CjsSchemaBoundFormat {
|
|
|
42
43
|
* @param {object|Uint8Array|ArrayBuffer|string} schema Schema document or its bytes.
|
|
43
44
|
* @returns {boolean} True when the schema has a root this reader understands.
|
|
44
45
|
*/
|
|
45
|
-
static is(
|
|
46
|
+
static is(input, options = null) {
|
|
46
47
|
try {
|
|
47
|
-
return ROOT_TYPES.has(this.schema(schema).type);
|
|
48
|
+
return ROOT_TYPES.has(this.schema(options?.schema ?? input).type);
|
|
48
49
|
} catch {
|
|
49
50
|
return false;
|
|
50
51
|
}
|
|
@@ -57,13 +58,41 @@ class CjsSchemaBoundFormat {
|
|
|
57
58
|
* @param {object} [options] Probe options.
|
|
58
59
|
* @returns {object} Resource probe.
|
|
59
60
|
*/
|
|
60
|
-
static
|
|
61
|
-
|
|
61
|
+
static probeSupport(input, options = null) {
|
|
62
|
+
const usable = this.is(input, options);
|
|
63
|
+
return {
|
|
64
|
+
format: this.id,
|
|
65
|
+
source: options?.source || "buffer",
|
|
66
|
+
recognized: usable,
|
|
67
|
+
supported: usable,
|
|
68
|
+
preferredOutput: usable ? OUTPUT_JSON : "",
|
|
69
|
+
reason: usable ? "The supplied schema declares a root this reader can decode." : "A readable companion schema was not supplied.",
|
|
70
|
+
variants: [{
|
|
71
|
+
kind: OUTPUT_JSON,
|
|
72
|
+
supported: usable
|
|
73
|
+
}, {
|
|
74
|
+
kind: OUTPUT_PAYLOAD,
|
|
75
|
+
supported: usable
|
|
76
|
+
}],
|
|
77
|
+
metadata: usable ? this.inspect(input, options) : {
|
|
78
|
+
family: this.id,
|
|
79
|
+
requiresSchema: true,
|
|
80
|
+
decodable: false
|
|
81
|
+
}
|
|
82
|
+
};
|
|
62
83
|
}
|
|
63
84
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
85
|
+
/** Return schema and payload facts without decoding the payload. */
|
|
86
|
+
static inspect(input, options = null) {
|
|
87
|
+
const schema = this.schema(options?.schema ?? input);
|
|
88
|
+
return {
|
|
89
|
+
family: this.id,
|
|
90
|
+
rootType: schema.type,
|
|
91
|
+
requiresSchema: true,
|
|
92
|
+
decodable: ROOT_TYPES.has(schema.type),
|
|
93
|
+
byteLength: options?.schema === undefined ? null : Normalize(input).byteLength
|
|
94
|
+
};
|
|
95
|
+
}
|
|
67
96
|
|
|
68
97
|
/**
|
|
69
98
|
* Reads a container against its schema.
|
|
@@ -101,7 +130,8 @@ class CjsSchemaBoundFormat {
|
|
|
101
130
|
view: new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)
|
|
102
131
|
};
|
|
103
132
|
const decoded = ReadValue(context, 0, schema).value;
|
|
104
|
-
|
|
133
|
+
const output = options.emit ?? options.output ?? OUTPUT_JSON;
|
|
134
|
+
return output === OUTPUT_PAYLOAD ? decoded : ToJSON(decoded);
|
|
105
135
|
}
|
|
106
136
|
|
|
107
137
|
/** Reads to plain JSON-compatible values. */
|
|
@@ -145,10 +175,16 @@ class CjsSchemaBoundFormat {
|
|
|
145
175
|
});
|
|
146
176
|
static id = "schemabound";
|
|
147
177
|
static extensions = Object.freeze([".static"]);
|
|
148
|
-
static type = Object.freeze(["data"]);
|
|
149
178
|
static mediaTypes = Object.freeze(["data"]);
|
|
150
|
-
static
|
|
151
|
-
|
|
179
|
+
static outputs = CjsFormat.defineOutputs({
|
|
180
|
+
json: {
|
|
181
|
+
default: true,
|
|
182
|
+
decoded: true
|
|
183
|
+
},
|
|
184
|
+
payload: {
|
|
185
|
+
decoded: true
|
|
186
|
+
}
|
|
187
|
+
});
|
|
152
188
|
}
|
|
153
189
|
|
|
154
190
|
/**
|
|
@@ -186,32 +222,6 @@ function Resolve(value) {
|
|
|
186
222
|
return walk(value);
|
|
187
223
|
}
|
|
188
224
|
|
|
189
|
-
/** Builds the probe shape the resource manager routes on. */
|
|
190
|
-
function Probe(usable, options) {
|
|
191
|
-
return {
|
|
192
|
-
format: "schemabound",
|
|
193
|
-
source: "buffer",
|
|
194
|
-
supported: usable ? "full" : "none",
|
|
195
|
-
confidence: usable ? 1 : 0,
|
|
196
|
-
preferred: "schemabound",
|
|
197
|
-
// The schema is read to answer this, so it is measured rather than declared.
|
|
198
|
-
// It says nothing about any payload: these containers carry no signature.
|
|
199
|
-
verified: true,
|
|
200
|
-
reason: usable ? "The schema declares a root this reader can decode." : "The schema is missing, unparsable, or declares an unreadable root.",
|
|
201
|
-
variants: [{
|
|
202
|
-
kind: "container",
|
|
203
|
-
codec: "schemabound",
|
|
204
|
-
supported: usable
|
|
205
|
-
}],
|
|
206
|
-
metadata: {
|
|
207
|
-
family: "schemabound",
|
|
208
|
-
requiresSchema: true,
|
|
209
|
-
decodable: usable
|
|
210
|
-
},
|
|
211
|
-
...(options || {})
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
|
|
215
225
|
/** Converts decoded values to something `JSON.stringify` keeps losslessly. */
|
|
216
226
|
function ToJSON(value) {
|
|
217
227
|
if (typeof value === "bigint") return value.toString(10);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CjsSchemaBoundFormat.js","sources":["../../../../src/formats/schemabound/CjsSchemaBoundFormat.js"],"sourcesContent":["import { CjsYamlFormat } from \"../yaml/index.js\";\nimport { ReadValue } from \"./core/schemaBoundValues.js\";\nimport { SchemaBoundError } from \"./core/schemaBoundErrors.js\";\n\nconst OUTPUT_JSON = \"json\";\nconst OUTPUT_PAYLOAD = \"payload\";\nconst ROOT_TYPES = new Set([ \"dict\", \"list\", \"object\" ]);\n\n/**\n * Reads a container whose layout lives in a separate schema.\n *\n * This is the third of the three families that share the `.static` extension,\n * and the one an extension check is least able to help with: the bytes carry no\n * signature, no version and no self-description. What they carry is a payload\n * whose every field position, width and meaning is stated in a sibling `.schema`\n * document — so the schema is not a hint here, it is the reader.\n *\n * That makes this the opposite of the hash-identified containers, where the\n * header names a layout it does not describe and the layout has to be derived\n * and pinned per dataset. Nothing needs deriving for this family. Supply the\n * schema and the bytes decode.\n *\n * **The schema is required and there is no default.** Given the wrong schema\n * these bytes decode into plausible nonsense rather than failing, because there\n * is nothing in them to disagree with. Pair each payload with the `.schema`\n * that shipped beside it.\n *\n * Read {@link CjsSchemaBoundFormat.read} before writing anything that walks the\n * result: a record's variable section changes length from record to record, and\n * a decoder written around a constant stride will read the first record\n * correctly and everything after it wrongly.\n */\nexport class CjsSchemaBoundFormat {\n\n /**\n * Reports whether a schema can drive this reader.\n *\n * The question is about the schema, never the payload. These containers have\n * no signature to test, so claiming to recognize the bytes would be a claim\n * this format cannot support - and `CjsStaticFormat` already answers which\n * family a `.static` file belongs to.\n *\n * @param {object|Uint8Array|ArrayBuffer|string} schema Schema document or its bytes.\n * @returns {boolean} True when the schema has a root this reader understands.\n */\n static is(schema) {\n try {\n return ROOT_TYPES.has(this.schema(schema).type);\n } catch {\n return false;\n }\n }\n\n /**\n * Reports whether this format can read a payload described by a schema.\n *\n * @param {object|Uint8Array|ArrayBuffer|string} schema Schema document or its bytes.\n * @param {object} [options] Probe options.\n * @returns {object} Resource probe.\n */\n static isSupported(schema, options = null) {\n return Probe(this.is(schema), options);\n }\n\n // INTERIM, 2026-08-16. No `inspect` alias, matching CjsSqliteFormat and\n // diverging from the older formats. Both are held by the same undecided\n // question; see maintenance/INTERIM-sqlite-and-static-2026-08-16.md.\n\n /**\n * Reads a container against its schema.\n *\n * The whole payload decodes in one pass. Three properties are worth knowing\n * before relying on the result:\n *\n * - **A keyed container's index is at the end.** Nothing at the front points\n * at it; it is found by reading the last four bytes as the index's own size.\n * - **Record offsets are relative to the four-byte header**, not to the file.\n * Decoding from the file start reads one field early, which looks like a\n * wrong layout rather than a wrong base.\n * - **The per-record offset table varies in length.** An optional attribute\n * that is absent occupies no slot, so consecutive records hold their\n * variable data at different distances from their own start.\n *\n * An absent optional takes the default its schema declares. Where none is\n * declared the attribute is left off the record entirely, which is what the\n * published static data exports show for those same rows.\n *\n * @param {Uint8Array|ArrayBuffer} input Container bytes.\n * @param {object} options Read options.\n * @param {object|Uint8Array|ArrayBuffer|string} options.schema The sibling schema.\n * @param {string} [options.output] `json` or `payload`.\n * @returns {object|Array} The decoded container.\n */\n static read(input, options = {}) {\n const bytes = Normalize(input);\n const schema = this.schema(options.schema);\n\n if (!ROOT_TYPES.has(schema.type)) {\n throw SchemaBoundError(`A container's root must be a dict, list or object, not ${schema.type}.`);\n }\n\n const context = {\n bytes,\n view: new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)\n };\n const decoded = ReadValue(context, 0, schema).value;\n\n return options.output === OUTPUT_PAYLOAD ? decoded : ToJSON(decoded);\n }\n\n /** Reads to plain JSON-compatible values. */\n static readJSON(input, options = {}) {\n return this.read(input, { ...options, output: OUTPUT_JSON });\n }\n\n /** Reads with wide integers left as `BigInt`. */\n static readPayload(input, options = {}) {\n return this.read(input, { ...options, output: OUTPUT_PAYLOAD });\n }\n\n /**\n * Parses a schema document, accepting YAML bytes, YAML text or a parsed object.\n *\n * @param {object|Uint8Array|ArrayBuffer|string} schema Schema in any accepted form.\n * @returns {object} The parsed schema.\n */\n static schema(schema) {\n if (!schema) {\n throw SchemaBoundError(\"This format cannot read a container without its schema.\");\n }\n\n if (typeof schema === \"object\" && !ArrayBuffer.isView(schema) && !(schema instanceof ArrayBuffer)) {\n return schema;\n }\n\n const parsed = CjsYamlFormat.read(typeof schema === \"string\" ? schema : Normalize(schema));\n\n if (!parsed || typeof parsed !== \"object\") {\n throw SchemaBoundError(\"A schema must parse to a mapping.\");\n }\n\n return Resolve(parsed);\n }\n\n static Output = Object.freeze({ JSON: OUTPUT_JSON, PAYLOAD: OUTPUT_PAYLOAD });\n\n static id = \"schemabound\";\n static extensions = Object.freeze([ \".static\" ]);\n static type = Object.freeze([ \"data\" ]);\n static mediaTypes = Object.freeze([ \"data\" ]);\n static inputTypes = Object.freeze([ \"schemabound\" ]);\n static outputTypes = Object.freeze([ OUTPUT_JSON, OUTPUT_PAYLOAD ]);\n}\n\n/**\n * Rejoins YAML anchors and aliases into the graph they describe.\n *\n * These schemas share repeated declarations by anchor - a container with two\n * coordinates writes the vector's component aliases once - and the YAML reader\n * reports that sharing as `$yamlId` and `$yamlRef` markers rather than\n * duplicating the node. Left alone, `$yamlId` reads as one more component and\n * `$yamlRef` as a declaration with no fields at all.\n *\n * @param {*} value Parsed schema, or any part of one.\n * @returns {*} The same schema with anchors resolved and markers removed.\n */\nfunction Resolve(value) {\n const anchors = new Map();\n\n const walk = node => {\n if (Array.isArray(node)) return node.map(walk);\n\n if (!node || typeof node !== \"object\") return node;\n\n if (Object.hasOwn(node, \"$yamlRef\")) {\n const target = anchors.get(node.$yamlRef);\n\n if (!target) {\n throw SchemaBoundError(`The schema refers to an anchor it never declares: ${node.$yamlRef}.`);\n }\n\n return target;\n }\n\n const result = {};\n const id = node.$yamlId;\n\n if (id !== undefined) anchors.set(id, result);\n\n for (const [ key, member ] of Object.entries(node)) {\n if (key !== \"$yamlId\") result[key] = walk(member);\n }\n\n return result;\n };\n\n return walk(value);\n}\n\n/** Builds the probe shape the resource manager routes on. */\nfunction Probe(usable, options) {\n return {\n format: \"schemabound\",\n source: \"buffer\",\n supported: usable ? \"full\" : \"none\",\n confidence: usable ? 1 : 0,\n preferred: \"schemabound\",\n // The schema is read to answer this, so it is measured rather than declared.\n // It says nothing about any payload: these containers carry no signature.\n verified: true,\n reason: usable\n ? \"The schema declares a root this reader can decode.\"\n : \"The schema is missing, unparsable, or declares an unreadable root.\",\n variants: [ { kind: \"container\", codec: \"schemabound\", supported: usable } ],\n metadata: { family: \"schemabound\", requiresSchema: true, decodable: usable },\n ...(options || {})\n };\n}\n\n/** Converts decoded values to something `JSON.stringify` keeps losslessly. */\nfunction ToJSON(value) {\n if (typeof value === \"bigint\") return value.toString(10);\n\n if (Array.isArray(value)) return value.map(ToJSON);\n\n if (value && typeof value === \"object\") {\n const result = {};\n\n for (const [ key, member ] of Object.entries(value)) result[key] = ToJSON(member);\n\n return result;\n }\n\n return value;\n}\n\n/** Accepts the byte forms every other format here accepts. */\nfunction Normalize(input) {\n if (input instanceof Uint8Array) return input;\n\n if (input instanceof ArrayBuffer) return new Uint8Array(input);\n\n if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n\n throw SchemaBoundError(\"A schema-bound container must be supplied as bytes.\");\n}\n\nexport default CjsSchemaBoundFormat;\n"],"names":["OUTPUT_JSON","OUTPUT_PAYLOAD","ROOT_TYPES","Set","CjsSchemaBoundFormat","is","schema","has","type","isSupported","options","Probe","read","input","bytes","Normalize","SchemaBoundError","context","view","DataView","buffer","byteOffset","byteLength","decoded","ReadValue","value","output","ToJSON","readJSON","readPayload","ArrayBuffer","isView","parsed","CjsYamlFormat","Resolve","Output","Object","freeze","JSON","PAYLOAD","id","extensions","mediaTypes","inputTypes","outputTypes","anchors","Map","walk","node","Array","isArray","map","hasOwn","target","get","$yamlRef","result","$yamlId","undefined","set","key","member","entries","usable","format","source","supported","confidence","preferred","verified","reason","variants","kind","codec","metadata","family","requiresSchema","decodable","toString","Uint8Array"],"mappings":";;;;AAIA,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,CAAC;AAEhC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOC,EAAEA,CAACC,MAAM,EAAE;IAChB,IAAI;AACF,MAAA,OAAOJ,UAAU,CAACK,GAAG,CAAC,IAAI,CAACD,MAAM,CAACA,MAAM,CAAC,CAACE,IAAI,CAAC;AACjD,IAAA,CAAC,CAAC,MAAM;AACN,MAAA,OAAO,KAAK;AACd,IAAA;AACF,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOC,WAAWA,CAACH,MAAM,EAAEI,OAAO,GAAG,IAAI,EAAE;IACzC,OAAOC,KAAK,CAAC,IAAI,CAACN,EAAE,CAACC,MAAM,CAAC,EAAEI,OAAO,CAAC;AACxC,EAAA;;AAEA;AACA;AACA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;A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A,CAACF,KAAK,EAAE;AACxB,EAAA,IAAIA,KAAK,YAAYkE,UAAU,EAAE,OAAOlE,KAAK;EAE7C,IAAIA,KAAK,YAAYiB,WAAW,EAAE,OAAO,IAAIiD,UAAU,CAAClE,KAAK,CAAC;EAE9D,IAAIiB,WAAW,CAACC,MAAM,CAAClB,KAAK,CAAC,EAAE,OAAO,IAAIkE,UAAU,CAAClE,KAAK,CAACO,MAAM,EAAEP,KAAK,CAACQ,UAAU,EAAER,KAAK,CAACS,UAAU,CAAC;EAEtG,MAAMN,gBAAgB,CAAC,qDAAqD,CAAC;AAC/E;;;;"}
|
|
1
|
+
{"version":3,"file":"CjsSchemaBoundFormat.js","sources":["../../../../src/formats/schemabound/CjsSchemaBoundFormat.js"],"sourcesContent":["import { CjsFormat } from \"../../format/CjsFormat.js\";\nimport { CjsYamlFormat } from \"../yaml/index.js\";\nimport { ReadValue } from \"./core/schemaBoundValues.js\";\nimport { SchemaBoundError } from \"./core/schemaBoundErrors.js\";\n\nconst OUTPUT_JSON = \"json\";\nconst OUTPUT_PAYLOAD = \"payload\";\nconst ROOT_TYPES = new Set([ \"dict\", \"list\", \"object\" ]);\n\n/**\n * Reads a container whose layout lives in a separate schema.\n *\n * This is the third of the three families that share the `.static` extension,\n * and the one an extension check is least able to help with: the bytes carry no\n * signature, no version and no self-description. What they carry is a payload\n * whose every field position, width and meaning is stated in a sibling `.schema`\n * document — so the schema is not a hint here, it is the reader.\n *\n * That makes this the opposite of the hash-identified containers, where the\n * header names a layout it does not describe and the layout has to be derived\n * and pinned per dataset. Nothing needs deriving for this family. Supply the\n * schema and the bytes decode.\n *\n * **The schema is required and there is no default.** Given the wrong schema\n * these bytes decode into plausible nonsense rather than failing, because there\n * is nothing in them to disagree with. Pair each payload with the `.schema`\n * that shipped beside it.\n *\n * Read {@link CjsSchemaBoundFormat.read} before writing anything that walks the\n * result: a record's variable section changes length from record to record, and\n * a decoder written around a constant stride will read the first record\n * correctly and everything after it wrongly.\n */\nexport class CjsSchemaBoundFormat extends CjsFormat {\n\n /**\n * Reports whether a schema can drive this reader.\n *\n * The question is about the schema, never the payload. These containers have\n * no signature to test, so claiming to recognize the bytes would be a claim\n * this format cannot support - and `CjsStaticFormat` already answers which\n * family a `.static` file belongs to.\n *\n * @param {object|Uint8Array|ArrayBuffer|string} schema Schema document or its bytes.\n * @returns {boolean} True when the schema has a root this reader understands.\n */\n static is(input, options = null) {\n try {\n return ROOT_TYPES.has(this.schema(options?.schema ?? input).type);\n } catch {\n return false;\n }\n }\n\n /**\n * Reports whether this format can read a payload described by a schema.\n *\n * @param {object|Uint8Array|ArrayBuffer|string} schema Schema document or its bytes.\n * @param {object} [options] Probe options.\n * @returns {object} Resource probe.\n */\n static probeSupport(input, options = null) {\n const usable = this.is(input, options);\n return {\n format: this.id,\n source: options?.source || \"buffer\",\n recognized: usable,\n supported: usable,\n preferredOutput: usable ? OUTPUT_JSON : \"\",\n reason: usable\n ? \"The supplied schema declares a root this reader can decode.\"\n : \"A readable companion schema was not supplied.\",\n variants: [\n { kind: OUTPUT_JSON, supported: usable },\n { kind: OUTPUT_PAYLOAD, supported: usable }\n ],\n metadata: usable ? this.inspect(input, options) : {\n family: this.id,\n requiresSchema: true,\n decodable: false\n }\n };\n }\n\n /** Return schema and payload facts without decoding the payload. */\n static inspect(input, options = null) {\n const schema = this.schema(options?.schema ?? input);\n return {\n family: this.id,\n rootType: schema.type,\n requiresSchema: true,\n decodable: ROOT_TYPES.has(schema.type),\n byteLength: options?.schema === undefined ? null : Normalize(input).byteLength\n };\n }\n\n /**\n * Reads a container against its schema.\n *\n * The whole payload decodes in one pass. Three properties are worth knowing\n * before relying on the result:\n *\n * - **A keyed container's index is at the end.** Nothing at the front points\n * at it; it is found by reading the last four bytes as the index's own size.\n * - **Record offsets are relative to the four-byte header**, not to the file.\n * Decoding from the file start reads one field early, which looks like a\n * wrong layout rather than a wrong base.\n * - **The per-record offset table varies in length.** An optional attribute\n * that is absent occupies no slot, so consecutive records hold their\n * variable data at different distances from their own start.\n *\n * An absent optional takes the default its schema declares. Where none is\n * declared the attribute is left off the record entirely, which is what the\n * published static data exports show for those same rows.\n *\n * @param {Uint8Array|ArrayBuffer} input Container bytes.\n * @param {object} options Read options.\n * @param {object|Uint8Array|ArrayBuffer|string} options.schema The sibling schema.\n * @param {string} [options.output] `json` or `payload`.\n * @returns {object|Array} The decoded container.\n */\n static read(input, options = {}) {\n const bytes = Normalize(input);\n const schema = this.schema(options.schema);\n\n if (!ROOT_TYPES.has(schema.type)) {\n throw SchemaBoundError(`A container's root must be a dict, list or object, not ${schema.type}.`);\n }\n\n const context = {\n bytes,\n view: new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)\n };\n const decoded = ReadValue(context, 0, schema).value;\n\n const output = options.emit ?? options.output ?? OUTPUT_JSON;\n return output === OUTPUT_PAYLOAD ? decoded : ToJSON(decoded);\n }\n\n /** Reads to plain JSON-compatible values. */\n static readJSON(input, options = {}) {\n return this.read(input, { ...options, output: OUTPUT_JSON });\n }\n\n /** Reads with wide integers left as `BigInt`. */\n static readPayload(input, options = {}) {\n return this.read(input, { ...options, output: OUTPUT_PAYLOAD });\n }\n\n /**\n * Parses a schema document, accepting YAML bytes, YAML text or a parsed object.\n *\n * @param {object|Uint8Array|ArrayBuffer|string} schema Schema in any accepted form.\n * @returns {object} The parsed schema.\n */\n static schema(schema) {\n if (!schema) {\n throw SchemaBoundError(\"This format cannot read a container without its schema.\");\n }\n\n if (typeof schema === \"object\" && !ArrayBuffer.isView(schema) && !(schema instanceof ArrayBuffer)) {\n return schema;\n }\n\n const parsed = CjsYamlFormat.read(typeof schema === \"string\" ? schema : Normalize(schema));\n\n if (!parsed || typeof parsed !== \"object\") {\n throw SchemaBoundError(\"A schema must parse to a mapping.\");\n }\n\n return Resolve(parsed);\n }\n\n static Output = Object.freeze({ JSON: OUTPUT_JSON, PAYLOAD: OUTPUT_PAYLOAD });\n\n static id = \"schemabound\";\n static extensions = Object.freeze([ \".static\" ]);\n static mediaTypes = Object.freeze([ \"data\" ]);\n static outputs = CjsFormat.defineOutputs({\n json: { default: true, decoded: true },\n payload: { decoded: true }\n });\n}\n\n/**\n * Rejoins YAML anchors and aliases into the graph they describe.\n *\n * These schemas share repeated declarations by anchor - a container with two\n * coordinates writes the vector's component aliases once - and the YAML reader\n * reports that sharing as `$yamlId` and `$yamlRef` markers rather than\n * duplicating the node. Left alone, `$yamlId` reads as one more component and\n * `$yamlRef` as a declaration with no fields at all.\n *\n * @param {*} value Parsed schema, or any part of one.\n * @returns {*} The same schema with anchors resolved and markers removed.\n */\nfunction Resolve(value) {\n const anchors = new Map();\n\n const walk = node => {\n if (Array.isArray(node)) return node.map(walk);\n\n if (!node || typeof node !== \"object\") return node;\n\n if (Object.hasOwn(node, \"$yamlRef\")) {\n const target = anchors.get(node.$yamlRef);\n\n if (!target) {\n throw SchemaBoundError(`The schema refers to an anchor it never declares: ${node.$yamlRef}.`);\n }\n\n return target;\n }\n\n const result = {};\n const id = node.$yamlId;\n\n if (id !== undefined) anchors.set(id, result);\n\n for (const [ key, member ] of Object.entries(node)) {\n if (key !== \"$yamlId\") result[key] = walk(member);\n }\n\n return result;\n };\n\n return walk(value);\n}\n\n/** Converts decoded values to something `JSON.stringify` keeps losslessly. */\nfunction ToJSON(value) {\n if (typeof value === \"bigint\") return value.toString(10);\n\n if (Array.isArray(value)) return value.map(ToJSON);\n\n if (value && typeof value === \"object\") {\n const result = {};\n\n for (const [ key, member ] of Object.entries(value)) result[key] = ToJSON(member);\n\n return result;\n }\n\n return value;\n}\n\n/** Accepts the byte forms every other format here accepts. */\nfunction Normalize(input) {\n if (input instanceof Uint8Array) return input;\n\n if (input instanceof ArrayBuffer) return new Uint8Array(input);\n\n if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n\n throw SchemaBoundError(\"A schema-bound container must be supplied as bytes.\");\n}\n\nexport default CjsSchemaBoundFormat;\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,EAAA,OAAOC,EAAEA,CAACC,KAAK,EAAEC,OAAO,GAAG,IAAI,EAAE;IAC/B,IAAI;AACF,MAAA,OAAON,UAAU,CAACO,GAAG,CAAC,IAAI,CAACC,MAAM,CAACF,OAAO,EAAEE,MAAM,IAAIH,KAAK,CAAC,CAACI,IAAI,CAAC;AACnE,IAAA,CAAC,CAAC,MAAM;AACN,MAAA,OAAO,KAAK;AACd,IAAA;AACF,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOC,YAAYA,CAACL,KAAK,EAAEC,OAAO,GAAG,IAAI,EAAE;IACzC,MAAMK,MAAM,GAAG,IAAI,CAACP,EAAE,CAACC,KAAK,EA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AAK,CAAC;AACpB;;AAEA;AACA,SAASG,MAAMA,CAACH,KAAK,EAAE;EACrB,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE,OAAOA,KAAK,CAACwC,QAAQ,CAAC,EAAE,CAAC;AAExD,EAAA,IAAIb,KAAK,CAACC,OAAO,CAAC5B,KAAK,CAAC,EAAE,OAAOA,KAAK,CAAC6B,GAAG,CAAC1B,MAAM,CAAC;AAElD,EAAA,IAAIH,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACtC,MAAMkC,MAAM,GAAG,EAAE;IAEjB,KAAK,MAAM,CAAEG,GAAG,EAAEC,MAAM,CAAE,IAAI1B,MAAM,CAAC2B,OAAO,CAACvC,KAAK,CAAC,EAAEkC,MAAM,CAACG,GAAG,CAAC,GAAGlC,MAAM,CAACmC,MAAM,CAAC;AAEjF,IAAA,OAAOJ,MAAM;AACf,EAAA;AAEA,EAAA,OAAOlC,KAAK;AACd;;AAEA;AACA,SAASX,SAASA,CAACxB,KAAK,EAAE;AACxB,EAAA,IAAIA,KAAK,YAAY4E,UAAU,EAAE,OAAO5E,KAAK;EAE7C,IAAIA,KAAK,YAAYyC,WAAW,EAAE,OAAO,IAAImC,UAAU,CAAC5E,KAAK,CAAC;EAE9D,IAAIyC,WAAW,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,6 +1,7 @@
|
|
|
1
|
+
import { CjsFormat } from '../../format/CjsFormat.js';
|
|
1
2
|
import { ReadColumns } from './core/sqliteSchema.js';
|
|
2
3
|
import { ReadHeader, TableRows } from './core/sqlitePages.js';
|
|
3
|
-
import {
|
|
4
|
+
import { ReadRecord, SqliteError } from './core/sqliteRecords.js';
|
|
4
5
|
|
|
5
6
|
const OUTPUT_JSON = "json";
|
|
6
7
|
const OUTPUT_PAYLOAD = "payload";
|
|
@@ -31,7 +32,7 @@ const MASTER_ROOT_PAGE = 1;
|
|
|
31
32
|
* than `Number.MAX_SAFE_INTEGER` is returned as a `BigInt` rather than silently
|
|
32
33
|
* rounded.
|
|
33
34
|
*/
|
|
34
|
-
class CjsSqliteFormat {
|
|
35
|
+
class CjsSqliteFormat extends CjsFormat {
|
|
35
36
|
/**
|
|
36
37
|
* Reports whether bytes are a SQLite container, by signature.
|
|
37
38
|
*
|
|
@@ -59,18 +60,41 @@ class CjsSqliteFormat {
|
|
|
59
60
|
* @param {object} [options] Probe options.
|
|
60
61
|
* @returns {object} Resource probe.
|
|
61
62
|
*/
|
|
62
|
-
static
|
|
63
|
-
|
|
63
|
+
static probeSupport(input, options = null) {
|
|
64
|
+
const recognized = this.is(input);
|
|
65
|
+
return {
|
|
66
|
+
format: this.id,
|
|
67
|
+
source: options?.source || "buffer",
|
|
68
|
+
recognized,
|
|
69
|
+
supported: recognized,
|
|
70
|
+
preferredOutput: recognized ? OUTPUT_JSON : "",
|
|
71
|
+
reason: recognized ? "Recognized a SQLite 3 container." : "The header signature is not SQLite 3.",
|
|
72
|
+
variants: [{
|
|
73
|
+
kind: OUTPUT_JSON,
|
|
74
|
+
supported: recognized
|
|
75
|
+
}, {
|
|
76
|
+
kind: OUTPUT_PAYLOAD,
|
|
77
|
+
supported: recognized
|
|
78
|
+
}, {
|
|
79
|
+
kind: OUTPUT_RAW,
|
|
80
|
+
supported: recognized
|
|
81
|
+
}],
|
|
82
|
+
metadata: recognized ? this.inspect(input) : {
|
|
83
|
+
family: this.id,
|
|
84
|
+
decodable: false
|
|
85
|
+
}
|
|
86
|
+
};
|
|
64
87
|
}
|
|
65
88
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
89
|
+
/** Return header facts without reading table rows. */
|
|
90
|
+
static inspect(input) {
|
|
91
|
+
const header = ReadHeader(Normalize(input));
|
|
92
|
+
return {
|
|
93
|
+
family: this.id,
|
|
94
|
+
decodable: true,
|
|
95
|
+
header
|
|
96
|
+
};
|
|
97
|
+
}
|
|
74
98
|
|
|
75
99
|
/**
|
|
76
100
|
* Reads every table and row.
|
|
@@ -82,7 +106,7 @@ class CjsSqliteFormat {
|
|
|
82
106
|
* @returns {object} Tables keyed by name, each an array of row objects.
|
|
83
107
|
*/
|
|
84
108
|
static read(input, options = {}) {
|
|
85
|
-
const output = options.output ?? OUTPUT_JSON;
|
|
109
|
+
const output = options.emit ?? options.output ?? OUTPUT_JSON;
|
|
86
110
|
const bytes = Normalize(input);
|
|
87
111
|
const header = ReadHeader(bytes);
|
|
88
112
|
const schema = ReadMaster(bytes, header);
|
|
@@ -146,36 +170,20 @@ class CjsSqliteFormat {
|
|
|
146
170
|
});
|
|
147
171
|
static id = "sqlite";
|
|
148
172
|
static extensions = Object.freeze([".sqlite", ".db", ".sqlite3"]);
|
|
149
|
-
static type = Object.freeze(["data"]);
|
|
150
173
|
static mediaTypes = Object.freeze(["data"]);
|
|
151
|
-
static
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
/** Builds the probe shape the resource manager routes on. */
|
|
157
|
-
function Probe(recognized, options) {
|
|
158
|
-
return {
|
|
159
|
-
format: "sqlite",
|
|
160
|
-
source: "buffer",
|
|
161
|
-
supported: recognized ? "full" : "none",
|
|
162
|
-
confidence: 1,
|
|
163
|
-
preferred: "sqlite",
|
|
164
|
-
// The header signature is content, not a declaration, so a match is
|
|
165
|
-
// evidence rather than a claim to be checked later.
|
|
166
|
-
verified: true,
|
|
167
|
-
reason: recognized ? "Recognized a SQLite 3 container." : "The header signature is not SQLite 3.",
|
|
168
|
-
variants: [{
|
|
169
|
-
kind: "container",
|
|
170
|
-
codec: "sqlite",
|
|
171
|
-
supported: recognized
|
|
172
|
-
}],
|
|
173
|
-
metadata: {
|
|
174
|
-
family: "sqlite",
|
|
175
|
-
decodable: recognized
|
|
174
|
+
static outputs = CjsFormat.defineOutputs({
|
|
175
|
+
json: {
|
|
176
|
+
default: true,
|
|
177
|
+
decoded: true
|
|
176
178
|
},
|
|
177
|
-
|
|
178
|
-
|
|
179
|
+
payload: {
|
|
180
|
+
decoded: true
|
|
181
|
+
},
|
|
182
|
+
raw: {
|
|
183
|
+
role: "debug",
|
|
184
|
+
decoded: true
|
|
185
|
+
}
|
|
186
|
+
});
|
|
179
187
|
}
|
|
180
188
|
|
|
181
189
|
/** Reads `sqlite_master`, which is always the table b-tree rooted at page 1. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CjsSqliteFormat.js","sources":["../../../../src/formats/sqlite/CjsSqliteFormat.js"],"sourcesContent":["import { ReadColumns } from \"./core/sqliteSchema.js\";\nimport { ReadHeader, TableRows } from \"./core/sqlitePages.js\";\nimport { ReadRecord, SqliteError } from \"./core/sqliteRecords.js\";\n\nconst OUTPUT_JSON = \"json\";\nconst OUTPUT_PAYLOAD = \"payload\";\nconst OUTPUT_RAW = \"raw\";\nconst MASTER_ROOT_PAGE = 1;\n\n/**\n * Reads a SQLite 3 container as data.\n *\n * **This is a reader, not a database.** It accepts no SQL and runs no queries.\n * It returns the tables a container holds and every row of them, because that\n * is the whole of what this organization does with a SQLite file: the client's\n * `.static` containers and the prepared static data export are both opened,\n * scanned once, and closed.\n *\n * That scope is what makes it small. A query planner, an index walker, writing,\n * journalling and transactions are most of SQLite and none of this, so none of\n * them are here. Index b-tree pages are never visited: an index holds no data a\n * table scan does not already produce.\n *\n * It exists because `runtime-resource` is browser-safe and ships no SQLite\n * engine, so `.static` containers of the SQLite family previously needed a\n * driver injected by the caller — which meant Node, and in practice the\n * experimental `node:sqlite`. Nothing here touches a filesystem or a binding.\n *\n * Values map as the format defines them: NULL, integers, doubles, text decoded\n * with the database's own encoding, and blobs as `Uint8Array`. An integer wider\n * than `Number.MAX_SAFE_INTEGER` is returned as a `BigInt` rather than silently\n * rounded.\n */\nexport class CjsSqliteFormat {\n\n /**\n * Reports whether bytes are a SQLite container, by signature.\n *\n * @param {Uint8Array|ArrayBuffer} input Candidate bytes.\n * @returns {boolean} True when the header signature matches.\n */\n static is(input) {\n try {\n ReadHeader(Normalize(input));\n\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Reports whether these bytes are a SQLite container, on the signature.\n *\n * The signature is the whole claim: the header either says\n * `SQLite format 3` or it does not, so this is verified by content rather\n * than inferred from a name — which matters because `.static` carries three\n * unrelated families and the extension proves nothing.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @param {object} [options] Probe options.\n * @returns {object} Resource probe.\n */\n static isSupported(input, options = null) {\n return Probe(this.is(input), options);\n }\n\n // INTERIM, 2026-08-16. No `inspect` alias onto `isSupported`, while nineteen\n // sibling formats have one. The capability-surface decision page names that\n // alias as the confusion it wants removed, but its own \"What is not proposed\"\n // says not to change things on its strength alone - so this is a divergence\n // awaiting a decision, not a settled position.\n //\n // See maintenance/INTERIM-sqlite-and-static-2026-08-16.md before resolving it,\n // and search for callers of `inspect` on any format first.\n\n /**\n * Reads every table and row.\n *\n * @param {Uint8Array|ArrayBuffer} input Container bytes.\n * @param {object} [options] Read options.\n * @param {string} [options.output] `json`, `payload` or `raw`.\n * @param {string[]} [options.tables] Read only these tables.\n * @returns {object} Tables keyed by name, each an array of row objects.\n */\n static read(input, options = {}) {\n const output = options.output ?? OUTPUT_JSON;\n const bytes = Normalize(input);\n const header = ReadHeader(bytes);\n const schema = ReadMaster(bytes, header);\n\n if (output === OUTPUT_RAW) {\n return { header, schema };\n }\n\n const wanted = options.tables ? new Set(options.tables) : null;\n const tables = {};\n\n for (const entry of schema) {\n if (entry.type !== \"table\" || (wanted && !wanted.has(entry.name))) {\n continue;\n }\n\n // A table with no root page holds nothing: a view, or WITHOUT ROWID.\n tables[entry.name] = entry.rootPage\n ? ReadTable(bytes, header, entry, output === OUTPUT_JSON)\n : [];\n }\n\n return tables;\n }\n\n /** Reads to plain JSON-compatible values, converting blobs to arrays. */\n static readJSON(input, options = {}) {\n return this.read(input, { ...options, output: OUTPUT_JSON });\n }\n\n /** Reads with blobs left as `Uint8Array` and wide integers as `BigInt`. */\n static readPayload(input, options = {}) {\n return this.read(input, { ...options, output: OUTPUT_PAYLOAD });\n }\n\n /** Returns the parsed header and `sqlite_master` entries, decoding no rows. */\n static readRaw(input, options = {}) {\n return this.read(input, { ...options, output: OUTPUT_RAW });\n }\n\n /**\n * Lists the tables a container holds, without reading their rows.\n *\n * @param {Uint8Array|ArrayBuffer} input Container bytes.\n * @returns {Array<object>} One entry per table.\n */\n static tables(input) {\n const bytes = Normalize(input);\n\n return ReadMaster(bytes, ReadHeader(bytes)).filter(entry => entry.type === \"table\");\n }\n\n static Output = Object.freeze({\n JSON: OUTPUT_JSON,\n PAYLOAD: OUTPUT_PAYLOAD,\n RAW: OUTPUT_RAW\n });\n\n static id = \"sqlite\";\n static extensions = Object.freeze([ \".sqlite\", \".db\", \".sqlite3\" ]);\n static type = Object.freeze([ \"data\" ]);\n static mediaTypes = Object.freeze([ \"data\" ]);\n static inputTypes = Object.freeze([ \"sqlite\" ]);\n static outputTypes = Object.freeze([ OUTPUT_JSON, OUTPUT_PAYLOAD ]);\n static debugOutputTypes = Object.freeze([ OUTPUT_RAW ]);\n}\n\n/** Builds the probe shape the resource manager routes on. */\nfunction Probe(recognized, options) {\n return {\n format: \"sqlite\",\n source: \"buffer\",\n supported: recognized ? \"full\" : \"none\",\n confidence: 1,\n preferred: \"sqlite\",\n // The header signature is content, not a declaration, so a match is\n // evidence rather than a claim to be checked later.\n verified: true,\n reason: recognized\n ? \"Recognized a SQLite 3 container.\"\n : \"The header signature is not SQLite 3.\",\n variants: [ { kind: \"container\", codec: \"sqlite\", supported: recognized } ],\n metadata: { family: \"sqlite\", decodable: recognized },\n ...(options || {})\n };\n}\n\n/** Reads `sqlite_master`, which is always the table b-tree rooted at page 1. */\nfunction ReadMaster(bytes, header) {\n const entries = [];\n\n for (const row of TableRows(bytes, header, MASTER_ROOT_PAGE)) {\n const [ type, name, tableName, rootPage, sql ] = ReadRecord(row.payload, header.encoding);\n\n entries.push({\n type: String(type ?? \"\"),\n name: String(name ?? \"\"),\n tableName: String(tableName ?? \"\"),\n rootPage: Number(rootPage ?? 0),\n sql: sql === null || sql === undefined ? \"\" : String(sql)\n });\n }\n\n return entries;\n}\n\n/** Reads one table's rows as objects, named from its `CREATE TABLE` text. */\nfunction ReadTable(bytes, header, entry, json) {\n const { names, rowidAlias } = ReadColumns(entry.sql);\n const rows = [];\n\n for (const row of TableRows(bytes, header, entry.rootPage)) {\n const values = ReadRecord(row.payload, header.encoding);\n const record = {};\n\n for (let index = 0; index < values.length; index += 1) {\n // Positional names keep a row readable when the statement could not be\n // parsed, rather than dropping columns that certainly hold data.\n const name = names[index] ?? `column${index}`;\n const value = index === rowidAlias && values[index] === null ? row.rowid : values[index];\n\n record[name] = json ? ToJSON(value) : value;\n }\n\n rows.push(record);\n }\n\n return rows;\n}\n\n/** Converts a decoded value to something `JSON.stringify` keeps losslessly. */\nfunction ToJSON(value) {\n if (value instanceof Uint8Array) {\n return Array.from(value);\n }\n\n // A BigInt has no JSON form; a decimal string keeps every digit.\n return typeof value === \"bigint\" ? value.toString(10) : value;\n}\n\n/** Accepts the byte forms every other format here accepts. */\nfunction Normalize(input) {\n if (input instanceof Uint8Array) {\n return input;\n }\n\n if (input instanceof ArrayBuffer) {\n return new Uint8Array(input);\n }\n\n if (ArrayBuffer.isView(input)) {\n return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n }\n\n throw SqliteError(\"A SQLite container must be supplied as bytes.\");\n}\n\nexport default CjsSqliteFormat;\n"],"names":["OUTPUT_JSON","OUTPUT_PAYLOAD","OUTPUT_RAW","MASTER_ROOT_PAGE","CjsSqliteFormat","is","input","ReadHeader","Normalize","isSupported","options","Probe","read","output","bytes","header","schema","ReadMaster","wanted","tables","Set","entry","type","has","name","rootPage","ReadTable","readJSON","readPayload","readRaw","filter","Output","Object","freeze","JSON","PAYLOAD","RAW","id","extensions","mediaTypes","inputTypes","outputTypes","debugOutputTypes","recognized","format","source","supported","confidence","preferred","verified","reason","variants","kind","codec","metadata","family","decodable","entries","row","TableRows","tableName","sql","ReadRecord","payload","encoding","push","String","Number","undefined","json","names","rowidAlias","ReadColumns","rows","values","record","index","length","value","rowid","ToJSON","Uint8Array","Array","from","toString","ArrayBuffer","isView","buffer","byteOffset","byteLength","SqliteError"],"mappings":";;;;AAIA,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,CAAC;AAE3B;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,WAAWA,CAACH,KAAK,EAAEI,OAAO,GAAG,IAAI,EAAE;IACxC,OAAOC,KAAK,CAAC,IAAI,CAACN,EAAE,CAACC,KAAK,CAAC,EAAEI,OAAO,CAAC;AACvC,EAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOE,IAAIA,CAACN,KAAK,EAAEI,OAAO,GAAG,EAAE,EAAE;AA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AGA,KAAK;AAC7C,IAAA;AAEAL,IAAAA,IAAI,CAACR,IAAI,CAACU,MAAM,CAAC;AACnB,EAAA;AAEA,EAAA,OAAOF,IAAI;AACb;;AAEA;AACA,SAASO,MAAMA,CAACF,KAAK,EAAE;EACrB,IAAIA,KAAK,YAAYG,UAAU,EAAE;AAC/B,IAAA,OAAOC,KAAK,CAACC,IAAI,CAACL,KAAK,CAAC;AAC1B,EAAA;;AAEA;AACA,EAAA,OAAO,OAAOA,KAAK,KAAK,QAAQ,GAAGA,KAAK,CAACM,QAAQ,CAAC,EAAE,CAAC,GAAGN,KAAK;AAC/D;;AAEA;AACA,SAAStE,SAASA,CAACF,KAAK,EAAE;EACxB,IAAIA,KAAK,YAAY2E,UAAU,EAAE;AAC/B,IAAA,OAAO3E,KAAK;AACd,EAAA;EAEA,IAAIA,KAAK,YAAY+E,WAAW,EAAE;AAChC,IAAA,OAAO,IAAIJ,UAAU,CAAC3E,KAAK,CAAC;AAC9B,EAAA;AAEA,EAAA,IAAI+E,WAAW,CAACC,MAAM,CAAChF,KAAK,CAAC,EAAE;AAC7B,IAAA,OAAO,IAAI2E,UAAU,CAAC3E,KAAK,CAACiF,MAAM,EAAEjF,KAAK,CAACkF,UAAU,EAAElF,KAAK,CAACmF,UAAU,CAAC;AACzE,EAAA;EAEA,MAAMC,WAAW,CAAC,+CAA+C,CAAC;AACpE;;;;"}
|
|
1
|
+
{"version":3,"file":"CjsSqliteFormat.js","sources":["../../../../src/formats/sqlite/CjsSqliteFormat.js"],"sourcesContent":["import { CjsFormat } from \"../../format/CjsFormat.js\";\nimport { ReadColumns } from \"./core/sqliteSchema.js\";\nimport { ReadHeader, TableRows } from \"./core/sqlitePages.js\";\nimport { ReadRecord, SqliteError } from \"./core/sqliteRecords.js\";\n\nconst OUTPUT_JSON = \"json\";\nconst OUTPUT_PAYLOAD = \"payload\";\nconst OUTPUT_RAW = \"raw\";\nconst MASTER_ROOT_PAGE = 1;\n\n/**\n * Reads a SQLite 3 container as data.\n *\n * **This is a reader, not a database.** It accepts no SQL and runs no queries.\n * It returns the tables a container holds and every row of them, because that\n * is the whole of what this organization does with a SQLite file: the client's\n * `.static` containers and the prepared static data export are both opened,\n * scanned once, and closed.\n *\n * That scope is what makes it small. A query planner, an index walker, writing,\n * journalling and transactions are most of SQLite and none of this, so none of\n * them are here. Index b-tree pages are never visited: an index holds no data a\n * table scan does not already produce.\n *\n * It exists because `runtime-resource` is browser-safe and ships no SQLite\n * engine, so `.static` containers of the SQLite family previously needed a\n * driver injected by the caller — which meant Node, and in practice the\n * experimental `node:sqlite`. Nothing here touches a filesystem or a binding.\n *\n * Values map as the format defines them: NULL, integers, doubles, text decoded\n * with the database's own encoding, and blobs as `Uint8Array`. An integer wider\n * than `Number.MAX_SAFE_INTEGER` is returned as a `BigInt` rather than silently\n * rounded.\n */\nexport class CjsSqliteFormat extends CjsFormat {\n\n /**\n * Reports whether bytes are a SQLite container, by signature.\n *\n * @param {Uint8Array|ArrayBuffer} input Candidate bytes.\n * @returns {boolean} True when the header signature matches.\n */\n static is(input) {\n try {\n ReadHeader(Normalize(input));\n\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Reports whether these bytes are a SQLite container, on the signature.\n *\n * The signature is the whole claim: the header either says\n * `SQLite format 3` or it does not, so this is verified by content rather\n * than inferred from a name — which matters because `.static` carries three\n * unrelated families and the extension proves nothing.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @param {object} [options] Probe options.\n * @returns {object} Resource probe.\n */\n static probeSupport(input, options = null) {\n const recognized = this.is(input);\n return {\n format: this.id,\n source: options?.source || \"buffer\",\n recognized,\n supported: recognized,\n preferredOutput: recognized ? OUTPUT_JSON : \"\",\n reason: recognized\n ? \"Recognized a SQLite 3 container.\"\n : \"The header signature is not SQLite 3.\",\n variants: [\n { kind: OUTPUT_JSON, supported: recognized },\n { kind: OUTPUT_PAYLOAD, supported: recognized },\n { kind: OUTPUT_RAW, supported: recognized }\n ],\n metadata: recognized ? this.inspect(input) : { family: this.id, decodable: false }\n };\n }\n\n /** Return header facts without reading table rows. */\n static inspect(input) {\n const header = ReadHeader(Normalize(input));\n return { family: this.id, decodable: true, header };\n }\n\n /**\n * Reads every table and row.\n *\n * @param {Uint8Array|ArrayBuffer} input Container bytes.\n * @param {object} [options] Read options.\n * @param {string} [options.output] `json`, `payload` or `raw`.\n * @param {string[]} [options.tables] Read only these tables.\n * @returns {object} Tables keyed by name, each an array of row objects.\n */\n static read(input, options = {}) {\n const output = options.emit ?? options.output ?? OUTPUT_JSON;\n const bytes = Normalize(input);\n const header = ReadHeader(bytes);\n const schema = ReadMaster(bytes, header);\n\n if (output === OUTPUT_RAW) {\n return { header, schema };\n }\n\n const wanted = options.tables ? new Set(options.tables) : null;\n const tables = {};\n\n for (const entry of schema) {\n if (entry.type !== \"table\" || (wanted && !wanted.has(entry.name))) {\n continue;\n }\n\n // A table with no root page holds nothing: a view, or WITHOUT ROWID.\n tables[entry.name] = entry.rootPage\n ? ReadTable(bytes, header, entry, output === OUTPUT_JSON)\n : [];\n }\n\n return tables;\n }\n\n /** Reads to plain JSON-compatible values, converting blobs to arrays. */\n static readJSON(input, options = {}) {\n return this.read(input, { ...options, output: OUTPUT_JSON });\n }\n\n /** Reads with blobs left as `Uint8Array` and wide integers as `BigInt`. */\n static readPayload(input, options = {}) {\n return this.read(input, { ...options, output: OUTPUT_PAYLOAD });\n }\n\n /** Returns the parsed header and `sqlite_master` entries, decoding no rows. */\n static readRaw(input, options = {}) {\n return this.read(input, { ...options, output: OUTPUT_RAW });\n }\n\n /**\n * Lists the tables a container holds, without reading their rows.\n *\n * @param {Uint8Array|ArrayBuffer} input Container bytes.\n * @returns {Array<object>} One entry per table.\n */\n static tables(input) {\n const bytes = Normalize(input);\n\n return ReadMaster(bytes, ReadHeader(bytes)).filter(entry => entry.type === \"table\");\n }\n\n static Output = Object.freeze({\n JSON: OUTPUT_JSON,\n PAYLOAD: OUTPUT_PAYLOAD,\n RAW: OUTPUT_RAW\n });\n\n static id = \"sqlite\";\n static extensions = Object.freeze([ \".sqlite\", \".db\", \".sqlite3\" ]);\n static mediaTypes = Object.freeze([ \"data\" ]);\n static outputs = CjsFormat.defineOutputs({\n json: { default: true, decoded: true },\n payload: { decoded: true },\n raw: { role: \"debug\", decoded: true }\n });\n}\n\n/** Reads `sqlite_master`, which is always the table b-tree rooted at page 1. */\nfunction ReadMaster(bytes, header) {\n const entries = [];\n\n for (const row of TableRows(bytes, header, MASTER_ROOT_PAGE)) {\n const [ type, name, tableName, rootPage, sql ] = ReadRecord(row.payload, header.encoding);\n\n entries.push({\n type: String(type ?? \"\"),\n name: String(name ?? \"\"),\n tableName: String(tableName ?? \"\"),\n rootPage: Number(rootPage ?? 0),\n sql: sql === null || sql === undefined ? \"\" : String(sql)\n });\n }\n\n return entries;\n}\n\n/** Reads one table's rows as objects, named from its `CREATE TABLE` text. */\nfunction ReadTable(bytes, header, entry, json) {\n const { names, rowidAlias } = ReadColumns(entry.sql);\n const rows = [];\n\n for (const row of TableRows(bytes, header, entry.rootPage)) {\n const values = ReadRecord(row.payload, header.encoding);\n const record = {};\n\n for (let index = 0; index < values.length; index += 1) {\n // Positional names keep a row readable when the statement could not be\n // parsed, rather than dropping columns that certainly hold data.\n const name = names[index] ?? `column${index}`;\n const value = index === rowidAlias && values[index] === null ? row.rowid : values[index];\n\n record[name] = json ? ToJSON(value) : value;\n }\n\n rows.push(record);\n }\n\n return rows;\n}\n\n/** Converts a decoded value to something `JSON.stringify` keeps losslessly. */\nfunction ToJSON(value) {\n if (value instanceof Uint8Array) {\n return Array.from(value);\n }\n\n // A BigInt has no JSON form; a decimal string keeps every digit.\n return typeof value === \"bigint\" ? value.toString(10) : value;\n}\n\n/** Accepts the byte forms every other format here accepts. */\nfunction Normalize(input) {\n if (input instanceof Uint8Array) {\n return input;\n }\n\n if (input instanceof ArrayBuffer) {\n return new Uint8Array(input);\n }\n\n if (ArrayBuffer.isView(input)) {\n return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n }\n\n throw SqliteError(\"A SQLite container must be supplied as bytes.\");\n}\n\nexport default CjsSqliteFormat;\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;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;AAC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AAA,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,3 +1,5 @@
|
|
|
1
|
+
import { CjsFormat } from '../../format/CjsFormat.js';
|
|
2
|
+
|
|
1
3
|
const SQLITE_SIGNATURE = "SQLite format 3\0";
|
|
2
4
|
const PICKLE_PREFIX_BYTES = 4;
|
|
3
5
|
|
|
@@ -39,7 +41,7 @@ const CJS_STATIC_FAMILIES = Object.freeze({
|
|
|
39
41
|
* about what to decode in the wrong place. Nothing outside its own tests ever
|
|
40
42
|
* called it.
|
|
41
43
|
*/
|
|
42
|
-
class CjsStaticFormat {
|
|
44
|
+
class CjsStaticFormat extends CjsFormat {
|
|
43
45
|
/**
|
|
44
46
|
* Report which family a container holds, on the declaration seam.
|
|
45
47
|
*
|
|
@@ -51,8 +53,16 @@ class CjsStaticFormat {
|
|
|
51
53
|
* @param {object} [options] Probe options.
|
|
52
54
|
* @returns {CjsResourceProbe} Declaration-derived probe.
|
|
53
55
|
*/
|
|
54
|
-
static
|
|
55
|
-
|
|
56
|
+
static probeSupport(input, options = null) {
|
|
57
|
+
const detected = this.describe(input);
|
|
58
|
+
return {
|
|
59
|
+
format: this.id,
|
|
60
|
+
source: options?.source || "buffer",
|
|
61
|
+
recognized: detected.family !== CJS_STATIC_FAMILIES.UNKNOWN,
|
|
62
|
+
supported: false,
|
|
63
|
+
reason: detected.reason ?? `Recognized a ${detected.family} container.`,
|
|
64
|
+
metadata: detected
|
|
65
|
+
};
|
|
56
66
|
}
|
|
57
67
|
|
|
58
68
|
/**
|
|
@@ -63,25 +73,7 @@ class CjsStaticFormat {
|
|
|
63
73
|
* @returns {CjsResourceProbe} Declaration-derived probe.
|
|
64
74
|
*/
|
|
65
75
|
static inspect(input, options = null) {
|
|
66
|
-
return this.
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Content-verified family resolution.
|
|
71
|
-
*
|
|
72
|
-
* Contract: docs/concepts/format-type-resolution.md. There is no declared
|
|
73
|
-
* type to disagree with here — the extension is silent — so the signature is
|
|
74
|
-
* both the claim and the evidence, and the resolution is always verified.
|
|
75
|
-
* `preferred` names the decode route, and all three now lead into this
|
|
76
|
-
* package: `CjsPickleFormat`, `CjsSqliteFormat`, and `CjsSchemaBoundFormat`
|
|
77
|
-
* once the caller has the `.schema` companion to hand it.
|
|
78
|
-
*
|
|
79
|
-
* @param {ArrayBuffer|ArrayBufferView} input Container bytes.
|
|
80
|
-
* @param {object} [options] Probe options.
|
|
81
|
-
* @returns {Promise<CjsResourceProbe>} Verified probe.
|
|
82
|
-
*/
|
|
83
|
-
static async resolveType(input, options = null) {
|
|
84
|
-
return Probe(this.describe(input), true, options);
|
|
76
|
+
return this.describe(input);
|
|
85
77
|
}
|
|
86
78
|
|
|
87
79
|
/**
|
|
@@ -147,8 +139,8 @@ class CjsStaticFormat {
|
|
|
147
139
|
}
|
|
148
140
|
static id = "static";
|
|
149
141
|
static extensions = Object.freeze([".static"]);
|
|
150
|
-
static type = Object.freeze(["data"]);
|
|
151
142
|
static mediaTypes = Object.freeze(["data"]);
|
|
143
|
+
static outputs = Object.freeze({});
|
|
152
144
|
|
|
153
145
|
/**
|
|
154
146
|
* The extension is the only input this format claims.
|
|
@@ -159,40 +151,6 @@ class CjsStaticFormat {
|
|
|
159
151
|
* nothing and the signature has to be read. The family belongs in
|
|
160
152
|
* `describe()`, which measures it, not in a static that asserts it.
|
|
161
153
|
*/
|
|
162
|
-
static inputTypes = Object.freeze(["static"]);
|
|
163
|
-
static outputTypes = Object.freeze(["json", "payload"]);
|
|
164
|
-
static debugOutputTypes = Object.freeze(["raw"]);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Build the shared probe payload.
|
|
169
|
-
*
|
|
170
|
-
* Formats report a plain probe-shaped object rather than constructing a
|
|
171
|
-
* `CjsResourceProbe`, which keeps this module free of the decorated class and
|
|
172
|
-
* of the build transform it needs.
|
|
173
|
-
*/
|
|
174
|
-
function Probe(detected, verified, options) {
|
|
175
|
-
return {
|
|
176
|
-
format: "static",
|
|
177
|
-
source: "buffer",
|
|
178
|
-
supported: detected.decodable ? "full" : "partial",
|
|
179
|
-
confidence: detected.family === CJS_STATIC_FAMILIES.UNKNOWN ? 0.5 : 1,
|
|
180
|
-
preferred: detected.family,
|
|
181
|
-
verified,
|
|
182
|
-
reason: detected.reason ?? `Recognized a ${detected.family} container.`,
|
|
183
|
-
variants: [{
|
|
184
|
-
kind: "container",
|
|
185
|
-
codec: detected.family,
|
|
186
|
-
supported: detected.decodable
|
|
187
|
-
}],
|
|
188
|
-
metadata: verified ? {
|
|
189
|
-
...detected,
|
|
190
|
-
declared: null,
|
|
191
|
-
resolved: detected.family,
|
|
192
|
-
mismatch: false
|
|
193
|
-
} : detected,
|
|
194
|
-
...(options || {})
|
|
195
|
-
};
|
|
196
154
|
}
|
|
197
155
|
function MatchesSqlite(bytes) {
|
|
198
156
|
if (bytes.byteLength < SQLITE_SIGNATURE.length) return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CjsStaticFormat.js","sources":["../../../../src/formats/static/CjsStaticFormat.js"],"sourcesContent":["\nconst SQLITE_SIGNATURE = \"SQLite format 3\\0\";\nconst PICKLE_PREFIX_BYTES = 4;\n\n/** Container families found behind the single `.static` extension. */\nexport const CJS_STATIC_FAMILIES = Object.freeze({\n SQLITE: \"sqlite\",\n PICKLE: \"pickle\",\n UNKNOWN: \"unknown\"\n});\n\n/**\n * Identifies which container a client `.static` file actually holds.\n *\n * The extension names a role, not a format. Three unrelated containers ship\n * under it, and each fails in its own way when guessed at:\n *\n * - **SQLite 3** — a `cache(key, value, time)` plus `indexes(key, value)`\n * database whose values are JSON documents. `CjsSqliteFormat` reads it.\n * - **Embedded schema** — a four-byte little-endian SCHEMA LENGTH followed by\n * that schema as a protocol-0 pickle, and then a payload. The prefix is not a\n * wrapper to skip: slice `[4, 4 + length)` for the schema and give the rest\n * to `CjsSchemaBoundFormat`. All 25 of these name one global,\n * `collections.OrderedDict`, which the pickle reader rebuilds as plain data.\n * - **Schema-bound** — a binary record container whose `.schema` companion is\n * YAML describing its own layout: attribute sizes and types, optional flags,\n * lists with a fixed item size, vectors with a precision, and a key footer of\n * key-to-offset pairs. Nothing needs deriving, because the build ships the\n * layout. Six datasets are stored this way - the map skeleton of regions,\n * constellations and systems. `CjsSchemaBoundFormat` reads it, given that\n * companion, and reads the embedded-schema family above from the same code.\n *\n * Detection is signature-based and never executes or trusts file names.\n *\n * **This class identifies and does not decode.** It reports the family, the\n * payload offset and what is still missing; the caller takes that answer to the\n * format that owns the family. It carried a `read()` that dispatched to\n * `CjsPickleFormat` and `CjsSqliteFormat` until 2026-08-15, which made an\n * identification format the routing table for two others and put the decision\n * about what to decode in the wrong place. Nothing outside its own tests ever\n * called it.\n */\nexport class CjsStaticFormat\n{\n\n /**\n * Report which family a container holds, on the declaration seam.\n *\n * `.static` declares nothing: the extension names a role and every family\n * wears it. The signature is therefore the only claim there is, which is why\n * this format reads it here rather than trusting a name.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @param {object} [options] Probe options.\n * @returns {CjsResourceProbe} Declaration-derived probe.\n */\n static isSupported(input, options = null)\n {\n return Probe(this.describe(input), false, options);\n }\n\n /**\n * Alias for canonical naming.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @param {object} [options] Probe options.\n * @returns {CjsResourceProbe} Declaration-derived probe.\n */\n static inspect(input, options = null)\n {\n return this.isSupported(input, options);\n }\n\n /**\n * Content-verified family resolution.\n *\n * Contract: docs/concepts/format-type-resolution.md. There is no declared\n * type to disagree with here — the extension is silent — so the signature is\n * both the claim and the evidence, and the resolution is always verified.\n * `preferred` names the decode route, and all three now lead into this\n * package: `CjsPickleFormat`, `CjsSqliteFormat`, and `CjsSchemaBoundFormat`\n * once the caller has the `.schema` companion to hand it.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @param {object} [options] Probe options.\n * @returns {Promise<CjsResourceProbe>} Verified probe.\n */\n static async resolveType(input, options = null)\n {\n return Probe(this.describe(input), true, options);\n }\n\n /**\n * Describe one container without decoding it or building a probe.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @returns {object} Family, payload offset, and whether this package decodes it.\n */\n static describe(input)\n {\n const bytes = Normalize(input);\n\n if (MatchesSqlite(bytes))\n {\n return Object.freeze({\n family: CJS_STATIC_FAMILIES.SQLITE,\n byteLength: bytes.byteLength,\n payloadOffset: 0,\n prefix: null,\n // Decodable outright since CjsSqliteFormat landed. This reported\n // `requires: \"sqlite\"` while a caller had to supply an engine, and was\n // the example behind the argument that a capability can depend on the\n // caller's environment - an argument that now needs a different one.\n decodable: true,\n requires: null,\n reason: \"Recognized a SQLite container.\"\n });\n }\n\n if (MatchesPickle(bytes))\n {\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n\n return Object.freeze({\n family: CJS_STATIC_FAMILIES.PICKLE,\n byteLength: bytes.byteLength,\n payloadOffset: PICKLE_PREFIX_BYTES,\n prefix: view.getUint32(0, true),\n decodable: true,\n requires: null,\n reason: null\n });\n }\n\n return Object.freeze({\n family: CJS_STATIC_FAMILIES.UNKNOWN,\n byteLength: bytes.byteLength,\n payloadOffset: 0,\n prefix: null,\n decodable: false,\n requires: \"schema\",\n // `decodable` is this format's own answer, and it stays false: these bytes\n // carry nothing to identify, so the family is an inference from the absence\n // of the other two signatures rather than a reading. `requires` names what\n // closes that gap - with the companion, CjsSchemaBoundFormat decodes it.\n reason: \"No signature. A schema-bound container needs its .schema companion, \"\n + \"which is YAML describing the layout. CjsSchemaBoundFormat reads it from there.\"\n });\n }\n\n /**\n * Return the decodable payload for a container, without its wrapper.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @returns {Uint8Array} Payload bytes.\n */\n static payload(input)\n {\n const bytes = Normalize(input);\n const detected = this.describe(bytes);\n\n return bytes.subarray(detected.payloadOffset);\n }\n\n\n static id = \"static\";\n static extensions = Object.freeze([ \".static\" ]);\n static type = Object.freeze([ \"data\" ]);\n static mediaTypes = Object.freeze([ \"data\" ]);\n\n /**\n * The extension is the only input this format claims.\n *\n * Naming the three families here would be a lie in the other direction: a\n * caller cannot hand this format \"a pickle\" or \"a sqlite\" and expect it to\n * route, because the whole point of the class is that `.static` declares\n * nothing and the signature has to be read. The family belongs in\n * `describe()`, which measures it, not in a static that asserts it.\n */\n static inputTypes = Object.freeze([ \"static\" ]);\n static outputTypes = Object.freeze([ \"json\", \"payload\" ]);\n static debugOutputTypes = Object.freeze([ \"raw\" ]);\n\n}\n\n/**\n * Build the shared probe payload.\n *\n * Formats report a plain probe-shaped object rather than constructing a\n * `CjsResourceProbe`, which keeps this module free of the decorated class and\n * of the build transform it needs.\n */\nfunction Probe(detected, verified, options)\n{\n return {\n format: \"static\",\n source: \"buffer\",\n supported: detected.decodable ? \"full\" : \"partial\",\n confidence: detected.family === CJS_STATIC_FAMILIES.UNKNOWN ? 0.5 : 1,\n preferred: detected.family,\n verified,\n reason: detected.reason ?? `Recognized a ${detected.family} container.`,\n variants: [ { kind: \"container\", codec: detected.family, supported: detected.decodable } ],\n metadata: verified\n ? { ...detected, declared: null, resolved: detected.family, mismatch: false }\n : detected,\n ...(options || {})\n };\n}\n\nfunction MatchesSqlite(bytes)\n{\n if (bytes.byteLength < SQLITE_SIGNATURE.length) return false;\n\n for (let index = 0; index < SQLITE_SIGNATURE.length; index++)\n {\n if (bytes[index] !== SQLITE_SIGNATURE.charCodeAt(index)) return false;\n }\n\n return true;\n}\n\nfunction MatchesPickle(bytes)\n{\n // A protocol-0 pickle opens a container then names it: \"(dp1\\n\" or \"(lp1\\n\".\n if (bytes.byteLength < PICKLE_PREFIX_BYTES + 3) return false;\n if (bytes[PICKLE_PREFIX_BYTES] !== 0x28) return false;\n\n const kind = bytes[PICKLE_PREFIX_BYTES + 1];\n\n return kind === 0x64 || kind === 0x6c;\n}\n\nfunction Normalize(input)\n{\n if (input instanceof ArrayBuffer) return new Uint8Array(input);\n\n if (ArrayBuffer.isView(input))\n {\n return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n }\n\n const error = new TypeError(\"A .static container must be an ArrayBuffer or a view over one.\");\n\n error.code = \"CJS_STATIC_FORMAT_INPUT_INVALID\";\n throw error;\n}\n"],"names":["SQLITE_SIGNATURE","PICKLE_PREFIX_BYTES","CJS_STATIC_FAMILIES","Object","freeze","SQLITE","PICKLE","UNKNOWN","CjsStaticFormat","isSupported","input","options","Probe","describe","inspect","resolveType","bytes","Normalize","MatchesSqlite","family","byteLength","payloadOffset","prefix","decodable","requires","reason","MatchesPickle","view","DataView","buffer","byteOffset","getUint32","payload","detected","subarray","id","extensions","type","mediaTypes","inputTypes","outputTypes","debugOutputTypes","verified","format","source","supported","confidence","preferred","variants","kind","codec","metadata","declared","resolved","mismatch","length","index","charCodeAt","ArrayBuffer","Uint8Array","isView","error","TypeError","code"],"mappings":"AACA,MAAMA,gBAAgB,GAAG,mBAAmB;AAC5C,MAAMC,mBAAmB,GAAG,CAAC;;AAE7B;MACaC,mBAAmB,GAAGC,MAAM,CAACC,MAAM,CAAC;AAC/CC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,OAAO,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,CAC5B;AAEE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOC,WAAWA,CAACC,KAAK,EAAEC,OAAO,G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"],"sourcesContent":["import { CjsFormat } from \"../../format/CjsFormat.js\";\n\nconst SQLITE_SIGNATURE = \"SQLite format 3\\0\";\nconst PICKLE_PREFIX_BYTES = 4;\n\n/** Container families found behind the single `.static` extension. */\nexport const CJS_STATIC_FAMILIES = Object.freeze({\n SQLITE: \"sqlite\",\n PICKLE: \"pickle\",\n UNKNOWN: \"unknown\"\n});\n\n/**\n * Identifies which container a client `.static` file actually holds.\n *\n * The extension names a role, not a format. Three unrelated containers ship\n * under it, and each fails in its own way when guessed at:\n *\n * - **SQLite 3** — a `cache(key, value, time)` plus `indexes(key, value)`\n * database whose values are JSON documents. `CjsSqliteFormat` reads it.\n * - **Embedded schema** — a four-byte little-endian SCHEMA LENGTH followed by\n * that schema as a protocol-0 pickle, and then a payload. The prefix is not a\n * wrapper to skip: slice `[4, 4 + length)` for the schema and give the rest\n * to `CjsSchemaBoundFormat`. All 25 of these name one global,\n * `collections.OrderedDict`, which the pickle reader rebuilds as plain data.\n * - **Schema-bound** — a binary record container whose `.schema` companion is\n * YAML describing its own layout: attribute sizes and types, optional flags,\n * lists with a fixed item size, vectors with a precision, and a key footer of\n * key-to-offset pairs. Nothing needs deriving, because the build ships the\n * layout. Six datasets are stored this way - the map skeleton of regions,\n * constellations and systems. `CjsSchemaBoundFormat` reads it, given that\n * companion, and reads the embedded-schema family above from the same code.\n *\n * Detection is signature-based and never executes or trusts file names.\n *\n * **This class identifies and does not decode.** It reports the family, the\n * payload offset and what is still missing; the caller takes that answer to the\n * format that owns the family. It carried a `read()` that dispatched to\n * `CjsPickleFormat` and `CjsSqliteFormat` until 2026-08-15, which made an\n * identification format the routing table for two others and put the decision\n * about what to decode in the wrong place. Nothing outside its own tests ever\n * called it.\n */\nexport class CjsStaticFormat extends CjsFormat\n{\n\n /**\n * Report which family a container holds, on the declaration seam.\n *\n * `.static` declares nothing: the extension names a role and every family\n * wears it. The signature is therefore the only claim there is, which is why\n * this format reads it here rather than trusting a name.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @param {object} [options] Probe options.\n * @returns {CjsResourceProbe} Declaration-derived probe.\n */\n static probeSupport(input, options = null)\n {\n const detected = this.describe(input);\n return {\n format: this.id,\n source: options?.source || \"buffer\",\n recognized: detected.family !== CJS_STATIC_FAMILIES.UNKNOWN,\n supported: false,\n reason: detected.reason ?? `Recognized a ${detected.family} container.`,\n metadata: detected\n };\n }\n\n /**\n * Alias for canonical naming.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @param {object} [options] Probe options.\n * @returns {CjsResourceProbe} Declaration-derived probe.\n */\n static inspect(input, options = null)\n {\n void options;\n return this.describe(input);\n }\n\n /**\n * Describe one container without decoding it or building a probe.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @returns {object} Family, payload offset, and whether this package decodes it.\n */\n static describe(input)\n {\n const bytes = Normalize(input);\n\n if (MatchesSqlite(bytes))\n {\n return Object.freeze({\n family: CJS_STATIC_FAMILIES.SQLITE,\n byteLength: bytes.byteLength,\n payloadOffset: 0,\n prefix: null,\n // Decodable outright since CjsSqliteFormat landed. This reported\n // `requires: \"sqlite\"` while a caller had to supply an engine, and was\n // the example behind the argument that a capability can depend on the\n // caller's environment - an argument that now needs a different one.\n decodable: true,\n requires: null,\n reason: \"Recognized a SQLite container.\"\n });\n }\n\n if (MatchesPickle(bytes))\n {\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n\n return Object.freeze({\n family: CJS_STATIC_FAMILIES.PICKLE,\n byteLength: bytes.byteLength,\n payloadOffset: PICKLE_PREFIX_BYTES,\n prefix: view.getUint32(0, true),\n decodable: true,\n requires: null,\n reason: null\n });\n }\n\n return Object.freeze({\n family: CJS_STATIC_FAMILIES.UNKNOWN,\n byteLength: bytes.byteLength,\n payloadOffset: 0,\n prefix: null,\n decodable: false,\n requires: \"schema\",\n // `decodable` is this format's own answer, and it stays false: these bytes\n // carry nothing to identify, so the family is an inference from the absence\n // of the other two signatures rather than a reading. `requires` names what\n // closes that gap - with the companion, CjsSchemaBoundFormat decodes it.\n reason: \"No signature. A schema-bound container needs its .schema companion, \"\n + \"which is YAML describing the layout. CjsSchemaBoundFormat reads it from there.\"\n });\n }\n\n /**\n * Return the decodable payload for a container, without its wrapper.\n *\n * @param {ArrayBuffer|ArrayBufferView} input Container bytes.\n * @returns {Uint8Array} Payload bytes.\n */\n static payload(input)\n {\n const bytes = Normalize(input);\n const detected = this.describe(bytes);\n\n return bytes.subarray(detected.payloadOffset);\n }\n\n\n static id = \"static\";\n static extensions = Object.freeze([ \".static\" ]);\n static mediaTypes = Object.freeze([ \"data\" ]);\n static outputs = Object.freeze({});\n\n /**\n * The extension is the only input this format claims.\n *\n * Naming the three families here would be a lie in the other direction: a\n * caller cannot hand this format \"a pickle\" or \"a sqlite\" and expect it to\n * route, because the whole point of the class is that `.static` declares\n * nothing and the signature has to be read. The family belongs in\n * `describe()`, which measures it, not in a static that asserts it.\n */\n\n}\n\nfunction MatchesSqlite(bytes)\n{\n if (bytes.byteLength < SQLITE_SIGNATURE.length) return false;\n\n for (let index = 0; index < SQLITE_SIGNATURE.length; index++)\n {\n if (bytes[index] !== SQLITE_SIGNATURE.charCodeAt(index)) return false;\n }\n\n return true;\n}\n\nfunction MatchesPickle(bytes)\n{\n // A protocol-0 pickle opens a container then names it: \"(dp1\\n\" or \"(lp1\\n\".\n if (bytes.byteLength < PICKLE_PREFIX_BYTES + 3) return false;\n if (bytes[PICKLE_PREFIX_BYTES] !== 0x28) return false;\n\n const kind = bytes[PICKLE_PREFIX_BYTES + 1];\n\n return kind === 0x64 || kind === 0x6c;\n}\n\nfunction Normalize(input)\n{\n if (input instanceof ArrayBuffer) return new Uint8Array(input);\n\n if (ArrayBuffer.isView(input))\n {\n return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n }\n\n const error = new TypeError(\"A .static container must be an ArrayBuffer or a view over one.\");\n\n error.code = \"CJS_STATIC_FORMAT_INPUT_INVALID\";\n throw error;\n}\n"],"names":["SQLITE_SIGNATURE","PICKLE_PREFIX_BYTES","CJS_STATIC_FAMILIES","Object","freeze","SQLITE","PICKLE","UNKNOWN","CjsStaticFormat","CjsFormat","probeSupport","input","options","detected","describe","format","id","source","recognized","family","supported","reason","metadata","inspect","bytes","Normalize","MatchesSqlite","byteLength","payloadOffset","prefix","decodable","requires","MatchesPickle","view","DataView","buffer","byteOffset","getUint32","payload","subarray","extensions","mediaTypes","outputs","length","index","charCodeAt","kind","ArrayBuffer","Uint8Array","isView","error","TypeError","code"],"mappings":";;AAEA,MAAMA,gBAAgB,GAAG,mBAAmB;AAC5C,MAAMC,mBAAmB,GAAG,CAAC;;AAE7B;MACaC,mBAAmB,GAAGC,MAAM,CAACC,MAAM,CAAC;AAC/CC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,OAAO,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,CAC9C;AAEE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOC,YAAYA,CAACC,KAAK,EAAEC,OAAO,GAAG,IAAI,EACzC;AACE,IAAA,MAAMC,QAAQ,GAAG,IAAI,CAACC,QAAQ,CAACH,KAAK,CAAC;IACrC,OAAO;MACLI,MAAM,EAAE,IAAI,CAACC,EAAE;AACfC,MAAAA,MAAM,EAAEL,OAAO,EAAEK,MAAM,IAAI,QAAQ;AACnCC,MAAAA,UAAU,EAAEL,QAAQ,CAACM,MAAM,KAAKjB,mBAAmB,CAACK,OAAO;AAC3Da,MAAAA,SAAS,EAAE,KAAK;MAChBC,MAAM,EAAER,QAAQ,CAACQ,MAAM,IAAI,CAAA,aAAA,EAAgBR,Q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ACoB,KAAK,CAAC,KAAK5C,gBAAgB,CAAC6C,UAAU,CAACD,KAAK,CAAC,EAAE,OAAO,KAAK;AACvE,EAAA;AAEA,EAAA,OAAO,IAAI;AACb;AAEA,SAASZ,aAAaA,CAACR,KAAK,EAC5B;AACE;EACA,IAAIA,KAAK,CAACG,UAAU,GAAG1B,mBAAmB,GAAG,CAAC,EAAE,OAAO,KAAK;EAC5D,IAAIuB,KAAK,CAACvB,mBAAmB,CAAC,KAAK,IAAI,EAAE,OAAO,KAAK;AAErD,EAAA,MAAM6C,IAAI,GAAGtB,KAAK,CAACvB,mBAAmB,GAAG,CAAC,CAAC;AAE3C,EAAA,OAAO6C,IAAI,KAAK,IAAI,IAAIA,IAAI,KAAK,IAAI;AACvC;AAEA,SAASrB,SAASA,CAACd,KAAK,EACxB;EACE,IAAIA,KAAK,YAAYoC,WAAW,EAAE,OAAO,IAAIC,UAAU,CAACrC,KAAK,CAAC;AAE9D,EAAA,IAAIoC,WAAW,CAACE,MAAM,CAACtC,KAAK,CAAC,EAC7B;AACE,IAAA,OAAO,IAAIqC,UAAU,CAACrC,KAAK,CAACwB,MAAM,EAAExB,KAAK,CAACyB,UAAU,EAAEzB,KAAK,CAACgB,UAAU,CAAC;AACzE,EAAA;AAEA,EAAA,MAAMuB,KAAK,GAAG,IAAIC,SAAS,CAAC,gEAAgE,CAAC;EAE7FD,KAAK,CAACE,IAAI,GAAG,iCAAiC;AAC9C,EAAA,MAAMF,KAAK;AACb;;;;"}
|
|
@@ -52,9 +52,9 @@ function FamilyError(path, found, wanted, reason) {
|
|
|
52
52
|
* @returns {Promise<object>} Records keyed by their container key.
|
|
53
53
|
*/
|
|
54
54
|
async function ReadStaticContainer(bytes, path = ".static input") {
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
throw FamilyError(path,
|
|
55
|
+
const detected = CjsStaticFormat.inspect(bytes);
|
|
56
|
+
if (detected.family !== CJS_STATIC_FAMILIES.SQLITE) {
|
|
57
|
+
throw FamilyError(path, detected.family, CJS_STATIC_FAMILIES.SQLITE, detected.reason);
|
|
58
58
|
}
|
|
59
59
|
const tables = CjsSqliteFormat.readJSON(bytes, {
|
|
60
60
|
tables: [CACHE_TABLE]
|
|
@@ -126,12 +126,12 @@ function ReadEmbeddedSchemaContainer(bytes, path = ".static input") {
|
|
|
126
126
|
* @returns {Promise<object|Array>} Decoded records.
|
|
127
127
|
*/
|
|
128
128
|
async function ReadSchemaBoundContainer(bytes, schema, path = ".static input") {
|
|
129
|
-
const
|
|
129
|
+
const detected = CjsStaticFormat.inspect(bytes);
|
|
130
130
|
|
|
131
131
|
// The schema-bound family is the one with nothing to recognize, so it is
|
|
132
132
|
// reported as `unknown` with `requires: "schema"` rather than named outright.
|
|
133
|
-
if (
|
|
134
|
-
throw FamilyError(path,
|
|
133
|
+
if (detected.family !== CJS_STATIC_FAMILIES.UNKNOWN) {
|
|
134
|
+
throw FamilyError(path, detected.family, "schema-bound", null);
|
|
135
135
|
}
|
|
136
136
|
return CjsSchemaBoundFormat.read(bytes, {
|
|
137
137
|
schema
|