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,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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structured-fields.d.ts","sourceRoot":"","sources":["../../../src/runtime/wasi-adapter/structured-fields.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { readId3v2FramesFromWasm } from "./wasm-io.js";
|
|
2
|
+
//#region src/runtime/wasi-adapter/structured-fields.ts
|
|
3
|
+
function getPictures(tagData) {
|
|
4
|
+
return tagData?.pictures ?? [];
|
|
5
|
+
}
|
|
6
|
+
function setPictures(tagData, pictures) {
|
|
7
|
+
return {
|
|
8
|
+
...tagData,
|
|
9
|
+
pictures
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function addPicture(tagData, picture) {
|
|
13
|
+
const pictures = getPictures(tagData);
|
|
14
|
+
pictures.push(picture);
|
|
15
|
+
return setPictures(tagData, pictures);
|
|
16
|
+
}
|
|
17
|
+
function removePictures(tagData) {
|
|
18
|
+
return {
|
|
19
|
+
...tagData,
|
|
20
|
+
pictures: []
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function getChapters(tagData) {
|
|
24
|
+
return tagData?.chapters ?? [];
|
|
25
|
+
}
|
|
26
|
+
function setChapters(tagData, chapters, mp4ChapterStyle) {
|
|
27
|
+
return {
|
|
28
|
+
...tagData,
|
|
29
|
+
_mp4ChapterStyle: mp4ChapterStyle,
|
|
30
|
+
chapters
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function getBextData(tagData) {
|
|
34
|
+
return tagData?.bextData ?? void 0;
|
|
35
|
+
}
|
|
36
|
+
function setBextData(tagData, data) {
|
|
37
|
+
return {
|
|
38
|
+
...tagData,
|
|
39
|
+
bextData: data
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function getIxml(tagData) {
|
|
43
|
+
const v = tagData?.ixml;
|
|
44
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
45
|
+
}
|
|
46
|
+
function setIxml(tagData, data) {
|
|
47
|
+
return {
|
|
48
|
+
...tagData,
|
|
49
|
+
ixml: data
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function hasId3Tags(tagData) {
|
|
53
|
+
const t = tagData?.id3Tags;
|
|
54
|
+
return {
|
|
55
|
+
v1: t?.v1 ?? false,
|
|
56
|
+
v2: t?.v2 ?? false
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function stripId3Tags(tagData, opts) {
|
|
60
|
+
const current = tagData?.id3Tags;
|
|
61
|
+
if (!current) return tagData;
|
|
62
|
+
const prior = tagData?._stripId3;
|
|
63
|
+
const stripV1 = (prior?.v1 ?? false) || opts.v1;
|
|
64
|
+
const stripV2 = (prior?.v2 ?? false) || opts.v2;
|
|
65
|
+
return {
|
|
66
|
+
...tagData,
|
|
67
|
+
_stripId3: {
|
|
68
|
+
v1: stripV1,
|
|
69
|
+
v2: stripV2
|
|
70
|
+
},
|
|
71
|
+
id3Tags: {
|
|
72
|
+
v1: (current.v1 ?? false) && !stripV1,
|
|
73
|
+
v2: (current.v2 ?? false) && !stripV2
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function getRatings(tagData) {
|
|
78
|
+
return tagData?.ratings ?? [];
|
|
79
|
+
}
|
|
80
|
+
function setRatings(tagData, ratings) {
|
|
81
|
+
const normalizedRatings = ratings.map((r) => ({
|
|
82
|
+
rating: r.rating,
|
|
83
|
+
email: r.email ?? "",
|
|
84
|
+
counter: r.counter ?? 0
|
|
85
|
+
}));
|
|
86
|
+
return {
|
|
87
|
+
...tagData,
|
|
88
|
+
ratings: normalizedRatings
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function getLyrics(tagData) {
|
|
92
|
+
const value = tagData?.lyrics;
|
|
93
|
+
if (value === void 0 || value === null) return [];
|
|
94
|
+
return (Array.isArray(value) ? value : [value]).map((entry) => typeof entry === "string" ? {
|
|
95
|
+
text: entry,
|
|
96
|
+
description: "",
|
|
97
|
+
language: ""
|
|
98
|
+
} : {
|
|
99
|
+
text: entry?.text ?? "",
|
|
100
|
+
description: entry?.description ?? "",
|
|
101
|
+
language: entry?.language ?? ""
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function setLyrics(tagData, lyrics) {
|
|
105
|
+
return {
|
|
106
|
+
...tagData,
|
|
107
|
+
lyrics
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function getStagedId3v2Frames(tagData) {
|
|
111
|
+
return tagData?.id3v2Frames;
|
|
112
|
+
}
|
|
113
|
+
function setId3v2Frames(tagData, id, data) {
|
|
114
|
+
const staged = { ...getStagedId3v2Frames(tagData) ?? {} };
|
|
115
|
+
staged[id] = data.map((d) => new Uint8Array(d));
|
|
116
|
+
return {
|
|
117
|
+
...tagData,
|
|
118
|
+
id3v2Frames: staged
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function removeId3v2Frames(tagData, id) {
|
|
122
|
+
return setId3v2Frames(tagData, id, []);
|
|
123
|
+
}
|
|
124
|
+
/** Raw ID3v2 frames: file state filtered by staged per-ID replacements. */
|
|
125
|
+
function getId3v2Frames(state, id) {
|
|
126
|
+
const filter = id === "" ? void 0 : id;
|
|
127
|
+
const source = state.filePath ?? state.fileData;
|
|
128
|
+
let frames = [];
|
|
129
|
+
if (source) frames = readId3v2FramesFromWasm(state.wasi, source, filter);
|
|
130
|
+
const staged = getStagedId3v2Frames(state.tagData);
|
|
131
|
+
if (!staged) return frames;
|
|
132
|
+
const stagedIds = new Set(Object.keys(staged));
|
|
133
|
+
frames = frames.filter((f) => !stagedIds.has(f.id));
|
|
134
|
+
for (const [sid, bodies] of Object.entries(staged)) {
|
|
135
|
+
if (filter && sid !== filter) continue;
|
|
136
|
+
for (const data of bodies) frames.push({
|
|
137
|
+
id: sid,
|
|
138
|
+
data: data.slice()
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return frames;
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { addPicture, getBextData, getChapters, getId3v2Frames, getIxml, getLyrics, getPictures, getRatings, getStagedId3v2Frames, hasId3Tags, removeId3v2Frames, removePictures, setBextData, setChapters, setId3v2Frames, setIxml, setLyrics, setPictures, setRatings, stripId3Tags };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag-keys.d.ts","sourceRoot":"","sources":["../../../src/runtime/wasi-adapter/tag-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,sEAAsE;AACtE,eAAO,MAAM,UAAU,aAiBrB,CAAC;AAEH,qEAAqE;AACrE,eAAO,MAAM,aAAa,aAaxB,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region src/runtime/wasi-adapter/tag-keys.ts
|
|
2
|
+
/**
|
|
3
|
+
* Internal key classification for the WASI tag-data snapshot.
|
|
4
|
+
*
|
|
5
|
+
* AUDIO_KEYS and INTERNAL_KEYS are excluded from the property surface
|
|
6
|
+
* (getProperties); preserveEmptyValues keeps empty-string fields alive for
|
|
7
|
+
* the save round-trip (taglib-yc1x). Extracted from file-handle.ts in the
|
|
8
|
+
* taglib-1dfc split.
|
|
9
|
+
*/
|
|
10
|
+
/** Audio metrics emitted by the C++ read path, not tag properties. */
|
|
11
|
+
const AUDIO_KEYS = /* @__PURE__ */ new Set([
|
|
12
|
+
"bitrate",
|
|
13
|
+
"bitrateMode",
|
|
14
|
+
"bitsPerSample",
|
|
15
|
+
"channels",
|
|
16
|
+
"codec",
|
|
17
|
+
"containerFormat",
|
|
18
|
+
"formatVersion",
|
|
19
|
+
"isEncrypted",
|
|
20
|
+
"isLossless",
|
|
21
|
+
"duration",
|
|
22
|
+
"length",
|
|
23
|
+
"lengthMs",
|
|
24
|
+
"mpegLayer",
|
|
25
|
+
"mpegVersion",
|
|
26
|
+
"outputGainDb",
|
|
27
|
+
"sampleRate"
|
|
28
|
+
]);
|
|
29
|
+
/** Structured fields and write-time directives, never properties. */
|
|
30
|
+
const INTERNAL_KEYS = /* @__PURE__ */ new Set([
|
|
31
|
+
"pictures",
|
|
32
|
+
"ratings",
|
|
33
|
+
"lyrics",
|
|
34
|
+
"chapters",
|
|
35
|
+
"_mp4ChapterStyle",
|
|
36
|
+
"bextData",
|
|
37
|
+
"ixml",
|
|
38
|
+
"_mp4ItemNames",
|
|
39
|
+
"_mp4ItemRemovals"
|
|
40
|
+
]);
|
|
41
|
+
/**
|
|
42
|
+
* A frame that exists holding an empty string is not the same state as no frame
|
|
43
|
+
* at all, and the read snapshot must say so — otherwise the save cannot carry
|
|
44
|
+
* the value back, `setProperties()` sees the field as absent, and TagLib deletes
|
|
45
|
+
* a frame the caller never touched (taglib-yc1x).
|
|
46
|
+
*
|
|
47
|
+
* The C++ encoder emits a single value as a bare string, and both `cleanObject`
|
|
48
|
+
* and `getProperties` drop a bare `""`. An ARRAY containing `""` already
|
|
49
|
+
* survives every one of those layers, so promoting the bare form to `[""]` here
|
|
50
|
+
* carries the value end to end without touching the encoder or the decoder.
|
|
51
|
+
*
|
|
52
|
+
* This only concerns readable tag properties: audio metrics and the internal
|
|
53
|
+
* write-time channels keep their own shapes.
|
|
54
|
+
*/
|
|
55
|
+
function preserveEmptyValues(data) {
|
|
56
|
+
for (const [key, value] of Object.entries(data)) {
|
|
57
|
+
if (value !== "") continue;
|
|
58
|
+
if (AUDIO_KEYS.has(key) || INTERNAL_KEYS.has(key)) continue;
|
|
59
|
+
if (key.startsWith("----:")) continue;
|
|
60
|
+
data[key] = [""];
|
|
61
|
+
}
|
|
62
|
+
return data;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { AUDIO_KEYS, INTERNAL_KEYS, preserveEmptyValues };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm-io.d.ts","sourceRoot":"","sources":["../../../src/runtime/wasi-adapter/wasm-io.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAahE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAyDnD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,UAAU,GACjB,UAAU,CA2BZ;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,GACX,UAAU,CAqBZ;AAED,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,UAAU,GAAG,MAAM,EAC3B,EAAE,CAAC,EAAE,MAAM,GACV,aAAa,EAAE,CA0CjB;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,GACnB,OAAO,CA0BT;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,WAAW,GACnB,UAAU,GAAG,IAAI,CA8BnB"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { FileOperationError, InvalidFormatError, UnsupportedFormatError } from "../../errors/classes.js";
|
|
2
|
+
import { decodeMessagePack } from "../../msgpack/decoder.js";
|
|
3
|
+
import { encodeTagData } from "../../msgpack/encoder.js";
|
|
4
|
+
import { WasmArena, WasmMemoryError } from "../wasi-memory.js";
|
|
5
|
+
import _usingCtx from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/usingCtx.js";
|
|
6
|
+
//#region src/runtime/wasi-adapter/wasm-io.ts
|
|
7
|
+
const TL_ERROR_INVALID_INPUT = -1;
|
|
8
|
+
const TL_ERROR_UNSUPPORTED_FORMAT = -2;
|
|
9
|
+
const TL_ERROR_IO_READ = -4;
|
|
10
|
+
const TL_ERROR_IO_WRITE = -5;
|
|
11
|
+
const TL_ERROR_PARSE_FAILED = -6;
|
|
12
|
+
/**
|
|
13
|
+
* The one code→class rule for a failing `tl_*` call, so a consumer's
|
|
14
|
+
* `isInvalidFormatError` branch means the same thing whichever call failed —
|
|
15
|
+
* and the same thing for a path as for a buffer of the same bytes.
|
|
16
|
+
*
|
|
17
|
+
* - `INVALID_INPUT`, `UNSUPPORTED_FORMAT`, `IO_READ` and `PARSE_FAILED` all say
|
|
18
|
+
* the *input* is not audio the library can open: a zero-length buffer, junk
|
|
19
|
+
* bytes, a corrupt file, a path that is not there. `IO_READ` reads as "could
|
|
20
|
+
* not open", and these read paths decide that from the content, never from the
|
|
21
|
+
* caller's reach — a path outside the WASI preopens fails the same way.
|
|
22
|
+
* - `IO_WRITE` is the file refusing the write, which is a file operation.
|
|
23
|
+
* - `MEMORY_ALLOCATION` is the only genuine memory failure. An unrecognised code
|
|
24
|
+
* (a module built against a different enum) keeps `WASM_MEMORY` rather than
|
|
25
|
+
* being folded into a format error.
|
|
26
|
+
*
|
|
27
|
+
* @param where - what the failure was observed on, as the message tail:
|
|
28
|
+
* `. Path: /x.mp3` or `. Buffer size: 1024 bytes`, empty when the caller has
|
|
29
|
+
* nothing to add.
|
|
30
|
+
* @param bufferSize - the buffer form's size hint, which `InvalidFormatError`
|
|
31
|
+
* renders as its own detail.
|
|
32
|
+
*/
|
|
33
|
+
function throwForErrorCode(errorCode, operation, where, bufferSize) {
|
|
34
|
+
switch (errorCode) {
|
|
35
|
+
case TL_ERROR_INVALID_INPUT:
|
|
36
|
+
case TL_ERROR_UNSUPPORTED_FORMAT:
|
|
37
|
+
case TL_ERROR_IO_READ:
|
|
38
|
+
case TL_ERROR_PARSE_FAILED: throw new InvalidFormatError(`File may be corrupted or in an unsupported format${where}`, bufferSize);
|
|
39
|
+
case TL_ERROR_IO_WRITE: throw new FileOperationError("write", `Failed to write tags${where}`);
|
|
40
|
+
default: throw new WasmMemoryError(`error code ${errorCode}${where}`, operation, errorCode);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function readTagsFromWasm(wasi, buffer) {
|
|
44
|
+
try {
|
|
45
|
+
var _usingCtx$1 = _usingCtx();
|
|
46
|
+
const arena = _usingCtx$1.u(new WasmArena(wasi));
|
|
47
|
+
const inputBuf = arena.allocBuffer(buffer);
|
|
48
|
+
const outSizePtr = arena.allocUint32();
|
|
49
|
+
const resultPtr = wasi.tl_read_tags(0, inputBuf.ptr, inputBuf.size, outSizePtr.ptr);
|
|
50
|
+
if (resultPtr === 0) throwForErrorCode(wasi.tl_get_last_error_code(), "read tags", `. Buffer size: ${buffer.length} bytes`, buffer.length);
|
|
51
|
+
const outSize = outSizePtr.readUint32();
|
|
52
|
+
const u8 = new Uint8Array(wasi.memory.buffer);
|
|
53
|
+
const result = new Uint8Array(u8.slice(resultPtr, resultPtr + outSize));
|
|
54
|
+
wasi.free(resultPtr);
|
|
55
|
+
return result;
|
|
56
|
+
} catch (_) {
|
|
57
|
+
_usingCtx$1.e = _;
|
|
58
|
+
} finally {
|
|
59
|
+
_usingCtx$1.d();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function readTagsFromWasmPath(wasi, path) {
|
|
63
|
+
try {
|
|
64
|
+
var _usingCtx3 = _usingCtx();
|
|
65
|
+
const arena = _usingCtx3.u(new WasmArena(wasi));
|
|
66
|
+
const pathAlloc = arena.allocString(path);
|
|
67
|
+
const outSizePtr = arena.allocUint32();
|
|
68
|
+
const resultPtr = wasi.tl_read_tags(pathAlloc.ptr, 0, 0, outSizePtr.ptr);
|
|
69
|
+
if (resultPtr === 0) throwForErrorCode(wasi.tl_get_last_error_code(), "read tags from path", `. Path: ${path}`);
|
|
70
|
+
const outSize = outSizePtr.readUint32();
|
|
71
|
+
const u8 = new Uint8Array(wasi.memory.buffer);
|
|
72
|
+
const result = new Uint8Array(u8.slice(resultPtr, resultPtr + outSize));
|
|
73
|
+
wasi.free(resultPtr);
|
|
74
|
+
return result;
|
|
75
|
+
} catch (_) {
|
|
76
|
+
_usingCtx3.e = _;
|
|
77
|
+
} finally {
|
|
78
|
+
_usingCtx3.d();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function readId3v2FramesFromWasm(wasi, source, id) {
|
|
82
|
+
try {
|
|
83
|
+
var _usingCtx4 = _usingCtx();
|
|
84
|
+
const arena = _usingCtx4.u(new WasmArena(wasi));
|
|
85
|
+
const idAlloc = id ? arena.allocString(id) : null;
|
|
86
|
+
const outSizePtr = arena.allocUint32();
|
|
87
|
+
let resultPtr;
|
|
88
|
+
if (typeof source === "string") {
|
|
89
|
+
const pathAlloc = arena.allocString(source);
|
|
90
|
+
resultPtr = wasi.tl_read_id3v2_frames(pathAlloc.ptr, 0, 0, idAlloc?.ptr ?? 0, outSizePtr.ptr);
|
|
91
|
+
} else {
|
|
92
|
+
const inputBuf = arena.allocBuffer(source);
|
|
93
|
+
resultPtr = wasi.tl_read_id3v2_frames(0, inputBuf.ptr, inputBuf.size, idAlloc?.ptr ?? 0, outSizePtr.ptr);
|
|
94
|
+
}
|
|
95
|
+
if (resultPtr === 0) {
|
|
96
|
+
const errorCode = wasi.tl_get_last_error_code();
|
|
97
|
+
if (errorCode === TL_ERROR_UNSUPPORTED_FORMAT) throw new UnsupportedFormatError("non-MP3", ["MP3"], { operation: "readId3v2Frames" });
|
|
98
|
+
throwForErrorCode(errorCode, "read ID3v2 frames", "");
|
|
99
|
+
}
|
|
100
|
+
const outSize = outSizePtr.readUint32();
|
|
101
|
+
const u8 = new Uint8Array(wasi.memory.buffer);
|
|
102
|
+
const bytes = new Uint8Array(u8.slice(resultPtr, resultPtr + outSize));
|
|
103
|
+
wasi.free(resultPtr);
|
|
104
|
+
return decodeMessagePack(bytes);
|
|
105
|
+
} catch (_) {
|
|
106
|
+
_usingCtx4.e = _;
|
|
107
|
+
} finally {
|
|
108
|
+
_usingCtx4.d();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function writeTagsToWasmPath(wasi, path, tagData) {
|
|
112
|
+
try {
|
|
113
|
+
var _usingCtx5 = _usingCtx();
|
|
114
|
+
const arena = _usingCtx5.u(new WasmArena(wasi));
|
|
115
|
+
const pathAlloc = arena.allocString(path);
|
|
116
|
+
const tagBytes = encodeTagData(tagData);
|
|
117
|
+
const tagBuf = arena.allocBuffer(tagBytes);
|
|
118
|
+
const outSizePtr = arena.allocUint32();
|
|
119
|
+
if (wasi.tl_write_tags(pathAlloc.ptr, 0, 0, tagBuf.ptr, tagBuf.size, 0, outSizePtr.ptr) !== 0) throwForErrorCode(wasi.tl_get_last_error_code(), "write tags to path", `. Path: ${path}`);
|
|
120
|
+
return true;
|
|
121
|
+
} catch (_) {
|
|
122
|
+
_usingCtx5.e = _;
|
|
123
|
+
} finally {
|
|
124
|
+
_usingCtx5.d();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function writeTagsToWasm(wasi, fileData, tagData) {
|
|
128
|
+
try {
|
|
129
|
+
var _usingCtx6 = _usingCtx();
|
|
130
|
+
const arena = _usingCtx6.u(new WasmArena(wasi));
|
|
131
|
+
const tagBytes = encodeTagData(tagData);
|
|
132
|
+
const inputBuf = arena.allocBuffer(fileData);
|
|
133
|
+
const tagBuf = arena.allocBuffer(tagBytes);
|
|
134
|
+
const outBufPtr = arena.allocUint32();
|
|
135
|
+
const outSizePtr = arena.allocUint32();
|
|
136
|
+
if (wasi.tl_write_tags(0, inputBuf.ptr, inputBuf.size, tagBuf.ptr, tagBuf.size, outBufPtr.ptr, outSizePtr.ptr) === 0) {
|
|
137
|
+
const bufferPtr = outBufPtr.readUint32();
|
|
138
|
+
const size = outSizePtr.readUint32();
|
|
139
|
+
if (bufferPtr && size > 0) {
|
|
140
|
+
const u8 = new Uint8Array(wasi.memory.buffer);
|
|
141
|
+
const output = new Uint8Array(u8.slice(bufferPtr, bufferPtr + size));
|
|
142
|
+
wasi.free(bufferPtr);
|
|
143
|
+
return output;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
} catch (_) {
|
|
148
|
+
_usingCtx6.e = _;
|
|
149
|
+
} finally {
|
|
150
|
+
_usingCtx6.d();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
export { readId3v2FramesFromWasm, readTagsFromWasm, readTagsFromWasmPath, writeTagsToWasm, writeTagsToWasmPath };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasi-fs-deno.d.ts","sourceRoot":"","sources":["../../src/runtime/wasi-fs-deno.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAGnB,MAAM,uBAAuB,CAAC;AAY/B,wBAAgB,oBAAoB,IAAI,kBAAkB,CAazD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/runtime/wasi-fs-deno.ts
|
|
2
|
+
function wrapDenoFile(file) {
|
|
3
|
+
return {
|
|
4
|
+
readSync: (target) => file.readSync(target),
|
|
5
|
+
writeSync: (data) => file.writeSync(data),
|
|
6
|
+
seekSync: (offset, whence) => file.seekSync(offset, whence),
|
|
7
|
+
truncateSync: (size) => file.truncateSync(size),
|
|
8
|
+
close: () => void file.close()
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function createDenoFsProvider() {
|
|
12
|
+
return {
|
|
13
|
+
openSync(path, options) {
|
|
14
|
+
return wrapDenoFile(Deno.openSync(path, options));
|
|
15
|
+
},
|
|
16
|
+
readFile(path) {
|
|
17
|
+
return Deno.readFile(path);
|
|
18
|
+
},
|
|
19
|
+
isNotFoundError(error) {
|
|
20
|
+
return error instanceof Deno.errors.NotFound;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { createDenoFsProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasi-fs-node.d.ts","sourceRoot":"","sources":["../../src/runtime/wasi-fs-node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAGnB,MAAM,uBAAuB,CAAC;AAwD/B,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAiBxE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { FileOperationError } from "../errors/classes.js";
|
|
2
|
+
//#region src/runtime/wasi-fs-node.ts
|
|
3
|
+
function mapOpenFlags(options) {
|
|
4
|
+
if (options.create && options.truncate) return "w+";
|
|
5
|
+
if (options.create) return "a+";
|
|
6
|
+
if (options.write) return "r+";
|
|
7
|
+
return "r";
|
|
8
|
+
}
|
|
9
|
+
function createNodeFileHandle(fs, fd) {
|
|
10
|
+
let position = 0;
|
|
11
|
+
return {
|
|
12
|
+
readSync(target) {
|
|
13
|
+
const n = fs.readSync(fd, target, 0, target.length, position);
|
|
14
|
+
if (n === 0) return null;
|
|
15
|
+
position += n;
|
|
16
|
+
return n;
|
|
17
|
+
},
|
|
18
|
+
writeSync(data) {
|
|
19
|
+
const n = fs.writeSync(fd, data, 0, data.length, position);
|
|
20
|
+
position += n;
|
|
21
|
+
return n;
|
|
22
|
+
},
|
|
23
|
+
seekSync(offset, whence) {
|
|
24
|
+
let next = position;
|
|
25
|
+
if (whence === 0) next = offset;
|
|
26
|
+
else if (whence === 1) next += offset;
|
|
27
|
+
else next = fs.fstatSync(fd).size + offset;
|
|
28
|
+
if (next < 0) throw new FileOperationError("read", `Invalid seek position: ${next}`);
|
|
29
|
+
position = next;
|
|
30
|
+
return position;
|
|
31
|
+
},
|
|
32
|
+
truncateSync(size) {
|
|
33
|
+
fs.ftruncateSync(fd, size);
|
|
34
|
+
},
|
|
35
|
+
close() {
|
|
36
|
+
fs.closeSync(fd);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async function createNodeFsProvider() {
|
|
41
|
+
const fs = await import("node:fs");
|
|
42
|
+
const fsp = await import("node:fs/promises");
|
|
43
|
+
return {
|
|
44
|
+
openSync(path, options) {
|
|
45
|
+
const flags = mapOpenFlags(options);
|
|
46
|
+
const fd = fs.openSync(path, flags);
|
|
47
|
+
return createNodeFileHandle(fs, fd);
|
|
48
|
+
},
|
|
49
|
+
async readFile(path) {
|
|
50
|
+
return new Uint8Array(await fsp.readFile(path));
|
|
51
|
+
},
|
|
52
|
+
isNotFoundError(error) {
|
|
53
|
+
return error?.code === "ENOENT";
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { createNodeFsProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasi-fs-provider.d.ts","sourceRoot":"","sources":["../../src/runtime/wasi-fs-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAAC;IAC5C,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;IACpD,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,cAAc,CAAC;IACjE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC5C,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;CAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|