@ikonai/sdk 1.0.10 → 1.0.12

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.
@@ -660,106 +660,116 @@ function $t(t) {
660
660
  e.push(r.asFloat32());
661
661
  return e;
662
662
  }
663
- const jt = 4194305, Qt = 265814330, Jt = 1368629611, Zt = 2431514951, qt = 2914494629, te = 3284746250, ee = 4101844078;
664
- function re(t) {
663
+ const jt = 4194305, Qt = 161083277, Jt = 265814330, Zt = 1368629611, qt = 2431514951, te = 2745379226, ee = 3282782683, re = 3284746250, se = 4101844078;
664
+ function ne(t) {
665
665
  const e = {};
666
666
  return at(e), e;
667
667
  }
668
668
  function at(t) {
669
- return t.Description = "", t.Codec = c.Unknown, t.SampleRate = 0, t.Channels = 0, t.BitDepth = 0, t.ShapeSets = void 0, t;
669
+ return t.StreamId = "", t.Description = "", t.SourceType = "", t.Codec = c.Unknown, t.CodecDetails = "", t.SampleRate = 0, t.Channels = 0, t.ShapeSets = void 0, t;
670
670
  }
671
- function se(t, e) {
671
+ function ie(t, e) {
672
672
  const r = M.create(t);
673
- return ne(r, e);
673
+ return ae(r, e);
674
674
  }
675
- function ne(t, e) {
676
- const r = e ?? re();
677
- return at(r), ie(t, r), r;
675
+ function ae(t, e) {
676
+ const r = e ?? ne();
677
+ return at(r), oe(t, r), r;
678
678
  }
679
- function ie(t, e) {
679
+ function oe(t, e) {
680
680
  let r;
681
681
  for (; (r = t.next()) !== null; )
682
682
  switch (r.fieldId) {
683
683
  case Qt: {
684
+ if (r.isNull) throw new Error();
685
+ e.StreamId = r.asString();
686
+ break;
687
+ }
688
+ case Jt: {
684
689
  if (r.isNull) {
685
690
  e.ShapeSets = void 0;
686
691
  break;
687
692
  }
688
- e.ShapeSets = oe(r.asArray());
693
+ e.ShapeSets = Ee(r.asArray());
689
694
  break;
690
695
  }
691
- case Jt: {
696
+ case Zt: {
692
697
  if (r.isNull) throw new Error();
693
698
  e.Description = r.asString();
694
699
  break;
695
700
  }
696
- case Zt: {
701
+ case qt: {
697
702
  if (r.isNull) throw new Error();
698
703
  e.Channels = r.asInt32();
699
704
  break;
700
705
  }
701
- case qt: {
706
+ case te: {
702
707
  if (r.isNull) throw new Error();
703
- e.BitDepth = r.asInt32();
708
+ e.CodecDetails = r.asString();
704
709
  break;
705
710
  }
706
- case te: {
711
+ case ee: {
712
+ if (r.isNull) throw new Error();
713
+ e.SourceType = r.asString();
714
+ break;
715
+ }
716
+ case re: {
707
717
  if (r.isNull) throw new Error();
708
718
  e.Codec = r.asInt32();
709
719
  break;
710
720
  }
711
- case ee: {
721
+ case se: {
712
722
  if (r.isNull) throw new Error();
713
723
  e.SampleRate = r.asInt32();
714
724
  break;
715
725
  }
716
726
  }
717
727
  }
718
- async function ae(t, e) {
728
+ async function _e(t, e) {
719
729
  const r = await rt(t, jt);
720
- return se(r, e);
730
+ return ie(r, e);
721
731
  }
722
- function oe(t) {
732
+ function Ee(t) {
723
733
  const e = [];
724
734
  let r;
725
735
  for (; (r = t.next()) !== null; )
726
- e.push(Ie(r.asObject()));
736
+ e.push(fe(r.asObject()));
727
737
  return e;
728
738
  }
729
- const _e = 1107713536, Ee = 1154362099, le = 1185721362;
730
- function ue(t) {
739
+ const le = 1107713536, ue = 1154362099, Ie = 1185721362;
740
+ function he(t) {
731
741
  const e = {};
732
742
  return ot(e), e;
733
743
  }
734
744
  function ot(t) {
735
745
  return t.SetId = 0, t.Name = "", t.ShapeNames = [], t;
736
746
  }
737
- function Ie(t, e) {
738
- const r = e ?? ue();
739
- return ot(r), he(t, r), r;
747
+ function fe(t, e) {
748
+ const r = e ?? he();
749
+ return ot(r), Ae(t, r), r;
740
750
  }
741
- function he(t, e) {
751
+ function Ae(t, e) {
742
752
  let r;
743
753
  for (; (r = t.next()) !== null; )
744
754
  switch (r.fieldId) {
745
- case _e: {
755
+ case le: {
746
756
  if (r.isNull) throw new Error();
747
757
  e.Name = r.asString();
748
758
  break;
749
759
  }
750
- case Ee: {
760
+ case ue: {
751
761
  if (r.isNull) throw new Error();
752
762
  e.SetId = r.asUInt32();
753
763
  break;
754
764
  }
755
- case le: {
765
+ case Ie: {
756
766
  if (r.isNull) throw new Error();
757
- e.ShapeNames = fe(r.asArray());
767
+ e.ShapeNames = ce(r.asArray());
758
768
  break;
759
769
  }
760
770
  }
761
771
  }
762
- function fe(t) {
772
+ function ce(t) {
763
773
  const e = [];
764
774
  let r;
765
775
  for (; (r = t.next()) !== null; )
@@ -820,19 +830,19 @@ class Q {
820
830
  return s = (s + r) % this.capacity, Atomics.store(this.readWrite, 0, s), r;
821
831
  }
822
832
  }
823
- let Ae = 1;
824
- const ce = /* @__PURE__ */ new Map(), Te = {
833
+ let Te = 1;
834
+ const Ne = /* @__PURE__ */ new Map(), Se = {
825
835
  0: "DEBUG",
826
836
  1: "INFO",
827
837
  2: "WARN",
828
838
  3: "ERROR",
829
839
  4: "NONE"
830
840
  };
831
- function Ne(t, e) {
841
+ function Ce(t, e) {
832
842
  return `[${t}] ${e}`;
833
843
  }
834
844
  function b(t, e, r, s) {
835
- const n = (/* @__PURE__ */ new Date()).toISOString(), a = Te[t], i = {
845
+ const n = (/* @__PURE__ */ new Date()).toISOString(), a = Se[t], i = {
836
846
  timestamp: n,
837
847
  level: t,
838
848
  levelName: a,
@@ -840,7 +850,7 @@ function b(t, e, r, s) {
840
850
  message: r,
841
851
  args: s
842
852
  };
843
- for (const [o, _] of ce) {
853
+ for (const [o, _] of Ne) {
844
854
  const E = _?.minLevel ?? 2;
845
855
  if (t >= E)
846
856
  try {
@@ -848,8 +858,8 @@ function b(t, e, r, s) {
848
858
  } catch {
849
859
  }
850
860
  }
851
- if (Ae <= t) {
852
- const o = Ne(e, r);
861
+ if (Te <= t) {
862
+ const o = Ce(e, r);
853
863
  switch (t) {
854
864
  case 0:
855
865
  console.debug(o, ...s);
@@ -882,13 +892,13 @@ function _t(t) {
882
892
  }
883
893
  };
884
894
  }
885
- const G = _t("Capabilities"), Se = globalThis;
886
- function Ce() {
895
+ const G = _t("Capabilities"), Re = globalThis;
896
+ function me() {
887
897
  if (typeof SharedArrayBuffer > "u")
888
898
  return G.debug("SharedArrayBuffer not supported: SharedArrayBuffer is undefined"), !1;
889
899
  if (typeof Atomics > "u")
890
900
  return G.debug("SharedArrayBuffer not supported: Atomics is undefined"), !1;
891
- if (Se.crossOriginIsolated === !1)
901
+ if (Re.crossOriginIsolated === !1)
892
902
  return G.debug("SharedArrayBuffer not supported: crossOriginIsolated is false (missing COOP/COEP headers)"), !1;
893
903
  try {
894
904
  new SharedArrayBuffer(1);
@@ -897,9 +907,9 @@ function Ce() {
897
907
  }
898
908
  return !0;
899
909
  }
900
- const Et = 48e3, lt = 2, Re = 1500, me = 10, J = 80, Ue = 50, Z = 64, z = _t("AudioPlaybackWorker"), P = (t, e) => {
910
+ const Et = 48e3, lt = 2, Ue = 1500, Le = 10, J = 80, de = 50, Z = 64, z = _t("AudioPlaybackWorker"), P = (t, e) => {
901
911
  self.postMessage(t, e ?? []);
902
- }, Le = Ce();
912
+ }, ye = me();
903
913
  let p = "pcm", ut = !0, R = Et, C = lt, d = null;
904
914
  function L(t, e) {
905
915
  const r = t instanceof Error ? t : new Error(String(t));
@@ -909,7 +919,7 @@ function X(t) {
909
919
  const e = et(t);
910
920
  return `${e.senderId}_${e.trackId}`;
911
921
  }
912
- class de {
922
+ class De {
913
923
  mode;
914
924
  ring = null;
915
925
  sab = void 0;
@@ -932,8 +942,8 @@ class de {
932
942
  }
933
943
  rebind(e) {
934
944
  if (!this.closed) {
935
- if (this.mode = e, e === "sab" && Le) {
936
- const r = Math.floor(Re * this.outputSampleRate * this.outputChannels / 1e3), s = Q.getStorageForCapacity(r, Float32Array), n = new Q(s, Float32Array);
945
+ if (this.mode = e, e === "sab" && ye) {
946
+ const r = Math.floor(Ue * this.outputSampleRate * this.outputChannels / 1e3), s = Q.getStorageForCapacity(r, Float32Array), n = new Q(s, Float32Array);
937
947
  n.flush(), this.sab = s, this.ring = n;
938
948
  return;
939
949
  }
@@ -944,7 +954,7 @@ class de {
944
954
  if (this.closed || this.mode !== "pcm" || this.pcmBatchOffset <= 0)
945
955
  return;
946
956
  const r = performance.now(), s = Math.max(1, Math.round(this.outputSampleRate * this.outputChannels * J / 1e3));
947
- if (!(e || this.pcmBatchOffset >= s || this.lastPcmFlushTimeMs > 0 && r - this.lastPcmFlushTimeMs >= Ue))
957
+ if (!(e || this.pcmBatchOffset >= s || this.lastPcmFlushTimeMs > 0 && r - this.lastPcmFlushTimeMs >= de))
948
958
  return;
949
959
  const a = new Float32Array(this.pcmBatchOffset);
950
960
  a.set(this.pcmBatchBuffer.subarray(0, this.pcmBatchOffset)), this.pcmBatchOffset = 0, this.lastPcmFlushTimeMs = r, P({ type: "pcm", streamId: this.streamId, pcm: a }, [a.buffer]);
@@ -980,7 +990,7 @@ class de {
980
990
  this.closed || (this.pcmBatchOffset = 0, this.lastPcmFlushTimeMs = 0, this.ring?.flush());
981
991
  }
982
992
  }
983
- function ye(t) {
993
+ function Pe(t) {
984
994
  switch (t) {
985
995
  case c.Opus:
986
996
  return "opus";
@@ -991,7 +1001,7 @@ function ye(t) {
991
1001
  }
992
1002
  }
993
1003
  let g = null;
994
- function De(t) {
1004
+ function we(t) {
995
1005
  const e = new DataView(t.buffer, t.byteOffset, t.byteLength), r = Math.floor(t.byteLength / 2);
996
1006
  (!g || g.length < r) && (g = new Float32Array(r));
997
1007
  for (let s = 0; s < r; s++)
@@ -1031,7 +1041,7 @@ class $ {
1031
1041
  const N = new Float32Array(r);
1032
1042
  e.copyTo(N, { planeIndex: h, format: i }), u[h] = N;
1033
1043
  }
1034
- return ve(u, r);
1044
+ return xe(u, r);
1035
1045
  }, E = () => {
1036
1046
  const u = new Float32Array(r * s);
1037
1047
  return e.copyTo(u, { planeIndex: 0, format: o }), u;
@@ -1053,25 +1063,25 @@ class $ {
1053
1063
  let n = e, a = e.length, i = r;
1054
1064
  if (s !== R) {
1055
1065
  const o = a / i, E = Math.max(1, Math.round(o * R / s)) * i, l = this.getResampleBuffer(E);
1056
- a = xe(n, l, i, s, R), n = l;
1066
+ a = Ye(n, l, i, s, R), n = l;
1057
1067
  }
1058
1068
  if (i !== C) {
1059
1069
  const _ = a / i * C, E = this.getRemixBuffer(_);
1060
- a = He(n.subarray(0, a), E, i, C), n = E, i = C;
1070
+ a = Ke(n.subarray(0, a), E, i, C), n = E, i = C;
1061
1071
  }
1062
1072
  return n.subarray(0, a);
1063
1073
  }
1064
1074
  }
1065
- class Pe extends $ {
1075
+ class Oe extends $ {
1066
1076
  feedChunk(e) {
1067
1077
  e.isFirst && this.reset();
1068
- const r = De(e.data);
1078
+ const r = we(e.data);
1069
1079
  this.writeConvertedPcm(r, this.inputChannels, this.inputSampleRate), e.isLast && this.reset();
1070
1080
  }
1071
1081
  close() {
1072
1082
  }
1073
1083
  }
1074
- class we extends $ {
1084
+ class ge extends $ {
1075
1085
  decoder;
1076
1086
  codec;
1077
1087
  constructor(e) {
@@ -1130,7 +1140,7 @@ class we extends $ {
1130
1140
  }
1131
1141
  }
1132
1142
  }
1133
- class Oe extends $ {
1143
+ class Me extends $ {
1134
1144
  decoder = null;
1135
1145
  isReady = !1;
1136
1146
  decoderSampleRate = 48e3;
@@ -1202,20 +1212,20 @@ class Oe extends $ {
1202
1212
  }
1203
1213
  }
1204
1214
  const T = /* @__PURE__ */ new Map();
1205
- async function ge(t) {
1215
+ async function Fe(t) {
1206
1216
  if (t.closed || t.decoder)
1207
1217
  return;
1208
1218
  if (t.codec === c.RawPcm16) {
1209
- t.decoder = new Pe({ inputChannels: t.inputChannels, inputSampleRate: t.inputSampleRate, sink: t.sink });
1219
+ t.decoder = new Oe({ inputChannels: t.inputChannels, inputSampleRate: t.inputSampleRate, sink: t.sink });
1210
1220
  return;
1211
1221
  }
1212
1222
  if (t.codec !== c.Opus && t.codec !== c.Mp3)
1213
1223
  throw new Error(`Unsupported audio codec: ${c[t.codec] ?? t.codec}`);
1214
- const e = ye(t.codec);
1224
+ const e = Pe(t.codec);
1215
1225
  if (ut && typeof AudioDecoder < "u" && e !== null)
1216
1226
  try {
1217
1227
  if ((await AudioDecoder.isConfigSupported({ codec: e, numberOfChannels: t.inputChannels, sampleRate: t.inputSampleRate })).supported) {
1218
- const n = new we({
1228
+ const n = new ge({
1219
1229
  codec: e,
1220
1230
  inputChannels: t.inputChannels,
1221
1231
  inputSampleRate: t.inputSampleRate,
@@ -1232,7 +1242,7 @@ async function ge(t) {
1232
1242
  z.warn(`WebCodecs AudioDecoder failed, falling back to WASM: ${s instanceof Error ? s.message : String(s)}`);
1233
1243
  }
1234
1244
  if (t.codec === c.Opus) {
1235
- const s = new Oe({ inputChannels: t.inputChannels, inputSampleRate: t.inputSampleRate, sink: t.sink });
1245
+ const s = new Me({ inputChannels: t.inputChannels, inputSampleRate: t.inputSampleRate, sink: t.sink });
1236
1246
  if (await s.initialise(t.inputChannels, t.inputSampleRate), t.closed) {
1237
1247
  s.close();
1238
1248
  return;
@@ -1242,7 +1252,7 @@ async function ge(t) {
1242
1252
  }
1243
1253
  throw new Error(`No available decoder for codec: ${c[t.codec] ?? t.codec}`);
1244
1254
  }
1245
- function Me(t) {
1255
+ function Be(t) {
1246
1256
  if (t.closed) {
1247
1257
  t.pendingFrames.splice(0);
1248
1258
  try {
@@ -1270,7 +1280,7 @@ function It(t, e) {
1270
1280
  const a = performance.now();
1271
1281
  if (t.lastArrivalTimeMs > 0) {
1272
1282
  const h = a - t.lastArrivalTimeMs, N = Math.abs(h - t.expectedIntervalMs);
1273
- t.jitterMs = t.jitterMs + (N - t.jitterMs) / me;
1283
+ t.jitterMs = t.jitterMs + (N - t.jitterMs) / Le;
1274
1284
  }
1275
1285
  t.lastArrivalTimeMs = a;
1276
1286
  const i = t.inputSampleRate * t.inputChannels, o = R * C, _ = Math.round(s * o / i), E = Math.round(n * o / i), l = Math.round(s * 1e6 / i), u = Math.round(n * 1e6 / i);
@@ -1292,8 +1302,8 @@ function It(t, e) {
1292
1302
  durationUs: u
1293
1303
  });
1294
1304
  }
1295
- async function Fe(t) {
1296
- const e = X(t), r = await ae(t), s = T.get(e);
1305
+ async function be(t) {
1306
+ const e = X(t), r = await _e(t), s = T.get(e);
1297
1307
  if (s) {
1298
1308
  s.closed = !0, s.pendingFrames.splice(0);
1299
1309
  try {
@@ -1306,7 +1316,7 @@ async function Fe(t) {
1306
1316
  }
1307
1317
  T.delete(e);
1308
1318
  }
1309
- const n = new de(e), a = {
1319
+ const n = new De(e), a = {
1310
1320
  streamId: e,
1311
1321
  codec: r.Codec,
1312
1322
  inputSampleRate: r.SampleRate,
@@ -1330,7 +1340,7 @@ async function Fe(t) {
1330
1340
  shapeSets: r.ShapeSets
1331
1341
  });
1332
1342
  }
1333
- function Be() {
1343
+ function Ge() {
1334
1344
  for (const t of T.values())
1335
1345
  P({
1336
1346
  type: "streamBegin",
@@ -1339,7 +1349,7 @@ function Be() {
1339
1349
  shapeSets: t.shapeSets
1340
1350
  });
1341
1351
  }
1342
- function be(t) {
1352
+ function Ve(t) {
1343
1353
  const e = X(t), r = T.get(e);
1344
1354
  if (r) {
1345
1355
  r.closed = !0, r.pendingFrames.splice(0);
@@ -1354,7 +1364,7 @@ function be(t) {
1354
1364
  r.decoder = null, T.delete(e), P({ type: "streamEnd", streamId: e });
1355
1365
  }
1356
1366
  }
1357
- async function Ge(t) {
1367
+ async function pe(t) {
1358
1368
  const e = X(t), r = T.get(e);
1359
1369
  if (!r || r.closed)
1360
1370
  return;
@@ -1364,23 +1374,23 @@ async function Ge(t) {
1364
1374
  const n = r.pendingFrames.length - Z + 1;
1365
1375
  r.pendingFrames.splice(0, n), z.warn(`Dropped ${n} frames waiting for decoder, streamId=${e.substring(0, 8)}`);
1366
1376
  }
1367
- r.pendingFrames.push(s), r.initTask || (r.initTask = ge(r).then(() => Me(r)).catch((n) => {
1377
+ r.pendingFrames.push(s), r.initTask || (r.initTask = Fe(r).then(() => Be(r)).catch((n) => {
1368
1378
  r.closed || L(n, e);
1369
1379
  }));
1370
1380
  return;
1371
1381
  }
1372
1382
  It(r, s);
1373
1383
  }
1374
- function Ve(t) {
1384
+ function ve(t) {
1375
1385
  switch (Tt(t)) {
1376
1386
  case V.AUDIO_STREAM_BEGIN:
1377
- Fe(t);
1387
+ be(t);
1378
1388
  return;
1379
1389
  case V.AUDIO_STREAM_END:
1380
- be(t);
1390
+ Ve(t);
1381
1391
  return;
1382
1392
  case V.AUDIO_FRAME2:
1383
- Ge(t);
1393
+ pe(t);
1384
1394
  return;
1385
1395
  default:
1386
1396
  return;
@@ -1395,7 +1405,7 @@ function ht() {
1395
1405
  d = null;
1396
1406
  }
1397
1407
  }
1398
- function pe() {
1408
+ function ke() {
1399
1409
  ht();
1400
1410
  for (const t of T.values()) {
1401
1411
  try {
@@ -1418,7 +1428,7 @@ self.addEventListener("message", (t) => {
1418
1428
  if (e.type === "attachProtocolPort") {
1419
1429
  ht(), d = e.port, d.addEventListener("message", (r) => {
1420
1430
  const s = r.data;
1421
- s?.type === "protocol" && s.message instanceof ArrayBuffer && Ve(new Uint8Array(s.message));
1431
+ s?.type === "protocol" && s.message instanceof ArrayBuffer && ve(new Uint8Array(s.message));
1422
1432
  }), d.start?.();
1423
1433
  return;
1424
1434
  }
@@ -1426,13 +1436,13 @@ self.addEventListener("message", (t) => {
1426
1436
  p = e.transport, typeof e.outputSampleRate == "number" && Number.isFinite(e.outputSampleRate) && e.outputSampleRate > 0 && (R = e.outputSampleRate), typeof e.outputChannels == "number" && Number.isFinite(e.outputChannels) && e.outputChannels > 0 && (C = e.outputChannels);
1427
1437
  for (const r of T.values())
1428
1438
  r.sink.setOutputFormat(R, C), r.sink.rebind(p);
1429
- Be();
1439
+ Ge();
1430
1440
  return;
1431
1441
  }
1432
- e.type === "dispose" && pe();
1442
+ e.type === "dispose" && ke();
1433
1443
  });
1434
1444
  let m = null;
1435
- function ve(t, e) {
1445
+ function xe(t, e) {
1436
1446
  const r = t.length;
1437
1447
  if (r === 1)
1438
1448
  return t[0];
@@ -1456,10 +1466,10 @@ function tt(t) {
1456
1466
  const e = Math.PI * t;
1457
1467
  return Math.sin(e) / e;
1458
1468
  }
1459
- function ke(t, e) {
1469
+ function He(t, e) {
1460
1470
  return t === 0 ? 1 : Math.abs(t) >= e ? 0 : tt(t) * tt(t / e);
1461
1471
  }
1462
- function xe(t, e, r, s, n) {
1472
+ function Ye(t, e, r, s, n) {
1463
1473
  if (s === n)
1464
1474
  return e.set(t), t.length;
1465
1475
  const a = t.length / r, i = Math.max(1, Math.round(a * n / s)), o = s / n, _ = o > 1 ? o : 1, E = Math.ceil(q * _);
@@ -1471,7 +1481,7 @@ function xe(t, e, r, s, n) {
1471
1481
  const B = N + v;
1472
1482
  if (B < 0 || B >= a)
1473
1483
  continue;
1474
- const ft = (h - B) / _, k = ke(ft, q);
1484
+ const ft = (h - B) / _, k = He(ft, q);
1475
1485
  if (k !== 0) {
1476
1486
  const At = t[B * r + l] ?? 0;
1477
1487
  w += At * k, U += k;
@@ -1481,7 +1491,7 @@ function xe(t, e, r, s, n) {
1481
1491
  }
1482
1492
  return i * r;
1483
1493
  }
1484
- function He(t, e, r, s) {
1494
+ function Ke(t, e, r, s) {
1485
1495
  const n = t.length / r;
1486
1496
  if (r === s)
1487
1497
  return e.set(t), t.length;