@ikonai/sdk-libopus 0.0.40 → 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.
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { OpusDecoder } from './lib/opus-decoder';
2
2
  export { OpusEncoder } from './lib/opus-encoder';
3
- export { getOpusModule, isModuleLoaded, isSimdSupported } from './lib/opus-module';
3
+ export { getOpusModule, isModuleLoaded } from './lib/opus-module';
4
4
  export { OPUS_APPLICATION_VOIP, OPUS_APPLICATION_AUDIO, OPUS_APPLICATION_RESTRICTED_LOWDELAY, OPUS_SET_BITRATE_REQUEST, OPUS_GET_BITRATE_REQUEST, OPUS_SET_COMPLEXITY_REQUEST, OPUS_GET_COMPLEXITY_REQUEST, OPUS_SET_VBR_REQUEST, OPUS_GET_VBR_REQUEST, OPUS_SET_DTX_REQUEST, OPUS_GET_DTX_REQUEST, OPUS_SET_INBAND_FEC_REQUEST, OPUS_GET_INBAND_FEC_REQUEST, OPUS_SET_PACKET_LOSS_PERC_REQUEST, OPUS_GET_PACKET_LOSS_PERC_REQUEST, OPUS_RESET_STATE, OPUS_OK, OPUS_BAD_ARG, OPUS_BUFFER_TOO_SMALL, OPUS_INTERNAL_ERROR, OPUS_INVALID_PACKET, OPUS_UNIMPLEMENTED, OPUS_INVALID_STATE, OPUS_ALLOC_FAIL, OPUS_BANDWIDTH_NARROWBAND, OPUS_BANDWIDTH_MEDIUMBAND, OPUS_BANDWIDTH_WIDEBAND, OPUS_BANDWIDTH_SUPERWIDEBAND, OPUS_BANDWIDTH_FULLBAND, OPUS_SIGNAL_VOICE, OPUS_SIGNAL_MUSIC, MAX_FRAME_SIZE, MAX_PACKET_SIZE, MAX_CHANNELS, } from './lib/opus-constants';
5
5
  export type { OpusModule, DecodedAudio, OpusDecoderOptions, OpusEncoderOptions, OpusModuleFactory, } from './lib/types';
package/index.js CHANGED
@@ -1,45 +1,44 @@
1
1
  import { OpusDecoder as S } from "./lib/opus-decoder.js";
2
2
  import { OpusEncoder as O } from "./lib/opus-encoder.js";
3
- import { getOpusModule as P, isModuleLoaded as A, isSimdSupported as I } from "./lib/opus-module.js";
4
- import { MAX_CHANNELS as D, MAX_FRAME_SIZE as N, MAX_PACKET_SIZE as L, OPUS_ALLOC_FAIL as B, OPUS_APPLICATION_AUDIO as C, OPUS_APPLICATION_RESTRICTED_LOWDELAY as o, OPUS_APPLICATION_VOIP as M, OPUS_BAD_ARG as e, OPUS_BANDWIDTH_FULLBAND as Q, OPUS_BANDWIDTH_MEDIUMBAND as r, OPUS_BANDWIDTH_NARROWBAND as p, OPUS_BANDWIDTH_SUPERWIDEBAND as G, OPUS_BANDWIDTH_WIDEBAND as W, OPUS_BUFFER_TOO_SMALL as d, OPUS_GET_BITRATE_REQUEST as F, OPUS_GET_COMPLEXITY_REQUEST as X, OPUS_GET_DTX_REQUEST as t, OPUS_GET_INBAND_FEC_REQUEST as u, OPUS_GET_PACKET_LOSS_PERC_REQUEST as H, OPUS_GET_VBR_REQUEST as V, OPUS_INTERNAL_ERROR as m, OPUS_INVALID_PACKET as s, OPUS_INVALID_STATE as K, OPUS_OK as f, OPUS_RESET_STATE as x, OPUS_SET_BITRATE_REQUEST as i, OPUS_SET_COMPLEXITY_REQUEST as Y, OPUS_SET_DTX_REQUEST as c, OPUS_SET_INBAND_FEC_REQUEST as l, OPUS_SET_PACKET_LOSS_PERC_REQUEST as Z, OPUS_SET_VBR_REQUEST as a, OPUS_SIGNAL_MUSIC as g, OPUS_SIGNAL_VOICE as n, OPUS_UNIMPLEMENTED as b } from "./lib/opus-constants.js";
3
+ import { getOpusModule as P, isModuleLoaded as A } from "./lib/opus-module.js";
4
+ import { MAX_CHANNELS as R, MAX_FRAME_SIZE as D, MAX_PACKET_SIZE as N, OPUS_ALLOC_FAIL as L, OPUS_APPLICATION_AUDIO as B, OPUS_APPLICATION_RESTRICTED_LOWDELAY as C, OPUS_APPLICATION_VOIP as M, OPUS_BAD_ARG as o, OPUS_BANDWIDTH_FULLBAND as Q, OPUS_BANDWIDTH_MEDIUMBAND as e, OPUS_BANDWIDTH_NARROWBAND as r, OPUS_BANDWIDTH_SUPERWIDEBAND as G, OPUS_BANDWIDTH_WIDEBAND as W, OPUS_BUFFER_TOO_SMALL as p, OPUS_GET_BITRATE_REQUEST as F, OPUS_GET_COMPLEXITY_REQUEST as X, OPUS_GET_DTX_REQUEST as d, OPUS_GET_INBAND_FEC_REQUEST as H, OPUS_GET_PACKET_LOSS_PERC_REQUEST as V, OPUS_GET_VBR_REQUEST as t, OPUS_INTERNAL_ERROR as u, OPUS_INVALID_PACKET as K, OPUS_INVALID_STATE as f, OPUS_OK as m, OPUS_RESET_STATE as s, OPUS_SET_BITRATE_REQUEST as x, OPUS_SET_COMPLEXITY_REQUEST as Y, OPUS_SET_DTX_REQUEST as c, OPUS_SET_INBAND_FEC_REQUEST as l, OPUS_SET_PACKET_LOSS_PERC_REQUEST as Z, OPUS_SET_VBR_REQUEST as a, OPUS_SIGNAL_MUSIC as g, OPUS_SIGNAL_VOICE as i, OPUS_UNIMPLEMENTED as n } from "./lib/opus-constants.js";
5
5
  export {
6
- D as MAX_CHANNELS,
7
- N as MAX_FRAME_SIZE,
8
- L as MAX_PACKET_SIZE,
9
- B as OPUS_ALLOC_FAIL,
10
- C as OPUS_APPLICATION_AUDIO,
11
- o as OPUS_APPLICATION_RESTRICTED_LOWDELAY,
6
+ R as MAX_CHANNELS,
7
+ D as MAX_FRAME_SIZE,
8
+ N as MAX_PACKET_SIZE,
9
+ L as OPUS_ALLOC_FAIL,
10
+ B as OPUS_APPLICATION_AUDIO,
11
+ C as OPUS_APPLICATION_RESTRICTED_LOWDELAY,
12
12
  M as OPUS_APPLICATION_VOIP,
13
- e as OPUS_BAD_ARG,
13
+ o as OPUS_BAD_ARG,
14
14
  Q as OPUS_BANDWIDTH_FULLBAND,
15
- r as OPUS_BANDWIDTH_MEDIUMBAND,
16
- p as OPUS_BANDWIDTH_NARROWBAND,
15
+ e as OPUS_BANDWIDTH_MEDIUMBAND,
16
+ r as OPUS_BANDWIDTH_NARROWBAND,
17
17
  G as OPUS_BANDWIDTH_SUPERWIDEBAND,
18
18
  W as OPUS_BANDWIDTH_WIDEBAND,
19
- d as OPUS_BUFFER_TOO_SMALL,
19
+ p as OPUS_BUFFER_TOO_SMALL,
20
20
  F as OPUS_GET_BITRATE_REQUEST,
21
21
  X as OPUS_GET_COMPLEXITY_REQUEST,
22
- t as OPUS_GET_DTX_REQUEST,
23
- u as OPUS_GET_INBAND_FEC_REQUEST,
24
- H as OPUS_GET_PACKET_LOSS_PERC_REQUEST,
25
- V as OPUS_GET_VBR_REQUEST,
26
- m as OPUS_INTERNAL_ERROR,
27
- s as OPUS_INVALID_PACKET,
28
- K as OPUS_INVALID_STATE,
29
- f as OPUS_OK,
30
- x as OPUS_RESET_STATE,
31
- i as OPUS_SET_BITRATE_REQUEST,
22
+ d as OPUS_GET_DTX_REQUEST,
23
+ H as OPUS_GET_INBAND_FEC_REQUEST,
24
+ V as OPUS_GET_PACKET_LOSS_PERC_REQUEST,
25
+ t as OPUS_GET_VBR_REQUEST,
26
+ u as OPUS_INTERNAL_ERROR,
27
+ K as OPUS_INVALID_PACKET,
28
+ f as OPUS_INVALID_STATE,
29
+ m as OPUS_OK,
30
+ s as OPUS_RESET_STATE,
31
+ x as OPUS_SET_BITRATE_REQUEST,
32
32
  Y as OPUS_SET_COMPLEXITY_REQUEST,
33
33
  c as OPUS_SET_DTX_REQUEST,
34
34
  l as OPUS_SET_INBAND_FEC_REQUEST,
35
35
  Z as OPUS_SET_PACKET_LOSS_PERC_REQUEST,
36
36
  a as OPUS_SET_VBR_REQUEST,
37
37
  g as OPUS_SIGNAL_MUSIC,
38
- n as OPUS_SIGNAL_VOICE,
39
- b as OPUS_UNIMPLEMENTED,
38
+ i as OPUS_SIGNAL_VOICE,
39
+ n as OPUS_UNIMPLEMENTED,
40
40
  S as OpusDecoder,
41
41
  O as OpusEncoder,
42
42
  P as getOpusModule,
43
- A as isModuleLoaded,
44
- I as isSimdSupported
43
+ A as isModuleLoaded
45
44
  };
@@ -2,14 +2,9 @@ import { OpusModule } from './types';
2
2
  /**
3
3
  * Get the shared OpusModule instance.
4
4
  * The module is loaded lazily on first call and cached for subsequent calls.
5
- * Automatically selects SIMD or non-SIMD version based on browser support.
6
5
  */
7
6
  export declare function getOpusModule(): Promise<OpusModule>;
8
7
  /**
9
8
  * Check if the OpusModule has been loaded.
10
9
  */
11
10
  export declare function isModuleLoaded(): boolean;
12
- /**
13
- * Check if SIMD is supported by the current browser.
14
- */
15
- export declare function isSimdSupported(): Promise<boolean>;
@@ -1,72 +1,16 @@
1
- let r = null, t = null;
2
- const i = 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
- ]);
44
- async function o() {
45
- try {
46
- return WebAssembly.validate(i);
47
- } catch {
48
- return !1;
49
- }
1
+ let t = null, e = null;
2
+ async function l() {
3
+ return e || (t || (t = (async () => {
4
+ const n = (await import("../wasm/libopus.js")).default;
5
+ return e = await n({
6
+ locateFile: (u) => u.endsWith(".wasm") ? new URL("../wasm/libopus.wasm", import.meta.url).href : u
7
+ }), e;
8
+ })()), t);
50
9
  }
51
- async function s() {
52
- return t || (r || (r = (async () => {
53
- const a = await o();
54
- let n;
55
- a ? n = (await import("../wasm/libopus-simd.js")).default : n = (await import("../wasm/libopus.js")).default;
56
- const u = a ? "../wasm/libopus-simd.wasm" : "../wasm/libopus.wasm";
57
- return t = await n({
58
- locateFile: (e) => e.endsWith(".wasm") ? new URL(u, import.meta.url).href : e
59
- }), t;
60
- })()), r);
61
- }
62
- function l() {
63
- return t !== null;
64
- }
65
- async function d() {
66
- return o();
10
+ function o() {
11
+ return e !== null;
67
12
  }
68
13
  export {
69
- s as getOpusModule,
70
- l as isModuleLoaded,
71
- d as isSimdSupported
14
+ l as getOpusModule,
15
+ o as isModuleLoaded
72
16
  };
package/lib/types.d.ts CHANGED
@@ -7,7 +7,6 @@ export interface OpusModule {
7
7
  _opus_encode_float(encoder: number, pcm: number, frameSize: number, data: number, maxDataBytes: number): number;
8
8
  _opus_encoder_destroy(encoder: number): void;
9
9
  _opus_encoder_ctl(encoder: number, request: number, ...args: number[]): number;
10
- _opus_strerror(error: number): number;
11
10
  _malloc(size: number): number;
12
11
  _free(ptr: number): void;
13
12
  HEAPU8: Uint8Array;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonai/sdk-libopus",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
package/wasm/libopus.js CHANGED
@@ -1,13 +1,10 @@
1
- async function Module(moduleArg={}){var moduleRtn;var b=moduleArg,m=!!globalThis.WorkerGlobalScope,aa=import.meta.url,n="",p,r;if(globalThis.window||m){try{n=(new URL(".",aa)).href}catch{}m&&(r=a=>{var c=new XMLHttpRequest;c.open("GET",a,!1);c.responseType="arraybuffer";c.send(null);return new Uint8Array(c.response)});p=async a=>{a=await fetch(a,{credentials:"same-origin"});if(a.ok)return a.arrayBuffer();throw Error(a.status+" : "+a.url);}}var t=console.log.bind(console),u=console.error.bind(console),v,x=!1,y,z,A,B,C,D=!1;
2
- function I(){var a=J.buffer;new Int8Array(a);new Int16Array(a);b.HEAPU8=B=new Uint8Array(a);new Uint16Array(a);new Int32Array(a);C=new Uint32Array(a);b.HEAPF32=new Float32Array(a);new Float64Array(a);new BigInt64Array(a);new BigUint64Array(a)}function K(a){b.onAbort?.(a);a="Aborted("+a+")";u(a);x=!0;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");A?.(a);throw a;}var L;
3
- async function ba(a){if(!v)try{var c=await p(a);return new Uint8Array(c)}catch{}if(a==L&&v)a=new Uint8Array(v);else if(r)a=r(a);else throw"both async and sync fetching of the wasm failed";return a}async function ca(a,c){try{var d=await ba(a);return await WebAssembly.instantiate(d,c)}catch(f){u(`failed to asynchronously prepare wasm: ${f}`),K(f)}}
4
- async function da(a){var c=L;if(!v)try{var d=fetch(c,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(d,a)}catch(f){u(`wasm streaming compile failed: ${f}`),u("falling back to ArrayBuffer instantiation")}return ca(c,a)}class M{name="ExitStatus";constructor(a){this.message=`Program terminated with exit(${a})`;this.status=a}}
5
- var N=a=>{for(;0<a.length;)a.shift()(b)},O=[],P=[],ea=()=>{var a=b.preRun.shift();P.push(a)},Q=!0,R=0,S={},T=a=>{if(!(a instanceof M||"unwind"==a))throw a;},U=a=>{y=a;Q||0<R||(b.onExit?.(a),x=!0);throw new M(a);},fa=a=>{if(!x)try{if(a(),!(Q||0<R))try{y=a=y,U(a)}catch(c){T(c)}}catch(c){T(c)}},ha=[null,[],[]],V=globalThis.TextDecoder&&new TextDecoder;b.noExitRuntime&&(Q=b.noExitRuntime);b.print&&(t=b.print);b.printErr&&(u=b.printErr);b.wasmBinary&&(v=b.wasmBinary);
6
- if(b.preInit)for("function"==typeof b.preInit&&(b.preInit=[b.preInit]);0<b.preInit.length;)b.preInit.shift()();
7
- var W,J,ja={e:()=>K(""),b:()=>{Q=!1;R=0},c:(a,c)=>{S[a]&&(clearTimeout(S[a].id),delete S[a]);if(!c)return 0;var d=setTimeout(()=>{delete S[a];fa(()=>W(a,performance.now()))},c);S[a]={id:d,u:c};return 0},d:a=>{var c=B.length;a>>>=0;if(67108864<a)return!1;for(var d=1;4>=d;d*=2){var f=c*(1+.2/d);f=Math.min(f,a+100663296);a:{f=(Math.min(67108864,65536*Math.ceil(Math.max(a,f)/65536))-J.buffer.byteLength+65535)/65536|0;try{J.grow(f);I();var l=1;break a}catch(E){}l=void 0}if(l)return!0}return!1},f:(a,c,
8
- d,f)=>{for(var l=0,E=0;E<d;E++){var ia=C[c>>2],Y=C[c+4>>2];c+=8;for(var F=0;F<Y;F++){var w=a,g=B[ia+F],G=ha[w];if(0===g||10===g){w=1===w?t:u;g=G;var k=0;var q=g;for(var h=k,e=h+void 0;q[h]&&!(h>=e);)++h;q=h;if(16<q-k&&g.buffer&&V)g=V.decode(g.subarray(k,q));else{for(h="";k<q;)if(e=g[k++],e&128){var H=g[k++]&63;if(192==(e&224))h+=String.fromCharCode((e&31)<<6|H);else{var Z=g[k++]&63;e=224==(e&240)?(e&15)<<12|H<<6|Z:(e&7)<<18|H<<12|Z<<6|g[k++]&63;65536>e?h+=String.fromCharCode(e):(e-=65536,h+=String.fromCharCode(55296|
9
- e>>10,56320|e&1023))}}else h+=String.fromCharCode(e);g=h}w(g);G.length=0}else G.push(g)}l+=Y}C[f>>2]=l;return 0},a:U},X;
10
- X=await (async function(){function a(d){d=X=d.exports;b._opus_strerror=d.i;b._opus_decoder_create=d.j;b._opus_decode_float=d.k;b._opus_decoder_ctl=d.l;b._opus_decoder_destroy=d.m;b._opus_encoder_create=d.n;b._opus_encode_float=d.o;b._opus_encoder_ctl=d.p;b._opus_encoder_destroy=d.q;W=d.r;b._malloc=d.s;b._free=d.t;J=d.g;I();return X}var c={a:ja};if(b.instantiateWasm)return new Promise(d=>{b.instantiateWasm(c,(f,l)=>{d(a(f,l))})});L??=b.locateFile?b.locateFile?b.locateFile("libopus.wasm",
11
- n):n+"libopus.wasm":(new URL("libopus.wasm",import.meta.url)).href;return a((await da(c)).instance)}());
12
- (function(){function a(){b.calledRun=!0;if(!x){D=!0;X.h();z?.(b);b.onRuntimeInitialized?.();if(b.postRun)for("function"==typeof b.postRun&&(b.postRun=[b.postRun]);b.postRun.length;){var c=b.postRun.shift();O.push(c)}N(O)}}if(b.preRun)for("function"==typeof b.preRun&&(b.preRun=[b.preRun]);b.preRun.length;)ea();N(P);b.setStatus?(b.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>b.setStatus(""),1);a()},1)):a()})();D?moduleRtn=b:moduleRtn=new Promise((a,c)=>{z=a;A=c});
1
+ async function Module(moduleArg={}){var moduleRtn;var b=moduleArg,f=!!globalThis.WorkerGlobalScope,g=import.meta.url,h="",k,l;if(globalThis.window||f){try{h=(new URL(".",g)).href}catch{}f&&(l=a=>{var c=new XMLHttpRequest;c.open("GET",a,!1);c.responseType="arraybuffer";c.send(null);return new Uint8Array(c.response)});k=async a=>{a=await fetch(a,{credentials:"same-origin"});if(a.ok)return a.arrayBuffer();throw Error(a.status+" : "+a.url);}}var m=console.error.bind(console),p,q=!1,r,t,u,v,w=!1;
2
+ function x(){var a=y.buffer;new Int8Array(a);new Int16Array(a);b.HEAPU8=v=new Uint8Array(a);new Uint16Array(a);new Int32Array(a);new Uint32Array(a);b.HEAPF32=new Float32Array(a);new Float64Array(a);new BigInt64Array(a);new BigUint64Array(a)}function z(a){b.onAbort?.(a);a="Aborted("+a+")";m(a);q=!0;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");u?.(a);throw a;}var A;
3
+ async function B(a){if(!p)try{var c=await k(a);return new Uint8Array(c)}catch{}if(a==A&&p)a=new Uint8Array(p);else if(l)a=l(a);else throw"both async and sync fetching of the wasm failed";return a}async function C(a,c){try{var d=await B(a);return await WebAssembly.instantiate(d,c)}catch(e){m(`failed to asynchronously prepare wasm: ${e}`),z(e)}}
4
+ async function D(a){var c=A;if(!p)try{var d=fetch(c,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(d,a)}catch(e){m(`wasm streaming compile failed: ${e}`),m("falling back to ArrayBuffer instantiation")}return C(c,a)}class E{name="ExitStatus";constructor(a){this.message=`Program terminated with exit(${a})`;this.status=a}}
5
+ var F=a=>{for(;0<a.length;)a.shift()(b)},G=[],H=[],I=()=>{var a=b.preRun.shift();H.push(a)},J=!0,K=0,L={},M=a=>{if(!(a instanceof E||"unwind"==a))throw a;},N=a=>{r=a;J||0<K||(b.onExit?.(a),q=!0);throw new E(a);},O=a=>{if(!q)try{if(a(),!(J||0<K))try{r=a=r,N(a)}catch(c){M(c)}}catch(c){M(c)}};b.noExitRuntime&&(J=b.noExitRuntime);b.printErr&&(m=b.printErr);b.wasmBinary&&(p=b.wasmBinary);if(b.preInit)for("function"==typeof b.preInit&&(b.preInit=[b.preInit]);0<b.preInit.length;)b.preInit.shift()();
6
+ var P,y,Q={c:()=>z(""),b:()=>{J=!1;K=0},d:(a,c)=>{L[a]&&(clearTimeout(L[a].id),delete L[a]);if(!c)return 0;var d=setTimeout(()=>{delete L[a];O(()=>P(a,performance.now()))},c);L[a]={id:d,s:c};return 0},e:a=>{var c=v.length;a>>>=0;if(67108864<a)return!1;for(var d=1;4>=d;d*=2){var e=c*(1+.2/d);e=Math.min(e,a+100663296);a:{e=(Math.min(67108864,65536*Math.ceil(Math.max(a,e)/65536))-y.buffer.byteLength+65535)/65536|0;try{y.grow(e);x();var n=1;break a}catch(S){}n=void 0}if(n)return!0}return!1},a:N},R;
7
+ R=await (async function(){function a(d){d=R=d.exports;b._opus_decoder_create=d.h;b._opus_decode_float=d.i;b._opus_decoder_ctl=d.j;b._opus_decoder_destroy=d.k;b._opus_encoder_create=d.l;b._opus_encode_float=d.m;b._opus_encoder_ctl=d.n;b._opus_encoder_destroy=d.o;P=d.p;b._free=d.q;b._malloc=d.r;y=d.f;x();return R}var c={a:Q};if(b.instantiateWasm)return new Promise(d=>{b.instantiateWasm(c,(e,n)=>{d(a(e,n))})});A??=b.locateFile?b.locateFile?b.locateFile("libopus.wasm",h):h+"libopus.wasm":(new URL("libopus.wasm",
8
+ import.meta.url)).href;return a((await D(c)).instance)}());(function(){function a(){b.calledRun=!0;if(!q){w=!0;R.g();t?.(b);b.onRuntimeInitialized?.();if(b.postRun)for("function"==typeof b.postRun&&(b.postRun=[b.postRun]);b.postRun.length;){var c=b.postRun.shift();G.push(c)}F(G)}}if(b.preRun)for("function"==typeof b.preRun&&(b.preRun=[b.preRun]);b.preRun.length;)I();F(H);b.setStatus?(b.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>b.setStatus(""),1);a()},1)):a()})();
9
+ w?moduleRtn=b:moduleRtn=new Promise((a,c)=>{t=a;u=c});
13
10
  ;return moduleRtn}export default Module;
package/wasm/libopus.wasm CHANGED
Binary file
@@ -1,3 +0,0 @@
1
- import type { OpusModuleFactory } from '../lib/types';
2
- declare const createOpusModule: OpusModuleFactory;
3
- export default createOpusModule;
@@ -1,13 +0,0 @@
1
- async function Module(moduleArg={}){var moduleRtn;var b=moduleArg,m=!!globalThis.WorkerGlobalScope,aa=import.meta.url,n="",p,r;if(globalThis.window||m){try{n=(new URL(".",aa)).href}catch{}m&&(r=a=>{var c=new XMLHttpRequest;c.open("GET",a,!1);c.responseType="arraybuffer";c.send(null);return new Uint8Array(c.response)});p=async a=>{a=await fetch(a,{credentials:"same-origin"});if(a.ok)return a.arrayBuffer();throw Error(a.status+" : "+a.url);}}var t=console.log.bind(console),u=console.error.bind(console),v,x=!1,y,z,A,B,C,D=!1;
2
- function I(){var a=J.buffer;new Int8Array(a);new Int16Array(a);b.HEAPU8=B=new Uint8Array(a);new Uint16Array(a);new Int32Array(a);C=new Uint32Array(a);b.HEAPF32=new Float32Array(a);new Float64Array(a);new BigInt64Array(a);new BigUint64Array(a)}function K(a){b.onAbort?.(a);a="Aborted("+a+")";u(a);x=!0;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");A?.(a);throw a;}var L;
3
- async function ba(a){if(!v)try{var c=await p(a);return new Uint8Array(c)}catch{}if(a==L&&v)a=new Uint8Array(v);else if(r)a=r(a);else throw"both async and sync fetching of the wasm failed";return a}async function ca(a,c){try{var d=await ba(a);return await WebAssembly.instantiate(d,c)}catch(f){u(`failed to asynchronously prepare wasm: ${f}`),K(f)}}
4
- async function da(a){var c=L;if(!v)try{var d=fetch(c,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(d,a)}catch(f){u(`wasm streaming compile failed: ${f}`),u("falling back to ArrayBuffer instantiation")}return ca(c,a)}class M{name="ExitStatus";constructor(a){this.message=`Program terminated with exit(${a})`;this.status=a}}
5
- var N=a=>{for(;0<a.length;)a.shift()(b)},O=[],P=[],ea=()=>{var a=b.preRun.shift();P.push(a)},Q=!0,R=0,S={},T=a=>{if(!(a instanceof M||"unwind"==a))throw a;},U=a=>{y=a;Q||0<R||(b.onExit?.(a),x=!0);throw new M(a);},fa=a=>{if(!x)try{if(a(),!(Q||0<R))try{y=a=y,U(a)}catch(c){T(c)}}catch(c){T(c)}},ha=[null,[],[]],V=globalThis.TextDecoder&&new TextDecoder;b.noExitRuntime&&(Q=b.noExitRuntime);b.print&&(t=b.print);b.printErr&&(u=b.printErr);b.wasmBinary&&(v=b.wasmBinary);
6
- if(b.preInit)for("function"==typeof b.preInit&&(b.preInit=[b.preInit]);0<b.preInit.length;)b.preInit.shift()();
7
- var W,J,ja={e:()=>K(""),b:()=>{Q=!1;R=0},c:(a,c)=>{S[a]&&(clearTimeout(S[a].id),delete S[a]);if(!c)return 0;var d=setTimeout(()=>{delete S[a];fa(()=>W(a,performance.now()))},c);S[a]={id:d,u:c};return 0},d:a=>{var c=B.length;a>>>=0;if(67108864<a)return!1;for(var d=1;4>=d;d*=2){var f=c*(1+.2/d);f=Math.min(f,a+100663296);a:{f=(Math.min(67108864,65536*Math.ceil(Math.max(a,f)/65536))-J.buffer.byteLength+65535)/65536|0;try{J.grow(f);I();var l=1;break a}catch(E){}l=void 0}if(l)return!0}return!1},f:(a,c,
8
- d,f)=>{for(var l=0,E=0;E<d;E++){var ia=C[c>>2],Y=C[c+4>>2];c+=8;for(var F=0;F<Y;F++){var w=a,g=B[ia+F],G=ha[w];if(0===g||10===g){w=1===w?t:u;g=G;var k=0;var q=g;for(var h=k,e=h+void 0;q[h]&&!(h>=e);)++h;q=h;if(16<q-k&&g.buffer&&V)g=V.decode(g.subarray(k,q));else{for(h="";k<q;)if(e=g[k++],e&128){var H=g[k++]&63;if(192==(e&224))h+=String.fromCharCode((e&31)<<6|H);else{var Z=g[k++]&63;e=224==(e&240)?(e&15)<<12|H<<6|Z:(e&7)<<18|H<<12|Z<<6|g[k++]&63;65536>e?h+=String.fromCharCode(e):(e-=65536,h+=String.fromCharCode(55296|
9
- e>>10,56320|e&1023))}}else h+=String.fromCharCode(e);g=h}w(g);G.length=0}else G.push(g)}l+=Y}C[f>>2]=l;return 0},a:U},X;
10
- X=await (async function(){function a(d){d=X=d.exports;b._opus_strerror=d.i;b._opus_decoder_create=d.j;b._opus_decode_float=d.k;b._opus_decoder_ctl=d.l;b._opus_decoder_destroy=d.m;b._opus_encoder_create=d.n;b._opus_encode_float=d.o;b._opus_encoder_ctl=d.p;b._opus_encoder_destroy=d.q;W=d.r;b._malloc=d.s;b._free=d.t;J=d.g;I();return X}var c={a:ja};if(b.instantiateWasm)return new Promise(d=>{b.instantiateWasm(c,(f,l)=>{d(a(f,l))})});L??=b.locateFile?b.locateFile?b.locateFile("libopus-simd.wasm",
11
- n):n+"libopus-simd.wasm":(new URL("libopus-simd.wasm",import.meta.url)).href;return a((await da(c)).instance)}());
12
- (function(){function a(){b.calledRun=!0;if(!x){D=!0;X.h();z?.(b);b.onRuntimeInitialized?.();if(b.postRun)for("function"==typeof b.postRun&&(b.postRun=[b.postRun]);b.postRun.length;){var c=b.postRun.shift();O.push(c)}N(O)}}if(b.preRun)for("function"==typeof b.preRun&&(b.preRun=[b.preRun]);b.preRun.length;)ea();N(P);b.setStatus?(b.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>b.setStatus(""),1);a()},1)):a()})();D?moduleRtn=b:moduleRtn=new Promise((a,c)=>{z=a;A=c});
13
- ;return moduleRtn}export default Module;
Binary file