@ikonai/sdk 0.0.41 → 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.
- package/assets/{audio-capture-worker-BZ6P8AHQ.js → audio-capture-worker-zx_Os6ad.js} +38 -32
- package/assets/{audio-playback-worker-DU7j77Kb.js → audio-playback-worker-CYoIqiGJ.js} +1 -1
- package/assets/index-Cns_7uAI.js +119 -0
- package/assets/index-D2GAzJKe.js +131 -0
- package/index.js +963 -915
- package/media/ikon-audio-capture.d.ts +2 -0
- package/media/ikon-audio-playback.d.ts +12 -0
- package/package.json +1 -1
- package/utils/platform.d.ts +5 -0
- package/assets/index-7lK3WfPs.js +0 -130
- package/assets/index-k5wFN_NP.js +0 -118
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
function B(e, t, r, n, i) {
|
|
2
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
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
|
|
5
|
-
for (let
|
|
6
|
-
u.setUint32(
|
|
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 || {});
|
|
@@ -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
|
-
|
|
447
|
-
|
|
446
|
+
C(t.subarray(8, 10)),
|
|
447
|
+
C(t.subarray(10, 16))
|
|
448
448
|
].join("-");
|
|
449
449
|
}
|
|
450
450
|
asBytes() {
|
|
@@ -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
|
|
530
|
+
function C(e) {
|
|
531
531
|
return Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
|
|
532
532
|
}
|
|
533
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
|
|
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(
|
|
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 B(J, n,
|
|
551
|
+
return B(J, n, x, t, r);
|
|
552
552
|
}
|
|
553
|
-
const
|
|
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(
|
|
562
|
+
const t = new p(N);
|
|
563
563
|
return mt(e, t), t.finish();
|
|
564
564
|
}
|
|
565
565
|
function mt(e, t) {
|
|
@@ -567,9 +567,9 @@ function mt(e, t) {
|
|
|
567
567
|
}
|
|
568
568
|
function It(e, t, r) {
|
|
569
569
|
const n = wt(e);
|
|
570
|
-
return B(dt, n,
|
|
570
|
+
return B(dt, n, N, t, r);
|
|
571
571
|
}
|
|
572
|
-
const
|
|
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
575
|
return Ot(t), e && Object.assign(t, e), t;
|
|
@@ -577,28 +577,28 @@ function Bt(e) {
|
|
|
577
577
|
function Ot(e) {
|
|
578
578
|
return e.Description = "", e.Codec = R.Unknown, e.SampleRate = 0, e.Channels = 0, e.BitDepth = 0, e;
|
|
579
579
|
}
|
|
580
|
-
function
|
|
581
|
-
const t = new p(
|
|
582
|
-
return
|
|
580
|
+
function St(e) {
|
|
581
|
+
const t = new p(v);
|
|
582
|
+
return Dt(e, t), t.finish();
|
|
583
583
|
}
|
|
584
|
-
function
|
|
584
|
+
function Dt(e, t) {
|
|
585
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 =
|
|
589
|
-
return B(gt, n,
|
|
588
|
+
const n = St(e);
|
|
589
|
+
return B(gt, n, v, t, r);
|
|
590
590
|
}
|
|
591
|
-
const
|
|
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(
|
|
597
|
+
return new p(K).finish();
|
|
598
598
|
}
|
|
599
599
|
function Lt(e, t, r) {
|
|
600
600
|
const n = Vt();
|
|
601
|
-
return B(Mt, n,
|
|
601
|
+
return B(Mt, n, K, t, r);
|
|
602
602
|
}
|
|
603
603
|
class Tt {
|
|
604
604
|
static getStorageForCapacity(t, r) {
|
|
@@ -710,7 +710,7 @@ class Nt {
|
|
|
710
710
|
}
|
|
711
711
|
async initialize() {
|
|
712
712
|
try {
|
|
713
|
-
const { OpusEncoder: t, OPUS_APPLICATION_VOIP: r, getOpusModule: n } = await import("./index-
|
|
713
|
+
const { OpusEncoder: t, OPUS_APPLICATION_VOIP: r, getOpusModule: n } = await import("./index-D2GAzJKe.js");
|
|
714
714
|
await n(), this.encoder = new t({
|
|
715
715
|
sampleRate: this.sampleRate,
|
|
716
716
|
channels: this.channels,
|
|
@@ -760,7 +760,7 @@ function m(e, t) {
|
|
|
760
760
|
function vt(e) {
|
|
761
761
|
return e.byteOffset === 0 && e.byteLength === e.buffer.byteLength ? e.buffer : e.slice().buffer;
|
|
762
762
|
}
|
|
763
|
-
function
|
|
763
|
+
function S(e) {
|
|
764
764
|
if (!f)
|
|
765
765
|
return;
|
|
766
766
|
const t = vt(e);
|
|
@@ -784,7 +784,7 @@ function zt() {
|
|
|
784
784
|
const t = e.ringBuffer.pop(e.ringTemp);
|
|
785
785
|
if (t <= 0)
|
|
786
786
|
continue;
|
|
787
|
-
|
|
787
|
+
P(e, e.ringTemp.subarray(0, t));
|
|
788
788
|
} catch (t) {
|
|
789
789
|
m(t, e.captureId);
|
|
790
790
|
}
|
|
@@ -825,7 +825,7 @@ function W(e) {
|
|
|
825
825
|
}
|
|
826
826
|
e.pendingReadOffset = (i + t) % n, e.pendingSamples -= t;
|
|
827
827
|
const s = Kt(r);
|
|
828
|
-
|
|
828
|
+
S(It(yt({ Volume: s, Count: t }), e.senderId, { trackId: e.trackId }));
|
|
829
829
|
try {
|
|
830
830
|
if (e.useWasmEncoder)
|
|
831
831
|
e.encoder.encode(r);
|
|
@@ -846,7 +846,7 @@ function W(e) {
|
|
|
846
846
|
e.timestampUs += e.frameDurationUs;
|
|
847
847
|
}
|
|
848
848
|
}
|
|
849
|
-
function
|
|
849
|
+
function P(e, t) {
|
|
850
850
|
if (e.stopped)
|
|
851
851
|
return;
|
|
852
852
|
const r = t.length;
|
|
@@ -878,7 +878,7 @@ function z(e, t, r, n, i = !0) {
|
|
|
878
878
|
const c = s.encoderOutputBuffer.subarray(0, a), l = s.segmentStartPending;
|
|
879
879
|
l && (s.segmentStartPending = !1);
|
|
880
880
|
const h = s.segmentEndPending;
|
|
881
|
-
h && (s.segmentEndPending = !1, s.inSegment = !1),
|
|
881
|
+
h && (s.segmentEndPending = !1, s.inSegment = !1), S(
|
|
882
882
|
lt(
|
|
883
883
|
at({
|
|
884
884
|
Data: c,
|
|
@@ -1008,7 +1008,7 @@ async function qt(e) {
|
|
|
1008
1008
|
const u = new Tt(e.sharedArrayBuffer, Float32Array);
|
|
1009
1009
|
y.ringBuffer = u, y.ringTemp = new Float32Array(Math.max(y.frameSize * 4, 4096)), zt();
|
|
1010
1010
|
}
|
|
1011
|
-
d.set(e.captureId, y),
|
|
1011
|
+
d.set(e.captureId, y), S(
|
|
1012
1012
|
_t(
|
|
1013
1013
|
Bt({
|
|
1014
1014
|
Description: `mic:${e.captureId}`,
|
|
@@ -1038,7 +1038,7 @@ async function H(e) {
|
|
|
1038
1038
|
t.encoder.close();
|
|
1039
1039
|
} catch {
|
|
1040
1040
|
}
|
|
1041
|
-
|
|
1041
|
+
S(Lt(Rt({}), t.senderId, { trackId: t.trackId })), T({ type: "stopped", captureId: e }), Ht();
|
|
1042
1042
|
}
|
|
1043
1043
|
}
|
|
1044
1044
|
function Gt(e) {
|
|
@@ -1047,7 +1047,13 @@ function Gt(e) {
|
|
|
1047
1047
|
}
|
|
1048
1048
|
function Jt(e) {
|
|
1049
1049
|
const t = d.get(e);
|
|
1050
|
-
!t || t.stopped || !t.inSegment
|
|
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
|
+
}
|
|
1051
1057
|
}
|
|
1052
1058
|
function Xt() {
|
|
1053
1059
|
for (const e of Array.from(d.keys()))
|
|
@@ -1085,7 +1091,7 @@ self.addEventListener("message", (e) => {
|
|
|
1085
1091
|
const r = d.get(t.captureId);
|
|
1086
1092
|
if (!r || r.stopped)
|
|
1087
1093
|
return;
|
|
1088
|
-
|
|
1094
|
+
P(r, t.pcm);
|
|
1089
1095
|
return;
|
|
1090
1096
|
}
|
|
1091
1097
|
if (t.type === "stop") {
|
|
@@ -984,7 +984,7 @@ class _e extends X {
|
|
|
984
984
|
decoderSampleRate = 48e3;
|
|
985
985
|
pendingChunks = [];
|
|
986
986
|
async initialise(e, r) {
|
|
987
|
-
const { OpusDecoder: s, getOpusModule: n } = await import("./index-
|
|
987
|
+
const { OpusDecoder: s, getOpusModule: n } = await import("./index-Cns_7uAI.js");
|
|
988
988
|
await n();
|
|
989
989
|
const i = [8e3, 12e3, 16e3, 24e3, 48e3].reduce((o, _) => Math.abs(_ - r) < Math.abs(o - r) ? _ : o);
|
|
990
990
|
this.decoderSampleRate = i, this.decoder = new s({ channels: e, sampleRate: this.decoderSampleRate }), await this.decoder.ready, this.isReady = !0, this.flushPendingChunks();
|