@carbonenginejs/runtime-resource 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FORMAT-PROVENANCE.md +135 -0
- package/LICENSE +21 -0
- package/NOTICE +29 -0
- package/README.md +241 -0
- package/dist/CjsMotherLode.js +56 -0
- package/dist/CjsMotherLode.js.map +1 -0
- package/dist/CjsResMan.js +740 -0
- package/dist/CjsResMan.js.map +1 -0
- package/dist/CjsResManQueue.js +214 -0
- package/dist/CjsResManQueue.js.map +1 -0
- package/dist/CjsResource.js +366 -0
- package/dist/CjsResource.js.map +1 -0
- package/dist/CjsResourceSource.js +59 -0
- package/dist/CjsResourceSource.js.map +1 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.js +153 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/dist/format/CjsFormat.js +178 -0
- package/dist/format/CjsFormat.js.map +1 -0
- package/dist/format/CjsResourceProbe.js +269 -0
- package/dist/format/CjsResourceProbe.js.map +1 -0
- package/dist/format/payloadContract.js +173 -0
- package/dist/format/payloadContract.js.map +1 -0
- package/dist/formats/black/CjsBlackFormat.js +272 -0
- package/dist/formats/black/CjsBlackFormat.js.map +1 -0
- package/dist/formats/black/core/CjsBlackBinaryReader.js +153 -0
- package/dist/formats/black/core/CjsBlackBinaryReader.js.map +1 -0
- package/dist/formats/black/core/CjsBlackPropertyReaders.js +382 -0
- package/dist/formats/black/core/CjsBlackPropertyReaders.js.map +1 -0
- package/dist/formats/black/core/CjsBlackReader.js +760 -0
- package/dist/formats/black/core/CjsBlackReader.js.map +1 -0
- package/dist/formats/black/core/CjsBlackSchemaRegistry.js +433 -0
- package/dist/formats/black/core/CjsBlackSchemaRegistry.js.map +1 -0
- package/dist/formats/black/core/black-schema-v1-2026-07-11.json.js +4 -0
- package/dist/formats/black/core/black-schema-v1-2026-07-11.json.js.map +1 -0
- package/dist/formats/black/core/blackConstants.js +7 -0
- package/dist/formats/black/core/blackConstants.js.map +1 -0
- package/dist/formats/black/core/blackDefinitions.js +10 -0
- package/dist/formats/black/core/blackDefinitions.js.map +1 -0
- package/dist/formats/black/core/blackEnums.js +6 -0
- package/dist/formats/black/core/blackEnums.js.map +1 -0
- package/dist/formats/black/core/blackSchema.js +3 -0
- package/dist/formats/black/core/blackSchema.js.map +1 -0
- package/dist/formats/black/core/blackVersion.js +22 -0
- package/dist/formats/black/core/blackVersion.js.map +1 -0
- package/dist/formats/black/core/helpers.js +182 -0
- package/dist/formats/black/core/helpers.js.map +1 -0
- package/dist/formats/black/core/schema.js +4 -0
- package/dist/formats/black/core/schema.js.map +1 -0
- package/dist/formats/black/index.js +2 -0
- package/dist/formats/black/index.js.map +1 -0
- package/dist/formats/bnk/CjsBnkFormat.js +245 -0
- package/dist/formats/bnk/CjsBnkFormat.js.map +1 -0
- package/dist/formats/bnk/core/helpers.js +354 -0
- package/dist/formats/bnk/core/helpers.js.map +1 -0
- package/dist/formats/bnk/core/soundbanksInfo.js +246 -0
- package/dist/formats/bnk/core/soundbanksInfo.js.map +1 -0
- package/dist/formats/bnk/index.js +3 -0
- package/dist/formats/bnk/index.js.map +1 -0
- package/dist/formats/cmf/CjsCmfFormat.js +491 -0
- package/dist/formats/cmf/CjsCmfFormat.js.map +1 -0
- package/dist/formats/cmf/core/binary.js +118 -0
- package/dist/formats/cmf/core/binary.js.map +1 -0
- package/dist/formats/cmf/core/buffers.js +233 -0
- package/dist/formats/cmf/core/buffers.js.map +1 -0
- package/dist/formats/cmf/core/constants.js +47 -0
- package/dist/formats/cmf/core/constants.js.map +1 -0
- package/dist/formats/cmf/core/gr2Anim.js +453 -0
- package/dist/formats/cmf/core/gr2Anim.js.map +1 -0
- package/dist/formats/cmf/core/helpers.js +287 -0
- package/dist/formats/cmf/core/helpers.js.map +1 -0
- package/dist/formats/cmf/core/pack.js +276 -0
- package/dist/formats/cmf/core/pack.js.map +1 -0
- package/dist/formats/cmf/core/schema.js +364 -0
- package/dist/formats/cmf/core/schema.js.map +1 -0
- package/dist/formats/cmf/core/shared.js +268 -0
- package/dist/formats/cmf/core/shared.js.map +1 -0
- package/dist/formats/cmf/core/writer.js +517 -0
- package/dist/formats/cmf/core/writer.js.map +1 -0
- package/dist/formats/cmf/index.js +2 -0
- package/dist/formats/cmf/index.js.map +1 -0
- package/dist/formats/dds/CjsDdsFormat.js +187 -0
- package/dist/formats/dds/CjsDdsFormat.js.map +1 -0
- package/dist/formats/dds/core/helpers.js +812 -0
- package/dist/formats/dds/core/helpers.js.map +1 -0
- package/dist/formats/dds/index.js +2 -0
- package/dist/formats/dds/index.js.map +1 -0
- package/dist/formats/fbx/CjsFbxFormat.js +260 -0
- package/dist/formats/fbx/CjsFbxFormat.js.map +1 -0
- package/dist/formats/fbx/core/helpers.js +3901 -0
- package/dist/formats/fbx/core/helpers.js.map +1 -0
- package/dist/formats/fbx/index.js +2 -0
- package/dist/formats/fbx/index.js.map +1 -0
- package/dist/formats/flac/CjsFlacFormat.js +81 -0
- package/dist/formats/flac/CjsFlacFormat.js.map +1 -0
- package/dist/formats/flac/core/helpers.js +295 -0
- package/dist/formats/flac/core/helpers.js.map +1 -0
- package/dist/formats/flac/index.js +2 -0
- package/dist/formats/flac/index.js.map +1 -0
- package/dist/formats/gif/CjsGifFormat.js +81 -0
- package/dist/formats/gif/CjsGifFormat.js.map +1 -0
- package/dist/formats/gif/core/helpers.js +360 -0
- package/dist/formats/gif/core/helpers.js.map +1 -0
- package/dist/formats/gif/index.js +2 -0
- package/dist/formats/gif/index.js.map +1 -0
- package/dist/formats/gltf/CjsGltfFormat.js +284 -0
- package/dist/formats/gltf/CjsGltfFormat.js.map +1 -0
- package/dist/formats/gltf/core/helpers.js +292 -0
- package/dist/formats/gltf/core/helpers.js.map +1 -0
- package/dist/formats/gltf/core/json.js +79 -0
- package/dist/formats/gltf/core/json.js.map +1 -0
- package/dist/formats/gltf/core/parser.js +666 -0
- package/dist/formats/gltf/core/parser.js.map +1 -0
- package/dist/formats/gltf/core/targets.js +163 -0
- package/dist/formats/gltf/core/targets.js.map +1 -0
- package/dist/formats/gltf/index.js +2 -0
- package/dist/formats/gltf/index.js.map +1 -0
- package/dist/formats/index.js +23 -0
- package/dist/formats/index.js.map +1 -0
- package/dist/formats/jpeg/CjsJpegFormat.js +200 -0
- package/dist/formats/jpeg/CjsJpegFormat.js.map +1 -0
- package/dist/formats/jpeg/core/helpers.js +350 -0
- package/dist/formats/jpeg/core/helpers.js.map +1 -0
- package/dist/formats/jpeg/core/jpeg.js +377 -0
- package/dist/formats/jpeg/core/jpeg.js.map +1 -0
- package/dist/formats/jpeg/index.js +2 -0
- package/dist/formats/jpeg/index.js.map +1 -0
- package/dist/formats/mp3/CjsMp3Format.js +186 -0
- package/dist/formats/mp3/CjsMp3Format.js.map +1 -0
- package/dist/formats/mp3/core/helpers.js +338 -0
- package/dist/formats/mp3/core/helpers.js.map +1 -0
- package/dist/formats/mp3/index.js +2 -0
- package/dist/formats/mp3/index.js.map +1 -0
- package/dist/formats/mp4/CjsMp4Format.js +185 -0
- package/dist/formats/mp4/CjsMp4Format.js.map +1 -0
- package/dist/formats/mp4/core/helpers.js +449 -0
- package/dist/formats/mp4/core/helpers.js.map +1 -0
- package/dist/formats/mp4/index.js +2 -0
- package/dist/formats/mp4/index.js.map +1 -0
- package/dist/formats/obj/CjsObjFormat.js +247 -0
- package/dist/formats/obj/CjsObjFormat.js.map +1 -0
- package/dist/formats/obj/core/helpers.js +573 -0
- package/dist/formats/obj/core/helpers.js.map +1 -0
- package/dist/formats/obj/core/json.js +64 -0
- package/dist/formats/obj/core/json.js.map +1 -0
- package/dist/formats/obj/core/parser.js +321 -0
- package/dist/formats/obj/core/parser.js.map +1 -0
- package/dist/formats/obj/index.js +2 -0
- package/dist/formats/obj/index.js.map +1 -0
- package/dist/formats/ogg/CjsOggFormat.js +82 -0
- package/dist/formats/ogg/CjsOggFormat.js.map +1 -0
- package/dist/formats/ogg/core/helpers.js +387 -0
- package/dist/formats/ogg/core/helpers.js.map +1 -0
- package/dist/formats/ogg/core/imdct.js +178 -0
- package/dist/formats/ogg/core/imdct.js.map +1 -0
- package/dist/formats/ogg/core/vorbis.js +999 -0
- package/dist/formats/ogg/core/vorbis.js.map +1 -0
- package/dist/formats/ogg/index.js +2 -0
- package/dist/formats/ogg/index.js.map +1 -0
- package/dist/formats/png/CjsPngFormat.js +189 -0
- package/dist/formats/png/CjsPngFormat.js.map +1 -0
- package/dist/formats/png/core/helpers.js +583 -0
- package/dist/formats/png/core/helpers.js.map +1 -0
- package/dist/formats/png/index.js +2 -0
- package/dist/formats/png/index.js.map +1 -0
- package/dist/formats/red/CjsRedFormat.js +247 -0
- package/dist/formats/red/CjsRedFormat.js.map +1 -0
- package/dist/formats/red/core/CjsRedReader.js +201 -0
- package/dist/formats/red/core/CjsRedReader.js.map +1 -0
- package/dist/formats/red/core/blackDefinitions.js +3 -0
- package/dist/formats/red/core/blackDefinitions.js.map +1 -0
- package/dist/formats/red/core/helpers.js +136 -0
- package/dist/formats/red/core/helpers.js.map +1 -0
- package/dist/formats/red/core/redGraph.js +68 -0
- package/dist/formats/red/core/redGraph.js.map +1 -0
- package/dist/formats/red/core/schema.js +4 -0
- package/dist/formats/red/core/schema.js.map +1 -0
- package/dist/formats/red/index.js +2 -0
- package/dist/formats/red/index.js.map +1 -0
- package/dist/formats/stl/CjsStlFormat.js +304 -0
- package/dist/formats/stl/CjsStlFormat.js.map +1 -0
- package/dist/formats/stl/core/helpers.js +257 -0
- package/dist/formats/stl/core/helpers.js.map +1 -0
- package/dist/formats/stl/core/json.js +51 -0
- package/dist/formats/stl/core/json.js.map +1 -0
- package/dist/formats/stl/core/stl.js +544 -0
- package/dist/formats/stl/core/stl.js.map +1 -0
- package/dist/formats/stl/core/targets.js +163 -0
- package/dist/formats/stl/core/targets.js.map +1 -0
- package/dist/formats/stl/index.js +2 -0
- package/dist/formats/stl/index.js.map +1 -0
- package/dist/formats/tga/CjsTgaFormat.js +186 -0
- package/dist/formats/tga/CjsTgaFormat.js.map +1 -0
- package/dist/formats/tga/core/helpers.js +446 -0
- package/dist/formats/tga/core/helpers.js.map +1 -0
- package/dist/formats/tga/index.js +2 -0
- package/dist/formats/tga/index.js.map +1 -0
- package/dist/formats/wav/CjsWavFormat.js +186 -0
- package/dist/formats/wav/CjsWavFormat.js.map +1 -0
- package/dist/formats/wav/core/helpers.js +328 -0
- package/dist/formats/wav/core/helpers.js.map +1 -0
- package/dist/formats/wav/index.js +2 -0
- package/dist/formats/wav/index.js.map +1 -0
- package/dist/formats/webm/CjsWebmFormat.js +185 -0
- package/dist/formats/webm/CjsWebmFormat.js.map +1 -0
- package/dist/formats/webm/core/helpers.js +537 -0
- package/dist/formats/webm/core/helpers.js.map +1 -0
- package/dist/formats/webm/index.js +2 -0
- package/dist/formats/webm/index.js.map +1 -0
- package/dist/formats/webp/CjsWebpFormat.js +80 -0
- package/dist/formats/webp/CjsWebpFormat.js.map +1 -0
- package/dist/formats/webp/core/helpers.js +214 -0
- package/dist/formats/webp/core/helpers.js.map +1 -0
- package/dist/formats/webp/index.js +2 -0
- package/dist/formats/webp/index.js.map +1 -0
- package/dist/formats/wem/CjsWemFormat.js +197 -0
- package/dist/formats/wem/CjsWemFormat.js.map +1 -0
- package/dist/formats/wem/core/bitStream.js +259 -0
- package/dist/formats/wem/core/bitStream.js.map +1 -0
- package/dist/formats/wem/core/codebookLibrary.js +164 -0
- package/dist/formats/wem/core/codebookLibrary.js.map +1 -0
- package/dist/formats/wem/core/helpers.js +336 -0
- package/dist/formats/wem/core/helpers.js.map +1 -0
- package/dist/formats/wem/core/packedCodebooksAotuv603.js +30 -0
- package/dist/formats/wem/core/packedCodebooksAotuv603.js.map +1 -0
- package/dist/formats/wem/core/wemToOgg.js +485 -0
- package/dist/formats/wem/core/wemToOgg.js.map +1 -0
- package/dist/formats/wem/index.js +2 -0
- package/dist/formats/wem/index.js.map +1 -0
- package/dist/formats/yaml/CjsYamlFormat.js +77 -0
- package/dist/formats/yaml/CjsYamlFormat.js.map +1 -0
- package/dist/formats/yaml/core/CjsYamlReader.js +304 -0
- package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -0
- package/dist/formats/yaml/core/helpers.js +160 -0
- package/dist/formats/yaml/core/helpers.js.map +1 -0
- package/dist/formats/yaml/index.js +2 -0
- package/dist/formats/yaml/index.js.map +1 -0
- package/dist/generated/resources/AudioGeometryResData.js +47 -0
- package/dist/generated/resources/AudioGeometryResData.js.map +1 -0
- package/dist/generated/resources/CmfVertexReader.js +46 -0
- package/dist/generated/resources/CmfVertexReader.js.map +1 -0
- package/dist/generated/resources/GStateBindingCallbackData.js +31 -0
- package/dist/generated/resources/GStateBindingCallbackData.js.map +1 -0
- package/dist/generated/resources/MeshDecalData.js +37 -0
- package/dist/generated/resources/MeshDecalData.js.map +1 -0
- package/dist/generated/resources/MeshDecalLodData.js +34 -0
- package/dist/generated/resources/MeshDecalLodData.js.map +1 -0
- package/dist/generated/resources/Tr2AsyncSave.js +46 -0
- package/dist/generated/resources/Tr2AsyncSave.js.map +1 -0
- package/dist/generated/resources/Tr2CmfContents.js +37 -0
- package/dist/generated/resources/Tr2CmfContents.js.map +1 -0
- package/dist/generated/resources/Tr2GrannyIntersectionResult.js +58 -0
- package/dist/generated/resources/Tr2GrannyIntersectionResult.js.map +1 -0
- package/dist/generated/resources/Tr2LoadPrepareFence.js +37 -0
- package/dist/generated/resources/Tr2LoadPrepareFence.js.map +1 -0
- package/dist/generated/resources/Tr2MaterialArea.js +34 -0
- package/dist/generated/resources/Tr2MaterialArea.js.map +1 -0
- package/dist/generated/resources/Tr2MaterialMesh.js +31 -0
- package/dist/generated/resources/Tr2MaterialMesh.js.map +1 -0
- package/dist/generated/resources/Tr2MaterialRes.js +34 -0
- package/dist/generated/resources/Tr2MaterialRes.js.map +1 -0
- package/dist/generated/resources/Tr2ShaderPermutation.js +43 -0
- package/dist/generated/resources/Tr2ShaderPermutation.js.map +1 -0
- package/dist/generated/resources/Tr2TextureLodManager.js +60 -0
- package/dist/generated/resources/Tr2TextureLodManager.js.map +1 -0
- package/dist/generated/resources/Tr2TextureLodUpdateRequest.js +37 -0
- package/dist/generated/resources/Tr2TextureLodUpdateRequest.js.map +1 -0
- package/dist/generated/resources/Tr2TexturePackChannel.js +37 -0
- package/dist/generated/resources/Tr2TexturePackChannel.js.map +1 -0
- package/dist/generated/resources/Tr2TexturePipeline.js +44 -0
- package/dist/generated/resources/Tr2TexturePipeline.js.map +1 -0
- package/dist/generated/resources/Tr2TexturePipelineParams.js +34 -0
- package/dist/generated/resources/Tr2TexturePipelineParams.js.map +1 -0
- package/dist/generated/resources/Tr2TexturePipelineStepCompress.js +40 -0
- package/dist/generated/resources/Tr2TexturePipelineStepCompress.js.map +1 -0
- package/dist/generated/resources/Tr2TexturePipelineStepLimitSize.js +34 -0
- package/dist/generated/resources/Tr2TexturePipelineStepLimitSize.js.map +1 -0
- package/dist/generated/resources/Tr2TexturePipelineStepLoad.js +31 -0
- package/dist/generated/resources/Tr2TexturePipelineStepLoad.js.map +1 -0
- package/dist/generated/resources/Tr2TexturePipelineStepPack.js +43 -0
- package/dist/generated/resources/Tr2TexturePipelineStepPack.js.map +1 -0
- package/dist/generated/resources/TriGeometryResAreaData.js +59 -0
- package/dist/generated/resources/TriGeometryResAreaData.js.map +1 -0
- package/dist/generated/resources/TriGeometryResJointData.js +38 -0
- package/dist/generated/resources/TriGeometryResJointData.js.map +1 -0
- package/dist/generated/resources/TriGeometryResLodData.js +88 -0
- package/dist/generated/resources/TriGeometryResLodData.js.map +1 -0
- package/dist/generated/resources/TriGeometryResMeshData.js +63 -0
- package/dist/generated/resources/TriGeometryResMeshData.js.map +1 -0
- package/dist/generated/resources/TriGeometryResSkeletonData.js +34 -0
- package/dist/generated/resources/TriGeometryResSkeletonData.js.map +1 -0
- package/dist/generated/resources/TriJointBinding.js +38 -0
- package/dist/generated/resources/TriJointBinding.js.map +1 -0
- package/dist/generated/resources/TriMorphTargetGeometryConstants.js +46 -0
- package/dist/generated/resources/TriMorphTargetGeometryConstants.js.map +1 -0
- package/dist/generated/resources/TriRtGeometryConstants.js +88 -0
- package/dist/generated/resources/TriRtGeometryConstants.js.map +1 -0
- package/dist/generated/resources/enums.js +18 -0
- package/dist/generated/resources/enums.js.map +1 -0
- package/dist/generated/resources/index.js +32 -0
- package/dist/generated/resources/index.js.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/resourcePath.js +18 -0
- package/dist/resourcePath.js.map +1 -0
- package/dist/resourceStates.js +9 -0
- package/dist/resourceStates.js.map +1 -0
- package/dist/resources/Tr2EffectRes.js +71 -0
- package/dist/resources/Tr2EffectRes.js.map +1 -0
- package/dist/resources/Tr2GrannyStateRes.js +44 -0
- package/dist/resources/Tr2GrannyStateRes.js.map +1 -0
- package/dist/resources/Tr2ImageRes.js +114 -0
- package/dist/resources/Tr2ImageRes.js.map +1 -0
- package/dist/resources/Tr2LightProfileRes.js +40 -0
- package/dist/resources/Tr2LightProfileRes.js.map +1 -0
- package/dist/resources/TriGeometryRes.js +216 -0
- package/dist/resources/TriGeometryRes.js.map +1 -0
- package/dist/resources/TriGrannyRes.js +43 -0
- package/dist/resources/TriGrannyRes.js.map +1 -0
- package/dist/resources/TriTextureRes.js +304 -0
- package/dist/resources/TriTextureRes.js.map +1 -0
- package/dist/resources/resourceBoundary.js +47 -0
- package/dist/resources/resourceBoundary.js.map +1 -0
- package/dist/texture/CjsTextureArrayRes.js +406 -0
- package/dist/texture/CjsTextureArrayRes.js.map +1 -0
- package/dist/texture/CjsTextureParameterProxy.js +133 -0
- package/dist/texture/CjsTextureParameterProxy.js.map +1 -0
- package/format-notices/black/LICENSE +21 -0
- package/format-notices/black/NOTICE +47 -0
- package/format-notices/bnk/LICENSE +21 -0
- package/format-notices/bnk/NOTICE +17 -0
- package/format-notices/cmf/LICENSE +21 -0
- package/format-notices/cmf/NOTICE +36 -0
- package/format-notices/dds/LICENSE +21 -0
- package/format-notices/dds/NOTICE +14 -0
- package/format-notices/fbx/LICENSE +21 -0
- package/format-notices/fbx/NOTICE +14 -0
- package/format-notices/flac/LICENSE +21 -0
- package/format-notices/flac/NOTICE +14 -0
- package/format-notices/gif/LICENSE +21 -0
- package/format-notices/gif/NOTICE +14 -0
- package/format-notices/gltf/LICENSE +21 -0
- package/format-notices/gltf/NOTICE +27 -0
- package/format-notices/jpeg/LICENSE +21 -0
- package/format-notices/jpeg/NOTICE +14 -0
- package/format-notices/mp3/LICENSE +21 -0
- package/format-notices/mp3/NOTICE +14 -0
- package/format-notices/mp4/LICENSE +21 -0
- package/format-notices/mp4/NOTICE +14 -0
- package/format-notices/obj/LICENSE +21 -0
- package/format-notices/obj/NOTICE +26 -0
- package/format-notices/ogg/LICENSE +21 -0
- package/format-notices/ogg/NOTICE +28 -0
- package/format-notices/png/LICENSE +21 -0
- package/format-notices/png/NOTICE +14 -0
- package/format-notices/red/LICENSE +21 -0
- package/format-notices/red/NOTICE +31 -0
- package/format-notices/stl/LICENSE +21 -0
- package/format-notices/stl/NOTICE +21 -0
- package/format-notices/tga/LICENSE +21 -0
- package/format-notices/tga/NOTICE +14 -0
- package/format-notices/wav/LICENSE +21 -0
- package/format-notices/wav/NOTICE +14 -0
- package/format-notices/webm/LICENSE +21 -0
- package/format-notices/webm/NOTICE +14 -0
- package/format-notices/webp/LICENSE +21 -0
- package/format-notices/webp/NOTICE +14 -0
- package/format-notices/wem/LICENSE +57 -0
- package/format-notices/wem/NOTICE +33 -0
- package/format-notices/yaml/LICENSE +21 -0
- package/format-notices/yaml/NOTICE +44 -0
- package/package.json +51 -0
- package/resource-lifecycle.md +487 -0
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import { canDecodeJpeg, decodeJpegToRgba } from './jpeg.js';
|
|
2
|
+
|
|
3
|
+
const OUTPUT_IMAGE = "image";
|
|
4
|
+
const OUTPUT_RGBA = "rgba";
|
|
5
|
+
const OUTPUT_RAW = "raw";
|
|
6
|
+
const OUTPUT_JSON = "json";
|
|
7
|
+
const DEFAULT_VALUES = Object.freeze({
|
|
8
|
+
emit: OUTPUT_RAW,
|
|
9
|
+
inputType: "",
|
|
10
|
+
source: ""
|
|
11
|
+
});
|
|
12
|
+
const DEBUG_OUTPUTS = Object.freeze({
|
|
13
|
+
png: "pngJson",
|
|
14
|
+
jpeg: "jpegJson",
|
|
15
|
+
jpg: "jpegJson",
|
|
16
|
+
tga: "tgaJson",
|
|
17
|
+
dds: "ddsJson"
|
|
18
|
+
});
|
|
19
|
+
const IMAGE_MIME_TYPES = Object.freeze({
|
|
20
|
+
png: "image/png",
|
|
21
|
+
jpeg: "image/jpeg",
|
|
22
|
+
jpg: "image/jpeg",
|
|
23
|
+
tga: "image/x-tga",
|
|
24
|
+
dds: "image/vnd-ms.dds"
|
|
25
|
+
});
|
|
26
|
+
function normalizeValues(base = DEFAULT_VALUES, options = {}, readerName = "CjsImageFormat") {
|
|
27
|
+
const values = {
|
|
28
|
+
...DEFAULT_VALUES,
|
|
29
|
+
...(base || {}),
|
|
30
|
+
...(options || {})
|
|
31
|
+
};
|
|
32
|
+
values.inputType = normalizeInputType(values.inputType);
|
|
33
|
+
values.emit = normalizeEmit(values.emit, values.inputType, readerName);
|
|
34
|
+
return values;
|
|
35
|
+
}
|
|
36
|
+
function normalizeInputType(inputType) {
|
|
37
|
+
if (!inputType) return "";
|
|
38
|
+
const value = String(inputType).replace(/^\./u, "").toLowerCase();
|
|
39
|
+
return value === "jpg" ? "jpeg" : value;
|
|
40
|
+
}
|
|
41
|
+
function normalizeEmit(emit, inputType, readerName) {
|
|
42
|
+
if (emit === undefined || emit === null) return OUTPUT_RAW;
|
|
43
|
+
if (emit === OUTPUT_JSON && inputType) return DEBUG_OUTPUTS[inputType] || OUTPUT_JSON;
|
|
44
|
+
if ([OUTPUT_IMAGE, OUTPUT_RGBA, OUTPUT_RAW, OUTPUT_JSON].includes(emit)) return emit;
|
|
45
|
+
if (Object.values(DEBUG_OUTPUTS).includes(emit)) return emit;
|
|
46
|
+
throw new TypeError(`${readerName}: unknown emit value ${JSON.stringify(emit)}`);
|
|
47
|
+
}
|
|
48
|
+
function toBytes(input) {
|
|
49
|
+
if (input instanceof Uint8Array) return input;
|
|
50
|
+
if (input instanceof ArrayBuffer) return new Uint8Array(input);
|
|
51
|
+
if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
52
|
+
throw new TypeError("Image input must be Uint8Array, ArrayBuffer, or DataView");
|
|
53
|
+
}
|
|
54
|
+
function inspectWithValues(input, values = DEFAULT_VALUES, expectedType = "") {
|
|
55
|
+
const bytes = toBytes(input);
|
|
56
|
+
const detected = inspectBytes(bytes);
|
|
57
|
+
const sourceFormat = expectedType || values.inputType || detected.sourceFormat;
|
|
58
|
+
if (expectedType && detected.sourceFormat && detected.sourceFormat !== expectedType) {
|
|
59
|
+
throw new TypeError(`CjsFormat${capitalize(expectedType)}: expected ${expectedType}, got ${detected.sourceFormat}`);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
payloadType: sourceFormat === "dds" ? "texture" : "image",
|
|
63
|
+
mediaTypes: sourceFormat === "dds" ? ["texture", "image"] : ["image"],
|
|
64
|
+
sourceFormat,
|
|
65
|
+
byteLength: bytes.byteLength,
|
|
66
|
+
...detected
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function isSupportedWithValues(input, values = DEFAULT_VALUES, expectedType = "") {
|
|
70
|
+
try {
|
|
71
|
+
const metadata = inspectWithValues(input, values, expectedType);
|
|
72
|
+
const canDecode = metadata.sourceFormat === "jpeg" && canDecodeJpeg(metadata);
|
|
73
|
+
const variants = [{
|
|
74
|
+
kind: "rgba",
|
|
75
|
+
payloadType: "rgba",
|
|
76
|
+
codec: "rgba8unorm",
|
|
77
|
+
supported: canDecode,
|
|
78
|
+
reason: canDecode ? "" : jpegDecodeReason(metadata),
|
|
79
|
+
containerOnly: false,
|
|
80
|
+
isDecoded: canDecode,
|
|
81
|
+
rgbaDecodeSupported: canDecode
|
|
82
|
+
}, rawVariant(metadata, canDecode)];
|
|
83
|
+
return {
|
|
84
|
+
format: metadata.sourceFormat,
|
|
85
|
+
source: values.source || "buffer",
|
|
86
|
+
supported: metadata.sourceFormat ? variants.some(variant => variant.supported && variant.kind === "rgba") ? "full" : "partial" : "none",
|
|
87
|
+
confidence: metadata.sourceFormat ? 1 : 0,
|
|
88
|
+
preferred: variants.find(v => v.supported)?.codec || "",
|
|
89
|
+
reason: metadata.sourceFormat ? "Container/header recognized." : "Unrecognized image format.",
|
|
90
|
+
metadata,
|
|
91
|
+
variants,
|
|
92
|
+
warnings: [],
|
|
93
|
+
errors: []
|
|
94
|
+
};
|
|
95
|
+
} catch (error) {
|
|
96
|
+
return {
|
|
97
|
+
format: expectedType || values.inputType || "",
|
|
98
|
+
source: values.source || "buffer",
|
|
99
|
+
supported: "none",
|
|
100
|
+
confidence: 0,
|
|
101
|
+
preferred: "",
|
|
102
|
+
reason: error.message,
|
|
103
|
+
metadata: null,
|
|
104
|
+
variants: [],
|
|
105
|
+
warnings: [],
|
|
106
|
+
errors: [error.message]
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function readWithValues(input, values = DEFAULT_VALUES, expectedType = "") {
|
|
111
|
+
const bytes = toBytes(input);
|
|
112
|
+
const metadata = inspectWithValues(bytes, values, expectedType);
|
|
113
|
+
if (values.emit === OUTPUT_RAW) {
|
|
114
|
+
return {
|
|
115
|
+
payloadType: "raw",
|
|
116
|
+
sourceFormat: metadata.sourceFormat,
|
|
117
|
+
mimeType: imageMimeType(metadata.sourceFormat),
|
|
118
|
+
containerOnly: true,
|
|
119
|
+
isDecoded: false,
|
|
120
|
+
rgbaDecodeSupported: metadata.sourceFormat === "jpeg" && canDecodeJpeg(metadata),
|
|
121
|
+
metadata,
|
|
122
|
+
bytes
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (values.emit === OUTPUT_JSON || values.emit === DEBUG_OUTPUTS[metadata.sourceFormat]) {
|
|
126
|
+
return metadata;
|
|
127
|
+
}
|
|
128
|
+
if ((values.emit === OUTPUT_RGBA || values.emit === OUTPUT_IMAGE) && metadata.sourceFormat === "jpeg") {
|
|
129
|
+
if (!canDecodeJpeg(metadata)) {
|
|
130
|
+
const error = new Error(`jpeg: ${jpegDecodeReason(metadata)}`);
|
|
131
|
+
error.code = "CJS_FORMAT_OUTPUT_UNSUPPORTED";
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
return decodeJpegToRgba(bytes, metadata);
|
|
135
|
+
}
|
|
136
|
+
const error = new Error(`${metadata.sourceFormat}: emit "${values.emit}" is not implemented yet`);
|
|
137
|
+
error.code = "CJS_FORMAT_OUTPUT_NOT_IMPLEMENTED";
|
|
138
|
+
error.sourceFormat = metadata.sourceFormat;
|
|
139
|
+
error.emit = values.emit;
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
function rawVariant(metadata, canDecode) {
|
|
143
|
+
return {
|
|
144
|
+
kind: "raw",
|
|
145
|
+
payloadType: "raw",
|
|
146
|
+
codec: metadata.sourceFormat,
|
|
147
|
+
mimeType: imageMimeType(metadata.sourceFormat),
|
|
148
|
+
supported: true,
|
|
149
|
+
containerOnly: true,
|
|
150
|
+
isDecoded: false,
|
|
151
|
+
rgbaDecodeSupported: metadata.sourceFormat === "jpeg" && canDecode === true
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function imageMimeType(sourceFormat) {
|
|
155
|
+
return IMAGE_MIME_TYPES[sourceFormat] || "application/octet-stream";
|
|
156
|
+
}
|
|
157
|
+
function toJsonValue(value) {
|
|
158
|
+
if (value instanceof Uint8Array) {
|
|
159
|
+
return {
|
|
160
|
+
byteLength: value.byteLength
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (Array.isArray(value)) return value.map(toJsonValue);
|
|
164
|
+
if (value && typeof value === "object") {
|
|
165
|
+
const output = {};
|
|
166
|
+
for (const [key, entry] of Object.entries(value)) output[key] = toJsonValue(entry);
|
|
167
|
+
return output;
|
|
168
|
+
}
|
|
169
|
+
return value;
|
|
170
|
+
}
|
|
171
|
+
function inspectBytes(bytes) {
|
|
172
|
+
if (isPNG(bytes)) return inspectPNG(bytes);
|
|
173
|
+
if (isJPEG(bytes)) return inspectJPEG(bytes);
|
|
174
|
+
if (isDDS(bytes)) return inspectDDS(bytes);
|
|
175
|
+
if (isTGA(bytes)) return inspectTGA(bytes);
|
|
176
|
+
return {
|
|
177
|
+
sourceFormat: "",
|
|
178
|
+
width: 0,
|
|
179
|
+
height: 0
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function isPNG(bytes) {
|
|
183
|
+
return bytes.byteLength >= 24 && bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47 && bytes[4] === 0x0d && bytes[5] === 0x0a && bytes[6] === 0x1a && bytes[7] === 0x0a;
|
|
184
|
+
}
|
|
185
|
+
function isJPEG(bytes) {
|
|
186
|
+
return bytes.byteLength >= 4 && bytes[0] === 0xff && bytes[1] === 0xd8;
|
|
187
|
+
}
|
|
188
|
+
function isJPG(bytes) {
|
|
189
|
+
return isJPEG(bytes);
|
|
190
|
+
}
|
|
191
|
+
function isDDS(bytes) {
|
|
192
|
+
return bytes.byteLength >= 128 && bytes[0] === 0x44 && bytes[1] === 0x44 && bytes[2] === 0x53 && bytes[3] === 0x20;
|
|
193
|
+
}
|
|
194
|
+
function isTGA(bytes) {
|
|
195
|
+
if (bytes.byteLength < 18) return false;
|
|
196
|
+
const imageType = bytes[2],
|
|
197
|
+
width = readU16LE(bytes, 12),
|
|
198
|
+
height = readU16LE(bytes, 14),
|
|
199
|
+
bpp = bytes[16];
|
|
200
|
+
return width > 0 && height > 0 && [1, 2, 3, 9, 10, 11].includes(imageType) && [8, 16, 24, 32].includes(bpp);
|
|
201
|
+
}
|
|
202
|
+
function inspectPNG(bytes) {
|
|
203
|
+
const colorType = bytes[25],
|
|
204
|
+
bitDepth = bytes[24];
|
|
205
|
+
return {
|
|
206
|
+
sourceFormat: "png",
|
|
207
|
+
width: readU32BE(bytes, 16),
|
|
208
|
+
height: readU32BE(bytes, 20),
|
|
209
|
+
bitDepth,
|
|
210
|
+
colorType,
|
|
211
|
+
channels: pngChannels(colorType),
|
|
212
|
+
pixelFormat: `png-${bitDepth}-${colorType}`,
|
|
213
|
+
isCompressed: false
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function inspectJPEG(bytes) {
|
|
217
|
+
let offset = 2;
|
|
218
|
+
let frame = null;
|
|
219
|
+
const summary = {
|
|
220
|
+
appMarkerCount: 0,
|
|
221
|
+
commentCount: 0,
|
|
222
|
+
hasExif: false,
|
|
223
|
+
hasIccProfile: false
|
|
224
|
+
};
|
|
225
|
+
while (offset + 9 < bytes.byteLength) {
|
|
226
|
+
if (bytes[offset] !== 0xff) {
|
|
227
|
+
offset++;
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
const marker = bytes[offset + 1],
|
|
231
|
+
length = readU16BE(bytes, offset + 2);
|
|
232
|
+
const dataStart = offset + 4;
|
|
233
|
+
const dataEnd = offset + 2 + length;
|
|
234
|
+
if (marker >= 0xe0 && marker <= 0xef) {
|
|
235
|
+
summary.appMarkerCount++;
|
|
236
|
+
if (marker === 0xe1 && ascii(bytes, dataStart, Math.min(6, dataEnd - dataStart)) === "Exif\0\0") summary.hasExif = true;
|
|
237
|
+
if (marker === 0xe2 && ascii(bytes, dataStart, Math.min(12, dataEnd - dataStart)) === "ICC_PROFILE\0") summary.hasIccProfile = true;
|
|
238
|
+
} else if (marker === 0xfe) {
|
|
239
|
+
summary.commentCount++;
|
|
240
|
+
}
|
|
241
|
+
if ([0xc0, 0xc1, 0xc2, 0xc3].includes(marker)) {
|
|
242
|
+
frame = {
|
|
243
|
+
sourceFormat: "jpeg",
|
|
244
|
+
width: readU16BE(bytes, offset + 7),
|
|
245
|
+
height: readU16BE(bytes, offset + 5),
|
|
246
|
+
channels: bytes[offset + 9],
|
|
247
|
+
components: bytes[offset + 9],
|
|
248
|
+
precision: bytes[offset + 4],
|
|
249
|
+
marker,
|
|
250
|
+
progressive: marker === 0xc2 || marker === 0xc3,
|
|
251
|
+
pixelFormat: "jpeg-ycbcr",
|
|
252
|
+
isCompressed: true
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
if (marker === 0xda && frame) {
|
|
256
|
+
const scanStart = offset + 4;
|
|
257
|
+
const scanComponents = bytes[scanStart];
|
|
258
|
+
const spectralStart = bytes[scanStart + 1 + scanComponents * 2];
|
|
259
|
+
const spectralEnd = bytes[scanStart + 2 + scanComponents * 2];
|
|
260
|
+
const successive = bytes[scanStart + 3 + scanComponents * 2];
|
|
261
|
+
return {
|
|
262
|
+
...frame,
|
|
263
|
+
...summary,
|
|
264
|
+
scanComponents,
|
|
265
|
+
spectralStart,
|
|
266
|
+
spectralEnd,
|
|
267
|
+
successive,
|
|
268
|
+
progressive: frame.progressive || spectralStart !== 0 || spectralEnd !== 63 || successive !== 0
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
offset += Math.max(length + 2, 2);
|
|
272
|
+
}
|
|
273
|
+
return frame ? {
|
|
274
|
+
...frame,
|
|
275
|
+
...summary
|
|
276
|
+
} : {
|
|
277
|
+
sourceFormat: "jpeg",
|
|
278
|
+
width: 0,
|
|
279
|
+
height: 0,
|
|
280
|
+
channels: 0,
|
|
281
|
+
pixelFormat: "jpeg",
|
|
282
|
+
isCompressed: true,
|
|
283
|
+
...summary
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function jpegDecodeReason(metadata) {
|
|
287
|
+
if (metadata.sourceFormat !== "jpeg") return `${metadata.sourceFormat.toUpperCase()} RGBA decode is not implemented yet.`;
|
|
288
|
+
if (metadata.progressive) return "Progressive JPEG software decode is not implemented yet.";
|
|
289
|
+
if (metadata.marker !== undefined && metadata.marker !== 0xc0 && metadata.marker !== 0xc1) {
|
|
290
|
+
return "Only sequential baseline JPEG frames are supported by the software decoder.";
|
|
291
|
+
}
|
|
292
|
+
if (metadata.precision !== undefined && metadata.precision !== 8) {
|
|
293
|
+
return `JPEG sample precision ${metadata.precision} is not supported by the software decoder.`;
|
|
294
|
+
}
|
|
295
|
+
if (metadata.components > 3) return "CMYK/YCCK JPEG software decode is not implemented yet.";
|
|
296
|
+
return "JPEG baseline frame metadata is incomplete or unsupported.";
|
|
297
|
+
}
|
|
298
|
+
function inspectDDS(bytes) {
|
|
299
|
+
const fourCc = String.fromCharCode(bytes[84], bytes[85], bytes[86], bytes[87]).replace(/\0+$/u, "");
|
|
300
|
+
return {
|
|
301
|
+
sourceFormat: "dds",
|
|
302
|
+
width: readU32LE(bytes, 16),
|
|
303
|
+
height: readU32LE(bytes, 12),
|
|
304
|
+
mipCount: Math.max(readU32LE(bytes, 28), 1),
|
|
305
|
+
fourCc,
|
|
306
|
+
textureFormat: fourCc || "dds-legacy",
|
|
307
|
+
isCompressed: !!fourCc,
|
|
308
|
+
hasMipMaps: readU32LE(bytes, 28) > 1
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function inspectTGA(bytes) {
|
|
312
|
+
return {
|
|
313
|
+
sourceFormat: "tga",
|
|
314
|
+
width: readU16LE(bytes, 12),
|
|
315
|
+
height: readU16LE(bytes, 14),
|
|
316
|
+
channels: Math.max(bytes[16] / 8, 1),
|
|
317
|
+
imageType: bytes[2],
|
|
318
|
+
pixelFormat: `tga-${bytes[16]}`,
|
|
319
|
+
isCompressed: [9, 10, 11].includes(bytes[2])
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
function pngChannels(colorType) {
|
|
323
|
+
if (colorType === 0) return 1;
|
|
324
|
+
if (colorType === 2) return 3;
|
|
325
|
+
if (colorType === 3) return 1;
|
|
326
|
+
if (colorType === 4) return 2;
|
|
327
|
+
if (colorType === 6) return 4;
|
|
328
|
+
return 0;
|
|
329
|
+
}
|
|
330
|
+
function readU16BE(bytes, offset) {
|
|
331
|
+
return bytes[offset] << 8 | bytes[offset + 1];
|
|
332
|
+
}
|
|
333
|
+
function readU16LE(bytes, offset) {
|
|
334
|
+
return bytes[offset] | bytes[offset + 1] << 8;
|
|
335
|
+
}
|
|
336
|
+
function readU32BE(bytes, offset) {
|
|
337
|
+
return bytes[offset] * 0x1000000 + (bytes[offset + 1] << 16 | bytes[offset + 2] << 8 | bytes[offset + 3]) >>> 0;
|
|
338
|
+
}
|
|
339
|
+
function readU32LE(bytes, offset) {
|
|
340
|
+
return (bytes[offset] | bytes[offset + 1] << 8 | bytes[offset + 2] << 16 | bytes[offset + 3] * 0x1000000) >>> 0;
|
|
341
|
+
}
|
|
342
|
+
function ascii(bytes, offset, length) {
|
|
343
|
+
return String.fromCharCode(...bytes.subarray(offset, offset + length));
|
|
344
|
+
}
|
|
345
|
+
function capitalize(value) {
|
|
346
|
+
return value ? value[0].toUpperCase() + value.slice(1) : "Image";
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export { DEFAULT_VALUES, OUTPUT_IMAGE, OUTPUT_JSON, OUTPUT_RAW, OUTPUT_RGBA, inspectBytes, inspectWithValues, isDDS, isJPEG, isJPG, isPNG, isSupportedWithValues, isTGA, normalizeEmit, normalizeInputType, normalizeValues, readWithValues, toBytes, toJsonValue };
|
|
350
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../../../src/formats/jpeg/core/helpers.js"],"sourcesContent":["export const OUTPUT_IMAGE = \"image\";\nexport const OUTPUT_TEXTURE = \"texture\";\nexport const OUTPUT_RGBA = \"rgba\";\nexport const OUTPUT_RAW = \"raw\";\nexport const OUTPUT_JSON = \"json\";\n\nimport { canDecodeJpeg, decodeJpegToRgba } from \"./jpeg.js\";\n\nexport const DEFAULT_VALUES = Object.freeze({\n emit: OUTPUT_RAW,\n inputType: \"\",\n source: \"\"\n});\n\nconst DEBUG_OUTPUTS = Object.freeze({\n png: \"pngJson\",\n jpeg: \"jpegJson\",\n jpg: \"jpegJson\",\n tga: \"tgaJson\",\n dds: \"ddsJson\"\n});\n\nconst IMAGE_MIME_TYPES = Object.freeze({\n png: \"image/png\",\n jpeg: \"image/jpeg\",\n jpg: \"image/jpeg\",\n tga: \"image/x-tga\",\n dds: \"image/vnd-ms.dds\"\n});\n\nexport function normalizeValues(base = DEFAULT_VALUES, options = {}, readerName = \"CjsImageFormat\")\n{\n const values = { ...DEFAULT_VALUES, ...(base || {}), ...(options || {}) };\n values.inputType = normalizeInputType(values.inputType);\n values.emit = normalizeEmit(values.emit, values.inputType, readerName);\n return values;\n}\n\nexport function normalizeInputType(inputType)\n{\n if (!inputType) return \"\";\n const value = String(inputType).replace(/^\\./u, \"\").toLowerCase();\n return value === \"jpg\" ? \"jpeg\" : value;\n}\n\nexport function normalizeEmit(emit, inputType, readerName)\n{\n if (emit === undefined || emit === null) return OUTPUT_RAW;\n if (emit === OUTPUT_JSON && inputType) return DEBUG_OUTPUTS[inputType] || OUTPUT_JSON;\n if ([ OUTPUT_IMAGE, OUTPUT_RGBA, OUTPUT_RAW, OUTPUT_JSON ].includes(emit)) return emit;\n if (Object.values(DEBUG_OUTPUTS).includes(emit)) return emit;\n throw new TypeError(`${readerName}: unknown emit value ${JSON.stringify(emit)}`);\n}\n\nexport function toBytes(input)\n{\n if (input instanceof Uint8Array) return input;\n if (input instanceof ArrayBuffer) return new Uint8Array(input);\n if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n throw new TypeError(\"Image input must be Uint8Array, ArrayBuffer, or DataView\");\n}\n\nexport function inspectWithValues(input, values = DEFAULT_VALUES, expectedType = \"\")\n{\n const bytes = toBytes(input);\n const detected = inspectBytes(bytes);\n const sourceFormat = expectedType || values.inputType || detected.sourceFormat;\n\n if (expectedType && detected.sourceFormat && detected.sourceFormat !== expectedType)\n {\n throw new TypeError(`CjsFormat${capitalize(expectedType)}: expected ${expectedType}, got ${detected.sourceFormat}`);\n }\n\n return {\n payloadType: sourceFormat === \"dds\" ? \"texture\" : \"image\",\n mediaTypes: sourceFormat === \"dds\" ? [ \"texture\", \"image\" ] : [ \"image\" ],\n sourceFormat,\n byteLength: bytes.byteLength,\n ...detected\n };\n}\n\nexport function isSupportedWithValues(input, values = DEFAULT_VALUES, expectedType = \"\")\n{\n try\n {\n const metadata = inspectWithValues(input, values, expectedType);\n const canDecode = metadata.sourceFormat === \"jpeg\" && canDecodeJpeg(metadata);\n const variants = [\n { kind: \"rgba\", payloadType: \"rgba\", codec: \"rgba8unorm\", supported: canDecode, reason: canDecode ? \"\" : jpegDecodeReason(metadata), containerOnly: false, isDecoded: canDecode, rgbaDecodeSupported: canDecode },\n rawVariant(metadata, canDecode)\n ];\n\n return {\n format: metadata.sourceFormat,\n source: values.source || \"buffer\",\n supported: metadata.sourceFormat ? (variants.some(variant => variant.supported && variant.kind === \"rgba\") ? \"full\" : \"partial\") : \"none\",\n confidence: metadata.sourceFormat ? 1 : 0,\n preferred: variants.find(v => v.supported)?.codec || \"\",\n reason: metadata.sourceFormat ? \"Container/header recognized.\" : \"Unrecognized image format.\",\n metadata,\n variants,\n warnings: [],\n errors: []\n };\n }\n catch (error)\n {\n return {\n format: expectedType || values.inputType || \"\",\n source: values.source || \"buffer\",\n supported: \"none\",\n confidence: 0,\n preferred: \"\",\n reason: error.message,\n metadata: null,\n variants: [],\n warnings: [],\n errors: [ error.message ]\n };\n }\n}\n\nexport function readWithValues(input, values = DEFAULT_VALUES, expectedType = \"\")\n{\n const bytes = toBytes(input);\n const metadata = inspectWithValues(bytes, values, expectedType);\n\n if (values.emit === OUTPUT_RAW)\n {\n return {\n payloadType: \"raw\",\n sourceFormat: metadata.sourceFormat,\n mimeType: imageMimeType(metadata.sourceFormat),\n containerOnly: true,\n isDecoded: false,\n rgbaDecodeSupported: metadata.sourceFormat === \"jpeg\" && canDecodeJpeg(metadata),\n metadata,\n bytes\n };\n }\n\n if (values.emit === OUTPUT_JSON || values.emit === DEBUG_OUTPUTS[metadata.sourceFormat])\n {\n return metadata;\n }\n\n if ((values.emit === OUTPUT_RGBA || values.emit === OUTPUT_IMAGE) && metadata.sourceFormat === \"jpeg\")\n {\n if (!canDecodeJpeg(metadata))\n {\n const error = new Error(`jpeg: ${jpegDecodeReason(metadata)}`);\n error.code = \"CJS_FORMAT_OUTPUT_UNSUPPORTED\";\n throw error;\n }\n return decodeJpegToRgba(bytes, metadata);\n }\n\n const error = new Error(`${metadata.sourceFormat}: emit \"${values.emit}\" is not implemented yet`);\n error.code = \"CJS_FORMAT_OUTPUT_NOT_IMPLEMENTED\";\n error.sourceFormat = metadata.sourceFormat;\n error.emit = values.emit;\n throw error;\n}\n\nfunction rawVariant(metadata, canDecode)\n{\n return {\n kind: \"raw\",\n payloadType: \"raw\",\n codec: metadata.sourceFormat,\n mimeType: imageMimeType(metadata.sourceFormat),\n supported: true,\n containerOnly: true,\n isDecoded: false,\n rgbaDecodeSupported: metadata.sourceFormat === \"jpeg\" && canDecode === true\n };\n}\n\nfunction imageMimeType(sourceFormat)\n{\n return IMAGE_MIME_TYPES[sourceFormat] || \"application/octet-stream\";\n}\n\nexport function toJsonValue(value)\n{\n if (value instanceof Uint8Array)\n {\n return { byteLength: value.byteLength };\n }\n if (Array.isArray(value)) return value.map(toJsonValue);\n if (value && typeof value === \"object\")\n {\n const output = {};\n for (const [ key, entry ] of Object.entries(value)) output[key] = toJsonValue(entry);\n return output;\n }\n return value;\n}\n\nexport function inspectBytes(bytes)\n{\n if (isPNG(bytes)) return inspectPNG(bytes);\n if (isJPEG(bytes)) return inspectJPEG(bytes);\n if (isDDS(bytes)) return inspectDDS(bytes);\n if (isTGA(bytes)) return inspectTGA(bytes);\n return { sourceFormat: \"\", width: 0, height: 0 };\n}\n\nexport function isPNG(bytes)\n{\n return bytes.byteLength >= 24 &&\n bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47 &&\n bytes[4] === 0x0d && bytes[5] === 0x0a && bytes[6] === 0x1a && bytes[7] === 0x0a;\n}\n\nexport function isJPEG(bytes)\n{\n return bytes.byteLength >= 4 && bytes[0] === 0xff && bytes[1] === 0xd8;\n}\n\nexport function isJPG(bytes)\n{\n return isJPEG(bytes);\n}\n\nexport function isDDS(bytes)\n{\n return bytes.byteLength >= 128 && bytes[0] === 0x44 && bytes[1] === 0x44 && bytes[2] === 0x53 && bytes[3] === 0x20;\n}\n\nexport function isTGA(bytes)\n{\n if (bytes.byteLength < 18) return false;\n const imageType = bytes[2], width = readU16LE(bytes, 12), height = readU16LE(bytes, 14), bpp = bytes[16];\n return width > 0 && height > 0 && [ 1, 2, 3, 9, 10, 11 ].includes(imageType) && [ 8, 16, 24, 32 ].includes(bpp);\n}\n\nfunction inspectPNG(bytes)\n{\n const colorType = bytes[25], bitDepth = bytes[24];\n return {\n sourceFormat: \"png\",\n width: readU32BE(bytes, 16),\n height: readU32BE(bytes, 20),\n bitDepth,\n colorType,\n channels: pngChannels(colorType),\n pixelFormat: `png-${bitDepth}-${colorType}`,\n isCompressed: false\n };\n}\n\nfunction inspectJPEG(bytes)\n{\n let offset = 2;\n let frame = null;\n const summary = {\n appMarkerCount: 0,\n commentCount: 0,\n hasExif: false,\n hasIccProfile: false\n };\n while (offset + 9 < bytes.byteLength)\n {\n if (bytes[offset] !== 0xff)\n {\n offset++;\n continue;\n }\n const marker = bytes[offset + 1], length = readU16BE(bytes, offset + 2);\n const dataStart = offset + 4;\n const dataEnd = offset + 2 + length;\n if (marker >= 0xe0 && marker <= 0xef)\n {\n summary.appMarkerCount++;\n if (marker === 0xe1 && ascii(bytes, dataStart, Math.min(6, dataEnd - dataStart)) === \"Exif\\0\\0\") summary.hasExif = true;\n if (marker === 0xe2 && ascii(bytes, dataStart, Math.min(12, dataEnd - dataStart)) === \"ICC_PROFILE\\0\") summary.hasIccProfile = true;\n }\n else if (marker === 0xfe)\n {\n summary.commentCount++;\n }\n if ([ 0xc0, 0xc1, 0xc2, 0xc3 ].includes(marker))\n {\n frame = {\n sourceFormat: \"jpeg\",\n width: readU16BE(bytes, offset + 7),\n height: readU16BE(bytes, offset + 5),\n channels: bytes[offset + 9],\n components: bytes[offset + 9],\n precision: bytes[offset + 4],\n marker,\n progressive: marker === 0xc2 || marker === 0xc3,\n pixelFormat: \"jpeg-ycbcr\",\n isCompressed: true\n };\n }\n if (marker === 0xda && frame)\n {\n const scanStart = offset + 4;\n const scanComponents = bytes[scanStart];\n const spectralStart = bytes[scanStart + 1 + scanComponents * 2];\n const spectralEnd = bytes[scanStart + 2 + scanComponents * 2];\n const successive = bytes[scanStart + 3 + scanComponents * 2];\n return {\n ...frame,\n ...summary,\n scanComponents,\n spectralStart,\n spectralEnd,\n successive,\n progressive: frame.progressive || spectralStart !== 0 || spectralEnd !== 63 || successive !== 0\n };\n }\n offset += Math.max(length + 2, 2);\n }\n return frame ? { ...frame, ...summary } : { sourceFormat: \"jpeg\", width: 0, height: 0, channels: 0, pixelFormat: \"jpeg\", isCompressed: true, ...summary };\n}\n\nfunction jpegDecodeReason(metadata)\n{\n if (metadata.sourceFormat !== \"jpeg\") return `${metadata.sourceFormat.toUpperCase()} RGBA decode is not implemented yet.`;\n if (metadata.progressive) return \"Progressive JPEG software decode is not implemented yet.\";\n if (metadata.marker !== undefined && metadata.marker !== 0xc0 && metadata.marker !== 0xc1)\n {\n return \"Only sequential baseline JPEG frames are supported by the software decoder.\";\n }\n if (metadata.precision !== undefined && metadata.precision !== 8)\n {\n return `JPEG sample precision ${metadata.precision} is not supported by the software decoder.`;\n }\n if (metadata.components > 3) return \"CMYK/YCCK JPEG software decode is not implemented yet.\";\n return \"JPEG baseline frame metadata is incomplete or unsupported.\";\n}\n\nfunction inspectDDS(bytes)\n{\n const fourCc = String.fromCharCode(bytes[84], bytes[85], bytes[86], bytes[87]).replace(/\\0+$/u, \"\");\n return {\n sourceFormat: \"dds\",\n width: readU32LE(bytes, 16),\n height: readU32LE(bytes, 12),\n mipCount: Math.max(readU32LE(bytes, 28), 1),\n fourCc,\n textureFormat: fourCc || \"dds-legacy\",\n isCompressed: !!fourCc,\n hasMipMaps: readU32LE(bytes, 28) > 1\n };\n}\n\nfunction inspectTGA(bytes)\n{\n return {\n sourceFormat: \"tga\",\n width: readU16LE(bytes, 12),\n height: readU16LE(bytes, 14),\n channels: Math.max(bytes[16] / 8, 1),\n imageType: bytes[2],\n pixelFormat: `tga-${bytes[16]}`,\n isCompressed: [ 9, 10, 11 ].includes(bytes[2])\n };\n}\n\nfunction pngChannels(colorType)\n{\n if (colorType === 0) return 1;\n if (colorType === 2) return 3;\n if (colorType === 3) return 1;\n if (colorType === 4) return 2;\n if (colorType === 6) return 4;\n return 0;\n}\n\nfunction readU16BE(bytes, offset)\n{\n return (bytes[offset] << 8) | bytes[offset + 1];\n}\n\nfunction readU16LE(bytes, offset)\n{\n return bytes[offset] | (bytes[offset + 1] << 8);\n}\n\nfunction readU32BE(bytes, offset)\n{\n return ((bytes[offset] * 0x1000000) + ((bytes[offset + 1] << 16) | (bytes[offset + 2] << 8) | bytes[offset + 3])) >>> 0;\n}\n\nfunction readU32LE(bytes, offset)\n{\n return (bytes[offset] | (bytes[offset + 1] << 8) | (bytes[offset + 2] << 16) | (bytes[offset + 3] * 0x1000000)) >>> 0;\n}\n\nfunction ascii(bytes, offset, length)\n{\n return String.fromCharCode(...bytes.subarray(offset, offset + length));\n}\n\nfunction capitalize(value)\n{\n return value ? value[0].toUpperCase() + value.slice(1) : \"Image\";\n}\n"],"names":["OUTPUT_IMAGE","OUTPUT_RGBA","OUTPUT_RAW","OUTPUT_JSON","DEFAULT_VALUES","Object","freeze","emit","inputType","source","DEBUG_OUTPUTS","png","jpeg","jpg","tga","dds","IMAGE_MIME_TYPES","normalizeValues","base","options","readerName","values","normalizeInputType","normalizeEmit","value","String","replace","toLowerCase","undefined","includes","TypeError","JSON","stringify","toBytes","input","Uint8Array","ArrayBuffer","isView","buffer","byteOffset","byteLength","inspectWithValues","expectedType","bytes","detected","inspectBytes","sourceFormat","capitalize","payloadType","mediaTypes","isSupportedWithValues","metadata","canDecode","canDecodeJpeg","variants","kind","codec","supported","reason","jpegDecodeReason","containerOnly","isDecoded","rgbaDecodeSupported","rawVariant","format","some","variant","confidence","preferred","find","v","warnings","errors","error","message","readWithValues","mimeType","imageMimeType","Error","code","decodeJpegToRgba","toJsonValue","Array","isArray","map","output","key","entry","entries","isPNG","inspectPNG","isJPEG","inspectJPEG","isDDS","inspectDDS","isTGA","inspectTGA","width","height","isJPG","imageType","readU16LE","bpp","colorType","bitDepth","readU32BE","channels","pngChannels","pixelFormat","isCompressed","offset","frame","summary","appMarkerCount","commentCount","hasExif","hasIccProfile","marker","length","readU16BE","dataStart","dataEnd","ascii","Math","min","components","precision","progressive","scanStart","scanComponents","spectralStart","spectralEnd","successive","max","toUpperCase","fourCc","fromCharCode","readU32LE","mipCount","textureFormat","hasMipMaps","subarray","slice"],"mappings":";;AAAO,MAAMA,YAAY,GAAG;AAErB,MAAMC,WAAW,GAAG;AACpB,MAAMC,UAAU,GAAG;AACnB,MAAMC,WAAW,GAAG;MAIdC,cAAc,GAAGC,MAAM,CAACC,MAAM,CAAC;AACxCC,EAAAA,IAAI,EAAEL,UAAU;AAChBM,EAAAA,SAAS,EAAE,EAAE;AACbC,EAAAA,MAAM,EAAE;AACZ,CAAC;AAED,MAAMC,aAAa,GAAGL,MAAM,CAACC,MAAM,CAAC;AAChCK,EAAAA,GAAG,EAAE,SAAS;AACdC,EAAAA,IAAI,EAAE,UAAU;AAChBC,EAAAA,GAAG,EAAE,UAAU;AACfC,EAAAA,GAAG,EAAE,SAAS;AACdC,EAAAA,GAAG,EAAE;AACT,CAAC,CAAC;AAEF,MAAMC,gBAAgB,GAAGX,MAAM,CAACC,MAAM,CAAC;AACnCK,EAAAA,GAAG,EAAE,WAAW;AAChBC,EAAAA,IAAI,EAAE,YAAY;AAClBC,EAAAA,GAAG,EAAE,YAAY;AACjBC,EAAAA,GAAG,EAAE,aAAa;AAClBC,EAAAA,GAAG,EAAE;AAC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