opus-codec-worker 1.0.8 → 2.0.0
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/actions/Client.d.ts +4 -1
- package/actions/Client.d.ts.map +1 -1
- package/actions/Client.js +16 -7
- package/actions/Client.js.map +1 -1
- package/actions/actions.d.ts +12 -8
- package/actions/actions.d.ts.map +1 -1
- package/actions/actions.js +24 -19
- package/actions/actions.js.map +1 -1
- package/actions/index.d.ts +2 -0
- package/actions/index.d.ts.map +1 -1
- package/actions/index.js +7 -0
- package/actions/index.js.map +1 -1
- package/package.json +2 -2
- package/worker.js +2 -1
- package/worklet/worklet.js +1 -1
package/actions/Client.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { IWorkerRequest, RequestResponse, RequestResponseType } from './actions.js';
|
|
2
|
+
export interface IClientOptions {
|
|
3
|
+
timeout: number;
|
|
4
|
+
}
|
|
2
5
|
export default class Client {
|
|
3
6
|
#private;
|
|
4
|
-
constructor(worker: Worker);
|
|
7
|
+
constructor(worker: Worker, clientOptions?: Partial<IClientOptions>);
|
|
5
8
|
close(): void;
|
|
6
9
|
sendMessage<T extends IWorkerRequest<unknown, unknown>>(data: T): Promise<RequestResponse<RequestResponseType<T>>>;
|
|
7
10
|
private onMessageError;
|
package/actions/Client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../actions/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,cAAc,EACd,eAAe,EACf,mBAAmB,EACtB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,OAAO,OAAO,MAAM;;
|
|
1
|
+
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../actions/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,cAAc,EACd,eAAe,EACf,mBAAmB,EACtB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,cAAc;IAC3B,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,CAAC,OAAO,OAAO,MAAM;;gBAQnB,MAAM,EAAE,MAAM,EACd,aAAa,GAAE,OAAO,CAAC,cAAc,CAAM;IAWxC,KAAK;IAUL,WAAW,CAAC,CAAC,SAAS,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC;IA0BtE,OAAO,CAAC,cAAc,CAEpB;IACF,OAAO,CAAC,OAAO,CAEb;IACF,OAAO,CAAC,SAAS,CAQf;CACL"}
|
package/actions/Client.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
export default class Client {
|
|
2
2
|
#worker;
|
|
3
3
|
#pending = new Map();
|
|
4
|
-
|
|
4
|
+
#clientOptions;
|
|
5
|
+
constructor(worker, clientOptions = {}) {
|
|
5
6
|
this.#worker = worker;
|
|
7
|
+
this.#clientOptions = {
|
|
8
|
+
timeout: 10000,
|
|
9
|
+
...clientOptions
|
|
10
|
+
};
|
|
6
11
|
worker.addEventListener('message', this.onMessage);
|
|
7
12
|
worker.addEventListener('messageerror', this.onMessageError);
|
|
8
13
|
worker.addEventListener('error', this.onError);
|
|
@@ -13,12 +18,11 @@ export default class Client {
|
|
|
13
18
|
this.#pending.delete(p[0]);
|
|
14
19
|
p[1]({
|
|
15
20
|
requestId: p[0],
|
|
16
|
-
failures: ['Worker destroyed']
|
|
21
|
+
failures: ['Worker destroyed']
|
|
17
22
|
});
|
|
18
23
|
}
|
|
19
24
|
}
|
|
20
25
|
sendMessage(data) {
|
|
21
|
-
const waitTimeBeforeResolvingAutomaticallyInMilliseconds = 10000;
|
|
22
26
|
return new Promise((resolve, reject) => {
|
|
23
27
|
if (this.#pending.has(data.requestId)) {
|
|
24
28
|
reject(new Error(`Request already exists: ${data.requestId}`));
|
|
@@ -28,15 +32,20 @@ export default class Client {
|
|
|
28
32
|
resolve({
|
|
29
33
|
requestId: data.requestId,
|
|
30
34
|
failures: [
|
|
31
|
-
`Timeout expired. It took more than ${
|
|
32
|
-
]
|
|
35
|
+
`Timeout expired. It took more than ${this.#clientOptions.timeout} ms to resolve this request.`
|
|
36
|
+
]
|
|
33
37
|
});
|
|
34
|
-
},
|
|
38
|
+
}, this.#clientOptions.timeout);
|
|
35
39
|
this.#pending.set(data.requestId, (data) => {
|
|
36
40
|
clearTimeout(timeoutId);
|
|
37
41
|
resolve(data);
|
|
38
42
|
});
|
|
39
|
-
|
|
43
|
+
if (data.transfer) {
|
|
44
|
+
this.#worker.postMessage(data, data.transfer);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.#worker.postMessage(data);
|
|
48
|
+
}
|
|
40
49
|
});
|
|
41
50
|
}
|
|
42
51
|
onMessageError = (e) => {
|
package/actions/Client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../actions/Client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../actions/Client.ts"],"names":[],"mappings":"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"}
|
package/actions/actions.d.ts
CHANGED
|
@@ -6,10 +6,11 @@ export interface IWorkerRequest<Data, Response> {
|
|
|
6
6
|
requestId: RequestId;
|
|
7
7
|
}
|
|
8
8
|
export type CodecId = string;
|
|
9
|
-
export
|
|
9
|
+
export interface IRequestResponseSuccess<T> {
|
|
10
10
|
requestId: RequestId;
|
|
11
11
|
value: T;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
|
+
export type RequestResponse<T> = IRequestResponseSuccess<T> | {
|
|
13
14
|
requestId: RequestId;
|
|
14
15
|
failures: string[];
|
|
15
16
|
};
|
|
@@ -30,6 +31,7 @@ export interface IOpusSetRequest extends IWorkerRequest<OpusSetRequest, boolean>
|
|
|
30
31
|
}
|
|
31
32
|
export declare function setToEncoder(data: OpusSetRequest): IOpusSetRequest;
|
|
32
33
|
export interface ICreateEncoder extends IWorkerRequest<ICreateEncoderOptions, CodecId> {
|
|
34
|
+
encoderId: CodecId;
|
|
33
35
|
type: RequestType.CreateEncoder;
|
|
34
36
|
}
|
|
35
37
|
export interface ICreateDecoderOptions {
|
|
@@ -38,16 +40,17 @@ export interface ICreateDecoderOptions {
|
|
|
38
40
|
frameSize: number;
|
|
39
41
|
}
|
|
40
42
|
export interface ICreateDecoder extends IWorkerRequest<ICreateDecoderOptions, CodecId> {
|
|
43
|
+
decoderId: CodecId;
|
|
41
44
|
type: RequestType.CreateDecoder;
|
|
42
45
|
}
|
|
43
|
-
export declare function createDecoder(sampleRate
|
|
46
|
+
export declare function createDecoder({ sampleRate, channels, frameSize }: ICreateDecoderOptions): ICreateDecoder;
|
|
44
47
|
export interface IDestroyEncoderOptions {
|
|
45
48
|
encoderId: CodecId;
|
|
46
49
|
}
|
|
47
|
-
export interface IDestroyEncoder extends IWorkerRequest<
|
|
50
|
+
export interface IDestroyEncoder extends IWorkerRequest<IDestroyEncoderOptions, null> {
|
|
48
51
|
type: RequestType.DestroyEncoder;
|
|
49
52
|
}
|
|
50
|
-
export declare function destroyEncoder(
|
|
53
|
+
export declare function destroyEncoder(data: IDestroyEncoderOptions): IDestroyEncoder;
|
|
51
54
|
export interface IDrainRingBufferResult {
|
|
52
55
|
}
|
|
53
56
|
export declare enum RequestType {
|
|
@@ -68,12 +71,13 @@ export interface IInitializeWorkerOptions {
|
|
|
68
71
|
wasmFileHref: string;
|
|
69
72
|
}
|
|
70
73
|
export declare function initializeWorker(data: IInitializeWorkerOptions): IInitializeWorker;
|
|
71
|
-
export interface
|
|
74
|
+
export interface IDestroyDecoderOptions {
|
|
72
75
|
decoderId: CodecId;
|
|
73
|
-
}
|
|
76
|
+
}
|
|
77
|
+
export interface IDestroyDecoder extends IWorkerRequest<IDestroyDecoderOptions, null> {
|
|
74
78
|
type: RequestType.DestroyDecoder;
|
|
75
79
|
}
|
|
76
|
-
export declare function destroyDecoder(
|
|
80
|
+
export declare function destroyDecoder(data: IDestroyDecoderOptions): IDestroyDecoder;
|
|
77
81
|
export interface IDecodeFloatOptions {
|
|
78
82
|
decoderId: CodecId;
|
|
79
83
|
decodeFec?: number;
|
package/actions/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../actions/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3D,MAAM,WAAW,cAAc,CAAC,IAAI,EAAE,QAAQ;IAC1C,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB,SAAS,EAAE,SAAS,CAAC;CACxB;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B,MAAM,
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../actions/actions.ts"],"names":[],"mappings":"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"}
|
package/actions/actions.js
CHANGED
|
@@ -2,32 +2,33 @@ export function getFromEncoder(data) {
|
|
|
2
2
|
return {
|
|
3
3
|
type: RequestType.OpusGetRequest,
|
|
4
4
|
data,
|
|
5
|
-
requestId: getRequestId()
|
|
5
|
+
requestId: getRequestId()
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
8
|
export function setToEncoder(data) {
|
|
9
9
|
return {
|
|
10
10
|
type: RequestType.OpusSetRequest,
|
|
11
11
|
data,
|
|
12
|
-
requestId: getRequestId()
|
|
12
|
+
requestId: getRequestId()
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
export function createDecoder(sampleRate, channels, frameSize) {
|
|
15
|
+
export function createDecoder({ sampleRate, channels, frameSize }) {
|
|
16
16
|
return {
|
|
17
17
|
type: RequestType.CreateDecoder,
|
|
18
|
+
decoderId: generateCodecId(),
|
|
18
19
|
data: {
|
|
19
20
|
frameSize,
|
|
20
21
|
sampleRate,
|
|
21
|
-
channels
|
|
22
|
+
channels
|
|
22
23
|
},
|
|
23
|
-
requestId: getRequestId()
|
|
24
|
+
requestId: getRequestId()
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
|
-
export function destroyEncoder(
|
|
27
|
+
export function destroyEncoder(data) {
|
|
27
28
|
return {
|
|
28
29
|
type: RequestType.DestroyEncoder,
|
|
29
|
-
data
|
|
30
|
-
requestId: getRequestId()
|
|
30
|
+
data,
|
|
31
|
+
requestId: getRequestId()
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
export var RequestType;
|
|
@@ -46,16 +47,14 @@ export function initializeWorker(data) {
|
|
|
46
47
|
return {
|
|
47
48
|
requestId: getRequestId(),
|
|
48
49
|
data,
|
|
49
|
-
type: RequestType.InitializeWorker
|
|
50
|
+
type: RequestType.InitializeWorker
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
|
-
export function destroyDecoder(
|
|
53
|
+
export function destroyDecoder(data) {
|
|
53
54
|
return {
|
|
54
55
|
type: RequestType.DestroyDecoder,
|
|
55
|
-
data
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
requestId: getRequestId(),
|
|
56
|
+
data,
|
|
57
|
+
requestId: getRequestId()
|
|
59
58
|
};
|
|
60
59
|
}
|
|
61
60
|
export function decodeFloat(data) {
|
|
@@ -63,18 +62,24 @@ export function decodeFloat(data) {
|
|
|
63
62
|
type: RequestType.DecodeFloat,
|
|
64
63
|
data,
|
|
65
64
|
requestId: getRequestId(),
|
|
66
|
-
transfer: [data.encoded]
|
|
65
|
+
transfer: [data.encoded]
|
|
67
66
|
};
|
|
68
67
|
}
|
|
68
|
+
function generateRandomId() {
|
|
69
|
+
return crypto.getRandomValues(new Uint32Array(4)).join('-');
|
|
70
|
+
}
|
|
69
71
|
function getRequestId() {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
return generateRandomId();
|
|
73
|
+
}
|
|
74
|
+
function generateCodecId() {
|
|
75
|
+
return generateRandomId();
|
|
72
76
|
}
|
|
73
77
|
export function createEncoder(data) {
|
|
74
78
|
return {
|
|
75
79
|
data,
|
|
80
|
+
encoderId: generateCodecId(),
|
|
76
81
|
requestId: getRequestId(),
|
|
77
|
-
type: RequestType.CreateEncoder
|
|
82
|
+
type: RequestType.CreateEncoder
|
|
78
83
|
};
|
|
79
84
|
}
|
|
80
85
|
export function encodeFloat(data) {
|
|
@@ -82,7 +87,7 @@ export function encodeFloat(data) {
|
|
|
82
87
|
data,
|
|
83
88
|
requestId: getRequestId(),
|
|
84
89
|
type: RequestType.EncodeFloat,
|
|
85
|
-
transfer: data.input !== null ? [data.input.pcm.buffer] : []
|
|
90
|
+
transfer: data.input !== null ? [data.input.pcm.buffer] : []
|
|
86
91
|
};
|
|
87
92
|
}
|
|
88
93
|
//# sourceMappingURL=actions.js.map
|
package/actions/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../actions/actions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../actions/actions.ts"],"names":[],"mappings":"AAwCA,MAAM,UAAU,cAAc,CAAC,IAAoB;IAC/C,OAAO;QACH,IAAI,EAAE,WAAW,CAAC,cAAc;QAChC,IAAI;QACJ,SAAS,EAAE,YAAY,EAAE;KAC5B,CAAC;AACN,CAAC;AASD,MAAM,UAAU,YAAY,CAAC,IAAoB;IAC7C,OAAO;QACH,IAAI,EAAE,WAAW,CAAC,cAAc;QAChC,IAAI;QACJ,SAAS,EAAE,YAAY,EAAE;KAC5B,CAAC;AACN,CAAC;AAwBD,MAAM,UAAU,aAAa,CAAC,EAC1B,UAAU,EACV,QAAQ,EACR,SAAS,EACW;IACpB,OAAO;QACH,IAAI,EAAE,WAAW,CAAC,aAAa;QAC/B,SAAS,EAAE,eAAe,EAAE;QAC5B,IAAI,EAAE;YACF,SAAS;YACT,UAAU;YACV,QAAQ;SACX;QACD,SAAS,EAAE,YAAY,EAAE;KAC5B,CAAC;AACN,CAAC;AAaD,MAAM,UAAU,cAAc,CAAC,IAA4B;IACvD,OAAO;QACH,IAAI,EAAE,WAAW,CAAC,cAAc;QAChC,IAAI;QACJ,SAAS,EAAE,YAAY,EAAE;KAC5B,CAAC;AACN,CAAC;AAID,MAAM,CAAN,IAAY,WAUX;AAVD,WAAY,WAAW;IACnB,+DAAa,CAAA;IACb,+DAAa,CAAA;IACb,2DAAW,CAAA;IACX,2DAAW,CAAA;IACX,iEAAc,CAAA;IACd,qEAAgB,CAAA;IAChB,iEAAc,CAAA;IACd,iEAAc,CAAA;IACd,iEAAc,CAAA;AAClB,CAAC,EAVW,WAAW,KAAX,WAAW,QAUtB;AAaD,MAAM,UAAU,gBAAgB,CAC5B,IAA8B;IAE9B,OAAO;QACH,SAAS,EAAE,YAAY,EAAE;QACzB,IAAI;QACJ,IAAI,EAAE,WAAW,CAAC,gBAAgB;KACrC,CAAC;AACN,CAAC;AAaD,MAAM,UAAU,cAAc,CAAC,IAA4B;IACvD,OAAO;QACH,IAAI,EAAE,WAAW,CAAC,cAAc;QAChC,IAAI;QACJ,SAAS,EAAE,YAAY,EAAE;KAC5B,CAAC;AACN,CAAC;AAkBD,MAAM,UAAU,WAAW,CAAC,IAAyB;IACjD,OAAO;QACH,IAAI,EAAE,WAAW,CAAC,WAAW;QAC7B,IAAI;QACJ,SAAS,EAAE,YAAY,EAAE;QACzB,QAAQ,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;KAC3B,CAAC;AACN,CAAC;AAgDD,SAAS,gBAAgB;IACrB,OAAO,MAAM,CAAC,eAAe,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,YAAY;IACjB,OAAO,gBAAgB,EAAE,CAAC;AAC9B,CAAC;AAED,SAAS,eAAe;IACpB,OAAO,gBAAgB,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAA2B;IACrD,OAAO;QACH,IAAI;QACJ,SAAS,EAAE,eAAe,EAAE;QAC5B,SAAS,EAAE,YAAY,EAAE;QACzB,IAAI,EAAE,WAAW,CAAC,aAAa;KAClC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAyB;IACjD,OAAO;QACH,IAAI;QACJ,SAAS,EAAE,YAAY,EAAE;QACzB,IAAI,EAAE,WAAW,CAAC,WAAW;QAC7B,QAAQ,EAAE,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;KAC/D,CAAC;AACN,CAAC"}
|
package/actions/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { type RequestResponse } from './actions.js';
|
|
1
2
|
export * as default from './actions.js';
|
|
3
|
+
export declare function successOrFail<T>(pendingResponse: RequestResponse<T> | Promise<RequestResponse<T>>): Promise<import("./actions.js").IRequestResponseSuccess<T>>;
|
|
2
4
|
//# sourceMappingURL=index.d.ts.map
|
package/actions/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,wBAAsB,aAAa,CAAC,CAAC,EACjC,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,8DASpE"}
|
package/actions/index.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
export * as default from './actions.js';
|
|
2
|
+
export async function successOrFail(pendingResponse) {
|
|
3
|
+
const response = await Promise.resolve(pendingResponse);
|
|
4
|
+
if ('failures' in response) {
|
|
5
|
+
throw new Error(`Request ${response.requestId} failed: ${response.failures?.join(', ')}`);
|
|
6
|
+
}
|
|
7
|
+
return response;
|
|
8
|
+
}
|
|
2
9
|
//# sourceMappingURL=index.js.map
|
package/actions/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,KAAK,UAAU,aAAa,CAC/B,eAAiE;IAEjE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACxD,IAAI,UAAU,IAAI,QAAQ,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACX,WAAW,QAAQ,CAAC,SAAS,YAAY,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAC3E,CAAC;IACN,CAAC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opus-codec-worker",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/VictorQueiroz/js-opus-codec"
|
|
7
|
+
"url": "git+https://github.com/VictorQueiroz/js-opus-codec.git"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"**/*.{js,d.ts,map}"
|
package/worker.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
(()=>{var e,t,r={178(){},306(){}},s={};function i(e){var t=s[e];if(void 0!==t)return t.exports;var a=s[e]={exports:{}};return r[e](a,a.exports,i),a.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(r,s){if(1&s&&(r=this(r)),8&s)return r;if("object"==typeof r&&r){if(4&s&&r.__esModule)return r;if(16&s&&"function"==typeof r.then)return r}var a=Object.create(null);i.r(a);var o={};e=e||[null,t({}),t([]),t(t)];for(var n=2&s&&r;("object"==typeof n||"function"==typeof n)&&!~e.indexOf(n);n=t(n))Object.getOwnPropertyNames(n).forEach(e=>o[e]=()=>r[e]);return o.default=()=>r,i.d(a,o),a},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{"use strict";var e;!function(e){e[e.CreateEncoder=0]="CreateEncoder",e[e.CreateDecoder=1]="CreateDecoder",e[e.EncodeFloat=2]="EncodeFloat",e[e.DecodeFloat=3]="DecodeFloat",e[e.DestroyEncoder=4]="DestroyEncoder",e[e.InitializeWorker=5]="InitializeWorker",e[e.DestroyDecoder=6]="DestroyDecoder",e[e.OpusGetRequest=7]="OpusGetRequest",e[e.OpusSetRequest=8]="OpusSetRequest"}(e||(e={}));class t{#e;#t;constructor(e){this.#e=e,this.#t=e.malloc(e.originalRuntime().size_of_int())}value(){if(4!==this.#e.originalRuntime().size_of_int())throw new Error("invalid integer byte size");return this.#e.view().getInt32(this.#t,!0)}set(e){this.#e.view().setInt32(this.#t,e,!0)}size(){return this.#e.originalRuntime().size_of_int()}offset(){if(0===this.#t)throw new Error("Integer has been destroyed");return this.#t}destroy(){this.#e.free(this.#t),this.#t=0}[Symbol.dispose](){this.destroy()}}class r{#e;#r=new Map;constructor(e){this.#e=e}originalRuntime(){return this.#e}subarray(e,t){return new Uint8Array(this.#e.memory.buffer,e,t-e)}free(e){this.#r.delete(e),this.#e.free(e)}view(){return new DataView(this.#e.memory.buffer)}malloc(e){const t=this.#e.malloc(e);if(!t)throw new Error(`Failed to allocate ${e} bytes`);const r=(new Error).stack??null;return this.#r.set(t,r),t}[Symbol.dispose](){for(const[e,t]of this.#r)throw new Error(`Memory leak detected at offset ${e}\nAllocation stack:\n${t}`)}}class s{#t;#s;#e;constructor(e,t){this.#e=e,this.#s=t,this.#t=e.malloc(t)}offset(){return this.#t}data(){return this.#e.subarray(this.#t,this.#t+this.#s)}size(){return this.#s}destroy(){this.#e.free(this.#t),this.#t=0}[Symbol.dispose](){this.destroy()}}class a{#i=new Set;#a=!1;constructor(){}add(e){this.#i.add(e)}destroy(){if(this.#a)throw new Error("ResourcesHolder already destroyed");for(const e of this.#i)e.destroy();this.#i.clear(),this.#a=!0}[Symbol.dispose](){this.destroy()}}class o{#o;#n;#u;#e;#d;#l;#h=null;constructor(e,r,i,o){if(this.#l=o,this.#e=e,this.#u=new a,this.#o=new t(e),this.#u.add(this.#o),this.#n=e.originalRuntime().opus_decoder_create(r,i,this.#o.offset()),!this.#n||this.#o.value()<0)throw new Error("Failed to create decoder");this.#d=new s(e,this.#l*i*Float32Array.BYTES_PER_ELEMENT),this.#u.add(this.#d)}decodeFloat(e,t=0){let r=this.#h;r||(r=new s(this.#e,e.byteLength)),r.data().byteLength<e.byteLength&&(r.destroy(),r=new s(this.#e,e.byteLength)),r.data().set(e),this.#h=r;const i=this.#e.originalRuntime().opus_decode_float(this.#n,r.offset(),e.byteLength,this.#d.offset(),this.#l,t);if(i<0)throw new Error("Failed to decode float");return i}decoded(){const e=this.#d.data();return new Float32Array(e.buffer,e.byteOffset,e.byteLength/Float32Array.BYTES_PER_ELEMENT)}destroy(){this.#e.originalRuntime().opus_decoder_destroy(this.#n),this.#u.destroy(),this.#h?.destroy()}[Symbol.dispose](){this.destroy()}}const n=async function({wasmFileHref:e}={}){const t={};for(const e of["args_get","args_sizes_get","fd_close","fd_seek","fd_write","proc_exit"])t[e]=function(t){return console.log("[%s] called with %o",e,t),0};const r={wasi_snapshot_preview1:t},s=await async function({wasmFileHref:e,importObject:t}){let r;if("process"in globalThis&&"nodejs"===process.env.RUNTIME){const e=await Promise.resolve().then(i.t.bind(i,306,19)),s=(await Promise.resolve().then(i.t.bind(i,178,19))).resolve("/","index.wasm"),a=await e.promises.readFile(s);r=WebAssembly.instantiate(a,t)}else{if("string"!=typeof e)throw new Error("Invalid wasmFileHref");const s=await fetch(e);r=await WebAssembly.instantiateStreaming(s,t)}return r}({wasmFileHref:e,importObject:r}),a=s.instance.exports.memory??null;if(null===a)throw new Error("Memory was expected to be imported but is null");return{...s.instance.exports,memory:a}};var u;function d(e,t){let r;switch(t.type){case u.SetComplexity:r=e.setComplexity(t.value);break;case u.SetBitrate:r=e.setBitrate(t.value);break;case u.SetVbr:r=e.setVbr(t.value);break;case u.SetVbrConstraint:r=e.setVbrConstraint(t.value);break;case u.SetForceChannels:r=e.setForceChannels(t.value);break;case u.SetMaxBandwidth:r=e.setMaxBandwidth(t.value);break;case u.SetBandwidth:r=e.setBandwidth(t.value);break;case u.SetSignal:r=e.setSignal(t.value);break;case u.SetApplication:r=e.setApplication(t.value);break;case u.SetInbandFec:r=e.setInbandFec(t.value);break;case u.SetPacketLossperc:r=e.setPacketLossperc(t.value);break;case u.SetDtx:r=e.setDtx(t.value);break;case u.SetLsbDepth:r=e.setLsbDepth(t.value);break;case u.SetExpertFrameduration:r=e.setExpertFrameduration(t.value);break;case u.SetPredictionDisabled:r=e.setPredictionDisabled(t.value);break;case u.SetPhaseInversiondisabled:r=e.setPhaseInversiondisabled(t.value);break;case u.SetGain:r=e.setGain(t.value)}return r}function l(e,t){let r;switch(t.type){case u.GetComplexity:r=e.getComplexity();break;case u.GetBitrate:r=e.getBitrate();break;case u.GetVbr:r=e.getVbr();break;case u.GetVbrConstraint:r=e.getVbrConstraint();break;case u.GetForceChannels:r=e.getForceChannels();break;case u.GetMaxBandwidth:r=e.getMaxBandwidth();break;case u.GetSignal:r=e.getSignal();break;case u.GetApplication:r=e.getApplication();break;case u.GetLookahead:r=e.getLookahead();break;case u.GetInbandFec:r=e.getInbandFec();break;case u.GetPacketLossperc:r=e.getPacketLossperc();break;case u.GetDtx:r=e.getDtx();break;case u.GetLsbDepth:r=e.getLsbDepth();break;case u.GetExpertFrameduration:r=e.getExpertFrameduration();break;case u.GetPredictionDisabled:r=e.getPredictionDisabled();break;case u.GetBandwidth:r=e.getBandwidth();break;case u.GetSampleRate:r=e.getSampleRate();break;case u.GetPhaseInversiondisabled:r=e.getPhaseInversiondisabled();break;case u.GetInDtx:r=e.getInDtx();break;case u.GetGain:r=e.getGain();break;case u.GetLastPacketduration:r=e.getLastPacketduration();break;case u.GetPitch:r=e.getPitch()}return r}!function(e){e.SetComplexity="OPUS_SET_COMPLEXITY",e.GetComplexity="OPUS_GET_COMPLEXITY",e.SetBitrate="OPUS_SET_BITRATE",e.GetBitrate="OPUS_GET_BITRATE",e.SetVbr="OPUS_SET_VBR",e.GetVbr="OPUS_GET_VBR",e.SetVbrConstraint="OPUS_SET_VBR_CONSTRAINT",e.GetVbrConstraint="OPUS_GET_VBR_CONSTRAINT",e.SetForceChannels="OPUS_SET_FORCE_CHANNELS",e.GetForceChannels="OPUS_GET_FORCE_CHANNELS",e.SetMaxBandwidth="OPUS_SET_MAX_BANDWIDTH",e.GetMaxBandwidth="OPUS_GET_MAX_BANDWIDTH",e.SetBandwidth="OPUS_SET_BANDWIDTH",e.SetSignal="OPUS_SET_SIGNAL",e.GetSignal="OPUS_GET_SIGNAL",e.SetApplication="OPUS_SET_APPLICATION",e.GetApplication="OPUS_GET_APPLICATION",e.GetLookahead="OPUS_GET_LOOKAHEAD",e.SetInbandFec="OPUS_SET_INBAND_FEC",e.GetInbandFec="OPUS_GET_INBAND_FEC",e.SetPacketLossperc="OPUS_SET_PACKET_LOSS_PERC",e.GetPacketLossperc="OPUS_GET_PACKET_LOSS_PERC",e.SetDtx="OPUS_SET_DTX",e.GetDtx="OPUS_GET_DTX",e.SetLsbDepth="OPUS_SET_LSB_DEPTH",e.GetLsbDepth="OPUS_GET_LSB_DEPTH",e.SetExpertFrameduration="OPUS_SET_EXPERT_FRAME_DURATION",e.GetExpertFrameduration="OPUS_GET_EXPERT_FRAME_DURATION",e.SetPredictionDisabled="OPUS_SET_PREDICTION_DISABLED",e.GetPredictionDisabled="OPUS_GET_PREDICTION_DISABLED",e.GetBandwidth="OPUS_GET_BANDWIDTH",e.GetSampleRate="OPUS_GET_SAMPLE_RATE",e.SetPhaseInversiondisabled="OPUS_SET_PHASE_INVERSION_DISABLED",e.GetPhaseInversiondisabled="OPUS_GET_PHASE_INVERSION_DISABLED",e.GetInDtx="OPUS_GET_IN_DTX",e.SetGain="OPUS_SET_GAIN",e.GetGain="OPUS_GET_GAIN",e.GetLastPacketduration="OPUS_GET_LAST_PACKET_DURATION",e.GetPitch="OPUS_GET_PITCH"}(u||(u={}));const h=0;class c{#c;#e;#f;constructor(e,r){this.#e=e,this.#f=new t(e),this.#c=r}setComplexity(e){return this.#e.originalRuntime().opus_set_complexity(this.#c,e)===h}getComplexity(){if(this.#e.originalRuntime().opus_get_complexity(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_COMPLEXITY");return this.#f.value()}setBitrate(e){return this.#e.originalRuntime().opus_set_bitrate(this.#c,e)===h}getBitrate(){if(this.#e.originalRuntime().opus_get_bitrate(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_BITRATE");return this.#f.value()}setVbr(e){return this.#e.originalRuntime().opus_set_vbr(this.#c,e)===h}getVbr(){if(this.#e.originalRuntime().opus_get_vbr(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_VBR");return this.#f.value()}setVbrConstraint(e){return this.#e.originalRuntime().opus_set_vbr_constraint(this.#c,e)===h}getVbrConstraint(){if(this.#e.originalRuntime().opus_get_vbr_constraint(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_VBR_CONSTRAINT");return this.#f.value()}setForceChannels(e){return this.#e.originalRuntime().opus_set_force_channels(this.#c,e)===h}getForceChannels(){if(this.#e.originalRuntime().opus_get_force_channels(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_FORCE_CHANNELS");return this.#f.value()}setMaxBandwidth(e){return this.#e.originalRuntime().opus_set_max_bandwidth(this.#c,e)===h}getMaxBandwidth(){if(this.#e.originalRuntime().opus_get_max_bandwidth(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_MAX_BANDWIDTH");return this.#f.value()}setBandwidth(e){return this.#e.originalRuntime().opus_set_bandwidth(this.#c,e)===h}setSignal(e){return this.#e.originalRuntime().opus_set_signal(this.#c,e)===h}getSignal(){if(this.#e.originalRuntime().opus_get_signal(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_SIGNAL");return this.#f.value()}setApplication(e){return this.#e.originalRuntime().opus_set_application(this.#c,e)===h}getApplication(){if(this.#e.originalRuntime().opus_get_application(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_APPLICATION");return this.#f.value()}getLookahead(){if(this.#e.originalRuntime().opus_get_lookahead(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_LOOKAHEAD");return this.#f.value()}setInbandFec(e){return this.#e.originalRuntime().opus_set_inband_fec(this.#c,e)===h}getInbandFec(){if(this.#e.originalRuntime().opus_get_inband_fec(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_INBAND_FEC");return this.#f.value()}setPacketLossperc(e){return this.#e.originalRuntime().opus_set_packet_loss_perc(this.#c,e)===h}getPacketLossperc(){if(this.#e.originalRuntime().opus_get_packet_loss_perc(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_PACKET_LOSS_PERC");return this.#f.value()}setDtx(e){return this.#e.originalRuntime().opus_set_dtx(this.#c,e)===h}getDtx(){if(this.#e.originalRuntime().opus_get_dtx(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_DTX");return this.#f.value()}setLsbDepth(e){return this.#e.originalRuntime().opus_set_lsb_depth(this.#c,e)===h}getLsbDepth(){if(this.#e.originalRuntime().opus_get_lsb_depth(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_LSB_DEPTH");return this.#f.value()}setExpertFrameduration(e){return this.#e.originalRuntime().opus_set_expert_frame_duration(this.#c,e)===h}getExpertFrameduration(){if(this.#e.originalRuntime().opus_get_expert_frame_duration(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_EXPERT_FRAME_DURATION");return this.#f.value()}setPredictionDisabled(e){return this.#e.originalRuntime().opus_set_prediction_disabled(this.#c,e)===h}getPredictionDisabled(){if(this.#e.originalRuntime().opus_get_prediction_disabled(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_PREDICTION_DISABLED");return this.#f.value()}getBandwidth(){if(this.#e.originalRuntime().opus_get_bandwidth(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_BANDWIDTH");return this.#f.value()}getSampleRate(){if(this.#e.originalRuntime().opus_get_sample_rate(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_SAMPLE_RATE");return this.#f.value()}setPhaseInversiondisabled(e){return this.#e.originalRuntime().opus_set_phase_inversion_disabled(this.#c,e)===h}getPhaseInversiondisabled(){if(this.#e.originalRuntime().opus_get_phase_inversion_disabled(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_PHASE_INVERSION_DISABLED");return this.#f.value()}getInDtx(){if(this.#e.originalRuntime().opus_get_in_dtx(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_IN_DTX");return this.#f.value()}setGain(e){return this.#e.originalRuntime().opus_set_gain(this.#c,e)===h}getGain(){if(this.#e.originalRuntime().opus_get_gain(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_GAIN");return this.#f.value()}getLastPacketduration(){if(this.#e.originalRuntime().opus_get_last_packet_duration(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_LAST_PACKET_DURATION");return this.#f.value()}getPitch(){if(this.#e.originalRuntime().opus_get_pitch(this.#c,this.#f.offset())!=h)throw new Error("Failed to set OPUS_GET_PITCH");return this.#f.value()}destroy(){this.#f.destroy()}[Symbol.dispose](){this.destroy()}}class f extends c{#o;#e;#_;#m;#d;#u;constructor(e,r,i,o,n,u){if(!n)throw new Error("Output buffer length must be more than 0");const d=new t(e),l=e.originalRuntime().opus_encoder_create(r,i,o,d.offset());if(super(e,l),this.#u=new a,this.#o=d,this.#e=e,this.#d=new s(e,u),this.#m=new s(e,n),this.#u.add(this.#m),this.#u.add(this.#d),this.#u.add(this.#o),this.#_=l,d.value()<0)throw this.destroy(),new Error("Failed to create encoder")}encoded(){return this.#m.data()}encodeFloat(e,t,r){if(r>this.#m.size())throw new Error(`encoded buffer length is ${this.#m.size()}, but maxDataBytes is ${r}`);this.#d.data().set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));const s=this.#e.originalRuntime().opus_encode_float(this.#_,this.#d.offset(),t,this.#m.offset(),r);if(s<0)throw new Error(`Failed to encode float: ${s}`);return s}destroy(){super.destroy(),this.#u.destroy(),this.#e.originalRuntime().opus_encoder_destroy(this.#_)}[Symbol.dispose](){this.destroy()}}class _ extends Error{constructor(e){super(e)}}function m({name:e,value:t,validations:r}){const s=new Array;if(r.integer&&!Number.isSafeInteger(t)&&s.push("It must be an integer."),t>r.max&&s.push(`It must be up to ${r.max}.`),t<r.min&&s.push(`It must be at least ${r.min}.`),s.length>0)throw new _([`"${t}" is not a valid value for ${e}. It failed to following validations:\n`,...s.map(e=>`\t- ${e}`)].join(""));return t}var p,E,S,g,b,w,v,O,y,T,P,I,R,G,A,D=function(e,t,r,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(e,r):i?i.value=r:t.set(e,r),r},F=function(e,t,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(e):s?s.value:t.get(e)};const k=4294967295;class U{constructor({frameSize:e,frameCacheSize:t=0,preallocateFrameCount:r=10,TypedArrayConstructor:s}){if(p.add(this),E.set(this,void 0),S.set(this,void 0),g.set(this,void 0),b.set(this,void 0),w.set(this,void 0),v.set(this,void 0),O.set(this,void 0),D(this,b,m({value:e,name:"Frame Size",validations:{min:1,integer:!0,max:k}}),"f"),D(this,S,m({value:r,name:"Preallocate Frame Count",validations:{min:1,integer:!0,max:k}}),"f"),D(this,g,m({value:t,name:"Frame Cache Size",validations:{min:0,integer:!1,max:k}}),"f"),!("BYTES_PER_ELEMENT"in s))throw new _("TypedArrayConstructor must be a typed array");D(this,v,0,"f"),D(this,O,0,"f"),D(this,E,s,"f"),D(this,w,new ArrayBuffer(F(this,p,"m",A).call(this)),"f")}empty(){return F(this,p,"m",P).call(this)<F(this,b,"f")}peek(){return F(this,p,"m",y).call(this)}write(e){F(this,p,"m",G).call(this,e.length),F(this,p,"m",y).call(this).subarray(F(this,O,"f"),F(this,O,"f")+e.length).set(e),D(this,O,F(this,O,"f")+e.length,"f")}remainingFrames(){return Math.floor(F(this,p,"m",T).call(this))}drain(){return F(this,p,"m",R).call(this,F(this,p,"m",P).call(this))}read(){return F(this,p,"m",R).call(this,F(this,b,"f"))}get[(E=new WeakMap,S=new WeakMap,g=new WeakMap,b=new WeakMap,w=new WeakMap,v=new WeakMap,O=new WeakMap,p=new WeakSet,y=function(){return new(F(this,E,"f"))(F(this,w,"f"))},T=function(){return F(this,p,"m",P).call(this)/F(this,b,"f")},P=function(){return F(this,O,"f")-F(this,v,"f")},I=function(){return F(this,g,"f")>0&&F(this,p,"m",T).call(this)>=F(this,g,"f")},R=function(e){if(!e)return null;if(F(this,p,"m",P).call(this)<e)return null;let t=F(this,p,"m",y).call(this).subarray(F(this,v,"f"),F(this,v,"f")+e);if(D(this,v,F(this,v,"f")+e,"f"),F(this,v,"f")===F(this,O,"f")&&(D(this,O,0,"f"),D(this,v,0,"f")),F(this,p,"m",I).call(this)){const e=this.drain();e&&(t=t.slice(0),this.write(e))}return t},G=function(e){const t=e*F(this,E,"f").BYTES_PER_ELEMENT;if(F(this,p,"m",y).call(this).length-F(this,O,"f")<=e){const e=F(this,w,"f");D(this,w,new ArrayBuffer(e.byteLength+t+F(this,p,"m",A).call(this)),"f"),F(this,p,"m",y).call(this).set(new(F(this,E,"f"))(e))}return F(this,p,"m",y).call(this).subarray(F(this,v,"f"),F(this,v,"f")+F(this,b,"f"))},A=function(){return F(this,b,"f")*F(this,E,"f").BYTES_PER_ELEMENT*F(this,S,"f")},Symbol.toStringTag)](){return"RingBuffer"}[Symbol.iterator](){return this[Symbol.asyncIterator]()}*[Symbol.asyncIterator](){let e;do{e=this.read(),null!==e&&(yield e)}while(null!==e)}}class B extends U{constructor(e,t={}){super(Object.assign(Object.assign({},t),{frameSize:e,TypedArrayConstructor:Float32Array}))}get[Symbol.toStringTag](){return"RingBufferF32"}}Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag;let L={queue:new Set};function C(){return crypto.getRandomValues(new Uint32Array(4)).join("-")}function x(e,t=[]){return postMessage(e,t)}const N=async t=>{if("queue"in L){switch(t.type){case e.InitializeWorker:{const e=L.queue,s={runtime:new r(await n({wasmFileHref:t.data.wasmFileHref})),encoders:new Map,decoders:new Map};L=s;for(const t of e)await N(t);e.clear(),x({requestId:t.requestId,value:null});break}default:L.queue.add(t)}return}const{runtime:s,encoders:i,decoders:a}=L;switch(t.type){case e.CreateEncoder:{const e=new f(s,t.data.sampleRate,t.data.channels,t.data.application,t.data.outBufferLength,t.data.pcmBufferLength),r=C();i.set(r,{sampleRate:t.data.sampleRate,ringBuffer:new B(t.data.pcmBufferLength/Float32Array.BYTES_PER_ELEMENT),encoder:e}),x({requestId:t.requestId,value:r});break}case e.CreateDecoder:{const e=new o(s,t.data.sampleRate,t.data.channels,t.data.frameSize),r=C();a.set(r,e),x({requestId:t.requestId,value:r});break}case e.DestroyEncoder:{const e=i.get(t.data);if(!e)throw new Error("Failed to get encoder");i.delete(t.data),e.encoder.destroy(),x(e?{requestId:t.requestId,value:null}:{requestId:t.requestId,failures:[`failed to find encoder with id: ${t.data}`]});break}case e.DestroyDecoder:{const e=a.get(t.data.decoderId);a.delete(t.data.decoderId),e&&e.destroy(),x(e?{requestId:t.requestId,value:null}:{requestId:t.requestId,failures:[`failed to find decoder with id: ${t.data.decoderId}`]});break}case e.EncodeFloat:{const e=i.get(t.data.encoderId);if(!e)throw new Error("Failed to get encoder");const r=null===t.data.input;t.data.input&&e.ringBuffer.write(t.data.input.pcm);const s=e.ringBuffer.read()??(r?e.ringBuffer.drain():null);if(null===s){x({requestId:t.requestId,value:{encoded:null}});break}const a=e.encoder.encodeFloat(s,s.length,t.data.maxDataBytes),o={buffer:new ArrayBuffer(a),duration:a/e.sampleRate};new Uint8Array(o.buffer).set(e.encoder.encoded().subarray(0,a)),x({requestId:t.requestId,value:{encoded:o}},[o.buffer]);break}case e.DecodeFloat:{const e=a.get(t.data.decoderId);let r;if(e){const s=e.decodeFloat(new Uint8Array(t.data.encoded),t.data.decodeFec);r=e.decoded().slice(0,s)}else r=null;x(r?{requestId:t.requestId,value:{decoded:r.buffer}}:{requestId:t.requestId,failures:[`no decoder found for decoder id: ${t.data.decoderId}`]},r?[r.buffer]:[]);break}case e.OpusSetRequest:{const e=i.get(t.data.encoderId);x(e?.encoder?{value:d(e.encoder,t.data),requestId:t.requestId}:{requestId:t.requestId,failures:[`no encoder found for: ${t.data.encoderId}`]});break}case e.OpusGetRequest:{const e=i.get(t.data.encoderId);x(e?.encoder?{value:l(e.encoder,t.data),requestId:t.requestId}:{requestId:t.requestId,failures:[`no encoder found for: ${t.data.encoderId}`]});break}}};onmessage=e=>{const t=e.data;N(t).catch(e=>{console.error("failed to process request: %o",{request:t,reason:e})})}})()})();
|
|
1
|
+
/*! For license information please see worker.js.LICENSE.txt */
|
|
2
|
+
(()=>{var e,t,r={178(){},306(){}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var i=Object.create(null);o.r(i);var a={};e=e||[null,t({}),t([]),t(t)];for(var s=2&n&&r;("object"==typeof s||"function"==typeof s)&&!~e.indexOf(s);s=t(s))Object.getOwnPropertyNames(s).forEach(e=>a[e]=()=>r[e]);return a.default=()=>r,o.d(i,a),i},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{"use strict";var e;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function r(e){if(null!=e){var r=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(t(e)+" is not iterable")}function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function a(e,r,n){return(r=function(e){var r=function(e){if("object"!=t(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==t(r)?r:r+""}(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function s(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var s=n&&n.prototype instanceof c?n:c,l=Object.create(s.prototype);return u(l,"_invoke",function(r,n,o){var i,s,u,c=0,l=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,s=0,u=e,h.n=r,a}};function d(r,n){for(s=r,u=n,t=0;!f&&c&&!o&&t<l.length;t++){var o,i=l[t],d=h.p,p=i[2];r>3?(o=p===n)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(s=0,h.v=n,h.n=i[1]):d<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,h.n=p,s=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,p){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,p),s=l,u=p;(t=s<2?e:u)||!f;){i||(s?s<3?(s>1&&(h.n=-1),d(s,u)):h.n=u:h.v=u);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(f=h.n<0)?u:r.call(n,h))!==a)break}catch(t){i=e,s=1,u=t}finally{c=1}}return{value:t,done:f}}}(r,o,i),!0),l}var a={};function c(){}function l(){}function f(){}t=Object.getPrototypeOf;var h=[][n]?t(t([][n]())):(u(t={},n,function(){return this}),t),d=f.prototype=c.prototype=Object.create(h);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,u(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=f,u(d,"constructor",f),u(f,"constructor",l),l.displayName="GeneratorFunction",u(f,o,"GeneratorFunction"),u(d),u(d,o,"Generator"),u(d,n,function(){return this}),u(d,"toString",function(){return"[object Generator]"}),(s=function(){return{w:i,m:p}})()}function u(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}u=function(e,t,r,n){function i(t,r){u(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},u(e,t,r,n)}function c(e,t,r,n,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,o)}function l(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){c(i,n,o,a,s,"next",e)}function s(e){c(i,n,o,a,s,"throw",e)}a(void 0)})}}function f(e){return h.apply(this,arguments)}function h(){return(h=l(s().m(function e(t){var r,n,i,a,u,c,l,f;return s().w(function(e){for(;;)switch(e.n){case 0:if(r=t.wasmFileHref,n=t.importObject,!("process"in globalThis)||"nodejs"!==process.env.RUNTIME){e.n=4;break}return e.n=1,Promise.resolve().then(o.t.bind(o,306,19));case 1:return a=e.v,e.n=2,Promise.resolve().then(o.t.bind(o,178,19));case 2:return u=e.v,c=u.resolve("/","index.wasm"),e.n=3,a.promises.readFile(c);case 3:l=e.v,i=WebAssembly.instantiate(l,n),e.n=8;break;case 4:if("string"==typeof r){e.n=5;break}throw new Error("Invalid wasmFileHref");case 5:return e.n=6,fetch(r);case 6:return f=e.v,e.n=7,WebAssembly.instantiateStreaming(f,n);case 7:i=e.v;case 8:return e.a(2,i)}},e)}))).apply(this,arguments)}function d(){return d=l(s().m(function e(){var t,n,o,a,u,c,l,h,d,p=arguments;return s().w(function(e){for(;;)switch(e.n){case 0:n=(p.length>0&&void 0!==p[0]?p[0]:{}).wasmFileHref,o={},a=s().m(function e(){var t;return s().w(function(e){for(;;)switch(e.n){case 0:t=c[u],o[t]=function(e){return console.log("[%s] called with %o",t,e),0};case 1:return e.a(2)}},e)}),u=0,c=["args_get","args_sizes_get","fd_close","fd_seek","fd_write","proc_exit"];case 1:if(!(u<c.length)){e.n=3;break}return e.d(r(a()),2);case 2:u++,e.n=1;break;case 3:return l={wasi_snapshot_preview1:o},e.n=4,f({wasmFileHref:n,importObject:l});case 4:if(h=e.v,null!==(d=null!==(t=h.instance.exports.memory)&&void 0!==t?t:null)){e.n=5;break}throw new Error("Memory was expected to be imported but is null");case 5:return e.a(2,i(i({},h.instance.exports),{},{memory:d}))}},e)})),d.apply(this,arguments)}!function(e){e[e.CreateEncoder=0]="CreateEncoder",e[e.CreateDecoder=1]="CreateDecoder",e[e.EncodeFloat=2]="EncodeFloat",e[e.DecodeFloat=3]="DecodeFloat",e[e.DestroyEncoder=4]="DestroyEncoder",e[e.InitializeWorker=5]="InitializeWorker",e[e.DestroyDecoder=6]="DestroyDecoder",e[e.OpusGetRequest=7]="OpusGetRequest",e[e.OpusSetRequest=8]="OpusSetRequest"}(e||(e={}));const p=function(){return d.apply(this,arguments)};function y(e){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(e)}function v(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,b(n.key),n)}}function b(e){var t=function(e){if("object"!=y(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==y(t)?t:t+""}function m(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function w(e,t){return e.get(_(e,t))}function g(e,t,r){return e.set(_(e,t),r),r}function _(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var S=new WeakMap,E=new WeakMap,P=function(){return e=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),m(this,S,void 0),m(this,E,void 0),g(S,this,t),g(E,this,t.malloc(t.originalRuntime().size_of_int()))},(t=[{key:"value",value:function(){if(4!==w(S,this).originalRuntime().size_of_int())throw new Error("invalid integer byte size");return w(S,this).view().getInt32(w(E,this),!0)}},{key:"set",value:function(e){w(S,this).view().setInt32(w(E,this),e,!0)}},{key:"size",value:function(){return w(S,this).originalRuntime().size_of_int()}},{key:"offset",value:function(){if(0===w(E,this))throw new Error("Integer has been destroyed");return w(E,this)}},{key:"destroy",value:function(){w(S,this).free(w(E,this)),g(E,this,0)}},{key:Symbol.dispose,value:function(){this.destroy()}}])&&v(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function k(e){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},k(e)}function T(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||O(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){if(e){if("string"==typeof e)return I(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(e,t):void 0}}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function R(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,j(n.key),n)}}function j(e){var t=function(e){if("object"!=k(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=k(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==k(t)?t:t+""}function G(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function A(e,t){return e.get(D(e,t))}function D(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var F=new WeakMap,C=new WeakMap,x=function(){return e=function e(t){var r,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),G(this,F,void 0),G(this,C,new Map),n=t,(r=F).set(D(r,this),n)},t=[{key:"originalRuntime",value:function(){return A(F,this)}},{key:"subarray",value:function(e,t){return new Uint8Array(A(F,this).memory.buffer,e,t-e)}},{key:"free",value:function(e){A(C,this).delete(e),A(F,this).free(e)}},{key:"view",value:function(){return new DataView(A(F,this).memory.buffer)}},{key:"malloc",value:function(e){var t,r=A(F,this).malloc(e);if(!r)throw new Error("Failed to allocate ".concat(e," bytes"));var n=null!==(t=(new Error).stack)&&void 0!==t?t:null;return A(C,this).set(r,n),r}},{key:Symbol.dispose,value:function(){var e,t=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=O(e))){t&&(e=t);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(A(C,this));try{for(t.s();!(e=t.n()).done;){var r=T(e.value,2),n=r[0],o=r[1];throw new Error("Memory leak detected at offset ".concat(n,"\nAllocation stack:\n").concat(o))}}catch(e){t.e(e)}finally{t.f()}}}],t&&R(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function B(e){return B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},B(e)}function L(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,U(n.key),n)}}function U(e){var t=function(e){if("object"!=B(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=B(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==B(t)?t:t+""}function M(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function N(e,t){return e.get(q(e,t))}function W(e,t,r){return e.set(q(e,t),r),r}function q(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var z=new WeakMap,H=new WeakMap,V=new WeakMap,X=function(){return e=function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),M(this,z,void 0),M(this,H,void 0),M(this,V,void 0),W(V,this,t),W(H,this,r),W(z,this,t.malloc(r))},(t=[{key:"offset",value:function(){return N(z,this)}},{key:"data",value:function(){return N(V,this).subarray(N(z,this),N(z,this)+N(H,this))}},{key:"size",value:function(){return N(H,this)}},{key:"destroy",value:function(){N(V,this).free(N(z,this)),W(z,this,0)}},{key:Symbol.dispose,value:function(){this.destroy()}}])&&L(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function Y(e){return Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Y(e)}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function K(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,J(n.key),n)}}function J(e){var t=function(e){if("object"!=Y(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Y(t)?t:t+""}function Q(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function Z(e,t){return e.get(ee(e,t))}function ee(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var te=new WeakMap,re=new WeakMap,ne=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Q(this,te,new Set),Q(this,re,!1)},(t=[{key:"add",value:function(e){Z(te,this).add(e)}},{key:"destroy",value:function(){if(Z(re,this))throw new Error("ResourcesHolder already destroyed");var e,t,r,n=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return $(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?$(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}(Z(te,this));try{for(n.s();!(e=n.n()).done;)e.value.destroy()}catch(e){n.e(e)}finally{n.f()}Z(te,this).clear(),r=this,(t=re).set(ee(t,r),!0)}},{key:Symbol.dispose,value:function(){this.destroy()}}])&&K(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();class oe extends Error{constructor(e){super(e)}}function ie({name:e,value:t,validations:r}){const n=new Array;if(r.integer&&!Number.isSafeInteger(t)&&n.push("It must be an integer."),t>r.max&&n.push(`It must be up to ${r.max}.`),t<r.min&&n.push(`It must be at least ${r.min}.`),n.length>0)throw new oe([`"${t}" is not a valid value for ${e}. It failed to following validations:\n`,...n.map(e=>`\t- ${e}`)].join(""));return t}var ae,se,ue,ce,le,fe,he,de,pe,ye,ve,be,me,we,ge,_e=function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},Se=function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};const Ee=4294967295;class Pe{constructor({frameSize:e,frameCacheSize:t=0,preallocateFrameCount:r=10,TypedArrayConstructor:n}){if(ae.add(this),se.set(this,void 0),ue.set(this,void 0),ce.set(this,void 0),le.set(this,void 0),fe.set(this,void 0),he.set(this,void 0),de.set(this,void 0),_e(this,le,ie({value:e,name:"Frame Size",validations:{min:1,integer:!0,max:Ee}}),"f"),_e(this,ue,ie({value:r,name:"Preallocate Frame Count",validations:{min:1,integer:!0,max:Ee}}),"f"),_e(this,ce,ie({value:t,name:"Frame Cache Size",validations:{min:0,integer:!1,max:Ee}}),"f"),!("BYTES_PER_ELEMENT"in n))throw new oe("TypedArrayConstructor must be a typed array");_e(this,he,0,"f"),_e(this,de,0,"f"),_e(this,se,n,"f"),_e(this,fe,new ArrayBuffer(Se(this,ae,"m",ge).call(this)),"f")}empty(){return Se(this,ae,"m",ve).call(this)<Se(this,le,"f")}peek(){return Se(this,ae,"m",pe).call(this)}write(e){Se(this,ae,"m",we).call(this,e.length),Se(this,ae,"m",pe).call(this).subarray(Se(this,de,"f"),Se(this,de,"f")+e.length).set(e),_e(this,de,Se(this,de,"f")+e.length,"f")}remainingFrames(){return Math.floor(Se(this,ae,"m",ye).call(this))}drain(){return Se(this,ae,"m",me).call(this,Se(this,ae,"m",ve).call(this))}read(){return Se(this,ae,"m",me).call(this,Se(this,le,"f"))}get[(se=new WeakMap,ue=new WeakMap,ce=new WeakMap,le=new WeakMap,fe=new WeakMap,he=new WeakMap,de=new WeakMap,ae=new WeakSet,pe=function(){return new(Se(this,se,"f"))(Se(this,fe,"f"))},ye=function(){return Se(this,ae,"m",ve).call(this)/Se(this,le,"f")},ve=function(){return Se(this,de,"f")-Se(this,he,"f")},be=function(){return Se(this,ce,"f")>0&&Se(this,ae,"m",ye).call(this)>=Se(this,ce,"f")},me=function(e){if(!e)return null;if(Se(this,ae,"m",ve).call(this)<e)return null;let t=Se(this,ae,"m",pe).call(this).subarray(Se(this,he,"f"),Se(this,he,"f")+e);if(_e(this,he,Se(this,he,"f")+e,"f"),Se(this,he,"f")===Se(this,de,"f")&&(_e(this,de,0,"f"),_e(this,he,0,"f")),Se(this,ae,"m",be).call(this)){const e=this.drain();e&&(t=t.slice(0),this.write(e))}return t},we=function(e){const t=e*Se(this,se,"f").BYTES_PER_ELEMENT;if(Se(this,ae,"m",pe).call(this).length-Se(this,de,"f")<=e){const e=Se(this,fe,"f");_e(this,fe,new ArrayBuffer(e.byteLength+t+Se(this,ae,"m",ge).call(this)),"f"),Se(this,ae,"m",pe).call(this).set(new(Se(this,se,"f"))(e))}return Se(this,ae,"m",pe).call(this).subarray(Se(this,he,"f"),Se(this,he,"f")+Se(this,le,"f"))},ge=function(){return Se(this,le,"f")*Se(this,se,"f").BYTES_PER_ELEMENT*Se(this,ue,"f")},Symbol.toStringTag)](){return"RingBuffer"}[Symbol.iterator](){return this[Symbol.asyncIterator]()}*[Symbol.asyncIterator](){let e;do{e=this.read(),null!==e&&(yield e)}while(null!==e)}}class ke extends Pe{constructor(e,t={}){super(Object.assign(Object.assign({},t),{frameSize:e,TypedArrayConstructor:Float32Array}))}get[Symbol.toStringTag](){return"RingBufferF32"}}Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag;const Te=0;function Oe(e){return Oe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Oe(e)}function Ie(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Re(n.key),n)}}function Re(e){var t=function(e){if("object"!=Oe(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Oe(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Oe(t)?t:t+""}function je(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function Ge(e,t){return e.get(De(e,t))}function Ae(e,t,r){return e.set(De(e,t),r),r}function De(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var Fe=new WeakMap,Ce=new WeakMap,xe=new WeakMap,Be=function(){return e=function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),je(this,Fe,void 0),je(this,Ce,void 0),je(this,xe,void 0),Ae(Ce,this,t),Ae(xe,this,new P(t)),Ae(Fe,this,r)},(t=[{key:"setComplexity",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_complexity(Ge(Fe,this),e)===Te}},{key:"getComplexity",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_complexity(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_COMPLEXITY");return Ge(xe,this).value()}},{key:"setBitrate",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_bitrate(Ge(Fe,this),e)===Te}},{key:"getBitrate",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_bitrate(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_BITRATE");return Ge(xe,this).value()}},{key:"setVbr",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_vbr(Ge(Fe,this),e)===Te}},{key:"getVbr",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_vbr(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_VBR");return Ge(xe,this).value()}},{key:"setVbrConstraint",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_vbr_constraint(Ge(Fe,this),e)===Te}},{key:"getVbrConstraint",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_vbr_constraint(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_VBR_CONSTRAINT");return Ge(xe,this).value()}},{key:"setForceChannels",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_force_channels(Ge(Fe,this),e)===Te}},{key:"getForceChannels",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_force_channels(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_FORCE_CHANNELS");return Ge(xe,this).value()}},{key:"setMaxBandwidth",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_max_bandwidth(Ge(Fe,this),e)===Te}},{key:"getMaxBandwidth",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_max_bandwidth(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_MAX_BANDWIDTH");return Ge(xe,this).value()}},{key:"setBandwidth",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_bandwidth(Ge(Fe,this),e)===Te}},{key:"setSignal",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_signal(Ge(Fe,this),e)===Te}},{key:"getSignal",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_signal(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_SIGNAL");return Ge(xe,this).value()}},{key:"setApplication",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_application(Ge(Fe,this),e)===Te}},{key:"getApplication",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_application(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_APPLICATION");return Ge(xe,this).value()}},{key:"getLookahead",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_lookahead(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_LOOKAHEAD");return Ge(xe,this).value()}},{key:"setInbandFec",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_inband_fec(Ge(Fe,this),e)===Te}},{key:"getInbandFec",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_inband_fec(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_INBAND_FEC");return Ge(xe,this).value()}},{key:"setPacketLossperc",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_packet_loss_perc(Ge(Fe,this),e)===Te}},{key:"getPacketLossperc",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_packet_loss_perc(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_PACKET_LOSS_PERC");return Ge(xe,this).value()}},{key:"setDtx",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_dtx(Ge(Fe,this),e)===Te}},{key:"getDtx",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_dtx(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_DTX");return Ge(xe,this).value()}},{key:"setLsbDepth",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_lsb_depth(Ge(Fe,this),e)===Te}},{key:"getLsbDepth",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_lsb_depth(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_LSB_DEPTH");return Ge(xe,this).value()}},{key:"setExpertFrameduration",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_expert_frame_duration(Ge(Fe,this),e)===Te}},{key:"getExpertFrameduration",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_expert_frame_duration(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_EXPERT_FRAME_DURATION");return Ge(xe,this).value()}},{key:"setPredictionDisabled",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_prediction_disabled(Ge(Fe,this),e)===Te}},{key:"getPredictionDisabled",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_prediction_disabled(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_PREDICTION_DISABLED");return Ge(xe,this).value()}},{key:"getBandwidth",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_bandwidth(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_BANDWIDTH");return Ge(xe,this).value()}},{key:"getSampleRate",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_sample_rate(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_SAMPLE_RATE");return Ge(xe,this).value()}},{key:"setPhaseInversiondisabled",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_phase_inversion_disabled(Ge(Fe,this),e)===Te}},{key:"getPhaseInversiondisabled",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_phase_inversion_disabled(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_PHASE_INVERSION_DISABLED");return Ge(xe,this).value()}},{key:"getInDtx",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_in_dtx(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_IN_DTX");return Ge(xe,this).value()}},{key:"setGain",value:function(e){return Ge(Ce,this).originalRuntime().opus_set_gain(Ge(Fe,this),e)===Te}},{key:"getGain",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_gain(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_GAIN");return Ge(xe,this).value()}},{key:"getLastPacketduration",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_last_packet_duration(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_LAST_PACKET_DURATION");return Ge(xe,this).value()}},{key:"getPitch",value:function(){if(Ge(Ce,this).originalRuntime().opus_get_pitch(Ge(Fe,this),Ge(xe,this).offset())!=Te)throw new Error("Failed to get OPUS_GET_PITCH");return Ge(xe,this).value()}},{key:"destroy",value:function(){Ge(xe,this).destroy()}},{key:Symbol.dispose,value:function(){this.destroy()}}])&&Ie(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function Le(e){return Le="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Le(e)}function Ue(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Me(n.key),n)}}function Me(e){var t=function(e){if("object"!=Le(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Le(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Le(t)?t:t+""}function Ne(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Ne=function(){return!!e})()}function We(){return We="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=qe(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(arguments.length<3?e:r):o.value}},We.apply(null,arguments)}function qe(e){return qe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},qe(e)}function ze(e,t){return ze=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ze(e,t)}function He(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function Ve(e,t){return e.get(Ye(e,t))}function Xe(e,t,r){return e.set(Ye(e,t),r),r}function Ye(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var $e=new WeakMap,Ke=new WeakMap,Je=new WeakMap,Qe=new WeakMap,Ze=new WeakMap,et=new WeakMap,tt=function(e){function t(e,r,n,o,i,a){var s;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),!i)throw new Error("Output buffer length must be more than 0");var u=new P(e),c=e.originalRuntime().opus_encoder_create(r,n,o,u.offset());if(He(s=function(e,t,r){return t=qe(t),function(e,t){if(t&&("object"==Le(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,Ne()?Reflect.construct(t,r||[],qe(e).constructor):t.apply(e,r))}(this,t,[e,c]),$e,void 0),He(s,Ke,void 0),He(s,Je,void 0),He(s,Qe,void 0),He(s,Ze,void 0),He(s,et,void 0),Xe(et,s,new ne),Xe($e,s,u),Xe(Ke,s,e),Xe(Ze,s,new X(e,a)),Xe(Qe,s,new X(e,i)),Ve(et,s).add(Ve(Qe,s)),Ve(et,s).add(Ve(Ze,s)),Ve(et,s).add(Ve($e,s)),Xe(Je,s,c),u.value()<0)throw s.destroy(),new Error("Failed to create encoder");return s}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ze(e,t)}(t,e),r=t,n=[{key:"encoded",value:function(){return Ve(Qe,this).data()}},{key:"encodeFloat",value:function(e,t,r){if(r>Ve(Qe,this).size())throw new Error("encoded buffer length is ".concat(Ve(Qe,this).size(),", but maxDataBytes is ").concat(r));Ve(Ze,this).data().set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));var n=Ve(Ke,this).originalRuntime().opus_encode_float(Ve(Je,this),Ve(Ze,this).offset(),t,Ve(Qe,this).offset(),r);if(n<0)throw new Error("Failed to encode float: ".concat(n));return n}},{key:"destroy",value:function(){var e,r,n;(e=t,r=this,"function"==typeof(n=We(qe(1&3?e.prototype:e),"destroy",r))?function(e){return n.apply(r,e)}:n)([]),Ve(et,this).destroy(),Ve(Ke,this).originalRuntime().opus_encoder_destroy(Ve(Je,this))}},{key:Symbol.dispose,value:function(){this.destroy()}}],n&&Ue(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(Be);function rt(e){return rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},rt(e)}function nt(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,ot(n.key),n)}}function ot(e){var t=function(e){if("object"!=rt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=rt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==rt(t)?t:t+""}function it(e,t,r){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,r)}function at(e,t){return e.get(ut(e,t))}function st(e,t,r){return e.set(ut(e,t),r),r}function ut(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var ct,lt=new WeakMap,ft=new WeakMap,ht=new WeakMap,dt=new WeakMap,pt=new WeakMap,yt=new WeakMap,vt=new WeakMap,bt=function(){return e=function e(t,r,n,o){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),it(this,lt,void 0),it(this,ft,void 0),it(this,ht,void 0),it(this,dt,void 0),it(this,pt,void 0),it(this,yt,void 0),it(this,vt,null),st(yt,this,o),st(dt,this,t),st(ht,this,new ne),st(lt,this,new P(t)),at(ht,this).add(at(lt,this)),st(ft,this,t.originalRuntime().opus_decoder_create(r,n,at(lt,this).offset())),!at(ft,this)||at(lt,this).value()<0)throw new Error("Failed to create decoder");st(pt,this,new X(t,at(yt,this)*n*Float32Array.BYTES_PER_ELEMENT)),at(ht,this).add(at(pt,this))},t=[{key:"decodeFloat",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=at(vt,this);r||(r=new X(at(dt,this),e.byteLength)),r.data().byteLength<e.byteLength&&(r.destroy(),r=new X(at(dt,this),e.byteLength)),r.data().set(e),st(vt,this,r);var n=at(dt,this).originalRuntime().opus_decode_float(at(ft,this),r.offset(),e.byteLength,at(pt,this).offset(),at(yt,this),t);if(n<0)throw new Error("Failed to decode float");return n}},{key:"decoded",value:function(){var e=at(pt,this).data();return new Float32Array(e.buffer,e.byteOffset,e.byteLength/Float32Array.BYTES_PER_ELEMENT)}},{key:"destroy",value:function(){var e;at(dt,this).originalRuntime().opus_decoder_destroy(at(ft,this)),at(ht,this).destroy(),null===(e=at(vt,this))||void 0===e||e.destroy()}},{key:Symbol.dispose,value:function(){this.destroy()}}],t&&nt(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function mt(e,t){var r;switch(t.type){case ct.SetComplexity:r=e.setComplexity(t.value);break;case ct.SetBitrate:r=e.setBitrate(t.value);break;case ct.SetVbr:r=e.setVbr(t.value);break;case ct.SetVbrConstraint:r=e.setVbrConstraint(t.value);break;case ct.SetForceChannels:r=e.setForceChannels(t.value);break;case ct.SetMaxBandwidth:r=e.setMaxBandwidth(t.value);break;case ct.SetBandwidth:r=e.setBandwidth(t.value);break;case ct.SetSignal:r=e.setSignal(t.value);break;case ct.SetApplication:r=e.setApplication(t.value);break;case ct.SetInbandFec:r=e.setInbandFec(t.value);break;case ct.SetPacketLossperc:r=e.setPacketLossperc(t.value);break;case ct.SetDtx:r=e.setDtx(t.value);break;case ct.SetLsbDepth:r=e.setLsbDepth(t.value);break;case ct.SetExpertFrameduration:r=e.setExpertFrameduration(t.value);break;case ct.SetPredictionDisabled:r=e.setPredictionDisabled(t.value);break;case ct.SetPhaseInversiondisabled:r=e.setPhaseInversiondisabled(t.value);break;case ct.SetGain:r=e.setGain(t.value)}return r}function wt(e,t){var r;switch(t.type){case ct.GetComplexity:r=e.getComplexity();break;case ct.GetBitrate:r=e.getBitrate();break;case ct.GetVbr:r=e.getVbr();break;case ct.GetVbrConstraint:r=e.getVbrConstraint();break;case ct.GetForceChannels:r=e.getForceChannels();break;case ct.GetMaxBandwidth:r=e.getMaxBandwidth();break;case ct.GetSignal:r=e.getSignal();break;case ct.GetApplication:r=e.getApplication();break;case ct.GetLookahead:r=e.getLookahead();break;case ct.GetInbandFec:r=e.getInbandFec();break;case ct.GetPacketLossperc:r=e.getPacketLossperc();break;case ct.GetDtx:r=e.getDtx();break;case ct.GetLsbDepth:r=e.getLsbDepth();break;case ct.GetExpertFrameduration:r=e.getExpertFrameduration();break;case ct.GetPredictionDisabled:r=e.getPredictionDisabled();break;case ct.GetBandwidth:r=e.getBandwidth();break;case ct.GetSampleRate:r=e.getSampleRate();break;case ct.GetPhaseInversiondisabled:r=e.getPhaseInversiondisabled();break;case ct.GetInDtx:r=e.getInDtx();break;case ct.GetGain:r=e.getGain();break;case ct.GetLastPacketduration:r=e.getLastPacketduration();break;case ct.GetPitch:r=e.getPitch()}return r}function gt(e){return gt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gt(e)}function _t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,St(n.key),n)}}function St(e){var t=function(e){if("object"!=gt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=gt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==gt(t)?t:t+""}function Et(e,t,r){Pt(e,t),t.set(e,r)}function Pt(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function kt(e,t){return e.get(Ot(e,t))}function Tt(e,t,r){return e.set(Ot(e,t),r),r}function Ot(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}!function(e){e.SetComplexity="OPUS_SET_COMPLEXITY",e.GetComplexity="OPUS_GET_COMPLEXITY",e.SetBitrate="OPUS_SET_BITRATE",e.GetBitrate="OPUS_GET_BITRATE",e.SetVbr="OPUS_SET_VBR",e.GetVbr="OPUS_GET_VBR",e.SetVbrConstraint="OPUS_SET_VBR_CONSTRAINT",e.GetVbrConstraint="OPUS_GET_VBR_CONSTRAINT",e.SetForceChannels="OPUS_SET_FORCE_CHANNELS",e.GetForceChannels="OPUS_GET_FORCE_CHANNELS",e.SetMaxBandwidth="OPUS_SET_MAX_BANDWIDTH",e.GetMaxBandwidth="OPUS_GET_MAX_BANDWIDTH",e.SetBandwidth="OPUS_SET_BANDWIDTH",e.SetSignal="OPUS_SET_SIGNAL",e.GetSignal="OPUS_GET_SIGNAL",e.SetApplication="OPUS_SET_APPLICATION",e.GetApplication="OPUS_GET_APPLICATION",e.GetLookahead="OPUS_GET_LOOKAHEAD",e.SetInbandFec="OPUS_SET_INBAND_FEC",e.GetInbandFec="OPUS_GET_INBAND_FEC",e.SetPacketLossperc="OPUS_SET_PACKET_LOSS_PERC",e.GetPacketLossperc="OPUS_GET_PACKET_LOSS_PERC",e.SetDtx="OPUS_SET_DTX",e.GetDtx="OPUS_GET_DTX",e.SetLsbDepth="OPUS_SET_LSB_DEPTH",e.GetLsbDepth="OPUS_GET_LSB_DEPTH",e.SetExpertFrameduration="OPUS_SET_EXPERT_FRAME_DURATION",e.GetExpertFrameduration="OPUS_GET_EXPERT_FRAME_DURATION",e.SetPredictionDisabled="OPUS_SET_PREDICTION_DISABLED",e.GetPredictionDisabled="OPUS_GET_PREDICTION_DISABLED",e.GetBandwidth="OPUS_GET_BANDWIDTH",e.GetSampleRate="OPUS_GET_SAMPLE_RATE",e.SetPhaseInversiondisabled="OPUS_SET_PHASE_INVERSION_DISABLED",e.GetPhaseInversiondisabled="OPUS_GET_PHASE_INVERSION_DISABLED",e.GetInDtx="OPUS_GET_IN_DTX",e.SetGain="OPUS_SET_GAIN",e.GetGain="OPUS_GET_GAIN",e.GetLastPacketduration="OPUS_GET_LAST_PACKET_DURATION",e.GetPitch="OPUS_GET_PITCH"}(ct||(ct={}));var It=new WeakMap,Rt=new WeakMap,jt=new WeakSet,Gt=function(){return e=function e(t){var r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Pt(this,r=jt),r.add(this),Et(this,It,void 0),Et(this,Rt,void 0),Tt(It,this,t),Tt(Rt,this,{decoders:new Map,encoders:new Map})},t=[{key:"sendResponse",value:function(e){return postMessage(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:[])}},{key:"onRequest",value:function(e){try{Ot(jt,this,Dt).call(this,e)}catch(r){var t=new Array;"object"===gt(r)&&null!==r&&"message"in r&&"string"==typeof r.message?t.push(r.message):t.push("Unknown error: ".concat(r)),this.sendResponse({requestId:e.requestId,failures:t})}}}],t&&_t(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function At(e,t){var r,n,o,i=null!==(r=kt(Rt,this).encoders.get(e))&&void 0!==r?r:null;if(null===i){var a=new tt(kt(It,this),t.sampleRate,t.channels,t.application,t.outBufferLength,t.pcmBufferLength);i={options:t,id:e,ringBuffer:new ke(t.pcmBufferLength/Float32Array.BYTES_PER_ELEMENT),encoder:a},kt(Rt,this).encoders.set(e,i)}else if(o=t,(n=i.options).application!==o.application||n.channels!==o.channels||n.outBufferLength!==o.outBufferLength||n.pcmBufferLength!==o.pcmBufferLength||n.sampleRate!==o.sampleRate)throw new Error("Encoder with same id but different options already exists");return i}function Dt(t){var r=kt(It,this),n=kt(Rt,this),o=n.encoders,i=n.decoders;switch(t.type){case e.CreateEncoder:this.sendResponse({requestId:t.requestId,value:Ot(jt,this,At).call(this,t.encoderId,t.data).id});break;case e.CreateDecoder:var a,s=null!==(a=i.get(t.decoderId))&&void 0!==a?a:null;if(null===s)s={sampleRate:t.data.sampleRate,channels:t.data.channels,frameSize:t.data.frameSize,decoder:new bt(r,t.data.sampleRate,t.data.channels,t.data.frameSize)};else if(s.sampleRate!==t.data.sampleRate||s.channels!==t.data.channels||s.frameSize!==t.data.frameSize)throw new Error("Decoder with same id but different options already exists");i.set(t.decoderId,s),this.sendResponse({requestId:t.requestId,value:t.decoderId});break;case e.DestroyEncoder:var u,c=null!==(u=o.get(t.data.encoderId))&&void 0!==u?u:null;null!==c&&(o.delete(t.data.encoderId),c.encoder.destroy()),this.sendResponse(c?{requestId:t.requestId,value:null}:{requestId:t.requestId,failures:["Failed to find encoder with id: ".concat(t.data)]});break;case e.DestroyDecoder:var l,f=null!==(l=i.get(t.data.decoderId))&&void 0!==l?l:null;null!==f&&(i.delete(t.data.decoderId),f.decoder.destroy()),this.sendResponse(f?{requestId:t.requestId,value:null}:{requestId:t.requestId,failures:["Failed to find decoder with id: ".concat(t.data.decoderId)]});break;case e.EncodeFloat:var h,d=o.get(t.data.encoderId);if(!d)throw new Error("Failed to get encoder");var p=null===t.data.input;t.data.input&&d.ringBuffer.write(t.data.input.pcm);var y=null!==(h=d.ringBuffer.read())&&void 0!==h?h:p?d.ringBuffer.drain():null;if(null===y){this.sendResponse({requestId:t.requestId,value:{encoded:null}});break}var v=d.encoder.encodeFloat(y,y.length,t.data.maxDataBytes),b={buffer:new ArrayBuffer(v),duration:v/d.options.sampleRate};new Uint8Array(b.buffer).set(d.encoder.encoded().subarray(0,v)),this.sendResponse({requestId:t.requestId,value:{encoded:b}},[b.buffer]);break;case e.DecodeFloat:var m,w,g=null!==(m=i.get(t.data.decoderId))&&void 0!==m?m:null;if(null===g)throw new Error("No decoder found for decoder id: ".concat(t.data.decoderId));var _=g.decoder,S=_.decodeFloat(new Uint8Array(t.data.encoded),t.data.decodeFec);w=_.decoded().slice(0,S),this.sendResponse({requestId:t.requestId,value:{decoded:w.buffer}},null!==w?[w.buffer]:[]);break;case e.OpusSetRequest:var E=o.get(t.data.encoderId);this.sendResponse(null!=E&&E.encoder?{value:mt(E.encoder,t.data),requestId:t.requestId}:{requestId:t.requestId,failures:["No encoder found for: ".concat(t.data.encoderId)]});break;case e.OpusGetRequest:var P,k=null!==(P=o.get(t.data.encoderId))&&void 0!==P?P:null;if(null===k)throw new Error("No encoder found for: ".concat(t.data.encoderId));this.sendResponse({value:wt(k.encoder,t.data),requestId:t.requestId})}}function Ft(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return Ct(c,"_invoke",function(r,n,o){var i,s,u,c=0,l=o||[],f=!1,h={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,s=0,u=e,h.n=r,a}};function d(r,n){for(s=r,u=n,t=0;!f&&c&&!o&&t<l.length;t++){var o,i=l[t],d=h.p,p=i[2];r>3?(o=p===n)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(s=0,h.v=n,h.n=i[1]):d<p&&(o=r<3||i[0]>n||n>p)&&(i[4]=r,i[5]=n,h.n=p,s=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,p){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,p),s=l,u=p;(t=s<2?e:u)||!f;){i||(s?s<3?(s>1&&(h.n=-1),d(s,u)):h.n=u:h.v=u);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(f=h.n<0)?u:r.call(n,h))!==a)break}catch(t){i=e,s=1,u=t}finally{c=1}}return{value:t,done:f}}}(r,o,i),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(Ct(t={},n,function(){return this}),t),f=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Ct(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,Ct(f,"constructor",c),Ct(c,"constructor",u),u.displayName="GeneratorFunction",Ct(c,o,"GeneratorFunction"),Ct(f),Ct(f,o,"Generator"),Ct(f,n,function(){return this}),Ct(f,"toString",function(){return"[object Generator]"}),(Ft=function(){return{w:i,m:h}})()}function Ct(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}Ct=function(e,t,r,n){function i(t,r){Ct(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},Ct(e,t,r,n)}function xt(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Bt(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Bt(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function Bt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Lt(e,t,r,n,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,o)}var Ut={queue:new Set},Mt=function(){var t,r=(t=Ft().m(function t(r){var n,o,i,a,s,u,c,l,f,h,d;return Ft().w(function(t){for(;;)switch(t.p=t.n){case 0:if("queue"in Ut){t.n=1;break}return Ut.onRequest(r),t.a(2);case 1:u=r.type,t.n=u===e.InitializeWorker?2:11;break;case 2:return n=Ut.queue,c=Gt,l=x,t.n=3,p({wasmFileHref:r.data.wasmFileHref});case 3:f=t.v,h=new l(f),o=new c(h),Ut=o,i=xt(n),t.p=4,i.s();case 5:if((a=i.n()).done){t.n=7;break}return s=a.value,t.n=6,Mt(s);case 6:t.n=5;break;case 7:t.n=9;break;case 8:t.p=8,d=t.v,i.e(d);case 9:return t.p=9,i.f(),t.f(9);case 10:return n.clear(),Ut.sendResponse({requestId:r.requestId,value:null}),t.a(3,12);case 11:return Ut.queue.add(r),t.a(3,12);case 12:return t.a(2)}},t,null,[[4,8,9,10]])}),function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(e){Lt(i,n,o,a,s,"next",e)}function s(e){Lt(i,n,o,a,s,"throw",e)}a(void 0)})});return function(e){return r.apply(this,arguments)}}(),Nt=Promise.resolve();onmessage=function(e){var t=e.data;Nt=Nt.then(function(){return Mt(t)}).catch(function(e){console.error("failed to process request: %o",{request:t,reason:e})})}})()})();
|
package/worklet/worklet.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";class t extends Error{constructor(t){super(t)}}function e({name:e,value:i,validations:r}){const s=new Array;if(r.integer&&!Number.isSafeInteger(i)&&s.push("It must be an integer."),i>r.max&&s.push(`It must be up to ${r.max}.`),i<r.min&&s.push(`It must be at least ${r.min}.`),s.length>0)throw new t([`"${i}" is not a valid value for ${e}. It failed to following validations:\n`,...s.map(t=>`\t- ${t}`)].join(""));return i}var i,r,s,n,a,o,h,l,f,u,c,m,d,g,w,p=function(t,e,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(t,i):s?s.value=i:e.set(t,i),i},y=function(t,e,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(t):r?r.value:e.get(t)};const S=4294967295;class v{constructor({frameSize:f,frameCacheSize:u=0,preallocateFrameCount:c=10,TypedArrayConstructor:m}){if(i.add(this),r.set(this,void 0),s.set(this,void 0),n.set(this,void 0),a.set(this,void 0),o.set(this,void 0),h.set(this,void 0),l.set(this,void 0),p(this,a,e({value:f,name:"Frame Size",validations:{min:1,integer:!0,max:S}}),"f"),p(this,s,e({value:c,name:"Preallocate Frame Count",validations:{min:1,integer:!0,max:S}}),"f"),p(this,n,e({value:u,name:"Frame Cache Size",validations:{min:0,integer:!1,max:S}}),"f"),!("BYTES_PER_ELEMENT"in m))throw new t("TypedArrayConstructor must be a typed array");p(this,h,0,"f"),p(this,l,0,"f"),p(this,r,m,"f"),p(this,o,new ArrayBuffer(y(this,i,"m",w).call(this)),"f")}empty(){return y(this,i,"m",c).call(this)<y(this,a,"f")}peek(){return y(this,i,"m",f).call(this)}write(t){y(this,i,"m",g).call(this,t.length),y(this,i,"m",f).call(this).subarray(y(this,l,"f"),y(this,l,"f")+t.length).set(t),p(this,l,y(this,l,"f")+t.length,"f")}remainingFrames(){return Math.floor(y(this,i,"m",u).call(this))}drain(){return y(this,i,"m",d).call(this,y(this,i,"m",c).call(this))}read(){return y(this,i,"m",d).call(this,y(this,a,"f"))}get[(r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,h=new WeakMap,l=new WeakMap,i=new WeakSet,f=function(){return new(y(this,r,"f"))(y(this,o,"f"))},u=function(){return y(this,i,"m",c).call(this)/y(this,a,"f")},c=function(){return y(this,l,"f")-y(this,h,"f")},m=function(){return y(this,n,"f")>0&&y(this,i,"m",u).call(this)>=y(this,n,"f")},d=function(t){if(!t)return null;if(y(this,i,"m",c).call(this)<t)return null;let e=y(this,i,"m",f).call(this).subarray(y(this,h,"f"),y(this,h,"f")+t);if(p(this,h,y(this,h,"f")+t,"f"),y(this,h,"f")===y(this,l,"f")&&(p(this,l,0,"f"),p(this,h,0,"f")),y(this,i,"m",m).call(this)){const t=this.drain();t&&(e=e.slice(0),this.write(t))}return e},g=function(t){const e=t*y(this,r,"f").BYTES_PER_ELEMENT;if(y(this,i,"m",f).call(this).length-y(this,l,"f")<=t){const t=y(this,o,"f");p(this,o,new ArrayBuffer(t.byteLength+e+y(this,i,"m",w).call(this)),"f"),y(this,i,"m",f).call(this).set(new(y(this,r,"f"))(t))}return y(this,i,"m",f).call(this).subarray(y(this,h,"f"),y(this,h,"f")+y(this,a,"f"))},w=function(){return y(this,a,"f")*y(this,r,"f").BYTES_PER_ELEMENT*y(this,s,"f")},Symbol.toStringTag)](){return"RingBuffer"}[Symbol.iterator](){return this[Symbol.asyncIterator]()}*[Symbol.asyncIterator](){let t;do{t=this.read(),null!==t&&(yield t)}while(null!==t)}}class b extends v{constructor(t,e={}){super(Object.assign(Object.assign({},e),{frameSize:t,TypedArrayConstructor:Float32Array}))}get[Symbol.toStringTag](){return"RingBufferF32"}}function E(t){const e=t.length;if(0===e)return new Float32Array(0);const i=t[0].length;for(let r=1;r<e;r++)if(t[r].length!==i)throw new Error("Channel length mismatch");const r=new Float32Array(i*e);for(let s=0,n=0;s<i;s++)for(let i=0;i<e;i++,n++)r[n]=t[i][s];return r}Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag;class T extends AudioWorkletProcessor{#t=null;#e=!0;static get parameterDescriptors(){return[{name:"frameSize"}]}constructor(){super(),this.port.addEventListener("message",this.onMessage),this.port.start()}process(t,e,i){const r=i.frameSize[0];this.#t||(this.#t=new b(r)),t.length||console.error("no data available in input list: %o",t);const s=new Array;for(const e of t)e.length&&s.push(E(e));this.#t.write(E(s));const n=this.#t.read();if(null!==n&&this.port.postMessage({samples:n}),!this.#e){let t;do{t=this.#t.drain(),null!==t&&this.port.postMessage({samples:t})}while(null!==t)}return this.#e}onMessage=t=>{t.data&&t.data.stop&&(this.#e=!1)}}registerProcessor("default-audio-processor",T)})();
|
|
1
|
+
(()=>{"use strict";class t extends Error{constructor(t){super(t)}}function e({name:e,value:r,validations:n}){const i=new Array;if(n.integer&&!Number.isSafeInteger(r)&&i.push("It must be an integer."),r>n.max&&i.push(`It must be up to ${n.max}.`),r<n.min&&i.push(`It must be at least ${n.min}.`),i.length>0)throw new t([`"${r}" is not a valid value for ${e}. It failed to following validations:\n`,...i.map(t=>`\t- ${t}`)].join(""));return r}var r,n,i,o,a,s,u,l,f,c,h,p,y,m,w,v=function(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},b=function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};const d=4294967295;class g{constructor({frameSize:f,frameCacheSize:c=0,preallocateFrameCount:h=10,TypedArrayConstructor:p}){if(r.add(this),n.set(this,void 0),i.set(this,void 0),o.set(this,void 0),a.set(this,void 0),s.set(this,void 0),u.set(this,void 0),l.set(this,void 0),v(this,a,e({value:f,name:"Frame Size",validations:{min:1,integer:!0,max:d}}),"f"),v(this,i,e({value:h,name:"Preallocate Frame Count",validations:{min:1,integer:!0,max:d}}),"f"),v(this,o,e({value:c,name:"Frame Cache Size",validations:{min:0,integer:!1,max:d}}),"f"),!("BYTES_PER_ELEMENT"in p))throw new t("TypedArrayConstructor must be a typed array");v(this,u,0,"f"),v(this,l,0,"f"),v(this,n,p,"f"),v(this,s,new ArrayBuffer(b(this,r,"m",w).call(this)),"f")}empty(){return b(this,r,"m",h).call(this)<b(this,a,"f")}peek(){return b(this,r,"m",f).call(this)}write(t){b(this,r,"m",m).call(this,t.length),b(this,r,"m",f).call(this).subarray(b(this,l,"f"),b(this,l,"f")+t.length).set(t),v(this,l,b(this,l,"f")+t.length,"f")}remainingFrames(){return Math.floor(b(this,r,"m",c).call(this))}drain(){return b(this,r,"m",y).call(this,b(this,r,"m",h).call(this))}read(){return b(this,r,"m",y).call(this,b(this,a,"f"))}get[(n=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakMap,s=new WeakMap,u=new WeakMap,l=new WeakMap,r=new WeakSet,f=function(){return new(b(this,n,"f"))(b(this,s,"f"))},c=function(){return b(this,r,"m",h).call(this)/b(this,a,"f")},h=function(){return b(this,l,"f")-b(this,u,"f")},p=function(){return b(this,o,"f")>0&&b(this,r,"m",c).call(this)>=b(this,o,"f")},y=function(t){if(!t)return null;if(b(this,r,"m",h).call(this)<t)return null;let e=b(this,r,"m",f).call(this).subarray(b(this,u,"f"),b(this,u,"f")+t);if(v(this,u,b(this,u,"f")+t,"f"),b(this,u,"f")===b(this,l,"f")&&(v(this,l,0,"f"),v(this,u,0,"f")),b(this,r,"m",p).call(this)){const t=this.drain();t&&(e=e.slice(0),this.write(t))}return e},m=function(t){const e=t*b(this,n,"f").BYTES_PER_ELEMENT;if(b(this,r,"m",f).call(this).length-b(this,l,"f")<=t){const t=b(this,s,"f");v(this,s,new ArrayBuffer(t.byteLength+e+b(this,r,"m",w).call(this)),"f"),b(this,r,"m",f).call(this).set(new(b(this,n,"f"))(t))}return b(this,r,"m",f).call(this).subarray(b(this,u,"f"),b(this,u,"f")+b(this,a,"f"))},w=function(){return b(this,a,"f")*b(this,n,"f").BYTES_PER_ELEMENT*b(this,i,"f")},Symbol.toStringTag)](){return"RingBuffer"}[Symbol.iterator](){return this[Symbol.asyncIterator]()}*[Symbol.asyncIterator](){let t;do{t=this.read(),null!==t&&(yield t)}while(null!==t)}}class S extends g{constructor(t,e={}){super(Object.assign(Object.assign({},e),{frameSize:t,TypedArrayConstructor:Float32Array}))}get[Symbol.toStringTag](){return"RingBufferF32"}}function E(t){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},E(t)}function T(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function j(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,k(n.key),n)}}function k(t){var e=function(t){if("object"!=E(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=E(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==E(e)?e:e+""}function M(t,e){return t.get(P(t,e))}function P(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag,Symbol.toStringTag;var C,O,W,A=new WeakMap,z=function(){return t=function t(e,r){var n,i;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,r)}(this,A,void 0),n=A,i=new Array,n.set(P(n,this),i);for(var o=0;o<r;o++)M(A,this).push(new S(e,{frameCacheSize:20}))},(e=[{key:"write",value:function(t){if(t.length!==M(A,this).length)throw new Error("Expected ".concat(M(A,this).length," channels, but got ").concat(t.length));for(var e=0;e<t.length;e++)M(A,this)[e].write(t[e])}},{key:"read",value:function(){for(var t=[],e=0;e<M(A,this).length;e++){var r=M(A,this)[e].read();if(null===r)return null;t.push(r.slice(0))}return t}},{key:"remainingFrames",value:function(){var t,e=[],r=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return T(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?T(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(M(A,this));try{for(r.s();!(t=r.n()).done;){var n=t.value;e.push(n.remainingFrames())}}catch(t){r.e(t)}finally{r.f()}return e}},{key:"drain",value:function(){for(var t=[],e=0;e<M(A,this).length;e++){var r=M(A,this)[e].drain();if(null===r)return null;t.push(r.slice(0))}return t.length?t:null}}])&&j(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),_=function(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},x=function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};function F(t,e){return t===e}new WeakMap,new WeakMap,new WeakMap,new WeakMap,new WeakMap,new WeakMap,new WeakMap;class I{constructor(t,e=F){C.set(this,void 0),O.set(this,void 0),W.set(this,void 0),_(this,W,null,"f"),_(this,C,t,"f"),_(this,O,e,"f")}get(t){const e=x(this,W,"f");if(e&&x(this,O,"f").call(this,e.key,t))return e.value;const r=x(this,C,"f").call(this,t);return _(this,W,{key:t,value:r},"f"),r}}function B(t){return B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},B(t)}function R(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function $(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,D(n.key),n)}}function L(t){var e="function"==typeof Map?new Map:void 0;return L=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(N())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var i=new(t.bind.apply(t,n));return r&&Y(i,r.prototype),i}(t,arguments,q(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Y(r,t)},L(t)}function N(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(N=function(){return!!t})()}function Y(t,e){return Y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Y(t,e)}function q(t){return q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},q(t)}function D(t){var e=function(t){if("object"!=B(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=B(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==B(e)?e:e+""}function U(t,e,r){G(t,e),e.set(t,r)}function G(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function H(t,e){return t.get(J(t,e))}function J(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}C=new WeakMap,O=new WeakMap,W=new WeakMap;var K=new WeakMap,Q=new WeakMap,V=new WeakSet,X=function(t){function e(){var t,r,n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=function(t,e,r){return e=q(e),function(t,e){if(e&&("object"==B(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,N()?Reflect.construct(e,r||[],q(t).constructor):e.apply(t,r))}(this,e),G(r=t,n=V),n.add(r),U(t,K,new I(function(t){var e=t.frameSize,r=t.channelCount;return new z(e,r)},function(t,e){return t.frameSize===e.frameSize&&t.channelCount===e.channelCount})),U(t,Q,!0),function(t,e,r){(e=D(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(t,"onMessage",function(e){e.data&&e.data.stop&&function(t,e){t.set(J(t,e),!1)}(Q,t)}),t.port.addEventListener("message",t.onMessage),t.port.start(),t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Y(t,e)}(e,t),r=e,i=[{key:"parameterDescriptors",get:function(){return[{name:"frameSize"},{name:"channelCount"},{name:"queueFrameCount"}]}}],(n=[{key:"process",value:function(t,e,r){var n,i,o,a=J(V,this,Z).call(this,"frameSize",r),s=J(V,this,Z).call(this,"channelCount",r),u=J(V,this,Z).call(this,"queueFrameCount",r),l=H(K,this).get({frameSize:a,channelCount:s}),f=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return R(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?R(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(t);try{for(f.s();!(n=f.n()).done;){var c=n.value;c.length&&l.write(c)}}catch(t){f.e(t)}finally{f.f()}if(l.remainingFrames().some(function(t){return t<u}))return H(Q,this);do{null!==(i=l.read())&&this.port.postMessage({samples:i},i.map(function(t){return t.buffer}))}while(null!==i);if(!H(Q,this))do{null!==(o=l.drain())&&this.port.postMessage({samples:o})}while(null!==o);return H(Q,this)}}])&&$(r.prototype,n),i&&$(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(L(AudioWorkletProcessor));function Z(t,e){var r=e[t];if(!r||0===r.length)throw new Error("Parameter ".concat(t," is missing"));return r[0]}registerProcessor("default-audio-processor",X)})();
|