@ikonai/sdk 0.0.40 → 0.0.42

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,13 +1,13 @@
1
- function S(e, t, r, n, i) {
2
- const s = i?.trackId ?? 0, a = i?.sequenceId ?? 0, c = i?.flags ?? 0, l = i?.targetIds ?? [], h = i?.payloadType ?? 8, I = 27 + l.length * 4, E = I + t.length, y = new Uint8Array(E), u = new DataView(y.buffer);
3
- u.setUint32(0, E, !0), u.setUint32(4, e >>> 0, !0), u.setUint32(8, n >>> 0, !0), u.setUint32(12, s >>> 0, !0), u.setUint32(16, a >>> 0, !0), u.setUint32(20, l.length >>> 0, !0), u.setUint8(24, r & 255), u.setUint8(25, h & 255), u.setUint8(26, c & 255);
4
- let U = 27;
5
- for (let _ = 0; _ < l.length; _++)
6
- u.setUint32(U, l[_] >>> 0, !0), U += 4;
1
+ function B(e, t, r, n, i) {
2
+ const s = i?.trackId ?? 0, a = i?.sequenceId ?? 0, c = i?.flags ?? 0, l = i?.targetIds ?? [], h = i?.payloadType ?? 8, I = 27 + l.length * 4, g = I + t.length, y = new Uint8Array(g), u = new DataView(y.buffer);
3
+ u.setUint32(0, g, !0), u.setUint32(4, e >>> 0, !0), u.setUint32(8, n >>> 0, !0), u.setUint32(12, s >>> 0, !0), u.setUint32(16, a >>> 0, !0), u.setUint32(20, l.length >>> 0, !0), u.setUint8(24, r & 255), u.setUint8(25, h & 255), u.setUint8(26, c & 255);
4
+ let k = 27;
5
+ for (let D = 0; D < l.length; D++)
6
+ u.setUint32(k, l[D] >>> 0, !0), k += 4;
7
7
  return y.set(t, I), y;
8
8
  }
9
9
  var w = /* @__PURE__ */ ((e) => (e[e.Null = 1] = "Null", e[e.Bool = 2] = "Bool", e[e.Int32 = 3] = "Int32", e[e.Int64 = 4] = "Int64", e[e.UInt32 = 5] = "UInt32", e[e.UInt64 = 6] = "UInt64", e[e.Float32 = 7] = "Float32", e[e.Float64 = 8] = "Float64", e[e.Array = 9] = "Array", e[e.Dict = 10] = "Dict", e[e.Object = 11] = "Object", e[e.String = 12] = "String", e[e.Binary = 13] = "Binary", e[e.Guid = 14] = "Guid", e))(w || {});
10
- const $ = 161, j = 162, F = new TextEncoder();
10
+ const $ = 161, j = 162, A = new TextEncoder();
11
11
  new TextDecoder("utf-8", { fatal: !0 });
12
12
  class p {
13
13
  constructor(t = 1) {
@@ -44,7 +44,7 @@ class p {
44
44
  this.writeFixedField(t, 14, () => this.buffer.writeBytes(n));
45
45
  }
46
46
  writeStringField(t, r) {
47
- const n = F.encode(r ?? "");
47
+ const n = A.encode(r ?? "");
48
48
  this.writeVariableField(t, 12, n);
49
49
  }
50
50
  writeBinaryField(t, r) {
@@ -63,7 +63,7 @@ class p {
63
63
  this.writeVariableField(t, 9, s);
64
64
  }
65
65
  writeDictionaryField(t, r, n, i) {
66
- const s = new R(r, n);
66
+ const s = new M(r, n);
67
67
  i(s);
68
68
  const a = s.finish();
69
69
  this.writeVariableField(t, 10, a);
@@ -78,7 +78,7 @@ class p {
78
78
  this.writeFieldHeader(t, r, n.length), this.buffer.writeBytes(n);
79
79
  }
80
80
  writeFieldHeader(t, r, n) {
81
- this.buffer.writeUInt32(t >>> 0), this.buffer.writeByte(B(r)), q(r) && this.buffer.writeVarUInt(n >>> 0);
81
+ this.buffer.writeUInt32(t >>> 0), this.buffer.writeByte(F(r)), q(r) && this.buffer.writeVarUInt(n >>> 0);
82
82
  }
83
83
  }
84
84
  class O {
@@ -144,7 +144,7 @@ class O {
144
144
  12
145
145
  /* String */
146
146
  ), this.count++;
147
- const r = F.encode(t ?? "");
147
+ const r = A.encode(t ?? "");
148
148
  this.payload.writeVarUInt(r.length), this.payload.writeBytes(r);
149
149
  }
150
150
  writeBinary(t) {
@@ -178,21 +178,21 @@ class O {
178
178
  10
179
179
  /* Dict */
180
180
  ), this.count++;
181
- const i = new R(t, r);
181
+ const i = new M(t, r);
182
182
  n(i);
183
183
  const s = i.finish();
184
184
  this.payload.writeBytes(s);
185
185
  }
186
186
  finish() {
187
187
  const t = new b();
188
- return t.writeByte(B(this.elementType)), t.writeVarUInt(this.count), t.writeBytes(this.payload.toUint8Array()), t.toUint8Array();
188
+ return t.writeByte(F(this.elementType)), t.writeVarUInt(this.count), t.writeBytes(this.payload.toUint8Array()), t.toUint8Array();
189
189
  }
190
190
  ensureElementType(t) {
191
191
  if (this.elementType !== t)
192
192
  throw new Error(`Array element type is ${w[this.elementType]}, expected ${w[t]}`);
193
193
  }
194
194
  }
195
- class R {
195
+ class M {
196
196
  constructor(t, r) {
197
197
  this.keyType = t, this.valueType = r, G(t);
198
198
  }
@@ -210,7 +210,7 @@ class R {
210
210
  if (this.entryOpen)
211
211
  throw new Error("Dictionary entry not completed");
212
212
  const t = new b();
213
- return t.writeByte(B(this.keyType)), t.writeByte(B(this.valueType)), t.writeVarUInt(this.count), t.writeBytes(this.payload.toUint8Array()), t.toUint8Array();
213
+ return t.writeByte(F(this.keyType)), t.writeByte(F(this.valueType)), t.writeVarUInt(this.count), t.writeBytes(this.payload.toUint8Array()), t.toUint8Array();
214
214
  }
215
215
  }
216
216
  class Y {
@@ -277,7 +277,7 @@ class Y {
277
277
  12
278
278
  /* String */
279
279
  );
280
- const r = F.encode(t ?? "");
280
+ const r = A.encode(t ?? "");
281
281
  this.payload.writeVarUInt(r.length), this.payload.writeBytes(r), this.keyWritten = !0;
282
282
  }
283
283
  writeKeyBinary(t) {
@@ -355,7 +355,7 @@ class Y {
355
355
  12
356
356
  /* String */
357
357
  );
358
- const r = F.encode(t ?? "");
358
+ const r = A.encode(t ?? "");
359
359
  this.payload.writeVarUInt(r.length), this.payload.writeBytes(r), this.valueWritten = !0;
360
360
  }
361
361
  writeValueObject(t, r) {
@@ -383,7 +383,7 @@ class Y {
383
383
  10
384
384
  /* Dict */
385
385
  );
386
- const i = new R(t, r);
386
+ const i = new M(t, r);
387
387
  n(i);
388
388
  const s = i.finish();
389
389
  this.payload.writeBytes(s), this.valueWritten = !0;
@@ -443,8 +443,8 @@ class o {
443
443
  o.toHex(o.readUInt32LE(t, 0), 8),
444
444
  o.toHex(o.readUInt16LE(t, 4), 4),
445
445
  o.toHex(o.readUInt16LE(t, 6), 4),
446
- k(t.subarray(8, 10)),
447
- k(t.subarray(10, 16))
446
+ C(t.subarray(8, 10)),
447
+ C(t.subarray(10, 16))
448
448
  ].join("-");
449
449
  }
450
450
  asBytes() {
@@ -515,7 +515,7 @@ class b {
515
515
  return Uint8Array.from(this.bytes);
516
516
  }
517
517
  }
518
- function B(e, t = 0) {
518
+ function F(e, t = 0) {
519
519
  if ((t & 240) !== 0)
520
520
  throw new Error("Teleport flags must fit into 4 bits");
521
521
  return (e & 15) << 4 | t & 15;
@@ -527,11 +527,11 @@ function G(e) {
527
527
  if (e === 9 || e === 11 || e === 10 || e === 1)
528
528
  throw new Error("Dictionary keys must be primitive Teleport types");
529
529
  }
530
- function k(e) {
530
+ function C(e) {
531
531
  return Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
532
532
  }
533
- var V = /* @__PURE__ */ ((e) => (e[e.Unknown = 0] = "Unknown", e[e.Opus = 1] = "Opus", e[e.Mp3 = 2] = "Mp3", e[e.RawPcm16 = 3] = "RawPcm16", e))(V || {});
534
- const C = 1, J = 4194307, X = 271275304, Z = 668699606, Q = 945580544, tt = 1594075008, et = 2079085407, rt = 2541432218, nt = 2986785889, it = 3105403172, st = 4017217601;
533
+ var R = /* @__PURE__ */ ((e) => (e[e.Unknown = 0] = "Unknown", e[e.Opus = 1] = "Opus", e[e.Mp3 = 2] = "Mp3", e[e.RawPcm16 = 3] = "RawPcm16", e))(R || {});
534
+ const x = 1, J = 4194307, X = 271275304, Z = 668699606, Q = 945580544, tt = 1594075008, et = 2079085407, rt = 2541432218, nt = 2986785889, it = 3105403172, st = 4017217601;
535
535
  function at(e) {
536
536
  const t = {};
537
537
  return ot(t), e && Object.assign(t, e), t;
@@ -540,7 +540,7 @@ function ot(e) {
540
540
  return e.Data = new Uint8Array(0), e.IsKey = !1, e.IsLast = !1, e.TimestampInUs = 0n, e.DurationInUs = 0, e.IsFirst = !1, e.TotalDurationInUs = 0, e.Volume = 0, e.VolumeSampleCount = 0, e;
541
541
  }
542
542
  function ut(e) {
543
- const t = new p(C);
543
+ const t = new p(x);
544
544
  return ct(e, t), t.finish();
545
545
  }
546
546
  function ct(e, t) {
@@ -548,9 +548,9 @@ function ct(e, t) {
548
548
  }
549
549
  function lt(e, t, r) {
550
550
  const n = ut(e);
551
- return S(J, n, C, t, r);
551
+ return B(J, n, x, t, r);
552
552
  }
553
- const x = 1, dt = 4194308, ht = 2079085407, ft = 3485914759;
553
+ const N = 1, dt = 4194308, ht = 2079085407, ft = 3485914759;
554
554
  function yt(e) {
555
555
  const t = {};
556
556
  return pt(t), e && Object.assign(t, e), t;
@@ -559,7 +559,7 @@ function pt(e) {
559
559
  return e.Volume = 0, e.Count = 0, e;
560
560
  }
561
561
  function wt(e) {
562
- const t = new p(x);
562
+ const t = new p(N);
563
563
  return mt(e, t), t.finish();
564
564
  }
565
565
  function mt(e, t) {
@@ -567,38 +567,38 @@ function mt(e, t) {
567
567
  }
568
568
  function It(e, t, r) {
569
569
  const n = wt(e);
570
- return S(dt, n, x, t, r);
570
+ return B(dt, n, N, t, r);
571
571
  }
572
- const N = 1, Et = 4194305, gt = 1368629611, bt = 2431514951, Ut = 2914494629, At = 3284746250, Ft = 4101844078;
572
+ const v = 1, gt = 4194305, Et = 1368629611, bt = 2431514951, Ut = 2914494629, At = 3284746250, Ft = 4101844078;
573
573
  function Bt(e) {
574
574
  const t = {};
575
- return St(t), e && Object.assign(t, e), t;
576
- }
577
- function St(e) {
578
- return e.Description = "", e.Codec = V.Unknown, e.SampleRate = 0, e.Channels = 0, e.BitDepth = 0, e;
575
+ return Ot(t), e && Object.assign(t, e), t;
579
576
  }
580
577
  function Ot(e) {
581
- const t = new p(N);
578
+ return e.Description = "", e.Codec = R.Unknown, e.SampleRate = 0, e.Channels = 0, e.BitDepth = 0, e;
579
+ }
580
+ function St(e) {
581
+ const t = new p(v);
582
582
  return Dt(e, t), t.finish();
583
583
  }
584
584
  function Dt(e, t) {
585
- t.writeStringField(gt, e.Description), t.writeInt32Field(bt, e.Channels | 0), t.writeInt32Field(Ut, e.BitDepth | 0), t.writeInt32Field(At, e.Codec), t.writeInt32Field(Ft, e.SampleRate | 0);
585
+ t.writeStringField(Et, e.Description), t.writeInt32Field(bt, e.Channels | 0), t.writeInt32Field(Ut, e.BitDepth | 0), t.writeInt32Field(At, e.Codec), t.writeInt32Field(Ft, e.SampleRate | 0);
586
586
  }
587
587
  function _t(e, t, r) {
588
- const n = Ot(e);
589
- return S(Et, n, N, t, r);
588
+ const n = St(e);
589
+ return B(gt, n, v, t, r);
590
590
  }
591
- const v = 1, Mt = 4194306;
591
+ const K = 1, Mt = 4194306;
592
592
  function Rt(e) {
593
593
  const t = {};
594
594
  return e && Object.assign(t, e), t;
595
595
  }
596
596
  function Vt(e) {
597
- return new p(v).finish();
597
+ return new p(K).finish();
598
598
  }
599
599
  function Lt(e, t, r) {
600
600
  const n = Vt();
601
- return S(Mt, n, v, t, r);
601
+ return B(Mt, n, K, t, r);
602
602
  }
603
603
  class Tt {
604
604
  static getStorageForCapacity(t, r) {
@@ -658,7 +658,7 @@ let Wt = 1;
658
658
  function Pt(e, t) {
659
659
  return `[${e}] ${t}`;
660
660
  }
661
- function A(e, t, r, n) {
661
+ function U(e, t, r, n) {
662
662
  if ((/* @__PURE__ */ new Date()).toISOString(), Wt <= e) {
663
663
  const i = Pt(t, r);
664
664
  switch (e) {
@@ -680,24 +680,23 @@ function A(e, t, r, n) {
680
680
  function kt(e) {
681
681
  return {
682
682
  debug(t, ...r) {
683
- A(0, e, t, r);
683
+ U(0, e, t, r);
684
684
  },
685
685
  info(t, ...r) {
686
- A(1, e, t, r);
686
+ U(1, e, t, r);
687
687
  },
688
688
  warn(t, ...r) {
689
- A(2, e, t, r);
689
+ U(2, e, t, r);
690
690
  },
691
691
  error(t, ...r) {
692
- A(3, e, t, r);
692
+ U(3, e, t, r);
693
693
  }
694
694
  };
695
695
  }
696
- const Ct = 20, L = 32e3, xt = 5, T = 8e3, M = kt("AudioCaptureWorker");
696
+ const Ct = 20, V = 32e3, xt = 5, L = 8e3, _ = kt("AudioCaptureWorker");
697
697
  class Nt {
698
698
  encoder = null;
699
699
  isReady = !1;
700
- simdEnabled = !1;
701
700
  sampleRate;
702
701
  channels;
703
702
  bitrate;
@@ -711,14 +710,14 @@ class Nt {
711
710
  }
712
711
  async initialize() {
713
712
  try {
714
- const { OpusEncoder: t, OPUS_APPLICATION_VOIP: r, isSimdSupported: n } = await import("./index-C-9F_--I.js"), i = await n();
715
- this.encoder = new t({
713
+ const { OpusEncoder: t, OPUS_APPLICATION_VOIP: r, getOpusModule: n } = await import("./index-D2GAzJKe.js");
714
+ await n(), this.encoder = new t({
716
715
  sampleRate: this.sampleRate,
717
716
  channels: this.channels,
718
717
  bitrate: this.bitrate,
719
718
  application: r,
720
719
  complexity: xt
721
- }), this.simdEnabled = i, await this.encoder.ready, this.isReady = !0;
720
+ }), await this.encoder.ready, this.isReady = !0;
722
721
  } catch (t) {
723
722
  this.onError(t instanceof Error ? t : new Error(String(t)));
724
723
  }
@@ -748,23 +747,20 @@ class Nt {
748
747
  }
749
748
  this.encoder = null, this.isReady = !1;
750
749
  }
751
- isSimdEnabled() {
752
- return this.simdEnabled;
753
- }
754
750
  getBitrate() {
755
751
  return this.bitrate;
756
752
  }
757
753
  }
758
- const W = (e) => self.postMessage(e);
754
+ const T = (e) => self.postMessage(e);
759
755
  let f = null;
760
756
  function m(e, t) {
761
757
  const r = e instanceof Error ? e : new Error(String(e));
762
- W({ type: "error", captureId: t, error: { name: r.name, message: r.message, stack: r.stack } });
758
+ T({ type: "error", captureId: t, error: { name: r.name, message: r.message, stack: r.stack } });
763
759
  }
764
760
  function vt(e) {
765
761
  return e.byteOffset === 0 && e.byteLength === e.buffer.byteLength ? e.buffer : e.slice().buffer;
766
762
  }
767
- function D(e) {
763
+ function S(e) {
768
764
  if (!f)
769
765
  return;
770
766
  const t = vt(e);
@@ -779,23 +775,23 @@ function Kt(e) {
779
775
  return t / e.length;
780
776
  }
781
777
  const d = /* @__PURE__ */ new Map();
782
- let g = null;
778
+ let E = null;
783
779
  function zt() {
784
- g === null && (g = self.setInterval(() => {
780
+ E === null && (E = self.setInterval(() => {
785
781
  for (const e of d.values())
786
782
  if (!(e.transport !== "sab" || !e.ringBuffer || !e.ringTemp || e.stopped))
787
783
  try {
788
784
  const t = e.ringBuffer.pop(e.ringTemp);
789
785
  if (t <= 0)
790
786
  continue;
791
- K(e, e.ringTemp.subarray(0, t));
787
+ P(e, e.ringTemp.subarray(0, t));
792
788
  } catch (t) {
793
789
  m(t, e.captureId);
794
790
  }
795
791
  }, 10));
796
792
  }
797
793
  function Ht() {
798
- if (g === null)
794
+ if (E === null)
799
795
  return;
800
796
  let e = !1;
801
797
  for (const t of d.values())
@@ -805,13 +801,13 @@ function Ht() {
805
801
  }
806
802
  if (!e) {
807
803
  try {
808
- self.clearInterval(g);
804
+ self.clearInterval(E);
809
805
  } catch {
810
806
  }
811
- g = null;
807
+ E = null;
812
808
  }
813
809
  }
814
- function P(e) {
810
+ function W(e) {
815
811
  if (e.stopped)
816
812
  return;
817
813
  if (!e.inSegment) {
@@ -829,7 +825,7 @@ function P(e) {
829
825
  }
830
826
  e.pendingReadOffset = (i + t) % n, e.pendingSamples -= t;
831
827
  const s = Kt(r);
832
- D(It(yt({ Volume: s, Count: t }), e.senderId, { trackId: e.trackId }));
828
+ S(It(yt({ Volume: s, Count: t }), e.senderId, { trackId: e.trackId }));
833
829
  try {
834
830
  if (e.useWasmEncoder)
835
831
  e.encoder.encode(r);
@@ -850,7 +846,7 @@ function P(e) {
850
846
  e.timestampUs += e.frameDurationUs;
851
847
  }
852
848
  }
853
- function K(e, t) {
849
+ function P(e, t) {
854
850
  if (e.stopped)
855
851
  return;
856
852
  const r = t.length;
@@ -871,7 +867,7 @@ function K(e, t) {
871
867
  e.pendingBuffer = c, e.pendingReadOffset = 0, e.pendingWriteOffset = e.pendingSamples;
872
868
  }
873
869
  const i = e.pendingBuffer.length, s = Math.min(r, i - e.pendingWriteOffset);
874
- e.pendingBuffer.set(t.subarray(0, s), e.pendingWriteOffset), s < r && e.pendingBuffer.set(t.subarray(s), 0), e.pendingWriteOffset = (e.pendingWriteOffset + r) % i, e.pendingSamples += r, P(e);
870
+ e.pendingBuffer.set(t.subarray(0, s), e.pendingWriteOffset), s < r && e.pendingBuffer.set(t.subarray(s), 0), e.pendingWriteOffset = (e.pendingWriteOffset + r) % i, e.pendingSamples += r, W(e);
875
871
  }
876
872
  function z(e, t, r, n, i = !0) {
877
873
  const s = d.get(e.captureId);
@@ -882,7 +878,7 @@ function z(e, t, r, n, i = !0) {
882
878
  const c = s.encoderOutputBuffer.subarray(0, a), l = s.segmentStartPending;
883
879
  l && (s.segmentStartPending = !1);
884
880
  const h = s.segmentEndPending;
885
- h && (s.segmentEndPending = !1, s.inSegment = !1), D(
881
+ h && (s.segmentEndPending = !1, s.inSegment = !1), S(
886
882
  lt(
887
883
  at({
888
884
  Data: c,
@@ -899,7 +895,7 @@ function z(e, t, r, n, i = !0) {
899
895
  );
900
896
  }
901
897
  function $t(e) {
902
- const t = Math.max(T, Math.floor(e.options?.bitrate ?? L)), r = new AudioEncoder({
898
+ const t = Math.max(L, Math.floor(e.options?.bitrate ?? V)), r = new AudioEncoder({
903
899
  output: (n) => {
904
900
  const i = d.get(e.captureId);
905
901
  if (!i)
@@ -931,7 +927,7 @@ function $t(e) {
931
927
  }), r;
932
928
  }
933
929
  function jt(e) {
934
- const t = Math.max(T, Math.floor(e.options?.bitrate ?? L));
930
+ const t = Math.max(L, Math.floor(e.options?.bitrate ?? V));
935
931
  return new Nt({
936
932
  sampleRate: e.sampleRate,
937
933
  channels: e.channels,
@@ -990,17 +986,15 @@ async function qt(e) {
990
986
  options: e.options
991
987
  }, l = (e.options?.preferWebCodecs ?? !0) && await Yt();
992
988
  let h, I = !1;
993
- const E = Math.max(T, Math.floor(e.options?.bitrate ?? L));
989
+ const g = Math.max(L, Math.floor(e.options?.bitrate ?? V));
994
990
  if (l)
995
- h = $t(a), M.info(
996
- `Audio capture started: encoder=WebCodecs, sampleRate=${t}Hz, channels=${r}, bitrate=${E}bps`
991
+ h = $t(a), _.info(
992
+ `Audio capture started: encoder=WebCodecs, sampleRate=${t}Hz, channels=${r}, bitrate=${g}bps`
997
993
  );
998
994
  else {
999
995
  const u = jt(a);
1000
- await u.initialize(), h = u, I = !0;
1001
- const U = u.isSimdEnabled() ? "SIMD" : "non-SIMD";
1002
- M.info(
1003
- `Audio capture started: encoder=WASM Opus (${U}), sampleRate=${t}Hz, channels=${r}, bitrate=${E}bps`
996
+ await u.initialize(), h = u, I = !0, _.info(
997
+ `Audio capture started: encoder=WASM Opus, sampleRate=${t}Hz, channels=${r}, bitrate=${g}bps`
1004
998
  );
1005
999
  }
1006
1000
  const y = {
@@ -1014,11 +1008,11 @@ async function qt(e) {
1014
1008
  const u = new Tt(e.sharedArrayBuffer, Float32Array);
1015
1009
  y.ringBuffer = u, y.ringTemp = new Float32Array(Math.max(y.frameSize * 4, 4096)), zt();
1016
1010
  }
1017
- d.set(e.captureId, y), D(
1011
+ d.set(e.captureId, y), S(
1018
1012
  _t(
1019
1013
  Bt({
1020
1014
  Description: `mic:${e.captureId}`,
1021
- Codec: V.Opus,
1015
+ Codec: R.Opus,
1022
1016
  SampleRate: t,
1023
1017
  Channels: r,
1024
1018
  BitDepth: 32
@@ -1026,14 +1020,14 @@ async function qt(e) {
1026
1020
  e.senderId,
1027
1021
  { trackId: e.trackId }
1028
1022
  )
1029
- ), W({ type: "started", captureId: e.captureId, sampleRate: t, channels: r });
1023
+ ), T({ type: "started", captureId: e.captureId, sampleRate: t, channels: r });
1030
1024
  }
1031
1025
  async function H(e) {
1032
1026
  const t = d.get(e);
1033
1027
  if (t) {
1034
1028
  t.stopped = !0, d.delete(e);
1035
1029
  try {
1036
- P(t);
1030
+ W(t);
1037
1031
  } catch {
1038
1032
  }
1039
1033
  try {
@@ -1044,7 +1038,7 @@ async function H(e) {
1044
1038
  t.encoder.close();
1045
1039
  } catch {
1046
1040
  }
1047
- D(Lt(Rt({}), t.senderId, { trackId: t.trackId })), W({ type: "stopped", captureId: e }), Ht();
1041
+ S(Lt(Rt({}), t.senderId, { trackId: t.trackId })), T({ type: "stopped", captureId: e }), Ht();
1048
1042
  }
1049
1043
  }
1050
1044
  function Gt(e) {
@@ -1053,7 +1047,13 @@ function Gt(e) {
1053
1047
  }
1054
1048
  function Jt(e) {
1055
1049
  const t = d.get(e);
1056
- !t || t.stopped || !t.inSegment || (t.segmentEndPending = !0, P(t));
1050
+ if (!(!t || t.stopped || !t.inSegment) && (t.segmentEndPending = !0, W(t), t.segmentEndPending && !t.stopped)) {
1051
+ const r = t.frameSize - t.pendingSamples;
1052
+ if (r > 0) {
1053
+ const n = new Float32Array(r);
1054
+ P(t, n);
1055
+ }
1056
+ }
1057
1057
  }
1058
1058
  function Xt() {
1059
1059
  for (const e of Array.from(d.keys()))
@@ -1091,12 +1091,12 @@ self.addEventListener("message", (e) => {
1091
1091
  const r = d.get(t.captureId);
1092
1092
  if (!r || r.stopped)
1093
1093
  return;
1094
- K(r, t.pcm);
1094
+ P(r, t.pcm);
1095
1095
  return;
1096
1096
  }
1097
1097
  if (t.type === "stop") {
1098
1098
  H(t.captureId).catch((r) => {
1099
- M.warn(`Failed to stop audio capture: ${r}`), m(r, t.captureId);
1099
+ _.warn(`Failed to stop audio capture: ${r}`), m(r, t.captureId);
1100
1100
  });
1101
1101
  return;
1102
1102
  }
@@ -984,8 +984,10 @@ class _e extends X {
984
984
  decoderSampleRate = 48e3;
985
985
  pendingChunks = [];
986
986
  async initialise(e, r) {
987
- const { OpusDecoder: s } = await import("./index-C3ZAK5YF.js"), a = [8e3, 12e3, 16e3, 24e3, 48e3].reduce((i, o) => Math.abs(o - r) < Math.abs(i - r) ? o : i);
988
- this.decoderSampleRate = a, this.decoder = new s({ channels: e, sampleRate: this.decoderSampleRate }), await this.decoder.ready, this.isReady = !0, this.flushPendingChunks();
987
+ const { OpusDecoder: s, getOpusModule: n } = await import("./index-Cns_7uAI.js");
988
+ await n();
989
+ const i = [8e3, 12e3, 16e3, 24e3, 48e3].reduce((o, _) => Math.abs(_ - r) < Math.abs(o - r) ? _ : o);
990
+ this.decoderSampleRate = i, this.decoder = new s({ channels: e, sampleRate: this.decoderSampleRate }), await this.decoder.ready, this.isReady = !0, this.flushPendingChunks();
989
991
  }
990
992
  flushPendingChunks() {
991
993
  if (!this.isReady || !this.decoder) {