@ikonai/sdk 0.0.39 → 0.0.41

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,66 +1,14 @@
1
- let a = null, i = null;
2
- const c = new Uint8Array([
3
- 0,
4
- 97,
5
- 115,
6
- 109,
7
- // magic
8
- 1,
9
- 0,
10
- 0,
11
- 0,
12
- // version
13
- 1,
14
- 5,
15
- 1,
16
- 96,
17
- 0,
18
- 1,
19
- 123,
20
- // type section: () -> v128
21
- 3,
22
- 2,
23
- 1,
24
- 0,
25
- // function section
26
- 10,
27
- 10,
28
- 1,
29
- 8,
30
- 0,
31
- // code section start
32
- 65,
33
- 0,
34
- // i32.const 0
35
- 253,
36
- 15,
37
- // v128.load (SIMD)
38
- 253,
39
- 98,
40
- // i32x4.extract_lane 0
41
- 11
42
- // end
43
- ]);
1
+ let l = null, o = null;
44
2
  async function u() {
45
- try {
46
- return WebAssembly.validate(c);
47
- } catch {
48
- return !1;
49
- }
50
- }
51
- async function m() {
52
- return i || (a || (a = (async () => {
53
- const l = await u();
54
- let e;
55
- l ? e = (await import("./libopus-simd-CQXMVirP.js")).default : e = (await import("./libopus-BBY7KH2-.js")).default;
56
- const t = l ? "../wasm/libopus-simd.wasm" : "../wasm/libopus.wasm";
57
- return i = await e({
58
- locateFile: (s) => s.endsWith(".wasm") ? new URL(t, import.meta.url).href : s
59
- }), i;
60
- })()), a);
3
+ return o || (l || (l = (async () => {
4
+ const e = (await import("./libopus-BEPFPIM_.js")).default;
5
+ return o = await e({
6
+ locateFile: (t) => t.endsWith(".wasm") ? new URL("../wasm/libopus.wasm", import.meta.url).href : t
7
+ }), o;
8
+ })()), l);
61
9
  }
62
- const p = 4028, n = 5760, d = 4e3;
63
- class f {
10
+ const c = 4028, n = 5760, h = 4e3;
11
+ class m {
64
12
  module = null;
65
13
  decoder = 0;
66
14
  channels;
@@ -75,13 +23,13 @@ class f {
75
23
  this.channels = e.channels, this.sampleRate = e.sampleRate, this.channelBuffers = Array.from({ length: this.channels }, () => new Float32Array(n)), this.ready = this.initialize();
76
24
  }
77
25
  async initialize() {
78
- this.module = await m();
26
+ this.module = await u();
79
27
  const e = this.module._malloc(4);
80
28
  this.decoder = this.module._opus_decoder_create(this.sampleRate, this.channels, e);
81
29
  const t = new DataView(this.module.HEAPU8.buffer).getInt32(e, !0);
82
30
  if (this.module._free(e), t !== 0)
83
31
  throw new Error(`opus_decoder_create failed with error code ${t}`);
84
- this.inputPtr = this.module._malloc(d), this.outputPtr = this.module._malloc(n * this.channels * 4);
32
+ this.inputPtr = this.module._malloc(h), this.outputPtr = this.module._malloc(n * this.channels * 4);
85
33
  }
86
34
  /**
87
35
  * Decode an Opus frame.
@@ -96,8 +44,8 @@ class f {
96
44
  decodeFrame(e) {
97
45
  if (!this.module || !this.decoder)
98
46
  throw new Error("Decoder not initialized");
99
- if (e.length > d)
100
- throw new Error(`Opus packet too large: ${e.length} > ${d}`);
47
+ if (e.length > h)
48
+ throw new Error(`Opus packet too large: ${e.length} > ${h}`);
101
49
  this.module.HEAPU8.set(e, this.inputPtr);
102
50
  const t = this.module._opus_decode_float(
103
51
  this.decoder,
@@ -110,11 +58,11 @@ class f {
110
58
  );
111
59
  if (t < 0)
112
60
  throw new Error(`opus_decode_float failed with error code ${t}`);
113
- const s = this.outputPtr / 4;
114
- for (let r = 0; r < this.channels; r++) {
115
- const h = this.channelBuffers[r];
116
- for (let o = 0; o < t; o++)
117
- h[o] = this.module.HEAPF32[s + o * this.channels + r];
61
+ const i = this.outputPtr / 4;
62
+ for (let s = 0; s < this.channels; s++) {
63
+ const d = this.channelBuffers[s];
64
+ for (let r = 0; r < t; r++)
65
+ d[r] = this.module.HEAPF32[i + r * this.channels + s];
118
66
  }
119
67
  return {
120
68
  channelData: this.channelBuffers,
@@ -129,7 +77,7 @@ class f {
129
77
  decodeFrameAndCopy(e) {
130
78
  const t = this.decodeFrame(e);
131
79
  return {
132
- channelData: t.channelData.map((s) => s.slice(0, t.samplesDecoded)),
80
+ channelData: t.channelData.map((i) => i.slice(0, t.samplesDecoded)),
133
81
  samplesDecoded: t.samplesDecoded,
134
82
  sampleRate: t.sampleRate
135
83
  };
@@ -139,7 +87,7 @@ class f {
139
87
  * Call this when there's a discontinuity in the audio stream.
140
88
  */
141
89
  reset() {
142
- this.module && this.decoder && this.module._opus_decoder_ctl(this.decoder, p);
90
+ this.module && this.decoder && this.module._opus_decoder_ctl(this.decoder, c);
143
91
  }
144
92
  /**
145
93
  * Get the number of channels this decoder was created with.
@@ -163,8 +111,8 @@ class f {
163
111
  }
164
112
  export {
165
113
  n as MAX_FRAME_SIZE,
166
- d as MAX_PACKET_SIZE,
167
- p as OPUS_RESET_STATE,
168
- f as OpusDecoder,
169
- m as getOpusModule
114
+ h as MAX_PACKET_SIZE,
115
+ c as OPUS_RESET_STATE,
116
+ m as OpusDecoder,
117
+ u as getOpusModule
170
118
  };