@vindral/web-sdk 4.8.2-2-g17ce1f28 → 4.8.2-21-g813526bf1

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,8 +1,7 @@
1
- import { n as e, t } from "./BsfwXDui.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
- //#region ../../libs/wasm-decoders/src/opus/wasm/opus.js
1
+ import { F as e, P as t } from "./ClL-QhcZ.js";
2
+ import { n, t as r } from "./DvtbAkGW.js";
3
+ import { l as i } from "./BeCY4GvT.js";
4
+ // ../../libs/wasm-decoders/src/opus/wasm/opus.js
6
5
  var a = (function() {
7
6
  var e = typeof document < "u" && document.currentScript ? document.currentScript.src : void 0;
8
7
  return (function(t) {
@@ -205,35 +204,34 @@ var a = (function() {
205
204
  });
206
205
  })(), o, s = /* @__PURE__ */ function(e) {
207
206
  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
- }(s || {}), c = class t {
209
- constructor(n, r, i) {
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", () => {
207
+ }(s || {}), c = class e {
208
+ constructor(t, r, i) {
209
+ n(this, "opusModule", void 0), n(this, "decoderInstance", void 0), n(this, "opusBufferPointer", void 0), n(this, "pcmBufferPointer", void 0), n(this, "channels", void 0), n(this, "pcmBufferByteSize", () => e.MAX_SAMPLES * this.channels * Float32Array.BYTES_PER_ELEMENT), n(this, "unload", () => {
211
210
  this.opusModule._free(this.opusBufferPointer), this.opusModule._free(this.pcmBufferPointer), this.opusModule._opus_decoder_destroy(this.decoderInstance);
212
- }), e(this, "decode", (e) => {
213
- if (e.byteLength > t.MAX_OPUS_BUFFER) throw Error(`Opus packet too large (${e.byteLength} bytes), max ${t.MAX_OPUS_BUFFER} bytes`);
214
- this.opusModule.HEAPU8.set(e, this.opusBufferPointer);
215
- let n = this.opusModule._opus_decode_float(this.decoderInstance, this.opusBufferPointer, e.byteLength, this.pcmBufferPointer, t.MAX_SAMPLES, 0);
211
+ }), n(this, "decode", (t) => {
212
+ if (t.byteLength > e.MAX_OPUS_BUFFER) throw Error(`Opus packet too large (${t.byteLength} bytes), max ${e.MAX_OPUS_BUFFER} bytes`);
213
+ this.opusModule.HEAPU8.set(t, this.opusBufferPointer);
214
+ let n = this.opusModule._opus_decode_float(this.decoderInstance, this.opusBufferPointer, t.byteLength, this.pcmBufferPointer, e.MAX_SAMPLES, 0);
216
215
  if (n < 0) throw Error(`${s[n]} (${n})`);
217
216
  let r = this.pcmBufferPointer / Float32Array.BYTES_PER_ELEMENT;
218
217
  return this.opusModule.HEAPF32.subarray(r, r + n * this.channels);
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());
218
+ }), this.opusModule = t, this.channels = i, this.decoderInstance = this.opusModule._opus_decoder_create(r, i, 0), this.opusBufferPointer = this.opusModule._malloc(e.MAX_OPUS_BUFFER), this.pcmBufferPointer = this.opusModule._malloc(this.pcmBufferByteSize());
220
219
  }
221
220
  };
222
- o = c, e(c, "MAX_OPUS_BUFFER", 16384), e(c, "MAX_SAMPLES", 6 * 960), e(c, "create", function() {
223
- var e = t(function* (e, t) {
221
+ o = c, n(c, "MAX_OPUS_BUFFER", 16384), n(c, "MAX_SAMPLES", 5760), n(c, "create", function() {
222
+ var e = r(function* (e, t) {
224
223
  return new o(yield a(), e, t);
225
224
  });
226
225
  return function(t, n) {
227
226
  return e.apply(this, arguments);
228
227
  };
229
228
  }());
230
- //#endregion
231
- //#region ../../libs/web-sdk/src/decoders/OpusDecoderContext.ts
229
+ // ../../libs/web-sdk/src/decoders/OpusDecoderContext.ts
232
230
  var l, u = class {
233
- constructor(t) {
234
- e(this, "decodedSamples", []), e(this, "decoder", void 0), e(this, "errors", new r(10)), e(this, "unload", () => {
231
+ constructor(r) {
232
+ n(this, "decodedSamples", []), n(this, "decoder", void 0), n(this, "errors", new t(10)), n(this, "unload", () => {
235
233
  this.decoder.unload();
236
- }), e(this, "enqueue", (e) => {
234
+ }), n(this, "enqueue", (e) => {
237
235
  try {
238
236
  let t = performance.now(), n = this.decoder.decode(new Uint8Array(e.data));
239
237
  this.decodedSamples.push(i(i({}, e), {}, {
@@ -250,19 +248,18 @@ var l, u = class {
250
248
  } catch (e) {
251
249
  e instanceof Error && this.errors.push(e);
252
250
  }
253
- }), e(this, "initSegment", n), e(this, "take", () => this.decodedSamples.shift()), this.decoder = t;
251
+ }), n(this, "initSegment", e), n(this, "take", () => this.decodedSamples.shift()), this.decoder = r;
254
252
  }
255
253
  error() {
256
254
  return this.errors.pop();
257
255
  }
258
256
  };
259
- l = u, e(u, "create", function() {
260
- var e = t(function* (e, t) {
257
+ l = u, n(u, "create", function() {
258
+ var e = r(function* (e, t) {
261
259
  return new l(yield c.create(e, t));
262
260
  });
263
261
  return function(t, n) {
264
262
  return e.apply(this, arguments);
265
263
  };
266
264
  }());
267
- //#endregion
268
265
  export { u as OpusDecoderContext };
@@ -1,8 +1,7 @@
1
- import { n as e, t } from "./BsfwXDui.js";
2
- import { t as n } from "./DrWNJwZx.js";
3
- import { i as r, n as i, t as a } from "./BdMchGeH.js";
4
- import { t as o } from "./D1kpe8tT.js";
5
- //#region ../../libs/web-sdk/src/decoders/WebCodecsAudioDecoderContext.ts
1
+ import { P as e, i as t, n, r } from "./ClL-QhcZ.js";
2
+ import { n as i, t as a } from "./DvtbAkGW.js";
3
+ import { l as o } from "./BeCY4GvT.js";
4
+ // ../../libs/web-sdk/src/decoders/WebCodecsAudioDecoderContext.ts
6
5
  var s, c = globalThis, l = (e) => {
7
6
  var t, n;
8
7
  if (!e) return {
@@ -22,11 +21,11 @@ var s, c = globalThis, l = (e) => {
22
21
  }, u = class {
23
22
  constructor(s) {
24
23
  var c = this;
25
- e(this, "decodedSamples", []), e(this, "decoder", null), e(this, "logger", void 0), e(this, "initSegments", /* @__PURE__ */ new Map()), e(this, "previousSample", void 0), e(this, "previousCodec", void 0), e(this, "pendingSamples", new n(Infinity)), e(this, "priming", { remaining: 0 }), e(this, "sentCount", 0), e(this, "doneCount", 0), e(this, "errors", new n(10)), e(this, "resetDecoderState", () => {
24
+ i(this, "decodedSamples", []), i(this, "decoder", null), i(this, "logger", void 0), i(this, "initSegments", /* @__PURE__ */ new Map()), i(this, "previousSample", void 0), i(this, "previousCodec", void 0), i(this, "pendingSamples", new e(Infinity)), i(this, "priming", { remaining: 0 }), i(this, "sentCount", 0), i(this, "doneCount", 0), i(this, "errors", new e(10)), i(this, "resetDecoderState", () => {
26
25
  this.pendingSamples.clear(), this.doneCount = this.sentCount, this.previousSample = void 0, this.previousCodec = void 0;
27
- }), e(this, "dropUndecoded", (e) => {
26
+ }), i(this, "dropUndecoded", (e) => {
28
27
  for (; this.doneCount < e && this.pendingSamples.pop();) this.doneCount++;
29
- }), e(this, "ensureDecoder", () => ((!this.decoder || this.decoder.state === "closed") && (this.decoder = this.createDecoder()), this.decoder)), e(this, "createDecoder", () => new AudioDecoder({
28
+ }), i(this, "ensureDecoder", () => (this.decoder && this.decoder.state !== "closed" || (this.decoder = this.createDecoder()), this.decoder)), i(this, "createDecoder", () => new AudioDecoder({
30
29
  output: (e) => {
31
30
  let t = this.pendingSamples.pop();
32
31
  if (!t) {
@@ -67,18 +66,18 @@ var s, c = globalThis, l = (e) => {
67
66
  error: (e) => {
68
67
  this.logger.error("Decoder error:", e.name, e.message), this.resetDecoderState(), this.errors.push(e);
69
68
  }
70
- })), e(this, "buildCodecString", a), e(this, "getDescription", (e, t) => {
71
- let n = this.initSegments.get(t.renditionId);
72
- if (n && n.data.byteLength > 0 && n.codec === e) return n.data;
73
- if (e === "opus") return i(t.channels, t.sampleRate);
74
- if (e === "aac") return r(t.channels, t.sampleRate);
75
- }), e(this, "reset", () => {
69
+ })), i(this, "buildCodecString", n), i(this, "getDescription", (e, n) => {
70
+ let i = this.initSegments.get(n.renditionId);
71
+ if (i && i.data.byteLength > 0 && i.codec === e) return i.data;
72
+ if (e === "opus") return r(n.channels, n.sampleRate);
73
+ if (e === "aac") return t(n.channels, n.sampleRate);
74
+ }), i(this, "reset", () => {
76
75
  this.decodedSamples = [], this.decoder && this.decoder.state !== "closed" && this.decoder.reset(), this.resetDecoderState();
77
- }), e(this, "unload", () => {
76
+ }), i(this, "unload", () => {
78
77
  this.reset(), this.decoder && this.decoder.state !== "closed" && this.decoder.close(), this.decoder = null;
79
- }), e(this, "initSegment", (e) => {
78
+ }), i(this, "initSegment", (e) => {
80
79
  this.initSegments.set(e.renditionId, e);
81
- }), e(this, "enqueue", (e) => {
80
+ }), i(this, "enqueue", (e) => {
82
81
  var t, n;
83
82
  let r = this.ensureDecoder(), i = e.codec, a = ((t = this.previousSample) == null ? void 0 : t.channelId) !== e.channelId, o = ((n = this.previousSample) == null ? void 0 : n.renditionId) !== e.renditionId, s = this.previousCodec !== i;
84
83
  if (!this.previousSample || a || o || s) {
@@ -131,18 +130,18 @@ var s, c = globalThis, l = (e) => {
131
130
  } catch (e) {
132
131
  this.logger.error("Failed to decode chunk:", e), this.pendingSamples.popLast(), this.sentCount--, r.state === "closed" && (this.resetDecoderState(), this.ensureDecoder());
133
132
  }
134
- }), e(this, "flush", t(function* () {
133
+ }), i(this, "flush", a(function* () {
135
134
  if (c.decoder && c.decoder.state === "configured") try {
136
135
  let e = c.sentCount;
137
136
  yield c.decoder.flush(), c.dropUndecoded(e);
138
137
  } catch (e) {
139
138
  c.logger.error("Failed to flush decoder:", e), c.resetDecoderState();
140
139
  }
141
- })), e(this, "error", () => this.errors.pop()), e(this, "take", () => this.decodedSamples.shift()), this.logger = s, this.decoder = this.createDecoder();
140
+ })), i(this, "error", () => this.errors.pop()), i(this, "take", () => this.decodedSamples.shift()), this.logger = s, this.decoder = this.createDecoder();
142
141
  }
143
142
  };
144
- s = u, e(u, "isSupported", () => c.AudioDecoder !== void 0), e(u, "create", function() {
145
- var e = t(function* (e) {
143
+ s = u, i(u, "isSupported", () => c.AudioDecoder !== void 0), i(u, "create", function() {
144
+ var e = a(function* (e) {
146
145
  if (!s.isSupported()) throw Error("WebCodecs AudioDecoder is not supported in this environment");
147
146
  return new s(e);
148
147
  });
@@ -150,5 +149,4 @@ s = u, e(u, "isSupported", () => c.AudioDecoder !== void 0), e(u, "create", func
150
149
  return e.apply(this, arguments);
151
150
  };
152
151
  }());
153
- //#endregion
154
152
  export { u as WebCodecsAudioDecoderContext };