@openclaw/whatsapp 2026.9.5 → 2026.9.7
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/assets/icon.png +0 -0
- package/dist/.setup/{accounts-D_NGDjCx.mjs → accounts-CtRPAQCL.mjs} +3 -9
- package/dist/.setup/{action-runtime-DZZFamfl.mjs → action-runtime-DeVk5V7r.mjs} +2 -2
- package/dist/.setup/{agent-tools-login-B6MAs75N.mjs → agent-tools-login-CL5C1rA2.mjs} +5 -1
- package/dist/.setup/{approval-handler.runtime-C0hzmMSj.mjs → approval-handler.runtime-CjqMlPOX.mjs} +6 -26
- package/dist/.setup/{approval-reactions-BnXw-UZI.mjs → approval-reactions-DiOFvb1s.mjs} +8 -14
- package/dist/.setup/{auth-store-Dh8a3cba.mjs → auth-store-BBonwKks.mjs} +9 -33
- package/dist/.setup/{channel-CSclZYjU.mjs → channel-CJFE0kD_.mjs} +82 -154
- package/dist/.setup/{channel-react-action-1iBiEnq7.mjs → channel-react-action-2r_hjLZV.mjs} +4 -8
- package/dist/.setup/{channel.runtime-ddGY37w8.mjs → channel.runtime-C94goLw9.mjs} +4 -4
- package/dist/.setup/{channel.setup-CqUl8COe.mjs → channel.setup-CfN1UfdY.mjs} +1 -1
- package/dist/.setup/{connection-controller-C60mU7j7.mjs → connection-controller-CHo1oRJA.mjs} +13 -63
- package/dist/.setup/{creds-files-Drg3usj1.mjs → creds-files-CDATZWWM.mjs} +5 -11
- package/dist/.setup/{directory-config-BHPoBklt.mjs → directory-config-DUiJ5d8I.mjs} +13 -14
- package/dist/.setup/doctor-iMwg0Vhr.mjs +222 -0
- package/dist/.setup/group-config-path-DZr3ucUO.mjs +40 -0
- package/dist/.setup/{group-session-key-D22hYMdE.mjs → group-session-key-2-mja4OF.mjs} +3 -9
- package/dist/.setup/{login-2dmd1TfE.mjs → login-BFlvSh9h.mjs} +9 -11
- package/dist/.setup/{login-qr-CgKtO_ef.mjs → login-qr-Ayb8i25J.mjs} +29 -77
- package/dist/.setup/{monitor-BblvzLpX.mjs → monitor-CGpV2VNN.mjs} +391 -509
- package/dist/.setup/{question-reactions-D3Zq9Gbn.mjs → question-reactions-CPyyi5AY.mjs} +2 -2
- package/dist/.setup/rolldown-runtime-BBjsoOtd.mjs +27 -0
- package/dist/.setup/{send-C6jDmcL9.mjs → send-BGdvf5cC.mjs} +31 -80
- package/dist/.setup/{send-api-B4DOt2RJ.mjs → send-api-H4AkQJjT.mjs} +45 -109
- package/dist/.setup/{session-errors-JuazczrA.mjs → session-errors-B8UcAnZN.mjs} +1 -4
- package/dist/.setup/{session.runtime-DcJuO42v.mjs → session.runtime-st1konFI.mjs} +1 -1
- package/dist/.setup/{setup-finalize-BYEgU0hb.mjs → setup-finalize-DmPX4EaW.mjs} +32 -70
- package/dist/.setup/setup-plugin-api-vJlxKzca.mjs +3 -0
- package/dist/.setup/{setup-surface-Cd3wN5HD.mjs → setup-surface-43fj197P.mjs} +3 -3
- package/dist/.setup/{shared-C9OEtKgc.mjs → shared-DgOG5Iqr.mjs} +26 -37
- package/dist/.setup/{socket-close-CCVSFufF.mjs → socket-close-CT__V2fz.mjs} +80 -92
- package/dist/.setup/{targets-runtime-RBjx3pg_.mjs → targets-runtime-DmiqXIXO.mjs} +2 -7
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/agent-tools-api.js +6 -13
- package/dist/api.js +10 -10
- package/dist/auth-presence.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/contract-api.js +2 -2
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +9 -10
- package/dist/light-runtime-api.js +3 -3
- package/dist/login-qr-runtime.js +1 -1
- package/dist/runtime-api.js +10 -10
- package/dist/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/node_modules/audio-decode/LICENSE +9 -10
- package/node_modules/audio-decode/README.md +16 -0
- package/node_modules/audio-decode/audio-decode.d.ts +2 -14
- package/node_modules/audio-decode/audio-decode.js +4 -92
- package/node_modules/audio-decode/meta.js +1 -0
- package/node_modules/audio-decode/node_modules/{audio-buffer → @audio/decode}/LICENSE +1 -1
- package/node_modules/audio-decode/node_modules/@audio/decode/audio-decode.d.ts +52 -0
- package/node_modules/audio-decode/node_modules/@audio/decode/audio-decode.js +242 -0
- package/node_modules/audio-decode/node_modules/@audio/decode/meta.js +14 -0
- package/node_modules/audio-decode/node_modules/@audio/decode/package.json +114 -0
- package/node_modules/audio-decode/node_modules/@audio/decode/readme.md +191 -0
- package/node_modules/audio-decode/node_modules/@audio/decode/stream.d.ts +12 -0
- package/node_modules/audio-decode/node_modules/@audio/decode/stream.js +1 -0
- package/node_modules/audio-decode/node_modules/@audio/decode/test.html +52 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/LICENSE +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/README.md +80 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/alac.js +326 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/decode-aac.d.ts +24 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/decode-aac.js +452 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/meta.js +81 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/package.json +63 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/src/aac.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/LICENSE +12 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/LICENSE.liba52 +340 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/README.md +41 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/decode-ac3.d.ts +20 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/decode-ac3.js +131 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/package.json +64 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/src/ac3.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aiff/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aiff/README.md +46 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aiff/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aiff/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aiff/decode-aiff.d.ts +16 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aiff/decode-aiff.js +583 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aiff/package.json +52 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/LICENSE +191 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/README.md +65 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/decode-amr.d.ts +16 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/decode-amr.js +150 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/package.json +58 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/src/amr.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-avi/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-avi/README.md +53 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-avi/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-avi/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-avi/decode-avi.d.ts +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-avi/decode-avi.js +241 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-avi/package.json +66 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-caf/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-caf/README.md +48 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-caf/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-caf/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-caf/decode-caf.d.ts +16 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-caf/decode-caf.js +238 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-caf/package.json +53 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/README.md +73 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/audio.d.ts +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/audio.js +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/decode-dsd.d.ts +29 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/decode-dsd.js +423 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/meta.js +40 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/package.json +64 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/LICENSE +12 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/LICENSE.libdca +339 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/README.md +41 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/decode-dts.d.ts +20 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/decode-dts.js +139 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/package.json +64 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/src/dts.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/LICENSE +12 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/LICENSE.ffmpeg +502 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/README.md +45 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/decode-eac3.d.ts +20 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/decode-eac3.js +124 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/package.json +68 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/src/eac3.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/LICENSE +25 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/README.md +23 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/decode-flac.d.ts +18 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/decode-flac.js +3172 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/meta.js +115 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/package.json +60 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/LICENSE +23 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/LICENSE.libopenmpt +25 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/README.md +86 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/audio.d.ts +20 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/audio.js +12 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/decode-mod.d.ts +58 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/decode-mod.js +148 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/package.json +68 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/src/mod.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/LICENSE +25 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/README.md +20 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/decode-mp3.d.ts +16 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/decode-mp3.js +793 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/meta.js +143 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/package.json +60 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp4/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp4/README.md +58 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp4/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp4/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp4/decode-mp4.d.ts +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp4/decode-mp4.js +455 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp4/package.json +74 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/LICENSE +31 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/LICENSE.libmpcdec +31 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/README.md +60 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/decode-mpc.d.ts +20 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/decode-mpc.js +158 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/package.json +64 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/src/mpc.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/LICENSE +25 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/LICENSE.libopus +44 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/README.md +32 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/core.d.ts +33 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/core.js +147 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/decode-opus.d.ts +18 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/decode-opus.js +1 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/meta.js +103 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/package.json +68 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/src/decode-opus.js +2 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/src/opus.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-qoa/LICENSE +25 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-qoa/README.md +19 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-qoa/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-qoa/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-qoa/decode-qoa.d.ts +16 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-qoa/decode-qoa.js +275 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-qoa/package.json +56 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/LICENSE.ttadec +39 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/README.md +58 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/decode-tta.d.ts +17 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/decode-tta.js +302 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/package.json +58 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/LICENSE +25 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/README.md +33 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/decode-vorbis.d.ts +18 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/decode-vorbis.js +2984 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/meta.js +102 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/package.json +60 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/README.md +23 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/decode-wav.d.ts +8 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/decode-wav.js +256 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/meta.js +114 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/package.json +52 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/LICENSE +29 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/LICENSE.wavpack +25 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/README.md +41 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/decode-wavpack.d.ts +18 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/decode-wavpack.js +140 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/package.json +62 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/src/wavpack.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/LICENSE.libopus +44 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/README.md +59 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/decode-webm.d.ts +18 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/decode-webm.js +141 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/package.json +76 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/src/opus.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/LICENSE +12 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/README.md +74 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/decode-wma.d.ts +33 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/decode-wma.js +516 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/package.json +57 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/src/wma.wasm.js +0 -0
- package/node_modules/audio-decode/package.json +37 -39
- package/node_modules/audio-decode/stream.d.ts +2 -0
- package/node_modules/audio-decode/stream.js +2 -0
- package/node_modules/baileys/lib/Utils/messages-media.js +1 -1
- package/node_modules/baileys/node_modules/file-type/package.json +3 -2
- package/node_modules/baileys/node_modules/file-type/readme.md +5 -0
- package/node_modules/baileys/node_modules/file-type/source/detectors/zip.js +9 -4
- package/node_modules/baileys/node_modules/file-type/source/index.js +28 -1
- package/node_modules/baileys/node_modules/file-type/source/supported.js +2 -0
- package/node_modules/baileys/node_modules/p-timeout/index.js +3 -0
- package/node_modules/baileys/node_modules/p-timeout/package.json +1 -1
- package/node_modules/baileys/package.json +1 -1
- package/node_modules/typebox/build/compile/code.mjs +1 -2
- package/node_modules/typebox/build/compile/validator.mjs +5 -1
- package/node_modules/typebox/build/format/iri.mjs +16 -9
- package/node_modules/typebox/build/guard/emit.mjs +2 -2
- package/node_modules/typebox/build/guard/guard.d.mts +7 -5
- package/node_modules/typebox/build/guard/guard.mjs +14 -9
- package/node_modules/typebox/build/guard/index.mjs +6 -0
- package/node_modules/typebox/build/guard/unicode/unicode.d.mts +6 -0
- package/node_modules/typebox/build/guard/unicode/unicode.mjs +35 -0
- package/node_modules/typebox/build/guard/{string.mjs → unicode/unicode_segment.mjs} +16 -19
- package/node_modules/typebox/build/schema/build.mjs +2 -3
- package/node_modules/typebox/build/schema/engine/_pathing.d.mts +1 -0
- package/node_modules/typebox/build/schema/engine/_pathing.mjs +11 -0
- package/node_modules/typebox/build/schema/engine/_refine.mjs +13 -5
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/dependencies.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/dependentSchemas.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +1 -1
- package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/format.mjs +9 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/properties.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +1 -1
- package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/ref.d.mts +1 -1
- package/node_modules/typebox/build/schema/engine/ref.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/schema.mjs +24 -24
- package/node_modules/typebox/build/schema/parse.mjs +3 -0
- package/node_modules/typebox/build/schema/pointer/pointer.d.mts +1 -6
- package/node_modules/typebox/build/schema/pointer/pointer.mjs +47 -64
- package/node_modules/typebox/build/system/settings/internal.d.mts +2 -0
- package/node_modules/typebox/build/system/settings/internal.mjs +20 -0
- package/node_modules/typebox/build/system/settings/settings.d.mts +11 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +14 -0
- package/node_modules/typebox/build/type/extends/inference.d.mts +1 -1
- package/node_modules/typebox/build/type/extends/inference.mjs +15 -2
- package/node_modules/typebox/build/type/extends/tuple.d.mts +2 -1
- package/node_modules/typebox/build/type/extends/tuple.mjs +21 -1
- package/node_modules/typebox/build/value/parse/parse.mjs +10 -4
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +3 -1
- package/package.json +6 -6
- package/dist/.setup/doctor-BPb-SjdE.mjs +0 -65
- package/dist/.setup/group-config-path-BGyzT9Lg.mjs +0 -54
- package/dist/.setup/normalize-DdsROMMa.mjs +0 -2
- package/dist/.setup/rolldown-runtime-D7D4PA-g.mjs +0 -13
- package/dist/.setup/runtime-group-policy-DeSRFXEV.mjs +0 -11
- package/dist/.setup/setup-plugin-api-CXfU-7vN.mjs +0 -3
- package/dist/.setup/text-runtime-CHl0iPYe.mjs +0 -4
- package/node_modules/audio-decode/.eslintrc.json +0 -43
- package/node_modules/audio-decode/.github/workflows/test.js.yml +0 -31
- package/node_modules/audio-decode/.travis.yml +0 -13
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/README.md +0 -293
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/dist/opus-ml-decoder.min.js +0 -11646
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/dist/opus-ml-decoder.min.js.map +0 -1
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/index.js +0 -8
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/package.json +0 -58
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/src/EmscriptenWasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/src/OpusMLDecoder.js +0 -253
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/src/OpusMLDecoderWebWorker.js +0 -17
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/types.d.ts +0 -77
- package/node_modules/audio-decode/node_modules/audio-buffer/.eslintrc.json +0 -44
- package/node_modules/audio-decode/node_modules/audio-buffer/.github/workflows/node.js.yml +0 -31
- package/node_modules/audio-decode/node_modules/audio-buffer/.travis.yml +0 -7
- package/node_modules/audio-decode/node_modules/audio-buffer/index.js +0 -76
- package/node_modules/audio-decode/node_modules/audio-buffer/package.json +0 -37
- package/node_modules/audio-decode/node_modules/audio-buffer/readme.md +0 -56
- package/node_modules/audio-decode/node_modules/node-wav/README.md +0 -35
- package/node_modules/audio-decode/node_modules/node-wav/file.wav +0 -0
- package/node_modules/audio-decode/node_modules/node-wav/index.js +0 -291
- package/node_modules/audio-decode/node_modules/node-wav/package.json +0 -29
- package/node_modules/audio-decode/node_modules/node-wav/tests/file1.wav +0 -0
- package/node_modules/audio-decode/node_modules/node-wav/tests/test.js +0 -66
- package/node_modules/audio-decode/node_modules/node-wav/x.js +0 -12
- package/node_modules/audio-decode/node_modules/node-wav/x.json +0 -86702
- package/node_modules/audio-decode/node_modules/node-wav/x.js~ +0 -13
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/README.md +0 -320
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/dist/ogg-opus-decoder.min.js +0 -232
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/dist/ogg-opus-decoder.min.js.map +0 -1
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/dist/ogg-opus-decoder.opus-ml.min.js +0 -0
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/dist/ogg-opus-decoder.opus-ml.min.js.map +0 -1
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/index.js +0 -8
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/package.json +0 -74
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/src/OggOpusDecoder.js +0 -226
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/src/OggOpusDecoderWebWorker.js +0 -17
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/types.d.ts +0 -37
- package/node_modules/audio-decode/node_modules/opus-decoder/README.md +0 -265
- package/node_modules/audio-decode/node_modules/opus-decoder/dist/opus-decoder.min.js +0 -232
- package/node_modules/audio-decode/node_modules/opus-decoder/dist/opus-decoder.min.js.map +0 -1
- package/node_modules/audio-decode/node_modules/opus-decoder/index.js +0 -8
- package/node_modules/audio-decode/node_modules/opus-decoder/package.json +0 -56
- package/node_modules/audio-decode/node_modules/opus-decoder/src/EmscriptenWasm.js +0 -0
- package/node_modules/audio-decode/node_modules/opus-decoder/src/OpusDecoder.js +0 -239
- package/node_modules/audio-decode/node_modules/opus-decoder/src/OpusDecoderWebWorker.js +0 -17
- package/node_modules/audio-decode/node_modules/opus-decoder/types.d.ts +0 -74
- package/node_modules/audio-decode/readme.md +0 -49
- package/node_modules/audio-decode/tea.yaml +0 -6
- package/node_modules/audio-decode/test-case.js +0 -11
- package/node_modules/audio-decode/test.html +0 -15
- package/node_modules/audio-decode/test.js +0 -107
- /package/node_modules/typebox/build/guard/{string.d.mts → unicode/unicode_segment.d.mts} +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ogg Vorbis metadata — Vorbis comment tags + cover art.
|
|
3
|
+
* @module @audio/decode-vorbis/meta
|
|
4
|
+
*
|
|
5
|
+
* import { parseMeta } from '@audio/decode-vorbis/meta'
|
|
6
|
+
* let { meta, sampleRate } = parseMeta(oggBytes)
|
|
7
|
+
* // meta: { title, artist, album, year, genre, ..., pictures, raw }
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const TD = new TextDecoder('utf-8'), TD_L1 = new TextDecoder('iso-8859-1')
|
|
11
|
+
|
|
12
|
+
const VORBIS_MAP = {
|
|
13
|
+
TITLE: 'title', ARTIST: 'artist', ALBUM: 'album', ALBUMARTIST: 'albumartist',
|
|
14
|
+
COMPOSER: 'composer', GENRE: 'genre', DATE: 'year', TRACKNUMBER: 'track',
|
|
15
|
+
DISCNUMBER: 'disc', BPM: 'bpm', KEY: 'key', COMMENT: 'comment', DESCRIPTION: 'comment',
|
|
16
|
+
COPYRIGHT: 'copyright', ISRC: 'isrc', PUBLISHER: 'publisher', ENCODER: 'software',
|
|
17
|
+
LYRICS: 'lyrics'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function u32le(b, o) { return (b[o] | (b[o + 1] << 8) | (b[o + 2] << 16) | (b[o + 3] * 0x1000000)) >>> 0 }
|
|
21
|
+
function u32be(b, o) { return (b[o] * 0x1000000) + (b[o + 1] << 16) + (b[o + 2] << 8) + b[o + 3] }
|
|
22
|
+
|
|
23
|
+
function concat(arr) {
|
|
24
|
+
if (arr.length === 1) return arr[0]
|
|
25
|
+
let n = 0; for (let a of arr) n += a.length
|
|
26
|
+
let out = new Uint8Array(n), o = 0
|
|
27
|
+
for (let a of arr) { out.set(a, o); o += a.length }
|
|
28
|
+
return out
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Reassemble logical packets from the leading Ogg pages (enough for the header packets).
|
|
32
|
+
function oggPackets(b, max) {
|
|
33
|
+
let packets = [], seg = [], off = 0
|
|
34
|
+
while (off + 27 <= b.length && packets.length < max) {
|
|
35
|
+
if (b[off] !== 0x4f || b[off + 1] !== 0x67 || b[off + 2] !== 0x67 || b[off + 3] !== 0x53) break // 'OggS'
|
|
36
|
+
let nseg = b[off + 26], tbl = off + 27, body = tbl + nseg
|
|
37
|
+
if (body > b.length) break
|
|
38
|
+
let size = 0
|
|
39
|
+
for (let i = 0; i < nseg; i++) size += b[tbl + i]
|
|
40
|
+
let p = body
|
|
41
|
+
for (let i = 0; i < nseg; i++) {
|
|
42
|
+
let lace = b[tbl + i]
|
|
43
|
+
seg.push(b.subarray(p, p + lace)); p += lace
|
|
44
|
+
if (lace < 255) { packets.push(concat(seg)); seg = []; if (packets.length >= max) break }
|
|
45
|
+
}
|
|
46
|
+
off = body + size
|
|
47
|
+
}
|
|
48
|
+
return packets
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function decodeB64(s) {
|
|
52
|
+
if (typeof atob === 'function') { let bin = atob(s), u = new Uint8Array(bin.length); for (let i = 0; i < bin.length; i++) u[i] = bin.charCodeAt(i); return u }
|
|
53
|
+
return Uint8Array.from(Buffer.from(s, 'base64'))
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// FLAC PICTURE block layout (also used by METADATA_BLOCK_PICTURE)
|
|
57
|
+
function parsePicture(b) {
|
|
58
|
+
let type = u32be(b, 0), o = 4
|
|
59
|
+
let ml = u32be(b, o); o += 4
|
|
60
|
+
let mime = TD_L1.decode(b.subarray(o, o + ml)); o += ml
|
|
61
|
+
let dl = u32be(b, o); o += 4
|
|
62
|
+
let desc = TD.decode(b.subarray(o, o + dl)); o += dl
|
|
63
|
+
o += 16 // width, height, depth, colors
|
|
64
|
+
let len = u32be(b, o); o += 4
|
|
65
|
+
return { mime, type, description: desc, data: b.slice(o, o + len) }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Vorbis comment block: vendor string + key=value list. Returns { tags, pictures, vendor }.
|
|
69
|
+
export function parseComment(b) {
|
|
70
|
+
let off = 0, tags = {}, pictures = []
|
|
71
|
+
let vlen = u32le(b, off); off += 4
|
|
72
|
+
let vendor = TD.decode(b.subarray(off, off + vlen)); off += vlen
|
|
73
|
+
let n = u32le(b, off); off += 4
|
|
74
|
+
for (let i = 0; i < n && off + 4 <= b.length; i++) {
|
|
75
|
+
let len = u32le(b, off); off += 4
|
|
76
|
+
let s = TD.decode(b.subarray(off, off + len)); off += len
|
|
77
|
+
let eq = s.indexOf('='); if (eq < 0) continue
|
|
78
|
+
let key = s.slice(0, eq).toUpperCase(), val = s.slice(eq + 1)
|
|
79
|
+
if (key === 'METADATA_BLOCK_PICTURE') { try { pictures.push(parsePicture(decodeB64(val))) } catch {} continue }
|
|
80
|
+
let norm = VORBIS_MAP[key]
|
|
81
|
+
if (norm && tags[norm] == null) tags[norm] = val
|
|
82
|
+
}
|
|
83
|
+
return { tags, pictures, vendor }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Parse Ogg Vorbis metadata. Returns { meta, sampleRate, markers, regions } or null. */
|
|
87
|
+
export function parseMeta(bytes) {
|
|
88
|
+
let b = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)
|
|
89
|
+
if (b.length < 4 || b[0] !== 0x4f || b[1] !== 0x67 || b[2] !== 0x67 || b[3] !== 0x53) return null
|
|
90
|
+
let [id, comment] = oggPackets(b, 2)
|
|
91
|
+
// identification header: 0x01 'vorbis' + version(4) + channels(1) + sampleRate(4 LE)
|
|
92
|
+
if (!id || id.length < 16 || id[0] !== 1 || String.fromCharCode(id[1], id[2], id[3], id[4], id[5], id[6]) !== 'vorbis') return null
|
|
93
|
+
let sampleRate = u32le(id, 12)
|
|
94
|
+
let meta = {}, pictures = []
|
|
95
|
+
// comment header: 0x03 'vorbis' then the comment block
|
|
96
|
+
if (comment && comment.length > 7 && comment[0] === 3) {
|
|
97
|
+
let { tags, pictures: pics, vendor } = parseComment(comment.subarray(7))
|
|
98
|
+
Object.assign(meta, tags); pictures = pics; meta.raw = { vendor }
|
|
99
|
+
}
|
|
100
|
+
meta.pictures = pictures
|
|
101
|
+
return { meta, sampleRate, markers: [], regions: [] }
|
|
102
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@audio/decode-vorbis",
|
|
3
|
+
"version": "1.3.2",
|
|
4
|
+
"description": "Decode Ogg Vorbis audio with libvorbis WASM",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "decode-vorbis.js",
|
|
7
|
+
"types": "decode-vorbis.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./decode-vorbis.js",
|
|
10
|
+
"./meta": "./meta.js",
|
|
11
|
+
"./audio": {
|
|
12
|
+
"types": "./audio.d.ts",
|
|
13
|
+
"default": "./audio.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"decode-vorbis.js",
|
|
19
|
+
"meta.js",
|
|
20
|
+
"decode-vorbis.d.ts",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"audio.js",
|
|
23
|
+
"audio.d.ts"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "bash build.sh",
|
|
27
|
+
"prepack": "npm run build",
|
|
28
|
+
"test": "node test.js"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"vorbis",
|
|
32
|
+
"ogg",
|
|
33
|
+
"audio",
|
|
34
|
+
"decode",
|
|
35
|
+
"decoder",
|
|
36
|
+
"wasm"
|
|
37
|
+
],
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"author": "audiojs",
|
|
43
|
+
"homepage": "https://github.com/audiojs/decode/tree/master/packages/decode-vorbis#readme",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/audiojs/decode.git",
|
|
47
|
+
"directory": "packages/decode-vorbis"
|
|
48
|
+
},
|
|
49
|
+
"bugs": "https://github.com/audiojs/decode/issues",
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@wasm-audio-decoders/ogg-vorbis": "~0.1.20",
|
|
52
|
+
"codec-parser": "~2.5.0"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=18"
|
|
56
|
+
},
|
|
57
|
+
"audio": "./audio.js",
|
|
58
|
+
"sideEffects": false,
|
|
59
|
+
"funding": "https://github.com/sponsors/audiojs"
|
|
60
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 audiojs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @audio/decode-wav
|
|
2
|
+
|
|
3
|
+
Decode WAV/RIFF audio in pure JavaScript. Supports PCM, float, A-law, µ-law, IMA ADPCM, and MS ADPCM.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npm install @audio/decode-wav
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import decode, { decoder } from '@audio/decode-wav'
|
|
11
|
+
|
|
12
|
+
let { channelData, sampleRate } = decode(bytes)
|
|
13
|
+
|
|
14
|
+
let dec = decoder()
|
|
15
|
+
let result = dec.decode(chunk)
|
|
16
|
+
dec.free()
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`decode()` and `decoder()` are synchronous. The `./meta` subpath reads embedded metadata. The `./audio` subpath registers the codec with [`audio`](https://github.com/audiojs/audio).
|
|
20
|
+
|
|
21
|
+
## License
|
|
22
|
+
|
|
23
|
+
[ॐ](https://github.com/krishnized/license/) · [MIT](./LICENSE)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Generated from the audio.js manifest (params metadata is the source of truth).
|
|
2
|
+
// Regenerate: node tools/dts.js in @audio/compile. Do not edit by hand.
|
|
3
|
+
|
|
4
|
+
/** Automatable number — scalar, `t => value` fn, or breakpoint curve {t, v} */
|
|
5
|
+
type Auto = number | ((t: number) => number) | { t: number[], v: number[] }
|
|
6
|
+
/** Per-block param values as delivered by hosts (numbers arrive as 1-length Float32Array) */
|
|
7
|
+
type Live = Record<string, Float32Array | string | boolean>
|
|
8
|
+
type Ctx = { sampleRate: number, maxBlockSize: number, maxChannels: number, currentTime: number, duration?: number, events?: readonly any[], emit?: (name: string, ...args: any[]) => void, [k: string]: unknown }
|
|
9
|
+
type Process = (inputs: Float32Array[][], outputs: Float32Array[][], params: Live) => void
|
|
10
|
+
|
|
11
|
+
/** Codec plugin 'wav' — extends audio()'s openable formats / save() targets */
|
|
12
|
+
export declare const wav: {
|
|
13
|
+
codec: 'wav'
|
|
14
|
+
decode(bytes: Uint8Array): { channelData: Float32Array[], sampleRate: number } | Promise<{ channelData: Float32Array[], sampleRate: number }>
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// audio.js manifest — codec atom, decode half: whole-buffer bytes → { channelData,
|
|
2
|
+
// sampleRate }. Hosts merge with the encode half (@audio/encode-wav) by format
|
|
3
|
+
// name. Format detection is magic-byte (audio-type) — no test() needed here.
|
|
4
|
+
|
|
5
|
+
import decodeFn from './decode-wav.js'
|
|
6
|
+
|
|
7
|
+
export const wav = {
|
|
8
|
+
codec: 'wav',
|
|
9
|
+
decode: (bytes) => decodeFn(bytes),
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Decoded PCM: planar channel data + rate. */
|
|
2
|
+
export interface AudioData { channelData: Float32Array[], sampleRate: number }
|
|
3
|
+
/** @deprecated Renamed to AudioData. */
|
|
4
|
+
export type Decoded = AudioData
|
|
5
|
+
/** Decode a complete WAV file synchronously. */
|
|
6
|
+
export default function decode(src: Uint8Array | ArrayBuffer): AudioData
|
|
7
|
+
/** Create a synchronous streaming decoder. */
|
|
8
|
+
export function decoder(): { decode(chunk: Uint8Array | ArrayBuffer): AudioData, flush(): AudioData, free(): void }
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WAV decoder — pure JS / ESM
|
|
3
|
+
* Decodes WAV audio to Float32Array samples:
|
|
4
|
+
* PCM 8/16/24/32-bit int, 32/64-bit float, G.711 A-law / µ-law,
|
|
5
|
+
* plus WAVE_FORMAT_EXTENSIBLE wrapping any of the above.
|
|
6
|
+
*
|
|
7
|
+
* let { channelData, sampleRate } = decode(wavbuf)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const EMPTY = Object.freeze({ channelData: [], sampleRate: 0 })
|
|
11
|
+
|
|
12
|
+
// WAVE format tag → codec. EXTENSIBLE (0xFFFE) is resolved to its SubFormat tag.
|
|
13
|
+
const WAV_CODECS = { 1: 'pcm', 3: 'float', 6: 'alaw', 7: 'ulaw', 2: 'ms', 0x11: 'ima' }
|
|
14
|
+
|
|
15
|
+
// IMA/DVI ADPCM tables (ITU-T / Intel)
|
|
16
|
+
const IMA_STEP = new Int16Array([7,8,9,10,11,12,13,14,16,17,19,21,23,25,28,31,34,37,41,45,50,55,60,66,73,80,88,97,107,118,130,143,157,173,190,209,230,253,279,307,337,371,408,449,494,544,598,658,724,796,876,963,1060,1166,1282,1411,1552,1707,1878,2066,2272,2499,2749,3024,3327,3660,4026,4428,4871,5358,5894,6484,7132,7845,8630,9493,10442,11487,12635,13899,15289,16818,18500,20350,22385,24623,27086,29794,32767])
|
|
17
|
+
const IMA_IDX = new Int8Array([-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8])
|
|
18
|
+
|
|
19
|
+
// MS ADPCM adaptation table + default predictor coefficients
|
|
20
|
+
const MS_ADAPT = new Int16Array([230,230,230,230,307,409,512,614,768,614,512,409,307,230,230,230])
|
|
21
|
+
const MS_DEFAULT_COEFS = [[256,0],[512,-256],[0,0],[192,64],[240,0],[460,-208],[392,-232]]
|
|
22
|
+
|
|
23
|
+
// G.711 expansion tables (ITU-T) — int16 PCM per encoded byte
|
|
24
|
+
const ALAW_TBL = new Int16Array(256)
|
|
25
|
+
const ULAW_TBL = new Int16Array(256)
|
|
26
|
+
for (let i = 0; i < 256; i++) {
|
|
27
|
+
let ax = i ^ 0x55, seg = (ax >> 4) & 7, val = ((ax & 0x0F) << 4) + 8
|
|
28
|
+
if (seg) val = (val + 256) << (seg - 1)
|
|
29
|
+
ALAW_TBL[i] = (ax & 0x80) ? val : -val
|
|
30
|
+
|
|
31
|
+
let ux = ~i & 0xFF
|
|
32
|
+
seg = (ux >> 4) & 7
|
|
33
|
+
val = ((ux & 0x0F) << 3) + 132
|
|
34
|
+
val <<= seg
|
|
35
|
+
ULAW_TBL[i] = (ux & 0x80) ? (132 - val) : (val - 132)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Decode a complete WAV file synchronously. */
|
|
39
|
+
export default function decode(src) {
|
|
40
|
+
let dec = decoder()
|
|
41
|
+
try { return dec.decode(src instanceof Uint8Array ? src : new Uint8Array(src)) }
|
|
42
|
+
finally { dec.free() }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Create a synchronous streaming decoder. */
|
|
46
|
+
export function decoder() {
|
|
47
|
+
let hdr = null, left = null, freed = false, dataLeft = Infinity
|
|
48
|
+
return {
|
|
49
|
+
decode(data) {
|
|
50
|
+
if (freed) throw Error('Decoder already freed')
|
|
51
|
+
if (!data || !data.byteLength) return EMPTY
|
|
52
|
+
let chunk = data instanceof Uint8Array ? data : new Uint8Array(data)
|
|
53
|
+
if (left) { chunk = cat(left, chunk); left = null }
|
|
54
|
+
if (!hdr) {
|
|
55
|
+
hdr = scanWavHdr(chunk)
|
|
56
|
+
if (!hdr) { left = chunk.slice(); return EMPTY }
|
|
57
|
+
// 0 / 0xFFFFFFFF are streaming placeholders; read to the end
|
|
58
|
+
dataLeft = hdr.dataSize > 0 && hdr.dataSize < 0xFFFFFFFF ? hdr.dataSize : Infinity
|
|
59
|
+
chunk = chunk.subarray(hdr.dataStart)
|
|
60
|
+
}
|
|
61
|
+
if (dataLeft <= 0) return EMPTY // Ignore chunks after the declared audio data.
|
|
62
|
+
let fb = hdr.blockSize
|
|
63
|
+
let avail = Math.min(chunk.length, dataLeft) // Do not read past the declared data size.
|
|
64
|
+
let complete = Math.floor(avail / fb) * fb
|
|
65
|
+
if (!complete) { if (chunk.length && dataLeft > chunk.length) left = chunk.slice(); return EMPTY }
|
|
66
|
+
dataLeft -= complete
|
|
67
|
+
let rest = chunk.subarray(complete)
|
|
68
|
+
if (rest.length && dataLeft > 0) left = rest.subarray(0, Math.min(rest.length, dataLeft)).slice()
|
|
69
|
+
return decodeRaw(chunk.subarray(0, complete), hdr)
|
|
70
|
+
},
|
|
71
|
+
flush() { left = null; return EMPTY },
|
|
72
|
+
free() { freed = true; left = null; hdr = null },
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function cat(a, b) {
|
|
77
|
+
let r = new Uint8Array(a.length + b.length)
|
|
78
|
+
r.set(a); r.set(b, a.length)
|
|
79
|
+
return r
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function s4(b, o) { return String.fromCharCode(b[o], b[o + 1], b[o + 2], b[o + 3]) }
|
|
83
|
+
|
|
84
|
+
function scanWavHdr(b) {
|
|
85
|
+
// reject non-WAV as soon as the magic is readable; only buffer when a valid header is still arriving
|
|
86
|
+
if (b.length >= 4 && s4(b, 0) !== 'RIFF') throw TypeError('Not a WAV file')
|
|
87
|
+
if (b.length < 12) return null
|
|
88
|
+
let dv = new DataView(b.buffer, b.byteOffset, b.byteLength)
|
|
89
|
+
if (s4(b, 8) !== 'WAVE') throw TypeError('Not a WAV file')
|
|
90
|
+
let pos = 12, fmt = null
|
|
91
|
+
while (pos + 8 <= b.length) {
|
|
92
|
+
let type = s4(b, pos), size = dv.getUint32(pos + 4, true)
|
|
93
|
+
if (type === 'fmt ') {
|
|
94
|
+
if (pos + 24 > b.length) return null
|
|
95
|
+
let fid = dv.getUint16(pos + 8, true)
|
|
96
|
+
// WAVE_FORMAT_EXTENSIBLE: real codec is the first 2 bytes of the SubFormat GUID
|
|
97
|
+
if (fid === 0xFFFE) {
|
|
98
|
+
if (pos + 48 > b.length) return null
|
|
99
|
+
fid = dv.getUint16(pos + 32, true)
|
|
100
|
+
}
|
|
101
|
+
let codec = WAV_CODECS[fid]
|
|
102
|
+
if (!codec) throw TypeError('Unsupported WAV format: 0x' + fid.toString(16))
|
|
103
|
+
fmt = {
|
|
104
|
+
codec, channels: dv.getUint16(pos + 10, true),
|
|
105
|
+
sampleRate: dv.getUint32(pos + 12, true),
|
|
106
|
+
blockSize: dv.getUint16(pos + 20, true), bitDepth: dv.getUint16(pos + 22, true),
|
|
107
|
+
}
|
|
108
|
+
// ADPCM: block-based — read samples-per-block (+ predictor coefs for MS) from the fmt extension
|
|
109
|
+
if (codec === 'ima' || codec === 'ms') {
|
|
110
|
+
if (pos + 8 + size > b.length) return null // wait for the full fmt chunk
|
|
111
|
+
let nCh = fmt.channels, ba = fmt.blockSize
|
|
112
|
+
let cbSize = dv.getUint16(pos + 24, true)
|
|
113
|
+
fmt.samplesPerBlock = cbSize >= 2 ? dv.getUint16(pos + 26, true) : 0
|
|
114
|
+
if (codec === 'ima') {
|
|
115
|
+
if (!fmt.samplesPerBlock) fmt.samplesPerBlock = 1 + (ba / nCh - 4) * 2
|
|
116
|
+
} else {
|
|
117
|
+
if (!fmt.samplesPerBlock) fmt.samplesPerBlock = 2 + (ba - 7 * nCh) * 2 / nCh
|
|
118
|
+
let nCoef = cbSize >= 4 ? dv.getUint16(pos + 28, true) : 0
|
|
119
|
+
let coefs = []
|
|
120
|
+
for (let i = 0; i < nCoef; i++)
|
|
121
|
+
coefs.push([dv.getInt16(pos + 30 + i * 4, true), dv.getInt16(pos + 32 + i * 4, true)])
|
|
122
|
+
fmt.coefs = coefs.length ? coefs : MS_DEFAULT_COEFS
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
} else if (type === 'data') {
|
|
126
|
+
if (!fmt) return null
|
|
127
|
+
return { ...fmt, dataStart: pos + 8, dataSize: size }
|
|
128
|
+
}
|
|
129
|
+
pos += 8 + size
|
|
130
|
+
}
|
|
131
|
+
return null
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function decodeRaw(raw, hdr) {
|
|
135
|
+
let { channels: nCh, bitDepth, codec, sampleRate, blockSize } = hdr
|
|
136
|
+
if (codec === 'ima') return decodeImaWav(raw, hdr)
|
|
137
|
+
if (codec === 'ms') return decodeMsWav(raw, hdr)
|
|
138
|
+
let frames = Math.floor(raw.length / blockSize)
|
|
139
|
+
if (!frames) return EMPTY
|
|
140
|
+
let ch = Array.from({ length: nCh }, () => new Float32Array(frames))
|
|
141
|
+
let dv = new DataView(raw.buffer, raw.byteOffset, raw.byteLength)
|
|
142
|
+
let p = 0
|
|
143
|
+
let isFloat = codec === 'float'
|
|
144
|
+
if (codec === 'alaw' || codec === 'ulaw') {
|
|
145
|
+
let tbl = codec === 'alaw' ? ALAW_TBL : ULAW_TBL
|
|
146
|
+
for (let i = 0; i < frames; i++) for (let c = 0; c < nCh; c++) ch[c][i] = tbl[raw[p++]] / 32768
|
|
147
|
+
} else if (isFloat && bitDepth === 64) {
|
|
148
|
+
for (let i = 0; i < frames; i++) for (let c = 0; c < nCh; c++) { ch[c][i] = dv.getFloat64(p, true); p += 8 }
|
|
149
|
+
} else if (isFloat && bitDepth === 32) {
|
|
150
|
+
for (let i = 0; i < frames; i++) for (let c = 0; c < nCh; c++) { ch[c][i] = dv.getFloat32(p, true); p += 4 }
|
|
151
|
+
} else if (bitDepth === 8) {
|
|
152
|
+
for (let i = 0; i < frames; i++) for (let c = 0; c < nCh; c++) {
|
|
153
|
+
let v = raw[p++] - 128; ch[c][i] = v < 0 ? v / 128 : v / 127
|
|
154
|
+
}
|
|
155
|
+
} else if (bitDepth === 16) {
|
|
156
|
+
for (let i = 0; i < frames; i++) for (let c = 0; c < nCh; c++) {
|
|
157
|
+
let v = dv.getInt16(p, true); p += 2; ch[c][i] = v < 0 ? v / 32768 : v / 32767
|
|
158
|
+
}
|
|
159
|
+
} else if (bitDepth === 24) {
|
|
160
|
+
for (let i = 0; i < frames; i++) for (let c = 0; c < nCh; c++) {
|
|
161
|
+
let v = raw[p] | (raw[p + 1] << 8) | (raw[p + 2] << 16); p += 3
|
|
162
|
+
if (v >= 0x800000) v -= 0x1000000
|
|
163
|
+
ch[c][i] = v < 0 ? v / 8388608 : v / 8388607
|
|
164
|
+
}
|
|
165
|
+
} else if (bitDepth === 32) {
|
|
166
|
+
for (let i = 0; i < frames; i++) for (let c = 0; c < nCh; c++) {
|
|
167
|
+
let v = dv.getInt32(p, true); p += 4; ch[c][i] = v < 0 ? v / 2147483648 : v / 2147483647
|
|
168
|
+
}
|
|
169
|
+
} else { throw TypeError('Unsupported WAV bit depth: ' + bitDepth) }
|
|
170
|
+
return { channelData: ch, sampleRate }
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// IMA/DVI ADPCM — per channel: 4-byte header (predictor int16 + step index), then
|
|
174
|
+
// 4-byte words round-robin across channels, low nibble first, 8 samples per word.
|
|
175
|
+
function decodeImaWav(raw, hdr) {
|
|
176
|
+
let { channels: nCh, blockSize: ba, samplesPerBlock: spb, sampleRate } = hdr
|
|
177
|
+
let nBlocks = Math.floor(raw.length / ba)
|
|
178
|
+
let ch = Array.from({ length: nCh }, () => new Float32Array(nBlocks * spb))
|
|
179
|
+
let dv = new DataView(raw.buffer, raw.byteOffset, raw.byteLength)
|
|
180
|
+
for (let blk = 0; blk < nBlocks; blk++) {
|
|
181
|
+
let base = blk * ba, outBase = blk * spb
|
|
182
|
+
let pred = new Int32Array(nCh), idx = new Int32Array(nCh), cnt = new Int32Array(nCh)
|
|
183
|
+
for (let c = 0; c < nCh; c++) {
|
|
184
|
+
pred[c] = dv.getInt16(base + c * 4, true)
|
|
185
|
+
idx[c] = Math.min(raw[base + c * 4 + 2], 88)
|
|
186
|
+
ch[c][outBase] = pred[c] / 32768
|
|
187
|
+
cnt[c] = 1
|
|
188
|
+
}
|
|
189
|
+
let p = base + nCh * 4, nWords = Math.ceil((spb - 1) / 8)
|
|
190
|
+
for (let w = 0; w < nWords; w++) {
|
|
191
|
+
for (let c = 0; c < nCh; c++, p += 4) {
|
|
192
|
+
let out = ch[c], pr = pred[c], ix = idx[c]
|
|
193
|
+
for (let n = 0; n < 4; n++) {
|
|
194
|
+
let byte = raw[p + n]
|
|
195
|
+
for (let half = 0; half < 2; half++) {
|
|
196
|
+
let nib = half === 0 ? (byte & 0x0F) : (byte >> 4)
|
|
197
|
+
let step = IMA_STEP[ix]
|
|
198
|
+
let diff = ((2 * (nib & 7) + 1) * step) >> 3
|
|
199
|
+
pr += (nib & 8) ? -diff : diff
|
|
200
|
+
if (pr > 32767) pr = 32767; else if (pr < -32768) pr = -32768
|
|
201
|
+
ix += IMA_IDX[nib]
|
|
202
|
+
if (ix < 0) ix = 0; else if (ix > 88) ix = 88
|
|
203
|
+
if (cnt[c] < spb) out[outBase + cnt[c]++] = pr / 32768
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
pred[c] = pr; idx[c] = ix
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return { channelData: ch, sampleRate }
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// MS ADPCM — per channel: predictor index byte, then int16 delta, sample1, sample2.
|
|
214
|
+
// Stereo interleaves one nibble per channel per byte (high=L, low=R); mono packs two.
|
|
215
|
+
function decodeMsWav(raw, hdr) {
|
|
216
|
+
let { channels: nCh, blockSize: ba, samplesPerBlock: spb, sampleRate, coefs } = hdr
|
|
217
|
+
let nBlocks = Math.floor(raw.length / ba)
|
|
218
|
+
let ch = Array.from({ length: nCh }, () => new Float32Array(nBlocks * spb))
|
|
219
|
+
let dv = new DataView(raw.buffer, raw.byteOffset, raw.byteLength)
|
|
220
|
+
let predIdx = new Int32Array(nCh), delta = new Int32Array(nCh), s1 = new Int32Array(nCh), s2 = new Int32Array(nCh)
|
|
221
|
+
let expand = (nib, c) => {
|
|
222
|
+
let signed = nib >= 8 ? nib - 16 : nib
|
|
223
|
+
let co = coefs[predIdx[c]]
|
|
224
|
+
let pr = (s1[c] * co[0] + s2[c] * co[1]) >> 8
|
|
225
|
+
pr += signed * delta[c]
|
|
226
|
+
if (pr > 32767) pr = 32767; else if (pr < -32768) pr = -32768
|
|
227
|
+
s2[c] = s1[c]; s1[c] = pr
|
|
228
|
+
delta[c] = (MS_ADAPT[nib] * delta[c]) >> 8
|
|
229
|
+
if (delta[c] < 16) delta[c] = 16
|
|
230
|
+
return pr / 32768
|
|
231
|
+
}
|
|
232
|
+
for (let blk = 0; blk < nBlocks; blk++) {
|
|
233
|
+
let base = blk * ba, outBase = blk * spb, p = base
|
|
234
|
+
for (let c = 0; c < nCh; c++) predIdx[c] = Math.min(raw[p++], coefs.length - 1)
|
|
235
|
+
for (let c = 0; c < nCh; c++) { delta[c] = dv.getInt16(p, true); p += 2 }
|
|
236
|
+
for (let c = 0; c < nCh; c++) { s1[c] = dv.getInt16(p, true); p += 2 }
|
|
237
|
+
for (let c = 0; c < nCh; c++) { s2[c] = dv.getInt16(p, true); p += 2 }
|
|
238
|
+
for (let c = 0; c < nCh; c++) { ch[c][outBase] = s2[c] / 32768; ch[c][outBase + 1] = s1[c] / 32768 }
|
|
239
|
+
let cnt = 2
|
|
240
|
+
if (nCh === 1) {
|
|
241
|
+
while (cnt < spb) {
|
|
242
|
+
let byte = raw[p++]
|
|
243
|
+
ch[0][outBase + cnt++] = expand(byte >> 4, 0)
|
|
244
|
+
if (cnt < spb) ch[0][outBase + cnt++] = expand(byte & 0x0F, 0)
|
|
245
|
+
}
|
|
246
|
+
} else {
|
|
247
|
+
while (cnt < spb) {
|
|
248
|
+
let byte = raw[p++]
|
|
249
|
+
ch[0][outBase + cnt] = expand(byte >> 4, 0)
|
|
250
|
+
ch[1][outBase + cnt] = expand(byte & 0x0F, 1)
|
|
251
|
+
cnt++
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return { channelData: ch, sampleRate }
|
|
256
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WAV RIFF metadata parser — INFO, bext, iXML, cue/adtl chunks.
|
|
3
|
+
* @module @audio/decode-wav/meta
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const TD_U8 = new TextDecoder('utf-8'), TD_L1 = new TextDecoder('iso-8859-1')
|
|
7
|
+
|
|
8
|
+
function str(bytes, enc = 'utf-8') {
|
|
9
|
+
let end = bytes.length
|
|
10
|
+
while (end > 0 && bytes[end - 1] === 0) end--
|
|
11
|
+
return (enc === 'iso-8859-1' ? TD_L1 : TD_U8).decode(bytes.subarray(0, end))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// ── Constants ───────────────────────────────────────────────────────────
|
|
15
|
+
|
|
16
|
+
export const INFO_MAP = {
|
|
17
|
+
INAM: 'title', IART: 'artist', IPRD: 'album', IGNR: 'genre',
|
|
18
|
+
ICRD: 'year', ITRK: 'track', ICMT: 'comment', ICOP: 'copyright',
|
|
19
|
+
IENG: 'engineer', ISFT: 'software', ISRC: 'isrc', ISBJ: 'subject',
|
|
20
|
+
IKEY: 'keywords', IARL: 'location'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// ── Binary helpers ──────────────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
function u32le(b, o) { return b[o] | (b[o + 1] << 8) | (b[o + 2] << 16) | (b[o + 3] * 0x1000000) }
|
|
26
|
+
function u16le(b, o) { return b[o] | (b[o + 1] << 8) }
|
|
27
|
+
function fourcc(b, o) { return String.fromCharCode(b[o], b[o + 1], b[o + 2], b[o + 3]) }
|
|
28
|
+
|
|
29
|
+
// ── Chunk parsers ───────────────────────────────────────────────────────
|
|
30
|
+
|
|
31
|
+
function parseBext(b) {
|
|
32
|
+
if (b.length < 348) return null
|
|
33
|
+
return {
|
|
34
|
+
description: str(b.subarray(0, 256)),
|
|
35
|
+
originator: str(b.subarray(256, 288)),
|
|
36
|
+
originatorReference: str(b.subarray(288, 320)),
|
|
37
|
+
originationDate: str(b.subarray(320, 330)),
|
|
38
|
+
originationTime: str(b.subarray(330, 338)),
|
|
39
|
+
timeReferenceLow: u32le(b, 338),
|
|
40
|
+
timeReferenceHigh: u32le(b, 342),
|
|
41
|
+
version: u16le(b, 346)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function parseInfo(b) {
|
|
46
|
+
let out = {}, off = 0
|
|
47
|
+
while (off + 8 <= b.length) {
|
|
48
|
+
let id = fourcc(b, off), size = u32le(b, off + 4)
|
|
49
|
+
let v = str(b.subarray(off + 8, off + 8 + size))
|
|
50
|
+
let key = INFO_MAP[id]
|
|
51
|
+
if (key) out[key] = v
|
|
52
|
+
off += 8 + size + (size & 1)
|
|
53
|
+
}
|
|
54
|
+
return out
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function parseCue(b, cues) {
|
|
58
|
+
let n = u32le(b, 0)
|
|
59
|
+
for (let i = 0; i < n; i++) {
|
|
60
|
+
let o = 4 + i * 24
|
|
61
|
+
if (o + 24 > b.length) break
|
|
62
|
+
let id = u32le(b, o), pos = u32le(b, o + 20)
|
|
63
|
+
cues.set(id, pos)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function parseAdtl(b, labels, notes, ltxts) {
|
|
68
|
+
let off = 0
|
|
69
|
+
while (off + 8 <= b.length) {
|
|
70
|
+
let id = fourcc(b, off), size = u32le(b, off + 4)
|
|
71
|
+
let body = b.subarray(off + 8, off + 8 + size)
|
|
72
|
+
if (id === 'labl' && body.length >= 4) labels.set(u32le(body, 0), str(body.subarray(4)))
|
|
73
|
+
else if (id === 'note' && body.length >= 4) notes.set(u32le(body, 0), str(body.subarray(4)))
|
|
74
|
+
else if (id === 'ltxt' && body.length >= 20) ltxts.set(u32le(body, 0), { duration: u32le(body, 4), label: str(body.subarray(20)) })
|
|
75
|
+
off += 8 + size + (size & 1)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Parse WAV RIFF metadata. Returns {meta, sampleRate, markers, regions} or null. */
|
|
80
|
+
export function parseMeta(bytes) {
|
|
81
|
+
if (!bytes?.length || bytes.length < 12 || fourcc(bytes, 0) !== 'RIFF' || fourcc(bytes, 8) !== 'WAVE') return null
|
|
82
|
+
let meta = {}, raw = {}, pictures = [], markers = [], regions = []
|
|
83
|
+
let cues = new Map(), labels = new Map(), notes = new Map(), ltxts = new Map()
|
|
84
|
+
let sampleRate = 0
|
|
85
|
+
|
|
86
|
+
let off = 12
|
|
87
|
+
while (off + 8 <= bytes.length) {
|
|
88
|
+
let id = fourcc(bytes, off), size = u32le(bytes, off + 4)
|
|
89
|
+
let body = bytes.subarray(off + 8, off + 8 + size)
|
|
90
|
+
if (id === 'fmt ' && body.length >= 16) sampleRate = u32le(body, 4)
|
|
91
|
+
else if (id === 'bext') raw.bext = parseBext(body)
|
|
92
|
+
else if (id === 'iXML') raw.iXML = str(body, 'utf-8')
|
|
93
|
+
else if (id === 'LIST' && body.length >= 4 && fourcc(body, 0) === 'INFO') Object.assign(meta, parseInfo(body.subarray(4)))
|
|
94
|
+
// NOTE: embedded ID3 in WAV (id === 'ID3 ') not parsed here — use @audio/decode-mp3/meta for that
|
|
95
|
+
else if (id === 'cue ') parseCue(body, cues)
|
|
96
|
+
else if (id === 'LIST' && body.length >= 4 && fourcc(body, 0) === 'adtl') parseAdtl(body.subarray(4), labels, notes, ltxts)
|
|
97
|
+
off += 8 + size + (size & 1)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
for (let [id, pos] of cues) {
|
|
101
|
+
let label = labels.get(id) || notes.get(id) || ''
|
|
102
|
+
let lt = ltxts.get(id)
|
|
103
|
+
if (lt && lt.duration > 0) regions.push({ sample: pos, length: lt.duration, label: lt.label || label })
|
|
104
|
+
else markers.push({ sample: pos, label })
|
|
105
|
+
}
|
|
106
|
+
markers.sort((a, b) => a.sample - b.sample)
|
|
107
|
+
regions.sort((a, b) => a.sample - b.sample)
|
|
108
|
+
|
|
109
|
+
if (raw.bext?.description && !meta.comment) meta.comment = raw.bext.description
|
|
110
|
+
|
|
111
|
+
meta.raw = raw
|
|
112
|
+
meta.pictures = pictures
|
|
113
|
+
return { meta, sampleRate, markers, regions }
|
|
114
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@audio/decode-wav",
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "Decode WAV audio to PCM samples",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "decode-wav.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"decode-wav.js",
|
|
9
|
+
"meta.js",
|
|
10
|
+
"audio.js",
|
|
11
|
+
"audio.d.ts",
|
|
12
|
+
"decode-wav.d.ts"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./decode-wav.js",
|
|
16
|
+
"./meta": "./meta.js",
|
|
17
|
+
"./audio": {
|
|
18
|
+
"types": "./audio.d.ts",
|
|
19
|
+
"default": "./audio.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"wav",
|
|
25
|
+
"audio",
|
|
26
|
+
"decode",
|
|
27
|
+
"decoder",
|
|
28
|
+
"pcm"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"author": "audiojs",
|
|
35
|
+
"scripts": {
|
|
36
|
+
"test": "node test.js"
|
|
37
|
+
},
|
|
38
|
+
"audio": "./audio.js",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/audiojs/decode.git",
|
|
42
|
+
"directory": "packages/decode-wav"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/audiojs/decode/tree/master/packages/decode-wav#readme",
|
|
45
|
+
"bugs": "https://github.com/audiojs/decode/issues",
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=18"
|
|
48
|
+
},
|
|
49
|
+
"sideEffects": false,
|
|
50
|
+
"funding": "https://github.com/sponsors/audiojs",
|
|
51
|
+
"types": "decode-wav.d.ts"
|
|
52
|
+
}
|