taglib-wasm 2.3.0 → 2.4.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/LICENSE +2 -2
- package/README.md +72 -64
- 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/constants/properties.d.ts +43 -0
- 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} +8 -2
- package/dist/deno-compile.d.ts.map +1 -0
- package/dist/deno-compile.js +113 -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.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 +29 -30
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +4106 -4479
- package/dist/index.d.ts +26 -26
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -185
- 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 +19 -0
- package/dist/runtime/deno-detect.d.ts.map +1 -0
- package/dist/runtime/deno-detect.js +26 -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 +168 -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/runtime/wasi-adapter/adapter.d.ts.map +1 -0
- package/dist/runtime/wasi-adapter/adapter.js +114 -0
- 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.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/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.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/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 +3405 -3692
- 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.map +1 -0
- package/dist/taglib/audio-file-checksum.js +90 -0
- package/dist/taglib/audio-file-impl.d.ts.map +1 -0
- package/dist/taglib/audio-file-impl.js +234 -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 +138 -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.map +1 -0
- package/dist/taglib/media-ranges.js +309 -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.d.ts.map +1 -0
- package/dist/taglib.js +7 -0
- package/dist/{src/types → types}/audio-formats.d.ts +5 -1
- 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.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/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 +5 -5
- package/dist/web.browser.d.ts.map +1 -1
- package/dist/web.browser.js +3169 -3411
- package/dist/web.d.ts +1 -1
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +5 -2
- package/package.json +136 -100
- 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 +0 -877
- 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.map +0 -1
- package/dist/src/errors/base.js +0 -49
- 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 +0 -8
- 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 -130
- package/dist/src/runtime/wasi-adapter/audio-properties.d.ts.map +0 -1
- package/dist/src/runtime/wasi-adapter/audio-properties.js +0 -102
- 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/path-open.d.ts.map +0 -1
- package/dist/src/runtime/wasi-adapter/path-open.js +0 -76
- 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 -257
- 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 -114
- 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/checksum-operations.d.ts.map +0 -1
- package/dist/src/simple/checksum-operations.js +0 -7
- 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 -60
- 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-checksum.d.ts.map +0 -1
- package/dist/src/taglib/audio-file-checksum.js +0 -77
- package/dist/src/taglib/audio-file-impl.d.ts.map +0 -1
- package/dist/src/taglib/audio-file-impl.js +0 -317
- 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/media-ranges.d.ts.map +0 -1
- package/dist/src/taglib/media-ranges.js +0 -192
- package/dist/src/taglib/metadata-extent.d.ts.map +0 -1
- package/dist/src/taglib/metadata-extent.js +0 -189
- 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 -195
- 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.map +0 -1
- package/dist/src/utils/path.js +0 -36
- 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}/base.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}/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/adapter.d.ts +0 -0
- /package/dist/{src/runtime → runtime}/wasi-adapter/audio-properties.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/path-open.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/runtime → runtime}/wasmer-sdk-loader/types.d.ts +0 -0
- /package/dist/{src/simple → simple}/batch-operations.d.ts +0 -0
- /package/dist/{src/simple → simple}/checksum-operations.d.ts +0 -0
- /package/dist/{src/simple → simple}/config.d.ts +0 -0
- /package/dist/{src/simple → simple}/index.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}/audio-file-checksum.d.ts +0 -0
- /package/dist/{src/taglib → taglib}/audio-file-impl.d.ts +0 -0
- /package/dist/{src/taglib → taglib}/audio-file-interface.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}/media-ranges.d.ts +0 -0
- /package/dist/{src/taglib → taglib}/metadata-extent.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}/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}/path.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/wasm.d.ts → wasm.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,245 @@
|
|
|
1
|
+
import { fromTagLibKey } from "../constants/properties.js";
|
|
2
|
+
import { isNamedAudioInput } from "../types/audio-formats.js";
|
|
3
|
+
import { InvalidFormatError } from "../errors/classes.js";
|
|
4
|
+
import "../errors.js";
|
|
5
|
+
import { mergeTagUpdatesInto, readExtendedTag } from "../utils/tag-mapping.js";
|
|
6
|
+
import { getTagLib } from "./config.js";
|
|
7
|
+
import { withAudioFileSaveToFile } from "./with-audio-file.js";
|
|
8
|
+
//#region src/simple/batch-operations.ts
|
|
9
|
+
async function executeBatch(files, options, processor) {
|
|
10
|
+
if (files.length === 0) return {
|
|
11
|
+
items: [],
|
|
12
|
+
duration: 0
|
|
13
|
+
};
|
|
14
|
+
const startTime = Date.now();
|
|
15
|
+
const { concurrency = 4, continueOnError = true, onProgress, signal } = options;
|
|
16
|
+
const items = new Array(files.length);
|
|
17
|
+
const taglib = await getTagLib();
|
|
18
|
+
let processed = 0;
|
|
19
|
+
const total = files.length;
|
|
20
|
+
for (let i = 0; i < files.length; i += concurrency) {
|
|
21
|
+
signal?.throwIfAborted();
|
|
22
|
+
const chunkPromises = files.slice(i, i + concurrency).map(async (file, idx) => {
|
|
23
|
+
const index = i + idx;
|
|
24
|
+
const fileName = typeof file === "string" ? file : file instanceof File ? file.name : isNamedAudioInput(file) ? file.name : `buffer-${index}`;
|
|
25
|
+
try {
|
|
26
|
+
const audioFile = await taglib.open(file);
|
|
27
|
+
try {
|
|
28
|
+
if (!audioFile.isValid()) throw new InvalidFormatError("File may be corrupted or in an unsupported format");
|
|
29
|
+
items[index] = {
|
|
30
|
+
status: "ok",
|
|
31
|
+
path: fileName,
|
|
32
|
+
data: processor(audioFile)
|
|
33
|
+
};
|
|
34
|
+
} finally {
|
|
35
|
+
audioFile.dispose();
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
39
|
+
items[index] = {
|
|
40
|
+
status: "error",
|
|
41
|
+
path: fileName,
|
|
42
|
+
error: err
|
|
43
|
+
};
|
|
44
|
+
if (!continueOnError) throw err;
|
|
45
|
+
}
|
|
46
|
+
processed++;
|
|
47
|
+
onProgress?.(processed, total, fileName);
|
|
48
|
+
});
|
|
49
|
+
await Promise.all(chunkPromises);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
items,
|
|
53
|
+
duration: Date.now() - startTime
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Read tags from multiple files with configurable concurrency.
|
|
58
|
+
*
|
|
59
|
+
* @param files - Array of file paths, Uint8Arrays, ArrayBuffers, File objects, or NamedAudioInputs.
|
|
60
|
+
* @param options - Batch processing options (concurrency, error handling, progress).
|
|
61
|
+
* @returns Batch result containing a `BatchItem` per file and total duration in ms.
|
|
62
|
+
* @throws If `continueOnError` is `false` and any file fails to process.
|
|
63
|
+
*/
|
|
64
|
+
async function readTagsBatch(files, options = {}) {
|
|
65
|
+
return executeBatch(files, options, (audioFile) => readExtendedTag(audioFile, options.includeProperties));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Read audio properties from multiple files with configurable concurrency.
|
|
69
|
+
*
|
|
70
|
+
* @param files - Array of file paths, Uint8Arrays, ArrayBuffers, File objects, or NamedAudioInputs.
|
|
71
|
+
* @param options - Batch processing options (concurrency, error handling, progress).
|
|
72
|
+
* @returns Batch result containing a `BatchItem` per file and total duration in ms.
|
|
73
|
+
* @throws If `continueOnError` is `false` and any file fails to process.
|
|
74
|
+
*/
|
|
75
|
+
async function readPropertiesBatch(files, options = {}) {
|
|
76
|
+
return executeBatch(files, options, (audioFile) => audioFile.audioProperties());
|
|
77
|
+
}
|
|
78
|
+
function extractDynamics(audioFile) {
|
|
79
|
+
const dynamics = {};
|
|
80
|
+
for (const field of [
|
|
81
|
+
"replayGainTrackGain",
|
|
82
|
+
"replayGainTrackPeak",
|
|
83
|
+
"replayGainAlbumGain",
|
|
84
|
+
"replayGainAlbumPeak"
|
|
85
|
+
]) {
|
|
86
|
+
const val = audioFile.getProperty(field)?.[0];
|
|
87
|
+
if (val !== void 0) dynamics[field] = val;
|
|
88
|
+
}
|
|
89
|
+
let appleSoundCheck = audioFile.getProperty("appleSoundCheck")?.[0];
|
|
90
|
+
if (!appleSoundCheck && audioFile.isMP4()) appleSoundCheck = audioFile.getMP4Item("----:com.apple.iTunes:iTunNORM");
|
|
91
|
+
if (appleSoundCheck) dynamics.appleSoundCheck = appleSoundCheck;
|
|
92
|
+
return Object.keys(dynamics).length > 0 ? dynamics : void 0;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Read complete metadata (tags, properties, cover art, dynamics) from a single file.
|
|
96
|
+
*
|
|
97
|
+
* @param file - A file path, Uint8Array, ArrayBuffer, File object, or NamedAudioInput.
|
|
98
|
+
* @param options - Read options; `includeProperties` (wire keys) surfaces raw
|
|
99
|
+
* values in `tags.extraProperties` (taglib-3s1f).
|
|
100
|
+
* @returns The file's complete metadata.
|
|
101
|
+
* @throws `InvalidFormatError` if the file is corrupted or in an unsupported format.
|
|
102
|
+
*/
|
|
103
|
+
async function readMetadata(file, options = {}) {
|
|
104
|
+
const audioFile = await (await getTagLib()).open(file);
|
|
105
|
+
try {
|
|
106
|
+
if (!audioFile.isValid()) {
|
|
107
|
+
let name;
|
|
108
|
+
if (typeof file === "string") name = file;
|
|
109
|
+
else if (file instanceof File) name = file.name;
|
|
110
|
+
else if (isNamedAudioInput(file)) name = file.name;
|
|
111
|
+
else name = `buffer (${file.byteLength} bytes)`;
|
|
112
|
+
throw new InvalidFormatError(`File may be corrupted or in an unsupported format. File: ${name}`);
|
|
113
|
+
}
|
|
114
|
+
const dynamics = extractDynamics(audioFile);
|
|
115
|
+
return {
|
|
116
|
+
tags: readExtendedTag(audioFile, options.includeProperties),
|
|
117
|
+
properties: audioFile.audioProperties(),
|
|
118
|
+
hasCoverArt: audioFile.getPictures().length > 0,
|
|
119
|
+
...dynamics !== void 0 ? { dynamics } : {}
|
|
120
|
+
};
|
|
121
|
+
} finally {
|
|
122
|
+
audioFile.dispose();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Read complete metadata from multiple files with configurable concurrency.
|
|
127
|
+
*
|
|
128
|
+
* @param files - Array of file paths, Uint8Arrays, ArrayBuffers, File objects, or NamedAudioInputs.
|
|
129
|
+
* @param options - Batch processing options (concurrency, error handling, progress).
|
|
130
|
+
* @returns Batch result containing a `BatchItem` per file and total duration in ms.
|
|
131
|
+
* @throws If `continueOnError` is `false` and any file fails to process.
|
|
132
|
+
*/
|
|
133
|
+
async function readMetadataBatch(files, options = {}) {
|
|
134
|
+
return executeBatch(files, options, (audioFile) => {
|
|
135
|
+
const dynamics = extractDynamics(audioFile);
|
|
136
|
+
return {
|
|
137
|
+
tags: readExtendedTag(audioFile, options.includeProperties),
|
|
138
|
+
properties: audioFile.audioProperties(),
|
|
139
|
+
hasCoverArt: audioFile.getPictures().length > 0,
|
|
140
|
+
...dynamics !== void 0 ? { dynamics } : {}
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function entryPath(entry) {
|
|
145
|
+
return typeof entry === "string" ? entry : entry.path;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Shared batch-write driver: the read-side executeBatch contract applied to
|
|
149
|
+
* writes (taglib-pmhp). Per-file try/catch with ok/error items, abort between
|
|
150
|
+
* chunks (never mid-save), progress after each file, input-order-preserving
|
|
151
|
+
* results. Atomicity is inherited from saveToFile's temp-file save: a failed
|
|
152
|
+
* file is left in its pre-write state.
|
|
153
|
+
*/
|
|
154
|
+
async function executeWriteBatch(entries, options, writer) {
|
|
155
|
+
if (entries.length === 0) return {
|
|
156
|
+
items: [],
|
|
157
|
+
duration: 0
|
|
158
|
+
};
|
|
159
|
+
await getTagLib();
|
|
160
|
+
const startTime = Date.now();
|
|
161
|
+
const { concurrency = 4, continueOnError = true, onProgress, signal } = options;
|
|
162
|
+
const items = new Array(entries.length);
|
|
163
|
+
let processed = 0;
|
|
164
|
+
const total = entries.length;
|
|
165
|
+
for (let i = 0; i < entries.length; i += concurrency) {
|
|
166
|
+
signal?.throwIfAborted();
|
|
167
|
+
const chunkPromises = entries.slice(i, i + concurrency).map(async (entry, idx) => {
|
|
168
|
+
const index = i + idx;
|
|
169
|
+
const path = entryPath(entry);
|
|
170
|
+
try {
|
|
171
|
+
await writer(path);
|
|
172
|
+
items[index] = {
|
|
173
|
+
status: "ok",
|
|
174
|
+
path,
|
|
175
|
+
data: void 0
|
|
176
|
+
};
|
|
177
|
+
} catch (error) {
|
|
178
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
179
|
+
items[index] = {
|
|
180
|
+
status: "error",
|
|
181
|
+
path,
|
|
182
|
+
error: err
|
|
183
|
+
};
|
|
184
|
+
if (!continueOnError) throw err;
|
|
185
|
+
}
|
|
186
|
+
processed++;
|
|
187
|
+
onProgress?.(processed, total, path);
|
|
188
|
+
});
|
|
189
|
+
await Promise.all(chunkPromises);
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
items,
|
|
193
|
+
duration: Date.now() - startTime
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Apply tag updates to multiple files with configurable concurrency.
|
|
198
|
+
*
|
|
199
|
+
* The batch write counterpart to {@link readTagsBatch}: same
|
|
200
|
+
* {@link BatchOptions} contract (concurrency, continueOnError, onProgress,
|
|
201
|
+
* signal). Each file is updated in ONE save via a single `setProperties`
|
|
202
|
+
* fold: the typed `tags` merge ({@link mergeTagUpdatesInto} — the same
|
|
203
|
+
* semantics as {@link applyTagsToFile}) plus the raw wire-key `properties`
|
|
204
|
+
* entries. Atomic temp-file save, so a failed file is left in its pre-write
|
|
205
|
+
* state.
|
|
206
|
+
*
|
|
207
|
+
* @param updates - Per-file tag updates; a path may appear more than once
|
|
208
|
+
* (the last update for a path wins).
|
|
209
|
+
* @param options - Batch processing options (concurrency, error handling,
|
|
210
|
+
* progress, abort).
|
|
211
|
+
* @returns A `BatchItem` per update in input order plus total duration in ms.
|
|
212
|
+
* @throws If `continueOnError` is `false` and any file fails to process.
|
|
213
|
+
*/
|
|
214
|
+
async function writeTagsBatch(updates, options = {}) {
|
|
215
|
+
const byPath = new Map(updates.map((u) => [u.path, u]));
|
|
216
|
+
return executeWriteBatch(updates, options, (path) => withAudioFileSaveToFile(path, (audioFile) => {
|
|
217
|
+
const update = byPath.get(path);
|
|
218
|
+
const merged = update.tags !== void 0 ? mergeTagUpdatesInto(audioFile.properties(), update.tags) : audioFile.properties();
|
|
219
|
+
if (update.properties !== void 0) for (const [key, values] of Object.entries(update.properties)) merged[fromTagLibKey(key)] = values;
|
|
220
|
+
audioFile.setProperties(merged);
|
|
221
|
+
}));
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Open, mutate, and save multiple files with configurable concurrency.
|
|
225
|
+
*
|
|
226
|
+
* Mutator-callback variant of {@link writeTagsBatch}: the callback receives
|
|
227
|
+
* the open {@link AudioFile} (Full-API style) plus the `path` it was opened
|
|
228
|
+
* from — the pair is a per-invocation contract, so precomputed per-path
|
|
229
|
+
* plans can be looked up without relying on invocation order (taglib-pmhp
|
|
230
|
+
* review). A one-argument mutator keeps working. Changes are saved per file;
|
|
231
|
+
* same {@link BatchOptions} contract and atomicity guarantees.
|
|
232
|
+
*
|
|
233
|
+
* @param files - File paths on disk, updated in place.
|
|
234
|
+
* @param mutator - Called once per file with the open audio file and its
|
|
235
|
+
* path; changes are saved automatically.
|
|
236
|
+
* @param options - Batch processing options (concurrency, error handling,
|
|
237
|
+
* progress, abort).
|
|
238
|
+
* @returns A `BatchItem` per file in input order plus total duration in ms.
|
|
239
|
+
* @throws If `continueOnError` is `false` and any file fails to process.
|
|
240
|
+
*/
|
|
241
|
+
async function editTagsBatch(files, mutator, options = {}) {
|
|
242
|
+
return executeWriteBatch(files, options, (path) => withAudioFileSaveToFile(path, (audioFile) => mutator(audioFile, path)));
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
export { editTagsBatch, readMetadata, readMetadataBatch, readPropertiesBatch, readTagsBatch, writeTagsBatch };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checksum-operations.d.ts","sourceRoot":"","sources":["../../src/simple/checksum-operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACrB,MAAM,kCAAkC,CAAC;AAG1C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,cAAc,EACpB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,aAAa,CAAC,CAExB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { withAudioFile } from "./with-audio-file.js";
|
|
2
|
+
//#region src/simple/checksum-operations.ts
|
|
3
|
+
/**
|
|
4
|
+
* Reads a checksum of an audio file's media content.
|
|
5
|
+
*
|
|
6
|
+
* The digest is of the *encoded media payload* — the bytes that are the audio,
|
|
7
|
+
* not the tags around them — so it survives a tag edit, with one boundary: an
|
|
8
|
+
* ID3v2 tag appended after a FLAC's audio is inside that payload, so editing it
|
|
9
|
+
* does move the hash. Formats whose payload cannot be delimited answer the
|
|
10
|
+
* whole file instead and say so (`source: "file"`), where a tag edit does move
|
|
11
|
+
* the hash.
|
|
12
|
+
*
|
|
13
|
+
* @param file - File path, Uint8Array, ArrayBuffer, or File object
|
|
14
|
+
* @param options - `basis: "pcm"` asks for FLAC's STREAMINFO MD5, the digest of
|
|
15
|
+
* the *uncompressed* stream, instead of the encoded payload's SHA-256
|
|
16
|
+
* @returns The hex digest, the algorithm, what it covers (`source`), and how
|
|
17
|
+
* many bytes were hashed
|
|
18
|
+
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
|
|
19
|
+
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
|
|
20
|
+
* @throws {UnsupportedFormatError} If `basis: "pcm"` is asked of a non-FLAC file
|
|
21
|
+
* @throws {MetadataError} If the payload cannot be walked, or the handle holds
|
|
22
|
+
* no bytes and no readable source
|
|
23
|
+
*/
|
|
24
|
+
async function readMediaChecksum(file, options) {
|
|
25
|
+
return withAudioFile(file, (audioFile) => audioFile.mediaChecksum(options));
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { readMediaChecksum };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/simple/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAK3C,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAGpD;AAED,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CASjD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/simple/config.ts
|
|
2
|
+
let cachedTagLib = null;
|
|
3
|
+
let bufferModeEnabled = false;
|
|
4
|
+
function setBufferMode(enabled) {
|
|
5
|
+
bufferModeEnabled = enabled;
|
|
6
|
+
cachedTagLib = null;
|
|
7
|
+
}
|
|
8
|
+
async function getTagLib() {
|
|
9
|
+
if (!cachedTagLib) {
|
|
10
|
+
const { TagLib } = await import("../taglib.js");
|
|
11
|
+
const initOptions = bufferModeEnabled ? { forceWasmType: "emscripten" } : void 0;
|
|
12
|
+
cachedTagLib = await TagLib.initialize(initOptions);
|
|
13
|
+
}
|
|
14
|
+
return cachedTagLib;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { getTagLib, setBufferMode };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/simple/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EACL,SAAS,EACT,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,UAAU,EACV,aAAa,EACb,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,SAAS,EACT,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,GACf,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,oBAAoB,GACrB,MAAM,kCAAkC,CAAC;AAE1C,YAAY,EACV,eAAe,EACf,WAAW,EACX,OAAO,EACP,WAAW,EACX,GAAG,EACH,QAAQ,GACT,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PICTURE_TYPE_NAMES, PICTURE_TYPE_VALUES } from "../types/pictures.js";
|
|
2
|
+
import "../types.js";
|
|
3
|
+
import { getTagLib, setBufferMode } from "./config.js";
|
|
4
|
+
import { applyTags, applyTagsToFile, clearTags, isValidAudioFile, readFormat, readProperties, readTags } from "./tag-operations.js";
|
|
5
|
+
import { addPicture, applyCoverArt, applyPictures, clearPictures, findPictureByType, readCoverArt, readPictureMetadata, readPictures, replacePictureByType } from "./picture-operations.js";
|
|
6
|
+
import { editTagsBatch, readMetadata, readMetadataBatch, readPropertiesBatch, readTagsBatch, writeTagsBatch } from "./batch-operations.js";
|
|
7
|
+
import { readMediaChecksum } from "./checksum-operations.js";
|
|
8
|
+
export { PICTURE_TYPE_NAMES, PICTURE_TYPE_VALUES, addPicture, applyCoverArt, applyPictures, applyTags, applyTagsToFile, clearPictures, clearTags, editTagsBatch, findPictureByType, getTagLib, isValidAudioFile, readCoverArt, readFormat, readMediaChecksum, readMetadata, readMetadataBatch, readPictureMetadata, readPictures, readProperties, readPropertiesBatch, readTags, readTagsBatch, replacePictureByType, setBufferMode, writeTagsBatch };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picture-operations.d.ts","sourceRoot":"","sources":["../../src/simple/picture-operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGxE;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAE3E;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,OAAO,EAAE,GAClB,OAAO,CAAC,UAAU,CAAC,CAIrB;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,UAAU,CAAC,CAIrB;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAE7E;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAYjC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,cAAc,EACpB,SAAS,EAAE,UAAU,EACrB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,UAAU,CAAC,CAQrB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,OAAO,EAAE,EACnB,IAAI,EAAE,WAAW,GAChB,OAAO,GAAG,SAAS,CAErB;AAED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,cAAc,EACpB,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC,UAAU,CAAC,CAUrB;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CACtE,KAAK,CAAC;IACJ,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CACH,CAQA"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { withAudioFile, withAudioFileSave } from "./with-audio-file.js";
|
|
2
|
+
//#region src/simple/picture-operations.ts
|
|
3
|
+
/**
|
|
4
|
+
* Reads all embedded pictures from an audio file.
|
|
5
|
+
*
|
|
6
|
+
* @param file - File path, Uint8Array, ArrayBuffer, or File object
|
|
7
|
+
* @returns Array of all pictures embedded in the file
|
|
8
|
+
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
|
|
9
|
+
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
|
|
10
|
+
*/
|
|
11
|
+
async function readPictures(file) {
|
|
12
|
+
return withAudioFile(file, (audioFile) => audioFile.getPictures());
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Replaces all embedded pictures in an audio file and returns the modified content as a buffer.
|
|
16
|
+
*
|
|
17
|
+
* @param file - File path, Uint8Array, ArrayBuffer, or File object
|
|
18
|
+
* @param pictures - Complete set of pictures to embed; replaces any existing pictures
|
|
19
|
+
* @returns Modified audio file contents with the updated picture set
|
|
20
|
+
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
|
|
21
|
+
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
|
|
22
|
+
* @throws {FileOperationError} If saving the modified picture data fails
|
|
23
|
+
*/
|
|
24
|
+
async function applyPictures(file, pictures) {
|
|
25
|
+
return withAudioFileSave(file, (audioFile) => {
|
|
26
|
+
audioFile.setPictures(pictures);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Appends a single picture to an audio file's existing embedded pictures.
|
|
31
|
+
*
|
|
32
|
+
* @param file - File path, Uint8Array, ArrayBuffer, or File object
|
|
33
|
+
* @param picture - Picture to append to the file
|
|
34
|
+
* @returns Modified audio file contents with the new picture added
|
|
35
|
+
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
|
|
36
|
+
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
|
|
37
|
+
* @throws {FileOperationError} If saving the modified picture data fails
|
|
38
|
+
*/
|
|
39
|
+
async function addPicture(file, picture) {
|
|
40
|
+
return withAudioFileSave(file, (audioFile) => {
|
|
41
|
+
audioFile.addPicture(picture);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Removes all embedded pictures from an audio file and returns the modified content as a buffer.
|
|
46
|
+
*
|
|
47
|
+
* @param file - File path, Uint8Array, ArrayBuffer, or File object
|
|
48
|
+
* @returns Modified audio file contents with all pictures removed
|
|
49
|
+
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
|
|
50
|
+
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
|
|
51
|
+
* @throws {FileOperationError} If saving the modified file fails
|
|
52
|
+
*/
|
|
53
|
+
async function clearPictures(file) {
|
|
54
|
+
return applyPictures(file, []);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Reads the front cover art from an audio file, falling back to the first embedded picture.
|
|
58
|
+
*
|
|
59
|
+
* @param file - File path, Uint8Array, ArrayBuffer, or File object
|
|
60
|
+
* @returns Raw image bytes for the cover art, or `undefined` if no pictures are embedded
|
|
61
|
+
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
|
|
62
|
+
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
|
|
63
|
+
*/
|
|
64
|
+
async function readCoverArt(file) {
|
|
65
|
+
const pictures = await readPictures(file);
|
|
66
|
+
if (pictures.length === 0) return;
|
|
67
|
+
const frontCover = pictures.find((pic) => pic.type === "FrontCover");
|
|
68
|
+
if (frontCover) return frontCover.data;
|
|
69
|
+
return pictures[0].data;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Replaces all embedded pictures with a single front cover image and returns the modified content as a buffer.
|
|
73
|
+
*
|
|
74
|
+
* @param file - File path, Uint8Array, ArrayBuffer, or File object
|
|
75
|
+
* @param imageData - Raw image bytes to embed as the front cover
|
|
76
|
+
* @param mimeType - MIME type of the image (e.g., `"image/jpeg"`, `"image/png"`)
|
|
77
|
+
* @returns Modified audio file contents with the new cover art
|
|
78
|
+
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
|
|
79
|
+
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
|
|
80
|
+
* @throws {FileOperationError} If saving the modified picture data fails
|
|
81
|
+
*/
|
|
82
|
+
async function applyCoverArt(file, imageData, mimeType) {
|
|
83
|
+
return applyPictures(file, [{
|
|
84
|
+
mimeType,
|
|
85
|
+
data: imageData,
|
|
86
|
+
type: "FrontCover",
|
|
87
|
+
description: "Front Cover"
|
|
88
|
+
}]);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Finds the first picture of a given type from an array of pictures.
|
|
92
|
+
*
|
|
93
|
+
* @param pictures - Array of pictures to search
|
|
94
|
+
* @param type - Picture type to find (e.g., `"FrontCover"`, `"BackCover"`)
|
|
95
|
+
* @returns The first matching picture, or `undefined` if none is found
|
|
96
|
+
*/
|
|
97
|
+
function findPictureByType(pictures, type) {
|
|
98
|
+
return pictures.find((pic) => pic.type === type);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Replaces all pictures of a given type with a new picture and returns the modified content as a buffer.
|
|
102
|
+
*
|
|
103
|
+
* @param file - File path, Uint8Array, ArrayBuffer, or File object
|
|
104
|
+
* @param newPicture - Replacement picture; its `type` determines which existing pictures are removed
|
|
105
|
+
* @returns Modified audio file contents with the updated picture
|
|
106
|
+
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
|
|
107
|
+
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
|
|
108
|
+
* @throws {FileOperationError} If saving the modified picture data fails
|
|
109
|
+
*/
|
|
110
|
+
async function replacePictureByType(file, newPicture) {
|
|
111
|
+
const filteredPictures = (await readPictures(file)).filter((pic) => pic.type !== newPicture.type);
|
|
112
|
+
filteredPictures.push(newPicture);
|
|
113
|
+
return applyPictures(file, filteredPictures);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Reads picture metadata (type, MIME type, description, and size) without returning raw image data.
|
|
117
|
+
*
|
|
118
|
+
* @param file - File path, Uint8Array, ArrayBuffer, or File object
|
|
119
|
+
* @returns Array of metadata objects for each embedded picture; `size` is the byte length of the image data
|
|
120
|
+
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
|
|
121
|
+
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
|
|
122
|
+
*/
|
|
123
|
+
async function readPictureMetadata(file) {
|
|
124
|
+
return (await readPictures(file)).map((pic) => ({
|
|
125
|
+
type: pic.type,
|
|
126
|
+
mimeType: pic.mimeType,
|
|
127
|
+
...pic.description !== void 0 ? { description: pic.description } : {},
|
|
128
|
+
size: pic.data.length
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
export { addPicture, applyCoverArt, applyPictures, clearPictures, findPictureByType, readCoverArt, readPictureMetadata, readPictures, replacePictureByType };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag-operations.d.ts","sourceRoot":"","sources":["../../src/simple/tag-operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,WAAW,EACX,QAAQ,EAER,QAAQ,EACT,MAAM,aAAa,CAAC;AAWrB;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,cAAc,EACpB,OAAO,GAAE;IAAE,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GAC7C,OAAO,CAAC,WAAW,CAAC,CAItB;AAED;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GACtB,OAAO,CAAC,UAAU,CAAC,CAIrB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GACtB,OAAO,CAAC,IAAI,CAAC,CAWf;AAED;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,eAAe,CAAC,CAY1B;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAY7E;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAW/B;AAED;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAsBzE"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { FileOperationError, MetadataError } from "../errors/classes.js";
|
|
2
|
+
import "../errors.js";
|
|
3
|
+
import { mergeTagUpdates, readExtendedTag } from "../utils/tag-mapping.js";
|
|
4
|
+
import { getTagLib } from "./config.js";
|
|
5
|
+
import { withAudioFile, withAudioFileSave, withAudioFileSaveToFile } from "./with-audio-file.js";
|
|
6
|
+
//#region src/simple/tag-operations.ts
|
|
7
|
+
/**
|
|
8
|
+
* Reads all metadata tags from an audio file.
|
|
9
|
+
*
|
|
10
|
+
* @param file - File path, Uint8Array, ArrayBuffer, or File object
|
|
11
|
+
* @param options - Read options; `includeProperties` (wire keys) surfaces raw
|
|
12
|
+
* values in `extraProperties` (taglib-3s1f)
|
|
13
|
+
* @returns Parsed tag fields including extended metadata from the audio file
|
|
14
|
+
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
|
|
15
|
+
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
|
|
16
|
+
*/
|
|
17
|
+
async function readTags(file, options = {}) {
|
|
18
|
+
return withAudioFile(file, (audioFile) => readExtendedTag(audioFile, options.includeProperties));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Applies metadata tag changes to an audio file and returns the modified content as a buffer.
|
|
22
|
+
*
|
|
23
|
+
* @param file - File path, Uint8Array, ArrayBuffer, or File object
|
|
24
|
+
* @param tags - Partial tag fields to merge with existing metadata
|
|
25
|
+
* @returns Modified audio file contents with updated tags
|
|
26
|
+
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
|
|
27
|
+
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
|
|
28
|
+
* @throws {FileOperationError} If saving the modified metadata fails
|
|
29
|
+
*/
|
|
30
|
+
async function applyTags(file, tags) {
|
|
31
|
+
return withAudioFileSave(file, (audioFile) => {
|
|
32
|
+
mergeTagUpdates(audioFile, tags);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Writes metadata tag changes directly to an audio file on disk.
|
|
37
|
+
*
|
|
38
|
+
* @param file - File path string; the file is updated in place
|
|
39
|
+
* @param tags - Partial tag fields to merge with existing metadata
|
|
40
|
+
* @returns Resolves when the file has been written successfully
|
|
41
|
+
* @throws {FileOperationError} If a non-string input is provided, saving fails, or the file write fails
|
|
42
|
+
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
|
|
43
|
+
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
|
|
44
|
+
* @throws {EnvironmentError} If the runtime does not support filesystem write access
|
|
45
|
+
*/
|
|
46
|
+
async function applyTagsToFile(file, tags) {
|
|
47
|
+
if (typeof file !== "string") throw new FileOperationError("save", "applyTagsToFile requires a file path string to save changes");
|
|
48
|
+
await withAudioFileSaveToFile(file, (audioFile) => {
|
|
49
|
+
mergeTagUpdates(audioFile, tags);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Reads audio properties (duration, bitrate, sample rate, channels) from an audio file.
|
|
54
|
+
*
|
|
55
|
+
* @param file - File path, Uint8Array, ArrayBuffer, or File object
|
|
56
|
+
* @returns Audio codec properties for the file
|
|
57
|
+
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
|
|
58
|
+
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
|
|
59
|
+
* @throws {MetadataError} If the file does not contain valid audio property data
|
|
60
|
+
*/
|
|
61
|
+
async function readProperties(file) {
|
|
62
|
+
return withAudioFile(file, (audioFile) => {
|
|
63
|
+
const props = audioFile.audioProperties();
|
|
64
|
+
if (!props) throw new MetadataError("read", "File may not contain valid audio data", "audioProperties");
|
|
65
|
+
return props;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Checks whether the given input is a valid, readable audio file.
|
|
70
|
+
*
|
|
71
|
+
* @param file - File path, Uint8Array, ArrayBuffer, or File object
|
|
72
|
+
* @returns `true` if the file is valid and recognized by TagLib; `false` otherwise
|
|
73
|
+
*/
|
|
74
|
+
async function isValidAudioFile(file) {
|
|
75
|
+
try {
|
|
76
|
+
const audioFile = await (await getTagLib()).open(file);
|
|
77
|
+
try {
|
|
78
|
+
return audioFile.isValid();
|
|
79
|
+
} finally {
|
|
80
|
+
audioFile.dispose();
|
|
81
|
+
}
|
|
82
|
+
} catch {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Detects the audio format of a file.
|
|
88
|
+
*
|
|
89
|
+
* @param file - File path, Uint8Array, ArrayBuffer, or File object
|
|
90
|
+
* @returns The detected `FileType`, or `undefined` if the format cannot be determined
|
|
91
|
+
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
|
|
92
|
+
*/
|
|
93
|
+
async function readFormat(file) {
|
|
94
|
+
const audioFile = await (await getTagLib()).open(file);
|
|
95
|
+
try {
|
|
96
|
+
if (!audioFile.isValid()) return;
|
|
97
|
+
return audioFile.getFormat();
|
|
98
|
+
} finally {
|
|
99
|
+
audioFile.dispose();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Removes all metadata tags and pictures from an audio file and returns the stripped content.
|
|
104
|
+
*
|
|
105
|
+
* @param file - File path, Uint8Array, ArrayBuffer, or File object
|
|
106
|
+
* @returns Modified audio file contents with all tags and pictures cleared
|
|
107
|
+
* @throws {TagLibInitializationError} If the Wasm module fails to initialize
|
|
108
|
+
* @throws {InvalidFormatError} If the file is corrupted or in an unsupported format
|
|
109
|
+
* @throws {FileOperationError} If saving the modified metadata fails
|
|
110
|
+
*/
|
|
111
|
+
async function clearTags(file) {
|
|
112
|
+
return withAudioFileSave(file, (audioFile) => {
|
|
113
|
+
const cleared = {};
|
|
114
|
+
for (const key of Object.keys(audioFile.properties())) cleared[key] = [];
|
|
115
|
+
audioFile.setProperties(cleared);
|
|
116
|
+
audioFile.removePictures();
|
|
117
|
+
audioFile.setLyrics([]);
|
|
118
|
+
audioFile.setRatings([]);
|
|
119
|
+
if (audioFile.getChapters().length > 0) audioFile.setChapters([]);
|
|
120
|
+
if (audioFile.getBextData() !== void 0) audioFile.setBextData(null);
|
|
121
|
+
if (audioFile.getIxml() !== void 0) audioFile.setIxml(null);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { applyTags, applyTagsToFile, clearTags, isValidAudioFile, readFormat, readProperties, readTags };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-audio-file.d.ts","sourceRoot":"","sources":["../../src/simple/with-audio-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/D,wBAAsB,aAAa,CAAC,CAAC,EACnC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC5C,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,cAAc,EACpB,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,GACjC,OAAO,CAAC,UAAU,CAAC,CAerB;AAED,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,GACjC,OAAO,CAAC,IAAI,CAAC,CAKf"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FileOperationError, InvalidFormatError } from "../errors/classes.js";
|
|
2
|
+
import "../errors.js";
|
|
3
|
+
import { getTagLib } from "./config.js";
|
|
4
|
+
//#region src/simple/with-audio-file.ts
|
|
5
|
+
async function withAudioFile(file, fn, options) {
|
|
6
|
+
const audioFile = await (await getTagLib()).open(file, options);
|
|
7
|
+
try {
|
|
8
|
+
if (!audioFile.isValid()) throw new InvalidFormatError("File may be corrupted or in an unsupported format");
|
|
9
|
+
return await fn(audioFile);
|
|
10
|
+
} finally {
|
|
11
|
+
audioFile.dispose();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async function withAudioFileSave(file, fn) {
|
|
15
|
+
return withAudioFile(file, (audioFile) => {
|
|
16
|
+
fn(audioFile);
|
|
17
|
+
if (!audioFile.save()) throw new FileOperationError("save", "Failed to save metadata changes. The file may be read-only or corrupted.");
|
|
18
|
+
return audioFile.getFileBuffer();
|
|
19
|
+
}, { partial: false });
|
|
20
|
+
}
|
|
21
|
+
async function withAudioFileSaveToFile(file, fn) {
|
|
22
|
+
return withAudioFile(file, async (audioFile) => {
|
|
23
|
+
fn(audioFile);
|
|
24
|
+
await audioFile.saveToFile(file);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { withAudioFile, withAudioFileSave, withAudioFileSaveToFile };
|
package/dist/simple.browser.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Simple API browser entry point.
|
|
3
|
-
* The
|
|
3
|
+
* The browser build's redirect plugin ensures the browser module loader is used.
|
|
4
4
|
*
|
|
5
5
|
* @module simple/browser
|
|
6
6
|
*/
|
|
7
|
-
export * from "./
|
|
7
|
+
export * from "./simple/index.js";
|
|
8
8
|
//# sourceMappingURL=simple.browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple.browser.d.ts","sourceRoot":"","sources":["../simple.browser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,
|
|
1
|
+
{"version":3,"file":"simple.browser.d.ts","sourceRoot":"","sources":["../src/simple.browser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,mBAAmB,CAAC"}
|