ipa-resign 0.0.5 → 0.0.7
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/LICENSE +47 -0
- package/README.md +22 -18
- package/assets/anisette/anisette_rs.js +557 -541
- package/assets/anisette/anisette_rs.wasm +0 -0
- package/assets/anisette/dist/anisette.d.ts +7 -0
- package/assets/anisette/dist/anisette.d.ts.map +1 -1
- package/assets/anisette/dist/anisette.js +32 -4
- package/assets/anisette/dist/anisette.js.map +1 -1
- package/assets/anisette/dist/anisette_rs.js +604 -841
- package/assets/anisette/dist/anisette_rs.node.js +539 -833
- package/assets/anisette/dist/anisette_rs.wasm +0 -0
- package/assets/anisette/dist/package.json +3 -0
- package/assets/zsign/zsign-wasm.min.js +27154 -27039
- package/dist/THIRD-PARTY-LICENSES.txt +1 -1
- package/dist/anisette-browser/index.d.ts +26 -0
- package/dist/anisette-browser/index.js +1 -452
- package/dist/browser/index.js +1 -554
- package/dist/core/index.js +1 -1302
- package/dist/index.js +1 -2
- package/dist/index.mjs +1 -2
- package/dist/sign-browser/index.js +2 -18313
- package/package.json +6 -6
- package/assets/anisette/dist/unified-wasm-loader.d.ts +0 -47
- package/assets/anisette/dist/unified-wasm-loader.d.ts.map +0 -1
- package/assets/anisette/dist/unified-wasm-loader.js +0 -77
- package/assets/anisette/dist/unified-wasm-loader.js.map +0 -1
- package/dist/index.jsc +0 -0
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
// When targeting node and ES6 we use `await import ..` in the generated code
|
|
5
5
|
// so the outer function needs to be marked as async.
|
|
6
6
|
async function Module(moduleArg = {}) {
|
|
7
|
-
var
|
|
8
|
-
|
|
7
|
+
var Module = moduleArg;
|
|
9
8
|
// include: shell.js
|
|
10
9
|
// include: minimum_runtime_check.js
|
|
11
10
|
(function() {
|
|
@@ -24,12 +23,17 @@ async function Module(moduleArg = {}) {
|
|
|
24
23
|
|
|
25
24
|
// Note: We use a typeof check here instead of optional chaining using
|
|
26
25
|
// globalThis because older browsers might not have globalThis defined.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
|
|
27
|
+
// We skip the node version checking when running on Bun/Deno since the node
|
|
28
|
+
// version they report doesn't seem to be useful.
|
|
29
|
+
if (typeof process !== 'undefined' && !process.versions?.bun && typeof Deno == "undefined") {
|
|
30
|
+
var currentNodeVersion = process.versions?.node ? humanReadableVersionToPacked(process.versions.node) : TARGET_NOT_SUPPORTED;
|
|
31
|
+
if (currentNodeVersion < TARGET_NOT_SUPPORTED) {
|
|
32
|
+
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?)');
|
|
33
|
+
}
|
|
34
|
+
if (currentNodeVersion < 2147483647) {
|
|
35
|
+
throw new Error(`This emscripten-generated code requires node v${ packedVersionToHumanReadable(2147483647) } (detected v${packedVersionToHumanReadable(currentNodeVersion)})`);
|
|
36
|
+
}
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
var userAgent = typeof navigator !== 'undefined' && navigator.userAgent;
|
|
@@ -67,7 +71,6 @@ async function Module(moduleArg = {}) {
|
|
|
67
71
|
// after the generated code, you will need to define var Module = {};
|
|
68
72
|
// before the code. Then that object will be used in the code, and you
|
|
69
73
|
// can continue to use Module afterwards as well.
|
|
70
|
-
var Module = moduleArg;
|
|
71
74
|
|
|
72
75
|
// Determine the runtime environment we are in. You can customize this by
|
|
73
76
|
// setting the ENVIRONMENT setting at compile time (see settings.js).
|
|
@@ -84,7 +87,7 @@ var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIR
|
|
|
84
87
|
// refer to Module (if they choose; they can also define Module)
|
|
85
88
|
|
|
86
89
|
|
|
87
|
-
var
|
|
90
|
+
var programArgs = [];
|
|
88
91
|
var thisProgram = './this.program';
|
|
89
92
|
var quit_ = (status, toThrow) => {
|
|
90
93
|
throw toThrow;
|
|
@@ -154,11 +157,11 @@ var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js';
|
|
|
154
157
|
// perform assertions in shell.js after we set up out() and err(), as otherwise
|
|
155
158
|
// if an assertion fails it cannot print the message
|
|
156
159
|
|
|
157
|
-
assert(!ENVIRONMENT_IS_WORKER, 'worker environment detected but not enabled at build time
|
|
160
|
+
assert(!ENVIRONMENT_IS_WORKER, 'worker environment detected but not enabled at build time (add `worker` to `-sENVIRONMENT` to enable)');
|
|
158
161
|
|
|
159
|
-
assert(!ENVIRONMENT_IS_NODE, 'node environment detected but not enabled at build time
|
|
162
|
+
assert(!ENVIRONMENT_IS_NODE, 'node environment detected but not enabled at build time (add `node` to `-sENVIRONMENT` to enable)');
|
|
160
163
|
|
|
161
|
-
assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time
|
|
164
|
+
assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time (add `shell` to `-sENVIRONMENT` to enable)');
|
|
162
165
|
|
|
163
166
|
// end include: shell.js
|
|
164
167
|
|
|
@@ -215,45 +218,12 @@ function assert(condition, text) {
|
|
|
215
218
|
var isFileURI = (filename) => filename.startsWith('file://');
|
|
216
219
|
|
|
217
220
|
// include: runtime_common.js
|
|
218
|
-
// include: runtime_stack_check.js
|
|
219
|
-
// Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
|
|
220
|
-
function writeStackCookie() {
|
|
221
|
-
var max = _emscripten_stack_get_end();
|
|
222
|
-
assert((max & 3) == 0);
|
|
223
|
-
// If the stack ends at address zero we write our cookies 4 bytes into the
|
|
224
|
-
// stack. This prevents interference with SAFE_HEAP and ASAN which also
|
|
225
|
-
// monitor writes to address zero.
|
|
226
|
-
if (max == 0) {
|
|
227
|
-
max += 4;
|
|
228
|
-
}
|
|
229
|
-
// The stack grow downwards towards _emscripten_stack_get_end.
|
|
230
|
-
// We write cookies to the final two words in the stack and detect if they are
|
|
231
|
-
// ever overwritten.
|
|
232
|
-
HEAPU32[((max)>>2)] = 0x02135467;
|
|
233
|
-
HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE;
|
|
234
|
-
// Also test the global address 0 for integrity.
|
|
235
|
-
HEAPU32[((0)>>2)] = 1668509029;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function checkStackCookie() {
|
|
239
|
-
if (ABORT) return;
|
|
240
|
-
var max = _emscripten_stack_get_end();
|
|
241
|
-
// See writeStackCookie().
|
|
242
|
-
if (max == 0) {
|
|
243
|
-
max += 4;
|
|
244
|
-
}
|
|
245
|
-
var cookie1 = HEAPU32[((max)>>2)];
|
|
246
|
-
var cookie2 = HEAPU32[(((max)+(4))>>2)];
|
|
247
|
-
if (cookie1 != 0x02135467 || cookie2 != 0x89BACDFE) {
|
|
248
|
-
abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`);
|
|
249
|
-
}
|
|
250
|
-
// Also test the global address 0 for integrity.
|
|
251
|
-
if (HEAPU32[((0)>>2)] != 0x63736d65 /* 'emsc' */) {
|
|
252
|
-
abort('Runtime error: The application has corrupted its heap memory area (address zero)!');
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
// end include: runtime_stack_check.js
|
|
256
221
|
// include: runtime_exceptions.js
|
|
222
|
+
// Base Emscripten EH error class
|
|
223
|
+
class EmscriptenEH {}
|
|
224
|
+
|
|
225
|
+
class EmscriptenSjLj extends EmscriptenEH {}
|
|
226
|
+
|
|
257
227
|
// end include: runtime_exceptions.js
|
|
258
228
|
// include: runtime_debug.js
|
|
259
229
|
var runtimeDebug = true; // Switch to false at runtime to disable logging at the right times
|
|
@@ -275,15 +245,31 @@ function dbg(...args) {
|
|
|
275
245
|
})();
|
|
276
246
|
|
|
277
247
|
function consumedModuleProp(prop) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
248
|
+
var value = Module[prop];
|
|
249
|
+
var msg = `Attempt to modify \`Module.${prop}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`;
|
|
250
|
+
if (Array.isArray(value)) {
|
|
251
|
+
value = new Proxy(value, {
|
|
252
|
+
set(target, key, val) {
|
|
253
|
+
abort(msg);
|
|
254
|
+
return false;
|
|
255
|
+
},
|
|
256
|
+
defineProperty(target, key, descriptor) {
|
|
257
|
+
abort(msg);
|
|
258
|
+
return false;
|
|
259
|
+
},
|
|
260
|
+
deleteProperty(target, key) {
|
|
261
|
+
abort(msg);
|
|
262
|
+
return false;
|
|
284
263
|
}
|
|
285
264
|
});
|
|
286
265
|
}
|
|
266
|
+
Object.defineProperty(Module, prop, {
|
|
267
|
+
configurable: true,
|
|
268
|
+
get() { return value; },
|
|
269
|
+
set() {
|
|
270
|
+
abort(msg);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
287
273
|
}
|
|
288
274
|
|
|
289
275
|
function makeInvalidEarlyAccess(name) {
|
|
@@ -334,41 +320,68 @@ function unexportedRuntimeSymbol(sym) {
|
|
|
334
320
|
}
|
|
335
321
|
|
|
336
322
|
// end include: runtime_debug.js
|
|
337
|
-
|
|
323
|
+
// include: runtime_stack_check.js
|
|
324
|
+
const stackCookie1 = 0x02135467;
|
|
325
|
+
const stackCookie2 = 0x89BACDFE;
|
|
326
|
+
|
|
327
|
+
// Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
|
|
328
|
+
function writeStackCookie() {
|
|
329
|
+
var max = _emscripten_stack_get_end();
|
|
330
|
+
assert((max & 3) == 0);
|
|
331
|
+
// If the stack ends at address zero we write our cookies 4 bytes into the
|
|
332
|
+
// stack. This prevents interference with SAFE_HEAP and ASAN which also
|
|
333
|
+
// monitor writes to address zero.
|
|
334
|
+
if (max == 0) {
|
|
335
|
+
max += 4;
|
|
336
|
+
}
|
|
337
|
+
// The stack grow downwards towards _emscripten_stack_get_end.
|
|
338
|
+
// We write cookies to the final two words in the stack and detect if they are
|
|
339
|
+
// ever overwritten.
|
|
340
|
+
HEAPU32[((max)>>2)] = stackCookie1;
|
|
341
|
+
HEAPU32[(((max)+(4))>>2)] = stackCookie2;
|
|
342
|
+
// Also test the global address 0 for integrity.
|
|
343
|
+
HEAPU32[((0)>>2)] = 1668509029;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function u32ToHexString(num) {
|
|
347
|
+
return '0x' + (num >>> 0).toString(16).padStart(8, '0');
|
|
348
|
+
}
|
|
338
349
|
|
|
350
|
+
function checkStackCookie() {
|
|
351
|
+
if (ABORT) return;
|
|
352
|
+
var max = _emscripten_stack_get_end();
|
|
353
|
+
// See writeStackCookie().
|
|
354
|
+
if (max == 0) {
|
|
355
|
+
max += 4;
|
|
356
|
+
}
|
|
357
|
+
var val1 = HEAPU32[((max)>>2)];
|
|
358
|
+
var val2 = HEAPU32[(((max)+(4))>>2)];
|
|
359
|
+
if (val1 != stackCookie1 || val2 != stackCookie2) {
|
|
360
|
+
abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords ${u32ToHexString(stackCookie2)} and ${u32ToHexString(stackCookie1)}, but received ${u32ToHexString(val2)} ${u32ToHexString(val1)}`);
|
|
361
|
+
}
|
|
362
|
+
// Also test the global address 0 for integrity.
|
|
363
|
+
if (HEAPU32[((0)>>2)] != 0x63736d65 /* 'emsc' */) {
|
|
364
|
+
abort('Runtime error: The application has corrupted its heap memory area (address zero)!');
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
// end include: runtime_stack_check.js
|
|
339
368
|
// Memory management
|
|
340
|
-
var
|
|
341
|
-
/** @type {!Int8Array} */
|
|
342
|
-
HEAP8,
|
|
343
|
-
/** @type {!Uint8Array} */
|
|
344
|
-
HEAPU8,
|
|
345
|
-
/** @type {!Int16Array} */
|
|
346
|
-
HEAP16,
|
|
347
|
-
/** @type {!Uint16Array} */
|
|
348
|
-
HEAPU16,
|
|
349
|
-
/** @type {!Int32Array} */
|
|
350
|
-
HEAP32,
|
|
351
|
-
/** @type {!Uint32Array} */
|
|
352
|
-
HEAPU32,
|
|
353
|
-
/** @type {!Float32Array} */
|
|
354
|
-
HEAPF32,
|
|
355
|
-
/** @type {!Float64Array} */
|
|
356
|
-
HEAPF64;
|
|
357
|
-
|
|
358
|
-
// BigInt64Array type is not correctly defined in closure
|
|
359
|
-
var
|
|
360
|
-
/** not-@type {!BigInt64Array} */
|
|
361
|
-
HEAP64,
|
|
362
|
-
/* BigUint64Array type is not correctly defined in closure
|
|
363
|
-
/** not-@type {!BigUint64Array} */
|
|
364
|
-
HEAPU64;
|
|
365
369
|
|
|
366
370
|
var runtimeInitialized = false;
|
|
367
371
|
|
|
368
372
|
|
|
369
373
|
|
|
374
|
+
// When ALLOW_MEMORY_GROWTH is enabled, the conversion from Wasm
|
|
375
|
+
// memory to ArrayBuffer requires some additional logic.
|
|
376
|
+
function getMemoryBuffer() {
|
|
377
|
+
return wasmMemory.buffer;
|
|
378
|
+
}
|
|
379
|
+
|
|
370
380
|
function updateMemoryViews() {
|
|
371
|
-
|
|
381
|
+
// If we already have a heap that is resizeable/growable buffer we don't
|
|
382
|
+
// need to do anything in updateMemoryViews.
|
|
383
|
+
if (HEAP8?.buffer?.resizable) return;
|
|
384
|
+
var b = getMemoryBuffer();
|
|
372
385
|
HEAP8 = new Int8Array(b);
|
|
373
386
|
HEAP16 = new Int16Array(b);
|
|
374
387
|
Module['HEAPU8'] = HEAPU8 = new Uint8Array(b);
|
|
@@ -388,11 +401,10 @@ assert(globalThis.Int32Array && globalThis.Float64Array && Int32Array.prototype.
|
|
|
388
401
|
'JS engine does not provide full typed array support');
|
|
389
402
|
|
|
390
403
|
function preRun() {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
404
|
+
var preRun = Module['preRun'];
|
|
405
|
+
if (preRun) {
|
|
406
|
+
if (typeof preRun == 'function') preRun = [preRun];
|
|
407
|
+
onPreRuns.push(...preRun);
|
|
396
408
|
}
|
|
397
409
|
consumedModuleProp('preRun');
|
|
398
410
|
// Begin ATPRERUNS hooks
|
|
@@ -416,17 +428,17 @@ TTY.init();
|
|
|
416
428
|
// Begin ATPOSTCTORS hooks
|
|
417
429
|
FS.ignorePermissions = false;
|
|
418
430
|
// End ATPOSTCTORS hooks
|
|
431
|
+
|
|
432
|
+
checkStackCookie();
|
|
419
433
|
}
|
|
420
434
|
|
|
421
435
|
function postRun() {
|
|
422
436
|
checkStackCookie();
|
|
423
|
-
// PThreads reuse the runtime from the main thread.
|
|
424
437
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}
|
|
438
|
+
var postRun = Module['postRun'];
|
|
439
|
+
if (postRun) {
|
|
440
|
+
if (typeof postRun == 'function') postRun = [postRun];
|
|
441
|
+
onPostRuns.push(...postRun);
|
|
430
442
|
}
|
|
431
443
|
consumedModuleProp('postRun');
|
|
432
444
|
|
|
@@ -435,11 +447,13 @@ function postRun() {
|
|
|
435
447
|
// End ATPOSTRUNS hooks
|
|
436
448
|
}
|
|
437
449
|
|
|
438
|
-
/**
|
|
450
|
+
/**
|
|
451
|
+
* @param {string|number=} what
|
|
452
|
+
*/
|
|
439
453
|
function abort(what) {
|
|
440
454
|
Module['onAbort']?.(what);
|
|
441
455
|
|
|
442
|
-
what =
|
|
456
|
+
what = `Aborted(${what})`;
|
|
443
457
|
// TODO(sbc): Should we remove printing and leave it up to whoever
|
|
444
458
|
// catches the exception?
|
|
445
459
|
err(what);
|
|
@@ -462,21 +476,19 @@ function abort(what) {
|
|
|
462
476
|
/** @suppress {checkTypes} */
|
|
463
477
|
var e = new WebAssembly.RuntimeError(what);
|
|
464
478
|
|
|
465
|
-
readyPromiseReject?.(e);
|
|
466
479
|
// Throw the error whether or not MODULARIZE is set because abort is used
|
|
467
480
|
// in code paths apart from instantiation where an exception is expected
|
|
468
481
|
// to be thrown when abort is called.
|
|
469
482
|
throw e;
|
|
470
483
|
}
|
|
471
484
|
|
|
472
|
-
function createExportWrapper(name, nargs) {
|
|
485
|
+
function createExportWrapper(name, func, nargs) {
|
|
486
|
+
assert(func);
|
|
473
487
|
return (...args) => {
|
|
474
488
|
assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`);
|
|
475
|
-
var f = wasmExports[name];
|
|
476
|
-
assert(f, `exported native function \`${name}\` not found`);
|
|
477
489
|
// Only assert for too many arguments. Too few can be valid since the missing arguments will be zero filled.
|
|
478
490
|
assert(args.length <= nargs, `native function \`${name}\` called with ${args.length} args but expects ${nargs}`);
|
|
479
|
-
return
|
|
491
|
+
return func(...args);
|
|
480
492
|
};
|
|
481
493
|
}
|
|
482
494
|
|
|
@@ -494,9 +506,6 @@ function findWasmBinary() {
|
|
|
494
506
|
}
|
|
495
507
|
|
|
496
508
|
function getBinarySync(file) {
|
|
497
|
-
if (file == wasmBinaryFile && wasmBinary) {
|
|
498
|
-
return new Uint8Array(wasmBinary);
|
|
499
|
-
}
|
|
500
509
|
if (readBinary) {
|
|
501
510
|
return readBinary(file);
|
|
502
511
|
}
|
|
@@ -570,8 +579,7 @@ async function createWasm() {
|
|
|
570
579
|
// Load the wasm module and create an instance of using native support in the JS engine.
|
|
571
580
|
// handle a generated wasm instance, receiving its exports and
|
|
572
581
|
// performing other necessary setup
|
|
573
|
-
|
|
574
|
-
function receiveInstance(instance, module) {
|
|
582
|
+
function receiveInstance(instance) {
|
|
575
583
|
wasmExports = instance.exports;
|
|
576
584
|
|
|
577
585
|
assignWasmExports(wasmExports);
|
|
@@ -604,15 +612,14 @@ async function createWasm() {
|
|
|
604
612
|
// performing.
|
|
605
613
|
// Also pthreads and wasm workers initialize the wasm instance through this
|
|
606
614
|
// path.
|
|
607
|
-
|
|
608
|
-
|
|
615
|
+
var instantiateWasm = Module['instantiateWasm'];
|
|
616
|
+
if (instantiateWasm) {
|
|
617
|
+
return new Promise((resolve) => {
|
|
609
618
|
try {
|
|
610
|
-
|
|
611
|
-
resolve(receiveInstance(inst, mod));
|
|
612
|
-
});
|
|
619
|
+
instantiateWasm(info, (inst) => resolve(receiveInstance(inst)));
|
|
613
620
|
} catch(e) {
|
|
614
621
|
err(`Module.instantiateWasm callback failed with error: ${e}`);
|
|
615
|
-
|
|
622
|
+
throw e;
|
|
616
623
|
}
|
|
617
624
|
});
|
|
618
625
|
}
|
|
@@ -636,6 +643,15 @@ async function createWasm() {
|
|
|
636
643
|
}
|
|
637
644
|
}
|
|
638
645
|
|
|
646
|
+
/** @type {!Int32Array} */
|
|
647
|
+
var HEAP32;
|
|
648
|
+
|
|
649
|
+
/** @type {!Int8Array} */
|
|
650
|
+
var HEAP8;
|
|
651
|
+
|
|
652
|
+
/** @type {!Uint32Array} */
|
|
653
|
+
var HEAPU32;
|
|
654
|
+
|
|
639
655
|
var callRuntimeCallbacks = (callbacks) => {
|
|
640
656
|
while (callbacks.length > 0) {
|
|
641
657
|
// Pass the module as the first argument.
|
|
@@ -649,55 +665,14 @@ async function createWasm() {
|
|
|
649
665
|
var addOnPreRun = (cb) => onPreRuns.push(cb);
|
|
650
666
|
|
|
651
667
|
|
|
652
|
-
|
|
653
|
-
/**
|
|
654
|
-
* @param {number} ptr
|
|
655
|
-
* @param {string} type
|
|
656
|
-
*/
|
|
657
|
-
function getValue(ptr, type = 'i8') {
|
|
658
|
-
if (type.endsWith('*')) type = '*';
|
|
659
|
-
switch (type) {
|
|
660
|
-
case 'i1': return HEAP8[ptr];
|
|
661
|
-
case 'i8': return HEAP8[ptr];
|
|
662
|
-
case 'i16': return HEAP16[((ptr)>>1)];
|
|
663
|
-
case 'i32': return HEAP32[((ptr)>>2)];
|
|
664
|
-
case 'i64': return HEAP64[((ptr)>>3)];
|
|
665
|
-
case 'float': return HEAPF32[((ptr)>>2)];
|
|
666
|
-
case 'double': return HEAPF64[((ptr)>>3)];
|
|
667
|
-
case '*': return HEAPU32[((ptr)>>2)];
|
|
668
|
-
default: abort(`invalid type for getValue: ${type}`);
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
|
|
672
668
|
var noExitRuntime = true;
|
|
673
669
|
|
|
674
|
-
|
|
670
|
+
function ptrToString(ptr) {
|
|
675
671
|
assert(typeof ptr === 'number', `ptrToString expects a number, got ${typeof ptr}`);
|
|
676
672
|
// Convert to 32-bit unsigned value
|
|
677
673
|
ptr >>>= 0;
|
|
678
674
|
return '0x' + ptr.toString(16).padStart(8, '0');
|
|
679
|
-
};
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
/**
|
|
683
|
-
* @param {number} ptr
|
|
684
|
-
* @param {number} value
|
|
685
|
-
* @param {string} type
|
|
686
|
-
*/
|
|
687
|
-
function setValue(ptr, value, type = 'i8') {
|
|
688
|
-
if (type.endsWith('*')) type = '*';
|
|
689
|
-
switch (type) {
|
|
690
|
-
case 'i1': HEAP8[ptr] = value; break;
|
|
691
|
-
case 'i8': HEAP8[ptr] = value; break;
|
|
692
|
-
case 'i16': HEAP16[((ptr)>>1)] = value; break;
|
|
693
|
-
case 'i32': HEAP32[((ptr)>>2)] = value; break;
|
|
694
|
-
case 'i64': HEAP64[((ptr)>>3)] = BigInt(value); break;
|
|
695
|
-
case 'float': HEAPF32[((ptr)>>2)] = value; break;
|
|
696
|
-
case 'double': HEAPF64[((ptr)>>3)] = value; break;
|
|
697
|
-
case '*': HEAPU32[((ptr)>>2)] = value; break;
|
|
698
|
-
default: abort(`invalid type for setValue: ${type}`);
|
|
699
675
|
}
|
|
700
|
-
}
|
|
701
676
|
|
|
702
677
|
var stackRestore = (val) => __emscripten_stack_restore(val);
|
|
703
678
|
|
|
@@ -713,77 +688,8 @@ async function createWasm() {
|
|
|
713
688
|
|
|
714
689
|
|
|
715
690
|
|
|
716
|
-
class ExceptionInfo {
|
|
717
|
-
// excPtr - Thrown object pointer to wrap. Metadata pointer is calculated from it.
|
|
718
|
-
constructor(excPtr) {
|
|
719
|
-
this.excPtr = excPtr;
|
|
720
|
-
this.ptr = excPtr - 24;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
set_type(type) {
|
|
724
|
-
HEAPU32[(((this.ptr)+(4))>>2)] = type;
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
get_type() {
|
|
728
|
-
return HEAPU32[(((this.ptr)+(4))>>2)];
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
set_destructor(destructor) {
|
|
732
|
-
HEAPU32[(((this.ptr)+(8))>>2)] = destructor;
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
get_destructor() {
|
|
736
|
-
return HEAPU32[(((this.ptr)+(8))>>2)];
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
set_caught(caught) {
|
|
740
|
-
caught = caught ? 1 : 0;
|
|
741
|
-
HEAP8[(this.ptr)+(12)] = caught;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
get_caught() {
|
|
745
|
-
return HEAP8[(this.ptr)+(12)] != 0;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
set_rethrown(rethrown) {
|
|
749
|
-
rethrown = rethrown ? 1 : 0;
|
|
750
|
-
HEAP8[(this.ptr)+(13)] = rethrown;
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
get_rethrown() {
|
|
754
|
-
return HEAP8[(this.ptr)+(13)] != 0;
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
// Initialize native structure fields. Should be called once after allocated.
|
|
758
|
-
init(type, destructor) {
|
|
759
|
-
this.set_adjusted_ptr(0);
|
|
760
|
-
this.set_type(type);
|
|
761
|
-
this.set_destructor(destructor);
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
set_adjusted_ptr(adjustedPtr) {
|
|
765
|
-
HEAPU32[(((this.ptr)+(16))>>2)] = adjustedPtr;
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
get_adjusted_ptr() {
|
|
769
|
-
return HEAPU32[(((this.ptr)+(16))>>2)];
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
var exceptionLast = 0;
|
|
774
|
-
|
|
775
|
-
var uncaughtExceptionCount = 0;
|
|
776
|
-
var ___cxa_throw = (ptr, type, destructor) => {
|
|
777
|
-
var info = new ExceptionInfo(ptr);
|
|
778
|
-
// Initialize ExceptionInfo content after it was allocated in __cxa_allocate_exception.
|
|
779
|
-
info.init(type, destructor);
|
|
780
|
-
exceptionLast = ptr;
|
|
781
|
-
uncaughtExceptionCount++;
|
|
782
|
-
assert(false, 'Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.');
|
|
783
|
-
};
|
|
784
691
|
var __Unwind_RaiseException = (ex) => {
|
|
785
|
-
|
|
786
|
-
return ___cxa_throw(ex, 0, 0);
|
|
692
|
+
assert(false, 'Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.');
|
|
787
693
|
};
|
|
788
694
|
|
|
789
695
|
var wasmTableMirror = [];
|
|
@@ -796,7 +702,7 @@ async function createWasm() {
|
|
|
796
702
|
wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
|
|
797
703
|
}
|
|
798
704
|
/** @suppress {checkTypes} */
|
|
799
|
-
assert(wasmTable.get(funcPtr) == func, '
|
|
705
|
+
assert(wasmTable.get(funcPtr) == func, 'table mirror is out of date');
|
|
800
706
|
return func;
|
|
801
707
|
};
|
|
802
708
|
var ___call_sighandler = (fp, sig) => getWasmTableEntry(fp)(sig);
|
|
@@ -874,12 +780,9 @@ join2:(l, r) => PATH.normalize(l + '/' + r),
|
|
|
874
780
|
|
|
875
781
|
var initRandomFill = () => {
|
|
876
782
|
|
|
877
|
-
return (view) => crypto.getRandomValues(view);
|
|
878
|
-
};
|
|
879
|
-
var randomFill = (view) => {
|
|
880
|
-
// Lazily init on the first invocation.
|
|
881
|
-
(randomFill = initRandomFill())(view);
|
|
783
|
+
return (view) => (crypto.getRandomValues(view), 0);
|
|
882
784
|
};
|
|
785
|
+
var randomFill = (view) => (randomFill = initRandomFill())(view);
|
|
883
786
|
|
|
884
787
|
|
|
885
788
|
|
|
@@ -940,19 +843,27 @@ relative:(from, to) => {
|
|
|
940
843
|
|
|
941
844
|
var UTF8Decoder = globalThis.TextDecoder && new TextDecoder();
|
|
942
845
|
|
|
943
|
-
var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
944
|
-
var maxIdx = idx + maxBytesToRead;
|
|
945
|
-
if (ignoreNul) return maxIdx;
|
|
946
|
-
// TextDecoder needs to know the byte length in advance, it doesn't stop on
|
|
947
|
-
// null terminator by itself.
|
|
948
|
-
// As a tiny code save trick, compare idx against maxIdx using a negation,
|
|
949
|
-
// so that maxBytesToRead=undefined/NaN means Infinity.
|
|
950
|
-
while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx;
|
|
951
|
-
return idx;
|
|
952
|
-
};
|
|
953
|
-
|
|
954
846
|
|
|
955
847
|
/**
|
|
848
|
+
* heapOrArray is either a regular array, or a JavaScript typed array view.
|
|
849
|
+
* @param {number} idx
|
|
850
|
+
* @param {number=} maxBytesToRead
|
|
851
|
+
* @param {boolean=} ignoreNul
|
|
852
|
+
* @return {number}
|
|
853
|
+
*/
|
|
854
|
+
var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
855
|
+
var maxIdx = idx + maxBytesToRead;
|
|
856
|
+
if (ignoreNul) return maxIdx;
|
|
857
|
+
// TextDecoder needs to know the byte length in advance, it doesn't stop on
|
|
858
|
+
// null terminator by itself.
|
|
859
|
+
// As a tiny code save trick, compare idx against maxIdx using a negation,
|
|
860
|
+
// so that maxBytesToRead=undefined/NaN means Infinity.
|
|
861
|
+
while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx;
|
|
862
|
+
return idx;
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
/**
|
|
956
867
|
* Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
|
|
957
868
|
* array that contains uint8 values, returns a copy of that string as a
|
|
958
869
|
* Javascript String object.
|
|
@@ -984,7 +895,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
984
895
|
if ((u0 & 0xF0) == 0xE0) {
|
|
985
896
|
u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
|
|
986
897
|
} else {
|
|
987
|
-
if ((u0 & 0xF8) != 0xF0) warnOnce(
|
|
898
|
+
if ((u0 & 0xF8) != 0xF0) warnOnce(`Invalid UTF-8 leading byte ${ptrToString(u0)} encountered when deserializing a UTF-8 string in wasm memory to a JS string!`);
|
|
988
899
|
u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
|
|
989
900
|
}
|
|
990
901
|
|
|
@@ -1049,7 +960,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1049
960
|
heap[outIdx++] = 0x80 | (u & 63);
|
|
1050
961
|
} else {
|
|
1051
962
|
if (outIdx + 3 >= endIdx) break;
|
|
1052
|
-
if (u > 0x10FFFF) warnOnce(
|
|
963
|
+
if (u > 0x10FFFF) warnOnce(`Invalid Unicode code point ${ptrToString(u)} encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).`);
|
|
1053
964
|
heap[outIdx++] = 0xF0 | (u >> 18);
|
|
1054
965
|
heap[outIdx++] = 0x80 | ((u >> 12) & 63);
|
|
1055
966
|
heap[outIdx++] = 0x80 | ((u >> 6) & 63);
|
|
@@ -1144,7 +1055,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1144
1055
|
} catch (e) {
|
|
1145
1056
|
throw new FS.ErrnoError(29);
|
|
1146
1057
|
}
|
|
1147
|
-
if (result === undefined && bytesRead
|
|
1058
|
+
if (result === undefined && !bytesRead) {
|
|
1148
1059
|
throw new FS.ErrnoError(6);
|
|
1149
1060
|
}
|
|
1150
1061
|
if (result === null || result === undefined) break;
|
|
@@ -1235,6 +1146,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1235
1146
|
var mmapAlloc = (size) => {
|
|
1236
1147
|
abort('internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported');
|
|
1237
1148
|
};
|
|
1149
|
+
|
|
1238
1150
|
var MEMFS = {
|
|
1239
1151
|
ops_table:null,
|
|
1240
1152
|
mount(mount) {
|
|
@@ -1299,11 +1211,14 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1299
1211
|
} else if (FS.isFile(node.mode)) {
|
|
1300
1212
|
node.node_ops = MEMFS.ops_table.file.node;
|
|
1301
1213
|
node.stream_ops = MEMFS.ops_table.file.stream;
|
|
1302
|
-
|
|
1303
|
-
//
|
|
1304
|
-
|
|
1305
|
-
//
|
|
1306
|
-
|
|
1214
|
+
// The actual number of bytes used in the typed array, as opposed to
|
|
1215
|
+
// contents.length which gives the whole capacity.
|
|
1216
|
+
node.usedBytes = 0;
|
|
1217
|
+
// The byte data of the file is stored in a typed array.
|
|
1218
|
+
// Note: typed arrays are not resizable like normal JS arrays are, so
|
|
1219
|
+
// there is a small penalty involved for appending file writes that
|
|
1220
|
+
// continuously grow a file similar to std::vector capacity vs used.
|
|
1221
|
+
node.contents = MEMFS.emptyFileContents ??= new Uint8Array(0);
|
|
1307
1222
|
} else if (FS.isLink(node.mode)) {
|
|
1308
1223
|
node.node_ops = MEMFS.ops_table.link.node;
|
|
1309
1224
|
node.stream_ops = MEMFS.ops_table.link.stream;
|
|
@@ -1320,36 +1235,30 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1320
1235
|
return node;
|
|
1321
1236
|
},
|
|
1322
1237
|
getFileDataAsTypedArray(node) {
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
return new Uint8Array(node.contents);
|
|
1238
|
+
assert(FS.isFile(node.mode), 'getFileDataAsTypedArray called on non-file');
|
|
1239
|
+
return node.contents.subarray(0, node.usedBytes); // Make sure to not return excess unused bytes.
|
|
1326
1240
|
},
|
|
1327
1241
|
expandFileStorage(node, newCapacity) {
|
|
1328
|
-
var prevCapacity = node.contents
|
|
1242
|
+
var prevCapacity = node.contents.length;
|
|
1329
1243
|
if (prevCapacity >= newCapacity) return; // No need to expand, the storage was already large enough.
|
|
1330
|
-
// Don't expand strictly to the given requested limit if it's only a very
|
|
1331
|
-
//
|
|
1332
|
-
//
|
|
1244
|
+
// Don't expand strictly to the given requested limit if it's only a very
|
|
1245
|
+
// small increase, but instead geometrically grow capacity.
|
|
1246
|
+
// For small filesizes (<1MB), perform size*2 geometric increase, but for
|
|
1247
|
+
// large sizes, do a much more conservative size*1.125 increase to avoid
|
|
1248
|
+
// overshooting the allocation cap by a very large margin.
|
|
1333
1249
|
var CAPACITY_DOUBLING_MAX = 1024 * 1024;
|
|
1334
1250
|
newCapacity = Math.max(newCapacity, (prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2.0 : 1.125)) >>> 0);
|
|
1335
|
-
if (prevCapacity
|
|
1336
|
-
var oldContents = node
|
|
1251
|
+
if (prevCapacity) newCapacity = Math.max(newCapacity, 256); // At minimum allocate 256b for each file when expanding.
|
|
1252
|
+
var oldContents = MEMFS.getFileDataAsTypedArray(node);
|
|
1337
1253
|
node.contents = new Uint8Array(newCapacity); // Allocate new storage.
|
|
1338
|
-
|
|
1254
|
+
node.contents.set(oldContents);
|
|
1339
1255
|
},
|
|
1340
1256
|
resizeFileStorage(node, newSize) {
|
|
1341
1257
|
if (node.usedBytes == newSize) return;
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
var oldContents = node.contents;
|
|
1347
|
-
node.contents = new Uint8Array(newSize); // Allocate new storage.
|
|
1348
|
-
if (oldContents) {
|
|
1349
|
-
node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes))); // Copy old data over to the new storage.
|
|
1350
|
-
}
|
|
1351
|
-
node.usedBytes = newSize;
|
|
1352
|
-
}
|
|
1258
|
+
var oldContents = node.contents;
|
|
1259
|
+
node.contents = new Uint8Array(newSize); // Allocate new storage.
|
|
1260
|
+
node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes))); // Copy old data over to the new storage.
|
|
1261
|
+
node.usedBytes = newSize;
|
|
1353
1262
|
},
|
|
1354
1263
|
node_ops:{
|
|
1355
1264
|
getattr(node) {
|
|
@@ -1381,7 +1290,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1381
1290
|
return attr;
|
|
1382
1291
|
},
|
|
1383
1292
|
setattr(node, attr) {
|
|
1384
|
-
for (const key of [
|
|
1293
|
+
for (const key of ['mode', 'atime', 'mtime', 'ctime']) {
|
|
1385
1294
|
if (attr[key] != null) {
|
|
1386
1295
|
node[key] = attr[key];
|
|
1387
1296
|
}
|
|
@@ -1449,16 +1358,11 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1449
1358
|
if (position >= stream.node.usedBytes) return 0;
|
|
1450
1359
|
var size = Math.min(stream.node.usedBytes - position, length);
|
|
1451
1360
|
assert(size >= 0);
|
|
1452
|
-
|
|
1453
|
-
buffer.set(contents.subarray(position, position + size), offset);
|
|
1454
|
-
} else {
|
|
1455
|
-
for (var i = 0; i < size; i++) buffer[offset + i] = contents[position + i];
|
|
1456
|
-
}
|
|
1361
|
+
buffer.set(contents.subarray(position, position + size), offset);
|
|
1457
1362
|
return size;
|
|
1458
1363
|
},
|
|
1459
1364
|
write(stream, buffer, offset, length, position, canOwn) {
|
|
1460
|
-
|
|
1461
|
-
assert(!(buffer instanceof ArrayBuffer));
|
|
1365
|
+
assert(buffer.subarray, 'FS.write expects a TypedArray');
|
|
1462
1366
|
// If the buffer is located in main memory (HEAP), and if
|
|
1463
1367
|
// memory can grow, we can't hold on to references of the
|
|
1464
1368
|
// memory buffer, as they may get invalidated. That means we
|
|
@@ -1471,33 +1375,19 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1471
1375
|
var node = stream.node;
|
|
1472
1376
|
node.mtime = node.ctime = Date.now();
|
|
1473
1377
|
|
|
1474
|
-
if (
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
return length;
|
|
1484
|
-
} else if (position + length <= node.usedBytes) { // Writing to an already allocated and used subrange of the file?
|
|
1485
|
-
node.contents.set(buffer.subarray(offset, offset + length), position);
|
|
1486
|
-
return length;
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
// Appending to an existing file and we need to reallocate, or source data did not come as a typed array.
|
|
1491
|
-
MEMFS.expandFileStorage(node, position+length);
|
|
1492
|
-
if (node.contents.subarray && buffer.subarray) {
|
|
1378
|
+
if (canOwn) {
|
|
1379
|
+
assert(!position, 'canOwn must imply no weird position inside the file');
|
|
1380
|
+
node.contents = buffer.subarray(offset, offset + length);
|
|
1381
|
+
node.usedBytes = length;
|
|
1382
|
+
} else if (!node.usedBytes && !position) { // If this is a simple first write to an empty file, do a fast set since we don't need to care about old data.
|
|
1383
|
+
node.contents = buffer.slice(offset, offset + length);
|
|
1384
|
+
node.usedBytes = length;
|
|
1385
|
+
} else {
|
|
1386
|
+
MEMFS.expandFileStorage(node, position+length);
|
|
1493
1387
|
// Use typed array write which is available.
|
|
1494
1388
|
node.contents.set(buffer.subarray(offset, offset + length), position);
|
|
1495
|
-
|
|
1496
|
-
for (var i = 0; i < length; i++) {
|
|
1497
|
-
node.contents[position + i] = buffer[offset + i]; // Or fall back to manual write if not.
|
|
1498
|
-
}
|
|
1389
|
+
node.usedBytes = Math.max(node.usedBytes, position + length);
|
|
1499
1390
|
}
|
|
1500
|
-
node.usedBytes = Math.max(node.usedBytes, position + length);
|
|
1501
1391
|
return length;
|
|
1502
1392
|
},
|
|
1503
1393
|
llseek(stream, offset, whence) {
|
|
@@ -1522,7 +1412,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1522
1412
|
var allocated;
|
|
1523
1413
|
var contents = stream.node.contents;
|
|
1524
1414
|
// Only make a new copy when MAP_PRIVATE is specified.
|
|
1525
|
-
if (!(flags & 2) && contents
|
|
1415
|
+
if (!(flags & 2) && contents.buffer === HEAP8.buffer) {
|
|
1526
1416
|
// We can't emulate MAP_SHARED when the file is not backed by the
|
|
1527
1417
|
// buffer we're mapping to (e.g. the HEAP buffer).
|
|
1528
1418
|
allocated = false;
|
|
@@ -1556,6 +1446,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1556
1446
|
};
|
|
1557
1447
|
|
|
1558
1448
|
var FS_modeStringToFlags = (str) => {
|
|
1449
|
+
if (typeof str != 'string') return str;
|
|
1559
1450
|
var flagModes = {
|
|
1560
1451
|
'r': 0,
|
|
1561
1452
|
'r+': 2,
|
|
@@ -1571,6 +1462,16 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1571
1462
|
return flags;
|
|
1572
1463
|
};
|
|
1573
1464
|
|
|
1465
|
+
var FS_fileDataToTypedArray = (data) => {
|
|
1466
|
+
if (typeof data == 'string') {
|
|
1467
|
+
data = intArrayFromString(data, true);
|
|
1468
|
+
}
|
|
1469
|
+
if (!data.subarray) {
|
|
1470
|
+
data = new Uint8Array(data);
|
|
1471
|
+
}
|
|
1472
|
+
return data;
|
|
1473
|
+
};
|
|
1474
|
+
|
|
1574
1475
|
var FS_getMode = (canRead, canWrite) => {
|
|
1575
1476
|
var mode = 0;
|
|
1576
1477
|
if (canRead) mode |= 292 | 73;
|
|
@@ -1593,10 +1494,14 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1593
1494
|
queuePersist:(mount) => {
|
|
1594
1495
|
function onPersistComplete() {
|
|
1595
1496
|
if (mount.idbPersistState === 'again') startPersist(); // If a new sync request has appeared in between, kick off a new sync
|
|
1596
|
-
else
|
|
1497
|
+
else {
|
|
1498
|
+
mount.idbPersistState = 0; // Otherwise reset sync state back to idle to wait for a new sync later
|
|
1499
|
+
IDBFS.onAutoPersistStateChanged?.(false);
|
|
1500
|
+
}
|
|
1597
1501
|
}
|
|
1598
1502
|
function startPersist() {
|
|
1599
1503
|
mount.idbPersistState = 'idb'; // Mark that we are currently running a sync operation
|
|
1504
|
+
IDBFS.onAutoPersistStateChanged?.(true);
|
|
1600
1505
|
IDBFS.syncfs(mount, /*populate:*/false, onPersistComplete);
|
|
1601
1506
|
}
|
|
1602
1507
|
|
|
@@ -1699,7 +1604,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1699
1604
|
return callback(e);
|
|
1700
1605
|
}
|
|
1701
1606
|
if (!req) {
|
|
1702
|
-
return callback(
|
|
1607
|
+
return callback('Unable to connect to IndexedDB');
|
|
1703
1608
|
}
|
|
1704
1609
|
req.onupgradeneeded = (e) => {
|
|
1705
1610
|
var db = /** @type {IDBDatabase} */ (e.target.result);
|
|
@@ -1746,7 +1651,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1746
1651
|
var stat;
|
|
1747
1652
|
|
|
1748
1653
|
try {
|
|
1749
|
-
stat = FS.
|
|
1654
|
+
stat = FS.lstat(path);
|
|
1750
1655
|
} catch (e) {
|
|
1751
1656
|
return callback(e);
|
|
1752
1657
|
}
|
|
@@ -1798,13 +1703,15 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1798
1703
|
try {
|
|
1799
1704
|
var lookup = FS.lookupPath(path);
|
|
1800
1705
|
node = lookup.node;
|
|
1801
|
-
stat = FS.
|
|
1706
|
+
stat = FS.lstat(path);
|
|
1802
1707
|
} catch (e) {
|
|
1803
1708
|
return callback(e);
|
|
1804
1709
|
}
|
|
1805
1710
|
|
|
1806
1711
|
if (FS.isDir(stat.mode)) {
|
|
1807
1712
|
return callback(null, { 'timestamp': stat.mtime, 'mode': stat.mode });
|
|
1713
|
+
} else if (FS.isLink(stat.mode)) {
|
|
1714
|
+
return callback(null, { 'timestamp': stat.mtime, 'mode': stat.mode, 'link': node.link, });
|
|
1808
1715
|
} else if (FS.isFile(stat.mode)) {
|
|
1809
1716
|
// Performance consideration: storing a normal JavaScript array to a IndexedDB is much slower than storing a typed array.
|
|
1810
1717
|
// Therefore always convert the file contents to a typed array first before writing the data to IndexedDB.
|
|
@@ -1818,6 +1725,8 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1818
1725
|
try {
|
|
1819
1726
|
if (FS.isDir(entry['mode'])) {
|
|
1820
1727
|
FS.mkdirTree(path, entry['mode']);
|
|
1728
|
+
} else if (FS.isLink(entry['mode'])) {
|
|
1729
|
+
FS.symlink(entry['link'], path);
|
|
1821
1730
|
} else if (FS.isFile(entry['mode'])) {
|
|
1822
1731
|
FS.writeFile(path, entry['contents'], { canOwn: true });
|
|
1823
1732
|
} else {
|
|
@@ -1834,11 +1743,11 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1834
1743
|
},
|
|
1835
1744
|
removeLocalEntry:(path, callback) => {
|
|
1836
1745
|
try {
|
|
1837
|
-
var stat = FS.
|
|
1746
|
+
var stat = FS.lstat(path);
|
|
1838
1747
|
|
|
1839
1748
|
if (FS.isDir(stat.mode)) {
|
|
1840
1749
|
FS.rmdir(path);
|
|
1841
|
-
} else
|
|
1750
|
+
} else {
|
|
1842
1751
|
FS.unlink(path);
|
|
1843
1752
|
}
|
|
1844
1753
|
} catch (e) {
|
|
@@ -1954,6 +1863,9 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
1954
1863
|
|
|
1955
1864
|
|
|
1956
1865
|
|
|
1866
|
+
/** @type {!Uint8Array} */
|
|
1867
|
+
var HEAPU8;
|
|
1868
|
+
|
|
1957
1869
|
/**
|
|
1958
1870
|
* Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
|
|
1959
1871
|
* emscripten HEAP, returns a copy of that string as a Javascript String object.
|
|
@@ -2115,10 +2027,12 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
2115
2027
|
}
|
|
2116
2028
|
};
|
|
2117
2029
|
|
|
2030
|
+
var dependenciesPromise = null;
|
|
2031
|
+
var resolveRunDependencies = async () => dependenciesPromise;
|
|
2118
2032
|
var runDependencies = 0;
|
|
2119
2033
|
|
|
2120
2034
|
|
|
2121
|
-
var
|
|
2035
|
+
var dependenciesPromiseResolve = null;
|
|
2122
2036
|
|
|
2123
2037
|
var runDependencyTracking = {
|
|
2124
2038
|
};
|
|
@@ -2132,21 +2046,22 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
2132
2046
|
assert(id, 'removeRunDependency requires an ID');
|
|
2133
2047
|
assert(runDependencyTracking[id]);
|
|
2134
2048
|
delete runDependencyTracking[id];
|
|
2135
|
-
if (runDependencies
|
|
2049
|
+
if (!runDependencies) {
|
|
2136
2050
|
if (runDependencyWatcher !== null) {
|
|
2137
2051
|
clearInterval(runDependencyWatcher);
|
|
2138
2052
|
runDependencyWatcher = null;
|
|
2139
2053
|
}
|
|
2140
|
-
|
|
2141
|
-
var callback = dependenciesFulfilled;
|
|
2142
|
-
dependenciesFulfilled = null;
|
|
2143
|
-
callback(); // can add another dependenciesFulfilled
|
|
2144
|
-
}
|
|
2054
|
+
dependenciesPromiseResolve();
|
|
2145
2055
|
}
|
|
2146
2056
|
};
|
|
2147
2057
|
|
|
2148
2058
|
|
|
2059
|
+
|
|
2060
|
+
|
|
2149
2061
|
var addRunDependency = (id) => {
|
|
2062
|
+
if (!runDependencies) {
|
|
2063
|
+
dependenciesPromise = new Promise((resolve) => dependenciesPromiseResolve = resolve);
|
|
2064
|
+
}
|
|
2150
2065
|
runDependencies++;
|
|
2151
2066
|
|
|
2152
2067
|
Module['monitorRunDependencies']?.(runDependencies);
|
|
@@ -2154,7 +2069,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
2154
2069
|
assert(id, 'addRunDependency requires an ID')
|
|
2155
2070
|
assert(!runDependencyTracking[id]);
|
|
2156
2071
|
runDependencyTracking[id] = 1;
|
|
2157
|
-
if (runDependencyWatcher
|
|
2072
|
+
if (!runDependencyWatcher && globalThis.setInterval) {
|
|
2158
2073
|
// Check for missing dependencies every few seconds
|
|
2159
2074
|
runDependencyWatcher = setInterval(() => {
|
|
2160
2075
|
if (ABORT) {
|
|
@@ -2218,6 +2133,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
2218
2133
|
var FS_createPreloadedFile = (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) => {
|
|
2219
2134
|
FS_preloadFile(parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish).then(onload).catch(onerror);
|
|
2220
2135
|
};
|
|
2136
|
+
|
|
2221
2137
|
var FS = {
|
|
2222
2138
|
root:null,
|
|
2223
2139
|
mounts:[],
|
|
@@ -2316,6 +2232,48 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
2316
2232
|
get isDevice() {
|
|
2317
2233
|
return FS.isChrdev(this.mode);
|
|
2318
2234
|
}
|
|
2235
|
+
// The per-inode readiness wait-queue. The node carries a Set of listener
|
|
2236
|
+
// entries {cb}; producers (SOCKFS, PIPEFS) call notifyListeners on a
|
|
2237
|
+
// readiness transition, and poll()/epoll consume it. It lives on the node
|
|
2238
|
+
// (not the fd) so dup'd fds share one queue. Only nodes that derive real
|
|
2239
|
+
// readiness (sockets, pipes, and an epoll's own node) ever use this -
|
|
2240
|
+
// always-ready types (regular files, ttys) never register or notify.
|
|
2241
|
+
addListener(cb, exclusive = false) {
|
|
2242
|
+
var entry = {cb, exclusive};
|
|
2243
|
+
var listeners = (this.listeners ??= new Set());
|
|
2244
|
+
listeners.add(entry);
|
|
2245
|
+
return {listeners, entry};
|
|
2246
|
+
}
|
|
2247
|
+
notifyListeners(flags) {
|
|
2248
|
+
// Iterates the set without copying, which is safe ONLY under a
|
|
2249
|
+
// load-bearing contract that every internal listener must honour:
|
|
2250
|
+
// 1. A listener must not run user code synchronously (a poll waiter only
|
|
2251
|
+
// resolves a Promise; an epoll registration only re-lists +
|
|
2252
|
+
// re-notifies; the epoll callback only schedules a tick). User code
|
|
2253
|
+
// runs on a later tick, never inside this loop.
|
|
2254
|
+
// 2. A listener may delete entries only from ITS OWN waiter, never from
|
|
2255
|
+
// a sibling node's set that may be mid-iteration. (Deleting an entry
|
|
2256
|
+
// of the set being iterated here is fine - a Set tolerates removal of
|
|
2257
|
+
// a not-yet-visited entry mid-iteration; mutating a *different* node's
|
|
2258
|
+
// set is fine because that set is not being iterated.)
|
|
2259
|
+
// Violating either gives silently skipped wakeups that are near-impossible
|
|
2260
|
+
// to reproduce. Any new producer/listener must preserve it.
|
|
2261
|
+
if (!this.listeners) return;
|
|
2262
|
+
// Fire every non-exclusive listener. Among EPOLLEXCLUSIVE registrations
|
|
2263
|
+
// (one fd watched by several epolls) wake only one, rotating round-robin
|
|
2264
|
+
// per node, to avoid a thundering herd. (Only epoll registrations are ever
|
|
2265
|
+
// exclusive; poll waiters and a node's own consumers are not.)
|
|
2266
|
+
var excl;
|
|
2267
|
+
for (var entry of this.listeners) {
|
|
2268
|
+
if (entry.exclusive) (excl ||= []).push(entry);
|
|
2269
|
+
else entry.cb(flags);
|
|
2270
|
+
}
|
|
2271
|
+
if (excl) {
|
|
2272
|
+
var i = (this.exclTurn || 0) % excl.length;
|
|
2273
|
+
this.exclTurn = i + 1;
|
|
2274
|
+
excl[i].cb(flags);
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2319
2277
|
},
|
|
2320
2278
|
lookupPath(path, opts = {}) {
|
|
2321
2279
|
if (!path) {
|
|
@@ -2327,7 +2285,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
2327
2285
|
path = FS.cwd() + '/' + path;
|
|
2328
2286
|
}
|
|
2329
2287
|
|
|
2330
|
-
// limit max consecutive symlinks to
|
|
2288
|
+
// limit max consecutive symlinks to SYMLOOP_MAX.
|
|
2331
2289
|
linkloop: for (var nlinks = 0; nlinks < 40; nlinks++) {
|
|
2332
2290
|
// split the absolute path
|
|
2333
2291
|
var parts = path.split('/').filter((p) => !!p);
|
|
@@ -2619,7 +2577,14 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
2619
2577
|
var arg = setattr ? stream : node;
|
|
2620
2578
|
setattr ??= node.node_ops.setattr;
|
|
2621
2579
|
FS.checkOpExists(setattr, 63)
|
|
2622
|
-
|
|
2580
|
+
try {
|
|
2581
|
+
setattr(arg, attr);
|
|
2582
|
+
} catch (e) {
|
|
2583
|
+
if (e instanceof RangeError) {
|
|
2584
|
+
throw new FS.ErrnoError(22);
|
|
2585
|
+
}
|
|
2586
|
+
throw e;
|
|
2587
|
+
}
|
|
2623
2588
|
},
|
|
2624
2589
|
chrdev_stream_ops:{
|
|
2625
2590
|
open(stream) {
|
|
@@ -2886,6 +2851,25 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
2886
2851
|
}
|
|
2887
2852
|
return parent.node_ops.symlink(parent, newname, oldpath);
|
|
2888
2853
|
},
|
|
2854
|
+
link(oldpath, newpath, flags) {
|
|
2855
|
+
var lookup = FS.lookupPath(newpath, { parent: true });
|
|
2856
|
+
var parent = lookup.node;
|
|
2857
|
+
if (!parent) {
|
|
2858
|
+
throw new FS.ErrnoError(44);
|
|
2859
|
+
}
|
|
2860
|
+
var newname = PATH.basename(newpath);
|
|
2861
|
+
var errCode = FS.mayCreate(parent, newname);
|
|
2862
|
+
if (errCode) {
|
|
2863
|
+
throw new FS.ErrnoError(errCode);
|
|
2864
|
+
}
|
|
2865
|
+
// Hardlinks are only supported by filesystem backends that provide a
|
|
2866
|
+
// `link` node op (e.g. NODERAWFS backed by the host). NODEFS omits it:
|
|
2867
|
+
// a host hardlink cannot be confined to the mount root.
|
|
2868
|
+
if (!parent.node_ops.link) {
|
|
2869
|
+
throw new FS.ErrnoError(34);
|
|
2870
|
+
}
|
|
2871
|
+
return parent.node_ops.link(parent, newname, oldpath, flags);
|
|
2872
|
+
},
|
|
2889
2873
|
rename(old_path, new_path) {
|
|
2890
2874
|
var old_dirname = PATH.dirname(old_path);
|
|
2891
2875
|
var new_dirname = PATH.dirname(new_path);
|
|
@@ -3132,20 +3116,19 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3132
3116
|
}
|
|
3133
3117
|
FS.doTruncate(stream, stream.node, len);
|
|
3134
3118
|
},
|
|
3135
|
-
utime(path, atime, mtime) {
|
|
3136
|
-
var lookup = FS.lookupPath(path, { follow:
|
|
3137
|
-
|
|
3138
|
-
var setattr = FS.checkOpExists(node.node_ops.setattr, 63);
|
|
3139
|
-
setattr(node, {
|
|
3119
|
+
utime(path, atime, mtime, dontFollow) {
|
|
3120
|
+
var lookup = FS.lookupPath(path, { follow: !dontFollow });
|
|
3121
|
+
FS.doSetAttr(null, lookup.node, {
|
|
3140
3122
|
atime: atime,
|
|
3141
|
-
mtime: mtime
|
|
3123
|
+
mtime: mtime,
|
|
3124
|
+
dontFollow
|
|
3142
3125
|
});
|
|
3143
3126
|
},
|
|
3144
3127
|
open(path, flags, mode = 0o666) {
|
|
3145
|
-
if (path ===
|
|
3128
|
+
if (path === '') {
|
|
3146
3129
|
throw new FS.ErrnoError(44);
|
|
3147
3130
|
}
|
|
3148
|
-
flags =
|
|
3131
|
+
flags = FS_modeStringToFlags(flags);
|
|
3149
3132
|
if ((flags & 64)) {
|
|
3150
3133
|
mode = (mode & 4095) | 32768;
|
|
3151
3134
|
} else {
|
|
@@ -3156,7 +3139,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3156
3139
|
if (typeof path == 'object') {
|
|
3157
3140
|
node = path;
|
|
3158
3141
|
} else {
|
|
3159
|
-
isDirPath = path.endsWith(
|
|
3142
|
+
isDirPath = path.endsWith('/');
|
|
3160
3143
|
// noent_okay makes it so that if the final component of the path
|
|
3161
3144
|
// doesn't exist, lookupPath returns `node: undefined`. `path` will be
|
|
3162
3145
|
// updated to point to the target of all symlinks.
|
|
@@ -3239,6 +3222,11 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3239
3222
|
throw new FS.ErrnoError(8);
|
|
3240
3223
|
}
|
|
3241
3224
|
if (stream.getdents) stream.getdents = null; // free readdir state
|
|
3225
|
+
// The fd is going away: wake anything waiting on it (poll/epoll) with
|
|
3226
|
+
// POLLNVAL so a blocking wait unblocks and an epoll registration is evicted
|
|
3227
|
+
// on its next derive. Only sockets/pipes/epoll ever carry a wait-queue, so
|
|
3228
|
+
// for every other stream (incl. nodeless noderawfs stdio) this is a no-op.
|
|
3229
|
+
stream.node?.notifyListeners(32);
|
|
3242
3230
|
try {
|
|
3243
3231
|
if (stream.stream_ops.close) {
|
|
3244
3232
|
stream.stream_ops.close(stream);
|
|
@@ -3296,6 +3284,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3296
3284
|
},
|
|
3297
3285
|
write(stream, buffer, offset, length, position, canOwn) {
|
|
3298
3286
|
assert(offset >= 0);
|
|
3287
|
+
assert(buffer.subarray, 'FS.write expects a TypedArray');
|
|
3299
3288
|
if (length < 0 || position < 0) {
|
|
3300
3289
|
throw new FS.ErrnoError(28);
|
|
3301
3290
|
}
|
|
@@ -3332,8 +3321,8 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3332
3321
|
// to write to file opened in read-only mode with MAP_PRIVATE flag,
|
|
3333
3322
|
// as all modifications will be visible only in the memory of
|
|
3334
3323
|
// the current process.
|
|
3335
|
-
if ((prot & 2)
|
|
3336
|
-
&& (flags & 2)
|
|
3324
|
+
if ((prot & 2)
|
|
3325
|
+
&& !(flags & 2)
|
|
3337
3326
|
&& (stream.flags & 2097155) !== 2) {
|
|
3338
3327
|
throw new FS.ErrnoError(2);
|
|
3339
3328
|
}
|
|
@@ -3362,8 +3351,8 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3362
3351
|
return stream.stream_ops.ioctl(stream, cmd, arg);
|
|
3363
3352
|
},
|
|
3364
3353
|
readFile(path, opts = {}) {
|
|
3365
|
-
opts.flags = opts.flags
|
|
3366
|
-
opts.encoding = opts.encoding
|
|
3354
|
+
opts.flags = opts.flags ?? 0;
|
|
3355
|
+
opts.encoding = opts.encoding ?? 'binary';
|
|
3367
3356
|
if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
|
|
3368
3357
|
abort(`Invalid encoding type "${opts.encoding}"`);
|
|
3369
3358
|
}
|
|
@@ -3379,16 +3368,10 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3379
3368
|
return buf;
|
|
3380
3369
|
},
|
|
3381
3370
|
writeFile(path, data, opts = {}) {
|
|
3382
|
-
opts.flags = opts.flags
|
|
3371
|
+
opts.flags = opts.flags ?? 577;
|
|
3383
3372
|
var stream = FS.open(path, opts.flags, opts.mode);
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
}
|
|
3387
|
-
if (ArrayBuffer.isView(data)) {
|
|
3388
|
-
FS.write(stream, data, 0, data.byteLength, undefined, opts.canOwn);
|
|
3389
|
-
} else {
|
|
3390
|
-
abort('Unsupported data type');
|
|
3391
|
-
}
|
|
3373
|
+
data = FS_fileDataToTypedArray(data);
|
|
3374
|
+
FS.write(stream, data, 0, data.byteLength, undefined, opts.canOwn);
|
|
3392
3375
|
FS.close(stream);
|
|
3393
3376
|
},
|
|
3394
3377
|
cwd:() => FS.currentPath,
|
|
@@ -3432,7 +3415,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3432
3415
|
// use a buffer to avoid overhead of individual crypto calls per byte
|
|
3433
3416
|
var randomBuffer = new Uint8Array(1024), randomLeft = 0;
|
|
3434
3417
|
var randomByte = () => {
|
|
3435
|
-
if (randomLeft
|
|
3418
|
+
if (!randomLeft) {
|
|
3436
3419
|
randomFill(randomBuffer);
|
|
3437
3420
|
randomLeft = randomBuffer.byteLength;
|
|
3438
3421
|
}
|
|
@@ -3614,11 +3597,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3614
3597
|
var mode = FS_getMode(canRead, canWrite);
|
|
3615
3598
|
var node = FS.create(path, mode);
|
|
3616
3599
|
if (data) {
|
|
3617
|
-
|
|
3618
|
-
var arr = new Array(data.length);
|
|
3619
|
-
for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
|
|
3620
|
-
data = arr;
|
|
3621
|
-
}
|
|
3600
|
+
data = FS_fileDataToTypedArray(data);
|
|
3622
3601
|
// make sure we can write to the file
|
|
3623
3602
|
FS.chmod(node, mode | 146);
|
|
3624
3603
|
var stream = FS.open(node, 577);
|
|
@@ -3653,7 +3632,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3653
3632
|
} catch (e) {
|
|
3654
3633
|
throw new FS.ErrnoError(29);
|
|
3655
3634
|
}
|
|
3656
|
-
if (result === undefined && bytesRead
|
|
3635
|
+
if (result === undefined && !bytesRead) {
|
|
3657
3636
|
throw new FS.ErrnoError(6);
|
|
3658
3637
|
}
|
|
3659
3638
|
if (result === null || result === undefined) break;
|
|
@@ -3684,7 +3663,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3684
3663
|
forceLoadFile(obj) {
|
|
3685
3664
|
if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
|
|
3686
3665
|
if (globalThis.XMLHttpRequest) {
|
|
3687
|
-
abort(
|
|
3666
|
+
abort('Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.');
|
|
3688
3667
|
} else { // Command-line.
|
|
3689
3668
|
try {
|
|
3690
3669
|
obj.contents = readBinary(obj.url);
|
|
@@ -3715,11 +3694,11 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3715
3694
|
var xhr = new XMLHttpRequest();
|
|
3716
3695
|
xhr.open('HEAD', url, false);
|
|
3717
3696
|
xhr.send(null);
|
|
3718
|
-
if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) abort(
|
|
3719
|
-
var datalength = Number(xhr.getResponseHeader(
|
|
3697
|
+
if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) abort(`Couldn't load ${url}. Status: ${xhr.status}`);
|
|
3698
|
+
var datalength = Number(xhr.getResponseHeader('Content-length'));
|
|
3720
3699
|
var header;
|
|
3721
|
-
var hasByteServing = (header = xhr.getResponseHeader(
|
|
3722
|
-
var usesGzip = (header = xhr.getResponseHeader(
|
|
3700
|
+
var hasByteServing = (header = xhr.getResponseHeader('Accept-Ranges')) && header === 'bytes';
|
|
3701
|
+
var usesGzip = (header = xhr.getResponseHeader('Content-Encoding')) && header === 'gzip';
|
|
3723
3702
|
|
|
3724
3703
|
var chunkSize = 1024*1024; // Chunk size in bytes
|
|
3725
3704
|
|
|
@@ -3727,13 +3706,13 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3727
3706
|
|
|
3728
3707
|
// Function to get a range from the remote URL.
|
|
3729
3708
|
var doXHR = (from, to) => {
|
|
3730
|
-
if (from > to) abort(
|
|
3731
|
-
if (to > datalength-1) abort(
|
|
3709
|
+
if (from > to) abort(`invalid range (${from}, ${to}) or no bytes requested!`);
|
|
3710
|
+
if (to > datalength-1) abort(`only ${datalength} bytes available! programmer error!`);
|
|
3732
3711
|
|
|
3733
3712
|
// TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
|
|
3734
3713
|
var xhr = new XMLHttpRequest();
|
|
3735
3714
|
xhr.open('GET', url, false);
|
|
3736
|
-
if (datalength !== chunkSize) xhr.setRequestHeader(
|
|
3715
|
+
if (datalength !== chunkSize) xhr.setRequestHeader('Range', `bytes=${from}-${to}`);
|
|
3737
3716
|
|
|
3738
3717
|
// Some hints to the browser that we want binary data.
|
|
3739
3718
|
xhr.responseType = 'arraybuffer';
|
|
@@ -3742,11 +3721,11 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3742
3721
|
}
|
|
3743
3722
|
|
|
3744
3723
|
xhr.send(null);
|
|
3745
|
-
if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) abort(
|
|
3724
|
+
if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) abort(`Couldn't load ${url}. Status: ${xhr.status}`);
|
|
3746
3725
|
if (xhr.response !== undefined) {
|
|
3747
3726
|
return new Uint8Array(/** @type{Array<number>} */(xhr.response || []));
|
|
3748
3727
|
}
|
|
3749
|
-
return intArrayFromString(xhr.responseText
|
|
3728
|
+
return intArrayFromString(xhr.responseText ?? '', true);
|
|
3750
3729
|
};
|
|
3751
3730
|
var lazyArray = this;
|
|
3752
3731
|
lazyArray.setDataGetter((chunkNum) => {
|
|
@@ -3765,7 +3744,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3765
3744
|
chunkSize = datalength = 1; // this will force getter(0)/doXHR do download the whole file
|
|
3766
3745
|
datalength = this.getter(0).length;
|
|
3767
3746
|
chunkSize = datalength;
|
|
3768
|
-
out(
|
|
3747
|
+
out('LazyFiles on gzip forces download of the whole file when length is accessed');
|
|
3769
3748
|
}
|
|
3770
3749
|
|
|
3771
3750
|
this._length = datalength;
|
|
@@ -3853,27 +3832,16 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3853
3832
|
node.stream_ops = stream_ops;
|
|
3854
3833
|
return node;
|
|
3855
3834
|
},
|
|
3856
|
-
absolutePath() {
|
|
3857
|
-
abort('FS.absolutePath has been removed; use PATH_FS.resolve instead');
|
|
3858
|
-
},
|
|
3859
|
-
createFolder() {
|
|
3860
|
-
abort('FS.createFolder has been removed; use FS.mkdir instead');
|
|
3861
|
-
},
|
|
3862
|
-
createLink() {
|
|
3863
|
-
abort('FS.createLink has been removed; use FS.symlink instead');
|
|
3864
|
-
},
|
|
3865
|
-
joinPath() {
|
|
3866
|
-
abort('FS.joinPath has been removed; use PATH.join instead');
|
|
3867
|
-
},
|
|
3868
|
-
mmapAlloc() {
|
|
3869
|
-
abort('FS.mmapAlloc has been replaced by the top level function mmapAlloc');
|
|
3870
|
-
},
|
|
3871
|
-
standardizePath() {
|
|
3872
|
-
abort('FS.standardizePath has been removed; use PATH.normalize instead');
|
|
3873
|
-
},
|
|
3874
3835
|
};
|
|
3875
3836
|
|
|
3837
|
+
|
|
3838
|
+
|
|
3839
|
+
|
|
3840
|
+
|
|
3841
|
+
/** not-@type {!BigInt64Array} */
|
|
3842
|
+
var HEAP64;
|
|
3876
3843
|
var SYSCALLS = {
|
|
3844
|
+
currentUmask:18,
|
|
3877
3845
|
calculateAt(dirfd, path, allowEmpty) {
|
|
3878
3846
|
if (PATH.isAbs(path)) {
|
|
3879
3847
|
return path;
|
|
@@ -3936,7 +3904,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3936
3904
|
// MAP_PRIVATE calls need not to be synced back to underlying fs
|
|
3937
3905
|
return 0;
|
|
3938
3906
|
}
|
|
3939
|
-
var buffer = HEAPU8.
|
|
3907
|
+
var buffer = HEAPU8.subarray(addr, addr + len);
|
|
3940
3908
|
FS.msync(stream, buffer, offset, len, flags);
|
|
3941
3909
|
},
|
|
3942
3910
|
getStreamFromFD(fd) {
|
|
@@ -3949,6 +3917,9 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3949
3917
|
return ret;
|
|
3950
3918
|
},
|
|
3951
3919
|
};
|
|
3920
|
+
|
|
3921
|
+
/** @type {!Int16Array} */
|
|
3922
|
+
var HEAP16;
|
|
3952
3923
|
function ___syscall_fcntl64(fd, cmd, varargs) {
|
|
3953
3924
|
SYSCALLS.varargs = varargs;
|
|
3954
3925
|
try {
|
|
@@ -3974,7 +3945,8 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3974
3945
|
return stream.flags;
|
|
3975
3946
|
case 4: {
|
|
3976
3947
|
var arg = syscallGetVarargI();
|
|
3977
|
-
|
|
3948
|
+
var mask = 289792;
|
|
3949
|
+
stream.flags = (stream.flags & ~mask) | (arg & mask);
|
|
3978
3950
|
return 0;
|
|
3979
3951
|
}
|
|
3980
3952
|
case 12: {
|
|
@@ -3998,6 +3970,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
3998
3970
|
return -e.errno;
|
|
3999
3971
|
}
|
|
4000
3972
|
}
|
|
3973
|
+
|
|
4001
3974
|
|
|
4002
3975
|
function ___syscall_fstat64(fd, buf) {
|
|
4003
3976
|
try {
|
|
@@ -4008,6 +3981,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4008
3981
|
return -e.errno;
|
|
4009
3982
|
}
|
|
4010
3983
|
}
|
|
3984
|
+
|
|
4011
3985
|
|
|
4012
3986
|
var INT53_MAX = 9007199254740992;
|
|
4013
3987
|
|
|
@@ -4019,7 +3993,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4019
3993
|
|
|
4020
3994
|
try {
|
|
4021
3995
|
|
|
4022
|
-
if (isNaN(length)) return -
|
|
3996
|
+
if (isNaN(length)) return -22;
|
|
4023
3997
|
FS.ftruncate(fd, length);
|
|
4024
3998
|
return 0;
|
|
4025
3999
|
} catch (e) {
|
|
@@ -4030,14 +4004,15 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4030
4004
|
}
|
|
4031
4005
|
|
|
4032
4006
|
|
|
4007
|
+
|
|
4033
4008
|
var stringToUTF8 = (str, outPtr, maxBytesToWrite) => {
|
|
4034
|
-
assert(typeof maxBytesToWrite == 'number', 'stringToUTF8
|
|
4009
|
+
assert(typeof maxBytesToWrite == 'number', 'stringToUTF8 requires a third parameter that specifies the length of the output buffer');
|
|
4035
4010
|
return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
|
|
4036
4011
|
};
|
|
4037
4012
|
function ___syscall_getcwd(buf, size) {
|
|
4038
4013
|
try {
|
|
4039
4014
|
|
|
4040
|
-
if (size
|
|
4015
|
+
if (!size) return -28;
|
|
4041
4016
|
var cwd = FS.cwd();
|
|
4042
4017
|
var cwdLengthInBytes = lengthBytesUTF8(cwd) + 1;
|
|
4043
4018
|
if (size < cwdLengthInBytes) return -68;
|
|
@@ -4048,8 +4023,12 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4048
4023
|
return -e.errno;
|
|
4049
4024
|
}
|
|
4050
4025
|
}
|
|
4026
|
+
|
|
4051
4027
|
|
|
4052
4028
|
|
|
4029
|
+
|
|
4030
|
+
|
|
4031
|
+
|
|
4053
4032
|
function ___syscall_ioctl(fd, op, varargs) {
|
|
4054
4033
|
SYSCALLS.varargs = varargs;
|
|
4055
4034
|
try {
|
|
@@ -4145,6 +4124,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4145
4124
|
return -e.errno;
|
|
4146
4125
|
}
|
|
4147
4126
|
}
|
|
4127
|
+
|
|
4148
4128
|
|
|
4149
4129
|
function ___syscall_lstat64(path, buf) {
|
|
4150
4130
|
try {
|
|
@@ -4156,12 +4136,14 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4156
4136
|
return -e.errno;
|
|
4157
4137
|
}
|
|
4158
4138
|
}
|
|
4139
|
+
|
|
4159
4140
|
|
|
4160
4141
|
function ___syscall_mkdirat(dirfd, path, mode) {
|
|
4161
4142
|
try {
|
|
4162
4143
|
|
|
4163
4144
|
path = SYSCALLS.getStr(path);
|
|
4164
4145
|
path = SYSCALLS.calculateAt(dirfd, path);
|
|
4146
|
+
mode &= ~SYSCALLS.currentUmask;
|
|
4165
4147
|
FS.mkdir(path, mode, 0);
|
|
4166
4148
|
return 0;
|
|
4167
4149
|
} catch (e) {
|
|
@@ -4169,6 +4151,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4169
4151
|
return -e.errno;
|
|
4170
4152
|
}
|
|
4171
4153
|
}
|
|
4154
|
+
|
|
4172
4155
|
|
|
4173
4156
|
function ___syscall_newfstatat(dirfd, path, buf, flags) {
|
|
4174
4157
|
try {
|
|
@@ -4185,6 +4168,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4185
4168
|
return -e.errno;
|
|
4186
4169
|
}
|
|
4187
4170
|
}
|
|
4171
|
+
|
|
4188
4172
|
|
|
4189
4173
|
|
|
4190
4174
|
function ___syscall_openat(dirfd, path, flags, varargs) {
|
|
@@ -4194,12 +4178,16 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4194
4178
|
path = SYSCALLS.getStr(path);
|
|
4195
4179
|
path = SYSCALLS.calculateAt(dirfd, path);
|
|
4196
4180
|
var mode = varargs ? syscallGetVarargI() : 0;
|
|
4181
|
+
if (flags & 64) {
|
|
4182
|
+
mode &= ~SYSCALLS.currentUmask;
|
|
4183
|
+
}
|
|
4197
4184
|
return FS.open(path, flags, mode).fd;
|
|
4198
4185
|
} catch (e) {
|
|
4199
4186
|
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
4200
4187
|
return -e.errno;
|
|
4201
4188
|
}
|
|
4202
4189
|
}
|
|
4190
|
+
|
|
4203
4191
|
|
|
4204
4192
|
function ___syscall_stat64(path, buf) {
|
|
4205
4193
|
try {
|
|
@@ -4211,6 +4199,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4211
4199
|
return -e.errno;
|
|
4212
4200
|
}
|
|
4213
4201
|
}
|
|
4202
|
+
|
|
4214
4203
|
|
|
4215
4204
|
var __abort_js = () =>
|
|
4216
4205
|
abort('native code called abort()');
|
|
@@ -4222,7 +4211,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4222
4211
|
};
|
|
4223
4212
|
|
|
4224
4213
|
var __emscripten_throw_longjmp = () => {
|
|
4225
|
-
throw
|
|
4214
|
+
throw new EmscriptenSjLj;
|
|
4226
4215
|
};
|
|
4227
4216
|
|
|
4228
4217
|
var _emscripten_get_now = () => performance.now();
|
|
@@ -4233,6 +4222,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4233
4222
|
|
|
4234
4223
|
var checkWasiClock = (clock_id) => clock_id >= 0 && clock_id <= 3;
|
|
4235
4224
|
|
|
4225
|
+
|
|
4236
4226
|
function _clock_time_get(clk_id, ignored_precision, ptime) {
|
|
4237
4227
|
ignored_precision = bigintToI53Checked(ignored_precision);
|
|
4238
4228
|
|
|
@@ -4268,7 +4258,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4268
4258
|
2147483648;
|
|
4269
4259
|
|
|
4270
4260
|
var alignMemory = (size, alignment) => {
|
|
4271
|
-
assert(alignment,
|
|
4261
|
+
assert(alignment, 'alignment argument is required');
|
|
4272
4262
|
return Math.ceil(size / alignment) * alignment;
|
|
4273
4263
|
};
|
|
4274
4264
|
|
|
@@ -4283,9 +4273,10 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4283
4273
|
} catch(e) {
|
|
4284
4274
|
err(`growMemory: Attempted to grow heap from ${oldHeapSize} bytes to ${size} bytes, but got error: ${e}`);
|
|
4285
4275
|
}
|
|
4286
|
-
// implicit 0 return to save code size (caller will cast
|
|
4276
|
+
// implicit 0 return to save code size (caller will cast 'undefined' into 0
|
|
4287
4277
|
// anyhow)
|
|
4288
4278
|
};
|
|
4279
|
+
|
|
4289
4280
|
var _emscripten_resize_heap = (requestedSize) => {
|
|
4290
4281
|
var oldSize = HEAPU8.length;
|
|
4291
4282
|
// With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
|
|
@@ -4372,6 +4363,24 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4372
4363
|
return convertFrameToPC(caller);
|
|
4373
4364
|
};
|
|
4374
4365
|
|
|
4366
|
+
|
|
4367
|
+
|
|
4368
|
+
|
|
4369
|
+
|
|
4370
|
+
/** @type {!Uint16Array} */
|
|
4371
|
+
var HEAPU16;
|
|
4372
|
+
|
|
4373
|
+
|
|
4374
|
+
|
|
4375
|
+
/** @type {!Float32Array} */
|
|
4376
|
+
var HEAPF32;
|
|
4377
|
+
|
|
4378
|
+
/** @type {!Float64Array} */
|
|
4379
|
+
var HEAPF64;
|
|
4380
|
+
|
|
4381
|
+
|
|
4382
|
+
/** not-@type {!BigUint64Array} */
|
|
4383
|
+
var HEAPU64;
|
|
4375
4384
|
var _emscripten_run_script = (ptr) => {
|
|
4376
4385
|
eval(UTF8ToString(ptr));
|
|
4377
4386
|
};
|
|
@@ -4379,11 +4388,10 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4379
4388
|
var ENV = {
|
|
4380
4389
|
};
|
|
4381
4390
|
|
|
4382
|
-
var getExecutableName = () => thisProgram
|
|
4391
|
+
var getExecutableName = () => thisProgram;
|
|
4383
4392
|
var getEnvStrings = () => {
|
|
4384
4393
|
if (!getEnvStrings.strings) {
|
|
4385
4394
|
// Default values.
|
|
4386
|
-
// Browser language detection #8751
|
|
4387
4395
|
var lang = (globalThis.navigator?.language ?? 'C').replace('-', '_') + '.UTF-8';
|
|
4388
4396
|
var env = {
|
|
4389
4397
|
'USER': 'web_user',
|
|
@@ -4411,6 +4419,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4411
4419
|
return getEnvStrings.strings;
|
|
4412
4420
|
};
|
|
4413
4421
|
|
|
4422
|
+
|
|
4414
4423
|
var _environ_get = (__environ, environ_buf) => {
|
|
4415
4424
|
var bufSize = 0;
|
|
4416
4425
|
var envp = 0;
|
|
@@ -4424,6 +4433,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4424
4433
|
};
|
|
4425
4434
|
|
|
4426
4435
|
|
|
4436
|
+
|
|
4427
4437
|
var _environ_sizes_get = (penviron_count, penviron_buf_size) => {
|
|
4428
4438
|
var strings = getEnvStrings();
|
|
4429
4439
|
HEAPU32[((penviron_count)>>2)] = strings.length;
|
|
@@ -4456,7 +4466,6 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4456
4466
|
// if exit() was called explicitly, warn the user if the runtime isn't actually being shut down
|
|
4457
4467
|
if (keepRuntimeAlive() && !implicit) {
|
|
4458
4468
|
var msg = `program exited (with status: ${status}), but keepRuntimeAlive() is set (counter=${runtimeKeepaliveCounter}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;
|
|
4459
|
-
readyPromiseReject?.(msg);
|
|
4460
4469
|
err(msg);
|
|
4461
4470
|
}
|
|
4462
4471
|
|
|
@@ -4475,7 +4484,9 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4475
4484
|
return e.errno;
|
|
4476
4485
|
}
|
|
4477
4486
|
}
|
|
4487
|
+
|
|
4478
4488
|
|
|
4489
|
+
|
|
4479
4490
|
/** @param {number=} offset */
|
|
4480
4491
|
var doReadv = (stream, iov, iovcnt, offset) => {
|
|
4481
4492
|
var ret = 0;
|
|
@@ -4483,7 +4494,18 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4483
4494
|
var ptr = HEAPU32[((iov)>>2)];
|
|
4484
4495
|
var len = HEAPU32[(((iov)+(4))>>2)];
|
|
4485
4496
|
iov += 8;
|
|
4486
|
-
|
|
4497
|
+
try {
|
|
4498
|
+
var curr = FS.read(stream, HEAP8, ptr, len, offset);
|
|
4499
|
+
} catch (e) {
|
|
4500
|
+
// On a non-blocking stream a subsequent read may would-block after we
|
|
4501
|
+
// already gathered data. POSIX readv is a single gather-read: return
|
|
4502
|
+
// what we have rather than failing the whole call.
|
|
4503
|
+
if (ret > 0 && e instanceof FS.ErrnoError &&
|
|
4504
|
+
(e.errno == 6 || e.errno == 6)) {
|
|
4505
|
+
break;
|
|
4506
|
+
}
|
|
4507
|
+
throw e;
|
|
4508
|
+
}
|
|
4487
4509
|
if (curr < 0) return -1;
|
|
4488
4510
|
ret += curr;
|
|
4489
4511
|
if (curr < len) break; // nothing more to read
|
|
@@ -4494,6 +4516,7 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4494
4516
|
return ret;
|
|
4495
4517
|
};
|
|
4496
4518
|
|
|
4519
|
+
|
|
4497
4520
|
function _fd_read(fd, iov, iovcnt, pnum) {
|
|
4498
4521
|
try {
|
|
4499
4522
|
|
|
@@ -4506,19 +4529,21 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4506
4529
|
return e.errno;
|
|
4507
4530
|
}
|
|
4508
4531
|
}
|
|
4532
|
+
|
|
4509
4533
|
|
|
4510
4534
|
|
|
4535
|
+
|
|
4511
4536
|
function _fd_seek(fd, offset, whence, newOffset) {
|
|
4512
4537
|
offset = bigintToI53Checked(offset);
|
|
4513
4538
|
|
|
4514
4539
|
|
|
4515
4540
|
try {
|
|
4516
4541
|
|
|
4517
|
-
if (isNaN(offset)) return
|
|
4542
|
+
if (isNaN(offset)) return 22;
|
|
4518
4543
|
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
4519
4544
|
FS.llseek(stream, offset, whence);
|
|
4520
4545
|
HEAP64[((newOffset)>>3)] = BigInt(stream.position);
|
|
4521
|
-
if (stream.getdents && offset
|
|
4546
|
+
if (stream.getdents && !offset && whence === 0) stream.getdents = null; // reset readdir state
|
|
4522
4547
|
return 0;
|
|
4523
4548
|
} catch (e) {
|
|
4524
4549
|
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
@@ -4527,27 +4552,34 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4527
4552
|
;
|
|
4528
4553
|
}
|
|
4529
4554
|
|
|
4555
|
+
|
|
4556
|
+
|
|
4530
4557
|
/** @param {number=} offset */
|
|
4531
4558
|
var doWritev = (stream, iov, iovcnt, offset) => {
|
|
4532
|
-
|
|
4533
|
-
|
|
4559
|
+
// Gather all iovecs into one contiguous buffer and issue a single
|
|
4560
|
+
// FS.write, matching POSIX writev's single gather-write semantics (as
|
|
4561
|
+
// __syscall_sendmsg already does). Per-iovec writes fragment a stream
|
|
4562
|
+
// socket send into multiple segments, breaking stream byte semantics.
|
|
4563
|
+
if (iovcnt == 1) {
|
|
4564
|
+
// Single iovec: write directly from HEAP8, no gather buffer needed.
|
|
4565
|
+
return FS.write(stream, HEAP8, HEAPU32[((iov)>>2)], HEAPU32[(((iov)+(4))>>2)], offset);
|
|
4566
|
+
}
|
|
4567
|
+
var total = 0;
|
|
4568
|
+
for (var i = 0, p = iov; i < iovcnt; i++, p += 8) {
|
|
4569
|
+
total += HEAPU32[(((p)+(4))>>2)];
|
|
4570
|
+
}
|
|
4571
|
+
var view = new Uint8Array(total);
|
|
4572
|
+
var voff = 0;
|
|
4573
|
+
for (var i = 0; i < iovcnt; i++, iov += 8) {
|
|
4534
4574
|
var ptr = HEAPU32[((iov)>>2)];
|
|
4535
4575
|
var len = HEAPU32[(((iov)+(4))>>2)];
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
if (curr < 0) return -1;
|
|
4539
|
-
ret += curr;
|
|
4540
|
-
if (curr < len) {
|
|
4541
|
-
// No more space to write.
|
|
4542
|
-
break;
|
|
4543
|
-
}
|
|
4544
|
-
if (typeof offset != 'undefined') {
|
|
4545
|
-
offset += curr;
|
|
4546
|
-
}
|
|
4576
|
+
view.set(HEAPU8.subarray(ptr, ptr + len), voff);
|
|
4577
|
+
voff += len;
|
|
4547
4578
|
}
|
|
4548
|
-
return
|
|
4579
|
+
return FS.write(stream, view, 0, total, offset);
|
|
4549
4580
|
};
|
|
4550
4581
|
|
|
4582
|
+
|
|
4551
4583
|
function _fd_write(fd, iov, iovcnt, pnum) {
|
|
4552
4584
|
try {
|
|
4553
4585
|
|
|
@@ -4560,18 +4592,12 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4560
4592
|
return e.errno;
|
|
4561
4593
|
}
|
|
4562
4594
|
}
|
|
4595
|
+
|
|
4563
4596
|
|
|
4564
4597
|
|
|
4565
|
-
function _random_get(buffer, size) {
|
|
4566
|
-
try {
|
|
4567
4598
|
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
} catch (e) {
|
|
4571
|
-
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
4572
|
-
return e.errno;
|
|
4573
|
-
}
|
|
4574
|
-
}
|
|
4599
|
+
var _random_get = (buffer, size) => randomFill(HEAPU8.subarray(buffer, buffer + size));
|
|
4600
|
+
|
|
4575
4601
|
|
|
4576
4602
|
|
|
4577
4603
|
|
|
@@ -4604,15 +4630,14 @@ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
|
4604
4630
|
|
|
4605
4631
|
// Begin ATMODULES hooks
|
|
4606
4632
|
if (Module['noExitRuntime']) noExitRuntime = Module['noExitRuntime'];
|
|
4607
|
-
|
|
4633
|
+
|
|
4608
4634
|
if (Module['print']) out = Module['print'];
|
|
4609
4635
|
if (Module['printErr']) err = Module['printErr'];
|
|
4610
|
-
if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
|
|
4611
4636
|
// End ATMODULES hooks
|
|
4612
4637
|
|
|
4613
4638
|
checkIncomingModuleAPI();
|
|
4614
4639
|
|
|
4615
|
-
if (Module['arguments'])
|
|
4640
|
+
if (Module['arguments']) programArgs = Module['arguments'];
|
|
4616
4641
|
if (Module['thisProgram']) thisProgram = Module['thisProgram'];
|
|
4617
4642
|
|
|
4618
4643
|
// Assertions on removed incoming Module JS APIs.
|
|
@@ -4631,10 +4656,13 @@ if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
|
|
|
4631
4656
|
assert(typeof Module['wasmMemory'] == 'undefined', 'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally');
|
|
4632
4657
|
assert(typeof Module['INITIAL_MEMORY'] == 'undefined', 'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically');
|
|
4633
4658
|
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4659
|
+
var preInit = Module['preInit'];
|
|
4660
|
+
if (preInit) {
|
|
4661
|
+
if (typeof preInit == 'function') Module['preInit'] = preInit = [preInit];
|
|
4662
|
+
// Written as a loop so that preInit functions that themselves add more
|
|
4663
|
+
// preInit functions. Is this actually needed?
|
|
4664
|
+
while (preInit.length > 0) {
|
|
4665
|
+
preInit.shift()();
|
|
4638
4666
|
}
|
|
4639
4667
|
}
|
|
4640
4668
|
consumedModuleProp('preInit');
|
|
@@ -4704,6 +4732,8 @@ if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
|
|
|
4704
4732
|
'getFunctionAddress',
|
|
4705
4733
|
'addFunction',
|
|
4706
4734
|
'removeFunction',
|
|
4735
|
+
'setValue',
|
|
4736
|
+
'getValue',
|
|
4707
4737
|
'intArrayToString',
|
|
4708
4738
|
'AsciiToString',
|
|
4709
4739
|
'stringToAscii',
|
|
@@ -4734,12 +4764,14 @@ if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
|
|
|
4734
4764
|
'registerOrientationChangeEventCallback',
|
|
4735
4765
|
'fillFullscreenChangeEventData',
|
|
4736
4766
|
'registerFullscreenChangeEventCallback',
|
|
4767
|
+
'callCanvasResizedCallback',
|
|
4737
4768
|
'JSEvents_requestFullscreen',
|
|
4738
4769
|
'JSEvents_resizeCanvasForFullscreen',
|
|
4739
4770
|
'registerRestoreOldStyle',
|
|
4740
4771
|
'hideEverythingExceptGivenElement',
|
|
4741
4772
|
'restoreHiddenElements',
|
|
4742
4773
|
'setLetterbox',
|
|
4774
|
+
'currentFullscreenStrategy',
|
|
4743
4775
|
'softFullscreenResizeWebGLRenderTarget',
|
|
4744
4776
|
'doRequestFullscreen',
|
|
4745
4777
|
'fillPointerlockChangeEventData',
|
|
@@ -4768,9 +4800,9 @@ if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
|
|
|
4768
4800
|
'registerPreMainLoop',
|
|
4769
4801
|
'getPromise',
|
|
4770
4802
|
'makePromise',
|
|
4803
|
+
'addPromise',
|
|
4771
4804
|
'idsToPromises',
|
|
4772
4805
|
'makePromiseCallback',
|
|
4773
|
-
'findMatchingCatch',
|
|
4774
4806
|
'Browser_asyncPrepareDataCounter',
|
|
4775
4807
|
'isLeapYear',
|
|
4776
4808
|
'ydayFromDate',
|
|
@@ -4794,6 +4826,7 @@ if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
|
|
|
4794
4826
|
'colorChannelsInGlTextureFormat',
|
|
4795
4827
|
'emscriptenWebGLGetTexPixelData',
|
|
4796
4828
|
'emscriptenWebGLGetUniform',
|
|
4829
|
+
'webglGetProgramUniformLocation',
|
|
4797
4830
|
'webglGetUniformLocation',
|
|
4798
4831
|
'webglPrepareUniformLocationsBeforeFirstUse',
|
|
4799
4832
|
'webglGetLeftBracePos',
|
|
@@ -4802,14 +4835,10 @@ if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];
|
|
|
4802
4835
|
'writeGLArray',
|
|
4803
4836
|
'registerWebGlEventCallback',
|
|
4804
4837
|
'runAndAbortIfError',
|
|
4805
|
-
'ALLOC_NORMAL',
|
|
4806
|
-
'ALLOC_STACK',
|
|
4807
|
-
'allocate',
|
|
4808
4838
|
'writeStringToMemory',
|
|
4809
4839
|
'writeAsciiToMemory',
|
|
4810
4840
|
'allocateUTF8',
|
|
4811
4841
|
'allocateUTF8OnStack',
|
|
4812
|
-
'demangle',
|
|
4813
4842
|
'stackTrace',
|
|
4814
4843
|
'getNativeTypeSize',
|
|
4815
4844
|
];
|
|
@@ -4822,20 +4851,20 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
|
4822
4851
|
'callMain',
|
|
4823
4852
|
'abort',
|
|
4824
4853
|
'wasmExports',
|
|
4825
|
-
'
|
|
4826
|
-
'
|
|
4854
|
+
'writeStackCookie',
|
|
4855
|
+
'checkStackCookie',
|
|
4856
|
+
'INT53_MAX',
|
|
4857
|
+
'INT53_MIN',
|
|
4858
|
+
'bigintToI53Checked',
|
|
4827
4859
|
'HEAP8',
|
|
4828
4860
|
'HEAP16',
|
|
4829
4861
|
'HEAPU16',
|
|
4830
4862
|
'HEAP32',
|
|
4831
4863
|
'HEAPU32',
|
|
4864
|
+
'HEAPF32',
|
|
4865
|
+
'HEAPF64',
|
|
4832
4866
|
'HEAP64',
|
|
4833
4867
|
'HEAPU64',
|
|
4834
|
-
'writeStackCookie',
|
|
4835
|
-
'checkStackCookie',
|
|
4836
|
-
'INT53_MAX',
|
|
4837
|
-
'INT53_MIN',
|
|
4838
|
-
'bigintToI53Checked',
|
|
4839
4868
|
'stackSave',
|
|
4840
4869
|
'stackRestore',
|
|
4841
4870
|
'ptrToString',
|
|
@@ -4864,8 +4893,6 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
|
4864
4893
|
'addOnPostRun',
|
|
4865
4894
|
'freeTableIndexes',
|
|
4866
4895
|
'functionsInTableMap',
|
|
4867
|
-
'setValue',
|
|
4868
|
-
'getValue',
|
|
4869
4896
|
'PATH',
|
|
4870
4897
|
'PATH_FS',
|
|
4871
4898
|
'UTF8Decoder',
|
|
@@ -4876,7 +4903,6 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
|
4876
4903
|
'JSEvents',
|
|
4877
4904
|
'specialHTMLTargets',
|
|
4878
4905
|
'findCanvasEventTarget',
|
|
4879
|
-
'currentFullscreenStrategy',
|
|
4880
4906
|
'restoreOldWindowedStyle',
|
|
4881
4907
|
'jsStackTrace',
|
|
4882
4908
|
'UNWIND_CACHE',
|
|
@@ -4891,13 +4917,8 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
|
4891
4917
|
'emClearImmediate_deps',
|
|
4892
4918
|
'emClearImmediate',
|
|
4893
4919
|
'promiseMap',
|
|
4894
|
-
'uncaughtExceptionCount',
|
|
4895
|
-
'exceptionLast',
|
|
4896
|
-
'exceptionCaught',
|
|
4897
|
-
'ExceptionInfo',
|
|
4898
4920
|
'Browser',
|
|
4899
4921
|
'requestFullscreen',
|
|
4900
|
-
'requestFullScreen',
|
|
4901
4922
|
'setCanvasSize',
|
|
4902
4923
|
'getUserMedia',
|
|
4903
4924
|
'createContext',
|
|
@@ -4912,6 +4933,7 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
|
4912
4933
|
'FS_createPreloadedFile',
|
|
4913
4934
|
'FS_modeStringToFlags',
|
|
4914
4935
|
'FS_getMode',
|
|
4936
|
+
'FS_fileDataToTypedArray',
|
|
4915
4937
|
'FS_stdin_getChar_buffer',
|
|
4916
4938
|
'FS_stdin_getChar',
|
|
4917
4939
|
'FS_readFile',
|
|
@@ -4976,6 +4998,7 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
|
4976
4998
|
'FS_mkdir',
|
|
4977
4999
|
'FS_mkdev',
|
|
4978
5000
|
'FS_symlink',
|
|
5001
|
+
'FS_link',
|
|
4979
5002
|
'FS_rename',
|
|
4980
5003
|
'FS_rmdir',
|
|
4981
5004
|
'FS_readdir',
|
|
@@ -5018,12 +5041,6 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
|
5018
5041
|
'FS_analyzePath',
|
|
5019
5042
|
'FS_createFile',
|
|
5020
5043
|
'FS_forceLoadFile',
|
|
5021
|
-
'FS_absolutePath',
|
|
5022
|
-
'FS_createFolder',
|
|
5023
|
-
'FS_createLink',
|
|
5024
|
-
'FS_joinPath',
|
|
5025
|
-
'FS_mmapAlloc',
|
|
5026
|
-
'FS_standardizePath',
|
|
5027
5044
|
'MEMFS',
|
|
5028
5045
|
'TTY',
|
|
5029
5046
|
'PIPEFS',
|
|
@@ -5056,10 +5073,37 @@ function checkIncomingModuleAPI() {
|
|
|
5056
5073
|
ignoredModuleProp('fetchSettings');
|
|
5057
5074
|
ignoredModuleProp('logReadFiles');
|
|
5058
5075
|
ignoredModuleProp('loadSplitModule');
|
|
5076
|
+
ignoredModuleProp('onMalloc');
|
|
5077
|
+
ignoredModuleProp('onRealloc');
|
|
5078
|
+
ignoredModuleProp('onFree');
|
|
5079
|
+
ignoredModuleProp('onSbrkGrow');
|
|
5080
|
+
ignoredModuleProp('onCOSCacheHit');
|
|
5081
|
+
ignoredModuleProp('onCOSCacheMiss');
|
|
5082
|
+
ignoredModuleProp('onCOSStore');
|
|
5083
|
+
ignoredModuleProp('GL_MAX_TEXTURE_IMAGE_UNITS');
|
|
5084
|
+
ignoredModuleProp('SDL_canPlayWithWebAudio');
|
|
5085
|
+
ignoredModuleProp('SDL_numSimultaneouslyQueuedBuffers');
|
|
5086
|
+
ignoredModuleProp('freePreloadedMediaOnUse');
|
|
5087
|
+
ignoredModuleProp('preinitializedWebGLContext');
|
|
5088
|
+
ignoredModuleProp('keyboardListeningElement');
|
|
5089
|
+
ignoredModuleProp('doNotCaptureKeyboard');
|
|
5090
|
+
ignoredModuleProp('extraStackTrace');
|
|
5091
|
+
ignoredModuleProp('preloadPlugins');
|
|
5092
|
+
ignoredModuleProp('preMainLoop');
|
|
5093
|
+
ignoredModuleProp('postMainLoop');
|
|
5094
|
+
ignoredModuleProp('forcedAspectRatio');
|
|
5095
|
+
ignoredModuleProp('mainScriptUrlOrBlob');
|
|
5096
|
+
ignoredModuleProp('onFullScreen');
|
|
5097
|
+
ignoredModuleProp('INITIAL_MEMORY');
|
|
5098
|
+
ignoredModuleProp('wasmMemory');
|
|
5099
|
+
ignoredModuleProp('wasmBinary');
|
|
5059
5100
|
}
|
|
5060
5101
|
|
|
5061
5102
|
// Imports from the Wasm binary.
|
|
5062
5103
|
var _anisette_end_provisioning = Module['_anisette_end_provisioning'] = makeInvalidEarlyAccess('_anisette_end_provisioning');
|
|
5104
|
+
var _anisette_fs_read_file = Module['_anisette_fs_read_file'] = makeInvalidEarlyAccess('_anisette_fs_read_file');
|
|
5105
|
+
var _anisette_fs_read_len = Module['_anisette_fs_read_len'] = makeInvalidEarlyAccess('_anisette_fs_read_len');
|
|
5106
|
+
var _anisette_fs_read_ptr = Module['_anisette_fs_read_ptr'] = makeInvalidEarlyAccess('_anisette_fs_read_ptr');
|
|
5063
5107
|
var _anisette_fs_write_file = Module['_anisette_fs_write_file'] = makeInvalidEarlyAccess('_anisette_fs_write_file');
|
|
5064
5108
|
var _anisette_get_cpim_len = Module['_anisette_get_cpim_len'] = makeInvalidEarlyAccess('_anisette_get_cpim_len');
|
|
5065
5109
|
var _anisette_get_cpim_ptr = Module['_anisette_get_cpim_ptr'] = makeInvalidEarlyAccess('_anisette_get_cpim_ptr');
|
|
@@ -5068,7 +5112,6 @@ var _anisette_get_mid_ptr = Module['_anisette_get_mid_ptr'] = makeInvalidEarlyAc
|
|
|
5068
5112
|
var _anisette_get_otp_len = Module['_anisette_get_otp_len'] = makeInvalidEarlyAccess('_anisette_get_otp_len');
|
|
5069
5113
|
var _anisette_get_otp_ptr = Module['_anisette_get_otp_ptr'] = makeInvalidEarlyAccess('_anisette_get_otp_ptr');
|
|
5070
5114
|
var _anisette_get_session = Module['_anisette_get_session'] = makeInvalidEarlyAccess('_anisette_get_session');
|
|
5071
|
-
var _anisette_idbfs_init = Module['_anisette_idbfs_init'] = makeInvalidEarlyAccess('_anisette_idbfs_init');
|
|
5072
5115
|
var _anisette_idbfs_sync = Module['_anisette_idbfs_sync'] = makeInvalidEarlyAccess('_anisette_idbfs_sync');
|
|
5073
5116
|
var _anisette_init_from_blobs = Module['_anisette_init_from_blobs'] = makeInvalidEarlyAccess('_anisette_init_from_blobs');
|
|
5074
5117
|
var _anisette_is_machine_provisioned = Module['_anisette_is_machine_provisioned'] = makeInvalidEarlyAccess('_anisette_is_machine_provisioned');
|
|
@@ -5101,6 +5144,9 @@ var wasmTable = makeInvalidEarlyAccess('wasmTable');
|
|
|
5101
5144
|
|
|
5102
5145
|
function assignWasmExports(wasmExports) {
|
|
5103
5146
|
assert(typeof wasmExports['anisette_end_provisioning'] != 'undefined', 'missing Wasm export: anisette_end_provisioning');
|
|
5147
|
+
assert(typeof wasmExports['anisette_fs_read_file'] != 'undefined', 'missing Wasm export: anisette_fs_read_file');
|
|
5148
|
+
assert(typeof wasmExports['anisette_fs_read_len'] != 'undefined', 'missing Wasm export: anisette_fs_read_len');
|
|
5149
|
+
assert(typeof wasmExports['anisette_fs_read_ptr'] != 'undefined', 'missing Wasm export: anisette_fs_read_ptr');
|
|
5104
5150
|
assert(typeof wasmExports['anisette_fs_write_file'] != 'undefined', 'missing Wasm export: anisette_fs_write_file');
|
|
5105
5151
|
assert(typeof wasmExports['anisette_get_cpim_len'] != 'undefined', 'missing Wasm export: anisette_get_cpim_len');
|
|
5106
5152
|
assert(typeof wasmExports['anisette_get_cpim_ptr'] != 'undefined', 'missing Wasm export: anisette_get_cpim_ptr');
|
|
@@ -5109,7 +5155,6 @@ function assignWasmExports(wasmExports) {
|
|
|
5109
5155
|
assert(typeof wasmExports['anisette_get_otp_len'] != 'undefined', 'missing Wasm export: anisette_get_otp_len');
|
|
5110
5156
|
assert(typeof wasmExports['anisette_get_otp_ptr'] != 'undefined', 'missing Wasm export: anisette_get_otp_ptr');
|
|
5111
5157
|
assert(typeof wasmExports['anisette_get_session'] != 'undefined', 'missing Wasm export: anisette_get_session');
|
|
5112
|
-
assert(typeof wasmExports['anisette_idbfs_init'] != 'undefined', 'missing Wasm export: anisette_idbfs_init');
|
|
5113
5158
|
assert(typeof wasmExports['anisette_idbfs_sync'] != 'undefined', 'missing Wasm export: anisette_idbfs_sync');
|
|
5114
5159
|
assert(typeof wasmExports['anisette_init_from_blobs'] != 'undefined', 'missing Wasm export: anisette_init_from_blobs');
|
|
5115
5160
|
assert(typeof wasmExports['anisette_is_machine_provisioned'] != 'undefined', 'missing Wasm export: anisette_is_machine_provisioned');
|
|
@@ -5137,34 +5182,36 @@ function assignWasmExports(wasmExports) {
|
|
|
5137
5182
|
assert(typeof wasmExports['emscripten_stack_get_current'] != 'undefined', 'missing Wasm export: emscripten_stack_get_current');
|
|
5138
5183
|
assert(typeof wasmExports['memory'] != 'undefined', 'missing Wasm export: memory');
|
|
5139
5184
|
assert(typeof wasmExports['__indirect_function_table'] != 'undefined', 'missing Wasm export: __indirect_function_table');
|
|
5140
|
-
_anisette_end_provisioning = Module['_anisette_end_provisioning'] = createExportWrapper('anisette_end_provisioning', 5);
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5185
|
+
_anisette_end_provisioning = Module['_anisette_end_provisioning'] = createExportWrapper('anisette_end_provisioning', wasmExports['anisette_end_provisioning'], 5);
|
|
5186
|
+
_anisette_fs_read_file = Module['_anisette_fs_read_file'] = createExportWrapper('anisette_fs_read_file', wasmExports['anisette_fs_read_file'], 1);
|
|
5187
|
+
_anisette_fs_read_len = Module['_anisette_fs_read_len'] = createExportWrapper('anisette_fs_read_len', wasmExports['anisette_fs_read_len'], 0);
|
|
5188
|
+
_anisette_fs_read_ptr = Module['_anisette_fs_read_ptr'] = createExportWrapper('anisette_fs_read_ptr', wasmExports['anisette_fs_read_ptr'], 0);
|
|
5189
|
+
_anisette_fs_write_file = Module['_anisette_fs_write_file'] = createExportWrapper('anisette_fs_write_file', wasmExports['anisette_fs_write_file'], 3);
|
|
5190
|
+
_anisette_get_cpim_len = Module['_anisette_get_cpim_len'] = createExportWrapper('anisette_get_cpim_len', wasmExports['anisette_get_cpim_len'], 0);
|
|
5191
|
+
_anisette_get_cpim_ptr = Module['_anisette_get_cpim_ptr'] = createExportWrapper('anisette_get_cpim_ptr', wasmExports['anisette_get_cpim_ptr'], 0);
|
|
5192
|
+
_anisette_get_mid_len = Module['_anisette_get_mid_len'] = createExportWrapper('anisette_get_mid_len', wasmExports['anisette_get_mid_len'], 0);
|
|
5193
|
+
_anisette_get_mid_ptr = Module['_anisette_get_mid_ptr'] = createExportWrapper('anisette_get_mid_ptr', wasmExports['anisette_get_mid_ptr'], 0);
|
|
5194
|
+
_anisette_get_otp_len = Module['_anisette_get_otp_len'] = createExportWrapper('anisette_get_otp_len', wasmExports['anisette_get_otp_len'], 0);
|
|
5195
|
+
_anisette_get_otp_ptr = Module['_anisette_get_otp_ptr'] = createExportWrapper('anisette_get_otp_ptr', wasmExports['anisette_get_otp_ptr'], 0);
|
|
5196
|
+
_anisette_get_session = Module['_anisette_get_session'] = createExportWrapper('anisette_get_session', wasmExports['anisette_get_session'], 0);
|
|
5197
|
+
_anisette_idbfs_sync = Module['_anisette_idbfs_sync'] = createExportWrapper('anisette_idbfs_sync', wasmExports['anisette_idbfs_sync'], 1);
|
|
5198
|
+
_anisette_init_from_blobs = Module['_anisette_init_from_blobs'] = createExportWrapper('anisette_init_from_blobs', wasmExports['anisette_init_from_blobs'], 7);
|
|
5199
|
+
_anisette_is_machine_provisioned = Module['_anisette_is_machine_provisioned'] = createExportWrapper('anisette_is_machine_provisioned', wasmExports['anisette_is_machine_provisioned'], 1);
|
|
5200
|
+
_anisette_last_error_len = Module['_anisette_last_error_len'] = createExportWrapper('anisette_last_error_len', wasmExports['anisette_last_error_len'], 0);
|
|
5201
|
+
_anisette_last_error_ptr = Module['_anisette_last_error_ptr'] = createExportWrapper('anisette_last_error_ptr', wasmExports['anisette_last_error_ptr'], 0);
|
|
5202
|
+
_anisette_request_otp = Module['_anisette_request_otp'] = createExportWrapper('anisette_request_otp', wasmExports['anisette_request_otp'], 1);
|
|
5203
|
+
_anisette_set_identifier = Module['_anisette_set_identifier'] = createExportWrapper('anisette_set_identifier', wasmExports['anisette_set_identifier'], 1);
|
|
5204
|
+
_anisette_set_provisioning_path = Module['_anisette_set_provisioning_path'] = createExportWrapper('anisette_set_provisioning_path', wasmExports['anisette_set_provisioning_path'], 1);
|
|
5205
|
+
_anisette_start_provisioning = Module['_anisette_start_provisioning'] = createExportWrapper('anisette_start_provisioning', wasmExports['anisette_start_provisioning'], 3);
|
|
5206
|
+
_fflush = createExportWrapper('fflush', wasmExports['fflush'], 1);
|
|
5207
|
+
_htonl = createExportWrapper('htonl', wasmExports['htonl'], 1);
|
|
5208
|
+
_htons = createExportWrapper('htons', wasmExports['htons'], 1);
|
|
5209
|
+
_ntohs = createExportWrapper('ntohs', wasmExports['ntohs'], 1);
|
|
5210
|
+
_strerror = createExportWrapper('strerror', wasmExports['strerror'], 1);
|
|
5211
|
+
_malloc = Module['_malloc'] = createExportWrapper('malloc', wasmExports['malloc'], 1);
|
|
5212
|
+
_free = Module['_free'] = createExportWrapper('free', wasmExports['free'], 1);
|
|
5213
|
+
_realloc = createExportWrapper('realloc', wasmExports['realloc'], 2);
|
|
5214
|
+
_setThrew = createExportWrapper('setThrew', wasmExports['setThrew'], 2);
|
|
5168
5215
|
_emscripten_stack_init = wasmExports['emscripten_stack_init'];
|
|
5169
5216
|
_emscripten_stack_get_free = wasmExports['emscripten_stack_get_free'];
|
|
5170
5217
|
_emscripten_stack_get_base = wasmExports['emscripten_stack_get_base'];
|
|
@@ -5267,7 +5314,7 @@ function invoke_viii(index,a1,a2,a3) {
|
|
|
5267
5314
|
getWasmTableEntry(index)(a1,a2,a3);
|
|
5268
5315
|
} catch(e) {
|
|
5269
5316
|
stackRestore(sp);
|
|
5270
|
-
if (e
|
|
5317
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
5271
5318
|
_setThrew(1, 0);
|
|
5272
5319
|
}
|
|
5273
5320
|
}
|
|
@@ -5278,7 +5325,7 @@ function invoke_ii(index,a1) {
|
|
|
5278
5325
|
return getWasmTableEntry(index)(a1);
|
|
5279
5326
|
} catch(e) {
|
|
5280
5327
|
stackRestore(sp);
|
|
5281
|
-
if (e
|
|
5328
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
5282
5329
|
_setThrew(1, 0);
|
|
5283
5330
|
}
|
|
5284
5331
|
}
|
|
@@ -5289,7 +5336,7 @@ function invoke_vi(index,a1) {
|
|
|
5289
5336
|
getWasmTableEntry(index)(a1);
|
|
5290
5337
|
} catch(e) {
|
|
5291
5338
|
stackRestore(sp);
|
|
5292
|
-
if (e
|
|
5339
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
5293
5340
|
_setThrew(1, 0);
|
|
5294
5341
|
}
|
|
5295
5342
|
}
|
|
@@ -5300,7 +5347,7 @@ function invoke_iii(index,a1,a2) {
|
|
|
5300
5347
|
return getWasmTableEntry(index)(a1,a2);
|
|
5301
5348
|
} catch(e) {
|
|
5302
5349
|
stackRestore(sp);
|
|
5303
|
-
if (e
|
|
5350
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
5304
5351
|
_setThrew(1, 0);
|
|
5305
5352
|
}
|
|
5306
5353
|
}
|
|
@@ -5311,7 +5358,7 @@ function invoke_viiii(index,a1,a2,a3,a4) {
|
|
|
5311
5358
|
getWasmTableEntry(index)(a1,a2,a3,a4);
|
|
5312
5359
|
} catch(e) {
|
|
5313
5360
|
stackRestore(sp);
|
|
5314
|
-
if (e
|
|
5361
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
5315
5362
|
_setThrew(1, 0);
|
|
5316
5363
|
}
|
|
5317
5364
|
}
|
|
@@ -5322,7 +5369,7 @@ function invoke_iiiiii(index,a1,a2,a3,a4,a5) {
|
|
|
5322
5369
|
return getWasmTableEntry(index)(a1,a2,a3,a4,a5);
|
|
5323
5370
|
} catch(e) {
|
|
5324
5371
|
stackRestore(sp);
|
|
5325
|
-
if (e
|
|
5372
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
5326
5373
|
_setThrew(1, 0);
|
|
5327
5374
|
}
|
|
5328
5375
|
}
|
|
@@ -5333,7 +5380,7 @@ function invoke_vii(index,a1,a2) {
|
|
|
5333
5380
|
getWasmTableEntry(index)(a1,a2);
|
|
5334
5381
|
} catch(e) {
|
|
5335
5382
|
stackRestore(sp);
|
|
5336
|
-
if (e
|
|
5383
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
5337
5384
|
_setThrew(1, 0);
|
|
5338
5385
|
}
|
|
5339
5386
|
}
|
|
@@ -5344,7 +5391,7 @@ function invoke_vij(index,a1,a2) {
|
|
|
5344
5391
|
getWasmTableEntry(index)(a1,a2);
|
|
5345
5392
|
} catch(e) {
|
|
5346
5393
|
stackRestore(sp);
|
|
5347
|
-
if (e
|
|
5394
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
5348
5395
|
_setThrew(1, 0);
|
|
5349
5396
|
}
|
|
5350
5397
|
}
|
|
@@ -5355,7 +5402,7 @@ function invoke_iijjii(index,a1,a2,a3,a4,a5) {
|
|
|
5355
5402
|
return getWasmTableEntry(index)(a1,a2,a3,a4,a5);
|
|
5356
5403
|
} catch(e) {
|
|
5357
5404
|
stackRestore(sp);
|
|
5358
|
-
if (e
|
|
5405
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
5359
5406
|
_setThrew(1, 0);
|
|
5360
5407
|
}
|
|
5361
5408
|
}
|
|
@@ -5366,7 +5413,7 @@ function invoke_iij(index,a1,a2) {
|
|
|
5366
5413
|
return getWasmTableEntry(index)(a1,a2);
|
|
5367
5414
|
} catch(e) {
|
|
5368
5415
|
stackRestore(sp);
|
|
5369
|
-
if (e
|
|
5416
|
+
if (!(e instanceof EmscriptenEH)) throw e;
|
|
5370
5417
|
_setThrew(1, 0);
|
|
5371
5418
|
}
|
|
5372
5419
|
}
|
|
@@ -5386,54 +5433,37 @@ function stackCheckInit() {
|
|
|
5386
5433
|
writeStackCookie();
|
|
5387
5434
|
}
|
|
5388
5435
|
|
|
5389
|
-
function run() {
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
dependenciesFulfilled = run;
|
|
5393
|
-
return;
|
|
5394
|
-
}
|
|
5436
|
+
async function run() {
|
|
5437
|
+
assert(!calledRun);
|
|
5438
|
+
calledRun = true;
|
|
5395
5439
|
|
|
5396
5440
|
stackCheckInit();
|
|
5397
5441
|
|
|
5398
5442
|
preRun();
|
|
5399
5443
|
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
dependenciesFulfilled = run;
|
|
5403
|
-
return;
|
|
5444
|
+
if (runDependencies) {
|
|
5445
|
+
await resolveRunDependencies();
|
|
5404
5446
|
}
|
|
5405
5447
|
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5448
|
+
var setStatus = Module['setStatus'];
|
|
5449
|
+
if (setStatus) {
|
|
5450
|
+
setStatus('Running...');
|
|
5451
|
+
// Yield to the event loop to allow the browser to paint "Running..."
|
|
5452
|
+
await new Promise((resolve) => setTimeout(resolve, 1));
|
|
5453
|
+
// Then we want to clear the status text, but only after the rest of this function runs.
|
|
5454
|
+
setTimeout(setStatus, 1, '');
|
|
5455
|
+
}
|
|
5414
5456
|
|
|
5415
|
-
|
|
5457
|
+
if (ABORT) return;
|
|
5416
5458
|
|
|
5417
|
-
|
|
5418
|
-
Module['onRuntimeInitialized']?.();
|
|
5419
|
-
consumedModuleProp('onRuntimeInitialized');
|
|
5459
|
+
initRuntime();
|
|
5420
5460
|
|
|
5421
|
-
|
|
5461
|
+
Module['onRuntimeInitialized']?.();
|
|
5462
|
+
consumedModuleProp('onRuntimeInitialized');
|
|
5422
5463
|
|
|
5423
|
-
|
|
5424
|
-
}
|
|
5464
|
+
assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');
|
|
5425
5465
|
|
|
5426
|
-
|
|
5427
|
-
Module['setStatus']('Running...');
|
|
5428
|
-
setTimeout(() => {
|
|
5429
|
-
setTimeout(() => Module['setStatus'](''), 1);
|
|
5430
|
-
doRun();
|
|
5431
|
-
}, 1);
|
|
5432
|
-
} else
|
|
5433
|
-
{
|
|
5434
|
-
doRun();
|
|
5435
|
-
}
|
|
5436
|
-
checkStackCookie();
|
|
5466
|
+
postRun();
|
|
5437
5467
|
}
|
|
5438
5468
|
|
|
5439
5469
|
function checkUnflushedContent() {
|
|
@@ -5479,28 +5509,14 @@ var wasmExports;
|
|
|
5479
5509
|
|
|
5480
5510
|
// In modularize mode the generated code is within a factory function so we
|
|
5481
5511
|
// can use await here (since it's not top-level-await).
|
|
5482
|
-
wasmExports = await
|
|
5483
|
-
|
|
5484
|
-
run();
|
|
5512
|
+
wasmExports = await createWasm();
|
|
5513
|
+
await run();
|
|
5485
5514
|
|
|
5486
5515
|
// end include: postamble.js
|
|
5487
5516
|
|
|
5488
5517
|
// include: postamble_modularize.js
|
|
5489
5518
|
// In MODULARIZE mode we wrap the generated code in a factory function
|
|
5490
5519
|
// and return either the Module itself, or a promise of the module.
|
|
5491
|
-
//
|
|
5492
|
-
// We assign to the `moduleRtn` global here and configure closure to see
|
|
5493
|
-
// this as an extern so it won't get minified.
|
|
5494
|
-
|
|
5495
|
-
if (runtimeInitialized) {
|
|
5496
|
-
moduleRtn = Module;
|
|
5497
|
-
} else {
|
|
5498
|
-
// Set up the promise that indicates the Module is initialized
|
|
5499
|
-
moduleRtn = new Promise((resolve, reject) => {
|
|
5500
|
-
readyPromiseResolve = resolve;
|
|
5501
|
-
readyPromiseReject = reject;
|
|
5502
|
-
});
|
|
5503
|
-
}
|
|
5504
5520
|
|
|
5505
5521
|
// Assertion for attempting to access module properties on the incoming
|
|
5506
5522
|
// moduleArg. In the past we used this object as the prototype of the module
|
|
@@ -5521,7 +5537,7 @@ for (const prop of Object.keys(Module)) {
|
|
|
5521
5537
|
|
|
5522
5538
|
|
|
5523
5539
|
|
|
5524
|
-
return
|
|
5540
|
+
return Module;
|
|
5525
5541
|
}
|
|
5526
5542
|
|
|
5527
5543
|
// Export using a UMD style export, or ES6 exports if selected
|