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,33 @@
|
|
|
1
|
+
import { TagLibInitializationError } from "../errors/classes.js";
|
|
2
|
+
//#region src/runtime/module-loader-browser.ts
|
|
3
|
+
/**
|
|
4
|
+
* Load the TagLib Wasm module using Emscripten only.
|
|
5
|
+
*
|
|
6
|
+
* Import paths use `./` because the browser bundle is output to `dist/`
|
|
7
|
+
* alongside `taglib-wrapper.js` and `taglib-web.wasm` (copied by postbuild).
|
|
8
|
+
*/
|
|
9
|
+
async function loadTagLibModule(options) {
|
|
10
|
+
let createTagLibModule;
|
|
11
|
+
try {
|
|
12
|
+
createTagLibModule = (await import("../taglib-wrapper.js")).default;
|
|
13
|
+
} catch {
|
|
14
|
+
try {
|
|
15
|
+
createTagLibModule = (await import("../taglib-wrapper.js")).default;
|
|
16
|
+
} catch {
|
|
17
|
+
throw new TagLibInitializationError("Could not load taglib-wrapper.js. Ensure it is co-located with the browser bundle.");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const moduleConfig = {};
|
|
21
|
+
if (options?.wasmBinary) moduleConfig.wasmBinary = options.wasmBinary;
|
|
22
|
+
if (options?.wasmUrl) moduleConfig.locateFile = (path) => {
|
|
23
|
+
if (path.endsWith(".wasm")) return options.wasmUrl;
|
|
24
|
+
return path;
|
|
25
|
+
};
|
|
26
|
+
else if (!options?.wasmBinary) {
|
|
27
|
+
const wasmUrl = new URL("./taglib-web.wasm", import.meta.url);
|
|
28
|
+
moduleConfig.locateFile = (path) => path.endsWith(".wasm") ? wasmUrl.href : path;
|
|
29
|
+
}
|
|
30
|
+
return await createTagLibModule(moduleConfig);
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { loadTagLibModule };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-loader.d.ts","sourceRoot":"","sources":["../../src/runtime/module-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAS/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAiFvB"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { EnvironmentError, TagLibInitializationError, errorMessage } from "../errors/classes.js";
|
|
2
|
+
import { checkNodeVersion } from "./detector.js";
|
|
3
|
+
import { isDenoCompiled } from "./deno-detect.js";
|
|
4
|
+
import { describeNonWasmBinary } from "./loader-types.js";
|
|
5
|
+
//#region src/runtime/module-loader.ts
|
|
6
|
+
/**
|
|
7
|
+
* Load the TagLib Wasm module.
|
|
8
|
+
* This function initializes the WebAssembly module and returns
|
|
9
|
+
* the loaded module for use with the Full API.
|
|
10
|
+
*
|
|
11
|
+
* Automatically selects the optimal implementation:
|
|
12
|
+
* - WASI for Deno/Node.js (faster filesystem access, MessagePack serialization)
|
|
13
|
+
* - Emscripten for browsers (universal compatibility)
|
|
14
|
+
*
|
|
15
|
+
* @param options - Optional configuration for module initialization
|
|
16
|
+
* @returns Promise resolving to the initialized TagLib module
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import { loadTagLibModule, TagLib } from "taglib-wasm";
|
|
21
|
+
*
|
|
22
|
+
* // Auto-select optimal implementation
|
|
23
|
+
* const module = await loadTagLibModule();
|
|
24
|
+
* const taglib = new TagLib(module);
|
|
25
|
+
*
|
|
26
|
+
* // Force Emscripten mode (in-memory I/O)
|
|
27
|
+
* const module = await loadTagLibModule({ forceWasmType: "emscripten" });
|
|
28
|
+
*
|
|
29
|
+
* // Force WASI mode (Deno/Node.js only)
|
|
30
|
+
* const module = await loadTagLibModule({ forceWasmType: "wasi" });
|
|
31
|
+
*
|
|
32
|
+
* // With custom WASM binary (selects the Emscripten backend; the bytes
|
|
33
|
+
* // must be its artifact, taglib-web.wasm)
|
|
34
|
+
* const wasmData = await fetch("taglib-web.wasm").then(r => r.arrayBuffer());
|
|
35
|
+
* const module = await loadTagLibModule({ wasmBinary: wasmData });
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @note Most users should use `TagLib.initialize()` instead,
|
|
39
|
+
* which handles module loading automatically.
|
|
40
|
+
*/
|
|
41
|
+
async function loadTagLibModule(options) {
|
|
42
|
+
const nodeVersion = globalThis.process?.versions?.node;
|
|
43
|
+
const versionError = checkNodeVersion(nodeVersion);
|
|
44
|
+
if (versionError) throw new EnvironmentError("Node.js", versionError, "WASI support");
|
|
45
|
+
if (options?.forceWasmType === "wasi" && options?.wasmBinary) throw new TagLibInitializationError("wasmBinary is not supported by the WASI backend: it loads from a filesystem path or URL. Use wasmUrl, or omit forceWasmType to use the Emscripten backend", { forceWasmType: "wasi" });
|
|
46
|
+
if (options?.wasmBinary) {
|
|
47
|
+
const problem = describeNonWasmBinary(options.wasmBinary);
|
|
48
|
+
if (problem) throw new TagLibInitializationError(problem, { byteLength: options.wasmBinary.byteLength });
|
|
49
|
+
}
|
|
50
|
+
if (!options?.wasmBinary && !options?.wasmUrl && !options?.forceWasmType && isDenoCompiled()) {
|
|
51
|
+
const wasmBinary = await tryLoadEmbeddedWasm();
|
|
52
|
+
if (!wasmBinary) console.warn("[TagLib] Deno compile detected but embedded Wasm not found. Include taglib-web.wasm with: deno compile --include taglib-web.wasm");
|
|
53
|
+
return loadBufferModeTagLibModule({
|
|
54
|
+
...options,
|
|
55
|
+
forceWasmType: "emscripten",
|
|
56
|
+
...wasmBinary ? { wasmBinary } : {}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (options?.forceWasmType === "emscripten") return loadBufferModeTagLibModule(options);
|
|
60
|
+
try {
|
|
61
|
+
const { loadUnifiedTagLibModule } = await import("./unified-loader/index.js");
|
|
62
|
+
return await loadUnifiedTagLibModule({
|
|
63
|
+
...options?.wasmBinary !== void 0 ? { wasmBinary: options.wasmBinary } : {},
|
|
64
|
+
...options?.wasmUrl !== void 0 ? { wasmUrl: options.wasmUrl } : {},
|
|
65
|
+
...options?.forceWasmType !== void 0 ? { forceWasmType: options.forceWasmType } : {},
|
|
66
|
+
debug: false
|
|
67
|
+
});
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (options?.forceWasmType === "wasi") throw new TagLibInitializationError(`WASI backend failed to load: ${errorMessage(error)}. forceWasmType is "wasi", so the Emscripten fallback was not attempted`, {
|
|
70
|
+
cause: error,
|
|
71
|
+
forceWasmType: "wasi"
|
|
72
|
+
});
|
|
73
|
+
console.warn(`[TagLib] Unified loader failed, falling back to buffer mode: ${errorMessage(error)}`);
|
|
74
|
+
return loadBufferModeTagLibModule(options || {});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Emscripten-only module loader for buffer mode (in-memory I/O).
|
|
79
|
+
* Used for fallback compatibility and when forceWasmType is "emscripten".
|
|
80
|
+
*
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
async function loadBufferModeTagLibModule(options) {
|
|
84
|
+
let createTagLibModule;
|
|
85
|
+
try {
|
|
86
|
+
createTagLibModule = (await import("../taglib-wrapper.js")).default;
|
|
87
|
+
} catch {
|
|
88
|
+
try {
|
|
89
|
+
createTagLibModule = (await import("../taglib-wrapper.js")).default;
|
|
90
|
+
} catch {
|
|
91
|
+
throw new TagLibInitializationError("Could not load taglib-wrapper.js from either ./build or ./dist");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const moduleConfig = {};
|
|
95
|
+
if (options?.wasmBinary) moduleConfig.wasmBinary = options.wasmBinary;
|
|
96
|
+
if (options?.wasmUrl) moduleConfig.locateFile = (path) => {
|
|
97
|
+
if (path.endsWith(".wasm")) return options.wasmUrl;
|
|
98
|
+
return path;
|
|
99
|
+
};
|
|
100
|
+
else if (!options?.wasmBinary) {
|
|
101
|
+
const wasmUrl = new URL("../taglib-web.wasm", import.meta.url);
|
|
102
|
+
moduleConfig.locateFile = (path) => path.endsWith(".wasm") ? wasmUrl.href : path;
|
|
103
|
+
}
|
|
104
|
+
return await createTagLibModule(moduleConfig);
|
|
105
|
+
}
|
|
106
|
+
/** @internal Try to load embedded Wasm from the default path. */
|
|
107
|
+
async function tryLoadEmbeddedWasm() {
|
|
108
|
+
const strategies = [
|
|
109
|
+
() => Deno.readFile(new URL("./taglib-web.wasm", Deno.mainModule)),
|
|
110
|
+
() => Deno.readFile(new URL("./taglib-web.wasm", import.meta.url)),
|
|
111
|
+
() => Deno.readFile("taglib-web.wasm")
|
|
112
|
+
];
|
|
113
|
+
for (const strategy of strategies) try {
|
|
114
|
+
return await strategy();
|
|
115
|
+
} catch {}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
export { loadTagLibModule };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-io.d.ts","sourceRoot":"","sources":["../../src/runtime/platform-io.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEvE,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC5C,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9C,OAAO,CACL,IAAI,EAAE,MAAM,GACX,cAAc,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC3E,WAAW,CAAC,EAAE,CACZ,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,UAAU,CAAC,CAAC;CAC1B,CAAC;AA2NF;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,kBAAkB,GAAG,UAAU,CAgBvE;AAED,wBAAgB,aAAa,IAAI,UAAU,CAM1C;AAED,gBAAgB;AAChB,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,UAAU,GAAG,IAAI,CAE7D;AAED,gBAAgB;AAChB,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { EnvironmentError } from "../errors/classes.js";
|
|
2
|
+
import { detectRuntime } from "./detector.js";
|
|
3
|
+
//#region src/runtime/platform-io.ts
|
|
4
|
+
let platformIO;
|
|
5
|
+
async function readFullFile(readFile, path, headerSize, footerSize, fileSize) {
|
|
6
|
+
const actualHeader = Math.min(headerSize, fileSize);
|
|
7
|
+
if (Math.max(0, fileSize - Math.min(footerSize, fileSize)) > actualHeader) return void 0;
|
|
8
|
+
return (await readFile(path)).slice(0, fileSize);
|
|
9
|
+
}
|
|
10
|
+
function createDenoIO() {
|
|
11
|
+
const D = globalThis.Deno;
|
|
12
|
+
return {
|
|
13
|
+
readFile: (path) => D.readFile(path),
|
|
14
|
+
writeFile: (path, data) => D.writeFile(path, data),
|
|
15
|
+
stat: async (path) => {
|
|
16
|
+
return { size: (await D.stat(path)).size };
|
|
17
|
+
},
|
|
18
|
+
async *readDir(path) {
|
|
19
|
+
for await (const entry of D.readDir(path)) yield {
|
|
20
|
+
name: entry.name,
|
|
21
|
+
isDirectory: entry.isDirectory,
|
|
22
|
+
isFile: entry.isFile
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
readPartial: async (path, headerSize, footerSize) => {
|
|
26
|
+
const file = await D.open(path, { read: true });
|
|
27
|
+
try {
|
|
28
|
+
const fileSize = (await file.stat()).size;
|
|
29
|
+
const full = await readFullFile((p) => D.readFile(p), path, headerSize, footerSize, fileSize);
|
|
30
|
+
if (full) return full;
|
|
31
|
+
const actualHeader = Math.min(headerSize, fileSize);
|
|
32
|
+
const header = new Uint8Array(actualHeader);
|
|
33
|
+
await file.read(header);
|
|
34
|
+
const actualFooter = Math.min(footerSize, fileSize);
|
|
35
|
+
const footerStart = fileSize - actualFooter;
|
|
36
|
+
await file.seek(footerStart, D.SeekMode.Start);
|
|
37
|
+
const footer = new Uint8Array(actualFooter);
|
|
38
|
+
await file.read(footer);
|
|
39
|
+
const combined = new Uint8Array(actualHeader + actualFooter);
|
|
40
|
+
combined.set(header, 0);
|
|
41
|
+
combined.set(footer, actualHeader);
|
|
42
|
+
return combined;
|
|
43
|
+
} finally {
|
|
44
|
+
file.close();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function createNodeIO() {
|
|
50
|
+
let fsCache;
|
|
51
|
+
let bufCache;
|
|
52
|
+
async function getFs() {
|
|
53
|
+
return fsCache ?? (fsCache = await import("node:fs/promises"));
|
|
54
|
+
}
|
|
55
|
+
async function getBuf() {
|
|
56
|
+
return bufCache ?? (bufCache = await import("node:buffer"));
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
readFile: async (path) => {
|
|
60
|
+
const fs = await getFs();
|
|
61
|
+
return new Uint8Array(await fs.readFile(path));
|
|
62
|
+
},
|
|
63
|
+
writeFile: async (path, data) => {
|
|
64
|
+
await (await getFs()).writeFile(path, data);
|
|
65
|
+
},
|
|
66
|
+
stat: async (path) => {
|
|
67
|
+
return { size: (await (await getFs()).stat(path)).size };
|
|
68
|
+
},
|
|
69
|
+
async *readDir(path) {
|
|
70
|
+
const entries = await (await getFs()).readdir(path, { withFileTypes: true });
|
|
71
|
+
for (const entry of entries) yield {
|
|
72
|
+
name: entry.name,
|
|
73
|
+
isDirectory: entry.isDirectory(),
|
|
74
|
+
isFile: entry.isFile()
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
readPartial: async (path, headerSize, footerSize) => {
|
|
78
|
+
const fs = await getFs();
|
|
79
|
+
const { Buffer } = await getBuf();
|
|
80
|
+
const file = await fs.open(path, "r");
|
|
81
|
+
try {
|
|
82
|
+
const fileSize = (await file.stat()).size;
|
|
83
|
+
const full = await readFullFile(async (p) => new Uint8Array(await fs.readFile(p)), path, headerSize, footerSize, fileSize);
|
|
84
|
+
if (full) return full;
|
|
85
|
+
const actualHeader = Math.min(headerSize, fileSize);
|
|
86
|
+
const header = Buffer.alloc(actualHeader);
|
|
87
|
+
await file.read(header, 0, actualHeader, 0);
|
|
88
|
+
const actualFooter = Math.min(footerSize, fileSize);
|
|
89
|
+
const footerStart = fileSize - actualFooter;
|
|
90
|
+
const footer = Buffer.alloc(actualFooter);
|
|
91
|
+
await file.read(footer, 0, actualFooter, footerStart);
|
|
92
|
+
const combined = new Uint8Array(actualHeader + actualFooter);
|
|
93
|
+
combined.set(new Uint8Array(header.buffer, header.byteOffset, header.byteLength), 0);
|
|
94
|
+
combined.set(new Uint8Array(footer.buffer, footer.byteOffset, footer.byteLength), actualHeader);
|
|
95
|
+
return combined;
|
|
96
|
+
} finally {
|
|
97
|
+
await file.close();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function createBunIO() {
|
|
103
|
+
const B = globalThis.Bun;
|
|
104
|
+
return {
|
|
105
|
+
readFile: async (path) => {
|
|
106
|
+
return new Uint8Array(await B.file(path).arrayBuffer());
|
|
107
|
+
},
|
|
108
|
+
writeFile: async (path, data) => {
|
|
109
|
+
await B.write(path, data);
|
|
110
|
+
},
|
|
111
|
+
stat: async (path) => {
|
|
112
|
+
return { size: B.file(path).size };
|
|
113
|
+
},
|
|
114
|
+
async *readDir(path) {
|
|
115
|
+
const entries = await (await import("node:fs/promises")).readdir(path, { withFileTypes: true });
|
|
116
|
+
for (const entry of entries) yield {
|
|
117
|
+
name: entry.name,
|
|
118
|
+
isDirectory: entry.isDirectory(),
|
|
119
|
+
isFile: entry.isFile()
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
readPartial: async (path, headerSize, footerSize) => {
|
|
123
|
+
const file = B.file(path);
|
|
124
|
+
const fileSize = file.size;
|
|
125
|
+
const full = await readFullFile(async (p) => new Uint8Array(await B.file(p).arrayBuffer()), path, headerSize, footerSize, fileSize);
|
|
126
|
+
if (full) return full;
|
|
127
|
+
const actualHeader = Math.min(headerSize, fileSize);
|
|
128
|
+
const header = new Uint8Array(await file.slice(0, actualHeader).arrayBuffer());
|
|
129
|
+
const actualFooter = Math.min(footerSize, fileSize);
|
|
130
|
+
const footerStart = fileSize - actualFooter;
|
|
131
|
+
const footer = new Uint8Array(await file.slice(footerStart, fileSize).arrayBuffer());
|
|
132
|
+
const combined = new Uint8Array(actualHeader + actualFooter);
|
|
133
|
+
combined.set(header, 0);
|
|
134
|
+
combined.set(footer, actualHeader);
|
|
135
|
+
return combined;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Pure environment -> PlatformIO selection (taglib-2b4): each environment's
|
|
141
|
+
* factory is chosen without sniffing, so the routing is testable with a
|
|
142
|
+
* synthetic environment. Factories are lazy — nothing touches the runtime
|
|
143
|
+
* until a method is called, so calling this under any runtime is safe.
|
|
144
|
+
*/
|
|
145
|
+
function createPlatformIOFor(env) {
|
|
146
|
+
switch (env) {
|
|
147
|
+
case "deno-wasi": return createDenoIO();
|
|
148
|
+
case "bun-wasi": return createBunIO();
|
|
149
|
+
case "node-wasi":
|
|
150
|
+
case "node-emscripten": return createNodeIO();
|
|
151
|
+
default: throw new EnvironmentError(env, "does not support filesystem operations", "filesystem access");
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function getPlatformIO() {
|
|
155
|
+
if (platformIO) return platformIO;
|
|
156
|
+
platformIO = createPlatformIOFor(detectRuntime().environment);
|
|
157
|
+
return platformIO;
|
|
158
|
+
}
|
|
159
|
+
/** @internal */
|
|
160
|
+
function _setPlatformIOForTesting(io) {
|
|
161
|
+
platformIO = io;
|
|
162
|
+
}
|
|
163
|
+
/** @internal */
|
|
164
|
+
function _resetPlatformIO() {
|
|
165
|
+
platformIO = void 0;
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
export { _resetPlatformIO, _setPlatformIOForTesting, createPlatformIOFor, getPlatformIO };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/unified-loader/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACjE,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { ModuleLoadError, UnifiedLoaderError } from "./types.js";
|
|
2
2
|
import { getRecommendedConfig, isWasiAvailable } from "./module-selection.js";
|
|
3
3
|
import { loadUnifiedTagLibModule } from "./loader.js";
|
|
4
|
-
export {
|
|
5
|
-
ModuleLoadError,
|
|
6
|
-
UnifiedLoaderError,
|
|
7
|
-
getRecommendedConfig,
|
|
8
|
-
isWasiAvailable,
|
|
9
|
-
loadUnifiedTagLibModule
|
|
10
|
-
};
|
|
4
|
+
export { ModuleLoadError, UnifiedLoaderError, getRecommendedConfig, isWasiAvailable, loadUnifiedTagLibModule };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/runtime/unified-loader/loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAM5E,wBAAsB,uBAAuB,CAC3C,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CAiD9B"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { detectRuntime } from "../detector.js";
|
|
2
|
+
import { describeNonWasmBinary } from "../loader-types.js";
|
|
3
|
+
import { ModuleLoadError } from "./types.js";
|
|
4
|
+
import { selectWasmType } from "./module-selection.js";
|
|
5
|
+
import { loadModule } from "./module-loading.js";
|
|
6
|
+
//#region src/runtime/unified-loader/loader.ts
|
|
7
|
+
async function loadUnifiedTagLibModule(options = {}) {
|
|
8
|
+
if (options.forceWasmType === "wasi" && options.wasmBinary) throw new ModuleLoadError("wasmBinary is not supported by the WASI backend: it loads from a filesystem path or URL. Use wasmUrl, or omit forceWasmType to select the Emscripten backend", "wasi");
|
|
9
|
+
if (options.wasmBinary) {
|
|
10
|
+
const problem = describeNonWasmBinary(options.wasmBinary);
|
|
11
|
+
if (problem) throw new ModuleLoadError(problem, "emscripten");
|
|
12
|
+
}
|
|
13
|
+
const startTime = performance.now();
|
|
14
|
+
const runtime = detectRuntime();
|
|
15
|
+
if (options.debug) console.log(`[UnifiedLoader] Detected runtime: ${runtime.environment}`);
|
|
16
|
+
const wasmType = selectWasmType(runtime, options);
|
|
17
|
+
if (options.debug) console.log(`[UnifiedLoader] Selected ${wasmType} for ${runtime.environment}`);
|
|
18
|
+
const { module, actualWasmType } = await loadModule(wasmType, runtime, options);
|
|
19
|
+
const unifiedModule = await createUnifiedModule(module, runtime, actualWasmType, startTime);
|
|
20
|
+
if (options.debug) {
|
|
21
|
+
const initTime = performance.now() - startTime;
|
|
22
|
+
console.log(`[UnifiedLoader] Initialized in ${initTime.toFixed(2)}ms`);
|
|
23
|
+
}
|
|
24
|
+
return unifiedModule;
|
|
25
|
+
}
|
|
26
|
+
async function createUnifiedModule(module, runtime, wasmType, startTime) {
|
|
27
|
+
const isWasi = wasmType === "wasi";
|
|
28
|
+
const initTime = performance.now() - startTime;
|
|
29
|
+
if (isWasi) {
|
|
30
|
+
const wasiModule = module;
|
|
31
|
+
const adapter = await createWasiAdapter(wasiModule);
|
|
32
|
+
return Object.assign(adapter, {
|
|
33
|
+
runtime,
|
|
34
|
+
isWasi: true,
|
|
35
|
+
isEmscripten: false,
|
|
36
|
+
getPerformanceMetrics: () => ({
|
|
37
|
+
initTime,
|
|
38
|
+
wasmType: "wasi",
|
|
39
|
+
environment: runtime.environment,
|
|
40
|
+
memoryUsage: wasiModule.memory.buffer.byteLength
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
} else {
|
|
44
|
+
const emscriptenModule = module;
|
|
45
|
+
return {
|
|
46
|
+
...emscriptenModule,
|
|
47
|
+
runtime,
|
|
48
|
+
isWasi: false,
|
|
49
|
+
isEmscripten: true,
|
|
50
|
+
getPerformanceMetrics: () => ({
|
|
51
|
+
initTime,
|
|
52
|
+
wasmType: "emscripten",
|
|
53
|
+
environment: runtime.environment,
|
|
54
|
+
memoryUsage: emscriptenModule.HEAP8?.buffer.byteLength
|
|
55
|
+
})
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function createWasiAdapter(wasiModule) {
|
|
60
|
+
const { WasiToTagLibAdapter } = await import("../wasi-adapter/index.js");
|
|
61
|
+
return new WasiToTagLibAdapter(wasiModule);
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { loadUnifiedTagLibModule };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-loading.d.ts","sourceRoot":"","sources":["../../../src/runtime/unified-loader/module-loading.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAG7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAmBzE,6EAA6E;AAC7E,wBAAgB,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA0BpD;AAOD,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,GAAG,YAAY,EAC/B,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CAS3B"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { errorMessage } from "../../errors/classes.js";
|
|
2
|
+
import { isDeno, supportsExnref } from "../detector.js";
|
|
3
|
+
import { getNodeFsSync } from "../../utils/node-fs.js";
|
|
4
|
+
import { fileUrlToPath } from "../../utils/path.js";
|
|
5
|
+
import { ModuleLoadError } from "./types.js";
|
|
6
|
+
//#region src/runtime/unified-loader/module-loading.ts
|
|
7
|
+
function isWindows() {
|
|
8
|
+
return isDeno() ? Deno.build.os === "windows" : globalThis.process ? globalThis.process.platform === "win32" : false;
|
|
9
|
+
}
|
|
10
|
+
/** @internal Exported for unit tests (tests/node-fs-acquisition.test.ts). */
|
|
11
|
+
function getPreopens() {
|
|
12
|
+
if (!isWindows()) return { "/": "/" };
|
|
13
|
+
const statSync = isDeno() ? (p) => Deno.statSync(p) : getNodeFsSync()?.statSync;
|
|
14
|
+
if (!statSync) {
|
|
15
|
+
console.warn("[taglib-wasm] Windows drive detection unavailable: node:fs could not be loaded. Only C:\\ is registered as a WASI preopen.");
|
|
16
|
+
return { "/C": "C:\\" };
|
|
17
|
+
}
|
|
18
|
+
const preopens = {};
|
|
19
|
+
for (const letter of "CDEFGHIJKLMNOPQRSTUVWXYZAB") {
|
|
20
|
+
const root = `${letter}:\\`;
|
|
21
|
+
try {
|
|
22
|
+
statSync(root);
|
|
23
|
+
preopens[`/${letter}`] = root;
|
|
24
|
+
} catch {}
|
|
25
|
+
}
|
|
26
|
+
return Object.keys(preopens).length > 0 ? preopens : { "/C": "C:\\" };
|
|
27
|
+
}
|
|
28
|
+
function resolveWasmPath(relativePath) {
|
|
29
|
+
const url = new URL(relativePath, import.meta.url);
|
|
30
|
+
return url.protocol === "file:" ? fileUrlToPath(url) : url.href;
|
|
31
|
+
}
|
|
32
|
+
async function loadModule(wasmType, runtime, options) {
|
|
33
|
+
if (wasmType === "wasi") return await loadWasiModuleWithFallback(runtime, options);
|
|
34
|
+
else return {
|
|
35
|
+
module: await loadEmscriptenModule(options),
|
|
36
|
+
actualWasmType: "emscripten"
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async function loadWasiModuleWithFallback(runtime, options) {
|
|
40
|
+
const defaultWasmPath = resolveWasmPath("../../taglib-wasi.wasm");
|
|
41
|
+
try {
|
|
42
|
+
const { loadWasiHost } = await import("../wasi-host-loader.js");
|
|
43
|
+
return {
|
|
44
|
+
module: await loadWasiHost({
|
|
45
|
+
wasmPath: options.wasmUrl || defaultWasmPath,
|
|
46
|
+
preopens: getPreopens()
|
|
47
|
+
}),
|
|
48
|
+
actualWasmType: "wasi"
|
|
49
|
+
};
|
|
50
|
+
} catch (hostError) {
|
|
51
|
+
if (options.forceWasmType === "wasi") throw new ModuleLoadError(`WASI backend failed to load: ${errorMessage(hostError)}. forceWasmType is "wasi", so the Emscripten fallback was not attempted`, "wasi", hostError);
|
|
52
|
+
if (runtime.environment === "node-wasi" && !supportsExnref()) {
|
|
53
|
+
const nodeVersion = globalThis.process?.versions?.node ?? "";
|
|
54
|
+
console.warn(`[taglib-wasm] WASI unavailable: Node.js ${nodeVersion} requires --experimental-wasm-exnref. Falling back to Emscripten. Run with: node --experimental-wasm-exnref your-script.js`);
|
|
55
|
+
} else if (options.debug) console.warn(`[UnifiedLoader] WASI host failed:`, hostError);
|
|
56
|
+
}
|
|
57
|
+
if (options.debug) console.warn(`[UnifiedLoader] WASI loader failed, using Emscripten`);
|
|
58
|
+
return {
|
|
59
|
+
module: await loadEmscriptenModule(options),
|
|
60
|
+
actualWasmType: "emscripten"
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async function loadEmscriptenModule(options) {
|
|
64
|
+
try {
|
|
65
|
+
let createModule;
|
|
66
|
+
try {
|
|
67
|
+
createModule = (await import("../../taglib-wrapper.js")).default;
|
|
68
|
+
} catch {
|
|
69
|
+
try {
|
|
70
|
+
createModule = (await import("../../taglib-wrapper.js")).default;
|
|
71
|
+
} catch {
|
|
72
|
+
throw new ModuleLoadError("Could not load Emscripten module from build or dist", "emscripten");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const moduleConfig = {};
|
|
76
|
+
if (options.wasmBinary) moduleConfig.wasmBinary = options.wasmBinary;
|
|
77
|
+
if (options.wasmUrl) moduleConfig.locateFile = (path) => {
|
|
78
|
+
return path.endsWith(".wasm") ? options.wasmUrl : path;
|
|
79
|
+
};
|
|
80
|
+
else if (!options.wasmBinary) {
|
|
81
|
+
const wasmUrl = new URL("../../taglib-web.wasm", import.meta.url);
|
|
82
|
+
moduleConfig.locateFile = (path) => path.endsWith(".wasm") ? wasmUrl.href : path;
|
|
83
|
+
}
|
|
84
|
+
return await createModule(moduleConfig);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
throw new ModuleLoadError(`Failed to load Emscripten module: ${errorMessage(error)}`, "emscripten", error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { getPreopens, loadModule };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-selection.d.ts","sourceRoot":"","sources":["../../../src/runtime/unified-loader/module-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,wBAAgB,cAAc,CAC5B,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,oBAAoB,GAC5B,MAAM,GAAG,YAAY,CAqBvB;AAED,wBAAgB,eAAe,CAC7B,OAAO,GAAE,sBAAwC,GAChD,OAAO,CAET;AAED,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,sBAAwC,GAChD,oBAAoB,CAqBtB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { detectRuntime } from "../detector.js";
|
|
2
|
+
//#region src/runtime/unified-loader/module-selection.ts
|
|
3
|
+
function selectWasmType(runtime, options) {
|
|
4
|
+
if (options.forceWasmType) return options.forceWasmType;
|
|
5
|
+
if (options.wasmBinary) return "emscripten";
|
|
6
|
+
if (options.disableOptimizations) return "emscripten";
|
|
7
|
+
if (runtime.wasmType === "wasi" && runtime.supportsFilesystem) return "wasi";
|
|
8
|
+
return "emscripten";
|
|
9
|
+
}
|
|
10
|
+
function isWasiAvailable(runtime = detectRuntime()) {
|
|
11
|
+
return runtime.wasmType === "wasi" && runtime.supportsFilesystem;
|
|
12
|
+
}
|
|
13
|
+
function getRecommendedConfig(runtime = detectRuntime()) {
|
|
14
|
+
if (runtime.environment === "browser") return {
|
|
15
|
+
forceWasmType: "emscripten",
|
|
16
|
+
disableOptimizations: false
|
|
17
|
+
};
|
|
18
|
+
if (runtime.wasmType === "wasi" && runtime.supportsFilesystem) return {
|
|
19
|
+
forceWasmType: "wasi",
|
|
20
|
+
disableOptimizations: false
|
|
21
|
+
};
|
|
22
|
+
return { disableOptimizations: false };
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { getRecommendedConfig, isWasiAvailable, selectWasmType };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/runtime/unified-loader/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qBAAa,kBAAmB,SAAQ,WAAW;gBACrC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAM7C;AAED,qBAAa,eAAgB,SAAQ,WAAW;aAG5B,QAAQ,EAAE,MAAM,GAAG,YAAY;gBAD/C,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,MAAM,GAAG,YAAY,EAC/C,KAAK,CAAC,EAAE,OAAO;CAOlB;AAED,MAAM,WAAW,oBAAoB;IACnC,+BAA+B;IAC/B,aAAa,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IACtC,0CAA0C;IAC1C,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;OAGG;IACH,UAAU,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IACtC,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACvD,+BAA+B;IAC/B,OAAO,EAAE,sBAAsB,CAAC;IAChC,wCAAwC;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,8CAA8C;IAC9C,YAAY,EAAE,OAAO,CAAC;IACtB,8BAA8B;IAC9B,qBAAqB,CAAC,EAAE,MAAM,kBAAkB,CAAC;CAClD;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,YAAY,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,YAAY,GAAG,UAAU,CAAC;IAClC,cAAc,EAAE,MAAM,GAAG,YAAY,CAAC;CACvC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TagLibError } from "../../errors/base.js";
|
|
2
|
+
//#region src/runtime/unified-loader/types.ts
|
|
3
|
+
var UnifiedLoaderError = class UnifiedLoaderError extends TagLibError {
|
|
4
|
+
constructor(message, cause) {
|
|
5
|
+
super("MODULE_LOAD", message, cause ? { cause } : void 0);
|
|
6
|
+
this.name = "UnifiedLoaderError";
|
|
7
|
+
if (cause) this.cause = cause;
|
|
8
|
+
Object.setPrototypeOf(this, UnifiedLoaderError.prototype);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var ModuleLoadError = class ModuleLoadError extends TagLibError {
|
|
12
|
+
constructor(message, wasmType, cause) {
|
|
13
|
+
super("MODULE_LOAD", message, cause ? {
|
|
14
|
+
cause,
|
|
15
|
+
wasmType
|
|
16
|
+
} : { wasmType });
|
|
17
|
+
this.wasmType = wasmType;
|
|
18
|
+
this.name = "ModuleLoadError";
|
|
19
|
+
if (cause) this.cause = cause;
|
|
20
|
+
Object.setPrototypeOf(this, ModuleLoadError.prototype);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ModuleLoadError, UnifiedLoaderError };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/runtime/wasi-adapter/adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAMhE,qBAAa,mBAAoB,YAAW,YAAY;IACtD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,UAAU,EAAE,UAAU;IAKlC,UAAU,EAMM,UAAU,UAAU,CAAC;IAErC,IAAI,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAEzB;IAED,IAAI,KAAK,IAAI,SAAS,CAErB;IAED,IAAI,MAAM,IAAI,UAAU,CAEvB;IAED,IAAI,MAAM,IAAI,UAAU,CAEvB;IAED,IAAI,MAAM,IAAI,UAAU,CAEvB;IAED,IAAI,OAAO,IAAI,WAAW,CAEzB;IAED,IAAI,OAAO,IAAI,WAAW,CAEzB;IAED,IAAI,OAAO,IAAI,YAAY,CAE1B;IAED,IAAI,OAAO,IAAI,YAAY,CAE1B;IAED,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI7B,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIxB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;IAa9C,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAOjC,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAQhE,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAIpC,gBAAgB,IAAI,UAAU;IAI9B;;;;;OAKG;IACH,IAAI,UAAU,IAAI,UAAU,CAE3B;IAED;;;OAGG;IACH,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,cAAc,CAAC;IAI1B,OAAO,IAAI,MAAM;IAIjB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM;IAI/B,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIlC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,GAAG;IAM1E,KAAK,CACH,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,SAAS,EAAE,MAAM,EAAE,EACnB,KAAK,EAAE,GAAG,EAAE,GACX,GAAG;CAKP"}
|