@openclaw/whatsapp 2026.5.28 → 2026.5.31-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{access-control-Z0fYaWrx.js → access-control-C53zKYSN.js} +1 -1
- package/dist/{accounts-BMGM1RtF.js → accounts-DgViSyJx.js} +1 -0
- package/dist/{action-runtime-BdhkGtaP.js → action-runtime-Cyp5GNIT.js} +2 -2
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/api.js +9 -9
- package/dist/{approval-handler.runtime-C25wPeBf.js → approval-handler.runtime-BVmOu6x1.js} +1 -2
- package/dist/{auth-store-BrKb0mwT.js → auth-store-CZ22aNcV.js} +4 -2
- package/dist/{channel-D3y4A5Dd.js → channel-DA2BAIo5.js} +17 -64
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-react-action-Cd2qkLqp.js → channel-react-action-zvbaCnGe.js} +3 -3
- package/dist/{channel.runtime-C228XUjs.js → channel.runtime-Q1LZDB5s.js} +4 -4
- package/dist/{channel.setup-BJQyTUUP.js → channel.setup-DHXOo4h5.js} +2 -3
- package/dist/{config-schema-CsNDlDpL.js → config-schema-CROZuhT-.js} +16 -0
- package/dist/{connection-controller-mpPGmqGq.js → connection-controller-Bnm4INld.js} +2 -2
- package/dist/contract-api.js +1 -1
- package/dist/light-runtime-api.js +1 -1
- package/dist/{login-CE4UYnyO.js → login-2fuBM7Je.js} +4 -4
- package/dist/{login-qr-LBvhEes5.js → login-qr-B1o7GFy8.js} +10 -6
- package/dist/login-qr-runtime.js +1 -1
- package/dist/{monitor-Ccph7Y8M.js → monitor-BVRq04Dt.js} +36 -18
- package/dist/runtime-api.js +7 -7
- package/dist/{send-C4LG-Cl6.js → send-DSlVXKL_.js} +53 -41
- package/dist/{send-api-C66vkRl9.js → send-api-Bjn-h80j.js} +3 -2
- package/dist/{session-D8UW2Vbn.js → session-DyGWNClj.js} +1 -1
- package/dist/{setup-core-DpfT4K-2.js → setup-core-OvPMaAsx.js} +4 -4
- package/dist/{setup-finalize-CFnxX7la.js → setup-finalize-Dk23pfKc.js} +3 -3
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-DRsmp0ZS.js → setup-surface-F-jVrH8u.js} +3 -3
- package/node_modules/@audio/decode-aac/LICENSE +9 -0
- package/node_modules/@audio/decode-aac/README.md +60 -0
- package/node_modules/@audio/decode-aac/decode-aac.d.ts +16 -0
- package/node_modules/@audio/decode-aac/decode-aac.js +391 -0
- package/node_modules/@audio/decode-aac/package.json +47 -0
- package/node_modules/@audio/decode-aac/src/aac.wasm.cjs +0 -0
- package/node_modules/@audio/decode-aiff/LICENSE +21 -0
- package/node_modules/@audio/decode-aiff/README.md +53 -0
- package/node_modules/@audio/decode-aiff/decode-aiff.d.ts +16 -0
- package/node_modules/@audio/decode-aiff/decode-aiff.js +583 -0
- package/node_modules/@audio/decode-aiff/package.json +42 -0
- package/node_modules/@audio/decode-amr/LICENSE +191 -0
- package/node_modules/@audio/decode-amr/README.md +65 -0
- package/node_modules/@audio/decode-amr/decode-amr.d.ts +16 -0
- package/node_modules/@audio/decode-amr/decode-amr.js +159 -0
- package/node_modules/@audio/decode-amr/package.json +48 -0
- package/node_modules/@audio/decode-amr/src/amr.wasm.cjs +0 -0
- package/node_modules/@audio/decode-caf/LICENSE +21 -0
- package/node_modules/@audio/decode-caf/README.md +55 -0
- package/node_modules/@audio/decode-caf/decode-caf.d.ts +16 -0
- package/node_modules/@audio/decode-caf/decode-caf.js +190 -0
- package/node_modules/@audio/decode-caf/package.json +43 -0
- package/node_modules/{audio-buffer → @audio/decode-flac}/LICENSE +5 -2
- package/node_modules/@audio/decode-flac/README.md +23 -0
- package/node_modules/@audio/decode-flac/decode-flac.d.ts +16 -0
- package/node_modules/@audio/decode-flac/decode-flac.js +2994 -0
- package/node_modules/@audio/decode-flac/meta.js +115 -0
- package/node_modules/@audio/decode-flac/package.json +49 -0
- package/node_modules/@audio/decode-mp3/LICENSE +25 -0
- package/node_modules/@audio/decode-mp3/README.md +23 -0
- package/node_modules/@audio/decode-mp3/decode-mp3.d.ts +16 -0
- package/node_modules/@audio/decode-mp3/decode-mp3.js +868 -0
- package/node_modules/@audio/decode-mp3/meta.js +143 -0
- package/node_modules/@audio/decode-mp3/package.json +50 -0
- package/node_modules/@audio/decode-opus/LICENSE +25 -0
- package/node_modules/@audio/decode-opus/README.md +23 -0
- package/node_modules/@audio/decode-opus/decode-opus.d.ts +16 -0
- package/node_modules/@audio/decode-opus/decode-opus.js +3179 -0
- package/node_modules/@audio/decode-opus/package.json +47 -0
- package/node_modules/@audio/decode-qoa/LICENSE +25 -0
- package/node_modules/@audio/decode-qoa/README.md +21 -0
- package/node_modules/@audio/decode-qoa/decode-qoa.d.ts +16 -0
- package/node_modules/@audio/decode-qoa/decode-qoa.js +278 -0
- package/node_modules/@audio/decode-qoa/package.json +46 -0
- package/node_modules/@audio/decode-vorbis/LICENSE +25 -0
- package/node_modules/@audio/decode-vorbis/README.md +23 -0
- package/node_modules/@audio/decode-vorbis/decode-vorbis.d.ts +16 -0
- package/node_modules/@audio/decode-vorbis/decode-vorbis.js +2984 -0
- package/node_modules/@audio/decode-vorbis/package.json +47 -0
- package/node_modules/@audio/decode-wav/decode-wav.js +104 -0
- package/node_modules/@audio/decode-wav/meta.js +114 -0
- package/node_modules/@audio/decode-wav/package.json +27 -0
- package/node_modules/@audio/decode-webm/LICENSE +21 -0
- package/node_modules/@audio/decode-webm/README.md +57 -0
- package/node_modules/@audio/decode-webm/decode-webm.d.ts +16 -0
- package/node_modules/@audio/decode-webm/decode-webm.js +3964 -0
- package/node_modules/@audio/decode-webm/package.json +51 -0
- package/node_modules/@audio/decode-wma/LICENSE +12 -0
- package/node_modules/@audio/decode-wma/README.md +76 -0
- package/node_modules/@audio/decode-wma/decode-wma.d.ts +33 -0
- package/node_modules/@audio/decode-wma/decode-wma.js +525 -0
- package/node_modules/@audio/decode-wma/package.json +47 -0
- package/node_modules/@audio/decode-wma/src/wma.wasm.cjs +0 -0
- package/node_modules/audio-decode/.claude/settings.json +204 -0
- package/node_modules/audio-decode/.github/workflows/test.js.yml +11 -20
- package/node_modules/audio-decode/.gitmodules +9 -0
- package/node_modules/audio-decode/audio-decode.d.ts +48 -10
- package/node_modules/audio-decode/audio-decode.js +193 -77
- package/node_modules/audio-decode/meta.js +11 -0
- package/node_modules/audio-decode/package.json +49 -21
- package/node_modules/audio-decode/readme.md +129 -29
- package/node_modules/audio-decode/stream.d.ts +15 -0
- package/node_modules/audio-decode/stream.js +1 -0
- package/node_modules/audio-decode/test.html +29 -10
- package/node_modules/lru-cache/dist/commonjs/browser/index.d.ts +2 -2
- package/node_modules/lru-cache/dist/commonjs/browser/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/browser/index.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/browser/index.min.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/index.d.ts +2 -2
- package/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/index.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/index.min.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/node/index.d.ts +2 -2
- package/node_modules/lru-cache/dist/commonjs/node/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/node/index.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/node/index.min.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/browser/index.d.ts +2 -2
- package/node_modules/lru-cache/dist/esm/browser/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/esm/browser/index.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/browser/index.min.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/index.d.ts +2 -2
- package/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/esm/index.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/index.min.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/node/index.d.ts +2 -2
- package/node_modules/lru-cache/dist/esm/node/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/esm/node/index.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/node/index.min.js.map +1 -1
- package/node_modules/lru-cache/package.json +1 -1
- package/node_modules/typebox/build/type/script/mapping.d.mts +5 -2
- package/node_modules/typebox/build/type/script/mapping.mjs +15 -8
- package/node_modules/typebox/build/type/script/parser.d.mts +3 -1
- package/node_modules/typebox/build/type/script/parser.mjs +2 -1
- package/node_modules/typebox/package.json +29 -29
- package/npm-shrinkwrap.json +156 -39
- package/openclaw.plugin.json +76 -0
- package/package.json +6 -6
- package/node_modules/audio-buffer/.eslintrc.json +0 -44
- package/node_modules/audio-buffer/.github/workflows/node.js.yml +0 -31
- package/node_modules/audio-buffer/.travis.yml +0 -7
- package/node_modules/audio-buffer/index.js +0 -76
- package/node_modules/audio-buffer/package.json +0 -37
- package/node_modules/audio-buffer/readme.md +0 -56
- package/node_modules/audio-decode/.eslintrc.json +0 -43
- package/node_modules/audio-decode/.travis.yml +0 -13
- 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.js +0 -107
- package/node_modules/node-wav/README.md +0 -35
- package/node_modules/node-wav/file.wav +0 -0
- package/node_modules/node-wav/index.js +0 -291
- package/node_modules/node-wav/package.json +0 -29
- package/node_modules/node-wav/tests/file1.wav +0 -0
- package/node_modules/node-wav/tests/test.js +0 -66
- package/node_modules/node-wav/x.js +0 -12
- package/node_modules/node-wav/x.json +0 -86702
- package/node_modules/node-wav/x.js~ +0 -13
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@audio/decode-opus",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Decode Ogg Opus audio via libopus WASM — self-contained bundle",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "decode-opus.js",
|
|
7
|
+
"types": "decode-opus.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./decode-opus.js",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"decode-opus.js",
|
|
14
|
+
"decode-opus.d.ts",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "bash build.sh",
|
|
19
|
+
"prepack": "npm run build",
|
|
20
|
+
"test": "node test.js"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"opus",
|
|
24
|
+
"ogg",
|
|
25
|
+
"audio",
|
|
26
|
+
"decode",
|
|
27
|
+
"decoder",
|
|
28
|
+
"wasm"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"author": "audiojs",
|
|
35
|
+
"homepage": "https://github.com/audiojs/audio-decode/tree/main/packages/decode-opus#readme",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/audiojs/audio-decode.git",
|
|
39
|
+
"directory": "packages/decode-opus"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"ogg-opus-decoder": "^1.7.3"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=16"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
This work is offered to Krishna (https://github.com/krishnized/license).
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The MIT License (MIT)
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2025 audiojs
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
20
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
21
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
22
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
23
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
24
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
25
|
+
OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @audio/decode-qoa
|
|
2
|
+
|
|
3
|
+
Decode QOA (Quite OK Audio) to PCM samples. Self-contained bundle — no import map entries needed.
|
|
4
|
+
|
|
5
|
+
Wraps [qoa-format](https://github.com/nicokoenig/qoa-format).
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import decode, { decoder } from '@audio/decode-qoa'
|
|
9
|
+
|
|
10
|
+
// whole-file
|
|
11
|
+
let { channelData, sampleRate } = await decode(qoabuf)
|
|
12
|
+
|
|
13
|
+
// streaming (stateless — each chunk must be a complete QOA file)
|
|
14
|
+
let dec = await decoder()
|
|
15
|
+
let a = dec.decode(chunk)
|
|
16
|
+
dec.free()
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
[MIT](./LICENSE) · [ॐ](https://github.com/krishnized/license/)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface AudioData {
|
|
2
|
+
channelData: Float32Array[];
|
|
3
|
+
sampleRate: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface QoaDecoder {
|
|
7
|
+
decode(data: Uint8Array): AudioData;
|
|
8
|
+
flush(): AudioData;
|
|
9
|
+
free(): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Whole-file QOA decode */
|
|
13
|
+
export default function decode(src: ArrayBuffer | Uint8Array): Promise<AudioData>;
|
|
14
|
+
|
|
15
|
+
/** Create streaming decoder instance */
|
|
16
|
+
export function decoder(): Promise<QoaDecoder>;
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
// ../../node_modules/@thi.ng/errors/deferror.js
|
|
2
|
+
var defError = (prefix, suffix = (msg) => msg !== void 0 ? ": " + msg : "") => class extends Error {
|
|
3
|
+
origMessage;
|
|
4
|
+
constructor(msg) {
|
|
5
|
+
super(prefix(msg) + suffix(msg));
|
|
6
|
+
this.origMessage = msg !== void 0 ? String(msg) : "";
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// ../../node_modules/@thi.ng/errors/illegal-arguments.js
|
|
11
|
+
var IllegalArgumentError = defError(() => "illegal argument(s)");
|
|
12
|
+
var illegalArgs = (msg) => {
|
|
13
|
+
throw new IllegalArgumentError(msg);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// ../../node_modules/@thi.ng/errors/illegal-state.js
|
|
17
|
+
var IllegalStateError = defError(() => "illegal state");
|
|
18
|
+
var illegalState = (msg) => {
|
|
19
|
+
throw new IllegalStateError(msg);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// ../../node_modules/@thi.ng/bitstream/input.js
|
|
23
|
+
var U32 = 4294967296;
|
|
24
|
+
var BitInputStream = class {
|
|
25
|
+
buffer;
|
|
26
|
+
start;
|
|
27
|
+
limit;
|
|
28
|
+
pos;
|
|
29
|
+
bitPos;
|
|
30
|
+
bit;
|
|
31
|
+
constructor(buffer, offset = 0, limit = buffer.length << 3) {
|
|
32
|
+
this.buffer = buffer;
|
|
33
|
+
this.start = offset;
|
|
34
|
+
this.limit = limit;
|
|
35
|
+
this.seek(offset);
|
|
36
|
+
}
|
|
37
|
+
*[Symbol.iterator]() {
|
|
38
|
+
let j = this.start;
|
|
39
|
+
let i = j >>> 3;
|
|
40
|
+
let b = 7 - (j & 7);
|
|
41
|
+
while (j < this.limit) {
|
|
42
|
+
yield this.buffer[i] >>> b & 1;
|
|
43
|
+
if (--b < 0) {
|
|
44
|
+
i++;
|
|
45
|
+
b = 7;
|
|
46
|
+
}
|
|
47
|
+
j++;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
get length() {
|
|
51
|
+
return this.limit;
|
|
52
|
+
}
|
|
53
|
+
get position() {
|
|
54
|
+
return this.bitPos;
|
|
55
|
+
}
|
|
56
|
+
seek(pos) {
|
|
57
|
+
if (pos < this.start || pos >= this.limit) {
|
|
58
|
+
illegalArgs(`seek pos out of bounds: ${pos}`);
|
|
59
|
+
}
|
|
60
|
+
this.pos = pos >>> 3;
|
|
61
|
+
this.bit = 8 - (pos & 7);
|
|
62
|
+
this.bitPos = pos;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
read(wordSize = 1, safe = true) {
|
|
66
|
+
if (wordSize > 32) {
|
|
67
|
+
return this.read(wordSize - 32, safe) * U32 + this.read(32, safe);
|
|
68
|
+
} else if (wordSize > 8) {
|
|
69
|
+
let out = 0;
|
|
70
|
+
let n = wordSize & -8;
|
|
71
|
+
let msb = wordSize - n;
|
|
72
|
+
if (msb > 0) {
|
|
73
|
+
out = this._read(msb, safe);
|
|
74
|
+
}
|
|
75
|
+
while (n > 0) {
|
|
76
|
+
out = (out << 8 | this._read(8, safe)) >>> 0;
|
|
77
|
+
n -= 8;
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
} else {
|
|
81
|
+
return this._read(wordSize, safe);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
readFields(fields, safe = true) {
|
|
85
|
+
return fields.map((word) => this.read(word, safe));
|
|
86
|
+
}
|
|
87
|
+
readWords(n, wordSize = 8, safe = true) {
|
|
88
|
+
let out = [];
|
|
89
|
+
while (n-- > 0) {
|
|
90
|
+
out.push(this.read(wordSize, safe));
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
readStruct(fields, safe = true) {
|
|
95
|
+
return fields.reduce((acc, [id, word]) => {
|
|
96
|
+
return acc[id] = this.read(word, safe), acc;
|
|
97
|
+
}, {});
|
|
98
|
+
}
|
|
99
|
+
readBit(safe = true) {
|
|
100
|
+
safe && this.checkLimit(1);
|
|
101
|
+
this.bit--;
|
|
102
|
+
this.bitPos++;
|
|
103
|
+
let out = this.buffer[this.pos] >>> this.bit & 1;
|
|
104
|
+
if (this.bit === 0) {
|
|
105
|
+
this.pos++;
|
|
106
|
+
this.bit = 8;
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
_read(wordSize, safe = true) {
|
|
111
|
+
safe && this.checkLimit(wordSize);
|
|
112
|
+
let l = this.bit - wordSize, out;
|
|
113
|
+
if (l >= 0) {
|
|
114
|
+
this.bit = l;
|
|
115
|
+
out = this.buffer[this.pos] >>> l & (1 << wordSize) - 1;
|
|
116
|
+
if (l === 0) {
|
|
117
|
+
this.pos++;
|
|
118
|
+
this.bit = 8;
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
out = (this.buffer[this.pos++] & (1 << this.bit) - 1) << -l;
|
|
122
|
+
this.bit = 8 + l;
|
|
123
|
+
out = out | this.buffer[this.pos] >>> this.bit;
|
|
124
|
+
}
|
|
125
|
+
this.bitPos += wordSize;
|
|
126
|
+
return out;
|
|
127
|
+
}
|
|
128
|
+
checkLimit(requested) {
|
|
129
|
+
if (this.bitPos + requested > this.limit) {
|
|
130
|
+
illegalState(`can't read past EOF`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// ../../node_modules/qoa-format/lib/common.js
|
|
136
|
+
var QOA_MIN_FILESIZE = 16;
|
|
137
|
+
var QOA_SLICE_LEN = 20;
|
|
138
|
+
var QOA_SLICES_PER_FRAME = 256;
|
|
139
|
+
var QOA_FRAME_LEN = QOA_SLICES_PER_FRAME * QOA_SLICE_LEN;
|
|
140
|
+
var QOA_LMS_LEN = 4;
|
|
141
|
+
var QOA_MAGIC = 1903124838;
|
|
142
|
+
function qoa_clamp(v, min, max) {
|
|
143
|
+
return v < min ? min : v > max ? max : v;
|
|
144
|
+
}
|
|
145
|
+
function LMS(h, w) {
|
|
146
|
+
const history = new Int16Array(h || 4);
|
|
147
|
+
const weights = new Int16Array(w || 4);
|
|
148
|
+
return { history, weights };
|
|
149
|
+
}
|
|
150
|
+
function qoa_lms_predict(weights, history) {
|
|
151
|
+
return weights[0] * history[0] + weights[1] * history[1] + weights[2] * history[2] + weights[3] * history[3] >> 13;
|
|
152
|
+
}
|
|
153
|
+
function qoa_lms_update(weights, history, sample, residual) {
|
|
154
|
+
let delta = residual >> 4;
|
|
155
|
+
weights[0] += history[0] < 0 ? -delta : delta;
|
|
156
|
+
weights[1] += history[1] < 0 ? -delta : delta;
|
|
157
|
+
weights[2] += history[2] < 0 ? -delta : delta;
|
|
158
|
+
weights[3] += history[3] < 0 ? -delta : delta;
|
|
159
|
+
history[0] = history[1];
|
|
160
|
+
history[1] = history[2];
|
|
161
|
+
history[2] = history[3];
|
|
162
|
+
history[3] = sample;
|
|
163
|
+
}
|
|
164
|
+
var qoa_round = (num) => Math.sign(num) * Math.round(Math.abs(num));
|
|
165
|
+
var qoa_scalefactor_tab = Array(16).fill().map((_, s) => qoa_round(Math.pow(s + 1, 2.75)));
|
|
166
|
+
var dqt = [0.75, -0.75, 2.5, -2.5, 4.5, -4.5, 7, -7];
|
|
167
|
+
var qoa_dequant_tab = qoa_scalefactor_tab.map((sf) => {
|
|
168
|
+
return dqt.map((dq) => qoa_round(dq * sf));
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// ../../node_modules/qoa-format/decode.js
|
|
172
|
+
function decodeHeader(stream) {
|
|
173
|
+
const magic = stream.read(32);
|
|
174
|
+
if (magic !== QOA_MAGIC) {
|
|
175
|
+
throw new Error(`Not a QOA file; expected magic number 'qoaf'`);
|
|
176
|
+
}
|
|
177
|
+
const header = {
|
|
178
|
+
samples: stream.read(32),
|
|
179
|
+
channels: stream.read(8),
|
|
180
|
+
sampleRate: stream.read(24)
|
|
181
|
+
};
|
|
182
|
+
stream.seek(64);
|
|
183
|
+
return header;
|
|
184
|
+
}
|
|
185
|
+
function qoa_decode_frame(stream, audio, lmses, channelData, sampleOffset) {
|
|
186
|
+
const channels = stream.read(8);
|
|
187
|
+
const sampleRate = stream.read(24);
|
|
188
|
+
const samples = stream.read(16);
|
|
189
|
+
const frameSize = stream.read(16);
|
|
190
|
+
const dataSize = Math.floor(frameSize - 8 - QOA_LMS_LEN * 4 * channels);
|
|
191
|
+
const numSlices = Math.floor(dataSize / 8);
|
|
192
|
+
const maxTotalSamples = numSlices * QOA_SLICE_LEN;
|
|
193
|
+
if (channels != audio.channels || sampleRate != audio.sampleRate || samples * channels > maxTotalSamples) {
|
|
194
|
+
throw new Error(`invalid frame header data`);
|
|
195
|
+
}
|
|
196
|
+
for (let c = 0; c < channels; c++) {
|
|
197
|
+
const lms = lmses[c];
|
|
198
|
+
for (let i = 0; i < QOA_LMS_LEN; i++) {
|
|
199
|
+
let h = stream.read(16);
|
|
200
|
+
lms.history[i] = h;
|
|
201
|
+
}
|
|
202
|
+
for (let i = 0; i < QOA_LMS_LEN; i++) {
|
|
203
|
+
let w = stream.read(16);
|
|
204
|
+
lms.weights[i] = w;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
for (let sample_index = 0; sample_index < samples; sample_index += QOA_SLICE_LEN) {
|
|
208
|
+
for (let c = 0; c < channels; c++) {
|
|
209
|
+
const scalefactor = stream.read(4);
|
|
210
|
+
const table = qoa_dequant_tab[scalefactor];
|
|
211
|
+
const slice_start = sample_index;
|
|
212
|
+
const slice_end = Math.min(sample_index + QOA_SLICE_LEN, samples);
|
|
213
|
+
const slice_count = slice_end - slice_start;
|
|
214
|
+
const lms = lmses[c];
|
|
215
|
+
const sampleData = channelData[c];
|
|
216
|
+
let idx = sampleOffset + slice_start;
|
|
217
|
+
const weights = lms.weights;
|
|
218
|
+
const history = lms.history;
|
|
219
|
+
let bitsRemaining = 60;
|
|
220
|
+
for (let i = 0; i < slice_count; i++) {
|
|
221
|
+
const predicted = qoa_lms_predict(weights, history);
|
|
222
|
+
const quantized = stream.read(3);
|
|
223
|
+
const dequantized = table[quantized];
|
|
224
|
+
const reconstructed = qoa_clamp(predicted + dequantized, -32768, 32767);
|
|
225
|
+
const sample = reconstructed < 0 ? reconstructed / 32768 : reconstructed / 32767;
|
|
226
|
+
sampleData[idx++] = sample;
|
|
227
|
+
qoa_lms_update(weights, history, reconstructed, dequantized);
|
|
228
|
+
bitsRemaining -= 3;
|
|
229
|
+
}
|
|
230
|
+
if (bitsRemaining > 0) {
|
|
231
|
+
stream.read(bitsRemaining);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return samples;
|
|
236
|
+
}
|
|
237
|
+
function decode(data) {
|
|
238
|
+
if (data.byteLength < QOA_MIN_FILESIZE) {
|
|
239
|
+
throw new Error(`QOA file size must be >= ${QOA_MIN_FILESIZE}`);
|
|
240
|
+
}
|
|
241
|
+
const stream = new BitInputStream(data);
|
|
242
|
+
const audio = decodeHeader(stream);
|
|
243
|
+
const channelData = [];
|
|
244
|
+
const lmses = [];
|
|
245
|
+
for (let c = 0; c < audio.channels; c++) {
|
|
246
|
+
const d = new Float32Array(audio.samples);
|
|
247
|
+
channelData.push(d);
|
|
248
|
+
lmses.push(LMS());
|
|
249
|
+
}
|
|
250
|
+
let sampleIndex = 0;
|
|
251
|
+
let frameLen = 0;
|
|
252
|
+
do {
|
|
253
|
+
frameLen = qoa_decode_frame(stream, audio, lmses, channelData, sampleIndex);
|
|
254
|
+
sampleIndex += frameLen;
|
|
255
|
+
} while (frameLen && sampleIndex < audio.samples);
|
|
256
|
+
return {
|
|
257
|
+
...audio,
|
|
258
|
+
channelData
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// src/decode-qoa.src.js
|
|
263
|
+
async function decode2(src) {
|
|
264
|
+
let buf = src instanceof Uint8Array ? src : new Uint8Array(src);
|
|
265
|
+
return decode(buf);
|
|
266
|
+
}
|
|
267
|
+
async function decoder() {
|
|
268
|
+
return {
|
|
269
|
+
decode: (chunk) => decode(chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk)),
|
|
270
|
+
flush: () => ({ channelData: [], sampleRate: 0 }),
|
|
271
|
+
free: () => {
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
export {
|
|
276
|
+
decoder,
|
|
277
|
+
decode2 as default
|
|
278
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@audio/decode-qoa",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Decode QOA (Quite OK Audio) — self-contained bundle",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "decode-qoa.js",
|
|
7
|
+
"types": "decode-qoa.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./decode-qoa.js",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"decode-qoa.js",
|
|
14
|
+
"decode-qoa.d.ts",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "bash build.sh",
|
|
19
|
+
"prepack": "npm run build",
|
|
20
|
+
"test": "node test.js"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"qoa",
|
|
24
|
+
"audio",
|
|
25
|
+
"decode",
|
|
26
|
+
"decoder",
|
|
27
|
+
"quite-ok-audio"
|
|
28
|
+
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"author": "audiojs",
|
|
34
|
+
"homepage": "https://github.com/audiojs/audio-decode/tree/main/packages/decode-qoa#readme",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/audiojs/audio-decode.git",
|
|
38
|
+
"directory": "packages/decode-qoa"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"qoa-format": "^1.0.1"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=16"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
This work is offered to Krishna (https://github.com/krishnized/license).
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The MIT License (MIT)
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2025 audiojs
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
20
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
21
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
22
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
23
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
24
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
25
|
+
OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @audio/decode-vorbis
|
|
2
|
+
|
|
3
|
+
Decode Ogg Vorbis audio to PCM samples. Self-contained WASM bundle — no import map entries needed.
|
|
4
|
+
|
|
5
|
+
Wraps [@wasm-audio-decoders/ogg-vorbis](https://github.com/eshaz/wasm-audio-decoders).
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import decode, { decoder } from '@audio/decode-vorbis'
|
|
9
|
+
|
|
10
|
+
// whole-file
|
|
11
|
+
let { channelData, sampleRate } = await decode(oggbuf)
|
|
12
|
+
|
|
13
|
+
// streaming
|
|
14
|
+
let dec = await decoder()
|
|
15
|
+
let a = dec.decode(chunk1)
|
|
16
|
+
let b = dec.decode(chunk2)
|
|
17
|
+
let c = dec.flush()
|
|
18
|
+
dec.free()
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## License
|
|
22
|
+
|
|
23
|
+
[MIT](./LICENSE) · [ॐ](https://github.com/krishnized/license/)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface AudioData {
|
|
2
|
+
channelData: Float32Array[];
|
|
3
|
+
sampleRate: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface VorbisDecoder {
|
|
7
|
+
decode(data: Uint8Array): AudioData;
|
|
8
|
+
flush(): AudioData;
|
|
9
|
+
free(): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Whole-file Ogg Vorbis decode */
|
|
13
|
+
export default function decode(src: ArrayBuffer | Uint8Array): Promise<AudioData>;
|
|
14
|
+
|
|
15
|
+
/** Create streaming decoder instance */
|
|
16
|
+
export function decoder(): Promise<VorbisDecoder>;
|