index.js (54226B)
1 // include: shell.js 2 // The Module object: Our interface to the outside world. We import 3 // and export values on it. There are various ways Module can be used: 4 // 1. Not defined. We create it here 5 // 2. A function parameter, function(moduleArg) => Promise<Module> 6 // 3. pre-run appended it, var Module = {}; ..generated code.. 7 // 4. External script tag defines var Module. 8 // We need to check if Module already exists (e.g. case 3 above). 9 // Substitution will be replaced with actual code on later stage of the build, 10 // this way Closure Compiler will not mangle it (e.g. case 4. above). 11 // Note that if you want to run closure, and also to use Module 12 // after the generated code, you will need to define var Module = {}; 13 // before the code. Then that object will be used in the code, and you 14 // can continue to use Module afterwards as well. 15 var Module = typeof Module != 'undefined' ? Module : {}; 16 17 // Determine the runtime environment we are in. You can customize this by 18 // setting the ENVIRONMENT setting at compile time (see settings.js). 19 20 // Attempt to auto-detect the environment 21 var ENVIRONMENT_IS_WEB = typeof window == 'object'; 22 var ENVIRONMENT_IS_WORKER = typeof WorkerGlobalScope != 'undefined'; 23 // N.b. Electron.js environment is simultaneously a NODE-environment, but 24 // also a web environment. 25 var ENVIRONMENT_IS_NODE = typeof process == 'object' && process.versions?.node && process.type != 'renderer'; 26 var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER; 27 28 // --pre-jses are emitted after the Module integration code, so that they can 29 // refer to Module (if they choose; they can also define Module) 30 31 32 var arguments_ = []; 33 var thisProgram = './this.program'; 34 var quit_ = (status, toThrow) => { 35 throw toThrow; 36 }; 37 38 // In MODULARIZE mode _scriptName needs to be captured already at the very top of the page immediately when the page is parsed, so it is generated there 39 // before the page load. In non-MODULARIZE modes generate it here. 40 var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined; 41 42 if (typeof __filename != 'undefined') { // Node 43 _scriptName = __filename; 44 } else 45 if (ENVIRONMENT_IS_WORKER) { 46 _scriptName = self.location.href; 47 } 48 49 // `/` should be present at the end if `scriptDirectory` is not empty 50 var scriptDirectory = ''; 51 function locateFile(path) { 52 if (Module['locateFile']) { 53 return Module['locateFile'](path, scriptDirectory); 54 } 55 return scriptDirectory + path; 56 } 57 58 // Hooks that are implemented differently in different runtime environments. 59 var readAsync, readBinary; 60 61 if (ENVIRONMENT_IS_NODE) { 62 const isNode = typeof process == 'object' && process.versions?.node && process.type != 'renderer'; 63 if (!isNode) 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?)'); 64 65 var nodeVersion = process.versions.node; 66 var numericVersion = nodeVersion.split('.').slice(0, 3); 67 numericVersion = (numericVersion[0] * 10000) + (numericVersion[1] * 100) + (numericVersion[2].split('-')[0] * 1); 68 if (numericVersion < 160000) { 69 throw new Error('This emscripten-generated code requires node v16.0.0 (detected v' + nodeVersion + ')'); 70 } 71 72 // These modules will usually be used on Node.js. Load them eagerly to avoid 73 // the complexity of lazy-loading. 74 var fs = require('fs'); 75 76 scriptDirectory = __dirname + '/'; 77 78 // include: node_shell_read.js 79 readBinary = (filename) => { 80 // We need to re-wrap `file://` strings to URLs. 81 filename = isFileURI(filename) ? new URL(filename) : filename; 82 var ret = fs.readFileSync(filename); 83 assert(Buffer.isBuffer(ret)); 84 return ret; 85 }; 86 87 readAsync = async (filename, binary = true) => { 88 // See the comment in the `readBinary` function. 89 filename = isFileURI(filename) ? new URL(filename) : filename; 90 var ret = fs.readFileSync(filename, binary ? undefined : 'utf8'); 91 assert(binary ? Buffer.isBuffer(ret) : typeof ret == 'string'); 92 return ret; 93 }; 94 // end include: node_shell_read.js 95 if (process.argv.length > 1) { 96 thisProgram = process.argv[1].replace(/\\/g, '/'); 97 } 98 99 arguments_ = process.argv.slice(2); 100 101 // MODULARIZE will export the module in the proper place outside, we don't need to export here 102 if (typeof module != 'undefined') { 103 module['exports'] = Module; 104 } 105 106 quit_ = (status, toThrow) => { 107 process.exitCode = status; 108 throw toThrow; 109 }; 110 111 } else 112 if (ENVIRONMENT_IS_SHELL) { 113 114 const isNode = typeof process == 'object' && process.versions?.node && process.type != 'renderer'; 115 if (isNode || typeof window == 'object' || typeof WorkerGlobalScope != 'undefined') 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?)'); 116 117 } else 118 119 // Note that this includes Node.js workers when relevant (pthreads is enabled). 120 // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and 121 // ENVIRONMENT_IS_NODE. 122 if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { 123 try { 124 scriptDirectory = new URL('.', _scriptName).href; // includes trailing slash 125 } catch { 126 // Must be a `blob:` or `data:` URL (e.g. `blob:http://site.com/etc/etc`), we cannot 127 // infer anything from them. 128 } 129 130 if (!(typeof window == 'object' || typeof WorkerGlobalScope != 'undefined')) 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?)'); 131 132 { 133 // include: web_or_worker_shell_read.js 134 if (ENVIRONMENT_IS_WORKER) { 135 readBinary = (url) => { 136 var xhr = new XMLHttpRequest(); 137 xhr.open('GET', url, false); 138 xhr.responseType = 'arraybuffer'; 139 xhr.send(null); 140 return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response)); 141 }; 142 } 143 144 readAsync = async (url) => { 145 // Fetch has some additional restrictions over XHR, like it can't be used on a file:// url. 146 // See https://github.com/github/fetch/pull/92#issuecomment-140665932 147 // Cordova or Electron apps are typically loaded from a file:// url. 148 // So use XHR on webview if URL is a file URL. 149 if (isFileURI(url)) { 150 return new Promise((resolve, reject) => { 151 var xhr = new XMLHttpRequest(); 152 xhr.open('GET', url, true); 153 xhr.responseType = 'arraybuffer'; 154 xhr.onload = () => { 155 if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0 156 resolve(xhr.response); 157 return; 158 } 159 reject(xhr.status); 160 }; 161 xhr.onerror = reject; 162 xhr.send(null); 163 }); 164 } 165 var response = await fetch(url, { credentials: 'same-origin' }); 166 if (response.ok) { 167 return response.arrayBuffer(); 168 } 169 throw new Error(response.status + ' : ' + response.url); 170 }; 171 // end include: web_or_worker_shell_read.js 172 } 173 } else 174 { 175 throw new Error('environment detection error'); 176 } 177 178 var out = console.log.bind(console); 179 var err = console.error.bind(console); 180 181 var IDBFS = 'IDBFS is no longer included by default; build with -lidbfs.js'; 182 var PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js'; 183 var WORKERFS = 'WORKERFS is no longer included by default; build with -lworkerfs.js'; 184 var FETCHFS = 'FETCHFS is no longer included by default; build with -lfetchfs.js'; 185 var ICASEFS = 'ICASEFS is no longer included by default; build with -licasefs.js'; 186 var JSFILEFS = 'JSFILEFS is no longer included by default; build with -ljsfilefs.js'; 187 var OPFS = 'OPFS is no longer included by default; build with -lopfs.js'; 188 189 var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js'; 190 191 // perform assertions in shell.js after we set up out() and err(), as otherwise 192 // if an assertion fails it cannot print the message 193 194 assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.'); 195 196 // end include: shell.js 197 198 // include: preamble.js 199 // === Preamble library stuff === 200 201 // Documentation for the public APIs defined in this file must be updated in: 202 // site/source/docs/api_reference/preamble.js.rst 203 // A prebuilt local version of the documentation is available at: 204 // site/build/text/docs/api_reference/preamble.js.txt 205 // You can also build docs locally as HTML or other formats in site/ 206 // An online HTML version (which may be of a different version of Emscripten) 207 // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html 208 209 var wasmBinary; 210 211 if (typeof WebAssembly != 'object') { 212 err('no native wasm support detected'); 213 } 214 215 // Wasm globals 216 217 //======================================== 218 // Runtime essentials 219 //======================================== 220 221 // whether we are quitting the application. no code should run after this. 222 // set in exit() and abort() 223 var ABORT = false; 224 225 // set by exit() and abort(). Passed to 'onExit' handler. 226 // NOTE: This is also used as the process return code code in shell environments 227 // but only when noExitRuntime is false. 228 var EXITSTATUS; 229 230 // In STRICT mode, we only define assert() when ASSERTIONS is set. i.e. we 231 // don't define it at all in release modes. This matches the behaviour of 232 // MINIMAL_RUNTIME. 233 // TODO(sbc): Make this the default even without STRICT enabled. 234 /** @type {function(*, string=)} */ 235 function assert(condition, text) { 236 if (!condition) { 237 abort('Assertion failed' + (text ? ': ' + text : '')); 238 } 239 } 240 241 // We used to include malloc/free by default in the past. Show a helpful error in 242 // builds with assertions. 243 function _malloc() { 244 abort('malloc() called but not included in the build - add `_malloc` to EXPORTED_FUNCTIONS'); 245 } 246 function _free() { 247 // Show a helpful error since we used to include free by default in the past. 248 abort('free() called but not included in the build - add `_free` to EXPORTED_FUNCTIONS'); 249 } 250 251 /** 252 * Indicates whether filename is delivered via file protocol (as opposed to http/https) 253 * @noinline 254 */ 255 var isFileURI = (filename) => filename.startsWith('file://'); 256 257 // include: runtime_common.js 258 // include: runtime_stack_check.js 259 // Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode. 260 function writeStackCookie() { 261 var max = _emscripten_stack_get_end(); 262 assert((max & 3) == 0); 263 // If the stack ends at address zero we write our cookies 4 bytes into the 264 // stack. This prevents interference with SAFE_HEAP and ASAN which also 265 // monitor writes to address zero. 266 if (max == 0) { 267 max += 4; 268 } 269 // The stack grow downwards towards _emscripten_stack_get_end. 270 // We write cookies to the final two words in the stack and detect if they are 271 // ever overwritten. 272 HEAPU32[((max)>>2)] = 0x02135467; 273 HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE; 274 // Also test the global address 0 for integrity. 275 HEAPU32[((0)>>2)] = 1668509029; 276 } 277 278 function checkStackCookie() { 279 if (ABORT) return; 280 var max = _emscripten_stack_get_end(); 281 // See writeStackCookie(). 282 if (max == 0) { 283 max += 4; 284 } 285 var cookie1 = HEAPU32[((max)>>2)]; 286 var cookie2 = HEAPU32[(((max)+(4))>>2)]; 287 if (cookie1 != 0x02135467 || cookie2 != 0x89BACDFE) { 288 abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`); 289 } 290 // Also test the global address 0 for integrity. 291 if (HEAPU32[((0)>>2)] != 0x63736d65 /* 'emsc' */) { 292 abort('Runtime error: The application has corrupted its heap memory area (address zero)!'); 293 } 294 } 295 // end include: runtime_stack_check.js 296 // include: runtime_exceptions.js 297 // end include: runtime_exceptions.js 298 // include: runtime_debug.js 299 var runtimeDebug = true; // Switch to false at runtime to disable logging at the right times 300 301 // Used by XXXXX_DEBUG settings to output debug messages. 302 function dbg(...args) { 303 if (!runtimeDebug && typeof runtimeDebug != 'undefined') return; 304 // TODO(sbc): Make this configurable somehow. Its not always convenient for 305 // logging to show up as warnings. 306 console.warn(...args); 307 } 308 309 // Endianness check 310 (() => { 311 var h16 = new Int16Array(1); 312 var h8 = new Int8Array(h16.buffer); 313 h16[0] = 0x6373; 314 if (h8[0] !== 0x73 || h8[1] !== 0x63) throw 'Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)'; 315 })(); 316 317 function consumedModuleProp(prop) { 318 if (!Object.getOwnPropertyDescriptor(Module, prop)) { 319 Object.defineProperty(Module, prop, { 320 configurable: true, 321 set() { 322 abort(`Attempt to set \`Module.${prop}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`); 323 324 } 325 }); 326 } 327 } 328 329 function makeInvalidEarlyAccess(name) { 330 return () => assert(false, `call to '${name}' via reference taken before Wasm module initialization`); 331 332 } 333 334 function ignoredModuleProp(prop) { 335 if (Object.getOwnPropertyDescriptor(Module, prop)) { 336 abort(`\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API`); 337 } 338 } 339 340 // forcing the filesystem exports a few things by default 341 function isExportedByForceFilesystem(name) { 342 return name === 'FS_createPath' || 343 name === 'FS_createDataFile' || 344 name === 'FS_createPreloadedFile' || 345 name === 'FS_unlink' || 346 name === 'addRunDependency' || 347 // The old FS has some functionality that WasmFS lacks. 348 name === 'FS_createLazyFile' || 349 name === 'FS_createDevice' || 350 name === 'removeRunDependency'; 351 } 352 353 /** 354 * Intercept access to a global symbol. This enables us to give informative 355 * warnings/errors when folks attempt to use symbols they did not include in 356 * their build, or no symbols that no longer exist. 357 */ 358 function hookGlobalSymbolAccess(sym, func) { 359 if (typeof globalThis != 'undefined' && !Object.getOwnPropertyDescriptor(globalThis, sym)) { 360 Object.defineProperty(globalThis, sym, { 361 configurable: true, 362 get() { 363 func(); 364 return undefined; 365 } 366 }); 367 } 368 } 369 370 function missingGlobal(sym, msg) { 371 hookGlobalSymbolAccess(sym, () => { 372 warnOnce(`\`${sym}\` is not longer defined by emscripten. ${msg}`); 373 }); 374 } 375 376 missingGlobal('buffer', 'Please use HEAP8.buffer or wasmMemory.buffer'); 377 missingGlobal('asm', 'Please use wasmExports instead'); 378 379 function missingLibrarySymbol(sym) { 380 hookGlobalSymbolAccess(sym, () => { 381 // Can't `abort()` here because it would break code that does runtime 382 // checks. e.g. `if (typeof SDL === 'undefined')`. 383 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`; 384 // DEFAULT_LIBRARY_FUNCS_TO_INCLUDE requires the name as it appears in 385 // library.js, which means $name for a JS name with no prefix, or name 386 // for a JS name like _name. 387 var librarySymbol = sym; 388 if (!librarySymbol.startsWith('_')) { 389 librarySymbol = '$' + sym; 390 } 391 msg += ` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${librarySymbol}')`; 392 if (isExportedByForceFilesystem(sym)) { 393 msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you'; 394 } 395 warnOnce(msg); 396 }); 397 398 // Any symbol that is not included from the JS library is also (by definition) 399 // not exported on the Module object. 400 unexportedRuntimeSymbol(sym); 401 } 402 403 function unexportedRuntimeSymbol(sym) { 404 if (!Object.getOwnPropertyDescriptor(Module, sym)) { 405 Object.defineProperty(Module, sym, { 406 configurable: true, 407 get() { 408 var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`; 409 if (isExportedByForceFilesystem(sym)) { 410 msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you'; 411 } 412 abort(msg); 413 } 414 }); 415 } 416 } 417 418 // end include: runtime_debug.js 419 // Memory management 420 421 var wasmMemory; 422 423 var 424 /** @type {!Int8Array} */ 425 HEAP8, 426 /** @type {!Uint8Array} */ 427 HEAPU8, 428 /** @type {!Int16Array} */ 429 HEAP16, 430 /** @type {!Uint16Array} */ 431 HEAPU16, 432 /** @type {!Int32Array} */ 433 HEAP32, 434 /** @type {!Uint32Array} */ 435 HEAPU32, 436 /** @type {!Float32Array} */ 437 HEAPF32, 438 /** @type {!Float64Array} */ 439 HEAPF64; 440 441 // BigInt64Array type is not correctly defined in closure 442 var 443 /** not-@type {!BigInt64Array} */ 444 HEAP64, 445 /* BigUint64Array type is not correctly defined in closure 446 /** not-@type {!BigUint64Array} */ 447 HEAPU64; 448 449 var runtimeInitialized = false; 450 451 452 453 function updateMemoryViews() { 454 var b = wasmMemory.buffer; 455 HEAP8 = new Int8Array(b); 456 HEAP16 = new Int16Array(b); 457 HEAPU8 = new Uint8Array(b); 458 HEAPU16 = new Uint16Array(b); 459 HEAP32 = new Int32Array(b); 460 HEAPU32 = new Uint32Array(b); 461 HEAPF32 = new Float32Array(b); 462 HEAPF64 = new Float64Array(b); 463 HEAP64 = new BigInt64Array(b); 464 HEAPU64 = new BigUint64Array(b); 465 } 466 467 // include: memoryprofiler.js 468 // end include: memoryprofiler.js 469 // end include: runtime_common.js 470 assert(typeof Int32Array != 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray != undefined && Int32Array.prototype.set != undefined, 471 'JS engine does not provide full typed array support'); 472 473 function preRun() { 474 if (Module['preRun']) { 475 if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']]; 476 while (Module['preRun'].length) { 477 addOnPreRun(Module['preRun'].shift()); 478 } 479 } 480 consumedModuleProp('preRun'); 481 // Begin ATPRERUNS hooks 482 callRuntimeCallbacks(onPreRuns); 483 // End ATPRERUNS hooks 484 } 485 486 function initRuntime() { 487 assert(!runtimeInitialized); 488 runtimeInitialized = true; 489 490 checkStackCookie(); 491 492 // No ATINITS hooks 493 494 wasmExports['__wasm_call_ctors'](); 495 496 // No ATPOSTCTORS hooks 497 } 498 499 function preMain() { 500 checkStackCookie(); 501 // No ATMAINS hooks 502 } 503 504 function postRun() { 505 checkStackCookie(); 506 // PThreads reuse the runtime from the main thread. 507 508 if (Module['postRun']) { 509 if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']]; 510 while (Module['postRun'].length) { 511 addOnPostRun(Module['postRun'].shift()); 512 } 513 } 514 consumedModuleProp('postRun'); 515 516 // Begin ATPOSTRUNS hooks 517 callRuntimeCallbacks(onPostRuns); 518 // End ATPOSTRUNS hooks 519 } 520 521 // A counter of dependencies for calling run(). If we need to 522 // do asynchronous work before running, increment this and 523 // decrement it. Incrementing must happen in a place like 524 // Module.preRun (used by emcc to add file preloading). 525 // Note that you can add dependencies in preRun, even though 526 // it happens right before run - run will be postponed until 527 // the dependencies are met. 528 var runDependencies = 0; 529 var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled 530 var runDependencyTracking = {}; 531 var runDependencyWatcher = null; 532 533 function addRunDependency(id) { 534 runDependencies++; 535 536 Module['monitorRunDependencies']?.(runDependencies); 537 538 if (id) { 539 assert(!runDependencyTracking[id]); 540 runDependencyTracking[id] = 1; 541 if (runDependencyWatcher === null && typeof setInterval != 'undefined') { 542 // Check for missing dependencies every few seconds 543 runDependencyWatcher = setInterval(() => { 544 if (ABORT) { 545 clearInterval(runDependencyWatcher); 546 runDependencyWatcher = null; 547 return; 548 } 549 var shown = false; 550 for (var dep in runDependencyTracking) { 551 if (!shown) { 552 shown = true; 553 err('still waiting on run dependencies:'); 554 } 555 err(`dependency: ${dep}`); 556 } 557 if (shown) { 558 err('(end of list)'); 559 } 560 }, 10000); 561 } 562 } else { 563 err('warning: run dependency added without ID'); 564 } 565 } 566 567 function removeRunDependency(id) { 568 runDependencies--; 569 570 Module['monitorRunDependencies']?.(runDependencies); 571 572 if (id) { 573 assert(runDependencyTracking[id]); 574 delete runDependencyTracking[id]; 575 } else { 576 err('warning: run dependency removed without ID'); 577 } 578 if (runDependencies == 0) { 579 if (runDependencyWatcher !== null) { 580 clearInterval(runDependencyWatcher); 581 runDependencyWatcher = null; 582 } 583 if (dependenciesFulfilled) { 584 var callback = dependenciesFulfilled; 585 dependenciesFulfilled = null; 586 callback(); // can add another dependenciesFulfilled 587 } 588 } 589 } 590 591 /** @param {string|number=} what */ 592 function abort(what) { 593 Module['onAbort']?.(what); 594 595 what = 'Aborted(' + what + ')'; 596 // TODO(sbc): Should we remove printing and leave it up to whoever 597 // catches the exception? 598 err(what); 599 600 ABORT = true; 601 602 // Use a wasm runtime error, because a JS error might be seen as a foreign 603 // exception, which means we'd run destructors on it. We need the error to 604 // simply make the program stop. 605 // FIXME This approach does not work in Wasm EH because it currently does not assume 606 // all RuntimeErrors are from traps; it decides whether a RuntimeError is from 607 // a trap or not based on a hidden field within the object. So at the moment 608 // we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that 609 // allows this in the wasm spec. 610 611 // Suppress closure compiler warning here. Closure compiler's builtin extern 612 // definition for WebAssembly.RuntimeError claims it takes no arguments even 613 // though it can. 614 // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed. 615 /** @suppress {checkTypes} */ 616 var e = new WebAssembly.RuntimeError(what); 617 618 // Throw the error whether or not MODULARIZE is set because abort is used 619 // in code paths apart from instantiation where an exception is expected 620 // to be thrown when abort is called. 621 throw e; 622 } 623 624 // show errors on likely calls to FS when it was not included 625 var FS = { 626 error() { 627 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'); 628 }, 629 init() { FS.error() }, 630 createDataFile() { FS.error() }, 631 createPreloadedFile() { FS.error() }, 632 createLazyFile() { FS.error() }, 633 open() { FS.error() }, 634 mkdev() { FS.error() }, 635 registerDevice() { FS.error() }, 636 analyzePath() { FS.error() }, 637 638 ErrnoError() { FS.error() }, 639 }; 640 641 642 function createExportWrapper(name, nargs) { 643 return (...args) => { 644 assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`); 645 var f = wasmExports[name]; 646 assert(f, `exported native function \`${name}\` not found`); 647 // Only assert for too many arguments. Too few can be valid since the missing arguments will be zero filled. 648 assert(args.length <= nargs, `native function \`${name}\` called with ${args.length} args but expects ${nargs}`); 649 return f(...args); 650 }; 651 } 652 653 var wasmBinaryFile; 654 655 function findWasmBinary() { 656 return locateFile('index.wasm'); 657 } 658 659 function getBinarySync(file) { 660 if (file == wasmBinaryFile && wasmBinary) { 661 return new Uint8Array(wasmBinary); 662 } 663 if (readBinary) { 664 return readBinary(file); 665 } 666 throw 'both async and sync fetching of the wasm failed'; 667 } 668 669 async function getWasmBinary(binaryFile) { 670 // If we don't have the binary yet, load it asynchronously using readAsync. 671 if (!wasmBinary) { 672 // Fetch the binary using readAsync 673 try { 674 var response = await readAsync(binaryFile); 675 return new Uint8Array(response); 676 } catch { 677 // Fall back to getBinarySync below; 678 } 679 } 680 681 // Otherwise, getBinarySync should be able to get it synchronously 682 return getBinarySync(binaryFile); 683 } 684 685 async function instantiateArrayBuffer(binaryFile, imports) { 686 try { 687 var binary = await getWasmBinary(binaryFile); 688 var instance = await WebAssembly.instantiate(binary, imports); 689 return instance; 690 } catch (reason) { 691 err(`failed to asynchronously prepare wasm: ${reason}`); 692 693 // Warn on some common problems. 694 if (isFileURI(wasmBinaryFile)) { 695 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`); 696 } 697 abort(reason); 698 } 699 } 700 701 async function instantiateAsync(binary, binaryFile, imports) { 702 if (!binary && typeof WebAssembly.instantiateStreaming == 'function' 703 // Don't use streaming for file:// delivered objects in a webview, fetch them synchronously. 704 && !isFileURI(binaryFile) 705 // Avoid instantiateStreaming() on Node.js environment for now, as while 706 // Node.js v18.1.0 implements it, it does not have a full fetch() 707 // implementation yet. 708 // 709 // Reference: 710 // https://github.com/emscripten-core/emscripten/pull/16917 711 && !ENVIRONMENT_IS_NODE 712 ) { 713 try { 714 var response = fetch(binaryFile, { credentials: 'same-origin' }); 715 var instantiationResult = await WebAssembly.instantiateStreaming(response, imports); 716 return instantiationResult; 717 } catch (reason) { 718 // We expect the most common failure cause to be a bad MIME type for the binary, 719 // in which case falling back to ArrayBuffer instantiation should work. 720 err(`wasm streaming compile failed: ${reason}`); 721 err('falling back to ArrayBuffer instantiation'); 722 // fall back of instantiateArrayBuffer below 723 }; 724 } 725 return instantiateArrayBuffer(binaryFile, imports); 726 } 727 728 function getWasmImports() { 729 // prepare imports 730 return { 731 'env': wasmImports, 732 'wasi_snapshot_preview1': wasmImports, 733 } 734 } 735 736 // Create the wasm instance. 737 // Receives the wasm imports, returns the exports. 738 async function createWasm() { 739 // Load the wasm module and create an instance of using native support in the JS engine. 740 // handle a generated wasm instance, receiving its exports and 741 // performing other necessary setup 742 /** @param {WebAssembly.Module=} module*/ 743 function receiveInstance(instance, module) { 744 wasmExports = instance.exports; 745 746 747 748 wasmMemory = wasmExports['memory']; 749 750 assert(wasmMemory, 'memory not found in wasm exports'); 751 updateMemoryViews(); 752 753 assignWasmExports(wasmExports); 754 removeRunDependency('wasm-instantiate'); 755 return wasmExports; 756 } 757 // wait for the pthread pool (if any) 758 addRunDependency('wasm-instantiate'); 759 760 // Prefer streaming instantiation if available. 761 // Async compilation can be confusing when an error on the page overwrites Module 762 // (for example, if the order of elements is wrong, and the one defining Module is 763 // later), so we save Module and check it later. 764 var trueModule = Module; 765 function receiveInstantiationResult(result) { 766 // 'result' is a ResultObject object which has both the module and instance. 767 // receiveInstance() will swap in the exports (to Module.asm) so they can be called 768 assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?'); 769 trueModule = null; 770 // 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. 771 // When the regression is fixed, can restore the above PTHREADS-enabled path. 772 return receiveInstance(result['instance']); 773 } 774 775 var info = getWasmImports(); 776 777 // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback 778 // to manually instantiate the Wasm module themselves. This allows pages to 779 // run the instantiation parallel to any other async startup actions they are 780 // performing. 781 // Also pthreads and wasm workers initialize the wasm instance through this 782 // path. 783 if (Module['instantiateWasm']) { 784 return new Promise((resolve, reject) => { 785 try { 786 Module['instantiateWasm'](info, (mod, inst) => { 787 resolve(receiveInstance(mod, inst)); 788 }); 789 } catch(e) { 790 err(`Module.instantiateWasm callback failed with error: ${e}`); 791 reject(e); 792 } 793 }); 794 } 795 796 wasmBinaryFile ??= findWasmBinary(); 797 var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info); 798 var exports = receiveInstantiationResult(result); 799 return exports; 800 } 801 802 // end include: preamble.js 803 804 // Begin JS library code 805 806 807 class ExitStatus { 808 name = 'ExitStatus'; 809 constructor(status) { 810 this.message = `Program terminated with exit(${status})`; 811 this.status = status; 812 } 813 } 814 815 var callRuntimeCallbacks = (callbacks) => { 816 while (callbacks.length > 0) { 817 // Pass the module as the first argument. 818 callbacks.shift()(Module); 819 } 820 }; 821 var onPostRuns = []; 822 var addOnPostRun = (cb) => onPostRuns.push(cb); 823 824 var onPreRuns = []; 825 var addOnPreRun = (cb) => onPreRuns.push(cb); 826 827 828 829 /** 830 * @param {number} ptr 831 * @param {string} type 832 */ 833 function getValue(ptr, type = 'i8') { 834 if (type.endsWith('*')) type = '*'; 835 switch (type) { 836 case 'i1': return HEAP8[ptr]; 837 case 'i8': return HEAP8[ptr]; 838 case 'i16': return HEAP16[((ptr)>>1)]; 839 case 'i32': return HEAP32[((ptr)>>2)]; 840 case 'i64': return HEAP64[((ptr)>>3)]; 841 case 'float': return HEAPF32[((ptr)>>2)]; 842 case 'double': return HEAPF64[((ptr)>>3)]; 843 case '*': return HEAPU32[((ptr)>>2)]; 844 default: abort(`invalid type for getValue: ${type}`); 845 } 846 } 847 848 var noExitRuntime = true; 849 850 var ptrToString = (ptr) => { 851 assert(typeof ptr === 'number'); 852 // With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned. 853 ptr >>>= 0; 854 return '0x' + ptr.toString(16).padStart(8, '0'); 855 }; 856 857 858 /** 859 * @param {number} ptr 860 * @param {number} value 861 * @param {string} type 862 */ 863 function setValue(ptr, value, type = 'i8') { 864 if (type.endsWith('*')) type = '*'; 865 switch (type) { 866 case 'i1': HEAP8[ptr] = value; break; 867 case 'i8': HEAP8[ptr] = value; break; 868 case 'i16': HEAP16[((ptr)>>1)] = value; break; 869 case 'i32': HEAP32[((ptr)>>2)] = value; break; 870 case 'i64': HEAP64[((ptr)>>3)] = BigInt(value); break; 871 case 'float': HEAPF32[((ptr)>>2)] = value; break; 872 case 'double': HEAPF64[((ptr)>>3)] = value; break; 873 case '*': HEAPU32[((ptr)>>2)] = value; break; 874 default: abort(`invalid type for setValue: ${type}`); 875 } 876 } 877 878 var stackRestore = (val) => __emscripten_stack_restore(val); 879 880 var stackSave = () => _emscripten_stack_get_current(); 881 882 var warnOnce = (text) => { 883 warnOnce.shown ||= {}; 884 if (!warnOnce.shown[text]) { 885 warnOnce.shown[text] = 1; 886 if (ENVIRONMENT_IS_NODE) text = 'warning: ' + text; 887 err(text); 888 } 889 }; 890 891 var printCharBuffers = [null,[],[]]; 892 893 var UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder() : undefined; 894 895 var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => { 896 var maxIdx = idx + maxBytesToRead; 897 if (ignoreNul) return maxIdx; 898 // TextDecoder needs to know the byte length in advance, it doesn't stop on 899 // null terminator by itself. 900 // As a tiny code save trick, compare idx against maxIdx using a negation, 901 // so that maxBytesToRead=undefined/NaN means Infinity. 902 while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx; 903 return idx; 904 }; 905 906 /** 907 * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given 908 * array that contains uint8 values, returns a copy of that string as a 909 * Javascript String object. 910 * heapOrArray is either a regular array, or a JavaScript typed array view. 911 * @param {number=} idx 912 * @param {number=} maxBytesToRead 913 * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character. 914 * @return {string} 915 */ 916 var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => { 917 918 var endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul); 919 920 // When using conditional TextDecoder, skip it for short strings as the overhead of the native call is not worth it. 921 if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) { 922 return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr)); 923 } 924 var str = ''; 925 // If building with TextDecoder, we have already computed the string length 926 // above, so test loop end condition against that 927 while (idx < endPtr) { 928 // For UTF8 byte structure, see: 929 // http://en.wikipedia.org/wiki/UTF-8#Description 930 // https://www.ietf.org/rfc/rfc2279.txt 931 // https://tools.ietf.org/html/rfc3629 932 var u0 = heapOrArray[idx++]; 933 if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; } 934 var u1 = heapOrArray[idx++] & 63; 935 if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; } 936 var u2 = heapOrArray[idx++] & 63; 937 if ((u0 & 0xF0) == 0xE0) { 938 u0 = ((u0 & 15) << 12) | (u1 << 6) | u2; 939 } else { 940 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!'); 941 u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63); 942 } 943 944 if (u0 < 0x10000) { 945 str += String.fromCharCode(u0); 946 } else { 947 var ch = u0 - 0x10000; 948 str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF)); 949 } 950 } 951 return str; 952 }; 953 var printChar = (stream, curr) => { 954 var buffer = printCharBuffers[stream]; 955 assert(buffer); 956 if (curr === 0 || curr === 10) { 957 (stream === 1 ? out : err)(UTF8ArrayToString(buffer)); 958 buffer.length = 0; 959 } else { 960 buffer.push(curr); 961 } 962 }; 963 964 var flush_NO_FILESYSTEM = () => { 965 // flush anything remaining in the buffers during shutdown 966 _fflush(0); 967 if (printCharBuffers[1].length) printChar(1, 10); 968 if (printCharBuffers[2].length) printChar(2, 10); 969 }; 970 971 972 973 /** 974 * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the 975 * emscripten HEAP, returns a copy of that string as a Javascript String object. 976 * 977 * @param {number} ptr 978 * @param {number=} maxBytesToRead - An optional length that specifies the 979 * maximum number of bytes to read. You can omit this parameter to scan the 980 * string until the first 0 byte. If maxBytesToRead is passed, and the string 981 * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the 982 * string will cut short at that byte index. 983 * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character. 984 * @return {string} 985 */ 986 var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => { 987 assert(typeof ptr == 'number', `UTF8ToString expects a number (got ${typeof ptr})`); 988 return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead, ignoreNul) : ''; 989 }; 990 var SYSCALLS = { 991 varargs:undefined, 992 getStr(ptr) { 993 var ret = UTF8ToString(ptr); 994 return ret; 995 }, 996 }; 997 var _fd_write = (fd, iov, iovcnt, pnum) => { 998 // hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0 999 var num = 0; 1000 for (var i = 0; i < iovcnt; i++) { 1001 var ptr = HEAPU32[((iov)>>2)]; 1002 var len = HEAPU32[(((iov)+(4))>>2)]; 1003 iov += 8; 1004 for (var j = 0; j < len; j++) { 1005 printChar(fd, HEAPU8[ptr+j]); 1006 } 1007 num += len; 1008 } 1009 HEAPU32[((pnum)>>2)] = num; 1010 return 0; 1011 }; 1012 1013 1014 var runtimeKeepaliveCounter = 0; 1015 var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0; 1016 var _proc_exit = (code) => { 1017 EXITSTATUS = code; 1018 if (!keepRuntimeAlive()) { 1019 Module['onExit']?.(code); 1020 ABORT = true; 1021 } 1022 quit_(code, new ExitStatus(code)); 1023 }; 1024 1025 1026 /** @param {boolean|number=} implicit */ 1027 var exitJS = (status, implicit) => { 1028 EXITSTATUS = status; 1029 1030 checkUnflushedContent(); 1031 1032 // if exit() was called explicitly, warn the user if the runtime isn't actually being shut down 1033 if (keepRuntimeAlive() && !implicit) { 1034 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)`; 1035 err(msg); 1036 } 1037 1038 _proc_exit(status); 1039 }; 1040 1041 var handleException = (e) => { 1042 // Certain exception types we do not treat as errors since they are used for 1043 // internal control flow. 1044 // 1. ExitStatus, which is thrown by exit() 1045 // 2. "unwind", which is thrown by emscripten_unwind_to_js_event_loop() and others 1046 // that wish to return to JS event loop. 1047 if (e instanceof ExitStatus || e == 'unwind') { 1048 return EXITSTATUS; 1049 } 1050 checkStackCookie(); 1051 if (e instanceof WebAssembly.RuntimeError) { 1052 if (_emscripten_stack_get_current() <= 0) { 1053 err('Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to 65536)'); 1054 } 1055 } 1056 quit_(1, e); 1057 }; 1058 // End JS library code 1059 1060 // include: postlibrary.js 1061 // This file is included after the automatically-generated JS library code 1062 // but before the wasm module is created. 1063 1064 { 1065 1066 // Begin ATMODULES hooks 1067 if (Module['noExitRuntime']) noExitRuntime = Module['noExitRuntime']; 1068 if (Module['print']) out = Module['print']; 1069 if (Module['printErr']) err = Module['printErr']; 1070 if (Module['wasmBinary']) wasmBinary = Module['wasmBinary']; 1071 1072 Module['FS_createDataFile'] = FS.createDataFile; 1073 Module['FS_createPreloadedFile'] = FS.createPreloadedFile; 1074 1075 // End ATMODULES hooks 1076 1077 checkIncomingModuleAPI(); 1078 1079 if (Module['arguments']) arguments_ = Module['arguments']; 1080 if (Module['thisProgram']) thisProgram = Module['thisProgram']; 1081 1082 // Assertions on removed incoming Module JS APIs. 1083 assert(typeof Module['memoryInitializerPrefixURL'] == 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead'); 1084 assert(typeof Module['pthreadMainPrefixURL'] == 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead'); 1085 assert(typeof Module['cdInitializerPrefixURL'] == 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead'); 1086 assert(typeof Module['filePackagePrefixURL'] == 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead'); 1087 assert(typeof Module['read'] == 'undefined', 'Module.read option was removed'); 1088 assert(typeof Module['readAsync'] == 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)'); 1089 assert(typeof Module['readBinary'] == 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)'); 1090 assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)'); 1091 assert(typeof Module['TOTAL_MEMORY'] == 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY'); 1092 assert(typeof Module['ENVIRONMENT'] == 'undefined', 'Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)'); 1093 assert(typeof Module['STACK_SIZE'] == 'undefined', 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time') 1094 // If memory is defined in wasm, the user can't provide it, or set INITIAL_MEMORY 1095 assert(typeof Module['wasmMemory'] == 'undefined', 'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally'); 1096 assert(typeof Module['INITIAL_MEMORY'] == 'undefined', 'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically'); 1097 1098 } 1099 1100 // Begin runtime exports 1101 var missingLibrarySymbols = [ 1102 'writeI53ToI64', 1103 'writeI53ToI64Clamped', 1104 'writeI53ToI64Signaling', 1105 'writeI53ToU64Clamped', 1106 'writeI53ToU64Signaling', 1107 'readI53FromI64', 1108 'readI53FromU64', 1109 'convertI32PairToI53', 1110 'convertI32PairToI53Checked', 1111 'convertU32PairToI53', 1112 'bigintToI53Checked', 1113 'stackAlloc', 1114 'getTempRet0', 1115 'setTempRet0', 1116 'zeroMemory', 1117 'getHeapMax', 1118 'abortOnCannotGrowMemory', 1119 'growMemory', 1120 'withStackSave', 1121 'strError', 1122 'inetPton4', 1123 'inetNtop4', 1124 'inetPton6', 1125 'inetNtop6', 1126 'readSockaddr', 1127 'writeSockaddr', 1128 'readEmAsmArgs', 1129 'jstoi_q', 1130 'getExecutableName', 1131 'autoResumeAudioContext', 1132 'getDynCaller', 1133 'dynCall', 1134 'runtimeKeepalivePush', 1135 'runtimeKeepalivePop', 1136 'callUserCallback', 1137 'maybeExit', 1138 'asmjsMangle', 1139 'asyncLoad', 1140 'alignMemory', 1141 'mmapAlloc', 1142 'HandleAllocator', 1143 'getNativeTypeSize', 1144 'getUniqueRunDependency', 1145 'addOnInit', 1146 'addOnPostCtor', 1147 'addOnPreMain', 1148 'addOnExit', 1149 'STACK_SIZE', 1150 'STACK_ALIGN', 1151 'POINTER_SIZE', 1152 'ASSERTIONS', 1153 'ccall', 1154 'cwrap', 1155 'convertJsFunctionToWasm', 1156 'getEmptyTableSlot', 1157 'updateTableMap', 1158 'getFunctionAddress', 1159 'addFunction', 1160 'removeFunction', 1161 'stringToUTF8Array', 1162 'stringToUTF8', 1163 'lengthBytesUTF8', 1164 'intArrayFromString', 1165 'intArrayToString', 1166 'AsciiToString', 1167 'stringToAscii', 1168 'UTF16ToString', 1169 'stringToUTF16', 1170 'lengthBytesUTF16', 1171 'UTF32ToString', 1172 'stringToUTF32', 1173 'lengthBytesUTF32', 1174 'stringToNewUTF8', 1175 'stringToUTF8OnStack', 1176 'writeArrayToMemory', 1177 'registerKeyEventCallback', 1178 'maybeCStringToJsString', 1179 'findEventTarget', 1180 'getBoundingClientRect', 1181 'fillMouseEventData', 1182 'registerMouseEventCallback', 1183 'registerWheelEventCallback', 1184 'registerUiEventCallback', 1185 'registerFocusEventCallback', 1186 'fillDeviceOrientationEventData', 1187 'registerDeviceOrientationEventCallback', 1188 'fillDeviceMotionEventData', 1189 'registerDeviceMotionEventCallback', 1190 'screenOrientation', 1191 'fillOrientationChangeEventData', 1192 'registerOrientationChangeEventCallback', 1193 'fillFullscreenChangeEventData', 1194 'registerFullscreenChangeEventCallback', 1195 'JSEvents_requestFullscreen', 1196 'JSEvents_resizeCanvasForFullscreen', 1197 'registerRestoreOldStyle', 1198 'hideEverythingExceptGivenElement', 1199 'restoreHiddenElements', 1200 'setLetterbox', 1201 'softFullscreenResizeWebGLRenderTarget', 1202 'doRequestFullscreen', 1203 'fillPointerlockChangeEventData', 1204 'registerPointerlockChangeEventCallback', 1205 'registerPointerlockErrorEventCallback', 1206 'requestPointerLock', 1207 'fillVisibilityChangeEventData', 1208 'registerVisibilityChangeEventCallback', 1209 'registerTouchEventCallback', 1210 'fillGamepadEventData', 1211 'registerGamepadEventCallback', 1212 'registerBeforeUnloadEventCallback', 1213 'fillBatteryEventData', 1214 'registerBatteryEventCallback', 1215 'setCanvasElementSize', 1216 'getCanvasElementSize', 1217 'jsStackTrace', 1218 'getCallstack', 1219 'convertPCtoSourceLocation', 1220 'getEnvStrings', 1221 'checkWasiClock', 1222 'wasiRightsToMuslOFlags', 1223 'wasiOFlagsToMuslOFlags', 1224 'initRandomFill', 1225 'randomFill', 1226 'safeSetTimeout', 1227 'setImmediateWrapped', 1228 'safeRequestAnimationFrame', 1229 'clearImmediateWrapped', 1230 'registerPostMainLoop', 1231 'registerPreMainLoop', 1232 'getPromise', 1233 'makePromise', 1234 'idsToPromises', 1235 'makePromiseCallback', 1236 'ExceptionInfo', 1237 'findMatchingCatch', 1238 'Browser_asyncPrepareDataCounter', 1239 'isLeapYear', 1240 'ydayFromDate', 1241 'arraySum', 1242 'addDays', 1243 'getSocketFromFD', 1244 'getSocketAddress', 1245 'FS_createPreloadedFile', 1246 'FS_modeStringToFlags', 1247 'FS_getMode', 1248 'FS_stdin_getChar', 1249 'FS_mkdirTree', 1250 '_setNetworkCallback', 1251 'heapObjectForWebGLType', 1252 'toTypedArrayIndex', 1253 'webgl_enable_ANGLE_instanced_arrays', 1254 'webgl_enable_OES_vertex_array_object', 1255 'webgl_enable_WEBGL_draw_buffers', 1256 'webgl_enable_WEBGL_multi_draw', 1257 'webgl_enable_EXT_polygon_offset_clamp', 1258 'webgl_enable_EXT_clip_control', 1259 'webgl_enable_WEBGL_polygon_mode', 1260 'emscriptenWebGLGet', 1261 'computeUnpackAlignedImageSize', 1262 'colorChannelsInGlTextureFormat', 1263 'emscriptenWebGLGetTexPixelData', 1264 'emscriptenWebGLGetUniform', 1265 'webglGetUniformLocation', 1266 'webglPrepareUniformLocationsBeforeFirstUse', 1267 'webglGetLeftBracePos', 1268 'emscriptenWebGLGetVertexAttrib', 1269 '__glGetActiveAttribOrUniform', 1270 'writeGLArray', 1271 'registerWebGlEventCallback', 1272 'runAndAbortIfError', 1273 'ALLOC_NORMAL', 1274 'ALLOC_STACK', 1275 'allocate', 1276 'writeStringToMemory', 1277 'writeAsciiToMemory', 1278 'demangle', 1279 'stackTrace', 1280 ]; 1281 missingLibrarySymbols.forEach(missingLibrarySymbol) 1282 1283 var unexportedSymbols = [ 1284 'run', 1285 'addRunDependency', 1286 'removeRunDependency', 1287 'out', 1288 'err', 1289 'callMain', 1290 'abort', 1291 'wasmMemory', 1292 'wasmExports', 1293 'HEAPF32', 1294 'HEAPF64', 1295 'HEAP8', 1296 'HEAPU8', 1297 'HEAP16', 1298 'HEAPU16', 1299 'HEAP32', 1300 'HEAPU32', 1301 'HEAP64', 1302 'HEAPU64', 1303 'writeStackCookie', 1304 'checkStackCookie', 1305 'INT53_MAX', 1306 'INT53_MIN', 1307 'stackSave', 1308 'stackRestore', 1309 'ptrToString', 1310 'exitJS', 1311 'ENV', 1312 'ERRNO_CODES', 1313 'DNS', 1314 'Protocols', 1315 'Sockets', 1316 'timers', 1317 'warnOnce', 1318 'readEmAsmArgsArray', 1319 'handleException', 1320 'keepRuntimeAlive', 1321 'wasmTable', 1322 'noExitRuntime', 1323 'addOnPreRun', 1324 'addOnPostRun', 1325 'freeTableIndexes', 1326 'functionsInTableMap', 1327 'setValue', 1328 'getValue', 1329 'PATH', 1330 'PATH_FS', 1331 'UTF8Decoder', 1332 'UTF8ArrayToString', 1333 'UTF8ToString', 1334 'UTF16Decoder', 1335 'JSEvents', 1336 'specialHTMLTargets', 1337 'findCanvasEventTarget', 1338 'currentFullscreenStrategy', 1339 'restoreOldWindowedStyle', 1340 'UNWIND_CACHE', 1341 'ExitStatus', 1342 'flush_NO_FILESYSTEM', 1343 'emSetImmediate', 1344 'emClearImmediate_deps', 1345 'emClearImmediate', 1346 'promiseMap', 1347 'uncaughtExceptionCount', 1348 'exceptionLast', 1349 'exceptionCaught', 1350 'Browser', 1351 'requestFullscreen', 1352 'requestFullScreen', 1353 'setCanvasSize', 1354 'getUserMedia', 1355 'createContext', 1356 'getPreloadedImageData__data', 1357 'wget', 1358 'MONTH_DAYS_REGULAR', 1359 'MONTH_DAYS_LEAP', 1360 'MONTH_DAYS_REGULAR_CUMULATIVE', 1361 'MONTH_DAYS_LEAP_CUMULATIVE', 1362 'SYSCALLS', 1363 'preloadPlugins', 1364 'FS_stdin_getChar_buffer', 1365 'FS_unlink', 1366 'FS_createPath', 1367 'FS_createDevice', 1368 'FS_readFile', 1369 'FS', 1370 'FS_root', 1371 'FS_mounts', 1372 'FS_devices', 1373 'FS_streams', 1374 'FS_nextInode', 1375 'FS_nameTable', 1376 'FS_currentPath', 1377 'FS_initialized', 1378 'FS_ignorePermissions', 1379 'FS_filesystems', 1380 'FS_syncFSRequests', 1381 'FS_readFiles', 1382 'FS_lookupPath', 1383 'FS_getPath', 1384 'FS_hashName', 1385 'FS_hashAddNode', 1386 'FS_hashRemoveNode', 1387 'FS_lookupNode', 1388 'FS_createNode', 1389 'FS_destroyNode', 1390 'FS_isRoot', 1391 'FS_isMountpoint', 1392 'FS_isFile', 1393 'FS_isDir', 1394 'FS_isLink', 1395 'FS_isChrdev', 1396 'FS_isBlkdev', 1397 'FS_isFIFO', 1398 'FS_isSocket', 1399 'FS_flagsToPermissionString', 1400 'FS_nodePermissions', 1401 'FS_mayLookup', 1402 'FS_mayCreate', 1403 'FS_mayDelete', 1404 'FS_mayOpen', 1405 'FS_checkOpExists', 1406 'FS_nextfd', 1407 'FS_getStreamChecked', 1408 'FS_getStream', 1409 'FS_createStream', 1410 'FS_closeStream', 1411 'FS_dupStream', 1412 'FS_doSetAttr', 1413 'FS_chrdev_stream_ops', 1414 'FS_major', 1415 'FS_minor', 1416 'FS_makedev', 1417 'FS_registerDevice', 1418 'FS_getDevice', 1419 'FS_getMounts', 1420 'FS_syncfs', 1421 'FS_mount', 1422 'FS_unmount', 1423 'FS_lookup', 1424 'FS_mknod', 1425 'FS_statfs', 1426 'FS_statfsStream', 1427 'FS_statfsNode', 1428 'FS_create', 1429 'FS_mkdir', 1430 'FS_mkdev', 1431 'FS_symlink', 1432 'FS_rename', 1433 'FS_rmdir', 1434 'FS_readdir', 1435 'FS_readlink', 1436 'FS_stat', 1437 'FS_fstat', 1438 'FS_lstat', 1439 'FS_doChmod', 1440 'FS_chmod', 1441 'FS_lchmod', 1442 'FS_fchmod', 1443 'FS_doChown', 1444 'FS_chown', 1445 'FS_lchown', 1446 'FS_fchown', 1447 'FS_doTruncate', 1448 'FS_truncate', 1449 'FS_ftruncate', 1450 'FS_utime', 1451 'FS_open', 1452 'FS_close', 1453 'FS_isClosed', 1454 'FS_llseek', 1455 'FS_read', 1456 'FS_write', 1457 'FS_mmap', 1458 'FS_msync', 1459 'FS_ioctl', 1460 'FS_writeFile', 1461 'FS_cwd', 1462 'FS_chdir', 1463 'FS_createDefaultDirectories', 1464 'FS_createDefaultDevices', 1465 'FS_createSpecialDirectories', 1466 'FS_createStandardStreams', 1467 'FS_staticInit', 1468 'FS_init', 1469 'FS_quit', 1470 'FS_findObject', 1471 'FS_analyzePath', 1472 'FS_createFile', 1473 'FS_createDataFile', 1474 'FS_forceLoadFile', 1475 'FS_createLazyFile', 1476 'FS_absolutePath', 1477 'FS_createFolder', 1478 'FS_createLink', 1479 'FS_joinPath', 1480 'FS_mmapAlloc', 1481 'FS_standardizePath', 1482 'MEMFS', 1483 'TTY', 1484 'PIPEFS', 1485 'SOCKFS', 1486 'tempFixedLengthArray', 1487 'miniTempWebGLFloatBuffers', 1488 'miniTempWebGLIntBuffers', 1489 'GL', 1490 'AL', 1491 'GLUT', 1492 'EGL', 1493 'GLEW', 1494 'IDBStore', 1495 'SDL', 1496 'SDL_gfx', 1497 'allocateUTF8', 1498 'allocateUTF8OnStack', 1499 'print', 1500 'printErr', 1501 'jstoi_s', 1502 ]; 1503 unexportedSymbols.forEach(unexportedRuntimeSymbol); 1504 1505 // End runtime exports 1506 // Begin JS library exports 1507 // End JS library exports 1508 1509 // end include: postlibrary.js 1510 1511 function checkIncomingModuleAPI() { 1512 ignoredModuleProp('fetchSettings'); 1513 } 1514 1515 // Imports from the Wasm binary. 1516 var _main = Module['_main'] = makeInvalidEarlyAccess('_main'); 1517 var _fflush = makeInvalidEarlyAccess('_fflush'); 1518 var _strerror = makeInvalidEarlyAccess('_strerror'); 1519 var _emscripten_stack_get_end = makeInvalidEarlyAccess('_emscripten_stack_get_end'); 1520 var _emscripten_stack_get_base = makeInvalidEarlyAccess('_emscripten_stack_get_base'); 1521 var _emscripten_stack_init = makeInvalidEarlyAccess('_emscripten_stack_init'); 1522 var _emscripten_stack_get_free = makeInvalidEarlyAccess('_emscripten_stack_get_free'); 1523 var __emscripten_stack_restore = makeInvalidEarlyAccess('__emscripten_stack_restore'); 1524 var __emscripten_stack_alloc = makeInvalidEarlyAccess('__emscripten_stack_alloc'); 1525 var _emscripten_stack_get_current = makeInvalidEarlyAccess('_emscripten_stack_get_current'); 1526 1527 function assignWasmExports(wasmExports) { 1528 Module['_main'] = _main = createExportWrapper('main', 2); 1529 _fflush = createExportWrapper('fflush', 1); 1530 _strerror = createExportWrapper('strerror', 1); 1531 _emscripten_stack_get_end = wasmExports['emscripten_stack_get_end']; 1532 _emscripten_stack_get_base = wasmExports['emscripten_stack_get_base']; 1533 _emscripten_stack_init = wasmExports['emscripten_stack_init']; 1534 _emscripten_stack_get_free = wasmExports['emscripten_stack_get_free']; 1535 __emscripten_stack_restore = wasmExports['_emscripten_stack_restore']; 1536 __emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc']; 1537 _emscripten_stack_get_current = wasmExports['emscripten_stack_get_current']; 1538 } 1539 var wasmImports = { 1540 /** @export */ 1541 fd_write: _fd_write 1542 }; 1543 var wasmExports; 1544 createWasm(); 1545 1546 1547 // include: postamble.js 1548 // === Auto-generated postamble setup entry stuff === 1549 1550 var calledRun; 1551 1552 function callMain() { 1553 assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on Module["onRuntimeInitialized"])'); 1554 assert(typeof onPreRuns === 'undefined' || onPreRuns.length == 0, 'cannot call main when preRun functions remain to be called'); 1555 1556 var entryFunction = _main; 1557 1558 var argc = 0; 1559 var argv = 0; 1560 1561 try { 1562 1563 var ret = entryFunction(argc, argv); 1564 1565 // if we're not running an evented main loop, it's time to exit 1566 exitJS(ret, /* implicit = */ true); 1567 return ret; 1568 } catch (e) { 1569 return handleException(e); 1570 } 1571 } 1572 1573 function stackCheckInit() { 1574 // This is normally called automatically during __wasm_call_ctors but need to 1575 // get these values before even running any of the ctors so we call it redundantly 1576 // here. 1577 _emscripten_stack_init(); 1578 // TODO(sbc): Move writeStackCookie to native to to avoid this. 1579 writeStackCookie(); 1580 } 1581 1582 function run() { 1583 1584 if (runDependencies > 0) { 1585 dependenciesFulfilled = run; 1586 return; 1587 } 1588 1589 stackCheckInit(); 1590 1591 preRun(); 1592 1593 // a preRun added a dependency, run will be called later 1594 if (runDependencies > 0) { 1595 dependenciesFulfilled = run; 1596 return; 1597 } 1598 1599 function doRun() { 1600 // run may have just been called through dependencies being fulfilled just in this very frame, 1601 // or while the async setStatus time below was happening 1602 assert(!calledRun); 1603 calledRun = true; 1604 Module['calledRun'] = true; 1605 1606 if (ABORT) return; 1607 1608 initRuntime(); 1609 1610 preMain(); 1611 1612 Module['onRuntimeInitialized']?.(); 1613 consumedModuleProp('onRuntimeInitialized'); 1614 1615 var noInitialRun = Module['noInitialRun'] || false; 1616 if (!noInitialRun) callMain(); 1617 1618 postRun(); 1619 } 1620 1621 if (Module['setStatus']) { 1622 Module['setStatus']('Running...'); 1623 setTimeout(() => { 1624 setTimeout(() => Module['setStatus'](''), 1); 1625 doRun(); 1626 }, 1); 1627 } else 1628 { 1629 doRun(); 1630 } 1631 checkStackCookie(); 1632 } 1633 1634 function checkUnflushedContent() { 1635 // Compiler settings do not allow exiting the runtime, so flushing 1636 // the streams is not possible. but in ASSERTIONS mode we check 1637 // if there was something to flush, and if so tell the user they 1638 // should request that the runtime be exitable. 1639 // Normally we would not even include flush() at all, but in ASSERTIONS 1640 // builds we do so just for this check, and here we see if there is any 1641 // content to flush, that is, we check if there would have been 1642 // something a non-ASSERTIONS build would have not seen. 1643 // How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0 1644 // mode (which has its own special function for this; otherwise, all 1645 // the code is inside libc) 1646 var oldOut = out; 1647 var oldErr = err; 1648 var has = false; 1649 out = err = (x) => { 1650 has = true; 1651 } 1652 try { // it doesn't matter if it fails 1653 flush_NO_FILESYSTEM(); 1654 } catch(e) {} 1655 out = oldOut; 1656 err = oldErr; 1657 if (has) { 1658 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.'); 1659 warnOnce('(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)'); 1660 } 1661 } 1662 1663 function preInit() { 1664 if (Module['preInit']) { 1665 if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']]; 1666 while (Module['preInit'].length > 0) { 1667 Module['preInit'].shift()(); 1668 } 1669 } 1670 consumedModuleProp('preInit'); 1671 } 1672 1673 preInit(); 1674 run(); 1675 1676 // end include: postamble.js 1677