autumnplot-gl 2.2.2 → 3.0.0

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