sp-graph-layout 0.0.1

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,3855 @@
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 targetting 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 GraphLayoutWASMModule(moduleArg = {}) {
7
+ var moduleRtn;
8
+
9
+ // include: shell.js
10
+ // include: minimum_runtime_check.js
11
+ (function() {
12
+ // "30.0.0" -> 300000
13
+ function humanReadableVersionToPacked(str) {
14
+ str = str.split('-')[0]; // Remove any trailing part from e.g. "12.53.3-alpha"
15
+ var vers = str.split('.').slice(0, 3);
16
+ while(vers.length < 3) vers.push('00');
17
+ vers = vers.map((n, i, arr) => n.padStart(2, '0'));
18
+ return vers.join('');
19
+ }
20
+ // 300000 -> "30.0.0"
21
+ var packedVersionToHumanReadable = n => [n / 10000 | 0, (n / 100 | 0) % 100, n % 100].join('.');
22
+
23
+ var TARGET_NOT_SUPPORTED = 2147483647;
24
+
25
+ // Note: We use a typeof check here instead of optional chaining using
26
+ // globalThis because older browsers might not have globalThis defined.
27
+ var currentNodeVersion = typeof process !== 'undefined' && process.versions?.node ? humanReadableVersionToPacked(process.versions.node) : TARGET_NOT_SUPPORTED;
28
+ if (currentNodeVersion < 160000) {
29
+ throw new Error(`This emscripten-generated code requires node v${ packedVersionToHumanReadable(160000) } (detected v${packedVersionToHumanReadable(currentNodeVersion)})`);
30
+ }
31
+
32
+ var userAgent = typeof navigator !== 'undefined' && navigator.userAgent;
33
+ if (!userAgent) {
34
+ return;
35
+ }
36
+
37
+ var currentSafariVersion = userAgent.includes("Safari/") && userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/) ? humanReadableVersionToPacked(userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/)[1]) : TARGET_NOT_SUPPORTED;
38
+ if (currentSafariVersion < 150000) {
39
+ throw new Error(`This emscripten-generated code requires Safari v${ packedVersionToHumanReadable(150000) } (detected v${currentSafariVersion})`);
40
+ }
41
+
42
+ var currentFirefoxVersion = userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/) ? parseFloat(userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/)[1]) : TARGET_NOT_SUPPORTED;
43
+ if (currentFirefoxVersion < 79) {
44
+ throw new Error(`This emscripten-generated code requires Firefox v79 (detected v${currentFirefoxVersion})`);
45
+ }
46
+
47
+ var currentChromeVersion = userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/) ? parseFloat(userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/)[1]) : TARGET_NOT_SUPPORTED;
48
+ if (currentChromeVersion < 85) {
49
+ throw new Error(`This emscripten-generated code requires Chrome v85 (detected v${currentChromeVersion})`);
50
+ }
51
+ })();
52
+
53
+ // end include: minimum_runtime_check.js
54
+ // The Module object: Our interface to the outside world. We import
55
+ // and export values on it. There are various ways Module can be used:
56
+ // 1. Not defined. We create it here
57
+ // 2. A function parameter, function(moduleArg) => Promise<Module>
58
+ // 3. pre-run appended it, var Module = {}; ..generated code..
59
+ // 4. External script tag defines var Module.
60
+ // We need to check if Module already exists (e.g. case 3 above).
61
+ // Substitution will be replaced with actual code on later stage of the build,
62
+ // this way Closure Compiler will not mangle it (e.g. case 4. above).
63
+ // Note that if you want to run closure, and also to use Module
64
+ // after the generated code, you will need to define var Module = {};
65
+ // before the code. Then that object will be used in the code, and you
66
+ // can continue to use Module afterwards as well.
67
+ var Module = moduleArg;
68
+
69
+ // Determine the runtime environment we are in. You can customize this by
70
+ // setting the ENVIRONMENT setting at compile time (see settings.js).
71
+
72
+ // Attempt to auto-detect the environment
73
+ var ENVIRONMENT_IS_WEB = !!globalThis.window;
74
+ var ENVIRONMENT_IS_WORKER = !!globalThis.WorkerGlobalScope;
75
+ // N.b. Electron.js environment is simultaneously a NODE-environment, but
76
+ // also a web environment.
77
+ var ENVIRONMENT_IS_NODE = globalThis.process?.versions?.node && globalThis.process?.type != 'renderer';
78
+ var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
79
+
80
+ if (ENVIRONMENT_IS_NODE) {
81
+ // When building an ES module `require` is not normally available.
82
+ // We need to use `createRequire()` to construct the require()` function.
83
+ const { createRequire } = await import('module');
84
+ /** @suppress{duplicate} */
85
+ var require = createRequire(import.meta.url);
86
+
87
+ }
88
+
89
+ // --pre-jses are emitted after the Module integration code, so that they can
90
+ // refer to Module (if they choose; they can also define Module)
91
+
92
+
93
+ var arguments_ = [];
94
+ var thisProgram = './this.program';
95
+ var quit_ = (status, toThrow) => {
96
+ throw toThrow;
97
+ };
98
+
99
+ var _scriptName = import.meta.url;
100
+
101
+ // `/` should be present at the end if `scriptDirectory` is not empty
102
+ var scriptDirectory = '';
103
+ function locateFile(path) {
104
+ if (Module['locateFile']) {
105
+ return Module['locateFile'](path, scriptDirectory);
106
+ }
107
+ return scriptDirectory + path;
108
+ }
109
+
110
+ // Hooks that are implemented differently in different runtime environments.
111
+ var readAsync, readBinary;
112
+
113
+ if (ENVIRONMENT_IS_NODE) {
114
+ const isNode = globalThis.process?.versions?.node && globalThis.process?.type != 'renderer';
115
+ 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?)');
116
+
117
+ // These modules will usually be used on Node.js. Load them eagerly to avoid
118
+ // the complexity of lazy-loading.
119
+ var fs = require('fs');
120
+
121
+ if (_scriptName.startsWith('file:')) {
122
+ scriptDirectory = require('path').dirname(require('url').fileURLToPath(_scriptName)) + '/';
123
+ }
124
+
125
+ // include: node_shell_read.js
126
+ readBinary = (filename) => {
127
+ // We need to re-wrap `file://` strings to URLs.
128
+ filename = isFileURI(filename) ? new URL(filename) : filename;
129
+ var ret = fs.readFileSync(filename);
130
+ assert(Buffer.isBuffer(ret));
131
+ return ret;
132
+ };
133
+
134
+ readAsync = async (filename, binary = true) => {
135
+ // See the comment in the `readBinary` function.
136
+ filename = isFileURI(filename) ? new URL(filename) : filename;
137
+ var ret = fs.readFileSync(filename, binary ? undefined : 'utf8');
138
+ assert(binary ? Buffer.isBuffer(ret) : typeof ret == 'string');
139
+ return ret;
140
+ };
141
+ // end include: node_shell_read.js
142
+ if (process.argv.length > 1) {
143
+ thisProgram = process.argv[1].replace(/\\/g, '/');
144
+ }
145
+
146
+ arguments_ = process.argv.slice(2);
147
+
148
+ quit_ = (status, toThrow) => {
149
+ process.exitCode = status;
150
+ throw toThrow;
151
+ };
152
+
153
+ } else
154
+ if (ENVIRONMENT_IS_SHELL) {
155
+
156
+ } else
157
+
158
+ // Note that this includes Node.js workers when relevant (pthreads is enabled).
159
+ // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
160
+ // ENVIRONMENT_IS_NODE.
161
+ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
162
+ try {
163
+ scriptDirectory = new URL('.', _scriptName).href; // includes trailing slash
164
+ } catch {
165
+ // Must be a `blob:` or `data:` URL (e.g. `blob:http://site.com/etc/etc`), we cannot
166
+ // infer anything from them.
167
+ }
168
+
169
+ 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?)');
170
+
171
+ {
172
+ // include: web_or_worker_shell_read.js
173
+ if (ENVIRONMENT_IS_WORKER) {
174
+ readBinary = (url) => {
175
+ var xhr = new XMLHttpRequest();
176
+ xhr.open('GET', url, false);
177
+ xhr.responseType = 'arraybuffer';
178
+ xhr.send(null);
179
+ return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response));
180
+ };
181
+ }
182
+
183
+ readAsync = async (url) => {
184
+ // Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
185
+ // See https://github.com/github/fetch/pull/92#issuecomment-140665932
186
+ // Cordova or Electron apps are typically loaded from a file:// url.
187
+ // So use XHR on webview if URL is a file URL.
188
+ if (isFileURI(url)) {
189
+ return new Promise((resolve, reject) => {
190
+ var xhr = new XMLHttpRequest();
191
+ xhr.open('GET', url, true);
192
+ xhr.responseType = 'arraybuffer';
193
+ xhr.onload = () => {
194
+ if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
195
+ resolve(xhr.response);
196
+ return;
197
+ }
198
+ reject(xhr.status);
199
+ };
200
+ xhr.onerror = reject;
201
+ xhr.send(null);
202
+ });
203
+ }
204
+ var response = await fetch(url, { credentials: 'same-origin' });
205
+ if (response.ok) {
206
+ return response.arrayBuffer();
207
+ }
208
+ throw new Error(response.status + ' : ' + response.url);
209
+ };
210
+ // end include: web_or_worker_shell_read.js
211
+ }
212
+ } else
213
+ {
214
+ throw new Error('environment detection error');
215
+ }
216
+
217
+ var out = console.log.bind(console);
218
+ var err = console.error.bind(console);
219
+
220
+ var IDBFS = 'IDBFS is no longer included by default; build with -lidbfs.js';
221
+ var PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js';
222
+ var WORKERFS = 'WORKERFS is no longer included by default; build with -lworkerfs.js';
223
+ var FETCHFS = 'FETCHFS is no longer included by default; build with -lfetchfs.js';
224
+ var ICASEFS = 'ICASEFS is no longer included by default; build with -licasefs.js';
225
+ var JSFILEFS = 'JSFILEFS is no longer included by default; build with -ljsfilefs.js';
226
+ var OPFS = 'OPFS is no longer included by default; build with -lopfs.js';
227
+
228
+ var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js';
229
+
230
+ // perform assertions in shell.js after we set up out() and err(), as otherwise
231
+ // if an assertion fails it cannot print the message
232
+
233
+ assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.');
234
+
235
+ // end include: shell.js
236
+
237
+ // include: preamble.js
238
+ // === Preamble library stuff ===
239
+
240
+ // Documentation for the public APIs defined in this file must be updated in:
241
+ // site/source/docs/api_reference/preamble.js.rst
242
+ // A prebuilt local version of the documentation is available at:
243
+ // site/build/text/docs/api_reference/preamble.js.txt
244
+ // You can also build docs locally as HTML or other formats in site/
245
+ // An online HTML version (which may be of a different version of Emscripten)
246
+ // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
247
+
248
+ var wasmBinary;
249
+
250
+ if (!globalThis.WebAssembly) {
251
+ err('no native wasm support detected');
252
+ }
253
+
254
+ // Wasm globals
255
+
256
+ //========================================
257
+ // Runtime essentials
258
+ //========================================
259
+
260
+ // whether we are quitting the application. no code should run after this.
261
+ // set in exit() and abort()
262
+ var ABORT = false;
263
+
264
+ // set by exit() and abort(). Passed to 'onExit' handler.
265
+ // NOTE: This is also used as the process return code code in shell environments
266
+ // but only when noExitRuntime is false.
267
+ var EXITSTATUS;
268
+
269
+ // In STRICT mode, we only define assert() when ASSERTIONS is set. i.e. we
270
+ // don't define it at all in release modes. This matches the behaviour of
271
+ // MINIMAL_RUNTIME.
272
+ // TODO(sbc): Make this the default even without STRICT enabled.
273
+ /** @type {function(*, string=)} */
274
+ function assert(condition, text) {
275
+ if (!condition) {
276
+ abort('Assertion failed' + (text ? ': ' + text : ''));
277
+ }
278
+ }
279
+
280
+ // We used to include malloc/free by default in the past. Show a helpful error in
281
+ // builds with assertions.
282
+
283
+ /**
284
+ * Indicates whether filename is delivered via file protocol (as opposed to http/https)
285
+ * @noinline
286
+ */
287
+ var isFileURI = (filename) => filename.startsWith('file://');
288
+
289
+ // include: runtime_common.js
290
+ // include: runtime_stack_check.js
291
+ // Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
292
+ function writeStackCookie() {
293
+ var max = _emscripten_stack_get_end();
294
+ assert((max & 3) == 0);
295
+ // If the stack ends at address zero we write our cookies 4 bytes into the
296
+ // stack. This prevents interference with SAFE_HEAP and ASAN which also
297
+ // monitor writes to address zero.
298
+ if (max == 0) {
299
+ max += 4;
300
+ }
301
+ // The stack grow downwards towards _emscripten_stack_get_end.
302
+ // We write cookies to the final two words in the stack and detect if they are
303
+ // ever overwritten.
304
+ HEAPU32[((max)>>2)] = 0x02135467;
305
+ HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE;
306
+ // Also test the global address 0 for integrity.
307
+ HEAPU32[((0)>>2)] = 1668509029;
308
+ }
309
+
310
+ function checkStackCookie() {
311
+ if (ABORT) return;
312
+ var max = _emscripten_stack_get_end();
313
+ // See writeStackCookie().
314
+ if (max == 0) {
315
+ max += 4;
316
+ }
317
+ var cookie1 = HEAPU32[((max)>>2)];
318
+ var cookie2 = HEAPU32[(((max)+(4))>>2)];
319
+ if (cookie1 != 0x02135467 || cookie2 != 0x89BACDFE) {
320
+ abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`);
321
+ }
322
+ // Also test the global address 0 for integrity.
323
+ if (HEAPU32[((0)>>2)] != 0x63736d65 /* 'emsc' */) {
324
+ abort('Runtime error: The application has corrupted its heap memory area (address zero)!');
325
+ }
326
+ }
327
+ // end include: runtime_stack_check.js
328
+ // include: runtime_exceptions.js
329
+ // end include: runtime_exceptions.js
330
+ // include: runtime_debug.js
331
+ var runtimeDebug = true; // Switch to false at runtime to disable logging at the right times
332
+
333
+ // Used by XXXXX_DEBUG settings to output debug messages.
334
+ function dbg(...args) {
335
+ if (!runtimeDebug && typeof runtimeDebug != 'undefined') return;
336
+ // TODO(sbc): Make this configurable somehow. Its not always convenient for
337
+ // logging to show up as warnings.
338
+ console.warn(...args);
339
+ }
340
+
341
+ // Endianness check
342
+ (() => {
343
+ var h16 = new Int16Array(1);
344
+ var h8 = new Int8Array(h16.buffer);
345
+ h16[0] = 0x6373;
346
+ if (h8[0] !== 0x73 || h8[1] !== 0x63) abort('Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)');
347
+ })();
348
+
349
+ function consumedModuleProp(prop) {
350
+ if (!Object.getOwnPropertyDescriptor(Module, prop)) {
351
+ Object.defineProperty(Module, prop, {
352
+ configurable: true,
353
+ set() {
354
+ 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'`);
355
+
356
+ }
357
+ });
358
+ }
359
+ }
360
+
361
+ function makeInvalidEarlyAccess(name) {
362
+ return () => assert(false, `call to '${name}' via reference taken before Wasm module initialization`);
363
+
364
+ }
365
+
366
+ function ignoredModuleProp(prop) {
367
+ if (Object.getOwnPropertyDescriptor(Module, prop)) {
368
+ abort(`\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API`);
369
+ }
370
+ }
371
+
372
+ // forcing the filesystem exports a few things by default
373
+ function isExportedByForceFilesystem(name) {
374
+ return name === 'FS_createPath' ||
375
+ name === 'FS_createDataFile' ||
376
+ name === 'FS_createPreloadedFile' ||
377
+ name === 'FS_preloadFile' ||
378
+ name === 'FS_unlink' ||
379
+ name === 'addRunDependency' ||
380
+ // The old FS has some functionality that WasmFS lacks.
381
+ name === 'FS_createLazyFile' ||
382
+ name === 'FS_createDevice' ||
383
+ name === 'removeRunDependency';
384
+ }
385
+
386
+ function missingLibrarySymbol(sym) {
387
+
388
+ // Any symbol that is not included from the JS library is also (by definition)
389
+ // not exported on the Module object.
390
+ unexportedRuntimeSymbol(sym);
391
+ }
392
+
393
+ function unexportedRuntimeSymbol(sym) {
394
+ if (!Object.getOwnPropertyDescriptor(Module, sym)) {
395
+ Object.defineProperty(Module, sym, {
396
+ configurable: true,
397
+ get() {
398
+ var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;
399
+ if (isExportedByForceFilesystem(sym)) {
400
+ msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
401
+ }
402
+ abort(msg);
403
+ },
404
+ });
405
+ }
406
+ }
407
+
408
+ // end include: runtime_debug.js
409
+ var readyPromiseResolve, readyPromiseReject;
410
+
411
+ // Memory management
412
+ var
413
+ /** @type {!Int8Array} */
414
+ HEAP8,
415
+ /** @type {!Uint8Array} */
416
+ HEAPU8,
417
+ /** @type {!Int16Array} */
418
+ HEAP16,
419
+ /** @type {!Uint16Array} */
420
+ HEAPU16,
421
+ /** @type {!Int32Array} */
422
+ HEAP32,
423
+ /** @type {!Uint32Array} */
424
+ HEAPU32,
425
+ /** @type {!Float32Array} */
426
+ HEAPF32,
427
+ /** @type {!Float64Array} */
428
+ HEAPF64;
429
+
430
+ // BigInt64Array type is not correctly defined in closure
431
+ var
432
+ /** not-@type {!BigInt64Array} */
433
+ HEAP64,
434
+ /* BigUint64Array type is not correctly defined in closure
435
+ /** not-@type {!BigUint64Array} */
436
+ HEAPU64;
437
+
438
+ var runtimeInitialized = false;
439
+
440
+
441
+
442
+ function updateMemoryViews() {
443
+ var b = wasmMemory.buffer;
444
+ HEAP8 = new Int8Array(b);
445
+ HEAP16 = new Int16Array(b);
446
+ HEAPU8 = new Uint8Array(b);
447
+ HEAPU16 = new Uint16Array(b);
448
+ HEAP32 = new Int32Array(b);
449
+ HEAPU32 = new Uint32Array(b);
450
+ HEAPF32 = new Float32Array(b);
451
+ HEAPF64 = new Float64Array(b);
452
+ HEAP64 = new BigInt64Array(b);
453
+ HEAPU64 = new BigUint64Array(b);
454
+ }
455
+
456
+ // include: memoryprofiler.js
457
+ // end include: memoryprofiler.js
458
+ // end include: runtime_common.js
459
+ assert(globalThis.Int32Array && globalThis.Float64Array && Int32Array.prototype.subarray && Int32Array.prototype.set,
460
+ 'JS engine does not provide full typed array support');
461
+
462
+ function preRun() {
463
+ if (Module['preRun']) {
464
+ if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
465
+ while (Module['preRun'].length) {
466
+ addOnPreRun(Module['preRun'].shift());
467
+ }
468
+ }
469
+ consumedModuleProp('preRun');
470
+ // Begin ATPRERUNS hooks
471
+ callRuntimeCallbacks(onPreRuns);
472
+ // End ATPRERUNS hooks
473
+ }
474
+
475
+ function initRuntime() {
476
+ assert(!runtimeInitialized);
477
+ runtimeInitialized = true;
478
+
479
+ checkStackCookie();
480
+
481
+ // No ATINITS hooks
482
+
483
+ wasmExports['__wasm_call_ctors']();
484
+
485
+ // No ATPOSTCTORS hooks
486
+ }
487
+
488
+ function postRun() {
489
+ checkStackCookie();
490
+ // PThreads reuse the runtime from the main thread.
491
+
492
+ if (Module['postRun']) {
493
+ if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
494
+ while (Module['postRun'].length) {
495
+ addOnPostRun(Module['postRun'].shift());
496
+ }
497
+ }
498
+ consumedModuleProp('postRun');
499
+
500
+ // Begin ATPOSTRUNS hooks
501
+ callRuntimeCallbacks(onPostRuns);
502
+ // End ATPOSTRUNS hooks
503
+ }
504
+
505
+ /** @param {string|number=} what */
506
+ function abort(what) {
507
+ Module['onAbort']?.(what);
508
+
509
+ what = 'Aborted(' + what + ')';
510
+ // TODO(sbc): Should we remove printing and leave it up to whoever
511
+ // catches the exception?
512
+ err(what);
513
+
514
+ ABORT = true;
515
+
516
+ // Use a wasm runtime error, because a JS error might be seen as a foreign
517
+ // exception, which means we'd run destructors on it. We need the error to
518
+ // simply make the program stop.
519
+ // FIXME This approach does not work in Wasm EH because it currently does not assume
520
+ // all RuntimeErrors are from traps; it decides whether a RuntimeError is from
521
+ // a trap or not based on a hidden field within the object. So at the moment
522
+ // we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that
523
+ // allows this in the wasm spec.
524
+
525
+ // Suppress closure compiler warning here. Closure compiler's builtin extern
526
+ // definition for WebAssembly.RuntimeError claims it takes no arguments even
527
+ // though it can.
528
+ // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
529
+ /** @suppress {checkTypes} */
530
+ var e = new WebAssembly.RuntimeError(what);
531
+
532
+ readyPromiseReject?.(e);
533
+ // Throw the error whether or not MODULARIZE is set because abort is used
534
+ // in code paths apart from instantiation where an exception is expected
535
+ // to be thrown when abort is called.
536
+ throw e;
537
+ }
538
+
539
+ // show errors on likely calls to FS when it was not included
540
+ var FS = {
541
+ error() {
542
+ 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');
543
+ },
544
+ init() { FS.error() },
545
+ createDataFile() { FS.error() },
546
+ createPreloadedFile() { FS.error() },
547
+ createLazyFile() { FS.error() },
548
+ open() { FS.error() },
549
+ mkdev() { FS.error() },
550
+ registerDevice() { FS.error() },
551
+ analyzePath() { FS.error() },
552
+
553
+ ErrnoError() { FS.error() },
554
+ };
555
+
556
+
557
+ function createExportWrapper(name, nargs) {
558
+ return (...args) => {
559
+ assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`);
560
+ var f = wasmExports[name];
561
+ assert(f, `exported native function \`${name}\` not found`);
562
+ // Only assert for too many arguments. Too few can be valid since the missing arguments will be zero filled.
563
+ assert(args.length <= nargs, `native function \`${name}\` called with ${args.length} args but expects ${nargs}`);
564
+ return f(...args);
565
+ };
566
+ }
567
+
568
+ var wasmBinaryFile;
569
+
570
+ function findWasmBinary() {
571
+
572
+ if (Module['locateFile']) {
573
+ return locateFile('GraphLayoutWASM.wasm');
574
+ }
575
+
576
+ // Use bundler-friendly `new URL(..., import.meta.url)` pattern; works in browsers too.
577
+ return new URL('GraphLayoutWASM.wasm', import.meta.url).href;
578
+
579
+ }
580
+
581
+ function getBinarySync(file) {
582
+ if (file == wasmBinaryFile && wasmBinary) {
583
+ return new Uint8Array(wasmBinary);
584
+ }
585
+ if (readBinary) {
586
+ return readBinary(file);
587
+ }
588
+ // Throwing a plain string here, even though it not normally adviables since
589
+ // this gets turning into an `abort` in instantiateArrayBuffer.
590
+ throw 'both async and sync fetching of the wasm failed';
591
+ }
592
+
593
+ async function getWasmBinary(binaryFile) {
594
+ // If we don't have the binary yet, load it asynchronously using readAsync.
595
+ if (!wasmBinary) {
596
+ // Fetch the binary using readAsync
597
+ try {
598
+ var response = await readAsync(binaryFile);
599
+ return new Uint8Array(response);
600
+ } catch {
601
+ // Fall back to getBinarySync below;
602
+ }
603
+ }
604
+
605
+ // Otherwise, getBinarySync should be able to get it synchronously
606
+ return getBinarySync(binaryFile);
607
+ }
608
+
609
+ async function instantiateArrayBuffer(binaryFile, imports) {
610
+ try {
611
+ var binary = await getWasmBinary(binaryFile);
612
+ var instance = await WebAssembly.instantiate(binary, imports);
613
+ return instance;
614
+ } catch (reason) {
615
+ err(`failed to asynchronously prepare wasm: ${reason}`);
616
+
617
+ // Warn on some common problems.
618
+ if (isFileURI(binaryFile)) {
619
+ 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`);
620
+ }
621
+ abort(reason);
622
+ }
623
+ }
624
+
625
+ async function instantiateAsync(binary, binaryFile, imports) {
626
+ if (!binary
627
+ // Don't use streaming for file:// delivered objects in a webview, fetch them synchronously.
628
+ && !isFileURI(binaryFile)
629
+ // Avoid instantiateStreaming() on Node.js environment for now, as while
630
+ // Node.js v18.1.0 implements it, it does not have a full fetch()
631
+ // implementation yet.
632
+ //
633
+ // Reference:
634
+ // https://github.com/emscripten-core/emscripten/pull/16917
635
+ && !ENVIRONMENT_IS_NODE
636
+ ) {
637
+ try {
638
+ var response = fetch(binaryFile, { credentials: 'same-origin' });
639
+ var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
640
+ return instantiationResult;
641
+ } catch (reason) {
642
+ // We expect the most common failure cause to be a bad MIME type for the binary,
643
+ // in which case falling back to ArrayBuffer instantiation should work.
644
+ err(`wasm streaming compile failed: ${reason}`);
645
+ err('falling back to ArrayBuffer instantiation');
646
+ // fall back of instantiateArrayBuffer below
647
+ };
648
+ }
649
+ return instantiateArrayBuffer(binaryFile, imports);
650
+ }
651
+
652
+ function getWasmImports() {
653
+ // prepare imports
654
+ var imports = {
655
+ 'env': wasmImports,
656
+ 'wasi_snapshot_preview1': wasmImports,
657
+ };
658
+ return imports;
659
+ }
660
+
661
+ // Create the wasm instance.
662
+ // Receives the wasm imports, returns the exports.
663
+ async function createWasm() {
664
+ // Load the wasm module and create an instance of using native support in the JS engine.
665
+ // handle a generated wasm instance, receiving its exports and
666
+ // performing other necessary setup
667
+ /** @param {WebAssembly.Module=} module*/
668
+ function receiveInstance(instance, module) {
669
+ wasmExports = instance.exports;
670
+
671
+ assignWasmExports(wasmExports);
672
+
673
+ updateMemoryViews();
674
+
675
+ return wasmExports;
676
+ }
677
+
678
+ // Prefer streaming instantiation if available.
679
+ // Async compilation can be confusing when an error on the page overwrites Module
680
+ // (for example, if the order of elements is wrong, and the one defining Module is
681
+ // later), so we save Module and check it later.
682
+ var trueModule = Module;
683
+ function receiveInstantiationResult(result) {
684
+ // 'result' is a ResultObject object which has both the module and instance.
685
+ // receiveInstance() will swap in the exports (to Module.asm) so they can be called
686
+ assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?');
687
+ trueModule = null;
688
+ // 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.
689
+ // When the regression is fixed, can restore the above PTHREADS-enabled path.
690
+ return receiveInstance(result['instance']);
691
+ }
692
+
693
+ var info = getWasmImports();
694
+
695
+ // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
696
+ // to manually instantiate the Wasm module themselves. This allows pages to
697
+ // run the instantiation parallel to any other async startup actions they are
698
+ // performing.
699
+ // Also pthreads and wasm workers initialize the wasm instance through this
700
+ // path.
701
+ if (Module['instantiateWasm']) {
702
+ return new Promise((resolve, reject) => {
703
+ try {
704
+ Module['instantiateWasm'](info, (inst, mod) => {
705
+ resolve(receiveInstance(inst, mod));
706
+ });
707
+ } catch(e) {
708
+ err(`Module.instantiateWasm callback failed with error: ${e}`);
709
+ reject(e);
710
+ }
711
+ });
712
+ }
713
+
714
+ wasmBinaryFile ??= findWasmBinary();
715
+ var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
716
+ var exports = receiveInstantiationResult(result);
717
+ return exports;
718
+ }
719
+
720
+ // end include: preamble.js
721
+
722
+ // Begin JS library code
723
+
724
+
725
+ class ExitStatus {
726
+ name = 'ExitStatus';
727
+ constructor(status) {
728
+ this.message = `Program terminated with exit(${status})`;
729
+ this.status = status;
730
+ }
731
+ }
732
+
733
+ var callRuntimeCallbacks = (callbacks) => {
734
+ while (callbacks.length > 0) {
735
+ // Pass the module as the first argument.
736
+ callbacks.shift()(Module);
737
+ }
738
+ };
739
+ var onPostRuns = [];
740
+ var addOnPostRun = (cb) => onPostRuns.push(cb);
741
+
742
+ var onPreRuns = [];
743
+ var addOnPreRun = (cb) => onPreRuns.push(cb);
744
+
745
+
746
+
747
+ /**
748
+ * @param {number} ptr
749
+ * @param {string} type
750
+ */
751
+ function getValue(ptr, type = 'i8') {
752
+ if (type.endsWith('*')) type = '*';
753
+ switch (type) {
754
+ case 'i1': return HEAP8[ptr];
755
+ case 'i8': return HEAP8[ptr];
756
+ case 'i16': return HEAP16[((ptr)>>1)];
757
+ case 'i32': return HEAP32[((ptr)>>2)];
758
+ case 'i64': return HEAP64[((ptr)>>3)];
759
+ case 'float': return HEAPF32[((ptr)>>2)];
760
+ case 'double': return HEAPF64[((ptr)>>3)];
761
+ case '*': return HEAPU32[((ptr)>>2)];
762
+ default: abort(`invalid type for getValue: ${type}`);
763
+ }
764
+ }
765
+
766
+ var noExitRuntime = true;
767
+
768
+ var 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
+
775
+
776
+ /**
777
+ * @param {number} ptr
778
+ * @param {number} value
779
+ * @param {string} type
780
+ */
781
+ function setValue(ptr, value, type = 'i8') {
782
+ if (type.endsWith('*')) type = '*';
783
+ switch (type) {
784
+ case 'i1': HEAP8[ptr] = value; break;
785
+ case 'i8': HEAP8[ptr] = value; break;
786
+ case 'i16': HEAP16[((ptr)>>1)] = value; break;
787
+ case 'i32': HEAP32[((ptr)>>2)] = value; break;
788
+ case 'i64': HEAP64[((ptr)>>3)] = BigInt(value); break;
789
+ case 'float': HEAPF32[((ptr)>>2)] = value; break;
790
+ case 'double': HEAPF64[((ptr)>>3)] = value; break;
791
+ case '*': HEAPU32[((ptr)>>2)] = value; break;
792
+ default: abort(`invalid type for setValue: ${type}`);
793
+ }
794
+ }
795
+
796
+ var stackRestore = (val) => __emscripten_stack_restore(val);
797
+
798
+ var stackSave = () => _emscripten_stack_get_current();
799
+
800
+ var warnOnce = (text) => {
801
+ warnOnce.shown ||= {};
802
+ if (!warnOnce.shown[text]) {
803
+ warnOnce.shown[text] = 1;
804
+ if (ENVIRONMENT_IS_NODE) text = 'warning: ' + text;
805
+ err(text);
806
+ }
807
+ };
808
+
809
+
810
+
811
+ var UTF8Decoder = globalThis.TextDecoder && new TextDecoder();
812
+
813
+ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
814
+ var maxIdx = idx + maxBytesToRead;
815
+ if (ignoreNul) return maxIdx;
816
+ // TextDecoder needs to know the byte length in advance, it doesn't stop on
817
+ // null terminator by itself.
818
+ // As a tiny code save trick, compare idx against maxIdx using a negation,
819
+ // so that maxBytesToRead=undefined/NaN means Infinity.
820
+ while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx;
821
+ return idx;
822
+ };
823
+
824
+
825
+ /**
826
+ * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
827
+ * array that contains uint8 values, returns a copy of that string as a
828
+ * Javascript String object.
829
+ * heapOrArray is either a regular array, or a JavaScript typed array view.
830
+ * @param {number=} idx
831
+ * @param {number=} maxBytesToRead
832
+ * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character.
833
+ * @return {string}
834
+ */
835
+ var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => {
836
+
837
+ var endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul);
838
+
839
+ // When using conditional TextDecoder, skip it for short strings as the overhead of the native call is not worth it.
840
+ if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
841
+ return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
842
+ }
843
+ var str = '';
844
+ while (idx < endPtr) {
845
+ // For UTF8 byte structure, see:
846
+ // http://en.wikipedia.org/wiki/UTF-8#Description
847
+ // https://www.ietf.org/rfc/rfc2279.txt
848
+ // https://tools.ietf.org/html/rfc3629
849
+ var u0 = heapOrArray[idx++];
850
+ if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
851
+ var u1 = heapOrArray[idx++] & 63;
852
+ if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
853
+ var u2 = heapOrArray[idx++] & 63;
854
+ if ((u0 & 0xF0) == 0xE0) {
855
+ u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
856
+ } else {
857
+ 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!');
858
+ u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
859
+ }
860
+
861
+ if (u0 < 0x10000) {
862
+ str += String.fromCharCode(u0);
863
+ } else {
864
+ var ch = u0 - 0x10000;
865
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
866
+ }
867
+ }
868
+ return str;
869
+ };
870
+
871
+ /**
872
+ * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
873
+ * emscripten HEAP, returns a copy of that string as a Javascript String object.
874
+ *
875
+ * @param {number} ptr
876
+ * @param {number=} maxBytesToRead - An optional length that specifies the
877
+ * maximum number of bytes to read. You can omit this parameter to scan the
878
+ * string until the first 0 byte. If maxBytesToRead is passed, and the string
879
+ * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
880
+ * string will cut short at that byte index.
881
+ * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character.
882
+ * @return {string}
883
+ */
884
+ var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => {
885
+ assert(typeof ptr == 'number', `UTF8ToString expects a number (got ${typeof ptr})`);
886
+ return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead, ignoreNul) : '';
887
+ };
888
+ var ___assert_fail = (condition, filename, line, func) =>
889
+ abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
890
+
891
+ class ExceptionInfo {
892
+ // excPtr - Thrown object pointer to wrap. Metadata pointer is calculated from it.
893
+ constructor(excPtr) {
894
+ this.excPtr = excPtr;
895
+ this.ptr = excPtr - 24;
896
+ }
897
+
898
+ set_type(type) {
899
+ HEAPU32[(((this.ptr)+(4))>>2)] = type;
900
+ }
901
+
902
+ get_type() {
903
+ return HEAPU32[(((this.ptr)+(4))>>2)];
904
+ }
905
+
906
+ set_destructor(destructor) {
907
+ HEAPU32[(((this.ptr)+(8))>>2)] = destructor;
908
+ }
909
+
910
+ get_destructor() {
911
+ return HEAPU32[(((this.ptr)+(8))>>2)];
912
+ }
913
+
914
+ set_caught(caught) {
915
+ caught = caught ? 1 : 0;
916
+ HEAP8[(this.ptr)+(12)] = caught;
917
+ }
918
+
919
+ get_caught() {
920
+ return HEAP8[(this.ptr)+(12)] != 0;
921
+ }
922
+
923
+ set_rethrown(rethrown) {
924
+ rethrown = rethrown ? 1 : 0;
925
+ HEAP8[(this.ptr)+(13)] = rethrown;
926
+ }
927
+
928
+ get_rethrown() {
929
+ return HEAP8[(this.ptr)+(13)] != 0;
930
+ }
931
+
932
+ // Initialize native structure fields. Should be called once after allocated.
933
+ init(type, destructor) {
934
+ this.set_adjusted_ptr(0);
935
+ this.set_type(type);
936
+ this.set_destructor(destructor);
937
+ }
938
+
939
+ set_adjusted_ptr(adjustedPtr) {
940
+ HEAPU32[(((this.ptr)+(16))>>2)] = adjustedPtr;
941
+ }
942
+
943
+ get_adjusted_ptr() {
944
+ return HEAPU32[(((this.ptr)+(16))>>2)];
945
+ }
946
+ }
947
+
948
+ var exceptionLast = 0;
949
+
950
+ var uncaughtExceptionCount = 0;
951
+ var ___cxa_throw = (ptr, type, destructor) => {
952
+ var info = new ExceptionInfo(ptr);
953
+ // Initialize ExceptionInfo content after it was allocated in __cxa_allocate_exception.
954
+ info.init(type, destructor);
955
+ exceptionLast = ptr;
956
+ uncaughtExceptionCount++;
957
+ assert(false, 'Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.');
958
+ };
959
+
960
+ var __abort_js = () =>
961
+ abort('native code called abort()');
962
+
963
+ var AsciiToString = (ptr) => {
964
+ var str = '';
965
+ while (1) {
966
+ var ch = HEAPU8[ptr++];
967
+ if (!ch) return str;
968
+ str += String.fromCharCode(ch);
969
+ }
970
+ };
971
+
972
+ var awaitingDependencies = {
973
+ };
974
+
975
+ var registeredTypes = {
976
+ };
977
+
978
+ var typeDependencies = {
979
+ };
980
+
981
+ var BindingError = class BindingError extends Error { constructor(message) { super(message); this.name = 'BindingError'; }};
982
+ var throwBindingError = (message) => { throw new BindingError(message); };
983
+ /** @param {Object=} options */
984
+ function sharedRegisterType(rawType, registeredInstance, options = {}) {
985
+ var name = registeredInstance.name;
986
+ if (!rawType) {
987
+ throwBindingError(`type "${name}" must have a positive integer typeid pointer`);
988
+ }
989
+ if (registeredTypes.hasOwnProperty(rawType)) {
990
+ if (options.ignoreDuplicateRegistrations) {
991
+ return;
992
+ } else {
993
+ throwBindingError(`Cannot register type '${name}' twice`);
994
+ }
995
+ }
996
+
997
+ registeredTypes[rawType] = registeredInstance;
998
+ delete typeDependencies[rawType];
999
+
1000
+ if (awaitingDependencies.hasOwnProperty(rawType)) {
1001
+ var callbacks = awaitingDependencies[rawType];
1002
+ delete awaitingDependencies[rawType];
1003
+ callbacks.forEach((cb) => cb());
1004
+ }
1005
+ }
1006
+ /** @param {Object=} options */
1007
+ function registerType(rawType, registeredInstance, options = {}) {
1008
+ return sharedRegisterType(rawType, registeredInstance, options);
1009
+ }
1010
+
1011
+ var integerReadValueFromPointer = (name, width, signed) => {
1012
+ // integers are quite common, so generate very specialized functions
1013
+ switch (width) {
1014
+ case 1: return signed ?
1015
+ (pointer) => HEAP8[pointer] :
1016
+ (pointer) => HEAPU8[pointer];
1017
+ case 2: return signed ?
1018
+ (pointer) => HEAP16[((pointer)>>1)] :
1019
+ (pointer) => HEAPU16[((pointer)>>1)]
1020
+ case 4: return signed ?
1021
+ (pointer) => HEAP32[((pointer)>>2)] :
1022
+ (pointer) => HEAPU32[((pointer)>>2)]
1023
+ case 8: return signed ?
1024
+ (pointer) => HEAP64[((pointer)>>3)] :
1025
+ (pointer) => HEAPU64[((pointer)>>3)]
1026
+ default:
1027
+ throw new TypeError(`invalid integer width (${width}): ${name}`);
1028
+ }
1029
+ };
1030
+
1031
+ var embindRepr = (v) => {
1032
+ if (v === null) {
1033
+ return 'null';
1034
+ }
1035
+ var t = typeof v;
1036
+ if (t === 'object' || t === 'array' || t === 'function') {
1037
+ return v.toString();
1038
+ } else {
1039
+ return '' + v;
1040
+ }
1041
+ };
1042
+
1043
+ var assertIntegerRange = (typeName, value, minRange, maxRange) => {
1044
+ if (value < minRange || value > maxRange) {
1045
+ throw new TypeError(`Passing a number "${embindRepr(value)}" from JS side to C/C++ side to an argument of type "${typeName}", which is outside the valid range [${minRange}, ${maxRange}]!`);
1046
+ }
1047
+ };
1048
+ /** @suppress {globalThis} */
1049
+ var __embind_register_bigint = (primitiveType, name, size, minRange, maxRange) => {
1050
+ name = AsciiToString(name);
1051
+
1052
+ const isUnsignedType = minRange === 0n;
1053
+
1054
+ let fromWireType = (value) => value;
1055
+ if (isUnsignedType) {
1056
+ // uint64 get converted to int64 in ABI, fix them up like we do for 32-bit integers.
1057
+ const bitSize = size * 8;
1058
+ fromWireType = (value) => {
1059
+ return BigInt.asUintN(bitSize, value);
1060
+ }
1061
+ maxRange = fromWireType(maxRange);
1062
+ }
1063
+
1064
+ registerType(primitiveType, {
1065
+ name,
1066
+ fromWireType: fromWireType,
1067
+ toWireType: (destructors, value) => {
1068
+ if (typeof value == "number") {
1069
+ value = BigInt(value);
1070
+ }
1071
+ else if (typeof value != "bigint") {
1072
+ throw new TypeError(`Cannot convert "${embindRepr(value)}" to ${this.name}`);
1073
+ }
1074
+ assertIntegerRange(name, value, minRange, maxRange);
1075
+ return value;
1076
+ },
1077
+ readValueFromPointer: integerReadValueFromPointer(name, size, !isUnsignedType),
1078
+ destructorFunction: null, // This type does not need a destructor
1079
+ });
1080
+ };
1081
+
1082
+
1083
+ /** @suppress {globalThis} */
1084
+ var __embind_register_bool = (rawType, name, trueValue, falseValue) => {
1085
+ name = AsciiToString(name);
1086
+ registerType(rawType, {
1087
+ name,
1088
+ fromWireType: function(wt) {
1089
+ // ambiguous emscripten ABI: sometimes return values are
1090
+ // true or false, and sometimes integers (0 or 1)
1091
+ return !!wt;
1092
+ },
1093
+ toWireType: function(destructors, o) {
1094
+ return o ? trueValue : falseValue;
1095
+ },
1096
+ readValueFromPointer: function(pointer) {
1097
+ return this.fromWireType(HEAPU8[pointer]);
1098
+ },
1099
+ destructorFunction: null, // This type does not need a destructor
1100
+ });
1101
+ };
1102
+
1103
+
1104
+
1105
+ var shallowCopyInternalPointer = (o) => {
1106
+ return {
1107
+ count: o.count,
1108
+ deleteScheduled: o.deleteScheduled,
1109
+ preservePointerOnDelete: o.preservePointerOnDelete,
1110
+ ptr: o.ptr,
1111
+ ptrType: o.ptrType,
1112
+ smartPtr: o.smartPtr,
1113
+ smartPtrType: o.smartPtrType,
1114
+ };
1115
+ };
1116
+
1117
+ var throwInstanceAlreadyDeleted = (obj) => {
1118
+ function getInstanceTypeName(handle) {
1119
+ return handle.$$.ptrType.registeredClass.name;
1120
+ }
1121
+ throwBindingError(getInstanceTypeName(obj) + ' instance already deleted');
1122
+ };
1123
+
1124
+ var finalizationRegistry = false;
1125
+
1126
+ var detachFinalizer = (handle) => {};
1127
+
1128
+ var runDestructor = ($$) => {
1129
+ if ($$.smartPtr) {
1130
+ $$.smartPtrType.rawDestructor($$.smartPtr);
1131
+ } else {
1132
+ $$.ptrType.registeredClass.rawDestructor($$.ptr);
1133
+ }
1134
+ };
1135
+ var releaseClassHandle = ($$) => {
1136
+ $$.count.value -= 1;
1137
+ var toDelete = 0 === $$.count.value;
1138
+ if (toDelete) {
1139
+ runDestructor($$);
1140
+ }
1141
+ };
1142
+
1143
+ var downcastPointer = (ptr, ptrClass, desiredClass) => {
1144
+ if (ptrClass === desiredClass) {
1145
+ return ptr;
1146
+ }
1147
+ if (undefined === desiredClass.baseClass) {
1148
+ return null; // no conversion
1149
+ }
1150
+
1151
+ var rv = downcastPointer(ptr, ptrClass, desiredClass.baseClass);
1152
+ if (rv === null) {
1153
+ return null;
1154
+ }
1155
+ return desiredClass.downcast(rv);
1156
+ };
1157
+
1158
+ var registeredPointers = {
1159
+ };
1160
+
1161
+ var registeredInstances = {
1162
+ };
1163
+
1164
+ var getBasestPointer = (class_, ptr) => {
1165
+ if (ptr === undefined) {
1166
+ throwBindingError('ptr should not be undefined');
1167
+ }
1168
+ while (class_.baseClass) {
1169
+ ptr = class_.upcast(ptr);
1170
+ class_ = class_.baseClass;
1171
+ }
1172
+ return ptr;
1173
+ };
1174
+ var getInheritedInstance = (class_, ptr) => {
1175
+ ptr = getBasestPointer(class_, ptr);
1176
+ return registeredInstances[ptr];
1177
+ };
1178
+
1179
+ var InternalError = class InternalError extends Error { constructor(message) { super(message); this.name = 'InternalError'; }};
1180
+ var throwInternalError = (message) => { throw new InternalError(message); };
1181
+
1182
+ var makeClassHandle = (prototype, record) => {
1183
+ if (!record.ptrType || !record.ptr) {
1184
+ throwInternalError('makeClassHandle requires ptr and ptrType');
1185
+ }
1186
+ var hasSmartPtrType = !!record.smartPtrType;
1187
+ var hasSmartPtr = !!record.smartPtr;
1188
+ if (hasSmartPtrType !== hasSmartPtr) {
1189
+ throwInternalError('Both smartPtrType and smartPtr must be specified');
1190
+ }
1191
+ record.count = { value: 1 };
1192
+ return attachFinalizer(Object.create(prototype, {
1193
+ $$: {
1194
+ value: record,
1195
+ writable: true,
1196
+ },
1197
+ }));
1198
+ };
1199
+ /** @suppress {globalThis} */
1200
+ function RegisteredPointer_fromWireType(ptr) {
1201
+ // ptr is a raw pointer (or a raw smartpointer)
1202
+
1203
+ // rawPointer is a maybe-null raw pointer
1204
+ var rawPointer = this.getPointee(ptr);
1205
+ if (!rawPointer) {
1206
+ this.destructor(ptr);
1207
+ return null;
1208
+ }
1209
+
1210
+ var registeredInstance = getInheritedInstance(this.registeredClass, rawPointer);
1211
+ if (undefined !== registeredInstance) {
1212
+ // JS object has been neutered, time to repopulate it
1213
+ if (0 === registeredInstance.$$.count.value) {
1214
+ registeredInstance.$$.ptr = rawPointer;
1215
+ registeredInstance.$$.smartPtr = ptr;
1216
+ return registeredInstance['clone']();
1217
+ } else {
1218
+ // else, just increment reference count on existing object
1219
+ // it already has a reference to the smart pointer
1220
+ var rv = registeredInstance['clone']();
1221
+ this.destructor(ptr);
1222
+ return rv;
1223
+ }
1224
+ }
1225
+
1226
+ function makeDefaultHandle() {
1227
+ if (this.isSmartPointer) {
1228
+ return makeClassHandle(this.registeredClass.instancePrototype, {
1229
+ ptrType: this.pointeeType,
1230
+ ptr: rawPointer,
1231
+ smartPtrType: this,
1232
+ smartPtr: ptr,
1233
+ });
1234
+ } else {
1235
+ return makeClassHandle(this.registeredClass.instancePrototype, {
1236
+ ptrType: this,
1237
+ ptr,
1238
+ });
1239
+ }
1240
+ }
1241
+
1242
+ var actualType = this.registeredClass.getActualType(rawPointer);
1243
+ var registeredPointerRecord = registeredPointers[actualType];
1244
+ if (!registeredPointerRecord) {
1245
+ return makeDefaultHandle.call(this);
1246
+ }
1247
+
1248
+ var toType;
1249
+ if (this.isConst) {
1250
+ toType = registeredPointerRecord.constPointerType;
1251
+ } else {
1252
+ toType = registeredPointerRecord.pointerType;
1253
+ }
1254
+ var dp = downcastPointer(
1255
+ rawPointer,
1256
+ this.registeredClass,
1257
+ toType.registeredClass);
1258
+ if (dp === null) {
1259
+ return makeDefaultHandle.call(this);
1260
+ }
1261
+ if (this.isSmartPointer) {
1262
+ return makeClassHandle(toType.registeredClass.instancePrototype, {
1263
+ ptrType: toType,
1264
+ ptr: dp,
1265
+ smartPtrType: this,
1266
+ smartPtr: ptr,
1267
+ });
1268
+ } else {
1269
+ return makeClassHandle(toType.registeredClass.instancePrototype, {
1270
+ ptrType: toType,
1271
+ ptr: dp,
1272
+ });
1273
+ }
1274
+ }
1275
+ var attachFinalizer = (handle) => {
1276
+ if (!globalThis.FinalizationRegistry) {
1277
+ attachFinalizer = (handle) => handle;
1278
+ return handle;
1279
+ }
1280
+ // If the running environment has a FinalizationRegistry (see
1281
+ // https://github.com/tc39/proposal-weakrefs), then attach finalizers
1282
+ // for class handles. We check for the presence of FinalizationRegistry
1283
+ // at run-time, not build-time.
1284
+ finalizationRegistry = new FinalizationRegistry((info) => {
1285
+ console.warn(info.leakWarning);
1286
+ releaseClassHandle(info.$$);
1287
+ });
1288
+ attachFinalizer = (handle) => {
1289
+ var $$ = handle.$$;
1290
+ var hasSmartPtr = !!$$.smartPtr;
1291
+ if (hasSmartPtr) {
1292
+ // We should not call the destructor on raw pointers in case other code expects the pointee to live
1293
+ var info = { $$: $$ };
1294
+ // Create a warning as an Error instance in advance so that we can store
1295
+ // the current stacktrace and point to it when / if a leak is detected.
1296
+ // This is more useful than the empty stacktrace of `FinalizationRegistry`
1297
+ // callback.
1298
+ var cls = $$.ptrType.registeredClass;
1299
+ var err = new Error(`Embind found a leaked C++ instance ${cls.name} <${ptrToString($$.ptr)}>.\n` +
1300
+ "We'll free it automatically in this case, but this functionality is not reliable across various environments.\n" +
1301
+ "Make sure to invoke .delete() manually once you're done with the instance instead.\n" +
1302
+ "Originally allocated"); // `.stack` will add "at ..." after this sentence
1303
+ if ('captureStackTrace' in Error) {
1304
+ Error.captureStackTrace(err, RegisteredPointer_fromWireType);
1305
+ }
1306
+ info.leakWarning = err.stack.replace(/^Error: /, '');
1307
+ finalizationRegistry.register(handle, info, handle);
1308
+ }
1309
+ return handle;
1310
+ };
1311
+ detachFinalizer = (handle) => finalizationRegistry.unregister(handle);
1312
+ return attachFinalizer(handle);
1313
+ };
1314
+
1315
+
1316
+
1317
+
1318
+ var deletionQueue = [];
1319
+ var flushPendingDeletes = () => {
1320
+ while (deletionQueue.length) {
1321
+ var obj = deletionQueue.pop();
1322
+ obj.$$.deleteScheduled = false;
1323
+ obj['delete']();
1324
+ }
1325
+ };
1326
+
1327
+ var delayFunction;
1328
+ var init_ClassHandle = () => {
1329
+ let proto = ClassHandle.prototype;
1330
+
1331
+ Object.assign(proto, {
1332
+ "isAliasOf"(other) {
1333
+ if (!(this instanceof ClassHandle)) {
1334
+ return false;
1335
+ }
1336
+ if (!(other instanceof ClassHandle)) {
1337
+ return false;
1338
+ }
1339
+
1340
+ var leftClass = this.$$.ptrType.registeredClass;
1341
+ var left = this.$$.ptr;
1342
+ other.$$ = /** @type {Object} */ (other.$$);
1343
+ var rightClass = other.$$.ptrType.registeredClass;
1344
+ var right = other.$$.ptr;
1345
+
1346
+ while (leftClass.baseClass) {
1347
+ left = leftClass.upcast(left);
1348
+ leftClass = leftClass.baseClass;
1349
+ }
1350
+
1351
+ while (rightClass.baseClass) {
1352
+ right = rightClass.upcast(right);
1353
+ rightClass = rightClass.baseClass;
1354
+ }
1355
+
1356
+ return leftClass === rightClass && left === right;
1357
+ },
1358
+
1359
+ "clone"() {
1360
+ if (!this.$$.ptr) {
1361
+ throwInstanceAlreadyDeleted(this);
1362
+ }
1363
+
1364
+ if (this.$$.preservePointerOnDelete) {
1365
+ this.$$.count.value += 1;
1366
+ return this;
1367
+ } else {
1368
+ var clone = attachFinalizer(Object.create(Object.getPrototypeOf(this), {
1369
+ $$: {
1370
+ value: shallowCopyInternalPointer(this.$$),
1371
+ }
1372
+ }));
1373
+
1374
+ clone.$$.count.value += 1;
1375
+ clone.$$.deleteScheduled = false;
1376
+ return clone;
1377
+ }
1378
+ },
1379
+
1380
+ "delete"() {
1381
+ if (!this.$$.ptr) {
1382
+ throwInstanceAlreadyDeleted(this);
1383
+ }
1384
+
1385
+ if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
1386
+ throwBindingError('Object already scheduled for deletion');
1387
+ }
1388
+
1389
+ detachFinalizer(this);
1390
+ releaseClassHandle(this.$$);
1391
+
1392
+ if (!this.$$.preservePointerOnDelete) {
1393
+ this.$$.smartPtr = undefined;
1394
+ this.$$.ptr = undefined;
1395
+ }
1396
+ },
1397
+
1398
+ "isDeleted"() {
1399
+ return !this.$$.ptr;
1400
+ },
1401
+
1402
+ "deleteLater"() {
1403
+ if (!this.$$.ptr) {
1404
+ throwInstanceAlreadyDeleted(this);
1405
+ }
1406
+ if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
1407
+ throwBindingError('Object already scheduled for deletion');
1408
+ }
1409
+ deletionQueue.push(this);
1410
+ if (deletionQueue.length === 1 && delayFunction) {
1411
+ delayFunction(flushPendingDeletes);
1412
+ }
1413
+ this.$$.deleteScheduled = true;
1414
+ return this;
1415
+ },
1416
+ });
1417
+
1418
+ // Support `using ...` from https://github.com/tc39/proposal-explicit-resource-management.
1419
+ const symbolDispose = Symbol.dispose;
1420
+ if (symbolDispose) {
1421
+ proto[symbolDispose] = proto['delete'];
1422
+ }
1423
+ };
1424
+ /** @constructor */
1425
+ function ClassHandle() {
1426
+ }
1427
+
1428
+ var createNamedFunction = (name, func) => Object.defineProperty(func, 'name', { value: name });
1429
+
1430
+
1431
+ var ensureOverloadTable = (proto, methodName, humanName) => {
1432
+ if (undefined === proto[methodName].overloadTable) {
1433
+ var prevFunc = proto[methodName];
1434
+ // Inject an overload resolver function that routes to the appropriate overload based on the number of arguments.
1435
+ proto[methodName] = function(...args) {
1436
+ // TODO This check can be removed in -O3 level "unsafe" optimizations.
1437
+ if (!proto[methodName].overloadTable.hasOwnProperty(args.length)) {
1438
+ throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${args.length}) - expects one of (${proto[methodName].overloadTable})!`);
1439
+ }
1440
+ return proto[methodName].overloadTable[args.length].apply(this, args);
1441
+ };
1442
+ // Move the previous function into the overload table.
1443
+ proto[methodName].overloadTable = [];
1444
+ proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;
1445
+ }
1446
+ };
1447
+
1448
+ /** @param {number=} numArguments */
1449
+ var exposePublicSymbol = (name, value, numArguments) => {
1450
+ if (Module.hasOwnProperty(name)) {
1451
+ if (undefined === numArguments || (undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments])) {
1452
+ throwBindingError(`Cannot register public name '${name}' twice`);
1453
+ }
1454
+
1455
+ // We are exposing a function with the same name as an existing function. Create an overload table and a function selector
1456
+ // that routes between the two.
1457
+ ensureOverloadTable(Module, name, name);
1458
+ if (Module[name].overloadTable.hasOwnProperty(numArguments)) {
1459
+ throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`);
1460
+ }
1461
+ // Add the new function into the overload table.
1462
+ Module[name].overloadTable[numArguments] = value;
1463
+ } else {
1464
+ Module[name] = value;
1465
+ Module[name].argCount = numArguments;
1466
+ }
1467
+ };
1468
+
1469
+ var char_0 = 48;
1470
+
1471
+ var char_9 = 57;
1472
+ var makeLegalFunctionName = (name) => {
1473
+ assert(typeof name === 'string');
1474
+ name = name.replace(/[^a-zA-Z0-9_]/g, '$');
1475
+ var f = name.charCodeAt(0);
1476
+ if (f >= char_0 && f <= char_9) {
1477
+ return `_${name}`;
1478
+ }
1479
+ return name;
1480
+ };
1481
+
1482
+
1483
+ /** @constructor */
1484
+ function RegisteredClass(name,
1485
+ constructor,
1486
+ instancePrototype,
1487
+ rawDestructor,
1488
+ baseClass,
1489
+ getActualType,
1490
+ upcast,
1491
+ downcast) {
1492
+ this.name = name;
1493
+ this.constructor = constructor;
1494
+ this.instancePrototype = instancePrototype;
1495
+ this.rawDestructor = rawDestructor;
1496
+ this.baseClass = baseClass;
1497
+ this.getActualType = getActualType;
1498
+ this.upcast = upcast;
1499
+ this.downcast = downcast;
1500
+ this.pureVirtualFunctions = [];
1501
+ }
1502
+
1503
+
1504
+ var upcastPointer = (ptr, ptrClass, desiredClass) => {
1505
+ while (ptrClass !== desiredClass) {
1506
+ if (!ptrClass.upcast) {
1507
+ throwBindingError(`Expected null or instance of ${desiredClass.name}, got an instance of ${ptrClass.name}`);
1508
+ }
1509
+ ptr = ptrClass.upcast(ptr);
1510
+ ptrClass = ptrClass.baseClass;
1511
+ }
1512
+ return ptr;
1513
+ };
1514
+
1515
+ /** @suppress {globalThis} */
1516
+ function constNoSmartPtrRawPointerToWireType(destructors, handle) {
1517
+ if (handle === null) {
1518
+ if (this.isReference) {
1519
+ throwBindingError(`null is not a valid ${this.name}`);
1520
+ }
1521
+ return 0;
1522
+ }
1523
+
1524
+ if (!handle.$$) {
1525
+ throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`);
1526
+ }
1527
+ if (!handle.$$.ptr) {
1528
+ throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`);
1529
+ }
1530
+ var handleClass = handle.$$.ptrType.registeredClass;
1531
+ var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
1532
+ return ptr;
1533
+ }
1534
+
1535
+
1536
+ /** @suppress {globalThis} */
1537
+ function genericPointerToWireType(destructors, handle) {
1538
+ var ptr;
1539
+ if (handle === null) {
1540
+ if (this.isReference) {
1541
+ throwBindingError(`null is not a valid ${this.name}`);
1542
+ }
1543
+
1544
+ if (this.isSmartPointer) {
1545
+ ptr = this.rawConstructor();
1546
+ if (destructors !== null) {
1547
+ destructors.push(this.rawDestructor, ptr);
1548
+ }
1549
+ return ptr;
1550
+ } else {
1551
+ return 0;
1552
+ }
1553
+ }
1554
+
1555
+ if (!handle || !handle.$$) {
1556
+ throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`);
1557
+ }
1558
+ if (!handle.$$.ptr) {
1559
+ throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`);
1560
+ }
1561
+ if (!this.isConst && handle.$$.ptrType.isConst) {
1562
+ throwBindingError(`Cannot convert argument of type ${(handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name)} to parameter type ${this.name}`);
1563
+ }
1564
+ var handleClass = handle.$$.ptrType.registeredClass;
1565
+ ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
1566
+
1567
+ if (this.isSmartPointer) {
1568
+ // TODO: this is not strictly true
1569
+ // We could support BY_EMVAL conversions from raw pointers to smart pointers
1570
+ // because the smart pointer can hold a reference to the handle
1571
+ if (undefined === handle.$$.smartPtr) {
1572
+ throwBindingError('Passing raw pointer to smart pointer is illegal');
1573
+ }
1574
+
1575
+ switch (this.sharingPolicy) {
1576
+ case 0: // NONE
1577
+ // no upcasting
1578
+ if (handle.$$.smartPtrType === this) {
1579
+ ptr = handle.$$.smartPtr;
1580
+ } else {
1581
+ throwBindingError(`Cannot convert argument of type ${(handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name)} to parameter type ${this.name}`);
1582
+ }
1583
+ break;
1584
+
1585
+ case 1: // INTRUSIVE
1586
+ ptr = handle.$$.smartPtr;
1587
+ break;
1588
+
1589
+ case 2: // BY_EMVAL
1590
+ if (handle.$$.smartPtrType === this) {
1591
+ ptr = handle.$$.smartPtr;
1592
+ } else {
1593
+ var clonedHandle = handle['clone']();
1594
+ ptr = this.rawShare(
1595
+ ptr,
1596
+ Emval.toHandle(() => clonedHandle['delete']())
1597
+ );
1598
+ if (destructors !== null) {
1599
+ destructors.push(this.rawDestructor, ptr);
1600
+ }
1601
+ }
1602
+ break;
1603
+
1604
+ default:
1605
+ throwBindingError('Unsupporting sharing policy');
1606
+ }
1607
+ }
1608
+ return ptr;
1609
+ }
1610
+
1611
+
1612
+
1613
+ /** @suppress {globalThis} */
1614
+ function nonConstNoSmartPtrRawPointerToWireType(destructors, handle) {
1615
+ if (handle === null) {
1616
+ if (this.isReference) {
1617
+ throwBindingError(`null is not a valid ${this.name}`);
1618
+ }
1619
+ return 0;
1620
+ }
1621
+
1622
+ if (!handle.$$) {
1623
+ throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`);
1624
+ }
1625
+ if (!handle.$$.ptr) {
1626
+ throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`);
1627
+ }
1628
+ if (handle.$$.ptrType.isConst) {
1629
+ throwBindingError(`Cannot convert argument of type ${handle.$$.ptrType.name} to parameter type ${this.name}`);
1630
+ }
1631
+ var handleClass = handle.$$.ptrType.registeredClass;
1632
+ var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
1633
+ return ptr;
1634
+ }
1635
+
1636
+
1637
+ /** @suppress {globalThis} */
1638
+ function readPointer(pointer) {
1639
+ return this.fromWireType(HEAPU32[((pointer)>>2)]);
1640
+ }
1641
+
1642
+ var init_RegisteredPointer = () => {
1643
+ Object.assign(RegisteredPointer.prototype, {
1644
+ getPointee(ptr) {
1645
+ if (this.rawGetPointee) {
1646
+ ptr = this.rawGetPointee(ptr);
1647
+ }
1648
+ return ptr;
1649
+ },
1650
+ destructor(ptr) {
1651
+ this.rawDestructor?.(ptr);
1652
+ },
1653
+ readValueFromPointer: readPointer,
1654
+ fromWireType: RegisteredPointer_fromWireType,
1655
+ });
1656
+ };
1657
+ /** @constructor
1658
+ @param {*=} pointeeType,
1659
+ @param {*=} sharingPolicy,
1660
+ @param {*=} rawGetPointee,
1661
+ @param {*=} rawConstructor,
1662
+ @param {*=} rawShare,
1663
+ @param {*=} rawDestructor,
1664
+ */
1665
+ function RegisteredPointer(
1666
+ name,
1667
+ registeredClass,
1668
+ isReference,
1669
+ isConst,
1670
+
1671
+ // smart pointer properties
1672
+ isSmartPointer,
1673
+ pointeeType,
1674
+ sharingPolicy,
1675
+ rawGetPointee,
1676
+ rawConstructor,
1677
+ rawShare,
1678
+ rawDestructor
1679
+ ) {
1680
+ this.name = name;
1681
+ this.registeredClass = registeredClass;
1682
+ this.isReference = isReference;
1683
+ this.isConst = isConst;
1684
+
1685
+ // smart pointer properties
1686
+ this.isSmartPointer = isSmartPointer;
1687
+ this.pointeeType = pointeeType;
1688
+ this.sharingPolicy = sharingPolicy;
1689
+ this.rawGetPointee = rawGetPointee;
1690
+ this.rawConstructor = rawConstructor;
1691
+ this.rawShare = rawShare;
1692
+ this.rawDestructor = rawDestructor;
1693
+
1694
+ if (!isSmartPointer && registeredClass.baseClass === undefined) {
1695
+ if (isConst) {
1696
+ this.toWireType = constNoSmartPtrRawPointerToWireType;
1697
+ this.destructorFunction = null;
1698
+ } else {
1699
+ this.toWireType = nonConstNoSmartPtrRawPointerToWireType;
1700
+ this.destructorFunction = null;
1701
+ }
1702
+ } else {
1703
+ this.toWireType = genericPointerToWireType;
1704
+ // Here we must leave this.destructorFunction undefined, since whether genericPointerToWireType returns
1705
+ // a pointer that needs to be freed up is runtime-dependent, and cannot be evaluated at registration time.
1706
+ // TODO: Create an alternative mechanism that allows removing the use of var destructors = []; array in
1707
+ // craftInvokerFunction altogether.
1708
+ }
1709
+ }
1710
+
1711
+ /** @param {number=} numArguments */
1712
+ var replacePublicSymbol = (name, value, numArguments) => {
1713
+ if (!Module.hasOwnProperty(name)) {
1714
+ throwInternalError('Replacing nonexistent public symbol');
1715
+ }
1716
+ // If there's an overload table for this symbol, replace the symbol in the overload table instead.
1717
+ if (undefined !== Module[name].overloadTable && undefined !== numArguments) {
1718
+ Module[name].overloadTable[numArguments] = value;
1719
+ } else {
1720
+ Module[name] = value;
1721
+ Module[name].argCount = numArguments;
1722
+ }
1723
+ };
1724
+
1725
+
1726
+
1727
+ var wasmTableMirror = [];
1728
+
1729
+
1730
+ var getWasmTableEntry = (funcPtr) => {
1731
+ var func = wasmTableMirror[funcPtr];
1732
+ if (!func) {
1733
+ /** @suppress {checkTypes} */
1734
+ wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
1735
+ }
1736
+ /** @suppress {checkTypes} */
1737
+ assert(wasmTable.get(funcPtr) == func, 'JavaScript-side Wasm function table mirror is out of date!');
1738
+ return func;
1739
+ };
1740
+ var embind__requireFunction = (signature, rawFunction, isAsync = false) => {
1741
+ assert(!isAsync, 'Async bindings are only supported with JSPI.');
1742
+
1743
+ signature = AsciiToString(signature);
1744
+
1745
+ function makeDynCaller() {
1746
+ var rtn = getWasmTableEntry(rawFunction);
1747
+ return rtn;
1748
+ }
1749
+
1750
+ var fp = makeDynCaller();
1751
+ if (typeof fp != 'function') {
1752
+ throwBindingError(`unknown function pointer with signature ${signature}: ${rawFunction}`);
1753
+ }
1754
+ return fp;
1755
+ };
1756
+
1757
+
1758
+
1759
+ class UnboundTypeError extends Error {}
1760
+
1761
+
1762
+
1763
+ var getTypeName = (type) => {
1764
+ var ptr = ___getTypeName(type);
1765
+ var rv = AsciiToString(ptr);
1766
+ _free(ptr);
1767
+ return rv;
1768
+ };
1769
+ var throwUnboundTypeError = (message, types) => {
1770
+ var unboundTypes = [];
1771
+ var seen = {};
1772
+ function visit(type) {
1773
+ if (seen[type]) {
1774
+ return;
1775
+ }
1776
+ if (registeredTypes[type]) {
1777
+ return;
1778
+ }
1779
+ if (typeDependencies[type]) {
1780
+ typeDependencies[type].forEach(visit);
1781
+ return;
1782
+ }
1783
+ unboundTypes.push(type);
1784
+ seen[type] = true;
1785
+ }
1786
+ types.forEach(visit);
1787
+
1788
+ throw new UnboundTypeError(`${message}: ` + unboundTypes.map(getTypeName).join([', ']));
1789
+ };
1790
+
1791
+
1792
+
1793
+
1794
+ var whenDependentTypesAreResolved = (myTypes, dependentTypes, getTypeConverters) => {
1795
+ myTypes.forEach((type) => typeDependencies[type] = dependentTypes);
1796
+
1797
+ function onComplete(typeConverters) {
1798
+ var myTypeConverters = getTypeConverters(typeConverters);
1799
+ if (myTypeConverters.length !== myTypes.length) {
1800
+ throwInternalError('Mismatched type converter count');
1801
+ }
1802
+ for (var i = 0; i < myTypes.length; ++i) {
1803
+ registerType(myTypes[i], myTypeConverters[i]);
1804
+ }
1805
+ }
1806
+
1807
+ var typeConverters = new Array(dependentTypes.length);
1808
+ var unregisteredTypes = [];
1809
+ var registered = 0;
1810
+ for (let [i, dt] of dependentTypes.entries()) {
1811
+ if (registeredTypes.hasOwnProperty(dt)) {
1812
+ typeConverters[i] = registeredTypes[dt];
1813
+ } else {
1814
+ unregisteredTypes.push(dt);
1815
+ if (!awaitingDependencies.hasOwnProperty(dt)) {
1816
+ awaitingDependencies[dt] = [];
1817
+ }
1818
+ awaitingDependencies[dt].push(() => {
1819
+ typeConverters[i] = registeredTypes[dt];
1820
+ ++registered;
1821
+ if (registered === unregisteredTypes.length) {
1822
+ onComplete(typeConverters);
1823
+ }
1824
+ });
1825
+ }
1826
+ }
1827
+ if (0 === unregisteredTypes.length) {
1828
+ onComplete(typeConverters);
1829
+ }
1830
+ };
1831
+ var __embind_register_class = (rawType,
1832
+ rawPointerType,
1833
+ rawConstPointerType,
1834
+ baseClassRawType,
1835
+ getActualTypeSignature,
1836
+ getActualType,
1837
+ upcastSignature,
1838
+ upcast,
1839
+ downcastSignature,
1840
+ downcast,
1841
+ name,
1842
+ destructorSignature,
1843
+ rawDestructor) => {
1844
+ name = AsciiToString(name);
1845
+ getActualType = embind__requireFunction(getActualTypeSignature, getActualType);
1846
+ upcast &&= embind__requireFunction(upcastSignature, upcast);
1847
+ downcast &&= embind__requireFunction(downcastSignature, downcast);
1848
+ rawDestructor = embind__requireFunction(destructorSignature, rawDestructor);
1849
+ var legalFunctionName = makeLegalFunctionName(name);
1850
+
1851
+ exposePublicSymbol(legalFunctionName, function() {
1852
+ // this code cannot run if baseClassRawType is zero
1853
+ throwUnboundTypeError(`Cannot construct ${name} due to unbound types`, [baseClassRawType]);
1854
+ });
1855
+
1856
+ whenDependentTypesAreResolved(
1857
+ [rawType, rawPointerType, rawConstPointerType],
1858
+ baseClassRawType ? [baseClassRawType] : [],
1859
+ (base) => {
1860
+ base = base[0];
1861
+
1862
+ var baseClass;
1863
+ var basePrototype;
1864
+ if (baseClassRawType) {
1865
+ baseClass = base.registeredClass;
1866
+ basePrototype = baseClass.instancePrototype;
1867
+ } else {
1868
+ basePrototype = ClassHandle.prototype;
1869
+ }
1870
+
1871
+ var constructor = createNamedFunction(name, function(...args) {
1872
+ if (Object.getPrototypeOf(this) !== instancePrototype) {
1873
+ throw new BindingError(`Use 'new' to construct ${name}`);
1874
+ }
1875
+ if (undefined === registeredClass.constructor_body) {
1876
+ throw new BindingError(`${name} has no accessible constructor`);
1877
+ }
1878
+ var body = registeredClass.constructor_body[args.length];
1879
+ if (undefined === body) {
1880
+ throw new BindingError(`Tried to invoke ctor of ${name} with invalid number of parameters (${args.length}) - expected (${Object.keys(registeredClass.constructor_body).toString()}) parameters instead!`);
1881
+ }
1882
+ return body.apply(this, args);
1883
+ });
1884
+
1885
+ var instancePrototype = Object.create(basePrototype, {
1886
+ constructor: { value: constructor },
1887
+ });
1888
+
1889
+ constructor.prototype = instancePrototype;
1890
+
1891
+ var registeredClass = new RegisteredClass(name,
1892
+ constructor,
1893
+ instancePrototype,
1894
+ rawDestructor,
1895
+ baseClass,
1896
+ getActualType,
1897
+ upcast,
1898
+ downcast);
1899
+
1900
+ if (registeredClass.baseClass) {
1901
+ // Keep track of class hierarchy. Used to allow sub-classes to inherit class functions.
1902
+ registeredClass.baseClass.__derivedClasses ??= [];
1903
+
1904
+ registeredClass.baseClass.__derivedClasses.push(registeredClass);
1905
+ }
1906
+
1907
+ var referenceConverter = new RegisteredPointer(name,
1908
+ registeredClass,
1909
+ true,
1910
+ false,
1911
+ false);
1912
+
1913
+ var pointerConverter = new RegisteredPointer(name + '*',
1914
+ registeredClass,
1915
+ false,
1916
+ false,
1917
+ false);
1918
+
1919
+ var constPointerConverter = new RegisteredPointer(name + ' const*',
1920
+ registeredClass,
1921
+ false,
1922
+ true,
1923
+ false);
1924
+
1925
+ registeredPointers[rawType] = {
1926
+ pointerType: pointerConverter,
1927
+ constPointerType: constPointerConverter
1928
+ };
1929
+
1930
+ replacePublicSymbol(legalFunctionName, constructor);
1931
+
1932
+ return [referenceConverter, pointerConverter, constPointerConverter];
1933
+ }
1934
+ );
1935
+ };
1936
+
1937
+ var heap32VectorToArray = (count, firstElement) => {
1938
+ var array = [];
1939
+ for (var i = 0; i < count; i++) {
1940
+ // TODO(https://github.com/emscripten-core/emscripten/issues/17310):
1941
+ // Find a way to hoist the `>> 2` or `>> 3` out of this loop.
1942
+ array.push(HEAPU32[(((firstElement)+(i * 4))>>2)]);
1943
+ }
1944
+ return array;
1945
+ };
1946
+
1947
+
1948
+
1949
+
1950
+ var runDestructors = (destructors) => {
1951
+ while (destructors.length) {
1952
+ var ptr = destructors.pop();
1953
+ var del = destructors.pop();
1954
+ del(ptr);
1955
+ }
1956
+ };
1957
+
1958
+
1959
+ function usesDestructorStack(argTypes) {
1960
+ // Skip return value at index 0 - it's not deleted here.
1961
+ for (var i = 1; i < argTypes.length; ++i) {
1962
+ // The type does not define a destructor function - must use dynamic stack
1963
+ if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) {
1964
+ return true;
1965
+ }
1966
+ }
1967
+ return false;
1968
+ }
1969
+
1970
+
1971
+ function checkArgCount(numArgs, minArgs, maxArgs, humanName, throwBindingError) {
1972
+ if (numArgs < minArgs || numArgs > maxArgs) {
1973
+ var argCountMessage = minArgs == maxArgs ? minArgs : `${minArgs} to ${maxArgs}`;
1974
+ throwBindingError(`function ${humanName} called with ${numArgs} arguments, expected ${argCountMessage}`);
1975
+ }
1976
+ }
1977
+ function createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync) {
1978
+ var needsDestructorStack = usesDestructorStack(argTypes);
1979
+ var argCount = argTypes.length - 2;
1980
+ var argsList = [];
1981
+ var argsListWired = ['fn'];
1982
+ if (isClassMethodFunc) {
1983
+ argsListWired.push('thisWired');
1984
+ }
1985
+ for (var i = 0; i < argCount; ++i) {
1986
+ argsList.push(`arg${i}`)
1987
+ argsListWired.push(`arg${i}Wired`)
1988
+ }
1989
+ argsList = argsList.join(',')
1990
+ argsListWired = argsListWired.join(',')
1991
+
1992
+ var invokerFnBody = `return function (${argsList}) {\n`;
1993
+
1994
+ invokerFnBody += "checkArgCount(arguments.length, minArgs, maxArgs, humanName, throwBindingError);\n";
1995
+
1996
+ if (needsDestructorStack) {
1997
+ invokerFnBody += "var destructors = [];\n";
1998
+ }
1999
+
2000
+ var dtorStack = needsDestructorStack ? "destructors" : "null";
2001
+ var args1 = ["humanName", "throwBindingError", "invoker", "fn", "runDestructors", "fromRetWire", "toClassParamWire"];
2002
+
2003
+ if (isClassMethodFunc) {
2004
+ invokerFnBody += `var thisWired = toClassParamWire(${dtorStack}, this);\n`;
2005
+ }
2006
+
2007
+ for (var i = 0; i < argCount; ++i) {
2008
+ var argName = `toArg${i}Wire`;
2009
+ invokerFnBody += `var arg${i}Wired = ${argName}(${dtorStack}, arg${i});\n`;
2010
+ args1.push(argName);
2011
+ }
2012
+
2013
+ invokerFnBody += (returns || isAsync ? "var rv = ":"") + `invoker(${argsListWired});\n`;
2014
+
2015
+ var returnVal = returns ? "rv" : "";
2016
+
2017
+ if (needsDestructorStack) {
2018
+ invokerFnBody += "runDestructors(destructors);\n";
2019
+ } else {
2020
+ for (var i = isClassMethodFunc?1:2; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here. Also skip class type if not a method.
2021
+ var paramName = (i === 1 ? "thisWired" : ("arg"+(i - 2)+"Wired"));
2022
+ if (argTypes[i].destructorFunction !== null) {
2023
+ invokerFnBody += `${paramName}_dtor(${paramName});\n`;
2024
+ args1.push(`${paramName}_dtor`);
2025
+ }
2026
+ }
2027
+ }
2028
+
2029
+ if (returns) {
2030
+ invokerFnBody += "var ret = fromRetWire(rv);\n" +
2031
+ "return ret;\n";
2032
+ } else {
2033
+ }
2034
+
2035
+ invokerFnBody += "}\n";
2036
+
2037
+ args1.push('checkArgCount', 'minArgs', 'maxArgs');
2038
+ invokerFnBody = `if (arguments.length !== ${args1.length}){ throw new Error(humanName + "Expected ${args1.length} closure arguments " + arguments.length + " given."); }\n${invokerFnBody}`;
2039
+ return new Function(args1, invokerFnBody);
2040
+ }
2041
+
2042
+ function getRequiredArgCount(argTypes) {
2043
+ var requiredArgCount = argTypes.length - 2;
2044
+ for (var i = argTypes.length - 1; i >= 2; --i) {
2045
+ if (!argTypes[i].optional) {
2046
+ break;
2047
+ }
2048
+ requiredArgCount--;
2049
+ }
2050
+ return requiredArgCount;
2051
+ }
2052
+
2053
+ function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc, /** boolean= */ isAsync) {
2054
+ // humanName: a human-readable string name for the function to be generated.
2055
+ // argTypes: An array that contains the embind type objects for all types in the function signature.
2056
+ // argTypes[0] is the type object for the function return value.
2057
+ // argTypes[1] is the type object for function this object/class type, or null if not crafting an invoker for a class method.
2058
+ // argTypes[2...] are the actual function parameters.
2059
+ // classType: The embind type object for the class to be bound, or null if this is not a method of a class.
2060
+ // cppInvokerFunc: JS Function object to the C++-side function that interops into C++ code.
2061
+ // cppTargetFunc: Function pointer (an integer to FUNCTION_TABLE) to the target C++ function the cppInvokerFunc will end up calling.
2062
+ // isAsync: Optional. If true, returns an async function. Async bindings are only supported with JSPI.
2063
+ var argCount = argTypes.length;
2064
+
2065
+ if (argCount < 2) {
2066
+ throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
2067
+ }
2068
+
2069
+ assert(!isAsync, 'Async bindings are only supported with JSPI.');
2070
+ var isClassMethodFunc = (argTypes[1] !== null && classType !== null);
2071
+
2072
+ // Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
2073
+ // TODO: This omits argument count check - enable only at -O3 or similar.
2074
+ // if (ENABLE_UNSAFE_OPTS && argCount == 2 && argTypes[0].name == "void" && !isClassMethodFunc) {
2075
+ // return FUNCTION_TABLE[fn];
2076
+ // }
2077
+
2078
+ // Determine if we need to use a dynamic stack to store the destructors for the function parameters.
2079
+ // TODO: Remove this completely once all function invokers are being dynamically generated.
2080
+ var needsDestructorStack = usesDestructorStack(argTypes);
2081
+
2082
+ var returns = !argTypes[0].isVoid;
2083
+
2084
+ var expectedArgCount = argCount - 2;
2085
+ var minArgs = getRequiredArgCount(argTypes);
2086
+ // Builld the arguments that will be passed into the closure around the invoker
2087
+ // function.
2088
+ var retType = argTypes[0];
2089
+ var instType = argTypes[1];
2090
+ var closureArgs = [humanName, throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, retType.fromWireType.bind(retType), instType?.toWireType.bind(instType)];
2091
+ for (var i = 2; i < argCount; ++i) {
2092
+ var argType = argTypes[i];
2093
+ closureArgs.push(argType.toWireType.bind(argType));
2094
+ }
2095
+ if (!needsDestructorStack) {
2096
+ // Skip return value at index 0 - it's not deleted here. Also skip class type if not a method.
2097
+ for (var i = isClassMethodFunc?1:2; i < argTypes.length; ++i) {
2098
+ if (argTypes[i].destructorFunction !== null) {
2099
+ closureArgs.push(argTypes[i].destructorFunction);
2100
+ }
2101
+ }
2102
+ }
2103
+ closureArgs.push(checkArgCount, minArgs, expectedArgCount);
2104
+
2105
+ let invokerFactory = createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync);
2106
+ var invokerFn = invokerFactory(...closureArgs);
2107
+ return createNamedFunction(humanName, invokerFn);
2108
+ }
2109
+ var __embind_register_class_constructor = (
2110
+ rawClassType,
2111
+ argCount,
2112
+ rawArgTypesAddr,
2113
+ invokerSignature,
2114
+ invoker,
2115
+ rawConstructor
2116
+ ) => {
2117
+ assert(argCount > 0);
2118
+ var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
2119
+ invoker = embind__requireFunction(invokerSignature, invoker);
2120
+ var args = [rawConstructor];
2121
+ var destructors = [];
2122
+
2123
+ whenDependentTypesAreResolved([], [rawClassType], (classType) => {
2124
+ classType = classType[0];
2125
+ var humanName = `constructor ${classType.name}`;
2126
+
2127
+ if (undefined === classType.registeredClass.constructor_body) {
2128
+ classType.registeredClass.constructor_body = [];
2129
+ }
2130
+ if (undefined !== classType.registeredClass.constructor_body[argCount - 1]) {
2131
+ throw new BindingError(`Cannot register multiple constructors with identical number of parameters (${argCount-1}) for class '${classType.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);
2132
+ }
2133
+ classType.registeredClass.constructor_body[argCount - 1] = () => {
2134
+ throwUnboundTypeError(`Cannot construct ${classType.name} due to unbound types`, rawArgTypes);
2135
+ };
2136
+
2137
+ whenDependentTypesAreResolved([], rawArgTypes, (argTypes) => {
2138
+ // Insert empty slot for context type (argTypes[1]).
2139
+ argTypes.splice(1, 0, null);
2140
+ classType.registeredClass.constructor_body[argCount - 1] = craftInvokerFunction(humanName, argTypes, null, invoker, rawConstructor);
2141
+ return [];
2142
+ });
2143
+ return [];
2144
+ });
2145
+ };
2146
+
2147
+
2148
+
2149
+
2150
+
2151
+
2152
+
2153
+ var getFunctionName = (signature) => {
2154
+ signature = signature.trim();
2155
+ const argsIndex = signature.indexOf("(");
2156
+ if (argsIndex === -1) return signature;
2157
+ assert(signature.endsWith(")"), "Parentheses for argument names should match.");
2158
+ return signature.slice(0, argsIndex);
2159
+ };
2160
+ var __embind_register_class_function = (rawClassType,
2161
+ methodName,
2162
+ argCount,
2163
+ rawArgTypesAddr, // [ReturnType, ThisType, Args...]
2164
+ invokerSignature,
2165
+ rawInvoker,
2166
+ context,
2167
+ isPureVirtual,
2168
+ isAsync,
2169
+ isNonnullReturn) => {
2170
+ var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
2171
+ methodName = AsciiToString(methodName);
2172
+ methodName = getFunctionName(methodName);
2173
+ rawInvoker = embind__requireFunction(invokerSignature, rawInvoker, isAsync);
2174
+
2175
+ whenDependentTypesAreResolved([], [rawClassType], (classType) => {
2176
+ classType = classType[0];
2177
+ var humanName = `${classType.name}.${methodName}`;
2178
+
2179
+ if (methodName.startsWith("@@")) {
2180
+ methodName = Symbol[methodName.substring(2)];
2181
+ }
2182
+
2183
+ if (isPureVirtual) {
2184
+ classType.registeredClass.pureVirtualFunctions.push(methodName);
2185
+ }
2186
+
2187
+ function unboundTypesHandler() {
2188
+ throwUnboundTypeError(`Cannot call ${humanName} due to unbound types`, rawArgTypes);
2189
+ }
2190
+
2191
+ var proto = classType.registeredClass.instancePrototype;
2192
+ var method = proto[methodName];
2193
+ if (undefined === method || (undefined === method.overloadTable && method.className !== classType.name && method.argCount === argCount - 2)) {
2194
+ // This is the first overload to be registered, OR we are replacing a
2195
+ // function in the base class with a function in the derived class.
2196
+ unboundTypesHandler.argCount = argCount - 2;
2197
+ unboundTypesHandler.className = classType.name;
2198
+ proto[methodName] = unboundTypesHandler;
2199
+ } else {
2200
+ // There was an existing function with the same name registered. Set up
2201
+ // a function overload routing table.
2202
+ ensureOverloadTable(proto, methodName, humanName);
2203
+ proto[methodName].overloadTable[argCount - 2] = unboundTypesHandler;
2204
+ }
2205
+
2206
+ whenDependentTypesAreResolved([], rawArgTypes, (argTypes) => {
2207
+ var memberFunction = craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context, isAsync);
2208
+
2209
+ // Replace the initial unbound-handler-stub function with the
2210
+ // appropriate member function, now that all types are resolved. If
2211
+ // multiple overloads are registered for this function, the function
2212
+ // goes into an overload table.
2213
+ if (undefined === proto[methodName].overloadTable) {
2214
+ // Set argCount in case an overload is registered later
2215
+ memberFunction.argCount = argCount - 2;
2216
+ proto[methodName] = memberFunction;
2217
+ } else {
2218
+ proto[methodName].overloadTable[argCount - 2] = memberFunction;
2219
+ }
2220
+
2221
+ return [];
2222
+ });
2223
+ return [];
2224
+ });
2225
+ };
2226
+
2227
+
2228
+ var emval_freelist = [];
2229
+
2230
+ var emval_handles = [0,1,,1,null,1,true,1,false,1];
2231
+ var __emval_decref = (handle) => {
2232
+ if (handle > 9 && 0 === --emval_handles[handle + 1]) {
2233
+ assert(emval_handles[handle] !== undefined, `Decref for unallocated handle.`);
2234
+ emval_handles[handle] = undefined;
2235
+ emval_freelist.push(handle);
2236
+ }
2237
+ };
2238
+
2239
+
2240
+
2241
+ var Emval = {
2242
+ toValue:(handle) => {
2243
+ if (!handle) {
2244
+ throwBindingError(`Cannot use deleted val. handle = ${handle}`);
2245
+ }
2246
+ // handle 2 is supposed to be `undefined`.
2247
+ assert(handle === 2 || emval_handles[handle] !== undefined && handle % 2 === 0, `invalid handle: ${handle}`);
2248
+ return emval_handles[handle];
2249
+ },
2250
+ toHandle:(value) => {
2251
+ switch (value) {
2252
+ case undefined: return 2;
2253
+ case null: return 4;
2254
+ case true: return 6;
2255
+ case false: return 8;
2256
+ default:{
2257
+ const handle = emval_freelist.pop() || emval_handles.length;
2258
+ emval_handles[handle] = value;
2259
+ emval_handles[handle + 1] = 1;
2260
+ return handle;
2261
+ }
2262
+ }
2263
+ },
2264
+ };
2265
+
2266
+ var EmValType = {
2267
+ name: 'emscripten::val',
2268
+ fromWireType: (handle) => {
2269
+ var rv = Emval.toValue(handle);
2270
+ __emval_decref(handle);
2271
+ return rv;
2272
+ },
2273
+ toWireType: (destructors, value) => Emval.toHandle(value),
2274
+ readValueFromPointer: readPointer,
2275
+ destructorFunction: null, // This type does not need a destructor
2276
+
2277
+ // TODO: do we need a deleteObject here? write a test where
2278
+ // emval is passed into JS via an interface
2279
+ };
2280
+ var __embind_register_emval = (rawType) => registerType(rawType, EmValType);
2281
+
2282
+ var floatReadValueFromPointer = (name, width) => {
2283
+ switch (width) {
2284
+ case 4: return function(pointer) {
2285
+ return this.fromWireType(HEAPF32[((pointer)>>2)]);
2286
+ };
2287
+ case 8: return function(pointer) {
2288
+ return this.fromWireType(HEAPF64[((pointer)>>3)]);
2289
+ };
2290
+ default:
2291
+ throw new TypeError(`invalid float width (${width}): ${name}`);
2292
+ }
2293
+ };
2294
+
2295
+
2296
+
2297
+ var __embind_register_float = (rawType, name, size) => {
2298
+ name = AsciiToString(name);
2299
+ registerType(rawType, {
2300
+ name,
2301
+ fromWireType: (value) => value,
2302
+ toWireType: (destructors, value) => {
2303
+ if (typeof value != "number" && typeof value != "boolean") {
2304
+ throw new TypeError(`Cannot convert ${embindRepr(value)} to ${this.name}`);
2305
+ }
2306
+ // The VM will perform JS to Wasm value conversion, according to the spec:
2307
+ // https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue
2308
+ return value;
2309
+ },
2310
+ readValueFromPointer: floatReadValueFromPointer(name, size),
2311
+ destructorFunction: null, // This type does not need a destructor
2312
+ });
2313
+ };
2314
+
2315
+
2316
+
2317
+
2318
+
2319
+
2320
+
2321
+
2322
+
2323
+ var __embind_register_function = (name, argCount, rawArgTypesAddr, signature, rawInvoker, fn, isAsync, isNonnullReturn) => {
2324
+ var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
2325
+ name = AsciiToString(name);
2326
+ name = getFunctionName(name);
2327
+
2328
+ rawInvoker = embind__requireFunction(signature, rawInvoker, isAsync);
2329
+
2330
+ exposePublicSymbol(name, function() {
2331
+ throwUnboundTypeError(`Cannot call ${name} due to unbound types`, argTypes);
2332
+ }, argCount - 1);
2333
+
2334
+ whenDependentTypesAreResolved([], argTypes, (argTypes) => {
2335
+ var invokerArgsArray = [argTypes[0] /* return value */, null /* no class 'this'*/].concat(argTypes.slice(1) /* actual params */);
2336
+ replacePublicSymbol(name, craftInvokerFunction(name, invokerArgsArray, null /* no class 'this'*/, rawInvoker, fn, isAsync), argCount - 1);
2337
+ return [];
2338
+ });
2339
+ };
2340
+
2341
+
2342
+
2343
+
2344
+
2345
+ /** @suppress {globalThis} */
2346
+ var __embind_register_integer = (primitiveType, name, size, minRange, maxRange) => {
2347
+ name = AsciiToString(name);
2348
+
2349
+ const isUnsignedType = minRange === 0;
2350
+
2351
+ let fromWireType = (value) => value;
2352
+ if (isUnsignedType) {
2353
+ var bitshift = 32 - 8*size;
2354
+ fromWireType = (value) => (value << bitshift) >>> bitshift;
2355
+ maxRange = fromWireType(maxRange);
2356
+ }
2357
+
2358
+ registerType(primitiveType, {
2359
+ name,
2360
+ fromWireType: fromWireType,
2361
+ toWireType: (destructors, value) => {
2362
+ if (typeof value != "number" && typeof value != "boolean") {
2363
+ throw new TypeError(`Cannot convert "${embindRepr(value)}" to ${name}`);
2364
+ }
2365
+ assertIntegerRange(name, value, minRange, maxRange);
2366
+ // The VM will perform JS to Wasm value conversion, according to the spec:
2367
+ // https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue
2368
+ return value;
2369
+ },
2370
+ readValueFromPointer: integerReadValueFromPointer(name, size, minRange !== 0),
2371
+ destructorFunction: null, // This type does not need a destructor
2372
+ });
2373
+ };
2374
+
2375
+
2376
+ var __embind_register_memory_view = (rawType, dataTypeIndex, name) => {
2377
+ var typeMapping = [
2378
+ Int8Array,
2379
+ Uint8Array,
2380
+ Int16Array,
2381
+ Uint16Array,
2382
+ Int32Array,
2383
+ Uint32Array,
2384
+ Float32Array,
2385
+ Float64Array,
2386
+ BigInt64Array,
2387
+ BigUint64Array,
2388
+ ];
2389
+
2390
+ var TA = typeMapping[dataTypeIndex];
2391
+
2392
+ function decodeMemoryView(handle) {
2393
+ var size = HEAPU32[((handle)>>2)];
2394
+ var data = HEAPU32[(((handle)+(4))>>2)];
2395
+ return new TA(HEAP8.buffer, data, size);
2396
+ }
2397
+
2398
+ name = AsciiToString(name);
2399
+ registerType(rawType, {
2400
+ name,
2401
+ fromWireType: decodeMemoryView,
2402
+ readValueFromPointer: decodeMemoryView,
2403
+ }, {
2404
+ ignoreDuplicateRegistrations: true,
2405
+ });
2406
+ };
2407
+
2408
+
2409
+
2410
+ var __embind_register_smart_ptr = (rawType,
2411
+ rawPointeeType,
2412
+ name,
2413
+ sharingPolicy,
2414
+ getPointeeSignature,
2415
+ rawGetPointee,
2416
+ constructorSignature,
2417
+ rawConstructor,
2418
+ shareSignature,
2419
+ rawShare,
2420
+ destructorSignature,
2421
+ rawDestructor) => {
2422
+ name = AsciiToString(name);
2423
+ rawGetPointee = embind__requireFunction(getPointeeSignature, rawGetPointee);
2424
+ rawConstructor = embind__requireFunction(constructorSignature, rawConstructor);
2425
+ rawShare = embind__requireFunction(shareSignature, rawShare);
2426
+ rawDestructor = embind__requireFunction(destructorSignature, rawDestructor);
2427
+
2428
+ whenDependentTypesAreResolved([rawType], [rawPointeeType], (pointeeType) => {
2429
+ pointeeType = pointeeType[0];
2430
+
2431
+ var registeredPointer = new RegisteredPointer(name,
2432
+ pointeeType.registeredClass,
2433
+ false,
2434
+ false,
2435
+ // smart pointer properties
2436
+ true,
2437
+ pointeeType,
2438
+ sharingPolicy,
2439
+ rawGetPointee,
2440
+ rawConstructor,
2441
+ rawShare,
2442
+ rawDestructor);
2443
+ return [registeredPointer];
2444
+ });
2445
+ };
2446
+
2447
+
2448
+
2449
+
2450
+
2451
+ var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
2452
+ assert(typeof str === 'string', `stringToUTF8Array expects a string (got ${typeof str})`);
2453
+ // Parameter maxBytesToWrite is not optional. Negative values, 0, null,
2454
+ // undefined and false each don't write out any bytes.
2455
+ if (!(maxBytesToWrite > 0))
2456
+ return 0;
2457
+
2458
+ var startIdx = outIdx;
2459
+ var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
2460
+ for (var i = 0; i < str.length; ++i) {
2461
+ // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
2462
+ // and https://www.ietf.org/rfc/rfc2279.txt
2463
+ // and https://tools.ietf.org/html/rfc3629
2464
+ var u = str.codePointAt(i);
2465
+ if (u <= 0x7F) {
2466
+ if (outIdx >= endIdx) break;
2467
+ heap[outIdx++] = u;
2468
+ } else if (u <= 0x7FF) {
2469
+ if (outIdx + 1 >= endIdx) break;
2470
+ heap[outIdx++] = 0xC0 | (u >> 6);
2471
+ heap[outIdx++] = 0x80 | (u & 63);
2472
+ } else if (u <= 0xFFFF) {
2473
+ if (outIdx + 2 >= endIdx) break;
2474
+ heap[outIdx++] = 0xE0 | (u >> 12);
2475
+ heap[outIdx++] = 0x80 | ((u >> 6) & 63);
2476
+ heap[outIdx++] = 0x80 | (u & 63);
2477
+ } else {
2478
+ if (outIdx + 3 >= endIdx) break;
2479
+ 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).');
2480
+ heap[outIdx++] = 0xF0 | (u >> 18);
2481
+ heap[outIdx++] = 0x80 | ((u >> 12) & 63);
2482
+ heap[outIdx++] = 0x80 | ((u >> 6) & 63);
2483
+ heap[outIdx++] = 0x80 | (u & 63);
2484
+ // Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
2485
+ // We need to manually skip over the second code unit for correct iteration.
2486
+ i++;
2487
+ }
2488
+ }
2489
+ // Null-terminate the pointer to the buffer.
2490
+ heap[outIdx] = 0;
2491
+ return outIdx - startIdx;
2492
+ };
2493
+ var stringToUTF8 = (str, outPtr, maxBytesToWrite) => {
2494
+ assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
2495
+ return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
2496
+ };
2497
+
2498
+ var lengthBytesUTF8 = (str) => {
2499
+ var len = 0;
2500
+ for (var i = 0; i < str.length; ++i) {
2501
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
2502
+ // unit, not a Unicode code point of the character! So decode
2503
+ // UTF16->UTF32->UTF8.
2504
+ // See http://unicode.org/faq/utf_bom.html#utf16-3
2505
+ var c = str.charCodeAt(i); // possibly a lead surrogate
2506
+ if (c <= 0x7F) {
2507
+ len++;
2508
+ } else if (c <= 0x7FF) {
2509
+ len += 2;
2510
+ } else if (c >= 0xD800 && c <= 0xDFFF) {
2511
+ len += 4; ++i;
2512
+ } else {
2513
+ len += 3;
2514
+ }
2515
+ }
2516
+ return len;
2517
+ };
2518
+
2519
+
2520
+
2521
+ var __embind_register_std_string = (rawType, name) => {
2522
+ name = AsciiToString(name);
2523
+ var stdStringIsUTF8 = true;
2524
+
2525
+ registerType(rawType, {
2526
+ name,
2527
+ // For some method names we use string keys here since they are part of
2528
+ // the public/external API and/or used by the runtime-generated code.
2529
+ fromWireType(value) {
2530
+ var length = HEAPU32[((value)>>2)];
2531
+ var payload = value + 4;
2532
+
2533
+ var str;
2534
+ if (stdStringIsUTF8) {
2535
+ str = UTF8ToString(payload, length, true);
2536
+ } else {
2537
+ str = '';
2538
+ for (var i = 0; i < length; ++i) {
2539
+ str += String.fromCharCode(HEAPU8[payload + i]);
2540
+ }
2541
+ }
2542
+
2543
+ _free(value);
2544
+
2545
+ return str;
2546
+ },
2547
+ toWireType(destructors, value) {
2548
+ if (value instanceof ArrayBuffer) {
2549
+ value = new Uint8Array(value);
2550
+ }
2551
+
2552
+ var length;
2553
+ var valueIsOfTypeString = (typeof value == 'string');
2554
+
2555
+ // We accept `string` or array views with single byte elements
2556
+ if (!(valueIsOfTypeString || (ArrayBuffer.isView(value) && value.BYTES_PER_ELEMENT == 1))) {
2557
+ throwBindingError('Cannot pass non-string to std::string');
2558
+ }
2559
+ if (stdStringIsUTF8 && valueIsOfTypeString) {
2560
+ length = lengthBytesUTF8(value);
2561
+ } else {
2562
+ length = value.length;
2563
+ }
2564
+
2565
+ // assumes POINTER_SIZE alignment
2566
+ var base = _malloc(4 + length + 1);
2567
+ var ptr = base + 4;
2568
+ HEAPU32[((base)>>2)] = length;
2569
+ if (valueIsOfTypeString) {
2570
+ if (stdStringIsUTF8) {
2571
+ stringToUTF8(value, ptr, length + 1);
2572
+ } else {
2573
+ for (var i = 0; i < length; ++i) {
2574
+ var charCode = value.charCodeAt(i);
2575
+ if (charCode > 255) {
2576
+ _free(base);
2577
+ throwBindingError('String has UTF-16 code units that do not fit in 8 bits');
2578
+ }
2579
+ HEAPU8[ptr + i] = charCode;
2580
+ }
2581
+ }
2582
+ } else {
2583
+ HEAPU8.set(value, ptr);
2584
+ }
2585
+
2586
+ if (destructors !== null) {
2587
+ destructors.push(_free, base);
2588
+ }
2589
+ return base;
2590
+ },
2591
+ readValueFromPointer: readPointer,
2592
+ destructorFunction(ptr) {
2593
+ _free(ptr);
2594
+ },
2595
+ });
2596
+ };
2597
+
2598
+
2599
+
2600
+
2601
+ var UTF16Decoder = globalThis.TextDecoder ? new TextDecoder('utf-16le') : undefined;;
2602
+
2603
+ var UTF16ToString = (ptr, maxBytesToRead, ignoreNul) => {
2604
+ assert(ptr % 2 == 0, 'Pointer passed to UTF16ToString must be aligned to two bytes!');
2605
+ var idx = ((ptr)>>1);
2606
+ var endIdx = findStringEnd(HEAPU16, idx, maxBytesToRead / 2, ignoreNul);
2607
+
2608
+ // When using conditional TextDecoder, skip it for short strings as the overhead of the native call is not worth it.
2609
+ if (endIdx - idx > 16 && UTF16Decoder)
2610
+ return UTF16Decoder.decode(HEAPU16.subarray(idx, endIdx));
2611
+
2612
+ // Fallback: decode without UTF16Decoder
2613
+ var str = '';
2614
+
2615
+ // If maxBytesToRead is not passed explicitly, it will be undefined, and the
2616
+ // for-loop's condition will always evaluate to true. The loop is then
2617
+ // terminated on the first null char.
2618
+ for (var i = idx; i < endIdx; ++i) {
2619
+ var codeUnit = HEAPU16[i];
2620
+ // fromCharCode constructs a character from a UTF-16 code unit, so we can
2621
+ // pass the UTF16 string right through.
2622
+ str += String.fromCharCode(codeUnit);
2623
+ }
2624
+
2625
+ return str;
2626
+ };
2627
+
2628
+ var stringToUTF16 = (str, outPtr, maxBytesToWrite) => {
2629
+ assert(outPtr % 2 == 0, 'Pointer passed to stringToUTF16 must be aligned to two bytes!');
2630
+ assert(typeof maxBytesToWrite == 'number', 'stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
2631
+ // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
2632
+ maxBytesToWrite ??= 0x7FFFFFFF;
2633
+ if (maxBytesToWrite < 2) return 0;
2634
+ maxBytesToWrite -= 2; // Null terminator.
2635
+ var startPtr = outPtr;
2636
+ var numCharsToWrite = (maxBytesToWrite < str.length*2) ? (maxBytesToWrite / 2) : str.length;
2637
+ for (var i = 0; i < numCharsToWrite; ++i) {
2638
+ // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
2639
+ var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
2640
+ HEAP16[((outPtr)>>1)] = codeUnit;
2641
+ outPtr += 2;
2642
+ }
2643
+ // Null-terminate the pointer to the HEAP.
2644
+ HEAP16[((outPtr)>>1)] = 0;
2645
+ return outPtr - startPtr;
2646
+ };
2647
+
2648
+ var lengthBytesUTF16 = (str) => str.length*2;
2649
+
2650
+ var UTF32ToString = (ptr, maxBytesToRead, ignoreNul) => {
2651
+ assert(ptr % 4 == 0, 'Pointer passed to UTF32ToString must be aligned to four bytes!');
2652
+ var str = '';
2653
+ var startIdx = ((ptr)>>2);
2654
+ // If maxBytesToRead is not passed explicitly, it will be undefined, and this
2655
+ // will always evaluate to true. This saves on code size.
2656
+ for (var i = 0; !(i >= maxBytesToRead / 4); i++) {
2657
+ var utf32 = HEAPU32[startIdx + i];
2658
+ if (!utf32 && !ignoreNul) break;
2659
+ str += String.fromCodePoint(utf32);
2660
+ }
2661
+ return str;
2662
+ };
2663
+
2664
+ var stringToUTF32 = (str, outPtr, maxBytesToWrite) => {
2665
+ assert(outPtr % 4 == 0, 'Pointer passed to stringToUTF32 must be aligned to four bytes!');
2666
+ assert(typeof maxBytesToWrite == 'number', 'stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
2667
+ // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
2668
+ maxBytesToWrite ??= 0x7FFFFFFF;
2669
+ if (maxBytesToWrite < 4) return 0;
2670
+ var startPtr = outPtr;
2671
+ var endPtr = startPtr + maxBytesToWrite - 4;
2672
+ for (var i = 0; i < str.length; ++i) {
2673
+ var codePoint = str.codePointAt(i);
2674
+ // Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
2675
+ // We need to manually skip over the second code unit for correct iteration.
2676
+ if (codePoint > 0xFFFF) {
2677
+ i++;
2678
+ }
2679
+ HEAP32[((outPtr)>>2)] = codePoint;
2680
+ outPtr += 4;
2681
+ if (outPtr + 4 > endPtr) break;
2682
+ }
2683
+ // Null-terminate the pointer to the HEAP.
2684
+ HEAP32[((outPtr)>>2)] = 0;
2685
+ return outPtr - startPtr;
2686
+ };
2687
+
2688
+ var lengthBytesUTF32 = (str) => {
2689
+ var len = 0;
2690
+ for (var i = 0; i < str.length; ++i) {
2691
+ var codePoint = str.codePointAt(i);
2692
+ // Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
2693
+ // We need to manually skip over the second code unit for correct iteration.
2694
+ if (codePoint > 0xFFFF) {
2695
+ i++;
2696
+ }
2697
+ len += 4;
2698
+ }
2699
+
2700
+ return len;
2701
+ };
2702
+ var __embind_register_std_wstring = (rawType, charSize, name) => {
2703
+ name = AsciiToString(name);
2704
+ var decodeString, encodeString, lengthBytesUTF;
2705
+ if (charSize === 2) {
2706
+ decodeString = UTF16ToString;
2707
+ encodeString = stringToUTF16;
2708
+ lengthBytesUTF = lengthBytesUTF16;
2709
+ } else {
2710
+ assert(charSize === 4, 'only 2-byte and 4-byte strings are currently supported');
2711
+ decodeString = UTF32ToString;
2712
+ encodeString = stringToUTF32;
2713
+ lengthBytesUTF = lengthBytesUTF32;
2714
+ }
2715
+ registerType(rawType, {
2716
+ name,
2717
+ fromWireType: (value) => {
2718
+ // Code mostly taken from _embind_register_std_string fromWireType
2719
+ var length = HEAPU32[((value)>>2)];
2720
+ var str = decodeString(value + 4, length * charSize, true);
2721
+
2722
+ _free(value);
2723
+
2724
+ return str;
2725
+ },
2726
+ toWireType: (destructors, value) => {
2727
+ if (!(typeof value == 'string')) {
2728
+ throwBindingError(`Cannot pass non-string to C++ string type ${name}`);
2729
+ }
2730
+
2731
+ // assumes POINTER_SIZE alignment
2732
+ var length = lengthBytesUTF(value);
2733
+ var ptr = _malloc(4 + length + charSize);
2734
+ HEAPU32[((ptr)>>2)] = length / charSize;
2735
+
2736
+ encodeString(value, ptr + 4, length + charSize);
2737
+
2738
+ if (destructors !== null) {
2739
+ destructors.push(_free, ptr);
2740
+ }
2741
+ return ptr;
2742
+ },
2743
+ readValueFromPointer: readPointer,
2744
+ destructorFunction(ptr) {
2745
+ _free(ptr);
2746
+ }
2747
+ });
2748
+ };
2749
+
2750
+
2751
+ var __embind_register_void = (rawType, name) => {
2752
+ name = AsciiToString(name);
2753
+ registerType(rawType, {
2754
+ isVoid: true, // void return values can be optimized out sometimes
2755
+ name,
2756
+ fromWireType: () => undefined,
2757
+ // TODO: assert if anything else is given?
2758
+ toWireType: (destructors, o) => undefined,
2759
+ });
2760
+ };
2761
+
2762
+ var emval_methodCallers = [];
2763
+ var emval_addMethodCaller = (caller) => {
2764
+ var id = emval_methodCallers.length;
2765
+ emval_methodCallers.push(caller);
2766
+ return id;
2767
+ };
2768
+
2769
+
2770
+
2771
+ var requireRegisteredType = (rawType, humanName) => {
2772
+ var impl = registeredTypes[rawType];
2773
+ if (undefined === impl) {
2774
+ throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`);
2775
+ }
2776
+ return impl;
2777
+ };
2778
+ var emval_lookupTypes = (argCount, argTypes) => {
2779
+ var a = new Array(argCount);
2780
+ for (var i = 0; i < argCount; ++i) {
2781
+ a[i] = requireRegisteredType(HEAPU32[(((argTypes)+(i*4))>>2)],
2782
+ `parameter ${i}`);
2783
+ }
2784
+ return a;
2785
+ };
2786
+
2787
+
2788
+ var emval_returnValue = (toReturnWire, destructorsRef, handle) => {
2789
+ var destructors = [];
2790
+ var result = toReturnWire(destructors, handle);
2791
+ if (destructors.length) {
2792
+ // void, primitives and any other types w/o destructors don't need to allocate a handle
2793
+ HEAPU32[((destructorsRef)>>2)] = Emval.toHandle(destructors);
2794
+ }
2795
+ return result;
2796
+ };
2797
+
2798
+
2799
+ var emval_symbols = {
2800
+ };
2801
+
2802
+ var getStringOrSymbol = (address) => {
2803
+ var symbol = emval_symbols[address];
2804
+ if (symbol === undefined) {
2805
+ return AsciiToString(address);
2806
+ }
2807
+ return symbol;
2808
+ };
2809
+ var __emval_create_invoker = (argCount, argTypesPtr, kind) => {
2810
+ var GenericWireTypeSize = 8;
2811
+
2812
+ var [retType, ...argTypes] = emval_lookupTypes(argCount, argTypesPtr);
2813
+ var toReturnWire = retType.toWireType.bind(retType);
2814
+ var argFromPtr = argTypes.map(type => type.readValueFromPointer.bind(type));
2815
+ argCount--; // remove the extracted return type
2816
+
2817
+ var captures = {'toValue': Emval.toValue};
2818
+ var args = argFromPtr.map((argFromPtr, i) => {
2819
+ var captureName = `argFromPtr${i}`;
2820
+ captures[captureName] = argFromPtr;
2821
+ return `${captureName}(args${i ? '+' + i * GenericWireTypeSize : ''})`;
2822
+ });
2823
+ var functionBody;
2824
+ switch (kind){
2825
+ case 0:
2826
+ functionBody = 'toValue(handle)';
2827
+ break;
2828
+ case 2:
2829
+ functionBody = 'new (toValue(handle))';
2830
+ break;
2831
+ case 3:
2832
+ functionBody = '';
2833
+ break;
2834
+ case 1:
2835
+ captures['getStringOrSymbol'] = getStringOrSymbol;
2836
+ functionBody = 'toValue(handle)[getStringOrSymbol(methodName)]';
2837
+ break;
2838
+ }
2839
+ functionBody += `(${args})`;
2840
+ if (!retType.isVoid) {
2841
+ captures['toReturnWire'] = toReturnWire;
2842
+ captures['emval_returnValue'] = emval_returnValue;
2843
+ functionBody = `return emval_returnValue(toReturnWire, destructorsRef, ${functionBody})`;
2844
+ }
2845
+ functionBody = `return function (handle, methodName, destructorsRef, args) {
2846
+ ${functionBody}
2847
+ }`;
2848
+
2849
+ var invokerFunction = new Function(Object.keys(captures), functionBody)(...Object.values(captures));
2850
+ var functionName = `methodCaller<(${argTypes.map(t => t.name)}) => ${retType.name}>`;
2851
+ return emval_addMethodCaller(createNamedFunction(functionName, invokerFunction));
2852
+ };
2853
+
2854
+
2855
+ var __emval_incref = (handle) => {
2856
+ if (handle > 9) {
2857
+ emval_handles[handle + 1] += 1;
2858
+ }
2859
+ };
2860
+
2861
+
2862
+
2863
+ var __emval_invoke = (caller, handle, methodName, destructorsRef, args) => {
2864
+ return emval_methodCallers[caller](handle, methodName, destructorsRef, args);
2865
+ };
2866
+
2867
+
2868
+
2869
+ var __emval_run_destructors = (handle) => {
2870
+ var destructors = Emval.toValue(handle);
2871
+ runDestructors(destructors);
2872
+ __emval_decref(handle);
2873
+ };
2874
+
2875
+
2876
+ var __tzset_js = (timezone, daylight, std_name, dst_name) => {
2877
+ // TODO: Use (malleable) environment variables instead of system settings.
2878
+ var currentYear = new Date().getFullYear();
2879
+ var winter = new Date(currentYear, 0, 1);
2880
+ var summer = new Date(currentYear, 6, 1);
2881
+ var winterOffset = winter.getTimezoneOffset();
2882
+ var summerOffset = summer.getTimezoneOffset();
2883
+
2884
+ // Local standard timezone offset. Local standard time is not adjusted for
2885
+ // daylight savings. This code uses the fact that getTimezoneOffset returns
2886
+ // a greater value during Standard Time versus Daylight Saving Time (DST).
2887
+ // Thus it determines the expected output during Standard Time, and it
2888
+ // compares whether the output of the given date the same (Standard) or less
2889
+ // (DST).
2890
+ var stdTimezoneOffset = Math.max(winterOffset, summerOffset);
2891
+
2892
+ // timezone is specified as seconds west of UTC ("The external variable
2893
+ // `timezone` shall be set to the difference, in seconds, between
2894
+ // Coordinated Universal Time (UTC) and local standard time."), the same
2895
+ // as returned by stdTimezoneOffset.
2896
+ // See http://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html
2897
+ HEAPU32[((timezone)>>2)] = stdTimezoneOffset * 60;
2898
+
2899
+ HEAP32[((daylight)>>2)] = Number(winterOffset != summerOffset);
2900
+
2901
+ var extractZone = (timezoneOffset) => {
2902
+ // Why inverse sign?
2903
+ // Read here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset
2904
+ var sign = timezoneOffset >= 0 ? "-" : "+";
2905
+
2906
+ var absOffset = Math.abs(timezoneOffset)
2907
+ var hours = String(Math.floor(absOffset / 60)).padStart(2, "0");
2908
+ var minutes = String(absOffset % 60).padStart(2, "0");
2909
+
2910
+ return `UTC${sign}${hours}${minutes}`;
2911
+ }
2912
+
2913
+ var winterName = extractZone(winterOffset);
2914
+ var summerName = extractZone(summerOffset);
2915
+ assert(winterName);
2916
+ assert(summerName);
2917
+ assert(lengthBytesUTF8(winterName) <= 16, `timezone name truncated to fit in TZNAME_MAX (${winterName})`);
2918
+ assert(lengthBytesUTF8(summerName) <= 16, `timezone name truncated to fit in TZNAME_MAX (${summerName})`);
2919
+ if (summerOffset < winterOffset) {
2920
+ // Northern hemisphere
2921
+ stringToUTF8(winterName, std_name, 17);
2922
+ stringToUTF8(summerName, dst_name, 17);
2923
+ } else {
2924
+ stringToUTF8(winterName, dst_name, 17);
2925
+ stringToUTF8(summerName, std_name, 17);
2926
+ }
2927
+ };
2928
+
2929
+ var abortOnCannotGrowMemory = (requestedSize) => {
2930
+ abort(`Cannot enlarge memory arrays to size ${requestedSize} bytes (OOM). Either (1) compile with -sINITIAL_MEMORY=X with X higher than the current value ${HEAP8.length}, (2) compile with -sALLOW_MEMORY_GROWTH which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -sABORTING_MALLOC=0`);
2931
+ };
2932
+ var _emscripten_resize_heap = (requestedSize) => {
2933
+ var oldSize = HEAPU8.length;
2934
+ // With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
2935
+ requestedSize >>>= 0;
2936
+ abortOnCannotGrowMemory(requestedSize);
2937
+ };
2938
+
2939
+ var ENV = {
2940
+ };
2941
+
2942
+ var getExecutableName = () => thisProgram || './this.program';
2943
+ var getEnvStrings = () => {
2944
+ if (!getEnvStrings.strings) {
2945
+ // Default values.
2946
+ // Browser language detection #8751
2947
+ var lang = ((typeof navigator == 'object' && navigator.language) || 'C').replace('-', '_') + '.UTF-8';
2948
+ var env = {
2949
+ 'USER': 'web_user',
2950
+ 'LOGNAME': 'web_user',
2951
+ 'PATH': '/',
2952
+ 'PWD': '/',
2953
+ 'HOME': '/home/web_user',
2954
+ 'LANG': lang,
2955
+ '_': getExecutableName()
2956
+ };
2957
+ // Apply the user-provided values, if any.
2958
+ for (var x in ENV) {
2959
+ // x is a key in ENV; if ENV[x] is undefined, that means it was
2960
+ // explicitly set to be so. We allow user code to do that to
2961
+ // force variables with default values to remain unset.
2962
+ if (ENV[x] === undefined) delete env[x];
2963
+ else env[x] = ENV[x];
2964
+ }
2965
+ var strings = [];
2966
+ for (var x in env) {
2967
+ strings.push(`${x}=${env[x]}`);
2968
+ }
2969
+ getEnvStrings.strings = strings;
2970
+ }
2971
+ return getEnvStrings.strings;
2972
+ };
2973
+
2974
+ var _environ_get = (__environ, environ_buf) => {
2975
+ var bufSize = 0;
2976
+ var envp = 0;
2977
+ for (var string of getEnvStrings()) {
2978
+ var ptr = environ_buf + bufSize;
2979
+ HEAPU32[(((__environ)+(envp))>>2)] = ptr;
2980
+ bufSize += stringToUTF8(string, ptr, Infinity) + 1;
2981
+ envp += 4;
2982
+ }
2983
+ return 0;
2984
+ };
2985
+
2986
+
2987
+ var _environ_sizes_get = (penviron_count, penviron_buf_size) => {
2988
+ var strings = getEnvStrings();
2989
+ HEAPU32[((penviron_count)>>2)] = strings.length;
2990
+ var bufSize = 0;
2991
+ for (var string of strings) {
2992
+ bufSize += lengthBytesUTF8(string) + 1;
2993
+ }
2994
+ HEAPU32[((penviron_buf_size)>>2)] = bufSize;
2995
+ return 0;
2996
+ };
2997
+
2998
+ var SYSCALLS = {
2999
+ varargs:undefined,
3000
+ getStr(ptr) {
3001
+ var ret = UTF8ToString(ptr);
3002
+ return ret;
3003
+ },
3004
+ };
3005
+ var _fd_close = (fd) => {
3006
+ abort('fd_close called without SYSCALLS_REQUIRE_FILESYSTEM');
3007
+ };
3008
+
3009
+ var INT53_MAX = 9007199254740992;
3010
+
3011
+ var INT53_MIN = -9007199254740992;
3012
+ var bigintToI53Checked = (num) => (num < INT53_MIN || num > INT53_MAX) ? NaN : Number(num);
3013
+ function _fd_seek(fd, offset, whence, newOffset) {
3014
+ offset = bigintToI53Checked(offset);
3015
+
3016
+
3017
+ return 70;
3018
+ ;
3019
+ }
3020
+
3021
+ var printCharBuffers = [null,[],[]];
3022
+
3023
+ var printChar = (stream, curr) => {
3024
+ var buffer = printCharBuffers[stream];
3025
+ assert(buffer);
3026
+ if (curr === 0 || curr === 10) {
3027
+ (stream === 1 ? out : err)(UTF8ArrayToString(buffer));
3028
+ buffer.length = 0;
3029
+ } else {
3030
+ buffer.push(curr);
3031
+ }
3032
+ };
3033
+
3034
+ var flush_NO_FILESYSTEM = () => {
3035
+ // flush anything remaining in the buffers during shutdown
3036
+ _fflush(0);
3037
+ if (printCharBuffers[1].length) printChar(1, 10);
3038
+ if (printCharBuffers[2].length) printChar(2, 10);
3039
+ };
3040
+
3041
+
3042
+ var _fd_write = (fd, iov, iovcnt, pnum) => {
3043
+ // hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
3044
+ var num = 0;
3045
+ for (var i = 0; i < iovcnt; i++) {
3046
+ var ptr = HEAPU32[((iov)>>2)];
3047
+ var len = HEAPU32[(((iov)+(4))>>2)];
3048
+ iov += 8;
3049
+ for (var j = 0; j < len; j++) {
3050
+ printChar(fd, HEAPU8[ptr+j]);
3051
+ }
3052
+ num += len;
3053
+ }
3054
+ HEAPU32[((pnum)>>2)] = num;
3055
+ return 0;
3056
+ };
3057
+ init_ClassHandle();
3058
+ init_RegisteredPointer();
3059
+ assert(emval_handles.length === 5 * 2);
3060
+ // End JS library code
3061
+
3062
+ // include: postlibrary.js
3063
+ // This file is included after the automatically-generated JS library code
3064
+ // but before the wasm module is created.
3065
+
3066
+ {
3067
+
3068
+ // Begin ATMODULES hooks
3069
+ if (Module['noExitRuntime']) noExitRuntime = Module['noExitRuntime'];
3070
+ if (Module['print']) out = Module['print'];
3071
+ if (Module['printErr']) err = Module['printErr'];
3072
+ if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
3073
+
3074
+ Module['FS_createDataFile'] = FS.createDataFile;
3075
+ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
3076
+
3077
+ // End ATMODULES hooks
3078
+
3079
+ checkIncomingModuleAPI();
3080
+
3081
+ if (Module['arguments']) arguments_ = Module['arguments'];
3082
+ if (Module['thisProgram']) thisProgram = Module['thisProgram'];
3083
+
3084
+ // Assertions on removed incoming Module JS APIs.
3085
+ assert(typeof Module['memoryInitializerPrefixURL'] == 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead');
3086
+ assert(typeof Module['pthreadMainPrefixURL'] == 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead');
3087
+ assert(typeof Module['cdInitializerPrefixURL'] == 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead');
3088
+ assert(typeof Module['filePackagePrefixURL'] == 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead');
3089
+ assert(typeof Module['read'] == 'undefined', 'Module.read option was removed');
3090
+ assert(typeof Module['readAsync'] == 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)');
3091
+ assert(typeof Module['readBinary'] == 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)');
3092
+ assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)');
3093
+ assert(typeof Module['TOTAL_MEMORY'] == 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY');
3094
+ 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)');
3095
+ assert(typeof Module['STACK_SIZE'] == 'undefined', 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time')
3096
+ // If memory is defined in wasm, the user can't provide it, or set INITIAL_MEMORY
3097
+ assert(typeof Module['wasmMemory'] == 'undefined', 'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally');
3098
+ assert(typeof Module['INITIAL_MEMORY'] == 'undefined', 'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically');
3099
+
3100
+ if (Module['preInit']) {
3101
+ if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
3102
+ while (Module['preInit'].length > 0) {
3103
+ Module['preInit'].shift()();
3104
+ }
3105
+ }
3106
+ consumedModuleProp('preInit');
3107
+ }
3108
+
3109
+ // Begin runtime exports
3110
+ var missingLibrarySymbols = [
3111
+ 'writeI53ToI64',
3112
+ 'writeI53ToI64Clamped',
3113
+ 'writeI53ToI64Signaling',
3114
+ 'writeI53ToU64Clamped',
3115
+ 'writeI53ToU64Signaling',
3116
+ 'readI53FromI64',
3117
+ 'readI53FromU64',
3118
+ 'convertI32PairToI53',
3119
+ 'convertI32PairToI53Checked',
3120
+ 'convertU32PairToI53',
3121
+ 'stackAlloc',
3122
+ 'getTempRet0',
3123
+ 'setTempRet0',
3124
+ 'zeroMemory',
3125
+ 'exitJS',
3126
+ 'getHeapMax',
3127
+ 'growMemory',
3128
+ 'withStackSave',
3129
+ 'strError',
3130
+ 'inetPton4',
3131
+ 'inetNtop4',
3132
+ 'inetPton6',
3133
+ 'inetNtop6',
3134
+ 'readSockaddr',
3135
+ 'writeSockaddr',
3136
+ 'readEmAsmArgs',
3137
+ 'jstoi_q',
3138
+ 'autoResumeAudioContext',
3139
+ 'getDynCaller',
3140
+ 'dynCall',
3141
+ 'handleException',
3142
+ 'keepRuntimeAlive',
3143
+ 'runtimeKeepalivePush',
3144
+ 'runtimeKeepalivePop',
3145
+ 'callUserCallback',
3146
+ 'maybeExit',
3147
+ 'asyncLoad',
3148
+ 'asmjsMangle',
3149
+ 'alignMemory',
3150
+ 'mmapAlloc',
3151
+ 'HandleAllocator',
3152
+ 'getUniqueRunDependency',
3153
+ 'addRunDependency',
3154
+ 'removeRunDependency',
3155
+ 'addOnInit',
3156
+ 'addOnPostCtor',
3157
+ 'addOnPreMain',
3158
+ 'addOnExit',
3159
+ 'STACK_SIZE',
3160
+ 'STACK_ALIGN',
3161
+ 'POINTER_SIZE',
3162
+ 'ASSERTIONS',
3163
+ 'ccall',
3164
+ 'cwrap',
3165
+ 'convertJsFunctionToWasm',
3166
+ 'getEmptyTableSlot',
3167
+ 'updateTableMap',
3168
+ 'getFunctionAddress',
3169
+ 'addFunction',
3170
+ 'removeFunction',
3171
+ 'intArrayFromString',
3172
+ 'intArrayToString',
3173
+ 'stringToAscii',
3174
+ 'stringToNewUTF8',
3175
+ 'stringToUTF8OnStack',
3176
+ 'writeArrayToMemory',
3177
+ 'registerKeyEventCallback',
3178
+ 'maybeCStringToJsString',
3179
+ 'findEventTarget',
3180
+ 'getBoundingClientRect',
3181
+ 'fillMouseEventData',
3182
+ 'registerMouseEventCallback',
3183
+ 'registerWheelEventCallback',
3184
+ 'registerUiEventCallback',
3185
+ 'registerFocusEventCallback',
3186
+ 'fillDeviceOrientationEventData',
3187
+ 'registerDeviceOrientationEventCallback',
3188
+ 'fillDeviceMotionEventData',
3189
+ 'registerDeviceMotionEventCallback',
3190
+ 'screenOrientation',
3191
+ 'fillOrientationChangeEventData',
3192
+ 'registerOrientationChangeEventCallback',
3193
+ 'fillFullscreenChangeEventData',
3194
+ 'registerFullscreenChangeEventCallback',
3195
+ 'JSEvents_requestFullscreen',
3196
+ 'JSEvents_resizeCanvasForFullscreen',
3197
+ 'registerRestoreOldStyle',
3198
+ 'hideEverythingExceptGivenElement',
3199
+ 'restoreHiddenElements',
3200
+ 'setLetterbox',
3201
+ 'softFullscreenResizeWebGLRenderTarget',
3202
+ 'doRequestFullscreen',
3203
+ 'fillPointerlockChangeEventData',
3204
+ 'registerPointerlockChangeEventCallback',
3205
+ 'registerPointerlockErrorEventCallback',
3206
+ 'requestPointerLock',
3207
+ 'fillVisibilityChangeEventData',
3208
+ 'registerVisibilityChangeEventCallback',
3209
+ 'registerTouchEventCallback',
3210
+ 'fillGamepadEventData',
3211
+ 'registerGamepadEventCallback',
3212
+ 'registerBeforeUnloadEventCallback',
3213
+ 'fillBatteryEventData',
3214
+ 'registerBatteryEventCallback',
3215
+ 'setCanvasElementSize',
3216
+ 'getCanvasElementSize',
3217
+ 'jsStackTrace',
3218
+ 'getCallstack',
3219
+ 'convertPCtoSourceLocation',
3220
+ 'checkWasiClock',
3221
+ 'wasiRightsToMuslOFlags',
3222
+ 'wasiOFlagsToMuslOFlags',
3223
+ 'initRandomFill',
3224
+ 'randomFill',
3225
+ 'safeSetTimeout',
3226
+ 'setImmediateWrapped',
3227
+ 'safeRequestAnimationFrame',
3228
+ 'clearImmediateWrapped',
3229
+ 'registerPostMainLoop',
3230
+ 'registerPreMainLoop',
3231
+ 'getPromise',
3232
+ 'makePromise',
3233
+ 'idsToPromises',
3234
+ 'makePromiseCallback',
3235
+ 'findMatchingCatch',
3236
+ 'Browser_asyncPrepareDataCounter',
3237
+ 'isLeapYear',
3238
+ 'ydayFromDate',
3239
+ 'arraySum',
3240
+ 'addDays',
3241
+ 'getSocketFromFD',
3242
+ 'getSocketAddress',
3243
+ 'FS_createPreloadedFile',
3244
+ 'FS_preloadFile',
3245
+ 'FS_modeStringToFlags',
3246
+ 'FS_getMode',
3247
+ 'FS_stdin_getChar',
3248
+ 'FS_mkdirTree',
3249
+ '_setNetworkCallback',
3250
+ 'heapObjectForWebGLType',
3251
+ 'toTypedArrayIndex',
3252
+ 'webgl_enable_ANGLE_instanced_arrays',
3253
+ 'webgl_enable_OES_vertex_array_object',
3254
+ 'webgl_enable_WEBGL_draw_buffers',
3255
+ 'webgl_enable_WEBGL_multi_draw',
3256
+ 'webgl_enable_EXT_polygon_offset_clamp',
3257
+ 'webgl_enable_EXT_clip_control',
3258
+ 'webgl_enable_WEBGL_polygon_mode',
3259
+ 'emscriptenWebGLGet',
3260
+ 'computeUnpackAlignedImageSize',
3261
+ 'colorChannelsInGlTextureFormat',
3262
+ 'emscriptenWebGLGetTexPixelData',
3263
+ 'emscriptenWebGLGetUniform',
3264
+ 'webglGetUniformLocation',
3265
+ 'webglPrepareUniformLocationsBeforeFirstUse',
3266
+ 'webglGetLeftBracePos',
3267
+ 'emscriptenWebGLGetVertexAttrib',
3268
+ '__glGetActiveAttribOrUniform',
3269
+ 'writeGLArray',
3270
+ 'registerWebGlEventCallback',
3271
+ 'runAndAbortIfError',
3272
+ 'ALLOC_NORMAL',
3273
+ 'ALLOC_STACK',
3274
+ 'allocate',
3275
+ 'writeStringToMemory',
3276
+ 'writeAsciiToMemory',
3277
+ 'allocateUTF8',
3278
+ 'allocateUTF8OnStack',
3279
+ 'demangle',
3280
+ 'stackTrace',
3281
+ 'getNativeTypeSize',
3282
+ 'getFunctionArgsName',
3283
+ 'createJsInvokerSignature',
3284
+ 'PureVirtualError',
3285
+ 'registerInheritedInstance',
3286
+ 'unregisterInheritedInstance',
3287
+ 'getInheritedInstanceCount',
3288
+ 'getLiveInheritedInstances',
3289
+ 'enumReadValueFromPointer',
3290
+ 'setDelayFunction',
3291
+ 'validateThis',
3292
+ 'count_emval_handles',
3293
+ ];
3294
+ missingLibrarySymbols.forEach(missingLibrarySymbol)
3295
+
3296
+ var unexportedSymbols = [
3297
+ 'run',
3298
+ 'out',
3299
+ 'err',
3300
+ 'callMain',
3301
+ 'abort',
3302
+ 'wasmExports',
3303
+ 'HEAPF32',
3304
+ 'HEAPF64',
3305
+ 'HEAP8',
3306
+ 'HEAPU8',
3307
+ 'HEAP16',
3308
+ 'HEAPU16',
3309
+ 'HEAP32',
3310
+ 'HEAPU32',
3311
+ 'HEAP64',
3312
+ 'HEAPU64',
3313
+ 'writeStackCookie',
3314
+ 'checkStackCookie',
3315
+ 'INT53_MAX',
3316
+ 'INT53_MIN',
3317
+ 'bigintToI53Checked',
3318
+ 'stackSave',
3319
+ 'stackRestore',
3320
+ 'createNamedFunction',
3321
+ 'ptrToString',
3322
+ 'abortOnCannotGrowMemory',
3323
+ 'ENV',
3324
+ 'ERRNO_CODES',
3325
+ 'DNS',
3326
+ 'Protocols',
3327
+ 'Sockets',
3328
+ 'timers',
3329
+ 'warnOnce',
3330
+ 'readEmAsmArgsArray',
3331
+ 'getExecutableName',
3332
+ 'wasmTable',
3333
+ 'wasmMemory',
3334
+ 'noExitRuntime',
3335
+ 'addOnPreRun',
3336
+ 'addOnPostRun',
3337
+ 'freeTableIndexes',
3338
+ 'functionsInTableMap',
3339
+ 'setValue',
3340
+ 'getValue',
3341
+ 'PATH',
3342
+ 'PATH_FS',
3343
+ 'UTF8Decoder',
3344
+ 'UTF8ArrayToString',
3345
+ 'UTF8ToString',
3346
+ 'stringToUTF8Array',
3347
+ 'stringToUTF8',
3348
+ 'lengthBytesUTF8',
3349
+ 'AsciiToString',
3350
+ 'UTF16Decoder',
3351
+ 'UTF16ToString',
3352
+ 'stringToUTF16',
3353
+ 'lengthBytesUTF16',
3354
+ 'UTF32ToString',
3355
+ 'stringToUTF32',
3356
+ 'lengthBytesUTF32',
3357
+ 'JSEvents',
3358
+ 'specialHTMLTargets',
3359
+ 'findCanvasEventTarget',
3360
+ 'currentFullscreenStrategy',
3361
+ 'restoreOldWindowedStyle',
3362
+ 'UNWIND_CACHE',
3363
+ 'ExitStatus',
3364
+ 'getEnvStrings',
3365
+ 'flush_NO_FILESYSTEM',
3366
+ 'emSetImmediate',
3367
+ 'emClearImmediate_deps',
3368
+ 'emClearImmediate',
3369
+ 'promiseMap',
3370
+ 'uncaughtExceptionCount',
3371
+ 'exceptionLast',
3372
+ 'exceptionCaught',
3373
+ 'ExceptionInfo',
3374
+ 'Browser',
3375
+ 'requestFullscreen',
3376
+ 'requestFullScreen',
3377
+ 'setCanvasSize',
3378
+ 'getUserMedia',
3379
+ 'createContext',
3380
+ 'getPreloadedImageData__data',
3381
+ 'wget',
3382
+ 'MONTH_DAYS_REGULAR',
3383
+ 'MONTH_DAYS_LEAP',
3384
+ 'MONTH_DAYS_REGULAR_CUMULATIVE',
3385
+ 'MONTH_DAYS_LEAP_CUMULATIVE',
3386
+ 'SYSCALLS',
3387
+ 'preloadPlugins',
3388
+ 'FS_stdin_getChar_buffer',
3389
+ 'FS_unlink',
3390
+ 'FS_createPath',
3391
+ 'FS_createDevice',
3392
+ 'FS_readFile',
3393
+ 'FS',
3394
+ 'FS_root',
3395
+ 'FS_mounts',
3396
+ 'FS_devices',
3397
+ 'FS_streams',
3398
+ 'FS_nextInode',
3399
+ 'FS_nameTable',
3400
+ 'FS_currentPath',
3401
+ 'FS_initialized',
3402
+ 'FS_ignorePermissions',
3403
+ 'FS_filesystems',
3404
+ 'FS_syncFSRequests',
3405
+ 'FS_readFiles',
3406
+ 'FS_lookupPath',
3407
+ 'FS_getPath',
3408
+ 'FS_hashName',
3409
+ 'FS_hashAddNode',
3410
+ 'FS_hashRemoveNode',
3411
+ 'FS_lookupNode',
3412
+ 'FS_createNode',
3413
+ 'FS_destroyNode',
3414
+ 'FS_isRoot',
3415
+ 'FS_isMountpoint',
3416
+ 'FS_isFile',
3417
+ 'FS_isDir',
3418
+ 'FS_isLink',
3419
+ 'FS_isChrdev',
3420
+ 'FS_isBlkdev',
3421
+ 'FS_isFIFO',
3422
+ 'FS_isSocket',
3423
+ 'FS_flagsToPermissionString',
3424
+ 'FS_nodePermissions',
3425
+ 'FS_mayLookup',
3426
+ 'FS_mayCreate',
3427
+ 'FS_mayDelete',
3428
+ 'FS_mayOpen',
3429
+ 'FS_checkOpExists',
3430
+ 'FS_nextfd',
3431
+ 'FS_getStreamChecked',
3432
+ 'FS_getStream',
3433
+ 'FS_createStream',
3434
+ 'FS_closeStream',
3435
+ 'FS_dupStream',
3436
+ 'FS_doSetAttr',
3437
+ 'FS_chrdev_stream_ops',
3438
+ 'FS_major',
3439
+ 'FS_minor',
3440
+ 'FS_makedev',
3441
+ 'FS_registerDevice',
3442
+ 'FS_getDevice',
3443
+ 'FS_getMounts',
3444
+ 'FS_syncfs',
3445
+ 'FS_mount',
3446
+ 'FS_unmount',
3447
+ 'FS_lookup',
3448
+ 'FS_mknod',
3449
+ 'FS_statfs',
3450
+ 'FS_statfsStream',
3451
+ 'FS_statfsNode',
3452
+ 'FS_create',
3453
+ 'FS_mkdir',
3454
+ 'FS_mkdev',
3455
+ 'FS_symlink',
3456
+ 'FS_rename',
3457
+ 'FS_rmdir',
3458
+ 'FS_readdir',
3459
+ 'FS_readlink',
3460
+ 'FS_stat',
3461
+ 'FS_fstat',
3462
+ 'FS_lstat',
3463
+ 'FS_doChmod',
3464
+ 'FS_chmod',
3465
+ 'FS_lchmod',
3466
+ 'FS_fchmod',
3467
+ 'FS_doChown',
3468
+ 'FS_chown',
3469
+ 'FS_lchown',
3470
+ 'FS_fchown',
3471
+ 'FS_doTruncate',
3472
+ 'FS_truncate',
3473
+ 'FS_ftruncate',
3474
+ 'FS_utime',
3475
+ 'FS_open',
3476
+ 'FS_close',
3477
+ 'FS_isClosed',
3478
+ 'FS_llseek',
3479
+ 'FS_read',
3480
+ 'FS_write',
3481
+ 'FS_mmap',
3482
+ 'FS_msync',
3483
+ 'FS_ioctl',
3484
+ 'FS_writeFile',
3485
+ 'FS_cwd',
3486
+ 'FS_chdir',
3487
+ 'FS_createDefaultDirectories',
3488
+ 'FS_createDefaultDevices',
3489
+ 'FS_createSpecialDirectories',
3490
+ 'FS_createStandardStreams',
3491
+ 'FS_staticInit',
3492
+ 'FS_init',
3493
+ 'FS_quit',
3494
+ 'FS_findObject',
3495
+ 'FS_analyzePath',
3496
+ 'FS_createFile',
3497
+ 'FS_createDataFile',
3498
+ 'FS_forceLoadFile',
3499
+ 'FS_createLazyFile',
3500
+ 'FS_absolutePath',
3501
+ 'FS_createFolder',
3502
+ 'FS_createLink',
3503
+ 'FS_joinPath',
3504
+ 'FS_mmapAlloc',
3505
+ 'FS_standardizePath',
3506
+ 'MEMFS',
3507
+ 'TTY',
3508
+ 'PIPEFS',
3509
+ 'SOCKFS',
3510
+ 'tempFixedLengthArray',
3511
+ 'miniTempWebGLFloatBuffers',
3512
+ 'miniTempWebGLIntBuffers',
3513
+ 'GL',
3514
+ 'AL',
3515
+ 'GLUT',
3516
+ 'EGL',
3517
+ 'GLEW',
3518
+ 'IDBStore',
3519
+ 'SDL',
3520
+ 'SDL_gfx',
3521
+ 'print',
3522
+ 'printErr',
3523
+ 'jstoi_s',
3524
+ 'InternalError',
3525
+ 'BindingError',
3526
+ 'throwInternalError',
3527
+ 'throwBindingError',
3528
+ 'registeredTypes',
3529
+ 'awaitingDependencies',
3530
+ 'typeDependencies',
3531
+ 'tupleRegistrations',
3532
+ 'structRegistrations',
3533
+ 'sharedRegisterType',
3534
+ 'whenDependentTypesAreResolved',
3535
+ 'getTypeName',
3536
+ 'getFunctionName',
3537
+ 'heap32VectorToArray',
3538
+ 'requireRegisteredType',
3539
+ 'usesDestructorStack',
3540
+ 'checkArgCount',
3541
+ 'getRequiredArgCount',
3542
+ 'createJsInvoker',
3543
+ 'UnboundTypeError',
3544
+ 'EmValType',
3545
+ 'EmValOptionalType',
3546
+ 'throwUnboundTypeError',
3547
+ 'ensureOverloadTable',
3548
+ 'exposePublicSymbol',
3549
+ 'replacePublicSymbol',
3550
+ 'embindRepr',
3551
+ 'registeredInstances',
3552
+ 'getBasestPointer',
3553
+ 'getInheritedInstance',
3554
+ 'registeredPointers',
3555
+ 'registerType',
3556
+ 'integerReadValueFromPointer',
3557
+ 'floatReadValueFromPointer',
3558
+ 'assertIntegerRange',
3559
+ 'readPointer',
3560
+ 'runDestructors',
3561
+ 'craftInvokerFunction',
3562
+ 'embind__requireFunction',
3563
+ 'genericPointerToWireType',
3564
+ 'constNoSmartPtrRawPointerToWireType',
3565
+ 'nonConstNoSmartPtrRawPointerToWireType',
3566
+ 'init_RegisteredPointer',
3567
+ 'RegisteredPointer',
3568
+ 'RegisteredPointer_fromWireType',
3569
+ 'runDestructor',
3570
+ 'releaseClassHandle',
3571
+ 'finalizationRegistry',
3572
+ 'detachFinalizer_deps',
3573
+ 'detachFinalizer',
3574
+ 'attachFinalizer',
3575
+ 'makeClassHandle',
3576
+ 'init_ClassHandle',
3577
+ 'ClassHandle',
3578
+ 'throwInstanceAlreadyDeleted',
3579
+ 'deletionQueue',
3580
+ 'flushPendingDeletes',
3581
+ 'delayFunction',
3582
+ 'RegisteredClass',
3583
+ 'shallowCopyInternalPointer',
3584
+ 'downcastPointer',
3585
+ 'upcastPointer',
3586
+ 'char_0',
3587
+ 'char_9',
3588
+ 'makeLegalFunctionName',
3589
+ 'emval_freelist',
3590
+ 'emval_handles',
3591
+ 'emval_symbols',
3592
+ 'getStringOrSymbol',
3593
+ 'Emval',
3594
+ 'emval_returnValue',
3595
+ 'emval_lookupTypes',
3596
+ 'emval_methodCallers',
3597
+ 'emval_addMethodCaller',
3598
+ ];
3599
+ unexportedSymbols.forEach(unexportedRuntimeSymbol);
3600
+
3601
+ // End runtime exports
3602
+ // Begin JS library exports
3603
+ // End JS library exports
3604
+
3605
+ // end include: postlibrary.js
3606
+
3607
+ function checkIncomingModuleAPI() {
3608
+ ignoredModuleProp('fetchSettings');
3609
+ }
3610
+
3611
+ // Imports from the Wasm binary.
3612
+ var ___getTypeName = makeInvalidEarlyAccess('___getTypeName');
3613
+ var _malloc = makeInvalidEarlyAccess('_malloc');
3614
+ var _fflush = makeInvalidEarlyAccess('_fflush');
3615
+ var _emscripten_stack_get_end = makeInvalidEarlyAccess('_emscripten_stack_get_end');
3616
+ var _emscripten_stack_get_base = makeInvalidEarlyAccess('_emscripten_stack_get_base');
3617
+ var _strerror = makeInvalidEarlyAccess('_strerror');
3618
+ var _free = makeInvalidEarlyAccess('_free');
3619
+ var _emscripten_stack_init = makeInvalidEarlyAccess('_emscripten_stack_init');
3620
+ var _emscripten_stack_get_free = makeInvalidEarlyAccess('_emscripten_stack_get_free');
3621
+ var __emscripten_stack_restore = makeInvalidEarlyAccess('__emscripten_stack_restore');
3622
+ var __emscripten_stack_alloc = makeInvalidEarlyAccess('__emscripten_stack_alloc');
3623
+ var _emscripten_stack_get_current = makeInvalidEarlyAccess('_emscripten_stack_get_current');
3624
+ var memory = makeInvalidEarlyAccess('memory');
3625
+ var __indirect_function_table = makeInvalidEarlyAccess('__indirect_function_table');
3626
+ var wasmMemory = makeInvalidEarlyAccess('wasmMemory');
3627
+ var wasmTable = makeInvalidEarlyAccess('wasmTable');
3628
+
3629
+ function assignWasmExports(wasmExports) {
3630
+ assert(typeof wasmExports['__getTypeName'] != 'undefined', 'missing Wasm export: __getTypeName');
3631
+ assert(typeof wasmExports['malloc'] != 'undefined', 'missing Wasm export: malloc');
3632
+ assert(typeof wasmExports['fflush'] != 'undefined', 'missing Wasm export: fflush');
3633
+ assert(typeof wasmExports['emscripten_stack_get_end'] != 'undefined', 'missing Wasm export: emscripten_stack_get_end');
3634
+ assert(typeof wasmExports['emscripten_stack_get_base'] != 'undefined', 'missing Wasm export: emscripten_stack_get_base');
3635
+ assert(typeof wasmExports['strerror'] != 'undefined', 'missing Wasm export: strerror');
3636
+ assert(typeof wasmExports['free'] != 'undefined', 'missing Wasm export: free');
3637
+ assert(typeof wasmExports['emscripten_stack_init'] != 'undefined', 'missing Wasm export: emscripten_stack_init');
3638
+ assert(typeof wasmExports['emscripten_stack_get_free'] != 'undefined', 'missing Wasm export: emscripten_stack_get_free');
3639
+ assert(typeof wasmExports['_emscripten_stack_restore'] != 'undefined', 'missing Wasm export: _emscripten_stack_restore');
3640
+ assert(typeof wasmExports['_emscripten_stack_alloc'] != 'undefined', 'missing Wasm export: _emscripten_stack_alloc');
3641
+ assert(typeof wasmExports['emscripten_stack_get_current'] != 'undefined', 'missing Wasm export: emscripten_stack_get_current');
3642
+ assert(typeof wasmExports['memory'] != 'undefined', 'missing Wasm export: memory');
3643
+ assert(typeof wasmExports['__indirect_function_table'] != 'undefined', 'missing Wasm export: __indirect_function_table');
3644
+ ___getTypeName = createExportWrapper('__getTypeName', 1);
3645
+ _malloc = createExportWrapper('malloc', 1);
3646
+ _fflush = createExportWrapper('fflush', 1);
3647
+ _emscripten_stack_get_end = wasmExports['emscripten_stack_get_end'];
3648
+ _emscripten_stack_get_base = wasmExports['emscripten_stack_get_base'];
3649
+ _strerror = createExportWrapper('strerror', 1);
3650
+ _free = createExportWrapper('free', 1);
3651
+ _emscripten_stack_init = wasmExports['emscripten_stack_init'];
3652
+ _emscripten_stack_get_free = wasmExports['emscripten_stack_get_free'];
3653
+ __emscripten_stack_restore = wasmExports['_emscripten_stack_restore'];
3654
+ __emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc'];
3655
+ _emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'];
3656
+ memory = wasmMemory = wasmExports['memory'];
3657
+ __indirect_function_table = wasmTable = wasmExports['__indirect_function_table'];
3658
+ }
3659
+
3660
+ var wasmImports = {
3661
+ /** @export */
3662
+ __assert_fail: ___assert_fail,
3663
+ /** @export */
3664
+ __cxa_throw: ___cxa_throw,
3665
+ /** @export */
3666
+ _abort_js: __abort_js,
3667
+ /** @export */
3668
+ _embind_register_bigint: __embind_register_bigint,
3669
+ /** @export */
3670
+ _embind_register_bool: __embind_register_bool,
3671
+ /** @export */
3672
+ _embind_register_class: __embind_register_class,
3673
+ /** @export */
3674
+ _embind_register_class_constructor: __embind_register_class_constructor,
3675
+ /** @export */
3676
+ _embind_register_class_function: __embind_register_class_function,
3677
+ /** @export */
3678
+ _embind_register_emval: __embind_register_emval,
3679
+ /** @export */
3680
+ _embind_register_float: __embind_register_float,
3681
+ /** @export */
3682
+ _embind_register_function: __embind_register_function,
3683
+ /** @export */
3684
+ _embind_register_integer: __embind_register_integer,
3685
+ /** @export */
3686
+ _embind_register_memory_view: __embind_register_memory_view,
3687
+ /** @export */
3688
+ _embind_register_smart_ptr: __embind_register_smart_ptr,
3689
+ /** @export */
3690
+ _embind_register_std_string: __embind_register_std_string,
3691
+ /** @export */
3692
+ _embind_register_std_wstring: __embind_register_std_wstring,
3693
+ /** @export */
3694
+ _embind_register_void: __embind_register_void,
3695
+ /** @export */
3696
+ _emval_create_invoker: __emval_create_invoker,
3697
+ /** @export */
3698
+ _emval_decref: __emval_decref,
3699
+ /** @export */
3700
+ _emval_incref: __emval_incref,
3701
+ /** @export */
3702
+ _emval_invoke: __emval_invoke,
3703
+ /** @export */
3704
+ _emval_run_destructors: __emval_run_destructors,
3705
+ /** @export */
3706
+ _tzset_js: __tzset_js,
3707
+ /** @export */
3708
+ emscripten_resize_heap: _emscripten_resize_heap,
3709
+ /** @export */
3710
+ environ_get: _environ_get,
3711
+ /** @export */
3712
+ environ_sizes_get: _environ_sizes_get,
3713
+ /** @export */
3714
+ fd_close: _fd_close,
3715
+ /** @export */
3716
+ fd_seek: _fd_seek,
3717
+ /** @export */
3718
+ fd_write: _fd_write
3719
+ };
3720
+
3721
+
3722
+ // include: postamble.js
3723
+ // === Auto-generated postamble setup entry stuff ===
3724
+
3725
+ var calledRun;
3726
+
3727
+ function stackCheckInit() {
3728
+ // This is normally called automatically during __wasm_call_ctors but need to
3729
+ // get these values before even running any of the ctors so we call it redundantly
3730
+ // here.
3731
+ _emscripten_stack_init();
3732
+ // TODO(sbc): Move writeStackCookie to native to to avoid this.
3733
+ writeStackCookie();
3734
+ }
3735
+
3736
+ function run() {
3737
+
3738
+ stackCheckInit();
3739
+
3740
+ preRun();
3741
+
3742
+ function doRun() {
3743
+ // run may have just been called through dependencies being fulfilled just in this very frame,
3744
+ // or while the async setStatus time below was happening
3745
+ assert(!calledRun);
3746
+ calledRun = true;
3747
+ Module['calledRun'] = true;
3748
+
3749
+ if (ABORT) return;
3750
+
3751
+ initRuntime();
3752
+
3753
+ readyPromiseResolve?.(Module);
3754
+ Module['onRuntimeInitialized']?.();
3755
+ consumedModuleProp('onRuntimeInitialized');
3756
+
3757
+ assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');
3758
+
3759
+ postRun();
3760
+ }
3761
+
3762
+ if (Module['setStatus']) {
3763
+ Module['setStatus']('Running...');
3764
+ setTimeout(() => {
3765
+ setTimeout(() => Module['setStatus'](''), 1);
3766
+ doRun();
3767
+ }, 1);
3768
+ } else
3769
+ {
3770
+ doRun();
3771
+ }
3772
+ checkStackCookie();
3773
+ }
3774
+
3775
+ function checkUnflushedContent() {
3776
+ // Compiler settings do not allow exiting the runtime, so flushing
3777
+ // the streams is not possible. but in ASSERTIONS mode we check
3778
+ // if there was something to flush, and if so tell the user they
3779
+ // should request that the runtime be exitable.
3780
+ // Normally we would not even include flush() at all, but in ASSERTIONS
3781
+ // builds we do so just for this check, and here we see if there is any
3782
+ // content to flush, that is, we check if there would have been
3783
+ // something a non-ASSERTIONS build would have not seen.
3784
+ // How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0
3785
+ // mode (which has its own special function for this; otherwise, all
3786
+ // the code is inside libc)
3787
+ var oldOut = out;
3788
+ var oldErr = err;
3789
+ var has = false;
3790
+ out = err = (x) => {
3791
+ has = true;
3792
+ }
3793
+ try { // it doesn't matter if it fails
3794
+ flush_NO_FILESYSTEM();
3795
+ } catch(e) {}
3796
+ out = oldOut;
3797
+ err = oldErr;
3798
+ if (has) {
3799
+ 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.');
3800
+ warnOnce('(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)');
3801
+ }
3802
+ }
3803
+
3804
+ var wasmExports;
3805
+
3806
+ // In modularize mode the generated code is within a factory function so we
3807
+ // can use await here (since it's not top-level-await).
3808
+ wasmExports = await (createWasm());
3809
+
3810
+ run();
3811
+
3812
+ // end include: postamble.js
3813
+
3814
+ // include: postamble_modularize.js
3815
+ // In MODULARIZE mode we wrap the generated code in a factory function
3816
+ // and return either the Module itself, or a promise of the module.
3817
+ //
3818
+ // We assign to the `moduleRtn` global here and configure closure to see
3819
+ // this as and extern so it won't get minified.
3820
+
3821
+ if (runtimeInitialized) {
3822
+ moduleRtn = Module;
3823
+ } else {
3824
+ // Set up the promise that indicates the Module is initialized
3825
+ moduleRtn = new Promise((resolve, reject) => {
3826
+ readyPromiseResolve = resolve;
3827
+ readyPromiseReject = reject;
3828
+ });
3829
+ }
3830
+
3831
+ // Assertion for attempting to access module properties on the incoming
3832
+ // moduleArg. In the past we used this object as the prototype of the module
3833
+ // and assigned properties to it, but now we return a distinct object. This
3834
+ // keeps the instance private until it is ready (i.e the promise has been
3835
+ // resolved).
3836
+ for (const prop of Object.keys(Module)) {
3837
+ if (!(prop in moduleArg)) {
3838
+ Object.defineProperty(moduleArg, prop, {
3839
+ configurable: true,
3840
+ get() {
3841
+ abort(`Access to module property ('${prop}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)
3842
+ }
3843
+ });
3844
+ }
3845
+ }
3846
+ // end include: postamble_modularize.js
3847
+
3848
+
3849
+
3850
+ return moduleRtn;
3851
+ }
3852
+
3853
+ // Export using a UMD style export, or ES6 exports if selected
3854
+ export default GraphLayoutWASMModule;
3855
+