litlaunch-library-api-debug 0.0.0-stage → 0.2.7-tweak.4

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,1895 @@
1
+ // This code implements the `-sMODULARIZE` settings by taking the generated
2
+ // JS program code (INNER_JS_CODE) and wrapping it in a factory function.
3
+
4
+ // When targeting node and ES6 we use `await import ..` in the generated code
5
+ // so the outer function needs to be marked as async.
6
+ async function LitLaunchLibraryApi(moduleArg = {}) {
7
+ var Module = moduleArg;
8
+ // include: shell.js
9
+ // include: minimum_runtime_check.js
10
+ (function() {
11
+ // "30.0.0" -> 300000
12
+ function humanReadableVersionToPacked(str) {
13
+ str = str.split('-')[0]; // Remove any trailing part from e.g. "12.53.3-alpha"
14
+ let vers = str.split('.').slice(0, 3);
15
+ while(vers.length < 3) vers.push('00');
16
+ vers = vers.map((n, i, arr) => n.padStart(2, '0'));
17
+ return vers.join('');
18
+ }
19
+ // 300000 -> "30.0.0"
20
+ const packedVersionToHumanReadable = n => [n / 10_000 | 0, (n / 100 | 0) % 100, n % 100].join('.');
21
+
22
+ const TARGET_NOT_SUPPORTED = 2147483647;
23
+
24
+ // Note: We use a typeof check here instead of optional chaining using
25
+ // globalThis because older browsers might not have globalThis defined.
26
+
27
+ // We skip the node version checking when running on Bun/Deno since the node
28
+ // version they report doesn't seem to be useful.
29
+ if (typeof process !== 'undefined' && !process.versions?.bun && typeof Deno === "undefined") {
30
+ const currentNodeVersion = process.versions?.node ? humanReadableVersionToPacked(process.versions.node) : TARGET_NOT_SUPPORTED;
31
+ if (currentNodeVersion < 180300) {
32
+ throw new Error(`This emscripten-generated code requires node v${ packedVersionToHumanReadable(180300) } (detected v${packedVersionToHumanReadable(currentNodeVersion)})`);
33
+ }
34
+ }
35
+
36
+ const userAgent = typeof navigator !== 'undefined' && navigator.userAgent;
37
+ if (!userAgent) {
38
+ return;
39
+ }
40
+
41
+ const currentSafariVersion = userAgent.includes("Safari/") && !userAgent.includes("Chrome/") && userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/) ? humanReadableVersionToPacked(userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/)[1]) : TARGET_NOT_SUPPORTED;
42
+ if (currentSafariVersion < 150400) {
43
+ throw new Error(`This emscripten-generated code requires Safari v${ packedVersionToHumanReadable(150400) } (detected v${currentSafariVersion})`);
44
+ }
45
+
46
+ const currentFirefoxVersion = userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/) ? parseFloat(userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/)[1]) : TARGET_NOT_SUPPORTED;
47
+ if (currentFirefoxVersion < 92) {
48
+ throw new Error(`This emscripten-generated code requires Firefox v92 (detected v${currentFirefoxVersion})`);
49
+ }
50
+
51
+ const currentChromeVersion = userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/) ? parseFloat(userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/)[1]) : TARGET_NOT_SUPPORTED;
52
+ if (currentChromeVersion < 93) {
53
+ throw new Error(`This emscripten-generated code requires Chrome v93 (detected v${currentChromeVersion})`);
54
+ }
55
+ })();
56
+
57
+ // end include: minimum_runtime_check.js
58
+ // The Module object: Our interface to the outside world. We import
59
+ // and export values on it. There are various ways Module can be used:
60
+ // 1. Not defined. We create it here
61
+ // 2. A function parameter, function(moduleArg) => Promise<Module>
62
+ // 3. pre-run appended it, var Module = {}; ..generated code..
63
+ // 4. External script tag defines var Module.
64
+ // We need to check if Module already exists (e.g. case 3 above).
65
+ // Substitution will be replaced with actual code on later stage of the build,
66
+ // this way Closure Compiler will not mangle it (e.g. case 4. above).
67
+ // Note that if you want to run closure, and also to use Module
68
+ // after the generated code, you will need to define var Module = {};
69
+ // before the code. Then that object will be used in the code, and you
70
+ // can continue to use Module afterwards as well.
71
+
72
+ // Determine the runtime environment we are in. You can customize this by
73
+ // setting the ENVIRONMENT setting at compile time (see settings.js).
74
+
75
+ // Attempt to auto-detect the environment
76
+ var ENVIRONMENT_IS_WEB = !!globalThis.window;
77
+ var ENVIRONMENT_IS_WORKER = !!globalThis.WorkerGlobalScope;
78
+ // N.b. Electron.js environment is simultaneously a NODE-environment, but
79
+ // also a web environment.
80
+ var ENVIRONMENT_IS_NODE = globalThis.process?.versions?.node && globalThis.process?.type != 'renderer';
81
+ var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
82
+
83
+ if (ENVIRONMENT_IS_NODE) {
84
+ // When building an ES module `require` is not normally available.
85
+ // We need to use `createRequire()` to construct the require()` function.
86
+ const { createRequire } = await import('node:module');
87
+ /** @suppress{duplicate} */
88
+ var require = createRequire(import.meta.url);
89
+
90
+ }
91
+
92
+ // --pre-jses are emitted after the Module integration code, so that they can
93
+ // refer to Module (if they choose; they can also define Module)
94
+
95
+
96
+ var programArgs = [];
97
+ var thisProgram = './this.program';
98
+ var quit_ = (status, toThrow) => {
99
+ throw toThrow;
100
+ };
101
+
102
+ var _scriptName = import.meta.url;
103
+
104
+ // `/` should be present at the end if `scriptDirectory` is not empty
105
+ var scriptDirectory = '';
106
+ function locateFile(path) {
107
+ if (Module['locateFile']) {
108
+ return Module['locateFile'](path, scriptDirectory);
109
+ }
110
+ return scriptDirectory + path;
111
+ }
112
+
113
+ // Hooks that are implemented differently in different runtime environments.
114
+ var readAsync, readBinary;
115
+
116
+ if (ENVIRONMENT_IS_NODE) {
117
+ const isNode = globalThis.process?.versions?.node && globalThis.process?.type != 'renderer';
118
+ 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?)');
119
+
120
+ // These modules will usually be used on Node.js. Load them eagerly to avoid
121
+ // the complexity of lazy-loading.
122
+ var fs = require('node:fs');
123
+
124
+ if (_scriptName.startsWith('file:')) {
125
+ scriptDirectory = require('node:path').dirname(require('node:url').fileURLToPath(_scriptName)) + '/';
126
+ }
127
+
128
+ // include: node_shell_read.js
129
+ readBinary = (filename) => {
130
+ // We need to re-wrap `file://` strings to URLs.
131
+ filename = isFileURI(filename) ? new URL(filename) : filename;
132
+ var ret = fs.readFileSync(filename);
133
+ assert(Buffer.isBuffer(ret));
134
+ return ret;
135
+ };
136
+
137
+ readAsync = async (filename, binary = true) => {
138
+ // See the comment in the `readBinary` function.
139
+ filename = isFileURI(filename) ? new URL(filename) : filename;
140
+ var ret = fs.readFileSync(filename, binary ? undefined : 'utf8');
141
+ assert(binary ? Buffer.isBuffer(ret) : typeof ret === 'string');
142
+ return ret;
143
+ };
144
+ // end include: node_shell_read.js
145
+ if (process.argv.length > 1) {
146
+ thisProgram = process.argv[1].replace(/\\/g, '/');
147
+ }
148
+
149
+ programArgs = process.argv.slice(2);
150
+
151
+ quit_ = (status, toThrow) => {
152
+ process.exitCode = status;
153
+ throw toThrow;
154
+ };
155
+
156
+ } else
157
+ if (ENVIRONMENT_IS_SHELL) {
158
+
159
+ } else
160
+
161
+ // Note that this includes Node.js workers when relevant (pthreads is enabled).
162
+ // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
163
+ // ENVIRONMENT_IS_NODE.
164
+ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
165
+ try {
166
+ scriptDirectory = new URL('.', _scriptName).href; // includes trailing slash
167
+ } catch {
168
+ // Must be a `blob:` or `data:` URL (e.g. `blob:http://site.com/etc/etc`), we cannot
169
+ // infer anything from them.
170
+ }
171
+
172
+ if (!(globalThis.window || globalThis.WorkerGlobalScope)) 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?)');
173
+
174
+ {
175
+ // include: web_or_worker_shell_read.js
176
+ if (ENVIRONMENT_IS_WORKER) {
177
+ readBinary = (url) => {
178
+ var xhr = new XMLHttpRequest();
179
+ xhr.open('GET', url, false);
180
+ xhr.responseType = 'arraybuffer';
181
+ xhr.send(null);
182
+ return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response));
183
+ };
184
+ }
185
+
186
+ readAsync = async (url) => {
187
+ // Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
188
+ // See https://github.com/github/fetch/pull/92#issuecomment-140665932
189
+ // Cordova or Electron apps are typically loaded from a file:// url.
190
+ // So use XHR on webview if URL is a file URL.
191
+ if (isFileURI(url)) {
192
+ return new Promise((resolve, reject) => {
193
+ var xhr = new XMLHttpRequest();
194
+ xhr.open('GET', url, true);
195
+ xhr.responseType = 'arraybuffer';
196
+ xhr.onload = () => {
197
+ if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
198
+ resolve(xhr.response);
199
+ return;
200
+ }
201
+ reject(xhr.status);
202
+ };
203
+ xhr.onerror = reject;
204
+ xhr.send(null);
205
+ });
206
+ }
207
+ var response = await fetch(url, { credentials: 'same-origin' });
208
+ if (response.ok) {
209
+ return response.arrayBuffer();
210
+ }
211
+ throw new Error(response.status + ' : ' + response.url);
212
+ };
213
+ // end include: web_or_worker_shell_read.js
214
+ }
215
+ } else
216
+ {
217
+ throw new Error('environment detection error');
218
+ }
219
+
220
+ var out = console.log.bind(console);
221
+ var err = console.error.bind(console);
222
+
223
+ var IDBFS = 'IDBFS is no longer included by default; build with -lidbfs.js';
224
+ var PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js';
225
+ var WORKERFS = 'WORKERFS is no longer included by default; build with -lworkerfs.js';
226
+ var FETCHFS = 'FETCHFS is no longer included by default; build with -lfetchfs.js';
227
+ var ICASEFS = 'ICASEFS is no longer included by default; build with -licasefs.js';
228
+ var JSFILEFS = 'JSFILEFS is no longer included by default; build with -ljsfilefs.js';
229
+ var OPFS = 'OPFS is no longer included by default; build with -lopfs.js';
230
+
231
+ var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js';
232
+
233
+ // perform assertions in shell.js after we set up out() and err(), as otherwise
234
+ // if an assertion fails it cannot print the message
235
+
236
+ assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time (add `shell` to `-sENVIRONMENT` to enable)');
237
+
238
+ // end include: shell.js
239
+
240
+ // include: preamble.js
241
+ // === Preamble library stuff ===
242
+
243
+ // Documentation for the public APIs defined in this file must be updated in:
244
+ // site/source/docs/api_reference/preamble.js.rst
245
+ // A prebuilt local version of the documentation is available at:
246
+ // site/build/text/docs/api_reference/preamble.js.txt
247
+ // You can also build docs locally as HTML or other formats in site/
248
+ // An online HTML version (which may be of a different version of Emscripten)
249
+ // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
250
+
251
+ var wasmBinary;
252
+
253
+ if (!globalThis.WebAssembly) {
254
+ err('no native wasm support detected');
255
+ }
256
+
257
+ // Wasm globals
258
+
259
+ //========================================
260
+ // Runtime essentials
261
+ //========================================
262
+
263
+ // whether we are quitting the application. no code should run after this.
264
+ // set in exit() and abort()
265
+ var ABORT = false;
266
+
267
+ // set by exit() and abort(). Passed to 'onExit' handler.
268
+ // NOTE: This is also used as the process return code in shell environments
269
+ // but only when noExitRuntime is false.
270
+ var EXITSTATUS;
271
+
272
+ // In STRICT mode, we only define assert() when ASSERTIONS is set. i.e. we
273
+ // don't define it at all in release modes. This matches the behaviour of
274
+ // MINIMAL_RUNTIME.
275
+ // TODO(sbc): Make this the default even without STRICT enabled.
276
+ /** @type {function(*, string=)} */
277
+ function assert(condition, text) {
278
+ if (!condition) {
279
+ abort('Assertion failed' + (text ? ': ' + text : ''));
280
+ }
281
+ }
282
+
283
+ // We used to include malloc/free by default in the past. Show a helpful error in
284
+ // builds with assertions.
285
+
286
+ /**
287
+ * Indicates whether filename is delivered via file protocol (as opposed to http/https)
288
+ * @noinline
289
+ */
290
+ var isFileURI = (filename) => filename.startsWith('file://');
291
+
292
+ // include: runtime_common.js
293
+ // include: runtime_exceptions.js
294
+ // Base Emscripten EH error class
295
+ class EmscriptenEH {}
296
+
297
+ class EmscriptenSjLj extends EmscriptenEH {}
298
+
299
+ // end include: runtime_exceptions.js
300
+ // include: runtime_debug.js
301
+ var runtimeDebug = true; // Switch to false at runtime to disable logging at the right times
302
+
303
+ // Used by XXXXX_DEBUG settings to output debug messages.
304
+ function dbg(...args) {
305
+ if (!runtimeDebug && typeof runtimeDebug !== 'undefined') return;
306
+ // TODO(sbc): Make this configurable somehow. Its not always convenient for
307
+ // logging to show up as warnings.
308
+ console.warn(...args);
309
+ }
310
+
311
+ // Endianness check
312
+ (() => {
313
+ const h16 = new Int16Array(1);
314
+ const h8 = new Int8Array(h16.buffer);
315
+ h16[0] = 0x6373;
316
+ if (h8[0] !== 0x73 || h8[1] !== 0x63) abort('Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)');
317
+ })();
318
+
319
+ function consumedModuleProp(prop) {
320
+ let value = Module[prop];
321
+ const msg = `Attempt to modify \`Module.${prop}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`;
322
+ if (Array.isArray(value)) {
323
+ value = new Proxy(value, {
324
+ set(target, key, val) {
325
+ abort(msg);
326
+ return false;
327
+ },
328
+ defineProperty(target, key, descriptor) {
329
+ abort(msg);
330
+ return false;
331
+ },
332
+ deleteProperty(target, key) {
333
+ abort(msg);
334
+ return false;
335
+ }
336
+ });
337
+ }
338
+ Object.defineProperty(Module, prop, {
339
+ configurable: true,
340
+ get() { return value; },
341
+ set() {
342
+ abort(msg);
343
+ }
344
+ });
345
+ }
346
+
347
+ function makeInvalidEarlyAccess(name) {
348
+ return () => assert(false, `call to '${name}' via reference taken before Wasm module initialization`);
349
+
350
+ }
351
+
352
+ function ignoredModuleProp(prop) {
353
+ if (Object.getOwnPropertyDescriptor(Module, prop)) {
354
+ abort(`\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API`);
355
+ }
356
+ }
357
+
358
+ // forcing the filesystem exports a few things by default
359
+ function isExportedByForceFilesystem(name) {
360
+ return name === 'FS_createPath' ||
361
+ name === 'FS_createDataFile' ||
362
+ name === 'FS_createPreloadedFile' ||
363
+ name === 'FS_preloadFile' ||
364
+ name === 'FS_unlink' ||
365
+ name === 'addRunDependency' ||
366
+ // The old FS has some functionality that WasmFS lacks.
367
+ name === 'FS_createLazyFile' ||
368
+ name === 'FS_createDevice' ||
369
+ name === 'removeRunDependency';
370
+ }
371
+
372
+ function missingLibrarySymbol(sym) {
373
+
374
+ // Any symbol that is not included from the JS library is also (by definition)
375
+ // not exported on the Module object.
376
+ unexportedRuntimeSymbol(sym);
377
+ }
378
+
379
+ function unexportedRuntimeSymbol(sym) {
380
+ if (!Object.getOwnPropertyDescriptor(Module, sym)) {
381
+ Object.defineProperty(Module, sym, {
382
+ configurable: true,
383
+ get() {
384
+ let msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;
385
+ if (isExportedByForceFilesystem(sym)) {
386
+ msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
387
+ }
388
+ abort(msg);
389
+ },
390
+ });
391
+ }
392
+ }
393
+
394
+ const MAX_UINT8 = (2 ** 8) - 1;
395
+ const MAX_UINT16 = (2 ** 16) - 1;
396
+ const MAX_UINT32 = (2 ** 32) - 1;
397
+ const MAX_UINT53 = (2 ** 53) - 1;
398
+ const MAX_UINT64 = (2 ** 64) - 1;
399
+
400
+ const MIN_INT8 = - (2 ** ( 8 - 1));
401
+ const MIN_INT16 = - (2 ** (16 - 1));
402
+ const MIN_INT32 = - (2 ** (32 - 1));
403
+ const MIN_INT53 = - (2 ** (53 - 1));
404
+ const MIN_INT64 = - (2 ** (64 - 1));
405
+
406
+ function checkInt(value, bits, min, max) {
407
+ assert(Number.isInteger(Number(value)), `attempt to write non-integer (${value}) into integer heap`);
408
+ assert(value <= max, `value (${value}) too large to write as ${bits}-bit value`);
409
+ assert(value >= min, `value (${value}) too small to write as ${bits}-bit value`);
410
+ }
411
+
412
+ const checkInt1 = (value) => checkInt(value, 1, 1);
413
+ const checkInt8 = (value) => checkInt(value, 8, MIN_INT8, MAX_UINT8);
414
+ const checkInt16 = (value) => checkInt(value, 16, MIN_INT16, MAX_UINT16);
415
+ const checkInt32 = (value) => checkInt(value, 32, MIN_INT32, MAX_UINT32);
416
+ const checkInt53 = (value) => checkInt(value, 53, MIN_INT53, MAX_UINT53);
417
+ const checkInt64 = (value) => checkInt(value, 64, MIN_INT64, MAX_UINT64);
418
+
419
+ // end include: runtime_debug.js
420
+ // include: runtime_stack_check.js
421
+ const stackCookie1 = 0x02135467;
422
+ const stackCookie2 = 0x89BACDFE;
423
+
424
+ // Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
425
+ function writeStackCookie() {
426
+ let max = _emscripten_stack_get_end();
427
+ assert((max & 3) == 0);
428
+ // If the stack ends at address zero we write our cookies 4 bytes into the
429
+ // stack. This prevents interference with SAFE_HEAP and ASAN which also
430
+ // monitor writes to address zero.
431
+ if (max == 0) {
432
+ max += 4;
433
+ }
434
+ // The stack grow downwards towards _emscripten_stack_get_end.
435
+ // We write cookies to the final two words in the stack and detect if they are
436
+ // ever overwritten.
437
+ HEAPU32[((max)>>2)] = stackCookie1;checkInt32(stackCookie1);
438
+ HEAPU32[(((max)+(4))>>2)] = stackCookie2;checkInt32(stackCookie2);
439
+ // Also test the global address 0 for integrity.
440
+ HEAPU32[((0)>>2)] = 1668509029;checkInt32(1668509029);
441
+ }
442
+
443
+ function u32ToHexString(num) {
444
+ return '0x' + (num >>> 0).toString(16).padStart(8, '0');
445
+ }
446
+
447
+ function checkStackCookie() {
448
+ if (ABORT) return;
449
+ let max = _emscripten_stack_get_end();
450
+ // See writeStackCookie().
451
+ if (max == 0) {
452
+ max += 4;
453
+ }
454
+ const val1 = HEAPU32[((max)>>2)];
455
+ const val2 = HEAPU32[(((max)+(4))>>2)];
456
+ if (val1 != stackCookie1 || val2 != stackCookie2) {
457
+ abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords ${u32ToHexString(stackCookie2)} and ${u32ToHexString(stackCookie1)}, but received ${u32ToHexString(val2)} ${u32ToHexString(val1)}`);
458
+ }
459
+ // Also test the global address 0 for integrity.
460
+ if (HEAPU32[((0)>>2)] != 0x63736d65 /* 'emsc' */) {
461
+ abort('Runtime error: The application has corrupted its heap memory area (address zero)!');
462
+ }
463
+ }
464
+ // end include: runtime_stack_check.js
465
+ // Memory management
466
+
467
+ var runtimeInitialized = false;
468
+
469
+
470
+
471
+ // When ALLOW_MEMORY_GROWTH is enabled, the conversion from Wasm
472
+ // memory to ArrayBuffer requires some additional logic.
473
+ function getMemoryBuffer() {
474
+ return wasmMemory.buffer;
475
+ }
476
+
477
+ function updateMemoryViews() {
478
+ // If we already have a heap that is resizeable/growable buffer we don't
479
+ // need to do anything in updateMemoryViews.
480
+ if (HEAP8?.buffer?.resizable) return;
481
+ var b = getMemoryBuffer();
482
+ HEAP8 = new Int8Array(b);
483
+
484
+ HEAPU8 = new Uint8Array(b);
485
+
486
+ HEAP32 = new Int32Array(b);
487
+ HEAPU32 = new Uint32Array(b);
488
+
489
+
490
+
491
+
492
+ }
493
+
494
+ // include: memoryprofiler.js
495
+ // end include: memoryprofiler.js
496
+ // end include: runtime_common.js
497
+ assert(globalThis.Int32Array && globalThis.Float64Array && Int32Array.prototype.subarray && Int32Array.prototype.set,
498
+ 'JS engine does not provide full typed array support');
499
+
500
+ function preRun() {
501
+ var preRun = Module['preRun'];
502
+ if (preRun) {
503
+ if (typeof preRun === 'function') preRun = [preRun];
504
+ onPreRuns.push(...preRun);
505
+ }
506
+ consumedModuleProp('preRun');
507
+ // Begin ATPRERUNS hooks
508
+ callRuntimeCallbacks(onPreRuns);
509
+ // End ATPRERUNS hooks
510
+ }
511
+
512
+ function initRuntime() {
513
+ assert(!runtimeInitialized);
514
+ runtimeInitialized = true;
515
+
516
+ setStackLimits();
517
+
518
+ checkStackCookie();
519
+
520
+ // No ATINITS hooks
521
+
522
+ wasmExports['__wasm_call_ctors']();
523
+
524
+ // No ATPOSTCTORS hooks
525
+
526
+ checkStackCookie();
527
+ }
528
+
529
+ function postRun() {
530
+ checkStackCookie();
531
+
532
+ var postRun = Module['postRun'];
533
+ if (postRun) {
534
+ if (typeof postRun === 'function') postRun = [postRun];
535
+ onPostRuns.push(...postRun);
536
+ }
537
+ consumedModuleProp('postRun');
538
+
539
+ // Begin ATPOSTRUNS hooks
540
+ callRuntimeCallbacks(onPostRuns);
541
+ // End ATPOSTRUNS hooks
542
+ }
543
+
544
+ /**
545
+ * @param {string|number=} what
546
+ */
547
+ function abort(what) {
548
+ Module['onAbort']?.(what);
549
+
550
+ what = `Aborted(${what})`;
551
+ // TODO(sbc): Should we remove printing and leave it up to whoever
552
+ // catches the exception?
553
+ err(what);
554
+
555
+ ABORT = true;
556
+
557
+ // Use a wasm runtime error, because a JS error might be seen as a foreign
558
+ // exception, which means we'd run destructors on it. We need the error to
559
+ // simply make the program stop.
560
+ // FIXME This approach does not work in Wasm EH because it currently does not assume
561
+ // all RuntimeErrors are from traps; it decides whether a RuntimeError is from
562
+ // a trap or not based on a hidden field within the object. So at the moment
563
+ // we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that
564
+ // allows this in the wasm spec.
565
+ throw new WebAssembly.RuntimeError(what);
566
+ }
567
+
568
+ // show errors on likely calls to FS when it was not included
569
+ function fsMissing() {
570
+ 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');
571
+ }
572
+ var FS = {
573
+ init: fsMissing,
574
+ createDataFile: fsMissing,
575
+ createPreloadedFile: fsMissing,
576
+ createLazyFile: fsMissing,
577
+ open: fsMissing,
578
+ mkdev: fsMissing,
579
+ registerDevice: fsMissing,
580
+ analyzePath: fsMissing,
581
+ ErrnoError: fsMissing,
582
+ };
583
+
584
+
585
+ function createExportWrapper(name, func, nargs) {
586
+ assert(func);
587
+ return (...args) => {
588
+ assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`);
589
+ // Only assert for too many arguments. Too few can be valid since the missing arguments will be zero filled.
590
+ assert(args.length <= nargs, `native function \`${name}\` called with ${args.length} args but expects ${nargs}`);
591
+ return func(...args);
592
+ };
593
+ }
594
+
595
+ var wasmBinaryFile;
596
+
597
+ function findWasmBinary() {
598
+
599
+ if (Module['locateFile']) {
600
+ return locateFile('litlaunch-library-api-0.2.7+tweak.4-wasm32-emscripten-debug.wasm');
601
+ }
602
+
603
+ // Use bundler-friendly `new URL(..., import.meta.url)` pattern; works in browsers too.
604
+ return new URL('litlaunch-library-api-0.2.7+tweak.4-wasm32-emscripten-debug.wasm', import.meta.url).href;
605
+
606
+ }
607
+
608
+ function getBinarySync(file) {
609
+ if (readBinary) {
610
+ return readBinary(file);
611
+ }
612
+ // Throwing a plain string here, even though it not normally advisable since
613
+ // this gets turning into an `abort` in instantiateArrayBuffer.
614
+ throw 'both async and sync fetching of the wasm failed';
615
+ }
616
+
617
+ async function getWasmBinary(binaryFile) {
618
+ // If we don't have the binary yet, load it asynchronously using readAsync.
619
+ if (!wasmBinary) {
620
+ // Fetch the binary using readAsync
621
+ try {
622
+ // Await so a rejection is caught and falls back to getBinarySync.
623
+ return await readAsync(binaryFile);
624
+ } catch {
625
+ // Fall back to getBinarySync below;
626
+ }
627
+ }
628
+
629
+ // Otherwise, getBinarySync should be able to get it synchronously
630
+ return getBinarySync(binaryFile);
631
+ }
632
+
633
+ async function instantiateArrayBuffer(binaryFile, imports) {
634
+ try {
635
+ var binary = await getWasmBinary(binaryFile);
636
+ var instance = await WebAssembly.instantiate(binary, imports);
637
+ return instance;
638
+ } catch (reason) {
639
+ err(`failed to asynchronously prepare wasm: ${reason}`);
640
+
641
+ // Warn on some common problems.
642
+ if (isFileURI(binaryFile)) {
643
+ err(`warning: Loading from a file URI (${binaryFile}) 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`);
644
+ }
645
+ abort(reason);
646
+ }
647
+ }
648
+
649
+ async function instantiateAsync(binary, binaryFile, imports) {
650
+ if (!binary
651
+ // Don't use streaming for file:// delivered objects in a webview, fetch them synchronously.
652
+ && !isFileURI(binaryFile)
653
+ // Avoid using instantiateStreaming() on Node.js since the `fetch()` API
654
+ // does not support `file://` URLs.
655
+ // See: https://github.com/emscripten-core/emscripten/pull/16917
656
+ && !ENVIRONMENT_IS_NODE
657
+ ) {
658
+ try {
659
+ var response = fetch(binaryFile, { credentials: 'same-origin' });
660
+ var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
661
+ return instantiationResult;
662
+ } catch (reason) {
663
+ // We expect the most common failure cause to be a bad MIME type for the binary,
664
+ // in which case falling back to ArrayBuffer instantiation should work.
665
+ err(`wasm streaming compile failed: ${reason}`);
666
+ err('falling back to ArrayBuffer instantiation');
667
+ // fall back of instantiateArrayBuffer below
668
+ };
669
+ }
670
+ return instantiateArrayBuffer(binaryFile, imports);
671
+ }
672
+
673
+ function getWasmImports() {
674
+ // prepare imports
675
+ var imports = {
676
+ 'env': wasmImports,
677
+ 'wasi_snapshot_preview1': wasmImports,
678
+ };
679
+ return imports;
680
+ }
681
+
682
+ // Create the wasm instance.
683
+ // Receives the wasm imports, returns the exports.
684
+ async function createWasm() {
685
+ // Load the wasm module and create an instance of using native support in the JS engine.
686
+ // handle a generated wasm instance, receiving its exports and
687
+ // performing other necessary setup
688
+ function receiveInstance(instance) {
689
+ wasmExports = instance.exports;
690
+
691
+ assignWasmExports(wasmExports);
692
+
693
+ updateMemoryViews();
694
+
695
+ return wasmExports;
696
+ }
697
+
698
+ // Prefer streaming instantiation if available.
699
+ // Async compilation can be confusing when an error on the page overwrites Module
700
+ // (for example, if the order of elements is wrong, and the one defining Module is
701
+ // later), so we save Module and check it later.
702
+ var trueModule = Module;
703
+ function receiveInstantiationResult(result) {
704
+ // 'result' is a ResultObject object which has both the module and instance.
705
+ // receiveInstance() will swap in the exports (to Module.asm) so they can be called
706
+ assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?');
707
+ trueModule = null;
708
+ // 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.
709
+ // When the regression is fixed, can restore the above PTHREADS-enabled path.
710
+ return receiveInstance(result['instance']);
711
+ }
712
+
713
+ var info = getWasmImports();
714
+
715
+ // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
716
+ // to manually instantiate the Wasm module themselves. This allows pages to
717
+ // run the instantiation parallel to any other async startup actions they are
718
+ // performing.
719
+ // Also pthreads and wasm workers initialize the wasm instance through this
720
+ // path.
721
+ var instantiateWasm = Module['instantiateWasm'];
722
+ if (instantiateWasm) {
723
+ return new Promise((resolve) => {
724
+ try {
725
+ instantiateWasm(info, (inst) => resolve(receiveInstance(inst)));
726
+ } catch(e) {
727
+ err(`Module.instantiateWasm callback failed with error: ${e}`);
728
+ throw e;
729
+ }
730
+ });
731
+ }
732
+
733
+ wasmBinaryFile ??= findWasmBinary();
734
+ var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
735
+ var exports = receiveInstantiationResult(result);
736
+ return exports;
737
+ }
738
+
739
+ // end include: preamble.js
740
+
741
+ // Begin JS library code
742
+
743
+ class ExitStatus {
744
+ name = 'ExitStatus';
745
+ constructor(status) {
746
+ this.message = `Program terminated with exit(${status})`;
747
+ this.status = status;
748
+ }
749
+ }
750
+ /** @type {!Int32Array} */
751
+ var HEAP32;
752
+ /** @type {!Int8Array} */
753
+ var HEAP8;
754
+ /** @type {!Uint32Array} */
755
+ var HEAPU32;
756
+ var callRuntimeCallbacks = (callbacks) => {
757
+ while (callbacks.length > 0) {
758
+ // Pass the module as the first argument.
759
+ callbacks.shift()(Module);
760
+ }
761
+ };
762
+ var onPostRuns = [];
763
+ var addOnPostRun = (cb) => onPostRuns.push(cb);
764
+ var onPreRuns = [];
765
+ var addOnPreRun = (cb) => onPreRuns.push(cb);
766
+
767
+ var noExitRuntime = true;
768
+ function ptrToString(ptr) {
769
+ assert(typeof ptr === 'number', `ptrToString expects a number, got ${typeof ptr}`);
770
+ // Convert to 32-bit unsigned value
771
+ ptr >>>= 0;
772
+ return '0x' + ptr.toString(16).padStart(8, '0');
773
+ }
774
+ var setStackLimits = () => {
775
+ var stackLow = _emscripten_stack_get_base();
776
+ var stackHigh = _emscripten_stack_get_end();
777
+ ___set_stack_limits(stackLow, stackHigh);
778
+ };
779
+ var stackRestore = (val) => __emscripten_stack_restore(val);
780
+ var stackSave = () => _emscripten_stack_get_current();
781
+ var warnOnce = (text) => {
782
+ warnOnce.shown ||= {};
783
+ if (!warnOnce.shown[text]) {
784
+ warnOnce.shown[text] = 1;
785
+ if (ENVIRONMENT_IS_NODE) text = 'warning: ' + text;
786
+ err(text);
787
+ }
788
+ };
789
+
790
+ /** @type {!Uint8Array} */
791
+ var HEAPU8;
792
+ var UTF8Decoder = globalThis.TextDecoder && new TextDecoder();
793
+
794
+ /**
795
+ * heapOrArray is either a regular array, or a JavaScript typed array view.
796
+ * @param {number} idx
797
+ * @param {number=} maxBytesToRead
798
+ * @param {boolean=} ignoreNul
799
+ * @return {number}
800
+ */
801
+ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
802
+ var maxIdx = idx + maxBytesToRead;
803
+ if (ignoreNul) return maxIdx;
804
+ // TextDecoder needs to know the byte length in advance, it doesn't stop on
805
+ // null terminator by itself.
806
+ // As a tiny code save trick, compare idx against maxIdx using a negation,
807
+ // so that maxBytesToRead=undefined/NaN means Infinity.
808
+ while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx;
809
+ return idx;
810
+ };
811
+
812
+ /**
813
+ * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
814
+ * array that contains uint8 values, returns a copy of that string as a
815
+ * Javascript String object.
816
+ * heapOrArray is either a regular array, or a JavaScript typed array view.
817
+ * @param {number=} idx
818
+ * @param {number=} maxBytesToRead
819
+ * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character.
820
+ * @return {string}
821
+ */
822
+ var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => {
823
+
824
+ var endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul);
825
+
826
+ // When using conditional TextDecoder, skip it for short strings as the overhead of the native call is not worth it.
827
+ if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
828
+ return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
829
+ }
830
+ var str = '';
831
+ while (idx < endPtr) {
832
+ // For UTF8 byte structure, see:
833
+ // http://en.wikipedia.org/wiki/UTF-8#Description
834
+ // https://www.ietf.org/rfc/rfc2279.txt
835
+ // https://tools.ietf.org/html/rfc3629
836
+ var u0 = heapOrArray[idx++];
837
+ if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
838
+ var u1 = heapOrArray[idx++] & 63;
839
+ if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
840
+ var u2 = heapOrArray[idx++] & 63;
841
+ if ((u0 & 0xF0) == 0xE0) {
842
+ u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
843
+ } else {
844
+ 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!`);
845
+ u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
846
+ }
847
+
848
+ if (u0 < 0x10000) {
849
+ str += String.fromCharCode(u0);
850
+ } else {
851
+ var ch = u0 - 0x10000;
852
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
853
+ }
854
+ }
855
+ return str;
856
+ };
857
+ var UTF8ToString_cache = {
858
+ };
859
+
860
+ /**
861
+ * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
862
+ * emscripten HEAP, returns a copy of that string as a Javascript String object.
863
+ *
864
+ * @param {number} ptr
865
+ * @param {number=} maxBytesToRead - An optional length that specifies the
866
+ * maximum number of bytes to read. You can omit this parameter to scan the
867
+ * string until the first 0 byte. If maxBytesToRead is passed, and the string
868
+ * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
869
+ * string will cut short at that byte index.
870
+ * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character.
871
+ * @return {string}
872
+ */
873
+ var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => {
874
+ assert(typeof ptr === 'number', `UTF8ToString expects a number (got ${typeof ptr})`);
875
+
876
+ // Only cache full string reads (when maxBytesToRead is omitted).
877
+ // We use `== null` here since its shorter than `=== undefined`
878
+ var useCache = maxBytesToRead == null && ptr >= 65536 && ptr < 71294;
879
+ if (useCache) {
880
+ var rtn = UTF8ToString_cache[ptr];
881
+ if (rtn != null) {
882
+ return rtn;
883
+ }
884
+ }
885
+
886
+ var rtn = ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead, ignoreNul) : '';
887
+
888
+ if (useCache) {
889
+ UTF8ToString_cache[ptr] = rtn;
890
+ }
891
+
892
+ return rtn;
893
+ };
894
+ var ___assert_fail = (condition, filename, line, func) =>
895
+ abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
896
+ var ___handle_stack_overflow = (requested) => {
897
+ var base = _emscripten_stack_get_base();
898
+ var end = _emscripten_stack_get_end();
899
+ abort(`stack overflow (Attempt to set SP to ${ptrToString(requested)}` +
900
+ `, with stack limits [${ptrToString(end)} - ${ptrToString(base)}` +
901
+ ']). If you require more stack space build with -sSTACK_SIZE=<bytes>');
902
+ };
903
+ var __abort_js = () =>
904
+ abort('native code called abort()');
905
+ var alignMemory = (size, alignment) => {
906
+ assert(alignment, 'alignment argument is required');
907
+ return Math.ceil(size / alignment) * alignment;
908
+ };
909
+ var getHeapMax = () =>
910
+ // Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
911
+ // full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
912
+ // for any code that deals with heap sizes, which would require special
913
+ // casing all heap size related code to treat 0 specially.
914
+ 2147483648;
915
+ var growMemory = (size) => {
916
+ var oldHeapSize = wasmMemory.buffer.byteLength;
917
+ var pages = ((size - oldHeapSize + 65535) / 65536) | 0;
918
+ try {
919
+ // round size grow request up to wasm page size (fixed 64KB per spec)
920
+ wasmMemory.grow(pages); // .grow() takes a delta compared to the previous size
921
+ updateMemoryViews();
922
+ return 1 /*success*/;
923
+ } catch(e) {
924
+ err(`growMemory: Attempted to grow heap from ${oldHeapSize} bytes to ${size} bytes, but got error: ${e}`);
925
+ }
926
+ // implicit 0 return to save code size (caller will cast 'undefined' into 0
927
+ // anyhow)
928
+ };
929
+ var _emscripten_get_now = () => performance.now();
930
+ var _emscripten_resize_heap = (requestedSize) => {
931
+ var oldSize = HEAPU8.length;
932
+ // With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
933
+ requestedSize >>>= 0;
934
+ // With multithreaded builds, races can happen (another thread might increase the size
935
+ // in between), so return a failure, and let the caller retry.
936
+ assert(requestedSize > oldSize);
937
+
938
+ // Memory resize rules:
939
+ // 1. Always increase heap size to at least the requested size, rounded up
940
+ // to next page multiple.
941
+ // 2a. If MEMORY_GROWTH_LINEAR_STEP == -1, excessively resize the heap
942
+ // geometrically: increase the heap size according to
943
+ // MEMORY_GROWTH_GEOMETRIC_STEP factor (default +20%), At most
944
+ // overreserve by MEMORY_GROWTH_GEOMETRIC_CAP bytes (default 96MB).
945
+ // 2b. If MEMORY_GROWTH_LINEAR_STEP != -1, excessively resize the heap
946
+ // linearly: increase the heap size by at least
947
+ // MEMORY_GROWTH_LINEAR_STEP bytes.
948
+ // 3. Max size for the heap is capped at 2048MB-WASM_PAGE_SIZE, or by
949
+ // MAXIMUM_MEMORY, or by ASAN limit, depending on which is smallest
950
+ // 4. If we were unable to allocate as much memory, it may be due to
951
+ // over-eager decision to excessively reserve due to (3) above.
952
+ // Hence if an allocation fails, cut down on the amount of excess
953
+ // growth, in an attempt to succeed to perform a smaller allocation.
954
+
955
+ // A limit is set for how much we can grow. We should not exceed that
956
+ // (the wasm binary specifies it, so if we tried, we'd fail anyhow).
957
+ var maxHeapSize = getHeapMax();
958
+ if (requestedSize > maxHeapSize) {
959
+ err(`Cannot enlarge memory, requested ${requestedSize} bytes, but the limit is ${maxHeapSize} bytes!`);
960
+ return false;
961
+ }
962
+
963
+ // Loop through potential heap size increases. If we attempt a too eager
964
+ // reservation that fails, cut down on the attempted size and reserve a
965
+ // smaller bump instead. (max 3 times, chosen somewhat arbitrarily)
966
+ for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
967
+ var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown); // ensure geometric growth
968
+ // but limit overreserving (default to capping at +96MB overgrowth at most)
969
+ overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296 );
970
+
971
+ var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
972
+
973
+ var t0 = _emscripten_get_now();
974
+ var replacement = growMemory(newSize);
975
+ var t1 = _emscripten_get_now();
976
+ dbg(`Heap resize call from ${oldSize} to ${newSize} took ${(t1 - t0)} msecs. Success: ${!!replacement}`);
977
+ if (replacement) {
978
+
979
+ return true;
980
+ }
981
+ }
982
+ err(`Failed to grow the heap from ${oldSize} bytes to ${newSize} bytes, not enough memory!`);
983
+ return false;
984
+ };
985
+ var _fd_close = (fd) => {
986
+ abort('fd_close called without SYSCALLS_REQUIRE_FILESYSTEM');
987
+ };
988
+ const ESPIPE = 70;
989
+ const INT53_MAX = 9007199254740992;
990
+ const INT53_MIN = -9007199254740992;
991
+ var bigintToI53Checked = (num) => (num < INT53_MIN || num > INT53_MAX) ? NaN : Number(num);
992
+ function _fd_seek(fd, offset, whence, newOffset) {
993
+ offset = bigintToI53Checked(offset);
994
+
995
+
996
+ return ESPIPE;
997
+ ;
998
+ }
999
+ var printCharBuffers = [null,[],[]];
1000
+ var printChar = (stream, curr) => {
1001
+ var buffer = printCharBuffers[stream];
1002
+ assert(buffer);
1003
+ if (!curr || curr === 10) {
1004
+ (stream === 1 ? out : err)(UTF8ArrayToString(buffer));
1005
+ buffer.length = 0;
1006
+ } else {
1007
+ buffer.push(curr);
1008
+ }
1009
+ };
1010
+ var flush_NO_FILESYSTEM = () => {
1011
+ // flush anything remaining in the buffers during shutdown
1012
+ _fflush(0);
1013
+ if (printCharBuffers[1].length) printChar(1, 10);
1014
+ if (printCharBuffers[2].length) printChar(2, 10);
1015
+ };
1016
+ var _fd_write = (fd, iov, iovcnt, pnum) => {
1017
+ // hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
1018
+ var num = 0;
1019
+ for (var i = 0; i < iovcnt; i++) {
1020
+ var ptr = HEAPU32[((iov)>>2)];
1021
+ var len = HEAPU32[(((iov)+(4))>>2)];
1022
+ iov += 8;
1023
+ for (var j = 0; j < len; j++) {
1024
+ printChar(fd, HEAPU8[ptr+j]);
1025
+ }
1026
+ num += len;
1027
+ }
1028
+ HEAPU32[((pnum)>>2)] = num;checkInt32(num);
1029
+ return 0;
1030
+ };
1031
+ var getCFunc = (ident) => {
1032
+ var func = Module['_' + ident]; // closure exported function
1033
+ assert(func, `Cannot call unknown function ${ident}, make sure it is exported`);
1034
+ return func;
1035
+ };
1036
+ var stackAlloc = (sz) => __emscripten_stack_alloc(sz);
1037
+ var lengthBytesUTF8 = (str) => {
1038
+ var len = 0;
1039
+ for (var i = 0; i < str.length; ++i) {
1040
+ var u = str.codePointAt(i);
1041
+ if (u <= 0x7F) {
1042
+ len++;
1043
+ } else if (u <= 0x7FF) {
1044
+ len += 2;
1045
+ } else if (u <= 0xFFFF) {
1046
+ len += 3;
1047
+ } else {
1048
+ len += 4;
1049
+ // Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
1050
+ // We need to manually skip over the second code unit for correct iteration.
1051
+ i++;
1052
+ }
1053
+ }
1054
+ return len;
1055
+ };
1056
+ var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
1057
+ assert(typeof str === 'string', `stringToUTF8Array expects a string (got ${typeof str})`);
1058
+ // Parameter maxBytesToWrite is not optional. Negative values, 0, null,
1059
+ // undefined and false each don't write out any bytes.
1060
+ if (!(maxBytesToWrite > 0))
1061
+ return 0;
1062
+
1063
+ var startIdx = outIdx;
1064
+ var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
1065
+ for (var i = 0; i < str.length; ++i) {
1066
+ // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
1067
+ // and https://www.ietf.org/rfc/rfc2279.txt
1068
+ // and https://tools.ietf.org/html/rfc3629
1069
+ var u = str.codePointAt(i);
1070
+ if (u <= 0x7F) {
1071
+ if (outIdx >= endIdx) break;
1072
+ heap[outIdx++] = u;
1073
+ } else if (u <= 0x7FF) {
1074
+ if (outIdx + 1 >= endIdx) break;
1075
+ heap[outIdx++] = 0xC0 | (u >> 6);
1076
+ heap[outIdx++] = 0x80 | (u & 63);
1077
+ } else if (u <= 0xFFFF) {
1078
+ if (outIdx + 2 >= endIdx) break;
1079
+ heap[outIdx++] = 0xE0 | (u >> 12);
1080
+ heap[outIdx++] = 0x80 | ((u >> 6) & 63);
1081
+ heap[outIdx++] = 0x80 | (u & 63);
1082
+ } else {
1083
+ if (outIdx + 3 >= endIdx) break;
1084
+ 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).`);
1085
+ heap[outIdx++] = 0xF0 | (u >> 18);
1086
+ heap[outIdx++] = 0x80 | ((u >> 12) & 63);
1087
+ heap[outIdx++] = 0x80 | ((u >> 6) & 63);
1088
+ heap[outIdx++] = 0x80 | (u & 63);
1089
+ // Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
1090
+ // We need to manually skip over the second code unit for correct iteration.
1091
+ i++;
1092
+ }
1093
+ }
1094
+ // Null-terminate the pointer to the buffer.
1095
+ heap[outIdx] = 0;
1096
+ return outIdx - startIdx;
1097
+ };
1098
+ var stringToUTF8 = (str, outPtr, maxBytesToWrite) => {
1099
+ assert(typeof maxBytesToWrite === 'number', 'stringToUTF8 requires a third parameter that specifies the length of the output buffer');
1100
+ return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
1101
+ };
1102
+ var stringToUTF8OnStack = (str) => {
1103
+ var size = lengthBytesUTF8(str) + 1;
1104
+ var ret = stackAlloc(size);
1105
+ stringToUTF8(str, ret, size);
1106
+ return ret;
1107
+ };
1108
+ var writeArrayToMemory = (array, buffer) => {
1109
+ assert(array.length >= 0, 'writeArrayToMemory array must have a length (should be an array or typed array)')
1110
+ HEAP8.set(array, buffer);
1111
+ };
1112
+
1113
+ /**
1114
+ * @param {string|null=} returnType
1115
+ * @param {Array=} argTypes
1116
+ * @param {Array=} args
1117
+ * @param {Object=} opts
1118
+ */
1119
+ var ccall = (ident, returnType, argTypes, args, opts) => {
1120
+ // For fast lookup of conversion functions
1121
+ var toC = {
1122
+ 'string': (str) => {
1123
+ var ret = 0;
1124
+ if (str !== null && str !== undefined && str !== 0) { // null string
1125
+ ret = stringToUTF8OnStack(str);
1126
+ }
1127
+ return ret;
1128
+ },
1129
+ 'array': (arr) => {
1130
+ var ret = stackAlloc(arr.length);
1131
+ writeArrayToMemory(arr, ret);
1132
+ return ret;
1133
+ }
1134
+ };
1135
+
1136
+ function convertReturnValue(ret) {
1137
+ if (returnType === 'string') {
1138
+ return UTF8ToString(ret);
1139
+ }
1140
+ if (returnType === 'boolean') return Boolean(ret);
1141
+ return ret;
1142
+ }
1143
+
1144
+ var func = getCFunc(ident);
1145
+ var cArgs = [];
1146
+ var stack = 0;
1147
+ assert(returnType !== 'array', 'return type should not be "array"');
1148
+ if (args) {
1149
+ for (var i = 0; i < args.length; i++) {
1150
+ var converter = toC[argTypes[i]];
1151
+ if (converter) {
1152
+ if (!stack) stack = stackSave();
1153
+ cArgs[i] = converter(args[i]);
1154
+ } else {
1155
+ cArgs[i] = args[i];
1156
+ }
1157
+ }
1158
+ }
1159
+ var ret = func(...cArgs);
1160
+ function onDone(ret) {
1161
+ if (stack) stackRestore(stack);
1162
+ return convertReturnValue(ret);
1163
+ }
1164
+
1165
+ ret = onDone(ret);
1166
+ return ret;
1167
+ };
1168
+
1169
+ /**
1170
+ * @param {string=} returnType
1171
+ * @param {Array=} argTypes
1172
+ * @param {Object=} opts
1173
+ */
1174
+ var cwrap = (ident, returnType, argTypes, opts) => {
1175
+ return (...args) => ccall(ident, returnType, argTypes, args, opts);
1176
+ };
1177
+
1178
+ var stringToNewUTF8 = (str) => {
1179
+ var size = lengthBytesUTF8(str) + 1;
1180
+ var ret = _malloc(size);
1181
+ if (ret) stringToUTF8(str, ret, size);
1182
+ return ret;
1183
+ };
1184
+ // End JS library code
1185
+
1186
+ // include: postlibrary.js
1187
+ // This file is included after the automatically-generated JS library code
1188
+ // but before the wasm module is created.
1189
+
1190
+ {
1191
+
1192
+ // Begin ATMODULES hooks
1193
+ if (Module['noExitRuntime']) noExitRuntime = Module['noExitRuntime'];
1194
+ if (Module['print']) out = Module['print'];
1195
+ if (Module['printErr']) err = Module['printErr'];
1196
+
1197
+ Module['FS_createDataFile'] = FS.createDataFile;
1198
+ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
1199
+
1200
+ // End ATMODULES hooks
1201
+
1202
+ checkIncomingModuleAPI();
1203
+
1204
+ if (Module['arguments']) programArgs = Module['arguments'];
1205
+ if (Module['thisProgram']) thisProgram = Module['thisProgram'];
1206
+
1207
+ // Assertions on removed incoming Module JS APIs.
1208
+ assert(typeof Module['memoryInitializerPrefixURL'] === 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead');
1209
+ assert(typeof Module['pthreadMainPrefixURL'] === 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead');
1210
+ assert(typeof Module['cdInitializerPrefixURL'] === 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead');
1211
+ assert(typeof Module['filePackagePrefixURL'] === 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead');
1212
+ assert(typeof Module['read'] === 'undefined', 'Module.read option was removed');
1213
+ assert(typeof Module['readAsync'] === 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)');
1214
+ assert(typeof Module['readBinary'] === 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)');
1215
+ assert(typeof Module['setWindowTitle'] === 'undefined', 'Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)');
1216
+ assert(typeof Module['TOTAL_MEMORY'] === 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY');
1217
+ 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)');
1218
+ assert(typeof Module['STACK_SIZE'] === 'undefined', 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time')
1219
+ // If memory is defined in wasm, the user can't provide it, or set INITIAL_MEMORY
1220
+ assert(typeof Module['wasmMemory'] === 'undefined', 'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally');
1221
+ assert(typeof Module['INITIAL_MEMORY'] === 'undefined', 'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically');
1222
+
1223
+ var preInit = Module['preInit'];
1224
+ if (preInit) {
1225
+ if (typeof preInit === 'function') Module['preInit'] = preInit = [preInit];
1226
+ // Written as a loop so that preInit functions that themselves add more
1227
+ // preInit functions. Is this actually needed?
1228
+ while (preInit.length > 0) {
1229
+ preInit.shift()();
1230
+ }
1231
+ }
1232
+ consumedModuleProp('preInit');
1233
+ }
1234
+
1235
+ // Begin runtime exports
1236
+ Module['ccall'] = ccall;
1237
+ Module['cwrap'] = cwrap;
1238
+ Module['UTF8ToString'] = UTF8ToString;
1239
+ Module['stringToNewUTF8'] = stringToNewUTF8;
1240
+ var missingLibrarySymbols = [
1241
+ 'writeI53ToI64',
1242
+ 'writeI53ToI64Clamped',
1243
+ 'writeI53ToI64Signaling',
1244
+ 'writeI53ToU64Clamped',
1245
+ 'writeI53ToU64Signaling',
1246
+ 'readI53FromI64',
1247
+ 'readI53FromU64',
1248
+ 'convertI32PairToI53',
1249
+ 'convertI32PairToI53Checked',
1250
+ 'convertU32PairToI53',
1251
+ 'getTempRet0',
1252
+ 'setTempRet0',
1253
+ 'createNamedFunction',
1254
+ 'zeroMemory',
1255
+ 'exitJS',
1256
+ 'withStackSave',
1257
+ 'strError',
1258
+ 'inetPton4',
1259
+ 'inetNtop4',
1260
+ 'inetPton6',
1261
+ 'inetNtop6',
1262
+ 'readSockaddr',
1263
+ 'writeSockaddr',
1264
+ 'readEmAsmArgs',
1265
+ 'jstoi_q',
1266
+ 'getExecutableName',
1267
+ 'autoResumeAudioContext',
1268
+ 'getDynCaller',
1269
+ 'dynCall',
1270
+ 'getWasmTableEntry',
1271
+ 'handleException',
1272
+ 'keepRuntimeAlive',
1273
+ 'runtimeKeepalivePush',
1274
+ 'runtimeKeepalivePop',
1275
+ 'callUserCallback',
1276
+ 'maybeExit',
1277
+ 'asyncLoad',
1278
+ 'asmjsMangle',
1279
+ 'mmapAlloc',
1280
+ 'HandleAllocator',
1281
+ 'getUniqueRunDependency',
1282
+ 'addRunDependency',
1283
+ 'removeRunDependency',
1284
+ 'addOnInit',
1285
+ 'addOnPostCtor',
1286
+ 'addOnPreMain',
1287
+ 'addOnExit',
1288
+ 'STACK_SIZE',
1289
+ 'STACK_ALIGN',
1290
+ 'POINTER_SIZE',
1291
+ 'ASSERTIONS',
1292
+ 'convertJsFunctionToWasm',
1293
+ 'getEmptyTableSlot',
1294
+ 'updateTableMap',
1295
+ 'getFunctionAddress',
1296
+ 'removeFunction',
1297
+ 'setValue',
1298
+ 'getValue',
1299
+ 'intArrayFromString',
1300
+ 'intArrayToString',
1301
+ 'AsciiToString',
1302
+ 'stringToAscii',
1303
+ 'UTF16ToString',
1304
+ 'stringToUTF16',
1305
+ 'lengthBytesUTF16',
1306
+ 'UTF32ToString',
1307
+ 'stringToUTF32',
1308
+ 'lengthBytesUTF32',
1309
+ 'registerKeyEventCallback',
1310
+ 'maybeCStringToJsString',
1311
+ 'findEventTarget',
1312
+ 'getBoundingClientRect',
1313
+ 'fillMouseEventData',
1314
+ 'registerMouseEventCallback',
1315
+ 'registerWheelEventCallback',
1316
+ 'registerUiEventCallback',
1317
+ 'registerFocusEventCallback',
1318
+ 'fillDeviceOrientationEventData',
1319
+ 'registerDeviceOrientationEventCallback',
1320
+ 'fillDeviceMotionEventData',
1321
+ 'registerDeviceMotionEventCallback',
1322
+ 'screenOrientation',
1323
+ 'fillOrientationChangeEventData',
1324
+ 'registerOrientationChangeEventCallback',
1325
+ 'fillFullscreenChangeEventData',
1326
+ 'registerFullscreenChangeEventCallback',
1327
+ 'callCanvasResizedCallback',
1328
+ 'JSEvents_requestFullscreen',
1329
+ 'JSEvents_resizeCanvasForFullscreen',
1330
+ 'registerRestoreOldStyle',
1331
+ 'hideEverythingExceptGivenElement',
1332
+ 'restoreHiddenElements',
1333
+ 'setLetterbox',
1334
+ 'currentFullscreenStrategy',
1335
+ 'softFullscreenResizeWebGLRenderTarget',
1336
+ 'doRequestFullscreen',
1337
+ 'fillPointerlockChangeEventData',
1338
+ 'registerPointerlockChangeEventCallback',
1339
+ 'registerPointerlockErrorEventCallback',
1340
+ 'requestPointerLock',
1341
+ 'fillVisibilityChangeEventData',
1342
+ 'registerVisibilityChangeEventCallback',
1343
+ 'registerTouchEventCallback',
1344
+ 'fillGamepadEventData',
1345
+ 'registerGamepadEventCallback',
1346
+ 'registerBeforeUnloadEventCallback',
1347
+ 'fillBatteryEventData',
1348
+ 'registerBatteryEventCallback',
1349
+ 'setCanvasElementSize',
1350
+ 'getCanvasElementSize',
1351
+ 'jsStackTrace',
1352
+ 'getCallstack',
1353
+ 'convertPCtoSourceLocation',
1354
+ 'getEnvStrings',
1355
+ 'checkWasiClock',
1356
+ 'wasiRightsToMuslOFlags',
1357
+ 'wasiOFlagsToMuslOFlags',
1358
+ 'initRandomFill',
1359
+ 'randomFill',
1360
+ 'safeSetTimeout',
1361
+ 'safeClearTimeout',
1362
+ 'setImmediateWrapped',
1363
+ 'safeRequestAnimationFrame',
1364
+ 'clearImmediateWrapped',
1365
+ 'registerPostMainLoop',
1366
+ 'registerPreMainLoop',
1367
+ 'getPromise',
1368
+ 'makePromise',
1369
+ 'addPromise',
1370
+ 'idsToPromises',
1371
+ 'makePromiseCallback',
1372
+ 'Browser_asyncPrepareDataCounter',
1373
+ 'isLeapYear',
1374
+ 'ydayFromDate',
1375
+ 'arraySum',
1376
+ 'addDays',
1377
+ 'getSocketFromFD',
1378
+ 'getSocketAddress',
1379
+ 'FS_createPreloadedFile',
1380
+ 'FS_preloadFile',
1381
+ 'FS_modeStringToFlags',
1382
+ 'FS_getMode',
1383
+ 'FS_fileDataToTypedArray',
1384
+ 'FS_stdin_getChar',
1385
+ 'FS_mkdirTree',
1386
+ '_setNetworkCallback',
1387
+ 'heapObjectForWebGLType',
1388
+ 'toTypedArrayIndex',
1389
+ 'webgl_enable_ANGLE_instanced_arrays',
1390
+ 'webgl_enable_OES_vertex_array_object',
1391
+ 'webgl_enable_WEBGL_draw_buffers',
1392
+ 'webgl_enable_WEBGL_multi_draw',
1393
+ 'webgl_enable_EXT_polygon_offset_clamp',
1394
+ 'webgl_enable_EXT_clip_control',
1395
+ 'webgl_enable_WEBGL_polygon_mode',
1396
+ 'emscriptenWebGLGet',
1397
+ 'computeUnpackAlignedImageSize',
1398
+ 'colorChannelsInGlTextureFormat',
1399
+ 'emscriptenWebGLGetTexPixelData',
1400
+ 'emscriptenWebGLGetUniform',
1401
+ 'webglGetProgramUniformLocation',
1402
+ 'webglGetUniformLocation',
1403
+ 'webglPrepareUniformLocationsBeforeFirstUse',
1404
+ 'webglGetLeftBracePos',
1405
+ 'emscriptenWebGLGetVertexAttrib',
1406
+ '__glGetActiveAttribOrUniform',
1407
+ 'writeGLArray',
1408
+ 'registerWebGlEventCallback',
1409
+ 'runAndAbortIfError',
1410
+ 'writeStringToMemory',
1411
+ 'writeAsciiToMemory',
1412
+ 'allocateUTF8',
1413
+ 'allocateUTF8OnStack',
1414
+ 'stackTrace',
1415
+ 'getNativeTypeSize',
1416
+ ];
1417
+ missingLibrarySymbols.forEach(missingLibrarySymbol)
1418
+
1419
+ var unexportedSymbols = [
1420
+ 'run',
1421
+ 'out',
1422
+ 'err',
1423
+ 'callMain',
1424
+ 'abort',
1425
+ 'wasmExports',
1426
+ 'writeStackCookie',
1427
+ 'checkStackCookie',
1428
+ 'INT53_MAX',
1429
+ 'INT53_MIN',
1430
+ 'bigintToI53Checked',
1431
+ 'HEAP8',
1432
+ 'HEAPU8',
1433
+ 'HEAP16',
1434
+ 'HEAPU16',
1435
+ 'HEAP32',
1436
+ 'HEAPU32',
1437
+ 'HEAPF32',
1438
+ 'HEAPF64',
1439
+ 'HEAP64',
1440
+ 'HEAPU64',
1441
+ 'stackSave',
1442
+ 'stackRestore',
1443
+ 'stackAlloc',
1444
+ 'ptrToString',
1445
+ 'getHeapMax',
1446
+ 'growMemory',
1447
+ 'ENV',
1448
+ 'setStackLimits',
1449
+ 'ERRNO_CODES',
1450
+ 'DNS',
1451
+ 'Protocols',
1452
+ 'timers',
1453
+ 'warnOnce',
1454
+ 'readEmAsmArgsArray',
1455
+ 'alignMemory',
1456
+ 'wasmTable',
1457
+ 'wasmMemory',
1458
+ 'noExitRuntime',
1459
+ 'addOnPreRun',
1460
+ 'addOnPostRun',
1461
+ 'freeTableIndexes',
1462
+ 'functionsInTableMap',
1463
+ 'addFunction',
1464
+ 'PATH',
1465
+ 'PATH_FS',
1466
+ 'UTF8Decoder',
1467
+ 'UTF8ArrayToString',
1468
+ 'stringToUTF8Array',
1469
+ 'stringToUTF8',
1470
+ 'lengthBytesUTF8',
1471
+ 'UTF16Decoder',
1472
+ 'stringToUTF8OnStack',
1473
+ 'writeArrayToMemory',
1474
+ 'JSEvents',
1475
+ 'specialHTMLTargets',
1476
+ 'findCanvasEventTarget',
1477
+ 'restoreOldWindowedStyle',
1478
+ 'UNWIND_CACHE',
1479
+ 'ExitStatus',
1480
+ 'flush_NO_FILESYSTEM',
1481
+ 'emSetImmediate',
1482
+ 'emClearImmediate',
1483
+ 'promiseMap',
1484
+ 'Browser',
1485
+ 'requestFullscreen',
1486
+ 'setCanvasSize',
1487
+ 'createContext',
1488
+ 'wget',
1489
+ 'MONTH_DAYS_REGULAR',
1490
+ 'MONTH_DAYS_LEAP',
1491
+ 'MONTH_DAYS_REGULAR_CUMULATIVE',
1492
+ 'MONTH_DAYS_LEAP_CUMULATIVE',
1493
+ 'SYSCALLS',
1494
+ 'preloadPlugins',
1495
+ 'FS_stdin_getChar_buffer',
1496
+ 'FS_unlink',
1497
+ 'FS_createPath',
1498
+ 'FS_createDevice',
1499
+ 'FS_readFile',
1500
+ 'FS',
1501
+ 'FS_lookupPath',
1502
+ 'FS_getPath',
1503
+ 'FS_hashName',
1504
+ 'FS_hashAddNode',
1505
+ 'FS_hashRemoveNode',
1506
+ 'FS_lookupNode',
1507
+ 'FS_createNode',
1508
+ 'FS_destroyNode',
1509
+ 'FS_isRoot',
1510
+ 'FS_isMountpoint',
1511
+ 'FS_isFile',
1512
+ 'FS_isDir',
1513
+ 'FS_isLink',
1514
+ 'FS_isChrdev',
1515
+ 'FS_isBlkdev',
1516
+ 'FS_isFIFO',
1517
+ 'FS_isSocket',
1518
+ 'FS_flagsToPermissionString',
1519
+ 'FS_nodePermissions',
1520
+ 'FS_mayLookup',
1521
+ 'FS_mayCreate',
1522
+ 'FS_mayDelete',
1523
+ 'FS_mayOpen',
1524
+ 'FS_checkOpExists',
1525
+ 'FS_nextfd',
1526
+ 'FS_getStreamChecked',
1527
+ 'FS_getStream',
1528
+ 'FS_createStream',
1529
+ 'FS_closeStream',
1530
+ 'FS_dupStream',
1531
+ 'FS_doSetAttr',
1532
+ 'FS_major',
1533
+ 'FS_minor',
1534
+ 'FS_makedev',
1535
+ 'FS_registerDevice',
1536
+ 'FS_getDevice',
1537
+ 'FS_getMounts',
1538
+ 'FS_syncfs',
1539
+ 'FS_mount',
1540
+ 'FS_unmount',
1541
+ 'FS_lookup',
1542
+ 'FS_mknod',
1543
+ 'FS_statfs',
1544
+ 'FS_statfsStream',
1545
+ 'FS_statfsNode',
1546
+ 'FS_create',
1547
+ 'FS_mkdir',
1548
+ 'FS_mkdev',
1549
+ 'FS_symlink',
1550
+ 'FS_link',
1551
+ 'FS_rename',
1552
+ 'FS_rmdir',
1553
+ 'FS_readdir',
1554
+ 'FS_readlink',
1555
+ 'FS_stat',
1556
+ 'FS_fstat',
1557
+ 'FS_lstat',
1558
+ 'FS_doChmod',
1559
+ 'FS_chmod',
1560
+ 'FS_lchmod',
1561
+ 'FS_fchmod',
1562
+ 'FS_doChown',
1563
+ 'FS_chown',
1564
+ 'FS_lchown',
1565
+ 'FS_fchown',
1566
+ 'FS_doTruncate',
1567
+ 'FS_truncate',
1568
+ 'FS_ftruncate',
1569
+ 'FS_utime',
1570
+ 'FS_open',
1571
+ 'FS_close',
1572
+ 'FS_isClosed',
1573
+ 'FS_llseek',
1574
+ 'FS_read',
1575
+ 'FS_write',
1576
+ 'FS_mmap',
1577
+ 'FS_msync',
1578
+ 'FS_ioctl',
1579
+ 'FS_writeFile',
1580
+ 'FS_cwd',
1581
+ 'FS_chdir',
1582
+ 'FS_createDefaultDirectories',
1583
+ 'FS_createDefaultDevices',
1584
+ 'FS_createSpecialDirectories',
1585
+ 'FS_createStandardStreams',
1586
+ 'FS_staticInit',
1587
+ 'FS_init',
1588
+ 'FS_quit',
1589
+ 'FS_analyzePath',
1590
+ 'FS_createFile',
1591
+ 'FS_createDataFile',
1592
+ 'FS_forceLoadFile',
1593
+ 'FS_createLazyFile',
1594
+ 'MEMFS',
1595
+ 'TTY',
1596
+ 'PIPEFS',
1597
+ 'SOCKFS',
1598
+ 'tempFixedLengthArray',
1599
+ 'miniTempWebGLFloatBuffers',
1600
+ 'miniTempWebGLIntBuffers',
1601
+ 'GL',
1602
+ 'AL',
1603
+ 'GLUT',
1604
+ 'EGL',
1605
+ 'GLEW',
1606
+ 'IDBStore',
1607
+ 'SDL',
1608
+ 'SDL_gfx',
1609
+ 'print',
1610
+ 'printErr',
1611
+ 'jstoi_s',
1612
+ ];
1613
+ unexportedSymbols.forEach(unexportedRuntimeSymbol);
1614
+
1615
+ // End runtime exports
1616
+ // Begin JS library exports
1617
+ // End JS library exports
1618
+
1619
+ // end include: postlibrary.js
1620
+
1621
+ function checkIncomingModuleAPI() {
1622
+ ignoredModuleProp('fetchSettings');
1623
+ ignoredModuleProp('logReadFiles');
1624
+ ignoredModuleProp('loadSplitModule');
1625
+ ignoredModuleProp('onMalloc');
1626
+ ignoredModuleProp('onRealloc');
1627
+ ignoredModuleProp('onFree');
1628
+ ignoredModuleProp('onSbrkGrow');
1629
+ ignoredModuleProp('onCOSCacheHit');
1630
+ ignoredModuleProp('onCOSCacheMiss');
1631
+ ignoredModuleProp('onCOSStore');
1632
+ ignoredModuleProp('GL_MAX_TEXTURE_IMAGE_UNITS');
1633
+ ignoredModuleProp('SDL_canPlayWithWebAudio');
1634
+ ignoredModuleProp('SDL_numSimultaneouslyQueuedBuffers');
1635
+ ignoredModuleProp('freePreloadedMediaOnUse');
1636
+ ignoredModuleProp('preinitializedWebGLContext');
1637
+ ignoredModuleProp('keyboardListeningElement');
1638
+ ignoredModuleProp('doNotCaptureKeyboard');
1639
+ ignoredModuleProp('extraStackTrace');
1640
+ ignoredModuleProp('preloadPlugins');
1641
+ ignoredModuleProp('preMainLoop');
1642
+ ignoredModuleProp('postMainLoop');
1643
+ ignoredModuleProp('forcedAspectRatio');
1644
+ ignoredModuleProp('mainScriptUrlOrBlob');
1645
+ ignoredModuleProp('onFullScreen');
1646
+ ignoredModuleProp('INITIAL_MEMORY');
1647
+ ignoredModuleProp('wasmMemory');
1648
+ ignoredModuleProp('wasmBinary');
1649
+ }
1650
+
1651
+ // Imports from the Wasm binary.
1652
+ var _newResourceLocation = Module['_newResourceLocation'] = makeInvalidEarlyAccess('_newResourceLocation');
1653
+ var _resourceLocationToString = Module['_resourceLocationToString'] = makeInvalidEarlyAccess('_resourceLocationToString');
1654
+ var _freeResourceLocation = Module['_freeResourceLocation'] = makeInvalidEarlyAccess('_freeResourceLocation');
1655
+ var _getSemVer2_0_0Comparator = Module['_getSemVer2_0_0Comparator'] = makeInvalidEarlyAccess('_getSemVer2_0_0Comparator');
1656
+ var _applyVersionComparator = Module['_applyVersionComparator'] = makeInvalidEarlyAccess('_applyVersionComparator');
1657
+ var _newVersionComparator = Module['_newVersionComparator'] = makeInvalidEarlyAccess('_newVersionComparator');
1658
+ var _freeVersionComparator = Module['_freeVersionComparator'] = makeInvalidEarlyAccess('_freeVersionComparator');
1659
+ var _newModule = Module['_newModule'] = makeInvalidEarlyAccess('_newModule');
1660
+ var _moduleToString = Module['_moduleToString'] = makeInvalidEarlyAccess('_moduleToString');
1661
+ var _freeModule = Module['_freeModule'] = makeInvalidEarlyAccess('_freeModule');
1662
+ var _newVersion = Module['_newVersion'] = makeInvalidEarlyAccess('_newVersion');
1663
+ var _versionToString = Module['_versionToString'] = makeInvalidEarlyAccess('_versionToString');
1664
+ var _freeVersion = Module['_freeVersion'] = makeInvalidEarlyAccess('_freeVersion');
1665
+ var _versionComparatorToString = Module['_versionComparatorToString'] = makeInvalidEarlyAccess('_versionComparatorToString');
1666
+ var _newDependencyDict = Module['_newDependencyDict'] = makeInvalidEarlyAccess('_newDependencyDict');
1667
+ var _addToDependencyDict = Module['_addToDependencyDict'] = makeInvalidEarlyAccess('_addToDependencyDict');
1668
+ var _removeFromDependencyDictAndFree = Module['_removeFromDependencyDictAndFree'] = makeInvalidEarlyAccess('_removeFromDependencyDictAndFree');
1669
+ var _dependencyDictToString = Module['_dependencyDictToString'] = makeInvalidEarlyAccess('_dependencyDictToString');
1670
+ var _dependencyDictElementToString = Module['_dependencyDictElementToString'] = makeInvalidEarlyAccess('_dependencyDictElementToString');
1671
+ var _freeDependencyDict = Module['_freeDependencyDict'] = makeInvalidEarlyAccess('_freeDependencyDict');
1672
+ var _initLibraryApi = Module['_initLibraryApi'] = makeInvalidEarlyAccess('_initLibraryApi');
1673
+ var _freeLitLaunchLibraryApi = Module['_freeLitLaunchLibraryApi'] = makeInvalidEarlyAccess('_freeLitLaunchLibraryApi');
1674
+ var _fflush = makeInvalidEarlyAccess('_fflush');
1675
+ var _strerror = makeInvalidEarlyAccess('_strerror');
1676
+ var _malloc = Module['_malloc'] = makeInvalidEarlyAccess('_malloc');
1677
+ var _free = Module['_free'] = makeInvalidEarlyAccess('_free');
1678
+ var _setThrew = makeInvalidEarlyAccess('_setThrew');
1679
+ var _emscripten_stack_init = makeInvalidEarlyAccess('_emscripten_stack_init');
1680
+ var _emscripten_stack_get_free = makeInvalidEarlyAccess('_emscripten_stack_get_free');
1681
+ var _emscripten_stack_get_base = makeInvalidEarlyAccess('_emscripten_stack_get_base');
1682
+ var _emscripten_stack_get_end = makeInvalidEarlyAccess('_emscripten_stack_get_end');
1683
+ var __emscripten_stack_restore = makeInvalidEarlyAccess('__emscripten_stack_restore');
1684
+ var __emscripten_stack_alloc = makeInvalidEarlyAccess('__emscripten_stack_alloc');
1685
+ var _emscripten_stack_get_current = makeInvalidEarlyAccess('_emscripten_stack_get_current');
1686
+ var ___set_stack_limits = Module['___set_stack_limits'] = makeInvalidEarlyAccess('___set_stack_limits');
1687
+ var memory = makeInvalidEarlyAccess('memory');
1688
+ var __indirect_function_table = makeInvalidEarlyAccess('__indirect_function_table');
1689
+ var wasmMemory = makeInvalidEarlyAccess('wasmMemory');
1690
+
1691
+ function assignWasmExports(wasmExports) {
1692
+ assert(typeof wasmExports['newResourceLocation'] !== 'undefined', 'missing Wasm export: newResourceLocation');
1693
+ assert(typeof wasmExports['resourceLocationToString'] !== 'undefined', 'missing Wasm export: resourceLocationToString');
1694
+ assert(typeof wasmExports['freeResourceLocation'] !== 'undefined', 'missing Wasm export: freeResourceLocation');
1695
+ assert(typeof wasmExports['getSemVer2_0_0Comparator'] !== 'undefined', 'missing Wasm export: getSemVer2_0_0Comparator');
1696
+ assert(typeof wasmExports['applyVersionComparator'] !== 'undefined', 'missing Wasm export: applyVersionComparator');
1697
+ assert(typeof wasmExports['newVersionComparator'] !== 'undefined', 'missing Wasm export: newVersionComparator');
1698
+ assert(typeof wasmExports['freeVersionComparator'] !== 'undefined', 'missing Wasm export: freeVersionComparator');
1699
+ assert(typeof wasmExports['newModule'] !== 'undefined', 'missing Wasm export: newModule');
1700
+ assert(typeof wasmExports['moduleToString'] !== 'undefined', 'missing Wasm export: moduleToString');
1701
+ assert(typeof wasmExports['freeModule'] !== 'undefined', 'missing Wasm export: freeModule');
1702
+ assert(typeof wasmExports['newVersion'] !== 'undefined', 'missing Wasm export: newVersion');
1703
+ assert(typeof wasmExports['versionToString'] !== 'undefined', 'missing Wasm export: versionToString');
1704
+ assert(typeof wasmExports['freeVersion'] !== 'undefined', 'missing Wasm export: freeVersion');
1705
+ assert(typeof wasmExports['versionComparatorToString'] !== 'undefined', 'missing Wasm export: versionComparatorToString');
1706
+ assert(typeof wasmExports['newDependencyDict'] !== 'undefined', 'missing Wasm export: newDependencyDict');
1707
+ assert(typeof wasmExports['addToDependencyDict'] !== 'undefined', 'missing Wasm export: addToDependencyDict');
1708
+ assert(typeof wasmExports['removeFromDependencyDictAndFree'] !== 'undefined', 'missing Wasm export: removeFromDependencyDictAndFree');
1709
+ assert(typeof wasmExports['dependencyDictToString'] !== 'undefined', 'missing Wasm export: dependencyDictToString');
1710
+ assert(typeof wasmExports['dependencyDictElementToString'] !== 'undefined', 'missing Wasm export: dependencyDictElementToString');
1711
+ assert(typeof wasmExports['freeDependencyDict'] !== 'undefined', 'missing Wasm export: freeDependencyDict');
1712
+ assert(typeof wasmExports['initLibraryApi'] !== 'undefined', 'missing Wasm export: initLibraryApi');
1713
+ assert(typeof wasmExports['freeLitLaunchLibraryApi'] !== 'undefined', 'missing Wasm export: freeLitLaunchLibraryApi');
1714
+ assert(typeof wasmExports['fflush'] !== 'undefined', 'missing Wasm export: fflush');
1715
+ assert(typeof wasmExports['strerror'] !== 'undefined', 'missing Wasm export: strerror');
1716
+ assert(typeof wasmExports['malloc'] !== 'undefined', 'missing Wasm export: malloc');
1717
+ assert(typeof wasmExports['free'] !== 'undefined', 'missing Wasm export: free');
1718
+ assert(typeof wasmExports['setThrew'] !== 'undefined', 'missing Wasm export: setThrew');
1719
+ assert(typeof wasmExports['emscripten_stack_init'] !== 'undefined', 'missing Wasm export: emscripten_stack_init');
1720
+ assert(typeof wasmExports['emscripten_stack_get_free'] !== 'undefined', 'missing Wasm export: emscripten_stack_get_free');
1721
+ assert(typeof wasmExports['emscripten_stack_get_base'] !== 'undefined', 'missing Wasm export: emscripten_stack_get_base');
1722
+ assert(typeof wasmExports['emscripten_stack_get_end'] !== 'undefined', 'missing Wasm export: emscripten_stack_get_end');
1723
+ assert(typeof wasmExports['_emscripten_stack_restore'] !== 'undefined', 'missing Wasm export: _emscripten_stack_restore');
1724
+ assert(typeof wasmExports['_emscripten_stack_alloc'] !== 'undefined', 'missing Wasm export: _emscripten_stack_alloc');
1725
+ assert(typeof wasmExports['emscripten_stack_get_current'] !== 'undefined', 'missing Wasm export: emscripten_stack_get_current');
1726
+ assert(typeof wasmExports['__set_stack_limits'] !== 'undefined', 'missing Wasm export: __set_stack_limits');
1727
+ assert(typeof wasmExports['memory'] !== 'undefined', 'missing Wasm export: memory');
1728
+ assert(typeof wasmExports['__indirect_function_table'] !== 'undefined', 'missing Wasm export: __indirect_function_table');
1729
+ _newResourceLocation = Module['_newResourceLocation'] = createExportWrapper('newResourceLocation', wasmExports['newResourceLocation'], 2);
1730
+ _resourceLocationToString = Module['_resourceLocationToString'] = createExportWrapper('resourceLocationToString', wasmExports['resourceLocationToString'], 1);
1731
+ _freeResourceLocation = Module['_freeResourceLocation'] = createExportWrapper('freeResourceLocation', wasmExports['freeResourceLocation'], 1);
1732
+ _getSemVer2_0_0Comparator = Module['_getSemVer2_0_0Comparator'] = createExportWrapper('getSemVer2_0_0Comparator', wasmExports['getSemVer2_0_0Comparator'], 0);
1733
+ _applyVersionComparator = Module['_applyVersionComparator'] = createExportWrapper('applyVersionComparator', wasmExports['applyVersionComparator'], 3);
1734
+ _newVersionComparator = Module['_newVersionComparator'] = createExportWrapper('newVersionComparator', wasmExports['newVersionComparator'], 2);
1735
+ _freeVersionComparator = Module['_freeVersionComparator'] = createExportWrapper('freeVersionComparator', wasmExports['freeVersionComparator'], 1);
1736
+ _newModule = Module['_newModule'] = createExportWrapper('newModule', wasmExports['newModule'], 3);
1737
+ _moduleToString = Module['_moduleToString'] = createExportWrapper('moduleToString', wasmExports['moduleToString'], 1);
1738
+ _freeModule = Module['_freeModule'] = createExportWrapper('freeModule', wasmExports['freeModule'], 1);
1739
+ _newVersion = Module['_newVersion'] = createExportWrapper('newVersion', wasmExports['newVersion'], 2);
1740
+ _versionToString = Module['_versionToString'] = createExportWrapper('versionToString', wasmExports['versionToString'], 1);
1741
+ _freeVersion = Module['_freeVersion'] = createExportWrapper('freeVersion', wasmExports['freeVersion'], 1);
1742
+ _versionComparatorToString = Module['_versionComparatorToString'] = createExportWrapper('versionComparatorToString', wasmExports['versionComparatorToString'], 1);
1743
+ _newDependencyDict = Module['_newDependencyDict'] = createExportWrapper('newDependencyDict', wasmExports['newDependencyDict'], 1);
1744
+ _addToDependencyDict = Module['_addToDependencyDict'] = createExportWrapper('addToDependencyDict', wasmExports['addToDependencyDict'], 6);
1745
+ _removeFromDependencyDictAndFree = Module['_removeFromDependencyDictAndFree'] = createExportWrapper('removeFromDependencyDictAndFree', wasmExports['removeFromDependencyDictAndFree'], 2);
1746
+ _dependencyDictToString = Module['_dependencyDictToString'] = createExportWrapper('dependencyDictToString', wasmExports['dependencyDictToString'], 1);
1747
+ _dependencyDictElementToString = Module['_dependencyDictElementToString'] = createExportWrapper('dependencyDictElementToString', wasmExports['dependencyDictElementToString'], 1);
1748
+ _freeDependencyDict = Module['_freeDependencyDict'] = createExportWrapper('freeDependencyDict', wasmExports['freeDependencyDict'], 1);
1749
+ _initLibraryApi = Module['_initLibraryApi'] = createExportWrapper('initLibraryApi', wasmExports['initLibraryApi'], 0);
1750
+ _freeLitLaunchLibraryApi = Module['_freeLitLaunchLibraryApi'] = createExportWrapper('freeLitLaunchLibraryApi', wasmExports['freeLitLaunchLibraryApi'], 1);
1751
+ _fflush = createExportWrapper('fflush', wasmExports['fflush'], 1);
1752
+ _strerror = createExportWrapper('strerror', wasmExports['strerror'], 1);
1753
+ _malloc = Module['_malloc'] = createExportWrapper('malloc', wasmExports['malloc'], 1);
1754
+ _free = Module['_free'] = createExportWrapper('free', wasmExports['free'], 1);
1755
+ _setThrew = createExportWrapper('setThrew', wasmExports['setThrew'], 2);
1756
+ _emscripten_stack_init = wasmExports['emscripten_stack_init'];
1757
+ _emscripten_stack_get_free = wasmExports['emscripten_stack_get_free'];
1758
+ _emscripten_stack_get_base = wasmExports['emscripten_stack_get_base'];
1759
+ _emscripten_stack_get_end = wasmExports['emscripten_stack_get_end'];
1760
+ __emscripten_stack_restore = wasmExports['_emscripten_stack_restore'];
1761
+ __emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc'];
1762
+ _emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'];
1763
+ ___set_stack_limits = Module['___set_stack_limits'] = createExportWrapper('__set_stack_limits', wasmExports['__set_stack_limits'], 2);
1764
+ memory = wasmMemory = wasmExports['memory'];
1765
+ __indirect_function_table = wasmExports['__indirect_function_table'];
1766
+ }
1767
+
1768
+ var wasmImports = {
1769
+ /** @export */
1770
+ __assert_fail: ___assert_fail,
1771
+ /** @export */
1772
+ __handle_stack_overflow: ___handle_stack_overflow,
1773
+ /** @export */
1774
+ _abort_js: __abort_js,
1775
+ /** @export */
1776
+ emscripten_resize_heap: _emscripten_resize_heap,
1777
+ /** @export */
1778
+ fd_close: _fd_close,
1779
+ /** @export */
1780
+ fd_seek: _fd_seek,
1781
+ /** @export */
1782
+ fd_write: _fd_write
1783
+ };
1784
+
1785
+
1786
+ // include: postamble.js
1787
+ // === Auto-generated postamble setup entry stuff ===
1788
+
1789
+ var calledRun;
1790
+
1791
+ function stackCheckInit() {
1792
+ // This is normally called automatically during __wasm_call_ctors but need to
1793
+ // get these values before even running any of the ctors so we call it redundantly
1794
+ // here.
1795
+ _emscripten_stack_init();
1796
+ // TODO(sbc): Move writeStackCookie to native to to avoid this.
1797
+ writeStackCookie();
1798
+ }
1799
+
1800
+ async function run() {
1801
+ assert(!calledRun);
1802
+ calledRun = true;
1803
+
1804
+ stackCheckInit();
1805
+
1806
+ preRun();
1807
+
1808
+ var setStatus = Module['setStatus'];
1809
+ if (setStatus) {
1810
+ setStatus('Running...');
1811
+ // Yield to the event loop to allow the browser to paint "Running..."
1812
+ await new Promise((resolve) => setTimeout(resolve, 1));
1813
+ // Then we want to clear the status text, but only after the rest of this function runs.
1814
+ setTimeout(setStatus, 1, '');
1815
+ }
1816
+
1817
+ if (ABORT) return;
1818
+
1819
+ initRuntime();
1820
+
1821
+ Module['onRuntimeInitialized']?.();
1822
+ consumedModuleProp('onRuntimeInitialized');
1823
+
1824
+ assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');
1825
+
1826
+ postRun();
1827
+ }
1828
+
1829
+ function checkUnflushedContent() {
1830
+ // Compiler settings do not allow exiting the runtime, so flushing
1831
+ // the streams is not possible. but in ASSERTIONS mode we check
1832
+ // if there was something to flush, and if so tell the user they
1833
+ // should request that the runtime be exitable.
1834
+ // Normally we would not even include flush() at all, but in ASSERTIONS
1835
+ // builds we do so just for this check, and here we see if there is any
1836
+ // content to flush, that is, we check if there would have been
1837
+ // something a non-ASSERTIONS build would have not seen.
1838
+ // How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0
1839
+ // mode (which has its own special function for this; otherwise, all
1840
+ // the code is inside libc)
1841
+ var oldOut = out;
1842
+ var oldErr = err;
1843
+ var has = false;
1844
+ out = err = (x) => {
1845
+ has = true;
1846
+ }
1847
+ try { // it doesn't matter if it fails
1848
+ flush_NO_FILESYSTEM();
1849
+ } catch(e) {}
1850
+ out = oldOut;
1851
+ err = oldErr;
1852
+ if (has) {
1853
+ 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.');
1854
+ warnOnce('(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)');
1855
+ }
1856
+ }
1857
+
1858
+ var wasmExports;
1859
+
1860
+ // In modularize mode the generated code is within a factory function so we
1861
+ // can use await here (since it's not top-level-await).
1862
+ wasmExports = await createWasm();
1863
+ await run();
1864
+
1865
+ // end include: postamble.js
1866
+
1867
+ // include: postamble_modularize.js
1868
+ // In MODULARIZE mode we wrap the generated code in a factory function
1869
+ // and return either the Module itself, or a promise of the module.
1870
+
1871
+ // Assertion for attempting to access module properties on the incoming
1872
+ // moduleArg. In the past we used this object as the prototype of the module
1873
+ // and assigned properties to it, but now we return a distinct object. This
1874
+ // keeps the instance private until it is ready (i.e the promise has been
1875
+ // resolved).
1876
+ for (const prop of Object.keys(Module)) {
1877
+ if (!(prop in moduleArg)) {
1878
+ Object.defineProperty(moduleArg, prop, {
1879
+ configurable: true,
1880
+ get() {
1881
+ abort(`Access to module property ('${prop}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)
1882
+ }
1883
+ });
1884
+ }
1885
+ }
1886
+ // end include: postamble_modularize.js
1887
+
1888
+
1889
+
1890
+ return Module;
1891
+ }
1892
+
1893
+ // Export using a UMD style export, or ES6 exports if selected
1894
+ export default LitLaunchLibraryApi;
1895
+