sql.js 1.10.2 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -73,7 +73,7 @@ var initSqlJs = function (moduleConfig) {
73
73
  // The Module object: Our interface to the outside world. We import
74
74
  // and export values on it. There are various ways Module can be used:
75
75
  // 1. Not defined. We create it here
76
- // 2. A function parameter, function(Module) { ..generated code.. }
76
+ // 2. A function parameter, function(moduleArg) => Promise<Module>
77
77
  // 3. pre-run appended it, var Module = {}; ..generated code..
78
78
  // 4. External script tag defines var Module.
79
79
  // We need to check if Module already exists (e.g. case 3 above).
@@ -85,8 +85,32 @@ var initSqlJs = function (moduleConfig) {
85
85
  // can continue to use Module afterwards as well.
86
86
  var Module = typeof Module != 'undefined' ? Module : {};
87
87
 
88
+ // Determine the runtime environment we are in. You can customize this by
89
+ // setting the ENVIRONMENT setting at compile time (see settings.js).
90
+
91
+ // Attempt to auto-detect the environment
92
+ var ENVIRONMENT_IS_WEB = typeof window == 'object';
93
+ var ENVIRONMENT_IS_WORKER = typeof importScripts == 'function';
94
+ // N.b. Electron.js environment is simultaneously a NODE-environment, but
95
+ // also a web environment.
96
+ var ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string';
97
+ var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
98
+
99
+ if (Module['ENVIRONMENT']) {
100
+ throw new Error('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)');
101
+ }
102
+
103
+ if (ENVIRONMENT_IS_NODE) {
104
+ // `require()` is no-op in an ESM module, use `createRequire()` to construct
105
+ // the require()` function. This is only necessary for multi-environment
106
+ // builds, `-sENVIRONMENT=node` emits a static import declaration instead.
107
+ // TODO: Swap all `require()`'s with `import()`'s?
108
+
109
+ }
110
+
88
111
  // --pre-jses are emitted after the Module integration code, so that they can
89
112
  // refer to Module (if they choose; they can also define Module)
113
+ // include: /github/workspace/src/api.js
90
114
  /* global
91
115
  FS
92
116
  HEAP8
@@ -1164,7 +1188,9 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
1164
1188
  return new StatementIterator(sql, this);
1165
1189
  };
1166
1190
 
1167
- /** Exports the contents of the database to a binary array
1191
+ /** Exports the contents of the database to a binary array. This
1192
+ * operation will close and re-open the database which will cause
1193
+ * any pragmas to be set back to their default values.
1168
1194
  @return {Uint8Array} An array of bytes of the SQLite3 database file
1169
1195
  */
1170
1196
  Database.prototype["export"] = function exportDatabase() {
@@ -1473,6 +1499,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
1473
1499
  // export Database to Module
1474
1500
  Module.Database = Database;
1475
1501
  };
1502
+ // end include: /github/workspace/src/api.js
1476
1503
 
1477
1504
 
1478
1505
  // Sometimes an existing Module object exists with properties
@@ -1488,21 +1515,6 @@ var quit_ = (status, toThrow) => {
1488
1515
  throw toThrow;
1489
1516
  };
1490
1517
 
1491
- // Determine the runtime environment we are in. You can customize this by
1492
- // setting the ENVIRONMENT setting at compile time (see settings.js).
1493
-
1494
- // Attempt to auto-detect the environment
1495
- var ENVIRONMENT_IS_WEB = typeof window == 'object';
1496
- var ENVIRONMENT_IS_WORKER = typeof importScripts == 'function';
1497
- // N.b. Electron.js environment is simultaneously a NODE-environment, but
1498
- // also a web environment.
1499
- var ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string';
1500
- var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
1501
-
1502
- if (Module['ENVIRONMENT']) {
1503
- throw new Error('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)');
1504
- }
1505
-
1506
1518
  // `/` should be present at the end if `scriptDirectory` is not empty
1507
1519
  var scriptDirectory = '';
1508
1520
  function locateFile(path) {
@@ -1513,9 +1525,7 @@ function locateFile(path) {
1513
1525
  }
1514
1526
 
1515
1527
  // Hooks that are implemented differently in different runtime environments.
1516
- var read_,
1517
- readAsync,
1518
- readBinary;
1528
+ var readAsync, readBinary;
1519
1529
 
1520
1530
  if (ENVIRONMENT_IS_NODE) {
1521
1531
  if (typeof process == 'undefined' || !process.release || process.release.name !== 'node') 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?)');
@@ -1528,44 +1538,31 @@ if (ENVIRONMENT_IS_NODE) {
1528
1538
  throw new Error('This emscripten-generated code requires node v16.0.0 (detected v' + nodeVersion + ')');
1529
1539
  }
1530
1540
 
1531
- // `require()` is no-op in an ESM module, use `createRequire()` to construct
1532
- // the require()` function. This is only necessary for multi-environment
1533
- // builds, `-sENVIRONMENT=node` emits a static import declaration instead.
1534
- // TODO: Swap all `require()`'s with `import()`'s?
1535
1541
  // These modules will usually be used on Node.js. Load them eagerly to avoid
1536
1542
  // the complexity of lazy-loading.
1537
1543
  var fs = require('fs');
1538
1544
  var nodePath = require('path');
1539
1545
 
1540
- if (ENVIRONMENT_IS_WORKER) {
1541
- scriptDirectory = nodePath.dirname(scriptDirectory) + '/';
1542
- } else {
1543
- scriptDirectory = __dirname + '/';
1544
- }
1546
+ scriptDirectory = __dirname + '/';
1545
1547
 
1546
1548
  // include: node_shell_read.js
1547
- read_ = (filename, binary) => {
1549
+ readBinary = (filename) => {
1548
1550
  // We need to re-wrap `file://` strings to URLs. Normalizing isn't
1549
1551
  // necessary in that case, the path should already be absolute.
1550
1552
  filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
1551
- return fs.readFileSync(filename, binary ? undefined : 'utf8');
1552
- };
1553
-
1554
- readBinary = (filename) => {
1555
- var ret = read_(filename, true);
1556
- if (!ret.buffer) {
1557
- ret = new Uint8Array(ret);
1558
- }
1553
+ var ret = fs.readFileSync(filename);
1559
1554
  assert(ret.buffer);
1560
1555
  return ret;
1561
1556
  };
1562
1557
 
1563
- readAsync = (filename, onload, onerror, binary = true) => {
1564
- // See the comment in the `read_` function.
1558
+ readAsync = (filename, binary = true) => {
1559
+ // See the comment in the `readBinary` function.
1565
1560
  filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
1566
- fs.readFile(filename, binary ? undefined : 'utf8', (err, data) => {
1567
- if (err) onerror(err);
1568
- else onload(binary ? data.buffer : data);
1561
+ return new Promise((resolve, reject) => {
1562
+ fs.readFile(filename, binary ? undefined : 'utf8', (err, data) => {
1563
+ if (err) reject(err);
1564
+ else resolve(binary ? data.buffer : data);
1565
+ });
1569
1566
  });
1570
1567
  };
1571
1568
  // end include: node_shell_read.js
@@ -1584,77 +1581,11 @@ readAsync = (filename, onload, onerror, binary = true) => {
1584
1581
  throw toThrow;
1585
1582
  };
1586
1583
 
1587
- Module['inspect'] = () => '[Emscripten Module object]';
1588
-
1589
1584
  } else
1590
1585
  if (ENVIRONMENT_IS_SHELL) {
1591
1586
 
1592
1587
  if ((typeof process == 'object' && typeof require === 'function') || typeof window == 'object' || typeof importScripts == 'function') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
1593
1588
 
1594
- if (typeof read != 'undefined') {
1595
- read_ = read;
1596
- }
1597
-
1598
- readBinary = (f) => {
1599
- if (typeof readbuffer == 'function') {
1600
- return new Uint8Array(readbuffer(f));
1601
- }
1602
- let data = read(f, 'binary');
1603
- assert(typeof data == 'object');
1604
- return data;
1605
- };
1606
-
1607
- readAsync = (f, onload, onerror) => {
1608
- setTimeout(() => onload(readBinary(f)));
1609
- };
1610
-
1611
- if (typeof clearTimeout == 'undefined') {
1612
- globalThis.clearTimeout = (id) => {};
1613
- }
1614
-
1615
- if (typeof setTimeout == 'undefined') {
1616
- // spidermonkey lacks setTimeout but we use it above in readAsync.
1617
- globalThis.setTimeout = (f) => (typeof f == 'function') ? f() : abort();
1618
- }
1619
-
1620
- if (typeof scriptArgs != 'undefined') {
1621
- arguments_ = scriptArgs;
1622
- } else if (typeof arguments != 'undefined') {
1623
- arguments_ = arguments;
1624
- }
1625
-
1626
- if (typeof quit == 'function') {
1627
- quit_ = (status, toThrow) => {
1628
- // Unlike node which has process.exitCode, d8 has no such mechanism. So we
1629
- // have no way to set the exit code and then let the program exit with
1630
- // that code when it naturally stops running (say, when all setTimeouts
1631
- // have completed). For that reason, we must call `quit` - the only way to
1632
- // set the exit code - but quit also halts immediately. To increase
1633
- // consistency with node (and the web) we schedule the actual quit call
1634
- // using a setTimeout to give the current stack and any exception handlers
1635
- // a chance to run. This enables features such as addOnPostRun (which
1636
- // expected to be able to run code after main returns).
1637
- setTimeout(() => {
1638
- if (!(toThrow instanceof ExitStatus)) {
1639
- let toLog = toThrow;
1640
- if (toThrow && typeof toThrow == 'object' && toThrow.stack) {
1641
- toLog = [toThrow, toThrow.stack];
1642
- }
1643
- err(`exiting due to exception: ${toLog}`);
1644
- }
1645
- quit(status);
1646
- });
1647
- throw toThrow;
1648
- };
1649
- }
1650
-
1651
- if (typeof print != 'undefined') {
1652
- // Prefer to use print/printErr where they exist, as they usually work better.
1653
- if (typeof console == 'undefined') console = /** @type{!Console} */({});
1654
- console.log = /** @type{!function(this:Console, ...*): undefined} */ (print);
1655
- console.warn = console.error = /** @type{!function(this:Console, ...*): undefined} */ (typeof printErr != 'undefined' ? printErr : print);
1656
- }
1657
-
1658
1589
  } else
1659
1590
 
1660
1591
  // Note that this includes Node.js workers when relevant (pthreads is enabled).
@@ -1672,26 +1603,17 @@ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
1672
1603
  // and scriptDirectory will correctly be replaced with an empty string.
1673
1604
  // If scriptDirectory contains a query (starting with ?) or a fragment (starting with #),
1674
1605
  // they are removed because they could contain a slash.
1675
- if (scriptDirectory.indexOf('blob:') !== 0) {
1676
- scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf('/')+1);
1677
- } else {
1606
+ if (scriptDirectory.startsWith('blob:')) {
1678
1607
  scriptDirectory = '';
1608
+ } else {
1609
+ scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, '').lastIndexOf('/')+1);
1679
1610
  }
1680
1611
 
1681
1612
  if (!(typeof window == 'object' || typeof importScripts == 'function')) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
1682
1613
 
1683
- // Differentiate the Web Worker from the Node Worker case, as reading must
1684
- // be done differently.
1685
1614
  {
1686
1615
  // include: web_or_worker_shell_read.js
1687
- read_ = (url) => {
1688
- var xhr = new XMLHttpRequest();
1689
- xhr.open('GET', url, false);
1690
- xhr.send(null);
1691
- return xhr.responseText;
1692
- }
1693
-
1694
- if (ENVIRONMENT_IS_WORKER) {
1616
+ if (ENVIRONMENT_IS_WORKER) {
1695
1617
  readBinary = (url) => {
1696
1618
  var xhr = new XMLHttpRequest();
1697
1619
  xhr.open('GET', url, false);
@@ -1701,21 +1623,34 @@ read_ = (url) => {
1701
1623
  };
1702
1624
  }
1703
1625
 
1704
- readAsync = (url, onload, onerror) => {
1705
- var xhr = new XMLHttpRequest();
1706
- xhr.open('GET', url, true);
1707
- xhr.responseType = 'arraybuffer';
1708
- xhr.onload = () => {
1709
- if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
1710
- onload(xhr.response);
1711
- return;
1712
- }
1713
- onerror();
1714
- };
1715
- xhr.onerror = onerror;
1716
- xhr.send(null);
1717
- }
1718
-
1626
+ readAsync = (url) => {
1627
+ // Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
1628
+ // See https://github.com/github/fetch/pull/92#issuecomment-140665932
1629
+ // Cordova or Electron apps are typically loaded from a file:// url.
1630
+ // So use XHR on webview if URL is a file URL.
1631
+ if (isFileURI(url)) {
1632
+ return new Promise((reject, resolve) => {
1633
+ var xhr = new XMLHttpRequest();
1634
+ xhr.open('GET', url, true);
1635
+ xhr.responseType = 'arraybuffer';
1636
+ xhr.onload = () => {
1637
+ if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
1638
+ resolve(xhr.response);
1639
+ }
1640
+ reject(xhr.status);
1641
+ };
1642
+ xhr.onerror = reject;
1643
+ xhr.send(null);
1644
+ });
1645
+ }
1646
+ return fetch(url, { credentials: 'same-origin' })
1647
+ .then((response) => {
1648
+ if (response.ok) {
1649
+ return response.arrayBuffer();
1650
+ }
1651
+ return Promise.reject(new Error(response.status + ' : ' + response.url));
1652
+ })
1653
+ };
1719
1654
  // end include: web_or_worker_shell_read.js
1720
1655
  }
1721
1656
  } else
@@ -1729,7 +1664,7 @@ var err = Module['printErr'] || console.error.bind(console);
1729
1664
  // Merge back in the overrides
1730
1665
  Object.assign(Module, moduleOverrides);
1731
1666
  // Free the object hierarchy contained in the overrides, this lets the GC
1732
- // reclaim data used e.g. in memoryInitializerRequest, which is a large typed array.
1667
+ // reclaim data used.
1733
1668
  moduleOverrides = null;
1734
1669
  checkIncomingModuleAPI();
1735
1670
 
@@ -1750,13 +1685,12 @@ assert(typeof Module['memoryInitializerPrefixURL'] == 'undefined', 'Module.memor
1750
1685
  assert(typeof Module['pthreadMainPrefixURL'] == 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead');
1751
1686
  assert(typeof Module['cdInitializerPrefixURL'] == 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead');
1752
1687
  assert(typeof Module['filePackagePrefixURL'] == 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead');
1753
- assert(typeof Module['read'] == 'undefined', 'Module.read option was removed (modify read_ in JS)');
1688
+ assert(typeof Module['read'] == 'undefined', 'Module.read option was removed');
1754
1689
  assert(typeof Module['readAsync'] == 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)');
1755
1690
  assert(typeof Module['readBinary'] == 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)');
1756
1691
  assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)');
1757
1692
  assert(typeof Module['TOTAL_MEMORY'] == 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY');
1758
1693
  legacyModuleProp('asm', 'wasmExports');
1759
- legacyModuleProp('read', 'read_');
1760
1694
  legacyModuleProp('readAsync', 'readAsync');
1761
1695
  legacyModuleProp('readBinary', 'readBinary');
1762
1696
  legacyModuleProp('setWindowTitle', 'setWindowTitle');
@@ -1770,10 +1704,10 @@ var OPFS = 'OPFS is no longer included by default; build with -lopfs.js';
1770
1704
 
1771
1705
  var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js';
1772
1706
 
1773
- assert(!ENVIRONMENT_IS_SHELL, "shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable.");
1774
-
1707
+ assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.');
1775
1708
 
1776
1709
  // end include: shell.js
1710
+
1777
1711
  // include: preamble.js
1778
1712
  // === Preamble library stuff ===
1779
1713
 
@@ -1789,7 +1723,7 @@ var wasmBinary;
1789
1723
  if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];legacyModuleProp('wasmBinary', 'wasmBinary');
1790
1724
 
1791
1725
  if (typeof WebAssembly != 'object') {
1792
- abort('no native wasm support detected');
1726
+ err('no native wasm support detected');
1793
1727
  }
1794
1728
 
1795
1729
  // Wasm globals
@@ -1843,6 +1777,7 @@ var HEAP,
1843
1777
  /** @type {!Float64Array} */
1844
1778
  HEAPF64;
1845
1779
 
1780
+ // include: runtime_shared.js
1846
1781
  function updateMemoryViews() {
1847
1782
  var b = wasmMemory.buffer;
1848
1783
  Module['HEAP8'] = HEAP8 = new Int8Array(b);
@@ -1854,7 +1789,7 @@ function updateMemoryViews() {
1854
1789
  Module['HEAPF32'] = HEAPF32 = new Float32Array(b);
1855
1790
  Module['HEAPF64'] = HEAPF64 = new Float64Array(b);
1856
1791
  }
1857
-
1792
+ // end include: runtime_shared.js
1858
1793
  assert(!Module['STACK_SIZE'], 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time')
1859
1794
 
1860
1795
  assert(typeof Int32Array != 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray != undefined && Int32Array.prototype.set != undefined,
@@ -1938,7 +1873,7 @@ function initRuntime() {
1938
1873
  setStackLimits();
1939
1874
 
1940
1875
 
1941
- if (!Module["noFSInit"] && !FS.init.initialized)
1876
+ if (!Module['noFSInit'] && !FS.init.initialized)
1942
1877
  FS.init();
1943
1878
  FS.ignorePermissions = false;
1944
1879
 
@@ -2088,7 +2023,7 @@ function abort(what) {
2088
2023
  // allows this in the wasm spec.
2089
2024
 
2090
2025
  // Suppress closure compiler warning here. Closure compiler's builtin extern
2091
- // defintion for WebAssembly.RuntimeError claims it takes no arguments even
2026
+ // definition for WebAssembly.RuntimeError claims it takes no arguments even
2092
2027
  // though it can.
2093
2028
  // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
2094
2029
  /** @suppress {checkTypes} */
@@ -2118,22 +2053,28 @@ var isDataURI = (filename) => filename.startsWith(dataURIPrefix);
2118
2053
  */
2119
2054
  var isFileURI = (filename) => filename.startsWith('file://');
2120
2055
  // end include: URIUtils.js
2121
- function createExportWrapper(name) {
2122
- return function() {
2056
+ function createExportWrapper(name, nargs) {
2057
+ return (...args) => {
2123
2058
  assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`);
2124
2059
  var f = wasmExports[name];
2125
2060
  assert(f, `exported native function \`${name}\` not found`);
2126
- return f.apply(null, arguments);
2061
+ // Only assert for too many arguments. Too few can be valid since the missing arguments will be zero filled.
2062
+ assert(args.length <= nargs, `native function \`${name}\` called with ${args.length} args but expects ${nargs}`);
2063
+ return f(...args);
2127
2064
  };
2128
2065
  }
2129
2066
 
2130
2067
  // include: runtime_exceptions.js
2131
2068
  // end include: runtime_exceptions.js
2069
+ function findWasmBinary() {
2070
+ var f = 'sql-wasm-debug.wasm';
2071
+ if (!isDataURI(f)) {
2072
+ return locateFile(f);
2073
+ }
2074
+ return f;
2075
+ }
2076
+
2132
2077
  var wasmBinaryFile;
2133
- wasmBinaryFile = 'sql-wasm-debug.wasm';
2134
- if (!isDataURI(wasmBinaryFile)) {
2135
- wasmBinaryFile = locateFile(wasmBinaryFile);
2136
- }
2137
2078
 
2138
2079
  function getBinarySync(file) {
2139
2080
  if (file == wasmBinaryFile && wasmBinary) {
@@ -2142,33 +2083,19 @@ function getBinarySync(file) {
2142
2083
  if (readBinary) {
2143
2084
  return readBinary(file);
2144
2085
  }
2145
- throw "both async and sync fetching of the wasm failed";
2086
+ throw 'both async and sync fetching of the wasm failed';
2146
2087
  }
2147
2088
 
2148
2089
  function getBinaryPromise(binaryFile) {
2149
- // If we don't have the binary yet, try to load it asynchronously.
2150
- // Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
2151
- // See https://github.com/github/fetch/pull/92#issuecomment-140665932
2152
- // Cordova or Electron apps are typically loaded from a file:// url.
2153
- // So use fetch if it is available and the url is not a file, otherwise fall back to XHR.
2090
+ // If we don't have the binary yet, load it asynchronously using readAsync.
2154
2091
  if (!wasmBinary
2155
- && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
2156
- if (typeof fetch == 'function'
2157
- && !isFileURI(binaryFile)
2158
- ) {
2159
- return fetch(binaryFile, { credentials: 'same-origin' }).then((response) => {
2160
- if (!response['ok']) {
2161
- throw "failed to load wasm binary file at '" + binaryFile + "'";
2162
- }
2163
- return response['arrayBuffer']();
2164
- }).catch(() => getBinarySync(binaryFile));
2165
- }
2166
- else if (readAsync) {
2167
- // fetch is not available or url is file => try XHR (readAsync uses XHR internally)
2168
- return new Promise((resolve, reject) => {
2169
- readAsync(binaryFile, (response) => resolve(new Uint8Array(/** @type{!ArrayBuffer} */(response))), reject)
2170
- });
2171
- }
2092
+ ) {
2093
+ // Fetch the binary using readAsync
2094
+ return readAsync(binaryFile).then(
2095
+ (response) => new Uint8Array(/** @type{!ArrayBuffer} */(response)),
2096
+ // Fall back to getBinarySync if readAsync fails
2097
+ () => getBinarySync(binaryFile)
2098
+ );
2172
2099
  }
2173
2100
 
2174
2101
  // Otherwise, getBinarySync should be able to get it synchronously
@@ -2178,8 +2105,6 @@ function getBinaryPromise(binaryFile) {
2178
2105
  function instantiateArrayBuffer(binaryFile, imports, receiver) {
2179
2106
  return getBinaryPromise(binaryFile).then((binary) => {
2180
2107
  return WebAssembly.instantiate(binary, imports);
2181
- }).then((instance) => {
2182
- return instance;
2183
2108
  }).then(receiver, (reason) => {
2184
2109
  err(`failed to asynchronously prepare wasm: ${reason}`);
2185
2110
 
@@ -2227,14 +2152,18 @@ function instantiateAsync(binary, binaryFile, imports, callback) {
2227
2152
  return instantiateArrayBuffer(binaryFile, imports, callback);
2228
2153
  }
2229
2154
 
2230
- // Create the wasm instance.
2231
- // Receives the wasm imports, returns the exports.
2232
- function createWasm() {
2155
+ function getWasmImports() {
2233
2156
  // prepare imports
2234
- var info = {
2157
+ return {
2235
2158
  'env': wasmImports,
2236
2159
  'wasi_snapshot_preview1': wasmImports,
2237
- };
2160
+ }
2161
+ }
2162
+
2163
+ // Create the wasm instance.
2164
+ // Receives the wasm imports, returns the exports.
2165
+ function createWasm() {
2166
+ var info = getWasmImports();
2238
2167
  // Load the wasm module and create an instance of using native support in the JS engine.
2239
2168
  // handle a generated wasm instance, receiving its exports and
2240
2169
  // performing other necessary setup
@@ -2246,16 +2175,12 @@ function createWasm() {
2246
2175
 
2247
2176
  wasmMemory = wasmExports['memory'];
2248
2177
 
2249
- assert(wasmMemory, "memory not found in wasm exports");
2250
- // This assertion doesn't hold when emscripten is run in --post-link
2251
- // mode.
2252
- // TODO(sbc): Read INITIAL_MEMORY out of the wasm file in post-link mode.
2253
- //assert(wasmMemory.buffer.byteLength === 16777216);
2178
+ assert(wasmMemory, 'memory not found in wasm exports');
2254
2179
  updateMemoryViews();
2255
2180
 
2256
2181
  wasmTable = wasmExports['__indirect_function_table'];
2257
2182
 
2258
- assert(wasmTable, "table not found in wasm exports");
2183
+ assert(wasmTable, 'table not found in wasm exports');
2259
2184
 
2260
2185
  addOnInit(wasmExports['__wasm_call_ctors']);
2261
2186
 
@@ -2287,7 +2212,6 @@ function createWasm() {
2287
2212
  // Also pthreads and wasm workers initialize the wasm instance through this
2288
2213
  // path.
2289
2214
  if (Module['instantiateWasm']) {
2290
-
2291
2215
  try {
2292
2216
  return Module['instantiateWasm'](info, receiveInstance);
2293
2217
  } catch(e) {
@@ -2296,6 +2220,8 @@ function createWasm() {
2296
2220
  }
2297
2221
  }
2298
2222
 
2223
+ if (!wasmBinaryFile) wasmBinaryFile = findWasmBinary();
2224
+
2299
2225
  instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult);
2300
2226
  return {}; // no exports yet; we'll fill them in later
2301
2227
  }
@@ -2305,12 +2231,12 @@ var tempDouble;
2305
2231
  var tempI64;
2306
2232
 
2307
2233
  // include: runtime_debug.js
2308
- function legacyModuleProp(prop, newName, incomming=true) {
2234
+ function legacyModuleProp(prop, newName, incoming=true) {
2309
2235
  if (!Object.getOwnPropertyDescriptor(Module, prop)) {
2310
2236
  Object.defineProperty(Module, prop, {
2311
2237
  configurable: true,
2312
2238
  get() {
2313
- let extra = incomming ? ' (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)' : '';
2239
+ let extra = incoming ? ' (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)' : '';
2314
2240
  abort(`\`Module.${prop}\` has been replaced by \`${newName}\`` + extra);
2315
2241
 
2316
2242
  }
@@ -2338,7 +2264,7 @@ function isExportedByForceFilesystem(name) {
2338
2264
  }
2339
2265
 
2340
2266
  function missingGlobal(sym, msg) {
2341
- if (typeof globalThis !== 'undefined') {
2267
+ if (typeof globalThis != 'undefined') {
2342
2268
  Object.defineProperty(globalThis, sym, {
2343
2269
  configurable: true,
2344
2270
  get() {
@@ -2353,7 +2279,7 @@ missingGlobal('buffer', 'Please use HEAP8.buffer or wasmMemory.buffer');
2353
2279
  missingGlobal('asm', 'Please use wasmExports instead');
2354
2280
 
2355
2281
  function missingLibrarySymbol(sym) {
2356
- if (typeof globalThis !== 'undefined' && !Object.getOwnPropertyDescriptor(globalThis, sym)) {
2282
+ if (typeof globalThis != 'undefined' && !Object.getOwnPropertyDescriptor(globalThis, sym)) {
2357
2283
  Object.defineProperty(globalThis, sym, {
2358
2284
  configurable: true,
2359
2285
  get() {
@@ -2376,7 +2302,7 @@ function missingLibrarySymbol(sym) {
2376
2302
  }
2377
2303
  });
2378
2304
  }
2379
- // Any symbol that is not included from the JS libary is also (by definition)
2305
+ // Any symbol that is not included from the JS library is also (by definition)
2380
2306
  // not exported on the Module object.
2381
2307
  unexportedRuntimeSymbol(sym);
2382
2308
  }
@@ -2422,16 +2348,16 @@ var checkInt53 = (value) => checkInt(value, 53, MIN_INT53, MAX_UINT53);
2422
2348
  var checkInt64 = (value) => checkInt(value, 64, MIN_INT64, MAX_UINT64);
2423
2349
 
2424
2350
  // Used by XXXXX_DEBUG settings to output debug messages.
2425
- function dbg(text) {
2351
+ function dbg(...args) {
2426
2352
  // TODO(sbc): Make this configurable somehow. Its not always convenient for
2427
2353
  // logging to show up as warnings.
2428
- console.warn.apply(console, arguments);
2354
+ console.warn(...args);
2429
2355
  }
2430
2356
  // end include: runtime_debug.js
2431
2357
  // === Body ===
2432
-
2433
2358
  // end include: preamble.js
2434
2359
 
2360
+
2435
2361
  /** @constructor */
2436
2362
  function ExitStatus(status) {
2437
2363
  this.name = 'ExitStatus';
@@ -2454,8 +2380,8 @@ function dbg(text) {
2454
2380
  function getValue(ptr, type = 'i8') {
2455
2381
  if (type.endsWith('*')) type = '*';
2456
2382
  switch (type) {
2457
- case 'i1': return HEAP8[((ptr)>>0)];
2458
- case 'i8': return HEAP8[((ptr)>>0)];
2383
+ case 'i1': return HEAP8[ptr];
2384
+ case 'i8': return HEAP8[ptr];
2459
2385
  case 'i16': return HEAP16[((ptr)>>1)];
2460
2386
  case 'i32': return HEAP32[((ptr)>>2)];
2461
2387
  case 'i64': abort('to do getValue(i64) use WASM_BIGINT');
@@ -2490,8 +2416,8 @@ function dbg(text) {
2490
2416
  function setValue(ptr, value, type = 'i8') {
2491
2417
  if (type.endsWith('*')) type = '*';
2492
2418
  switch (type) {
2493
- case 'i1': HEAP8[((ptr)>>0)] = value;checkInt8(value); break;
2494
- case 'i8': HEAP8[((ptr)>>0)] = value;checkInt8(value); break;
2419
+ case 'i1': HEAP8[ptr] = value;checkInt8(value); break;
2420
+ case 'i8': HEAP8[ptr] = value;checkInt8(value); break;
2495
2421
  case 'i16': HEAP16[((ptr)>>1)] = value;checkInt16(value); break;
2496
2422
  case 'i32': HEAP32[((ptr)>>2)] = value;checkInt32(value); break;
2497
2423
  case 'i64': abort('to do setValue(i64) use WASM_BIGINT');
@@ -2502,6 +2428,10 @@ function dbg(text) {
2502
2428
  }
2503
2429
  }
2504
2430
 
2431
+ var stackRestore = (val) => __emscripten_stack_restore(val);
2432
+
2433
+ var stackSave = () => _emscripten_stack_get_current();
2434
+
2505
2435
  var warnOnce = (text) => {
2506
2436
  warnOnce.shown ||= {};
2507
2437
  if (!warnOnce.shown[text]) {
@@ -2511,7 +2441,7 @@ function dbg(text) {
2511
2441
  }
2512
2442
  };
2513
2443
 
2514
- var UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf8') : undefined;
2444
+ var UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder() : undefined;
2515
2445
 
2516
2446
  /**
2517
2447
  * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
@@ -2663,10 +2593,7 @@ function dbg(text) {
2663
2593
  if (lastSlash === -1) return path;
2664
2594
  return path.substr(lastSlash+1);
2665
2595
  },
2666
- join:function() {
2667
- var paths = Array.prototype.slice.call(arguments);
2668
- return PATH.normalize(paths.join('/'));
2669
- },
2596
+ join:(...paths) => PATH.normalize(paths.join('/')),
2670
2597
  join2:(l, r) => PATH.normalize(l + '/' + r),
2671
2598
  };
2672
2599
 
@@ -2696,7 +2623,7 @@ function dbg(text) {
2696
2623
  }
2697
2624
  }
2698
2625
  // we couldn't find a proper implementation, as Math.random() is not suitable for /dev/random, see emscripten-core/emscripten/pull/7096
2699
- abort("no cryptographic support found for randomDevice. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: (array) => { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };");
2626
+ abort('no cryptographic support found for randomDevice. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: (array) => { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };');
2700
2627
  };
2701
2628
  var randomFill = (view) => {
2702
2629
  // Lazily init on the first invocation.
@@ -2706,11 +2633,11 @@ function dbg(text) {
2706
2633
 
2707
2634
 
2708
2635
  var PATH_FS = {
2709
- resolve:function() {
2636
+ resolve:(...args) => {
2710
2637
  var resolvedPath = '',
2711
2638
  resolvedAbsolute = false;
2712
- for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
2713
- var path = (i >= 0) ? arguments[i] : FS.cwd();
2639
+ for (var i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
2640
+ var path = (i >= 0) ? args[i] : FS.cwd();
2714
2641
  // Skip empty and invalid entries
2715
2642
  if (typeof path != 'string') {
2716
2643
  throw new TypeError('Arguments to path.resolve must be strings');
@@ -2858,18 +2785,17 @@ function dbg(text) {
2858
2785
  var fd = process.stdin.fd;
2859
2786
 
2860
2787
  try {
2861
- bytesRead = fs.readSync(fd, buf);
2788
+ bytesRead = fs.readSync(fd, buf, 0, BUFSIZE);
2862
2789
  } catch(e) {
2863
- // Cross-platform differences: on Windows, reading EOF throws an exception, but on other OSes,
2864
- // reading EOF returns 0. Uniformize behavior by treating the EOF exception to return 0.
2790
+ // Cross-platform differences: on Windows, reading EOF throws an
2791
+ // exception, but on other OSes, reading EOF returns 0. Uniformize
2792
+ // behavior by treating the EOF exception to return 0.
2865
2793
  if (e.toString().includes('EOF')) bytesRead = 0;
2866
2794
  else throw e;
2867
2795
  }
2868
2796
 
2869
2797
  if (bytesRead > 0) {
2870
2798
  result = buf.slice(0, bytesRead).toString('utf-8');
2871
- } else {
2872
- result = null;
2873
2799
  }
2874
2800
  } else
2875
2801
  if (typeof window != 'undefined' &&
@@ -2879,13 +2805,8 @@ function dbg(text) {
2879
2805
  if (result !== null) {
2880
2806
  result += '\n';
2881
2807
  }
2882
- } else if (typeof readline == 'function') {
2883
- // Command line.
2884
- result = readline();
2885
- if (result !== null) {
2886
- result += '\n';
2887
- }
2888
- }
2808
+ } else
2809
+ {}
2889
2810
  if (!result) {
2890
2811
  return null;
2891
2812
  }
@@ -3234,7 +3155,6 @@ function dbg(text) {
3234
3155
  old_node.name = new_name;
3235
3156
  new_dir.contents[new_name] = old_node;
3236
3157
  new_dir.timestamp = old_node.parent.timestamp;
3237
- old_node.parent = new_dir;
3238
3158
  },
3239
3159
  unlink(parent, name) {
3240
3160
  delete parent.contents[name];
@@ -3384,17 +3304,20 @@ function dbg(text) {
3384
3304
  /** @param {boolean=} noRunDep */
3385
3305
  var asyncLoad = (url, onload, onerror, noRunDep) => {
3386
3306
  var dep = !noRunDep ? getUniqueRunDependency(`al ${url}`) : '';
3387
- readAsync(url, (arrayBuffer) => {
3388
- assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
3389
- onload(new Uint8Array(arrayBuffer));
3390
- if (dep) removeRunDependency(dep);
3391
- }, (event) => {
3392
- if (onerror) {
3393
- onerror();
3394
- } else {
3395
- throw `Loading data file "${url}" failed.`;
3307
+ readAsync(url).then(
3308
+ (arrayBuffer) => {
3309
+ assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
3310
+ onload(new Uint8Array(arrayBuffer));
3311
+ if (dep) removeRunDependency(dep);
3312
+ },
3313
+ (err) => {
3314
+ if (onerror) {
3315
+ onerror();
3316
+ } else {
3317
+ throw `Loading data file "${url}" failed.`;
3318
+ }
3396
3319
  }
3397
- });
3320
+ );
3398
3321
  if (dep) addRunDependency(dep);
3399
3322
  };
3400
3323
 
@@ -3442,7 +3365,7 @@ function dbg(text) {
3442
3365
  }
3443
3366
  addRunDependency(dep);
3444
3367
  if (typeof url == 'string') {
3445
- asyncLoad(url, (byteArray) => processData(byteArray), onerror);
3368
+ asyncLoad(url, processData, onerror);
3446
3369
  } else {
3447
3370
  processData(url);
3448
3371
  }
@@ -3474,127 +3397,11 @@ function dbg(text) {
3474
3397
 
3475
3398
 
3476
3399
 
3477
- var ERRNO_MESSAGES = {
3478
- 0:"Success",
3479
- 1:"Arg list too long",
3480
- 2:"Permission denied",
3481
- 3:"Address already in use",
3482
- 4:"Address not available",
3483
- 5:"Address family not supported by protocol family",
3484
- 6:"No more processes",
3485
- 7:"Socket already connected",
3486
- 8:"Bad file number",
3487
- 9:"Trying to read unreadable message",
3488
- 10:"Mount device busy",
3489
- 11:"Operation canceled",
3490
- 12:"No children",
3491
- 13:"Connection aborted",
3492
- 14:"Connection refused",
3493
- 15:"Connection reset by peer",
3494
- 16:"File locking deadlock error",
3495
- 17:"Destination address required",
3496
- 18:"Math arg out of domain of func",
3497
- 19:"Quota exceeded",
3498
- 20:"File exists",
3499
- 21:"Bad address",
3500
- 22:"File too large",
3501
- 23:"Host is unreachable",
3502
- 24:"Identifier removed",
3503
- 25:"Illegal byte sequence",
3504
- 26:"Connection already in progress",
3505
- 27:"Interrupted system call",
3506
- 28:"Invalid argument",
3507
- 29:"I/O error",
3508
- 30:"Socket is already connected",
3509
- 31:"Is a directory",
3510
- 32:"Too many symbolic links",
3511
- 33:"Too many open files",
3512
- 34:"Too many links",
3513
- 35:"Message too long",
3514
- 36:"Multihop attempted",
3515
- 37:"File or path name too long",
3516
- 38:"Network interface is not configured",
3517
- 39:"Connection reset by network",
3518
- 40:"Network is unreachable",
3519
- 41:"Too many open files in system",
3520
- 42:"No buffer space available",
3521
- 43:"No such device",
3522
- 44:"No such file or directory",
3523
- 45:"Exec format error",
3524
- 46:"No record locks available",
3525
- 47:"The link has been severed",
3526
- 48:"Not enough core",
3527
- 49:"No message of desired type",
3528
- 50:"Protocol not available",
3529
- 51:"No space left on device",
3530
- 52:"Function not implemented",
3531
- 53:"Socket is not connected",
3532
- 54:"Not a directory",
3533
- 55:"Directory not empty",
3534
- 56:"State not recoverable",
3535
- 57:"Socket operation on non-socket",
3536
- 59:"Not a typewriter",
3537
- 60:"No such device or address",
3538
- 61:"Value too large for defined data type",
3539
- 62:"Previous owner died",
3540
- 63:"Not super-user",
3541
- 64:"Broken pipe",
3542
- 65:"Protocol error",
3543
- 66:"Unknown protocol",
3544
- 67:"Protocol wrong type for socket",
3545
- 68:"Math result not representable",
3546
- 69:"Read only file system",
3547
- 70:"Illegal seek",
3548
- 71:"No such process",
3549
- 72:"Stale file handle",
3550
- 73:"Connection timed out",
3551
- 74:"Text file busy",
3552
- 75:"Cross-device link",
3553
- 100:"Device not a stream",
3554
- 101:"Bad font file fmt",
3555
- 102:"Invalid slot",
3556
- 103:"Invalid request code",
3557
- 104:"No anode",
3558
- 105:"Block device required",
3559
- 106:"Channel number out of range",
3560
- 107:"Level 3 halted",
3561
- 108:"Level 3 reset",
3562
- 109:"Link number out of range",
3563
- 110:"Protocol driver not attached",
3564
- 111:"No CSI structure available",
3565
- 112:"Level 2 halted",
3566
- 113:"Invalid exchange",
3567
- 114:"Invalid request descriptor",
3568
- 115:"Exchange full",
3569
- 116:"No data (for no delay io)",
3570
- 117:"Timer expired",
3571
- 118:"Out of streams resources",
3572
- 119:"Machine is not on the network",
3573
- 120:"Package not installed",
3574
- 121:"The object is remote",
3575
- 122:"Advertise error",
3576
- 123:"Srmount error",
3577
- 124:"Communication error on send",
3578
- 125:"Cross mount point (not really error)",
3579
- 126:"Given log. name not unique",
3580
- 127:"f.d. invalid for this operation",
3581
- 128:"Remote address changed",
3582
- 129:"Can access a needed shared lib",
3583
- 130:"Accessing a corrupted shared lib",
3584
- 131:".lib section in a.out corrupted",
3585
- 132:"Attempting to link in too many libs",
3586
- 133:"Attempting to exec a shared library",
3587
- 135:"Streams pipe error",
3588
- 136:"Too many users",
3589
- 137:"Socket type not supported",
3590
- 138:"Not supported",
3591
- 139:"Protocol family not supported",
3592
- 140:"Can't send after socket shutdown",
3593
- 141:"Too many references",
3594
- 142:"Host is down",
3595
- 148:"No medium (in tape drive)",
3596
- 156:"Level 2 not synchronized",
3597
- };
3400
+
3401
+
3402
+ var strError = (errno) => {
3403
+ return UTF8ToString(_strerror(errno));
3404
+ };
3598
3405
 
3599
3406
  var ERRNO_CODES = {
3600
3407
  'EPERM': 63,
@@ -3719,20 +3526,6 @@ function dbg(text) {
3719
3526
  'EOWNERDEAD': 62,
3720
3527
  'ESTRPIPE': 135,
3721
3528
  };
3722
-
3723
- var demangle = (func) => {
3724
- warnOnce('warning: build with -sDEMANGLE_SUPPORT to link in libcxxabi demangling');
3725
- return func;
3726
- };
3727
- var demangleAll = (text) => {
3728
- var regex =
3729
- /\b_Z[\w\d_]+/g;
3730
- return text.replace(regex,
3731
- function(x) {
3732
- var y = demangle(x);
3733
- return x === y ? x : (y + ' [' + x + ']');
3734
- });
3735
- };
3736
3529
  var FS = {
3737
3530
  root:null,
3738
3531
  mounts:[],
@@ -3744,11 +3537,101 @@ function dbg(text) {
3744
3537
  currentPath:"/",
3745
3538
  initialized:false,
3746
3539
  ignorePermissions:true,
3747
- ErrnoError:null,
3540
+ ErrnoError:class extends Error {
3541
+ // We set the `name` property to be able to identify `FS.ErrnoError`
3542
+ // - the `name` is a standard ECMA-262 property of error objects. Kind of good to have it anyway.
3543
+ // - when using PROXYFS, an error can come from an underlying FS
3544
+ // as different FS objects have their own FS.ErrnoError each,
3545
+ // the test `err instanceof FS.ErrnoError` won't detect an error coming from another filesystem, causing bugs.
3546
+ // we'll use the reliable test `err.name == "ErrnoError"` instead
3547
+ constructor(errno) {
3548
+ super(runtimeInitialized ? strError(errno) : '');
3549
+ // TODO(sbc): Use the inline member declaration syntax once we
3550
+ // support it in acorn and closure.
3551
+ this.name = 'ErrnoError';
3552
+ this.errno = errno;
3553
+ for (var key in ERRNO_CODES) {
3554
+ if (ERRNO_CODES[key] === errno) {
3555
+ this.code = key;
3556
+ break;
3557
+ }
3558
+ }
3559
+ }
3560
+ },
3748
3561
  genericErrors:{
3749
3562
  },
3750
3563
  filesystems:null,
3751
3564
  syncFSRequests:0,
3565
+ FSStream:class {
3566
+ constructor() {
3567
+ // TODO(https://github.com/emscripten-core/emscripten/issues/21414):
3568
+ // Use inline field declarations.
3569
+ this.shared = {};
3570
+ }
3571
+ get object() {
3572
+ return this.node;
3573
+ }
3574
+ set object(val) {
3575
+ this.node = val;
3576
+ }
3577
+ get isRead() {
3578
+ return (this.flags & 2097155) !== 1;
3579
+ }
3580
+ get isWrite() {
3581
+ return (this.flags & 2097155) !== 0;
3582
+ }
3583
+ get isAppend() {
3584
+ return (this.flags & 1024);
3585
+ }
3586
+ get flags() {
3587
+ return this.shared.flags;
3588
+ }
3589
+ set flags(val) {
3590
+ this.shared.flags = val;
3591
+ }
3592
+ get position() {
3593
+ return this.shared.position;
3594
+ }
3595
+ set position(val) {
3596
+ this.shared.position = val;
3597
+ }
3598
+ },
3599
+ FSNode:class {
3600
+ constructor(parent, name, mode, rdev) {
3601
+ if (!parent) {
3602
+ parent = this; // root node sets parent to itself
3603
+ }
3604
+ this.parent = parent;
3605
+ this.mount = parent.mount;
3606
+ this.mounted = null;
3607
+ this.id = FS.nextInode++;
3608
+ this.name = name;
3609
+ this.mode = mode;
3610
+ this.node_ops = {};
3611
+ this.stream_ops = {};
3612
+ this.rdev = rdev;
3613
+ this.readMode = 292/*292*/ | 73/*73*/;
3614
+ this.writeMode = 146/*146*/;
3615
+ }
3616
+ get read() {
3617
+ return (this.mode & this.readMode) === this.readMode;
3618
+ }
3619
+ set read(val) {
3620
+ val ? this.mode |= this.readMode : this.mode &= ~this.readMode;
3621
+ }
3622
+ get write() {
3623
+ return (this.mode & this.writeMode) === this.writeMode;
3624
+ }
3625
+ set write(val) {
3626
+ val ? this.mode |= this.writeMode : this.mode &= ~this.writeMode;
3627
+ }
3628
+ get isFolder() {
3629
+ return FS.isDir(this.mode);
3630
+ }
3631
+ get isDevice() {
3632
+ return FS.isChrdev(this.mode);
3633
+ }
3634
+ },
3752
3635
  lookupPath(path, opts = {}) {
3753
3636
  path = PATH_FS.resolve(path);
3754
3637
 
@@ -3851,7 +3734,7 @@ function dbg(text) {
3851
3734
  lookupNode(parent, name) {
3852
3735
  var errCode = FS.mayLookup(parent);
3853
3736
  if (errCode) {
3854
- throw new FS.ErrnoError(errCode, parent);
3737
+ throw new FS.ErrnoError(errCode);
3855
3738
  }
3856
3739
  var hash = FS.hashName(parent.id, name);
3857
3740
  for (var node = FS.nameTable[hash]; node; node = node.name_next) {
@@ -3923,6 +3806,7 @@ function dbg(text) {
3923
3806
  return 0;
3924
3807
  },
3925
3808
  mayLookup(dir) {
3809
+ if (!FS.isDir(dir.mode)) return 54;
3926
3810
  var errCode = FS.nodePermissions(dir, 'x');
3927
3811
  if (errCode) return errCode;
3928
3812
  if (!dir.node_ops.lookup) return 2;
@@ -3993,44 +3877,8 @@ function dbg(text) {
3993
3877
  },
3994
3878
  getStream:(fd) => FS.streams[fd],
3995
3879
  createStream(stream, fd = -1) {
3996
- if (!FS.FSStream) {
3997
- FS.FSStream = /** @constructor */ function() {
3998
- this.shared = { };
3999
- };
4000
- FS.FSStream.prototype = {};
4001
- Object.defineProperties(FS.FSStream.prototype, {
4002
- object: {
4003
- /** @this {FS.FSStream} */
4004
- get() { return this.node; },
4005
- /** @this {FS.FSStream} */
4006
- set(val) { this.node = val; }
4007
- },
4008
- isRead: {
4009
- /** @this {FS.FSStream} */
4010
- get() { return (this.flags & 2097155) !== 1; }
4011
- },
4012
- isWrite: {
4013
- /** @this {FS.FSStream} */
4014
- get() { return (this.flags & 2097155) !== 0; }
4015
- },
4016
- isAppend: {
4017
- /** @this {FS.FSStream} */
4018
- get() { return (this.flags & 1024); }
4019
- },
4020
- flags: {
4021
- /** @this {FS.FSStream} */
4022
- get() { return this.shared.flags; },
4023
- /** @this {FS.FSStream} */
4024
- set(val) { this.shared.flags = val; },
4025
- },
4026
- position : {
4027
- /** @this {FS.FSStream} */
4028
- get() { return this.shared.position; },
4029
- /** @this {FS.FSStream} */
4030
- set(val) { this.shared.position = val; },
4031
- },
4032
- });
4033
- }
3880
+ assert(fd >= -1);
3881
+
4034
3882
  // clone it, so we can return an instance of FSStream
4035
3883
  stream = Object.assign(new FS.FSStream(), stream);
4036
3884
  if (fd == -1) {
@@ -4043,6 +3891,11 @@ function dbg(text) {
4043
3891
  closeStream(fd) {
4044
3892
  FS.streams[fd] = null;
4045
3893
  },
3894
+ dupStream(origStream, fd = -1) {
3895
+ var stream = FS.createStream(origStream, fd);
3896
+ stream.stream_ops?.dup?.(stream);
3897
+ return stream;
3898
+ },
4046
3899
  chrdev_stream_ops:{
4047
3900
  open(stream) {
4048
3901
  var device = FS.getDevice(stream.node.rdev);
@@ -4071,7 +3924,7 @@ function dbg(text) {
4071
3924
 
4072
3925
  mounts.push(m);
4073
3926
 
4074
- check.push.apply(check, m.mounts);
3927
+ check.push(...m.mounts);
4075
3928
  }
4076
3929
 
4077
3930
  return mounts;
@@ -4284,7 +4137,7 @@ function dbg(text) {
4284
4137
  // parents must exist
4285
4138
  var lookup, old_dir, new_dir;
4286
4139
 
4287
- // let the errors from non existant directories percolate up
4140
+ // let the errors from non existent directories percolate up
4288
4141
  lookup = FS.lookupPath(old_path, { parent: true });
4289
4142
  old_dir = lookup.node;
4290
4143
  lookup = FS.lookupPath(new_path, { parent: true });
@@ -4350,6 +4203,9 @@ function dbg(text) {
4350
4203
  // do the underlying fs rename
4351
4204
  try {
4352
4205
  old_dir.node_ops.rename(old_node, new_dir, new_name);
4206
+ // update old node (we do this here to avoid each backend
4207
+ // needing to)
4208
+ old_node.parent = new_dir;
4353
4209
  } catch (e) {
4354
4210
  throw e;
4355
4211
  } finally {
@@ -4527,8 +4383,8 @@ function dbg(text) {
4527
4383
  throw new FS.ErrnoError(44);
4528
4384
  }
4529
4385
  flags = typeof flags == 'string' ? FS_modeStringToFlags(flags) : flags;
4530
- mode = typeof mode == 'undefined' ? 438 /* 0666 */ : mode;
4531
4386
  if ((flags & 64)) {
4387
+ mode = typeof mode == 'undefined' ? 438 /* 0666 */ : mode;
4532
4388
  mode = (mode & 4095) | 32768;
4533
4389
  } else {
4534
4390
  mode = 0;
@@ -4748,7 +4604,6 @@ function dbg(text) {
4748
4604
  }
4749
4605
  return stream.stream_ops.msync(stream, buffer, offset, length, mmapFlags);
4750
4606
  },
4751
- munmap:(stream) => 0,
4752
4607
  ioctl(stream, cmd, arg) {
4753
4608
  if (!stream.stream_ops.ioctl) {
4754
4609
  throw new FS.ErrnoError(59);
@@ -4900,47 +4755,12 @@ function dbg(text) {
4900
4755
  assert(stdout.fd === 1, `invalid handle for stdout (${stdout.fd})`);
4901
4756
  assert(stderr.fd === 2, `invalid handle for stderr (${stderr.fd})`);
4902
4757
  },
4903
- ensureErrnoError() {
4904
- if (FS.ErrnoError) return;
4905
- FS.ErrnoError = /** @this{Object} */ function ErrnoError(errno, node) {
4906
- // We set the `name` property to be able to identify `FS.ErrnoError`
4907
- // - the `name` is a standard ECMA-262 property of error objects. Kind of good to have it anyway.
4908
- // - when using PROXYFS, an error can come from an underlying FS
4909
- // as different FS objects have their own FS.ErrnoError each,
4910
- // the test `err instanceof FS.ErrnoError` won't detect an error coming from another filesystem, causing bugs.
4911
- // we'll use the reliable test `err.name == "ErrnoError"` instead
4912
- this.name = 'ErrnoError';
4913
- this.node = node;
4914
- this.setErrno = /** @this{Object} */ function(errno) {
4915
- this.errno = errno;
4916
- for (var key in ERRNO_CODES) {
4917
- if (ERRNO_CODES[key] === errno) {
4918
- this.code = key;
4919
- break;
4920
- }
4921
- }
4922
- };
4923
- this.setErrno(errno);
4924
- this.message = ERRNO_MESSAGES[errno];
4925
-
4926
- // Try to get a maximally helpful stack trace. On Node.js, getting Error.stack
4927
- // now ensures it shows what we want.
4928
- if (this.stack) {
4929
- // Define the stack property for Node.js 4, which otherwise errors on the next line.
4930
- Object.defineProperty(this, "stack", { value: (new Error).stack, writable: true });
4931
- this.stack = demangleAll(this.stack);
4932
- }
4933
- };
4934
- FS.ErrnoError.prototype = new Error();
4935
- FS.ErrnoError.prototype.constructor = FS.ErrnoError;
4758
+ staticInit() {
4936
4759
  // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
4937
4760
  [44].forEach((code) => {
4938
4761
  FS.genericErrors[code] = new FS.ErrnoError(code);
4939
4762
  FS.genericErrors[code].stack = '<generic error, no stack>';
4940
4763
  });
4941
- },
4942
- staticInit() {
4943
- FS.ensureErrnoError();
4944
4764
 
4945
4765
  FS.nameTable = new Array(4096);
4946
4766
 
@@ -4958,8 +4778,6 @@ function dbg(text) {
4958
4778
  assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
4959
4779
  FS.init.initialized = true;
4960
4780
 
4961
- FS.ensureErrnoError();
4962
-
4963
4781
  // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
4964
4782
  Module['stdin'] = input || Module['stdin'];
4965
4783
  Module['stdout'] = output || Module['stdout'];
@@ -5116,122 +4934,113 @@ function dbg(text) {
5116
4934
  if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
5117
4935
  if (typeof XMLHttpRequest != 'undefined') {
5118
4936
  throw new Error("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.");
5119
- } else if (read_) {
5120
- // Command-line.
4937
+ } else { // Command-line.
5121
4938
  try {
5122
- // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as
5123
- // read() will try to parse UTF8.
5124
- obj.contents = intArrayFromString(read_(obj.url), true);
4939
+ obj.contents = readBinary(obj.url);
5125
4940
  obj.usedBytes = obj.contents.length;
5126
4941
  } catch (e) {
5127
4942
  throw new FS.ErrnoError(29);
5128
4943
  }
5129
- } else {
5130
- throw new Error('Cannot load without read() or XMLHttpRequest.');
5131
4944
  }
5132
4945
  },
5133
4946
  createLazyFile(parent, name, url, canRead, canWrite) {
5134
- // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.
5135
- /** @constructor */
5136
- function LazyUint8Array() {
5137
- this.lengthKnown = false;
5138
- this.chunks = []; // Loaded chunks. Index is the chunk number
5139
- }
5140
- LazyUint8Array.prototype.get = /** @this{Object} */ function LazyUint8Array_get(idx) {
5141
- if (idx > this.length-1 || idx < 0) {
5142
- return undefined;
4947
+ // Lazy chunked Uint8Array (implements get and length from Uint8Array).
4948
+ // Actual getting is abstracted away for eventual reuse.
4949
+ class LazyUint8Array {
4950
+ constructor() {
4951
+ this.lengthKnown = false;
4952
+ this.chunks = []; // Loaded chunks. Index is the chunk number
5143
4953
  }
5144
- var chunkOffset = idx % this.chunkSize;
5145
- var chunkNum = (idx / this.chunkSize)|0;
5146
- return this.getter(chunkNum)[chunkOffset];
5147
- };
5148
- LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
5149
- this.getter = getter;
5150
- };
5151
- LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
5152
- // Find length
5153
- var xhr = new XMLHttpRequest();
5154
- xhr.open('HEAD', url, false);
5155
- xhr.send(null);
5156
- if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
5157
- var datalength = Number(xhr.getResponseHeader("Content-length"));
5158
- var header;
5159
- var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
5160
- var usesGzip = (header = xhr.getResponseHeader("Content-Encoding")) && header === "gzip";
5161
-
5162
- var chunkSize = 1024*1024; // Chunk size in bytes
5163
-
5164
- if (!hasByteServing) chunkSize = datalength;
5165
-
5166
- // Function to get a range from the remote URL.
5167
- var doXHR = (from, to) => {
5168
- if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
5169
- if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
5170
-
5171
- // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
4954
+ get(idx) {
4955
+ if (idx > this.length-1 || idx < 0) {
4956
+ return undefined;
4957
+ }
4958
+ var chunkOffset = idx % this.chunkSize;
4959
+ var chunkNum = (idx / this.chunkSize)|0;
4960
+ return this.getter(chunkNum)[chunkOffset];
4961
+ }
4962
+ setDataGetter(getter) {
4963
+ this.getter = getter;
4964
+ }
4965
+ cacheLength() {
4966
+ // Find length
5172
4967
  var xhr = new XMLHttpRequest();
5173
- xhr.open('GET', url, false);
5174
- if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
4968
+ xhr.open('HEAD', url, false);
4969
+ xhr.send(null);
4970
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
4971
+ var datalength = Number(xhr.getResponseHeader("Content-length"));
4972
+ var header;
4973
+ var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
4974
+ var usesGzip = (header = xhr.getResponseHeader("Content-Encoding")) && header === "gzip";
4975
+
4976
+ var chunkSize = 1024*1024; // Chunk size in bytes
4977
+
4978
+ if (!hasByteServing) chunkSize = datalength;
4979
+
4980
+ // Function to get a range from the remote URL.
4981
+ var doXHR = (from, to) => {
4982
+ if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
4983
+ if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
4984
+
4985
+ // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
4986
+ var xhr = new XMLHttpRequest();
4987
+ xhr.open('GET', url, false);
4988
+ if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
4989
+
4990
+ // Some hints to the browser that we want binary data.
4991
+ xhr.responseType = 'arraybuffer';
4992
+ if (xhr.overrideMimeType) {
4993
+ xhr.overrideMimeType('text/plain; charset=x-user-defined');
4994
+ }
5175
4995
 
5176
- // Some hints to the browser that we want binary data.
5177
- xhr.responseType = 'arraybuffer';
5178
- if (xhr.overrideMimeType) {
5179
- xhr.overrideMimeType('text/plain; charset=x-user-defined');
4996
+ xhr.send(null);
4997
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
4998
+ if (xhr.response !== undefined) {
4999
+ return new Uint8Array(/** @type{Array<number>} */(xhr.response || []));
5000
+ }
5001
+ return intArrayFromString(xhr.responseText || '', true);
5002
+ };
5003
+ var lazyArray = this;
5004
+ lazyArray.setDataGetter((chunkNum) => {
5005
+ var start = chunkNum * chunkSize;
5006
+ var end = (chunkNum+1) * chunkSize - 1; // including this byte
5007
+ end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
5008
+ if (typeof lazyArray.chunks[chunkNum] == 'undefined') {
5009
+ lazyArray.chunks[chunkNum] = doXHR(start, end);
5010
+ }
5011
+ if (typeof lazyArray.chunks[chunkNum] == 'undefined') throw new Error('doXHR failed!');
5012
+ return lazyArray.chunks[chunkNum];
5013
+ });
5014
+
5015
+ if (usesGzip || !datalength) {
5016
+ // if the server uses gzip or doesn't supply the length, we have to download the whole file to get the (uncompressed) length
5017
+ chunkSize = datalength = 1; // this will force getter(0)/doXHR do download the whole file
5018
+ datalength = this.getter(0).length;
5019
+ chunkSize = datalength;
5020
+ out("LazyFiles on gzip forces download of the whole file when length is accessed");
5180
5021
  }
5181
5022
 
5182
- xhr.send(null);
5183
- if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
5184
- if (xhr.response !== undefined) {
5185
- return new Uint8Array(/** @type{Array<number>} */(xhr.response || []));
5023
+ this._length = datalength;
5024
+ this._chunkSize = chunkSize;
5025
+ this.lengthKnown = true;
5026
+ }
5027
+ get length() {
5028
+ if (!this.lengthKnown) {
5029
+ this.cacheLength();
5186
5030
  }
5187
- return intArrayFromString(xhr.responseText || '', true);
5188
- };
5189
- var lazyArray = this;
5190
- lazyArray.setDataGetter((chunkNum) => {
5191
- var start = chunkNum * chunkSize;
5192
- var end = (chunkNum+1) * chunkSize - 1; // including this byte
5193
- end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
5194
- if (typeof lazyArray.chunks[chunkNum] == 'undefined') {
5195
- lazyArray.chunks[chunkNum] = doXHR(start, end);
5031
+ return this._length;
5032
+ }
5033
+ get chunkSize() {
5034
+ if (!this.lengthKnown) {
5035
+ this.cacheLength();
5196
5036
  }
5197
- if (typeof lazyArray.chunks[chunkNum] == 'undefined') throw new Error('doXHR failed!');
5198
- return lazyArray.chunks[chunkNum];
5199
- });
5200
-
5201
- if (usesGzip || !datalength) {
5202
- // if the server uses gzip or doesn't supply the length, we have to download the whole file to get the (uncompressed) length
5203
- chunkSize = datalength = 1; // this will force getter(0)/doXHR do download the whole file
5204
- datalength = this.getter(0).length;
5205
- chunkSize = datalength;
5206
- out("LazyFiles on gzip forces download of the whole file when length is accessed");
5037
+ return this._chunkSize;
5207
5038
  }
5039
+ }
5208
5040
 
5209
- this._length = datalength;
5210
- this._chunkSize = chunkSize;
5211
- this.lengthKnown = true;
5212
- };
5213
5041
  if (typeof XMLHttpRequest != 'undefined') {
5214
5042
  if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
5215
5043
  var lazyArray = new LazyUint8Array();
5216
- Object.defineProperties(lazyArray, {
5217
- length: {
5218
- get: /** @this{Object} */ function() {
5219
- if (!this.lengthKnown) {
5220
- this.cacheLength();
5221
- }
5222
- return this._length;
5223
- }
5224
- },
5225
- chunkSize: {
5226
- get: /** @this{Object} */ function() {
5227
- if (!this.lengthKnown) {
5228
- this.cacheLength();
5229
- }
5230
- return this._chunkSize;
5231
- }
5232
- }
5233
- });
5234
-
5235
5044
  var properties = { isDevice: false, contents: lazyArray };
5236
5045
  } else {
5237
5046
  var properties = { isDevice: false, url: url };
@@ -5250,7 +5059,7 @@ function dbg(text) {
5250
5059
  // Add a function that defers querying the file size until it is asked the first time.
5251
5060
  Object.defineProperties(node, {
5252
5061
  usedBytes: {
5253
- get: /** @this {FSNode} */ function() { return this.contents.length; }
5062
+ get: function() { return this.contents.length; }
5254
5063
  }
5255
5064
  });
5256
5065
  // override each stream op with one that tries to force load the lazy file first
@@ -5258,9 +5067,9 @@ function dbg(text) {
5258
5067
  var keys = Object.keys(node.stream_ops);
5259
5068
  keys.forEach((key) => {
5260
5069
  var fn = node.stream_ops[key];
5261
- stream_ops[key] = function forceLoadLazyFile() {
5070
+ stream_ops[key] = (...args) => {
5262
5071
  FS.forceLoadFile(node);
5263
- return fn.apply(null, arguments);
5072
+ return fn(...args);
5264
5073
  };
5265
5074
  });
5266
5075
  function writeChunks(stream, buffer, offset, length, position) {
@@ -5341,15 +5150,7 @@ function dbg(text) {
5341
5150
  return PATH.join2(dir, path);
5342
5151
  },
5343
5152
  doStat(func, path, buf) {
5344
- try {
5345
- var stat = func(path);
5346
- } catch (e) {
5347
- if (e && e.node && PATH.normalize(path) !== PATH.normalize(FS.getPath(e.node))) {
5348
- // an error occurred while trying to look up the path; we should just report ENOTDIR
5349
- return -54;
5350
- }
5351
- throw e;
5352
- }
5153
+ var stat = func(path);
5353
5154
  HEAP32[((buf)>>2)] = stat.dev;checkInt32(stat.dev);
5354
5155
  HEAP32[(((buf)+(4))>>2)] = stat.mode;checkInt32(stat.mode);
5355
5156
  HEAPU32[(((buf)+(8))>>2)] = stat.nlink;checkInt32(stat.nlink);
@@ -5382,23 +5183,15 @@ function dbg(text) {
5382
5183
  var buffer = HEAPU8.slice(addr, addr + len);
5383
5184
  FS.msync(stream, buffer, offset, len, flags);
5384
5185
  },
5385
- varargs:undefined,
5386
- get() {
5387
- assert(SYSCALLS.varargs != undefined);
5388
- // the `+` prepended here is necessary to convince the JSCompiler that varargs is indeed a number.
5389
- var ret = HEAP32[((+SYSCALLS.varargs)>>2)];
5390
- SYSCALLS.varargs += 4;
5391
- return ret;
5186
+ getStreamFromFD(fd) {
5187
+ var stream = FS.getStreamChecked(fd);
5188
+ return stream;
5392
5189
  },
5393
- getp() { return SYSCALLS.get() },
5190
+ varargs:undefined,
5394
5191
  getStr(ptr) {
5395
5192
  var ret = UTF8ToString(ptr);
5396
5193
  return ret;
5397
5194
  },
5398
- getStreamFromFD(fd) {
5399
- var stream = FS.getStreamChecked(fd);
5400
- return stream;
5401
- },
5402
5195
  };
5403
5196
  function ___syscall_chmod(path, mode) {
5404
5197
  try {
@@ -5463,10 +5256,16 @@ function dbg(text) {
5463
5256
  }
5464
5257
  }
5465
5258
 
5466
- var setErrNo = (value) => {
5467
- HEAP32[((___errno_location())>>2)] = value;checkInt32(value);
5468
- return value;
5469
- };
5259
+ /** @suppress {duplicate } */
5260
+ function syscallGetVarargI() {
5261
+ assert(SYSCALLS.varargs != undefined);
5262
+ // the `+` prepended here is necessary to convince the JSCompiler that varargs is indeed a number.
5263
+ var ret = HEAP32[((+SYSCALLS.varargs)>>2)];
5264
+ SYSCALLS.varargs += 4;
5265
+ return ret;
5266
+ }
5267
+ var syscallGetVarargP = syscallGetVarargI;
5268
+
5470
5269
 
5471
5270
  function ___syscall_fcntl64(fd, cmd, varargs) {
5472
5271
  SYSCALLS.varargs = varargs;
@@ -5475,7 +5274,7 @@ function dbg(text) {
5475
5274
  var stream = SYSCALLS.getStreamFromFD(fd);
5476
5275
  switch (cmd) {
5477
5276
  case 0: {
5478
- var arg = SYSCALLS.get();
5277
+ var arg = syscallGetVarargI();
5479
5278
  if (arg < 0) {
5480
5279
  return -28;
5481
5280
  }
@@ -5483,7 +5282,7 @@ function dbg(text) {
5483
5282
  arg++;
5484
5283
  }
5485
5284
  var newStream;
5486
- newStream = FS.createStream(stream, arg);
5285
+ newStream = FS.dupStream(stream, arg);
5487
5286
  return newStream.fd;
5488
5287
  }
5489
5288
  case 1:
@@ -5492,31 +5291,22 @@ function dbg(text) {
5492
5291
  case 3:
5493
5292
  return stream.flags;
5494
5293
  case 4: {
5495
- var arg = SYSCALLS.get();
5294
+ var arg = syscallGetVarargI();
5496
5295
  stream.flags |= arg;
5497
5296
  return 0;
5498
5297
  }
5499
- case 5: {
5500
- var arg = SYSCALLS.getp();
5298
+ case 12: {
5299
+ var arg = syscallGetVarargP();
5501
5300
  var offset = 0;
5502
5301
  // We're always unlocked.
5503
5302
  HEAP16[(((arg)+(offset))>>1)] = 2;checkInt16(2);
5504
5303
  return 0;
5505
5304
  }
5506
- case 6:
5507
- case 7:
5305
+ case 13:
5306
+ case 14:
5508
5307
  return 0; // Pretend that the locking is successful.
5509
- case 16:
5510
- case 8:
5511
- return -28; // These are for sockets. We don't have them fully implemented yet.
5512
- case 9:
5513
- // musl trusts getown return values, due to a bug where they must be, as they overlap with errors. just return -1 here, so fcntl() returns that, and we set errno ourselves.
5514
- setErrNo(28);
5515
- return -1;
5516
- default: {
5517
- return -28;
5518
- }
5519
5308
  }
5309
+ return -28;
5520
5310
  } catch (e) {
5521
5311
  if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
5522
5312
  return -e.errno;
@@ -5534,14 +5324,13 @@ function dbg(text) {
5534
5324
  }
5535
5325
  }
5536
5326
 
5537
-
5538
5327
  var convertI32PairToI53Checked = (lo, hi) => {
5539
5328
  assert(lo == (lo >>> 0) || lo == (lo|0)); // lo should either be a i32 or a u32
5540
5329
  assert(hi === (hi|0)); // hi should be a i32
5541
5330
  return ((hi + 0x200000) >>> 0 < 0x400001 - !!lo) ? (lo >>> 0) + hi * 4294967296 : NaN;
5542
5331
  };
5543
5332
  function ___syscall_ftruncate64(fd,length_low, length_high) {
5544
- var length = convertI32PairToI53Checked(length_low, length_high);;
5333
+ var length = convertI32PairToI53Checked(length_low, length_high);
5545
5334
 
5546
5335
 
5547
5336
  try {
@@ -5561,7 +5350,6 @@ function dbg(text) {
5561
5350
  assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
5562
5351
  return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
5563
5352
  };
5564
-
5565
5353
  function ___syscall_getcwd(buf, size) {
5566
5354
  try {
5567
5355
 
@@ -5621,13 +5409,14 @@ function dbg(text) {
5621
5409
  }
5622
5410
  }
5623
5411
 
5412
+
5624
5413
  function ___syscall_openat(dirfd, path, flags, varargs) {
5625
5414
  SYSCALLS.varargs = varargs;
5626
5415
  try {
5627
5416
 
5628
5417
  path = SYSCALLS.getStr(path);
5629
5418
  path = SYSCALLS.calculateAt(dirfd, path);
5630
- var mode = varargs ? SYSCALLS.get() : 0;
5419
+ var mode = varargs ? syscallGetVarargI() : 0;
5631
5420
  return FS.open(path, flags, mode).fd;
5632
5421
  } catch (e) {
5633
5422
  if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
@@ -5730,9 +5519,15 @@ function dbg(text) {
5730
5519
  }
5731
5520
  }
5732
5521
 
5522
+ var __abort_js = () => {
5523
+ abort('native code called abort()');
5524
+ };
5525
+
5733
5526
  var nowIsMonotonic = 1;
5734
5527
  var __emscripten_get_now_is_monotonic = () => nowIsMonotonic;
5735
5528
 
5529
+ var __emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num);
5530
+
5736
5531
  var isLeapYear = (year) => year%4 === 0 && (year%100 !== 0 || year%400 === 0);
5737
5532
 
5738
5533
  var MONTH_DAYS_LEAP_CUMULATIVE = [0,31,60,91,121,152,182,213,244,274,305,335];
@@ -5747,7 +5542,7 @@ function dbg(text) {
5747
5542
  };
5748
5543
 
5749
5544
  function __localtime_js(time_low, time_high,tmPtr) {
5750
- var time = convertI32PairToI53Checked(time_low, time_high);;
5545
+ var time = convertI32PairToI53Checked(time_low, time_high);
5751
5546
 
5752
5547
 
5753
5548
  var date = new Date(time*1000);
@@ -5778,7 +5573,7 @@ function dbg(text) {
5778
5573
 
5779
5574
 
5780
5575
  function __mmap_js(len,prot,flags,fd,offset_low, offset_high,allocated,addr) {
5781
- var offset = convertI32PairToI53Checked(offset_low, offset_high);;
5576
+ var offset = convertI32PairToI53Checked(offset_low, offset_high);
5782
5577
 
5783
5578
 
5784
5579
  try {
@@ -5798,21 +5593,16 @@ function dbg(text) {
5798
5593
  }
5799
5594
 
5800
5595
 
5801
-
5802
-
5803
5596
  function __munmap_js(addr,len,prot,flags,fd,offset_low, offset_high) {
5804
- var offset = convertI32PairToI53Checked(offset_low, offset_high);;
5597
+ var offset = convertI32PairToI53Checked(offset_low, offset_high);
5805
5598
 
5806
5599
 
5807
5600
  try {
5808
5601
 
5809
- if (isNaN(offset)) return 61;
5810
5602
  var stream = SYSCALLS.getStreamFromFD(fd);
5811
5603
  if (prot & 2) {
5812
5604
  SYSCALLS.doMsync(addr, stream, len, flags, offset);
5813
5605
  }
5814
- FS.munmap(stream);
5815
- // implicitly return 0
5816
5606
  } catch (e) {
5817
5607
  if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
5818
5608
  return -e.errno;
@@ -5821,14 +5611,7 @@ function dbg(text) {
5821
5611
  }
5822
5612
 
5823
5613
 
5824
-
5825
- var stringToNewUTF8 = (str) => {
5826
- var size = lengthBytesUTF8(str) + 1;
5827
- var ret = _malloc(size);
5828
- if (ret) stringToUTF8(str, ret, size);
5829
- return ret;
5830
- };
5831
- var __tzset_js = (timezone, daylight, tzname) => {
5614
+ var __tzset_js = (timezone, daylight, std_name, dst_name) => {
5832
5615
  // TODO: Use (malleable) environment variables instead of system settings.
5833
5616
  var currentYear = new Date().getFullYear();
5834
5617
  var winter = new Date(currentYear, 0, 1);
@@ -5836,9 +5619,12 @@ function dbg(text) {
5836
5619
  var winterOffset = winter.getTimezoneOffset();
5837
5620
  var summerOffset = summer.getTimezoneOffset();
5838
5621
 
5839
- // Local standard timezone offset. Local standard time is not adjusted for daylight savings.
5840
- // This code uses the fact that getTimezoneOffset returns a greater value during Standard Time versus Daylight Saving Time (DST).
5841
- // Thus it determines the expected output during Standard Time, and it compares whether the output of the given date the same (Standard) or less (DST).
5622
+ // Local standard timezone offset. Local standard time is not adjusted for
5623
+ // daylight savings. This code uses the fact that getTimezoneOffset returns
5624
+ // a greater value during Standard Time versus Daylight Saving Time (DST).
5625
+ // Thus it determines the expected output during Standard Time, and it
5626
+ // compares whether the output of the given date the same (Standard) or less
5627
+ // (DST).
5842
5628
  var stdTimezoneOffset = Math.max(winterOffset, summerOffset);
5843
5629
 
5844
5630
  // timezone is specified as seconds west of UTC ("The external variable
@@ -5850,28 +5636,34 @@ function dbg(text) {
5850
5636
 
5851
5637
  HEAP32[((daylight)>>2)] = Number(winterOffset != summerOffset);checkInt32(Number(winterOffset != summerOffset));
5852
5638
 
5853
- function extractZone(date) {
5854
- var match = date.toTimeString().match(/\(([A-Za-z ]+)\)$/);
5855
- return match ? match[1] : "GMT";
5856
- };
5857
- var winterName = extractZone(winter);
5858
- var summerName = extractZone(summer);
5859
- var winterNamePtr = stringToNewUTF8(winterName);
5860
- var summerNamePtr = stringToNewUTF8(summerName);
5639
+ var extractZone = (timezoneOffset) => {
5640
+ // Why inverse sign?
5641
+ // Read here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset
5642
+ var sign = timezoneOffset >= 0 ? "-" : "+";
5643
+
5644
+ var absOffset = Math.abs(timezoneOffset)
5645
+ var hours = String(Math.floor(absOffset / 60)).padStart(2, "0");
5646
+ var minutes = String(absOffset % 60).padStart(2, "0");
5647
+
5648
+ return `UTC${sign}${hours}${minutes}`;
5649
+ }
5650
+
5651
+ var winterName = extractZone(winterOffset);
5652
+ var summerName = extractZone(summerOffset);
5653
+ assert(winterName);
5654
+ assert(summerName);
5655
+ assert(lengthBytesUTF8(winterName) <= 16, `timezone name truncated to fit in TZNAME_MAX (${winterName})`);
5656
+ assert(lengthBytesUTF8(summerName) <= 16, `timezone name truncated to fit in TZNAME_MAX (${summerName})`);
5861
5657
  if (summerOffset < winterOffset) {
5862
5658
  // Northern hemisphere
5863
- HEAPU32[((tzname)>>2)] = winterNamePtr;checkInt32(winterNamePtr);
5864
- HEAPU32[(((tzname)+(4))>>2)] = summerNamePtr;checkInt32(summerNamePtr);
5659
+ stringToUTF8(winterName, std_name, 17);
5660
+ stringToUTF8(summerName, dst_name, 17);
5865
5661
  } else {
5866
- HEAPU32[((tzname)>>2)] = summerNamePtr;checkInt32(summerNamePtr);
5867
- HEAPU32[(((tzname)+(4))>>2)] = winterNamePtr;checkInt32(winterNamePtr);
5662
+ stringToUTF8(winterName, dst_name, 17);
5663
+ stringToUTF8(summerName, std_name, 17);
5868
5664
  }
5869
5665
  };
5870
5666
 
5871
- var _abort = () => {
5872
- abort('native code called abort()');
5873
- };
5874
-
5875
5667
  var _emscripten_date_now = () => Date.now();
5876
5668
 
5877
5669
  var getHeapMax = () =>
@@ -5889,8 +5681,6 @@ function dbg(text) {
5889
5681
  _emscripten_get_now = () => performance.now();
5890
5682
  ;
5891
5683
 
5892
- var _emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num);
5893
-
5894
5684
 
5895
5685
 
5896
5686
  var growMemory = (size) => {
@@ -6005,12 +5795,11 @@ function dbg(text) {
6005
5795
  var stringToAscii = (str, buffer) => {
6006
5796
  for (var i = 0; i < str.length; ++i) {
6007
5797
  assert(str.charCodeAt(i) === (str.charCodeAt(i) & 0xff));
6008
- HEAP8[((buffer++)>>0)] = str.charCodeAt(i);checkInt8(str.charCodeAt(i));
5798
+ HEAP8[buffer++] = str.charCodeAt(i);checkInt8(str.charCodeAt(i));
6009
5799
  }
6010
5800
  // Null-terminate the string
6011
- HEAP8[((buffer)>>0)] = 0;checkInt8(0);
5801
+ HEAP8[buffer] = 0;checkInt8(0);
6012
5802
  };
6013
-
6014
5803
  var _environ_get = (__environ, environ_buf) => {
6015
5804
  var bufSize = 0;
6016
5805
  getEnvStrings().forEach((string, i) => {
@@ -6022,7 +5811,6 @@ function dbg(text) {
6022
5811
  return 0;
6023
5812
  };
6024
5813
 
6025
-
6026
5814
  var _environ_sizes_get = (penviron_count, penviron_buf_size) => {
6027
5815
  var strings = getEnvStrings();
6028
5816
  HEAPU32[((penviron_count)>>2)] = strings.length;checkInt32(strings.length);
@@ -6059,7 +5847,7 @@ function dbg(text) {
6059
5847
  FS.isLink(stream.mode) ? 7 :
6060
5848
  4;
6061
5849
  }
6062
- HEAP8[((pbuf)>>0)] = type;checkInt8(type);
5850
+ HEAP8[pbuf] = type;checkInt8(type);
6063
5851
  HEAP16[(((pbuf)+(2))>>1)] = flags;checkInt16(flags);
6064
5852
  (tempI64 = [rightsBase>>>0,(tempDouble = rightsBase,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((pbuf)+(8))>>2)] = tempI64[0],HEAP32[(((pbuf)+(12))>>2)] = tempI64[1]);checkInt64(rightsBase);
6065
5853
  (tempI64 = [rightsInheriting>>>0,(tempDouble = rightsInheriting,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? (+(Math.floor((tempDouble)/4294967296.0)))>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)], HEAP32[(((pbuf)+(16))>>2)] = tempI64[0],HEAP32[(((pbuf)+(20))>>2)] = tempI64[1]);checkInt64(rightsInheriting);
@@ -6081,7 +5869,7 @@ function dbg(text) {
6081
5869
  if (curr < 0) return -1;
6082
5870
  ret += curr;
6083
5871
  if (curr < len) break; // nothing more to read
6084
- if (typeof offset !== 'undefined') {
5872
+ if (typeof offset != 'undefined') {
6085
5873
  offset += curr;
6086
5874
  }
6087
5875
  }
@@ -6103,7 +5891,7 @@ function dbg(text) {
6103
5891
 
6104
5892
 
6105
5893
  function _fd_seek(fd,offset_low, offset_high,whence,newOffset) {
6106
- var offset = convertI32PairToI53Checked(offset_low, offset_high);;
5894
+ var offset = convertI32PairToI53Checked(offset_low, offset_high);
6107
5895
 
6108
5896
 
6109
5897
  try {
@@ -6145,7 +5933,7 @@ function dbg(text) {
6145
5933
  var curr = FS.write(stream, HEAP8, ptr, len, offset);
6146
5934
  if (curr < 0) return -1;
6147
5935
  ret += curr;
6148
- if (typeof offset !== 'undefined') {
5936
+ if (typeof offset != 'undefined') {
6149
5937
  offset += curr;
6150
5938
  }
6151
5939
  }
@@ -6178,6 +5966,8 @@ function dbg(text) {
6178
5966
  };
6179
5967
 
6180
5968
 
5969
+
5970
+ var stackAlloc = (sz) => __emscripten_stack_alloc(sz);
6181
5971
  var stringToUTF8OnStack = (str) => {
6182
5972
  var size = lengthBytesUTF8(str) + 1;
6183
5973
  var ret = stackAlloc(size);
@@ -6186,6 +5976,9 @@ function dbg(text) {
6186
5976
  };
6187
5977
 
6188
5978
 
5979
+
5980
+
5981
+
6189
5982
  /**
6190
5983
  * @param {string|null=} returnType
6191
5984
  * @param {Array=} argTypes
@@ -6234,7 +6027,7 @@ function dbg(text) {
6234
6027
  }
6235
6028
  }
6236
6029
  }
6237
- var ret = func.apply(null, cArgs);
6030
+ var ret = func(...cArgs);
6238
6031
  function onDone(ret) {
6239
6032
  if (stack !== 0) stackRestore(stack);
6240
6033
  return convertReturnValue(ret);
@@ -6250,16 +6043,19 @@ function dbg(text) {
6250
6043
  * @param {Object=} opts
6251
6044
  */
6252
6045
  var cwrap = (ident, returnType, argTypes, opts) => {
6253
- return function() {
6254
- return ccall(ident, returnType, argTypes, arguments, opts);
6255
- }
6046
+ return (...args) => ccall(ident, returnType, argTypes, args, opts);
6256
6047
  };
6257
6048
 
6258
6049
 
6050
+
6051
+
6052
+
6259
6053
  var ALLOC_NORMAL = 0;
6260
6054
 
6261
6055
  var ALLOC_STACK = 1;
6262
6056
 
6057
+
6058
+
6263
6059
  var allocate = (slab, allocator) => {
6264
6060
  var ret;
6265
6061
  assert(typeof allocator == 'number', 'allocate no longer takes a type argument')
@@ -6279,6 +6075,7 @@ function dbg(text) {
6279
6075
  };
6280
6076
 
6281
6077
 
6078
+
6282
6079
  var allocateUTF8OnStack = stringToUTF8OnStack;
6283
6080
 
6284
6081
  var functionsInTableMap;
@@ -6287,6 +6084,7 @@ function dbg(text) {
6287
6084
 
6288
6085
  var wasmTableMirror = [];
6289
6086
 
6087
+ /** @type {WebAssembly.Table} */
6290
6088
  var wasmTable;
6291
6089
  var getWasmTableEntry = (funcPtr) => {
6292
6090
  var func = wasmTableMirror[funcPtr];
@@ -6294,14 +6092,14 @@ function dbg(text) {
6294
6092
  if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1;
6295
6093
  wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
6296
6094
  }
6297
- assert(wasmTable.get(funcPtr) == func, "JavaScript-side Wasm function table mirror is out of date!");
6095
+ assert(wasmTable.get(funcPtr) == func, 'JavaScript-side Wasm function table mirror is out of date!');
6298
6096
  return func;
6299
6097
  };
6300
6098
 
6301
6099
 
6302
6100
  var setWasmTableEntry = (idx, func) => {
6303
6101
  wasmTable.set(idx, func);
6304
- // With ABORT_ON_WASM_EXCEPTIONS wasmTable.get is overriden to return wrapped
6102
+ // With ABORT_ON_WASM_EXCEPTIONS wasmTable.get is overridden to return wrapped
6305
6103
  // functions so we need to call it here to retrieve the potential wrapper correctly
6306
6104
  // instead of just storing 'func' directly into wasmTableMirror
6307
6105
  wasmTableMirror[idx] = wasmTable.get(idx);
@@ -6398,7 +6196,7 @@ function dbg(text) {
6398
6196
  ];
6399
6197
  // Write the overall length of the type section followed by the body
6400
6198
  uleb128Encode(typeSectionBody.length, bytes);
6401
- bytes.push.apply(bytes, typeSectionBody);
6199
+ bytes.push(...typeSectionBody);
6402
6200
 
6403
6201
  // The rest of the module is static
6404
6202
  bytes.push(
@@ -6502,51 +6300,6 @@ function dbg(text) {
6502
6300
  return ret;
6503
6301
  };
6504
6302
 
6505
- var FSNode = /** @constructor */ function(parent, name, mode, rdev) {
6506
- if (!parent) {
6507
- parent = this; // root node sets parent to itself
6508
- }
6509
- this.parent = parent;
6510
- this.mount = parent.mount;
6511
- this.mounted = null;
6512
- this.id = FS.nextInode++;
6513
- this.name = name;
6514
- this.mode = mode;
6515
- this.node_ops = {};
6516
- this.stream_ops = {};
6517
- this.rdev = rdev;
6518
- };
6519
- var readMode = 292/*292*/ | 73/*73*/;
6520
- var writeMode = 146/*146*/;
6521
- Object.defineProperties(FSNode.prototype, {
6522
- read: {
6523
- get: /** @this{FSNode} */function() {
6524
- return (this.mode & readMode) === readMode;
6525
- },
6526
- set: /** @this{FSNode} */function(val) {
6527
- val ? this.mode |= readMode : this.mode &= ~readMode;
6528
- }
6529
- },
6530
- write: {
6531
- get: /** @this{FSNode} */function() {
6532
- return (this.mode & writeMode) === writeMode;
6533
- },
6534
- set: /** @this{FSNode} */function(val) {
6535
- val ? this.mode |= writeMode : this.mode &= ~writeMode;
6536
- }
6537
- },
6538
- isFolder: {
6539
- get: /** @this{FSNode} */function() {
6540
- return FS.isDir(this.mode);
6541
- }
6542
- },
6543
- isDevice: {
6544
- get: /** @this{FSNode} */function() {
6545
- return FS.isChrdev(this.mode);
6546
- }
6547
- }
6548
- });
6549
- FS.FSNode = FSNode;
6550
6303
  FS.createPreloadedFile = FS_createPreloadedFile;
6551
6304
  FS.staticInit();;
6552
6305
  function checkIncomingModuleAPI() {
@@ -6592,8 +6345,12 @@ var wasmImports = {
6592
6345
  /** @export */
6593
6346
  __syscall_utimensat: ___syscall_utimensat,
6594
6347
  /** @export */
6348
+ _abort_js: __abort_js,
6349
+ /** @export */
6595
6350
  _emscripten_get_now_is_monotonic: __emscripten_get_now_is_monotonic,
6596
6351
  /** @export */
6352
+ _emscripten_memcpy_js: __emscripten_memcpy_js,
6353
+ /** @export */
6597
6354
  _localtime_js: __localtime_js,
6598
6355
  /** @export */
6599
6356
  _mmap_js: __mmap_js,
@@ -6602,16 +6359,12 @@ var wasmImports = {
6602
6359
  /** @export */
6603
6360
  _tzset_js: __tzset_js,
6604
6361
  /** @export */
6605
- abort: _abort,
6606
- /** @export */
6607
6362
  emscripten_date_now: _emscripten_date_now,
6608
6363
  /** @export */
6609
6364
  emscripten_get_heap_max: _emscripten_get_heap_max,
6610
6365
  /** @export */
6611
6366
  emscripten_get_now: _emscripten_get_now,
6612
6367
  /** @export */
6613
- emscripten_memcpy_js: _emscripten_memcpy_js,
6614
- /** @export */
6615
6368
  emscripten_resize_heap: _emscripten_resize_heap,
6616
6369
  /** @export */
6617
6370
  environ_get: _environ_get,
@@ -6631,79 +6384,78 @@ var wasmImports = {
6631
6384
  fd_write: _fd_write
6632
6385
  };
6633
6386
  var wasmExports = createWasm();
6634
- var ___wasm_call_ctors = createExportWrapper('__wasm_call_ctors');
6635
- var _sqlite3_free = Module['_sqlite3_free'] = createExportWrapper('sqlite3_free');
6636
- var _sqlite3_value_text = Module['_sqlite3_value_text'] = createExportWrapper('sqlite3_value_text');
6637
- var ___errno_location = createExportWrapper('__errno_location');
6638
- var _sqlite3_prepare_v2 = Module['_sqlite3_prepare_v2'] = createExportWrapper('sqlite3_prepare_v2');
6639
- var _sqlite3_step = Module['_sqlite3_step'] = createExportWrapper('sqlite3_step');
6640
- var _sqlite3_finalize = Module['_sqlite3_finalize'] = createExportWrapper('sqlite3_finalize');
6641
- var _sqlite3_reset = Module['_sqlite3_reset'] = createExportWrapper('sqlite3_reset');
6642
- var _sqlite3_clear_bindings = Module['_sqlite3_clear_bindings'] = createExportWrapper('sqlite3_clear_bindings');
6643
- var _sqlite3_value_blob = Module['_sqlite3_value_blob'] = createExportWrapper('sqlite3_value_blob');
6644
- var _sqlite3_value_bytes = Module['_sqlite3_value_bytes'] = createExportWrapper('sqlite3_value_bytes');
6645
- var _sqlite3_value_double = Module['_sqlite3_value_double'] = createExportWrapper('sqlite3_value_double');
6646
- var _sqlite3_value_int = Module['_sqlite3_value_int'] = createExportWrapper('sqlite3_value_int');
6647
- var _sqlite3_value_type = Module['_sqlite3_value_type'] = createExportWrapper('sqlite3_value_type');
6648
- var _sqlite3_result_blob = Module['_sqlite3_result_blob'] = createExportWrapper('sqlite3_result_blob');
6649
- var _sqlite3_result_double = Module['_sqlite3_result_double'] = createExportWrapper('sqlite3_result_double');
6650
- var _sqlite3_result_error = Module['_sqlite3_result_error'] = createExportWrapper('sqlite3_result_error');
6651
- var _sqlite3_result_int = Module['_sqlite3_result_int'] = createExportWrapper('sqlite3_result_int');
6652
- var _sqlite3_result_int64 = Module['_sqlite3_result_int64'] = createExportWrapper('sqlite3_result_int64');
6653
- var _sqlite3_result_null = Module['_sqlite3_result_null'] = createExportWrapper('sqlite3_result_null');
6654
- var _sqlite3_result_text = Module['_sqlite3_result_text'] = createExportWrapper('sqlite3_result_text');
6655
- var _sqlite3_aggregate_context = Module['_sqlite3_aggregate_context'] = createExportWrapper('sqlite3_aggregate_context');
6656
- var _sqlite3_column_count = Module['_sqlite3_column_count'] = createExportWrapper('sqlite3_column_count');
6657
- var _sqlite3_data_count = Module['_sqlite3_data_count'] = createExportWrapper('sqlite3_data_count');
6658
- var _sqlite3_column_blob = Module['_sqlite3_column_blob'] = createExportWrapper('sqlite3_column_blob');
6659
- var _sqlite3_column_bytes = Module['_sqlite3_column_bytes'] = createExportWrapper('sqlite3_column_bytes');
6660
- var _sqlite3_column_double = Module['_sqlite3_column_double'] = createExportWrapper('sqlite3_column_double');
6661
- var _sqlite3_column_text = Module['_sqlite3_column_text'] = createExportWrapper('sqlite3_column_text');
6662
- var _sqlite3_column_type = Module['_sqlite3_column_type'] = createExportWrapper('sqlite3_column_type');
6663
- var _sqlite3_column_name = Module['_sqlite3_column_name'] = createExportWrapper('sqlite3_column_name');
6664
- var _sqlite3_bind_blob = Module['_sqlite3_bind_blob'] = createExportWrapper('sqlite3_bind_blob');
6665
- var _sqlite3_bind_double = Module['_sqlite3_bind_double'] = createExportWrapper('sqlite3_bind_double');
6666
- var _sqlite3_bind_int = Module['_sqlite3_bind_int'] = createExportWrapper('sqlite3_bind_int');
6667
- var _sqlite3_bind_text = Module['_sqlite3_bind_text'] = createExportWrapper('sqlite3_bind_text');
6668
- var _sqlite3_bind_parameter_index = Module['_sqlite3_bind_parameter_index'] = createExportWrapper('sqlite3_bind_parameter_index');
6669
- var _sqlite3_sql = Module['_sqlite3_sql'] = createExportWrapper('sqlite3_sql');
6670
- var _sqlite3_normalized_sql = Module['_sqlite3_normalized_sql'] = createExportWrapper('sqlite3_normalized_sql');
6671
- var _sqlite3_errmsg = Module['_sqlite3_errmsg'] = createExportWrapper('sqlite3_errmsg');
6672
- var _sqlite3_exec = Module['_sqlite3_exec'] = createExportWrapper('sqlite3_exec');
6673
- var _sqlite3_changes = Module['_sqlite3_changes'] = createExportWrapper('sqlite3_changes');
6674
- var _sqlite3_close_v2 = Module['_sqlite3_close_v2'] = createExportWrapper('sqlite3_close_v2');
6675
- var _sqlite3_create_function_v2 = Module['_sqlite3_create_function_v2'] = createExportWrapper('sqlite3_create_function_v2');
6676
- var _sqlite3_open = Module['_sqlite3_open'] = createExportWrapper('sqlite3_open');
6677
- var _malloc = Module['_malloc'] = createExportWrapper('malloc');
6678
- var _free = Module['_free'] = createExportWrapper('free');
6679
- var _RegisterExtensionFunctions = Module['_RegisterExtensionFunctions'] = createExportWrapper('RegisterExtensionFunctions');
6680
- var _fflush = Module['_fflush'] = createExportWrapper('fflush');
6681
- var _emscripten_builtin_memalign = createExportWrapper('emscripten_builtin_memalign');
6682
- var setTempRet0 = createExportWrapper('setTempRet0');
6387
+ var ___wasm_call_ctors = createExportWrapper('__wasm_call_ctors', 0);
6388
+ var _sqlite3_free = Module['_sqlite3_free'] = createExportWrapper('sqlite3_free', 1);
6389
+ var _sqlite3_value_text = Module['_sqlite3_value_text'] = createExportWrapper('sqlite3_value_text', 1);
6390
+ var _sqlite3_prepare_v2 = Module['_sqlite3_prepare_v2'] = createExportWrapper('sqlite3_prepare_v2', 5);
6391
+ var _sqlite3_step = Module['_sqlite3_step'] = createExportWrapper('sqlite3_step', 1);
6392
+ var _sqlite3_reset = Module['_sqlite3_reset'] = createExportWrapper('sqlite3_reset', 1);
6393
+ var _sqlite3_exec = Module['_sqlite3_exec'] = createExportWrapper('sqlite3_exec', 5);
6394
+ var _sqlite3_finalize = Module['_sqlite3_finalize'] = createExportWrapper('sqlite3_finalize', 1);
6395
+ var _sqlite3_column_name = Module['_sqlite3_column_name'] = createExportWrapper('sqlite3_column_name', 2);
6396
+ var _sqlite3_column_text = Module['_sqlite3_column_text'] = createExportWrapper('sqlite3_column_text', 2);
6397
+ var _sqlite3_column_type = Module['_sqlite3_column_type'] = createExportWrapper('sqlite3_column_type', 2);
6398
+ var _sqlite3_errmsg = Module['_sqlite3_errmsg'] = createExportWrapper('sqlite3_errmsg', 1);
6399
+ var _sqlite3_clear_bindings = Module['_sqlite3_clear_bindings'] = createExportWrapper('sqlite3_clear_bindings', 1);
6400
+ var _sqlite3_value_blob = Module['_sqlite3_value_blob'] = createExportWrapper('sqlite3_value_blob', 1);
6401
+ var _sqlite3_value_bytes = Module['_sqlite3_value_bytes'] = createExportWrapper('sqlite3_value_bytes', 1);
6402
+ var _sqlite3_value_double = Module['_sqlite3_value_double'] = createExportWrapper('sqlite3_value_double', 1);
6403
+ var _sqlite3_value_int = Module['_sqlite3_value_int'] = createExportWrapper('sqlite3_value_int', 1);
6404
+ var _sqlite3_value_type = Module['_sqlite3_value_type'] = createExportWrapper('sqlite3_value_type', 1);
6405
+ var _sqlite3_result_blob = Module['_sqlite3_result_blob'] = createExportWrapper('sqlite3_result_blob', 4);
6406
+ var _sqlite3_result_double = Module['_sqlite3_result_double'] = createExportWrapper('sqlite3_result_double', 2);
6407
+ var _sqlite3_result_error = Module['_sqlite3_result_error'] = createExportWrapper('sqlite3_result_error', 3);
6408
+ var _sqlite3_result_int = Module['_sqlite3_result_int'] = createExportWrapper('sqlite3_result_int', 2);
6409
+ var _sqlite3_result_int64 = Module['_sqlite3_result_int64'] = createExportWrapper('sqlite3_result_int64', 3);
6410
+ var _sqlite3_result_null = Module['_sqlite3_result_null'] = createExportWrapper('sqlite3_result_null', 1);
6411
+ var _sqlite3_result_text = Module['_sqlite3_result_text'] = createExportWrapper('sqlite3_result_text', 4);
6412
+ var _sqlite3_aggregate_context = Module['_sqlite3_aggregate_context'] = createExportWrapper('sqlite3_aggregate_context', 2);
6413
+ var _sqlite3_column_count = Module['_sqlite3_column_count'] = createExportWrapper('sqlite3_column_count', 1);
6414
+ var _sqlite3_data_count = Module['_sqlite3_data_count'] = createExportWrapper('sqlite3_data_count', 1);
6415
+ var _sqlite3_column_blob = Module['_sqlite3_column_blob'] = createExportWrapper('sqlite3_column_blob', 2);
6416
+ var _sqlite3_column_bytes = Module['_sqlite3_column_bytes'] = createExportWrapper('sqlite3_column_bytes', 2);
6417
+ var _sqlite3_column_double = Module['_sqlite3_column_double'] = createExportWrapper('sqlite3_column_double', 2);
6418
+ var _sqlite3_bind_blob = Module['_sqlite3_bind_blob'] = createExportWrapper('sqlite3_bind_blob', 5);
6419
+ var _sqlite3_bind_double = Module['_sqlite3_bind_double'] = createExportWrapper('sqlite3_bind_double', 3);
6420
+ var _sqlite3_bind_int = Module['_sqlite3_bind_int'] = createExportWrapper('sqlite3_bind_int', 3);
6421
+ var _sqlite3_bind_text = Module['_sqlite3_bind_text'] = createExportWrapper('sqlite3_bind_text', 5);
6422
+ var _sqlite3_bind_parameter_index = Module['_sqlite3_bind_parameter_index'] = createExportWrapper('sqlite3_bind_parameter_index', 2);
6423
+ var _sqlite3_sql = Module['_sqlite3_sql'] = createExportWrapper('sqlite3_sql', 1);
6424
+ var _sqlite3_normalized_sql = Module['_sqlite3_normalized_sql'] = createExportWrapper('sqlite3_normalized_sql', 1);
6425
+ var _sqlite3_changes = Module['_sqlite3_changes'] = createExportWrapper('sqlite3_changes', 1);
6426
+ var _sqlite3_close_v2 = Module['_sqlite3_close_v2'] = createExportWrapper('sqlite3_close_v2', 1);
6427
+ var _sqlite3_create_function_v2 = Module['_sqlite3_create_function_v2'] = createExportWrapper('sqlite3_create_function_v2', 9);
6428
+ var _sqlite3_open = Module['_sqlite3_open'] = createExportWrapper('sqlite3_open', 2);
6429
+ var _strerror = createExportWrapper('strerror', 1);
6430
+ var _malloc = Module['_malloc'] = createExportWrapper('malloc', 1);
6431
+ var _free = Module['_free'] = createExportWrapper('free', 1);
6432
+ var _RegisterExtensionFunctions = Module['_RegisterExtensionFunctions'] = createExportWrapper('RegisterExtensionFunctions', 1);
6433
+ var _fflush = createExportWrapper('fflush', 1);
6434
+ var _emscripten_builtin_memalign = createExportWrapper('emscripten_builtin_memalign', 2);
6435
+ var __emscripten_tempret_set = createExportWrapper('_emscripten_tempret_set', 1);
6683
6436
  var _emscripten_stack_init = () => (_emscripten_stack_init = wasmExports['emscripten_stack_init'])();
6684
6437
  var _emscripten_stack_get_free = () => (_emscripten_stack_get_free = wasmExports['emscripten_stack_get_free'])();
6685
6438
  var _emscripten_stack_get_base = () => (_emscripten_stack_get_base = wasmExports['emscripten_stack_get_base'])();
6686
6439
  var _emscripten_stack_get_end = () => (_emscripten_stack_get_end = wasmExports['emscripten_stack_get_end'])();
6687
- var stackSave = createExportWrapper('stackSave');
6688
- var stackRestore = createExportWrapper('stackRestore');
6689
- var stackAlloc = createExportWrapper('stackAlloc');
6440
+ var __emscripten_stack_restore = (a0) => (__emscripten_stack_restore = wasmExports['_emscripten_stack_restore'])(a0);
6441
+ var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc'])(a0);
6690
6442
  var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
6691
- var ___set_stack_limits = Module['___set_stack_limits'] = createExportWrapper('__set_stack_limits');
6692
- var dynCall_iiiij = Module['dynCall_iiiij'] = createExportWrapper('dynCall_iiiij');
6693
- var dynCall_iij = Module['dynCall_iij'] = createExportWrapper('dynCall_iij');
6694
- var dynCall_iijii = Module['dynCall_iijii'] = createExportWrapper('dynCall_iijii');
6695
- var dynCall_iiji = Module['dynCall_iiji'] = createExportWrapper('dynCall_iiji');
6696
- var dynCall_iiiiiij = Module['dynCall_iiiiiij'] = createExportWrapper('dynCall_iiiiiij');
6697
- var dynCall_viji = Module['dynCall_viji'] = createExportWrapper('dynCall_viji');
6698
- var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji');
6443
+ var ___set_stack_limits = Module['___set_stack_limits'] = createExportWrapper('__set_stack_limits', 2);
6444
+ var dynCall_iiiij = Module['dynCall_iiiij'] = createExportWrapper('dynCall_iiiij', 6);
6445
+ var dynCall_iij = Module['dynCall_iij'] = createExportWrapper('dynCall_iij', 4);
6446
+ var dynCall_iijii = Module['dynCall_iijii'] = createExportWrapper('dynCall_iijii', 6);
6447
+ var dynCall_iiji = Module['dynCall_iiji'] = createExportWrapper('dynCall_iiji', 5);
6448
+ var dynCall_iiiiiij = Module['dynCall_iiiiiij'] = createExportWrapper('dynCall_iiiiiij', 8);
6449
+ var dynCall_viji = Module['dynCall_viji'] = createExportWrapper('dynCall_viji', 5);
6450
+ var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji', 5);
6699
6451
 
6700
6452
 
6701
6453
  // include: postamble.js
6702
6454
  // === Auto-generated postamble setup entry stuff ===
6703
6455
 
6704
- Module['stackAlloc'] = stackAlloc;
6705
6456
  Module['stackSave'] = stackSave;
6706
6457
  Module['stackRestore'] = stackRestore;
6458
+ Module['stackAlloc'] = stackAlloc;
6707
6459
  Module['cwrap'] = cwrap;
6708
6460
  Module['addFunction'] = addFunction;
6709
6461
  Module['removeFunction'] = removeFunction;
@@ -6720,6 +6472,8 @@ var missingLibrarySymbols = [
6720
6472
  'readI53FromU64',
6721
6473
  'convertI32PairToI53',
6722
6474
  'convertU32PairToI53',
6475
+ 'getTempRet0',
6476
+ 'setTempRet0',
6723
6477
  'exitJS',
6724
6478
  'arraySum',
6725
6479
  'addDays',
@@ -6729,13 +6483,9 @@ var missingLibrarySymbols = [
6729
6483
  'inetNtop6',
6730
6484
  'readSockaddr',
6731
6485
  'writeSockaddr',
6732
- 'getHostByName',
6733
- 'getCallstack',
6734
6486
  'emscriptenLog',
6735
- 'convertPCtoSourceLocation',
6736
6487
  'readEmAsmArgs',
6737
6488
  'jstoi_q',
6738
- 'jstoi_s',
6739
6489
  'listenOnce',
6740
6490
  'autoResumeAudioContext',
6741
6491
  'dynCallLegacy',
@@ -6748,7 +6498,6 @@ var missingLibrarySymbols = [
6748
6498
  'callUserCallback',
6749
6499
  'maybeExit',
6750
6500
  'asmjsMangle',
6751
- 'handleAllocatorInit',
6752
6501
  'HandleAllocator',
6753
6502
  'getNativeTypeSize',
6754
6503
  'STACK_SIZE',
@@ -6768,10 +6517,10 @@ var missingLibrarySymbols = [
6768
6517
  'UTF32ToString',
6769
6518
  'stringToUTF32',
6770
6519
  'lengthBytesUTF32',
6520
+ 'stringToNewUTF8',
6771
6521
  'registerKeyEventCallback',
6772
6522
  'maybeCStringToJsString',
6773
6523
  'findEventTarget',
6774
- 'findCanvasEventTarget',
6775
6524
  'getBoundingClientRect',
6776
6525
  'fillMouseEventData',
6777
6526
  'registerMouseEventCallback',
@@ -6804,7 +6553,6 @@ var missingLibrarySymbols = [
6804
6553
  'registerTouchEventCallback',
6805
6554
  'fillGamepadEventData',
6806
6555
  'registerGamepadEventCallback',
6807
- 'disableGamepadApiIfItThrows',
6808
6556
  'registerBeforeUnloadEventCallback',
6809
6557
  'fillBatteryEventData',
6810
6558
  'battery',
@@ -6812,7 +6560,8 @@ var missingLibrarySymbols = [
6812
6560
  'setCanvasElementSize',
6813
6561
  'getCanvasElementSize',
6814
6562
  'jsStackTrace',
6815
- 'stackTrace',
6563
+ 'getCallstack',
6564
+ 'convertPCtoSourceLocation',
6816
6565
  'checkWasiClock',
6817
6566
  'wasiRightsToMuslOFlags',
6818
6567
  'wasiOFlagsToMuslOFlags',
@@ -6835,7 +6584,7 @@ var missingLibrarySymbols = [
6835
6584
  'FS_mkdirTree',
6836
6585
  '_setNetworkCallback',
6837
6586
  'heapObjectForWebGLType',
6838
- 'heapAccessShiftForWebGLHeap',
6587
+ 'toTypedArrayIndex',
6839
6588
  'webgl_enable_ANGLE_instanced_arrays',
6840
6589
  'webgl_enable_OES_vertex_array_object',
6841
6590
  'webgl_enable_WEBGL_draw_buffers',
@@ -6844,7 +6593,6 @@ var missingLibrarySymbols = [
6844
6593
  'computeUnpackAlignedImageSize',
6845
6594
  'colorChannelsInGlTextureFormat',
6846
6595
  'emscriptenWebGLGetTexPixelData',
6847
- '__glGenObject',
6848
6596
  'emscriptenWebGLGetUniform',
6849
6597
  'webglGetUniformLocation',
6850
6598
  'webglPrepareUniformLocationsBeforeFirstUse',
@@ -6854,11 +6602,11 @@ var missingLibrarySymbols = [
6854
6602
  'writeGLArray',
6855
6603
  'registerWebGlEventCallback',
6856
6604
  'runAndAbortIfError',
6857
- 'SDL_unicode',
6858
- 'SDL_ttfContext',
6859
- 'SDL_audio',
6860
6605
  'writeStringToMemory',
6861
6606
  'writeAsciiToMemory',
6607
+ 'setErrNo',
6608
+ 'demangle',
6609
+ 'stackTrace',
6862
6610
  ];
6863
6611
  missingLibrarySymbols.forEach(missingLibrarySymbol)
6864
6612
 
@@ -6871,20 +6619,12 @@ var unexportedSymbols = [
6871
6619
  'addOnPostRun',
6872
6620
  'addRunDependency',
6873
6621
  'removeRunDependency',
6874
- 'FS_createFolder',
6875
- 'FS_createPath',
6876
- 'FS_createLazyFile',
6877
- 'FS_createLink',
6878
- 'FS_createDevice',
6879
- 'FS_readFile',
6880
6622
  'out',
6881
6623
  'err',
6882
6624
  'callMain',
6883
6625
  'abort',
6884
6626
  'wasmMemory',
6885
6627
  'wasmExports',
6886
- 'getTempRet0',
6887
- 'setTempRet0',
6888
6628
  'writeStackCookie',
6889
6629
  'checkStackCookie',
6890
6630
  'readI53FromI64',
@@ -6902,8 +6642,7 @@ var unexportedSymbols = [
6902
6642
  'isLeapYear',
6903
6643
  'ydayFromDate',
6904
6644
  'ERRNO_CODES',
6905
- 'ERRNO_MESSAGES',
6906
- 'setErrNo',
6645
+ 'strError',
6907
6646
  'DNS',
6908
6647
  'Protocols',
6909
6648
  'Sockets',
@@ -6911,8 +6650,8 @@ var unexportedSymbols = [
6911
6650
  'randomFill',
6912
6651
  'timers',
6913
6652
  'warnOnce',
6914
- 'UNWIND_CACHE',
6915
6653
  'readEmAsmArgsArray',
6654
+ 'jstoi_s',
6916
6655
  'getExecutableName',
6917
6656
  'asyncLoad',
6918
6657
  'alignMemory',
@@ -6942,15 +6681,14 @@ var unexportedSymbols = [
6942
6681
  'intArrayFromString',
6943
6682
  'stringToAscii',
6944
6683
  'UTF16Decoder',
6945
- 'stringToNewUTF8',
6946
6684
  'stringToUTF8OnStack',
6947
6685
  'writeArrayToMemory',
6948
6686
  'JSEvents',
6949
6687
  'specialHTMLTargets',
6688
+ 'findCanvasEventTarget',
6950
6689
  'currentFullscreenStrategy',
6951
6690
  'restoreOldWindowedStyle',
6952
- 'demangle',
6953
- 'demangleAll',
6691
+ 'UNWIND_CACHE',
6954
6692
  'ExitStatus',
6955
6693
  'getEnvStrings',
6956
6694
  'doReadv',
@@ -6960,6 +6698,7 @@ var unexportedSymbols = [
6960
6698
  'exceptionLast',
6961
6699
  'exceptionCaught',
6962
6700
  'Browser',
6701
+ 'getPreloadedImageData__data',
6963
6702
  'wget',
6964
6703
  'SYSCALLS',
6965
6704
  'preloadPlugins',
@@ -6968,8 +6707,12 @@ var unexportedSymbols = [
6968
6707
  'FS_getMode',
6969
6708
  'FS_stdin_getChar_buffer',
6970
6709
  'FS_stdin_getChar',
6710
+ 'FS_createPath',
6711
+ 'FS_createDevice',
6712
+ 'FS_readFile',
6971
6713
  'FS',
6972
6714
  'FS_createDataFile',
6715
+ 'FS_createLazyFile',
6973
6716
  'MEMFS',
6974
6717
  'TTY',
6975
6718
  'PIPEFS',
@@ -6978,7 +6721,6 @@ var unexportedSymbols = [
6978
6721
  'miniTempWebGLFloatBuffers',
6979
6722
  'miniTempWebGLIntBuffers',
6980
6723
  'GL',
6981
- 'emscripten_webgl_power_preferences',
6982
6724
  'AL',
6983
6725
  'GLUT',
6984
6726
  'EGL',
@@ -6988,6 +6730,8 @@ var unexportedSymbols = [
6988
6730
  'SDL_gfx',
6989
6731
  'ALLOC_STACK',
6990
6732
  'allocateUTF8',
6733
+ 'print',
6734
+ 'printErr',
6991
6735
  ];
6992
6736
  unexportedSymbols.forEach(unexportedRuntimeSymbol);
6993
6737
 
@@ -7036,7 +6780,7 @@ function run() {
7036
6780
 
7037
6781
  initRuntime();
7038
6782
 
7039
- if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']();
6783
+ Module['onRuntimeInitialized']?.();
7040
6784
 
7041
6785
  assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');
7042
6786
 
@@ -7106,10 +6850,10 @@ if (Module['preInit']) {
7106
6850
 
7107
6851
  run();
7108
6852
 
7109
-
7110
6853
  // end include: postamble.js
7111
6854
 
7112
6855
 
6856
+
7113
6857
  // The shell-pre.js and emcc-generated code goes above
7114
6858
  return Module;
7115
6859
  }); // The end of the promise being returned