opus-codec-worker 0.0.10 → 0.0.13

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/worker.js +1 -2457
package/worker.js CHANGED
@@ -1,2457 +1 @@
1
- /******/ (() => { // webpackBootstrap
2
- /******/ var __webpack_modules__ = ({
3
-
4
- /***/ "./actions/actions.js":
5
- /*!****************************!*\
6
- !*** ./actions/actions.js ***!
7
- \****************************/
8
- /***/ ((__unused_webpack_module, exports) => {
9
-
10
- "use strict";
11
-
12
- Object.defineProperty(exports, "__esModule", ({ value: true }));
13
- exports.encodeFloat = exports.createEncoder = exports.RequestType = exports.destroyEncoder = void 0;
14
- function destroyEncoder(encoder) {
15
- return {
16
- type: RequestType.DestroyEncoder,
17
- data: encoder,
18
- requestId: getRequestId()
19
- };
20
- }
21
- exports.destroyEncoder = destroyEncoder;
22
- var RequestType;
23
- (function (RequestType) {
24
- RequestType[RequestType["CreateEncoder"] = 0] = "CreateEncoder";
25
- RequestType[RequestType["EncodeFloat"] = 1] = "EncodeFloat";
26
- RequestType[RequestType["DestroyEncoder"] = 2] = "DestroyEncoder";
27
- })(RequestType = exports.RequestType || (exports.RequestType = {}));
28
- function getRequestId() {
29
- const ids = crypto.getRandomValues(new Int32Array(4));
30
- return ids.join('-');
31
- }
32
- function createEncoder(data) {
33
- return {
34
- data,
35
- requestId: getRequestId(),
36
- type: RequestType.CreateEncoder
37
- };
38
- }
39
- exports.createEncoder = createEncoder;
40
- function encodeFloat(data) {
41
- return {
42
- data,
43
- requestId: getRequestId(),
44
- type: RequestType.EncodeFloat,
45
- transfer: [data.pcm.buffer]
46
- };
47
- }
48
- exports.encodeFloat = encodeFloat;
49
-
50
-
51
- /***/ }),
52
-
53
- /***/ "./node_modules/opus-codec/native/index.js":
54
- /*!*************************************************!*\
55
- !*** ./node_modules/opus-codec/native/index.js ***!
56
- \*************************************************/
57
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
58
-
59
- var __filename = "/index.js";
60
- var __dirname = "/";
61
-
62
- var Module = (() => {
63
- var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
64
- if (true) _scriptDir = _scriptDir || __filename;
65
- return (
66
- function(Module = {}) {
67
-
68
- // include: shell.js
69
- // The Module object: Our interface to the outside world. We import
70
- // and export values on it. There are various ways Module can be used:
71
- // 1. Not defined. We create it here
72
- // 2. A function parameter, function(Module) { ..generated code.. }
73
- // 3. pre-run appended it, var Module = {}; ..generated code..
74
- // 4. External script tag defines var Module.
75
- // We need to check if Module already exists (e.g. case 3 above).
76
- // Substitution will be replaced with actual code on later stage of the build,
77
- // this way Closure Compiler will not mangle it (e.g. case 4. above).
78
- // Note that if you want to run closure, and also to use Module
79
- // after the generated code, you will need to define var Module = {};
80
- // before the code. Then that object will be used in the code, and you
81
- // can continue to use Module afterwards as well.
82
- var Module = typeof Module != 'undefined' ? Module : {};
83
-
84
- // Set up the promise that indicates the Module is initialized
85
- var readyPromiseResolve, readyPromiseReject;
86
- Module['ready'] = new Promise(function(resolve, reject) {
87
- readyPromiseResolve = resolve;
88
- readyPromiseReject = reject;
89
- });
90
- ["_size_of_int","_size_of_void_ptr","_malloc","_free","_opus_decoder_create","_opus_decoder_destroy","_opus_decode_float","_opus_encoder_create","_opus_encoder_destroy","_opus_encode_float","_fflush","onRuntimeInitialized"].forEach((prop) => {
91
- if (!Object.getOwnPropertyDescriptor(Module['ready'], prop)) {
92
- Object.defineProperty(Module['ready'], prop, {
93
- get: () => abort('You are getting ' + prop + ' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js'),
94
- set: () => abort('You are setting ' + prop + ' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js'),
95
- });
96
- }
97
- });
98
-
99
- // --pre-jses are emitted after the Module integration code, so that they can
100
- // refer to Module (if they choose; they can also define Module)
101
-
102
-
103
- // Sometimes an existing Module object exists with properties
104
- // meant to overwrite the default module functionality. Here
105
- // we collect those properties and reapply _after_ we configure
106
- // the current environment's defaults to avoid having to be so
107
- // defensive during initialization.
108
- var moduleOverrides = Object.assign({}, Module);
109
-
110
- var arguments_ = [];
111
- var thisProgram = './this.program';
112
- var quit_ = (status, toThrow) => {
113
- throw toThrow;
114
- };
115
-
116
- // Determine the runtime environment we are in. You can customize this by
117
- // setting the ENVIRONMENT setting at compile time (see settings.js).
118
-
119
- // Attempt to auto-detect the environment
120
- var ENVIRONMENT_IS_WEB = typeof window == 'object';
121
- var ENVIRONMENT_IS_WORKER = typeof importScripts == 'function';
122
- // N.b. Electron.js environment is simultaneously a NODE-environment, but
123
- // also a web environment.
124
- var ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string';
125
- var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
126
-
127
- if (Module['ENVIRONMENT']) {
128
- throw new Error('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)');
129
- }
130
-
131
- // `/` should be present at the end if `scriptDirectory` is not empty
132
- var scriptDirectory = '';
133
- function locateFile(path) {
134
- if (Module['locateFile']) {
135
- return Module['locateFile'](path, scriptDirectory);
136
- }
137
- return scriptDirectory + path;
138
- }
139
-
140
- // Hooks that are implemented differently in different runtime environments.
141
- var read_,
142
- readAsync,
143
- readBinary,
144
- setWindowTitle;
145
-
146
- if (ENVIRONMENT_IS_NODE) {
147
- if (typeof process == 'undefined' || !process.release || process.release.name !== 'node') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
148
-
149
- var nodeVersion = process.versions.node;
150
- var numericVersion = nodeVersion.split('.').slice(0, 3);
151
- numericVersion = (numericVersion[0] * 10000) + (numericVersion[1] * 100) + numericVersion[2] * 1;
152
- var minVersion = 101900;
153
- if (numericVersion < 101900) {
154
- throw new Error('This emscripten-generated code requires node v10.19.19.0 (detected v' + nodeVersion + ')');
155
- }
156
-
157
- // `require()` is no-op in an ESM module, use `createRequire()` to construct
158
- // the require()` function. This is only necessary for multi-environment
159
- // builds, `-sENVIRONMENT=node` emits a static import declaration instead.
160
- // TODO: Swap all `require()`'s with `import()`'s?
161
- // These modules will usually be used on Node.js. Load them eagerly to avoid
162
- // the complexity of lazy-loading.
163
- var fs = __webpack_require__(/*! fs */ "?b97d");
164
- var nodePath = __webpack_require__(/*! path */ "?54bb");
165
-
166
- if (ENVIRONMENT_IS_WORKER) {
167
- scriptDirectory = nodePath.dirname(scriptDirectory) + '/';
168
- } else {
169
- scriptDirectory = __dirname + '/';
170
- }
171
-
172
- // include: node_shell_read.js
173
- read_ = (filename, binary) => {
174
- // We need to re-wrap `file://` strings to URLs. Normalizing isn't
175
- // necessary in that case, the path should already be absolute.
176
- filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
177
- return fs.readFileSync(filename, binary ? undefined : 'utf8');
178
- };
179
-
180
- readBinary = (filename) => {
181
- var ret = read_(filename, true);
182
- if (!ret.buffer) {
183
- ret = new Uint8Array(ret);
184
- }
185
- assert(ret.buffer);
186
- return ret;
187
- };
188
-
189
- readAsync = (filename, onload, onerror) => {
190
- // See the comment in the `read_` function.
191
- filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
192
- fs.readFile(filename, function(err, data) {
193
- if (err) onerror(err);
194
- else onload(data.buffer);
195
- });
196
- };
197
-
198
- // end include: node_shell_read.js
199
- if (process.argv.length > 1) {
200
- thisProgram = process.argv[1].replace(/\\/g, '/');
201
- }
202
-
203
- arguments_ = process.argv.slice(2);
204
-
205
- // MODULARIZE will export the module in the proper place outside, we don't need to export here
206
-
207
- quit_ = (status, toThrow) => {
208
- process.exitCode = status;
209
- throw toThrow;
210
- };
211
-
212
- Module['inspect'] = function () { return '[Emscripten Module object]'; };
213
-
214
- } else
215
- if (ENVIRONMENT_IS_SHELL) {
216
-
217
- if ((typeof process == 'object' && "function" === 'function') || typeof window == 'object' || typeof importScripts == 'function') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
218
-
219
- if (typeof read != 'undefined') {
220
- read_ = function shell_read(f) {
221
- return read(f);
222
- };
223
- }
224
-
225
- readBinary = function readBinary(f) {
226
- let data;
227
- if (typeof readbuffer == 'function') {
228
- return new Uint8Array(readbuffer(f));
229
- }
230
- data = read(f, 'binary');
231
- assert(typeof data == 'object');
232
- return data;
233
- };
234
-
235
- readAsync = function readAsync(f, onload, onerror) {
236
- setTimeout(() => onload(readBinary(f)), 0);
237
- };
238
-
239
- if (typeof clearTimeout == 'undefined') {
240
- globalThis.clearTimeout = (id) => {};
241
- }
242
-
243
- if (typeof scriptArgs != 'undefined') {
244
- arguments_ = scriptArgs;
245
- } else if (typeof arguments != 'undefined') {
246
- arguments_ = arguments;
247
- }
248
-
249
- if (typeof quit == 'function') {
250
- quit_ = (status, toThrow) => {
251
- // Unlike node which has process.exitCode, d8 has no such mechanism. So we
252
- // have no way to set the exit code and then let the program exit with
253
- // that code when it naturally stops running (say, when all setTimeouts
254
- // have completed). For that reason, we must call `quit` - the only way to
255
- // set the exit code - but quit also halts immediately. To increase
256
- // consistency with node (and the web) we schedule the actual quit call
257
- // using a setTimeout to give the current stack and any exception handlers
258
- // a chance to run. This enables features such as addOnPostRun (which
259
- // expected to be able to run code after main returns).
260
- setTimeout(() => {
261
- if (!(toThrow instanceof ExitStatus)) {
262
- let toLog = toThrow;
263
- if (toThrow && typeof toThrow == 'object' && toThrow.stack) {
264
- toLog = [toThrow, toThrow.stack];
265
- }
266
- err('exiting due to exception: ' + toLog);
267
- }
268
- quit(status);
269
- });
270
- throw toThrow;
271
- };
272
- }
273
-
274
- if (typeof print != 'undefined') {
275
- // Prefer to use print/printErr where they exist, as they usually work better.
276
- if (typeof console == 'undefined') console = /** @type{!Console} */({});
277
- console.log = /** @type{!function(this:Console, ...*): undefined} */ (print);
278
- console.warn = console.error = /** @type{!function(this:Console, ...*): undefined} */ (typeof printErr != 'undefined' ? printErr : print);
279
- }
280
-
281
- } else
282
-
283
- // Note that this includes Node.js workers when relevant (pthreads is enabled).
284
- // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
285
- // ENVIRONMENT_IS_NODE.
286
- if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
287
- if (ENVIRONMENT_IS_WORKER) { // Check worker, not web, since window could be polyfilled
288
- scriptDirectory = self.location.href;
289
- } else if (typeof document != 'undefined' && document.currentScript) { // web
290
- scriptDirectory = document.currentScript.src;
291
- }
292
- // When MODULARIZE, this JS may be executed later, after document.currentScript
293
- // is gone, so we saved it, and we use it here instead of any other info.
294
- if (_scriptDir) {
295
- scriptDirectory = _scriptDir;
296
- }
297
- // blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them.
298
- // otherwise, slice off the final part of the url to find the script directory.
299
- // if scriptDirectory does not contain a slash, lastIndexOf will return -1,
300
- // and scriptDirectory will correctly be replaced with an empty string.
301
- // If scriptDirectory contains a query (starting with ?) or a fragment (starting with #),
302
- // they are removed because they could contain a slash.
303
- if (scriptDirectory.indexOf('blob:') !== 0) {
304
- scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf('/')+1);
305
- } else {
306
- scriptDirectory = '';
307
- }
308
-
309
- if (!(typeof window == 'object' || typeof importScripts == 'function')) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
310
-
311
- // Differentiate the Web Worker from the Node Worker case, as reading must
312
- // be done differently.
313
- {
314
- // include: web_or_worker_shell_read.js
315
- read_ = (url) => {
316
- var xhr = new XMLHttpRequest();
317
- xhr.open('GET', url, false);
318
- xhr.send(null);
319
- return xhr.responseText;
320
- }
321
-
322
- if (ENVIRONMENT_IS_WORKER) {
323
- readBinary = (url) => {
324
- var xhr = new XMLHttpRequest();
325
- xhr.open('GET', url, false);
326
- xhr.responseType = 'arraybuffer';
327
- xhr.send(null);
328
- return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response));
329
- };
330
- }
331
-
332
- readAsync = (url, onload, onerror) => {
333
- var xhr = new XMLHttpRequest();
334
- xhr.open('GET', url, true);
335
- xhr.responseType = 'arraybuffer';
336
- xhr.onload = () => {
337
- if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
338
- onload(xhr.response);
339
- return;
340
- }
341
- onerror();
342
- };
343
- xhr.onerror = onerror;
344
- xhr.send(null);
345
- }
346
-
347
- // end include: web_or_worker_shell_read.js
348
- }
349
-
350
- setWindowTitle = (title) => document.title = title;
351
- } else
352
- {
353
- throw new Error('environment detection error');
354
- }
355
-
356
- var out = Module['print'] || console.log.bind(console);
357
- var err = Module['printErr'] || console.warn.bind(console);
358
-
359
- // Merge back in the overrides
360
- Object.assign(Module, moduleOverrides);
361
- // Free the object hierarchy contained in the overrides, this lets the GC
362
- // reclaim data used e.g. in memoryInitializerRequest, which is a large typed array.
363
- moduleOverrides = null;
364
- checkIncomingModuleAPI();
365
-
366
- // Emit code to handle expected values on the Module object. This applies Module.x
367
- // to the proper local x. This has two benefits: first, we only emit it if it is
368
- // expected to arrive, and second, by using a local everywhere else that can be
369
- // minified.
370
-
371
- if (Module['arguments']) arguments_ = Module['arguments'];legacyModuleProp('arguments', 'arguments_');
372
-
373
- if (Module['thisProgram']) thisProgram = Module['thisProgram'];legacyModuleProp('thisProgram', 'thisProgram');
374
-
375
- if (Module['quit']) quit_ = Module['quit'];legacyModuleProp('quit', 'quit_');
376
-
377
- // perform assertions in shell.js after we set up out() and err(), as otherwise if an assertion fails it cannot print the message
378
- // Assertions on removed incoming Module JS APIs.
379
- assert(typeof Module['memoryInitializerPrefixURL'] == 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead');
380
- assert(typeof Module['pthreadMainPrefixURL'] == 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead');
381
- assert(typeof Module['cdInitializerPrefixURL'] == 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead');
382
- assert(typeof Module['filePackagePrefixURL'] == 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead');
383
- assert(typeof Module['read'] == 'undefined', 'Module.read option was removed (modify read_ in JS)');
384
- assert(typeof Module['readAsync'] == 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)');
385
- assert(typeof Module['readBinary'] == 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)');
386
- assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify setWindowTitle in JS)');
387
- assert(typeof Module['TOTAL_MEMORY'] == 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY');
388
- legacyModuleProp('read', 'read_');
389
- legacyModuleProp('readAsync', 'readAsync');
390
- legacyModuleProp('readBinary', 'readBinary');
391
- legacyModuleProp('setWindowTitle', 'setWindowTitle');
392
- var IDBFS = 'IDBFS is no longer included by default; build with -lidbfs.js';
393
- var PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js';
394
- var WORKERFS = 'WORKERFS is no longer included by default; build with -lworkerfs.js';
395
- var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js';
396
-
397
- assert(!ENVIRONMENT_IS_WEB, "web environment detected but not enabled at build time. Add 'web' to `-sENVIRONMENT` to enable.");
398
-
399
- assert(!ENVIRONMENT_IS_SHELL, "shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable.");
400
-
401
-
402
- // end include: shell.js
403
- // include: preamble.js
404
- // === Preamble library stuff ===
405
-
406
- // Documentation for the public APIs defined in this file must be updated in:
407
- // site/source/docs/api_reference/preamble.js.rst
408
- // A prebuilt local version of the documentation is available at:
409
- // site/build/text/docs/api_reference/preamble.js.txt
410
- // You can also build docs locally as HTML or other formats in site/
411
- // An online HTML version (which may be of a different version of Emscripten)
412
- // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
413
-
414
- var wasmBinary;
415
- if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];legacyModuleProp('wasmBinary', 'wasmBinary');
416
- var noExitRuntime = Module['noExitRuntime'] || true;legacyModuleProp('noExitRuntime', 'noExitRuntime');
417
-
418
- if (typeof WebAssembly != 'object') {
419
- abort('no native wasm support detected');
420
- }
421
-
422
- // Wasm globals
423
-
424
- var wasmMemory;
425
-
426
- //========================================
427
- // Runtime essentials
428
- //========================================
429
-
430
- // whether we are quitting the application. no code should run after this.
431
- // set in exit() and abort()
432
- var ABORT = false;
433
-
434
- // set by exit() and abort(). Passed to 'onExit' handler.
435
- // NOTE: This is also used as the process return code code in shell environments
436
- // but only when noExitRuntime is false.
437
- var EXITSTATUS;
438
-
439
- /** @type {function(*, string=)} */
440
- function assert(condition, text) {
441
- if (!condition) {
442
- abort('Assertion failed' + (text ? ': ' + text : ''));
443
- }
444
- }
445
-
446
- // We used to include malloc/free by default in the past. Show a helpful error in
447
- // builds with assertions.
448
-
449
- // include: runtime_strings.js
450
- // runtime_strings.js: String related runtime functions that are part of both
451
- // MINIMAL_RUNTIME and regular runtime.
452
-
453
- var UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf8') : undefined;
454
-
455
- /**
456
- * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
457
- * array that contains uint8 values, returns a copy of that string as a
458
- * Javascript String object.
459
- * heapOrArray is either a regular array, or a JavaScript typed array view.
460
- * @param {number} idx
461
- * @param {number=} maxBytesToRead
462
- * @return {string}
463
- */
464
- function UTF8ArrayToString(heapOrArray, idx, maxBytesToRead) {
465
- var endIdx = idx + maxBytesToRead;
466
- var endPtr = idx;
467
- // TextDecoder needs to know the byte length in advance, it doesn't stop on
468
- // null terminator by itself. Also, use the length info to avoid running tiny
469
- // strings through TextDecoder, since .subarray() allocates garbage.
470
- // (As a tiny code save trick, compare endPtr against endIdx using a negation,
471
- // so that undefined means Infinity)
472
- while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
473
-
474
- if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
475
- return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
476
- }
477
- var str = '';
478
- // If building with TextDecoder, we have already computed the string length
479
- // above, so test loop end condition against that
480
- while (idx < endPtr) {
481
- // For UTF8 byte structure, see:
482
- // http://en.wikipedia.org/wiki/UTF-8#Description
483
- // https://www.ietf.org/rfc/rfc2279.txt
484
- // https://tools.ietf.org/html/rfc3629
485
- var u0 = heapOrArray[idx++];
486
- if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
487
- var u1 = heapOrArray[idx++] & 63;
488
- if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
489
- var u2 = heapOrArray[idx++] & 63;
490
- if ((u0 & 0xF0) == 0xE0) {
491
- u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
492
- } else {
493
- if ((u0 & 0xF8) != 0xF0) warnOnce('Invalid UTF-8 leading byte ' + ptrToString(u0) + ' encountered when deserializing a UTF-8 string in wasm memory to a JS string!');
494
- u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
495
- }
496
-
497
- if (u0 < 0x10000) {
498
- str += String.fromCharCode(u0);
499
- } else {
500
- var ch = u0 - 0x10000;
501
- str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
502
- }
503
- }
504
- return str;
505
- }
506
-
507
- /**
508
- * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
509
- * emscripten HEAP, returns a copy of that string as a Javascript String object.
510
- *
511
- * @param {number} ptr
512
- * @param {number=} maxBytesToRead - An optional length that specifies the
513
- * maximum number of bytes to read. You can omit this parameter to scan the
514
- * string until the first \0 byte. If maxBytesToRead is passed, and the string
515
- * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
516
- * string will cut short at that byte index (i.e. maxBytesToRead will not
517
- * produce a string of exact length [ptr, ptr+maxBytesToRead[) N.B. mixing
518
- * frequent uses of UTF8ToString() with and without maxBytesToRead may throw
519
- * JS JIT optimizations off, so it is worth to consider consistently using one
520
- * @return {string}
521
- */
522
- function UTF8ToString(ptr, maxBytesToRead) {
523
- assert(typeof ptr == 'number');
524
- return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
525
- }
526
-
527
- /**
528
- * Copies the given Javascript String object 'str' to the given byte array at
529
- * address 'outIdx', encoded in UTF8 form and null-terminated. The copy will
530
- * require at most str.length*4+1 bytes of space in the HEAP. Use the function
531
- * lengthBytesUTF8 to compute the exact number of bytes (excluding null
532
- * terminator) that this function will write.
533
- *
534
- * @param {string} str - The Javascript string to copy.
535
- * @param {ArrayBufferView|Array<number>} heap - The array to copy to. Each
536
- * index in this array is assumed
537
- * to be one 8-byte element.
538
- * @param {number} outIdx - The starting offset in the array to begin the copying.
539
- * @param {number} maxBytesToWrite - The maximum number of bytes this function
540
- * can write to the array. This count should
541
- * include the null terminator, i.e. if
542
- * maxBytesToWrite=1, only the null terminator
543
- * will be written and nothing else.
544
- * maxBytesToWrite=0 does not write any bytes
545
- * to the output, not even the null
546
- * terminator.
547
- * @return {number} The number of bytes written, EXCLUDING the null terminator.
548
- */
549
- function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) {
550
- // Parameter maxBytesToWrite is not optional. Negative values, 0, null,
551
- // undefined and false each don't write out any bytes.
552
- if (!(maxBytesToWrite > 0))
553
- return 0;
554
-
555
- var startIdx = outIdx;
556
- var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
557
- for (var i = 0; i < str.length; ++i) {
558
- // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
559
- // unit, not a Unicode code point of the character! So decode
560
- // UTF16->UTF32->UTF8.
561
- // See http://unicode.org/faq/utf_bom.html#utf16-3
562
- // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
563
- // and https://www.ietf.org/rfc/rfc2279.txt
564
- // and https://tools.ietf.org/html/rfc3629
565
- var u = str.charCodeAt(i); // possibly a lead surrogate
566
- if (u >= 0xD800 && u <= 0xDFFF) {
567
- var u1 = str.charCodeAt(++i);
568
- u = 0x10000 + ((u & 0x3FF) << 10) | (u1 & 0x3FF);
569
- }
570
- if (u <= 0x7F) {
571
- if (outIdx >= endIdx) break;
572
- heap[outIdx++] = u;
573
- } else if (u <= 0x7FF) {
574
- if (outIdx + 1 >= endIdx) break;
575
- heap[outIdx++] = 0xC0 | (u >> 6);
576
- heap[outIdx++] = 0x80 | (u & 63);
577
- } else if (u <= 0xFFFF) {
578
- if (outIdx + 2 >= endIdx) break;
579
- heap[outIdx++] = 0xE0 | (u >> 12);
580
- heap[outIdx++] = 0x80 | ((u >> 6) & 63);
581
- heap[outIdx++] = 0x80 | (u & 63);
582
- } else {
583
- if (outIdx + 3 >= endIdx) break;
584
- if (u > 0x10FFFF) warnOnce('Invalid Unicode code point ' + ptrToString(u) + ' encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).');
585
- heap[outIdx++] = 0xF0 | (u >> 18);
586
- heap[outIdx++] = 0x80 | ((u >> 12) & 63);
587
- heap[outIdx++] = 0x80 | ((u >> 6) & 63);
588
- heap[outIdx++] = 0x80 | (u & 63);
589
- }
590
- }
591
- // Null-terminate the pointer to the buffer.
592
- heap[outIdx] = 0;
593
- return outIdx - startIdx;
594
- }
595
-
596
- /**
597
- * Copies the given Javascript String object 'str' to the emscripten HEAP at
598
- * address 'outPtr', null-terminated and encoded in UTF8 form. The copy will
599
- * require at most str.length*4+1 bytes of space in the HEAP.
600
- * Use the function lengthBytesUTF8 to compute the exact number of bytes
601
- * (excluding null terminator) that this function will write.
602
- *
603
- * @return {number} The number of bytes written, EXCLUDING the null terminator.
604
- */
605
- function stringToUTF8(str, outPtr, maxBytesToWrite) {
606
- assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
607
- return stringToUTF8Array(str, HEAPU8,outPtr, maxBytesToWrite);
608
- }
609
-
610
- /**
611
- * Returns the number of bytes the given Javascript string takes if encoded as a
612
- * UTF8 byte array, EXCLUDING the null terminator byte.
613
- *
614
- * @param {string} str - JavaScript string to operator on
615
- * @return {number} Length, in bytes, of the UTF8 encoded string.
616
- */
617
- function lengthBytesUTF8(str) {
618
- var len = 0;
619
- for (var i = 0; i < str.length; ++i) {
620
- // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
621
- // unit, not a Unicode code point of the character! So decode
622
- // UTF16->UTF32->UTF8.
623
- // See http://unicode.org/faq/utf_bom.html#utf16-3
624
- var c = str.charCodeAt(i); // possibly a lead surrogate
625
- if (c <= 0x7F) {
626
- len++;
627
- } else if (c <= 0x7FF) {
628
- len += 2;
629
- } else if (c >= 0xD800 && c <= 0xDFFF) {
630
- len += 4; ++i;
631
- } else {
632
- len += 3;
633
- }
634
- }
635
- return len;
636
- }
637
-
638
- // end include: runtime_strings.js
639
- // Memory management
640
-
641
- var HEAP,
642
- /** @type {!Int8Array} */
643
- HEAP8,
644
- /** @type {!Uint8Array} */
645
- HEAPU8,
646
- /** @type {!Int16Array} */
647
- HEAP16,
648
- /** @type {!Uint16Array} */
649
- HEAPU16,
650
- /** @type {!Int32Array} */
651
- HEAP32,
652
- /** @type {!Uint32Array} */
653
- HEAPU32,
654
- /** @type {!Float32Array} */
655
- HEAPF32,
656
- /** @type {!Float64Array} */
657
- HEAPF64;
658
-
659
- function updateMemoryViews() {
660
- var b = wasmMemory.buffer;
661
- Module['HEAP8'] = HEAP8 = new Int8Array(b);
662
- Module['HEAP16'] = HEAP16 = new Int16Array(b);
663
- Module['HEAP32'] = HEAP32 = new Int32Array(b);
664
- Module['HEAPU8'] = HEAPU8 = new Uint8Array(b);
665
- Module['HEAPU16'] = HEAPU16 = new Uint16Array(b);
666
- Module['HEAPU32'] = HEAPU32 = new Uint32Array(b);
667
- Module['HEAPF32'] = HEAPF32 = new Float32Array(b);
668
- Module['HEAPF64'] = HEAPF64 = new Float64Array(b);
669
- }
670
-
671
- assert(!Module['STACK_SIZE'], 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time')
672
-
673
- assert(typeof Int32Array != 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray != undefined && Int32Array.prototype.set != undefined,
674
- 'JS engine does not provide full typed array support');
675
-
676
- // If memory is defined in wasm, the user can't provide it, or set INITIAL_MEMORY
677
- assert(!Module['wasmMemory'], 'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally');
678
- assert(!Module['INITIAL_MEMORY'], 'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically');
679
-
680
- // include: runtime_init_table.js
681
- // In regular non-RELOCATABLE mode the table is exported
682
- // from the wasm module and this will be assigned once
683
- // the exports are available.
684
- var wasmTable;
685
-
686
- // end include: runtime_init_table.js
687
- // include: runtime_stack_check.js
688
- // Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
689
- function writeStackCookie() {
690
- var max = _emscripten_stack_get_end();
691
- assert((max & 3) == 0);
692
- // If the stack ends at address zero we write our cookies 4 bytes into the
693
- // stack. This prevents interference with the (separate) address-zero check
694
- // below.
695
- if (max == 0) {
696
- max += 4;
697
- }
698
- // The stack grow downwards towards _emscripten_stack_get_end.
699
- // We write cookies to the final two words in the stack and detect if they are
700
- // ever overwritten.
701
- HEAPU32[((max)>>2)] = 0x02135467;
702
- HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE;
703
- // Also test the global address 0 for integrity.
704
- HEAPU32[0] = 0x63736d65; /* 'emsc' */
705
- }
706
-
707
- function checkStackCookie() {
708
- if (ABORT) return;
709
- var max = _emscripten_stack_get_end();
710
- // See writeStackCookie().
711
- if (max == 0) {
712
- max += 4;
713
- }
714
- var cookie1 = HEAPU32[((max)>>2)];
715
- var cookie2 = HEAPU32[(((max)+(4))>>2)];
716
- if (cookie1 != 0x02135467 || cookie2 != 0x89BACDFE) {
717
- abort('Stack overflow! Stack cookie has been overwritten at ' + ptrToString(max) + ', expected hex dwords 0x89BACDFE and 0x2135467, but received ' + ptrToString(cookie2) + ' ' + ptrToString(cookie1));
718
- }
719
- // Also test the global address 0 for integrity.
720
- if (HEAPU32[0] !== 0x63736d65 /* 'emsc' */) {
721
- abort('Runtime error: The application has corrupted its heap memory area (address zero)!');
722
- }
723
- }
724
-
725
- // end include: runtime_stack_check.js
726
- // include: runtime_assertions.js
727
- // Endianness check
728
- (function() {
729
- var h16 = new Int16Array(1);
730
- var h8 = new Int8Array(h16.buffer);
731
- h16[0] = 0x6373;
732
- if (h8[0] !== 0x73 || h8[1] !== 0x63) throw 'Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)';
733
- })();
734
-
735
- // end include: runtime_assertions.js
736
- var __ATPRERUN__ = []; // functions called before the runtime is initialized
737
- var __ATINIT__ = []; // functions called during startup
738
- var __ATEXIT__ = []; // functions called during shutdown
739
- var __ATPOSTRUN__ = []; // functions called after the main() is called
740
-
741
- var runtimeInitialized = false;
742
-
743
- var runtimeKeepaliveCounter = 0;
744
-
745
- function keepRuntimeAlive() {
746
- return noExitRuntime || runtimeKeepaliveCounter > 0;
747
- }
748
-
749
- function preRun() {
750
- if (Module['preRun']) {
751
- if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
752
- while (Module['preRun'].length) {
753
- addOnPreRun(Module['preRun'].shift());
754
- }
755
- }
756
- callRuntimeCallbacks(__ATPRERUN__);
757
- }
758
-
759
- function initRuntime() {
760
- assert(!runtimeInitialized);
761
- runtimeInitialized = true;
762
-
763
- checkStackCookie();
764
-
765
-
766
- callRuntimeCallbacks(__ATINIT__);
767
- }
768
-
769
- function postRun() {
770
- checkStackCookie();
771
-
772
- if (Module['postRun']) {
773
- if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
774
- while (Module['postRun'].length) {
775
- addOnPostRun(Module['postRun'].shift());
776
- }
777
- }
778
-
779
- callRuntimeCallbacks(__ATPOSTRUN__);
780
- }
781
-
782
- function addOnPreRun(cb) {
783
- __ATPRERUN__.unshift(cb);
784
- }
785
-
786
- function addOnInit(cb) {
787
- __ATINIT__.unshift(cb);
788
- }
789
-
790
- function addOnExit(cb) {
791
- }
792
-
793
- function addOnPostRun(cb) {
794
- __ATPOSTRUN__.unshift(cb);
795
- }
796
-
797
- // include: runtime_math.js
798
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
799
-
800
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround
801
-
802
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
803
-
804
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc
805
-
806
- assert(Math.imul, 'This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
807
- assert(Math.fround, 'This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
808
- assert(Math.clz32, 'This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
809
- assert(Math.trunc, 'This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
810
-
811
- // end include: runtime_math.js
812
- // A counter of dependencies for calling run(). If we need to
813
- // do asynchronous work before running, increment this and
814
- // decrement it. Incrementing must happen in a place like
815
- // Module.preRun (used by emcc to add file preloading).
816
- // Note that you can add dependencies in preRun, even though
817
- // it happens right before run - run will be postponed until
818
- // the dependencies are met.
819
- var runDependencies = 0;
820
- var runDependencyWatcher = null;
821
- var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
822
- var runDependencyTracking = {};
823
-
824
- function getUniqueRunDependency(id) {
825
- var orig = id;
826
- while (1) {
827
- if (!runDependencyTracking[id]) return id;
828
- id = orig + Math.random();
829
- }
830
- }
831
-
832
- function addRunDependency(id) {
833
- runDependencies++;
834
-
835
- if (Module['monitorRunDependencies']) {
836
- Module['monitorRunDependencies'](runDependencies);
837
- }
838
-
839
- if (id) {
840
- assert(!runDependencyTracking[id]);
841
- runDependencyTracking[id] = 1;
842
- if (runDependencyWatcher === null && typeof setInterval != 'undefined') {
843
- // Check for missing dependencies every few seconds
844
- runDependencyWatcher = setInterval(function() {
845
- if (ABORT) {
846
- clearInterval(runDependencyWatcher);
847
- runDependencyWatcher = null;
848
- return;
849
- }
850
- var shown = false;
851
- for (var dep in runDependencyTracking) {
852
- if (!shown) {
853
- shown = true;
854
- err('still waiting on run dependencies:');
855
- }
856
- err('dependency: ' + dep);
857
- }
858
- if (shown) {
859
- err('(end of list)');
860
- }
861
- }, 10000);
862
- }
863
- } else {
864
- err('warning: run dependency added without ID');
865
- }
866
- }
867
-
868
- function removeRunDependency(id) {
869
- runDependencies--;
870
-
871
- if (Module['monitorRunDependencies']) {
872
- Module['monitorRunDependencies'](runDependencies);
873
- }
874
-
875
- if (id) {
876
- assert(runDependencyTracking[id]);
877
- delete runDependencyTracking[id];
878
- } else {
879
- err('warning: run dependency removed without ID');
880
- }
881
- if (runDependencies == 0) {
882
- if (runDependencyWatcher !== null) {
883
- clearInterval(runDependencyWatcher);
884
- runDependencyWatcher = null;
885
- }
886
- if (dependenciesFulfilled) {
887
- var callback = dependenciesFulfilled;
888
- dependenciesFulfilled = null;
889
- callback(); // can add another dependenciesFulfilled
890
- }
891
- }
892
- }
893
-
894
- /** @param {string|number=} what */
895
- function abort(what) {
896
- if (Module['onAbort']) {
897
- Module['onAbort'](what);
898
- }
899
-
900
- what = 'Aborted(' + what + ')';
901
- // TODO(sbc): Should we remove printing and leave it up to whoever
902
- // catches the exception?
903
- err(what);
904
-
905
- ABORT = true;
906
- EXITSTATUS = 1;
907
-
908
- // Use a wasm runtime error, because a JS error might be seen as a foreign
909
- // exception, which means we'd run destructors on it. We need the error to
910
- // simply make the program stop.
911
- // FIXME This approach does not work in Wasm EH because it currently does not assume
912
- // all RuntimeErrors are from traps; it decides whether a RuntimeError is from
913
- // a trap or not based on a hidden field within the object. So at the moment
914
- // we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that
915
- // allows this in the wasm spec.
916
-
917
- // Suppress closure compiler warning here. Closure compiler's builtin extern
918
- // defintion for WebAssembly.RuntimeError claims it takes no arguments even
919
- // though it can.
920
- // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
921
- /** @suppress {checkTypes} */
922
- var e = new WebAssembly.RuntimeError(what);
923
-
924
- readyPromiseReject(e);
925
- // Throw the error whether or not MODULARIZE is set because abort is used
926
- // in code paths apart from instantiation where an exception is expected
927
- // to be thrown when abort is called.
928
- throw e;
929
- }
930
-
931
- // include: memoryprofiler.js
932
- // end include: memoryprofiler.js
933
- // show errors on likely calls to FS when it was not included
934
- var FS = {
935
- error: function() {
936
- abort('Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM');
937
- },
938
- init: function() { FS.error() },
939
- createDataFile: function() { FS.error() },
940
- createPreloadedFile: function() { FS.error() },
941
- createLazyFile: function() { FS.error() },
942
- open: function() { FS.error() },
943
- mkdev: function() { FS.error() },
944
- registerDevice: function() { FS.error() },
945
- analyzePath: function() { FS.error() },
946
- loadFilesFromDB: function() { FS.error() },
947
-
948
- ErrnoError: function ErrnoError() { FS.error() },
949
- };
950
- Module['FS_createDataFile'] = FS.createDataFile;
951
- Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
952
-
953
- // include: URIUtils.js
954
- // Prefix of data URIs emitted by SINGLE_FILE and related options.
955
- var dataURIPrefix = 'data:application/octet-stream;base64,';
956
-
957
- // Indicates whether filename is a base64 data URI.
958
- function isDataURI(filename) {
959
- // Prefix of data URIs emitted by SINGLE_FILE and related options.
960
- return filename.startsWith(dataURIPrefix);
961
- }
962
-
963
- // Indicates whether filename is delivered via file protocol (as opposed to http/https)
964
- function isFileURI(filename) {
965
- return filename.startsWith('file://');
966
- }
967
-
968
- // end include: URIUtils.js
969
- /** @param {boolean=} fixedasm */
970
- function createExportWrapper(name, fixedasm) {
971
- return function() {
972
- var displayName = name;
973
- var asm = fixedasm;
974
- if (!fixedasm) {
975
- asm = Module['asm'];
976
- }
977
- assert(runtimeInitialized, 'native function `' + displayName + '` called before runtime initialization');
978
- if (!asm[name]) {
979
- assert(asm[name], 'exported native function `' + displayName + '` not found');
980
- }
981
- return asm[name].apply(null, arguments);
982
- };
983
- }
984
-
985
- // include: runtime_exceptions.js
986
- // end include: runtime_exceptions.js
987
- var wasmBinaryFile;
988
- wasmBinaryFile = 'index.wasm';
989
- if (!isDataURI(wasmBinaryFile)) {
990
- wasmBinaryFile = locateFile(wasmBinaryFile);
991
- }
992
-
993
- function getBinary(file) {
994
- try {
995
- if (file == wasmBinaryFile && wasmBinary) {
996
- return new Uint8Array(wasmBinary);
997
- }
998
- if (readBinary) {
999
- return readBinary(file);
1000
- }
1001
- throw "both async and sync fetching of the wasm failed";
1002
- }
1003
- catch (err) {
1004
- abort(err);
1005
- }
1006
- }
1007
-
1008
- function getBinaryPromise(binaryFile) {
1009
- // If we don't have the binary yet, try to to load it asynchronously.
1010
- // Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
1011
- // See https://github.com/github/fetch/pull/92#issuecomment-140665932
1012
- // Cordova or Electron apps are typically loaded from a file:// url.
1013
- // So use fetch if it is available and the url is not a file, otherwise fall back to XHR.
1014
- if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
1015
- if (typeof fetch == 'function'
1016
- ) {
1017
- return fetch(binaryFile, { credentials: 'same-origin' }).then(function(response) {
1018
- if (!response['ok']) {
1019
- throw "failed to load wasm binary file at '" + binaryFile + "'";
1020
- }
1021
- return response['arrayBuffer']();
1022
- }).catch(function () {
1023
- return getBinary(binaryFile);
1024
- });
1025
- }
1026
- }
1027
-
1028
- // Otherwise, getBinary should be able to get it synchronously
1029
- return Promise.resolve().then(function() { return getBinary(binaryFile); });
1030
- }
1031
-
1032
- function instantiateArrayBuffer(binaryFile, imports, receiver) {
1033
- return getBinaryPromise(binaryFile).then(function(binary) {
1034
- return WebAssembly.instantiate(binary, imports);
1035
- }).then(function (instance) {
1036
- return instance;
1037
- }).then(receiver, function(reason) {
1038
- err('failed to asynchronously prepare wasm: ' + reason);
1039
-
1040
- // Warn on some common problems.
1041
- if (isFileURI(wasmBinaryFile)) {
1042
- err('warning: Loading from a file URI (' + wasmBinaryFile + ') is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing');
1043
- }
1044
- abort(reason);
1045
- });
1046
- }
1047
-
1048
- function instantiateAsync(binary, binaryFile, imports, callback) {
1049
- if (!binary &&
1050
- typeof WebAssembly.instantiateStreaming == 'function' &&
1051
- !isDataURI(binaryFile) &&
1052
- // Avoid instantiateStreaming() on Node.js environment for now, as while
1053
- // Node.js v18.1.0 implements it, it does not have a full fetch()
1054
- // implementation yet.
1055
- //
1056
- // Reference:
1057
- // https://github.com/emscripten-core/emscripten/pull/16917
1058
- !ENVIRONMENT_IS_NODE &&
1059
- typeof fetch == 'function') {
1060
- return fetch(binaryFile, { credentials: 'same-origin' }).then(function(response) {
1061
- // Suppress closure warning here since the upstream definition for
1062
- // instantiateStreaming only allows Promise<Repsponse> rather than
1063
- // an actual Response.
1064
- // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure is fixed.
1065
- /** @suppress {checkTypes} */
1066
- var result = WebAssembly.instantiateStreaming(response, imports);
1067
-
1068
- return result.then(
1069
- callback,
1070
- function(reason) {
1071
- // We expect the most common failure cause to be a bad MIME type for the binary,
1072
- // in which case falling back to ArrayBuffer instantiation should work.
1073
- err('wasm streaming compile failed: ' + reason);
1074
- err('falling back to ArrayBuffer instantiation');
1075
- return instantiateArrayBuffer(binaryFile, imports, callback);
1076
- });
1077
- });
1078
- } else {
1079
- return instantiateArrayBuffer(binaryFile, imports, callback);
1080
- }
1081
- }
1082
-
1083
- // Create the wasm instance.
1084
- // Receives the wasm imports, returns the exports.
1085
- function createWasm() {
1086
- // prepare imports
1087
- var info = {
1088
- 'env': wasmImports,
1089
- 'wasi_snapshot_preview1': wasmImports,
1090
- };
1091
- // Load the wasm module and create an instance of using native support in the JS engine.
1092
- // handle a generated wasm instance, receiving its exports and
1093
- // performing other necessary setup
1094
- /** @param {WebAssembly.Module=} module*/
1095
- function receiveInstance(instance, module) {
1096
- var exports = instance.exports;
1097
-
1098
- Module['asm'] = exports;
1099
-
1100
- wasmMemory = Module['asm']['memory'];
1101
- assert(wasmMemory, "memory not found in wasm exports");
1102
- // This assertion doesn't hold when emscripten is run in --post-link
1103
- // mode.
1104
- // TODO(sbc): Read INITIAL_MEMORY out of the wasm file in post-link mode.
1105
- //assert(wasmMemory.buffer.byteLength === 16777216);
1106
- updateMemoryViews();
1107
-
1108
- wasmTable = Module['asm']['__indirect_function_table'];
1109
- assert(wasmTable, "table not found in wasm exports");
1110
-
1111
- addOnInit(Module['asm']['__wasm_call_ctors']);
1112
-
1113
- removeRunDependency('wasm-instantiate');
1114
-
1115
- return exports;
1116
- }
1117
- // wait for the pthread pool (if any)
1118
- addRunDependency('wasm-instantiate');
1119
-
1120
- // Prefer streaming instantiation if available.
1121
- // Async compilation can be confusing when an error on the page overwrites Module
1122
- // (for example, if the order of elements is wrong, and the one defining Module is
1123
- // later), so we save Module and check it later.
1124
- var trueModule = Module;
1125
- function receiveInstantiationResult(result) {
1126
- // 'result' is a ResultObject object which has both the module and instance.
1127
- // receiveInstance() will swap in the exports (to Module.asm) so they can be called
1128
- assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?');
1129
- trueModule = null;
1130
- // TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193, the above line no longer optimizes out down to the following line.
1131
- // When the regression is fixed, can restore the above PTHREADS-enabled path.
1132
- receiveInstance(result['instance']);
1133
- }
1134
-
1135
- // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
1136
- // to manually instantiate the Wasm module themselves. This allows pages to run the instantiation parallel
1137
- // to any other async startup actions they are performing.
1138
- // Also pthreads and wasm workers initialize the wasm instance through this path.
1139
- if (Module['instantiateWasm']) {
1140
- try {
1141
- return Module['instantiateWasm'](info, receiveInstance);
1142
- } catch(e) {
1143
- err('Module.instantiateWasm callback failed with error: ' + e);
1144
- // If instantiation fails, reject the module ready promise.
1145
- readyPromiseReject(e);
1146
- }
1147
- }
1148
-
1149
- // If instantiation fails, reject the module ready promise.
1150
- instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject);
1151
- return {}; // no exports yet; we'll fill them in later
1152
- }
1153
-
1154
- // Globals used by JS i64 conversions (see makeSetValue)
1155
- var tempDouble;
1156
- var tempI64;
1157
-
1158
- // include: runtime_debug.js
1159
- function legacyModuleProp(prop, newName) {
1160
- if (!Object.getOwnPropertyDescriptor(Module, prop)) {
1161
- Object.defineProperty(Module, prop, {
1162
- configurable: true,
1163
- get: function() {
1164
- abort('Module.' + prop + ' has been replaced with plain ' + newName + ' (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)');
1165
- }
1166
- });
1167
- }
1168
- }
1169
-
1170
- function ignoredModuleProp(prop) {
1171
- if (Object.getOwnPropertyDescriptor(Module, prop)) {
1172
- abort('`Module.' + prop + '` was supplied but `' + prop + '` not included in INCOMING_MODULE_JS_API');
1173
- }
1174
- }
1175
-
1176
- // forcing the filesystem exports a few things by default
1177
- function isExportedByForceFilesystem(name) {
1178
- return name === 'FS_createPath' ||
1179
- name === 'FS_createDataFile' ||
1180
- name === 'FS_createPreloadedFile' ||
1181
- name === 'FS_unlink' ||
1182
- name === 'addRunDependency' ||
1183
- // The old FS has some functionality that WasmFS lacks.
1184
- name === 'FS_createLazyFile' ||
1185
- name === 'FS_createDevice' ||
1186
- name === 'removeRunDependency';
1187
- }
1188
-
1189
- function missingGlobal(sym, msg) {
1190
- if (typeof globalThis !== 'undefined') {
1191
- Object.defineProperty(globalThis, sym, {
1192
- configurable: true,
1193
- get: function() {
1194
- warnOnce('`' + sym + '` is not longer defined by emscripten. ' + msg);
1195
- return undefined;
1196
- }
1197
- });
1198
- }
1199
- }
1200
-
1201
- missingGlobal('buffer', 'Please use HEAP8.buffer or wasmMemory.buffer');
1202
-
1203
- function missingLibrarySymbol(sym) {
1204
- if (typeof globalThis !== 'undefined' && !Object.getOwnPropertyDescriptor(globalThis, sym)) {
1205
- Object.defineProperty(globalThis, sym, {
1206
- configurable: true,
1207
- get: function() {
1208
- // Can't `abort()` here because it would break code that does runtime
1209
- // checks. e.g. `if (typeof SDL === 'undefined')`.
1210
- var msg = '`' + sym + '` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line';
1211
- // DEFAULT_LIBRARY_FUNCS_TO_INCLUDE requires the name as it appears in
1212
- // library.js, which means $name for a JS name with no prefix, or name
1213
- // for a JS name like _name.
1214
- var librarySymbol = sym;
1215
- if (!librarySymbol.startsWith('_')) {
1216
- librarySymbol = '$' + sym;
1217
- }
1218
- msg += " (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=" + librarySymbol + ")";
1219
- if (isExportedByForceFilesystem(sym)) {
1220
- msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
1221
- }
1222
- warnOnce(msg);
1223
- return undefined;
1224
- }
1225
- });
1226
- }
1227
- // Any symbol that is not included from the JS libary is also (by definition)
1228
- // not exported on the Module object.
1229
- unexportedRuntimeSymbol(sym);
1230
- }
1231
-
1232
- function unexportedRuntimeSymbol(sym) {
1233
- if (!Object.getOwnPropertyDescriptor(Module, sym)) {
1234
- Object.defineProperty(Module, sym, {
1235
- configurable: true,
1236
- get: function() {
1237
- var msg = "'" + sym + "' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)";
1238
- if (isExportedByForceFilesystem(sym)) {
1239
- msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
1240
- }
1241
- abort(msg);
1242
- }
1243
- });
1244
- }
1245
- }
1246
-
1247
- // Used by XXXXX_DEBUG settings to output debug messages.
1248
- function dbg(text) {
1249
- // TODO(sbc): Make this configurable somehow. Its not always convenient for
1250
- // logging to show up as errors.
1251
- console.error(text);
1252
- }
1253
-
1254
- // end include: runtime_debug.js
1255
- // === Body ===
1256
-
1257
-
1258
- // end include: preamble.js
1259
-
1260
- /** @constructor */
1261
- function ExitStatus(status) {
1262
- this.name = 'ExitStatus';
1263
- this.message = 'Program terminated with exit(' + status + ')';
1264
- this.status = status;
1265
- }
1266
-
1267
- function callRuntimeCallbacks(callbacks) {
1268
- while (callbacks.length > 0) {
1269
- // Pass the module as the first argument.
1270
- callbacks.shift()(Module);
1271
- }
1272
- }
1273
-
1274
-
1275
- /**
1276
- * @param {number} ptr
1277
- * @param {string} type
1278
- */
1279
- function getValue(ptr, type = 'i8') {
1280
- if (type.endsWith('*')) type = '*';
1281
- switch (type) {
1282
- case 'i1': return HEAP8[((ptr)>>0)];
1283
- case 'i8': return HEAP8[((ptr)>>0)];
1284
- case 'i16': return HEAP16[((ptr)>>1)];
1285
- case 'i32': return HEAP32[((ptr)>>2)];
1286
- case 'i64': return HEAP32[((ptr)>>2)];
1287
- case 'float': return HEAPF32[((ptr)>>2)];
1288
- case 'double': return HEAPF64[((ptr)>>3)];
1289
- case '*': return HEAPU32[((ptr)>>2)];
1290
- default: abort('invalid type for getValue: ' + type);
1291
- }
1292
- }
1293
-
1294
- function ptrToString(ptr) {
1295
- assert(typeof ptr === 'number');
1296
- return '0x' + ptr.toString(16).padStart(8, '0');
1297
- }
1298
-
1299
-
1300
- /**
1301
- * @param {number} ptr
1302
- * @param {number} value
1303
- * @param {string} type
1304
- */
1305
- function setValue(ptr, value, type = 'i8') {
1306
- if (type.endsWith('*')) type = '*';
1307
- switch (type) {
1308
- case 'i1': HEAP8[((ptr)>>0)] = value; break;
1309
- case 'i8': HEAP8[((ptr)>>0)] = value; break;
1310
- case 'i16': HEAP16[((ptr)>>1)] = value; break;
1311
- case 'i32': HEAP32[((ptr)>>2)] = value; break;
1312
- case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? ((Math.min((+(Math.floor((tempDouble)/4294967296.0))), 4294967295.0))|0)>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)],HEAP32[((ptr)>>2)] = tempI64[0],HEAP32[(((ptr)+(4))>>2)] = tempI64[1]); break;
1313
- case 'float': HEAPF32[((ptr)>>2)] = value; break;
1314
- case 'double': HEAPF64[((ptr)>>3)] = value; break;
1315
- case '*': HEAPU32[((ptr)>>2)] = value; break;
1316
- default: abort('invalid type for setValue: ' + type);
1317
- }
1318
- }
1319
-
1320
- function warnOnce(text) {
1321
- if (!warnOnce.shown) warnOnce.shown = {};
1322
- if (!warnOnce.shown[text]) {
1323
- warnOnce.shown[text] = 1;
1324
- if (ENVIRONMENT_IS_NODE) text = 'warning: ' + text;
1325
- err(text);
1326
- }
1327
- }
1328
-
1329
- function _abort() {
1330
- abort('native code called abort()');
1331
- }
1332
-
1333
- function _emscripten_memcpy_big(dest, src, num) {
1334
- HEAPU8.copyWithin(dest, src, src + num);
1335
- }
1336
-
1337
- function getHeapMax() {
1338
- return HEAPU8.length;
1339
- }
1340
-
1341
- function abortOnCannotGrowMemory(requestedSize) {
1342
- abort('Cannot enlarge memory arrays to size ' + requestedSize + ' bytes (OOM). Either (1) compile with -sINITIAL_MEMORY=X with X higher than the current value ' + HEAP8.length + ', (2) compile with -sALLOW_MEMORY_GROWTH which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -sABORTING_MALLOC=0');
1343
- }
1344
- function _emscripten_resize_heap(requestedSize) {
1345
- var oldSize = HEAPU8.length;
1346
- requestedSize = requestedSize >>> 0;
1347
- abortOnCannotGrowMemory(requestedSize);
1348
- }
1349
-
1350
- var SYSCALLS = {varargs:undefined,get:function() {
1351
- assert(SYSCALLS.varargs != undefined);
1352
- SYSCALLS.varargs += 4;
1353
- var ret = HEAP32[(((SYSCALLS.varargs)-(4))>>2)];
1354
- return ret;
1355
- },getStr:function(ptr) {
1356
- var ret = UTF8ToString(ptr);
1357
- return ret;
1358
- }};
1359
- function _fd_close(fd) {
1360
- abort('fd_close called without SYSCALLS_REQUIRE_FILESYSTEM');
1361
- }
1362
-
1363
- function convertI32PairToI53Checked(lo, hi) {
1364
- assert(lo == (lo >>> 0) || lo == (lo|0)); // lo should either be a i32 or a u32
1365
- assert(hi === (hi|0)); // hi should be a i32
1366
- return ((hi + 0x200000) >>> 0 < 0x400001 - !!lo) ? (lo >>> 0) + hi * 4294967296 : NaN;
1367
- }
1368
-
1369
-
1370
-
1371
-
1372
- function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {
1373
- return 70;
1374
- }
1375
-
1376
- var printCharBuffers = [null,[],[]];
1377
- function printChar(stream, curr) {
1378
- var buffer = printCharBuffers[stream];
1379
- assert(buffer);
1380
- if (curr === 0 || curr === 10) {
1381
- (stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0));
1382
- buffer.length = 0;
1383
- } else {
1384
- buffer.push(curr);
1385
- }
1386
- }
1387
-
1388
- function flush_NO_FILESYSTEM() {
1389
- // flush anything remaining in the buffers during shutdown
1390
- _fflush(0);
1391
- if (printCharBuffers[1].length) printChar(1, 10);
1392
- if (printCharBuffers[2].length) printChar(2, 10);
1393
- }
1394
-
1395
-
1396
- function _fd_write(fd, iov, iovcnt, pnum) {
1397
- // hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
1398
- var num = 0;
1399
- for (var i = 0; i < iovcnt; i++) {
1400
- var ptr = HEAPU32[((iov)>>2)];
1401
- var len = HEAPU32[(((iov)+(4))>>2)];
1402
- iov += 8;
1403
- for (var j = 0; j < len; j++) {
1404
- printChar(fd, HEAPU8[ptr+j]);
1405
- }
1406
- num += len;
1407
- }
1408
- HEAPU32[((pnum)>>2)] = num;
1409
- return 0;
1410
- }
1411
- function checkIncomingModuleAPI() {
1412
- ignoredModuleProp('fetchSettings');
1413
- }
1414
- var wasmImports = {
1415
- "abort": _abort,
1416
- "emscripten_memcpy_big": _emscripten_memcpy_big,
1417
- "emscripten_resize_heap": _emscripten_resize_heap,
1418
- "fd_close": _fd_close,
1419
- "fd_seek": _fd_seek,
1420
- "fd_write": _fd_write
1421
- };
1422
- var asm = createWasm();
1423
- /** @type {function(...*):?} */
1424
- var ___wasm_call_ctors = createExportWrapper("__wasm_call_ctors");
1425
- /** @type {function(...*):?} */
1426
- var _opus_decoder_create = Module["_opus_decoder_create"] = createExportWrapper("opus_decoder_create");
1427
- /** @type {function(...*):?} */
1428
- var _opus_decode_float = Module["_opus_decode_float"] = createExportWrapper("opus_decode_float");
1429
- /** @type {function(...*):?} */
1430
- var _opus_decoder_destroy = Module["_opus_decoder_destroy"] = createExportWrapper("opus_decoder_destroy");
1431
- /** @type {function(...*):?} */
1432
- var _opus_encoder_create = Module["_opus_encoder_create"] = createExportWrapper("opus_encoder_create");
1433
- /** @type {function(...*):?} */
1434
- var _opus_encode_float = Module["_opus_encode_float"] = createExportWrapper("opus_encode_float");
1435
- /** @type {function(...*):?} */
1436
- var _opus_encoder_destroy = Module["_opus_encoder_destroy"] = createExportWrapper("opus_encoder_destroy");
1437
- /** @type {function(...*):?} */
1438
- var _size_of_int = Module["_size_of_int"] = createExportWrapper("size_of_int");
1439
- /** @type {function(...*):?} */
1440
- var _size_of_void_ptr = Module["_size_of_void_ptr"] = createExportWrapper("size_of_void_ptr");
1441
- /** @type {function(...*):?} */
1442
- var ___errno_location = createExportWrapper("__errno_location");
1443
- /** @type {function(...*):?} */
1444
- var _fflush = Module["_fflush"] = createExportWrapper("fflush");
1445
- /** @type {function(...*):?} */
1446
- var _malloc = Module["_malloc"] = createExportWrapper("malloc");
1447
- /** @type {function(...*):?} */
1448
- var _free = Module["_free"] = createExportWrapper("free");
1449
- /** @type {function(...*):?} */
1450
- var _emscripten_stack_init = function() {
1451
- return (_emscripten_stack_init = Module["asm"]["emscripten_stack_init"]).apply(null, arguments);
1452
- };
1453
-
1454
- /** @type {function(...*):?} */
1455
- var _emscripten_stack_get_free = function() {
1456
- return (_emscripten_stack_get_free = Module["asm"]["emscripten_stack_get_free"]).apply(null, arguments);
1457
- };
1458
-
1459
- /** @type {function(...*):?} */
1460
- var _emscripten_stack_get_base = function() {
1461
- return (_emscripten_stack_get_base = Module["asm"]["emscripten_stack_get_base"]).apply(null, arguments);
1462
- };
1463
-
1464
- /** @type {function(...*):?} */
1465
- var _emscripten_stack_get_end = function() {
1466
- return (_emscripten_stack_get_end = Module["asm"]["emscripten_stack_get_end"]).apply(null, arguments);
1467
- };
1468
-
1469
- /** @type {function(...*):?} */
1470
- var stackSave = createExportWrapper("stackSave");
1471
- /** @type {function(...*):?} */
1472
- var stackRestore = createExportWrapper("stackRestore");
1473
- /** @type {function(...*):?} */
1474
- var stackAlloc = createExportWrapper("stackAlloc");
1475
- /** @type {function(...*):?} */
1476
- var _emscripten_stack_get_current = function() {
1477
- return (_emscripten_stack_get_current = Module["asm"]["emscripten_stack_get_current"]).apply(null, arguments);
1478
- };
1479
-
1480
- /** @type {function(...*):?} */
1481
- var dynCall_jiji = Module["dynCall_jiji"] = createExportWrapper("dynCall_jiji");
1482
-
1483
-
1484
- // include: postamble.js
1485
- // === Auto-generated postamble setup entry stuff ===
1486
-
1487
- var missingLibrarySymbols = [
1488
- 'zeroMemory',
1489
- 'stringToNewUTF8',
1490
- 'exitJS',
1491
- 'emscripten_realloc_buffer',
1492
- 'setErrNo',
1493
- 'inetPton4',
1494
- 'inetNtop4',
1495
- 'inetPton6',
1496
- 'inetNtop6',
1497
- 'readSockaddr',
1498
- 'writeSockaddr',
1499
- 'getHostByName',
1500
- 'getRandomDevice',
1501
- 'traverseStack',
1502
- 'convertPCtoSourceLocation',
1503
- 'readEmAsmArgs',
1504
- 'jstoi_q',
1505
- 'jstoi_s',
1506
- 'getExecutableName',
1507
- 'listenOnce',
1508
- 'autoResumeAudioContext',
1509
- 'dynCallLegacy',
1510
- 'getDynCaller',
1511
- 'dynCall',
1512
- 'handleException',
1513
- 'runtimeKeepalivePush',
1514
- 'runtimeKeepalivePop',
1515
- 'callUserCallback',
1516
- 'maybeExit',
1517
- 'safeSetTimeout',
1518
- 'asmjsMangle',
1519
- 'asyncLoad',
1520
- 'alignMemory',
1521
- 'mmapAlloc',
1522
- 'HandleAllocator',
1523
- 'getNativeTypeSize',
1524
- 'STACK_SIZE',
1525
- 'STACK_ALIGN',
1526
- 'POINTER_SIZE',
1527
- 'ASSERTIONS',
1528
- 'writeI53ToI64',
1529
- 'writeI53ToI64Clamped',
1530
- 'writeI53ToI64Signaling',
1531
- 'writeI53ToU64Clamped',
1532
- 'writeI53ToU64Signaling',
1533
- 'readI53FromI64',
1534
- 'readI53FromU64',
1535
- 'convertI32PairToI53',
1536
- 'convertU32PairToI53',
1537
- 'getCFunc',
1538
- 'ccall',
1539
- 'cwrap',
1540
- 'uleb128Encode',
1541
- 'sigToWasmTypes',
1542
- 'generateFuncType',
1543
- 'convertJsFunctionToWasm',
1544
- 'getEmptyTableSlot',
1545
- 'updateTableMap',
1546
- 'getFunctionAddress',
1547
- 'addFunction',
1548
- 'removeFunction',
1549
- 'reallyNegative',
1550
- 'unSign',
1551
- 'strLen',
1552
- 'reSign',
1553
- 'formatString',
1554
- 'intArrayFromString',
1555
- 'intArrayToString',
1556
- 'AsciiToString',
1557
- 'stringToAscii',
1558
- 'UTF16ToString',
1559
- 'stringToUTF16',
1560
- 'lengthBytesUTF16',
1561
- 'UTF32ToString',
1562
- 'stringToUTF32',
1563
- 'lengthBytesUTF32',
1564
- 'allocateUTF8',
1565
- 'allocateUTF8OnStack',
1566
- 'writeStringToMemory',
1567
- 'writeArrayToMemory',
1568
- 'writeAsciiToMemory',
1569
- 'getSocketFromFD',
1570
- 'getSocketAddress',
1571
- 'registerKeyEventCallback',
1572
- 'maybeCStringToJsString',
1573
- 'findEventTarget',
1574
- 'findCanvasEventTarget',
1575
- 'getBoundingClientRect',
1576
- 'fillMouseEventData',
1577
- 'registerMouseEventCallback',
1578
- 'registerWheelEventCallback',
1579
- 'registerUiEventCallback',
1580
- 'registerFocusEventCallback',
1581
- 'fillDeviceOrientationEventData',
1582
- 'registerDeviceOrientationEventCallback',
1583
- 'fillDeviceMotionEventData',
1584
- 'registerDeviceMotionEventCallback',
1585
- 'screenOrientation',
1586
- 'fillOrientationChangeEventData',
1587
- 'registerOrientationChangeEventCallback',
1588
- 'fillFullscreenChangeEventData',
1589
- 'registerFullscreenChangeEventCallback',
1590
- 'JSEvents_requestFullscreen',
1591
- 'JSEvents_resizeCanvasForFullscreen',
1592
- 'registerRestoreOldStyle',
1593
- 'hideEverythingExceptGivenElement',
1594
- 'restoreHiddenElements',
1595
- 'setLetterbox',
1596
- 'softFullscreenResizeWebGLRenderTarget',
1597
- 'doRequestFullscreen',
1598
- 'fillPointerlockChangeEventData',
1599
- 'registerPointerlockChangeEventCallback',
1600
- 'registerPointerlockErrorEventCallback',
1601
- 'requestPointerLock',
1602
- 'fillVisibilityChangeEventData',
1603
- 'registerVisibilityChangeEventCallback',
1604
- 'registerTouchEventCallback',
1605
- 'fillGamepadEventData',
1606
- 'registerGamepadEventCallback',
1607
- 'registerBeforeUnloadEventCallback',
1608
- 'fillBatteryEventData',
1609
- 'battery',
1610
- 'registerBatteryEventCallback',
1611
- 'setCanvasElementSize',
1612
- 'getCanvasElementSize',
1613
- 'demangle',
1614
- 'demangleAll',
1615
- 'jsStackTrace',
1616
- 'stackTrace',
1617
- 'getEnvStrings',
1618
- 'checkWasiClock',
1619
- 'createDyncallWrapper',
1620
- 'setImmediateWrapped',
1621
- 'clearImmediateWrapped',
1622
- 'polyfillSetImmediate',
1623
- 'getPromise',
1624
- 'makePromise',
1625
- 'makePromiseCallback',
1626
- 'ExceptionInfo',
1627
- 'exception_addRef',
1628
- 'exception_decRef',
1629
- 'setMainLoop',
1630
- '_setNetworkCallback',
1631
- 'heapObjectForWebGLType',
1632
- 'heapAccessShiftForWebGLHeap',
1633
- 'emscriptenWebGLGet',
1634
- 'computeUnpackAlignedImageSize',
1635
- 'emscriptenWebGLGetTexPixelData',
1636
- 'emscriptenWebGLGetUniform',
1637
- 'webglGetUniformLocation',
1638
- 'webglPrepareUniformLocationsBeforeFirstUse',
1639
- 'webglGetLeftBracePos',
1640
- 'emscriptenWebGLGetVertexAttrib',
1641
- 'writeGLArray',
1642
- 'SDL_unicode',
1643
- 'SDL_ttfContext',
1644
- 'SDL_audio',
1645
- 'GLFW_Window',
1646
- 'runAndAbortIfError',
1647
- 'ALLOC_NORMAL',
1648
- 'ALLOC_STACK',
1649
- 'allocate',
1650
- ];
1651
- missingLibrarySymbols.forEach(missingLibrarySymbol)
1652
-
1653
- var unexportedSymbols = [
1654
- 'run',
1655
- 'UTF8ArrayToString',
1656
- 'UTF8ToString',
1657
- 'stringToUTF8Array',
1658
- 'stringToUTF8',
1659
- 'lengthBytesUTF8',
1660
- 'addOnPreRun',
1661
- 'addOnInit',
1662
- 'addOnPreMain',
1663
- 'addOnExit',
1664
- 'addOnPostRun',
1665
- 'addRunDependency',
1666
- 'removeRunDependency',
1667
- 'FS_createFolder',
1668
- 'FS_createPath',
1669
- 'FS_createDataFile',
1670
- 'FS_createPreloadedFile',
1671
- 'FS_createLazyFile',
1672
- 'FS_createLink',
1673
- 'FS_createDevice',
1674
- 'FS_unlink',
1675
- 'out',
1676
- 'err',
1677
- 'callMain',
1678
- 'abort',
1679
- 'keepRuntimeAlive',
1680
- 'wasmMemory',
1681
- 'stackAlloc',
1682
- 'stackSave',
1683
- 'stackRestore',
1684
- 'getTempRet0',
1685
- 'setTempRet0',
1686
- 'writeStackCookie',
1687
- 'checkStackCookie',
1688
- 'ptrToString',
1689
- 'getHeapMax',
1690
- 'abortOnCannotGrowMemory',
1691
- 'ENV',
1692
- 'ERRNO_CODES',
1693
- 'ERRNO_MESSAGES',
1694
- 'DNS',
1695
- 'Protocols',
1696
- 'Sockets',
1697
- 'timers',
1698
- 'warnOnce',
1699
- 'UNWIND_CACHE',
1700
- 'readEmAsmArgsArray',
1701
- 'convertI32PairToI53Checked',
1702
- 'freeTableIndexes',
1703
- 'functionsInTableMap',
1704
- 'setValue',
1705
- 'getValue',
1706
- 'PATH',
1707
- 'PATH_FS',
1708
- 'UTF16Decoder',
1709
- 'SYSCALLS',
1710
- 'JSEvents',
1711
- 'specialHTMLTargets',
1712
- 'currentFullscreenStrategy',
1713
- 'restoreOldWindowedStyle',
1714
- 'ExitStatus',
1715
- 'flush_NO_FILESYSTEM',
1716
- 'dlopenMissingError',
1717
- 'promiseMap',
1718
- 'uncaughtExceptionCount',
1719
- 'exceptionLast',
1720
- 'exceptionCaught',
1721
- 'Browser',
1722
- 'wget',
1723
- 'FS',
1724
- 'MEMFS',
1725
- 'TTY',
1726
- 'PIPEFS',
1727
- 'SOCKFS',
1728
- 'tempFixedLengthArray',
1729
- 'miniTempWebGLFloatBuffers',
1730
- 'GL',
1731
- 'AL',
1732
- 'SDL',
1733
- 'SDL_gfx',
1734
- 'GLUT',
1735
- 'EGL',
1736
- 'GLFW',
1737
- 'GLEW',
1738
- 'IDBStore',
1739
- ];
1740
- unexportedSymbols.forEach(unexportedRuntimeSymbol);
1741
-
1742
-
1743
-
1744
- var calledRun;
1745
-
1746
- dependenciesFulfilled = function runCaller() {
1747
- // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
1748
- if (!calledRun) run();
1749
- if (!calledRun) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
1750
- };
1751
-
1752
- function stackCheckInit() {
1753
- // This is normally called automatically during __wasm_call_ctors but need to
1754
- // get these values before even running any of the ctors so we call it redundantly
1755
- // here.
1756
- _emscripten_stack_init();
1757
- // TODO(sbc): Move writeStackCookie to native to to avoid this.
1758
- writeStackCookie();
1759
- }
1760
-
1761
- function run() {
1762
-
1763
- if (runDependencies > 0) {
1764
- return;
1765
- }
1766
-
1767
- stackCheckInit();
1768
-
1769
- preRun();
1770
-
1771
- // a preRun added a dependency, run will be called later
1772
- if (runDependencies > 0) {
1773
- return;
1774
- }
1775
-
1776
- function doRun() {
1777
- // run may have just been called through dependencies being fulfilled just in this very frame,
1778
- // or while the async setStatus time below was happening
1779
- if (calledRun) return;
1780
- calledRun = true;
1781
- Module['calledRun'] = true;
1782
-
1783
- if (ABORT) return;
1784
-
1785
- initRuntime();
1786
-
1787
- readyPromiseResolve(Module);
1788
- if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']();
1789
-
1790
- assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');
1791
-
1792
- postRun();
1793
- }
1794
-
1795
- if (Module['setStatus']) {
1796
- Module['setStatus']('Running...');
1797
- setTimeout(function() {
1798
- setTimeout(function() {
1799
- Module['setStatus']('');
1800
- }, 1);
1801
- doRun();
1802
- }, 1);
1803
- } else
1804
- {
1805
- doRun();
1806
- }
1807
- checkStackCookie();
1808
- }
1809
-
1810
- function checkUnflushedContent() {
1811
- // Compiler settings do not allow exiting the runtime, so flushing
1812
- // the streams is not possible. but in ASSERTIONS mode we check
1813
- // if there was something to flush, and if so tell the user they
1814
- // should request that the runtime be exitable.
1815
- // Normally we would not even include flush() at all, but in ASSERTIONS
1816
- // builds we do so just for this check, and here we see if there is any
1817
- // content to flush, that is, we check if there would have been
1818
- // something a non-ASSERTIONS build would have not seen.
1819
- // How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0
1820
- // mode (which has its own special function for this; otherwise, all
1821
- // the code is inside libc)
1822
- var oldOut = out;
1823
- var oldErr = err;
1824
- var has = false;
1825
- out = err = (x) => {
1826
- has = true;
1827
- }
1828
- try { // it doesn't matter if it fails
1829
- flush_NO_FILESYSTEM();
1830
- } catch(e) {}
1831
- out = oldOut;
1832
- err = oldErr;
1833
- if (has) {
1834
- warnOnce('stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the FAQ), or make sure to emit a newline when you printf etc.');
1835
- warnOnce('(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)');
1836
- }
1837
- }
1838
-
1839
- if (Module['preInit']) {
1840
- if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
1841
- while (Module['preInit'].length > 0) {
1842
- Module['preInit'].pop()();
1843
- }
1844
- }
1845
-
1846
- run();
1847
-
1848
-
1849
- // end include: postamble.js
1850
-
1851
-
1852
- return Module.ready
1853
- }
1854
-
1855
- );
1856
- })();
1857
- if (true)
1858
- module.exports = Module;
1859
- else {}
1860
-
1861
-
1862
- /***/ }),
1863
-
1864
- /***/ "./node_modules/opus-codec/opus/Decoder.js":
1865
- /*!*************************************************!*\
1866
- !*** ./node_modules/opus-codec/opus/Decoder.js ***!
1867
- \*************************************************/
1868
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1869
-
1870
- "use strict";
1871
-
1872
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1873
- const runtime_1 = __webpack_require__(/*! ../runtime */ "./node_modules/opus-codec/runtime/index.js");
1874
- class Decoder {
1875
- #errorPointer;
1876
- #error;
1877
- #decoder;
1878
- #holder;
1879
- #runtime;
1880
- #pcm;
1881
- #frameSize;
1882
- constructor(runtime, sampleRate, channels, frameSize) {
1883
- this.#frameSize = frameSize;
1884
- this.#runtime = runtime;
1885
- this.#holder = new runtime_1.ResourcesHolder();
1886
- this.#error = new runtime_1.Integer(runtime);
1887
- this.#errorPointer = new runtime_1.Pointer(runtime, this.#error);
1888
- /**
1889
- * holder
1890
- */
1891
- this.#holder.add(this.#error);
1892
- this.#holder.add(this.#errorPointer);
1893
- /**
1894
- * create decoder
1895
- */
1896
- this.#decoder = runtime.originalRuntime()._opus_decoder_create(sampleRate, channels, this.#errorPointer.offset());
1897
- if (!this.#decoder || this.#error.value() < 0) {
1898
- throw new Error('Failed to create decoder');
1899
- }
1900
- this.#pcm = new runtime_1.Buffer(runtime, this.#frameSize * channels * Float32Array.BYTES_PER_ELEMENT);
1901
- }
1902
- #data = null;
1903
- decodeFloat(value, decodeFec = 0) {
1904
- let data = this.#data;
1905
- if (!data) {
1906
- data = new runtime_1.Buffer(this.#runtime, value.byteLength);
1907
- }
1908
- /**
1909
- * reallocate in case current allocated buffer is smaller than the actual
1910
- * incoming data
1911
- */
1912
- if (data.data().byteLength < value.byteLength) {
1913
- data.destroy();
1914
- data = new runtime_1.Buffer(this.#runtime, value.byteLength);
1915
- }
1916
- /**
1917
- * set data
1918
- */
1919
- data.data().set(value);
1920
- /**
1921
- * in case the data buffer has changed, set it back to the class
1922
- * instance so we can later destroy it
1923
- */
1924
- this.#data = data;
1925
- /**
1926
- * decode float data
1927
- */
1928
- const decodedSamples = this.#runtime.originalRuntime()._opus_decode_float(this.#decoder, data.offset(), value.byteLength, this.#pcm.offset(), this.#frameSize, decodeFec);
1929
- if (decodedSamples < 0) {
1930
- throw new Error('Failed to decode float');
1931
- }
1932
- return decodedSamples;
1933
- }
1934
- decoded() {
1935
- const pcm = this.#pcm.data();
1936
- return new Float32Array(pcm.buffer, pcm.byteOffset, pcm.byteLength / Float32Array.BYTES_PER_ELEMENT);
1937
- }
1938
- destroy() {
1939
- this.#runtime.originalRuntime()._opus_decoder_destroy(this.#decoder);
1940
- this.#holder.destroy();
1941
- this.#data?.destroy();
1942
- }
1943
- }
1944
- exports["default"] = Decoder;
1945
-
1946
-
1947
- /***/ }),
1948
-
1949
- /***/ "./node_modules/opus-codec/opus/Encoder.js":
1950
- /*!*************************************************!*\
1951
- !*** ./node_modules/opus-codec/opus/Encoder.js ***!
1952
- \*************************************************/
1953
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1954
-
1955
- "use strict";
1956
-
1957
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1958
- const runtime_1 = __webpack_require__(/*! ../runtime */ "./node_modules/opus-codec/runtime/index.js");
1959
- class Encoder {
1960
- #errorPointer;
1961
- #error;
1962
- #runtime;
1963
- #encoder;
1964
- #encoded;
1965
- #pcm;
1966
- #holder;
1967
- constructor(runtime, sampleRate, channels, application,
1968
- /**
1969
- * what is the size of the buffer that holds the encoded data
1970
- */
1971
- outBufferLength,
1972
- /**
1973
- * how many bytes will we be receiving through encodeFloat() function
1974
- */
1975
- pcmBufferLength) {
1976
- if (!outBufferLength) {
1977
- throw new Error("outBufferLength must be more than 0");
1978
- }
1979
- this.#holder = new runtime_1.ResourcesHolder();
1980
- this.#error = new runtime_1.Integer(runtime);
1981
- this.#runtime = runtime;
1982
- this.#errorPointer = new runtime_1.Pointer(runtime, this.#error);
1983
- /**
1984
- * pcm buffer
1985
- */
1986
- this.#pcm = new runtime_1.Buffer(runtime, pcmBufferLength);
1987
- /**
1988
- * out buffer
1989
- */
1990
- this.#encoded = new runtime_1.Buffer(runtime, outBufferLength);
1991
- /**
1992
- * add items to resources holder
1993
- */
1994
- this.#holder.add(this.#encoded);
1995
- this.#holder.add(this.#pcm);
1996
- this.#holder.add(this.#errorPointer);
1997
- this.#holder.add(this.#error);
1998
- /**
1999
- * create encoder
2000
- */
2001
- this.#encoder = runtime
2002
- .originalRuntime()
2003
- ._opus_encoder_create(sampleRate, channels, application, this.#errorPointer.value());
2004
- if (this.#error.value() < 0) {
2005
- throw new Error("Failed to create encoder");
2006
- }
2007
- }
2008
- encoded() {
2009
- return this.#encoded.data();
2010
- }
2011
- /**
2012
- *
2013
- * @param value
2014
- * @param frameSize
2015
- * @param maxDataBytes
2016
- * @returns encoded sample count
2017
- */
2018
- encodeFloat(value, frameSize, maxDataBytes) {
2019
- if (maxDataBytes > this.#encoded.size()) {
2020
- throw new Error(`encoded buffer length is ${this.#encoded.size()}, but maxDataBytes is ${maxDataBytes}`);
2021
- }
2022
- this.#pcm
2023
- .data()
2024
- .set(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));
2025
- const result = this.#runtime
2026
- .originalRuntime()
2027
- ._opus_encode_float(this.#encoder, this.#pcm.offset(), frameSize, this.#encoded.offset(), maxDataBytes);
2028
- if (result < 0) {
2029
- throw new Error(`Failed to encode float`);
2030
- }
2031
- return result;
2032
- }
2033
- destroy() {
2034
- this.#holder.destroy();
2035
- this.#runtime.originalRuntime()._opus_encoder_destroy(this.#encoder);
2036
- }
2037
- }
2038
- exports["default"] = Encoder;
2039
-
2040
-
2041
- /***/ }),
2042
-
2043
- /***/ "./node_modules/opus-codec/opus/RingBuffer.js":
2044
- /*!****************************************************!*\
2045
- !*** ./node_modules/opus-codec/opus/RingBuffer.js ***!
2046
- \****************************************************/
2047
- /***/ ((__unused_webpack_module, exports) => {
2048
-
2049
- "use strict";
2050
-
2051
- Object.defineProperty(exports, "__esModule", ({ value: true }));
2052
- class RingBuffer {
2053
- #arrayBuffer;
2054
- #readOffset;
2055
- #writeOffset;
2056
- #frameSize;
2057
- constructor(frameSize) {
2058
- this.#readOffset = 0;
2059
- this.#writeOffset = 0;
2060
- this.#arrayBuffer = new ArrayBuffer(1024 * 1024 * 4);
2061
- this.#frameSize = frameSize;
2062
- }
2063
- #view() {
2064
- return new Float32Array(this.#arrayBuffer);
2065
- }
2066
- write(value) {
2067
- this.#maybeReallocate(value.length);
2068
- this.#view().set(value, this.#writeOffset);
2069
- this.#writeOffset += value.length;
2070
- }
2071
- read() {
2072
- if (this.#writeOffset >= this.#frameSize) {
2073
- const view = this.#view().subarray(this.#readOffset, this.#readOffset + this.#frameSize);
2074
- this.#readOffset += this.#frameSize;
2075
- if (this.#readOffset >= this.#writeOffset) {
2076
- this.#writeOffset = 0;
2077
- }
2078
- return view;
2079
- }
2080
- return null;
2081
- }
2082
- #maybeReallocate(samples) {
2083
- const sampleCountInBytes = samples * Float32Array.BYTES_PER_ELEMENT;
2084
- if (this.#view().length <= samples) {
2085
- const oldArrayBuffer = this.#arrayBuffer;
2086
- this.#arrayBuffer = new ArrayBuffer(oldArrayBuffer.byteLength + sampleCountInBytes + 1024 * 1024 * 4);
2087
- this.#view().set(new Uint8Array(oldArrayBuffer));
2088
- }
2089
- }
2090
- }
2091
- exports["default"] = RingBuffer;
2092
-
2093
-
2094
- /***/ }),
2095
-
2096
- /***/ "./node_modules/opus-codec/opus/index.js":
2097
- /*!***********************************************!*\
2098
- !*** ./node_modules/opus-codec/opus/index.js ***!
2099
- \***********************************************/
2100
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
2101
-
2102
- "use strict";
2103
-
2104
- var __importDefault = (this && this.__importDefault) || function (mod) {
2105
- return (mod && mod.__esModule) ? mod : { "default": mod };
2106
- };
2107
- Object.defineProperty(exports, "__esModule", ({ value: true }));
2108
- exports.RingBuffer = exports.Decoder = exports.Encoder = void 0;
2109
- var Encoder_1 = __webpack_require__(/*! ./Encoder */ "./node_modules/opus-codec/opus/Encoder.js");
2110
- Object.defineProperty(exports, "Encoder", ({ enumerable: true, get: function () { return __importDefault(Encoder_1).default; } }));
2111
- var Decoder_1 = __webpack_require__(/*! ./Decoder */ "./node_modules/opus-codec/opus/Decoder.js");
2112
- Object.defineProperty(exports, "Decoder", ({ enumerable: true, get: function () { return __importDefault(Decoder_1).default; } }));
2113
- var RingBuffer_1 = __webpack_require__(/*! ./RingBuffer */ "./node_modules/opus-codec/opus/RingBuffer.js");
2114
- Object.defineProperty(exports, "RingBuffer", ({ enumerable: true, get: function () { return __importDefault(RingBuffer_1).default; } }));
2115
-
2116
-
2117
- /***/ }),
2118
-
2119
- /***/ "./node_modules/opus-codec/runtime/Buffer.js":
2120
- /*!***************************************************!*\
2121
- !*** ./node_modules/opus-codec/runtime/Buffer.js ***!
2122
- \***************************************************/
2123
- /***/ ((__unused_webpack_module, exports) => {
2124
-
2125
- "use strict";
2126
-
2127
- Object.defineProperty(exports, "__esModule", ({ value: true }));
2128
- class Buffer {
2129
- #offset;
2130
- #size;
2131
- #runtime;
2132
- constructor(runtime, size) {
2133
- this.#runtime = runtime;
2134
- this.#size = size;
2135
- this.#offset = runtime.malloc(size);
2136
- }
2137
- offset() {
2138
- return this.#offset;
2139
- }
2140
- data() {
2141
- return this.#runtime.subarray(this.#offset, this.#offset + this.#size);
2142
- }
2143
- size() {
2144
- return this.#size;
2145
- }
2146
- destroy() {
2147
- this.#runtime.free(this.#offset);
2148
- this.#offset = 0;
2149
- }
2150
- }
2151
- exports["default"] = Buffer;
2152
-
2153
-
2154
- /***/ }),
2155
-
2156
- /***/ "./node_modules/opus-codec/runtime/Integer.js":
2157
- /*!****************************************************!*\
2158
- !*** ./node_modules/opus-codec/runtime/Integer.js ***!
2159
- \****************************************************/
2160
- /***/ ((__unused_webpack_module, exports) => {
2161
-
2162
- "use strict";
2163
-
2164
- Object.defineProperty(exports, "__esModule", ({ value: true }));
2165
- class Integer {
2166
- #runtime;
2167
- #offset;
2168
- constructor(runtime) {
2169
- this.#runtime = runtime;
2170
- this.#offset = runtime.malloc(runtime.originalRuntime()._size_of_int());
2171
- }
2172
- value() {
2173
- if (this.#runtime.originalRuntime()._size_of_int() !== 4) {
2174
- throw new Error('invalid integer byte size');
2175
- }
2176
- return this.#runtime.view().getInt32(this.#offset);
2177
- }
2178
- size() {
2179
- return this.#runtime.originalRuntime()._size_of_int();
2180
- }
2181
- offset() {
2182
- return this.#offset;
2183
- }
2184
- destroy() {
2185
- this.#runtime.free(this.#offset);
2186
- this.#offset = 0;
2187
- }
2188
- }
2189
- exports["default"] = Integer;
2190
-
2191
-
2192
- /***/ }),
2193
-
2194
- /***/ "./node_modules/opus-codec/runtime/Pointer.js":
2195
- /*!****************************************************!*\
2196
- !*** ./node_modules/opus-codec/runtime/Pointer.js ***!
2197
- \****************************************************/
2198
- /***/ ((__unused_webpack_module, exports) => {
2199
-
2200
- "use strict";
2201
-
2202
- Object.defineProperty(exports, "__esModule", ({ value: true }));
2203
- class Pointer {
2204
- #offset;
2205
- #runtime;
2206
- constructor(runtime, value) {
2207
- this.#runtime = runtime;
2208
- this.#offset = runtime.malloc(runtime.originalRuntime()._size_of_void_ptr());
2209
- this.#runtime.view().setUint32(this.#offset, value.offset(), true);
2210
- }
2211
- offset() {
2212
- return this.#offset;
2213
- }
2214
- destroy() {
2215
- this.#runtime.free(this.#offset);
2216
- }
2217
- value() {
2218
- return this.#runtime.view().getUint32(this.#offset, true);
2219
- }
2220
- }
2221
- exports["default"] = Pointer;
2222
-
2223
-
2224
- /***/ }),
2225
-
2226
- /***/ "./node_modules/opus-codec/runtime/ResourcesHolder.js":
2227
- /*!************************************************************!*\
2228
- !*** ./node_modules/opus-codec/runtime/ResourcesHolder.js ***!
2229
- \************************************************************/
2230
- /***/ ((__unused_webpack_module, exports) => {
2231
-
2232
- "use strict";
2233
-
2234
- Object.defineProperty(exports, "__esModule", ({ value: true }));
2235
- class ResourcesHolder {
2236
- #resources = new Set();
2237
- constructor() {
2238
- }
2239
- add(resource) {
2240
- this.#resources.add(resource);
2241
- }
2242
- destroy() {
2243
- for (const r of this.#resources) {
2244
- r.destroy();
2245
- }
2246
- }
2247
- }
2248
- exports["default"] = ResourcesHolder;
2249
-
2250
-
2251
- /***/ }),
2252
-
2253
- /***/ "./node_modules/opus-codec/runtime/Runtime.js":
2254
- /*!****************************************************!*\
2255
- !*** ./node_modules/opus-codec/runtime/Runtime.js ***!
2256
- \****************************************************/
2257
- /***/ ((__unused_webpack_module, exports) => {
2258
-
2259
- "use strict";
2260
-
2261
- Object.defineProperty(exports, "__esModule", ({ value: true }));
2262
- class Runtime {
2263
- #runtime;
2264
- constructor(runtime) {
2265
- this.#runtime = runtime;
2266
- }
2267
- originalRuntime() {
2268
- return this.#runtime;
2269
- }
2270
- subarray(start, end) {
2271
- return this.#runtime.HEAPU8.subarray(start, end);
2272
- }
2273
- free(offset) {
2274
- this.#runtime._free(offset);
2275
- }
2276
- view() {
2277
- return new DataView(this.#runtime.HEAPU8.buffer);
2278
- }
2279
- malloc(len) {
2280
- const offset = this.#runtime._malloc(len);
2281
- if (!offset) {
2282
- throw new Error(`failed to allocate ${len} bytes`);
2283
- }
2284
- return offset;
2285
- }
2286
- }
2287
- exports["default"] = Runtime;
2288
-
2289
-
2290
- /***/ }),
2291
-
2292
- /***/ "./node_modules/opus-codec/runtime/index.js":
2293
- /*!**************************************************!*\
2294
- !*** ./node_modules/opus-codec/runtime/index.js ***!
2295
- \**************************************************/
2296
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
2297
-
2298
- "use strict";
2299
-
2300
- var __importDefault = (this && this.__importDefault) || function (mod) {
2301
- return (mod && mod.__esModule) ? mod : { "default": mod };
2302
- };
2303
- Object.defineProperty(exports, "__esModule", ({ value: true }));
2304
- exports.ResourcesHolder = exports.Buffer = exports.Runtime = exports.Pointer = exports.Integer = void 0;
2305
- var Integer_1 = __webpack_require__(/*! ./Integer */ "./node_modules/opus-codec/runtime/Integer.js");
2306
- Object.defineProperty(exports, "Integer", ({ enumerable: true, get: function () { return __importDefault(Integer_1).default; } }));
2307
- var Pointer_1 = __webpack_require__(/*! ./Pointer */ "./node_modules/opus-codec/runtime/Pointer.js");
2308
- Object.defineProperty(exports, "Pointer", ({ enumerable: true, get: function () { return __importDefault(Pointer_1).default; } }));
2309
- var Runtime_1 = __webpack_require__(/*! ./Runtime */ "./node_modules/opus-codec/runtime/Runtime.js");
2310
- Object.defineProperty(exports, "Runtime", ({ enumerable: true, get: function () { return __importDefault(Runtime_1).default; } }));
2311
- var Buffer_1 = __webpack_require__(/*! ./Buffer */ "./node_modules/opus-codec/runtime/Buffer.js");
2312
- Object.defineProperty(exports, "Buffer", ({ enumerable: true, get: function () { return __importDefault(Buffer_1).default; } }));
2313
- var ResourcesHolder_1 = __webpack_require__(/*! ./ResourcesHolder */ "./node_modules/opus-codec/runtime/ResourcesHolder.js");
2314
- Object.defineProperty(exports, "ResourcesHolder", ({ enumerable: true, get: function () { return __importDefault(ResourcesHolder_1).default; } }));
2315
-
2316
-
2317
- /***/ }),
2318
-
2319
- /***/ "./worker/index.js":
2320
- /*!*************************!*\
2321
- !*** ./worker/index.js ***!
2322
- \*************************/
2323
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
2324
-
2325
- "use strict";
2326
-
2327
- var __importDefault = (this && this.__importDefault) || function (mod) {
2328
- return (mod && mod.__esModule) ? mod : { "default": mod };
2329
- };
2330
- Object.defineProperty(exports, "__esModule", ({ value: true }));
2331
- const opus_1 = __webpack_require__(/*! opus-codec/opus */ "./node_modules/opus-codec/opus/index.js");
2332
- const actions_1 = __webpack_require__(/*! ../actions/actions */ "./actions/actions.js");
2333
- const native_1 = __importDefault(__webpack_require__(/*! opus-codec/native */ "./node_modules/opus-codec/native/index.js"));
2334
- const runtime_1 = __webpack_require__(/*! opus-codec/runtime */ "./node_modules/opus-codec/runtime/index.js");
2335
- const pendingRuntime = (0, native_1.default)({
2336
- locateFile: () => '/opus/index.wasm',
2337
- });
2338
- let nextEncoderId = 0;
2339
- const encoders = new Map();
2340
- onmessage = async (e) => {
2341
- const runtime = new runtime_1.Runtime(await pendingRuntime);
2342
- const req = e.data;
2343
- switch (req.type) {
2344
- case actions_1.RequestType.CreateEncoder: {
2345
- const encoder = new opus_1.Encoder(runtime, req.data.sampleRate, req.data.channels, req.data.application, req.data.outBufferLength, req.data.pcmBufferLength);
2346
- const encoderId = nextEncoderId++;
2347
- encoders.set(encoderId, {
2348
- ringBuffer: new opus_1.RingBuffer(req.data.pcmBufferLength / Float32Array.BYTES_PER_ELEMENT),
2349
- encoder,
2350
- });
2351
- const response = {
2352
- requestId: req.requestId,
2353
- value: nextEncoderId++,
2354
- };
2355
- postMessage(response);
2356
- break;
2357
- }
2358
- case actions_1.RequestType.DestroyEncoder: {
2359
- const encoderInstance = encoders.get(req.data);
2360
- if (!encoderInstance) {
2361
- throw new Error('Failed to get encoder');
2362
- }
2363
- encoderInstance.encoder.destroy();
2364
- encoders.delete(req.data);
2365
- const response = {
2366
- requestId: req.requestId,
2367
- value: req.data,
2368
- };
2369
- postMessage(response);
2370
- break;
2371
- }
2372
- case actions_1.RequestType.EncodeFloat: {
2373
- const encoderInstance = encoders.get(req.data.encoder);
2374
- if (!encoderInstance) {
2375
- throw new Error('Failed to get encoder');
2376
- }
2377
- encoderInstance.ringBuffer.write(req.data.pcm);
2378
- const samples = encoderInstance.ringBuffer.read();
2379
- const response = {
2380
- requestId: req.requestId,
2381
- value: {
2382
- encoded: null,
2383
- },
2384
- };
2385
- if (samples === null) {
2386
- postMessage(response);
2387
- return;
2388
- }
2389
- const encodedSampleCount = encoderInstance.encoder.encodeFloat(samples, req.data.frameSize, req.data.maxDataBytes);
2390
- response.value.encoded = new ArrayBuffer(encodedSampleCount);
2391
- new Uint8Array(response.value.encoded).set(encoderInstance.encoder
2392
- .encoded()
2393
- .subarray(0, encodedSampleCount));
2394
- postMessage(response, [response.value.encoded]);
2395
- break;
2396
- }
2397
- }
2398
- };
2399
-
2400
-
2401
- /***/ }),
2402
-
2403
- /***/ "?b97d":
2404
- /*!********************!*\
2405
- !*** fs (ignored) ***!
2406
- \********************/
2407
- /***/ (() => {
2408
-
2409
- /* (ignored) */
2410
-
2411
- /***/ }),
2412
-
2413
- /***/ "?54bb":
2414
- /*!**********************!*\
2415
- !*** path (ignored) ***!
2416
- \**********************/
2417
- /***/ (() => {
2418
-
2419
- /* (ignored) */
2420
-
2421
- /***/ })
2422
-
2423
- /******/ });
2424
- /************************************************************************/
2425
- /******/ // The module cache
2426
- /******/ var __webpack_module_cache__ = {};
2427
- /******/
2428
- /******/ // The require function
2429
- /******/ function __webpack_require__(moduleId) {
2430
- /******/ // Check if module is in cache
2431
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
2432
- /******/ if (cachedModule !== undefined) {
2433
- /******/ return cachedModule.exports;
2434
- /******/ }
2435
- /******/ // Create a new module (and put it into the cache)
2436
- /******/ var module = __webpack_module_cache__[moduleId] = {
2437
- /******/ // no module.id needed
2438
- /******/ // no module.loaded needed
2439
- /******/ exports: {}
2440
- /******/ };
2441
- /******/
2442
- /******/ // Execute the module function
2443
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
2444
- /******/
2445
- /******/ // Return the exports of the module
2446
- /******/ return module.exports;
2447
- /******/ }
2448
- /******/
2449
- /************************************************************************/
2450
- /******/
2451
- /******/ // startup
2452
- /******/ // Load entry module and return exports
2453
- /******/ // This entry module is referenced by other modules so it can't be inlined
2454
- /******/ var __webpack_exports__ = __webpack_require__("./worker/index.js");
2455
- /******/
2456
- /******/ })()
2457
- ;
1
+ (()=>{var e={910:(e,t)=>{"use strict";var r;function n(){return crypto.getRandomValues(new Int32Array(4)).join("-")}Object.defineProperty(t,"__esModule",{value:!0}),t.encodeFloat=t.createEncoder=t.RequestType=t.destroyEncoder=void 0,t.destroyEncoder=function(e){return{type:r.DestroyEncoder,data:e,requestId:n()}},function(e){e[e.CreateEncoder=0]="CreateEncoder",e[e.EncodeFloat=1]="EncodeFloat",e[e.DestroyEncoder=2]="DestroyEncoder"}(r=t.RequestType||(t.RequestType={})),t.createEncoder=function(e){return{data:e,requestId:n(),type:r.CreateEncoder}},t.encodeFloat=function(e){return{data:e,requestId:n(),type:r.EncodeFloat,transfer:[e.pcm.buffer]}}},827:(e,t,r)=>{var n,o=(n=(n="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(e={}){var t,o;(e=void 0!==e?e:{}).ready=new Promise((function(e,r){t=e,o=r})),["_size_of_int","_size_of_void_ptr","_malloc","_free","_opus_decoder_create","_opus_decoder_destroy","_opus_decode_float","_opus_encoder_create","_opus_encoder_destroy","_opus_encode_float","_fflush","onRuntimeInitialized"].forEach((t=>{Object.getOwnPropertyDescriptor(e.ready,t)||Object.defineProperty(e.ready,t,{get:()=>N("You are getting "+t+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js"),set:()=>N("You are setting "+t+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")})}));var i=Object.assign({},e),a="object"==typeof window,s="function"==typeof importScripts,d="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,c=!a&&!d&&!s;if(e.ENVIRONMENT)throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");var l,u,f="";if(d){if("undefined"==typeof process||!process.release||"node"!==process.release.name)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");var p=process.versions.node,h=p.split(".").slice(0,3);if((h=1e4*h[0]+100*h[1]+1*h[2])<101900)throw new Error("This emscripten-generated code requires node v10.19.19.0 (detected v"+p+")");var m=r(194),y=r(472);f=s?y.dirname(f)+"/":"//",l=(e,t)=>(e=G(e)?new URL(e):y.normalize(e),m.readFileSync(e,t?void 0:"utf8")),u=e=>{var t=l(e,!0);return t.buffer||(t=new Uint8Array(t)),T(t.buffer),t},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),e.inspect=function(){return"[Emscripten Module object]"}}else if(c){if("object"==typeof process||"object"==typeof window||"function"==typeof importScripts)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");"undefined"!=typeof read&&(l=function(e){return read(e)}),u=function(e){let t;return"function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(t=read(e,"binary"),T("object"==typeof t),t)},"undefined"==typeof clearTimeout&&(globalThis.clearTimeout=e=>{}),"undefined"!=typeof scriptArgs&&scriptArgs,"undefined"!=typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print)}else{if(!a&&!s)throw new Error("environment detection error");if(s?f=self.location.href:"undefined"!=typeof document&&document.currentScript&&(f=document.currentScript.src),n&&(f=n),f=0!==f.indexOf("blob:")?f.substr(0,f.replace(/[?#].*/,"").lastIndexOf("/")+1):"","object"!=typeof window&&"function"!=typeof importScripts)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");l=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},s&&(u=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)})}var _,g,b,w=e.print||console.log.bind(console),v=e.printErr||console.warn.bind(console);Object.assign(e,i),i=null,_="fetchSettings",Object.getOwnPropertyDescriptor(e,_)&&N("`Module."+_+"` was supplied but `"+_+"` not included in INCOMING_MODULE_JS_API"),e.arguments&&e.arguments,V("arguments","arguments_"),e.thisProgram&&e.thisProgram,V("thisProgram","thisProgram"),e.quit&&e.quit,V("quit","quit_"),T(void 0===e.memoryInitializerPrefixURL,"Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),T(void 0===e.pthreadMainPrefixURL,"Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),T(void 0===e.cdInitializerPrefixURL,"Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),T(void 0===e.filePackagePrefixURL,"Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),T(void 0===e.read,"Module.read option was removed (modify read_ in JS)"),T(void 0===e.readAsync,"Module.readAsync option was removed (modify readAsync in JS)"),T(void 0===e.readBinary,"Module.readBinary option was removed (modify readBinary in JS)"),T(void 0===e.setWindowTitle,"Module.setWindowTitle option was removed (modify setWindowTitle in JS)"),T(void 0===e.TOTAL_MEMORY,"Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),V("read","read_"),V("readAsync","readAsync"),V("readBinary","readBinary"),V("setWindowTitle","setWindowTitle"),T(!a,"web environment detected but not enabled at build time. Add 'web' to `-sENVIRONMENT` to enable."),T(!c,"shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable."),e.wasmBinary&&(g=e.wasmBinary),V("wasmBinary","wasmBinary"),e.noExitRuntime,V("noExitRuntime","noExitRuntime"),"object"!=typeof WebAssembly&&N("no native wasm support detected");var E=!1;function T(e,t){e||N("Assertion failed"+(t?": "+t:""))}var S,R,M,F="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function A(){if(!E){var e=oe();0==e&&(e+=4);var t=M[e>>2],r=M[e+4>>2];34821223==t&&2310721022==r||N("Stack overflow! Stack cookie has been overwritten at "+X(e)+", expected hex dwords 0x89BACDFE and 0x2135467, but received "+X(r)+" "+X(t)),1668509029!==M[0]&&N("Runtime error: The application has corrupted its heap memory area (address zero)!")}}T(!e.STACK_SIZE,"STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),T("undefined"!=typeof Int32Array&&"undefined"!=typeof Float64Array&&null!=Int32Array.prototype.subarray&&null!=Int32Array.prototype.set,"JS engine does not provide full typed array support"),T(!e.wasmMemory,"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),T(!e.INITIAL_MEMORY,"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically"),function(){var e=new Int16Array(1),t=new Int8Array(e.buffer);if(e[0]=25459,115!==t[0]||99!==t[1])throw"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)"}();var O=[],I=[],P=[],L=!1;T(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),T(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),T(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),T(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill");var C=0,U=null,D=null,k={};function N(t){e.onAbort&&e.onAbort(t),v(t="Aborted("+t+")"),E=!0;var r=new WebAssembly.RuntimeError(t);throw o(r),r}var x={error:function(){N("Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM")},init:function(){x.error()},createDataFile:function(){x.error()},createPreloadedFile:function(){x.error()},createLazyFile:function(){x.error()},open:function(){x.error()},mkdev:function(){x.error()},registerDevice:function(){x.error()},analyzePath:function(){x.error()},loadFilesFromDB:function(){x.error()},ErrnoError:function(){x.error()}};e.FS_createDataFile=x.createDataFile,e.FS_createPreloadedFile=x.createPreloadedFile;var B,j,z;function W(e){return e.startsWith("data:application/octet-stream;base64,")}function G(e){return e.startsWith("file://")}function H(t,r){return function(){var n=t,o=r;return r||(o=e.asm),T(L,"native function `"+n+"` called before runtime initialization"),o[t]||T(o[t],"exported native function `"+n+"` not found"),o[t].apply(null,arguments)}}function Y(e){try{if(e==B&&g)return new Uint8Array(g);if(u)return u(e);throw"both async and sync fetching of the wasm failed"}catch(e){N(e)}}function q(e,t,r){return function(e){return g||!a&&!s||"function"!=typeof fetch?Promise.resolve().then((function(){return Y(e)})):fetch(e,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((function(){return Y(e)}))}(e).then((function(e){return WebAssembly.instantiate(e,t)})).then((function(e){return e})).then(r,(function(e){v("failed to asynchronously prepare wasm: "+e),G(B)&&v("warning: Loading from a file URI ("+B+") is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing"),N(e)}))}function V(t,r){Object.getOwnPropertyDescriptor(e,t)||Object.defineProperty(e,t,{configurable:!0,get:function(){N("Module."+t+" has been replaced with plain "+r+" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}})}function J(e){return"FS_createPath"===e||"FS_createDataFile"===e||"FS_createPreloadedFile"===e||"FS_unlink"===e||"addRunDependency"===e||"FS_createLazyFile"===e||"FS_createDevice"===e||"removeRunDependency"===e}function K(t){Object.getOwnPropertyDescriptor(e,t)||Object.defineProperty(e,t,{configurable:!0,get:function(){var e="'"+t+"' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)";J(t)&&(e+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),N(e)}})}function Z(t){for(;t.length>0;)t.shift()(e)}function X(e){return T("number"==typeof e),"0x"+e.toString(16).padStart(8,"0")}function $(e){$.shown||($.shown={}),$.shown[e]||($.shown[e]=1,d&&(e="warning: "+e),v(e))}W(B="index.wasm")||(j=B,B=e.locateFile?e.locateFile(j,f):f+j),z="buffer","undefined"!=typeof globalThis&&Object.defineProperty(globalThis,z,{configurable:!0,get:function(){$("`"+z+"` is not longer defined by emscripten. Please use HEAP8.buffer or wasmMemory.buffer")}});var Q=[null,[],[]];function ee(e,t){var r=Q[e];T(r),0===t||10===t?((1===e?w:v)(function(e,t,r){for(var n=t+r,o=t;e[o]&&!(o>=n);)++o;if(o-t>16&&e.buffer&&F)return F.decode(e.subarray(t,o));for(var i="";t<o;){var a=e[t++];if(128&a){var s=63&e[t++];if(192!=(224&a)){var d=63&e[t++];if(224==(240&a)?a=(15&a)<<12|s<<6|d:(240!=(248&a)&&$("Invalid UTF-8 leading byte "+X(a)+" encountered when deserializing a UTF-8 string in wasm memory to a JS string!"),a=(7&a)<<18|s<<12|d<<6|63&e[t++]),a<65536)i+=String.fromCharCode(a);else{var c=a-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&a)<<6|s)}else i+=String.fromCharCode(a)}return i}(r,0)),r.length=0):r.push(t)}var te,re={abort:function(){N("native code called abort()")},emscripten_memcpy_big:function(e,t,r){R.copyWithin(e,t,t+r)},emscripten_resize_heap:function(e){R.length,function(e){N("Cannot enlarge memory arrays to size "+e+" bytes (OOM). Either (1) compile with -sINITIAL_MEMORY=X with X higher than the current value "+S.length+", (2) compile with -sALLOW_MEMORY_GROWTH which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -sABORTING_MALLOC=0")}(e>>>=0)},fd_close:function(e){N("fd_close called without SYSCALLS_REQUIRE_FILESYSTEM")},fd_seek:function(e,t,r,n,o){return 70},fd_write:function(e,t,r,n){for(var o=0,i=0;i<r;i++){var a=M[t>>2],s=M[t+4>>2];t+=8;for(var d=0;d<s;d++)ee(e,R[a+d]);o+=s}return M[n>>2]=o,0}},ne=(function(){var t,r={env:re,wasi_snapshot_preview1:re};function n(t,r){var n,o,i=t.exports;return e.asm=i,T(b=e.asm.memory,"memory not found in wasm exports"),n=b.buffer,e.HEAP8=S=new Int8Array(n),e.HEAP16=new Int16Array(n),e.HEAP32=new Int32Array(n),e.HEAPU8=R=new Uint8Array(n),e.HEAPU16=new Uint16Array(n),e.HEAPU32=M=new Uint32Array(n),e.HEAPF32=new Float32Array(n),e.HEAPF64=new Float64Array(n),T(e.asm.__indirect_function_table,"table not found in wasm exports"),o=e.asm.__wasm_call_ctors,I.unshift(o),function(t){if(C--,e.monitorRunDependencies&&e.monitorRunDependencies(C),t?(T(k[t]),delete k[t]):v("warning: run dependency removed without ID"),0==C&&(null!==U&&(clearInterval(U),U=null),D)){var r=D;D=null,r()}}("wasm-instantiate"),i}t="wasm-instantiate",C++,e.monitorRunDependencies&&e.monitorRunDependencies(C),t?(T(!k[t]),k[t]=1,null===U&&"undefined"!=typeof setInterval&&(U=setInterval((function(){if(E)return clearInterval(U),void(U=null);var e=!1;for(var t in k)e||(e=!0,v("still waiting on run dependencies:")),v("dependency: "+t);e&&v("(end of list)")}),1e4))):v("warning: run dependency added without ID");var i,a,s,c,l=e;if(e.instantiateWasm)try{return e.instantiateWasm(r,n)}catch(e){v("Module.instantiateWasm callback failed with error: "+e),o(e)}(i=g,a=B,s=r,c=function(t){T(e===l,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),l=null,n(t.instance)},i||"function"!=typeof WebAssembly.instantiateStreaming||W(a)||d||"function"!=typeof fetch?q(a,s,c):fetch(a,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,s).then(c,(function(e){return v("wasm streaming compile failed: "+e),v("falling back to ArrayBuffer instantiation"),q(a,s,c)}))}))).catch(o)}(),H("__wasm_call_ctors"),e._opus_decoder_create=H("opus_decoder_create"),e._opus_decode_float=H("opus_decode_float"),e._opus_decoder_destroy=H("opus_decoder_destroy"),e._opus_encoder_create=H("opus_encoder_create"),e._opus_encode_float=H("opus_encode_float"),e._opus_encoder_destroy=H("opus_encoder_destroy"),e._size_of_int=H("size_of_int"),e._size_of_void_ptr=H("size_of_void_ptr"),H("__errno_location"),e._fflush=H("fflush"),e._malloc=H("malloc"),e._free=H("free"),function(){return(ne=e.asm.emscripten_stack_init).apply(null,arguments)}),oe=function(){return(oe=e.asm.emscripten_stack_get_end).apply(null,arguments)};function ie(){function r(){te||(te=!0,e.calledRun=!0,E||(T(!L),L=!0,A(),Z(I),t(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),T(!e._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),function(){if(A(),e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;)t=e.postRun.shift(),P.unshift(t);var t;Z(P)}()))}var n;C>0||(ne(),T(0==(3&(n=oe()))),0==n&&(n+=4),M[n>>2]=34821223,M[n+4>>2]=2310721022,M[0]=1668509029,function(){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)t=e.preRun.shift(),O.unshift(t);var t;Z(O)}(),C>0||(e.setStatus?(e.setStatus("Running..."),setTimeout((function(){setTimeout((function(){e.setStatus("")}),1),r()}),1)):r(),A()))}if(H("stackSave"),H("stackRestore"),H("stackAlloc"),e.dynCall_jiji=H("dynCall_jiji"),["zeroMemory","stringToNewUTF8","exitJS","emscripten_realloc_buffer","setErrNo","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","getHostByName","getRandomDevice","traverseStack","convertPCtoSourceLocation","readEmAsmArgs","jstoi_q","jstoi_s","getExecutableName","listenOnce","autoResumeAudioContext","dynCallLegacy","getDynCaller","dynCall","handleException","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","safeSetTimeout","asmjsMangle","asyncLoad","alignMemory","mmapAlloc","HandleAllocator","getNativeTypeSize","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertU32PairToI53","getCFunc","ccall","cwrap","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","getFunctionAddress","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","intArrayFromString","intArrayToString","AsciiToString","stringToAscii","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","allocateUTF8","allocateUTF8OnStack","writeStringToMemory","writeArrayToMemory","writeAsciiToMemory","getSocketFromFD","getSocketAddress","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","findCanvasEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","demangle","demangleAll","jsStackTrace","stackTrace","getEnvStrings","checkWasiClock","createDyncallWrapper","setImmediateWrapped","clearImmediateWrapped","polyfillSetImmediate","getPromise","makePromise","makePromiseCallback","ExceptionInfo","exception_addRef","exception_decRef","setMainLoop","_setNetworkCallback","heapObjectForWebGLType","heapAccessShiftForWebGLHeap","emscriptenWebGLGet","computeUnpackAlignedImageSize","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","writeGLArray","SDL_unicode","SDL_ttfContext","SDL_audio","GLFW_Window","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate"].forEach((function(e){"undefined"==typeof globalThis||Object.getOwnPropertyDescriptor(globalThis,e)||Object.defineProperty(globalThis,e,{configurable:!0,get:function(){var t="`"+e+"` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line",r=e;r.startsWith("_")||(r="$"+e),t+=" (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE="+r+")",J(e)&&(t+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),$(t)}}),K(e)})),["run","UTF8ArrayToString","UTF8ToString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","addOnPreRun","addOnInit","addOnPreMain","addOnExit","addOnPostRun","addRunDependency","removeRunDependency","FS_createFolder","FS_createPath","FS_createDataFile","FS_createPreloadedFile","FS_createLazyFile","FS_createLink","FS_createDevice","FS_unlink","out","err","callMain","abort","keepRuntimeAlive","wasmMemory","stackAlloc","stackSave","stackRestore","getTempRet0","setTempRet0","writeStackCookie","checkStackCookie","ptrToString","getHeapMax","abortOnCannotGrowMemory","ENV","ERRNO_CODES","ERRNO_MESSAGES","DNS","Protocols","Sockets","timers","warnOnce","UNWIND_CACHE","readEmAsmArgsArray","convertI32PairToI53Checked","freeTableIndexes","functionsInTableMap","setValue","getValue","PATH","PATH_FS","UTF16Decoder","SYSCALLS","JSEvents","specialHTMLTargets","currentFullscreenStrategy","restoreOldWindowedStyle","ExitStatus","flush_NO_FILESYSTEM","dlopenMissingError","promiseMap","uncaughtExceptionCount","exceptionLast","exceptionCaught","Browser","wget","FS","MEMFS","TTY","PIPEFS","SOCKFS","tempFixedLengthArray","miniTempWebGLFloatBuffers","GL","AL","SDL","SDL_gfx","GLUT","EGL","GLFW","GLEW","IDBStore"].forEach(K),D=function e(){te||ie(),te||(D=e)},e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return ie(),e.ready});e.exports=o},244:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(704);t.default=class{#e;#t;#r;#n;#o;#i;#a;constructor(e,t,r,o){if(this.#a=o,this.#o=e,this.#n=new n.ResourcesHolder,this.#t=new n.Integer(e),this.#e=new n.Pointer(e,this.#t),this.#n.add(this.#t),this.#n.add(this.#e),this.#r=e.originalRuntime()._opus_decoder_create(t,r,this.#e.offset()),!this.#r||this.#t.value()<0)throw new Error("Failed to create decoder");this.#i=new n.Buffer(e,this.#a*r*Float32Array.BYTES_PER_ELEMENT)}#s=null;decodeFloat(e,t=0){let r=this.#s;r||(r=new n.Buffer(this.#o,e.byteLength)),r.data().byteLength<e.byteLength&&(r.destroy(),r=new n.Buffer(this.#o,e.byteLength)),r.data().set(e),this.#s=r;const o=this.#o.originalRuntime()._opus_decode_float(this.#r,r.offset(),e.byteLength,this.#i.offset(),this.#a,t);if(o<0)throw new Error("Failed to decode float");return o}decoded(){const e=this.#i.data();return new Float32Array(e.buffer,e.byteOffset,e.byteLength/Float32Array.BYTES_PER_ELEMENT)}destroy(){this.#o.originalRuntime()._opus_decoder_destroy(this.#r),this.#n.destroy(),this.#s?.destroy()}}},414:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(704);t.default=class{#e;#t;#o;#d;#c;#i;#n;constructor(e,t,r,o,i,a){if(!i)throw new Error("outBufferLength must be more than 0");if(this.#n=new n.ResourcesHolder,this.#t=new n.Integer(e),this.#o=e,this.#e=new n.Pointer(e,this.#t),this.#i=new n.Buffer(e,a),this.#c=new n.Buffer(e,i),this.#n.add(this.#c),this.#n.add(this.#i),this.#n.add(this.#e),this.#n.add(this.#t),this.#d=e.originalRuntime()._opus_encoder_create(t,r,o,this.#e.value()),this.#t.value()<0)throw new Error("Failed to create encoder")}encoded(){return this.#c.data()}encodeFloat(e,t,r){if(r>this.#c.size())throw new Error(`encoded buffer length is ${this.#c.size()}, but maxDataBytes is ${r}`);this.#i.data().set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));const n=this.#o.originalRuntime()._opus_encode_float(this.#d,this.#i.offset(),t,this.#c.offset(),r);if(n<0)throw new Error("Failed to encode float");return n}destroy(){this.#n.destroy(),this.#o.originalRuntime()._opus_encoder_destroy(this.#d)}}},750:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{#l;#u;#f;#a;constructor(e){this.#u=0,this.#f=0,this.#l=new ArrayBuffer(4194304),this.#a=e}#p(){return new Float32Array(this.#l)}write(e){this.#h(e.length),this.#p().set(e,this.#f),this.#f+=e.length}read(){if(this.#f>=this.#a){const e=this.#p().subarray(this.#u,this.#u+this.#a);return this.#u+=this.#a,this.#u>=this.#f&&(this.#f=0),e}return null}#h(e){const t=e*Float32Array.BYTES_PER_ELEMENT;if(this.#p().length<=e){const e=this.#l;this.#l=new ArrayBuffer(e.byteLength+t+4194304),this.#p().set(new Uint8Array(e))}}}},426:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.RingBuffer=t.Decoder=t.Encoder=void 0;var o=r(414);Object.defineProperty(t,"Encoder",{enumerable:!0,get:function(){return n(o).default}});var i=r(244);Object.defineProperty(t,"Decoder",{enumerable:!0,get:function(){return n(i).default}});var a=r(750);Object.defineProperty(t,"RingBuffer",{enumerable:!0,get:function(){return n(a).default}})},263:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{#m;#y;#o;constructor(e,t){this.#o=e,this.#y=t,this.#m=e.malloc(t)}offset(){return this.#m}data(){return this.#o.subarray(this.#m,this.#m+this.#y)}size(){return this.#y}destroy(){this.#o.free(this.#m),this.#m=0}}},877:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{#o;#m;constructor(e){this.#o=e,this.#m=e.malloc(e.originalRuntime()._size_of_int())}value(){if(4!==this.#o.originalRuntime()._size_of_int())throw new Error("invalid integer byte size");return this.#o.view().getInt32(this.#m)}size(){return this.#o.originalRuntime()._size_of_int()}offset(){return this.#m}destroy(){this.#o.free(this.#m),this.#m=0}}},577:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{#m;#o;constructor(e,t){this.#o=e,this.#m=e.malloc(e.originalRuntime()._size_of_void_ptr()),this.#o.view().setUint32(this.#m,t.offset(),!0)}offset(){return this.#m}destroy(){this.#o.free(this.#m)}value(){return this.#o.view().getUint32(this.#m,!0)}}},438:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{#_=new Set;constructor(){}add(e){this.#_.add(e)}destroy(){for(const e of this.#_)e.destroy()}}},714:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{#o;constructor(e){this.#o=e}originalRuntime(){return this.#o}subarray(e,t){return this.#o.HEAPU8.subarray(e,t)}free(e){this.#o._free(e)}view(){return new DataView(this.#o.HEAPU8.buffer)}malloc(e){const t=this.#o._malloc(e);if(!t)throw new Error(`failed to allocate ${e} bytes`);return t}}},704:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ResourcesHolder=t.Buffer=t.Runtime=t.Pointer=t.Integer=void 0;var o=r(877);Object.defineProperty(t,"Integer",{enumerable:!0,get:function(){return n(o).default}});var i=r(577);Object.defineProperty(t,"Pointer",{enumerable:!0,get:function(){return n(i).default}});var a=r(714);Object.defineProperty(t,"Runtime",{enumerable:!0,get:function(){return n(a).default}});var s=r(263);Object.defineProperty(t,"Buffer",{enumerable:!0,get:function(){return n(s).default}});var d=r(438);Object.defineProperty(t,"ResourcesHolder",{enumerable:!0,get:function(){return n(d).default}})},977:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(426),i=r(910),a=n(r(827)),s=r(704),d=(0,a.default)({locateFile:()=>"/opus/index.wasm"});let c=0;const l=new Map;onmessage=async e=>{const t=new s.Runtime(await d),r=e.data;switch(r.type){case i.RequestType.CreateEncoder:{const e=new o.Encoder(t,r.data.sampleRate,r.data.channels,r.data.application,r.data.outBufferLength,r.data.pcmBufferLength),n=c++;l.set(n,{ringBuffer:new o.RingBuffer(r.data.pcmBufferLength/Float32Array.BYTES_PER_ELEMENT),encoder:e});const i={requestId:r.requestId,value:c++};postMessage(i);break}case i.RequestType.DestroyEncoder:{const e=l.get(r.data);if(!e)throw new Error("Failed to get encoder");e.encoder.destroy(),l.delete(r.data);const t={requestId:r.requestId,value:r.data};postMessage(t);break}case i.RequestType.EncodeFloat:{const e=l.get(r.data.encoder);if(!e)throw new Error("Failed to get encoder");e.ringBuffer.write(r.data.pcm);const t=e.ringBuffer.read(),n={requestId:r.requestId,value:{encoded:null}};if(null===t)return void postMessage(n);const o=e.encoder.encodeFloat(t,r.data.frameSize,r.data.maxDataBytes);n.value.encoded=new ArrayBuffer(o),new Uint8Array(n.value.encoded).set(e.encoder.encoded().subarray(0,o)),postMessage(n,[n.value.encoded]);break}}}},194:()=>{},472:()=>{}},t={};!function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}(977)})();