taglib-wasm 2.3.0 → 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 +70 -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/{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.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 +4101 -4478
- 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.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/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 +3404 -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 +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.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-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.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 +3168 -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 +131 -96
- 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.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.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}/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/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}/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}/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,120 @@
|
|
|
1
|
+
//#region src/runtime/wasi-adapter/audio-properties.ts
|
|
2
|
+
/**
|
|
3
|
+
* Container string (from the C++ snapshot) to declared `FileType`. Every
|
|
4
|
+
* `ContainerFormat` member has a key here except "unknown"; where the two
|
|
5
|
+
* unions differ in spelling, this table carries the translation — "Shorten"
|
|
6
|
+
* (container) is "SHN" (FileType). A container with no key falls through to
|
|
7
|
+
* the magic-byte sniff and then to "unknown", so a missing key silently
|
|
8
|
+
* degrades `getFormat()` on the WASI backend only (taglib-uat8).
|
|
9
|
+
*/
|
|
10
|
+
const CONTAINER_TO_FORMAT = {
|
|
11
|
+
MP3: "MP3",
|
|
12
|
+
ADTS: "AAC",
|
|
13
|
+
MP4: "MP4",
|
|
14
|
+
FLAC: "FLAC",
|
|
15
|
+
OGG: "OGG",
|
|
16
|
+
WAV: "WAV",
|
|
17
|
+
AIFF: "AIFF",
|
|
18
|
+
ASF: "ASF",
|
|
19
|
+
APE: "APE",
|
|
20
|
+
DSF: "DSF",
|
|
21
|
+
DSDIFF: "DSDIFF",
|
|
22
|
+
WavPack: "WV",
|
|
23
|
+
MPC: "MPC",
|
|
24
|
+
TTA: "TTA",
|
|
25
|
+
Shorten: "SHN",
|
|
26
|
+
MOD: "MOD",
|
|
27
|
+
S3M: "S3M",
|
|
28
|
+
IT: "IT",
|
|
29
|
+
XM: "XM",
|
|
30
|
+
Matroska: "MATROSKA"
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Formats inside the Ogg container. The container alone is not enough: three
|
|
34
|
+
* of the four codecs TagLib reads there are declared FileType members of their
|
|
35
|
+
* own ("OPUS", "OggFLAC", "SPEEX"), so Ogg Vorbis is the only flavour that
|
|
36
|
+
* stays "OGG" (taglib-f6a3). Keyed by the snapshot's codec value.
|
|
37
|
+
*/
|
|
38
|
+
const OGG_CODEC_TO_FORMAT = {
|
|
39
|
+
Opus: "OPUS",
|
|
40
|
+
FLAC: "OggFLAC",
|
|
41
|
+
Speex: "SPEEX"
|
|
42
|
+
};
|
|
43
|
+
/** The audio-properties block of the C++ snapshot, null when absent. */
|
|
44
|
+
function getAudioProperties(tagData) {
|
|
45
|
+
if (!tagData || !("sampleRate" in tagData)) return null;
|
|
46
|
+
const d = tagData;
|
|
47
|
+
const containerFormat = d.containerFormat || "unknown";
|
|
48
|
+
const mpegVersion = d.mpegVersion ?? 0;
|
|
49
|
+
const formatVersion = d.formatVersion ?? 0;
|
|
50
|
+
return {
|
|
51
|
+
duration: d.length ?? 0,
|
|
52
|
+
durationMs: d.lengthMs ?? 0,
|
|
53
|
+
bitrate: d.bitrate ?? 0,
|
|
54
|
+
sampleRate: d.sampleRate ?? 0,
|
|
55
|
+
channels: d.channels ?? 0,
|
|
56
|
+
bitsPerSample: d.bitsPerSample ?? 0,
|
|
57
|
+
codec: d.codec || "unknown",
|
|
58
|
+
containerFormat,
|
|
59
|
+
isLossless: d.isLossless ?? false,
|
|
60
|
+
...mpegVersion > 0 ? {
|
|
61
|
+
mpegVersion,
|
|
62
|
+
mpegLayer: d.mpegLayer ?? 0
|
|
63
|
+
} : {},
|
|
64
|
+
...containerFormat === "MP4" || containerFormat === "ASF" ? { isEncrypted: d.isEncrypted ?? false } : {},
|
|
65
|
+
...formatVersion > 0 ? { formatVersion } : {},
|
|
66
|
+
...d.outputGainDb !== void 0 ? { outputGainDb: d.outputGainDb } : {}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* OGG codec sniffing from the first page payload: "OpusHead" (Opus),
|
|
71
|
+
* 0x7F"FLAC" (FLAC-in-Ogg), "Speex " (Speex), else Ogg Vorbis ("OGG").
|
|
72
|
+
*/
|
|
73
|
+
function detectOggCodec(fileData) {
|
|
74
|
+
if (fileData.length < 37) return "OGG";
|
|
75
|
+
const segCount = fileData[26];
|
|
76
|
+
if (segCount === void 0) return "OGG";
|
|
77
|
+
const payloadStart = 27 + segCount;
|
|
78
|
+
if (fileData.length < payloadStart + 8) return "OGG";
|
|
79
|
+
const sig = fileData.slice(payloadStart, payloadStart + 8);
|
|
80
|
+
const text = String.fromCharCode(...sig);
|
|
81
|
+
if (text === "OpusHead") return "OPUS";
|
|
82
|
+
if (sig[0] === 127 && sig[1] === 70 && sig[2] === 76 && sig[3] === 65 && sig[4] === 67) return "OggFLAC";
|
|
83
|
+
if (text === "Speex ") return "SPEEX";
|
|
84
|
+
return "OGG";
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Format detection: container-based first (works for path and buffer modes),
|
|
88
|
+
* magic-byte fallback for buffers.
|
|
89
|
+
*/
|
|
90
|
+
function getFormat(tagData, fileData) {
|
|
91
|
+
const container = tagData?.containerFormat;
|
|
92
|
+
if (container) {
|
|
93
|
+
const codec = tagData?.codec;
|
|
94
|
+
if (container === "OGG" && codec && OGG_CODEC_TO_FORMAT[codec]) return OGG_CODEC_TO_FORMAT[codec];
|
|
95
|
+
if (CONTAINER_TO_FORMAT[container]) return CONTAINER_TO_FORMAT[container];
|
|
96
|
+
}
|
|
97
|
+
if (!fileData || fileData.length < 8) return "unknown";
|
|
98
|
+
const magic = fileData.slice(0, 4);
|
|
99
|
+
if (magic[0] === 255 && (magic[1] & 224) === 224) return "MP3";
|
|
100
|
+
if (magic[0] === 73 && magic[1] === 68 && magic[2] === 51) return "MP3";
|
|
101
|
+
if (magic[0] === 102 && magic[1] === 76 && magic[2] === 97 && magic[3] === 67) return "FLAC";
|
|
102
|
+
if (magic[0] === 79 && magic[1] === 103 && magic[2] === 103 && magic[3] === 83) return detectOggCodec(fileData);
|
|
103
|
+
if (magic[0] === 82 && magic[1] === 73 && magic[2] === 70 && magic[3] === 70) return "WAV";
|
|
104
|
+
if (magic[0] === 119 && magic[1] === 118 && magic[2] === 112 && magic[3] === 107) return "WV";
|
|
105
|
+
if (magic[0] === 84 && magic[1] === 84 && magic[2] === 65 && magic[3] === 49) return "TTA";
|
|
106
|
+
if (fileData.length >= 16 && magic[0] === 48 && magic[1] === 38 && magic[2] === 178 && magic[3] === 117) return "ASF";
|
|
107
|
+
if (magic[0] === 26 && magic[1] === 69 && magic[2] === 223 && magic[3] === 163) return "MATROSKA";
|
|
108
|
+
const ftyp = fileData.slice(4, 8);
|
|
109
|
+
if (ftyp[0] === 102 && ftyp[1] === 116 && ftyp[2] === 121 && ftyp[3] === 112) return "MP4";
|
|
110
|
+
return "unknown";
|
|
111
|
+
}
|
|
112
|
+
/** MP4 detection: containerFormat (path mode) or ftyp box (buffer mode). */
|
|
113
|
+
function isMP4(tagData, fileData) {
|
|
114
|
+
if (!fileData) return tagData?.containerFormat === "MP4";
|
|
115
|
+
if (fileData.length < 8) return false;
|
|
116
|
+
const magic = fileData.slice(4, 8);
|
|
117
|
+
return magic[0] === 102 && magic[1] === 116 && magic[2] === 121 && magic[3] === 112;
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
export { detectOggCodec, getAudioProperties, getFormat, isMP4 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-handle.d.ts","sourceRoot":"","sources":["../../../src/runtime/wasi-adapter/file-handle.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAEhE,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAiBhE,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IACpC,OAAO,CAAC,SAAS,CAAS;gBAEd,UAAU,EAAE,UAAU;IAIlC,OAAO,CAAC,iBAAiB;IAMzB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO;IAM3C,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAMnC,OAAO,IAAI,OAAO;IAKlB,IAAI,IAAI,OAAO;IAKf,SAAS,IAAI,UAAU;IAKvB,UAAU,IAAI,YAAY;IAK1B,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAK7C,kBAAkB,IAAI,eAAe,GAAG,IAAI;IAK5C,SAAS,IAAI,MAAM;IAKnB,KAAK,IAAI,OAAO;IAKhB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAKzC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAKzD,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAKhC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7C,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAK/B,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAK5C,kBAAkB,IAAI,MAAM,EAAE,GAAG,SAAS;IAK1C,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI;IAK5C,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKhC,WAAW,IAAI,UAAU,EAAE;IAK3B,WAAW,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,IAAI;IAKzC,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI;IAKrC,cAAc,IAAI,IAAI;IAKtB,WAAW,IAAI,UAAU,EAAE;IAK3B,WAAW,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI;IASlE,WAAW,IAAI,UAAU,GAAG,SAAS;IAKrC,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI;IAK1C,OAAO,IAAI,MAAM,GAAG,SAAS;IAK7B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAKlC,UAAU,IAAI;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,OAAO,CAAA;KAAE;IAK1C,YAAY,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IAKtD,UAAU,IAAI;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE;IAKlE,UAAU,CACR,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,GAC9D,IAAI;IAKP,SAAS,IAAI,SAAS,EAAE;IAKxB,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI;IAKpC,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,EAAE;IAK3C,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,IAAI;IAKpD,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAKnC,oBAAoB,IAAI,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,GAAG,SAAS;IAIhE,OAAO,IAAI,IAAI;CAIhB"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/defineProperty.js";
|
|
2
|
+
import { WasmerExecutionError } from "../wasmer-sdk-loader/types.js";
|
|
3
|
+
import { createHandleState, destroy, getBuffer, isValid, loadBuffer, loadPath, save } from "./handle-state.js";
|
|
4
|
+
import { getAudioProperties, getFormat, isMP4 } from "./audio-properties.js";
|
|
5
|
+
import { getBasicTagData, getProperties, getProperty, setBasicTagData, setProperties, setProperty } from "./property-surface.js";
|
|
6
|
+
import { getMP4Item, getMp4ItemRemovals, removeMP4Item, setMP4Item, setMp4ItemRemovals } from "./mp4-items.js";
|
|
7
|
+
import { addPicture, getBextData, getChapters, getId3v2Frames, getIxml, getLyrics, getPictures, getRatings, getStagedId3v2Frames, hasId3Tags, removeId3v2Frames, removePictures, setBextData, setChapters, setId3v2Frames, setIxml, setLyrics, setPictures, setRatings, stripId3Tags } from "./structured-fields.js";
|
|
8
|
+
//#region src/runtime/wasi-adapter/file-handle.ts
|
|
9
|
+
var WasiFileHandle = class {
|
|
10
|
+
constructor(wasiModule) {
|
|
11
|
+
_defineProperty(this, "state", void 0);
|
|
12
|
+
_defineProperty(this, "destroyed", false);
|
|
13
|
+
this.state = createHandleState(wasiModule);
|
|
14
|
+
}
|
|
15
|
+
checkNotDestroyed() {
|
|
16
|
+
if (this.destroyed) throw new WasmerExecutionError("FileHandle has been destroyed");
|
|
17
|
+
}
|
|
18
|
+
loadFromBuffer(buffer) {
|
|
19
|
+
this.checkNotDestroyed();
|
|
20
|
+
loadBuffer(this.state, buffer);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
loadFromPath(path) {
|
|
24
|
+
this.checkNotDestroyed();
|
|
25
|
+
loadPath(this.state, path);
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
isValid() {
|
|
29
|
+
this.checkNotDestroyed();
|
|
30
|
+
return isValid(this.state);
|
|
31
|
+
}
|
|
32
|
+
save() {
|
|
33
|
+
this.checkNotDestroyed();
|
|
34
|
+
return save(this.state);
|
|
35
|
+
}
|
|
36
|
+
getBuffer() {
|
|
37
|
+
this.checkNotDestroyed();
|
|
38
|
+
return getBuffer(this.state);
|
|
39
|
+
}
|
|
40
|
+
getTagData() {
|
|
41
|
+
this.checkNotDestroyed();
|
|
42
|
+
return getBasicTagData(this.state.tagData);
|
|
43
|
+
}
|
|
44
|
+
setTagData(data) {
|
|
45
|
+
this.checkNotDestroyed();
|
|
46
|
+
this.state.tagData = setBasicTagData(this.state.tagData, data);
|
|
47
|
+
}
|
|
48
|
+
getAudioProperties() {
|
|
49
|
+
this.checkNotDestroyed();
|
|
50
|
+
return getAudioProperties(this.state.tagData);
|
|
51
|
+
}
|
|
52
|
+
getFormat() {
|
|
53
|
+
this.checkNotDestroyed();
|
|
54
|
+
return getFormat(this.state.tagData, this.state.fileData);
|
|
55
|
+
}
|
|
56
|
+
isMP4() {
|
|
57
|
+
this.checkNotDestroyed();
|
|
58
|
+
return isMP4(this.state.tagData, this.state.fileData);
|
|
59
|
+
}
|
|
60
|
+
getProperties() {
|
|
61
|
+
this.checkNotDestroyed();
|
|
62
|
+
return getProperties(this.state.tagData);
|
|
63
|
+
}
|
|
64
|
+
setProperties(properties) {
|
|
65
|
+
this.checkNotDestroyed();
|
|
66
|
+
this.state.tagData = setProperties(this.state.tagData, properties);
|
|
67
|
+
}
|
|
68
|
+
getProperty(key) {
|
|
69
|
+
this.checkNotDestroyed();
|
|
70
|
+
return getProperty(this.state.tagData, key);
|
|
71
|
+
}
|
|
72
|
+
setProperty(key, value) {
|
|
73
|
+
this.checkNotDestroyed();
|
|
74
|
+
this.state.tagData = setProperty(this.state.tagData, key, value);
|
|
75
|
+
}
|
|
76
|
+
getMP4Item(key) {
|
|
77
|
+
this.checkNotDestroyed();
|
|
78
|
+
return getMP4Item(this.state.tagData, key);
|
|
79
|
+
}
|
|
80
|
+
setMP4Item(key, value) {
|
|
81
|
+
this.checkNotDestroyed();
|
|
82
|
+
this.state.tagData = setMP4Item(this.state.tagData, key, value);
|
|
83
|
+
}
|
|
84
|
+
getMp4ItemRemovals() {
|
|
85
|
+
this.checkNotDestroyed();
|
|
86
|
+
return getMp4ItemRemovals(this.state.tagData);
|
|
87
|
+
}
|
|
88
|
+
setMp4ItemRemovals(removals) {
|
|
89
|
+
this.checkNotDestroyed();
|
|
90
|
+
this.state.tagData = setMp4ItemRemovals(this.state.tagData, removals);
|
|
91
|
+
}
|
|
92
|
+
removeMP4Item(key) {
|
|
93
|
+
this.checkNotDestroyed();
|
|
94
|
+
this.state.tagData = removeMP4Item(this.state.tagData, key);
|
|
95
|
+
}
|
|
96
|
+
getPictures() {
|
|
97
|
+
this.checkNotDestroyed();
|
|
98
|
+
return getPictures(this.state.tagData);
|
|
99
|
+
}
|
|
100
|
+
setPictures(pictures) {
|
|
101
|
+
this.checkNotDestroyed();
|
|
102
|
+
this.state.tagData = setPictures(this.state.tagData, pictures);
|
|
103
|
+
}
|
|
104
|
+
addPicture(picture) {
|
|
105
|
+
this.checkNotDestroyed();
|
|
106
|
+
this.state.tagData = addPicture(this.state.tagData, picture);
|
|
107
|
+
}
|
|
108
|
+
removePictures() {
|
|
109
|
+
this.checkNotDestroyed();
|
|
110
|
+
this.state.tagData = removePictures(this.state.tagData);
|
|
111
|
+
}
|
|
112
|
+
getChapters() {
|
|
113
|
+
this.checkNotDestroyed();
|
|
114
|
+
return getChapters(this.state.tagData);
|
|
115
|
+
}
|
|
116
|
+
setChapters(chapters, mp4ChapterStyle) {
|
|
117
|
+
this.checkNotDestroyed();
|
|
118
|
+
this.state.tagData = setChapters(this.state.tagData, chapters, mp4ChapterStyle);
|
|
119
|
+
}
|
|
120
|
+
getBextData() {
|
|
121
|
+
this.checkNotDestroyed();
|
|
122
|
+
return getBextData(this.state.tagData);
|
|
123
|
+
}
|
|
124
|
+
setBextData(data) {
|
|
125
|
+
this.checkNotDestroyed();
|
|
126
|
+
this.state.tagData = setBextData(this.state.tagData, data);
|
|
127
|
+
}
|
|
128
|
+
getIxml() {
|
|
129
|
+
this.checkNotDestroyed();
|
|
130
|
+
return getIxml(this.state.tagData);
|
|
131
|
+
}
|
|
132
|
+
setIxml(data) {
|
|
133
|
+
this.checkNotDestroyed();
|
|
134
|
+
this.state.tagData = setIxml(this.state.tagData, data);
|
|
135
|
+
}
|
|
136
|
+
hasId3Tags() {
|
|
137
|
+
this.checkNotDestroyed();
|
|
138
|
+
return hasId3Tags(this.state.tagData);
|
|
139
|
+
}
|
|
140
|
+
stripId3Tags(opts) {
|
|
141
|
+
this.checkNotDestroyed();
|
|
142
|
+
this.state.tagData = stripId3Tags(this.state.tagData, opts);
|
|
143
|
+
}
|
|
144
|
+
getRatings() {
|
|
145
|
+
this.checkNotDestroyed();
|
|
146
|
+
return getRatings(this.state.tagData);
|
|
147
|
+
}
|
|
148
|
+
setRatings(ratings) {
|
|
149
|
+
this.checkNotDestroyed();
|
|
150
|
+
this.state.tagData = setRatings(this.state.tagData, ratings);
|
|
151
|
+
}
|
|
152
|
+
getLyrics() {
|
|
153
|
+
this.checkNotDestroyed();
|
|
154
|
+
return getLyrics(this.state.tagData);
|
|
155
|
+
}
|
|
156
|
+
setLyrics(lyrics) {
|
|
157
|
+
this.checkNotDestroyed();
|
|
158
|
+
this.state.tagData = setLyrics(this.state.tagData, lyrics);
|
|
159
|
+
}
|
|
160
|
+
getId3v2Frames(id) {
|
|
161
|
+
this.checkNotDestroyed();
|
|
162
|
+
return getId3v2Frames(this.state, id);
|
|
163
|
+
}
|
|
164
|
+
setId3v2Frames(id, data) {
|
|
165
|
+
this.checkNotDestroyed();
|
|
166
|
+
this.state.tagData = setId3v2Frames(this.state.tagData, id, data);
|
|
167
|
+
}
|
|
168
|
+
removeId3v2Frames(id) {
|
|
169
|
+
this.checkNotDestroyed();
|
|
170
|
+
this.state.tagData = removeId3v2Frames(this.state.tagData, id);
|
|
171
|
+
}
|
|
172
|
+
getStagedId3v2Frames() {
|
|
173
|
+
return getStagedId3v2Frames(this.state.tagData);
|
|
174
|
+
}
|
|
175
|
+
destroy() {
|
|
176
|
+
destroy(this.state);
|
|
177
|
+
this.destroyed = true;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
//#endregion
|
|
181
|
+
export { WasiFileHandle };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle-state.d.ts","sourceRoot":"","sources":["../../../src/runtime/wasi-adapter/handle-state.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAKhE,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAC;IAC5B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACzC;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,WAAW,CAE/D;AAED,mEAAmE;AACnE,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAKvE;AAED,iEAAiE;AACjE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAK/D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAKnD;AAED;iEACiE;AACjE,wBAAgB,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAsBhD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,CAExD;AAED,yEAAyE;AACzE,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAGhD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { decodeTagData } from "../../msgpack/decoder.js";
|
|
2
|
+
import { preserveEmptyValues } from "./tag-keys.js";
|
|
3
|
+
import { readTagsFromWasm, readTagsFromWasmPath, writeTagsToWasm, writeTagsToWasmPath } from "./wasm-io.js";
|
|
4
|
+
//#region src/runtime/wasi-adapter/handle-state.ts
|
|
5
|
+
function createHandleState(wasi) {
|
|
6
|
+
return {
|
|
7
|
+
wasi,
|
|
8
|
+
fileData: null,
|
|
9
|
+
filePath: null,
|
|
10
|
+
tagData: null
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** Read + decode + normalize a buffer source into the snapshot. */
|
|
14
|
+
function loadBuffer(state, buffer) {
|
|
15
|
+
state.fileData = buffer;
|
|
16
|
+
state.tagData = preserveEmptyValues(decodeTagData(readTagsFromWasm(state.wasi, buffer)));
|
|
17
|
+
}
|
|
18
|
+
/** Read + decode + normalize a path source into the snapshot. */
|
|
19
|
+
function loadPath(state, path) {
|
|
20
|
+
state.filePath = path;
|
|
21
|
+
state.tagData = preserveEmptyValues(decodeTagData(readTagsFromWasmPath(state.wasi, path)));
|
|
22
|
+
}
|
|
23
|
+
function isValid(state) {
|
|
24
|
+
return state.fileData !== null && state.fileData.length > 0 || state.filePath !== null && state.tagData !== null;
|
|
25
|
+
}
|
|
26
|
+
/** Write the snapshot back; path mode writes in place, buffer mode returns
|
|
27
|
+
* the new bytes (stored back into state.fileData on success). */
|
|
28
|
+
function save(state) {
|
|
29
|
+
if (!state.tagData) return false;
|
|
30
|
+
if (state.filePath) return writeTagsToWasmPath(state.wasi, state.filePath, state.tagData);
|
|
31
|
+
if (!state.fileData) return false;
|
|
32
|
+
const result = writeTagsToWasm(state.wasi, state.fileData, state.tagData);
|
|
33
|
+
if (result) {
|
|
34
|
+
state.fileData = result;
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
function getBuffer(state) {
|
|
40
|
+
return state.fileData ?? /* @__PURE__ */ new Uint8Array(0);
|
|
41
|
+
}
|
|
42
|
+
/** Null the source and snapshot; the class tracks the destroyed flag. */
|
|
43
|
+
function destroy(state) {
|
|
44
|
+
state.fileData = null;
|
|
45
|
+
state.tagData = null;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { createHandleState, destroy, getBuffer, isValid, loadBuffer, loadPath, save };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/wasi-adapter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mp4-items.d.ts","sourceRoot":"","sources":["../../../src/runtime/wasi-adapter/mp4-items.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAStD;AAED,yEAAyE;AACzE,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACvC,GAAG,EAAE,MAAM,GACV,MAAM,CAiBR;AAED,2DAA2D;AAC3D,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACvC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgBzB;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACvC,IAAI,EAAE,MAAM,GACX,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOzB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACvC,IAAI,EAAE,MAAM,GACX,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOzB;AAED,mEAAmE;AACnE,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GACtC,MAAM,EAAE,GAAG,SAAS,CAEtB;AAED,qDAAqD;AACrD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACvC,QAAQ,EAAE,MAAM,EAAE,GACjB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAKzB;AAED,4EAA4E;AAC5E,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACvC,GAAG,EAAE,MAAM,GACV,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAmBhC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { fromTagLibKey, mp4AtomWireKey } from "../../constants/properties.js";
|
|
2
|
+
import { mirrorForRawKey, stringifyScalar } from "../../utils/mirror-fields.js";
|
|
3
|
+
import { getProperty, setProperty } from "./property-surface.js";
|
|
4
|
+
//#region src/runtime/wasi-adapter/mp4-items.ts
|
|
5
|
+
/**
|
|
6
|
+
* MP4 item operations over the WASI tag-data snapshot.
|
|
7
|
+
*
|
|
8
|
+
* Pure functions over tagData: the WasiFileHandle wrappers add destruction
|
|
9
|
+
* guards. Extracted from file-handle.ts in the taglib-1dfc split.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Normalize an MP4 item key for the PropertyMap path. TagLib's MP4 PropertyMap
|
|
13
|
+
* keys a freeform `----:mean:NAME` atom by its bare NAME, uppercased (the usual
|
|
14
|
+
* key remap then maps known atoms like iTunNORM -> appleSoundCheck). WASI MP4
|
|
15
|
+
* items ride the PropertyMap, so the full iTunes atom key that Emscripten's
|
|
16
|
+
* dedicated Item API uses must be normalized or the value is silently dropped on
|
|
17
|
+
* save (taglib-1qn). Non-freeform keys pass through unchanged.
|
|
18
|
+
*/
|
|
19
|
+
function mp4ItemPropertyKey(key) {
|
|
20
|
+
if (key.startsWith("----:")) return key.slice(key.lastIndexOf(":") + 1).toUpperCase();
|
|
21
|
+
return mp4AtomWireKey(key) ?? key;
|
|
22
|
+
}
|
|
23
|
+
/** Read an MP4 item; foreign-mean atoms ride their full `----:` slot. */
|
|
24
|
+
function getMP4Item(tagData, key) {
|
|
25
|
+
if (key.startsWith("----:")) {
|
|
26
|
+
const foreign = tagData?.[key];
|
|
27
|
+
if (foreign !== void 0) {
|
|
28
|
+
if (Array.isArray(foreign)) {
|
|
29
|
+
const first = foreign[0];
|
|
30
|
+
return stringifyScalar(first);
|
|
31
|
+
}
|
|
32
|
+
return stringifyScalar(foreign);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return getProperty(tagData, mp4ItemPropertyKey(key));
|
|
36
|
+
}
|
|
37
|
+
/** Write an MP4 item; returns the next snapshot record. */
|
|
38
|
+
function setMP4Item(tagData, key, value) {
|
|
39
|
+
let next = setProperty(tagData, mp4ItemPropertyKey(key), value);
|
|
40
|
+
if (key.startsWith("----:")) {
|
|
41
|
+
next = registerMp4ItemName(next, key);
|
|
42
|
+
if (next?.[key] !== void 0) next = {
|
|
43
|
+
...next,
|
|
44
|
+
[key]: value
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return next;
|
|
48
|
+
}
|
|
49
|
+
/** Record an exact atom name to be repaired after the PropertyMap write. */
|
|
50
|
+
function registerMp4ItemName(tagData, name) {
|
|
51
|
+
const existing = tagData?._mp4ItemNames ?? [];
|
|
52
|
+
if (existing.includes(name)) return tagData ?? {};
|
|
53
|
+
return {
|
|
54
|
+
...tagData,
|
|
55
|
+
_mp4ItemNames: [...existing, name]
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Record a foreign-mean freeform atom for deletion at save (taglib-65nm).
|
|
60
|
+
* The PropertyMap erase pass cannot express foreign atoms, so the C++ shim
|
|
61
|
+
* consumes this list and calls removeItem on each exact atom name.
|
|
62
|
+
*/
|
|
63
|
+
function registerMp4ItemRemoval(tagData, name) {
|
|
64
|
+
const existing = tagData?._mp4ItemRemovals ?? [];
|
|
65
|
+
if (existing.includes(name)) return tagData ?? {};
|
|
66
|
+
return {
|
|
67
|
+
...tagData,
|
|
68
|
+
_mp4ItemRemovals: [...existing, name]
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** The accumulated foreign-atom removals pending the next save. */
|
|
72
|
+
function getMp4ItemRemovals(tagData) {
|
|
73
|
+
return tagData?._mp4ItemRemovals;
|
|
74
|
+
}
|
|
75
|
+
/** Replace the pending foreign-atom removal list. */
|
|
76
|
+
function setMp4ItemRemovals(tagData, removals) {
|
|
77
|
+
return {
|
|
78
|
+
...tagData,
|
|
79
|
+
_mp4ItemRemovals: [...new Set(removals)]
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** Remove an MP4 item; returns the next snapshot record (null on no-op). */
|
|
83
|
+
function removeMP4Item(tagData, key) {
|
|
84
|
+
if (!tagData) return null;
|
|
85
|
+
let next = tagData;
|
|
86
|
+
if (key.startsWith("----:")) {
|
|
87
|
+
delete next[key];
|
|
88
|
+
next = registerMp4ItemRemoval(next, key);
|
|
89
|
+
}
|
|
90
|
+
const mappedKey = fromTagLibKey(mp4ItemPropertyKey(key));
|
|
91
|
+
delete next[mappedKey];
|
|
92
|
+
const mirror = mirrorForRawKey(mappedKey);
|
|
93
|
+
if (mirror !== void 0) delete next[mirror.numeric];
|
|
94
|
+
return next;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
export { getMP4Item, getMp4ItemRemovals, mp4ItemPropertyKey, registerMp4ItemName, registerMp4ItemRemoval, removeMP4Item, setMP4Item, setMp4ItemRemovals };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-open.d.ts","sourceRoot":"","sources":["../../../src/runtime/wasi-adapter/path-open.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAqBhE;;qBAEqB;AACrB,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,gBAAgB,IAAI,UAAU,CAAC;CAChC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,cAAc,CAAC,CAwCzB"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { FileOperationError, InvalidFormatError } from "../../errors/classes.js";
|
|
2
|
+
import { getFileSize, readPartialFileData } from "../../utils/file.js";
|
|
3
|
+
import { readTagsFromWasm } from "./wasm-io.js";
|
|
4
|
+
//#region src/runtime/wasi-adapter/path-open.ts
|
|
5
|
+
/** `TL_FORMAT_AUTO`: what the detector answers for bytes it cannot place
|
|
6
|
+
* (`src/capi/core/taglib_core.h`). */
|
|
7
|
+
const TL_FORMAT_AUTO = 0;
|
|
8
|
+
/**
|
|
9
|
+
* How much of the head the detector gets: every rule it has reads inside this
|
|
10
|
+
* (the deepest is MOD's signature at offset 1080), and a file smaller than this
|
|
11
|
+
* is read whole, which makes the head's buffer verdict exactly the buffer
|
|
12
|
+
* branch's verdict for it. A larger window would cost a larger read per refused
|
|
13
|
+
* path and could only agree more often, never less.
|
|
14
|
+
*/
|
|
15
|
+
const HEADER_WINDOW = 4096;
|
|
16
|
+
/**
|
|
17
|
+
* Load an audio file by path, verifying that its content is audio.
|
|
18
|
+
*
|
|
19
|
+
* Every failure the caller can act on is distinct: `FileOperationError` for a
|
|
20
|
+
* path the host does not have (what the buffer form's own stat answers, so a
|
|
21
|
+
* typo reads the same on both backends), `InvalidFormatError` for a zero-byte
|
|
22
|
+
* file (see below) and for content the boundary could not resolve as audio, and
|
|
23
|
+
* the wasm-level errors unchanged. Either content signal above suffices; both
|
|
24
|
+
* saying nothing is a refusal.
|
|
25
|
+
*
|
|
26
|
+
* The returned handle is the library-owned one (the WASI brand asserted here,
|
|
27
|
+
* the WASI equivalent of `wrapEmbindHandle`), destroyed on any failure — the
|
|
28
|
+
* caller's `AudioFile` takes it over on success.
|
|
29
|
+
*/
|
|
30
|
+
async function openAudioPath(backend, wasiPath, displayPath) {
|
|
31
|
+
const hostPath = backend.hostModule.hostPathFor(wasiPath);
|
|
32
|
+
if (hostPath === void 0) throw new FileOperationError("read", "The path is outside the WASI preopens this host was created with", displayPath);
|
|
33
|
+
if (await getFileSize(hostPath) === 0) throw new InvalidFormatError(`The file is empty. Path: ${displayPath}`);
|
|
34
|
+
const handle = backend.createFileHandle();
|
|
35
|
+
try {
|
|
36
|
+
if (!handle.loadFromPath(wasiPath)) throw new InvalidFormatError(`Failed to load audio file. Path: ${displayPath}`);
|
|
37
|
+
if (!await holdsAudio(backend, wasiPath, handle)) throw new InvalidFormatError(`Failed to load audio file. File may be corrupted or in an unsupported format. Path: ${displayPath}`);
|
|
38
|
+
return handle;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
handle.destroy();
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Whether either signal fires: the parse read an audio property, or the head is
|
|
45
|
+
* content a detector knows. */
|
|
46
|
+
async function holdsAudio(backend, wasiPath, handle) {
|
|
47
|
+
return statesAudioProperties(handle) || await hasRecognizableHead(backend, wasiPath);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Whether the parse read an audio property out of the file.
|
|
51
|
+
*
|
|
52
|
+
* `mpegVersion`, `mpegLayer` and `formatVersion` are deliberately not evidence —
|
|
53
|
+
* the boundary writes them for any file the extension named MPEG, junk included
|
|
54
|
+
* (a 1 KiB junk `.mp3` and a zero-byte one both report `mpegVersion: 1`,
|
|
55
|
+
* measured) — and neither are `codec`/`containerFormat`/`isLossless`, which are
|
|
56
|
+
* the file class's opinion of itself rather than something read from the audio.
|
|
57
|
+
*
|
|
58
|
+
* Tags are not part of this signal either: a tag-only file's head *is* the tag,
|
|
59
|
+
* so the second signal covers it, and counting tags here would keep a file whose
|
|
60
|
+
* only finding is a tag TagLib parsed out of corrupt bytes (measured:
|
|
61
|
+
* `lib/taglib/tests/data/64bit.mp4` yields one).
|
|
62
|
+
*/
|
|
63
|
+
function statesAudioProperties(handle) {
|
|
64
|
+
const audio = handle.getAudioProperties();
|
|
65
|
+
return audio !== null && (audio.sampleRate > 0 || audio.channels > 0 || audio.bitrate > 0 || audio.duration > 0 || audio.bitsPerSample > 0);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Whether the head is content a detector knows. A path no preopen covers is
|
|
69
|
+
* `false` too — the guest cannot read it either, and the failure it earns is the
|
|
70
|
+
* same `InvalidFormatError`.
|
|
71
|
+
*/
|
|
72
|
+
async function hasRecognizableHead(backend, wasiPath) {
|
|
73
|
+
const wasi = backend.hostModule;
|
|
74
|
+
const hostPath = wasi.hostPathFor(wasiPath);
|
|
75
|
+
if (hostPath === void 0) return false;
|
|
76
|
+
const head = await readPartialFileData(hostPath, HEADER_WINDOW, 0);
|
|
77
|
+
return detectsFormat(wasi, head) || opensAsBuffer(wasi, head);
|
|
78
|
+
}
|
|
79
|
+
function detectsFormat(wasi, head) {
|
|
80
|
+
const ptr = wasi.malloc(Math.max(head.length, 1));
|
|
81
|
+
try {
|
|
82
|
+
new Uint8Array(wasi.memory.buffer).set(head, ptr);
|
|
83
|
+
return wasi.tl_detect_format(ptr, head.length) !== TL_FORMAT_AUTO;
|
|
84
|
+
} finally {
|
|
85
|
+
wasi.free(ptr);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** Whether the buffer branch accepts these bytes — the same call `TagLib.open()`
|
|
89
|
+
* makes for a `Uint8Array`, whose acceptance is the authority here. Only the
|
|
90
|
+
* acceptance is of interest, so the tag snapshot is dropped. */
|
|
91
|
+
function opensAsBuffer(wasi, head) {
|
|
92
|
+
try {
|
|
93
|
+
readTagsFromWasm(wasi, head);
|
|
94
|
+
return true;
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (error instanceof InvalidFormatError) return false;
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { openAudioPath };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-surface.d.ts","sourceRoot":"","sources":["../../../src/runtime/wasi-adapter/property-surface.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAexD,2EAA2E;AAC3E,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GACtC,YAAY,CAWd;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACvC,IAAI,EAAE,OAAO,CAAC,YAAY,CAAC,GAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASzB;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GACtC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAwC1B;AAED,sEAAsE;AACtE,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACvC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgCzB;AAED,oDAAoD;AACpD,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACvC,GAAG,EAAE,MAAM,GACV,MAAM,CAQR;AAED,+DAA+D;AAC/D,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACvC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { fromTagLibKey, toTagLibKey } from "../../constants/properties.js";
|
|
2
|
+
import { DATE_MIRROR, TRACK_MIRROR, firstValueString, isShadowedNumericMirror, mirrorForRawKey, readNumericMirror, stageNumericWrite, stageRawWrite, stringifyScalar } from "../../utils/mirror-fields.js";
|
|
3
|
+
import { AUDIO_KEYS, INTERNAL_KEYS } from "./tag-keys.js";
|
|
4
|
+
//#region src/runtime/wasi-adapter/property-surface.ts
|
|
5
|
+
/** The readable basic-tag surface (first-value idiom, numeric mirrors). */
|
|
6
|
+
function getBasicTagData(tagData) {
|
|
7
|
+
const d = tagData ?? {};
|
|
8
|
+
return {
|
|
9
|
+
title: firstValueString(d.title),
|
|
10
|
+
artist: firstValueString(d.artist),
|
|
11
|
+
album: firstValueString(d.album),
|
|
12
|
+
comment: firstValueString(d.comment),
|
|
13
|
+
genre: firstValueString(d.genre),
|
|
14
|
+
year: readNumericMirror(d, DATE_MIRROR),
|
|
15
|
+
track: readNumericMirror(d, TRACK_MIRROR)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Merge a basic-tag write into the snapshot. setYear()/setTrack() are
|
|
20
|
+
* authoritative for their wire key: the raw mirror is replaced so a stale
|
|
21
|
+
* "1975-10-31" or "3/12" cannot shadow the new number, and a non-positive
|
|
22
|
+
* value clears the field outright (taglib-bk7, taglib-qpl).
|
|
23
|
+
*/
|
|
24
|
+
function setBasicTagData(tagData, data) {
|
|
25
|
+
const merged = {
|
|
26
|
+
...tagData,
|
|
27
|
+
...data
|
|
28
|
+
};
|
|
29
|
+
if (data.year !== void 0) stageNumericWrite(merged, DATE_MIRROR, data.year);
|
|
30
|
+
if (data.track !== void 0) stageNumericWrite(merged, TRACK_MIRROR, data.track);
|
|
31
|
+
return merged;
|
|
32
|
+
}
|
|
33
|
+
/** The property map over the snapshot, excluding audio/internal keys. */
|
|
34
|
+
function getProperties(tagData) {
|
|
35
|
+
const result = {};
|
|
36
|
+
const data = tagData ?? {};
|
|
37
|
+
for (const [key, value] of Object.entries(data)) {
|
|
38
|
+
if (AUDIO_KEYS.has(key) || INTERNAL_KEYS.has(key)) continue;
|
|
39
|
+
if (key.startsWith("----:")) continue;
|
|
40
|
+
if (isShadowedNumericMirror(data, key)) continue;
|
|
41
|
+
if (value === void 0 || value === null) continue;
|
|
42
|
+
if (value === 0 || value === "") continue;
|
|
43
|
+
const propKey = toTagLibKey(key);
|
|
44
|
+
if (Array.isArray(value)) {
|
|
45
|
+
if (value.length === 0) continue;
|
|
46
|
+
result[propKey] = value.map(String);
|
|
47
|
+
} else if (typeof value === "object") continue;
|
|
48
|
+
else if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint" || typeof value === "symbol") result[propKey] = [String(value)];
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
/** Replace-style property write; returns the next snapshot record. */
|
|
53
|
+
function setProperties(tagData, props) {
|
|
54
|
+
const next = { ...tagData };
|
|
55
|
+
for (const [key, values] of Object.entries(props)) {
|
|
56
|
+
const camelKey = fromTagLibKey(key);
|
|
57
|
+
if (camelKey === "_mp4ItemNames") {
|
|
58
|
+
const existing = next._mp4ItemNames ?? [];
|
|
59
|
+
next._mp4ItemNames = [.../* @__PURE__ */ new Set([...existing, ...values])];
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const mirror = mirrorForRawKey(camelKey);
|
|
63
|
+
if (mirror !== void 0) stageRawWrite(next, mirror, values);
|
|
64
|
+
else if (values.length === 0) {
|
|
65
|
+
if (camelKey === "itunesAdvisory") next[camelKey] = [];
|
|
66
|
+
else delete next[camelKey];
|
|
67
|
+
} else next[camelKey] = values;
|
|
68
|
+
}
|
|
69
|
+
return next;
|
|
70
|
+
}
|
|
71
|
+
/** Single-property read (first value of arrays). */
|
|
72
|
+
function getProperty(tagData, key) {
|
|
73
|
+
const mappedKey = fromTagLibKey(key);
|
|
74
|
+
const stored = tagData?.[mappedKey];
|
|
75
|
+
if (Array.isArray(stored)) {
|
|
76
|
+
const first = stored[0];
|
|
77
|
+
return stringifyScalar(first);
|
|
78
|
+
}
|
|
79
|
+
return stringifyScalar(stored);
|
|
80
|
+
}
|
|
81
|
+
/** Single-property write; returns the next snapshot record. */
|
|
82
|
+
function setProperty(tagData, key, value) {
|
|
83
|
+
const mappedKey = fromTagLibKey(key);
|
|
84
|
+
const mirror = mirrorForRawKey(mappedKey);
|
|
85
|
+
if (mirror !== void 0) {
|
|
86
|
+
const next = { ...tagData };
|
|
87
|
+
stageRawWrite(next, mirror, value === "" ? [] : [value]);
|
|
88
|
+
return next;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
...tagData,
|
|
92
|
+
[mappedKey]: value
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
export { getBasicTagData, getProperties, getProperty, setBasicTagData, setProperties, setProperty };
|