taglib-wasm 2.2.3 → 2.3.1
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/LICENSE +1 -1
- package/README.md +206 -21
- package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/assertClassBrand.js +7 -0
- package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/checkPrivateRedeclaration.js +6 -0
- package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/classPrivateFieldGet2.js +7 -0
- package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/classPrivateFieldInitSpec.js +7 -0
- package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/classPrivateFieldSet2.js +7 -0
- package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/defineProperty.js +12 -0
- package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/toPrimitive.js +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/toPropertyKey.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/typeof.js +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/usingCtx.js +57 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/bwf/bext.d.ts.map +1 -0
- package/dist/bwf/bext.js +119 -0
- package/dist/{src/constants → constants}/additional-properties.d.ts.map +1 -1
- package/dist/constants/additional-properties.js +270 -0
- package/dist/constants/basic-properties.d.ts.map +1 -0
- package/dist/constants/basic-properties.js +128 -0
- package/dist/constants/complex-properties.d.ts.map +1 -0
- package/dist/constants/complex-properties.js +1 -0
- package/dist/constants/format-mappings.d.ts.map +1 -0
- package/dist/constants/format-mappings.js +58 -0
- package/dist/{src/constants → constants}/general-extended-properties.d.ts.map +1 -1
- package/dist/constants/general-extended-properties.js +272 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +5 -0
- package/dist/{src/constants → constants}/properties.d.ts +1 -1
- package/dist/constants/properties.d.ts.map +1 -0
- package/dist/constants/properties.js +105 -0
- package/dist/constants/property-types.d.ts.map +1 -0
- package/dist/constants/property-types.js +1 -0
- package/dist/{src/constants → constants}/specialized-properties.d.ts.map +1 -1
- package/dist/constants/specialized-properties.js +335 -0
- package/dist/{src/constants → constants}/utilities.d.ts +1 -1
- package/dist/constants/utilities.d.ts.map +1 -0
- package/dist/constants/utilities.js +50 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +5 -0
- package/dist/{src/deno-compile.d.ts → deno-compile.d.ts} +4 -2
- package/dist/deno-compile.d.ts.map +1 -0
- package/dist/deno-compile.js +109 -0
- package/dist/disc-folder.d.ts +4 -4
- package/dist/disc-folder.d.ts.map +1 -1
- package/dist/disc-folder.js +596 -544
- package/dist/errors/base.d.ts +38 -0
- package/dist/errors/base.d.ts.map +1 -0
- package/dist/errors/base.js +66 -0
- package/dist/errors/classes.d.ts.map +1 -0
- package/dist/errors/classes.js +164 -0
- package/dist/errors/guards.d.ts.map +1 -0
- package/dist/errors/guards.js +26 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +4 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +5 -0
- package/dist/file-utils/copy-and-find.d.ts.map +1 -0
- package/dist/file-utils/copy-and-find.js +107 -0
- package/dist/file-utils/export-operations.d.ts.map +1 -0
- package/dist/file-utils/export-operations.js +84 -0
- package/dist/file-utils/import-operations.d.ts.map +1 -0
- package/dist/file-utils/import-operations.js +109 -0
- package/dist/file-utils/index.d.ts.map +1 -0
- package/dist/file-utils/index.js +5 -0
- package/dist/file-utils/mime-detection.d.ts.map +1 -0
- package/dist/file-utils/mime-detection.js +44 -0
- package/dist/folder-api/album-corroborate.d.ts.map +1 -0
- package/dist/folder-api/album-corroborate.js +35 -0
- package/dist/folder-api/album-discs.d.ts.map +1 -0
- package/dist/folder-api/album-discs.js +119 -0
- package/dist/folder-api/album-grouping.d.ts.map +1 -0
- package/dist/folder-api/album-grouping.js +161 -0
- package/dist/folder-api/album-identity.d.ts.map +1 -0
- package/dist/folder-api/album-identity.js +165 -0
- package/dist/folder-api/album-types.d.ts.map +1 -0
- package/dist/folder-api/album-types.js +1 -0
- package/dist/folder-api/directory-walker.d.ts.map +1 -0
- package/dist/folder-api/directory-walker.js +27 -0
- package/dist/folder-api/file-processors.d.ts.map +1 -0
- package/dist/folder-api/file-processors.js +52 -0
- package/dist/folder-api/folder-disc.d.ts.map +1 -0
- package/dist/folder-api/folder-disc.js +166 -0
- package/dist/folder-api/folder-operations.d.ts.map +1 -0
- package/dist/folder-api/folder-operations.js +69 -0
- package/dist/folder-api/index.d.ts.map +1 -0
- package/dist/{src/folder-api → folder-api}/index.js +1 -8
- package/dist/folder-api/scan-for-albums.d.ts.map +1 -0
- package/dist/folder-api/scan-for-albums.js +25 -0
- package/dist/folder-api/scan-operations.d.ts.map +1 -0
- package/dist/folder-api/scan-operations.js +79 -0
- package/dist/folder-api/types.d.ts.map +1 -0
- package/dist/folder-api/types.js +21 -0
- package/dist/folder.d.ts +1 -1
- package/dist/folder.d.ts.map +1 -1
- package/dist/folder.js +7 -2
- package/dist/global.d.js +1 -0
- package/dist/index.browser.d.ts +40 -21
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +4194 -3656
- package/dist/index.d.ts +26 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -183
- package/dist/msgpack/decoder.d.ts.map +1 -0
- package/dist/msgpack/decoder.js +177 -0
- package/dist/msgpack/encoder.d.ts.map +1 -0
- package/dist/msgpack/encoder.js +211 -0
- package/dist/msgpack/index.d.ts.map +1 -0
- package/dist/msgpack/index.js +5 -0
- package/dist/{src/msgpack → msgpack}/types.d.ts +1 -1
- package/dist/msgpack/types.d.ts.map +1 -0
- package/dist/msgpack/types.js +13 -0
- package/dist/msgpack/utils.d.ts.map +1 -0
- package/dist/msgpack/utils.js +116 -0
- package/dist/rating.d.ts +1 -1
- package/dist/rating.d.ts.map +1 -1
- package/dist/rating.js +2 -2
- package/dist/runtime/deno-detect.d.ts.map +1 -0
- package/dist/runtime/deno-detect.js +12 -0
- package/dist/{src/runtime → runtime}/detector.d.ts +2 -0
- package/dist/runtime/detector.d.ts.map +1 -0
- package/dist/runtime/detector.js +173 -0
- package/dist/runtime/loader-types.d.ts.map +1 -0
- package/dist/runtime/loader-types.js +23 -0
- package/dist/runtime/module-loader-browser.d.ts.map +1 -0
- package/dist/runtime/module-loader-browser.js +33 -0
- package/dist/runtime/module-loader.d.ts.map +1 -0
- package/dist/runtime/module-loader.js +119 -0
- package/dist/runtime/platform-io.d.ts.map +1 -0
- package/dist/runtime/platform-io.js +153 -0
- package/dist/runtime/unified-loader/index.d.ts.map +1 -0
- package/dist/{src/runtime → runtime}/unified-loader/index.js +1 -7
- package/dist/runtime/unified-loader/loader.d.ts.map +1 -0
- package/dist/runtime/unified-loader/loader.js +64 -0
- package/dist/runtime/unified-loader/module-loading.d.ts.map +1 -0
- package/dist/runtime/unified-loader/module-loading.js +90 -0
- package/dist/runtime/unified-loader/module-selection.d.ts.map +1 -0
- package/dist/runtime/unified-loader/module-selection.js +25 -0
- package/dist/runtime/unified-loader/types.d.ts.map +1 -0
- package/dist/runtime/unified-loader/types.js +24 -0
- package/dist/{src/runtime → runtime}/wasi-adapter/adapter.d.ts +13 -1
- package/dist/runtime/wasi-adapter/adapter.d.ts.map +1 -0
- package/dist/runtime/wasi-adapter/adapter.js +114 -0
- package/dist/{src/runtime → runtime}/wasi-adapter/audio-properties.d.ts +4 -1
- package/dist/runtime/wasi-adapter/audio-properties.d.ts.map +1 -0
- package/dist/runtime/wasi-adapter/audio-properties.js +120 -0
- package/dist/runtime/wasi-adapter/file-handle.d.ts.map +1 -0
- package/dist/runtime/wasi-adapter/file-handle.js +181 -0
- package/dist/runtime/wasi-adapter/handle-state.d.ts.map +1 -0
- package/dist/runtime/wasi-adapter/handle-state.js +48 -0
- package/dist/runtime/wasi-adapter/index.d.ts.map +1 -0
- package/dist/{src/runtime → runtime}/wasi-adapter/index.js +1 -3
- package/dist/runtime/wasi-adapter/mp4-items.d.ts.map +1 -0
- package/dist/runtime/wasi-adapter/mp4-items.js +97 -0
- package/dist/runtime/wasi-adapter/path-open.d.ts +68 -0
- package/dist/runtime/wasi-adapter/path-open.d.ts.map +1 -0
- package/dist/runtime/wasi-adapter/path-open.js +101 -0
- package/dist/runtime/wasi-adapter/property-surface.d.ts.map +1 -0
- package/dist/runtime/wasi-adapter/property-surface.js +96 -0
- package/dist/runtime/wasi-adapter/structured-fields.d.ts.map +1 -0
- package/dist/runtime/wasi-adapter/structured-fields.js +144 -0
- package/dist/runtime/wasi-adapter/tag-keys.d.ts.map +1 -0
- package/dist/runtime/wasi-adapter/tag-keys.js +65 -0
- package/dist/runtime/wasi-adapter/wasm-io.d.ts.map +1 -0
- package/dist/runtime/wasi-adapter/wasm-io.js +154 -0
- package/dist/runtime/wasi-fs-deno.d.ts.map +1 -0
- package/dist/runtime/wasi-fs-deno.js +25 -0
- package/dist/runtime/wasi-fs-node.d.ts.map +1 -0
- package/dist/runtime/wasi-fs-node.js +58 -0
- package/dist/runtime/wasi-fs-provider.d.ts.map +1 -0
- package/dist/runtime/wasi-fs-provider.js +1 -0
- package/dist/runtime/wasi-host-loader.d.ts.map +1 -0
- package/dist/runtime/wasi-host-loader.js +101 -0
- package/dist/runtime/wasi-host.d.ts.map +1 -0
- package/dist/runtime/wasi-host.js +199 -0
- package/dist/runtime/wasi-memory.d.ts.map +1 -0
- package/dist/runtime/wasi-memory.js +179 -0
- package/dist/{src/runtime → runtime}/wasmer-sdk-loader/types.d.ts +13 -0
- package/dist/runtime/wasmer-sdk-loader/types.d.ts.map +1 -0
- package/dist/runtime/wasmer-sdk-loader/types.js +15 -0
- package/dist/simple/batch-operations.d.ts.map +1 -0
- package/dist/simple/batch-operations.js +245 -0
- package/dist/simple/checksum-operations.d.ts +25 -0
- package/dist/simple/checksum-operations.d.ts.map +1 -0
- package/dist/simple/checksum-operations.js +28 -0
- package/dist/simple/config.d.ts.map +1 -0
- package/dist/simple/config.js +17 -0
- package/dist/{src/simple → simple}/index.d.ts +2 -0
- package/dist/simple/index.d.ts.map +1 -0
- package/dist/simple/index.js +8 -0
- package/dist/simple/picture-operations.d.ts.map +1 -0
- package/dist/simple/picture-operations.js +132 -0
- package/dist/simple/tag-operations.d.ts.map +1 -0
- package/dist/simple/tag-operations.js +125 -0
- package/dist/simple/with-audio-file.d.ts.map +1 -0
- package/dist/simple/with-audio-file.js +28 -0
- package/dist/simple.browser.d.ts +2 -2
- package/dist/simple.browser.d.ts.map +1 -1
- package/dist/simple.browser.js +3462 -3425
- package/dist/simple.d.ts +1 -1
- package/dist/simple.d.ts.map +1 -1
- package/dist/simple.js +8 -2
- package/dist/taglib/audio-file-base.d.ts.map +1 -0
- package/dist/taglib/audio-file-base.js +166 -0
- package/dist/taglib/audio-file-bwf.d.ts.map +1 -0
- package/dist/taglib/audio-file-bwf.js +33 -0
- package/dist/taglib/audio-file-checksum.d.ts +47 -0
- package/dist/taglib/audio-file-checksum.d.ts.map +1 -0
- package/dist/taglib/audio-file-checksum.js +90 -0
- package/dist/{src/taglib → taglib}/audio-file-impl.d.ts +4 -0
- package/dist/taglib/audio-file-impl.d.ts.map +1 -0
- package/dist/taglib/audio-file-impl.js +234 -0
- package/dist/{src/taglib → taglib}/audio-file-interface.d.ts +17 -0
- package/dist/taglib/audio-file-interface.d.ts.map +1 -0
- package/dist/taglib/audio-file-interface.js +1 -0
- package/dist/taglib/auto-dispose.d.ts.map +1 -0
- package/dist/taglib/auto-dispose.js +34 -0
- package/dist/taglib/embind-adapter.d.ts.map +1 -0
- package/dist/taglib/embind-adapter.js +137 -0
- package/dist/taglib/extra-state-registry.d.ts.map +1 -0
- package/dist/taglib/extra-state-registry.js +72 -0
- package/dist/{src/taglib → taglib}/id3v2-frames.d.ts +0 -1
- package/dist/taglib/id3v2-frames.d.ts.map +1 -0
- package/dist/taglib/id3v2-frames.js +25 -0
- package/dist/taglib/index.d.ts.map +1 -0
- package/dist/taglib/index.js +7 -0
- package/dist/taglib/load-audio-data.d.ts.map +1 -0
- package/dist/taglib/load-audio-data.js +54 -0
- package/dist/taglib/media-ranges.d.ts +85 -0
- package/dist/taglib/media-ranges.d.ts.map +1 -0
- package/dist/taglib/media-ranges.js +309 -0
- package/dist/taglib/metadata-extent.d.ts +96 -0
- package/dist/taglib/metadata-extent.d.ts.map +1 -0
- package/dist/taglib/metadata-extent.js +394 -0
- package/dist/taglib/mp4-item-names.d.ts.map +1 -0
- package/dist/taglib/mp4-item-names.js +14 -0
- package/dist/taglib/mutable-tag-impl.d.ts.map +1 -0
- package/dist/taglib/mutable-tag-impl.js +81 -0
- package/dist/taglib/mutable-tag.d.ts.map +1 -0
- package/dist/taglib/mutable-tag.js +1 -0
- package/dist/taglib/save-reconstruct.d.ts.map +1 -0
- package/dist/taglib/save-reconstruct.js +53 -0
- package/dist/taglib/taglib-class.d.ts.map +1 -0
- package/dist/taglib/taglib-class.js +146 -0
- package/dist/taglib-wasi.wasm +0 -0
- package/dist/taglib-web.wasm +0 -0
- package/dist/taglib-wrapper.js +1 -1
- package/dist/taglib.d.ts.map +1 -0
- package/dist/taglib.js +7 -0
- package/dist/types/audio-formats.d.ts.map +1 -0
- package/dist/types/audio-formats.js +6 -0
- package/dist/types/bwf.d.ts.map +1 -0
- package/dist/types/bwf.js +1 -0
- package/dist/types/chapters.d.ts.map +1 -0
- package/dist/types/chapters.js +1 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +1 -0
- package/dist/types/format-property-keys.d.ts.map +1 -0
- package/dist/types/format-property-keys.js +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +9 -0
- package/dist/types/metadata-mappings.d.ts.map +1 -0
- package/dist/types/metadata-mappings.js +323 -0
- package/dist/types/pictures.d.ts.map +1 -0
- package/dist/types/pictures.js +79 -0
- package/dist/types/tags.d.ts.map +1 -0
- package/dist/types/tags.js +1 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +43 -0
- package/dist/utils/mirror-fields.d.ts.map +1 -0
- package/dist/utils/mirror-fields.js +107 -0
- package/dist/utils/node-fs.d.ts.map +1 -0
- package/dist/utils/node-fs.js +36 -0
- package/dist/utils/path.d.ts +26 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +52 -0
- package/dist/utils/rating.d.ts.map +1 -0
- package/dist/utils/rating.js +150 -0
- package/dist/utils/tag-mapping.d.ts.map +1 -0
- package/dist/utils/tag-mapping.js +207 -0
- package/dist/utils/write.d.ts.map +1 -0
- package/dist/utils/write.js +18 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +4 -0
- package/dist/{src/wasm.d.ts → wasm.d.ts} +9 -0
- package/dist/wasm.d.ts.map +1 -0
- package/dist/wasm.js +1 -0
- package/dist/web-utils/canvas.d.ts.map +1 -0
- package/dist/web-utils/canvas.js +97 -0
- package/dist/web-utils/data-url.d.ts.map +1 -0
- package/dist/web-utils/data-url.js +54 -0
- package/dist/web-utils/dom-integration.d.ts.map +1 -0
- package/dist/web-utils/dom-integration.js +105 -0
- package/dist/web-utils/index.d.ts.map +1 -0
- package/dist/web-utils/index.js +4 -0
- package/dist/web.browser.d.ts +13 -0
- package/dist/web.browser.d.ts.map +1 -0
- package/dist/web.browser.js +3387 -0
- package/dist/web.d.ts +1 -1
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +5 -2
- package/package.json +140 -97
- package/dist/src/bwf/bext.d.ts.map +0 -1
- package/dist/src/bwf/bext.js +0 -126
- package/dist/src/constants/additional-properties.js +0 -204
- package/dist/src/constants/basic-properties.d.ts.map +0 -1
- package/dist/src/constants/basic-properties.js +0 -89
- package/dist/src/constants/complex-properties.d.ts.map +0 -1
- package/dist/src/constants/complex-properties.js +0 -0
- package/dist/src/constants/format-mappings.d.ts.map +0 -1
- package/dist/src/constants/format-mappings.js +0 -54
- package/dist/src/constants/general-extended-properties.js +0 -254
- package/dist/src/constants/index.d.ts.map +0 -1
- package/dist/src/constants/index.js +0 -4
- package/dist/src/constants/properties.d.ts.map +0 -1
- package/dist/src/constants/properties.js +0 -95
- package/dist/src/constants/property-types.d.ts.map +0 -1
- package/dist/src/constants/property-types.js +0 -0
- package/dist/src/constants/specialized-properties.js +0 -223
- package/dist/src/constants/utilities.d.ts.map +0 -1
- package/dist/src/constants/utilities.js +0 -33
- package/dist/src/constants.d.ts.map +0 -1
- package/dist/src/constants.js +0 -1
- package/dist/src/deno-compile.d.ts.map +0 -1
- package/dist/src/deno-compile.js +0 -75
- package/dist/src/errors/base.d.ts +0 -23
- package/dist/src/errors/base.d.ts.map +0 -1
- package/dist/src/errors/base.js +0 -31
- package/dist/src/errors/classes.d.ts.map +0 -1
- package/dist/src/errors/classes.js +0 -170
- package/dist/src/errors/guards.d.ts.map +0 -1
- package/dist/src/errors/guards.js +0 -39
- package/dist/src/errors/index.d.ts.map +0 -1
- package/dist/src/errors/index.js +0 -39
- package/dist/src/errors.d.ts.map +0 -1
- package/dist/src/errors.js +0 -1
- package/dist/src/file-utils/copy-and-find.d.ts.map +0 -1
- package/dist/src/file-utils/copy-and-find.js +0 -89
- package/dist/src/file-utils/export-operations.d.ts.map +0 -1
- package/dist/src/file-utils/export-operations.js +0 -40
- package/dist/src/file-utils/import-operations.d.ts.map +0 -1
- package/dist/src/file-utils/import-operations.js +0 -42
- package/dist/src/file-utils/index.d.ts.map +0 -1
- package/dist/src/file-utils/index.js +0 -26
- package/dist/src/file-utils/mime-detection.d.ts.map +0 -1
- package/dist/src/file-utils/mime-detection.js +0 -45
- package/dist/src/folder-api/album-corroborate.d.ts.map +0 -1
- package/dist/src/folder-api/album-corroborate.js +0 -36
- package/dist/src/folder-api/album-discs.d.ts.map +0 -1
- package/dist/src/folder-api/album-discs.js +0 -122
- package/dist/src/folder-api/album-grouping.d.ts.map +0 -1
- package/dist/src/folder-api/album-grouping.js +0 -118
- package/dist/src/folder-api/album-identity.d.ts.map +0 -1
- package/dist/src/folder-api/album-identity.js +0 -151
- package/dist/src/folder-api/album-types.d.ts.map +0 -1
- package/dist/src/folder-api/album-types.js +0 -0
- package/dist/src/folder-api/directory-walker.d.ts.map +0 -1
- package/dist/src/folder-api/directory-walker.js +0 -35
- package/dist/src/folder-api/file-processors.d.ts.map +0 -1
- package/dist/src/folder-api/file-processors.js +0 -63
- package/dist/src/folder-api/folder-disc.d.ts.map +0 -1
- package/dist/src/folder-api/folder-disc.js +0 -169
- package/dist/src/folder-api/folder-operations.d.ts.map +0 -1
- package/dist/src/folder-api/folder-operations.js +0 -54
- package/dist/src/folder-api/index.d.ts.map +0 -1
- package/dist/src/folder-api/scan-for-albums.d.ts.map +0 -1
- package/dist/src/folder-api/scan-for-albums.js +0 -20
- package/dist/src/folder-api/scan-operations.d.ts.map +0 -1
- package/dist/src/folder-api/scan-operations.js +0 -77
- package/dist/src/folder-api/types.d.ts.map +0 -1
- package/dist/src/folder-api/types.js +0 -21
- package/dist/src/msgpack/decoder.d.ts.map +0 -1
- package/dist/src/msgpack/decoder.js +0 -215
- package/dist/src/msgpack/encoder.d.ts.map +0 -1
- package/dist/src/msgpack/encoder.js +0 -249
- package/dist/src/msgpack/index.d.ts.map +0 -1
- package/dist/src/msgpack/index.js +0 -56
- package/dist/src/msgpack/types.d.ts.map +0 -1
- package/dist/src/msgpack/types.js +0 -12
- package/dist/src/msgpack/utils.d.ts.map +0 -1
- package/dist/src/msgpack/utils.js +0 -134
- package/dist/src/runtime/deno-detect.d.ts.map +0 -1
- package/dist/src/runtime/deno-detect.js +0 -6
- package/dist/src/runtime/detector.d.ts.map +0 -1
- package/dist/src/runtime/detector.js +0 -181
- package/dist/src/runtime/loader-types.d.ts.map +0 -1
- package/dist/src/runtime/loader-types.js +0 -10
- package/dist/src/runtime/module-loader-browser.d.ts.map +0 -1
- package/dist/src/runtime/module-loader-browser.js +0 -37
- package/dist/src/runtime/module-loader.d.ts.map +0 -1
- package/dist/src/runtime/module-loader.js +0 -119
- package/dist/src/runtime/platform-io.d.ts.map +0 -1
- package/dist/src/runtime/platform-io.js +0 -188
- package/dist/src/runtime/unified-loader/index.d.ts.map +0 -1
- package/dist/src/runtime/unified-loader/loader.d.ts.map +0 -1
- package/dist/src/runtime/unified-loader/loader.js +0 -84
- package/dist/src/runtime/unified-loader/module-loading.d.ts.map +0 -1
- package/dist/src/runtime/unified-loader/module-loading.js +0 -122
- package/dist/src/runtime/unified-loader/module-selection.d.ts.map +0 -1
- package/dist/src/runtime/unified-loader/module-selection.js +0 -41
- package/dist/src/runtime/unified-loader/types.d.ts.map +0 -1
- package/dist/src/runtime/unified-loader/types.js +0 -25
- package/dist/src/runtime/wasi-adapter/adapter.d.ts.map +0 -1
- package/dist/src/runtime/wasi-adapter/adapter.js +0 -113
- package/dist/src/runtime/wasi-adapter/audio-properties.d.ts.map +0 -1
- package/dist/src/runtime/wasi-adapter/audio-properties.js +0 -85
- package/dist/src/runtime/wasi-adapter/file-handle.d.ts.map +0 -1
- package/dist/src/runtime/wasi-adapter/file-handle.js +0 -197
- package/dist/src/runtime/wasi-adapter/handle-state.d.ts.map +0 -1
- package/dist/src/runtime/wasi-adapter/handle-state.js +0 -58
- package/dist/src/runtime/wasi-adapter/index.d.ts.map +0 -1
- package/dist/src/runtime/wasi-adapter/mp4-items.d.ts.map +0 -1
- package/dist/src/runtime/wasi-adapter/mp4-items.js +0 -80
- package/dist/src/runtime/wasi-adapter/property-surface.d.ts.map +0 -1
- package/dist/src/runtime/wasi-adapter/property-surface.js +0 -104
- package/dist/src/runtime/wasi-adapter/structured-fields.d.ts.map +0 -1
- package/dist/src/runtime/wasi-adapter/structured-fields.js +0 -139
- package/dist/src/runtime/wasi-adapter/tag-keys.d.ts.map +0 -1
- package/dist/src/runtime/wasi-adapter/tag-keys.js +0 -46
- package/dist/src/runtime/wasi-adapter/wasm-io.d.ts.map +0 -1
- package/dist/src/runtime/wasi-adapter/wasm-io.js +0 -249
- package/dist/src/runtime/wasi-fs-deno.d.ts.map +0 -1
- package/dist/src/runtime/wasi-fs-deno.js +0 -26
- package/dist/src/runtime/wasi-fs-node.d.ts.map +0 -1
- package/dist/src/runtime/wasi-fs-node.js +0 -66
- package/dist/src/runtime/wasi-fs-provider.d.ts.map +0 -1
- package/dist/src/runtime/wasi-fs-provider.js +0 -0
- package/dist/src/runtime/wasi-host-loader.d.ts.map +0 -1
- package/dist/src/runtime/wasi-host-loader.js +0 -109
- package/dist/src/runtime/wasi-host.d.ts.map +0 -1
- package/dist/src/runtime/wasi-host.js +0 -202
- package/dist/src/runtime/wasi-memory.d.ts.map +0 -1
- package/dist/src/runtime/wasi-memory.js +0 -197
- package/dist/src/runtime/wasmer-sdk-loader/types.d.ts.map +0 -1
- package/dist/src/runtime/wasmer-sdk-loader/types.js +0 -12
- package/dist/src/simple/batch-operations.d.ts.map +0 -1
- package/dist/src/simple/batch-operations.js +0 -186
- package/dist/src/simple/config.d.ts.map +0 -1
- package/dist/src/simple/config.js +0 -18
- package/dist/src/simple/index.d.ts.map +0 -1
- package/dist/src/simple/index.js +0 -58
- package/dist/src/simple/picture-operations.d.ts.map +0 -1
- package/dist/src/simple/picture-operations.js +0 -68
- package/dist/src/simple/tag-operations.d.ts.map +0 -1
- package/dist/src/simple/tag-operations.js +0 -90
- package/dist/src/simple/with-audio-file.d.ts.map +0 -1
- package/dist/src/simple/with-audio-file.js +0 -39
- package/dist/src/taglib/audio-file-base.d.ts.map +0 -1
- package/dist/src/taglib/audio-file-base.js +0 -187
- package/dist/src/taglib/audio-file-bwf.d.ts.map +0 -1
- package/dist/src/taglib/audio-file-bwf.js +0 -41
- package/dist/src/taglib/audio-file-impl.d.ts.map +0 -1
- package/dist/src/taglib/audio-file-impl.js +0 -285
- package/dist/src/taglib/audio-file-interface.d.ts.map +0 -1
- package/dist/src/taglib/audio-file-interface.js +0 -0
- package/dist/src/taglib/auto-dispose.d.ts.map +0 -1
- package/dist/src/taglib/auto-dispose.js +0 -13
- package/dist/src/taglib/embind-adapter.d.ts.map +0 -1
- package/dist/src/taglib/embind-adapter.js +0 -141
- package/dist/src/taglib/extra-state-registry.d.ts.map +0 -1
- package/dist/src/taglib/extra-state-registry.js +0 -78
- package/dist/src/taglib/id3v2-frames.d.ts.map +0 -1
- package/dist/src/taglib/id3v2-frames.js +0 -42
- package/dist/src/taglib/index.d.ts.map +0 -1
- package/dist/src/taglib/index.js +0 -41
- package/dist/src/taglib/load-audio-data.d.ts.map +0 -1
- package/dist/src/taglib/load-audio-data.js +0 -51
- package/dist/src/taglib/metadata-extent.d.ts +0 -41
- package/dist/src/taglib/metadata-extent.d.ts.map +0 -1
- package/dist/src/taglib/metadata-extent.js +0 -171
- package/dist/src/taglib/mp4-item-names.d.ts.map +0 -1
- package/dist/src/taglib/mp4-item-names.js +0 -4
- package/dist/src/taglib/mutable-tag-impl.d.ts.map +0 -1
- package/dist/src/taglib/mutable-tag-impl.js +0 -88
- package/dist/src/taglib/mutable-tag.d.ts.map +0 -1
- package/dist/src/taglib/mutable-tag.js +0 -0
- package/dist/src/taglib/save-reconstruct.d.ts.map +0 -1
- package/dist/src/taglib/save-reconstruct.js +0 -43
- package/dist/src/taglib/taglib-class.d.ts.map +0 -1
- package/dist/src/taglib/taglib-class.js +0 -206
- package/dist/src/taglib.d.ts.map +0 -1
- package/dist/src/taglib.js +0 -1
- package/dist/src/types/audio-formats.d.ts.map +0 -1
- package/dist/src/types/audio-formats.js +0 -6
- package/dist/src/types/bwf.d.ts.map +0 -1
- package/dist/src/types/bwf.js +0 -0
- package/dist/src/types/chapters.d.ts.map +0 -1
- package/dist/src/types/chapters.js +0 -0
- package/dist/src/types/config.d.ts.map +0 -1
- package/dist/src/types/config.js +0 -0
- package/dist/src/types/format-property-keys.d.ts.map +0 -1
- package/dist/src/types/format-property-keys.js +0 -0
- package/dist/src/types/index.d.ts.map +0 -1
- package/dist/src/types/index.js +0 -8
- package/dist/src/types/metadata-mappings.d.ts.map +0 -1
- package/dist/src/types/metadata-mappings.js +0 -252
- package/dist/src/types/pictures.d.ts.map +0 -1
- package/dist/src/types/pictures.js +0 -64
- package/dist/src/types/tags.d.ts.map +0 -1
- package/dist/src/types/tags.js +0 -0
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -1
- package/dist/src/utils/file.d.ts.map +0 -1
- package/dist/src/utils/file.js +0 -52
- package/dist/src/utils/mirror-fields.d.ts.map +0 -1
- package/dist/src/utils/mirror-fields.js +0 -75
- package/dist/src/utils/node-fs.d.ts.map +0 -1
- package/dist/src/utils/node-fs.js +0 -22
- package/dist/src/utils/path.d.ts +0 -14
- package/dist/src/utils/path.d.ts.map +0 -1
- package/dist/src/utils/path.js +0 -17
- package/dist/src/utils/rating.d.ts.map +0 -1
- package/dist/src/utils/rating.js +0 -73
- package/dist/src/utils/tag-mapping.d.ts.map +0 -1
- package/dist/src/utils/tag-mapping.js +0 -214
- package/dist/src/utils/write.d.ts.map +0 -1
- package/dist/src/utils/write.js +0 -17
- package/dist/src/version.d.ts +0 -2
- package/dist/src/version.d.ts.map +0 -1
- package/dist/src/version.js +0 -4
- package/dist/src/wasm.d.ts.map +0 -1
- package/dist/src/wasm.js +0 -0
- package/dist/src/web-utils/canvas.d.ts.map +0 -1
- package/dist/src/web-utils/canvas.js +0 -60
- package/dist/src/web-utils/data-url.d.ts.map +0 -1
- package/dist/src/web-utils/data-url.js +0 -34
- package/dist/src/web-utils/dom-integration.d.ts.map +0 -1
- package/dist/src/web-utils/dom-integration.js +0 -53
- package/dist/src/web-utils/index.d.ts.map +0 -1
- package/dist/src/web-utils/index.js +0 -21
- /package/dist/{src/bwf → bwf}/bext.d.ts +0 -0
- /package/dist/{src/constants → constants}/additional-properties.d.ts +0 -0
- /package/dist/{src/constants → constants}/basic-properties.d.ts +0 -0
- /package/dist/{src/constants → constants}/complex-properties.d.ts +0 -0
- /package/dist/{src/constants → constants}/format-mappings.d.ts +0 -0
- /package/dist/{src/constants → constants}/general-extended-properties.d.ts +0 -0
- /package/dist/{src/constants → constants}/index.d.ts +0 -0
- /package/dist/{src/constants → constants}/property-types.d.ts +0 -0
- /package/dist/{src/constants → constants}/specialized-properties.d.ts +0 -0
- /package/dist/{src/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/{src/errors → errors}/classes.d.ts +0 -0
- /package/dist/{src/errors → errors}/guards.d.ts +0 -0
- /package/dist/{src/errors → errors}/index.d.ts +0 -0
- /package/dist/{src/errors.d.ts → errors.d.ts} +0 -0
- /package/dist/{src/file-utils → file-utils}/copy-and-find.d.ts +0 -0
- /package/dist/{src/file-utils → file-utils}/export-operations.d.ts +0 -0
- /package/dist/{src/file-utils → file-utils}/import-operations.d.ts +0 -0
- /package/dist/{src/file-utils → file-utils}/index.d.ts +0 -0
- /package/dist/{src/file-utils → file-utils}/mime-detection.d.ts +0 -0
- /package/dist/{src/folder-api → folder-api}/album-corroborate.d.ts +0 -0
- /package/dist/{src/folder-api → folder-api}/album-discs.d.ts +0 -0
- /package/dist/{src/folder-api → folder-api}/album-grouping.d.ts +0 -0
- /package/dist/{src/folder-api → folder-api}/album-identity.d.ts +0 -0
- /package/dist/{src/folder-api → folder-api}/album-types.d.ts +0 -0
- /package/dist/{src/folder-api → folder-api}/directory-walker.d.ts +0 -0
- /package/dist/{src/folder-api → folder-api}/file-processors.d.ts +0 -0
- /package/dist/{src/folder-api → folder-api}/folder-disc.d.ts +0 -0
- /package/dist/{src/folder-api → folder-api}/folder-operations.d.ts +0 -0
- /package/dist/{src/folder-api → folder-api}/index.d.ts +0 -0
- /package/dist/{src/folder-api → folder-api}/scan-for-albums.d.ts +0 -0
- /package/dist/{src/folder-api → folder-api}/scan-operations.d.ts +0 -0
- /package/dist/{src/folder-api → folder-api}/types.d.ts +0 -0
- /package/dist/{src/msgpack → msgpack}/decoder.d.ts +0 -0
- /package/dist/{src/msgpack → msgpack}/encoder.d.ts +0 -0
- /package/dist/{src/msgpack → msgpack}/index.d.ts +0 -0
- /package/dist/{src/msgpack → msgpack}/utils.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/deno-detect.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/loader-types.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/module-loader-browser.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/module-loader.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/platform-io.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/unified-loader/index.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/unified-loader/loader.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/unified-loader/module-loading.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/unified-loader/module-selection.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/unified-loader/types.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/wasi-adapter/file-handle.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/wasi-adapter/handle-state.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/wasi-adapter/index.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/wasi-adapter/mp4-items.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/wasi-adapter/property-surface.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/wasi-adapter/structured-fields.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/wasi-adapter/tag-keys.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/wasi-adapter/wasm-io.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/wasi-fs-deno.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/wasi-fs-node.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/wasi-fs-provider.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/wasi-host-loader.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/wasi-host.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/wasi-memory.d.ts +0 -0
- /package/dist/{src/simple → simple}/batch-operations.d.ts +0 -0
- /package/dist/{src/simple → simple}/config.d.ts +0 -0
- /package/dist/{src/simple → simple}/picture-operations.d.ts +0 -0
- /package/dist/{src/simple → simple}/tag-operations.d.ts +0 -0
- /package/dist/{src/simple → simple}/with-audio-file.d.ts +0 -0
- /package/dist/{src/taglib → taglib}/audio-file-base.d.ts +0 -0
- /package/dist/{src/taglib → taglib}/audio-file-bwf.d.ts +0 -0
- /package/dist/{src/taglib → taglib}/auto-dispose.d.ts +0 -0
- /package/dist/{src/taglib → taglib}/embind-adapter.d.ts +0 -0
- /package/dist/{src/taglib → taglib}/extra-state-registry.d.ts +0 -0
- /package/dist/{src/taglib → taglib}/index.d.ts +0 -0
- /package/dist/{src/taglib → taglib}/load-audio-data.d.ts +0 -0
- /package/dist/{src/taglib → taglib}/mp4-item-names.d.ts +0 -0
- /package/dist/{src/taglib → taglib}/mutable-tag-impl.d.ts +0 -0
- /package/dist/{src/taglib → taglib}/mutable-tag.d.ts +0 -0
- /package/dist/{src/taglib → taglib}/save-reconstruct.d.ts +0 -0
- /package/dist/{src/taglib → taglib}/taglib-class.d.ts +0 -0
- /package/dist/{src/taglib.d.ts → taglib.d.ts} +0 -0
- /package/dist/{src/types → types}/audio-formats.d.ts +0 -0
- /package/dist/{src/types → types}/bwf.d.ts +0 -0
- /package/dist/{src/types → types}/chapters.d.ts +0 -0
- /package/dist/{src/types → types}/config.d.ts +0 -0
- /package/dist/{src/types → types}/format-property-keys.d.ts +0 -0
- /package/dist/{src/types → types}/index.d.ts +0 -0
- /package/dist/{src/types → types}/metadata-mappings.d.ts +0 -0
- /package/dist/{src/types → types}/pictures.d.ts +0 -0
- /package/dist/{src/types → types}/tags.d.ts +0 -0
- /package/dist/{src/types.d.ts → types.d.ts} +0 -0
- /package/dist/{src/utils → utils}/file.d.ts +0 -0
- /package/dist/{src/utils → utils}/mirror-fields.d.ts +0 -0
- /package/dist/{src/utils → utils}/node-fs.d.ts +0 -0
- /package/dist/{src/utils → utils}/rating.d.ts +0 -0
- /package/dist/{src/utils → utils}/tag-mapping.d.ts +0 -0
- /package/dist/{src/utils → utils}/write.d.ts +0 -0
- /package/dist/{src/web-utils → web-utils}/canvas.d.ts +0 -0
- /package/dist/{src/web-utils → web-utils}/data-url.d.ts +0 -0
- /package/dist/{src/web-utils → web-utils}/dom-integration.d.ts +0 -0
- /package/dist/{src/web-utils → web-utils}/index.d.ts +0 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { flacAudioStart, flacMarkerOffset, id3v2End, mpegFrameLength } from "./metadata-extent.js";
|
|
2
|
+
//#region src/taglib/media-ranges.ts
|
|
3
|
+
const decoder = new TextDecoder();
|
|
4
|
+
const text = (b, o, n) => decoder.decode(b.subarray(o, o + n));
|
|
5
|
+
/** Every walk's "I cannot vouch for this" answer: the caller then hashes the
|
|
6
|
+
* whole file and reports source: "file". */
|
|
7
|
+
const fallback = (detail) => ({
|
|
8
|
+
kind: "fallback",
|
|
9
|
+
ranges: [],
|
|
10
|
+
detail
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* ADTS (raw AAC) frame length: 13 bits spanning bytes 3..5, header included.
|
|
14
|
+
* Syncword 0xFFF plus the layer bits that must be zero — which is exactly the
|
|
15
|
+
* header `mpegFrameLength` rejects (metadata-extent.ts returns 0 for
|
|
16
|
+
* `layer === 0`), so this is a rule of its own rather than a variant of it.
|
|
17
|
+
*/
|
|
18
|
+
function adtsFrameLength(bytes, at) {
|
|
19
|
+
if (bytes.length < at + 7) return 0;
|
|
20
|
+
if (bytes[at] !== 255 || (bytes[at + 1] & 246) !== 240) return 0;
|
|
21
|
+
const length = (bytes[at + 3] & 3) << 11 | bytes[at + 4] << 3 | bytes[at + 5] >> 5;
|
|
22
|
+
return length >= 7 ? length : 0;
|
|
23
|
+
}
|
|
24
|
+
/** The frame length either rule recognises at `at`, or 0. */
|
|
25
|
+
const frameLengthAt = (bytes, at) => mpegFrameLength(bytes, at) || adtsFrameLength(bytes, at);
|
|
26
|
+
/**
|
|
27
|
+
* Start offset of a trailing tag run (ID3v1 and/or APEv2), scanning inward.
|
|
28
|
+
* TagLib ends a FLAC stream at its ID3v1 location for the same reason.
|
|
29
|
+
*/
|
|
30
|
+
function trailingTagStart(bytes, end = bytes.length) {
|
|
31
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
32
|
+
let at = Math.max(0, Math.min(end, bytes.length));
|
|
33
|
+
for (;;) {
|
|
34
|
+
if (at >= 128 && text(bytes, at - 128, 3) === "TAG") {
|
|
35
|
+
at -= 128;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (at >= 32 && text(bytes, at - 32, 8) === "APETAGEX") {
|
|
39
|
+
const size = view.getUint32(at - 32 + 12, true);
|
|
40
|
+
const flags = view.getUint32(at - 32 + 20, true);
|
|
41
|
+
const start = at - size - ((flags & 2147483648) !== 0 ? 32 : 0);
|
|
42
|
+
if (start < 0 || start >= at) return at;
|
|
43
|
+
at = start;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
return at;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** How far past the scan's start the MPEG first-frame hunt will look. A file
|
|
50
|
+
* whose audio does not start within this window is not one whose offsets this
|
|
51
|
+
* walk may vouch for, and an unbounded hunt turns a junk buffer into a
|
|
52
|
+
* quadratic scan. That bound is also why an MP3 with a large APEv2 tag *in
|
|
53
|
+
* front of* the audio falls back rather than guessing: `id3v2End` skips only
|
|
54
|
+
* ID3v2 (measured: a 70 KiB front area puts the first frame past the window and
|
|
55
|
+
* the walk falls back, while a 1 KiB one is found normally). */
|
|
56
|
+
const MPEG_SCAN_LIMIT = 65536;
|
|
57
|
+
/**
|
|
58
|
+
* First frame: skip ID3v2, then require two consecutive plausible frames. The
|
|
59
|
+
* hunt is bounded to `MPEG_SCAN_LIMIT` past the scan's start so a junk buffer
|
|
60
|
+
* cannot turn into a quadratic scan.
|
|
61
|
+
*/
|
|
62
|
+
function firstFrame(bytes) {
|
|
63
|
+
const from = id3v2End(bytes) ?? 0;
|
|
64
|
+
const limit = Math.min(bytes.length - 6, from + MPEG_SCAN_LIMIT);
|
|
65
|
+
for (let o = from; o < limit; o++) {
|
|
66
|
+
const len = frameLengthAt(bytes, o);
|
|
67
|
+
if (len > 0 && frameLengthAt(bytes, o + len) > 0) return o;
|
|
68
|
+
}
|
|
69
|
+
return -1;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Forward walk from the first frame to the last: the authority for where the
|
|
73
|
+
* payload ends, O(frames).
|
|
74
|
+
*
|
|
75
|
+
* There is deliberately no backward scan to cross-check it. The spike used one
|
|
76
|
+
* to derive the boundary rule — a reverse scan is O(payload) per file, and a
|
|
77
|
+
* candidate that merely "fits inside" the payload is not the last frame, because
|
|
78
|
+
* a false sync can sit within the last frame's own payload (measured on
|
|
79
|
+
* kiss-snippet.mp3: an offer at 84558+72 inside the real frame ending at 85226).
|
|
80
|
+
* The rule that survived is "stop on the first frame that would cross the
|
|
81
|
+
* boundary": the payload ends at the last frame that ends at or before it, so
|
|
82
|
+
* the walk can stop short of the boundary rather than land on it — on
|
|
83
|
+
* ape-id3v1.mp3 it ends at 8150 against a trim boundary of 8208. A reverse pass
|
|
84
|
+
* could never change that answer, and would run in addition to the forward walk
|
|
85
|
+
* rather than instead of it.
|
|
86
|
+
*/
|
|
87
|
+
function forwardLastFrame(bytes, from, end) {
|
|
88
|
+
let o = from;
|
|
89
|
+
let start = -1;
|
|
90
|
+
let length = 0;
|
|
91
|
+
let frames = 0;
|
|
92
|
+
while (o + 6 <= end) {
|
|
93
|
+
const len = frameLengthAt(bytes, o);
|
|
94
|
+
if (len === 0 || o + len > end) break;
|
|
95
|
+
start = o;
|
|
96
|
+
length = len;
|
|
97
|
+
frames++;
|
|
98
|
+
o += len;
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
start,
|
|
102
|
+
length,
|
|
103
|
+
frames
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function walkMpeg(bytes) {
|
|
107
|
+
const from = firstFrame(bytes);
|
|
108
|
+
if (from < 0) return fallback("no valid first frame");
|
|
109
|
+
const last = forwardLastFrame(bytes, from, trailingTagStart(bytes));
|
|
110
|
+
if (last.start < 0) return fallback("no valid frames");
|
|
111
|
+
return {
|
|
112
|
+
kind: "ranges",
|
|
113
|
+
ranges: [{
|
|
114
|
+
offset: from,
|
|
115
|
+
length: last.start + last.length - from
|
|
116
|
+
}],
|
|
117
|
+
detail: `first=${from} last=${last.start}+${last.length} frames=${last.frames}`
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/** STREAMINFO is a FLAC file's first metadata block: the `fLaC` marker, a
|
|
121
|
+
* 4-byte block header, then its 34-byte payload, whose last 16 bytes are the
|
|
122
|
+
* MD5 of the *uncompressed* stream — the digest `basis: "pcm"` reports. */
|
|
123
|
+
function flacStreamInfoMd5(bytes) {
|
|
124
|
+
const marker = flacMarkerOffset(bytes);
|
|
125
|
+
if (marker === void 0) return void 0;
|
|
126
|
+
const header = marker + 4;
|
|
127
|
+
if (header + 4 > bytes.length) return void 0;
|
|
128
|
+
if ((bytes[header] & 127) !== 0) return void 0;
|
|
129
|
+
if ((bytes[header + 1] << 16 | bytes[header + 2] << 8 | bytes[header + 3]) < 34) return void 0;
|
|
130
|
+
const payload = header + 4;
|
|
131
|
+
if (payload + 34 > bytes.length) return void 0;
|
|
132
|
+
let hex = "";
|
|
133
|
+
for (const byte of bytes.subarray(payload + 18, payload + 34)) hex += byte.toString(16).padStart(2, "0");
|
|
134
|
+
return hex;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* FLAC's encoded payload: the audio frames between the end of the metadata
|
|
138
|
+
* block chain and an appended ID3v1/APEv2 tag. An appended ID3v2 is *inside*
|
|
139
|
+
* the payload: TagLib ends a FLAC stream at its ID3v1 location
|
|
140
|
+
* (`flacfile.cpp:595-599`), and a tag not at that location is stream by the
|
|
141
|
+
* same rule — TagLib is this feature's ground truth, so the boundary is pinned
|
|
142
|
+
* by `tests/media-ranges.test.ts`, not "fixed" here. Nothing inside a FLAC
|
|
143
|
+
* stream delimits the frames — the block chain's end is the start, and the
|
|
144
|
+
* stream runs to EOF — so the whole rule is the block walk plus the
|
|
145
|
+
* trailing-tag trim.
|
|
146
|
+
*
|
|
147
|
+
* `flacAudioStart` may legitimately answer past `bytes.length`, because a
|
|
148
|
+
* block's declared length can reach beyond the bytes in hand: that is the
|
|
149
|
+
* extent the chain *implies*, and hashing it would read nothing while claiming
|
|
150
|
+
* a payload. The `end <= start` guard is what refuses it.
|
|
151
|
+
*
|
|
152
|
+
* The walk deliberately does **not** carry the STREAMINFO digest: a range result
|
|
153
|
+
* is not a digest carrier, and the PCM basis reads the digest with
|
|
154
|
+
* `flacStreamInfoMd5` directly. A second, unread path to the same value rots.
|
|
155
|
+
*/
|
|
156
|
+
function walkFlac(bytes) {
|
|
157
|
+
const start = flacAudioStart(bytes);
|
|
158
|
+
if (start === void 0) return fallback("no fLaC marker");
|
|
159
|
+
const end = trailingTagStart(bytes);
|
|
160
|
+
if (end <= start) return fallback("no audio bytes");
|
|
161
|
+
return {
|
|
162
|
+
kind: "ranges",
|
|
163
|
+
ranges: [{
|
|
164
|
+
offset: start,
|
|
165
|
+
length: end - start
|
|
166
|
+
}],
|
|
167
|
+
detail: `audioStart=${start} end=${end}`
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/** Length of the atom starting at `o`, or `undefined` when its size field is
|
|
171
|
+
* malformed. `size === 0` runs to end of file (8-byte header); `size === 1`
|
|
172
|
+
* means the real length is the 64-bit value after the type. */
|
|
173
|
+
function atomLength(bytes, view, o) {
|
|
174
|
+
const size = view.getUint32(o, false);
|
|
175
|
+
if (size === 0) return {
|
|
176
|
+
length: bytes.length - o,
|
|
177
|
+
headerSize: 8
|
|
178
|
+
};
|
|
179
|
+
if (size === 1) {
|
|
180
|
+
if (o + 16 > bytes.length) return void 0;
|
|
181
|
+
const big = view.getBigUint64(o + 8, false);
|
|
182
|
+
if (big > BigInt(Number.MAX_SAFE_INTEGER)) return void 0;
|
|
183
|
+
return {
|
|
184
|
+
length: Number(big),
|
|
185
|
+
headerSize: 16
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
length: size,
|
|
190
|
+
headerSize: 8
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* MP4's payload: the contents of every non-empty top-level `mdat`, in file
|
|
195
|
+
* order — a fragmented file spreads its audio over several, and a rewritten one
|
|
196
|
+
* may carry an empty `mdat`, which is legal and contributes nothing. The header
|
|
197
|
+
* is excluded, and it is 16 bytes rather than 8 when the size took the 64-bit
|
|
198
|
+
* form.
|
|
199
|
+
*
|
|
200
|
+
* Deliberately not `metadata-extent.ts`'s atom walk: that one looks for `moov`
|
|
201
|
+
* to size the partial-load gate, so it bails on any size below 8 and has no
|
|
202
|
+
* 64-bit path. The checksum's rules differ — `size === 0` runs to EOF, a 64-bit
|
|
203
|
+
* size is legal, and anything the walk cannot fully account for is a fallback —
|
|
204
|
+
* so the two contracts stay apart rather than share an abstraction.
|
|
205
|
+
*
|
|
206
|
+
* Those fallbacks are the point. A range that runs past the buffer would hash
|
|
207
|
+
* zero padding while `bytesHashed` counts it as payload, and bytes no atom
|
|
208
|
+
* accounts for are not something this walk may call audio.
|
|
209
|
+
*/
|
|
210
|
+
function walkMp4(bytes) {
|
|
211
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
212
|
+
const ranges = [];
|
|
213
|
+
let o = 0;
|
|
214
|
+
while (o + 8 <= bytes.length) {
|
|
215
|
+
const type = text(bytes, o + 4, 4);
|
|
216
|
+
const atom = atomLength(bytes, view, o);
|
|
217
|
+
if (atom === void 0) return fallback(`malformed ${type} size`);
|
|
218
|
+
if (atom.length < atom.headerSize) return fallback(`malformed ${type} size`);
|
|
219
|
+
if (o + atom.length > bytes.length) return fallback(`oversized ${type}`);
|
|
220
|
+
if (type === "mdat" && atom.length > atom.headerSize) ranges.push({
|
|
221
|
+
offset: o + atom.headerSize,
|
|
222
|
+
length: atom.length - atom.headerSize
|
|
223
|
+
});
|
|
224
|
+
o += atom.length;
|
|
225
|
+
}
|
|
226
|
+
if (o !== bytes.length) return fallback("trailing bytes after the last atom");
|
|
227
|
+
if (ranges.length === 0) return fallback("no non-empty mdat");
|
|
228
|
+
return {
|
|
229
|
+
kind: "ranges",
|
|
230
|
+
ranges,
|
|
231
|
+
detail: `${ranges.length} mdat(s)`
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* WAV's payload: every non-empty `data` chunk's contents, payload only.
|
|
236
|
+
*
|
|
237
|
+
* The chunk list is the whole rule: a chunk is a 4-byte id, a 4-byte
|
|
238
|
+
* little-endian size that counts the payload but not the header, and that
|
|
239
|
+
* payload padded to an even length. Tag chunks (`LIST`, `id3 `, `bext`, `iXML`)
|
|
240
|
+
* are therefore skipped by construction rather than by name, and chunks that
|
|
241
|
+
* follow `data` cannot move or clip the range — which is the property the
|
|
242
|
+
* repo's `wav/kiss-snippet.wav` pins, `data` first and `LIST` + `id3 ` behind it.
|
|
243
|
+
*
|
|
244
|
+
* A chunk whose declared size reaches past the buffer is a fallback, not a
|
|
245
|
+
* clamp: hashing the bytes that survive would report a payload the file does not
|
|
246
|
+
* claim. That is also the truncated-file case.
|
|
247
|
+
*/
|
|
248
|
+
function walkWav(bytes) {
|
|
249
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
250
|
+
if (text(bytes, 0, 4) !== "RIFF") return fallback("not RIFF");
|
|
251
|
+
if (text(bytes, 8, 4) !== "WAVE") return fallback("not WAVE");
|
|
252
|
+
const ranges = [];
|
|
253
|
+
let o = 12;
|
|
254
|
+
while (o + 8 <= bytes.length) {
|
|
255
|
+
const id = text(bytes, o, 4);
|
|
256
|
+
const size = view.getUint32(o + 4, true);
|
|
257
|
+
const dataStart = o + 8;
|
|
258
|
+
if (dataStart + size > bytes.length) return fallback(`truncated ${id}`);
|
|
259
|
+
if (id === "data" && size > 0) ranges.push({
|
|
260
|
+
offset: dataStart,
|
|
261
|
+
length: size
|
|
262
|
+
});
|
|
263
|
+
o = dataStart + size + size % 2;
|
|
264
|
+
}
|
|
265
|
+
if (ranges.length === 0) return fallback("no data chunk");
|
|
266
|
+
return {
|
|
267
|
+
kind: "ranges",
|
|
268
|
+
ranges,
|
|
269
|
+
detail: `${ranges.length} data chunk(s)`
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* The per-format dispatch: the one entry point a consumer calls, and the one
|
|
274
|
+
* place a format-level fallback becomes a whole-file range.
|
|
275
|
+
*
|
|
276
|
+
* Consumers MUST dispatch on `kind`, never on `ranges.length`. The walks
|
|
277
|
+
* themselves answer a fallback with `ranges: []`, which this function replaces
|
|
278
|
+
* with the whole file — so after normalization there is no empty-ranges answer
|
|
279
|
+
* to detect, and a caller testing `ranges.length === 0` would read a fallback as
|
|
280
|
+
* a genuine payload and hash the whole file while claiming a range.
|
|
281
|
+
*/
|
|
282
|
+
function mediaRanges(format, bytes) {
|
|
283
|
+
const walked = (() => {
|
|
284
|
+
switch (format.toUpperCase()) {
|
|
285
|
+
case "MP3":
|
|
286
|
+
case "AAC": return walkMpeg(bytes);
|
|
287
|
+
case "FLAC": return walkFlac(bytes);
|
|
288
|
+
case "MP4":
|
|
289
|
+
case "M4A": return walkMp4(bytes);
|
|
290
|
+
case "WAV": return walkWav(bytes);
|
|
291
|
+
default: return {
|
|
292
|
+
kind: "fallback",
|
|
293
|
+
ranges: [],
|
|
294
|
+
detail: "format not covered"
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
})();
|
|
298
|
+
if (walked.kind === "fallback") return {
|
|
299
|
+
kind: "fallback",
|
|
300
|
+
ranges: [{
|
|
301
|
+
offset: 0,
|
|
302
|
+
length: bytes.length
|
|
303
|
+
}],
|
|
304
|
+
detail: `${walked.detail} → whole file`
|
|
305
|
+
};
|
|
306
|
+
return walked;
|
|
307
|
+
}
|
|
308
|
+
//#endregion
|
|
309
|
+
export { flacStreamInfoMd5, mediaRanges, trailingTagStart, walkFlac, walkMp4, walkMpeg, walkWav };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Is a file's metadata provably contained in its first N bytes?
|
|
3
|
+
*
|
|
4
|
+
* Partial loading (`TagLib.open(path, { partial: true })`) hands TagLib the
|
|
5
|
+
* file's first `maxHeaderSize` bytes concatenated with its last `maxFooterSize`
|
|
6
|
+
* bytes, discarding the middle. That is only sound when the metadata lives
|
|
7
|
+
* entirely inside the header window: otherwise the tag is cut mid-structure and
|
|
8
|
+
* unrelated footer bytes are spliced onto the cut, so TagLib parses whatever
|
|
9
|
+
* lands there. Measured on a real library, 18 of 40 large MP3s read back
|
|
10
|
+
* DIFFERENT metadata that way, and before taglib-f5hp the malformed image also
|
|
11
|
+
* tripped a double free that trapped the whole Wasm module (taglib-f5hp).
|
|
12
|
+
*
|
|
13
|
+
* So the decision is made before splicing, and the rule is deliberately
|
|
14
|
+
* asymmetric: return true ONLY when the metadata is provably contained. Anything
|
|
15
|
+
* unrecognised, malformed, or unbounded answers false, which costs a full read
|
|
16
|
+
* and never costs correctness.
|
|
17
|
+
*
|
|
18
|
+
* The container walkers themselves are exported (id3v2End, mpegFrameLength,
|
|
19
|
+
* flacAudioStart, flacMarkerOffset) because the media checksum walks the same
|
|
20
|
+
* containers to find a file's encoded-audio payload. One walker per container:
|
|
21
|
+
* a second copy of these rules could silently disagree with the one that
|
|
22
|
+
* decides whether a splice is safe.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* End of an ID3v2 tag at offset 0, or undefined when there is none.
|
|
26
|
+
*
|
|
27
|
+
* The size field is "syncsafe": seven bits per byte, so the high bit can never
|
|
28
|
+
* produce a false frame sync. A footer, when the flags say there is one, adds
|
|
29
|
+
* ten bytes that the size does not cover.
|
|
30
|
+
*
|
|
31
|
+
* The `ID3` magic check is part of the contract, not a convenience: the size
|
|
32
|
+
* arithmetic reads a number out of any ten bytes, so a tagless buffer would
|
|
33
|
+
* otherwise report 22.8 million as the end of a tag it does not have. Callers
|
|
34
|
+
* that have already established the magic pay one comparison for it; callers
|
|
35
|
+
* that have not (the media checksum walks) need it.
|
|
36
|
+
*/
|
|
37
|
+
export declare function id3v2End(bytes: Uint8Array): number | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Offset of FLAC's `fLaC` stream marker — at 0, or just past a prepended ID3v2
|
|
40
|
+
* tag (TagLib supports exactly that, flacfile.cpp:90) — or undefined when
|
|
41
|
+
* neither is there. A caller that only wants STREAMINFO can seek straight to it
|
|
42
|
+
* instead of walking the metadata-block chain.
|
|
43
|
+
*/
|
|
44
|
+
export declare function flacMarkerOffset(bytes: Uint8Array): number | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Offset of FLAC's first audio byte: the end of the metadata-block chain, past
|
|
47
|
+
* the optional ID3v2 tag.
|
|
48
|
+
*
|
|
49
|
+
* The chain is walked from block headers alone, so the result can exceed
|
|
50
|
+
* `bytes.length` when a block's declared length reaches past the buffer — that
|
|
51
|
+
* is the extent the chain implies, and the caller decides whether it holds
|
|
52
|
+
* enough of the file to believe it. A buffer too short to hold the next block
|
|
53
|
+
* header has no implied extent at all and answers undefined, as does one with
|
|
54
|
+
* no `fLaC` marker.
|
|
55
|
+
*/
|
|
56
|
+
export declare function flacAudioStart(bytes: Uint8Array): number | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Length in bytes of the MPEG (Layer I/II/III) frame whose header sits at `at`,
|
|
59
|
+
* or 0 when `at` is not a plausible frame header.
|
|
60
|
+
*
|
|
61
|
+
* Plausibility is the header alone: eleven sync bits, a non-reserved version
|
|
62
|
+
* and layer, a bitrate index that is neither free (0) nor invalid (15), and a
|
|
63
|
+
* sample-rate index that is not reserved (3). Nothing here looks at what
|
|
64
|
+
* FOLLOWS the frame — a frame header at the very end of a file is as plausible
|
|
65
|
+
* as any other, which is what lets a walk reach the last frame. Callers that
|
|
66
|
+
* need confidence the bytes really are MPEG audio want isMpegFrameSync, which
|
|
67
|
+
* adds the next-header consistency check.
|
|
68
|
+
*
|
|
69
|
+
* The arithmetic mirrors mpegheader.cpp:236-264: bitrate/sample-rate tables
|
|
70
|
+
* plus the padding bit, and C++ integer division truncates.
|
|
71
|
+
*/
|
|
72
|
+
export declare function mpegFrameLength(bytes: Uint8Array, at: number): number;
|
|
73
|
+
/**
|
|
74
|
+
* True only when the metadata of `header` provably ends within `limit` bytes.
|
|
75
|
+
*
|
|
76
|
+
* `header` is the start of the file and may be shorter than `limit`; anything
|
|
77
|
+
* this cannot prove — an unknown container, a truncated header, a malformed
|
|
78
|
+
* size — answers false so the caller reads the whole file.
|
|
79
|
+
*
|
|
80
|
+
* NOTE this judges the HEADER window only. Trailer metadata (ID3v1, APE) is the
|
|
81
|
+
* caller's business — see trailerFitsInFooter.
|
|
82
|
+
*/
|
|
83
|
+
export declare function metadataFitsInHeader(header: Uint8Array, limit: number): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* True when a file's TRAILER metadata provably fits in the last `footerSize`
|
|
86
|
+
* bytes, given `tail` — the end of the file, at least that long.
|
|
87
|
+
*
|
|
88
|
+
* Partial loading keeps the file's last `footerSize` bytes, so ID3v1 (always
|
|
89
|
+
* exactly 128 bytes) is safe by construction. APEv2 is not: it is unbounded
|
|
90
|
+
* because it can carry cover art, and an APE tag larger than the footer window
|
|
91
|
+
* is spliced so that TagLib computes its start inside the header window's audio
|
|
92
|
+
* and reads nothing. Measured: a 410 KB APE tag lost EVERY tag value silently,
|
|
93
|
+
* while a 41 KB one round-tripped.
|
|
94
|
+
*/
|
|
95
|
+
export declare function trailerFitsInFooter(tail: Uint8Array, footerSize: number): boolean;
|
|
96
|
+
//# sourceMappingURL=metadata-extent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata-extent.d.ts","sourceRoot":"","sources":["../../src/taglib/metadata-extent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAqBH;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAK9D;AA2BD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAItE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAIpE;AAwGD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CA4BrE;AAsED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAiCT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,MAAM,GACjB,OAAO,CAuBT"}
|