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