@keymanapp/kmc-kmn 17.0.155-alpha → 17.0.157-alpha

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 (54) hide show
  1. package/build/src/compiler/compiler.d.ts +98 -50
  2. package/build/src/compiler/compiler.d.ts.map +1 -1
  3. package/build/src/compiler/compiler.js +405 -268
  4. package/build/src/compiler/compiler.js.map +1 -1
  5. package/build/src/compiler/messages.d.ts +230 -218
  6. package/build/src/compiler/messages.d.ts.map +1 -1
  7. package/build/src/compiler/messages.js +242 -234
  8. package/build/src/compiler/messages.js.map +1 -1
  9. package/build/src/import/kmcmplib/wasm-host.d.ts +5 -3
  10. package/build/src/import/kmcmplib/wasm-host.d.ts.map +1 -1
  11. package/build/src/import/kmcmplib/wasm-host.js +3264 -1145
  12. package/build/src/import/kmcmplib/wasm-host.js.map +1 -1
  13. package/build/src/import/kmcmplib/wasm-host.wasm +0 -0
  14. package/build/src/kmw-compiler/compiler-globals.d.ts +21 -0
  15. package/build/src/kmw-compiler/compiler-globals.d.ts.map +1 -0
  16. package/build/src/kmw-compiler/compiler-globals.js +37 -0
  17. package/build/src/kmw-compiler/compiler-globals.js.map +1 -0
  18. package/build/src/kmw-compiler/constants.d.ts +16 -0
  19. package/build/src/kmw-compiler/constants.d.ts.map +1 -0
  20. package/build/src/kmw-compiler/constants.js +62 -0
  21. package/build/src/kmw-compiler/constants.js.map +1 -0
  22. package/build/src/kmw-compiler/javascript-strings.d.ts +35 -0
  23. package/build/src/kmw-compiler/javascript-strings.d.ts.map +1 -0
  24. package/build/src/kmw-compiler/javascript-strings.js +854 -0
  25. package/build/src/kmw-compiler/javascript-strings.js.map +1 -0
  26. package/build/src/kmw-compiler/keymanweb-key-codes.d.ts +25 -0
  27. package/build/src/kmw-compiler/keymanweb-key-codes.d.ts.map +1 -0
  28. package/build/src/kmw-compiler/keymanweb-key-codes.js +806 -0
  29. package/build/src/kmw-compiler/keymanweb-key-codes.js.map +1 -0
  30. package/build/src/kmw-compiler/kmw-compiler.d.ts +16 -0
  31. package/build/src/kmw-compiler/kmw-compiler.d.ts.map +1 -0
  32. package/build/src/kmw-compiler/kmw-compiler.js +535 -0
  33. package/build/src/kmw-compiler/kmw-compiler.js.map +1 -0
  34. package/build/src/kmw-compiler/messages.d.ts +85 -0
  35. package/build/src/kmw-compiler/messages.d.ts.map +1 -0
  36. package/build/src/kmw-compiler/messages.js +48 -0
  37. package/build/src/kmw-compiler/messages.js.map +1 -0
  38. package/build/src/kmw-compiler/util.d.ts +77 -0
  39. package/build/src/kmw-compiler/util.d.ts.map +1 -0
  40. package/build/src/kmw-compiler/util.js +249 -0
  41. package/build/src/kmw-compiler/util.js.map +1 -0
  42. package/build/src/kmw-compiler/validate-layout-file.d.ts +10 -0
  43. package/build/src/kmw-compiler/validate-layout-file.d.ts.map +1 -0
  44. package/build/src/kmw-compiler/validate-layout-file.js +246 -0
  45. package/build/src/kmw-compiler/validate-layout-file.js.map +1 -0
  46. package/build/src/kmw-compiler/visual-keyboard-compiler.d.ts +5 -0
  47. package/build/src/kmw-compiler/visual-keyboard-compiler.d.ts.map +1 -0
  48. package/build/src/kmw-compiler/visual-keyboard-compiler.js +121 -0
  49. package/build/src/kmw-compiler/visual-keyboard-compiler.js.map +1 -0
  50. package/build/src/main.d.ts +6 -3
  51. package/build/src/main.d.ts.map +1 -1
  52. package/build/src/main.js +6 -3
  53. package/build/src/main.js.map +1 -1
  54. package/package.json +7 -5
@@ -1,1145 +1,3264 @@
1
- var Module = (() => {
2
- var _scriptDir = import.meta.url;
3
- return (async function (Module = {}) {
4
- var Module = typeof Module != "undefined" ? Module : {};
5
- var readyPromiseResolve, readyPromiseReject;
6
- Module["ready"] = new Promise(function (resolve, reject) { readyPromiseResolve = resolve; readyPromiseReject = reject; });
7
- var moduleOverrides = Object.assign({}, Module);
8
- var arguments_ = [];
9
- var thisProgram = "./this.program";
10
- var quit_ = (status, toThrow) => { throw toThrow; };
11
- var ENVIRONMENT_IS_WEB = typeof window == "object";
12
- var ENVIRONMENT_IS_WORKER = typeof importScripts == "function";
13
- var ENVIRONMENT_IS_NODE = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string";
14
- var scriptDirectory = "";
15
- function locateFile(path) { if (Module["locateFile"]) {
16
- return Module["locateFile"](path, scriptDirectory);
17
- } return scriptDirectory + path; }
18
- var read_, readAsync, readBinary, setWindowTitle;
19
- if (ENVIRONMENT_IS_NODE) {
20
- const { createRequire: createRequire } = await import("module");
21
- var require = createRequire(import.meta.url);
22
- var fs = require("fs");
23
- var nodePath = require("path");
24
- if (ENVIRONMENT_IS_WORKER) {
25
- scriptDirectory = nodePath.dirname(scriptDirectory) + "/";
26
- }
27
- else {
28
- scriptDirectory = require("url").fileURLToPath(new URL("./", import.meta.url));
29
- }
30
- read_ = (filename, binary) => { filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename); return fs.readFileSync(filename, binary ? undefined : "utf8"); };
31
- readBinary = filename => { var ret = read_(filename, true); if (!ret.buffer) {
32
- ret = new Uint8Array(ret);
33
- } return ret; };
34
- readAsync = (filename, onload, onerror) => { filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename); fs.readFile(filename, function (err, data) { if (err)
35
- onerror(err);
36
- else
37
- onload(data.buffer); }); };
38
- if (process.argv.length > 1) {
39
- thisProgram = process.argv[1].replace(/\\/g, "/");
40
- }
41
- arguments_ = process.argv.slice(2);
42
- process.on("uncaughtException", function (ex) { if (ex !== "unwind" && !(ex instanceof ExitStatus) && !(ex.context instanceof ExitStatus)) {
43
- throw ex;
44
- } });
45
- var nodeMajor = process.versions.node.split(".")[0];
46
- if (nodeMajor < 15) {
47
- process.on("unhandledRejection", function (reason) { throw reason; });
48
- }
49
- quit_ = (status, toThrow) => { process.exitCode = status; throw toThrow; };
50
- Module["inspect"] = function () { return "[Emscripten Module object]"; };
51
- }
52
- else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
53
- if (ENVIRONMENT_IS_WORKER) {
54
- scriptDirectory = self.location.href;
55
- }
56
- else if (typeof document != "undefined" && document.currentScript) {
57
- scriptDirectory = document.currentScript.src;
58
- }
59
- if (_scriptDir) {
60
- scriptDirectory = _scriptDir;
61
- }
62
- if (scriptDirectory.indexOf("blob:") !== 0) {
63
- scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
64
- }
65
- else {
66
- scriptDirectory = "";
67
- }
68
- {
69
- read_ = url => { var xhr = new XMLHttpRequest; xhr.open("GET", url, false); xhr.send(null); return xhr.responseText; };
70
- if (ENVIRONMENT_IS_WORKER) {
71
- readBinary = url => { var xhr = new XMLHttpRequest; xhr.open("GET", url, false); xhr.responseType = "arraybuffer"; xhr.send(null); return new Uint8Array(xhr.response); };
72
- }
73
- readAsync = (url, onload, onerror) => { var xhr = new XMLHttpRequest; xhr.open("GET", url, true); xhr.responseType = "arraybuffer"; xhr.onload = () => { if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
74
- onload(xhr.response);
75
- return;
76
- } onerror(); }; xhr.onerror = onerror; xhr.send(null); };
77
- }
78
- setWindowTitle = title => document.title = title;
79
- }
80
- else { }
81
- var out = Module["print"] || console.log.bind(console);
82
- var err = Module["printErr"] || console.warn.bind(console);
83
- Object.assign(Module, moduleOverrides);
84
- moduleOverrides = null;
85
- if (Module["arguments"])
86
- arguments_ = Module["arguments"];
87
- if (Module["thisProgram"])
88
- thisProgram = Module["thisProgram"];
89
- if (Module["quit"])
90
- quit_ = Module["quit"];
91
- var wasmBinary;
92
- if (Module["wasmBinary"])
93
- wasmBinary = Module["wasmBinary"];
94
- var noExitRuntime = Module["noExitRuntime"] || true;
95
- if (typeof WebAssembly != "object") {
96
- abort("no native wasm support detected");
97
- }
98
- var wasmMemory;
99
- var ABORT = false;
100
- var EXITSTATUS;
101
- function assert(condition, text) { if (!condition) {
102
- abort(text);
103
- } }
104
- var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : undefined;
105
- function UTF8ArrayToString(heapOrArray, idx, maxBytesToRead) { var endIdx = idx + maxBytesToRead; var endPtr = idx; while (heapOrArray[endPtr] && !(endPtr >= endIdx))
106
- ++endPtr; if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
107
- return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
108
- } var str = ""; while (idx < endPtr) {
109
- var u0 = heapOrArray[idx++];
110
- if (!(u0 & 128)) {
111
- str += String.fromCharCode(u0);
112
- continue;
113
- }
114
- var u1 = heapOrArray[idx++] & 63;
115
- if ((u0 & 224) == 192) {
116
- str += String.fromCharCode((u0 & 31) << 6 | u1);
117
- continue;
118
- }
119
- var u2 = heapOrArray[idx++] & 63;
120
- if ((u0 & 240) == 224) {
121
- u0 = (u0 & 15) << 12 | u1 << 6 | u2;
122
- }
123
- else {
124
- u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;
125
- }
126
- if (u0 < 65536) {
127
- str += String.fromCharCode(u0);
128
- }
129
- else {
130
- var ch = u0 - 65536;
131
- str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
132
- }
133
- } return str; }
134
- function UTF8ToString(ptr, maxBytesToRead) { return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : ""; }
135
- function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) { if (!(maxBytesToWrite > 0))
136
- return 0; var startIdx = outIdx; var endIdx = outIdx + maxBytesToWrite - 1; for (var i = 0; i < str.length; ++i) {
137
- var u = str.charCodeAt(i);
138
- if (u >= 55296 && u <= 57343) {
139
- var u1 = str.charCodeAt(++i);
140
- u = 65536 + ((u & 1023) << 10) | u1 & 1023;
141
- }
142
- if (u <= 127) {
143
- if (outIdx >= endIdx)
144
- break;
145
- heap[outIdx++] = u;
146
- }
147
- else if (u <= 2047) {
148
- if (outIdx + 1 >= endIdx)
149
- break;
150
- heap[outIdx++] = 192 | u >> 6;
151
- heap[outIdx++] = 128 | u & 63;
152
- }
153
- else if (u <= 65535) {
154
- if (outIdx + 2 >= endIdx)
155
- break;
156
- heap[outIdx++] = 224 | u >> 12;
157
- heap[outIdx++] = 128 | u >> 6 & 63;
158
- heap[outIdx++] = 128 | u & 63;
159
- }
160
- else {
161
- if (outIdx + 3 >= endIdx)
162
- break;
163
- heap[outIdx++] = 240 | u >> 18;
164
- heap[outIdx++] = 128 | u >> 12 & 63;
165
- heap[outIdx++] = 128 | u >> 6 & 63;
166
- heap[outIdx++] = 128 | u & 63;
167
- }
168
- } heap[outIdx] = 0; return outIdx - startIdx; }
169
- function stringToUTF8(str, outPtr, maxBytesToWrite) { return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite); }
170
- function lengthBytesUTF8(str) { var len = 0; for (var i = 0; i < str.length; ++i) {
171
- var c = str.charCodeAt(i);
172
- if (c <= 127) {
173
- len++;
174
- }
175
- else if (c <= 2047) {
176
- len += 2;
177
- }
178
- else if (c >= 55296 && c <= 57343) {
179
- len += 4;
180
- ++i;
181
- }
182
- else {
183
- len += 3;
184
- }
185
- } return len; }
186
- var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
187
- function updateMemoryViews() { var b = wasmMemory.buffer; Module["HEAP8"] = HEAP8 = new Int8Array(b); Module["HEAP16"] = HEAP16 = new Int16Array(b); Module["HEAP32"] = HEAP32 = new Int32Array(b); Module["HEAPU8"] = HEAPU8 = new Uint8Array(b); Module["HEAPU16"] = HEAPU16 = new Uint16Array(b); Module["HEAPU32"] = HEAPU32 = new Uint32Array(b); Module["HEAPF32"] = HEAPF32 = new Float32Array(b); Module["HEAPF64"] = HEAPF64 = new Float64Array(b); }
188
- var wasmTable;
189
- var __ATPRERUN__ = [];
190
- var __ATINIT__ = [];
191
- var __ATPOSTRUN__ = [];
192
- var runtimeInitialized = false;
193
- var runtimeKeepaliveCounter = 0;
194
- function preRun() { if (Module["preRun"]) {
195
- if (typeof Module["preRun"] == "function")
196
- Module["preRun"] = [Module["preRun"]];
197
- while (Module["preRun"].length) {
198
- addOnPreRun(Module["preRun"].shift());
199
- }
200
- } callRuntimeCallbacks(__ATPRERUN__); }
201
- function initRuntime() { runtimeInitialized = true; callRuntimeCallbacks(__ATINIT__); }
202
- function postRun() { if (Module["postRun"]) {
203
- if (typeof Module["postRun"] == "function")
204
- Module["postRun"] = [Module["postRun"]];
205
- while (Module["postRun"].length) {
206
- addOnPostRun(Module["postRun"].shift());
207
- }
208
- } callRuntimeCallbacks(__ATPOSTRUN__); }
209
- function addOnPreRun(cb) { __ATPRERUN__.unshift(cb); }
210
- function addOnInit(cb) { __ATINIT__.unshift(cb); }
211
- function addOnPostRun(cb) { __ATPOSTRUN__.unshift(cb); }
212
- var runDependencies = 0;
213
- var runDependencyWatcher = null;
214
- var dependenciesFulfilled = null;
215
- function addRunDependency(id) { runDependencies++; if (Module["monitorRunDependencies"]) {
216
- Module["monitorRunDependencies"](runDependencies);
217
- } }
218
- function removeRunDependency(id) { runDependencies--; if (Module["monitorRunDependencies"]) {
219
- Module["monitorRunDependencies"](runDependencies);
220
- } if (runDependencies == 0) {
221
- if (runDependencyWatcher !== null) {
222
- clearInterval(runDependencyWatcher);
223
- runDependencyWatcher = null;
224
- }
225
- if (dependenciesFulfilled) {
226
- var callback = dependenciesFulfilled;
227
- dependenciesFulfilled = null;
228
- callback();
229
- }
230
- } }
231
- function abort(what) { if (Module["onAbort"]) {
232
- Module["onAbort"](what);
233
- } what = "Aborted(" + what + ")"; err(what); ABORT = true; EXITSTATUS = 1; what += ". Build with -sASSERTIONS for more info."; if (runtimeInitialized) {
234
- ___trap();
235
- } var e = new WebAssembly.RuntimeError(what); readyPromiseReject(e); throw e; }
236
- var dataURIPrefix = "data:application/octet-stream;base64,";
237
- function isDataURI(filename) { return filename.startsWith(dataURIPrefix); }
238
- function isFileURI(filename) { return filename.startsWith("file://"); }
239
- var wasmBinaryFile;
240
- if (Module["locateFile"]) {
241
- wasmBinaryFile = "wasm-host.wasm";
242
- if (!isDataURI(wasmBinaryFile)) {
243
- wasmBinaryFile = locateFile(wasmBinaryFile);
244
- }
245
- }
246
- else {
247
- wasmBinaryFile = new URL("wasm-host.wasm", import.meta.url).href;
248
- }
249
- function getBinary(file) { try {
250
- if (file == wasmBinaryFile && wasmBinary) {
251
- return new Uint8Array(wasmBinary);
252
- }
253
- if (readBinary) {
254
- return readBinary(file);
255
- }
256
- throw "both async and sync fetching of the wasm failed";
257
- }
258
- catch (err) {
259
- abort(err);
260
- } }
261
- function getBinaryPromise(binaryFile) { if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
262
- if (typeof fetch == "function" && !isFileURI(binaryFile)) {
263
- return fetch(binaryFile, { credentials: "same-origin" }).then(function (response) { if (!response["ok"]) {
264
- throw "failed to load wasm binary file at '" + binaryFile + "'";
265
- } return response["arrayBuffer"](); }).catch(function () { return getBinary(binaryFile); });
266
- }
267
- else {
268
- if (readAsync) {
269
- return new Promise(function (resolve, reject) { readAsync(binaryFile, function (response) { resolve(new Uint8Array(response)); }, reject); });
270
- }
271
- }
272
- } return Promise.resolve().then(function () { return getBinary(binaryFile); }); }
273
- function instantiateArrayBuffer(binaryFile, imports, receiver) { return getBinaryPromise(binaryFile).then(function (binary) { return WebAssembly.instantiate(binary, imports); }).then(function (instance) { return instance; }).then(receiver, function (reason) { err("failed to asynchronously prepare wasm: " + reason); abort(reason); }); }
274
- function instantiateAsync(binary, binaryFile, imports, callback) { if (!binary && typeof WebAssembly.instantiateStreaming == "function" && !isDataURI(binaryFile) && !isFileURI(binaryFile) && !ENVIRONMENT_IS_NODE && typeof fetch == "function") {
275
- return fetch(binaryFile, { credentials: "same-origin" }).then(function (response) { var result = WebAssembly.instantiateStreaming(response, imports); return result.then(callback, function (reason) { err("wasm streaming compile failed: " + reason); err("falling back to ArrayBuffer instantiation"); return instantiateArrayBuffer(binaryFile, imports, callback); }); });
276
- }
277
- else {
278
- return instantiateArrayBuffer(binaryFile, imports, callback);
279
- } }
280
- function createWasm() { var info = { "env": wasmImports, "wasi_snapshot_preview1": wasmImports }; function receiveInstance(instance, module) { var exports = instance.exports; Module["asm"] = exports; wasmMemory = Module["asm"]["memory"]; updateMemoryViews(); wasmTable = Module["asm"]["__indirect_function_table"]; addOnInit(Module["asm"]["__wasm_call_ctors"]); removeRunDependency("wasm-instantiate"); return exports; } addRunDependency("wasm-instantiate"); function receiveInstantiationResult(result) { receiveInstance(result["instance"]); } if (Module["instantiateWasm"]) {
281
- try {
282
- return Module["instantiateWasm"](info, receiveInstance);
283
- }
284
- catch (e) {
285
- err("Module.instantiateWasm callback failed with error: " + e);
286
- readyPromiseReject(e);
287
- }
288
- } instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject); return {}; }
289
- var tempDouble;
290
- var tempI64;
291
- function wasm_msgproc(line, msgcode, text, context) { const proc = globalThis[UTF8ToString(context)].message; if (!proc || typeof proc != "function") {
292
- console.log(`[${line}: ${msgcode}: ${UTF8ToString(text)}]`);
293
- return 0;
294
- }
295
- else {
296
- return proc(line, msgcode, UTF8ToString(text));
297
- } }
298
- function wasm_loadfileproc(filename, baseFilename, buffer, bufferSize, context) { const proc = globalThis[UTF8ToString(context)].loadFile; if (!proc || typeof proc != "function") {
299
- return 0;
300
- }
301
- else {
302
- if (buffer == 0) {
303
- return proc(UTF8ToString(filename), UTF8ToString(baseFilename), 0, 0);
304
- }
305
- else {
306
- return proc(UTF8ToString(filename), UTF8ToString(baseFilename), buffer, bufferSize);
307
- }
308
- } }
309
- function ExitStatus(status) { this.name = "ExitStatus"; this.message = "Program terminated with exit(" + status + ")"; this.status = status; }
310
- function callRuntimeCallbacks(callbacks) { while (callbacks.length > 0) {
311
- callbacks.shift()(Module);
312
- } }
313
- function ___assert_fail(condition, filename, line, func) { abort("Assertion failed: " + UTF8ToString(condition) + ", at: " + [filename ? UTF8ToString(filename) : "unknown filename", line, func ? UTF8ToString(func) : "unknown function"]); }
314
- function __embind_register_bigint(primitiveType, name, size, minRange, maxRange) { }
315
- function getShiftFromSize(size) { switch (size) {
316
- case 1: return 0;
317
- case 2: return 1;
318
- case 4: return 2;
319
- case 8: return 3;
320
- default: throw new TypeError("Unknown type size: " + size);
321
- } }
322
- function embind_init_charCodes() { var codes = new Array(256); for (var i = 0; i < 256; ++i) {
323
- codes[i] = String.fromCharCode(i);
324
- } embind_charCodes = codes; }
325
- var embind_charCodes = undefined;
326
- function readLatin1String(ptr) { var ret = ""; var c = ptr; while (HEAPU8[c]) {
327
- ret += embind_charCodes[HEAPU8[c++]];
328
- } return ret; }
329
- var awaitingDependencies = {};
330
- var registeredTypes = {};
331
- var typeDependencies = {};
332
- var char_0 = 48;
333
- var char_9 = 57;
334
- function makeLegalFunctionName(name) { if (undefined === name) {
335
- return "_unknown";
336
- } name = name.replace(/[^a-zA-Z0-9_]/g, "$"); var f = name.charCodeAt(0); if (f >= char_0 && f <= char_9) {
337
- return "_" + name;
338
- } return name; }
339
- function createNamedFunction(name, body) { name = makeLegalFunctionName(name); return { [name]: function () { return body.apply(this, arguments); } }[name]; }
340
- function extendError(baseErrorType, errorName) { var errorClass = createNamedFunction(errorName, function (message) { this.name = errorName; this.message = message; var stack = new Error(message).stack; if (stack !== undefined) {
341
- this.stack = this.toString() + "\n" + stack.replace(/^Error(:[^\n]*)?\n/, "");
342
- } }); errorClass.prototype = Object.create(baseErrorType.prototype); errorClass.prototype.constructor = errorClass; errorClass.prototype.toString = function () { if (this.message === undefined) {
343
- return this.name;
344
- }
345
- else {
346
- return this.name + ": " + this.message;
347
- } }; return errorClass; }
348
- var BindingError = undefined;
349
- function throwBindingError(message) { throw new BindingError(message); }
350
- var InternalError = undefined;
351
- function throwInternalError(message) { throw new InternalError(message); }
352
- function whenDependentTypesAreResolved(myTypes, dependentTypes, getTypeConverters) { myTypes.forEach(function (type) { typeDependencies[type] = dependentTypes; }); function onComplete(typeConverters) { var myTypeConverters = getTypeConverters(typeConverters); if (myTypeConverters.length !== myTypes.length) {
353
- throwInternalError("Mismatched type converter count");
354
- } for (var i = 0; i < myTypes.length; ++i) {
355
- registerType(myTypes[i], myTypeConverters[i]);
356
- } } var typeConverters = new Array(dependentTypes.length); var unregisteredTypes = []; var registered = 0; dependentTypes.forEach((dt, i) => { if (registeredTypes.hasOwnProperty(dt)) {
357
- typeConverters[i] = registeredTypes[dt];
358
- }
359
- else {
360
- unregisteredTypes.push(dt);
361
- if (!awaitingDependencies.hasOwnProperty(dt)) {
362
- awaitingDependencies[dt] = [];
363
- }
364
- awaitingDependencies[dt].push(() => { typeConverters[i] = registeredTypes[dt]; ++registered; if (registered === unregisteredTypes.length) {
365
- onComplete(typeConverters);
366
- } });
367
- } }); if (0 === unregisteredTypes.length) {
368
- onComplete(typeConverters);
369
- } }
370
- function registerType(rawType, registeredInstance, options = {}) { if (!("argPackAdvance" in registeredInstance)) {
371
- throw new TypeError("registerType registeredInstance requires argPackAdvance");
372
- } var name = registeredInstance.name; if (!rawType) {
373
- throwBindingError('type "' + name + '" must have a positive integer typeid pointer');
374
- } if (registeredTypes.hasOwnProperty(rawType)) {
375
- if (options.ignoreDuplicateRegistrations) {
376
- return;
377
- }
378
- else {
379
- throwBindingError("Cannot register type '" + name + "' twice");
380
- }
381
- } registeredTypes[rawType] = registeredInstance; delete typeDependencies[rawType]; if (awaitingDependencies.hasOwnProperty(rawType)) {
382
- var callbacks = awaitingDependencies[rawType];
383
- delete awaitingDependencies[rawType];
384
- callbacks.forEach(cb => cb());
385
- } }
386
- function __embind_register_bool(rawType, name, size, trueValue, falseValue) { var shift = getShiftFromSize(size); name = readLatin1String(name); registerType(rawType, { name: name, "fromWireType": function (wt) { return !!wt; }, "toWireType": function (destructors, o) { return o ? trueValue : falseValue; }, "argPackAdvance": 8, "readValueFromPointer": function (pointer) { var heap; if (size === 1) {
387
- heap = HEAP8;
388
- }
389
- else if (size === 2) {
390
- heap = HEAP16;
391
- }
392
- else if (size === 4) {
393
- heap = HEAP32;
394
- }
395
- else {
396
- throw new TypeError("Unknown boolean type size: " + name);
397
- } return this["fromWireType"](heap[pointer >> shift]); }, destructorFunction: null }); }
398
- function ClassHandle_isAliasOf(other) { if (!(this instanceof ClassHandle)) {
399
- return false;
400
- } if (!(other instanceof ClassHandle)) {
401
- return false;
402
- } var leftClass = this.$$.ptrType.registeredClass; var left = this.$$.ptr; var rightClass = other.$$.ptrType.registeredClass; var right = other.$$.ptr; while (leftClass.baseClass) {
403
- left = leftClass.upcast(left);
404
- leftClass = leftClass.baseClass;
405
- } while (rightClass.baseClass) {
406
- right = rightClass.upcast(right);
407
- rightClass = rightClass.baseClass;
408
- } return leftClass === rightClass && left === right; }
409
- function shallowCopyInternalPointer(o) { return { count: o.count, deleteScheduled: o.deleteScheduled, preservePointerOnDelete: o.preservePointerOnDelete, ptr: o.ptr, ptrType: o.ptrType, smartPtr: o.smartPtr, smartPtrType: o.smartPtrType }; }
410
- function throwInstanceAlreadyDeleted(obj) { function getInstanceTypeName(handle) { return handle.$$.ptrType.registeredClass.name; } throwBindingError(getInstanceTypeName(obj) + " instance already deleted"); }
411
- var finalizationRegistry = false;
412
- function detachFinalizer(handle) { }
413
- function runDestructor($$) { if ($$.smartPtr) {
414
- $$.smartPtrType.rawDestructor($$.smartPtr);
415
- }
416
- else {
417
- $$.ptrType.registeredClass.rawDestructor($$.ptr);
418
- } }
419
- function releaseClassHandle($$) { $$.count.value -= 1; var toDelete = 0 === $$.count.value; if (toDelete) {
420
- runDestructor($$);
421
- } }
422
- function downcastPointer(ptr, ptrClass, desiredClass) { if (ptrClass === desiredClass) {
423
- return ptr;
424
- } if (undefined === desiredClass.baseClass) {
425
- return null;
426
- } var rv = downcastPointer(ptr, ptrClass, desiredClass.baseClass); if (rv === null) {
427
- return null;
428
- } return desiredClass.downcast(rv); }
429
- var registeredPointers = {};
430
- function getInheritedInstanceCount() { return Object.keys(registeredInstances).length; }
431
- function getLiveInheritedInstances() { var rv = []; for (var k in registeredInstances) {
432
- if (registeredInstances.hasOwnProperty(k)) {
433
- rv.push(registeredInstances[k]);
434
- }
435
- } return rv; }
436
- var deletionQueue = [];
437
- function flushPendingDeletes() { while (deletionQueue.length) {
438
- var obj = deletionQueue.pop();
439
- obj.$$.deleteScheduled = false;
440
- obj["delete"]();
441
- } }
442
- var delayFunction = undefined;
443
- function setDelayFunction(fn) { delayFunction = fn; if (deletionQueue.length && delayFunction) {
444
- delayFunction(flushPendingDeletes);
445
- } }
446
- function init_embind() { Module["getInheritedInstanceCount"] = getInheritedInstanceCount; Module["getLiveInheritedInstances"] = getLiveInheritedInstances; Module["flushPendingDeletes"] = flushPendingDeletes; Module["setDelayFunction"] = setDelayFunction; }
447
- var registeredInstances = {};
448
- function getBasestPointer(class_, ptr) { if (ptr === undefined) {
449
- throwBindingError("ptr should not be undefined");
450
- } while (class_.baseClass) {
451
- ptr = class_.upcast(ptr);
452
- class_ = class_.baseClass;
453
- } return ptr; }
454
- function getInheritedInstance(class_, ptr) { ptr = getBasestPointer(class_, ptr); return registeredInstances[ptr]; }
455
- function makeClassHandle(prototype, record) { if (!record.ptrType || !record.ptr) {
456
- throwInternalError("makeClassHandle requires ptr and ptrType");
457
- } var hasSmartPtrType = !!record.smartPtrType; var hasSmartPtr = !!record.smartPtr; if (hasSmartPtrType !== hasSmartPtr) {
458
- throwInternalError("Both smartPtrType and smartPtr must be specified");
459
- } record.count = { value: 1 }; return attachFinalizer(Object.create(prototype, { $$: { value: record } })); }
460
- function RegisteredPointer_fromWireType(ptr) { var rawPointer = this.getPointee(ptr); if (!rawPointer) {
461
- this.destructor(ptr);
462
- return null;
463
- } var registeredInstance = getInheritedInstance(this.registeredClass, rawPointer); if (undefined !== registeredInstance) {
464
- if (0 === registeredInstance.$$.count.value) {
465
- registeredInstance.$$.ptr = rawPointer;
466
- registeredInstance.$$.smartPtr = ptr;
467
- return registeredInstance["clone"]();
468
- }
469
- else {
470
- var rv = registeredInstance["clone"]();
471
- this.destructor(ptr);
472
- return rv;
473
- }
474
- } function makeDefaultHandle() { if (this.isSmartPointer) {
475
- return makeClassHandle(this.registeredClass.instancePrototype, { ptrType: this.pointeeType, ptr: rawPointer, smartPtrType: this, smartPtr: ptr });
476
- }
477
- else {
478
- return makeClassHandle(this.registeredClass.instancePrototype, { ptrType: this, ptr: ptr });
479
- } } var actualType = this.registeredClass.getActualType(rawPointer); var registeredPointerRecord = registeredPointers[actualType]; if (!registeredPointerRecord) {
480
- return makeDefaultHandle.call(this);
481
- } var toType; if (this.isConst) {
482
- toType = registeredPointerRecord.constPointerType;
483
- }
484
- else {
485
- toType = registeredPointerRecord.pointerType;
486
- } var dp = downcastPointer(rawPointer, this.registeredClass, toType.registeredClass); if (dp === null) {
487
- return makeDefaultHandle.call(this);
488
- } if (this.isSmartPointer) {
489
- return makeClassHandle(toType.registeredClass.instancePrototype, { ptrType: toType, ptr: dp, smartPtrType: this, smartPtr: ptr });
490
- }
491
- else {
492
- return makeClassHandle(toType.registeredClass.instancePrototype, { ptrType: toType, ptr: dp });
493
- } }
494
- function attachFinalizer(handle) { if ("undefined" === typeof FinalizationRegistry) {
495
- attachFinalizer = handle => handle;
496
- return handle;
497
- } finalizationRegistry = new FinalizationRegistry(info => { releaseClassHandle(info.$$); }); attachFinalizer = handle => { var $$ = handle.$$; var hasSmartPtr = !!$$.smartPtr; if (hasSmartPtr) {
498
- var info = { $$: $$ };
499
- finalizationRegistry.register(handle, info, handle);
500
- } return handle; }; detachFinalizer = handle => finalizationRegistry.unregister(handle); return attachFinalizer(handle); }
501
- function ClassHandle_clone() { if (!this.$$.ptr) {
502
- throwInstanceAlreadyDeleted(this);
503
- } if (this.$$.preservePointerOnDelete) {
504
- this.$$.count.value += 1;
505
- return this;
506
- }
507
- else {
508
- var clone = attachFinalizer(Object.create(Object.getPrototypeOf(this), { $$: { value: shallowCopyInternalPointer(this.$$) } }));
509
- clone.$$.count.value += 1;
510
- clone.$$.deleteScheduled = false;
511
- return clone;
512
- } }
513
- function ClassHandle_delete() { if (!this.$$.ptr) {
514
- throwInstanceAlreadyDeleted(this);
515
- } if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
516
- throwBindingError("Object already scheduled for deletion");
517
- } detachFinalizer(this); releaseClassHandle(this.$$); if (!this.$$.preservePointerOnDelete) {
518
- this.$$.smartPtr = undefined;
519
- this.$$.ptr = undefined;
520
- } }
521
- function ClassHandle_isDeleted() { return !this.$$.ptr; }
522
- function ClassHandle_deleteLater() { if (!this.$$.ptr) {
523
- throwInstanceAlreadyDeleted(this);
524
- } if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
525
- throwBindingError("Object already scheduled for deletion");
526
- } deletionQueue.push(this); if (deletionQueue.length === 1 && delayFunction) {
527
- delayFunction(flushPendingDeletes);
528
- } this.$$.deleteScheduled = true; return this; }
529
- function init_ClassHandle() { ClassHandle.prototype["isAliasOf"] = ClassHandle_isAliasOf; ClassHandle.prototype["clone"] = ClassHandle_clone; ClassHandle.prototype["delete"] = ClassHandle_delete; ClassHandle.prototype["isDeleted"] = ClassHandle_isDeleted; ClassHandle.prototype["deleteLater"] = ClassHandle_deleteLater; }
530
- function ClassHandle() { }
531
- function ensureOverloadTable(proto, methodName, humanName) { if (undefined === proto[methodName].overloadTable) {
532
- var prevFunc = proto[methodName];
533
- proto[methodName] = function () { if (!proto[methodName].overloadTable.hasOwnProperty(arguments.length)) {
534
- throwBindingError("Function '" + humanName + "' called with an invalid number of arguments (" + arguments.length + ") - expects one of (" + proto[methodName].overloadTable + ")!");
535
- } return proto[methodName].overloadTable[arguments.length].apply(this, arguments); };
536
- proto[methodName].overloadTable = [];
537
- proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;
538
- } }
539
- function exposePublicSymbol(name, value, numArguments) { if (Module.hasOwnProperty(name)) {
540
- if (undefined === numArguments || undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments]) {
541
- throwBindingError("Cannot register public name '" + name + "' twice");
542
- }
543
- ensureOverloadTable(Module, name, name);
544
- if (Module.hasOwnProperty(numArguments)) {
545
- throwBindingError("Cannot register multiple overloads of a function with the same number of arguments (" + numArguments + ")!");
546
- }
547
- Module[name].overloadTable[numArguments] = value;
548
- }
549
- else {
550
- Module[name] = value;
551
- if (undefined !== numArguments) {
552
- Module[name].numArguments = numArguments;
553
- }
554
- } }
555
- function RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast) { this.name = name; this.constructor = constructor; this.instancePrototype = instancePrototype; this.rawDestructor = rawDestructor; this.baseClass = baseClass; this.getActualType = getActualType; this.upcast = upcast; this.downcast = downcast; this.pureVirtualFunctions = []; }
556
- function upcastPointer(ptr, ptrClass, desiredClass) { while (ptrClass !== desiredClass) {
557
- if (!ptrClass.upcast) {
558
- throwBindingError("Expected null or instance of " + desiredClass.name + ", got an instance of " + ptrClass.name);
559
- }
560
- ptr = ptrClass.upcast(ptr);
561
- ptrClass = ptrClass.baseClass;
562
- } return ptr; }
563
- function constNoSmartPtrRawPointerToWireType(destructors, handle) { if (handle === null) {
564
- if (this.isReference) {
565
- throwBindingError("null is not a valid " + this.name);
566
- }
567
- return 0;
568
- } if (!handle.$$) {
569
- throwBindingError('Cannot pass "' + embindRepr(handle) + '" as a ' + this.name);
570
- } if (!handle.$$.ptr) {
571
- throwBindingError("Cannot pass deleted object as a pointer of type " + this.name);
572
- } var handleClass = handle.$$.ptrType.registeredClass; var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass); return ptr; }
573
- function genericPointerToWireType(destructors, handle) { var ptr; if (handle === null) {
574
- if (this.isReference) {
575
- throwBindingError("null is not a valid " + this.name);
576
- }
577
- if (this.isSmartPointer) {
578
- ptr = this.rawConstructor();
579
- if (destructors !== null) {
580
- destructors.push(this.rawDestructor, ptr);
581
- }
582
- return ptr;
583
- }
584
- else {
585
- return 0;
586
- }
587
- } if (!handle.$$) {
588
- throwBindingError('Cannot pass "' + embindRepr(handle) + '" as a ' + this.name);
589
- } if (!handle.$$.ptr) {
590
- throwBindingError("Cannot pass deleted object as a pointer of type " + this.name);
591
- } if (!this.isConst && handle.$$.ptrType.isConst) {
592
- throwBindingError("Cannot convert argument of type " + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + " to parameter type " + this.name);
593
- } var handleClass = handle.$$.ptrType.registeredClass; ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass); if (this.isSmartPointer) {
594
- if (undefined === handle.$$.smartPtr) {
595
- throwBindingError("Passing raw pointer to smart pointer is illegal");
596
- }
597
- switch (this.sharingPolicy) {
598
- case 0:
599
- if (handle.$$.smartPtrType === this) {
600
- ptr = handle.$$.smartPtr;
601
- }
602
- else {
603
- throwBindingError("Cannot convert argument of type " + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + " to parameter type " + this.name);
604
- }
605
- break;
606
- case 1:
607
- ptr = handle.$$.smartPtr;
608
- break;
609
- case 2:
610
- if (handle.$$.smartPtrType === this) {
611
- ptr = handle.$$.smartPtr;
612
- }
613
- else {
614
- var clonedHandle = handle["clone"]();
615
- ptr = this.rawShare(ptr, Emval.toHandle(function () { clonedHandle["delete"](); }));
616
- if (destructors !== null) {
617
- destructors.push(this.rawDestructor, ptr);
618
- }
619
- }
620
- break;
621
- default: throwBindingError("Unsupporting sharing policy");
622
- }
623
- } return ptr; }
624
- function nonConstNoSmartPtrRawPointerToWireType(destructors, handle) { if (handle === null) {
625
- if (this.isReference) {
626
- throwBindingError("null is not a valid " + this.name);
627
- }
628
- return 0;
629
- } if (!handle.$$) {
630
- throwBindingError('Cannot pass "' + embindRepr(handle) + '" as a ' + this.name);
631
- } if (!handle.$$.ptr) {
632
- throwBindingError("Cannot pass deleted object as a pointer of type " + this.name);
633
- } if (handle.$$.ptrType.isConst) {
634
- throwBindingError("Cannot convert argument of type " + handle.$$.ptrType.name + " to parameter type " + this.name);
635
- } var handleClass = handle.$$.ptrType.registeredClass; var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass); return ptr; }
636
- function simpleReadValueFromPointer(pointer) { return this["fromWireType"](HEAP32[pointer >> 2]); }
637
- function RegisteredPointer_getPointee(ptr) { if (this.rawGetPointee) {
638
- ptr = this.rawGetPointee(ptr);
639
- } return ptr; }
640
- function RegisteredPointer_destructor(ptr) { if (this.rawDestructor) {
641
- this.rawDestructor(ptr);
642
- } }
643
- function RegisteredPointer_deleteObject(handle) { if (handle !== null) {
644
- handle["delete"]();
645
- } }
646
- function init_RegisteredPointer() { RegisteredPointer.prototype.getPointee = RegisteredPointer_getPointee; RegisteredPointer.prototype.destructor = RegisteredPointer_destructor; RegisteredPointer.prototype["argPackAdvance"] = 8; RegisteredPointer.prototype["readValueFromPointer"] = simpleReadValueFromPointer; RegisteredPointer.prototype["deleteObject"] = RegisteredPointer_deleteObject; RegisteredPointer.prototype["fromWireType"] = RegisteredPointer_fromWireType; }
647
- function RegisteredPointer(name, registeredClass, isReference, isConst, isSmartPointer, pointeeType, sharingPolicy, rawGetPointee, rawConstructor, rawShare, rawDestructor) { this.name = name; this.registeredClass = registeredClass; this.isReference = isReference; this.isConst = isConst; this.isSmartPointer = isSmartPointer; this.pointeeType = pointeeType; this.sharingPolicy = sharingPolicy; this.rawGetPointee = rawGetPointee; this.rawConstructor = rawConstructor; this.rawShare = rawShare; this.rawDestructor = rawDestructor; if (!isSmartPointer && registeredClass.baseClass === undefined) {
648
- if (isConst) {
649
- this["toWireType"] = constNoSmartPtrRawPointerToWireType;
650
- this.destructorFunction = null;
651
- }
652
- else {
653
- this["toWireType"] = nonConstNoSmartPtrRawPointerToWireType;
654
- this.destructorFunction = null;
655
- }
656
- }
657
- else {
658
- this["toWireType"] = genericPointerToWireType;
659
- } }
660
- function replacePublicSymbol(name, value, numArguments) { if (!Module.hasOwnProperty(name)) {
661
- throwInternalError("Replacing nonexistant public symbol");
662
- } if (undefined !== Module[name].overloadTable && undefined !== numArguments) {
663
- Module[name].overloadTable[numArguments] = value;
664
- }
665
- else {
666
- Module[name] = value;
667
- Module[name].argCount = numArguments;
668
- } }
669
- function dynCallLegacy(sig, ptr, args) { var f = Module["dynCall_" + sig]; return args && args.length ? f.apply(null, [ptr].concat(args)) : f.call(null, ptr); }
670
- var wasmTableMirror = [];
671
- function getWasmTableEntry(funcPtr) { var func = wasmTableMirror[funcPtr]; if (!func) {
672
- if (funcPtr >= wasmTableMirror.length)
673
- wasmTableMirror.length = funcPtr + 1;
674
- wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
675
- } return func; }
676
- function dynCall(sig, ptr, args) { if (sig.includes("j")) {
677
- return dynCallLegacy(sig, ptr, args);
678
- } var rtn = getWasmTableEntry(ptr).apply(null, args); return rtn; }
679
- function getDynCaller(sig, ptr) { var argCache = []; return function () { argCache.length = 0; Object.assign(argCache, arguments); return dynCall(sig, ptr, argCache); }; }
680
- function embind__requireFunction(signature, rawFunction) { signature = readLatin1String(signature); function makeDynCaller() { if (signature.includes("j")) {
681
- return getDynCaller(signature, rawFunction);
682
- } return getWasmTableEntry(rawFunction); } var fp = makeDynCaller(); if (typeof fp != "function") {
683
- throwBindingError("unknown function pointer with signature " + signature + ": " + rawFunction);
684
- } return fp; }
685
- var UnboundTypeError = undefined;
686
- function getTypeName(type) { var ptr = ___getTypeName(type); var rv = readLatin1String(ptr); _free(ptr); return rv; }
687
- function throwUnboundTypeError(message, types) { var unboundTypes = []; var seen = {}; function visit(type) { if (seen[type]) {
688
- return;
689
- } if (registeredTypes[type]) {
690
- return;
691
- } if (typeDependencies[type]) {
692
- typeDependencies[type].forEach(visit);
693
- return;
694
- } unboundTypes.push(type); seen[type] = true; } types.forEach(visit); throw new UnboundTypeError(message + ": " + unboundTypes.map(getTypeName).join([", "])); }
695
- function __embind_register_class(rawType, rawPointerType, rawConstPointerType, baseClassRawType, getActualTypeSignature, getActualType, upcastSignature, upcast, downcastSignature, downcast, name, destructorSignature, rawDestructor) { name = readLatin1String(name); getActualType = embind__requireFunction(getActualTypeSignature, getActualType); if (upcast) {
696
- upcast = embind__requireFunction(upcastSignature, upcast);
697
- } if (downcast) {
698
- downcast = embind__requireFunction(downcastSignature, downcast);
699
- } rawDestructor = embind__requireFunction(destructorSignature, rawDestructor); var legalFunctionName = makeLegalFunctionName(name); exposePublicSymbol(legalFunctionName, function () { throwUnboundTypeError("Cannot construct " + name + " due to unbound types", [baseClassRawType]); }); whenDependentTypesAreResolved([rawType, rawPointerType, rawConstPointerType], baseClassRawType ? [baseClassRawType] : [], function (base) { base = base[0]; var baseClass; var basePrototype; if (baseClassRawType) {
700
- baseClass = base.registeredClass;
701
- basePrototype = baseClass.instancePrototype;
702
- }
703
- else {
704
- basePrototype = ClassHandle.prototype;
705
- } var constructor = createNamedFunction(legalFunctionName, function () { if (Object.getPrototypeOf(this) !== instancePrototype) {
706
- throw new BindingError("Use 'new' to construct " + name);
707
- } if (undefined === registeredClass.constructor_body) {
708
- throw new BindingError(name + " has no accessible constructor");
709
- } var body = registeredClass.constructor_body[arguments.length]; if (undefined === body) {
710
- 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!");
711
- } return body.apply(this, arguments); }); var instancePrototype = Object.create(basePrototype, { constructor: { value: constructor } }); constructor.prototype = instancePrototype; var registeredClass = new RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast); var referenceConverter = new RegisteredPointer(name, registeredClass, true, false, false); var pointerConverter = new RegisteredPointer(name + "*", registeredClass, false, false, false); var constPointerConverter = new RegisteredPointer(name + " const*", registeredClass, false, true, false); registeredPointers[rawType] = { pointerType: pointerConverter, constPointerType: constPointerConverter }; replacePublicSymbol(legalFunctionName, constructor); return [referenceConverter, pointerConverter, constPointerConverter]; }); }
712
- function heap32VectorToArray(count, firstElement) { var array = []; for (var i = 0; i < count; i++) {
713
- array.push(HEAPU32[firstElement + i * 4 >> 2]);
714
- } return array; }
715
- function runDestructors(destructors) { while (destructors.length) {
716
- var ptr = destructors.pop();
717
- var del = destructors.pop();
718
- del(ptr);
719
- } }
720
- function new_(constructor, argumentList) { if (!(constructor instanceof Function)) {
721
- throw new TypeError("new_ called with constructor type " + typeof constructor + " which is not a function");
722
- } var dummy = createNamedFunction(constructor.name || "unknownFunctionName", function () { }); dummy.prototype = constructor.prototype; var obj = new dummy; var r = constructor.apply(obj, argumentList); return r instanceof Object ? r : obj; }
723
- function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc, isAsync) { var argCount = argTypes.length; if (argCount < 2) {
724
- throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
725
- } var isClassMethodFunc = argTypes[1] !== null && classType !== null; var needsDestructorStack = false; for (var i = 1; i < argTypes.length; ++i) {
726
- if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) {
727
- needsDestructorStack = true;
728
- break;
729
- }
730
- } var returns = argTypes[0].name !== "void"; var argsList = ""; var argsListWired = ""; for (var i = 0; i < argCount - 2; ++i) {
731
- argsList += (i !== 0 ? ", " : "") + "arg" + i;
732
- argsListWired += (i !== 0 ? ", " : "") + "arg" + i + "Wired";
733
- } var invokerFnBody = "return function " + makeLegalFunctionName(humanName) + "(" + argsList + ") {\n" + "if (arguments.length !== " + (argCount - 2) + ") {\n" + "throwBindingError('function " + humanName + " called with ' + arguments.length + ' arguments, expected " + (argCount - 2) + " args!');\n" + "}\n"; if (needsDestructorStack) {
734
- invokerFnBody += "var destructors = [];\n";
735
- } var dtorStack = needsDestructorStack ? "destructors" : "null"; var args1 = ["throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"]; var args2 = [throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]]; if (isClassMethodFunc) {
736
- invokerFnBody += "var thisWired = classParam.toWireType(" + dtorStack + ", this);\n";
737
- } for (var i = 0; i < argCount - 2; ++i) {
738
- invokerFnBody += "var arg" + i + "Wired = argType" + i + ".toWireType(" + dtorStack + ", arg" + i + "); // " + argTypes[i + 2].name + "\n";
739
- args1.push("argType" + i);
740
- args2.push(argTypes[i + 2]);
741
- } if (isClassMethodFunc) {
742
- argsListWired = "thisWired" + (argsListWired.length > 0 ? ", " : "") + argsListWired;
743
- } invokerFnBody += (returns || isAsync ? "var rv = " : "") + "invoker(fn" + (argsListWired.length > 0 ? ", " : "") + argsListWired + ");\n"; if (needsDestructorStack) {
744
- invokerFnBody += "runDestructors(destructors);\n";
745
- }
746
- else {
747
- for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) {
748
- var paramName = i === 1 ? "thisWired" : "arg" + (i - 2) + "Wired";
749
- if (argTypes[i].destructorFunction !== null) {
750
- invokerFnBody += paramName + "_dtor(" + paramName + "); // " + argTypes[i].name + "\n";
751
- args1.push(paramName + "_dtor");
752
- args2.push(argTypes[i].destructorFunction);
753
- }
754
- }
755
- } if (returns) {
756
- invokerFnBody += "var ret = retType.fromWireType(rv);\n" + "return ret;\n";
757
- }
758
- else { } invokerFnBody += "}\n"; args1.push(invokerFnBody); var invokerFunction = new_(Function, args1).apply(null, args2); return invokerFunction; }
759
- function __embind_register_class_constructor(rawClassType, argCount, rawArgTypesAddr, invokerSignature, invoker, rawConstructor) { assert(argCount > 0); var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr); invoker = embind__requireFunction(invokerSignature, invoker); whenDependentTypesAreResolved([], [rawClassType], function (classType) { classType = classType[0]; var humanName = "constructor " + classType.name; if (undefined === classType.registeredClass.constructor_body) {
760
- classType.registeredClass.constructor_body = [];
761
- } if (undefined !== classType.registeredClass.constructor_body[argCount - 1]) {
762
- 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!");
763
- } classType.registeredClass.constructor_body[argCount - 1] = () => { throwUnboundTypeError("Cannot construct " + classType.name + " due to unbound types", rawArgTypes); }; whenDependentTypesAreResolved([], rawArgTypes, function (argTypes) { argTypes.splice(1, 0, null); classType.registeredClass.constructor_body[argCount - 1] = craftInvokerFunction(humanName, argTypes, null, invoker, rawConstructor); return []; }); return []; }); }
764
- function validateThis(this_, classType, humanName) { if (!(this_ instanceof Object)) {
765
- throwBindingError(humanName + ' with invalid "this": ' + this_);
766
- } if (!(this_ instanceof classType.registeredClass.constructor)) {
767
- throwBindingError(humanName + ' incompatible with "this" of type ' + this_.constructor.name);
768
- } if (!this_.$$.ptr) {
769
- throwBindingError("cannot call emscripten binding method " + humanName + " on deleted object");
770
- } return upcastPointer(this_.$$.ptr, this_.$$.ptrType.registeredClass, classType.registeredClass); }
771
- function __embind_register_class_property(classType, fieldName, getterReturnType, getterSignature, getter, getterContext, setterArgumentType, setterSignature, setter, setterContext) { fieldName = readLatin1String(fieldName); getter = embind__requireFunction(getterSignature, getter); whenDependentTypesAreResolved([], [classType], function (classType) { classType = classType[0]; var humanName = classType.name + "." + fieldName; var desc = { get: function () { throwUnboundTypeError("Cannot access " + humanName + " due to unbound types", [getterReturnType, setterArgumentType]); }, enumerable: true, configurable: true }; if (setter) {
772
- desc.set = () => { throwUnboundTypeError("Cannot access " + humanName + " due to unbound types", [getterReturnType, setterArgumentType]); };
773
- }
774
- else {
775
- desc.set = v => { throwBindingError(humanName + " is a read-only property"); };
776
- } Object.defineProperty(classType.registeredClass.instancePrototype, fieldName, desc); whenDependentTypesAreResolved([], setter ? [getterReturnType, setterArgumentType] : [getterReturnType], function (types) { var getterReturnType = types[0]; var desc = { get: function () { var ptr = validateThis(this, classType, humanName + " getter"); return getterReturnType["fromWireType"](getter(getterContext, ptr)); }, enumerable: true }; if (setter) {
777
- setter = embind__requireFunction(setterSignature, setter);
778
- var setterArgumentType = types[1];
779
- desc.set = function (v) { var ptr = validateThis(this, classType, humanName + " setter"); var destructors = []; setter(setterContext, ptr, setterArgumentType["toWireType"](destructors, v)); runDestructors(destructors); };
780
- } Object.defineProperty(classType.registeredClass.instancePrototype, fieldName, desc); return []; }); return []; }); }
781
- var emval_free_list = [];
782
- var emval_handle_array = [{}, { value: undefined }, { value: null }, { value: true }, { value: false }];
783
- function __emval_decref(handle) { if (handle > 4 && 0 === --emval_handle_array[handle].refcount) {
784
- emval_handle_array[handle] = undefined;
785
- emval_free_list.push(handle);
786
- } }
787
- function count_emval_handles() { var count = 0; for (var i = 5; i < emval_handle_array.length; ++i) {
788
- if (emval_handle_array[i] !== undefined) {
789
- ++count;
790
- }
791
- } return count; }
792
- function get_first_emval() { for (var i = 5; i < emval_handle_array.length; ++i) {
793
- if (emval_handle_array[i] !== undefined) {
794
- return emval_handle_array[i];
795
- }
796
- } return null; }
797
- function init_emval() { Module["count_emval_handles"] = count_emval_handles; Module["get_first_emval"] = get_first_emval; }
798
- var Emval = { toValue: handle => { if (!handle) {
799
- throwBindingError("Cannot use deleted val. handle = " + handle);
800
- } return emval_handle_array[handle].value; }, toHandle: value => { switch (value) {
801
- case undefined: return 1;
802
- case null: return 2;
803
- case true: return 3;
804
- case false: return 4;
805
- default: {
806
- var handle = emval_free_list.length ? emval_free_list.pop() : emval_handle_array.length;
807
- emval_handle_array[handle] = { refcount: 1, value: value };
808
- return handle;
809
- }
810
- } } };
811
- function __embind_register_emval(rawType, name) { name = readLatin1String(name); registerType(rawType, { name: name, "fromWireType": function (handle) { var rv = Emval.toValue(handle); __emval_decref(handle); return rv; }, "toWireType": function (destructors, value) { return Emval.toHandle(value); }, "argPackAdvance": 8, "readValueFromPointer": simpleReadValueFromPointer, destructorFunction: null }); }
812
- function embindRepr(v) { if (v === null) {
813
- return "null";
814
- } var t = typeof v; if (t === "object" || t === "array" || t === "function") {
815
- return v.toString();
816
- }
817
- else {
818
- return "" + v;
819
- } }
820
- function floatReadValueFromPointer(name, shift) { switch (shift) {
821
- case 2: return function (pointer) { return this["fromWireType"](HEAPF32[pointer >> 2]); };
822
- case 3: return function (pointer) { return this["fromWireType"](HEAPF64[pointer >> 3]); };
823
- default: throw new TypeError("Unknown float type: " + name);
824
- } }
825
- function __embind_register_float(rawType, name, size) { var shift = getShiftFromSize(size); name = readLatin1String(name); registerType(rawType, { name: name, "fromWireType": function (value) { return value; }, "toWireType": function (destructors, value) { return value; }, "argPackAdvance": 8, "readValueFromPointer": floatReadValueFromPointer(name, shift), destructorFunction: null }); }
826
- function __embind_register_function(name, argCount, rawArgTypesAddr, signature, rawInvoker, fn, isAsync) { var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr); name = readLatin1String(name); rawInvoker = embind__requireFunction(signature, rawInvoker); exposePublicSymbol(name, function () { throwUnboundTypeError("Cannot call " + name + " due to unbound types", argTypes); }, argCount - 1); whenDependentTypesAreResolved([], argTypes, function (argTypes) { var invokerArgsArray = [argTypes[0], null].concat(argTypes.slice(1)); replacePublicSymbol(name, craftInvokerFunction(name, invokerArgsArray, null, rawInvoker, fn, isAsync), argCount - 1); return []; }); }
827
- function integerReadValueFromPointer(name, shift, signed) { switch (shift) {
828
- case 0: return signed ? function readS8FromPointer(pointer) { return HEAP8[pointer]; } : function readU8FromPointer(pointer) { return HEAPU8[pointer]; };
829
- case 1: return signed ? function readS16FromPointer(pointer) { return HEAP16[pointer >> 1]; } : function readU16FromPointer(pointer) { return HEAPU16[pointer >> 1]; };
830
- case 2: return signed ? function readS32FromPointer(pointer) { return HEAP32[pointer >> 2]; } : function readU32FromPointer(pointer) { return HEAPU32[pointer >> 2]; };
831
- default: throw new TypeError("Unknown integer type: " + name);
832
- } }
833
- function __embind_register_integer(primitiveType, name, size, minRange, maxRange) { name = readLatin1String(name); if (maxRange === -1) {
834
- maxRange = 4294967295;
835
- } var shift = getShiftFromSize(size); var fromWireType = value => value; if (minRange === 0) {
836
- var bitshift = 32 - 8 * size;
837
- fromWireType = value => value << bitshift >>> bitshift;
838
- } var isUnsignedType = name.includes("unsigned"); var checkAssertions = (value, toTypeName) => { }; var toWireType; if (isUnsignedType) {
839
- toWireType = function (destructors, value) { checkAssertions(value, this.name); return value >>> 0; };
840
- }
841
- else {
842
- toWireType = function (destructors, value) { checkAssertions(value, this.name); return value; };
843
- } registerType(primitiveType, { name: name, "fromWireType": fromWireType, "toWireType": toWireType, "argPackAdvance": 8, "readValueFromPointer": integerReadValueFromPointer(name, shift, minRange !== 0), destructorFunction: null }); }
844
- function __embind_register_memory_view(rawType, dataTypeIndex, name) { var typeMapping = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]; var TA = typeMapping[dataTypeIndex]; function decodeMemoryView(handle) { handle = handle >> 2; var heap = HEAPU32; var size = heap[handle]; var data = heap[handle + 1]; return new TA(heap.buffer, data, size); } name = readLatin1String(name); registerType(rawType, { name: name, "fromWireType": decodeMemoryView, "argPackAdvance": 8, "readValueFromPointer": decodeMemoryView }, { ignoreDuplicateRegistrations: true }); }
845
- function __embind_register_std_string(rawType, name) { name = readLatin1String(name); var stdStringIsUTF8 = name === "std::string"; registerType(rawType, { name: name, "fromWireType": function (value) { var length = HEAPU32[value >> 2]; var payload = value + 4; var str; if (stdStringIsUTF8) {
846
- var decodeStartPtr = payload;
847
- for (var i = 0; i <= length; ++i) {
848
- var currentBytePtr = payload + i;
849
- if (i == length || HEAPU8[currentBytePtr] == 0) {
850
- var maxRead = currentBytePtr - decodeStartPtr;
851
- var stringSegment = UTF8ToString(decodeStartPtr, maxRead);
852
- if (str === undefined) {
853
- str = stringSegment;
854
- }
855
- else {
856
- str += String.fromCharCode(0);
857
- str += stringSegment;
858
- }
859
- decodeStartPtr = currentBytePtr + 1;
860
- }
861
- }
862
- }
863
- else {
864
- var a = new Array(length);
865
- for (var i = 0; i < length; ++i) {
866
- a[i] = String.fromCharCode(HEAPU8[payload + i]);
867
- }
868
- str = a.join("");
869
- } _free(value); return str; }, "toWireType": function (destructors, value) { if (value instanceof ArrayBuffer) {
870
- value = new Uint8Array(value);
871
- } var length; var valueIsOfTypeString = typeof value == "string"; if (!(valueIsOfTypeString || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int8Array)) {
872
- throwBindingError("Cannot pass non-string to std::string");
873
- } if (stdStringIsUTF8 && valueIsOfTypeString) {
874
- length = lengthBytesUTF8(value);
875
- }
876
- else {
877
- length = value.length;
878
- } var base = _malloc(4 + length + 1); var ptr = base + 4; HEAPU32[base >> 2] = length; if (stdStringIsUTF8 && valueIsOfTypeString) {
879
- stringToUTF8(value, ptr, length + 1);
880
- }
881
- else {
882
- if (valueIsOfTypeString) {
883
- for (var i = 0; i < length; ++i) {
884
- var charCode = value.charCodeAt(i);
885
- if (charCode > 255) {
886
- _free(ptr);
887
- throwBindingError("String has UTF-16 code units that do not fit in 8 bits");
888
- }
889
- HEAPU8[ptr + i] = charCode;
890
- }
891
- }
892
- else {
893
- for (var i = 0; i < length; ++i) {
894
- HEAPU8[ptr + i] = value[i];
895
- }
896
- }
897
- } if (destructors !== null) {
898
- destructors.push(_free, base);
899
- } return base; }, "argPackAdvance": 8, "readValueFromPointer": simpleReadValueFromPointer, destructorFunction: function (ptr) { _free(ptr); } }); }
900
- var UTF16Decoder = typeof TextDecoder != "undefined" ? new TextDecoder("utf-16le") : undefined;
901
- function UTF16ToString(ptr, maxBytesToRead) { var endPtr = ptr; var idx = endPtr >> 1; var maxIdx = idx + maxBytesToRead / 2; while (!(idx >= maxIdx) && HEAPU16[idx])
902
- ++idx; endPtr = idx << 1; if (endPtr - ptr > 32 && UTF16Decoder)
903
- return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr)); var str = ""; for (var i = 0; !(i >= maxBytesToRead / 2); ++i) {
904
- var codeUnit = HEAP16[ptr + i * 2 >> 1];
905
- if (codeUnit == 0)
906
- break;
907
- str += String.fromCharCode(codeUnit);
908
- } return str; }
909
- function stringToUTF16(str, outPtr, maxBytesToWrite) { if (maxBytesToWrite === undefined) {
910
- maxBytesToWrite = 2147483647;
911
- } if (maxBytesToWrite < 2)
912
- return 0; maxBytesToWrite -= 2; var startPtr = outPtr; var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length; for (var i = 0; i < numCharsToWrite; ++i) {
913
- var codeUnit = str.charCodeAt(i);
914
- HEAP16[outPtr >> 1] = codeUnit;
915
- outPtr += 2;
916
- } HEAP16[outPtr >> 1] = 0; return outPtr - startPtr; }
917
- function lengthBytesUTF16(str) { return str.length * 2; }
918
- function UTF32ToString(ptr, maxBytesToRead) { var i = 0; var str = ""; while (!(i >= maxBytesToRead / 4)) {
919
- var utf32 = HEAP32[ptr + i * 4 >> 2];
920
- if (utf32 == 0)
921
- break;
922
- ++i;
923
- if (utf32 >= 65536) {
924
- var ch = utf32 - 65536;
925
- str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
926
- }
927
- else {
928
- str += String.fromCharCode(utf32);
929
- }
930
- } return str; }
931
- function stringToUTF32(str, outPtr, maxBytesToWrite) { if (maxBytesToWrite === undefined) {
932
- maxBytesToWrite = 2147483647;
933
- } if (maxBytesToWrite < 4)
934
- return 0; var startPtr = outPtr; var endPtr = startPtr + maxBytesToWrite - 4; for (var i = 0; i < str.length; ++i) {
935
- var codeUnit = str.charCodeAt(i);
936
- if (codeUnit >= 55296 && codeUnit <= 57343) {
937
- var trailSurrogate = str.charCodeAt(++i);
938
- codeUnit = 65536 + ((codeUnit & 1023) << 10) | trailSurrogate & 1023;
939
- }
940
- HEAP32[outPtr >> 2] = codeUnit;
941
- outPtr += 4;
942
- if (outPtr + 4 > endPtr)
943
- break;
944
- } HEAP32[outPtr >> 2] = 0; return outPtr - startPtr; }
945
- function lengthBytesUTF32(str) { var len = 0; for (var i = 0; i < str.length; ++i) {
946
- var codeUnit = str.charCodeAt(i);
947
- if (codeUnit >= 55296 && codeUnit <= 57343)
948
- ++i;
949
- len += 4;
950
- } return len; }
951
- function __embind_register_std_wstring(rawType, charSize, name) { name = readLatin1String(name); var decodeString, encodeString, getHeap, lengthBytesUTF, shift; if (charSize === 2) {
952
- decodeString = UTF16ToString;
953
- encodeString = stringToUTF16;
954
- lengthBytesUTF = lengthBytesUTF16;
955
- getHeap = () => HEAPU16;
956
- shift = 1;
957
- }
958
- else if (charSize === 4) {
959
- decodeString = UTF32ToString;
960
- encodeString = stringToUTF32;
961
- lengthBytesUTF = lengthBytesUTF32;
962
- getHeap = () => HEAPU32;
963
- shift = 2;
964
- } registerType(rawType, { name: name, "fromWireType": function (value) { var length = HEAPU32[value >> 2]; var HEAP = getHeap(); var str; var decodeStartPtr = value + 4; for (var i = 0; i <= length; ++i) {
965
- var currentBytePtr = value + 4 + i * charSize;
966
- if (i == length || HEAP[currentBytePtr >> shift] == 0) {
967
- var maxReadBytes = currentBytePtr - decodeStartPtr;
968
- var stringSegment = decodeString(decodeStartPtr, maxReadBytes);
969
- if (str === undefined) {
970
- str = stringSegment;
971
- }
972
- else {
973
- str += String.fromCharCode(0);
974
- str += stringSegment;
975
- }
976
- decodeStartPtr = currentBytePtr + charSize;
977
- }
978
- } _free(value); return str; }, "toWireType": function (destructors, value) { if (!(typeof value == "string")) {
979
- throwBindingError("Cannot pass non-string to C++ string type " + name);
980
- } var length = lengthBytesUTF(value); var ptr = _malloc(4 + length + charSize); HEAPU32[ptr >> 2] = length >> shift; encodeString(value, ptr + 4, length + charSize); if (destructors !== null) {
981
- destructors.push(_free, ptr);
982
- } return ptr; }, "argPackAdvance": 8, "readValueFromPointer": simpleReadValueFromPointer, destructorFunction: function (ptr) { _free(ptr); } }); }
983
- function __embind_register_void(rawType, name) { name = readLatin1String(name); registerType(rawType, { isVoid: true, name: name, "argPackAdvance": 0, "fromWireType": function () { return undefined; }, "toWireType": function (destructors, o) { return undefined; } }); }
984
- function _abort() { abort(""); }
985
- function _emscripten_memcpy_big(dest, src, num) { HEAPU8.copyWithin(dest, src, src + num); }
986
- function abortOnCannotGrowMemory(requestedSize) { abort("OOM"); }
987
- function _emscripten_resize_heap(requestedSize) { var oldSize = HEAPU8.length; requestedSize = requestedSize >>> 0; abortOnCannotGrowMemory(requestedSize); }
988
- var ENV = {};
989
- function getExecutableName() { return thisProgram || "./this.program"; }
990
- function getEnvStrings() { if (!getEnvStrings.strings) {
991
- var lang = (typeof navigator == "object" && navigator.languages && navigator.languages[0] || "C").replace("-", "_") + ".UTF-8";
992
- var env = { "USER": "web_user", "LOGNAME": "web_user", "PATH": "/", "PWD": "/", "HOME": "/home/web_user", "LANG": lang, "_": getExecutableName() };
993
- for (var x in ENV) {
994
- if (ENV[x] === undefined)
995
- delete env[x];
996
- else
997
- env[x] = ENV[x];
998
- }
999
- var strings = [];
1000
- for (var x in env) {
1001
- strings.push(x + "=" + env[x]);
1002
- }
1003
- getEnvStrings.strings = strings;
1004
- } return getEnvStrings.strings; }
1005
- function writeAsciiToMemory(str, buffer, dontAddNull) { for (var i = 0; i < str.length; ++i) {
1006
- HEAP8[buffer++ >> 0] = str.charCodeAt(i);
1007
- } if (!dontAddNull)
1008
- HEAP8[buffer >> 0] = 0; }
1009
- var SYSCALLS = { varargs: undefined, get: function () { SYSCALLS.varargs += 4; var ret = HEAP32[SYSCALLS.varargs - 4 >> 2]; return ret; }, getStr: function (ptr) { var ret = UTF8ToString(ptr); return ret; } };
1010
- function _environ_get(__environ, environ_buf) { var bufSize = 0; getEnvStrings().forEach(function (string, i) { var ptr = environ_buf + bufSize; HEAPU32[__environ + i * 4 >> 2] = ptr; writeAsciiToMemory(string, ptr); bufSize += string.length + 1; }); return 0; }
1011
- function _environ_sizes_get(penviron_count, penviron_buf_size) { var strings = getEnvStrings(); HEAPU32[penviron_count >> 2] = strings.length; var bufSize = 0; strings.forEach(function (string) { bufSize += string.length + 1; }); HEAPU32[penviron_buf_size >> 2] = bufSize; return 0; }
1012
- function __isLeapYear(year) { return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0); }
1013
- function __arraySum(array, index) { var sum = 0; for (var i = 0; i <= index; sum += array[i++]) { } return sum; }
1014
- var __MONTH_DAYS_LEAP = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
1015
- var __MONTH_DAYS_REGULAR = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
1016
- function __addDays(date, days) { var newDate = new Date(date.getTime()); while (days > 0) {
1017
- var leap = __isLeapYear(newDate.getFullYear());
1018
- var currentMonth = newDate.getMonth();
1019
- var daysInCurrentMonth = (leap ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR)[currentMonth];
1020
- if (days > daysInCurrentMonth - newDate.getDate()) {
1021
- days -= daysInCurrentMonth - newDate.getDate() + 1;
1022
- newDate.setDate(1);
1023
- if (currentMonth < 11) {
1024
- newDate.setMonth(currentMonth + 1);
1025
- }
1026
- else {
1027
- newDate.setMonth(0);
1028
- newDate.setFullYear(newDate.getFullYear() + 1);
1029
- }
1030
- }
1031
- else {
1032
- newDate.setDate(newDate.getDate() + days);
1033
- return newDate;
1034
- }
1035
- } return newDate; }
1036
- function intArrayFromString(stringy, dontAddNull, length) { var len = length > 0 ? length : lengthBytesUTF8(stringy) + 1; var u8array = new Array(len); var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length); if (dontAddNull)
1037
- u8array.length = numBytesWritten; return u8array; }
1038
- function writeArrayToMemory(array, buffer) { HEAP8.set(array, buffer); }
1039
- function _strftime(s, maxsize, format, tm) { var tm_zone = HEAP32[tm + 40 >> 2]; var date = { tm_sec: HEAP32[tm >> 2], tm_min: HEAP32[tm + 4 >> 2], tm_hour: HEAP32[tm + 8 >> 2], tm_mday: HEAP32[tm + 12 >> 2], tm_mon: HEAP32[tm + 16 >> 2], tm_year: HEAP32[tm + 20 >> 2], tm_wday: HEAP32[tm + 24 >> 2], tm_yday: HEAP32[tm + 28 >> 2], tm_isdst: HEAP32[tm + 32 >> 2], tm_gmtoff: HEAP32[tm + 36 >> 2], tm_zone: tm_zone ? UTF8ToString(tm_zone) : "" }; var pattern = UTF8ToString(format); var EXPANSION_RULES_1 = { "%c": "%a %b %d %H:%M:%S %Y", "%D": "%m/%d/%y", "%F": "%Y-%m-%d", "%h": "%b", "%r": "%I:%M:%S %p", "%R": "%H:%M", "%T": "%H:%M:%S", "%x": "%m/%d/%y", "%X": "%H:%M:%S", "%Ec": "%c", "%EC": "%C", "%Ex": "%m/%d/%y", "%EX": "%H:%M:%S", "%Ey": "%y", "%EY": "%Y", "%Od": "%d", "%Oe": "%e", "%OH": "%H", "%OI": "%I", "%Om": "%m", "%OM": "%M", "%OS": "%S", "%Ou": "%u", "%OU": "%U", "%OV": "%V", "%Ow": "%w", "%OW": "%W", "%Oy": "%y" }; for (var rule in EXPANSION_RULES_1) {
1040
- pattern = pattern.replace(new RegExp(rule, "g"), EXPANSION_RULES_1[rule]);
1041
- } var WEEKDAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; var MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; function leadingSomething(value, digits, character) { var str = typeof value == "number" ? value.toString() : value || ""; while (str.length < digits) {
1042
- str = character[0] + str;
1043
- } return str; } function leadingNulls(value, digits) { return leadingSomething(value, digits, "0"); } function compareByDay(date1, date2) { function sgn(value) { return value < 0 ? -1 : value > 0 ? 1 : 0; } var compare; if ((compare = sgn(date1.getFullYear() - date2.getFullYear())) === 0) {
1044
- if ((compare = sgn(date1.getMonth() - date2.getMonth())) === 0) {
1045
- compare = sgn(date1.getDate() - date2.getDate());
1046
- }
1047
- } return compare; } function getFirstWeekStartDate(janFourth) { switch (janFourth.getDay()) {
1048
- case 0: return new Date(janFourth.getFullYear() - 1, 11, 29);
1049
- case 1: return janFourth;
1050
- case 2: return new Date(janFourth.getFullYear(), 0, 3);
1051
- case 3: return new Date(janFourth.getFullYear(), 0, 2);
1052
- case 4: return new Date(janFourth.getFullYear(), 0, 1);
1053
- case 5: return new Date(janFourth.getFullYear() - 1, 11, 31);
1054
- case 6: return new Date(janFourth.getFullYear() - 1, 11, 30);
1055
- } } function getWeekBasedYear(date) { var thisDate = __addDays(new Date(date.tm_year + 1900, 0, 1), date.tm_yday); var janFourthThisYear = new Date(thisDate.getFullYear(), 0, 4); var janFourthNextYear = new Date(thisDate.getFullYear() + 1, 0, 4); var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear); var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear); if (compareByDay(firstWeekStartThisYear, thisDate) <= 0) {
1056
- if (compareByDay(firstWeekStartNextYear, thisDate) <= 0) {
1057
- return thisDate.getFullYear() + 1;
1058
- }
1059
- return thisDate.getFullYear();
1060
- } return thisDate.getFullYear() - 1; } var EXPANSION_RULES_2 = { "%a": function (date) { return WEEKDAYS[date.tm_wday].substring(0, 3); }, "%A": function (date) { return WEEKDAYS[date.tm_wday]; }, "%b": function (date) { return MONTHS[date.tm_mon].substring(0, 3); }, "%B": function (date) { return MONTHS[date.tm_mon]; }, "%C": function (date) { var year = date.tm_year + 1900; return leadingNulls(year / 100 | 0, 2); }, "%d": function (date) { return leadingNulls(date.tm_mday, 2); }, "%e": function (date) { return leadingSomething(date.tm_mday, 2, " "); }, "%g": function (date) { return getWeekBasedYear(date).toString().substring(2); }, "%G": function (date) { return getWeekBasedYear(date); }, "%H": function (date) { return leadingNulls(date.tm_hour, 2); }, "%I": function (date) { var twelveHour = date.tm_hour; if (twelveHour == 0)
1061
- twelveHour = 12;
1062
- else if (twelveHour > 12)
1063
- twelveHour -= 12; return leadingNulls(twelveHour, 2); }, "%j": function (date) { return leadingNulls(date.tm_mday + __arraySum(__isLeapYear(date.tm_year + 1900) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, date.tm_mon - 1), 3); }, "%m": function (date) { return leadingNulls(date.tm_mon + 1, 2); }, "%M": function (date) { return leadingNulls(date.tm_min, 2); }, "%n": function () { return "\n"; }, "%p": function (date) { if (date.tm_hour >= 0 && date.tm_hour < 12) {
1064
- return "AM";
1065
- } return "PM"; }, "%S": function (date) { return leadingNulls(date.tm_sec, 2); }, "%t": function () { return "\t"; }, "%u": function (date) { return date.tm_wday || 7; }, "%U": function (date) { var days = date.tm_yday + 7 - date.tm_wday; return leadingNulls(Math.floor(days / 7), 2); }, "%V": function (date) { var val = Math.floor((date.tm_yday + 7 - (date.tm_wday + 6) % 7) / 7); if ((date.tm_wday + 371 - date.tm_yday - 2) % 7 <= 2) {
1066
- val++;
1067
- } if (!val) {
1068
- val = 52;
1069
- var dec31 = (date.tm_wday + 7 - date.tm_yday - 1) % 7;
1070
- if (dec31 == 4 || dec31 == 5 && __isLeapYear(date.tm_year % 400 - 1)) {
1071
- val++;
1072
- }
1073
- }
1074
- else if (val == 53) {
1075
- var jan1 = (date.tm_wday + 371 - date.tm_yday) % 7;
1076
- if (jan1 != 4 && (jan1 != 3 || !__isLeapYear(date.tm_year)))
1077
- val = 1;
1078
- } return leadingNulls(val, 2); }, "%w": function (date) { return date.tm_wday; }, "%W": function (date) { var days = date.tm_yday + 7 - (date.tm_wday + 6) % 7; return leadingNulls(Math.floor(days / 7), 2); }, "%y": function (date) { return (date.tm_year + 1900).toString().substring(2); }, "%Y": function (date) { return date.tm_year + 1900; }, "%z": function (date) { var off = date.tm_gmtoff; var ahead = off >= 0; off = Math.abs(off) / 60; off = off / 60 * 100 + off % 60; return (ahead ? "+" : "-") + String("0000" + off).slice(-4); }, "%Z": function (date) { return date.tm_zone; }, "%%": function () { return "%"; } }; pattern = pattern.replace(/%%/g, "\0\0"); for (var rule in EXPANSION_RULES_2) {
1079
- if (pattern.includes(rule)) {
1080
- pattern = pattern.replace(new RegExp(rule, "g"), EXPANSION_RULES_2[rule](date));
1081
- }
1082
- } pattern = pattern.replace(/\0\0/g, "%"); var bytes = intArrayFromString(pattern, false); if (bytes.length > maxsize) {
1083
- return 0;
1084
- } writeArrayToMemory(bytes, s); return bytes.length - 1; }
1085
- function _strftime_l(s, maxsize, format, tm, loc) { return _strftime(s, maxsize, format, tm); }
1086
- embind_init_charCodes();
1087
- BindingError = Module["BindingError"] = extendError(Error, "BindingError");
1088
- InternalError = Module["InternalError"] = extendError(Error, "InternalError");
1089
- init_ClassHandle();
1090
- init_embind();
1091
- init_RegisteredPointer();
1092
- UnboundTypeError = Module["UnboundTypeError"] = extendError(Error, "UnboundTypeError");
1093
- init_emval();
1094
- var wasmImports = { "__assert_fail": ___assert_fail, "_embind_register_bigint": __embind_register_bigint, "_embind_register_bool": __embind_register_bool, "_embind_register_class": __embind_register_class, "_embind_register_class_constructor": __embind_register_class_constructor, "_embind_register_class_property": __embind_register_class_property, "_embind_register_emval": __embind_register_emval, "_embind_register_float": __embind_register_float, "_embind_register_function": __embind_register_function, "_embind_register_integer": __embind_register_integer, "_embind_register_memory_view": __embind_register_memory_view, "_embind_register_std_string": __embind_register_std_string, "_embind_register_std_wstring": __embind_register_std_wstring, "_embind_register_void": __embind_register_void, "abort": _abort, "emscripten_memcpy_big": _emscripten_memcpy_big, "emscripten_resize_heap": _emscripten_resize_heap, "environ_get": _environ_get, "environ_sizes_get": _environ_sizes_get, "strftime_l": _strftime_l, "wasm_loadfileproc": wasm_loadfileproc, "wasm_msgproc": wasm_msgproc };
1095
- var asm = createWasm();
1096
- var ___wasm_call_ctors = function () { return (___wasm_call_ctors = Module["asm"]["__wasm_call_ctors"]).apply(null, arguments); };
1097
- var _kmcmp_CompileKeyboard = Module["_kmcmp_CompileKeyboard"] = function () { return (_kmcmp_CompileKeyboard = Module["_kmcmp_CompileKeyboard"] = Module["asm"]["kmcmp_CompileKeyboard"]).apply(null, arguments); };
1098
- var _kmcmp_parseUnicodeSet = Module["_kmcmp_parseUnicodeSet"] = function () { return (_kmcmp_parseUnicodeSet = Module["_kmcmp_parseUnicodeSet"] = Module["asm"]["kmcmp_parseUnicodeSet"]).apply(null, arguments); };
1099
- var _malloc = function () { return (_malloc = Module["asm"]["malloc"]).apply(null, arguments); };
1100
- var _free = function () { return (_free = Module["asm"]["free"]).apply(null, arguments); };
1101
- var ___getTypeName = Module["___getTypeName"] = function () { return (___getTypeName = Module["___getTypeName"] = Module["asm"]["__getTypeName"]).apply(null, arguments); };
1102
- var __embind_initialize_bindings = Module["__embind_initialize_bindings"] = function () { return (__embind_initialize_bindings = Module["__embind_initialize_bindings"] = Module["asm"]["_embind_initialize_bindings"]).apply(null, arguments); };
1103
- var ___errno_location = function () { return (___errno_location = Module["asm"]["__errno_location"]).apply(null, arguments); };
1104
- var ___trap = function () { return (___trap = Module["asm"]["__trap"]).apply(null, arguments); };
1105
- var stackSave = function () { return (stackSave = Module["asm"]["stackSave"]).apply(null, arguments); };
1106
- var stackRestore = function () { return (stackRestore = Module["asm"]["stackRestore"]).apply(null, arguments); };
1107
- var stackAlloc = function () { return (stackAlloc = Module["asm"]["stackAlloc"]).apply(null, arguments); };
1108
- var dynCall_viijii = Module["dynCall_viijii"] = function () { return (dynCall_viijii = Module["dynCall_viijii"] = Module["asm"]["dynCall_viijii"]).apply(null, arguments); };
1109
- var dynCall_iiiiij = Module["dynCall_iiiiij"] = function () { return (dynCall_iiiiij = Module["dynCall_iiiiij"] = Module["asm"]["dynCall_iiiiij"]).apply(null, arguments); };
1110
- var dynCall_iiiiijj = Module["dynCall_iiiiijj"] = function () { return (dynCall_iiiiijj = Module["dynCall_iiiiijj"] = Module["asm"]["dynCall_iiiiijj"]).apply(null, arguments); };
1111
- var dynCall_iiiiiijj = Module["dynCall_iiiiiijj"] = function () { return (dynCall_iiiiiijj = Module["dynCall_iiiiiijj"] = Module["asm"]["dynCall_iiiiiijj"]).apply(null, arguments); };
1112
- var ___start_em_js = Module["___start_em_js"] = 58144;
1113
- var ___stop_em_js = Module["___stop_em_js"] = 58840;
1114
- Module["UTF8ToString"] = UTF8ToString;
1115
- var calledRun;
1116
- dependenciesFulfilled = function runCaller() { if (!calledRun)
1117
- run(); if (!calledRun)
1118
- dependenciesFulfilled = runCaller; };
1119
- function run() { if (runDependencies > 0) {
1120
- return;
1121
- } preRun(); if (runDependencies > 0) {
1122
- return;
1123
- } function doRun() { if (calledRun)
1124
- return; calledRun = true; Module["calledRun"] = true; if (ABORT)
1125
- return; initRuntime(); readyPromiseResolve(Module); if (Module["onRuntimeInitialized"])
1126
- Module["onRuntimeInitialized"](); postRun(); } if (Module["setStatus"]) {
1127
- Module["setStatus"]("Running...");
1128
- setTimeout(function () { setTimeout(function () { Module["setStatus"](""); }, 1); doRun(); }, 1);
1129
- }
1130
- else {
1131
- doRun();
1132
- } }
1133
- if (Module["preInit"]) {
1134
- if (typeof Module["preInit"] == "function")
1135
- Module["preInit"] = [Module["preInit"]];
1136
- while (Module["preInit"].length > 0) {
1137
- Module["preInit"].pop()();
1138
- }
1139
- }
1140
- run();
1141
- return Module.ready;
1142
- });
1143
- })();
1144
- export default Module;
1145
- //# sourceMappingURL=wasm-host.js.map
1
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e74e4a68-a330-5169-afb5-9cc31699f8ce")}catch(e){}}();
2
+ var Module = (() => {
3
+ var _scriptDir = import.meta.url;
4
+ return (async function (Module = {}) {
5
+ // include: shell.js
6
+ // The Module object: Our interface to the outside world. We import
7
+ // and export values on it. There are various ways Module can be used:
8
+ // 1. Not defined. We create it here
9
+ // 2. A function parameter, function(Module) { ..generated code.. }
10
+ // 3. pre-run appended it, var Module = {}; ..generated code..
11
+ // 4. External script tag defines var Module.
12
+ // We need to check if Module already exists (e.g. case 3 above).
13
+ // Substitution will be replaced with actual code on later stage of the build,
14
+ // this way Closure Compiler will not mangle it (e.g. case 4. above).
15
+ // Note that if you want to run closure, and also to use Module
16
+ // after the generated code, you will need to define var Module = {};
17
+ // before the code. Then that object will be used in the code, and you
18
+ // can continue to use Module afterwards as well.
19
+ var Module = typeof Module != 'undefined' ? Module : {};
20
+ // Set up the promise that indicates the Module is initialized
21
+ var readyPromiseResolve, readyPromiseReject;
22
+ Module['ready'] = new Promise(function (resolve, reject) {
23
+ readyPromiseResolve = resolve;
24
+ readyPromiseReject = reject;
25
+ });
26
+ // --pre-jses are emitted after the Module integration code, so that they can
27
+ // refer to Module (if they choose; they can also define Module)
28
+ // Sometimes an existing Module object exists with properties
29
+ // meant to overwrite the default module functionality. Here
30
+ // we collect those properties and reapply _after_ we configure
31
+ // the current environment's defaults to avoid having to be so
32
+ // defensive during initialization.
33
+ var moduleOverrides = Object.assign({}, Module);
34
+ var arguments_ = [];
35
+ var thisProgram = './this.program';
36
+ var quit_ = (status, toThrow) => {
37
+ throw toThrow;
38
+ };
39
+ // Determine the runtime environment we are in. You can customize this by
40
+ // setting the ENVIRONMENT setting at compile time (see settings.js).
41
+ // Attempt to auto-detect the environment
42
+ var ENVIRONMENT_IS_WEB = typeof window == 'object';
43
+ var ENVIRONMENT_IS_WORKER = typeof importScripts == 'function';
44
+ // N.b. Electron.js environment is simultaneously a NODE-environment, but
45
+ // also a web environment.
46
+ var ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string';
47
+ var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
48
+ // `/` should be present at the end if `scriptDirectory` is not empty
49
+ var scriptDirectory = '';
50
+ function locateFile(path) {
51
+ if (Module['locateFile']) {
52
+ return Module['locateFile'](path, scriptDirectory);
53
+ }
54
+ return scriptDirectory + path;
55
+ }
56
+ // Hooks that are implemented differently in different runtime environments.
57
+ var read_, readAsync, readBinary, setWindowTitle;
58
+ if (ENVIRONMENT_IS_NODE) {
59
+ // `require()` is no-op in an ESM module, use `createRequire()` to construct
60
+ // the require()` function. This is only necessary for multi-environment
61
+ // builds, `-sENVIRONMENT=node` emits a static import declaration instead.
62
+ // TODO: Swap all `require()`'s with `import()`'s?
63
+ const { createRequire } = await import('module');
64
+ /** @suppress{duplicate} */
65
+ var require = createRequire(import.meta.url);
66
+ // These modules will usually be used on Node.js. Load them eagerly to avoid
67
+ // the complexity of lazy-loading.
68
+ var fs = require('fs');
69
+ var nodePath = require('path');
70
+ if (ENVIRONMENT_IS_WORKER) {
71
+ scriptDirectory = nodePath.dirname(scriptDirectory) + '/';
72
+ }
73
+ else {
74
+ // EXPORT_ES6 + ENVIRONMENT_IS_NODE always requires use of import.meta.url,
75
+ // since there's no way getting the current absolute path of the module when
76
+ // support for that is not available.
77
+ scriptDirectory = require('url').fileURLToPath(new URL('./', import.meta.url)); // includes trailing slash
78
+ }
79
+ // include: node_shell_read.js
80
+ read_ = (filename, binary) => {
81
+ // We need to re-wrap `file://` strings to URLs. Normalizing isn't
82
+ // necessary in that case, the path should already be absolute.
83
+ filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
84
+ return fs.readFileSync(filename, binary ? undefined : 'utf8');
85
+ };
86
+ readBinary = (filename) => {
87
+ var ret = read_(filename, true);
88
+ if (!ret.buffer) {
89
+ ret = new Uint8Array(ret);
90
+ }
91
+ return ret;
92
+ };
93
+ readAsync = (filename, onload, onerror) => {
94
+ // See the comment in the `read_` function.
95
+ filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
96
+ fs.readFile(filename, function (err, data) {
97
+ if (err)
98
+ onerror(err);
99
+ else
100
+ onload(data.buffer);
101
+ });
102
+ };
103
+ // end include: node_shell_read.js
104
+ if (process.argv.length > 1) {
105
+ thisProgram = process.argv[1].replace(/\\/g, '/');
106
+ }
107
+ arguments_ = process.argv.slice(2);
108
+ // MODULARIZE will export the module in the proper place outside, we don't need to export here
109
+ process.on('uncaughtException', function (ex) {
110
+ // suppress ExitStatus exceptions from showing an error
111
+ if (ex !== 'unwind' && !(ex instanceof ExitStatus) && !(ex.context instanceof ExitStatus)) {
112
+ throw ex;
113
+ }
114
+ });
115
+ // Without this older versions of node (< v15) will log unhandled rejections
116
+ // but return 0, which is not normally the desired behaviour. This is
117
+ // not be needed with node v15 and about because it is now the default
118
+ // behaviour:
119
+ // See https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode
120
+ var nodeMajor = process.versions.node.split(".")[0];
121
+ if (nodeMajor < 15) {
122
+ process.on('unhandledRejection', function (reason) { throw reason; });
123
+ }
124
+ quit_ = (status, toThrow) => {
125
+ process.exitCode = status;
126
+ throw toThrow;
127
+ };
128
+ Module['inspect'] = function () { return '[Emscripten Module object]'; };
129
+ }
130
+ else
131
+ // Note that this includes Node.js workers when relevant (pthreads is enabled).
132
+ // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
133
+ // ENVIRONMENT_IS_NODE.
134
+ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
135
+ if (ENVIRONMENT_IS_WORKER) { // Check worker, not web, since window could be polyfilled
136
+ scriptDirectory = self.location.href;
137
+ }
138
+ else if (typeof document != 'undefined' && document.currentScript) { // web
139
+ scriptDirectory = document.currentScript.src;
140
+ }
141
+ // When MODULARIZE, this JS may be executed later, after document.currentScript
142
+ // is gone, so we saved it, and we use it here instead of any other info.
143
+ if (_scriptDir) {
144
+ scriptDirectory = _scriptDir;
145
+ }
146
+ // blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them.
147
+ // otherwise, slice off the final part of the url to find the script directory.
148
+ // if scriptDirectory does not contain a slash, lastIndexOf will return -1,
149
+ // and scriptDirectory will correctly be replaced with an empty string.
150
+ // If scriptDirectory contains a query (starting with ?) or a fragment (starting with #),
151
+ // they are removed because they could contain a slash.
152
+ if (scriptDirectory.indexOf('blob:') !== 0) {
153
+ scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf('/') + 1);
154
+ }
155
+ else {
156
+ scriptDirectory = '';
157
+ }
158
+ // Differentiate the Web Worker from the Node Worker case, as reading must
159
+ // be done differently.
160
+ {
161
+ // include: web_or_worker_shell_read.js
162
+ read_ = (url) => {
163
+ var xhr = new XMLHttpRequest();
164
+ xhr.open('GET', url, false);
165
+ xhr.send(null);
166
+ return xhr.responseText;
167
+ };
168
+ if (ENVIRONMENT_IS_WORKER) {
169
+ readBinary = (url) => {
170
+ var xhr = new XMLHttpRequest();
171
+ xhr.open('GET', url, false);
172
+ xhr.responseType = 'arraybuffer';
173
+ xhr.send(null);
174
+ return new Uint8Array(/** @type{!ArrayBuffer} */ (xhr.response));
175
+ };
176
+ }
177
+ readAsync = (url, onload, onerror) => {
178
+ var xhr = new XMLHttpRequest();
179
+ xhr.open('GET', url, true);
180
+ xhr.responseType = 'arraybuffer';
181
+ xhr.onload = () => {
182
+ if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
183
+ onload(xhr.response);
184
+ return;
185
+ }
186
+ onerror();
187
+ };
188
+ xhr.onerror = onerror;
189
+ xhr.send(null);
190
+ };
191
+ // end include: web_or_worker_shell_read.js
192
+ }
193
+ setWindowTitle = (title) => document.title = title;
194
+ }
195
+ else {
196
+ }
197
+ var out = Module['print'] || console.log.bind(console);
198
+ var err = Module['printErr'] || console.warn.bind(console);
199
+ // Merge back in the overrides
200
+ Object.assign(Module, moduleOverrides);
201
+ // Free the object hierarchy contained in the overrides, this lets the GC
202
+ // reclaim data used e.g. in memoryInitializerRequest, which is a large typed array.
203
+ moduleOverrides = null;
204
+ // Emit code to handle expected values on the Module object. This applies Module.x
205
+ // to the proper local x. This has two benefits: first, we only emit it if it is
206
+ // expected to arrive, and second, by using a local everywhere else that can be
207
+ // minified.
208
+ if (Module['arguments'])
209
+ arguments_ = Module['arguments'];
210
+ if (Module['thisProgram'])
211
+ thisProgram = Module['thisProgram'];
212
+ if (Module['quit'])
213
+ quit_ = Module['quit'];
214
+ // perform assertions in shell.js after we set up out() and err(), as otherwise if an assertion fails it cannot print the message
215
+ // end include: shell.js
216
+ // include: preamble.js
217
+ // === Preamble library stuff ===
218
+ // Documentation for the public APIs defined in this file must be updated in:
219
+ // site/source/docs/api_reference/preamble.js.rst
220
+ // A prebuilt local version of the documentation is available at:
221
+ // site/build/text/docs/api_reference/preamble.js.txt
222
+ // You can also build docs locally as HTML or other formats in site/
223
+ // An online HTML version (which may be of a different version of Emscripten)
224
+ // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
225
+ var wasmBinary;
226
+ if (Module['wasmBinary'])
227
+ wasmBinary = Module['wasmBinary'];
228
+ var noExitRuntime = Module['noExitRuntime'] || true;
229
+ if (typeof WebAssembly != 'object') {
230
+ abort('no native wasm support detected');
231
+ }
232
+ // Wasm globals
233
+ var wasmMemory;
234
+ //========================================
235
+ // Runtime essentials
236
+ //========================================
237
+ // whether we are quitting the application. no code should run after this.
238
+ // set in exit() and abort()
239
+ var ABORT = false;
240
+ // set by exit() and abort(). Passed to 'onExit' handler.
241
+ // NOTE: This is also used as the process return code code in shell environments
242
+ // but only when noExitRuntime is false.
243
+ var EXITSTATUS;
244
+ /** @type {function(*, string=)} */
245
+ function assert(condition, text) {
246
+ if (!condition) {
247
+ // This build was created without ASSERTIONS defined. `assert()` should not
248
+ // ever be called in this configuration but in case there are callers in
249
+ // the wild leave this simple abort() implemenation here for now.
250
+ abort(text);
251
+ }
252
+ }
253
+ // include: runtime_strings.js
254
+ // runtime_strings.js: String related runtime functions that are part of both
255
+ // MINIMAL_RUNTIME and regular runtime.
256
+ var UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf8') : undefined;
257
+ /**
258
+ * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
259
+ * array that contains uint8 values, returns a copy of that string as a
260
+ * Javascript String object.
261
+ * heapOrArray is either a regular array, or a JavaScript typed array view.
262
+ * @param {number} idx
263
+ * @param {number=} maxBytesToRead
264
+ * @return {string}
265
+ */
266
+ function UTF8ArrayToString(heapOrArray, idx, maxBytesToRead) {
267
+ var endIdx = idx + maxBytesToRead;
268
+ var endPtr = idx;
269
+ // TextDecoder needs to know the byte length in advance, it doesn't stop on
270
+ // null terminator by itself. Also, use the length info to avoid running tiny
271
+ // strings through TextDecoder, since .subarray() allocates garbage.
272
+ // (As a tiny code save trick, compare endPtr against endIdx using a negation,
273
+ // so that undefined means Infinity)
274
+ while (heapOrArray[endPtr] && !(endPtr >= endIdx))
275
+ ++endPtr;
276
+ if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
277
+ return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
278
+ }
279
+ var str = '';
280
+ // If building with TextDecoder, we have already computed the string length
281
+ // above, so test loop end condition against that
282
+ while (idx < endPtr) {
283
+ // For UTF8 byte structure, see:
284
+ // http://en.wikipedia.org/wiki/UTF-8#Description
285
+ // https://www.ietf.org/rfc/rfc2279.txt
286
+ // https://tools.ietf.org/html/rfc3629
287
+ var u0 = heapOrArray[idx++];
288
+ if (!(u0 & 0x80)) {
289
+ str += String.fromCharCode(u0);
290
+ continue;
291
+ }
292
+ var u1 = heapOrArray[idx++] & 63;
293
+ if ((u0 & 0xE0) == 0xC0) {
294
+ str += String.fromCharCode(((u0 & 31) << 6) | u1);
295
+ continue;
296
+ }
297
+ var u2 = heapOrArray[idx++] & 63;
298
+ if ((u0 & 0xF0) == 0xE0) {
299
+ u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
300
+ }
301
+ else {
302
+ u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
303
+ }
304
+ if (u0 < 0x10000) {
305
+ str += String.fromCharCode(u0);
306
+ }
307
+ else {
308
+ var ch = u0 - 0x10000;
309
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
310
+ }
311
+ }
312
+ return str;
313
+ }
314
+ /**
315
+ * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
316
+ * emscripten HEAP, returns a copy of that string as a Javascript String object.
317
+ *
318
+ * @param {number} ptr
319
+ * @param {number=} maxBytesToRead - An optional length that specifies the
320
+ * maximum number of bytes to read. You can omit this parameter to scan the
321
+ * string until the first \0 byte. If maxBytesToRead is passed, and the string
322
+ * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
323
+ * string will cut short at that byte index (i.e. maxBytesToRead will not
324
+ * produce a string of exact length [ptr, ptr+maxBytesToRead[) N.B. mixing
325
+ * frequent uses of UTF8ToString() with and without maxBytesToRead may throw
326
+ * JS JIT optimizations off, so it is worth to consider consistently using one
327
+ * @return {string}
328
+ */
329
+ function UTF8ToString(ptr, maxBytesToRead) {
330
+ return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
331
+ }
332
+ /**
333
+ * Copies the given Javascript String object 'str' to the given byte array at
334
+ * address 'outIdx', encoded in UTF8 form and null-terminated. The copy will
335
+ * require at most str.length*4+1 bytes of space in the HEAP. Use the function
336
+ * lengthBytesUTF8 to compute the exact number of bytes (excluding null
337
+ * terminator) that this function will write.
338
+ *
339
+ * @param {string} str - The Javascript string to copy.
340
+ * @param {ArrayBufferView|Array<number>} heap - The array to copy to. Each
341
+ * index in this array is assumed
342
+ * to be one 8-byte element.
343
+ * @param {number} outIdx - The starting offset in the array to begin the copying.
344
+ * @param {number} maxBytesToWrite - The maximum number of bytes this function
345
+ * can write to the array. This count should
346
+ * include the null terminator, i.e. if
347
+ * maxBytesToWrite=1, only the null terminator
348
+ * will be written and nothing else.
349
+ * maxBytesToWrite=0 does not write any bytes
350
+ * to the output, not even the null
351
+ * terminator.
352
+ * @return {number} The number of bytes written, EXCLUDING the null terminator.
353
+ */
354
+ function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) {
355
+ // Parameter maxBytesToWrite is not optional. Negative values, 0, null,
356
+ // undefined and false each don't write out any bytes.
357
+ if (!(maxBytesToWrite > 0))
358
+ return 0;
359
+ var startIdx = outIdx;
360
+ var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
361
+ for (var i = 0; i < str.length; ++i) {
362
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
363
+ // unit, not a Unicode code point of the character! So decode
364
+ // UTF16->UTF32->UTF8.
365
+ // See http://unicode.org/faq/utf_bom.html#utf16-3
366
+ // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
367
+ // and https://www.ietf.org/rfc/rfc2279.txt
368
+ // and https://tools.ietf.org/html/rfc3629
369
+ var u = str.charCodeAt(i); // possibly a lead surrogate
370
+ if (u >= 0xD800 && u <= 0xDFFF) {
371
+ var u1 = str.charCodeAt(++i);
372
+ u = 0x10000 + ((u & 0x3FF) << 10) | (u1 & 0x3FF);
373
+ }
374
+ if (u <= 0x7F) {
375
+ if (outIdx >= endIdx)
376
+ break;
377
+ heap[outIdx++] = u;
378
+ }
379
+ else if (u <= 0x7FF) {
380
+ if (outIdx + 1 >= endIdx)
381
+ break;
382
+ heap[outIdx++] = 0xC0 | (u >> 6);
383
+ heap[outIdx++] = 0x80 | (u & 63);
384
+ }
385
+ else if (u <= 0xFFFF) {
386
+ if (outIdx + 2 >= endIdx)
387
+ break;
388
+ heap[outIdx++] = 0xE0 | (u >> 12);
389
+ heap[outIdx++] = 0x80 | ((u >> 6) & 63);
390
+ heap[outIdx++] = 0x80 | (u & 63);
391
+ }
392
+ else {
393
+ if (outIdx + 3 >= endIdx)
394
+ break;
395
+ heap[outIdx++] = 0xF0 | (u >> 18);
396
+ heap[outIdx++] = 0x80 | ((u >> 12) & 63);
397
+ heap[outIdx++] = 0x80 | ((u >> 6) & 63);
398
+ heap[outIdx++] = 0x80 | (u & 63);
399
+ }
400
+ }
401
+ // Null-terminate the pointer to the buffer.
402
+ heap[outIdx] = 0;
403
+ return outIdx - startIdx;
404
+ }
405
+ /**
406
+ * Copies the given Javascript String object 'str' to the emscripten HEAP at
407
+ * address 'outPtr', null-terminated and encoded in UTF8 form. The copy will
408
+ * require at most str.length*4+1 bytes of space in the HEAP.
409
+ * Use the function lengthBytesUTF8 to compute the exact number of bytes
410
+ * (excluding null terminator) that this function will write.
411
+ *
412
+ * @return {number} The number of bytes written, EXCLUDING the null terminator.
413
+ */
414
+ function stringToUTF8(str, outPtr, maxBytesToWrite) {
415
+ return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
416
+ }
417
+ /**
418
+ * Returns the number of bytes the given Javascript string takes if encoded as a
419
+ * UTF8 byte array, EXCLUDING the null terminator byte.
420
+ *
421
+ * @param {string} str - JavaScript string to operator on
422
+ * @return {number} Length, in bytes, of the UTF8 encoded string.
423
+ */
424
+ function lengthBytesUTF8(str) {
425
+ var len = 0;
426
+ for (var i = 0; i < str.length; ++i) {
427
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
428
+ // unit, not a Unicode code point of the character! So decode
429
+ // UTF16->UTF32->UTF8.
430
+ // See http://unicode.org/faq/utf_bom.html#utf16-3
431
+ var c = str.charCodeAt(i); // possibly a lead surrogate
432
+ if (c <= 0x7F) {
433
+ len++;
434
+ }
435
+ else if (c <= 0x7FF) {
436
+ len += 2;
437
+ }
438
+ else if (c >= 0xD800 && c <= 0xDFFF) {
439
+ len += 4;
440
+ ++i;
441
+ }
442
+ else {
443
+ len += 3;
444
+ }
445
+ }
446
+ return len;
447
+ }
448
+ // end include: runtime_strings.js
449
+ // Memory management
450
+ var HEAP,
451
+ /** @type {!Int8Array} */
452
+ HEAP8,
453
+ /** @type {!Uint8Array} */
454
+ HEAPU8,
455
+ /** @type {!Int16Array} */
456
+ HEAP16,
457
+ /** @type {!Uint16Array} */
458
+ HEAPU16,
459
+ /** @type {!Int32Array} */
460
+ HEAP32,
461
+ /** @type {!Uint32Array} */
462
+ HEAPU32,
463
+ /** @type {!Float32Array} */
464
+ HEAPF32,
465
+ /** @type {!Float64Array} */
466
+ HEAPF64;
467
+ function updateMemoryViews() {
468
+ var b = wasmMemory.buffer;
469
+ Module['HEAP8'] = HEAP8 = new Int8Array(b);
470
+ Module['HEAP16'] = HEAP16 = new Int16Array(b);
471
+ Module['HEAP32'] = HEAP32 = new Int32Array(b);
472
+ Module['HEAPU8'] = HEAPU8 = new Uint8Array(b);
473
+ Module['HEAPU16'] = HEAPU16 = new Uint16Array(b);
474
+ Module['HEAPU32'] = HEAPU32 = new Uint32Array(b);
475
+ Module['HEAPF32'] = HEAPF32 = new Float32Array(b);
476
+ Module['HEAPF64'] = HEAPF64 = new Float64Array(b);
477
+ }
478
+ // include: runtime_init_table.js
479
+ // In regular non-RELOCATABLE mode the table is exported
480
+ // from the wasm module and this will be assigned once
481
+ // the exports are available.
482
+ var wasmTable;
483
+ // end include: runtime_init_table.js
484
+ // include: runtime_stack_check.js
485
+ // end include: runtime_stack_check.js
486
+ // include: runtime_assertions.js
487
+ // end include: runtime_assertions.js
488
+ var __ATPRERUN__ = []; // functions called before the runtime is initialized
489
+ var __ATINIT__ = []; // functions called during startup
490
+ var __ATEXIT__ = []; // functions called during shutdown
491
+ var __ATPOSTRUN__ = []; // functions called after the main() is called
492
+ var runtimeInitialized = false;
493
+ var runtimeKeepaliveCounter = 0;
494
+ function keepRuntimeAlive() {
495
+ return noExitRuntime || runtimeKeepaliveCounter > 0;
496
+ }
497
+ function preRun() {
498
+ if (Module['preRun']) {
499
+ if (typeof Module['preRun'] == 'function')
500
+ Module['preRun'] = [Module['preRun']];
501
+ while (Module['preRun'].length) {
502
+ addOnPreRun(Module['preRun'].shift());
503
+ }
504
+ }
505
+ callRuntimeCallbacks(__ATPRERUN__);
506
+ }
507
+ function initRuntime() {
508
+ runtimeInitialized = true;
509
+ callRuntimeCallbacks(__ATINIT__);
510
+ }
511
+ function postRun() {
512
+ if (Module['postRun']) {
513
+ if (typeof Module['postRun'] == 'function')
514
+ Module['postRun'] = [Module['postRun']];
515
+ while (Module['postRun'].length) {
516
+ addOnPostRun(Module['postRun'].shift());
517
+ }
518
+ }
519
+ callRuntimeCallbacks(__ATPOSTRUN__);
520
+ }
521
+ function addOnPreRun(cb) {
522
+ __ATPRERUN__.unshift(cb);
523
+ }
524
+ function addOnInit(cb) {
525
+ __ATINIT__.unshift(cb);
526
+ }
527
+ function addOnExit(cb) {
528
+ }
529
+ function addOnPostRun(cb) {
530
+ __ATPOSTRUN__.unshift(cb);
531
+ }
532
+ // include: runtime_math.js
533
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
534
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround
535
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
536
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc
537
+ // end include: runtime_math.js
538
+ // A counter of dependencies for calling run(). If we need to
539
+ // do asynchronous work before running, increment this and
540
+ // decrement it. Incrementing must happen in a place like
541
+ // Module.preRun (used by emcc to add file preloading).
542
+ // Note that you can add dependencies in preRun, even though
543
+ // it happens right before run - run will be postponed until
544
+ // the dependencies are met.
545
+ var runDependencies = 0;
546
+ var runDependencyWatcher = null;
547
+ var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
548
+ function getUniqueRunDependency(id) {
549
+ return id;
550
+ }
551
+ function addRunDependency(id) {
552
+ runDependencies++;
553
+ if (Module['monitorRunDependencies']) {
554
+ Module['monitorRunDependencies'](runDependencies);
555
+ }
556
+ }
557
+ function removeRunDependency(id) {
558
+ runDependencies--;
559
+ if (Module['monitorRunDependencies']) {
560
+ Module['monitorRunDependencies'](runDependencies);
561
+ }
562
+ if (runDependencies == 0) {
563
+ if (runDependencyWatcher !== null) {
564
+ clearInterval(runDependencyWatcher);
565
+ runDependencyWatcher = null;
566
+ }
567
+ if (dependenciesFulfilled) {
568
+ var callback = dependenciesFulfilled;
569
+ dependenciesFulfilled = null;
570
+ callback(); // can add another dependenciesFulfilled
571
+ }
572
+ }
573
+ }
574
+ /** @param {string|number=} what */
575
+ function abort(what) {
576
+ if (Module['onAbort']) {
577
+ Module['onAbort'](what);
578
+ }
579
+ what = 'Aborted(' + what + ')';
580
+ // TODO(sbc): Should we remove printing and leave it up to whoever
581
+ // catches the exception?
582
+ err(what);
583
+ ABORT = true;
584
+ EXITSTATUS = 1;
585
+ what += '. Build with -sASSERTIONS for more info.';
586
+ // Use a wasm runtime error, because a JS error might be seen as a foreign
587
+ // exception, which means we'd run destructors on it. We need the error to
588
+ // simply make the program stop.
589
+ // FIXME This approach does not work in Wasm EH because it currently does not assume
590
+ // all RuntimeErrors are from traps; it decides whether a RuntimeError is from
591
+ // a trap or not based on a hidden field within the object. So at the moment
592
+ // we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that
593
+ // allows this in the wasm spec.
594
+ // Suppress closure compiler warning here. Closure compiler's builtin extern
595
+ // defintion for WebAssembly.RuntimeError claims it takes no arguments even
596
+ // though it can.
597
+ // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
598
+ // See above, in the meantime, we resort to wasm code for trapping.
599
+ //
600
+ // In case abort() is called before the module is initialized, Module['asm']
601
+ // and its exported '__trap' function is not available, in which case we throw
602
+ // a RuntimeError.
603
+ //
604
+ // We trap instead of throwing RuntimeError to prevent infinite-looping in
605
+ // Wasm EH code (because RuntimeError is considered as a foreign exception and
606
+ // caught by 'catch_all'), but in case throwing RuntimeError is fine because
607
+ // the module has not even been instantiated, even less running.
608
+ if (runtimeInitialized) {
609
+ ___trap();
610
+ }
611
+ /** @suppress {checkTypes} */
612
+ var e = new WebAssembly.RuntimeError(what);
613
+ readyPromiseReject(e);
614
+ // Throw the error whether or not MODULARIZE is set because abort is used
615
+ // in code paths apart from instantiation where an exception is expected
616
+ // to be thrown when abort is called.
617
+ throw e;
618
+ }
619
+ // include: memoryprofiler.js
620
+ // end include: memoryprofiler.js
621
+ // include: URIUtils.js
622
+ // Prefix of data URIs emitted by SINGLE_FILE and related options.
623
+ var dataURIPrefix = 'data:application/octet-stream;base64,';
624
+ // Indicates whether filename is a base64 data URI.
625
+ function isDataURI(filename) {
626
+ // Prefix of data URIs emitted by SINGLE_FILE and related options.
627
+ return filename.startsWith(dataURIPrefix);
628
+ }
629
+ // Indicates whether filename is delivered via file protocol (as opposed to http/https)
630
+ function isFileURI(filename) {
631
+ return filename.startsWith('file://');
632
+ }
633
+ // end include: URIUtils.js
634
+ // include: runtime_exceptions.js
635
+ // end include: runtime_exceptions.js
636
+ var wasmBinaryFile;
637
+ if (Module['locateFile']) {
638
+ wasmBinaryFile = 'wasm-host.wasm';
639
+ if (!isDataURI(wasmBinaryFile)) {
640
+ wasmBinaryFile = locateFile(wasmBinaryFile);
641
+ }
642
+ }
643
+ else {
644
+ // Use bundler-friendly `new URL(..., import.meta.url)` pattern; works in browsers too.
645
+ wasmBinaryFile = new URL('wasm-host.wasm', import.meta.url).href;
646
+ }
647
+ function getBinary(file) {
648
+ try {
649
+ if (file == wasmBinaryFile && wasmBinary) {
650
+ return new Uint8Array(wasmBinary);
651
+ }
652
+ if (readBinary) {
653
+ return readBinary(file);
654
+ }
655
+ throw "both async and sync fetching of the wasm failed";
656
+ }
657
+ catch (err) {
658
+ abort(err);
659
+ }
660
+ }
661
+ function getBinaryPromise(binaryFile) {
662
+ // If we don't have the binary yet, try to to load it asynchronously.
663
+ // Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
664
+ // See https://github.com/github/fetch/pull/92#issuecomment-140665932
665
+ // Cordova or Electron apps are typically loaded from a file:// url.
666
+ // So use fetch if it is available and the url is not a file, otherwise fall back to XHR.
667
+ if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
668
+ if (typeof fetch == 'function'
669
+ && !isFileURI(binaryFile)) {
670
+ return fetch(binaryFile, { credentials: 'same-origin' }).then(function (response) {
671
+ if (!response['ok']) {
672
+ throw "failed to load wasm binary file at '" + binaryFile + "'";
673
+ }
674
+ return response['arrayBuffer']();
675
+ }).catch(function () {
676
+ return getBinary(binaryFile);
677
+ });
678
+ }
679
+ else {
680
+ if (readAsync) {
681
+ // fetch is not available or url is file => try XHR (readAsync uses XHR internally)
682
+ return new Promise(function (resolve, reject) {
683
+ readAsync(binaryFile, function (response) { resolve(new Uint8Array(/** @type{!ArrayBuffer} */ (response))); }, reject);
684
+ });
685
+ }
686
+ }
687
+ }
688
+ // Otherwise, getBinary should be able to get it synchronously
689
+ return Promise.resolve().then(function () { return getBinary(binaryFile); });
690
+ }
691
+ function instantiateArrayBuffer(binaryFile, imports, receiver) {
692
+ return getBinaryPromise(binaryFile).then(function (binary) {
693
+ return WebAssembly.instantiate(binary, imports);
694
+ }).then(function (instance) {
695
+ return instance;
696
+ }).then(receiver, function (reason) {
697
+ err('failed to asynchronously prepare wasm: ' + reason);
698
+ abort(reason);
699
+ });
700
+ }
701
+ function instantiateAsync(binary, binaryFile, imports, callback) {
702
+ if (!binary &&
703
+ typeof WebAssembly.instantiateStreaming == 'function' &&
704
+ !isDataURI(binaryFile) &&
705
+ // Don't use streaming for file:// delivered objects in a webview, fetch them synchronously.
706
+ !isFileURI(binaryFile) &&
707
+ // Avoid instantiateStreaming() on Node.js environment for now, as while
708
+ // Node.js v18.1.0 implements it, it does not have a full fetch()
709
+ // implementation yet.
710
+ //
711
+ // Reference:
712
+ // https://github.com/emscripten-core/emscripten/pull/16917
713
+ !ENVIRONMENT_IS_NODE &&
714
+ typeof fetch == 'function') {
715
+ return fetch(binaryFile, { credentials: 'same-origin' }).then(function (response) {
716
+ // Suppress closure warning here since the upstream definition for
717
+ // instantiateStreaming only allows Promise<Repsponse> rather than
718
+ // an actual Response.
719
+ // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure is fixed.
720
+ /** @suppress {checkTypes} */
721
+ var result = WebAssembly.instantiateStreaming(response, imports);
722
+ return result.then(callback, function (reason) {
723
+ // We expect the most common failure cause to be a bad MIME type for the binary,
724
+ // in which case falling back to ArrayBuffer instantiation should work.
725
+ err('wasm streaming compile failed: ' + reason);
726
+ err('falling back to ArrayBuffer instantiation');
727
+ return instantiateArrayBuffer(binaryFile, imports, callback);
728
+ });
729
+ });
730
+ }
731
+ else {
732
+ return instantiateArrayBuffer(binaryFile, imports, callback);
733
+ }
734
+ }
735
+ // Create the wasm instance.
736
+ // Receives the wasm imports, returns the exports.
737
+ function createWasm() {
738
+ // prepare imports
739
+ var info = {
740
+ 'env': wasmImports,
741
+ 'wasi_snapshot_preview1': wasmImports,
742
+ };
743
+ // Load the wasm module and create an instance of using native support in the JS engine.
744
+ // handle a generated wasm instance, receiving its exports and
745
+ // performing other necessary setup
746
+ /** @param {WebAssembly.Module=} module*/
747
+ function receiveInstance(instance, module) {
748
+ var exports = instance.exports;
749
+ Module['asm'] = exports;
750
+ wasmMemory = Module['asm']['memory'];
751
+ updateMemoryViews();
752
+ wasmTable = Module['asm']['__indirect_function_table'];
753
+ addOnInit(Module['asm']['__wasm_call_ctors']);
754
+ removeRunDependency('wasm-instantiate');
755
+ return exports;
756
+ }
757
+ // wait for the pthread pool (if any)
758
+ addRunDependency('wasm-instantiate');
759
+ // Prefer streaming instantiation if available.
760
+ function receiveInstantiationResult(result) {
761
+ // 'result' is a ResultObject object which has both the module and instance.
762
+ // receiveInstance() will swap in the exports (to Module.asm) so they can be called
763
+ // 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.
764
+ // When the regression is fixed, can restore the above USE_PTHREADS-enabled path.
765
+ receiveInstance(result['instance']);
766
+ }
767
+ // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
768
+ // to manually instantiate the Wasm module themselves. This allows pages to run the instantiation parallel
769
+ // to any other async startup actions they are performing.
770
+ // Also pthreads and wasm workers initialize the wasm instance through this path.
771
+ if (Module['instantiateWasm']) {
772
+ try {
773
+ return Module['instantiateWasm'](info, receiveInstance);
774
+ }
775
+ catch (e) {
776
+ err('Module.instantiateWasm callback failed with error: ' + e);
777
+ // If instantiation fails, reject the module ready promise.
778
+ readyPromiseReject(e);
779
+ }
780
+ }
781
+ // If instantiation fails, reject the module ready promise.
782
+ instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject);
783
+ return {}; // no exports yet; we'll fill them in later
784
+ }
785
+ // Globals used by JS i64 conversions (see makeSetValue)
786
+ var tempDouble;
787
+ var tempI64;
788
+ // include: runtime_debug.js
789
+ // end include: runtime_debug.js
790
+ // === Body ===
791
+ function wasm_msgproc(line, msgcode, text, context) { const proc = globalThis[UTF8ToString(context)].message; if (!proc || typeof proc != 'function') {
792
+ console.log(`[${line}: ${msgcode}: ${UTF8ToString(text)}]`);
793
+ return 0;
794
+ }
795
+ else {
796
+ return proc(line, msgcode, UTF8ToString(text));
797
+ } }
798
+ function wasm_loadfileproc(filename, baseFilename, buffer, bufferSize, context) { const proc = globalThis[UTF8ToString(context)].loadFile; if (!proc || typeof proc != 'function') {
799
+ return 0;
800
+ }
801
+ else {
802
+ if (buffer == 0) {
803
+ return proc(UTF8ToString(filename), UTF8ToString(baseFilename), 0, 0);
804
+ }
805
+ else {
806
+ return proc(UTF8ToString(filename), UTF8ToString(baseFilename), buffer, bufferSize);
807
+ }
808
+ } }
809
+ // end include: preamble.js
810
+ /** @constructor */
811
+ function ExitStatus(status) {
812
+ this.name = 'ExitStatus';
813
+ this.message = 'Program terminated with exit(' + status + ')';
814
+ this.status = status;
815
+ }
816
+ function callRuntimeCallbacks(callbacks) {
817
+ while (callbacks.length > 0) {
818
+ // Pass the module as the first argument.
819
+ callbacks.shift()(Module);
820
+ }
821
+ }
822
+ /**
823
+ * @param {number} ptr
824
+ * @param {string} type
825
+ */
826
+ function getValue(ptr, type = 'i8') {
827
+ if (type.endsWith('*'))
828
+ type = '*';
829
+ switch (type) {
830
+ case 'i1': return HEAP8[((ptr) >> 0)];
831
+ case 'i8': return HEAP8[((ptr) >> 0)];
832
+ case 'i16': return HEAP16[((ptr) >> 1)];
833
+ case 'i32': return HEAP32[((ptr) >> 2)];
834
+ case 'i64': return HEAP32[((ptr) >> 2)];
835
+ case 'float': return HEAPF32[((ptr) >> 2)];
836
+ case 'double': return HEAPF64[((ptr) >> 3)];
837
+ case '*': return HEAPU32[((ptr) >> 2)];
838
+ default: abort('invalid type for getValue: ' + type);
839
+ }
840
+ }
841
+ /**
842
+ * @param {number} ptr
843
+ * @param {number} value
844
+ * @param {string} type
845
+ */
846
+ function setValue(ptr, value, type = 'i8') {
847
+ if (type.endsWith('*'))
848
+ type = '*';
849
+ switch (type) {
850
+ case 'i1':
851
+ HEAP8[((ptr) >> 0)] = value;
852
+ break;
853
+ case 'i8':
854
+ HEAP8[((ptr) >> 0)] = value;
855
+ break;
856
+ case 'i16':
857
+ HEAP16[((ptr) >> 1)] = value;
858
+ break;
859
+ case 'i32':
860
+ HEAP32[((ptr) >> 2)] = value;
861
+ break;
862
+ case 'i64':
863
+ (tempI64 = [value >>> 0, (tempDouble = value, (+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? ((Math.min((+(Math.floor((tempDouble) / 4294967296.0))), 4294967295.0)) | 0) >>> 0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble))) >>> 0)) / 4294967296.0))))) >>> 0) : 0)], HEAP32[((ptr) >> 2)] = tempI64[0], HEAP32[(((ptr) + (4)) >> 2)] = tempI64[1]);
864
+ break;
865
+ case 'float':
866
+ HEAPF32[((ptr) >> 2)] = value;
867
+ break;
868
+ case 'double':
869
+ HEAPF64[((ptr) >> 3)] = value;
870
+ break;
871
+ case '*':
872
+ HEAPU32[((ptr) >> 2)] = value;
873
+ break;
874
+ default: abort('invalid type for setValue: ' + type);
875
+ }
876
+ }
877
+ function ___assert_fail(condition, filename, line, func) {
878
+ abort('Assertion failed: ' + UTF8ToString(condition) + ', at: ' + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
879
+ }
880
+ var structRegistrations = {};
881
+ function runDestructors(destructors) {
882
+ while (destructors.length) {
883
+ var ptr = destructors.pop();
884
+ var del = destructors.pop();
885
+ del(ptr);
886
+ }
887
+ }
888
+ function simpleReadValueFromPointer(pointer) {
889
+ return this['fromWireType'](HEAP32[((pointer) >> 2)]);
890
+ }
891
+ var awaitingDependencies = {};
892
+ var registeredTypes = {};
893
+ var typeDependencies = {};
894
+ var char_0 = 48;
895
+ var char_9 = 57;
896
+ function makeLegalFunctionName(name) {
897
+ if (undefined === name) {
898
+ return '_unknown';
899
+ }
900
+ name = name.replace(/[^a-zA-Z0-9_]/g, '$');
901
+ var f = name.charCodeAt(0);
902
+ if (f >= char_0 && f <= char_9) {
903
+ return '_' + name;
904
+ }
905
+ return name;
906
+ }
907
+ function createNamedFunction(name, body) {
908
+ name = makeLegalFunctionName(name);
909
+ // Use an abject with a computed property name to create a new function with
910
+ // a name specified at runtime, but without using `new Function` or `eval`.
911
+ return {
912
+ [name]: function () {
913
+ return body.apply(this, arguments);
914
+ }
915
+ }[name];
916
+ }
917
+ function extendError(baseErrorType, errorName) {
918
+ var errorClass = createNamedFunction(errorName, function (message) {
919
+ this.name = errorName;
920
+ this.message = message;
921
+ var stack = (new Error(message)).stack;
922
+ if (stack !== undefined) {
923
+ this.stack = this.toString() + '\n' +
924
+ stack.replace(/^Error(:[^\n]*)?\n/, '');
925
+ }
926
+ });
927
+ errorClass.prototype = Object.create(baseErrorType.prototype);
928
+ errorClass.prototype.constructor = errorClass;
929
+ errorClass.prototype.toString = function () {
930
+ if (this.message === undefined) {
931
+ return this.name;
932
+ }
933
+ else {
934
+ return this.name + ': ' + this.message;
935
+ }
936
+ };
937
+ return errorClass;
938
+ }
939
+ var InternalError = undefined;
940
+ function throwInternalError(message) {
941
+ throw new InternalError(message);
942
+ }
943
+ function whenDependentTypesAreResolved(myTypes, dependentTypes, getTypeConverters) {
944
+ myTypes.forEach(function (type) {
945
+ typeDependencies[type] = dependentTypes;
946
+ });
947
+ function onComplete(typeConverters) {
948
+ var myTypeConverters = getTypeConverters(typeConverters);
949
+ if (myTypeConverters.length !== myTypes.length) {
950
+ throwInternalError('Mismatched type converter count');
951
+ }
952
+ for (var i = 0; i < myTypes.length; ++i) {
953
+ registerType(myTypes[i], myTypeConverters[i]);
954
+ }
955
+ }
956
+ var typeConverters = new Array(dependentTypes.length);
957
+ var unregisteredTypes = [];
958
+ var registered = 0;
959
+ dependentTypes.forEach((dt, i) => {
960
+ if (registeredTypes.hasOwnProperty(dt)) {
961
+ typeConverters[i] = registeredTypes[dt];
962
+ }
963
+ else {
964
+ unregisteredTypes.push(dt);
965
+ if (!awaitingDependencies.hasOwnProperty(dt)) {
966
+ awaitingDependencies[dt] = [];
967
+ }
968
+ awaitingDependencies[dt].push(() => {
969
+ typeConverters[i] = registeredTypes[dt];
970
+ ++registered;
971
+ if (registered === unregisteredTypes.length) {
972
+ onComplete(typeConverters);
973
+ }
974
+ });
975
+ }
976
+ });
977
+ if (0 === unregisteredTypes.length) {
978
+ onComplete(typeConverters);
979
+ }
980
+ }
981
+ function __embind_finalize_value_object(structType) {
982
+ var reg = structRegistrations[structType];
983
+ delete structRegistrations[structType];
984
+ var rawConstructor = reg.rawConstructor;
985
+ var rawDestructor = reg.rawDestructor;
986
+ var fieldRecords = reg.fields;
987
+ var fieldTypes = fieldRecords.map((field) => field.getterReturnType).
988
+ concat(fieldRecords.map((field) => field.setterArgumentType));
989
+ whenDependentTypesAreResolved([structType], fieldTypes, (fieldTypes) => {
990
+ var fields = {};
991
+ fieldRecords.forEach((field, i) => {
992
+ var fieldName = field.fieldName;
993
+ var getterReturnType = fieldTypes[i];
994
+ var getter = field.getter;
995
+ var getterContext = field.getterContext;
996
+ var setterArgumentType = fieldTypes[i + fieldRecords.length];
997
+ var setter = field.setter;
998
+ var setterContext = field.setterContext;
999
+ fields[fieldName] = {
1000
+ read: (ptr) => {
1001
+ return getterReturnType['fromWireType'](getter(getterContext, ptr));
1002
+ },
1003
+ write: (ptr, o) => {
1004
+ var destructors = [];
1005
+ setter(setterContext, ptr, setterArgumentType['toWireType'](destructors, o));
1006
+ runDestructors(destructors);
1007
+ }
1008
+ };
1009
+ });
1010
+ return [{
1011
+ name: reg.name,
1012
+ 'fromWireType': function (ptr) {
1013
+ var rv = {};
1014
+ for (var i in fields) {
1015
+ rv[i] = fields[i].read(ptr);
1016
+ }
1017
+ rawDestructor(ptr);
1018
+ return rv;
1019
+ },
1020
+ 'toWireType': function (destructors, o) {
1021
+ // todo: Here we have an opportunity for -O3 level "unsafe" optimizations:
1022
+ // assume all fields are present without checking.
1023
+ for (var fieldName in fields) {
1024
+ if (!(fieldName in o)) {
1025
+ throw new TypeError('Missing field: "' + fieldName + '"');
1026
+ }
1027
+ }
1028
+ var ptr = rawConstructor();
1029
+ for (fieldName in fields) {
1030
+ fields[fieldName].write(ptr, o[fieldName]);
1031
+ }
1032
+ if (destructors !== null) {
1033
+ destructors.push(rawDestructor, ptr);
1034
+ }
1035
+ return ptr;
1036
+ },
1037
+ 'argPackAdvance': 8,
1038
+ 'readValueFromPointer': simpleReadValueFromPointer,
1039
+ destructorFunction: rawDestructor,
1040
+ }];
1041
+ });
1042
+ }
1043
+ function __embind_register_bigint(primitiveType, name, size, minRange, maxRange) { }
1044
+ function getShiftFromSize(size) {
1045
+ switch (size) {
1046
+ case 1: return 0;
1047
+ case 2: return 1;
1048
+ case 4: return 2;
1049
+ case 8: return 3;
1050
+ default:
1051
+ throw new TypeError('Unknown type size: ' + size);
1052
+ }
1053
+ }
1054
+ function embind_init_charCodes() {
1055
+ var codes = new Array(256);
1056
+ for (var i = 0; i < 256; ++i) {
1057
+ codes[i] = String.fromCharCode(i);
1058
+ }
1059
+ embind_charCodes = codes;
1060
+ }
1061
+ var embind_charCodes = undefined;
1062
+ function readLatin1String(ptr) {
1063
+ var ret = "";
1064
+ var c = ptr;
1065
+ while (HEAPU8[c]) {
1066
+ ret += embind_charCodes[HEAPU8[c++]];
1067
+ }
1068
+ return ret;
1069
+ }
1070
+ var BindingError = undefined;
1071
+ function throwBindingError(message) {
1072
+ throw new BindingError(message);
1073
+ }
1074
+ /** @param {Object=} options */
1075
+ function registerType(rawType, registeredInstance, options = {}) {
1076
+ if (!('argPackAdvance' in registeredInstance)) {
1077
+ throw new TypeError('registerType registeredInstance requires argPackAdvance');
1078
+ }
1079
+ var name = registeredInstance.name;
1080
+ if (!rawType) {
1081
+ throwBindingError('type "' + name + '" must have a positive integer typeid pointer');
1082
+ }
1083
+ if (registeredTypes.hasOwnProperty(rawType)) {
1084
+ if (options.ignoreDuplicateRegistrations) {
1085
+ return;
1086
+ }
1087
+ else {
1088
+ throwBindingError("Cannot register type '" + name + "' twice");
1089
+ }
1090
+ }
1091
+ registeredTypes[rawType] = registeredInstance;
1092
+ delete typeDependencies[rawType];
1093
+ if (awaitingDependencies.hasOwnProperty(rawType)) {
1094
+ var callbacks = awaitingDependencies[rawType];
1095
+ delete awaitingDependencies[rawType];
1096
+ callbacks.forEach((cb) => cb());
1097
+ }
1098
+ }
1099
+ function __embind_register_bool(rawType, name, size, trueValue, falseValue) {
1100
+ var shift = getShiftFromSize(size);
1101
+ name = readLatin1String(name);
1102
+ registerType(rawType, {
1103
+ name: name,
1104
+ 'fromWireType': function (wt) {
1105
+ // ambiguous emscripten ABI: sometimes return values are
1106
+ // true or false, and sometimes integers (0 or 1)
1107
+ return !!wt;
1108
+ },
1109
+ 'toWireType': function (destructors, o) {
1110
+ return o ? trueValue : falseValue;
1111
+ },
1112
+ 'argPackAdvance': 8,
1113
+ 'readValueFromPointer': function (pointer) {
1114
+ // TODO: if heap is fixed (like in asm.js) this could be executed outside
1115
+ var heap;
1116
+ if (size === 1) {
1117
+ heap = HEAP8;
1118
+ }
1119
+ else if (size === 2) {
1120
+ heap = HEAP16;
1121
+ }
1122
+ else if (size === 4) {
1123
+ heap = HEAP32;
1124
+ }
1125
+ else {
1126
+ throw new TypeError("Unknown boolean type size: " + name);
1127
+ }
1128
+ return this['fromWireType'](heap[pointer >> shift]);
1129
+ },
1130
+ destructorFunction: null, // This type does not need a destructor
1131
+ });
1132
+ }
1133
+ function ClassHandle_isAliasOf(other) {
1134
+ if (!(this instanceof ClassHandle)) {
1135
+ return false;
1136
+ }
1137
+ if (!(other instanceof ClassHandle)) {
1138
+ return false;
1139
+ }
1140
+ var leftClass = this.$$.ptrType.registeredClass;
1141
+ var left = this.$$.ptr;
1142
+ var rightClass = other.$$.ptrType.registeredClass;
1143
+ var right = other.$$.ptr;
1144
+ while (leftClass.baseClass) {
1145
+ left = leftClass.upcast(left);
1146
+ leftClass = leftClass.baseClass;
1147
+ }
1148
+ while (rightClass.baseClass) {
1149
+ right = rightClass.upcast(right);
1150
+ rightClass = rightClass.baseClass;
1151
+ }
1152
+ return leftClass === rightClass && left === right;
1153
+ }
1154
+ function shallowCopyInternalPointer(o) {
1155
+ return {
1156
+ count: o.count,
1157
+ deleteScheduled: o.deleteScheduled,
1158
+ preservePointerOnDelete: o.preservePointerOnDelete,
1159
+ ptr: o.ptr,
1160
+ ptrType: o.ptrType,
1161
+ smartPtr: o.smartPtr,
1162
+ smartPtrType: o.smartPtrType,
1163
+ };
1164
+ }
1165
+ function throwInstanceAlreadyDeleted(obj) {
1166
+ function getInstanceTypeName(handle) {
1167
+ return handle.$$.ptrType.registeredClass.name;
1168
+ }
1169
+ throwBindingError(getInstanceTypeName(obj) + ' instance already deleted');
1170
+ }
1171
+ var finalizationRegistry = false;
1172
+ function detachFinalizer(handle) { }
1173
+ function runDestructor($$) {
1174
+ if ($$.smartPtr) {
1175
+ $$.smartPtrType.rawDestructor($$.smartPtr);
1176
+ }
1177
+ else {
1178
+ $$.ptrType.registeredClass.rawDestructor($$.ptr);
1179
+ }
1180
+ }
1181
+ function releaseClassHandle($$) {
1182
+ $$.count.value -= 1;
1183
+ var toDelete = 0 === $$.count.value;
1184
+ if (toDelete) {
1185
+ runDestructor($$);
1186
+ }
1187
+ }
1188
+ function downcastPointer(ptr, ptrClass, desiredClass) {
1189
+ if (ptrClass === desiredClass) {
1190
+ return ptr;
1191
+ }
1192
+ if (undefined === desiredClass.baseClass) {
1193
+ return null; // no conversion
1194
+ }
1195
+ var rv = downcastPointer(ptr, ptrClass, desiredClass.baseClass);
1196
+ if (rv === null) {
1197
+ return null;
1198
+ }
1199
+ return desiredClass.downcast(rv);
1200
+ }
1201
+ var registeredPointers = {};
1202
+ function getInheritedInstanceCount() {
1203
+ return Object.keys(registeredInstances).length;
1204
+ }
1205
+ function getLiveInheritedInstances() {
1206
+ var rv = [];
1207
+ for (var k in registeredInstances) {
1208
+ if (registeredInstances.hasOwnProperty(k)) {
1209
+ rv.push(registeredInstances[k]);
1210
+ }
1211
+ }
1212
+ return rv;
1213
+ }
1214
+ var deletionQueue = [];
1215
+ function flushPendingDeletes() {
1216
+ while (deletionQueue.length) {
1217
+ var obj = deletionQueue.pop();
1218
+ obj.$$.deleteScheduled = false;
1219
+ obj['delete']();
1220
+ }
1221
+ }
1222
+ var delayFunction = undefined;
1223
+ function setDelayFunction(fn) {
1224
+ delayFunction = fn;
1225
+ if (deletionQueue.length && delayFunction) {
1226
+ delayFunction(flushPendingDeletes);
1227
+ }
1228
+ }
1229
+ function init_embind() {
1230
+ Module['getInheritedInstanceCount'] = getInheritedInstanceCount;
1231
+ Module['getLiveInheritedInstances'] = getLiveInheritedInstances;
1232
+ Module['flushPendingDeletes'] = flushPendingDeletes;
1233
+ Module['setDelayFunction'] = setDelayFunction;
1234
+ }
1235
+ var registeredInstances = {};
1236
+ function getBasestPointer(class_, ptr) {
1237
+ if (ptr === undefined) {
1238
+ throwBindingError('ptr should not be undefined');
1239
+ }
1240
+ while (class_.baseClass) {
1241
+ ptr = class_.upcast(ptr);
1242
+ class_ = class_.baseClass;
1243
+ }
1244
+ return ptr;
1245
+ }
1246
+ function getInheritedInstance(class_, ptr) {
1247
+ ptr = getBasestPointer(class_, ptr);
1248
+ return registeredInstances[ptr];
1249
+ }
1250
+ function makeClassHandle(prototype, record) {
1251
+ if (!record.ptrType || !record.ptr) {
1252
+ throwInternalError('makeClassHandle requires ptr and ptrType');
1253
+ }
1254
+ var hasSmartPtrType = !!record.smartPtrType;
1255
+ var hasSmartPtr = !!record.smartPtr;
1256
+ if (hasSmartPtrType !== hasSmartPtr) {
1257
+ throwInternalError('Both smartPtrType and smartPtr must be specified');
1258
+ }
1259
+ record.count = { value: 1 };
1260
+ return attachFinalizer(Object.create(prototype, {
1261
+ $$: {
1262
+ value: record,
1263
+ },
1264
+ }));
1265
+ }
1266
+ function RegisteredPointer_fromWireType(ptr) {
1267
+ // ptr is a raw pointer (or a raw smartpointer)
1268
+ // rawPointer is a maybe-null raw pointer
1269
+ var rawPointer = this.getPointee(ptr);
1270
+ if (!rawPointer) {
1271
+ this.destructor(ptr);
1272
+ return null;
1273
+ }
1274
+ var registeredInstance = getInheritedInstance(this.registeredClass, rawPointer);
1275
+ if (undefined !== registeredInstance) {
1276
+ // JS object has been neutered, time to repopulate it
1277
+ if (0 === registeredInstance.$$.count.value) {
1278
+ registeredInstance.$$.ptr = rawPointer;
1279
+ registeredInstance.$$.smartPtr = ptr;
1280
+ return registeredInstance['clone']();
1281
+ }
1282
+ else {
1283
+ // else, just increment reference count on existing object
1284
+ // it already has a reference to the smart pointer
1285
+ var rv = registeredInstance['clone']();
1286
+ this.destructor(ptr);
1287
+ return rv;
1288
+ }
1289
+ }
1290
+ function makeDefaultHandle() {
1291
+ if (this.isSmartPointer) {
1292
+ return makeClassHandle(this.registeredClass.instancePrototype, {
1293
+ ptrType: this.pointeeType,
1294
+ ptr: rawPointer,
1295
+ smartPtrType: this,
1296
+ smartPtr: ptr,
1297
+ });
1298
+ }
1299
+ else {
1300
+ return makeClassHandle(this.registeredClass.instancePrototype, {
1301
+ ptrType: this,
1302
+ ptr: ptr,
1303
+ });
1304
+ }
1305
+ }
1306
+ var actualType = this.registeredClass.getActualType(rawPointer);
1307
+ var registeredPointerRecord = registeredPointers[actualType];
1308
+ if (!registeredPointerRecord) {
1309
+ return makeDefaultHandle.call(this);
1310
+ }
1311
+ var toType;
1312
+ if (this.isConst) {
1313
+ toType = registeredPointerRecord.constPointerType;
1314
+ }
1315
+ else {
1316
+ toType = registeredPointerRecord.pointerType;
1317
+ }
1318
+ var dp = downcastPointer(rawPointer, this.registeredClass, toType.registeredClass);
1319
+ if (dp === null) {
1320
+ return makeDefaultHandle.call(this);
1321
+ }
1322
+ if (this.isSmartPointer) {
1323
+ return makeClassHandle(toType.registeredClass.instancePrototype, {
1324
+ ptrType: toType,
1325
+ ptr: dp,
1326
+ smartPtrType: this,
1327
+ smartPtr: ptr,
1328
+ });
1329
+ }
1330
+ else {
1331
+ return makeClassHandle(toType.registeredClass.instancePrototype, {
1332
+ ptrType: toType,
1333
+ ptr: dp,
1334
+ });
1335
+ }
1336
+ }
1337
+ function attachFinalizer(handle) {
1338
+ if ('undefined' === typeof FinalizationRegistry) {
1339
+ attachFinalizer = (handle) => handle;
1340
+ return handle;
1341
+ }
1342
+ // If the running environment has a FinalizationRegistry (see
1343
+ // https://github.com/tc39/proposal-weakrefs), then attach finalizers
1344
+ // for class handles. We check for the presence of FinalizationRegistry
1345
+ // at run-time, not build-time.
1346
+ finalizationRegistry = new FinalizationRegistry((info) => {
1347
+ releaseClassHandle(info.$$);
1348
+ });
1349
+ attachFinalizer = (handle) => {
1350
+ var $$ = handle.$$;
1351
+ var hasSmartPtr = !!$$.smartPtr;
1352
+ if (hasSmartPtr) {
1353
+ // We should not call the destructor on raw pointers in case other code expects the pointee to live
1354
+ var info = { $$: $$ };
1355
+ finalizationRegistry.register(handle, info, handle);
1356
+ }
1357
+ return handle;
1358
+ };
1359
+ detachFinalizer = (handle) => finalizationRegistry.unregister(handle);
1360
+ return attachFinalizer(handle);
1361
+ }
1362
+ function ClassHandle_clone() {
1363
+ if (!this.$$.ptr) {
1364
+ throwInstanceAlreadyDeleted(this);
1365
+ }
1366
+ if (this.$$.preservePointerOnDelete) {
1367
+ this.$$.count.value += 1;
1368
+ return this;
1369
+ }
1370
+ else {
1371
+ var clone = attachFinalizer(Object.create(Object.getPrototypeOf(this), {
1372
+ $$: {
1373
+ value: shallowCopyInternalPointer(this.$$),
1374
+ }
1375
+ }));
1376
+ clone.$$.count.value += 1;
1377
+ clone.$$.deleteScheduled = false;
1378
+ return clone;
1379
+ }
1380
+ }
1381
+ function ClassHandle_delete() {
1382
+ if (!this.$$.ptr) {
1383
+ throwInstanceAlreadyDeleted(this);
1384
+ }
1385
+ if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
1386
+ throwBindingError('Object already scheduled for deletion');
1387
+ }
1388
+ detachFinalizer(this);
1389
+ releaseClassHandle(this.$$);
1390
+ if (!this.$$.preservePointerOnDelete) {
1391
+ this.$$.smartPtr = undefined;
1392
+ this.$$.ptr = undefined;
1393
+ }
1394
+ }
1395
+ function ClassHandle_isDeleted() {
1396
+ return !this.$$.ptr;
1397
+ }
1398
+ function ClassHandle_deleteLater() {
1399
+ if (!this.$$.ptr) {
1400
+ throwInstanceAlreadyDeleted(this);
1401
+ }
1402
+ if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
1403
+ throwBindingError('Object already scheduled for deletion');
1404
+ }
1405
+ deletionQueue.push(this);
1406
+ if (deletionQueue.length === 1 && delayFunction) {
1407
+ delayFunction(flushPendingDeletes);
1408
+ }
1409
+ this.$$.deleteScheduled = true;
1410
+ return this;
1411
+ }
1412
+ function init_ClassHandle() {
1413
+ ClassHandle.prototype['isAliasOf'] = ClassHandle_isAliasOf;
1414
+ ClassHandle.prototype['clone'] = ClassHandle_clone;
1415
+ ClassHandle.prototype['delete'] = ClassHandle_delete;
1416
+ ClassHandle.prototype['isDeleted'] = ClassHandle_isDeleted;
1417
+ ClassHandle.prototype['deleteLater'] = ClassHandle_deleteLater;
1418
+ }
1419
+ function ClassHandle() {
1420
+ }
1421
+ function ensureOverloadTable(proto, methodName, humanName) {
1422
+ if (undefined === proto[methodName].overloadTable) {
1423
+ var prevFunc = proto[methodName];
1424
+ // Inject an overload resolver function that routes to the appropriate overload based on the number of arguments.
1425
+ proto[methodName] = function () {
1426
+ // TODO This check can be removed in -O3 level "unsafe" optimizations.
1427
+ if (!proto[methodName].overloadTable.hasOwnProperty(arguments.length)) {
1428
+ throwBindingError("Function '" + humanName + "' called with an invalid number of arguments (" + arguments.length + ") - expects one of (" + proto[methodName].overloadTable + ")!");
1429
+ }
1430
+ return proto[methodName].overloadTable[arguments.length].apply(this, arguments);
1431
+ };
1432
+ // Move the previous function into the overload table.
1433
+ proto[methodName].overloadTable = [];
1434
+ proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;
1435
+ }
1436
+ }
1437
+ /** @param {number=} numArguments */
1438
+ function exposePublicSymbol(name, value, numArguments) {
1439
+ if (Module.hasOwnProperty(name)) {
1440
+ if (undefined === numArguments || (undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments])) {
1441
+ throwBindingError("Cannot register public name '" + name + "' twice");
1442
+ }
1443
+ // We are exposing a function with the same name as an existing function. Create an overload table and a function selector
1444
+ // that routes between the two.
1445
+ ensureOverloadTable(Module, name, name);
1446
+ if (Module.hasOwnProperty(numArguments)) {
1447
+ throwBindingError("Cannot register multiple overloads of a function with the same number of arguments (" + numArguments + ")!");
1448
+ }
1449
+ // Add the new function into the overload table.
1450
+ Module[name].overloadTable[numArguments] = value;
1451
+ }
1452
+ else {
1453
+ Module[name] = value;
1454
+ if (undefined !== numArguments) {
1455
+ Module[name].numArguments = numArguments;
1456
+ }
1457
+ }
1458
+ }
1459
+ /** @constructor */
1460
+ function RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast) {
1461
+ this.name = name;
1462
+ this.constructor = constructor;
1463
+ this.instancePrototype = instancePrototype;
1464
+ this.rawDestructor = rawDestructor;
1465
+ this.baseClass = baseClass;
1466
+ this.getActualType = getActualType;
1467
+ this.upcast = upcast;
1468
+ this.downcast = downcast;
1469
+ this.pureVirtualFunctions = [];
1470
+ }
1471
+ function upcastPointer(ptr, ptrClass, desiredClass) {
1472
+ while (ptrClass !== desiredClass) {
1473
+ if (!ptrClass.upcast) {
1474
+ throwBindingError("Expected null or instance of " + desiredClass.name + ", got an instance of " + ptrClass.name);
1475
+ }
1476
+ ptr = ptrClass.upcast(ptr);
1477
+ ptrClass = ptrClass.baseClass;
1478
+ }
1479
+ return ptr;
1480
+ }
1481
+ function constNoSmartPtrRawPointerToWireType(destructors, handle) {
1482
+ if (handle === null) {
1483
+ if (this.isReference) {
1484
+ throwBindingError('null is not a valid ' + this.name);
1485
+ }
1486
+ return 0;
1487
+ }
1488
+ if (!handle.$$) {
1489
+ throwBindingError('Cannot pass "' + embindRepr(handle) + '" as a ' + this.name);
1490
+ }
1491
+ if (!handle.$$.ptr) {
1492
+ throwBindingError('Cannot pass deleted object as a pointer of type ' + this.name);
1493
+ }
1494
+ var handleClass = handle.$$.ptrType.registeredClass;
1495
+ var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
1496
+ return ptr;
1497
+ }
1498
+ function genericPointerToWireType(destructors, handle) {
1499
+ var ptr;
1500
+ if (handle === null) {
1501
+ if (this.isReference) {
1502
+ throwBindingError('null is not a valid ' + this.name);
1503
+ }
1504
+ if (this.isSmartPointer) {
1505
+ ptr = this.rawConstructor();
1506
+ if (destructors !== null) {
1507
+ destructors.push(this.rawDestructor, ptr);
1508
+ }
1509
+ return ptr;
1510
+ }
1511
+ else {
1512
+ return 0;
1513
+ }
1514
+ }
1515
+ if (!handle.$$) {
1516
+ throwBindingError('Cannot pass "' + embindRepr(handle) + '" as a ' + this.name);
1517
+ }
1518
+ if (!handle.$$.ptr) {
1519
+ throwBindingError('Cannot pass deleted object as a pointer of type ' + this.name);
1520
+ }
1521
+ if (!this.isConst && handle.$$.ptrType.isConst) {
1522
+ throwBindingError('Cannot convert argument of type ' + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + ' to parameter type ' + this.name);
1523
+ }
1524
+ var handleClass = handle.$$.ptrType.registeredClass;
1525
+ ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
1526
+ if (this.isSmartPointer) {
1527
+ // TODO: this is not strictly true
1528
+ // We could support BY_EMVAL conversions from raw pointers to smart pointers
1529
+ // because the smart pointer can hold a reference to the handle
1530
+ if (undefined === handle.$$.smartPtr) {
1531
+ throwBindingError('Passing raw pointer to smart pointer is illegal');
1532
+ }
1533
+ switch (this.sharingPolicy) {
1534
+ case 0: // NONE
1535
+ // no upcasting
1536
+ if (handle.$$.smartPtrType === this) {
1537
+ ptr = handle.$$.smartPtr;
1538
+ }
1539
+ else {
1540
+ throwBindingError('Cannot convert argument of type ' + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + ' to parameter type ' + this.name);
1541
+ }
1542
+ break;
1543
+ case 1: // INTRUSIVE
1544
+ ptr = handle.$$.smartPtr;
1545
+ break;
1546
+ case 2: // BY_EMVAL
1547
+ if (handle.$$.smartPtrType === this) {
1548
+ ptr = handle.$$.smartPtr;
1549
+ }
1550
+ else {
1551
+ var clonedHandle = handle['clone']();
1552
+ ptr = this.rawShare(ptr, Emval.toHandle(function () {
1553
+ clonedHandle['delete']();
1554
+ }));
1555
+ if (destructors !== null) {
1556
+ destructors.push(this.rawDestructor, ptr);
1557
+ }
1558
+ }
1559
+ break;
1560
+ default:
1561
+ throwBindingError('Unsupporting sharing policy');
1562
+ }
1563
+ }
1564
+ return ptr;
1565
+ }
1566
+ function nonConstNoSmartPtrRawPointerToWireType(destructors, handle) {
1567
+ if (handle === null) {
1568
+ if (this.isReference) {
1569
+ throwBindingError('null is not a valid ' + this.name);
1570
+ }
1571
+ return 0;
1572
+ }
1573
+ if (!handle.$$) {
1574
+ throwBindingError('Cannot pass "' + embindRepr(handle) + '" as a ' + this.name);
1575
+ }
1576
+ if (!handle.$$.ptr) {
1577
+ throwBindingError('Cannot pass deleted object as a pointer of type ' + this.name);
1578
+ }
1579
+ if (handle.$$.ptrType.isConst) {
1580
+ throwBindingError('Cannot convert argument of type ' + handle.$$.ptrType.name + ' to parameter type ' + this.name);
1581
+ }
1582
+ var handleClass = handle.$$.ptrType.registeredClass;
1583
+ var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
1584
+ return ptr;
1585
+ }
1586
+ function RegisteredPointer_getPointee(ptr) {
1587
+ if (this.rawGetPointee) {
1588
+ ptr = this.rawGetPointee(ptr);
1589
+ }
1590
+ return ptr;
1591
+ }
1592
+ function RegisteredPointer_destructor(ptr) {
1593
+ if (this.rawDestructor) {
1594
+ this.rawDestructor(ptr);
1595
+ }
1596
+ }
1597
+ function RegisteredPointer_deleteObject(handle) {
1598
+ if (handle !== null) {
1599
+ handle['delete']();
1600
+ }
1601
+ }
1602
+ function init_RegisteredPointer() {
1603
+ RegisteredPointer.prototype.getPointee = RegisteredPointer_getPointee;
1604
+ RegisteredPointer.prototype.destructor = RegisteredPointer_destructor;
1605
+ RegisteredPointer.prototype['argPackAdvance'] = 8;
1606
+ RegisteredPointer.prototype['readValueFromPointer'] = simpleReadValueFromPointer;
1607
+ RegisteredPointer.prototype['deleteObject'] = RegisteredPointer_deleteObject;
1608
+ RegisteredPointer.prototype['fromWireType'] = RegisteredPointer_fromWireType;
1609
+ }
1610
+ /** @constructor
1611
+ @param {*=} pointeeType,
1612
+ @param {*=} sharingPolicy,
1613
+ @param {*=} rawGetPointee,
1614
+ @param {*=} rawConstructor,
1615
+ @param {*=} rawShare,
1616
+ @param {*=} rawDestructor,
1617
+ */
1618
+ function RegisteredPointer(name, registeredClass, isReference, isConst,
1619
+ // smart pointer properties
1620
+ isSmartPointer, pointeeType, sharingPolicy, rawGetPointee, rawConstructor, rawShare, rawDestructor) {
1621
+ this.name = name;
1622
+ this.registeredClass = registeredClass;
1623
+ this.isReference = isReference;
1624
+ this.isConst = isConst;
1625
+ // smart pointer properties
1626
+ this.isSmartPointer = isSmartPointer;
1627
+ this.pointeeType = pointeeType;
1628
+ this.sharingPolicy = sharingPolicy;
1629
+ this.rawGetPointee = rawGetPointee;
1630
+ this.rawConstructor = rawConstructor;
1631
+ this.rawShare = rawShare;
1632
+ this.rawDestructor = rawDestructor;
1633
+ if (!isSmartPointer && registeredClass.baseClass === undefined) {
1634
+ if (isConst) {
1635
+ this['toWireType'] = constNoSmartPtrRawPointerToWireType;
1636
+ this.destructorFunction = null;
1637
+ }
1638
+ else {
1639
+ this['toWireType'] = nonConstNoSmartPtrRawPointerToWireType;
1640
+ this.destructorFunction = null;
1641
+ }
1642
+ }
1643
+ else {
1644
+ this['toWireType'] = genericPointerToWireType;
1645
+ // Here we must leave this.destructorFunction undefined, since whether genericPointerToWireType returns
1646
+ // a pointer that needs to be freed up is runtime-dependent, and cannot be evaluated at registration time.
1647
+ // TODO: Create an alternative mechanism that allows removing the use of var destructors = []; array in
1648
+ // craftInvokerFunction altogether.
1649
+ }
1650
+ }
1651
+ /** @param {number=} numArguments */
1652
+ function replacePublicSymbol(name, value, numArguments) {
1653
+ if (!Module.hasOwnProperty(name)) {
1654
+ throwInternalError('Replacing nonexistant public symbol');
1655
+ }
1656
+ // If there's an overload table for this symbol, replace the symbol in the overload table instead.
1657
+ if (undefined !== Module[name].overloadTable && undefined !== numArguments) {
1658
+ Module[name].overloadTable[numArguments] = value;
1659
+ }
1660
+ else {
1661
+ Module[name] = value;
1662
+ Module[name].argCount = numArguments;
1663
+ }
1664
+ }
1665
+ function dynCallLegacy(sig, ptr, args) {
1666
+ var f = Module['dynCall_' + sig];
1667
+ return args && args.length ? f.apply(null, [ptr].concat(args)) : f.call(null, ptr);
1668
+ }
1669
+ var wasmTableMirror = [];
1670
+ function getWasmTableEntry(funcPtr) {
1671
+ var func = wasmTableMirror[funcPtr];
1672
+ if (!func) {
1673
+ if (funcPtr >= wasmTableMirror.length)
1674
+ wasmTableMirror.length = funcPtr + 1;
1675
+ wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
1676
+ }
1677
+ return func;
1678
+ }
1679
+ /** @param {Object=} args */
1680
+ function dynCall(sig, ptr, args) {
1681
+ // Without WASM_BIGINT support we cannot directly call function with i64 as
1682
+ // part of thier signature, so we rely the dynCall functions generated by
1683
+ // wasm-emscripten-finalize
1684
+ if (sig.includes('j')) {
1685
+ return dynCallLegacy(sig, ptr, args);
1686
+ }
1687
+ var rtn = getWasmTableEntry(ptr).apply(null, args);
1688
+ return rtn;
1689
+ }
1690
+ function getDynCaller(sig, ptr) {
1691
+ var argCache = [];
1692
+ return function () {
1693
+ argCache.length = 0;
1694
+ Object.assign(argCache, arguments);
1695
+ return dynCall(sig, ptr, argCache);
1696
+ };
1697
+ }
1698
+ function embind__requireFunction(signature, rawFunction) {
1699
+ signature = readLatin1String(signature);
1700
+ function makeDynCaller() {
1701
+ if (signature.includes('j')) {
1702
+ return getDynCaller(signature, rawFunction);
1703
+ }
1704
+ return getWasmTableEntry(rawFunction);
1705
+ }
1706
+ var fp = makeDynCaller();
1707
+ if (typeof fp != "function") {
1708
+ throwBindingError("unknown function pointer with signature " + signature + ": " + rawFunction);
1709
+ }
1710
+ return fp;
1711
+ }
1712
+ var UnboundTypeError = undefined;
1713
+ function getTypeName(type) {
1714
+ var ptr = ___getTypeName(type);
1715
+ var rv = readLatin1String(ptr);
1716
+ _free(ptr);
1717
+ return rv;
1718
+ }
1719
+ function throwUnboundTypeError(message, types) {
1720
+ var unboundTypes = [];
1721
+ var seen = {};
1722
+ function visit(type) {
1723
+ if (seen[type]) {
1724
+ return;
1725
+ }
1726
+ if (registeredTypes[type]) {
1727
+ return;
1728
+ }
1729
+ if (typeDependencies[type]) {
1730
+ typeDependencies[type].forEach(visit);
1731
+ return;
1732
+ }
1733
+ unboundTypes.push(type);
1734
+ seen[type] = true;
1735
+ }
1736
+ types.forEach(visit);
1737
+ throw new UnboundTypeError(message + ': ' + unboundTypes.map(getTypeName).join([', ']));
1738
+ }
1739
+ function __embind_register_class(rawType, rawPointerType, rawConstPointerType, baseClassRawType, getActualTypeSignature, getActualType, upcastSignature, upcast, downcastSignature, downcast, name, destructorSignature, rawDestructor) {
1740
+ name = readLatin1String(name);
1741
+ getActualType = embind__requireFunction(getActualTypeSignature, getActualType);
1742
+ if (upcast) {
1743
+ upcast = embind__requireFunction(upcastSignature, upcast);
1744
+ }
1745
+ if (downcast) {
1746
+ downcast = embind__requireFunction(downcastSignature, downcast);
1747
+ }
1748
+ rawDestructor = embind__requireFunction(destructorSignature, rawDestructor);
1749
+ var legalFunctionName = makeLegalFunctionName(name);
1750
+ exposePublicSymbol(legalFunctionName, function () {
1751
+ // this code cannot run if baseClassRawType is zero
1752
+ throwUnboundTypeError('Cannot construct ' + name + ' due to unbound types', [baseClassRawType]);
1753
+ });
1754
+ whenDependentTypesAreResolved([rawType, rawPointerType, rawConstPointerType], baseClassRawType ? [baseClassRawType] : [], function (base) {
1755
+ base = base[0];
1756
+ var baseClass;
1757
+ var basePrototype;
1758
+ if (baseClassRawType) {
1759
+ baseClass = base.registeredClass;
1760
+ basePrototype = baseClass.instancePrototype;
1761
+ }
1762
+ else {
1763
+ basePrototype = ClassHandle.prototype;
1764
+ }
1765
+ var constructor = createNamedFunction(legalFunctionName, function () {
1766
+ if (Object.getPrototypeOf(this) !== instancePrototype) {
1767
+ throw new BindingError("Use 'new' to construct " + name);
1768
+ }
1769
+ if (undefined === registeredClass.constructor_body) {
1770
+ throw new BindingError(name + " has no accessible constructor");
1771
+ }
1772
+ var body = registeredClass.constructor_body[arguments.length];
1773
+ if (undefined === body) {
1774
+ 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!");
1775
+ }
1776
+ return body.apply(this, arguments);
1777
+ });
1778
+ var instancePrototype = Object.create(basePrototype, {
1779
+ constructor: { value: constructor },
1780
+ });
1781
+ constructor.prototype = instancePrototype;
1782
+ var registeredClass = new RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast);
1783
+ var referenceConverter = new RegisteredPointer(name, registeredClass, true, false, false);
1784
+ var pointerConverter = new RegisteredPointer(name + '*', registeredClass, false, false, false);
1785
+ var constPointerConverter = new RegisteredPointer(name + ' const*', registeredClass, false, true, false);
1786
+ registeredPointers[rawType] = {
1787
+ pointerType: pointerConverter,
1788
+ constPointerType: constPointerConverter
1789
+ };
1790
+ replacePublicSymbol(legalFunctionName, constructor);
1791
+ return [referenceConverter, pointerConverter, constPointerConverter];
1792
+ });
1793
+ }
1794
+ function heap32VectorToArray(count, firstElement) {
1795
+ var array = [];
1796
+ for (var i = 0; i < count; i++) {
1797
+ // TODO(https://github.com/emscripten-core/emscripten/issues/17310):
1798
+ // Find a way to hoist the `>> 2` or `>> 3` out of this loop.
1799
+ array.push(HEAPU32[(((firstElement) + (i * 4)) >> 2)]);
1800
+ }
1801
+ return array;
1802
+ }
1803
+ function new_(constructor, argumentList) {
1804
+ if (!(constructor instanceof Function)) {
1805
+ throw new TypeError('new_ called with constructor type ' + typeof (constructor) + " which is not a function");
1806
+ }
1807
+ /*
1808
+ * Previously, the following line was just:
1809
+ * function dummy() {};
1810
+ * Unfortunately, Chrome was preserving 'dummy' as the object's name, even
1811
+ * though at creation, the 'dummy' has the correct constructor name. Thus,
1812
+ * objects created with IMVU.new would show up in the debugger as 'dummy',
1813
+ * which isn't very helpful. Using IMVU.createNamedFunction addresses the
1814
+ * issue. Doublely-unfortunately, there's no way to write a test for this
1815
+ * behavior. -NRD 2013.02.22
1816
+ */
1817
+ var dummy = createNamedFunction(constructor.name || 'unknownFunctionName', function () { });
1818
+ dummy.prototype = constructor.prototype;
1819
+ var obj = new dummy;
1820
+ var r = constructor.apply(obj, argumentList);
1821
+ return (r instanceof Object) ? r : obj;
1822
+ }
1823
+ function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc, isAsync) {
1824
+ // humanName: a human-readable string name for the function to be generated.
1825
+ // argTypes: An array that contains the embind type objects for all types in the function signature.
1826
+ // argTypes[0] is the type object for the function return value.
1827
+ // argTypes[1] is the type object for function this object/class type, or null if not crafting an invoker for a class method.
1828
+ // argTypes[2...] are the actual function parameters.
1829
+ // classType: The embind type object for the class to be bound, or null if this is not a method of a class.
1830
+ // cppInvokerFunc: JS Function object to the C++-side function that interops into C++ code.
1831
+ // cppTargetFunc: Function pointer (an integer to FUNCTION_TABLE) to the target C++ function the cppInvokerFunc will end up calling.
1832
+ var argCount = argTypes.length;
1833
+ if (argCount < 2) {
1834
+ throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
1835
+ }
1836
+ var isClassMethodFunc = (argTypes[1] !== null && classType !== null);
1837
+ // Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
1838
+ // TODO: This omits argument count check - enable only at -O3 or similar.
1839
+ // if (ENABLE_UNSAFE_OPTS && argCount == 2 && argTypes[0].name == "void" && !isClassMethodFunc) {
1840
+ // return FUNCTION_TABLE[fn];
1841
+ // }
1842
+ // Determine if we need to use a dynamic stack to store the destructors for the function parameters.
1843
+ // TODO: Remove this completely once all function invokers are being dynamically generated.
1844
+ var needsDestructorStack = false;
1845
+ for (var i = 1; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here.
1846
+ if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) { // The type does not define a destructor function - must use dynamic stack
1847
+ needsDestructorStack = true;
1848
+ break;
1849
+ }
1850
+ }
1851
+ var returns = (argTypes[0].name !== "void");
1852
+ var argsList = "";
1853
+ var argsListWired = "";
1854
+ for (var i = 0; i < argCount - 2; ++i) {
1855
+ argsList += (i !== 0 ? ", " : "") + "arg" + i;
1856
+ argsListWired += (i !== 0 ? ", " : "") + "arg" + i + "Wired";
1857
+ }
1858
+ var invokerFnBody = "return function " + makeLegalFunctionName(humanName) + "(" + argsList + ") {\n" +
1859
+ "if (arguments.length !== " + (argCount - 2) + ") {\n" +
1860
+ "throwBindingError('function " + humanName + " called with ' + arguments.length + ' arguments, expected " + (argCount - 2) + " args!');\n" +
1861
+ "}\n";
1862
+ if (needsDestructorStack) {
1863
+ invokerFnBody += "var destructors = [];\n";
1864
+ }
1865
+ var dtorStack = needsDestructorStack ? "destructors" : "null";
1866
+ var args1 = ["throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"];
1867
+ var args2 = [throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];
1868
+ if (isClassMethodFunc) {
1869
+ invokerFnBody += "var thisWired = classParam.toWireType(" + dtorStack + ", this);\n";
1870
+ }
1871
+ for (var i = 0; i < argCount - 2; ++i) {
1872
+ invokerFnBody += "var arg" + i + "Wired = argType" + i + ".toWireType(" + dtorStack + ", arg" + i + "); // " + argTypes[i + 2].name + "\n";
1873
+ args1.push("argType" + i);
1874
+ args2.push(argTypes[i + 2]);
1875
+ }
1876
+ if (isClassMethodFunc) {
1877
+ argsListWired = "thisWired" + (argsListWired.length > 0 ? ", " : "") + argsListWired;
1878
+ }
1879
+ invokerFnBody +=
1880
+ (returns || isAsync ? "var rv = " : "") + "invoker(fn" + (argsListWired.length > 0 ? ", " : "") + argsListWired + ");\n";
1881
+ if (needsDestructorStack) {
1882
+ invokerFnBody += "runDestructors(destructors);\n";
1883
+ }
1884
+ else {
1885
+ 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.
1886
+ var paramName = (i === 1 ? "thisWired" : ("arg" + (i - 2) + "Wired"));
1887
+ if (argTypes[i].destructorFunction !== null) {
1888
+ invokerFnBody += paramName + "_dtor(" + paramName + "); // " + argTypes[i].name + "\n";
1889
+ args1.push(paramName + "_dtor");
1890
+ args2.push(argTypes[i].destructorFunction);
1891
+ }
1892
+ }
1893
+ }
1894
+ if (returns) {
1895
+ invokerFnBody += "var ret = retType.fromWireType(rv);\n" +
1896
+ "return ret;\n";
1897
+ }
1898
+ else {
1899
+ }
1900
+ invokerFnBody += "}\n";
1901
+ args1.push(invokerFnBody);
1902
+ var invokerFunction = new_(Function, args1).apply(null, args2);
1903
+ return invokerFunction;
1904
+ }
1905
+ function __embind_register_class_constructor(rawClassType, argCount, rawArgTypesAddr, invokerSignature, invoker, rawConstructor) {
1906
+ assert(argCount > 0);
1907
+ var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
1908
+ invoker = embind__requireFunction(invokerSignature, invoker);
1909
+ var args = [rawConstructor];
1910
+ var destructors = [];
1911
+ whenDependentTypesAreResolved([], [rawClassType], function (classType) {
1912
+ classType = classType[0];
1913
+ var humanName = 'constructor ' + classType.name;
1914
+ if (undefined === classType.registeredClass.constructor_body) {
1915
+ classType.registeredClass.constructor_body = [];
1916
+ }
1917
+ if (undefined !== classType.registeredClass.constructor_body[argCount - 1]) {
1918
+ 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!");
1919
+ }
1920
+ classType.registeredClass.constructor_body[argCount - 1] = () => {
1921
+ throwUnboundTypeError('Cannot construct ' + classType.name + ' due to unbound types', rawArgTypes);
1922
+ };
1923
+ whenDependentTypesAreResolved([], rawArgTypes, function (argTypes) {
1924
+ // Insert empty slot for context type (argTypes[1]).
1925
+ argTypes.splice(1, 0, null);
1926
+ classType.registeredClass.constructor_body[argCount - 1] = craftInvokerFunction(humanName, argTypes, null, invoker, rawConstructor);
1927
+ return [];
1928
+ });
1929
+ return [];
1930
+ });
1931
+ }
1932
+ function validateThis(this_, classType, humanName) {
1933
+ if (!(this_ instanceof Object)) {
1934
+ throwBindingError(humanName + ' with invalid "this": ' + this_);
1935
+ }
1936
+ if (!(this_ instanceof classType.registeredClass.constructor)) {
1937
+ throwBindingError(humanName + ' incompatible with "this" of type ' + this_.constructor.name);
1938
+ }
1939
+ if (!this_.$$.ptr) {
1940
+ throwBindingError('cannot call emscripten binding method ' + humanName + ' on deleted object');
1941
+ }
1942
+ // todo: kill this
1943
+ return upcastPointer(this_.$$.ptr, this_.$$.ptrType.registeredClass, classType.registeredClass);
1944
+ }
1945
+ function __embind_register_class_property(classType, fieldName, getterReturnType, getterSignature, getter, getterContext, setterArgumentType, setterSignature, setter, setterContext) {
1946
+ fieldName = readLatin1String(fieldName);
1947
+ getter = embind__requireFunction(getterSignature, getter);
1948
+ whenDependentTypesAreResolved([], [classType], function (classType) {
1949
+ classType = classType[0];
1950
+ var humanName = classType.name + '.' + fieldName;
1951
+ var desc = {
1952
+ get: function () {
1953
+ throwUnboundTypeError('Cannot access ' + humanName + ' due to unbound types', [getterReturnType, setterArgumentType]);
1954
+ },
1955
+ enumerable: true,
1956
+ configurable: true
1957
+ };
1958
+ if (setter) {
1959
+ desc.set = () => {
1960
+ throwUnboundTypeError('Cannot access ' + humanName + ' due to unbound types', [getterReturnType, setterArgumentType]);
1961
+ };
1962
+ }
1963
+ else {
1964
+ desc.set = (v) => {
1965
+ throwBindingError(humanName + ' is a read-only property');
1966
+ };
1967
+ }
1968
+ Object.defineProperty(classType.registeredClass.instancePrototype, fieldName, desc);
1969
+ whenDependentTypesAreResolved([], (setter ? [getterReturnType, setterArgumentType] : [getterReturnType]), function (types) {
1970
+ var getterReturnType = types[0];
1971
+ var desc = {
1972
+ get: function () {
1973
+ var ptr = validateThis(this, classType, humanName + ' getter');
1974
+ return getterReturnType['fromWireType'](getter(getterContext, ptr));
1975
+ },
1976
+ enumerable: true
1977
+ };
1978
+ if (setter) {
1979
+ setter = embind__requireFunction(setterSignature, setter);
1980
+ var setterArgumentType = types[1];
1981
+ desc.set = function (v) {
1982
+ var ptr = validateThis(this, classType, humanName + ' setter');
1983
+ var destructors = [];
1984
+ setter(setterContext, ptr, setterArgumentType['toWireType'](destructors, v));
1985
+ runDestructors(destructors);
1986
+ };
1987
+ }
1988
+ Object.defineProperty(classType.registeredClass.instancePrototype, fieldName, desc);
1989
+ return [];
1990
+ });
1991
+ return [];
1992
+ });
1993
+ }
1994
+ var emval_free_list = [];
1995
+ var emval_handle_array = [{}, { value: undefined }, { value: null }, { value: true }, { value: false }];
1996
+ function __emval_decref(handle) {
1997
+ if (handle > 4 && 0 === --emval_handle_array[handle].refcount) {
1998
+ emval_handle_array[handle] = undefined;
1999
+ emval_free_list.push(handle);
2000
+ }
2001
+ }
2002
+ function count_emval_handles() {
2003
+ var count = 0;
2004
+ for (var i = 5; i < emval_handle_array.length; ++i) {
2005
+ if (emval_handle_array[i] !== undefined) {
2006
+ ++count;
2007
+ }
2008
+ }
2009
+ return count;
2010
+ }
2011
+ function get_first_emval() {
2012
+ for (var i = 5; i < emval_handle_array.length; ++i) {
2013
+ if (emval_handle_array[i] !== undefined) {
2014
+ return emval_handle_array[i];
2015
+ }
2016
+ }
2017
+ return null;
2018
+ }
2019
+ function init_emval() {
2020
+ Module['count_emval_handles'] = count_emval_handles;
2021
+ Module['get_first_emval'] = get_first_emval;
2022
+ }
2023
+ var Emval = { toValue: (handle) => {
2024
+ if (!handle) {
2025
+ throwBindingError('Cannot use deleted val. handle = ' + handle);
2026
+ }
2027
+ return emval_handle_array[handle].value;
2028
+ }, toHandle: (value) => {
2029
+ switch (value) {
2030
+ case undefined: return 1;
2031
+ case null: return 2;
2032
+ case true: return 3;
2033
+ case false: return 4;
2034
+ default: {
2035
+ var handle = emval_free_list.length ?
2036
+ emval_free_list.pop() :
2037
+ emval_handle_array.length;
2038
+ emval_handle_array[handle] = { refcount: 1, value: value };
2039
+ return handle;
2040
+ }
2041
+ }
2042
+ } };
2043
+ function __embind_register_emval(rawType, name) {
2044
+ name = readLatin1String(name);
2045
+ registerType(rawType, {
2046
+ name: name,
2047
+ 'fromWireType': function (handle) {
2048
+ var rv = Emval.toValue(handle);
2049
+ __emval_decref(handle);
2050
+ return rv;
2051
+ },
2052
+ 'toWireType': function (destructors, value) {
2053
+ return Emval.toHandle(value);
2054
+ },
2055
+ 'argPackAdvance': 8,
2056
+ 'readValueFromPointer': simpleReadValueFromPointer,
2057
+ destructorFunction: null, // This type does not need a destructor
2058
+ // TODO: do we need a deleteObject here? write a test where
2059
+ // emval is passed into JS via an interface
2060
+ });
2061
+ }
2062
+ function embindRepr(v) {
2063
+ if (v === null) {
2064
+ return 'null';
2065
+ }
2066
+ var t = typeof v;
2067
+ if (t === 'object' || t === 'array' || t === 'function') {
2068
+ return v.toString();
2069
+ }
2070
+ else {
2071
+ return '' + v;
2072
+ }
2073
+ }
2074
+ function floatReadValueFromPointer(name, shift) {
2075
+ switch (shift) {
2076
+ case 2: return function (pointer) {
2077
+ return this['fromWireType'](HEAPF32[pointer >> 2]);
2078
+ };
2079
+ case 3: return function (pointer) {
2080
+ return this['fromWireType'](HEAPF64[pointer >> 3]);
2081
+ };
2082
+ default:
2083
+ throw new TypeError("Unknown float type: " + name);
2084
+ }
2085
+ }
2086
+ function __embind_register_float(rawType, name, size) {
2087
+ var shift = getShiftFromSize(size);
2088
+ name = readLatin1String(name);
2089
+ registerType(rawType, {
2090
+ name: name,
2091
+ 'fromWireType': function (value) {
2092
+ return value;
2093
+ },
2094
+ 'toWireType': function (destructors, value) {
2095
+ // The VM will perform JS to Wasm value conversion, according to the spec:
2096
+ // https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue
2097
+ return value;
2098
+ },
2099
+ 'argPackAdvance': 8,
2100
+ 'readValueFromPointer': floatReadValueFromPointer(name, shift),
2101
+ destructorFunction: null, // This type does not need a destructor
2102
+ });
2103
+ }
2104
+ function __embind_register_function(name, argCount, rawArgTypesAddr, signature, rawInvoker, fn, isAsync) {
2105
+ var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
2106
+ name = readLatin1String(name);
2107
+ rawInvoker = embind__requireFunction(signature, rawInvoker);
2108
+ exposePublicSymbol(name, function () {
2109
+ throwUnboundTypeError('Cannot call ' + name + ' due to unbound types', argTypes);
2110
+ }, argCount - 1);
2111
+ whenDependentTypesAreResolved([], argTypes, function (argTypes) {
2112
+ var invokerArgsArray = [argTypes[0] /* return value */, null /* no class 'this'*/].concat(argTypes.slice(1) /* actual params */);
2113
+ replacePublicSymbol(name, craftInvokerFunction(name, invokerArgsArray, null /* no class 'this'*/, rawInvoker, fn, isAsync), argCount - 1);
2114
+ return [];
2115
+ });
2116
+ }
2117
+ function integerReadValueFromPointer(name, shift, signed) {
2118
+ // integers are quite common, so generate very specialized functions
2119
+ switch (shift) {
2120
+ case 0: return signed ?
2121
+ function readS8FromPointer(pointer) { return HEAP8[pointer]; } :
2122
+ function readU8FromPointer(pointer) { return HEAPU8[pointer]; };
2123
+ case 1: return signed ?
2124
+ function readS16FromPointer(pointer) { return HEAP16[pointer >> 1]; } :
2125
+ function readU16FromPointer(pointer) { return HEAPU16[pointer >> 1]; };
2126
+ case 2: return signed ?
2127
+ function readS32FromPointer(pointer) { return HEAP32[pointer >> 2]; } :
2128
+ function readU32FromPointer(pointer) { return HEAPU32[pointer >> 2]; };
2129
+ default:
2130
+ throw new TypeError("Unknown integer type: " + name);
2131
+ }
2132
+ }
2133
+ function __embind_register_integer(primitiveType, name, size, minRange, maxRange) {
2134
+ name = readLatin1String(name);
2135
+ // LLVM doesn't have signed and unsigned 32-bit types, so u32 literals come
2136
+ // out as 'i32 -1'. Always treat those as max u32.
2137
+ if (maxRange === -1) {
2138
+ maxRange = 4294967295;
2139
+ }
2140
+ var shift = getShiftFromSize(size);
2141
+ var fromWireType = (value) => value;
2142
+ if (minRange === 0) {
2143
+ var bitshift = 32 - 8 * size;
2144
+ fromWireType = (value) => (value << bitshift) >>> bitshift;
2145
+ }
2146
+ var isUnsignedType = (name.includes('unsigned'));
2147
+ var checkAssertions = (value, toTypeName) => {
2148
+ };
2149
+ var toWireType;
2150
+ if (isUnsignedType) {
2151
+ toWireType = function (destructors, value) {
2152
+ checkAssertions(value, this.name);
2153
+ return value >>> 0;
2154
+ };
2155
+ }
2156
+ else {
2157
+ toWireType = function (destructors, value) {
2158
+ checkAssertions(value, this.name);
2159
+ // The VM will perform JS to Wasm value conversion, according to the spec:
2160
+ // https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue
2161
+ return value;
2162
+ };
2163
+ }
2164
+ registerType(primitiveType, {
2165
+ name: name,
2166
+ 'fromWireType': fromWireType,
2167
+ 'toWireType': toWireType,
2168
+ 'argPackAdvance': 8,
2169
+ 'readValueFromPointer': integerReadValueFromPointer(name, shift, minRange !== 0),
2170
+ destructorFunction: null, // This type does not need a destructor
2171
+ });
2172
+ }
2173
+ function __embind_register_memory_view(rawType, dataTypeIndex, name) {
2174
+ var typeMapping = [
2175
+ Int8Array,
2176
+ Uint8Array,
2177
+ Int16Array,
2178
+ Uint16Array,
2179
+ Int32Array,
2180
+ Uint32Array,
2181
+ Float32Array,
2182
+ Float64Array,
2183
+ ];
2184
+ var TA = typeMapping[dataTypeIndex];
2185
+ function decodeMemoryView(handle) {
2186
+ handle = handle >> 2;
2187
+ var heap = HEAPU32;
2188
+ var size = heap[handle]; // in elements
2189
+ var data = heap[handle + 1]; // byte offset into emscripten heap
2190
+ return new TA(heap.buffer, data, size);
2191
+ }
2192
+ name = readLatin1String(name);
2193
+ registerType(rawType, {
2194
+ name: name,
2195
+ 'fromWireType': decodeMemoryView,
2196
+ 'argPackAdvance': 8,
2197
+ 'readValueFromPointer': decodeMemoryView,
2198
+ }, {
2199
+ ignoreDuplicateRegistrations: true,
2200
+ });
2201
+ }
2202
+ function __embind_register_std_string(rawType, name) {
2203
+ name = readLatin1String(name);
2204
+ var stdStringIsUTF8
2205
+ //process only std::string bindings with UTF8 support, in contrast to e.g. std::basic_string<unsigned char>
2206
+ = (name === "std::string");
2207
+ registerType(rawType, {
2208
+ name: name,
2209
+ 'fromWireType': function (value) {
2210
+ var length = HEAPU32[((value) >> 2)];
2211
+ var payload = value + 4;
2212
+ var str;
2213
+ if (stdStringIsUTF8) {
2214
+ var decodeStartPtr = payload;
2215
+ // Looping here to support possible embedded '0' bytes
2216
+ for (var i = 0; i <= length; ++i) {
2217
+ var currentBytePtr = payload + i;
2218
+ if (i == length || HEAPU8[currentBytePtr] == 0) {
2219
+ var maxRead = currentBytePtr - decodeStartPtr;
2220
+ var stringSegment = UTF8ToString(decodeStartPtr, maxRead);
2221
+ if (str === undefined) {
2222
+ str = stringSegment;
2223
+ }
2224
+ else {
2225
+ str += String.fromCharCode(0);
2226
+ str += stringSegment;
2227
+ }
2228
+ decodeStartPtr = currentBytePtr + 1;
2229
+ }
2230
+ }
2231
+ }
2232
+ else {
2233
+ var a = new Array(length);
2234
+ for (var i = 0; i < length; ++i) {
2235
+ a[i] = String.fromCharCode(HEAPU8[payload + i]);
2236
+ }
2237
+ str = a.join('');
2238
+ }
2239
+ _free(value);
2240
+ return str;
2241
+ },
2242
+ 'toWireType': function (destructors, value) {
2243
+ if (value instanceof ArrayBuffer) {
2244
+ value = new Uint8Array(value);
2245
+ }
2246
+ var length;
2247
+ var valueIsOfTypeString = (typeof value == 'string');
2248
+ if (!(valueIsOfTypeString || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int8Array)) {
2249
+ throwBindingError('Cannot pass non-string to std::string');
2250
+ }
2251
+ if (stdStringIsUTF8 && valueIsOfTypeString) {
2252
+ length = lengthBytesUTF8(value);
2253
+ }
2254
+ else {
2255
+ length = value.length;
2256
+ }
2257
+ // assumes 4-byte alignment
2258
+ var base = _malloc(4 + length + 1);
2259
+ var ptr = base + 4;
2260
+ HEAPU32[((base) >> 2)] = length;
2261
+ if (stdStringIsUTF8 && valueIsOfTypeString) {
2262
+ stringToUTF8(value, ptr, length + 1);
2263
+ }
2264
+ else {
2265
+ if (valueIsOfTypeString) {
2266
+ for (var i = 0; i < length; ++i) {
2267
+ var charCode = value.charCodeAt(i);
2268
+ if (charCode > 255) {
2269
+ _free(ptr);
2270
+ throwBindingError('String has UTF-16 code units that do not fit in 8 bits');
2271
+ }
2272
+ HEAPU8[ptr + i] = charCode;
2273
+ }
2274
+ }
2275
+ else {
2276
+ for (var i = 0; i < length; ++i) {
2277
+ HEAPU8[ptr + i] = value[i];
2278
+ }
2279
+ }
2280
+ }
2281
+ if (destructors !== null) {
2282
+ destructors.push(_free, base);
2283
+ }
2284
+ return base;
2285
+ },
2286
+ 'argPackAdvance': 8,
2287
+ 'readValueFromPointer': simpleReadValueFromPointer,
2288
+ destructorFunction: function (ptr) { _free(ptr); },
2289
+ });
2290
+ }
2291
+ var UTF16Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf-16le') : undefined;
2292
+ ;
2293
+ function UTF16ToString(ptr, maxBytesToRead) {
2294
+ var endPtr = ptr;
2295
+ // TextDecoder needs to know the byte length in advance, it doesn't stop on
2296
+ // null terminator by itself.
2297
+ // Also, use the length info to avoid running tiny strings through
2298
+ // TextDecoder, since .subarray() allocates garbage.
2299
+ var idx = endPtr >> 1;
2300
+ var maxIdx = idx + maxBytesToRead / 2;
2301
+ // If maxBytesToRead is not passed explicitly, it will be undefined, and this
2302
+ // will always evaluate to true. This saves on code size.
2303
+ while (!(idx >= maxIdx) && HEAPU16[idx])
2304
+ ++idx;
2305
+ endPtr = idx << 1;
2306
+ if (endPtr - ptr > 32 && UTF16Decoder)
2307
+ return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr));
2308
+ // Fallback: decode without UTF16Decoder
2309
+ var str = '';
2310
+ // If maxBytesToRead is not passed explicitly, it will be undefined, and the
2311
+ // for-loop's condition will always evaluate to true. The loop is then
2312
+ // terminated on the first null char.
2313
+ for (var i = 0; !(i >= maxBytesToRead / 2); ++i) {
2314
+ var codeUnit = HEAP16[(((ptr) + (i * 2)) >> 1)];
2315
+ if (codeUnit == 0)
2316
+ break;
2317
+ // fromCharCode constructs a character from a UTF-16 code unit, so we can
2318
+ // pass the UTF16 string right through.
2319
+ str += String.fromCharCode(codeUnit);
2320
+ }
2321
+ return str;
2322
+ }
2323
+ function stringToUTF16(str, outPtr, maxBytesToWrite) {
2324
+ // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
2325
+ if (maxBytesToWrite === undefined) {
2326
+ maxBytesToWrite = 0x7FFFFFFF;
2327
+ }
2328
+ if (maxBytesToWrite < 2)
2329
+ return 0;
2330
+ maxBytesToWrite -= 2; // Null terminator.
2331
+ var startPtr = outPtr;
2332
+ var numCharsToWrite = (maxBytesToWrite < str.length * 2) ? (maxBytesToWrite / 2) : str.length;
2333
+ for (var i = 0; i < numCharsToWrite; ++i) {
2334
+ // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
2335
+ var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
2336
+ HEAP16[((outPtr) >> 1)] = codeUnit;
2337
+ outPtr += 2;
2338
+ }
2339
+ // Null-terminate the pointer to the HEAP.
2340
+ HEAP16[((outPtr) >> 1)] = 0;
2341
+ return outPtr - startPtr;
2342
+ }
2343
+ function lengthBytesUTF16(str) {
2344
+ return str.length * 2;
2345
+ }
2346
+ function UTF32ToString(ptr, maxBytesToRead) {
2347
+ var i = 0;
2348
+ var str = '';
2349
+ // If maxBytesToRead is not passed explicitly, it will be undefined, and this
2350
+ // will always evaluate to true. This saves on code size.
2351
+ while (!(i >= maxBytesToRead / 4)) {
2352
+ var utf32 = HEAP32[(((ptr) + (i * 4)) >> 2)];
2353
+ if (utf32 == 0)
2354
+ break;
2355
+ ++i;
2356
+ // 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.
2357
+ // See http://unicode.org/faq/utf_bom.html#utf16-3
2358
+ if (utf32 >= 0x10000) {
2359
+ var ch = utf32 - 0x10000;
2360
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
2361
+ }
2362
+ else {
2363
+ str += String.fromCharCode(utf32);
2364
+ }
2365
+ }
2366
+ return str;
2367
+ }
2368
+ function stringToUTF32(str, outPtr, maxBytesToWrite) {
2369
+ // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
2370
+ if (maxBytesToWrite === undefined) {
2371
+ maxBytesToWrite = 0x7FFFFFFF;
2372
+ }
2373
+ if (maxBytesToWrite < 4)
2374
+ return 0;
2375
+ var startPtr = outPtr;
2376
+ var endPtr = startPtr + maxBytesToWrite - 4;
2377
+ for (var i = 0; i < str.length; ++i) {
2378
+ // 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.
2379
+ // See http://unicode.org/faq/utf_bom.html#utf16-3
2380
+ var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
2381
+ if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
2382
+ var trailSurrogate = str.charCodeAt(++i);
2383
+ codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
2384
+ }
2385
+ HEAP32[((outPtr) >> 2)] = codeUnit;
2386
+ outPtr += 4;
2387
+ if (outPtr + 4 > endPtr)
2388
+ break;
2389
+ }
2390
+ // Null-terminate the pointer to the HEAP.
2391
+ HEAP32[((outPtr) >> 2)] = 0;
2392
+ return outPtr - startPtr;
2393
+ }
2394
+ function lengthBytesUTF32(str) {
2395
+ var len = 0;
2396
+ for (var i = 0; i < str.length; ++i) {
2397
+ // 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.
2398
+ // See http://unicode.org/faq/utf_bom.html#utf16-3
2399
+ var codeUnit = str.charCodeAt(i);
2400
+ if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF)
2401
+ ++i; // possibly a lead surrogate, so skip over the tail surrogate.
2402
+ len += 4;
2403
+ }
2404
+ return len;
2405
+ }
2406
+ function __embind_register_std_wstring(rawType, charSize, name) {
2407
+ name = readLatin1String(name);
2408
+ var decodeString, encodeString, getHeap, lengthBytesUTF, shift;
2409
+ if (charSize === 2) {
2410
+ decodeString = UTF16ToString;
2411
+ encodeString = stringToUTF16;
2412
+ lengthBytesUTF = lengthBytesUTF16;
2413
+ getHeap = () => HEAPU16;
2414
+ shift = 1;
2415
+ }
2416
+ else if (charSize === 4) {
2417
+ decodeString = UTF32ToString;
2418
+ encodeString = stringToUTF32;
2419
+ lengthBytesUTF = lengthBytesUTF32;
2420
+ getHeap = () => HEAPU32;
2421
+ shift = 2;
2422
+ }
2423
+ registerType(rawType, {
2424
+ name: name,
2425
+ 'fromWireType': function (value) {
2426
+ // Code mostly taken from _embind_register_std_string fromWireType
2427
+ var length = HEAPU32[value >> 2];
2428
+ var HEAP = getHeap();
2429
+ var str;
2430
+ var decodeStartPtr = value + 4;
2431
+ // Looping here to support possible embedded '0' bytes
2432
+ for (var i = 0; i <= length; ++i) {
2433
+ var currentBytePtr = value + 4 + i * charSize;
2434
+ if (i == length || HEAP[currentBytePtr >> shift] == 0) {
2435
+ var maxReadBytes = currentBytePtr - decodeStartPtr;
2436
+ var stringSegment = decodeString(decodeStartPtr, maxReadBytes);
2437
+ if (str === undefined) {
2438
+ str = stringSegment;
2439
+ }
2440
+ else {
2441
+ str += String.fromCharCode(0);
2442
+ str += stringSegment;
2443
+ }
2444
+ decodeStartPtr = currentBytePtr + charSize;
2445
+ }
2446
+ }
2447
+ _free(value);
2448
+ return str;
2449
+ },
2450
+ 'toWireType': function (destructors, value) {
2451
+ if (!(typeof value == 'string')) {
2452
+ throwBindingError('Cannot pass non-string to C++ string type ' + name);
2453
+ }
2454
+ // assumes 4-byte alignment
2455
+ var length = lengthBytesUTF(value);
2456
+ var ptr = _malloc(4 + length + charSize);
2457
+ HEAPU32[ptr >> 2] = length >> shift;
2458
+ encodeString(value, ptr + 4, length + charSize);
2459
+ if (destructors !== null) {
2460
+ destructors.push(_free, ptr);
2461
+ }
2462
+ return ptr;
2463
+ },
2464
+ 'argPackAdvance': 8,
2465
+ 'readValueFromPointer': simpleReadValueFromPointer,
2466
+ destructorFunction: function (ptr) { _free(ptr); },
2467
+ });
2468
+ }
2469
+ function __embind_register_value_object(rawType, name, constructorSignature, rawConstructor, destructorSignature, rawDestructor) {
2470
+ structRegistrations[rawType] = {
2471
+ name: readLatin1String(name),
2472
+ rawConstructor: embind__requireFunction(constructorSignature, rawConstructor),
2473
+ rawDestructor: embind__requireFunction(destructorSignature, rawDestructor),
2474
+ fields: [],
2475
+ };
2476
+ }
2477
+ function __embind_register_value_object_field(structType, fieldName, getterReturnType, getterSignature, getter, getterContext, setterArgumentType, setterSignature, setter, setterContext) {
2478
+ structRegistrations[structType].fields.push({
2479
+ fieldName: readLatin1String(fieldName),
2480
+ getterReturnType: getterReturnType,
2481
+ getter: embind__requireFunction(getterSignature, getter),
2482
+ getterContext: getterContext,
2483
+ setterArgumentType: setterArgumentType,
2484
+ setter: embind__requireFunction(setterSignature, setter),
2485
+ setterContext: setterContext,
2486
+ });
2487
+ }
2488
+ function __embind_register_void(rawType, name) {
2489
+ name = readLatin1String(name);
2490
+ registerType(rawType, {
2491
+ isVoid: true,
2492
+ name: name,
2493
+ 'argPackAdvance': 0,
2494
+ 'fromWireType': function () {
2495
+ return undefined;
2496
+ },
2497
+ 'toWireType': function (destructors, o) {
2498
+ // TODO: assert if anything else is given?
2499
+ return undefined;
2500
+ },
2501
+ });
2502
+ }
2503
+ function requireRegisteredType(rawType, humanName) {
2504
+ var impl = registeredTypes[rawType];
2505
+ if (undefined === impl) {
2506
+ throwBindingError(humanName + " has unknown type " + getTypeName(rawType));
2507
+ }
2508
+ return impl;
2509
+ }
2510
+ function __emval_as(handle, returnType, destructorsRef) {
2511
+ handle = Emval.toValue(handle);
2512
+ returnType = requireRegisteredType(returnType, 'emval::as');
2513
+ var destructors = [];
2514
+ var rd = Emval.toHandle(destructors);
2515
+ HEAPU32[((destructorsRef) >> 2)] = rd;
2516
+ return returnType['toWireType'](destructors, handle);
2517
+ }
2518
+ function emval_allocateDestructors(destructorsRef) {
2519
+ var destructors = [];
2520
+ HEAPU32[((destructorsRef) >> 2)] = Emval.toHandle(destructors);
2521
+ return destructors;
2522
+ }
2523
+ var emval_symbols = {};
2524
+ function getStringOrSymbol(address) {
2525
+ var symbol = emval_symbols[address];
2526
+ if (symbol === undefined) {
2527
+ return readLatin1String(address);
2528
+ }
2529
+ return symbol;
2530
+ }
2531
+ var emval_methodCallers = [];
2532
+ function __emval_call_void_method(caller, handle, methodName, args) {
2533
+ caller = emval_methodCallers[caller];
2534
+ handle = Emval.toValue(handle);
2535
+ methodName = getStringOrSymbol(methodName);
2536
+ caller(handle, methodName, null, args);
2537
+ }
2538
+ function emval_addMethodCaller(caller) {
2539
+ var id = emval_methodCallers.length;
2540
+ emval_methodCallers.push(caller);
2541
+ return id;
2542
+ }
2543
+ function emval_lookupTypes(argCount, argTypes) {
2544
+ var a = new Array(argCount);
2545
+ for (var i = 0; i < argCount; ++i) {
2546
+ a[i] = requireRegisteredType(HEAPU32[(((argTypes) + (i * 4)) >> 2)], "parameter " + i);
2547
+ }
2548
+ return a;
2549
+ }
2550
+ var emval_registeredMethods = [];
2551
+ function __emval_get_method_caller(argCount, argTypes) {
2552
+ var types = emval_lookupTypes(argCount, argTypes);
2553
+ var retType = types[0];
2554
+ var signatureName = retType.name + "_$" + types.slice(1).map(function (t) { return t.name; }).join("_") + "$";
2555
+ var returnId = emval_registeredMethods[signatureName];
2556
+ if (returnId !== undefined) {
2557
+ return returnId;
2558
+ }
2559
+ var params = ["retType"];
2560
+ var args = [retType];
2561
+ var argsList = ""; // 'arg0, arg1, arg2, ... , argN'
2562
+ for (var i = 0; i < argCount - 1; ++i) {
2563
+ argsList += (i !== 0 ? ", " : "") + "arg" + i;
2564
+ params.push("argType" + i);
2565
+ args.push(types[1 + i]);
2566
+ }
2567
+ var functionName = makeLegalFunctionName("methodCaller_" + signatureName);
2568
+ var functionBody = "return function " + functionName + "(handle, name, destructors, args) {\n";
2569
+ var offset = 0;
2570
+ for (var i = 0; i < argCount - 1; ++i) {
2571
+ functionBody +=
2572
+ " var arg" + i + " = argType" + i + ".readValueFromPointer(args" + (offset ? ("+" + offset) : "") + ");\n";
2573
+ offset += types[i + 1]['argPackAdvance'];
2574
+ }
2575
+ functionBody +=
2576
+ " var rv = handle[name](" + argsList + ");\n";
2577
+ for (var i = 0; i < argCount - 1; ++i) {
2578
+ if (types[i + 1]['deleteObject']) {
2579
+ functionBody +=
2580
+ " argType" + i + ".deleteObject(arg" + i + ");\n";
2581
+ }
2582
+ }
2583
+ if (!retType.isVoid) {
2584
+ functionBody +=
2585
+ " return retType.toWireType(destructors, rv);\n";
2586
+ }
2587
+ functionBody +=
2588
+ "};\n";
2589
+ params.push(functionBody);
2590
+ var invokerFunction = new_(Function, params).apply(null, args);
2591
+ returnId = emval_addMethodCaller(invokerFunction);
2592
+ emval_registeredMethods[signatureName] = returnId;
2593
+ return returnId;
2594
+ }
2595
+ function __emval_get_property(handle, key) {
2596
+ handle = Emval.toValue(handle);
2597
+ key = Emval.toValue(key);
2598
+ return Emval.toHandle(handle[key]);
2599
+ }
2600
+ function __emval_incref(handle) {
2601
+ if (handle > 4) {
2602
+ emval_handle_array[handle].refcount += 1;
2603
+ }
2604
+ }
2605
+ function __emval_new_array() {
2606
+ return Emval.toHandle([]);
2607
+ }
2608
+ function __emval_new_cstring(v) {
2609
+ return Emval.toHandle(getStringOrSymbol(v));
2610
+ }
2611
+ function __emval_run_destructors(handle) {
2612
+ var destructors = Emval.toValue(handle);
2613
+ runDestructors(destructors);
2614
+ __emval_decref(handle);
2615
+ }
2616
+ function __emval_take_value(type, arg) {
2617
+ type = requireRegisteredType(type, '_emval_take_value');
2618
+ var v = type['readValueFromPointer'](arg);
2619
+ return Emval.toHandle(v);
2620
+ }
2621
+ function _abort() {
2622
+ abort('');
2623
+ }
2624
+ function _emscripten_memcpy_big(dest, src, num) {
2625
+ HEAPU8.copyWithin(dest, src, src + num);
2626
+ }
2627
+ function getHeapMax() {
2628
+ // Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
2629
+ // full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
2630
+ // for any code that deals with heap sizes, which would require special
2631
+ // casing all heap size related code to treat 0 specially.
2632
+ return 2147483648;
2633
+ }
2634
+ function emscripten_realloc_buffer(size) {
2635
+ var b = wasmMemory.buffer;
2636
+ try {
2637
+ // round size grow request up to wasm page size (fixed 64KB per spec)
2638
+ wasmMemory.grow((size - b.byteLength + 65535) >>> 16); // .grow() takes a delta compared to the previous size
2639
+ updateMemoryViews();
2640
+ return 1 /*success*/;
2641
+ }
2642
+ catch (e) {
2643
+ }
2644
+ // implicit 0 return to save code size (caller will cast "undefined" into 0
2645
+ // anyhow)
2646
+ }
2647
+ function _emscripten_resize_heap(requestedSize) {
2648
+ var oldSize = HEAPU8.length;
2649
+ requestedSize = requestedSize >>> 0;
2650
+ // With multithreaded builds, races can happen (another thread might increase the size
2651
+ // in between), so return a failure, and let the caller retry.
2652
+ // Memory resize rules:
2653
+ // 1. Always increase heap size to at least the requested size, rounded up
2654
+ // to next page multiple.
2655
+ // 2a. If MEMORY_GROWTH_LINEAR_STEP == -1, excessively resize the heap
2656
+ // geometrically: increase the heap size according to
2657
+ // MEMORY_GROWTH_GEOMETRIC_STEP factor (default +20%), At most
2658
+ // overreserve by MEMORY_GROWTH_GEOMETRIC_CAP bytes (default 96MB).
2659
+ // 2b. If MEMORY_GROWTH_LINEAR_STEP != -1, excessively resize the heap
2660
+ // linearly: increase the heap size by at least
2661
+ // MEMORY_GROWTH_LINEAR_STEP bytes.
2662
+ // 3. Max size for the heap is capped at 2048MB-WASM_PAGE_SIZE, or by
2663
+ // MAXIMUM_MEMORY, or by ASAN limit, depending on which is smallest
2664
+ // 4. If we were unable to allocate as much memory, it may be due to
2665
+ // over-eager decision to excessively reserve due to (3) above.
2666
+ // Hence if an allocation fails, cut down on the amount of excess
2667
+ // growth, in an attempt to succeed to perform a smaller allocation.
2668
+ // A limit is set for how much we can grow. We should not exceed that
2669
+ // (the wasm binary specifies it, so if we tried, we'd fail anyhow).
2670
+ var maxHeapSize = getHeapMax();
2671
+ if (requestedSize > maxHeapSize) {
2672
+ return false;
2673
+ }
2674
+ let alignUp = (x, multiple) => x + (multiple - x % multiple) % multiple;
2675
+ // Loop through potential heap size increases. If we attempt a too eager
2676
+ // reservation that fails, cut down on the attempted size and reserve a
2677
+ // smaller bump instead. (max 3 times, chosen somewhat arbitrarily)
2678
+ for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
2679
+ var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown); // ensure geometric growth
2680
+ // but limit overreserving (default to capping at +96MB overgrowth at most)
2681
+ overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
2682
+ var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536));
2683
+ var replacement = emscripten_realloc_buffer(newSize);
2684
+ if (replacement) {
2685
+ return true;
2686
+ }
2687
+ }
2688
+ return false;
2689
+ }
2690
+ var ENV = {};
2691
+ function getExecutableName() {
2692
+ return thisProgram || './this.program';
2693
+ }
2694
+ function getEnvStrings() {
2695
+ if (!getEnvStrings.strings) {
2696
+ // Default values.
2697
+ // Browser language detection #8751
2698
+ var lang = ((typeof navigator == 'object' && navigator.languages && navigator.languages[0]) || 'C').replace('-', '_') + '.UTF-8';
2699
+ var env = {
2700
+ 'USER': 'web_user',
2701
+ 'LOGNAME': 'web_user',
2702
+ 'PATH': '/',
2703
+ 'PWD': '/',
2704
+ 'HOME': '/home/web_user',
2705
+ 'LANG': lang,
2706
+ '_': getExecutableName()
2707
+ };
2708
+ // Apply the user-provided values, if any.
2709
+ for (var x in ENV) {
2710
+ // x is a key in ENV; if ENV[x] is undefined, that means it was
2711
+ // explicitly set to be so. We allow user code to do that to
2712
+ // force variables with default values to remain unset.
2713
+ if (ENV[x] === undefined)
2714
+ delete env[x];
2715
+ else
2716
+ env[x] = ENV[x];
2717
+ }
2718
+ var strings = [];
2719
+ for (var x in env) {
2720
+ strings.push(x + '=' + env[x]);
2721
+ }
2722
+ getEnvStrings.strings = strings;
2723
+ }
2724
+ return getEnvStrings.strings;
2725
+ }
2726
+ /** @param {boolean=} dontAddNull */
2727
+ function writeAsciiToMemory(str, buffer, dontAddNull) {
2728
+ for (var i = 0; i < str.length; ++i) {
2729
+ HEAP8[((buffer++) >> 0)] = str.charCodeAt(i);
2730
+ }
2731
+ // Null-terminate the pointer to the HEAP.
2732
+ if (!dontAddNull)
2733
+ HEAP8[((buffer) >> 0)] = 0;
2734
+ }
2735
+ var SYSCALLS = { varargs: undefined, get: function () {
2736
+ SYSCALLS.varargs += 4;
2737
+ var ret = HEAP32[(((SYSCALLS.varargs) - (4)) >> 2)];
2738
+ return ret;
2739
+ }, getStr: function (ptr) {
2740
+ var ret = UTF8ToString(ptr);
2741
+ return ret;
2742
+ } };
2743
+ function _environ_get(__environ, environ_buf) {
2744
+ var bufSize = 0;
2745
+ getEnvStrings().forEach(function (string, i) {
2746
+ var ptr = environ_buf + bufSize;
2747
+ HEAPU32[(((__environ) + (i * 4)) >> 2)] = ptr;
2748
+ writeAsciiToMemory(string, ptr);
2749
+ bufSize += string.length + 1;
2750
+ });
2751
+ return 0;
2752
+ }
2753
+ function _environ_sizes_get(penviron_count, penviron_buf_size) {
2754
+ var strings = getEnvStrings();
2755
+ HEAPU32[((penviron_count) >> 2)] = strings.length;
2756
+ var bufSize = 0;
2757
+ strings.forEach(function (string) {
2758
+ bufSize += string.length + 1;
2759
+ });
2760
+ HEAPU32[((penviron_buf_size) >> 2)] = bufSize;
2761
+ return 0;
2762
+ }
2763
+ function __isLeapYear(year) {
2764
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
2765
+ }
2766
+ function __arraySum(array, index) {
2767
+ var sum = 0;
2768
+ for (var i = 0; i <= index; sum += array[i++]) {
2769
+ // no-op
2770
+ }
2771
+ return sum;
2772
+ }
2773
+ var __MONTH_DAYS_LEAP = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
2774
+ var __MONTH_DAYS_REGULAR = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
2775
+ function __addDays(date, days) {
2776
+ var newDate = new Date(date.getTime());
2777
+ while (days > 0) {
2778
+ var leap = __isLeapYear(newDate.getFullYear());
2779
+ var currentMonth = newDate.getMonth();
2780
+ var daysInCurrentMonth = (leap ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR)[currentMonth];
2781
+ if (days > daysInCurrentMonth - newDate.getDate()) {
2782
+ // we spill over to next month
2783
+ days -= (daysInCurrentMonth - newDate.getDate() + 1);
2784
+ newDate.setDate(1);
2785
+ if (currentMonth < 11) {
2786
+ newDate.setMonth(currentMonth + 1);
2787
+ }
2788
+ else {
2789
+ newDate.setMonth(0);
2790
+ newDate.setFullYear(newDate.getFullYear() + 1);
2791
+ }
2792
+ }
2793
+ else {
2794
+ // we stay in current month
2795
+ newDate.setDate(newDate.getDate() + days);
2796
+ return newDate;
2797
+ }
2798
+ }
2799
+ return newDate;
2800
+ }
2801
+ /** @type {function(string, boolean=, number=)} */
2802
+ function intArrayFromString(stringy, dontAddNull, length) {
2803
+ var len = length > 0 ? length : lengthBytesUTF8(stringy) + 1;
2804
+ var u8array = new Array(len);
2805
+ var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
2806
+ if (dontAddNull)
2807
+ u8array.length = numBytesWritten;
2808
+ return u8array;
2809
+ }
2810
+ function writeArrayToMemory(array, buffer) {
2811
+ HEAP8.set(array, buffer);
2812
+ }
2813
+ function _strftime(s, maxsize, format, tm) {
2814
+ // size_t strftime(char *restrict s, size_t maxsize, const char *restrict format, const struct tm *restrict timeptr);
2815
+ // http://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html
2816
+ var tm_zone = HEAP32[(((tm) + (40)) >> 2)];
2817
+ var date = {
2818
+ tm_sec: HEAP32[((tm) >> 2)],
2819
+ tm_min: HEAP32[(((tm) + (4)) >> 2)],
2820
+ tm_hour: HEAP32[(((tm) + (8)) >> 2)],
2821
+ tm_mday: HEAP32[(((tm) + (12)) >> 2)],
2822
+ tm_mon: HEAP32[(((tm) + (16)) >> 2)],
2823
+ tm_year: HEAP32[(((tm) + (20)) >> 2)],
2824
+ tm_wday: HEAP32[(((tm) + (24)) >> 2)],
2825
+ tm_yday: HEAP32[(((tm) + (28)) >> 2)],
2826
+ tm_isdst: HEAP32[(((tm) + (32)) >> 2)],
2827
+ tm_gmtoff: HEAP32[(((tm) + (36)) >> 2)],
2828
+ tm_zone: tm_zone ? UTF8ToString(tm_zone) : ''
2829
+ };
2830
+ var pattern = UTF8ToString(format);
2831
+ // expand format
2832
+ var EXPANSION_RULES_1 = {
2833
+ '%c': '%a %b %d %H:%M:%S %Y',
2834
+ '%D': '%m/%d/%y',
2835
+ '%F': '%Y-%m-%d',
2836
+ '%h': '%b',
2837
+ '%r': '%I:%M:%S %p',
2838
+ '%R': '%H:%M',
2839
+ '%T': '%H:%M:%S',
2840
+ '%x': '%m/%d/%y',
2841
+ '%X': '%H:%M:%S',
2842
+ // Modified Conversion Specifiers
2843
+ '%Ec': '%c',
2844
+ '%EC': '%C',
2845
+ '%Ex': '%m/%d/%y',
2846
+ '%EX': '%H:%M:%S',
2847
+ '%Ey': '%y',
2848
+ '%EY': '%Y',
2849
+ '%Od': '%d',
2850
+ '%Oe': '%e',
2851
+ '%OH': '%H',
2852
+ '%OI': '%I',
2853
+ '%Om': '%m',
2854
+ '%OM': '%M',
2855
+ '%OS': '%S',
2856
+ '%Ou': '%u',
2857
+ '%OU': '%U',
2858
+ '%OV': '%V',
2859
+ '%Ow': '%w',
2860
+ '%OW': '%W',
2861
+ '%Oy': '%y', // Replaced by the year (offset from %C ) using the locale's alternative numeric symbols.
2862
+ };
2863
+ for (var rule in EXPANSION_RULES_1) {
2864
+ pattern = pattern.replace(new RegExp(rule, 'g'), EXPANSION_RULES_1[rule]);
2865
+ }
2866
+ var WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
2867
+ var MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
2868
+ function leadingSomething(value, digits, character) {
2869
+ var str = typeof value == 'number' ? value.toString() : (value || '');
2870
+ while (str.length < digits) {
2871
+ str = character[0] + str;
2872
+ }
2873
+ return str;
2874
+ }
2875
+ function leadingNulls(value, digits) {
2876
+ return leadingSomething(value, digits, '0');
2877
+ }
2878
+ function compareByDay(date1, date2) {
2879
+ function sgn(value) {
2880
+ return value < 0 ? -1 : (value > 0 ? 1 : 0);
2881
+ }
2882
+ var compare;
2883
+ if ((compare = sgn(date1.getFullYear() - date2.getFullYear())) === 0) {
2884
+ if ((compare = sgn(date1.getMonth() - date2.getMonth())) === 0) {
2885
+ compare = sgn(date1.getDate() - date2.getDate());
2886
+ }
2887
+ }
2888
+ return compare;
2889
+ }
2890
+ function getFirstWeekStartDate(janFourth) {
2891
+ switch (janFourth.getDay()) {
2892
+ case 0: // Sunday
2893
+ return new Date(janFourth.getFullYear() - 1, 11, 29);
2894
+ case 1: // Monday
2895
+ return janFourth;
2896
+ case 2: // Tuesday
2897
+ return new Date(janFourth.getFullYear(), 0, 3);
2898
+ case 3: // Wednesday
2899
+ return new Date(janFourth.getFullYear(), 0, 2);
2900
+ case 4: // Thursday
2901
+ return new Date(janFourth.getFullYear(), 0, 1);
2902
+ case 5: // Friday
2903
+ return new Date(janFourth.getFullYear() - 1, 11, 31);
2904
+ case 6: // Saturday
2905
+ return new Date(janFourth.getFullYear() - 1, 11, 30);
2906
+ }
2907
+ }
2908
+ function getWeekBasedYear(date) {
2909
+ var thisDate = __addDays(new Date(date.tm_year + 1900, 0, 1), date.tm_yday);
2910
+ var janFourthThisYear = new Date(thisDate.getFullYear(), 0, 4);
2911
+ var janFourthNextYear = new Date(thisDate.getFullYear() + 1, 0, 4);
2912
+ var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);
2913
+ var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear);
2914
+ if (compareByDay(firstWeekStartThisYear, thisDate) <= 0) {
2915
+ // this date is after the start of the first week of this year
2916
+ if (compareByDay(firstWeekStartNextYear, thisDate) <= 0) {
2917
+ return thisDate.getFullYear() + 1;
2918
+ }
2919
+ return thisDate.getFullYear();
2920
+ }
2921
+ return thisDate.getFullYear() - 1;
2922
+ }
2923
+ var EXPANSION_RULES_2 = {
2924
+ '%a': function (date) {
2925
+ return WEEKDAYS[date.tm_wday].substring(0, 3);
2926
+ },
2927
+ '%A': function (date) {
2928
+ return WEEKDAYS[date.tm_wday];
2929
+ },
2930
+ '%b': function (date) {
2931
+ return MONTHS[date.tm_mon].substring(0, 3);
2932
+ },
2933
+ '%B': function (date) {
2934
+ return MONTHS[date.tm_mon];
2935
+ },
2936
+ '%C': function (date) {
2937
+ var year = date.tm_year + 1900;
2938
+ return leadingNulls((year / 100) | 0, 2);
2939
+ },
2940
+ '%d': function (date) {
2941
+ return leadingNulls(date.tm_mday, 2);
2942
+ },
2943
+ '%e': function (date) {
2944
+ return leadingSomething(date.tm_mday, 2, ' ');
2945
+ },
2946
+ '%g': function (date) {
2947
+ // %g, %G, and %V give values according to the ISO 8601:2000 standard week-based year.
2948
+ // In this system, weeks begin on a Monday and week 1 of the year is the week that includes
2949
+ // January 4th, which is also the week that includes the first Thursday of the year, and
2950
+ // is also the first week that contains at least four days in the year.
2951
+ // If the first Monday of January is the 2nd, 3rd, or 4th, the preceding days are part of
2952
+ // the last week of the preceding year; thus, for Saturday 2nd January 1999,
2953
+ // %G is replaced by 1998 and %V is replaced by 53. If December 29th, 30th,
2954
+ // or 31st is a Monday, it and any following days are part of week 1 of the following year.
2955
+ // Thus, for Tuesday 30th December 1997, %G is replaced by 1998 and %V is replaced by 01.
2956
+ return getWeekBasedYear(date).toString().substring(2);
2957
+ },
2958
+ '%G': function (date) {
2959
+ return getWeekBasedYear(date);
2960
+ },
2961
+ '%H': function (date) {
2962
+ return leadingNulls(date.tm_hour, 2);
2963
+ },
2964
+ '%I': function (date) {
2965
+ var twelveHour = date.tm_hour;
2966
+ if (twelveHour == 0)
2967
+ twelveHour = 12;
2968
+ else if (twelveHour > 12)
2969
+ twelveHour -= 12;
2970
+ return leadingNulls(twelveHour, 2);
2971
+ },
2972
+ '%j': function (date) {
2973
+ // Day of the year (001-366)
2974
+ return leadingNulls(date.tm_mday + __arraySum(__isLeapYear(date.tm_year + 1900) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, date.tm_mon - 1), 3);
2975
+ },
2976
+ '%m': function (date) {
2977
+ return leadingNulls(date.tm_mon + 1, 2);
2978
+ },
2979
+ '%M': function (date) {
2980
+ return leadingNulls(date.tm_min, 2);
2981
+ },
2982
+ '%n': function () {
2983
+ return '\n';
2984
+ },
2985
+ '%p': function (date) {
2986
+ if (date.tm_hour >= 0 && date.tm_hour < 12) {
2987
+ return 'AM';
2988
+ }
2989
+ return 'PM';
2990
+ },
2991
+ '%S': function (date) {
2992
+ return leadingNulls(date.tm_sec, 2);
2993
+ },
2994
+ '%t': function () {
2995
+ return '\t';
2996
+ },
2997
+ '%u': function (date) {
2998
+ return date.tm_wday || 7;
2999
+ },
3000
+ '%U': function (date) {
3001
+ var days = date.tm_yday + 7 - date.tm_wday;
3002
+ return leadingNulls(Math.floor(days / 7), 2);
3003
+ },
3004
+ '%V': function (date) {
3005
+ // Replaced by the week number of the year (Monday as the first day of the week)
3006
+ // as a decimal number [01,53]. If the week containing 1 January has four
3007
+ // or more days in the new year, then it is considered week 1.
3008
+ // Otherwise, it is the last week of the previous year, and the next week is week 1.
3009
+ // Both January 4th and the first Thursday of January are always in week 1. [ tm_year, tm_wday, tm_yday]
3010
+ var val = Math.floor((date.tm_yday + 7 - (date.tm_wday + 6) % 7) / 7);
3011
+ // If 1 Jan is just 1-3 days past Monday, the previous week
3012
+ // is also in this year.
3013
+ if ((date.tm_wday + 371 - date.tm_yday - 2) % 7 <= 2) {
3014
+ val++;
3015
+ }
3016
+ if (!val) {
3017
+ val = 52;
3018
+ // If 31 December of prev year a Thursday, or Friday of a
3019
+ // leap year, then the prev year has 53 weeks.
3020
+ var dec31 = (date.tm_wday + 7 - date.tm_yday - 1) % 7;
3021
+ if (dec31 == 4 || (dec31 == 5 && __isLeapYear(date.tm_year % 400 - 1))) {
3022
+ val++;
3023
+ }
3024
+ }
3025
+ else if (val == 53) {
3026
+ // If 1 January is not a Thursday, and not a Wednesday of a
3027
+ // leap year, then this year has only 52 weeks.
3028
+ var jan1 = (date.tm_wday + 371 - date.tm_yday) % 7;
3029
+ if (jan1 != 4 && (jan1 != 3 || !__isLeapYear(date.tm_year)))
3030
+ val = 1;
3031
+ }
3032
+ return leadingNulls(val, 2);
3033
+ },
3034
+ '%w': function (date) {
3035
+ return date.tm_wday;
3036
+ },
3037
+ '%W': function (date) {
3038
+ var days = date.tm_yday + 7 - ((date.tm_wday + 6) % 7);
3039
+ return leadingNulls(Math.floor(days / 7), 2);
3040
+ },
3041
+ '%y': function (date) {
3042
+ // Replaced by the last two digits of the year as a decimal number [00,99]. [ tm_year]
3043
+ return (date.tm_year + 1900).toString().substring(2);
3044
+ },
3045
+ '%Y': function (date) {
3046
+ // Replaced by the year as a decimal number (for example, 1997). [ tm_year]
3047
+ return date.tm_year + 1900;
3048
+ },
3049
+ '%z': function (date) {
3050
+ // Replaced by the offset from UTC in the ISO 8601:2000 standard format ( +hhmm or -hhmm ).
3051
+ // For example, "-0430" means 4 hours 30 minutes behind UTC (west of Greenwich).
3052
+ var off = date.tm_gmtoff;
3053
+ var ahead = off >= 0;
3054
+ off = Math.abs(off) / 60;
3055
+ // convert from minutes into hhmm format (which means 60 minutes = 100 units)
3056
+ off = (off / 60) * 100 + (off % 60);
3057
+ return (ahead ? '+' : '-') + String("0000" + off).slice(-4);
3058
+ },
3059
+ '%Z': function (date) {
3060
+ return date.tm_zone;
3061
+ },
3062
+ '%%': function () {
3063
+ return '%';
3064
+ }
3065
+ };
3066
+ // Replace %% with a pair of NULLs (which cannot occur in a C string), then
3067
+ // re-inject them after processing.
3068
+ pattern = pattern.replace(/%%/g, '\0\0');
3069
+ for (var rule in EXPANSION_RULES_2) {
3070
+ if (pattern.includes(rule)) {
3071
+ pattern = pattern.replace(new RegExp(rule, 'g'), EXPANSION_RULES_2[rule](date));
3072
+ }
3073
+ }
3074
+ pattern = pattern.replace(/\0\0/g, '%');
3075
+ var bytes = intArrayFromString(pattern, false);
3076
+ if (bytes.length > maxsize) {
3077
+ return 0;
3078
+ }
3079
+ writeArrayToMemory(bytes, s);
3080
+ return bytes.length - 1;
3081
+ }
3082
+ function _strftime_l(s, maxsize, format, tm, loc) {
3083
+ return _strftime(s, maxsize, format, tm); // no locale support yet
3084
+ }
3085
+ InternalError = Module['InternalError'] = extendError(Error, 'InternalError');
3086
+ ;
3087
+ embind_init_charCodes();
3088
+ BindingError = Module['BindingError'] = extendError(Error, 'BindingError');
3089
+ ;
3090
+ init_ClassHandle();
3091
+ init_embind();
3092
+ ;
3093
+ init_RegisteredPointer();
3094
+ UnboundTypeError = Module['UnboundTypeError'] = extendError(Error, 'UnboundTypeError');
3095
+ ;
3096
+ init_emval();
3097
+ ;
3098
+ var wasmImports = {
3099
+ "__assert_fail": ___assert_fail,
3100
+ "_embind_finalize_value_object": __embind_finalize_value_object,
3101
+ "_embind_register_bigint": __embind_register_bigint,
3102
+ "_embind_register_bool": __embind_register_bool,
3103
+ "_embind_register_class": __embind_register_class,
3104
+ "_embind_register_class_constructor": __embind_register_class_constructor,
3105
+ "_embind_register_class_property": __embind_register_class_property,
3106
+ "_embind_register_emval": __embind_register_emval,
3107
+ "_embind_register_float": __embind_register_float,
3108
+ "_embind_register_function": __embind_register_function,
3109
+ "_embind_register_integer": __embind_register_integer,
3110
+ "_embind_register_memory_view": __embind_register_memory_view,
3111
+ "_embind_register_std_string": __embind_register_std_string,
3112
+ "_embind_register_std_wstring": __embind_register_std_wstring,
3113
+ "_embind_register_value_object": __embind_register_value_object,
3114
+ "_embind_register_value_object_field": __embind_register_value_object_field,
3115
+ "_embind_register_void": __embind_register_void,
3116
+ "_emval_as": __emval_as,
3117
+ "_emval_call_void_method": __emval_call_void_method,
3118
+ "_emval_decref": __emval_decref,
3119
+ "_emval_get_method_caller": __emval_get_method_caller,
3120
+ "_emval_get_property": __emval_get_property,
3121
+ "_emval_incref": __emval_incref,
3122
+ "_emval_new_array": __emval_new_array,
3123
+ "_emval_new_cstring": __emval_new_cstring,
3124
+ "_emval_run_destructors": __emval_run_destructors,
3125
+ "_emval_take_value": __emval_take_value,
3126
+ "abort": _abort,
3127
+ "emscripten_memcpy_big": _emscripten_memcpy_big,
3128
+ "emscripten_resize_heap": _emscripten_resize_heap,
3129
+ "environ_get": _environ_get,
3130
+ "environ_sizes_get": _environ_sizes_get,
3131
+ "strftime_l": _strftime_l,
3132
+ "wasm_loadfileproc": wasm_loadfileproc,
3133
+ "wasm_msgproc": wasm_msgproc
3134
+ };
3135
+ var asm = createWasm();
3136
+ /** @type {function(...*):?} */
3137
+ var ___wasm_call_ctors = function () {
3138
+ return (___wasm_call_ctors = Module["asm"]["__wasm_call_ctors"]).apply(null, arguments);
3139
+ };
3140
+ /** @type {function(...*):?} */
3141
+ var _kmcmp_CompileKeyboard = Module["_kmcmp_CompileKeyboard"] = function () {
3142
+ return (_kmcmp_CompileKeyboard = Module["_kmcmp_CompileKeyboard"] = Module["asm"]["kmcmp_CompileKeyboard"]).apply(null, arguments);
3143
+ };
3144
+ /** @type {function(...*):?} */
3145
+ var _kmcmp_parseUnicodeSet = Module["_kmcmp_parseUnicodeSet"] = function () {
3146
+ return (_kmcmp_parseUnicodeSet = Module["_kmcmp_parseUnicodeSet"] = Module["asm"]["kmcmp_parseUnicodeSet"]).apply(null, arguments);
3147
+ };
3148
+ /** @type {function(...*):?} */
3149
+ var _malloc = function () {
3150
+ return (_malloc = Module["asm"]["malloc"]).apply(null, arguments);
3151
+ };
3152
+ /** @type {function(...*):?} */
3153
+ var _free = function () {
3154
+ return (_free = Module["asm"]["free"]).apply(null, arguments);
3155
+ };
3156
+ /** @type {function(...*):?} */
3157
+ var ___getTypeName = Module["___getTypeName"] = function () {
3158
+ return (___getTypeName = Module["___getTypeName"] = Module["asm"]["__getTypeName"]).apply(null, arguments);
3159
+ };
3160
+ /** @type {function(...*):?} */
3161
+ var __embind_initialize_bindings = Module["__embind_initialize_bindings"] = function () {
3162
+ return (__embind_initialize_bindings = Module["__embind_initialize_bindings"] = Module["asm"]["_embind_initialize_bindings"]).apply(null, arguments);
3163
+ };
3164
+ /** @type {function(...*):?} */
3165
+ var ___errno_location = function () {
3166
+ return (___errno_location = Module["asm"]["__errno_location"]).apply(null, arguments);
3167
+ };
3168
+ /** @type {function(...*):?} */
3169
+ var ___trap = function () {
3170
+ return (___trap = Module["asm"]["__trap"]).apply(null, arguments);
3171
+ };
3172
+ /** @type {function(...*):?} */
3173
+ var stackSave = function () {
3174
+ return (stackSave = Module["asm"]["stackSave"]).apply(null, arguments);
3175
+ };
3176
+ /** @type {function(...*):?} */
3177
+ var stackRestore = function () {
3178
+ return (stackRestore = Module["asm"]["stackRestore"]).apply(null, arguments);
3179
+ };
3180
+ /** @type {function(...*):?} */
3181
+ var stackAlloc = function () {
3182
+ return (stackAlloc = Module["asm"]["stackAlloc"]).apply(null, arguments);
3183
+ };
3184
+ /** @type {function(...*):?} */
3185
+ var dynCall_viijii = Module["dynCall_viijii"] = function () {
3186
+ return (dynCall_viijii = Module["dynCall_viijii"] = Module["asm"]["dynCall_viijii"]).apply(null, arguments);
3187
+ };
3188
+ /** @type {function(...*):?} */
3189
+ var dynCall_iiiiij = Module["dynCall_iiiiij"] = function () {
3190
+ return (dynCall_iiiiij = Module["dynCall_iiiiij"] = Module["asm"]["dynCall_iiiiij"]).apply(null, arguments);
3191
+ };
3192
+ /** @type {function(...*):?} */
3193
+ var dynCall_iiiiijj = Module["dynCall_iiiiijj"] = function () {
3194
+ return (dynCall_iiiiijj = Module["dynCall_iiiiijj"] = Module["asm"]["dynCall_iiiiijj"]).apply(null, arguments);
3195
+ };
3196
+ /** @type {function(...*):?} */
3197
+ var dynCall_iiiiiijj = Module["dynCall_iiiiiijj"] = function () {
3198
+ return (dynCall_iiiiiijj = Module["dynCall_iiiiiijj"] = Module["asm"]["dynCall_iiiiiijj"]).apply(null, arguments);
3199
+ };
3200
+ var ___start_em_js = Module['___start_em_js'] = 58784;
3201
+ var ___stop_em_js = Module['___stop_em_js'] = 59480;
3202
+ // include: postamble.js
3203
+ // === Auto-generated postamble setup entry stuff ===
3204
+ Module["UTF8ToString"] = UTF8ToString;
3205
+ var calledRun;
3206
+ dependenciesFulfilled = function runCaller() {
3207
+ // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
3208
+ if (!calledRun)
3209
+ run();
3210
+ if (!calledRun)
3211
+ dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
3212
+ };
3213
+ function run() {
3214
+ if (runDependencies > 0) {
3215
+ return;
3216
+ }
3217
+ preRun();
3218
+ // a preRun added a dependency, run will be called later
3219
+ if (runDependencies > 0) {
3220
+ return;
3221
+ }
3222
+ function doRun() {
3223
+ // run may have just been called through dependencies being fulfilled just in this very frame,
3224
+ // or while the async setStatus time below was happening
3225
+ if (calledRun)
3226
+ return;
3227
+ calledRun = true;
3228
+ Module['calledRun'] = true;
3229
+ if (ABORT)
3230
+ return;
3231
+ initRuntime();
3232
+ readyPromiseResolve(Module);
3233
+ if (Module['onRuntimeInitialized'])
3234
+ Module['onRuntimeInitialized']();
3235
+ postRun();
3236
+ }
3237
+ if (Module['setStatus']) {
3238
+ Module['setStatus']('Running...');
3239
+ setTimeout(function () {
3240
+ setTimeout(function () {
3241
+ Module['setStatus']('');
3242
+ }, 1);
3243
+ doRun();
3244
+ }, 1);
3245
+ }
3246
+ else {
3247
+ doRun();
3248
+ }
3249
+ }
3250
+ if (Module['preInit']) {
3251
+ if (typeof Module['preInit'] == 'function')
3252
+ Module['preInit'] = [Module['preInit']];
3253
+ while (Module['preInit'].length > 0) {
3254
+ Module['preInit'].pop()();
3255
+ }
3256
+ }
3257
+ run();
3258
+ // end include: postamble.js
3259
+ return Module.ready;
3260
+ });
3261
+ })();
3262
+ export default Module;
3263
+ //# debugId=e74e4a68-a330-5169-afb5-9cc31699f8ce
3264
+ //# sourceMappingURL=wasm-host.js.map