detect-arch 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CREDITS.md +37 -0
- package/LICENSE +9 -0
- package/README.md +20 -0
- package/dist/detect-arch.cjs +1193 -0
- package/dist/detect-arch.iife.js +1193 -0
- package/dist/detect-arch.iife.min.js +1 -0
- package/dist/detect-arch.min.cjs +1 -0
- package/dist/detect-arch.min.mjs +1 -0
- package/dist/detect-arch.mjs +1193 -0
- package/package.json +54 -0
- package/src/index.mjs +27 -0
- package/src/native/detect-arch.c +51 -0
- package/types/detect-arch.d.ts +11 -0
|
@@ -0,0 +1,1193 @@
|
|
|
1
|
+
var detectArch=(function(exports){'use strict';var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;// This code implements the `-sMODULARIZE` settings by taking the generated
|
|
2
|
+
// JS program code (INNER_JS_CODE) and wrapping it in a factory function.
|
|
3
|
+
|
|
4
|
+
// When targeting node and ES6 we use `await import ..` in the generated code
|
|
5
|
+
// so the outer function needs to be marked as async.
|
|
6
|
+
async function Module(moduleArg = {}) {
|
|
7
|
+
var moduleRtn;
|
|
8
|
+
|
|
9
|
+
// include: shell.js
|
|
10
|
+
// include: minimum_runtime_check.js
|
|
11
|
+
(function() {
|
|
12
|
+
// "30.0.0" -> 300000
|
|
13
|
+
function humanReadableVersionToPacked(str) {
|
|
14
|
+
str = str.split('-')[0]; // Remove any trailing part from e.g. "12.53.3-alpha"
|
|
15
|
+
var vers = str.split('.').slice(0, 3);
|
|
16
|
+
while(vers.length < 3) vers.push('00');
|
|
17
|
+
vers = vers.map((n, i, arr) => n.padStart(2, '0'));
|
|
18
|
+
return vers.join('');
|
|
19
|
+
}
|
|
20
|
+
// 300000 -> "30.0.0"
|
|
21
|
+
var packedVersionToHumanReadable = n => [n / 10000 | 0, (n / 100 | 0) % 100, n % 100].join('.');
|
|
22
|
+
|
|
23
|
+
var TARGET_NOT_SUPPORTED = 2147483647;
|
|
24
|
+
|
|
25
|
+
// Note: We use a typeof check here instead of optional chaining using
|
|
26
|
+
// globalThis because older browsers might not have globalThis defined.
|
|
27
|
+
var currentNodeVersion = typeof process !== 'undefined' && process.versions?.node ? humanReadableVersionToPacked(process.versions.node) : TARGET_NOT_SUPPORTED;
|
|
28
|
+
if (currentNodeVersion < 160000) {
|
|
29
|
+
throw new Error(`This emscripten-generated code requires node v${ packedVersionToHumanReadable(160000) } (detected v${packedVersionToHumanReadable(currentNodeVersion)})`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var userAgent = typeof navigator !== 'undefined' && navigator.userAgent;
|
|
33
|
+
if (!userAgent) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var currentSafariVersion = userAgent.includes("Safari/") && !userAgent.includes("Chrome/") && userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/) ? humanReadableVersionToPacked(userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/)[1]) : TARGET_NOT_SUPPORTED;
|
|
38
|
+
if (currentSafariVersion < 150000) {
|
|
39
|
+
throw new Error(`This emscripten-generated code requires Safari v${ packedVersionToHumanReadable(150000) } (detected v${currentSafariVersion})`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var currentFirefoxVersion = userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/) ? parseFloat(userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/)[1]) : TARGET_NOT_SUPPORTED;
|
|
43
|
+
if (currentFirefoxVersion < 79) {
|
|
44
|
+
throw new Error(`This emscripten-generated code requires Firefox v79 (detected v${currentFirefoxVersion})`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var currentChromeVersion = userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/) ? parseFloat(userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/)[1]) : TARGET_NOT_SUPPORTED;
|
|
48
|
+
if (currentChromeVersion < 85) {
|
|
49
|
+
throw new Error(`This emscripten-generated code requires Chrome v85 (detected v${currentChromeVersion})`);
|
|
50
|
+
}
|
|
51
|
+
})();
|
|
52
|
+
|
|
53
|
+
// end include: minimum_runtime_check.js
|
|
54
|
+
// The Module object: Our interface to the outside world. We import
|
|
55
|
+
// and export values on it. There are various ways Module can be used:
|
|
56
|
+
// 1. Not defined. We create it here
|
|
57
|
+
// 2. A function parameter, function(moduleArg) => Promise<Module>
|
|
58
|
+
// 3. pre-run appended it, var Module = {}; ..generated code..
|
|
59
|
+
// 4. External script tag defines var Module.
|
|
60
|
+
// We need to check if Module already exists (e.g. case 3 above).
|
|
61
|
+
// Substitution will be replaced with actual code on later stage of the build,
|
|
62
|
+
// this way Closure Compiler will not mangle it (e.g. case 4. above).
|
|
63
|
+
// Note that if you want to run closure, and also to use Module
|
|
64
|
+
// after the generated code, you will need to define var Module = {};
|
|
65
|
+
// before the code. Then that object will be used in the code, and you
|
|
66
|
+
// can continue to use Module afterwards as well.
|
|
67
|
+
var Module = moduleArg;
|
|
68
|
+
|
|
69
|
+
// Determine the runtime environment we are in. You can customize this by
|
|
70
|
+
// setting the ENVIRONMENT setting at compile time (see settings.js).
|
|
71
|
+
|
|
72
|
+
// Attempt to auto-detect the environment
|
|
73
|
+
var ENVIRONMENT_IS_WEB = !!globalThis.window;
|
|
74
|
+
var ENVIRONMENT_IS_WORKER = !!globalThis.WorkerGlobalScope;
|
|
75
|
+
// N.b. Electron.js environment is simultaneously a NODE-environment, but
|
|
76
|
+
// also a web environment.
|
|
77
|
+
var ENVIRONMENT_IS_NODE = globalThis.process?.versions?.node && globalThis.process?.type != 'renderer';
|
|
78
|
+
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
|
|
79
|
+
|
|
80
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
81
|
+
// When building an ES module `require` is not normally available.
|
|
82
|
+
// We need to use `createRequire()` to construct the require()` function.
|
|
83
|
+
const { createRequire } = await import('node:module');
|
|
84
|
+
/** @suppress{duplicate} */
|
|
85
|
+
var require = createRequire((_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('detect-arch.iife.js', document.baseURI).href));
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
var _scriptName = (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('detect-arch.iife.js', document.baseURI).href);
|
|
90
|
+
|
|
91
|
+
// `/` should be present at the end if `scriptDirectory` is not empty
|
|
92
|
+
var scriptDirectory = '';
|
|
93
|
+
|
|
94
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
95
|
+
const isNode = globalThis.process?.versions?.node && globalThis.process?.type != 'renderer';
|
|
96
|
+
if (!isNode) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
|
|
97
|
+
|
|
98
|
+
// These modules will usually be used on Node.js. Load them eagerly to avoid
|
|
99
|
+
// the complexity of lazy-loading.
|
|
100
|
+
require('node:fs');
|
|
101
|
+
|
|
102
|
+
if (_scriptName.startsWith('file:')) {
|
|
103
|
+
scriptDirectory = require('node:path').dirname(require('node:url').fileURLToPath(_scriptName)) + '/';
|
|
104
|
+
}
|
|
105
|
+
// end include: node_shell_read.js
|
|
106
|
+
if (process.argv.length > 1) {
|
|
107
|
+
process.argv[1].replace(/\\/g, '/');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
process.argv.slice(2);
|
|
111
|
+
|
|
112
|
+
} else
|
|
113
|
+
if (ENVIRONMENT_IS_SHELL) ; else
|
|
114
|
+
|
|
115
|
+
// Note that this includes Node.js workers when relevant (pthreads is enabled).
|
|
116
|
+
// Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
|
|
117
|
+
// ENVIRONMENT_IS_NODE.
|
|
118
|
+
if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
119
|
+
try {
|
|
120
|
+
scriptDirectory = new URL('.', _scriptName).href; // includes trailing slash
|
|
121
|
+
} catch {
|
|
122
|
+
// Must be a `blob:` or `data:` URL (e.g. `blob:http://site.com/etc/etc`), we cannot
|
|
123
|
+
// infer anything from them.
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!(globalThis.window || globalThis.WorkerGlobalScope)) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
|
|
127
|
+
} else
|
|
128
|
+
{
|
|
129
|
+
throw new Error('environment detection error');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
console.log.bind(console);
|
|
133
|
+
var err = console.error.bind(console);
|
|
134
|
+
|
|
135
|
+
// perform assertions in shell.js after we set up out() and err(), as otherwise
|
|
136
|
+
// if an assertion fails it cannot print the message
|
|
137
|
+
|
|
138
|
+
assert(!ENVIRONMENT_IS_WORKER, 'worker environment detected but not enabled at build time. Add `worker` to `-sENVIRONMENT` to enable.');
|
|
139
|
+
|
|
140
|
+
assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.');
|
|
141
|
+
|
|
142
|
+
// end include: shell.js
|
|
143
|
+
|
|
144
|
+
// include: preamble.js
|
|
145
|
+
// === Preamble library stuff ===
|
|
146
|
+
|
|
147
|
+
// Documentation for the public APIs defined in this file must be updated in:
|
|
148
|
+
// site/source/docs/api_reference/preamble.js.rst
|
|
149
|
+
// A prebuilt local version of the documentation is available at:
|
|
150
|
+
// site/build/text/docs/api_reference/preamble.js.txt
|
|
151
|
+
// You can also build docs locally as HTML or other formats in site/
|
|
152
|
+
// An online HTML version (which may be of a different version of Emscripten)
|
|
153
|
+
// is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
|
|
154
|
+
|
|
155
|
+
var wasmBinary;
|
|
156
|
+
|
|
157
|
+
if (!globalThis.WebAssembly) {
|
|
158
|
+
err('no native wasm support detected');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Wasm globals
|
|
162
|
+
|
|
163
|
+
//========================================
|
|
164
|
+
// Runtime essentials
|
|
165
|
+
//========================================
|
|
166
|
+
|
|
167
|
+
// whether we are quitting the application. no code should run after this.
|
|
168
|
+
// set in exit() and abort()
|
|
169
|
+
var ABORT = false;
|
|
170
|
+
|
|
171
|
+
// In STRICT mode, we only define assert() when ASSERTIONS is set. i.e. we
|
|
172
|
+
// don't define it at all in release modes. This matches the behaviour of
|
|
173
|
+
// MINIMAL_RUNTIME.
|
|
174
|
+
// TODO(sbc): Make this the default even without STRICT enabled.
|
|
175
|
+
/** @type {function(*, string=)} */
|
|
176
|
+
function assert(condition, text) {
|
|
177
|
+
if (!condition) {
|
|
178
|
+
abort('Assertion failed' + (text ? ': ' + text : ''));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Indicates whether filename is delivered via file protocol (as opposed to http/https)
|
|
184
|
+
* @noinline
|
|
185
|
+
*/
|
|
186
|
+
var isFileURI = (filename) => filename.startsWith('file://');
|
|
187
|
+
|
|
188
|
+
// include: runtime_common.js
|
|
189
|
+
// include: runtime_stack_check.js
|
|
190
|
+
// Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
|
|
191
|
+
function writeStackCookie() {
|
|
192
|
+
var max = _emscripten_stack_get_end();
|
|
193
|
+
assert((max & 3) == 0);
|
|
194
|
+
// If the stack ends at address zero we write our cookies 4 bytes into the
|
|
195
|
+
// stack. This prevents interference with SAFE_HEAP and ASAN which also
|
|
196
|
+
// monitor writes to address zero.
|
|
197
|
+
if (max == 0) {
|
|
198
|
+
max += 4;
|
|
199
|
+
}
|
|
200
|
+
// The stack grow downwards towards _emscripten_stack_get_end.
|
|
201
|
+
// We write cookies to the final two words in the stack and detect if they are
|
|
202
|
+
// ever overwritten.
|
|
203
|
+
HEAPU32[((max)>>2)] = 0x02135467;
|
|
204
|
+
HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE;
|
|
205
|
+
// Also test the global address 0 for integrity.
|
|
206
|
+
HEAPU32[((0)>>2)] = 1668509029;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function checkStackCookie() {
|
|
210
|
+
if (ABORT) return;
|
|
211
|
+
var max = _emscripten_stack_get_end();
|
|
212
|
+
// See writeStackCookie().
|
|
213
|
+
if (max == 0) {
|
|
214
|
+
max += 4;
|
|
215
|
+
}
|
|
216
|
+
var cookie1 = HEAPU32[((max)>>2)];
|
|
217
|
+
var cookie2 = HEAPU32[(((max)+(4))>>2)];
|
|
218
|
+
if (cookie1 != 0x02135467 || cookie2 != 0x89BACDFE) {
|
|
219
|
+
abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`);
|
|
220
|
+
}
|
|
221
|
+
// Also test the global address 0 for integrity.
|
|
222
|
+
if (HEAPU32[((0)>>2)] != 0x63736d65 /* 'emsc' */) {
|
|
223
|
+
abort('Runtime error: The application has corrupted its heap memory area (address zero)!');
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Endianness check
|
|
228
|
+
(() => {
|
|
229
|
+
var h16 = new Int16Array(1);
|
|
230
|
+
var h8 = new Int8Array(h16.buffer);
|
|
231
|
+
h16[0] = 0x6373;
|
|
232
|
+
if (h8[0] !== 0x73 || h8[1] !== 0x63) abort('Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)');
|
|
233
|
+
})();
|
|
234
|
+
|
|
235
|
+
function consumedModuleProp(prop) {
|
|
236
|
+
if (!Object.getOwnPropertyDescriptor(Module, prop)) {
|
|
237
|
+
Object.defineProperty(Module, prop, {
|
|
238
|
+
configurable: true,
|
|
239
|
+
set() {
|
|
240
|
+
abort(`Attempt to set \`Module.${prop}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`);
|
|
241
|
+
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function makeInvalidEarlyAccess(name) {
|
|
248
|
+
return () => assert(false, `call to '${name}' via reference taken before Wasm module initialization`);
|
|
249
|
+
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function ignoredModuleProp(prop) {
|
|
253
|
+
if (Object.getOwnPropertyDescriptor(Module, prop)) {
|
|
254
|
+
abort(`\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// forcing the filesystem exports a few things by default
|
|
259
|
+
function isExportedByForceFilesystem(name) {
|
|
260
|
+
return name === 'FS_createPath' ||
|
|
261
|
+
name === 'FS_createDataFile' ||
|
|
262
|
+
name === 'FS_createPreloadedFile' ||
|
|
263
|
+
name === 'FS_preloadFile' ||
|
|
264
|
+
name === 'FS_unlink' ||
|
|
265
|
+
name === 'addRunDependency' ||
|
|
266
|
+
// The old FS has some functionality that WasmFS lacks.
|
|
267
|
+
name === 'FS_createLazyFile' ||
|
|
268
|
+
name === 'FS_createDevice' ||
|
|
269
|
+
name === 'removeRunDependency';
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function missingLibrarySymbol(sym) {
|
|
273
|
+
|
|
274
|
+
// Any symbol that is not included from the JS library is also (by definition)
|
|
275
|
+
// not exported on the Module object.
|
|
276
|
+
unexportedRuntimeSymbol(sym);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function unexportedRuntimeSymbol(sym) {
|
|
280
|
+
if (!Object.getOwnPropertyDescriptor(Module, sym)) {
|
|
281
|
+
Object.defineProperty(Module, sym, {
|
|
282
|
+
configurable: true,
|
|
283
|
+
get() {
|
|
284
|
+
var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;
|
|
285
|
+
if (isExportedByForceFilesystem(sym)) {
|
|
286
|
+
msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
|
|
287
|
+
}
|
|
288
|
+
abort(msg);
|
|
289
|
+
},
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// end include: runtime_debug.js
|
|
295
|
+
// include: binaryDecode.js
|
|
296
|
+
// Prevent Closure from minifying the binaryDecode() function, or otherwise
|
|
297
|
+
// Closure may analyze through the WASM_BINARY_DATA placeholder string into this
|
|
298
|
+
// function, leading into incorrect results.
|
|
299
|
+
/** @noinline */
|
|
300
|
+
function binaryDecode(bin) {
|
|
301
|
+
for (var i = 0, l = bin.length, o = new Uint8Array(l), c; i < l; ++i) {
|
|
302
|
+
c = bin.charCodeAt(i);
|
|
303
|
+
o[i] = ~c >> 8 & c; // Recover the null byte in a manner that is compatible with https://crbug.com/453961758
|
|
304
|
+
}
|
|
305
|
+
return o;
|
|
306
|
+
}
|
|
307
|
+
// end include: binaryDecode.js
|
|
308
|
+
var readyPromiseResolve, readyPromiseReject;
|
|
309
|
+
|
|
310
|
+
// Memory management
|
|
311
|
+
|
|
312
|
+
var runtimeInitialized = false;
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
function updateMemoryViews() {
|
|
317
|
+
var b = wasmMemory.buffer;
|
|
318
|
+
HEAPU32 = new Uint32Array(b);
|
|
319
|
+
new BigInt64Array(b);
|
|
320
|
+
new BigUint64Array(b);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// include: memoryprofiler.js
|
|
324
|
+
// end include: memoryprofiler.js
|
|
325
|
+
// end include: runtime_common.js
|
|
326
|
+
assert(globalThis.Int32Array && globalThis.Float64Array && Int32Array.prototype.subarray && Int32Array.prototype.set,
|
|
327
|
+
'JS engine does not provide full typed array support');
|
|
328
|
+
|
|
329
|
+
function preRun() {
|
|
330
|
+
if (Module['preRun']) {
|
|
331
|
+
if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
|
|
332
|
+
while (Module['preRun'].length) {
|
|
333
|
+
addOnPreRun(Module['preRun'].shift());
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
consumedModuleProp('preRun');
|
|
337
|
+
// Begin ATPRERUNS hooks
|
|
338
|
+
callRuntimeCallbacks(onPreRuns);
|
|
339
|
+
// End ATPRERUNS hooks
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function initRuntime() {
|
|
343
|
+
assert(!runtimeInitialized);
|
|
344
|
+
runtimeInitialized = true;
|
|
345
|
+
|
|
346
|
+
checkStackCookie();
|
|
347
|
+
|
|
348
|
+
// No ATINITS hooks
|
|
349
|
+
|
|
350
|
+
wasmExports['__wasm_call_ctors']();
|
|
351
|
+
|
|
352
|
+
// No ATPOSTCTORS hooks
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function postRun() {
|
|
356
|
+
checkStackCookie();
|
|
357
|
+
// PThreads reuse the runtime from the main thread.
|
|
358
|
+
|
|
359
|
+
if (Module['postRun']) {
|
|
360
|
+
if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
|
|
361
|
+
while (Module['postRun'].length) {
|
|
362
|
+
addOnPostRun(Module['postRun'].shift());
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
consumedModuleProp('postRun');
|
|
366
|
+
|
|
367
|
+
// Begin ATPOSTRUNS hooks
|
|
368
|
+
callRuntimeCallbacks(onPostRuns);
|
|
369
|
+
// End ATPOSTRUNS hooks
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** @param {string|number=} what */
|
|
373
|
+
function abort(what) {
|
|
374
|
+
Module['onAbort']?.(what);
|
|
375
|
+
|
|
376
|
+
what = 'Aborted(' + what + ')';
|
|
377
|
+
// TODO(sbc): Should we remove printing and leave it up to whoever
|
|
378
|
+
// catches the exception?
|
|
379
|
+
err(what);
|
|
380
|
+
|
|
381
|
+
ABORT = true;
|
|
382
|
+
|
|
383
|
+
// Use a wasm runtime error, because a JS error might be seen as a foreign
|
|
384
|
+
// exception, which means we'd run destructors on it. We need the error to
|
|
385
|
+
// simply make the program stop.
|
|
386
|
+
// FIXME This approach does not work in Wasm EH because it currently does not assume
|
|
387
|
+
// all RuntimeErrors are from traps; it decides whether a RuntimeError is from
|
|
388
|
+
// a trap or not based on a hidden field within the object. So at the moment
|
|
389
|
+
// we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that
|
|
390
|
+
// allows this in the wasm spec.
|
|
391
|
+
|
|
392
|
+
// Suppress closure compiler warning here. Closure compiler's builtin extern
|
|
393
|
+
// definition for WebAssembly.RuntimeError claims it takes no arguments even
|
|
394
|
+
// though it can.
|
|
395
|
+
// TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
|
|
396
|
+
/** @suppress {checkTypes} */
|
|
397
|
+
var e = new WebAssembly.RuntimeError(what);
|
|
398
|
+
|
|
399
|
+
readyPromiseReject?.(e);
|
|
400
|
+
// Throw the error whether or not MODULARIZE is set because abort is used
|
|
401
|
+
// in code paths apart from instantiation where an exception is expected
|
|
402
|
+
// to be thrown when abort is called.
|
|
403
|
+
throw e;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// show errors on likely calls to FS when it was not included
|
|
407
|
+
var FS = {
|
|
408
|
+
error() {
|
|
409
|
+
abort('Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM');
|
|
410
|
+
},
|
|
411
|
+
init() { FS.error(); },
|
|
412
|
+
createDataFile() { FS.error(); },
|
|
413
|
+
createPreloadedFile() { FS.error(); },
|
|
414
|
+
createLazyFile() { FS.error(); },
|
|
415
|
+
open() { FS.error(); },
|
|
416
|
+
mkdev() { FS.error(); },
|
|
417
|
+
registerDevice() { FS.error(); },
|
|
418
|
+
analyzePath() { FS.error(); },
|
|
419
|
+
|
|
420
|
+
ErrnoError() { FS.error(); },
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
function createExportWrapper(name, nargs) {
|
|
425
|
+
return (...args) => {
|
|
426
|
+
assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`);
|
|
427
|
+
var f = wasmExports[name];
|
|
428
|
+
assert(f, `exported native function \`${name}\` not found`);
|
|
429
|
+
// Only assert for too many arguments. Too few can be valid since the missing arguments will be zero filled.
|
|
430
|
+
assert(args.length <= nargs, `native function \`${name}\` called with ${args.length} args but expects ${nargs}`);
|
|
431
|
+
return f(...args);
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
var wasmBinaryFile;
|
|
436
|
+
|
|
437
|
+
function findWasmBinary() {
|
|
438
|
+
return binaryDecode('asm$``~~```}``pAAAmemory__wasm_call_ctorsisX86isArmisRiscVfflushemscripten_stack_initemscripten_stack_get_freeemscripten_stack_get_baseemscripten_stack_get_end_emscripten_stack_restore_emscripten_stack_allocemscripten_stack_get_current __indirect_function_table\n¥A*A*Av&#Ak! 8 *8 (N#Ak! Aøªþ6 (6 *C?8 (6 (AþFAq +!A!@ \rAGAs! Aq(!A!@ \rAG! Aq\n $# kApq"$ #AAA@ \rA!@A(E\rA(!@A(E\rA( r!@("E\r@@ ( (F\r r! (8"\r @ ( (F\r AA ($ (\rA@ (" ("F\r k¬A (( A6 B7 B7A A$AAjApq$##k##Atarget_features+bulk-memory+bulk-memory-opt+call-indirect-overlong+\nmultivalue+mutable-globals+nontrapping-fptoint+reference-types+sign-ext');
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function getBinarySync(file) {
|
|
442
|
+
return file;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
async function getWasmBinary(binaryFile) {
|
|
446
|
+
|
|
447
|
+
// Otherwise, getBinarySync should be able to get it synchronously
|
|
448
|
+
return getBinarySync(binaryFile);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
async function instantiateArrayBuffer(binaryFile, imports) {
|
|
452
|
+
try {
|
|
453
|
+
var binary = await getWasmBinary(binaryFile);
|
|
454
|
+
var instance = await WebAssembly.instantiate(binary, imports);
|
|
455
|
+
return instance;
|
|
456
|
+
} catch (reason) {
|
|
457
|
+
err(`failed to asynchronously prepare wasm: ${reason}`);
|
|
458
|
+
|
|
459
|
+
// Warn on some common problems.
|
|
460
|
+
if (isFileURI(binaryFile)) {
|
|
461
|
+
err(`warning: Loading from a file URI (${binaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`);
|
|
462
|
+
}
|
|
463
|
+
abort(reason);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
async function instantiateAsync(binary, binaryFile, imports) {
|
|
468
|
+
return instantiateArrayBuffer(binaryFile, imports);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
function getWasmImports() {
|
|
472
|
+
// prepare imports
|
|
473
|
+
var imports = {
|
|
474
|
+
'env': wasmImports,
|
|
475
|
+
'wasi_snapshot_preview1': wasmImports,
|
|
476
|
+
};
|
|
477
|
+
return imports;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// Create the wasm instance.
|
|
481
|
+
// Receives the wasm imports, returns the exports.
|
|
482
|
+
async function createWasm() {
|
|
483
|
+
// Load the wasm module and create an instance of using native support in the JS engine.
|
|
484
|
+
// handle a generated wasm instance, receiving its exports and
|
|
485
|
+
// performing other necessary setup
|
|
486
|
+
/** @param {WebAssembly.Module=} module*/
|
|
487
|
+
function receiveInstance(instance, module) {
|
|
488
|
+
wasmExports = instance.exports;
|
|
489
|
+
|
|
490
|
+
assignWasmExports(wasmExports);
|
|
491
|
+
|
|
492
|
+
updateMemoryViews();
|
|
493
|
+
|
|
494
|
+
return wasmExports;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// Prefer streaming instantiation if available.
|
|
498
|
+
// Async compilation can be confusing when an error on the page overwrites Module
|
|
499
|
+
// (for example, if the order of elements is wrong, and the one defining Module is
|
|
500
|
+
// later), so we save Module and check it later.
|
|
501
|
+
var trueModule = Module;
|
|
502
|
+
function receiveInstantiationResult(result) {
|
|
503
|
+
// 'result' is a ResultObject object which has both the module and instance.
|
|
504
|
+
// receiveInstance() will swap in the exports (to Module.asm) so they can be called
|
|
505
|
+
assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?');
|
|
506
|
+
trueModule = null;
|
|
507
|
+
// 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.
|
|
508
|
+
// When the regression is fixed, can restore the above PTHREADS-enabled path.
|
|
509
|
+
return receiveInstance(result['instance']);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
var info = getWasmImports();
|
|
513
|
+
|
|
514
|
+
// User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
|
|
515
|
+
// to manually instantiate the Wasm module themselves. This allows pages to
|
|
516
|
+
// run the instantiation parallel to any other async startup actions they are
|
|
517
|
+
// performing.
|
|
518
|
+
// Also pthreads and wasm workers initialize the wasm instance through this
|
|
519
|
+
// path.
|
|
520
|
+
if (Module['instantiateWasm']) {
|
|
521
|
+
return new Promise((resolve, reject) => {
|
|
522
|
+
try {
|
|
523
|
+
Module['instantiateWasm'](info, (inst, mod) => {
|
|
524
|
+
resolve(receiveInstance(inst, mod));
|
|
525
|
+
});
|
|
526
|
+
} catch(e) {
|
|
527
|
+
err(`Module.instantiateWasm callback failed with error: ${e}`);
|
|
528
|
+
reject(e);
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
wasmBinaryFile ??= findWasmBinary();
|
|
534
|
+
var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
|
|
535
|
+
var exports$1 = receiveInstantiationResult(result);
|
|
536
|
+
return exports$1;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/** @type {!Uint32Array} */
|
|
540
|
+
var HEAPU32;
|
|
541
|
+
|
|
542
|
+
var callRuntimeCallbacks = (callbacks) => {
|
|
543
|
+
while (callbacks.length > 0) {
|
|
544
|
+
// Pass the module as the first argument.
|
|
545
|
+
callbacks.shift()(Module);
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
var onPostRuns = [];
|
|
549
|
+
var addOnPostRun = (cb) => onPostRuns.push(cb);
|
|
550
|
+
|
|
551
|
+
var onPreRuns = [];
|
|
552
|
+
var addOnPreRun = (cb) => onPreRuns.push(cb);
|
|
553
|
+
|
|
554
|
+
function ptrToString(ptr) {
|
|
555
|
+
assert(typeof ptr === 'number', `ptrToString expects a number, got ${typeof ptr}`);
|
|
556
|
+
// Convert to 32-bit unsigned value
|
|
557
|
+
ptr >>>= 0;
|
|
558
|
+
return '0x' + ptr.toString(16).padStart(8, '0');
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
// End JS library code
|
|
563
|
+
|
|
564
|
+
// include: postlibrary.js
|
|
565
|
+
// This file is included after the automatically-generated JS library code
|
|
566
|
+
// but before the wasm module is created.
|
|
567
|
+
|
|
568
|
+
{
|
|
569
|
+
|
|
570
|
+
// Begin ATMODULES hooks
|
|
571
|
+
if (Module['noExitRuntime']) Module['noExitRuntime'];
|
|
572
|
+
if (Module['print']) Module['print'];
|
|
573
|
+
if (Module['printErr']) err = Module['printErr'];
|
|
574
|
+
if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
|
|
575
|
+
|
|
576
|
+
Module['FS_createDataFile'] = FS.createDataFile;
|
|
577
|
+
Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
|
|
578
|
+
|
|
579
|
+
// End ATMODULES hooks
|
|
580
|
+
|
|
581
|
+
checkIncomingModuleAPI();
|
|
582
|
+
|
|
583
|
+
if (Module['arguments']) Module['arguments'];
|
|
584
|
+
if (Module['thisProgram']) Module['thisProgram'];
|
|
585
|
+
|
|
586
|
+
// Assertions on removed incoming Module JS APIs.
|
|
587
|
+
assert(typeof Module['memoryInitializerPrefixURL'] == 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead');
|
|
588
|
+
assert(typeof Module['pthreadMainPrefixURL'] == 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead');
|
|
589
|
+
assert(typeof Module['cdInitializerPrefixURL'] == 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead');
|
|
590
|
+
assert(typeof Module['filePackagePrefixURL'] == 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead');
|
|
591
|
+
assert(typeof Module['read'] == 'undefined', 'Module.read option was removed');
|
|
592
|
+
assert(typeof Module['readAsync'] == 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)');
|
|
593
|
+
assert(typeof Module['readBinary'] == 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)');
|
|
594
|
+
assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)');
|
|
595
|
+
assert(typeof Module['TOTAL_MEMORY'] == 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY');
|
|
596
|
+
assert(typeof Module['ENVIRONMENT'] == 'undefined', 'Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)');
|
|
597
|
+
assert(typeof Module['STACK_SIZE'] == 'undefined', 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time');
|
|
598
|
+
// If memory is defined in wasm, the user can't provide it, or set INITIAL_MEMORY
|
|
599
|
+
assert(typeof Module['wasmMemory'] == 'undefined', 'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally');
|
|
600
|
+
assert(typeof Module['INITIAL_MEMORY'] == 'undefined', 'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically');
|
|
601
|
+
|
|
602
|
+
if (Module['preInit']) {
|
|
603
|
+
if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
|
|
604
|
+
while (Module['preInit'].length > 0) {
|
|
605
|
+
Module['preInit'].shift()();
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
consumedModuleProp('preInit');
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// Begin runtime exports
|
|
612
|
+
var missingLibrarySymbols = [
|
|
613
|
+
'writeI53ToI64',
|
|
614
|
+
'writeI53ToI64Clamped',
|
|
615
|
+
'writeI53ToI64Signaling',
|
|
616
|
+
'writeI53ToU64Clamped',
|
|
617
|
+
'writeI53ToU64Signaling',
|
|
618
|
+
'readI53FromI64',
|
|
619
|
+
'readI53FromU64',
|
|
620
|
+
'convertI32PairToI53',
|
|
621
|
+
'convertI32PairToI53Checked',
|
|
622
|
+
'convertU32PairToI53',
|
|
623
|
+
'bigintToI53Checked',
|
|
624
|
+
'stackAlloc',
|
|
625
|
+
'getTempRet0',
|
|
626
|
+
'setTempRet0',
|
|
627
|
+
'createNamedFunction',
|
|
628
|
+
'zeroMemory',
|
|
629
|
+
'exitJS',
|
|
630
|
+
'getHeapMax',
|
|
631
|
+
'abortOnCannotGrowMemory',
|
|
632
|
+
'growMemory',
|
|
633
|
+
'withStackSave',
|
|
634
|
+
'strError',
|
|
635
|
+
'inetPton4',
|
|
636
|
+
'inetNtop4',
|
|
637
|
+
'inetPton6',
|
|
638
|
+
'inetNtop6',
|
|
639
|
+
'readSockaddr',
|
|
640
|
+
'writeSockaddr',
|
|
641
|
+
'readEmAsmArgs',
|
|
642
|
+
'jstoi_q',
|
|
643
|
+
'getExecutableName',
|
|
644
|
+
'autoResumeAudioContext',
|
|
645
|
+
'getDynCaller',
|
|
646
|
+
'dynCall',
|
|
647
|
+
'handleException',
|
|
648
|
+
'keepRuntimeAlive',
|
|
649
|
+
'runtimeKeepalivePush',
|
|
650
|
+
'runtimeKeepalivePop',
|
|
651
|
+
'callUserCallback',
|
|
652
|
+
'maybeExit',
|
|
653
|
+
'asyncLoad',
|
|
654
|
+
'asmjsMangle',
|
|
655
|
+
'alignMemory',
|
|
656
|
+
'mmapAlloc',
|
|
657
|
+
'HandleAllocator',
|
|
658
|
+
'getUniqueRunDependency',
|
|
659
|
+
'addRunDependency',
|
|
660
|
+
'removeRunDependency',
|
|
661
|
+
'addOnInit',
|
|
662
|
+
'addOnPostCtor',
|
|
663
|
+
'addOnPreMain',
|
|
664
|
+
'addOnExit',
|
|
665
|
+
'STACK_SIZE',
|
|
666
|
+
'STACK_ALIGN',
|
|
667
|
+
'POINTER_SIZE',
|
|
668
|
+
'ASSERTIONS',
|
|
669
|
+
'ccall',
|
|
670
|
+
'cwrap',
|
|
671
|
+
'convertJsFunctionToWasm',
|
|
672
|
+
'getEmptyTableSlot',
|
|
673
|
+
'updateTableMap',
|
|
674
|
+
'getFunctionAddress',
|
|
675
|
+
'addFunction',
|
|
676
|
+
'removeFunction',
|
|
677
|
+
'UTF8ArrayToString',
|
|
678
|
+
'UTF8ToString',
|
|
679
|
+
'stringToUTF8Array',
|
|
680
|
+
'stringToUTF8',
|
|
681
|
+
'lengthBytesUTF8',
|
|
682
|
+
'intArrayFromString',
|
|
683
|
+
'intArrayToString',
|
|
684
|
+
'AsciiToString',
|
|
685
|
+
'stringToAscii',
|
|
686
|
+
'UTF16ToString',
|
|
687
|
+
'stringToUTF16',
|
|
688
|
+
'lengthBytesUTF16',
|
|
689
|
+
'UTF32ToString',
|
|
690
|
+
'stringToUTF32',
|
|
691
|
+
'lengthBytesUTF32',
|
|
692
|
+
'stringToNewUTF8',
|
|
693
|
+
'stringToUTF8OnStack',
|
|
694
|
+
'writeArrayToMemory',
|
|
695
|
+
'registerKeyEventCallback',
|
|
696
|
+
'maybeCStringToJsString',
|
|
697
|
+
'findEventTarget',
|
|
698
|
+
'getBoundingClientRect',
|
|
699
|
+
'fillMouseEventData',
|
|
700
|
+
'registerMouseEventCallback',
|
|
701
|
+
'registerWheelEventCallback',
|
|
702
|
+
'registerUiEventCallback',
|
|
703
|
+
'registerFocusEventCallback',
|
|
704
|
+
'fillDeviceOrientationEventData',
|
|
705
|
+
'registerDeviceOrientationEventCallback',
|
|
706
|
+
'fillDeviceMotionEventData',
|
|
707
|
+
'registerDeviceMotionEventCallback',
|
|
708
|
+
'screenOrientation',
|
|
709
|
+
'fillOrientationChangeEventData',
|
|
710
|
+
'registerOrientationChangeEventCallback',
|
|
711
|
+
'fillFullscreenChangeEventData',
|
|
712
|
+
'registerFullscreenChangeEventCallback',
|
|
713
|
+
'JSEvents_requestFullscreen',
|
|
714
|
+
'JSEvents_resizeCanvasForFullscreen',
|
|
715
|
+
'registerRestoreOldStyle',
|
|
716
|
+
'hideEverythingExceptGivenElement',
|
|
717
|
+
'restoreHiddenElements',
|
|
718
|
+
'setLetterbox',
|
|
719
|
+
'softFullscreenResizeWebGLRenderTarget',
|
|
720
|
+
'doRequestFullscreen',
|
|
721
|
+
'fillPointerlockChangeEventData',
|
|
722
|
+
'registerPointerlockChangeEventCallback',
|
|
723
|
+
'registerPointerlockErrorEventCallback',
|
|
724
|
+
'requestPointerLock',
|
|
725
|
+
'fillVisibilityChangeEventData',
|
|
726
|
+
'registerVisibilityChangeEventCallback',
|
|
727
|
+
'registerTouchEventCallback',
|
|
728
|
+
'fillGamepadEventData',
|
|
729
|
+
'registerGamepadEventCallback',
|
|
730
|
+
'registerBeforeUnloadEventCallback',
|
|
731
|
+
'fillBatteryEventData',
|
|
732
|
+
'registerBatteryEventCallback',
|
|
733
|
+
'setCanvasElementSize',
|
|
734
|
+
'getCanvasElementSize',
|
|
735
|
+
'jsStackTrace',
|
|
736
|
+
'getCallstack',
|
|
737
|
+
'convertPCtoSourceLocation',
|
|
738
|
+
'getEnvStrings',
|
|
739
|
+
'checkWasiClock',
|
|
740
|
+
'flush_NO_FILESYSTEM',
|
|
741
|
+
'wasiRightsToMuslOFlags',
|
|
742
|
+
'wasiOFlagsToMuslOFlags',
|
|
743
|
+
'initRandomFill',
|
|
744
|
+
'randomFill',
|
|
745
|
+
'safeSetTimeout',
|
|
746
|
+
'setImmediateWrapped',
|
|
747
|
+
'safeRequestAnimationFrame',
|
|
748
|
+
'clearImmediateWrapped',
|
|
749
|
+
'registerPostMainLoop',
|
|
750
|
+
'registerPreMainLoop',
|
|
751
|
+
'getPromise',
|
|
752
|
+
'makePromise',
|
|
753
|
+
'idsToPromises',
|
|
754
|
+
'makePromiseCallback',
|
|
755
|
+
'ExceptionInfo',
|
|
756
|
+
'findMatchingCatch',
|
|
757
|
+
'Browser_asyncPrepareDataCounter',
|
|
758
|
+
'isLeapYear',
|
|
759
|
+
'ydayFromDate',
|
|
760
|
+
'arraySum',
|
|
761
|
+
'addDays',
|
|
762
|
+
'getSocketFromFD',
|
|
763
|
+
'getSocketAddress',
|
|
764
|
+
'FS_createPreloadedFile',
|
|
765
|
+
'FS_preloadFile',
|
|
766
|
+
'FS_modeStringToFlags',
|
|
767
|
+
'FS_getMode',
|
|
768
|
+
'FS_fileDataToTypedArray',
|
|
769
|
+
'FS_stdin_getChar',
|
|
770
|
+
'FS_mkdirTree',
|
|
771
|
+
'_setNetworkCallback',
|
|
772
|
+
'heapObjectForWebGLType',
|
|
773
|
+
'toTypedArrayIndex',
|
|
774
|
+
'webgl_enable_ANGLE_instanced_arrays',
|
|
775
|
+
'webgl_enable_OES_vertex_array_object',
|
|
776
|
+
'webgl_enable_WEBGL_draw_buffers',
|
|
777
|
+
'webgl_enable_WEBGL_multi_draw',
|
|
778
|
+
'webgl_enable_EXT_polygon_offset_clamp',
|
|
779
|
+
'webgl_enable_EXT_clip_control',
|
|
780
|
+
'webgl_enable_WEBGL_polygon_mode',
|
|
781
|
+
'emscriptenWebGLGet',
|
|
782
|
+
'computeUnpackAlignedImageSize',
|
|
783
|
+
'colorChannelsInGlTextureFormat',
|
|
784
|
+
'emscriptenWebGLGetTexPixelData',
|
|
785
|
+
'emscriptenWebGLGetUniform',
|
|
786
|
+
'webglGetUniformLocation',
|
|
787
|
+
'webglPrepareUniformLocationsBeforeFirstUse',
|
|
788
|
+
'webglGetLeftBracePos',
|
|
789
|
+
'emscriptenWebGLGetVertexAttrib',
|
|
790
|
+
'__glGetActiveAttribOrUniform',
|
|
791
|
+
'writeGLArray',
|
|
792
|
+
'registerWebGlEventCallback',
|
|
793
|
+
'runAndAbortIfError',
|
|
794
|
+
'ALLOC_NORMAL',
|
|
795
|
+
'ALLOC_STACK',
|
|
796
|
+
'allocate',
|
|
797
|
+
'writeStringToMemory',
|
|
798
|
+
'writeAsciiToMemory',
|
|
799
|
+
'allocateUTF8',
|
|
800
|
+
'allocateUTF8OnStack',
|
|
801
|
+
'demangle',
|
|
802
|
+
'stackTrace',
|
|
803
|
+
'getNativeTypeSize',
|
|
804
|
+
];
|
|
805
|
+
missingLibrarySymbols.forEach(missingLibrarySymbol);
|
|
806
|
+
|
|
807
|
+
var unexportedSymbols = [
|
|
808
|
+
'run',
|
|
809
|
+
'out',
|
|
810
|
+
'err',
|
|
811
|
+
'callMain',
|
|
812
|
+
'abort',
|
|
813
|
+
'wasmExports',
|
|
814
|
+
'writeStackCookie',
|
|
815
|
+
'checkStackCookie',
|
|
816
|
+
'INT53_MAX',
|
|
817
|
+
'INT53_MIN',
|
|
818
|
+
'HEAP8',
|
|
819
|
+
'HEAPU8',
|
|
820
|
+
'HEAP16',
|
|
821
|
+
'HEAPU16',
|
|
822
|
+
'HEAP32',
|
|
823
|
+
'HEAPU32',
|
|
824
|
+
'HEAPF32',
|
|
825
|
+
'HEAPF64',
|
|
826
|
+
'HEAP64',
|
|
827
|
+
'HEAPU64',
|
|
828
|
+
'stackSave',
|
|
829
|
+
'stackRestore',
|
|
830
|
+
'ptrToString',
|
|
831
|
+
'ENV',
|
|
832
|
+
'ERRNO_CODES',
|
|
833
|
+
'DNS',
|
|
834
|
+
'Protocols',
|
|
835
|
+
'Sockets',
|
|
836
|
+
'timers',
|
|
837
|
+
'warnOnce',
|
|
838
|
+
'readEmAsmArgsArray',
|
|
839
|
+
'wasmTable',
|
|
840
|
+
'wasmMemory',
|
|
841
|
+
'noExitRuntime',
|
|
842
|
+
'addOnPreRun',
|
|
843
|
+
'addOnPostRun',
|
|
844
|
+
'freeTableIndexes',
|
|
845
|
+
'functionsInTableMap',
|
|
846
|
+
'setValue',
|
|
847
|
+
'getValue',
|
|
848
|
+
'PATH',
|
|
849
|
+
'PATH_FS',
|
|
850
|
+
'UTF8Decoder',
|
|
851
|
+
'UTF16Decoder',
|
|
852
|
+
'JSEvents',
|
|
853
|
+
'specialHTMLTargets',
|
|
854
|
+
'findCanvasEventTarget',
|
|
855
|
+
'currentFullscreenStrategy',
|
|
856
|
+
'restoreOldWindowedStyle',
|
|
857
|
+
'UNWIND_CACHE',
|
|
858
|
+
'ExitStatus',
|
|
859
|
+
'emSetImmediate',
|
|
860
|
+
'emClearImmediate_deps',
|
|
861
|
+
'emClearImmediate',
|
|
862
|
+
'promiseMap',
|
|
863
|
+
'uncaughtExceptionCount',
|
|
864
|
+
'exceptionLast',
|
|
865
|
+
'exceptionCaught',
|
|
866
|
+
'Browser',
|
|
867
|
+
'requestFullscreen',
|
|
868
|
+
'requestFullScreen',
|
|
869
|
+
'setCanvasSize',
|
|
870
|
+
'getUserMedia',
|
|
871
|
+
'createContext',
|
|
872
|
+
'getPreloadedImageData__data',
|
|
873
|
+
'wget',
|
|
874
|
+
'MONTH_DAYS_REGULAR',
|
|
875
|
+
'MONTH_DAYS_LEAP',
|
|
876
|
+
'MONTH_DAYS_REGULAR_CUMULATIVE',
|
|
877
|
+
'MONTH_DAYS_LEAP_CUMULATIVE',
|
|
878
|
+
'SYSCALLS',
|
|
879
|
+
'preloadPlugins',
|
|
880
|
+
'FS_stdin_getChar_buffer',
|
|
881
|
+
'FS_unlink',
|
|
882
|
+
'FS_createPath',
|
|
883
|
+
'FS_createDevice',
|
|
884
|
+
'FS_readFile',
|
|
885
|
+
'FS',
|
|
886
|
+
'FS_root',
|
|
887
|
+
'FS_mounts',
|
|
888
|
+
'FS_devices',
|
|
889
|
+
'FS_streams',
|
|
890
|
+
'FS_nextInode',
|
|
891
|
+
'FS_nameTable',
|
|
892
|
+
'FS_currentPath',
|
|
893
|
+
'FS_initialized',
|
|
894
|
+
'FS_ignorePermissions',
|
|
895
|
+
'FS_filesystems',
|
|
896
|
+
'FS_syncFSRequests',
|
|
897
|
+
'FS_lookupPath',
|
|
898
|
+
'FS_getPath',
|
|
899
|
+
'FS_hashName',
|
|
900
|
+
'FS_hashAddNode',
|
|
901
|
+
'FS_hashRemoveNode',
|
|
902
|
+
'FS_lookupNode',
|
|
903
|
+
'FS_createNode',
|
|
904
|
+
'FS_destroyNode',
|
|
905
|
+
'FS_isRoot',
|
|
906
|
+
'FS_isMountpoint',
|
|
907
|
+
'FS_isFile',
|
|
908
|
+
'FS_isDir',
|
|
909
|
+
'FS_isLink',
|
|
910
|
+
'FS_isChrdev',
|
|
911
|
+
'FS_isBlkdev',
|
|
912
|
+
'FS_isFIFO',
|
|
913
|
+
'FS_isSocket',
|
|
914
|
+
'FS_flagsToPermissionString',
|
|
915
|
+
'FS_nodePermissions',
|
|
916
|
+
'FS_mayLookup',
|
|
917
|
+
'FS_mayCreate',
|
|
918
|
+
'FS_mayDelete',
|
|
919
|
+
'FS_mayOpen',
|
|
920
|
+
'FS_checkOpExists',
|
|
921
|
+
'FS_nextfd',
|
|
922
|
+
'FS_getStreamChecked',
|
|
923
|
+
'FS_getStream',
|
|
924
|
+
'FS_createStream',
|
|
925
|
+
'FS_closeStream',
|
|
926
|
+
'FS_dupStream',
|
|
927
|
+
'FS_doSetAttr',
|
|
928
|
+
'FS_chrdev_stream_ops',
|
|
929
|
+
'FS_major',
|
|
930
|
+
'FS_minor',
|
|
931
|
+
'FS_makedev',
|
|
932
|
+
'FS_registerDevice',
|
|
933
|
+
'FS_getDevice',
|
|
934
|
+
'FS_getMounts',
|
|
935
|
+
'FS_syncfs',
|
|
936
|
+
'FS_mount',
|
|
937
|
+
'FS_unmount',
|
|
938
|
+
'FS_lookup',
|
|
939
|
+
'FS_mknod',
|
|
940
|
+
'FS_statfs',
|
|
941
|
+
'FS_statfsStream',
|
|
942
|
+
'FS_statfsNode',
|
|
943
|
+
'FS_create',
|
|
944
|
+
'FS_mkdir',
|
|
945
|
+
'FS_mkdev',
|
|
946
|
+
'FS_symlink',
|
|
947
|
+
'FS_rename',
|
|
948
|
+
'FS_rmdir',
|
|
949
|
+
'FS_readdir',
|
|
950
|
+
'FS_readlink',
|
|
951
|
+
'FS_stat',
|
|
952
|
+
'FS_fstat',
|
|
953
|
+
'FS_lstat',
|
|
954
|
+
'FS_doChmod',
|
|
955
|
+
'FS_chmod',
|
|
956
|
+
'FS_lchmod',
|
|
957
|
+
'FS_fchmod',
|
|
958
|
+
'FS_doChown',
|
|
959
|
+
'FS_chown',
|
|
960
|
+
'FS_lchown',
|
|
961
|
+
'FS_fchown',
|
|
962
|
+
'FS_doTruncate',
|
|
963
|
+
'FS_truncate',
|
|
964
|
+
'FS_ftruncate',
|
|
965
|
+
'FS_utime',
|
|
966
|
+
'FS_open',
|
|
967
|
+
'FS_close',
|
|
968
|
+
'FS_isClosed',
|
|
969
|
+
'FS_llseek',
|
|
970
|
+
'FS_read',
|
|
971
|
+
'FS_write',
|
|
972
|
+
'FS_mmap',
|
|
973
|
+
'FS_msync',
|
|
974
|
+
'FS_ioctl',
|
|
975
|
+
'FS_writeFile',
|
|
976
|
+
'FS_cwd',
|
|
977
|
+
'FS_chdir',
|
|
978
|
+
'FS_createDefaultDirectories',
|
|
979
|
+
'FS_createDefaultDevices',
|
|
980
|
+
'FS_createSpecialDirectories',
|
|
981
|
+
'FS_createStandardStreams',
|
|
982
|
+
'FS_staticInit',
|
|
983
|
+
'FS_init',
|
|
984
|
+
'FS_quit',
|
|
985
|
+
'FS_findObject',
|
|
986
|
+
'FS_analyzePath',
|
|
987
|
+
'FS_createFile',
|
|
988
|
+
'FS_createDataFile',
|
|
989
|
+
'FS_forceLoadFile',
|
|
990
|
+
'FS_createLazyFile',
|
|
991
|
+
'MEMFS',
|
|
992
|
+
'TTY',
|
|
993
|
+
'PIPEFS',
|
|
994
|
+
'SOCKFS',
|
|
995
|
+
'tempFixedLengthArray',
|
|
996
|
+
'miniTempWebGLFloatBuffers',
|
|
997
|
+
'miniTempWebGLIntBuffers',
|
|
998
|
+
'GL',
|
|
999
|
+
'AL',
|
|
1000
|
+
'GLUT',
|
|
1001
|
+
'EGL',
|
|
1002
|
+
'GLEW',
|
|
1003
|
+
'IDBStore',
|
|
1004
|
+
'SDL',
|
|
1005
|
+
'SDL_gfx',
|
|
1006
|
+
'print',
|
|
1007
|
+
'printErr',
|
|
1008
|
+
'jstoi_s',
|
|
1009
|
+
];
|
|
1010
|
+
unexportedSymbols.forEach(unexportedRuntimeSymbol);
|
|
1011
|
+
|
|
1012
|
+
// End runtime exports
|
|
1013
|
+
// Begin JS library exports
|
|
1014
|
+
// End JS library exports
|
|
1015
|
+
|
|
1016
|
+
// end include: postlibrary.js
|
|
1017
|
+
|
|
1018
|
+
function checkIncomingModuleAPI() {
|
|
1019
|
+
ignoredModuleProp('fetchSettings');
|
|
1020
|
+
ignoredModuleProp('logReadFiles');
|
|
1021
|
+
ignoredModuleProp('loadSplitModule');
|
|
1022
|
+
ignoredModuleProp('onMalloc');
|
|
1023
|
+
ignoredModuleProp('onRealloc');
|
|
1024
|
+
ignoredModuleProp('onFree');
|
|
1025
|
+
ignoredModuleProp('onSbrkGrow');
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// Imports from the Wasm binary.
|
|
1029
|
+
Module['_isX86'] = makeInvalidEarlyAccess('_isX86');
|
|
1030
|
+
Module['_isArm'] = makeInvalidEarlyAccess('_isArm');
|
|
1031
|
+
Module['_isRiscV'] = makeInvalidEarlyAccess('_isRiscV');
|
|
1032
|
+
var _emscripten_stack_init = makeInvalidEarlyAccess('_emscripten_stack_init');
|
|
1033
|
+
var _emscripten_stack_get_end = makeInvalidEarlyAccess('_emscripten_stack_get_end');
|
|
1034
|
+
var wasmMemory = makeInvalidEarlyAccess('wasmMemory');
|
|
1035
|
+
|
|
1036
|
+
function assignWasmExports(wasmExports) {
|
|
1037
|
+
assert(typeof wasmExports['isX86'] != 'undefined', 'missing Wasm export: isX86');
|
|
1038
|
+
assert(typeof wasmExports['isArm'] != 'undefined', 'missing Wasm export: isArm');
|
|
1039
|
+
assert(typeof wasmExports['isRiscV'] != 'undefined', 'missing Wasm export: isRiscV');
|
|
1040
|
+
assert(typeof wasmExports['fflush'] != 'undefined', 'missing Wasm export: fflush');
|
|
1041
|
+
assert(typeof wasmExports['emscripten_stack_init'] != 'undefined', 'missing Wasm export: emscripten_stack_init');
|
|
1042
|
+
assert(typeof wasmExports['emscripten_stack_get_free'] != 'undefined', 'missing Wasm export: emscripten_stack_get_free');
|
|
1043
|
+
assert(typeof wasmExports['emscripten_stack_get_base'] != 'undefined', 'missing Wasm export: emscripten_stack_get_base');
|
|
1044
|
+
assert(typeof wasmExports['emscripten_stack_get_end'] != 'undefined', 'missing Wasm export: emscripten_stack_get_end');
|
|
1045
|
+
assert(typeof wasmExports['_emscripten_stack_restore'] != 'undefined', 'missing Wasm export: _emscripten_stack_restore');
|
|
1046
|
+
assert(typeof wasmExports['_emscripten_stack_alloc'] != 'undefined', 'missing Wasm export: _emscripten_stack_alloc');
|
|
1047
|
+
assert(typeof wasmExports['emscripten_stack_get_current'] != 'undefined', 'missing Wasm export: emscripten_stack_get_current');
|
|
1048
|
+
assert(typeof wasmExports['memory'] != 'undefined', 'missing Wasm export: memory');
|
|
1049
|
+
assert(typeof wasmExports['__indirect_function_table'] != 'undefined', 'missing Wasm export: __indirect_function_table');
|
|
1050
|
+
Module['_isX86'] = createExportWrapper('isX86', 0);
|
|
1051
|
+
Module['_isArm'] = createExportWrapper('isArm', 0);
|
|
1052
|
+
Module['_isRiscV'] = createExportWrapper('isRiscV', 0);
|
|
1053
|
+
_emscripten_stack_init = wasmExports['emscripten_stack_init'];
|
|
1054
|
+
wasmExports['emscripten_stack_get_free'];
|
|
1055
|
+
wasmExports['emscripten_stack_get_base'];
|
|
1056
|
+
_emscripten_stack_get_end = wasmExports['emscripten_stack_get_end'];
|
|
1057
|
+
wasmExports['_emscripten_stack_restore'];
|
|
1058
|
+
wasmExports['_emscripten_stack_alloc'];
|
|
1059
|
+
wasmExports['emscripten_stack_get_current'];
|
|
1060
|
+
wasmMemory = wasmExports['memory'];
|
|
1061
|
+
wasmExports['__indirect_function_table'];
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
var wasmImports = {
|
|
1065
|
+
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
// include: postamble.js
|
|
1070
|
+
// === Auto-generated postamble setup entry stuff ===
|
|
1071
|
+
|
|
1072
|
+
var calledRun;
|
|
1073
|
+
|
|
1074
|
+
function stackCheckInit() {
|
|
1075
|
+
// This is normally called automatically during __wasm_call_ctors but need to
|
|
1076
|
+
// get these values before even running any of the ctors so we call it redundantly
|
|
1077
|
+
// here.
|
|
1078
|
+
_emscripten_stack_init();
|
|
1079
|
+
// TODO(sbc): Move writeStackCookie to native to to avoid this.
|
|
1080
|
+
writeStackCookie();
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
function run() {
|
|
1084
|
+
|
|
1085
|
+
stackCheckInit();
|
|
1086
|
+
|
|
1087
|
+
preRun();
|
|
1088
|
+
|
|
1089
|
+
function doRun() {
|
|
1090
|
+
// run may have just been called through dependencies being fulfilled just in this very frame,
|
|
1091
|
+
// or while the async setStatus time below was happening
|
|
1092
|
+
assert(!calledRun);
|
|
1093
|
+
calledRun = true;
|
|
1094
|
+
Module['calledRun'] = true;
|
|
1095
|
+
|
|
1096
|
+
if (ABORT) return;
|
|
1097
|
+
|
|
1098
|
+
initRuntime();
|
|
1099
|
+
|
|
1100
|
+
readyPromiseResolve?.(Module);
|
|
1101
|
+
Module['onRuntimeInitialized']?.();
|
|
1102
|
+
consumedModuleProp('onRuntimeInitialized');
|
|
1103
|
+
|
|
1104
|
+
assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');
|
|
1105
|
+
|
|
1106
|
+
postRun();
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
if (Module['setStatus']) {
|
|
1110
|
+
Module['setStatus']('Running...');
|
|
1111
|
+
setTimeout(() => {
|
|
1112
|
+
setTimeout(() => Module['setStatus'](''), 1);
|
|
1113
|
+
doRun();
|
|
1114
|
+
}, 1);
|
|
1115
|
+
} else
|
|
1116
|
+
{
|
|
1117
|
+
doRun();
|
|
1118
|
+
}
|
|
1119
|
+
checkStackCookie();
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
var wasmExports;
|
|
1123
|
+
|
|
1124
|
+
// In modularize mode the generated code is within a factory function so we
|
|
1125
|
+
// can use await here (since it's not top-level-await).
|
|
1126
|
+
wasmExports = await (createWasm());
|
|
1127
|
+
|
|
1128
|
+
run();
|
|
1129
|
+
|
|
1130
|
+
// end include: postamble.js
|
|
1131
|
+
|
|
1132
|
+
// include: postamble_modularize.js
|
|
1133
|
+
// In MODULARIZE mode we wrap the generated code in a factory function
|
|
1134
|
+
// and return either the Module itself, or a promise of the module.
|
|
1135
|
+
//
|
|
1136
|
+
// We assign to the `moduleRtn` global here and configure closure to see
|
|
1137
|
+
// this as an extern so it won't get minified.
|
|
1138
|
+
|
|
1139
|
+
if (runtimeInitialized) {
|
|
1140
|
+
moduleRtn = Module;
|
|
1141
|
+
} else {
|
|
1142
|
+
// Set up the promise that indicates the Module is initialized
|
|
1143
|
+
moduleRtn = new Promise((resolve, reject) => {
|
|
1144
|
+
readyPromiseResolve = resolve;
|
|
1145
|
+
readyPromiseReject = reject;
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
// Assertion for attempting to access module properties on the incoming
|
|
1150
|
+
// moduleArg. In the past we used this object as the prototype of the module
|
|
1151
|
+
// and assigned properties to it, but now we return a distinct object. This
|
|
1152
|
+
// keeps the instance private until it is ready (i.e the promise has been
|
|
1153
|
+
// resolved).
|
|
1154
|
+
for (const prop of Object.keys(Module)) {
|
|
1155
|
+
if (!(prop in moduleArg)) {
|
|
1156
|
+
Object.defineProperty(moduleArg, prop, {
|
|
1157
|
+
configurable: true,
|
|
1158
|
+
get() {
|
|
1159
|
+
abort(`Access to module property ('${prop}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`);
|
|
1160
|
+
}
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
// end include: postamble_modularize.js
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
|
|
1168
|
+
return moduleRtn;
|
|
1169
|
+
}let wasmModule;
|
|
1170
|
+
|
|
1171
|
+
async function initialize() {
|
|
1172
|
+
if (wasmModule) return wasmModule;
|
|
1173
|
+
wasmModule = await Module();
|
|
1174
|
+
return wasmModule;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
async function isX86() {
|
|
1178
|
+
return Boolean((await initialize())._isX86());
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
async function isArm() {
|
|
1182
|
+
return Boolean((await initialize())._isArm());
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
async function isRiscV() {
|
|
1186
|
+
return Boolean((await initialize())._isRiscV());
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
var index = {
|
|
1190
|
+
isX86,
|
|
1191
|
+
isArm,
|
|
1192
|
+
isRiscV
|
|
1193
|
+
};exports.default=index;exports.isArm=isArm;exports.isRiscV=isRiscV;exports.isX86=isX86;Object.defineProperty(exports,'__esModule',{value:true});return exports;})({});
|