@componentor/quickjs-wasmfile-debug-asyncify 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2441 @@
1
+
2
+ var QuickJSRaw = (() => {
3
+ var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;
4
+ if (typeof __filename != 'undefined') _scriptName ||= __filename;
5
+ return (
6
+ function(moduleArg = {}) {
7
+ var moduleRtn;
8
+
9
+ // include: shell.js
10
+ // The Module object: Our interface to the outside world. We import
11
+ // and export values on it. There are various ways Module can be used:
12
+ // 1. Not defined. We create it here
13
+ // 2. A function parameter, function(moduleArg) => Promise<Module>
14
+ // 3. pre-run appended it, var Module = {}; ..generated code..
15
+ // 4. External script tag defines var Module.
16
+ // We need to check if Module already exists (e.g. case 3 above).
17
+ // Substitution will be replaced with actual code on later stage of the build,
18
+ // this way Closure Compiler will not mangle it (e.g. case 4. above).
19
+ // Note that if you want to run closure, and also to use Module
20
+ // after the generated code, you will need to define var Module = {};
21
+ // before the code. Then that object will be used in the code, and you
22
+ // can continue to use Module afterwards as well.
23
+ var Module = moduleArg;
24
+
25
+ // Set up the promise that indicates the Module is initialized
26
+ var readyPromiseResolve, readyPromiseReject;
27
+ var readyPromise = new Promise((resolve, reject) => {
28
+ readyPromiseResolve = resolve;
29
+ readyPromiseReject = reject;
30
+ });
31
+ ["_QTS_Throw","_QTS_NewError","_QTS_RuntimeSetMemoryLimit","_QTS_RuntimeComputeMemoryUsage","_QTS_RuntimeDumpMemoryUsage","_QTS_RecoverableLeakCheck","_QTS_BuildIsSanitizeLeak","_QTS_RuntimeSetMaxStackSize","_QTS_GetUndefined","_QTS_GetNull","_QTS_GetFalse","_QTS_GetTrue","_QTS_NewRuntime","_QTS_FreeRuntime","_QTS_NewContext","_QTS_FreeContext","_QTS_FreeValuePointer","_QTS_FreeValuePointerRuntime","_QTS_FreeVoidPointer","_QTS_FreeCString","_QTS_DupValuePointer","_QTS_NewObject","_QTS_NewObjectProto","_QTS_NewArray","_QTS_NewArrayBuffer","_QTS_NewFloat64","_QTS_GetFloat64","_QTS_NewString","_QTS_GetString","_QTS_GetArrayBuffer","_QTS_GetArrayBufferLength","_QTS_NewSymbol","_QTS_GetSymbolDescriptionOrKey","_QTS_IsGlobalSymbol","_QTS_IsJobPending","_QTS_ExecutePendingJob","_QTS_GetProp","_QTS_GetPropNumber","_QTS_SetProp","_QTS_DefineProp","_QTS_GetOwnPropertyNames","_QTS_Call","_QTS_ResolveException","_QTS_Dump","_QTS_Eval","_QTS_GetModuleNamespace","_QTS_Typeof","_QTS_GetLength","_QTS_IsEqual","_QTS_GetGlobalObject","_QTS_NewPromiseCapability","_QTS_PromiseState","_QTS_PromiseResult","_QTS_TestStringArg","_QTS_GetDebugLogEnabled","_QTS_SetDebugLogEnabled","_QTS_BuildIsDebug","_QTS_BuildIsAsyncify","_QTS_NewFunction","_QTS_ArgvGetJSValueConstPointer","_QTS_RuntimeEnableInterruptHandler","_QTS_RuntimeDisableInterruptHandler","_QTS_RuntimeEnableModuleLoader","_QTS_RuntimeDisableModuleLoader","_QTS_bjson_encode","_QTS_bjson_decode","_QTS_EvalFunction","_QTS_EncodeBytecode","_QTS_DecodeBytecode","_malloc","_free","_set_asyncify_stack_size","_qts_host_call_function","_qts_host_interrupt_handler","_qts_host_load_module_source","_qts_host_normalize_module","___indirect_function_table","onRuntimeInitialized"].forEach((prop) => {
32
+ if (!Object.getOwnPropertyDescriptor(readyPromise, prop)) {
33
+ Object.defineProperty(readyPromise, prop, {
34
+ 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'),
35
+ 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'),
36
+ });
37
+ }
38
+ });
39
+
40
+ // Determine the runtime environment we are in. You can customize this by
41
+ // setting the ENVIRONMENT setting at compile time (see settings.js).
42
+
43
+ var ENVIRONMENT_IS_WEB = false;
44
+ var ENVIRONMENT_IS_WORKER = false;
45
+ var ENVIRONMENT_IS_NODE = true;
46
+ var ENVIRONMENT_IS_SHELL = false;
47
+
48
+ if (Module['ENVIRONMENT']) {
49
+ 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)');
50
+ }
51
+
52
+ if (ENVIRONMENT_IS_NODE) {
53
+ // `require()` is no-op in an ESM module, use `createRequire()` to construct
54
+ // the require()` function. This is only necessary for multi-environment
55
+ // builds, `-sENVIRONMENT=node` emits a static import declaration instead.
56
+ // TODO: Swap all `require()`'s with `import()`'s?
57
+
58
+ }
59
+
60
+ // --pre-jses are emitted after the Module integration code, so that they can
61
+ // refer to Module (if they choose; they can also define Module)
62
+ // include: /Users/steffanhalvorsen/Desktop/git/quickjs-emscripten/templates/pre-extension.js
63
+ /* eslint-disable no-undef */
64
+ // quickjs-emscripten code injected into emscripten-module.js
65
+ // We use this to expose and patch up issues with Emscripten's source map handling...
66
+ function quickjsEmscriptenInit(debugLog) {
67
+ const log = debugLog || function () {}
68
+ // Everything goes in a function so we can defer running until other variables
69
+ // are initialized in case they change.
70
+ const extension = { log }
71
+ for (const init of quickjsEmscriptenInit.inits) {
72
+ init(extension)
73
+ }
74
+ Module["quickJSEmscriptenExtensions"] = extension
75
+ return extension
76
+ }
77
+ quickjsEmscriptenInit.inits = []
78
+ Module["quickjsEmscriptenInit"] = quickjsEmscriptenInit
79
+ // end include: /Users/steffanhalvorsen/Desktop/git/quickjs-emscripten/templates/pre-extension.js
80
+ // include: /Users/steffanhalvorsen/Desktop/git/quickjs-emscripten/templates/pre-sourceMapJson.js
81
+ /* eslint-disable no-undef */
82
+ quickjsEmscriptenInit.inits.push((extension) => {
83
+ if (typeof receiveSourceMapJSON !== "undefined") {
84
+ extension["receiveSourceMapJSON"] = (data) => {
85
+ if (typeof wasmSourceMap === "undefined") {
86
+ extension.log("receiveSourceMapJSON: received", data)
87
+ return receiveSourceMapJSON(data)
88
+ } else {
89
+ extension.log("receiveSourceMapJSON: already have data:", wasmSourceMap, "ignoring", data)
90
+ }
91
+ }
92
+ }
93
+ })
94
+ // end include: /Users/steffanhalvorsen/Desktop/git/quickjs-emscripten/templates/pre-sourceMapJson.js
95
+ // include: /Users/steffanhalvorsen/Desktop/git/quickjs-emscripten/templates/pre-wasmOffsetConverter.js
96
+ /* eslint-disable no-undef */
97
+ quickjsEmscriptenInit.inits.push((extension) => {
98
+ if (typeof WasmOffsetConverter !== "undefined") {
99
+ extension["WasmOffsetConverter"] = WasmOffsetConverter
100
+ // Expose function to receive WasmOffsetConverter, set to wasmOffsetConverter local variable
101
+ // if it exists
102
+ try {
103
+ // Check if wasmOffsetConverter variable exists. If it isn't defined, this
104
+ // will throw and we'll skip the rest of the branch.
105
+ extension["existingWasmOffsetConverter"] = wasmOffsetConverter
106
+ extension["receiveWasmOffsetConverter"] = function (wasmBinary, wasmModule) {
107
+ if (!wasmOffsetConverter) {
108
+ extension.log("wasmOffsetConverter set")
109
+ wasmOffsetConverter = new WasmOffsetConverter(wasmBinary, wasmModule)
110
+ } else {
111
+ extension.log("wasmOffsetConverter already set, ignored")
112
+ }
113
+ }
114
+ } catch (error) {
115
+ // Nothing.
116
+ extension["receiveWasmOffsetConverter"] = function () {
117
+ extension.log("wasmOffsetConverter variable not defined, this is a no-op")
118
+ }
119
+ }
120
+ }
121
+ })
122
+ // end include: /Users/steffanhalvorsen/Desktop/git/quickjs-emscripten/templates/pre-wasmOffsetConverter.js
123
+ // include: /Users/steffanhalvorsen/Desktop/git/quickjs-emscripten/templates/pre-wasmMemory.js
124
+ /* eslint-disable no-undef */
125
+ quickjsEmscriptenInit.inits.push((extension) => {
126
+ extension["getWasmMemory"] = function () {
127
+ return wasmMemory
128
+ }
129
+ })
130
+ // end include: /Users/steffanhalvorsen/Desktop/git/quickjs-emscripten/templates/pre-wasmMemory.js
131
+
132
+
133
+ // Sometimes an existing Module object exists with properties
134
+ // meant to overwrite the default module functionality. Here
135
+ // we collect those properties and reapply _after_ we configure
136
+ // the current environment's defaults to avoid having to be so
137
+ // defensive during initialization.
138
+ var moduleOverrides = Object.assign({}, Module);
139
+
140
+ var arguments_ = [];
141
+ var thisProgram = './this.program';
142
+ var quit_ = (status, toThrow) => {
143
+ throw toThrow;
144
+ };
145
+
146
+ // `/` should be present at the end if `scriptDirectory` is not empty
147
+ var scriptDirectory = '';
148
+ function locateFile(path) {
149
+ if (Module['locateFile']) {
150
+ return Module['locateFile'](path, scriptDirectory);
151
+ }
152
+ return scriptDirectory + path;
153
+ }
154
+
155
+ // Hooks that are implemented differently in different runtime environments.
156
+ var readAsync, readBinary;
157
+
158
+ if (ENVIRONMENT_IS_NODE) {
159
+ 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?)');
160
+
161
+ var nodeVersion = process.versions.node;
162
+ var numericVersion = nodeVersion.split('.').slice(0, 3);
163
+ numericVersion = (numericVersion[0] * 10000) + (numericVersion[1] * 100) + (numericVersion[2].split('-')[0] * 1);
164
+ var minVersion = 160000;
165
+ if (numericVersion < 160000) {
166
+ throw new Error('This emscripten-generated code requires node v16.0.0 (detected v' + nodeVersion + ')');
167
+ }
168
+
169
+ // These modules will usually be used on Node.js. Load them eagerly to avoid
170
+ // the complexity of lazy-loading.
171
+ var fs = require('fs');
172
+ var nodePath = require('path');
173
+
174
+ scriptDirectory = __dirname + '/';
175
+
176
+ // include: node_shell_read.js
177
+ readBinary = (filename) => {
178
+ // We need to re-wrap `file://` strings to URLs. Normalizing isn't
179
+ // necessary in that case, the path should already be absolute.
180
+ filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
181
+ var ret = fs.readFileSync(filename);
182
+ assert(ret.buffer);
183
+ return ret;
184
+ };
185
+
186
+ readAsync = (filename, binary = true) => {
187
+ // See the comment in the `readBinary` function.
188
+ filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
189
+ return new Promise((resolve, reject) => {
190
+ fs.readFile(filename, binary ? undefined : 'utf8', (err, data) => {
191
+ if (err) reject(err);
192
+ else resolve(binary ? data.buffer : data);
193
+ });
194
+ });
195
+ };
196
+ // end include: node_shell_read.js
197
+ if (!Module['thisProgram'] && process.argv.length > 1) {
198
+ thisProgram = process.argv[1].replace(/\\/g, '/');
199
+ }
200
+
201
+ arguments_ = process.argv.slice(2);
202
+
203
+ // MODULARIZE will export the module in the proper place outside, we don't need to export here
204
+
205
+ quit_ = (status, toThrow) => {
206
+ process.exitCode = status;
207
+ throw toThrow;
208
+ };
209
+
210
+ } else
211
+ if (ENVIRONMENT_IS_SHELL) {
212
+
213
+ if ((typeof process == 'object' && typeof require === '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?)');
214
+
215
+ } else
216
+
217
+ // Note that this includes Node.js workers when relevant (pthreads is enabled).
218
+ // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
219
+ // ENVIRONMENT_IS_NODE.
220
+ {
221
+ throw new Error('environment detection error');
222
+ }
223
+
224
+ var out = Module['print'] || console.log.bind(console);
225
+ var err = Module['printErr'] || console.error.bind(console);
226
+
227
+ // Merge back in the overrides
228
+ Object.assign(Module, moduleOverrides);
229
+ // Free the object hierarchy contained in the overrides, this lets the GC
230
+ // reclaim data used.
231
+ moduleOverrides = null;
232
+ checkIncomingModuleAPI();
233
+
234
+ // Emit code to handle expected values on the Module object. This applies Module.x
235
+ // to the proper local x. This has two benefits: first, we only emit it if it is
236
+ // expected to arrive, and second, by using a local everywhere else that can be
237
+ // minified.
238
+
239
+ if (Module['arguments']) arguments_ = Module['arguments'];legacyModuleProp('arguments', 'arguments_');
240
+
241
+ if (Module['thisProgram']) thisProgram = Module['thisProgram'];legacyModuleProp('thisProgram', 'thisProgram');
242
+
243
+ // perform assertions in shell.js after we set up out() and err(), as otherwise if an assertion fails it cannot print the message
244
+ // Assertions on removed incoming Module JS APIs.
245
+ assert(typeof Module['memoryInitializerPrefixURL'] == 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead');
246
+ assert(typeof Module['pthreadMainPrefixURL'] == 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead');
247
+ assert(typeof Module['cdInitializerPrefixURL'] == 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead');
248
+ assert(typeof Module['filePackagePrefixURL'] == 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead');
249
+ assert(typeof Module['read'] == 'undefined', 'Module.read option was removed');
250
+ assert(typeof Module['readAsync'] == 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)');
251
+ assert(typeof Module['readBinary'] == 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)');
252
+ assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)');
253
+ assert(typeof Module['TOTAL_MEMORY'] == 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY');
254
+ legacyModuleProp('asm', 'wasmExports');
255
+ legacyModuleProp('readAsync', 'readAsync');
256
+ legacyModuleProp('readBinary', 'readBinary');
257
+ legacyModuleProp('setWindowTitle', 'setWindowTitle');
258
+ var IDBFS = 'IDBFS is no longer included by default; build with -lidbfs.js';
259
+ var PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js';
260
+ var WORKERFS = 'WORKERFS is no longer included by default; build with -lworkerfs.js';
261
+ var FETCHFS = 'FETCHFS is no longer included by default; build with -lfetchfs.js';
262
+ var ICASEFS = 'ICASEFS is no longer included by default; build with -licasefs.js';
263
+ var JSFILEFS = 'JSFILEFS is no longer included by default; build with -ljsfilefs.js';
264
+ var OPFS = 'OPFS is no longer included by default; build with -lopfs.js';
265
+
266
+ var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js';
267
+
268
+ assert(!ENVIRONMENT_IS_WEB, 'web environment detected but not enabled at build time. Add `web` to `-sENVIRONMENT` to enable.');
269
+
270
+ assert(!ENVIRONMENT_IS_WORKER, 'worker environment detected but not enabled at build time. Add `worker` to `-sENVIRONMENT` to enable.');
271
+
272
+ assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.');
273
+
274
+ // end include: shell.js
275
+
276
+ // include: preamble.js
277
+ // === Preamble library stuff ===
278
+
279
+ // Documentation for the public APIs defined in this file must be updated in:
280
+ // site/source/docs/api_reference/preamble.js.rst
281
+ // A prebuilt local version of the documentation is available at:
282
+ // site/build/text/docs/api_reference/preamble.js.txt
283
+ // You can also build docs locally as HTML or other formats in site/
284
+ // An online HTML version (which may be of a different version of Emscripten)
285
+ // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
286
+
287
+ var wasmBinary = Module['wasmBinary'];legacyModuleProp('wasmBinary', 'wasmBinary');
288
+
289
+ if (typeof WebAssembly != 'object') {
290
+ err('no native wasm support detected');
291
+ }
292
+
293
+ // Wasm globals
294
+
295
+ var wasmMemory;
296
+
297
+ //========================================
298
+ // Runtime essentials
299
+ //========================================
300
+
301
+ // whether we are quitting the application. no code should run after this.
302
+ // set in exit() and abort()
303
+ var ABORT = false;
304
+
305
+ // set by exit() and abort(). Passed to 'onExit' handler.
306
+ // NOTE: This is also used as the process return code code in shell environments
307
+ // but only when noExitRuntime is false.
308
+ var EXITSTATUS;
309
+
310
+ // In STRICT mode, we only define assert() when ASSERTIONS is set. i.e. we
311
+ // don't define it at all in release modes. This matches the behaviour of
312
+ // MINIMAL_RUNTIME.
313
+ // TODO(sbc): Make this the default even without STRICT enabled.
314
+ /** @type {function(*, string=)} */
315
+ function assert(condition, text) {
316
+ if (!condition) {
317
+ abort('Assertion failed' + (text ? ': ' + text : ''));
318
+ }
319
+ }
320
+
321
+ // We used to include malloc/free by default in the past. Show a helpful error in
322
+ // builds with assertions.
323
+
324
+ // Memory management
325
+
326
+ var HEAP,
327
+ /** @type {!Int8Array} */
328
+ HEAP8,
329
+ /** @type {!Uint8Array} */
330
+ HEAPU8,
331
+ /** @type {!Int16Array} */
332
+ HEAP16,
333
+ /** @type {!Uint16Array} */
334
+ HEAPU16,
335
+ /** @type {!Int32Array} */
336
+ HEAP32,
337
+ /** @type {!Uint32Array} */
338
+ HEAPU32,
339
+ /** @type {!Float32Array} */
340
+ HEAPF32,
341
+ /** @type {!Float64Array} */
342
+ HEAPF64;
343
+
344
+ // include: runtime_shared.js
345
+ function updateMemoryViews() {
346
+ var b = wasmMemory.buffer;
347
+ Module['HEAP8'] = HEAP8 = new Int8Array(b);
348
+ Module['HEAP16'] = HEAP16 = new Int16Array(b);
349
+ Module['HEAPU8'] = HEAPU8 = new Uint8Array(b);
350
+ Module['HEAPU16'] = HEAPU16 = new Uint16Array(b);
351
+ Module['HEAP32'] = HEAP32 = new Int32Array(b);
352
+ Module['HEAPU32'] = HEAPU32 = new Uint32Array(b);
353
+ Module['HEAPF32'] = HEAPF32 = new Float32Array(b);
354
+ Module['HEAPF64'] = HEAPF64 = new Float64Array(b);
355
+ }
356
+ // end include: runtime_shared.js
357
+ assert(!Module['STACK_SIZE'], 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time')
358
+
359
+ assert(typeof Int32Array != 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray != undefined && Int32Array.prototype.set != undefined,
360
+ 'JS engine does not provide full typed array support');
361
+
362
+ // In non-standalone/normal mode, we create the memory here.
363
+ // include: runtime_init_memory.js
364
+ // Create the wasm memory. (Note: this only applies if IMPORTED_MEMORY is defined)
365
+
366
+ // check for full engine support (use string 'subarray' to avoid closure compiler confusion)
367
+
368
+ if (Module['wasmMemory']) {
369
+ wasmMemory = Module['wasmMemory'];
370
+ } else
371
+ {
372
+ var INITIAL_MEMORY = Module['INITIAL_MEMORY'] || 16777216;legacyModuleProp('INITIAL_MEMORY', 'INITIAL_MEMORY');
373
+
374
+ assert(INITIAL_MEMORY >= 5242880, 'INITIAL_MEMORY should be larger than STACK_SIZE, was ' + INITIAL_MEMORY + '! (STACK_SIZE=' + 5242880 + ')');
375
+ wasmMemory = new WebAssembly.Memory({
376
+ 'initial': INITIAL_MEMORY / 65536,
377
+ // In theory we should not need to emit the maximum if we want "unlimited"
378
+ // or 4GB of memory, but VMs error on that atm, see
379
+ // https://github.com/emscripten-core/emscripten/issues/14130
380
+ // And in the pthreads case we definitely need to emit a maximum. So
381
+ // always emit one.
382
+ 'maximum': 2147483648 / 65536,
383
+ });
384
+ }
385
+
386
+ updateMemoryViews();
387
+
388
+ // end include: runtime_init_memory.js
389
+
390
+ // include: runtime_stack_check.js
391
+ // Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
392
+ function writeStackCookie() {
393
+ var max = _emscripten_stack_get_end();
394
+ assert((max & 3) == 0);
395
+ // If the stack ends at address zero we write our cookies 4 bytes into the
396
+ // stack. This prevents interference with SAFE_HEAP and ASAN which also
397
+ // monitor writes to address zero.
398
+ if (max == 0) {
399
+ max += 4;
400
+ }
401
+ // The stack grow downwards towards _emscripten_stack_get_end.
402
+ // We write cookies to the final two words in the stack and detect if they are
403
+ // ever overwritten.
404
+ HEAPU32[((max)>>2)] = 0x02135467;
405
+ HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE;
406
+ // Also test the global address 0 for integrity.
407
+ HEAPU32[((0)>>2)] = 1668509029;
408
+ }
409
+
410
+ function checkStackCookie() {
411
+ if (ABORT) return;
412
+ var max = _emscripten_stack_get_end();
413
+ // See writeStackCookie().
414
+ if (max == 0) {
415
+ max += 4;
416
+ }
417
+ var cookie1 = HEAPU32[((max)>>2)];
418
+ var cookie2 = HEAPU32[(((max)+(4))>>2)];
419
+ if (cookie1 != 0x02135467 || cookie2 != 0x89BACDFE) {
420
+ abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`);
421
+ }
422
+ // Also test the global address 0 for integrity.
423
+ if (HEAPU32[((0)>>2)] != 0x63736d65 /* 'emsc' */) {
424
+ abort('Runtime error: The application has corrupted its heap memory area (address zero)!');
425
+ }
426
+ }
427
+ // end include: runtime_stack_check.js
428
+ var __ATPRERUN__ = []; // functions called before the runtime is initialized
429
+ var __ATINIT__ = []; // functions called during startup
430
+ var __ATEXIT__ = []; // functions called during shutdown
431
+ var __ATPOSTRUN__ = []; // functions called after the main() is called
432
+
433
+ var runtimeInitialized = false;
434
+
435
+ function preRun() {
436
+ if (Module['preRun']) {
437
+ if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
438
+ while (Module['preRun'].length) {
439
+ addOnPreRun(Module['preRun'].shift());
440
+ }
441
+ }
442
+ callRuntimeCallbacks(__ATPRERUN__);
443
+ }
444
+
445
+ function initRuntime() {
446
+ assert(!runtimeInitialized);
447
+ runtimeInitialized = true;
448
+
449
+ checkStackCookie();
450
+
451
+
452
+ callRuntimeCallbacks(__ATINIT__);
453
+ }
454
+
455
+ function postRun() {
456
+ checkStackCookie();
457
+
458
+ if (Module['postRun']) {
459
+ if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
460
+ while (Module['postRun'].length) {
461
+ addOnPostRun(Module['postRun'].shift());
462
+ }
463
+ }
464
+
465
+ callRuntimeCallbacks(__ATPOSTRUN__);
466
+ }
467
+
468
+ function addOnPreRun(cb) {
469
+ __ATPRERUN__.unshift(cb);
470
+ }
471
+
472
+ function addOnInit(cb) {
473
+ __ATINIT__.unshift(cb);
474
+ }
475
+
476
+ function addOnExit(cb) {
477
+ }
478
+
479
+ function addOnPostRun(cb) {
480
+ __ATPOSTRUN__.unshift(cb);
481
+ }
482
+
483
+ // include: runtime_math.js
484
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
485
+
486
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround
487
+
488
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
489
+
490
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc
491
+
492
+ 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');
493
+ 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');
494
+ 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');
495
+ 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');
496
+ // end include: runtime_math.js
497
+ // A counter of dependencies for calling run(). If we need to
498
+ // do asynchronous work before running, increment this and
499
+ // decrement it. Incrementing must happen in a place like
500
+ // Module.preRun (used by emcc to add file preloading).
501
+ // Note that you can add dependencies in preRun, even though
502
+ // it happens right before run - run will be postponed until
503
+ // the dependencies are met.
504
+ var runDependencies = 0;
505
+ var runDependencyWatcher = null;
506
+ var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
507
+ var runDependencyTracking = {};
508
+
509
+ function getUniqueRunDependency(id) {
510
+ var orig = id;
511
+ while (1) {
512
+ if (!runDependencyTracking[id]) return id;
513
+ id = orig + Math.random();
514
+ }
515
+ }
516
+
517
+ function addRunDependency(id) {
518
+ runDependencies++;
519
+
520
+ Module['monitorRunDependencies']?.(runDependencies);
521
+
522
+ if (id) {
523
+ assert(!runDependencyTracking[id]);
524
+ runDependencyTracking[id] = 1;
525
+ if (runDependencyWatcher === null && typeof setInterval != 'undefined') {
526
+ // Check for missing dependencies every few seconds
527
+ runDependencyWatcher = setInterval(() => {
528
+ if (ABORT) {
529
+ clearInterval(runDependencyWatcher);
530
+ runDependencyWatcher = null;
531
+ return;
532
+ }
533
+ var shown = false;
534
+ for (var dep in runDependencyTracking) {
535
+ if (!shown) {
536
+ shown = true;
537
+ err('still waiting on run dependencies:');
538
+ }
539
+ err(`dependency: ${dep}`);
540
+ }
541
+ if (shown) {
542
+ err('(end of list)');
543
+ }
544
+ }, 10000);
545
+ }
546
+ } else {
547
+ err('warning: run dependency added without ID');
548
+ }
549
+ }
550
+
551
+ function removeRunDependency(id) {
552
+ runDependencies--;
553
+
554
+ Module['monitorRunDependencies']?.(runDependencies);
555
+
556
+ if (id) {
557
+ assert(runDependencyTracking[id]);
558
+ delete runDependencyTracking[id];
559
+ } else {
560
+ err('warning: run dependency removed without ID');
561
+ }
562
+ if (runDependencies == 0) {
563
+ if (runDependencyWatcher !== null) {
564
+ clearInterval(runDependencyWatcher);
565
+ runDependencyWatcher = null;
566
+ }
567
+ if (dependenciesFulfilled) {
568
+ var callback = dependenciesFulfilled;
569
+ dependenciesFulfilled = null;
570
+ callback(); // can add another dependenciesFulfilled
571
+ }
572
+ }
573
+ }
574
+
575
+ /** @param {string|number=} what */
576
+ function abort(what) {
577
+ Module['onAbort']?.(what);
578
+
579
+ what = 'Aborted(' + what + ')';
580
+ // TODO(sbc): Should we remove printing and leave it up to whoever
581
+ // catches the exception?
582
+ err(what);
583
+
584
+ ABORT = true;
585
+ EXITSTATUS = 1;
586
+
587
+ if (what.indexOf('RuntimeError: unreachable') >= 0) {
588
+ what += '. "unreachable" may be due to ASYNCIFY_STACK_SIZE not being large enough (try increasing it)';
589
+ }
590
+
591
+ // Use a wasm runtime error, because a JS error might be seen as a foreign
592
+ // exception, which means we'd run destructors on it. We need the error to
593
+ // simply make the program stop.
594
+ // FIXME This approach does not work in Wasm EH because it currently does not assume
595
+ // all RuntimeErrors are from traps; it decides whether a RuntimeError is from
596
+ // a trap or not based on a hidden field within the object. So at the moment
597
+ // we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that
598
+ // allows this in the wasm spec.
599
+
600
+ // Suppress closure compiler warning here. Closure compiler's builtin extern
601
+ // definition for WebAssembly.RuntimeError claims it takes no arguments even
602
+ // though it can.
603
+ // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
604
+ /** @suppress {checkTypes} */
605
+ var e = new WebAssembly.RuntimeError(what);
606
+
607
+ readyPromiseReject(e);
608
+ // Throw the error whether or not MODULARIZE is set because abort is used
609
+ // in code paths apart from instantiation where an exception is expected
610
+ // to be thrown when abort is called.
611
+ throw e;
612
+ }
613
+
614
+ // include: memoryprofiler.js
615
+ // end include: memoryprofiler.js
616
+ // show errors on likely calls to FS when it was not included
617
+ var FS = {
618
+ error() {
619
+ 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');
620
+ },
621
+ init() { FS.error() },
622
+ createDataFile() { FS.error() },
623
+ createPreloadedFile() { FS.error() },
624
+ createLazyFile() { FS.error() },
625
+ open() { FS.error() },
626
+ mkdev() { FS.error() },
627
+ registerDevice() { FS.error() },
628
+ analyzePath() { FS.error() },
629
+
630
+ ErrnoError() { FS.error() },
631
+ };
632
+ Module['FS_createDataFile'] = FS.createDataFile;
633
+ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
634
+
635
+ // include: URIUtils.js
636
+ // Prefix of data URIs emitted by SINGLE_FILE and related options.
637
+ var dataURIPrefix = 'data:application/octet-stream;base64,';
638
+
639
+ /**
640
+ * Indicates whether filename is a base64 data URI.
641
+ * @noinline
642
+ */
643
+ var isDataURI = (filename) => filename.startsWith(dataURIPrefix);
644
+
645
+ /**
646
+ * Indicates whether filename is delivered via file protocol (as opposed to http/https)
647
+ * @noinline
648
+ */
649
+ var isFileURI = (filename) => filename.startsWith('file://');
650
+ // end include: URIUtils.js
651
+ function createExportWrapper(name, nargs) {
652
+ return (...args) => {
653
+ assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`);
654
+ var f = wasmExports[name];
655
+ assert(f, `exported native function \`${name}\` not found`);
656
+ // Only assert for too many arguments. Too few can be valid since the missing arguments will be zero filled.
657
+ assert(args.length <= nargs, `native function \`${name}\` called with ${args.length} args but expects ${nargs}`);
658
+ return f(...args);
659
+ };
660
+ }
661
+
662
+ // include: runtime_exceptions.js
663
+ // end include: runtime_exceptions.js
664
+ function findWasmBinary() {
665
+ var f = 'emscripten-module.wasm';
666
+ if (!isDataURI(f)) {
667
+ return locateFile(f);
668
+ }
669
+ return f;
670
+ }
671
+
672
+ var wasmBinaryFile;
673
+
674
+ function getBinarySync(file) {
675
+ if (file == wasmBinaryFile && wasmBinary) {
676
+ return new Uint8Array(wasmBinary);
677
+ }
678
+ if (readBinary) {
679
+ return readBinary(file);
680
+ }
681
+ throw 'both async and sync fetching of the wasm failed';
682
+ }
683
+
684
+ function getBinaryPromise(binaryFile) {
685
+ // If we don't have the binary yet, load it asynchronously using readAsync.
686
+ if (!wasmBinary
687
+ ) {
688
+ // Fetch the binary using readAsync
689
+ return readAsync(binaryFile).then(
690
+ (response) => new Uint8Array(/** @type{!ArrayBuffer} */(response)),
691
+ // Fall back to getBinarySync if readAsync fails
692
+ () => getBinarySync(binaryFile)
693
+ );
694
+ }
695
+
696
+ // Otherwise, getBinarySync should be able to get it synchronously
697
+ return Promise.resolve().then(() => getBinarySync(binaryFile));
698
+ }
699
+
700
+ function instantiateArrayBuffer(binaryFile, imports, receiver) {
701
+ return getBinaryPromise(binaryFile).then((binary) => {
702
+ return WebAssembly.instantiate(binary, imports);
703
+ }).then(receiver, (reason) => {
704
+ err(`failed to asynchronously prepare wasm: ${reason}`);
705
+
706
+ // Warn on some common problems.
707
+ if (isFileURI(wasmBinaryFile)) {
708
+ 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`);
709
+ }
710
+ abort(reason);
711
+ });
712
+ }
713
+
714
+ function instantiateAsync(binary, binaryFile, imports, callback) {
715
+ if (!binary &&
716
+ typeof WebAssembly.instantiateStreaming == 'function' &&
717
+ !isDataURI(binaryFile) &&
718
+ // Avoid instantiateStreaming() on Node.js environment for now, as while
719
+ // Node.js v18.1.0 implements it, it does not have a full fetch()
720
+ // implementation yet.
721
+ //
722
+ // Reference:
723
+ // https://github.com/emscripten-core/emscripten/pull/16917
724
+ !ENVIRONMENT_IS_NODE &&
725
+ typeof fetch == 'function') {
726
+ return fetch(binaryFile, { credentials: 'same-origin' }).then((response) => {
727
+ // Suppress closure warning here since the upstream definition for
728
+ // instantiateStreaming only allows Promise<Repsponse> rather than
729
+ // an actual Response.
730
+ // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure is fixed.
731
+ /** @suppress {checkTypes} */
732
+ var result = WebAssembly.instantiateStreaming(response, imports);
733
+
734
+ return result.then(
735
+ callback,
736
+ function(reason) {
737
+ // We expect the most common failure cause to be a bad MIME type for the binary,
738
+ // in which case falling back to ArrayBuffer instantiation should work.
739
+ err(`wasm streaming compile failed: ${reason}`);
740
+ err('falling back to ArrayBuffer instantiation');
741
+ return instantiateArrayBuffer(binaryFile, imports, callback);
742
+ });
743
+ });
744
+ }
745
+ return instantiateArrayBuffer(binaryFile, imports, callback);
746
+ }
747
+
748
+ function getWasmImports() {
749
+ // instrumenting imports is used in asyncify in two ways: to add assertions
750
+ // that check for proper import use, and for ASYNCIFY=2 we use them to set up
751
+ // the Promise API on the import side.
752
+ Asyncify.instrumentWasmImports(wasmImports);
753
+ // prepare imports
754
+ return {
755
+ 'env': wasmImports,
756
+ 'wasi_snapshot_preview1': wasmImports,
757
+ }
758
+ }
759
+
760
+ // Create the wasm instance.
761
+ // Receives the wasm imports, returns the exports.
762
+ function createWasm() {
763
+ var info = getWasmImports();
764
+ // Load the wasm module and create an instance of using native support in the JS engine.
765
+ // handle a generated wasm instance, receiving its exports and
766
+ // performing other necessary setup
767
+ /** @param {WebAssembly.Module=} module*/
768
+ function receiveInstance(instance, module) {
769
+ wasmExports = instance.exports;
770
+
771
+ wasmExports = Asyncify.instrumentWasmExports(wasmExports);
772
+
773
+
774
+
775
+ addOnInit(wasmExports['__wasm_call_ctors']);
776
+
777
+ removeRunDependency('wasm-instantiate');
778
+ return wasmExports;
779
+ }
780
+ // wait for the pthread pool (if any)
781
+ addRunDependency('wasm-instantiate');
782
+
783
+ // Prefer streaming instantiation if available.
784
+ // Async compilation can be confusing when an error on the page overwrites Module
785
+ // (for example, if the order of elements is wrong, and the one defining Module is
786
+ // later), so we save Module and check it later.
787
+ var trueModule = Module;
788
+ function receiveInstantiationResult(result) {
789
+ // 'result' is a ResultObject object which has both the module and instance.
790
+ // receiveInstance() will swap in the exports (to Module.asm) so they can be called
791
+ assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?');
792
+ trueModule = null;
793
+ // 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.
794
+ // When the regression is fixed, can restore the above PTHREADS-enabled path.
795
+ receiveInstance(result['instance']);
796
+ }
797
+
798
+ // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
799
+ // to manually instantiate the Wasm module themselves. This allows pages to
800
+ // run the instantiation parallel to any other async startup actions they are
801
+ // performing.
802
+ // Also pthreads and wasm workers initialize the wasm instance through this
803
+ // path.
804
+ if (Module['instantiateWasm']) {
805
+ try {
806
+ return Module['instantiateWasm'](info, receiveInstance);
807
+ } catch(e) {
808
+ err(`Module.instantiateWasm callback failed with error: ${e}`);
809
+ // If instantiation fails, reject the module ready promise.
810
+ readyPromiseReject(e);
811
+ }
812
+ }
813
+
814
+ if (!wasmBinaryFile) wasmBinaryFile = findWasmBinary();
815
+
816
+ // If instantiation fails, reject the module ready promise.
817
+ instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject);
818
+ return {}; // no exports yet; we'll fill them in later
819
+ }
820
+
821
+ // Globals used by JS i64 conversions (see makeSetValue)
822
+ var tempDouble;
823
+ var tempI64;
824
+
825
+ // include: runtime_debug.js
826
+ // Endianness check
827
+ (function() {
828
+ var h16 = new Int16Array(1);
829
+ var h8 = new Int8Array(h16.buffer);
830
+ h16[0] = 0x6373;
831
+ if (h8[0] !== 0x73 || h8[1] !== 0x63) throw 'Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)';
832
+ })();
833
+
834
+ function legacyModuleProp(prop, newName, incoming=true) {
835
+ if (!Object.getOwnPropertyDescriptor(Module, prop)) {
836
+ Object.defineProperty(Module, prop, {
837
+ configurable: true,
838
+ get() {
839
+ let extra = incoming ? ' (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)' : '';
840
+ abort(`\`Module.${prop}\` has been replaced by \`${newName}\`` + extra);
841
+
842
+ }
843
+ });
844
+ }
845
+ }
846
+
847
+ function ignoredModuleProp(prop) {
848
+ if (Object.getOwnPropertyDescriptor(Module, prop)) {
849
+ abort(`\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API`);
850
+ }
851
+ }
852
+
853
+ // forcing the filesystem exports a few things by default
854
+ function isExportedByForceFilesystem(name) {
855
+ return name === 'FS_createPath' ||
856
+ name === 'FS_createDataFile' ||
857
+ name === 'FS_createPreloadedFile' ||
858
+ name === 'FS_unlink' ||
859
+ name === 'addRunDependency' ||
860
+ // The old FS has some functionality that WasmFS lacks.
861
+ name === 'FS_createLazyFile' ||
862
+ name === 'FS_createDevice' ||
863
+ name === 'removeRunDependency';
864
+ }
865
+
866
+ function missingGlobal(sym, msg) {
867
+ if (typeof globalThis != 'undefined') {
868
+ Object.defineProperty(globalThis, sym, {
869
+ configurable: true,
870
+ get() {
871
+ warnOnce(`\`${sym}\` is not longer defined by emscripten. ${msg}`);
872
+ return undefined;
873
+ }
874
+ });
875
+ }
876
+ }
877
+
878
+ missingGlobal('buffer', 'Please use HEAP8.buffer or wasmMemory.buffer');
879
+ missingGlobal('asm', 'Please use wasmExports instead');
880
+
881
+ function missingLibrarySymbol(sym) {
882
+ if (typeof globalThis != 'undefined' && !Object.getOwnPropertyDescriptor(globalThis, sym)) {
883
+ Object.defineProperty(globalThis, sym, {
884
+ configurable: true,
885
+ get() {
886
+ // Can't `abort()` here because it would break code that does runtime
887
+ // checks. e.g. `if (typeof SDL === 'undefined')`.
888
+ 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`;
889
+ // DEFAULT_LIBRARY_FUNCS_TO_INCLUDE requires the name as it appears in
890
+ // library.js, which means $name for a JS name with no prefix, or name
891
+ // for a JS name like _name.
892
+ var librarySymbol = sym;
893
+ if (!librarySymbol.startsWith('_')) {
894
+ librarySymbol = '$' + sym;
895
+ }
896
+ msg += ` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${librarySymbol}')`;
897
+ if (isExportedByForceFilesystem(sym)) {
898
+ msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
899
+ }
900
+ warnOnce(msg);
901
+ return undefined;
902
+ }
903
+ });
904
+ }
905
+ // Any symbol that is not included from the JS library is also (by definition)
906
+ // not exported on the Module object.
907
+ unexportedRuntimeSymbol(sym);
908
+ }
909
+
910
+ function unexportedRuntimeSymbol(sym) {
911
+ if (!Object.getOwnPropertyDescriptor(Module, sym)) {
912
+ Object.defineProperty(Module, sym, {
913
+ configurable: true,
914
+ get() {
915
+ var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;
916
+ if (isExportedByForceFilesystem(sym)) {
917
+ msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
918
+ }
919
+ abort(msg);
920
+ }
921
+ });
922
+ }
923
+ }
924
+
925
+ // Used by XXXXX_DEBUG settings to output debug messages.
926
+ function dbg(...args) {
927
+ // TODO(sbc): Make this configurable somehow. Its not always convenient for
928
+ // logging to show up as warnings.
929
+ console.warn(...args);
930
+ }
931
+ // end include: runtime_debug.js
932
+ // === Body ===
933
+
934
+ function set_asyncify_stack_size(size,default_size) { Asyncify.StackSize = size || default_size; }
935
+ function qts_host_call_function(ctx,this_ptr,argc,argv,magic_func_id) { const asyncify = {['handleSleep'] : Asyncify.handleSleep}; return Module['callbacks']['callFunction'](asyncify, ctx, this_ptr, argc, argv, magic_func_id); }
936
+ function qts_host_interrupt_handler(rt) { const asyncify = undefined; return Module['callbacks']['shouldInterrupt'](asyncify, rt); }
937
+ function qts_host_load_module_source(rt,ctx,module_name) { const asyncify = {['handleSleep'] : Asyncify.handleSleep}; const moduleNameString = UTF8ToString(module_name); return Module['callbacks']['loadModuleSource'](asyncify, rt, ctx, moduleNameString); }
938
+ function qts_host_normalize_module(rt,ctx,module_base_name,module_name) { const asyncify = {['handleSleep'] : Asyncify.handleSleep}; const moduleBaseNameString = UTF8ToString(module_base_name); const moduleNameString = UTF8ToString(module_name); return Module['callbacks']['normalizeModule'](asyncify, rt, ctx, moduleBaseNameString, moduleNameString); }
939
+
940
+ // end include: preamble.js
941
+
942
+
943
+ /** @constructor */
944
+ function ExitStatus(status) {
945
+ this.name = 'ExitStatus';
946
+ this.message = `Program terminated with exit(${status})`;
947
+ this.status = status;
948
+ }
949
+
950
+ var callRuntimeCallbacks = (callbacks) => {
951
+ while (callbacks.length > 0) {
952
+ // Pass the module as the first argument.
953
+ callbacks.shift()(Module);
954
+ }
955
+ };
956
+
957
+
958
+ /**
959
+ * @param {number} ptr
960
+ * @param {string} type
961
+ */
962
+ function getValue(ptr, type = 'i8') {
963
+ if (type.endsWith('*')) type = '*';
964
+ switch (type) {
965
+ case 'i1': return HEAP8[ptr];
966
+ case 'i8': return HEAP8[ptr];
967
+ case 'i16': return HEAP16[((ptr)>>1)];
968
+ case 'i32': return HEAP32[((ptr)>>2)];
969
+ case 'i64': abort('to do getValue(i64) use WASM_BIGINT');
970
+ case 'float': return HEAPF32[((ptr)>>2)];
971
+ case 'double': return HEAPF64[((ptr)>>3)];
972
+ case '*': return HEAPU32[((ptr)>>2)];
973
+ default: abort(`invalid type for getValue: ${type}`);
974
+ }
975
+ }
976
+
977
+ var noExitRuntime = Module['noExitRuntime'] || true;
978
+
979
+ var ptrToString = (ptr) => {
980
+ assert(typeof ptr === 'number');
981
+ // With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
982
+ ptr >>>= 0;
983
+ return '0x' + ptr.toString(16).padStart(8, '0');
984
+ };
985
+
986
+
987
+ /**
988
+ * @param {number} ptr
989
+ * @param {number} value
990
+ * @param {string} type
991
+ */
992
+ function setValue(ptr, value, type = 'i8') {
993
+ if (type.endsWith('*')) type = '*';
994
+ switch (type) {
995
+ case 'i1': HEAP8[ptr] = value; break;
996
+ case 'i8': HEAP8[ptr] = value; break;
997
+ case 'i16': HEAP16[((ptr)>>1)] = value; break;
998
+ case 'i32': HEAP32[((ptr)>>2)] = value; break;
999
+ case 'i64': abort('to do setValue(i64) use WASM_BIGINT');
1000
+ case 'float': HEAPF32[((ptr)>>2)] = value; break;
1001
+ case 'double': HEAPF64[((ptr)>>3)] = value; break;
1002
+ case '*': HEAPU32[((ptr)>>2)] = value; break;
1003
+ default: abort(`invalid type for setValue: ${type}`);
1004
+ }
1005
+ }
1006
+
1007
+ var stackRestore = (val) => __emscripten_stack_restore(val);
1008
+
1009
+ var stackSave = () => _emscripten_stack_get_current();
1010
+
1011
+ var warnOnce = (text) => {
1012
+ warnOnce.shown ||= {};
1013
+ if (!warnOnce.shown[text]) {
1014
+ warnOnce.shown[text] = 1;
1015
+ if (ENVIRONMENT_IS_NODE) text = 'warning: ' + text;
1016
+ err(text);
1017
+ }
1018
+ };
1019
+
1020
+ var UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder() : undefined;
1021
+
1022
+ /**
1023
+ * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
1024
+ * array that contains uint8 values, returns a copy of that string as a
1025
+ * Javascript String object.
1026
+ * heapOrArray is either a regular array, or a JavaScript typed array view.
1027
+ * @param {number} idx
1028
+ * @param {number=} maxBytesToRead
1029
+ * @return {string}
1030
+ */
1031
+ var UTF8ArrayToString = (heapOrArray, idx, maxBytesToRead) => {
1032
+ var endIdx = idx + maxBytesToRead;
1033
+ var endPtr = idx;
1034
+ // TextDecoder needs to know the byte length in advance, it doesn't stop on
1035
+ // null terminator by itself. Also, use the length info to avoid running tiny
1036
+ // strings through TextDecoder, since .subarray() allocates garbage.
1037
+ // (As a tiny code save trick, compare endPtr against endIdx using a negation,
1038
+ // so that undefined means Infinity)
1039
+ while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
1040
+
1041
+ if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
1042
+ return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
1043
+ }
1044
+ var str = '';
1045
+ // If building with TextDecoder, we have already computed the string length
1046
+ // above, so test loop end condition against that
1047
+ while (idx < endPtr) {
1048
+ // For UTF8 byte structure, see:
1049
+ // http://en.wikipedia.org/wiki/UTF-8#Description
1050
+ // https://www.ietf.org/rfc/rfc2279.txt
1051
+ // https://tools.ietf.org/html/rfc3629
1052
+ var u0 = heapOrArray[idx++];
1053
+ if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
1054
+ var u1 = heapOrArray[idx++] & 63;
1055
+ if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
1056
+ var u2 = heapOrArray[idx++] & 63;
1057
+ if ((u0 & 0xF0) == 0xE0) {
1058
+ u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
1059
+ } else {
1060
+ 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!');
1061
+ u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
1062
+ }
1063
+
1064
+ if (u0 < 0x10000) {
1065
+ str += String.fromCharCode(u0);
1066
+ } else {
1067
+ var ch = u0 - 0x10000;
1068
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
1069
+ }
1070
+ }
1071
+ return str;
1072
+ };
1073
+
1074
+ /**
1075
+ * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
1076
+ * emscripten HEAP, returns a copy of that string as a Javascript String object.
1077
+ *
1078
+ * @param {number} ptr
1079
+ * @param {number=} maxBytesToRead - An optional length that specifies the
1080
+ * maximum number of bytes to read. You can omit this parameter to scan the
1081
+ * string until the first 0 byte. If maxBytesToRead is passed, and the string
1082
+ * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
1083
+ * string will cut short at that byte index (i.e. maxBytesToRead will not
1084
+ * produce a string of exact length [ptr, ptr+maxBytesToRead[) N.B. mixing
1085
+ * frequent uses of UTF8ToString() with and without maxBytesToRead may throw
1086
+ * JS JIT optimizations off, so it is worth to consider consistently using one
1087
+ * @return {string}
1088
+ */
1089
+ var UTF8ToString = (ptr, maxBytesToRead) => {
1090
+ assert(typeof ptr == 'number', `UTF8ToString expects a number (got ${typeof ptr})`);
1091
+ return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
1092
+ };
1093
+ var ___assert_fail = (condition, filename, line, func) => {
1094
+ abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
1095
+ };
1096
+
1097
+ var __abort_js = () => {
1098
+ abort('native code called abort()');
1099
+ };
1100
+
1101
+ var __emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num);
1102
+
1103
+ var isLeapYear = (year) => year%4 === 0 && (year%100 !== 0 || year%400 === 0);
1104
+
1105
+ var MONTH_DAYS_LEAP_CUMULATIVE = [0,31,60,91,121,152,182,213,244,274,305,335];
1106
+
1107
+ var MONTH_DAYS_REGULAR_CUMULATIVE = [0,31,59,90,120,151,181,212,243,273,304,334];
1108
+ var ydayFromDate = (date) => {
1109
+ var leap = isLeapYear(date.getFullYear());
1110
+ var monthDaysCumulative = (leap ? MONTH_DAYS_LEAP_CUMULATIVE : MONTH_DAYS_REGULAR_CUMULATIVE);
1111
+ var yday = monthDaysCumulative[date.getMonth()] + date.getDate() - 1; // -1 since it's days since Jan 1
1112
+
1113
+ return yday;
1114
+ };
1115
+
1116
+ var convertI32PairToI53Checked = (lo, hi) => {
1117
+ assert(lo == (lo >>> 0) || lo == (lo|0)); // lo should either be a i32 or a u32
1118
+ assert(hi === (hi|0)); // hi should be a i32
1119
+ return ((hi + 0x200000) >>> 0 < 0x400001 - !!lo) ? (lo >>> 0) + hi * 4294967296 : NaN;
1120
+ };
1121
+ function __localtime_js(time_low, time_high,tmPtr) {
1122
+ var time = convertI32PairToI53Checked(time_low, time_high);
1123
+
1124
+
1125
+ var date = new Date(time*1000);
1126
+ HEAP32[((tmPtr)>>2)] = date.getSeconds();
1127
+ HEAP32[(((tmPtr)+(4))>>2)] = date.getMinutes();
1128
+ HEAP32[(((tmPtr)+(8))>>2)] = date.getHours();
1129
+ HEAP32[(((tmPtr)+(12))>>2)] = date.getDate();
1130
+ HEAP32[(((tmPtr)+(16))>>2)] = date.getMonth();
1131
+ HEAP32[(((tmPtr)+(20))>>2)] = date.getFullYear()-1900;
1132
+ HEAP32[(((tmPtr)+(24))>>2)] = date.getDay();
1133
+
1134
+ var yday = ydayFromDate(date)|0;
1135
+ HEAP32[(((tmPtr)+(28))>>2)] = yday;
1136
+ HEAP32[(((tmPtr)+(36))>>2)] = -(date.getTimezoneOffset() * 60);
1137
+
1138
+ // Attention: DST is in December in South, and some regions don't have DST at all.
1139
+ var start = new Date(date.getFullYear(), 0, 1);
1140
+ var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
1141
+ var winterOffset = start.getTimezoneOffset();
1142
+ var dst = (summerOffset != winterOffset && date.getTimezoneOffset() == Math.min(winterOffset, summerOffset))|0;
1143
+ HEAP32[(((tmPtr)+(32))>>2)] = dst;
1144
+ ;
1145
+ }
1146
+
1147
+ var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
1148
+ assert(typeof str === 'string', `stringToUTF8Array expects a string (got ${typeof str})`);
1149
+ // Parameter maxBytesToWrite is not optional. Negative values, 0, null,
1150
+ // undefined and false each don't write out any bytes.
1151
+ if (!(maxBytesToWrite > 0))
1152
+ return 0;
1153
+
1154
+ var startIdx = outIdx;
1155
+ var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
1156
+ for (var i = 0; i < str.length; ++i) {
1157
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
1158
+ // unit, not a Unicode code point of the character! So decode
1159
+ // UTF16->UTF32->UTF8.
1160
+ // See http://unicode.org/faq/utf_bom.html#utf16-3
1161
+ // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
1162
+ // and https://www.ietf.org/rfc/rfc2279.txt
1163
+ // and https://tools.ietf.org/html/rfc3629
1164
+ var u = str.charCodeAt(i); // possibly a lead surrogate
1165
+ if (u >= 0xD800 && u <= 0xDFFF) {
1166
+ var u1 = str.charCodeAt(++i);
1167
+ u = 0x10000 + ((u & 0x3FF) << 10) | (u1 & 0x3FF);
1168
+ }
1169
+ if (u <= 0x7F) {
1170
+ if (outIdx >= endIdx) break;
1171
+ heap[outIdx++] = u;
1172
+ } else if (u <= 0x7FF) {
1173
+ if (outIdx + 1 >= endIdx) break;
1174
+ heap[outIdx++] = 0xC0 | (u >> 6);
1175
+ heap[outIdx++] = 0x80 | (u & 63);
1176
+ } else if (u <= 0xFFFF) {
1177
+ if (outIdx + 2 >= endIdx) break;
1178
+ heap[outIdx++] = 0xE0 | (u >> 12);
1179
+ heap[outIdx++] = 0x80 | ((u >> 6) & 63);
1180
+ heap[outIdx++] = 0x80 | (u & 63);
1181
+ } else {
1182
+ if (outIdx + 3 >= endIdx) break;
1183
+ 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).');
1184
+ heap[outIdx++] = 0xF0 | (u >> 18);
1185
+ heap[outIdx++] = 0x80 | ((u >> 12) & 63);
1186
+ heap[outIdx++] = 0x80 | ((u >> 6) & 63);
1187
+ heap[outIdx++] = 0x80 | (u & 63);
1188
+ }
1189
+ }
1190
+ // Null-terminate the pointer to the buffer.
1191
+ heap[outIdx] = 0;
1192
+ return outIdx - startIdx;
1193
+ };
1194
+ var stringToUTF8 = (str, outPtr, maxBytesToWrite) => {
1195
+ assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
1196
+ return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
1197
+ };
1198
+
1199
+ var lengthBytesUTF8 = (str) => {
1200
+ var len = 0;
1201
+ for (var i = 0; i < str.length; ++i) {
1202
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
1203
+ // unit, not a Unicode code point of the character! So decode
1204
+ // UTF16->UTF32->UTF8.
1205
+ // See http://unicode.org/faq/utf_bom.html#utf16-3
1206
+ var c = str.charCodeAt(i); // possibly a lead surrogate
1207
+ if (c <= 0x7F) {
1208
+ len++;
1209
+ } else if (c <= 0x7FF) {
1210
+ len += 2;
1211
+ } else if (c >= 0xD800 && c <= 0xDFFF) {
1212
+ len += 4; ++i;
1213
+ } else {
1214
+ len += 3;
1215
+ }
1216
+ }
1217
+ return len;
1218
+ };
1219
+ var __tzset_js = (timezone, daylight, std_name, dst_name) => {
1220
+ // TODO: Use (malleable) environment variables instead of system settings.
1221
+ var currentYear = new Date().getFullYear();
1222
+ var winter = new Date(currentYear, 0, 1);
1223
+ var summer = new Date(currentYear, 6, 1);
1224
+ var winterOffset = winter.getTimezoneOffset();
1225
+ var summerOffset = summer.getTimezoneOffset();
1226
+
1227
+ // Local standard timezone offset. Local standard time is not adjusted for
1228
+ // daylight savings. This code uses the fact that getTimezoneOffset returns
1229
+ // a greater value during Standard Time versus Daylight Saving Time (DST).
1230
+ // Thus it determines the expected output during Standard Time, and it
1231
+ // compares whether the output of the given date the same (Standard) or less
1232
+ // (DST).
1233
+ var stdTimezoneOffset = Math.max(winterOffset, summerOffset);
1234
+
1235
+ // timezone is specified as seconds west of UTC ("The external variable
1236
+ // `timezone` shall be set to the difference, in seconds, between
1237
+ // Coordinated Universal Time (UTC) and local standard time."), the same
1238
+ // as returned by stdTimezoneOffset.
1239
+ // See http://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html
1240
+ HEAPU32[((timezone)>>2)] = stdTimezoneOffset * 60;
1241
+
1242
+ HEAP32[((daylight)>>2)] = Number(winterOffset != summerOffset);
1243
+
1244
+ var extractZone = (timezoneOffset) => {
1245
+ // Why inverse sign?
1246
+ // Read here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset
1247
+ var sign = timezoneOffset >= 0 ? "-" : "+";
1248
+
1249
+ var absOffset = Math.abs(timezoneOffset)
1250
+ var hours = String(Math.floor(absOffset / 60)).padStart(2, "0");
1251
+ var minutes = String(absOffset % 60).padStart(2, "0");
1252
+
1253
+ return `UTC${sign}${hours}${minutes}`;
1254
+ }
1255
+
1256
+ var winterName = extractZone(winterOffset);
1257
+ var summerName = extractZone(summerOffset);
1258
+ assert(winterName);
1259
+ assert(summerName);
1260
+ assert(lengthBytesUTF8(winterName) <= 16, `timezone name truncated to fit in TZNAME_MAX (${winterName})`);
1261
+ assert(lengthBytesUTF8(summerName) <= 16, `timezone name truncated to fit in TZNAME_MAX (${summerName})`);
1262
+ if (summerOffset < winterOffset) {
1263
+ // Northern hemisphere
1264
+ stringToUTF8(winterName, std_name, 17);
1265
+ stringToUTF8(summerName, dst_name, 17);
1266
+ } else {
1267
+ stringToUTF8(winterName, dst_name, 17);
1268
+ stringToUTF8(summerName, std_name, 17);
1269
+ }
1270
+ };
1271
+
1272
+ var _emscripten_date_now = () => Date.now();
1273
+
1274
+ var getHeapMax = () =>
1275
+ // Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
1276
+ // full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
1277
+ // for any code that deals with heap sizes, which would require special
1278
+ // casing all heap size related code to treat 0 specially.
1279
+ 2147483648;
1280
+
1281
+ var alignMemory = (size, alignment) => {
1282
+ assert(alignment, "alignment argument is required");
1283
+ return Math.ceil(size / alignment) * alignment;
1284
+ };
1285
+
1286
+ var growMemory = (size) => {
1287
+ var b = wasmMemory.buffer;
1288
+ var pages = (size - b.byteLength + 65535) / 65536;
1289
+ try {
1290
+ // round size grow request up to wasm page size (fixed 64KB per spec)
1291
+ wasmMemory.grow(pages); // .grow() takes a delta compared to the previous size
1292
+ updateMemoryViews();
1293
+ return 1 /*success*/;
1294
+ } catch(e) {
1295
+ err(`growMemory: Attempted to grow heap from ${b.byteLength} bytes to ${size} bytes, but got error: ${e}`);
1296
+ }
1297
+ // implicit 0 return to save code size (caller will cast "undefined" into 0
1298
+ // anyhow)
1299
+ };
1300
+ var _emscripten_resize_heap = (requestedSize) => {
1301
+ var oldSize = HEAPU8.length;
1302
+ // With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
1303
+ requestedSize >>>= 0;
1304
+ // With multithreaded builds, races can happen (another thread might increase the size
1305
+ // in between), so return a failure, and let the caller retry.
1306
+ assert(requestedSize > oldSize);
1307
+
1308
+ // Memory resize rules:
1309
+ // 1. Always increase heap size to at least the requested size, rounded up
1310
+ // to next page multiple.
1311
+ // 2a. If MEMORY_GROWTH_LINEAR_STEP == -1, excessively resize the heap
1312
+ // geometrically: increase the heap size according to
1313
+ // MEMORY_GROWTH_GEOMETRIC_STEP factor (default +20%), At most
1314
+ // overreserve by MEMORY_GROWTH_GEOMETRIC_CAP bytes (default 96MB).
1315
+ // 2b. If MEMORY_GROWTH_LINEAR_STEP != -1, excessively resize the heap
1316
+ // linearly: increase the heap size by at least
1317
+ // MEMORY_GROWTH_LINEAR_STEP bytes.
1318
+ // 3. Max size for the heap is capped at 2048MB-WASM_PAGE_SIZE, or by
1319
+ // MAXIMUM_MEMORY, or by ASAN limit, depending on which is smallest
1320
+ // 4. If we were unable to allocate as much memory, it may be due to
1321
+ // over-eager decision to excessively reserve due to (3) above.
1322
+ // Hence if an allocation fails, cut down on the amount of excess
1323
+ // growth, in an attempt to succeed to perform a smaller allocation.
1324
+
1325
+ // A limit is set for how much we can grow. We should not exceed that
1326
+ // (the wasm binary specifies it, so if we tried, we'd fail anyhow).
1327
+ var maxHeapSize = getHeapMax();
1328
+ if (requestedSize > maxHeapSize) {
1329
+ err(`Cannot enlarge memory, requested ${requestedSize} bytes, but the limit is ${maxHeapSize} bytes!`);
1330
+ return false;
1331
+ }
1332
+
1333
+ // Loop through potential heap size increases. If we attempt a too eager
1334
+ // reservation that fails, cut down on the attempted size and reserve a
1335
+ // smaller bump instead. (max 3 times, chosen somewhat arbitrarily)
1336
+ for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
1337
+ var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown); // ensure geometric growth
1338
+ // but limit overreserving (default to capping at +96MB overgrowth at most)
1339
+ overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296 );
1340
+
1341
+ var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
1342
+
1343
+ var replacement = growMemory(newSize);
1344
+ if (replacement) {
1345
+
1346
+ return true;
1347
+ }
1348
+ }
1349
+ err(`Failed to grow the heap from ${oldSize} bytes to ${newSize} bytes, not enough memory!`);
1350
+ return false;
1351
+ };
1352
+
1353
+ var SYSCALLS = {
1354
+ varargs:undefined,
1355
+ getStr(ptr) {
1356
+ var ret = UTF8ToString(ptr);
1357
+ return ret;
1358
+ },
1359
+ };
1360
+ var _fd_close = (fd) => {
1361
+ abort('fd_close called without SYSCALLS_REQUIRE_FILESYSTEM');
1362
+ };
1363
+
1364
+ function _fd_seek(fd,offset_low, offset_high,whence,newOffset) {
1365
+ var offset = convertI32PairToI53Checked(offset_low, offset_high);
1366
+
1367
+
1368
+ return 70;
1369
+ ;
1370
+ }
1371
+
1372
+ var printCharBuffers = [null,[],[]];
1373
+
1374
+ var printChar = (stream, curr) => {
1375
+ var buffer = printCharBuffers[stream];
1376
+ assert(buffer);
1377
+ if (curr === 0 || curr === 10) {
1378
+ (stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0));
1379
+ buffer.length = 0;
1380
+ } else {
1381
+ buffer.push(curr);
1382
+ }
1383
+ };
1384
+
1385
+ var flush_NO_FILESYSTEM = () => {
1386
+ // flush anything remaining in the buffers during shutdown
1387
+ _fflush(0);
1388
+ if (printCharBuffers[1].length) printChar(1, 10);
1389
+ if (printCharBuffers[2].length) printChar(2, 10);
1390
+ };
1391
+
1392
+
1393
+ var _fd_write = (fd, iov, iovcnt, pnum) => {
1394
+ // hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
1395
+ var num = 0;
1396
+ for (var i = 0; i < iovcnt; i++) {
1397
+ var ptr = HEAPU32[((iov)>>2)];
1398
+ var len = HEAPU32[(((iov)+(4))>>2)];
1399
+ iov += 8;
1400
+ for (var j = 0; j < len; j++) {
1401
+ printChar(fd, HEAPU8[ptr+j]);
1402
+ }
1403
+ num += len;
1404
+ }
1405
+ HEAPU32[((pnum)>>2)] = num;
1406
+ return 0;
1407
+ };
1408
+
1409
+ var runAndAbortIfError = (func) => {
1410
+ try {
1411
+ return func();
1412
+ } catch (e) {
1413
+ abort(e);
1414
+ }
1415
+ };
1416
+
1417
+ var handleException = (e) => {
1418
+ // Certain exception types we do not treat as errors since they are used for
1419
+ // internal control flow.
1420
+ // 1. ExitStatus, which is thrown by exit()
1421
+ // 2. "unwind", which is thrown by emscripten_unwind_to_js_event_loop() and others
1422
+ // that wish to return to JS event loop.
1423
+ if (e instanceof ExitStatus || e == 'unwind') {
1424
+ return EXITSTATUS;
1425
+ }
1426
+ checkStackCookie();
1427
+ if (e instanceof WebAssembly.RuntimeError) {
1428
+ if (_emscripten_stack_get_current() <= 0) {
1429
+ err('Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to 5242880)');
1430
+ }
1431
+ }
1432
+ quit_(1, e);
1433
+ };
1434
+
1435
+
1436
+ var runtimeKeepaliveCounter = 0;
1437
+ var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
1438
+ var _proc_exit = (code) => {
1439
+ EXITSTATUS = code;
1440
+ if (!keepRuntimeAlive()) {
1441
+ Module['onExit']?.(code);
1442
+ ABORT = true;
1443
+ }
1444
+ quit_(code, new ExitStatus(code));
1445
+ };
1446
+
1447
+ /** @suppress {duplicate } */
1448
+ /** @param {boolean|number=} implicit */
1449
+ var exitJS = (status, implicit) => {
1450
+ EXITSTATUS = status;
1451
+
1452
+ checkUnflushedContent();
1453
+
1454
+ // if exit() was called explicitly, warn the user if the runtime isn't actually being shut down
1455
+ if (keepRuntimeAlive() && !implicit) {
1456
+ var msg = `program exited (with status: ${status}), but keepRuntimeAlive() is set (counter=${runtimeKeepaliveCounter}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;
1457
+ readyPromiseReject(msg);
1458
+ err(msg);
1459
+ }
1460
+
1461
+ _proc_exit(status);
1462
+ };
1463
+ var _exit = exitJS;
1464
+
1465
+
1466
+ var maybeExit = () => {
1467
+ if (!keepRuntimeAlive()) {
1468
+ try {
1469
+ _exit(EXITSTATUS);
1470
+ } catch (e) {
1471
+ handleException(e);
1472
+ }
1473
+ }
1474
+ };
1475
+ var callUserCallback = (func) => {
1476
+ if (ABORT) {
1477
+ err('user callback triggered after runtime exited or application aborted. Ignoring.');
1478
+ return;
1479
+ }
1480
+ try {
1481
+ func();
1482
+ maybeExit();
1483
+ } catch (e) {
1484
+ handleException(e);
1485
+ }
1486
+ };
1487
+
1488
+ var sigToWasmTypes = (sig) => {
1489
+ assert(!sig.includes('j'), 'i64 not permitted in function signatures when WASM_BIGINT is disabled');
1490
+ var typeNames = {
1491
+ 'i': 'i32',
1492
+ 'j': 'i64',
1493
+ 'f': 'f32',
1494
+ 'd': 'f64',
1495
+ 'e': 'externref',
1496
+ 'p': 'i32',
1497
+ };
1498
+ var type = {
1499
+ parameters: [],
1500
+ results: sig[0] == 'v' ? [] : [typeNames[sig[0]]]
1501
+ };
1502
+ for (var i = 1; i < sig.length; ++i) {
1503
+ assert(sig[i] in typeNames, 'invalid signature char: ' + sig[i]);
1504
+ type.parameters.push(typeNames[sig[i]]);
1505
+ }
1506
+ return type;
1507
+ };
1508
+
1509
+ var runtimeKeepalivePush = () => {
1510
+ runtimeKeepaliveCounter += 1;
1511
+ };
1512
+
1513
+ var runtimeKeepalivePop = () => {
1514
+ assert(runtimeKeepaliveCounter > 0);
1515
+ runtimeKeepaliveCounter -= 1;
1516
+ };
1517
+
1518
+
1519
+ var Asyncify = {
1520
+ instrumentWasmImports(imports) {
1521
+ var importPattern = /^(qts_host_call_function|qts_host_load_module_source|qts_host_normalize_module|invoke_.*|__asyncjs__.*)$/;
1522
+
1523
+ for (let [x, original] of Object.entries(imports)) {
1524
+ if (typeof original == 'function') {
1525
+ let isAsyncifyImport = original.isAsync || importPattern.test(x);
1526
+ imports[x] = (...args) => {
1527
+ var originalAsyncifyState = Asyncify.state;
1528
+ try {
1529
+ return original(...args);
1530
+ } finally {
1531
+ // Only asyncify-declared imports are allowed to change the
1532
+ // state.
1533
+ // Changing the state from normal to disabled is allowed (in any
1534
+ // function) as that is what shutdown does (and we don't have an
1535
+ // explicit list of shutdown imports).
1536
+ var changedToDisabled =
1537
+ originalAsyncifyState === Asyncify.State.Normal &&
1538
+ Asyncify.state === Asyncify.State.Disabled;
1539
+ // invoke_* functions are allowed to change the state if we do
1540
+ // not ignore indirect calls.
1541
+ var ignoredInvoke = x.startsWith('invoke_') &&
1542
+ true;
1543
+ if (Asyncify.state !== originalAsyncifyState &&
1544
+ !isAsyncifyImport &&
1545
+ !changedToDisabled &&
1546
+ !ignoredInvoke) {
1547
+ throw new Error(`import ${x} was not in ASYNCIFY_IMPORTS, but changed the state`);
1548
+ }
1549
+ }
1550
+ };
1551
+ }
1552
+ }
1553
+ },
1554
+ instrumentWasmExports(exports) {
1555
+ var ret = {};
1556
+ for (let [x, original] of Object.entries(exports)) {
1557
+ if (typeof original == 'function') {
1558
+ ret[x] = (...args) => {
1559
+ Asyncify.exportCallStack.push(x);
1560
+ try {
1561
+ return original(...args);
1562
+ } finally {
1563
+ if (!ABORT) {
1564
+ var y = Asyncify.exportCallStack.pop();
1565
+ assert(y === x);
1566
+ Asyncify.maybeStopUnwind();
1567
+ }
1568
+ }
1569
+ };
1570
+ } else {
1571
+ ret[x] = original;
1572
+ }
1573
+ }
1574
+ return ret;
1575
+ },
1576
+ State:{
1577
+ Normal:0,
1578
+ Unwinding:1,
1579
+ Rewinding:2,
1580
+ Disabled:3,
1581
+ },
1582
+ state:0,
1583
+ StackSize:81920,
1584
+ currData:null,
1585
+ handleSleepReturnValue:0,
1586
+ exportCallStack:[],
1587
+ callStackNameToId:{
1588
+ },
1589
+ callStackIdToName:{
1590
+ },
1591
+ callStackId:0,
1592
+ asyncPromiseHandlers:null,
1593
+ sleepCallbacks:[],
1594
+ getCallStackId(funcName) {
1595
+ var id = Asyncify.callStackNameToId[funcName];
1596
+ if (id === undefined) {
1597
+ id = Asyncify.callStackId++;
1598
+ Asyncify.callStackNameToId[funcName] = id;
1599
+ Asyncify.callStackIdToName[id] = funcName;
1600
+ }
1601
+ return id;
1602
+ },
1603
+ maybeStopUnwind() {
1604
+ if (Asyncify.currData &&
1605
+ Asyncify.state === Asyncify.State.Unwinding &&
1606
+ Asyncify.exportCallStack.length === 0) {
1607
+ // We just finished unwinding.
1608
+ // Be sure to set the state before calling any other functions to avoid
1609
+ // possible infinite recursion here (For example in debug pthread builds
1610
+ // the dbg() function itself can call back into WebAssembly to get the
1611
+ // current pthread_self() pointer).
1612
+ Asyncify.state = Asyncify.State.Normal;
1613
+
1614
+ // Keep the runtime alive so that a re-wind can be done later.
1615
+ runAndAbortIfError(_asyncify_stop_unwind);
1616
+ if (typeof Fibers != 'undefined') {
1617
+ Fibers.trampoline();
1618
+ }
1619
+ }
1620
+ },
1621
+ whenDone() {
1622
+ assert(Asyncify.currData, 'Tried to wait for an async operation when none is in progress.');
1623
+ assert(!Asyncify.asyncPromiseHandlers, 'Cannot have multiple async operations in flight at once');
1624
+ return new Promise((resolve, reject) => {
1625
+ Asyncify.asyncPromiseHandlers = { resolve, reject };
1626
+ });
1627
+ },
1628
+ allocateData() {
1629
+ // An asyncify data structure has three fields:
1630
+ // 0 current stack pos
1631
+ // 4 max stack pos
1632
+ // 8 id of function at bottom of the call stack (callStackIdToName[id] == name of js function)
1633
+ //
1634
+ // The Asyncify ABI only interprets the first two fields, the rest is for the runtime.
1635
+ // We also embed a stack in the same memory region here, right next to the structure.
1636
+ // This struct is also defined as asyncify_data_t in emscripten/fiber.h
1637
+ var ptr = _malloc(12 + Asyncify.StackSize);
1638
+ Asyncify.setDataHeader(ptr, ptr + 12, Asyncify.StackSize);
1639
+ Asyncify.setDataRewindFunc(ptr);
1640
+ return ptr;
1641
+ },
1642
+ setDataHeader(ptr, stack, stackSize) {
1643
+ HEAPU32[((ptr)>>2)] = stack;
1644
+ HEAPU32[(((ptr)+(4))>>2)] = stack + stackSize;
1645
+ },
1646
+ setDataRewindFunc(ptr) {
1647
+ var bottomOfCallStack = Asyncify.exportCallStack[0];
1648
+ var rewindId = Asyncify.getCallStackId(bottomOfCallStack);
1649
+ HEAP32[(((ptr)+(8))>>2)] = rewindId;
1650
+ },
1651
+ getDataRewindFuncName(ptr) {
1652
+ var id = HEAP32[(((ptr)+(8))>>2)];
1653
+ var name = Asyncify.callStackIdToName[id];
1654
+ return name;
1655
+ },
1656
+ getDataRewindFunc(name) {
1657
+ var func = wasmExports[name];
1658
+ return func;
1659
+ },
1660
+ doRewind(ptr) {
1661
+ var name = Asyncify.getDataRewindFuncName(ptr);
1662
+ var func = Asyncify.getDataRewindFunc(name);
1663
+ // Once we have rewound and the stack we no longer need to artificially
1664
+ // keep the runtime alive.
1665
+
1666
+ return func();
1667
+ },
1668
+ handleSleep(startAsync) {
1669
+ assert(Asyncify.state !== Asyncify.State.Disabled, 'Asyncify cannot be done during or after the runtime exits');
1670
+ if (ABORT) return;
1671
+ if (Asyncify.state === Asyncify.State.Normal) {
1672
+ // Prepare to sleep. Call startAsync, and see what happens:
1673
+ // if the code decided to call our callback synchronously,
1674
+ // then no async operation was in fact begun, and we don't
1675
+ // need to do anything.
1676
+ var reachedCallback = false;
1677
+ var reachedAfterCallback = false;
1678
+ startAsync((handleSleepReturnValue = 0) => {
1679
+ assert(!handleSleepReturnValue || typeof handleSleepReturnValue == 'number' || typeof handleSleepReturnValue == 'boolean'); // old emterpretify API supported other stuff
1680
+ if (ABORT) return;
1681
+ Asyncify.handleSleepReturnValue = handleSleepReturnValue;
1682
+ reachedCallback = true;
1683
+ if (!reachedAfterCallback) {
1684
+ // We are happening synchronously, so no need for async.
1685
+ return;
1686
+ }
1687
+ // This async operation did not happen synchronously, so we did
1688
+ // unwind. In that case there can be no compiled code on the stack,
1689
+ // as it might break later operations (we can rewind ok now, but if
1690
+ // we unwind again, we would unwind through the extra compiled code
1691
+ // too).
1692
+ assert(!Asyncify.exportCallStack.length, 'Waking up (starting to rewind) must be done from JS, without compiled code on the stack.');
1693
+ Asyncify.state = Asyncify.State.Rewinding;
1694
+ runAndAbortIfError(() => _asyncify_start_rewind(Asyncify.currData));
1695
+ if (typeof Browser != 'undefined' && Browser.mainLoop.func) {
1696
+ Browser.mainLoop.resume();
1697
+ }
1698
+ var asyncWasmReturnValue, isError = false;
1699
+ try {
1700
+ asyncWasmReturnValue = Asyncify.doRewind(Asyncify.currData);
1701
+ } catch (err) {
1702
+ asyncWasmReturnValue = err;
1703
+ isError = true;
1704
+ }
1705
+ // Track whether the return value was handled by any promise handlers.
1706
+ var handled = false;
1707
+ if (!Asyncify.currData) {
1708
+ // All asynchronous execution has finished.
1709
+ // `asyncWasmReturnValue` now contains the final
1710
+ // return value of the exported async WASM function.
1711
+ //
1712
+ // Note: `asyncWasmReturnValue` is distinct from
1713
+ // `Asyncify.handleSleepReturnValue`.
1714
+ // `Asyncify.handleSleepReturnValue` contains the return
1715
+ // value of the last C function to have executed
1716
+ // `Asyncify.handleSleep()`, where as `asyncWasmReturnValue`
1717
+ // contains the return value of the exported WASM function
1718
+ // that may have called C functions that
1719
+ // call `Asyncify.handleSleep()`.
1720
+ var asyncPromiseHandlers = Asyncify.asyncPromiseHandlers;
1721
+ if (asyncPromiseHandlers) {
1722
+ Asyncify.asyncPromiseHandlers = null;
1723
+ (isError ? asyncPromiseHandlers.reject : asyncPromiseHandlers.resolve)(asyncWasmReturnValue);
1724
+ handled = true;
1725
+ }
1726
+ }
1727
+ if (isError && !handled) {
1728
+ // If there was an error and it was not handled by now, we have no choice but to
1729
+ // rethrow that error into the global scope where it can be caught only by
1730
+ // `onerror` or `onunhandledpromiserejection`.
1731
+ throw asyncWasmReturnValue;
1732
+ }
1733
+ });
1734
+ reachedAfterCallback = true;
1735
+ if (!reachedCallback) {
1736
+ // A true async operation was begun; start a sleep.
1737
+ Asyncify.state = Asyncify.State.Unwinding;
1738
+ // TODO: reuse, don't alloc/free every sleep
1739
+ Asyncify.currData = Asyncify.allocateData();
1740
+ if (typeof Browser != 'undefined' && Browser.mainLoop.func) {
1741
+ Browser.mainLoop.pause();
1742
+ }
1743
+ runAndAbortIfError(() => _asyncify_start_unwind(Asyncify.currData));
1744
+ }
1745
+ } else if (Asyncify.state === Asyncify.State.Rewinding) {
1746
+ // Stop a resume.
1747
+ Asyncify.state = Asyncify.State.Normal;
1748
+ runAndAbortIfError(_asyncify_stop_rewind);
1749
+ _free(Asyncify.currData);
1750
+ Asyncify.currData = null;
1751
+ // Call all sleep callbacks now that the sleep-resume is all done.
1752
+ Asyncify.sleepCallbacks.forEach(callUserCallback);
1753
+ } else {
1754
+ abort(`invalid state: ${Asyncify.state}`);
1755
+ }
1756
+ return Asyncify.handleSleepReturnValue;
1757
+ },
1758
+ handleAsync(startAsync) {
1759
+ return Asyncify.handleSleep((wakeUp) => {
1760
+ // TODO: add error handling as a second param when handleSleep implements it.
1761
+ startAsync().then(wakeUp);
1762
+ });
1763
+ },
1764
+ };
1765
+
1766
+ var getCFunc = (ident) => {
1767
+ var func = Module['_' + ident]; // closure exported function
1768
+ assert(func, 'Cannot call unknown function ' + ident + ', make sure it is exported');
1769
+ return func;
1770
+ };
1771
+
1772
+
1773
+ var writeArrayToMemory = (array, buffer) => {
1774
+ assert(array.length >= 0, 'writeArrayToMemory array must have a length (should be an array or typed array)')
1775
+ HEAP8.set(array, buffer);
1776
+ };
1777
+
1778
+
1779
+
1780
+ var stackAlloc = (sz) => __emscripten_stack_alloc(sz);
1781
+ var stringToUTF8OnStack = (str) => {
1782
+ var size = lengthBytesUTF8(str) + 1;
1783
+ var ret = stackAlloc(size);
1784
+ stringToUTF8(str, ret, size);
1785
+ return ret;
1786
+ };
1787
+
1788
+
1789
+
1790
+
1791
+
1792
+
1793
+
1794
+ /**
1795
+ * @param {string|null=} returnType
1796
+ * @param {Array=} argTypes
1797
+ * @param {Arguments|Array=} args
1798
+ * @param {Object=} opts
1799
+ */
1800
+ var ccall = (ident, returnType, argTypes, args, opts) => {
1801
+ // For fast lookup of conversion functions
1802
+ var toC = {
1803
+ 'string': (str) => {
1804
+ var ret = 0;
1805
+ if (str !== null && str !== undefined && str !== 0) { // null string
1806
+ // at most 4 bytes per UTF-8 code point, +1 for the trailing '\0'
1807
+ ret = stringToUTF8OnStack(str);
1808
+ }
1809
+ return ret;
1810
+ },
1811
+ 'array': (arr) => {
1812
+ var ret = stackAlloc(arr.length);
1813
+ writeArrayToMemory(arr, ret);
1814
+ return ret;
1815
+ }
1816
+ };
1817
+
1818
+ function convertReturnValue(ret) {
1819
+ if (returnType === 'string') {
1820
+
1821
+ return UTF8ToString(ret);
1822
+ }
1823
+ if (returnType === 'boolean') return Boolean(ret);
1824
+ return ret;
1825
+ }
1826
+
1827
+ var func = getCFunc(ident);
1828
+ var cArgs = [];
1829
+ var stack = 0;
1830
+ assert(returnType !== 'array', 'Return type should not be "array".');
1831
+ if (args) {
1832
+ for (var i = 0; i < args.length; i++) {
1833
+ var converter = toC[argTypes[i]];
1834
+ if (converter) {
1835
+ if (stack === 0) stack = stackSave();
1836
+ cArgs[i] = converter(args[i]);
1837
+ } else {
1838
+ cArgs[i] = args[i];
1839
+ }
1840
+ }
1841
+ }
1842
+ // Data for a previous async operation that was in flight before us.
1843
+ var previousAsync = Asyncify.currData;
1844
+ var ret = func(...cArgs);
1845
+ function onDone(ret) {
1846
+ runtimeKeepalivePop();
1847
+ if (stack !== 0) stackRestore(stack);
1848
+ return convertReturnValue(ret);
1849
+ }
1850
+ var asyncMode = opts?.async;
1851
+
1852
+ // Keep the runtime alive through all calls. Note that this call might not be
1853
+ // async, but for simplicity we push and pop in all calls.
1854
+ runtimeKeepalivePush();
1855
+ if (Asyncify.currData != previousAsync) {
1856
+ // A change in async operation happened. If there was already an async
1857
+ // operation in flight before us, that is an error: we should not start
1858
+ // another async operation while one is active, and we should not stop one
1859
+ // either. The only valid combination is to have no change in the async
1860
+ // data (so we either had one in flight and left it alone, or we didn't have
1861
+ // one), or to have nothing in flight and to start one.
1862
+ assert(!(previousAsync && Asyncify.currData), 'We cannot start an async operation when one is already flight');
1863
+ assert(!(previousAsync && !Asyncify.currData), 'We cannot stop an async operation in flight');
1864
+ // This is a new async operation. The wasm is paused and has unwound its stack.
1865
+ // We need to return a Promise that resolves the return value
1866
+ // once the stack is rewound and execution finishes.
1867
+ assert(asyncMode, 'The call to ' + ident + ' is running asynchronously. If this was intended, add the async option to the ccall/cwrap call.');
1868
+ return Asyncify.whenDone().then(onDone);
1869
+ }
1870
+
1871
+ ret = onDone(ret);
1872
+ // If this is an async ccall, ensure we return a promise
1873
+ if (asyncMode) return Promise.resolve(ret);
1874
+ return ret;
1875
+ };
1876
+
1877
+ /**
1878
+ * @param {string=} returnType
1879
+ * @param {Array=} argTypes
1880
+ * @param {Object=} opts
1881
+ */
1882
+ var cwrap = (ident, returnType, argTypes, opts) => {
1883
+ return (...args) => ccall(ident, returnType, argTypes, args, opts);
1884
+ };
1885
+
1886
+
1887
+
1888
+ function checkIncomingModuleAPI() {
1889
+ ignoredModuleProp('fetchSettings');
1890
+ }
1891
+ var wasmImports = {
1892
+ /** @export */
1893
+ __assert_fail: ___assert_fail,
1894
+ /** @export */
1895
+ _abort_js: __abort_js,
1896
+ /** @export */
1897
+ _emscripten_memcpy_js: __emscripten_memcpy_js,
1898
+ /** @export */
1899
+ _localtime_js: __localtime_js,
1900
+ /** @export */
1901
+ _tzset_js: __tzset_js,
1902
+ /** @export */
1903
+ emscripten_date_now: _emscripten_date_now,
1904
+ /** @export */
1905
+ emscripten_resize_heap: _emscripten_resize_heap,
1906
+ /** @export */
1907
+ fd_close: _fd_close,
1908
+ /** @export */
1909
+ fd_seek: _fd_seek,
1910
+ /** @export */
1911
+ fd_write: _fd_write,
1912
+ /** @export */
1913
+ memory: wasmMemory,
1914
+ /** @export */
1915
+ qts_host_call_function,
1916
+ /** @export */
1917
+ qts_host_interrupt_handler,
1918
+ /** @export */
1919
+ qts_host_load_module_source,
1920
+ /** @export */
1921
+ qts_host_normalize_module,
1922
+ /** @export */
1923
+ set_asyncify_stack_size
1924
+ };
1925
+ var wasmExports = createWasm();
1926
+ var ___wasm_call_ctors = createExportWrapper('__wasm_call_ctors', 0);
1927
+ var _malloc = Module['_malloc'] = createExportWrapper('malloc', 1);
1928
+ var _QTS_Throw = Module['_QTS_Throw'] = createExportWrapper('QTS_Throw', 2);
1929
+ var _QTS_NewError = Module['_QTS_NewError'] = createExportWrapper('QTS_NewError', 1);
1930
+ var _QTS_RuntimeSetMemoryLimit = Module['_QTS_RuntimeSetMemoryLimit'] = createExportWrapper('QTS_RuntimeSetMemoryLimit', 2);
1931
+ var _QTS_RuntimeComputeMemoryUsage = Module['_QTS_RuntimeComputeMemoryUsage'] = createExportWrapper('QTS_RuntimeComputeMemoryUsage', 2);
1932
+ var _QTS_RuntimeDumpMemoryUsage = Module['_QTS_RuntimeDumpMemoryUsage'] = createExportWrapper('QTS_RuntimeDumpMemoryUsage', 1);
1933
+ var _QTS_RecoverableLeakCheck = Module['_QTS_RecoverableLeakCheck'] = createExportWrapper('QTS_RecoverableLeakCheck', 0);
1934
+ var _QTS_BuildIsSanitizeLeak = Module['_QTS_BuildIsSanitizeLeak'] = createExportWrapper('QTS_BuildIsSanitizeLeak', 0);
1935
+ var _QTS_RuntimeSetMaxStackSize = Module['_QTS_RuntimeSetMaxStackSize'] = createExportWrapper('QTS_RuntimeSetMaxStackSize', 2);
1936
+ var _QTS_GetUndefined = Module['_QTS_GetUndefined'] = createExportWrapper('QTS_GetUndefined', 0);
1937
+ var _QTS_GetNull = Module['_QTS_GetNull'] = createExportWrapper('QTS_GetNull', 0);
1938
+ var _QTS_GetFalse = Module['_QTS_GetFalse'] = createExportWrapper('QTS_GetFalse', 0);
1939
+ var _QTS_GetTrue = Module['_QTS_GetTrue'] = createExportWrapper('QTS_GetTrue', 0);
1940
+ var _QTS_NewRuntime = Module['_QTS_NewRuntime'] = createExportWrapper('QTS_NewRuntime', 0);
1941
+ var _QTS_FreeRuntime = Module['_QTS_FreeRuntime'] = createExportWrapper('QTS_FreeRuntime', 1);
1942
+ var _free = Module['_free'] = createExportWrapper('free', 1);
1943
+ var _QTS_NewContext = Module['_QTS_NewContext'] = createExportWrapper('QTS_NewContext', 2);
1944
+ var _QTS_FreeContext = Module['_QTS_FreeContext'] = createExportWrapper('QTS_FreeContext', 1);
1945
+ var _QTS_FreeValuePointer = Module['_QTS_FreeValuePointer'] = createExportWrapper('QTS_FreeValuePointer', 2);
1946
+ var _QTS_FreeValuePointerRuntime = Module['_QTS_FreeValuePointerRuntime'] = createExportWrapper('QTS_FreeValuePointerRuntime', 2);
1947
+ var _QTS_FreeVoidPointer = Module['_QTS_FreeVoidPointer'] = createExportWrapper('QTS_FreeVoidPointer', 2);
1948
+ var _QTS_FreeCString = Module['_QTS_FreeCString'] = createExportWrapper('QTS_FreeCString', 2);
1949
+ var _QTS_DupValuePointer = Module['_QTS_DupValuePointer'] = createExportWrapper('QTS_DupValuePointer', 2);
1950
+ var _QTS_NewObject = Module['_QTS_NewObject'] = createExportWrapper('QTS_NewObject', 1);
1951
+ var _QTS_NewObjectProto = Module['_QTS_NewObjectProto'] = createExportWrapper('QTS_NewObjectProto', 2);
1952
+ var _QTS_NewArray = Module['_QTS_NewArray'] = createExportWrapper('QTS_NewArray', 1);
1953
+ var _QTS_NewArrayBuffer = Module['_QTS_NewArrayBuffer'] = createExportWrapper('QTS_NewArrayBuffer', 3);
1954
+ var _QTS_NewFloat64 = Module['_QTS_NewFloat64'] = createExportWrapper('QTS_NewFloat64', 2);
1955
+ var _QTS_GetFloat64 = Module['_QTS_GetFloat64'] = createExportWrapper('QTS_GetFloat64', 2);
1956
+ var _QTS_NewString = Module['_QTS_NewString'] = createExportWrapper('QTS_NewString', 2);
1957
+ var _QTS_GetString = Module['_QTS_GetString'] = createExportWrapper('QTS_GetString', 2);
1958
+ var _QTS_GetArrayBuffer = Module['_QTS_GetArrayBuffer'] = createExportWrapper('QTS_GetArrayBuffer', 2);
1959
+ var _QTS_GetArrayBufferLength = Module['_QTS_GetArrayBufferLength'] = createExportWrapper('QTS_GetArrayBufferLength', 2);
1960
+ var _QTS_NewSymbol = Module['_QTS_NewSymbol'] = createExportWrapper('QTS_NewSymbol', 3);
1961
+ var _QTS_GetSymbolDescriptionOrKey = Module['_QTS_GetSymbolDescriptionOrKey'] = createExportWrapper('QTS_GetSymbolDescriptionOrKey', 2);
1962
+ var _QTS_IsGlobalSymbol = Module['_QTS_IsGlobalSymbol'] = createExportWrapper('QTS_IsGlobalSymbol', 2);
1963
+ var _QTS_IsJobPending = Module['_QTS_IsJobPending'] = createExportWrapper('QTS_IsJobPending', 1);
1964
+ var _QTS_ExecutePendingJob = Module['_QTS_ExecutePendingJob'] = createExportWrapper('QTS_ExecutePendingJob', 3);
1965
+ var _QTS_GetProp = Module['_QTS_GetProp'] = createExportWrapper('QTS_GetProp', 3);
1966
+ var _QTS_GetPropNumber = Module['_QTS_GetPropNumber'] = createExportWrapper('QTS_GetPropNumber', 3);
1967
+ var _QTS_SetProp = Module['_QTS_SetProp'] = createExportWrapper('QTS_SetProp', 4);
1968
+ var _QTS_DefineProp = Module['_QTS_DefineProp'] = createExportWrapper('QTS_DefineProp', 9);
1969
+ var _QTS_GetOwnPropertyNames = Module['_QTS_GetOwnPropertyNames'] = createExportWrapper('QTS_GetOwnPropertyNames', 5);
1970
+ var _QTS_Call = Module['_QTS_Call'] = createExportWrapper('QTS_Call', 5);
1971
+ var _QTS_ResolveException = Module['_QTS_ResolveException'] = createExportWrapper('QTS_ResolveException', 2);
1972
+ var _QTS_Dump = Module['_QTS_Dump'] = createExportWrapper('QTS_Dump', 2);
1973
+ var _QTS_Eval = Module['_QTS_Eval'] = createExportWrapper('QTS_Eval', 6);
1974
+ var _QTS_GetModuleNamespace = Module['_QTS_GetModuleNamespace'] = createExportWrapper('QTS_GetModuleNamespace', 2);
1975
+ var _QTS_Typeof = Module['_QTS_Typeof'] = createExportWrapper('QTS_Typeof', 2);
1976
+ var _QTS_GetLength = Module['_QTS_GetLength'] = createExportWrapper('QTS_GetLength', 3);
1977
+ var _QTS_IsEqual = Module['_QTS_IsEqual'] = createExportWrapper('QTS_IsEqual', 4);
1978
+ var _QTS_GetGlobalObject = Module['_QTS_GetGlobalObject'] = createExportWrapper('QTS_GetGlobalObject', 1);
1979
+ var _QTS_NewPromiseCapability = Module['_QTS_NewPromiseCapability'] = createExportWrapper('QTS_NewPromiseCapability', 2);
1980
+ var _QTS_PromiseState = Module['_QTS_PromiseState'] = createExportWrapper('QTS_PromiseState', 2);
1981
+ var _QTS_PromiseResult = Module['_QTS_PromiseResult'] = createExportWrapper('QTS_PromiseResult', 2);
1982
+ var _QTS_TestStringArg = Module['_QTS_TestStringArg'] = createExportWrapper('QTS_TestStringArg', 1);
1983
+ var _QTS_GetDebugLogEnabled = Module['_QTS_GetDebugLogEnabled'] = createExportWrapper('QTS_GetDebugLogEnabled', 1);
1984
+ var _QTS_SetDebugLogEnabled = Module['_QTS_SetDebugLogEnabled'] = createExportWrapper('QTS_SetDebugLogEnabled', 2);
1985
+ var _QTS_BuildIsDebug = Module['_QTS_BuildIsDebug'] = createExportWrapper('QTS_BuildIsDebug', 0);
1986
+ var _QTS_BuildIsAsyncify = Module['_QTS_BuildIsAsyncify'] = createExportWrapper('QTS_BuildIsAsyncify', 0);
1987
+ var _QTS_NewFunction = Module['_QTS_NewFunction'] = createExportWrapper('QTS_NewFunction', 3);
1988
+ var _QTS_ArgvGetJSValueConstPointer = Module['_QTS_ArgvGetJSValueConstPointer'] = createExportWrapper('QTS_ArgvGetJSValueConstPointer', 2);
1989
+ var _QTS_RuntimeEnableInterruptHandler = Module['_QTS_RuntimeEnableInterruptHandler'] = createExportWrapper('QTS_RuntimeEnableInterruptHandler', 1);
1990
+ var _QTS_RuntimeDisableInterruptHandler = Module['_QTS_RuntimeDisableInterruptHandler'] = createExportWrapper('QTS_RuntimeDisableInterruptHandler', 1);
1991
+ var _QTS_RuntimeEnableModuleLoader = Module['_QTS_RuntimeEnableModuleLoader'] = createExportWrapper('QTS_RuntimeEnableModuleLoader', 2);
1992
+ var _QTS_RuntimeDisableModuleLoader = Module['_QTS_RuntimeDisableModuleLoader'] = createExportWrapper('QTS_RuntimeDisableModuleLoader', 1);
1993
+ var _QTS_bjson_encode = Module['_QTS_bjson_encode'] = createExportWrapper('QTS_bjson_encode', 2);
1994
+ var _QTS_bjson_decode = Module['_QTS_bjson_decode'] = createExportWrapper('QTS_bjson_decode', 2);
1995
+ var _QTS_EvalFunction = Module['_QTS_EvalFunction'] = createExportWrapper('QTS_EvalFunction', 2);
1996
+ var _QTS_EncodeBytecode = Module['_QTS_EncodeBytecode'] = createExportWrapper('QTS_EncodeBytecode', 2);
1997
+ var _QTS_DecodeBytecode = Module['_QTS_DecodeBytecode'] = createExportWrapper('QTS_DecodeBytecode', 2);
1998
+ var _fflush = createExportWrapper('fflush', 1);
1999
+ var _strerror = createExportWrapper('strerror', 1);
2000
+ var __emscripten_tempret_set = createExportWrapper('_emscripten_tempret_set', 1);
2001
+ var _emscripten_stack_init = () => (_emscripten_stack_init = wasmExports['emscripten_stack_init'])();
2002
+ var _emscripten_stack_get_free = () => (_emscripten_stack_get_free = wasmExports['emscripten_stack_get_free'])();
2003
+ var _emscripten_stack_get_base = () => (_emscripten_stack_get_base = wasmExports['emscripten_stack_get_base'])();
2004
+ var _emscripten_stack_get_end = () => (_emscripten_stack_get_end = wasmExports['emscripten_stack_get_end'])();
2005
+ var __emscripten_stack_restore = (a0) => (__emscripten_stack_restore = wasmExports['_emscripten_stack_restore'])(a0);
2006
+ var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc'])(a0);
2007
+ var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
2008
+ var dynCall_viii = Module['dynCall_viii'] = createExportWrapper('dynCall_viii', 4);
2009
+ var dynCall_jijiiii = Module['dynCall_jijiiii'] = createExportWrapper('dynCall_jijiiii', 8);
2010
+ var dynCall_jijiii = Module['dynCall_jijiii'] = createExportWrapper('dynCall_jijiii', 7);
2011
+ var dynCall_iii = Module['dynCall_iii'] = createExportWrapper('dynCall_iii', 3);
2012
+ var dynCall_iiiii = Module['dynCall_iiiii'] = createExportWrapper('dynCall_iiiii', 5);
2013
+ var dynCall_iiii = Module['dynCall_iiii'] = createExportWrapper('dynCall_iiii', 4);
2014
+ var dynCall_ii = Module['dynCall_ii'] = createExportWrapper('dynCall_ii', 2);
2015
+ var dynCall_jiij = Module['dynCall_jiij'] = createExportWrapper('dynCall_jiij', 5);
2016
+ var dynCall_iiiijj = Module['dynCall_iiiijj'] = createExportWrapper('dynCall_iiiijj', 8);
2017
+ var dynCall_iiiij = Module['dynCall_iiiij'] = createExportWrapper('dynCall_iiiij', 6);
2018
+ var dynCall_jiiiii = Module['dynCall_jiiiii'] = createExportWrapper('dynCall_jiiiii', 6);
2019
+ var dynCall_jij = Module['dynCall_jij'] = createExportWrapper('dynCall_jij', 4);
2020
+ var dynCall_jijjiii = Module['dynCall_jijjiii'] = createExportWrapper('dynCall_jijjiii', 9);
2021
+ var dynCall_vii = Module['dynCall_vii'] = createExportWrapper('dynCall_vii', 3);
2022
+ var dynCall_jiii = Module['dynCall_jiii'] = createExportWrapper('dynCall_jiii', 4);
2023
+ var dynCall_jijii = Module['dynCall_jijii'] = createExportWrapper('dynCall_jijii', 6);
2024
+ var dynCall_jijiiiii = Module['dynCall_jijiiiii'] = createExportWrapper('dynCall_jijiiiii', 9);
2025
+ var dynCall_jijj = Module['dynCall_jijj'] = createExportWrapper('dynCall_jijj', 6);
2026
+ var dynCall_viji = Module['dynCall_viji'] = createExportWrapper('dynCall_viji', 5);
2027
+ var dynCall_vij = Module['dynCall_vij'] = createExportWrapper('dynCall_vij', 4);
2028
+ var dynCall_iiijj = Module['dynCall_iiijj'] = createExportWrapper('dynCall_iiijj', 7);
2029
+ var dynCall_iijijjji = Module['dynCall_iijijjji'] = createExportWrapper('dynCall_iijijjji', 12);
2030
+ var dynCall_iiiji = Module['dynCall_iiiji'] = createExportWrapper('dynCall_iiiji', 6);
2031
+ var dynCall_iiji = Module['dynCall_iiji'] = createExportWrapper('dynCall_iiji', 5);
2032
+ var dynCall_jijij = Module['dynCall_jijij'] = createExportWrapper('dynCall_jijij', 7);
2033
+ var dynCall_iijijji = Module['dynCall_iijijji'] = createExportWrapper('dynCall_iijijji', 10);
2034
+ var dynCall_jiiii = Module['dynCall_jiiii'] = createExportWrapper('dynCall_jiiii', 5);
2035
+ var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji', 5);
2036
+ var dynCall_jijji = Module['dynCall_jijji'] = createExportWrapper('dynCall_jijji', 7);
2037
+ var dynCall_dd = Module['dynCall_dd'] = createExportWrapper('dynCall_dd', 2);
2038
+ var dynCall_ddd = Module['dynCall_ddd'] = createExportWrapper('dynCall_ddd', 3);
2039
+ var dynCall_jii = Module['dynCall_jii'] = createExportWrapper('dynCall_jii', 3);
2040
+ var dynCall_iiiiii = Module['dynCall_iiiiii'] = createExportWrapper('dynCall_iiiiii', 6);
2041
+ var dynCall_iidiiii = Module['dynCall_iidiiii'] = createExportWrapper('dynCall_iidiiii', 7);
2042
+ var _asyncify_start_unwind = createExportWrapper('asyncify_start_unwind', 1);
2043
+ var _asyncify_stop_unwind = createExportWrapper('asyncify_stop_unwind', 0);
2044
+ var _asyncify_start_rewind = createExportWrapper('asyncify_start_rewind', 1);
2045
+ var _asyncify_stop_rewind = createExportWrapper('asyncify_stop_rewind', 0);
2046
+
2047
+
2048
+ // include: postamble.js
2049
+ // === Auto-generated postamble setup entry stuff ===
2050
+
2051
+ Module['cwrap'] = cwrap;
2052
+ Module['UTF8ToString'] = UTF8ToString;
2053
+ Module['stringToUTF8'] = stringToUTF8;
2054
+ Module['lengthBytesUTF8'] = lengthBytesUTF8;
2055
+ var missingLibrarySymbols = [
2056
+ 'writeI53ToI64',
2057
+ 'writeI53ToI64Clamped',
2058
+ 'writeI53ToI64Signaling',
2059
+ 'writeI53ToU64Clamped',
2060
+ 'writeI53ToU64Signaling',
2061
+ 'readI53FromI64',
2062
+ 'readI53FromU64',
2063
+ 'convertI32PairToI53',
2064
+ 'convertU32PairToI53',
2065
+ 'getTempRet0',
2066
+ 'setTempRet0',
2067
+ 'zeroMemory',
2068
+ 'strError',
2069
+ 'inetPton4',
2070
+ 'inetNtop4',
2071
+ 'inetPton6',
2072
+ 'inetNtop6',
2073
+ 'readSockaddr',
2074
+ 'writeSockaddr',
2075
+ 'initRandomFill',
2076
+ 'randomFill',
2077
+ 'emscriptenLog',
2078
+ 'readEmAsmArgs',
2079
+ 'jstoi_q',
2080
+ 'getExecutableName',
2081
+ 'listenOnce',
2082
+ 'autoResumeAudioContext',
2083
+ 'dynCallLegacy',
2084
+ 'getDynCaller',
2085
+ 'dynCall',
2086
+ 'asmjsMangle',
2087
+ 'asyncLoad',
2088
+ 'mmapAlloc',
2089
+ 'HandleAllocator',
2090
+ 'getNativeTypeSize',
2091
+ 'STACK_SIZE',
2092
+ 'STACK_ALIGN',
2093
+ 'POINTER_SIZE',
2094
+ 'ASSERTIONS',
2095
+ 'uleb128Encode',
2096
+ 'generateFuncType',
2097
+ 'convertJsFunctionToWasm',
2098
+ 'getEmptyTableSlot',
2099
+ 'updateTableMap',
2100
+ 'getFunctionAddress',
2101
+ 'addFunction',
2102
+ 'removeFunction',
2103
+ 'reallyNegative',
2104
+ 'unSign',
2105
+ 'strLen',
2106
+ 'reSign',
2107
+ 'formatString',
2108
+ 'intArrayFromString',
2109
+ 'intArrayToString',
2110
+ 'AsciiToString',
2111
+ 'stringToAscii',
2112
+ 'UTF16ToString',
2113
+ 'stringToUTF16',
2114
+ 'lengthBytesUTF16',
2115
+ 'UTF32ToString',
2116
+ 'stringToUTF32',
2117
+ 'lengthBytesUTF32',
2118
+ 'stringToNewUTF8',
2119
+ 'registerKeyEventCallback',
2120
+ 'maybeCStringToJsString',
2121
+ 'findEventTarget',
2122
+ 'getBoundingClientRect',
2123
+ 'fillMouseEventData',
2124
+ 'registerMouseEventCallback',
2125
+ 'registerWheelEventCallback',
2126
+ 'registerUiEventCallback',
2127
+ 'registerFocusEventCallback',
2128
+ 'fillDeviceOrientationEventData',
2129
+ 'registerDeviceOrientationEventCallback',
2130
+ 'fillDeviceMotionEventData',
2131
+ 'registerDeviceMotionEventCallback',
2132
+ 'screenOrientation',
2133
+ 'fillOrientationChangeEventData',
2134
+ 'registerOrientationChangeEventCallback',
2135
+ 'fillFullscreenChangeEventData',
2136
+ 'registerFullscreenChangeEventCallback',
2137
+ 'JSEvents_requestFullscreen',
2138
+ 'JSEvents_resizeCanvasForFullscreen',
2139
+ 'registerRestoreOldStyle',
2140
+ 'hideEverythingExceptGivenElement',
2141
+ 'restoreHiddenElements',
2142
+ 'setLetterbox',
2143
+ 'softFullscreenResizeWebGLRenderTarget',
2144
+ 'doRequestFullscreen',
2145
+ 'fillPointerlockChangeEventData',
2146
+ 'registerPointerlockChangeEventCallback',
2147
+ 'registerPointerlockErrorEventCallback',
2148
+ 'requestPointerLock',
2149
+ 'fillVisibilityChangeEventData',
2150
+ 'registerVisibilityChangeEventCallback',
2151
+ 'registerTouchEventCallback',
2152
+ 'fillGamepadEventData',
2153
+ 'registerGamepadEventCallback',
2154
+ 'registerBeforeUnloadEventCallback',
2155
+ 'fillBatteryEventData',
2156
+ 'battery',
2157
+ 'registerBatteryEventCallback',
2158
+ 'setCanvasElementSize',
2159
+ 'getCanvasElementSize',
2160
+ 'jsStackTrace',
2161
+ 'getCallstack',
2162
+ 'convertPCtoSourceLocation',
2163
+ 'getEnvStrings',
2164
+ 'checkWasiClock',
2165
+ 'wasiRightsToMuslOFlags',
2166
+ 'wasiOFlagsToMuslOFlags',
2167
+ 'createDyncallWrapper',
2168
+ 'safeSetTimeout',
2169
+ 'setImmediateWrapped',
2170
+ 'clearImmediateWrapped',
2171
+ 'polyfillSetImmediate',
2172
+ 'getPromise',
2173
+ 'makePromise',
2174
+ 'idsToPromises',
2175
+ 'makePromiseCallback',
2176
+ 'Browser_asyncPrepareDataCounter',
2177
+ 'setMainLoop',
2178
+ 'arraySum',
2179
+ 'addDays',
2180
+ 'getSocketFromFD',
2181
+ 'getSocketAddress',
2182
+ 'FS_createPreloadedFile',
2183
+ 'FS_modeStringToFlags',
2184
+ 'FS_getMode',
2185
+ 'FS_stdin_getChar',
2186
+ 'FS_unlink',
2187
+ 'FS_createDataFile',
2188
+ 'FS_mkdirTree',
2189
+ '_setNetworkCallback',
2190
+ 'ALLOC_NORMAL',
2191
+ 'ALLOC_STACK',
2192
+ 'allocate',
2193
+ 'writeStringToMemory',
2194
+ 'writeAsciiToMemory',
2195
+ 'setErrNo',
2196
+ 'stackTrace',
2197
+ ];
2198
+ missingLibrarySymbols.forEach(missingLibrarySymbol)
2199
+
2200
+ var unexportedSymbols = [
2201
+ 'run',
2202
+ 'addOnPreRun',
2203
+ 'addOnInit',
2204
+ 'addOnPreMain',
2205
+ 'addOnExit',
2206
+ 'addOnPostRun',
2207
+ 'addRunDependency',
2208
+ 'removeRunDependency',
2209
+ 'out',
2210
+ 'err',
2211
+ 'callMain',
2212
+ 'abort',
2213
+ 'wasmMemory',
2214
+ 'wasmExports',
2215
+ 'writeStackCookie',
2216
+ 'checkStackCookie',
2217
+ 'convertI32PairToI53Checked',
2218
+ 'stackSave',
2219
+ 'stackRestore',
2220
+ 'stackAlloc',
2221
+ 'ptrToString',
2222
+ 'exitJS',
2223
+ 'getHeapMax',
2224
+ 'growMemory',
2225
+ 'ENV',
2226
+ 'ERRNO_CODES',
2227
+ 'DNS',
2228
+ 'Protocols',
2229
+ 'Sockets',
2230
+ 'timers',
2231
+ 'warnOnce',
2232
+ 'readEmAsmArgsArray',
2233
+ 'jstoi_s',
2234
+ 'handleException',
2235
+ 'keepRuntimeAlive',
2236
+ 'runtimeKeepalivePush',
2237
+ 'runtimeKeepalivePop',
2238
+ 'callUserCallback',
2239
+ 'maybeExit',
2240
+ 'alignMemory',
2241
+ 'wasmTable',
2242
+ 'noExitRuntime',
2243
+ 'getCFunc',
2244
+ 'ccall',
2245
+ 'sigToWasmTypes',
2246
+ 'freeTableIndexes',
2247
+ 'functionsInTableMap',
2248
+ 'setValue',
2249
+ 'getValue',
2250
+ 'PATH',
2251
+ 'PATH_FS',
2252
+ 'UTF8Decoder',
2253
+ 'UTF8ArrayToString',
2254
+ 'stringToUTF8Array',
2255
+ 'UTF16Decoder',
2256
+ 'stringToUTF8OnStack',
2257
+ 'writeArrayToMemory',
2258
+ 'JSEvents',
2259
+ 'specialHTMLTargets',
2260
+ 'findCanvasEventTarget',
2261
+ 'currentFullscreenStrategy',
2262
+ 'restoreOldWindowedStyle',
2263
+ 'UNWIND_CACHE',
2264
+ 'ExitStatus',
2265
+ 'flush_NO_FILESYSTEM',
2266
+ 'promiseMap',
2267
+ 'Browser',
2268
+ 'getPreloadedImageData__data',
2269
+ 'wget',
2270
+ 'MONTH_DAYS_REGULAR',
2271
+ 'MONTH_DAYS_LEAP',
2272
+ 'MONTH_DAYS_REGULAR_CUMULATIVE',
2273
+ 'MONTH_DAYS_LEAP_CUMULATIVE',
2274
+ 'isLeapYear',
2275
+ 'ydayFromDate',
2276
+ 'SYSCALLS',
2277
+ 'preloadPlugins',
2278
+ 'FS_stdin_getChar_buffer',
2279
+ 'FS_createPath',
2280
+ 'FS_createDevice',
2281
+ 'FS_readFile',
2282
+ 'FS',
2283
+ 'FS_createLazyFile',
2284
+ 'MEMFS',
2285
+ 'TTY',
2286
+ 'PIPEFS',
2287
+ 'SOCKFS',
2288
+ 'runAndAbortIfError',
2289
+ 'Asyncify',
2290
+ 'Fibers',
2291
+ 'allocateUTF8',
2292
+ 'allocateUTF8OnStack',
2293
+ 'print',
2294
+ 'printErr',
2295
+ ];
2296
+ unexportedSymbols.forEach(unexportedRuntimeSymbol);
2297
+
2298
+
2299
+
2300
+ var calledRun;
2301
+
2302
+ dependenciesFulfilled = function runCaller() {
2303
+ // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
2304
+ if (!calledRun) run();
2305
+ if (!calledRun) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
2306
+ };
2307
+
2308
+ function stackCheckInit() {
2309
+ // This is normally called automatically during __wasm_call_ctors but need to
2310
+ // get these values before even running any of the ctors so we call it redundantly
2311
+ // here.
2312
+ _emscripten_stack_init();
2313
+ // TODO(sbc): Move writeStackCookie to native to to avoid this.
2314
+ writeStackCookie();
2315
+ }
2316
+
2317
+ function run() {
2318
+
2319
+ if (runDependencies > 0) {
2320
+ return;
2321
+ }
2322
+
2323
+ stackCheckInit();
2324
+
2325
+ preRun();
2326
+
2327
+ // a preRun added a dependency, run will be called later
2328
+ if (runDependencies > 0) {
2329
+ return;
2330
+ }
2331
+
2332
+ function doRun() {
2333
+ // run may have just been called through dependencies being fulfilled just in this very frame,
2334
+ // or while the async setStatus time below was happening
2335
+ if (calledRun) return;
2336
+ calledRun = true;
2337
+ Module['calledRun'] = true;
2338
+
2339
+ if (ABORT) return;
2340
+
2341
+ initRuntime();
2342
+
2343
+ readyPromiseResolve(Module);
2344
+ Module['onRuntimeInitialized']?.();
2345
+
2346
+ assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');
2347
+
2348
+ postRun();
2349
+ }
2350
+
2351
+ if (Module['setStatus']) {
2352
+ Module['setStatus']('Running...');
2353
+ setTimeout(function() {
2354
+ setTimeout(function() {
2355
+ Module['setStatus']('');
2356
+ }, 1);
2357
+ doRun();
2358
+ }, 1);
2359
+ } else
2360
+ {
2361
+ doRun();
2362
+ }
2363
+ checkStackCookie();
2364
+ }
2365
+
2366
+ function checkUnflushedContent() {
2367
+ // Compiler settings do not allow exiting the runtime, so flushing
2368
+ // the streams is not possible. but in ASSERTIONS mode we check
2369
+ // if there was something to flush, and if so tell the user they
2370
+ // should request that the runtime be exitable.
2371
+ // Normally we would not even include flush() at all, but in ASSERTIONS
2372
+ // builds we do so just for this check, and here we see if there is any
2373
+ // content to flush, that is, we check if there would have been
2374
+ // something a non-ASSERTIONS build would have not seen.
2375
+ // How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0
2376
+ // mode (which has its own special function for this; otherwise, all
2377
+ // the code is inside libc)
2378
+ var oldOut = out;
2379
+ var oldErr = err;
2380
+ var has = false;
2381
+ out = err = (x) => {
2382
+ has = true;
2383
+ }
2384
+ try { // it doesn't matter if it fails
2385
+ flush_NO_FILESYSTEM();
2386
+ } catch(e) {}
2387
+ out = oldOut;
2388
+ err = oldErr;
2389
+ if (has) {
2390
+ warnOnce('stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.');
2391
+ warnOnce('(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)');
2392
+ }
2393
+ }
2394
+
2395
+ if (Module['preInit']) {
2396
+ if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
2397
+ while (Module['preInit'].length > 0) {
2398
+ Module['preInit'].pop()();
2399
+ }
2400
+ }
2401
+
2402
+ run();
2403
+
2404
+ // end include: postamble.js
2405
+
2406
+ // include: postamble_modularize.js
2407
+ // In MODULARIZE mode we wrap the generated code in a factory function
2408
+ // and return either the Module itself, or a promise of the module.
2409
+ //
2410
+ // We assign to the `moduleRtn` global here and configure closure to see
2411
+ // this as and extern so it won't get minified.
2412
+
2413
+ moduleRtn = readyPromise;
2414
+
2415
+ // Assertion for attempting to access module properties on the incoming
2416
+ // moduleArg. In the past we used this object as the prototype of the module
2417
+ // and assigned properties to it, but now we return a distinct object. This
2418
+ // keeps the instance private until it is ready (i.e the promise has been
2419
+ // resolved).
2420
+ for (const prop of Object.keys(Module)) {
2421
+ if (!(prop in moduleArg)) {
2422
+ Object.defineProperty(moduleArg, prop, {
2423
+ configurable: true,
2424
+ get() {
2425
+ abort(`Access to module property ('${prop}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)
2426
+ }
2427
+ });
2428
+ }
2429
+ }
2430
+ // end include: postamble_modularize.js
2431
+
2432
+
2433
+
2434
+ return moduleRtn;
2435
+ }
2436
+ );
2437
+ })();
2438
+ if (typeof exports === 'object' && typeof module === 'object')
2439
+ module.exports = QuickJSRaw;
2440
+ else if (typeof define === 'function' && define['amd'])
2441
+ define([], () => QuickJSRaw);