@vindral/web-sdk 4.6.0 → 4.7.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.
@@ -1,9 +1,9 @@
1
1
  import { n as e, t } from "./BsfwXDui.js";
2
- import { F as n, x as r } from "./BBVSf5AB.js";
3
- import { t as i } from "./DrWNJwZx.js";
4
- import { t as a } from "./BKeRxR4O.js";
2
+ import { t as n } from "./CuYn2z5X.js";
3
+ import { t as r } from "./DrWNJwZx.js";
4
+ import { t as i } from "./D1kpe8tT.js";
5
5
  //#region ../../libs/wasm-decoders/src/opus/wasm/opus.js
6
- var o = (function() {
6
+ var a = (function() {
7
7
  var e = typeof document < "u" && document.currentScript ? document.currentScript.src : void 0;
8
8
  return (function(t) {
9
9
  t = t || {};
@@ -203,9 +203,9 @@ var o = (function() {
203
203
  if (n.run = F, n.preInit) for (typeof n.preInit == "function" && (n.preInit = [n.preInit]); 0 < n.preInit.length;) n.preInit.pop()();
204
204
  return F(), t.ready;
205
205
  });
206
- })(), s, c = /* @__PURE__ */ function(e) {
206
+ })(), o, s = /* @__PURE__ */ function(e) {
207
207
  return e[e.OK = 0] = "OK", e[e["Bad argument"] = -1] = "Bad argument", e[e["Buffer too small"] = -2] = "Buffer too small", e[e["Internal error"] = -3] = "Internal error", e[e["Invalid packet"] = -4] = "Invalid packet", e[e.Unimplemented = -5] = "Unimplemented", e[e["Invalid state"] = -6] = "Invalid state", e[e["Memory allocation fail"] = -7] = "Memory allocation fail", e;
208
- }(c || {}), l = class t {
208
+ }(s || {}), c = class t {
209
209
  constructor(n, r, i) {
210
210
  e(this, "opusModule", void 0), e(this, "decoderInstance", void 0), e(this, "opusBufferPointer", void 0), e(this, "pcmBufferPointer", void 0), e(this, "channels", void 0), e(this, "pcmBufferByteSize", () => t.MAX_SAMPLES * this.channels * Float32Array.BYTES_PER_ELEMENT), e(this, "unload", () => {
211
211
  this.opusModule._free(this.opusBufferPointer), this.opusModule._free(this.pcmBufferPointer), this.opusModule._opus_decoder_destroy(this.decoderInstance);
@@ -213,15 +213,15 @@ var o = (function() {
213
213
  if (e.byteLength > t.MAX_OPUS_BUFFER) throw Error(`Opus packet too large (${e.byteLength} bytes), max ${t.MAX_OPUS_BUFFER} bytes`);
214
214
  this.opusModule.HEAPU8.set(e, this.opusBufferPointer);
215
215
  let n = this.opusModule._opus_decode_float(this.decoderInstance, this.opusBufferPointer, e.byteLength, this.pcmBufferPointer, t.MAX_SAMPLES, 0);
216
- if (n < 0) throw Error(`${c[n]} (${n})`);
216
+ if (n < 0) throw Error(`${s[n]} (${n})`);
217
217
  let r = this.pcmBufferPointer / Float32Array.BYTES_PER_ELEMENT;
218
218
  return this.opusModule.HEAPF32.subarray(r, r + n * this.channels);
219
219
  }), this.opusModule = n, this.channels = i, this.decoderInstance = this.opusModule._opus_decoder_create(r, i, 0), this.opusBufferPointer = this.opusModule._malloc(t.MAX_OPUS_BUFFER), this.pcmBufferPointer = this.opusModule._malloc(this.pcmBufferByteSize());
220
220
  }
221
221
  };
222
- s = l, e(l, "MAX_OPUS_BUFFER", 16384), e(l, "MAX_SAMPLES", 6 * 960), e(l, "create", function() {
222
+ o = c, e(c, "MAX_OPUS_BUFFER", 16384), e(c, "MAX_SAMPLES", 6 * 960), e(c, "create", function() {
223
223
  var e = t(function* (e, t) {
224
- return new s(yield o(), e, t);
224
+ return new o(yield a(), e, t);
225
225
  });
226
226
  return function(t, n) {
227
227
  return e.apply(this, arguments);
@@ -229,14 +229,14 @@ s = l, e(l, "MAX_OPUS_BUFFER", 16384), e(l, "MAX_SAMPLES", 6 * 960), e(l, "creat
229
229
  }());
230
230
  //#endregion
231
231
  //#region ../../libs/web-sdk/src/decoders/OpusDecoderContext.ts
232
- var u, d = class {
232
+ var l, u = class {
233
233
  constructor(t) {
234
- e(this, "decodedSamples", []), e(this, "decoder", void 0), e(this, "errors", new i(10)), e(this, "unload", () => {
234
+ e(this, "decodedSamples", []), e(this, "decoder", void 0), e(this, "errors", new r(10)), e(this, "unload", () => {
235
235
  this.decoder.unload();
236
236
  }), e(this, "enqueue", (e) => {
237
237
  try {
238
238
  let t = performance.now(), n = this.decoder.decode(new Uint8Array(e.data));
239
- this.decodedSamples.push(a(a({}, e), {}, {
239
+ this.decodedSamples.push(i(i({}, e), {}, {
240
240
  type: "audio",
241
241
  format: "f32",
242
242
  data: n,
@@ -248,7 +248,7 @@ var u, d = class {
248
248
  }
249
249
  }));
250
250
  } catch (e) {
251
- e instanceof Error && this.errors.push(r(!1, e));
251
+ e instanceof Error && this.errors.push(e);
252
252
  }
253
253
  }), e(this, "initSegment", n), e(this, "take", () => this.decodedSamples.shift()), this.decoder = t;
254
254
  }
@@ -256,13 +256,13 @@ var u, d = class {
256
256
  return this.errors.pop();
257
257
  }
258
258
  };
259
- u = d, e(d, "create", function() {
259
+ l = u, e(u, "create", function() {
260
260
  var e = t(function* (e, t) {
261
- return new u(yield l.create(e, t));
261
+ return new l(yield c.create(e, t));
262
262
  });
263
263
  return function(t, n) {
264
264
  return e.apply(this, arguments);
265
265
  };
266
266
  }());
267
267
  //#endregion
268
- export { d as OpusDecoderContext };
268
+ export { u as OpusDecoderContext };
package/BdMchGeH.js ADDED
@@ -0,0 +1,169 @@
1
+ import { n as e } from "./BsfwXDui.js";
2
+ import { i as t, n, t as r } from "./DSw1XhvD.js";
3
+ //#region ../../libs/utils/src/BitReader.ts
4
+ var i = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), s = class {
5
+ constructor(s, c = 0) {
6
+ t(this, i, void 0), t(this, a, void 0), t(this, o, void 0), e(this, "position", () => r(o, this)), e(this, "peekBit", () => this.getBit(r(a, this), r(o, this))), e(this, "readBit", () => {
7
+ var e;
8
+ let t = this.peekBit();
9
+ return n(o, this, (e = r(o, this), e++, e)), t;
10
+ }), e(this, "readBits", (e) => {
11
+ let t = 0;
12
+ for (let c = 0; c < e; c++) {
13
+ var i, s;
14
+ t = t << 1 | (this.getBit(r(a, this), (n(o, this, (i = r(o, this), s = i++, i)), s)) ? 1 : 0);
15
+ }
16
+ return t;
17
+ }), e(this, "remainingBits", () => r(a, this).byteLength * 8 - r(o, this)), e(this, "readSignedExpGolomb", () => {
18
+ let e = this.readUnsignedExpGolomb();
19
+ return e & 1 ? (e + 1) / 2 : -(e / 2);
20
+ }), e(this, "readUnsignedExpGolomb", () => {
21
+ var e, t;
22
+ let i = 0;
23
+ for (; this.getBit(r(a, this), (n(o, this, (e = r(o, this), t = e++, e)), t)) === 0;) i++;
24
+ let s = 1 << i;
25
+ for (let e = i - 1; e >= 0; e--) {
26
+ var c, l;
27
+ s |= this.getBit(r(a, this), (n(o, this, (c = r(o, this), l = c++, c)), l)) << e;
28
+ }
29
+ return s - 1;
30
+ }), e(this, "getBit", (e, t) => {
31
+ if (e.byteLength * 8 <= t) throw Error("BitReader: Out of bounds");
32
+ return e[t >> 3] >> 7 - (t & 7) & 1;
33
+ }), n(i, this, s), n(a, this, new Uint8Array(r(i, this))), n(o, this, c);
34
+ }
35
+ bytes() {
36
+ return r(a, this);
37
+ }
38
+ }, c = [
39
+ 96e3,
40
+ 88200,
41
+ 64e3,
42
+ 48e3,
43
+ 44100,
44
+ 32e3,
45
+ 24e3,
46
+ 22050,
47
+ 16e3,
48
+ 12e3,
49
+ 11025,
50
+ 8e3,
51
+ 7350
52
+ ], l = (e, t) => {
53
+ let n = c.indexOf(t);
54
+ if (n === -1 || e < 1 || e > 8 || e === 7) return;
55
+ let r = /* @__PURE__ */ new ArrayBuffer(2), i = new Uint8Array(r), a = e === 8 ? 7 : e;
56
+ return i[0] = 16 | n >> 1, i[1] = (n & 1) << 7 | a << 3, r;
57
+ }, u = [
58
+ void 0,
59
+ 1,
60
+ 2,
61
+ 3,
62
+ 4,
63
+ 5,
64
+ 6,
65
+ 8,
66
+ void 0,
67
+ void 0,
68
+ void 0,
69
+ 7,
70
+ 8,
71
+ 24,
72
+ 8
73
+ ], d = 5, f = 29, p = new Set([
74
+ 1,
75
+ 2,
76
+ 3,
77
+ 4
78
+ ]), m = 695, h = 1352, g = (e) => {
79
+ let t = new s(e.slice().buffer), n = (e) => t.remainingBits() >= e, r = () => {
80
+ if (!n(5)) return;
81
+ let e = t.readBits(5);
82
+ return e === 31 ? n(6) ? 32 + t.readBits(6) : void 0 : e;
83
+ }, i = () => {
84
+ if (!n(4)) return;
85
+ let e = t.readBits(4);
86
+ return e === 15 ? n(24) ? t.readBits(24) : void 0 : c[e];
87
+ }, a = r(), o = i();
88
+ if (!a || !o || !n(4)) return;
89
+ let l = t.readBits(4), g = u[l];
90
+ if (a !== d && a !== f) {
91
+ if (!p.has(a) || l === 0 || !n(2)) return {
92
+ sampleRate: o,
93
+ channelCount: g
94
+ };
95
+ if (t.readBits(1), t.readBits(1) === 1) {
96
+ if (!n(14)) return {
97
+ sampleRate: o,
98
+ channelCount: g
99
+ };
100
+ t.readBits(14);
101
+ }
102
+ if (!n(1)) return {
103
+ sampleRate: o,
104
+ channelCount: g
105
+ };
106
+ if (t.readBits(1) === 1) {
107
+ if (!n(1)) return {
108
+ sampleRate: o,
109
+ channelCount: g
110
+ };
111
+ t.readBits(1);
112
+ }
113
+ if (!n(16) || t.readBits(11) !== m || r() !== d || !n(1) || t.readBits(1) === 0) return {
114
+ sampleRate: o,
115
+ channelCount: g
116
+ };
117
+ let e = i();
118
+ return e ? {
119
+ sampleRate: e,
120
+ channelCount: n(12) && t.readBits(11) === h && t.readBits(1) === 1 && g === 1 ? 2 : g
121
+ } : {
122
+ sampleRate: o,
123
+ channelCount: g
124
+ };
125
+ }
126
+ let _ = i();
127
+ if (!(!_ || r() === void 0)) return a === f && g === 1 && (g = 2), {
128
+ sampleRate: _,
129
+ channelCount: g
130
+ };
131
+ }, _ = (e) => {
132
+ if (!e) return;
133
+ let t = e.channelMappingTable, n = new Uint8Array(19 + t.byteLength), r = new DataView(n.buffer, n.byteOffset, n.byteLength);
134
+ return n.set([
135
+ 79,
136
+ 112,
137
+ 117,
138
+ 115,
139
+ 72,
140
+ 101,
141
+ 97,
142
+ 100
143
+ ], 0), r.setUint8(8, 1), r.setUint8(9, e.channelCount), r.setUint16(10, e.preSkip, !0), r.setUint32(12, e.inputSampleRate, !0), r.setInt16(16, e.outputGain, !0), r.setUint8(18, e.channelMappingFamily), t.byteLength > 0 && n.set(t, 19), n;
144
+ }, v = (e, t) => {
145
+ if (e < 1 || e > 2) return;
146
+ let n = new Uint8Array(19), r = new DataView(n.buffer, n.byteOffset, n.byteLength);
147
+ return n.set([
148
+ 79,
149
+ 112,
150
+ 117,
151
+ 115,
152
+ 72,
153
+ 101,
154
+ 97,
155
+ 100
156
+ ]), r.setUint8(8, 1), r.setUint8(9, e), r.setUint16(10, 3840, !0), r.setUint32(12, t, !0), r.setInt16(16, 0, !0), r.setUint8(18, 0), n;
157
+ }, y = (e) => {
158
+ switch (e) {
159
+ case "opus": return "opus";
160
+ case "aac": return "mp4a.40.2";
161
+ case "mp3": return "mp3";
162
+ default: {
163
+ let t = e;
164
+ throw Error(`Unsupported audio codec: ${t}`);
165
+ }
166
+ }
167
+ };
168
+ //#endregion
169
+ export { g as a, l as i, v as n, s as o, _ as r, y as t };