sql.js 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.devcontainer/Dockerfile +7 -36
- package/.devcontainer/devcontainer.json +3 -9
- package/dist/sql-asm-debug.js +66441 -63535
- package/dist/sql-asm-memory-growth.js +110 -108
- package/dist/sql-asm.js +110 -107
- package/dist/sql-wasm-debug.js +889 -776
- package/dist/sql-wasm-debug.wasm +0 -0
- package/dist/sql-wasm.js +95 -96
- package/dist/sql-wasm.wasm +0 -0
- package/dist/sqljs-all.zip +0 -0
- package/dist/sqljs-wasm.zip +0 -0
- package/dist/sqljs-worker-wasm.zip +0 -0
- package/dist/worker.sql-asm-debug.js +66472 -63542
- package/dist/worker.sql-asm.js +141 -114
- package/dist/worker.sql-wasm-debug.js +916 -779
- package/dist/worker.sql-wasm.js +126 -103
- package/package.json +1 -2
|
@@ -90,27 +90,19 @@ var Module = typeof Module != 'undefined' ? Module : {};
|
|
|
90
90
|
|
|
91
91
|
// Attempt to auto-detect the environment
|
|
92
92
|
var ENVIRONMENT_IS_WEB = typeof window == 'object';
|
|
93
|
-
var ENVIRONMENT_IS_WORKER = typeof
|
|
93
|
+
var ENVIRONMENT_IS_WORKER = typeof WorkerGlobalScope != 'undefined';
|
|
94
94
|
// N.b. Electron.js environment is simultaneously a NODE-environment, but
|
|
95
95
|
// also a web environment.
|
|
96
|
-
var ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string';
|
|
96
|
+
var ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string' && process.type != 'renderer';
|
|
97
97
|
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
|
|
98
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
99
|
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
100
|
|
|
109
101
|
}
|
|
110
102
|
|
|
111
103
|
// --pre-jses are emitted after the Module integration code, so that they can
|
|
112
104
|
// refer to Module (if they choose; they can also define Module)
|
|
113
|
-
// include:
|
|
105
|
+
// include: src/api.js
|
|
114
106
|
/* global
|
|
115
107
|
FS
|
|
116
108
|
HEAP8
|
|
@@ -184,6 +176,10 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
|
|
|
184
176
|
var SQLITE_BLOB = 4;
|
|
185
177
|
// var - Encodings, used for registering functions.
|
|
186
178
|
var SQLITE_UTF8 = 1;
|
|
179
|
+
// var - Authorizer Action Codes used to identify change types in updateHook
|
|
180
|
+
var SQLITE_INSERT = 18;
|
|
181
|
+
var SQLITE_UPDATE = 23;
|
|
182
|
+
var SQLITE_DELETE = 9;
|
|
187
183
|
// var - cwrap function
|
|
188
184
|
var sqlite3_open = cwrap("sqlite3_open", "number", ["string", "number"]);
|
|
189
185
|
var sqlite3_close_v2 = cwrap("sqlite3_close_v2", "number", ["number"]);
|
|
@@ -352,6 +348,12 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
|
|
|
352
348
|
["number"]
|
|
353
349
|
);
|
|
354
350
|
|
|
351
|
+
var sqlite3_update_hook = cwrap(
|
|
352
|
+
"sqlite3_update_hook",
|
|
353
|
+
"number",
|
|
354
|
+
["number", "number", "number"]
|
|
355
|
+
);
|
|
356
|
+
|
|
355
357
|
/**
|
|
356
358
|
* @classdesc
|
|
357
359
|
* Represents a prepared statement.
|
|
@@ -1227,6 +1229,12 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
|
|
|
1227
1229
|
});
|
|
1228
1230
|
Object.values(this.functions).forEach(removeFunction);
|
|
1229
1231
|
this.functions = {};
|
|
1232
|
+
|
|
1233
|
+
if (this.updateHookFunctionPtr) {
|
|
1234
|
+
removeFunction(this.updateHookFunctionPtr);
|
|
1235
|
+
this.updateHookFunctionPtr = undefined;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1230
1238
|
this.handleError(sqlite3_close_v2(this.db));
|
|
1231
1239
|
FS.unlink("/" + this.filename);
|
|
1232
1240
|
this.db = null;
|
|
@@ -1496,10 +1504,91 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
|
|
|
1496
1504
|
return this;
|
|
1497
1505
|
};
|
|
1498
1506
|
|
|
1507
|
+
/** Registers the update hook with SQLite
|
|
1508
|
+
@param {function(operation, database, table, rowId) | null} callback
|
|
1509
|
+
executed whenever a row in any rowid table is changed
|
|
1510
|
+
|
|
1511
|
+
For each changed row, the callback is called once with the change
|
|
1512
|
+
('insert', 'update' or 'delete'), the database name and table name
|
|
1513
|
+
where the change happened and the rowid of the row that has been
|
|
1514
|
+
changed.
|
|
1515
|
+
|
|
1516
|
+
rowid is cast to a plain number, if it exceeds Number.MAX_SAFE_INTEGER
|
|
1517
|
+
an error will be thrown.
|
|
1518
|
+
|
|
1519
|
+
The callback MUST NOT modify the database in any way.
|
|
1520
|
+
|
|
1521
|
+
Only a single callback can be registered. Unregister the callback by
|
|
1522
|
+
passing null.
|
|
1523
|
+
|
|
1524
|
+
Not called for some updates like ON REPLACE CONFLICT and TRUNCATE (a
|
|
1525
|
+
DELETE FROM without a WHERE clause).
|
|
1526
|
+
|
|
1527
|
+
See sqlite docs on sqlite3_update_hook for more details.
|
|
1528
|
+
*/
|
|
1529
|
+
Database.prototype["updateHook"] = function updateHook(callback) {
|
|
1530
|
+
if (this.updateHookFunctionPtr) {
|
|
1531
|
+
// unregister and cleanup a previously registered update hook
|
|
1532
|
+
sqlite3_update_hook(this.db, 0, 0);
|
|
1533
|
+
removeFunction(this.updateHookFunctionPtr);
|
|
1534
|
+
this.updateHookFunctionPtr = undefined;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
if (!callback) {
|
|
1538
|
+
// no new callback to register
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
// void(*)(void *,int ,char const *,char const *,sqlite3_int64)
|
|
1543
|
+
function wrappedCallback(
|
|
1544
|
+
ignored,
|
|
1545
|
+
operationCode,
|
|
1546
|
+
databaseNamePtr,
|
|
1547
|
+
tableNamePtr,
|
|
1548
|
+
rowIdBigInt
|
|
1549
|
+
) {
|
|
1550
|
+
var operation;
|
|
1551
|
+
|
|
1552
|
+
switch (operationCode) {
|
|
1553
|
+
case SQLITE_INSERT:
|
|
1554
|
+
operation = "insert";
|
|
1555
|
+
break;
|
|
1556
|
+
case SQLITE_UPDATE:
|
|
1557
|
+
operation = "update";
|
|
1558
|
+
break;
|
|
1559
|
+
case SQLITE_DELETE:
|
|
1560
|
+
operation = "delete";
|
|
1561
|
+
break;
|
|
1562
|
+
default:
|
|
1563
|
+
throw "unknown operationCode in updateHook callback: "
|
|
1564
|
+
+ operationCode;
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
var databaseName = UTF8ToString(databaseNamePtr);
|
|
1568
|
+
var tableName = UTF8ToString(tableNamePtr);
|
|
1569
|
+
|
|
1570
|
+
if (rowIdBigInt > Number.MAX_SAFE_INTEGER) {
|
|
1571
|
+
throw "rowId too big to fit inside a Number";
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
var rowId = Number(rowIdBigInt);
|
|
1575
|
+
|
|
1576
|
+
callback(operation, databaseName, tableName, rowId);
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
this.updateHookFunctionPtr = addFunction(wrappedCallback, "viiiij");
|
|
1580
|
+
|
|
1581
|
+
sqlite3_update_hook(
|
|
1582
|
+
this.db,
|
|
1583
|
+
this.updateHookFunctionPtr,
|
|
1584
|
+
0 // passed as the first arg to wrappedCallback
|
|
1585
|
+
);
|
|
1586
|
+
};
|
|
1587
|
+
|
|
1499
1588
|
// export Database to Module
|
|
1500
1589
|
Module.Database = Database;
|
|
1501
1590
|
};
|
|
1502
|
-
// end include:
|
|
1591
|
+
// end include: src/api.js
|
|
1503
1592
|
|
|
1504
1593
|
|
|
1505
1594
|
// Sometimes an existing Module object exists with properties
|
|
@@ -1507,7 +1596,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
|
|
|
1507
1596
|
// we collect those properties and reapply _after_ we configure
|
|
1508
1597
|
// the current environment's defaults to avoid having to be so
|
|
1509
1598
|
// defensive during initialization.
|
|
1510
|
-
var moduleOverrides =
|
|
1599
|
+
var moduleOverrides = {...Module};
|
|
1511
1600
|
|
|
1512
1601
|
var arguments_ = [];
|
|
1513
1602
|
var thisProgram = './this.program';
|
|
@@ -1547,23 +1636,19 @@ if (ENVIRONMENT_IS_NODE) {
|
|
|
1547
1636
|
|
|
1548
1637
|
// include: node_shell_read.js
|
|
1549
1638
|
readBinary = (filename) => {
|
|
1550
|
-
// We need to re-wrap `file://` strings to URLs.
|
|
1551
|
-
|
|
1552
|
-
filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
|
|
1639
|
+
// We need to re-wrap `file://` strings to URLs.
|
|
1640
|
+
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
1553
1641
|
var ret = fs.readFileSync(filename);
|
|
1554
|
-
assert(ret
|
|
1642
|
+
assert(Buffer.isBuffer(ret));
|
|
1555
1643
|
return ret;
|
|
1556
1644
|
};
|
|
1557
1645
|
|
|
1558
|
-
readAsync = (filename, binary = true) => {
|
|
1646
|
+
readAsync = async (filename, binary = true) => {
|
|
1559
1647
|
// See the comment in the `readBinary` function.
|
|
1560
|
-
filename = isFileURI(filename) ? new URL(filename) :
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
else resolve(binary ? data.buffer : data);
|
|
1565
|
-
});
|
|
1566
|
-
});
|
|
1648
|
+
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
1649
|
+
var ret = fs.readFileSync(filename, binary ? undefined : 'utf8');
|
|
1650
|
+
assert(binary ? Buffer.isBuffer(ret) : typeof ret == 'string');
|
|
1651
|
+
return ret;
|
|
1567
1652
|
};
|
|
1568
1653
|
// end include: node_shell_read.js
|
|
1569
1654
|
if (!Module['thisProgram'] && process.argv.length > 1) {
|
|
@@ -1584,7 +1669,7 @@ readAsync = (filename, binary = true) => {
|
|
|
1584
1669
|
} else
|
|
1585
1670
|
if (ENVIRONMENT_IS_SHELL) {
|
|
1586
1671
|
|
|
1587
|
-
if ((typeof process == 'object' && typeof require === 'function') || typeof window == 'object' || typeof
|
|
1672
|
+
if ((typeof process == 'object' && typeof require === 'function') || typeof window == 'object' || typeof WorkerGlobalScope != 'undefined') 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?)');
|
|
1588
1673
|
|
|
1589
1674
|
} else
|
|
1590
1675
|
|
|
@@ -1606,10 +1691,10 @@ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
|
1606
1691
|
if (scriptDirectory.startsWith('blob:')) {
|
|
1607
1692
|
scriptDirectory = '';
|
|
1608
1693
|
} else {
|
|
1609
|
-
scriptDirectory = scriptDirectory.
|
|
1694
|
+
scriptDirectory = scriptDirectory.slice(0, scriptDirectory.replace(/[?#].*/, '').lastIndexOf('/')+1);
|
|
1610
1695
|
}
|
|
1611
1696
|
|
|
1612
|
-
if (!(typeof window == 'object' || typeof
|
|
1697
|
+
if (!(typeof window == 'object' || typeof WorkerGlobalScope != 'undefined')) 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?)');
|
|
1613
1698
|
|
|
1614
1699
|
{
|
|
1615
1700
|
// include: web_or_worker_shell_read.js
|
|
@@ -1623,19 +1708,20 @@ if (ENVIRONMENT_IS_WORKER) {
|
|
|
1623
1708
|
};
|
|
1624
1709
|
}
|
|
1625
1710
|
|
|
1626
|
-
readAsync = (url) => {
|
|
1711
|
+
readAsync = async (url) => {
|
|
1627
1712
|
// Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
|
|
1628
1713
|
// See https://github.com/github/fetch/pull/92#issuecomment-140665932
|
|
1629
1714
|
// Cordova or Electron apps are typically loaded from a file:// url.
|
|
1630
1715
|
// So use XHR on webview if URL is a file URL.
|
|
1631
1716
|
if (isFileURI(url)) {
|
|
1632
|
-
return new Promise((
|
|
1717
|
+
return new Promise((resolve, reject) => {
|
|
1633
1718
|
var xhr = new XMLHttpRequest();
|
|
1634
1719
|
xhr.open('GET', url, true);
|
|
1635
1720
|
xhr.responseType = 'arraybuffer';
|
|
1636
1721
|
xhr.onload = () => {
|
|
1637
1722
|
if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
|
|
1638
1723
|
resolve(xhr.response);
|
|
1724
|
+
return;
|
|
1639
1725
|
}
|
|
1640
1726
|
reject(xhr.status);
|
|
1641
1727
|
};
|
|
@@ -1643,13 +1729,11 @@ if (ENVIRONMENT_IS_WORKER) {
|
|
|
1643
1729
|
xhr.send(null);
|
|
1644
1730
|
});
|
|
1645
1731
|
}
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
return Promise.reject(new Error(response.status + ' : ' + response.url));
|
|
1652
|
-
})
|
|
1732
|
+
var response = await fetch(url, { credentials: 'same-origin' });
|
|
1733
|
+
if (response.ok) {
|
|
1734
|
+
return response.arrayBuffer();
|
|
1735
|
+
}
|
|
1736
|
+
throw new Error(response.status + ' : ' + response.url);
|
|
1653
1737
|
};
|
|
1654
1738
|
// end include: web_or_worker_shell_read.js
|
|
1655
1739
|
}
|
|
@@ -1677,8 +1761,6 @@ if (Module['arguments']) arguments_ = Module['arguments'];legacyModuleProp('argu
|
|
|
1677
1761
|
|
|
1678
1762
|
if (Module['thisProgram']) thisProgram = Module['thisProgram'];legacyModuleProp('thisProgram', 'thisProgram');
|
|
1679
1763
|
|
|
1680
|
-
if (Module['quit']) quit_ = Module['quit'];legacyModuleProp('quit', 'quit_');
|
|
1681
|
-
|
|
1682
1764
|
// perform assertions in shell.js after we set up out() and err(), as otherwise if an assertion fails it cannot print the message
|
|
1683
1765
|
// Assertions on removed incoming Module JS APIs.
|
|
1684
1766
|
assert(typeof Module['memoryInitializerPrefixURL'] == 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead');
|
|
@@ -1719,8 +1801,7 @@ assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at bui
|
|
|
1719
1801
|
// An online HTML version (which may be of a different version of Emscripten)
|
|
1720
1802
|
// is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
|
|
1721
1803
|
|
|
1722
|
-
var wasmBinary;
|
|
1723
|
-
if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];legacyModuleProp('wasmBinary', 'wasmBinary');
|
|
1804
|
+
var wasmBinary = Module['wasmBinary'];legacyModuleProp('wasmBinary', 'wasmBinary');
|
|
1724
1805
|
|
|
1725
1806
|
if (typeof WebAssembly != 'object') {
|
|
1726
1807
|
err('no native wasm support detected');
|
|
@@ -1774,31 +1855,24 @@ var HEAP,
|
|
|
1774
1855
|
HEAPU32,
|
|
1775
1856
|
/** @type {!Float32Array} */
|
|
1776
1857
|
HEAPF32,
|
|
1858
|
+
/* BigInt64Array type is not correctly defined in closure
|
|
1859
|
+
/** not-@type {!BigInt64Array} */
|
|
1860
|
+
HEAP64,
|
|
1861
|
+
/* BigUint64Array type is not correctly defined in closure
|
|
1862
|
+
/** not-t@type {!BigUint64Array} */
|
|
1863
|
+
HEAPU64,
|
|
1777
1864
|
/** @type {!Float64Array} */
|
|
1778
1865
|
HEAPF64;
|
|
1779
1866
|
|
|
1780
|
-
|
|
1781
|
-
function updateMemoryViews() {
|
|
1782
|
-
var b = wasmMemory.buffer;
|
|
1783
|
-
Module['HEAP8'] = HEAP8 = new Int8Array(b);
|
|
1784
|
-
Module['HEAP16'] = HEAP16 = new Int16Array(b);
|
|
1785
|
-
Module['HEAPU8'] = HEAPU8 = new Uint8Array(b);
|
|
1786
|
-
Module['HEAPU16'] = HEAPU16 = new Uint16Array(b);
|
|
1787
|
-
Module['HEAP32'] = HEAP32 = new Int32Array(b);
|
|
1788
|
-
Module['HEAPU32'] = HEAPU32 = new Uint32Array(b);
|
|
1789
|
-
Module['HEAPF32'] = HEAPF32 = new Float32Array(b);
|
|
1790
|
-
Module['HEAPF64'] = HEAPF64 = new Float64Array(b);
|
|
1791
|
-
}
|
|
1792
|
-
// end include: runtime_shared.js
|
|
1793
|
-
assert(!Module['STACK_SIZE'], 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time')
|
|
1794
|
-
|
|
1795
|
-
assert(typeof Int32Array != 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray != undefined && Int32Array.prototype.set != undefined,
|
|
1796
|
-
'JS engine does not provide full typed array support');
|
|
1867
|
+
var runtimeInitialized = false;
|
|
1797
1868
|
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1869
|
+
/**
|
|
1870
|
+
* Indicates whether filename is delivered via file protocol (as opposed to http/https)
|
|
1871
|
+
* @noinline
|
|
1872
|
+
*/
|
|
1873
|
+
var isFileURI = (filename) => filename.startsWith('file://');
|
|
1801
1874
|
|
|
1875
|
+
// include: runtime_shared.js
|
|
1802
1876
|
// include: runtime_stack_check.js
|
|
1803
1877
|
// Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
|
|
1804
1878
|
function writeStackCookie() {
|
|
@@ -1837,22 +1911,192 @@ function checkStackCookie() {
|
|
|
1837
1911
|
}
|
|
1838
1912
|
}
|
|
1839
1913
|
// end include: runtime_stack_check.js
|
|
1840
|
-
// include:
|
|
1914
|
+
// include: runtime_exceptions.js
|
|
1915
|
+
// end include: runtime_exceptions.js
|
|
1916
|
+
// include: runtime_debug.js
|
|
1841
1917
|
// Endianness check
|
|
1842
|
-
(
|
|
1918
|
+
(() => {
|
|
1843
1919
|
var h16 = new Int16Array(1);
|
|
1844
1920
|
var h8 = new Int8Array(h16.buffer);
|
|
1845
1921
|
h16[0] = 0x6373;
|
|
1846
1922
|
if (h8[0] !== 0x73 || h8[1] !== 0x63) throw 'Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)';
|
|
1847
1923
|
})();
|
|
1848
1924
|
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
var __ATEXIT__ = []; // functions called during shutdown
|
|
1853
|
-
var __ATPOSTRUN__ = []; // functions called after the main() is called
|
|
1925
|
+
if (Module['ENVIRONMENT']) {
|
|
1926
|
+
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)');
|
|
1927
|
+
}
|
|
1854
1928
|
|
|
1855
|
-
|
|
1929
|
+
function legacyModuleProp(prop, newName, incoming=true) {
|
|
1930
|
+
if (!Object.getOwnPropertyDescriptor(Module, prop)) {
|
|
1931
|
+
Object.defineProperty(Module, prop, {
|
|
1932
|
+
configurable: true,
|
|
1933
|
+
get() {
|
|
1934
|
+
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)' : '';
|
|
1935
|
+
abort(`\`Module.${prop}\` has been replaced by \`${newName}\`` + extra);
|
|
1936
|
+
|
|
1937
|
+
}
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
function consumedModuleProp(prop) {
|
|
1943
|
+
if (!Object.getOwnPropertyDescriptor(Module, prop)) {
|
|
1944
|
+
Object.defineProperty(Module, prop, {
|
|
1945
|
+
configurable: true,
|
|
1946
|
+
set() {
|
|
1947
|
+
abort(`Attempt to set \`Module.${prop}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`);
|
|
1948
|
+
|
|
1949
|
+
}
|
|
1950
|
+
});
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
function ignoredModuleProp(prop) {
|
|
1955
|
+
if (Object.getOwnPropertyDescriptor(Module, prop)) {
|
|
1956
|
+
abort(`\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API`);
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
// forcing the filesystem exports a few things by default
|
|
1961
|
+
function isExportedByForceFilesystem(name) {
|
|
1962
|
+
return name === 'FS_createPath' ||
|
|
1963
|
+
name === 'FS_createDataFile' ||
|
|
1964
|
+
name === 'FS_createPreloadedFile' ||
|
|
1965
|
+
name === 'FS_unlink' ||
|
|
1966
|
+
name === 'addRunDependency' ||
|
|
1967
|
+
// The old FS has some functionality that WasmFS lacks.
|
|
1968
|
+
name === 'FS_createLazyFile' ||
|
|
1969
|
+
name === 'FS_createDevice' ||
|
|
1970
|
+
name === 'removeRunDependency';
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
/**
|
|
1974
|
+
* Intercept access to a global symbol. This enables us to give informative
|
|
1975
|
+
* warnings/errors when folks attempt to use symbols they did not include in
|
|
1976
|
+
* their build, or no symbols that no longer exist.
|
|
1977
|
+
*/
|
|
1978
|
+
function hookGlobalSymbolAccess(sym, func) {
|
|
1979
|
+
if (typeof globalThis != 'undefined' && !Object.getOwnPropertyDescriptor(globalThis, sym)) {
|
|
1980
|
+
Object.defineProperty(globalThis, sym, {
|
|
1981
|
+
configurable: true,
|
|
1982
|
+
get() {
|
|
1983
|
+
func();
|
|
1984
|
+
return undefined;
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
function missingGlobal(sym, msg) {
|
|
1991
|
+
hookGlobalSymbolAccess(sym, () => {
|
|
1992
|
+
warnOnce(`\`${sym}\` is not longer defined by emscripten. ${msg}`);
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
missingGlobal('buffer', 'Please use HEAP8.buffer or wasmMemory.buffer');
|
|
1997
|
+
missingGlobal('asm', 'Please use wasmExports instead');
|
|
1998
|
+
|
|
1999
|
+
function missingLibrarySymbol(sym) {
|
|
2000
|
+
hookGlobalSymbolAccess(sym, () => {
|
|
2001
|
+
// Can't `abort()` here because it would break code that does runtime
|
|
2002
|
+
// checks. e.g. `if (typeof SDL === 'undefined')`.
|
|
2003
|
+
var msg = `\`${sym}\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line`;
|
|
2004
|
+
// DEFAULT_LIBRARY_FUNCS_TO_INCLUDE requires the name as it appears in
|
|
2005
|
+
// library.js, which means $name for a JS name with no prefix, or name
|
|
2006
|
+
// for a JS name like _name.
|
|
2007
|
+
var librarySymbol = sym;
|
|
2008
|
+
if (!librarySymbol.startsWith('_')) {
|
|
2009
|
+
librarySymbol = '$' + sym;
|
|
2010
|
+
}
|
|
2011
|
+
msg += ` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${librarySymbol}')`;
|
|
2012
|
+
if (isExportedByForceFilesystem(sym)) {
|
|
2013
|
+
msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
|
|
2014
|
+
}
|
|
2015
|
+
warnOnce(msg);
|
|
2016
|
+
});
|
|
2017
|
+
|
|
2018
|
+
// Any symbol that is not included from the JS library is also (by definition)
|
|
2019
|
+
// not exported on the Module object.
|
|
2020
|
+
unexportedRuntimeSymbol(sym);
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
function unexportedRuntimeSymbol(sym) {
|
|
2024
|
+
if (!Object.getOwnPropertyDescriptor(Module, sym)) {
|
|
2025
|
+
Object.defineProperty(Module, sym, {
|
|
2026
|
+
configurable: true,
|
|
2027
|
+
get() {
|
|
2028
|
+
var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;
|
|
2029
|
+
if (isExportedByForceFilesystem(sym)) {
|
|
2030
|
+
msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
|
|
2031
|
+
}
|
|
2032
|
+
abort(msg);
|
|
2033
|
+
}
|
|
2034
|
+
});
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
var MAX_UINT8 = (2 ** 8) - 1;
|
|
2039
|
+
var MAX_UINT16 = (2 ** 16) - 1;
|
|
2040
|
+
var MAX_UINT32 = (2 ** 32) - 1;
|
|
2041
|
+
var MAX_UINT53 = (2 ** 53) - 1;
|
|
2042
|
+
var MAX_UINT64 = (2 ** 64) - 1;
|
|
2043
|
+
|
|
2044
|
+
var MIN_INT8 = - (2 ** ( 8 - 1));
|
|
2045
|
+
var MIN_INT16 = - (2 ** (16 - 1));
|
|
2046
|
+
var MIN_INT32 = - (2 ** (32 - 1));
|
|
2047
|
+
var MIN_INT53 = - (2 ** (53 - 1));
|
|
2048
|
+
var MIN_INT64 = - (2 ** (64 - 1));
|
|
2049
|
+
|
|
2050
|
+
function checkInt(value, bits, min, max) {
|
|
2051
|
+
assert(Number.isInteger(Number(value)), `attempt to write non-integer (${value}) into integer heap`);
|
|
2052
|
+
assert(value <= max, `value (${value}) too large to write as ${bits}-bit value`);
|
|
2053
|
+
assert(value >= min, `value (${value}) too small to write as ${bits}-bit value`);
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2056
|
+
var checkInt1 = (value) => checkInt(value, 1, 1);
|
|
2057
|
+
var checkInt8 = (value) => checkInt(value, 8, MIN_INT8, MAX_UINT8);
|
|
2058
|
+
var checkInt16 = (value) => checkInt(value, 16, MIN_INT16, MAX_UINT16);
|
|
2059
|
+
var checkInt32 = (value) => checkInt(value, 32, MIN_INT32, MAX_UINT32);
|
|
2060
|
+
var checkInt53 = (value) => checkInt(value, 53, MIN_INT53, MAX_UINT53);
|
|
2061
|
+
var checkInt64 = (value) => checkInt(value, 64, MIN_INT64, MAX_UINT64);
|
|
2062
|
+
|
|
2063
|
+
var runtimeDebug = true; // Switch to false at runtime to disable logging at the right times
|
|
2064
|
+
|
|
2065
|
+
// Used by XXXXX_DEBUG settings to output debug messages.
|
|
2066
|
+
function dbg(...args) {
|
|
2067
|
+
if (!runtimeDebug && typeof runtimeDebug != 'undefined') return;
|
|
2068
|
+
// TODO(sbc): Make this configurable somehow. Its not always convenient for
|
|
2069
|
+
// logging to show up as warnings.
|
|
2070
|
+
console.warn(...args);
|
|
2071
|
+
}
|
|
2072
|
+
// end include: runtime_debug.js
|
|
2073
|
+
// include: memoryprofiler.js
|
|
2074
|
+
// end include: memoryprofiler.js
|
|
2075
|
+
|
|
2076
|
+
|
|
2077
|
+
function updateMemoryViews() {
|
|
2078
|
+
var b = wasmMemory.buffer;
|
|
2079
|
+
Module['HEAP8'] = HEAP8 = new Int8Array(b);
|
|
2080
|
+
Module['HEAP16'] = HEAP16 = new Int16Array(b);
|
|
2081
|
+
Module['HEAPU8'] = HEAPU8 = new Uint8Array(b);
|
|
2082
|
+
Module['HEAPU16'] = HEAPU16 = new Uint16Array(b);
|
|
2083
|
+
Module['HEAP32'] = HEAP32 = new Int32Array(b);
|
|
2084
|
+
Module['HEAPU32'] = HEAPU32 = new Uint32Array(b);
|
|
2085
|
+
Module['HEAPF32'] = HEAPF32 = new Float32Array(b);
|
|
2086
|
+
Module['HEAPF64'] = HEAPF64 = new Float64Array(b);
|
|
2087
|
+
Module['HEAP64'] = HEAP64 = new BigInt64Array(b);
|
|
2088
|
+
Module['HEAPU64'] = HEAPU64 = new BigUint64Array(b);
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
// end include: runtime_shared.js
|
|
2092
|
+
assert(!Module['STACK_SIZE'], 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time')
|
|
2093
|
+
|
|
2094
|
+
assert(typeof Int32Array != 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray != undefined && Int32Array.prototype.set != undefined,
|
|
2095
|
+
'JS engine does not provide full typed array support');
|
|
2096
|
+
|
|
2097
|
+
// If memory is defined in wasm, the user can't provide it, or set INITIAL_MEMORY
|
|
2098
|
+
assert(!Module['wasmMemory'], 'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally');
|
|
2099
|
+
assert(!Module['INITIAL_MEMORY'], 'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically');
|
|
1856
2100
|
|
|
1857
2101
|
function preRun() {
|
|
1858
2102
|
if (Module['preRun']) {
|
|
@@ -1861,7 +2105,8 @@ function preRun() {
|
|
|
1861
2105
|
addOnPreRun(Module['preRun'].shift());
|
|
1862
2106
|
}
|
|
1863
2107
|
}
|
|
1864
|
-
|
|
2108
|
+
consumedModuleProp('preRun');
|
|
2109
|
+
callRuntimeCallbacks(onPreRuns);
|
|
1865
2110
|
}
|
|
1866
2111
|
|
|
1867
2112
|
function initRuntime() {
|
|
@@ -1872,13 +2117,12 @@ function initRuntime() {
|
|
|
1872
2117
|
|
|
1873
2118
|
setStackLimits();
|
|
1874
2119
|
|
|
1875
|
-
|
|
1876
|
-
if (!Module['noFSInit'] && !FS.init.initialized)
|
|
1877
|
-
FS.init();
|
|
1878
|
-
FS.ignorePermissions = false;
|
|
1879
|
-
|
|
2120
|
+
if (!Module['noFSInit'] && !FS.initialized) FS.init();
|
|
1880
2121
|
TTY.init();
|
|
1881
|
-
|
|
2122
|
+
|
|
2123
|
+
wasmExports['__wasm_call_ctors']();
|
|
2124
|
+
|
|
2125
|
+
FS.ignorePermissions = false;
|
|
1882
2126
|
}
|
|
1883
2127
|
|
|
1884
2128
|
function postRun() {
|
|
@@ -1890,39 +2134,11 @@ function postRun() {
|
|
|
1890
2134
|
addOnPostRun(Module['postRun'].shift());
|
|
1891
2135
|
}
|
|
1892
2136
|
}
|
|
2137
|
+
consumedModuleProp('postRun');
|
|
1893
2138
|
|
|
1894
|
-
callRuntimeCallbacks(
|
|
1895
|
-
}
|
|
1896
|
-
|
|
1897
|
-
function addOnPreRun(cb) {
|
|
1898
|
-
__ATPRERUN__.unshift(cb);
|
|
1899
|
-
}
|
|
1900
|
-
|
|
1901
|
-
function addOnInit(cb) {
|
|
1902
|
-
__ATINIT__.unshift(cb);
|
|
2139
|
+
callRuntimeCallbacks(onPostRuns);
|
|
1903
2140
|
}
|
|
1904
2141
|
|
|
1905
|
-
function addOnExit(cb) {
|
|
1906
|
-
}
|
|
1907
|
-
|
|
1908
|
-
function addOnPostRun(cb) {
|
|
1909
|
-
__ATPOSTRUN__.unshift(cb);
|
|
1910
|
-
}
|
|
1911
|
-
|
|
1912
|
-
// include: runtime_math.js
|
|
1913
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
|
|
1914
|
-
|
|
1915
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround
|
|
1916
|
-
|
|
1917
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
|
|
1918
|
-
|
|
1919
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc
|
|
1920
|
-
|
|
1921
|
-
assert(Math.imul, 'This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
|
|
1922
|
-
assert(Math.fround, 'This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
|
|
1923
|
-
assert(Math.clz32, 'This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
|
|
1924
|
-
assert(Math.trunc, 'This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
|
|
1925
|
-
// end include: runtime_math.js
|
|
1926
2142
|
// A counter of dependencies for calling run(). If we need to
|
|
1927
2143
|
// do asynchronous work before running, increment this and
|
|
1928
2144
|
// decrement it. Incrementing must happen in a place like
|
|
@@ -1931,9 +2147,9 @@ assert(Math.trunc, 'This browser does not support Math.trunc(), build with LEGAC
|
|
|
1931
2147
|
// it happens right before run - run will be postponed until
|
|
1932
2148
|
// the dependencies are met.
|
|
1933
2149
|
var runDependencies = 0;
|
|
1934
|
-
var runDependencyWatcher = null;
|
|
1935
2150
|
var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
|
|
1936
2151
|
var runDependencyTracking = {};
|
|
2152
|
+
var runDependencyWatcher = null;
|
|
1937
2153
|
|
|
1938
2154
|
function getUniqueRunDependency(id) {
|
|
1939
2155
|
var orig = id;
|
|
@@ -2011,7 +2227,6 @@ function abort(what) {
|
|
|
2011
2227
|
err(what);
|
|
2012
2228
|
|
|
2013
2229
|
ABORT = true;
|
|
2014
|
-
EXITSTATUS = 1;
|
|
2015
2230
|
|
|
2016
2231
|
// Use a wasm runtime error, because a JS error might be seen as a foreign
|
|
2017
2232
|
// exception, which means we'd run destructors on it. We need the error to
|
|
@@ -2035,24 +2250,6 @@ function abort(what) {
|
|
|
2035
2250
|
throw e;
|
|
2036
2251
|
}
|
|
2037
2252
|
|
|
2038
|
-
// include: memoryprofiler.js
|
|
2039
|
-
// end include: memoryprofiler.js
|
|
2040
|
-
// include: URIUtils.js
|
|
2041
|
-
// Prefix of data URIs emitted by SINGLE_FILE and related options.
|
|
2042
|
-
var dataURIPrefix = 'data:application/octet-stream;base64,';
|
|
2043
|
-
|
|
2044
|
-
/**
|
|
2045
|
-
* Indicates whether filename is a base64 data URI.
|
|
2046
|
-
* @noinline
|
|
2047
|
-
*/
|
|
2048
|
-
var isDataURI = (filename) => filename.startsWith(dataURIPrefix);
|
|
2049
|
-
|
|
2050
|
-
/**
|
|
2051
|
-
* Indicates whether filename is delivered via file protocol (as opposed to http/https)
|
|
2052
|
-
* @noinline
|
|
2053
|
-
*/
|
|
2054
|
-
var isFileURI = (filename) => filename.startsWith('file://');
|
|
2055
|
-
// end include: URIUtils.js
|
|
2056
2253
|
function createExportWrapper(name, nargs) {
|
|
2057
2254
|
return (...args) => {
|
|
2058
2255
|
assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`);
|
|
@@ -2064,18 +2261,12 @@ function createExportWrapper(name, nargs) {
|
|
|
2064
2261
|
};
|
|
2065
2262
|
}
|
|
2066
2263
|
|
|
2067
|
-
|
|
2068
|
-
|
|
2264
|
+
var wasmBinaryFile;
|
|
2265
|
+
|
|
2069
2266
|
function findWasmBinary() {
|
|
2070
|
-
|
|
2071
|
-
if (!isDataURI(f)) {
|
|
2072
|
-
return locateFile(f);
|
|
2073
|
-
}
|
|
2074
|
-
return f;
|
|
2267
|
+
return locateFile('sql-wasm-debug.wasm');
|
|
2075
2268
|
}
|
|
2076
2269
|
|
|
2077
|
-
var wasmBinaryFile;
|
|
2078
|
-
|
|
2079
2270
|
function getBinarySync(file) {
|
|
2080
2271
|
if (file == wasmBinaryFile && wasmBinary) {
|
|
2081
2272
|
return new Uint8Array(wasmBinary);
|
|
@@ -2086,26 +2277,28 @@ function getBinarySync(file) {
|
|
|
2086
2277
|
throw 'both async and sync fetching of the wasm failed';
|
|
2087
2278
|
}
|
|
2088
2279
|
|
|
2089
|
-
function
|
|
2280
|
+
async function getWasmBinary(binaryFile) {
|
|
2090
2281
|
// If we don't have the binary yet, load it asynchronously using readAsync.
|
|
2091
|
-
if (!wasmBinary
|
|
2092
|
-
) {
|
|
2282
|
+
if (!wasmBinary) {
|
|
2093
2283
|
// Fetch the binary using readAsync
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2284
|
+
try {
|
|
2285
|
+
var response = await readAsync(binaryFile);
|
|
2286
|
+
return new Uint8Array(response);
|
|
2287
|
+
} catch {
|
|
2288
|
+
// Fall back to getBinarySync below;
|
|
2289
|
+
}
|
|
2099
2290
|
}
|
|
2100
2291
|
|
|
2101
2292
|
// Otherwise, getBinarySync should be able to get it synchronously
|
|
2102
|
-
return
|
|
2293
|
+
return getBinarySync(binaryFile);
|
|
2103
2294
|
}
|
|
2104
2295
|
|
|
2105
|
-
function instantiateArrayBuffer(binaryFile, imports
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2296
|
+
async function instantiateArrayBuffer(binaryFile, imports) {
|
|
2297
|
+
try {
|
|
2298
|
+
var binary = await getWasmBinary(binaryFile);
|
|
2299
|
+
var instance = await WebAssembly.instantiate(binary, imports);
|
|
2300
|
+
return instance;
|
|
2301
|
+
} catch (reason) {
|
|
2109
2302
|
err(`failed to asynchronously prepare wasm: ${reason}`);
|
|
2110
2303
|
|
|
2111
2304
|
// Warn on some common problems.
|
|
@@ -2113,43 +2306,34 @@ function instantiateArrayBuffer(binaryFile, imports, receiver) {
|
|
|
2113
2306
|
err(`warning: Loading from a file URI (${wasmBinaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`);
|
|
2114
2307
|
}
|
|
2115
2308
|
abort(reason);
|
|
2116
|
-
}
|
|
2309
|
+
}
|
|
2117
2310
|
}
|
|
2118
2311
|
|
|
2119
|
-
function instantiateAsync(binary, binaryFile, imports
|
|
2120
|
-
if (!binary &&
|
|
2121
|
-
typeof WebAssembly.instantiateStreaming == 'function' &&
|
|
2122
|
-
!isDataURI(binaryFile) &&
|
|
2312
|
+
async function instantiateAsync(binary, binaryFile, imports) {
|
|
2313
|
+
if (!binary && typeof WebAssembly.instantiateStreaming == 'function'
|
|
2123
2314
|
// Don't use streaming for file:// delivered objects in a webview, fetch them synchronously.
|
|
2124
|
-
!isFileURI(binaryFile)
|
|
2315
|
+
&& !isFileURI(binaryFile)
|
|
2125
2316
|
// Avoid instantiateStreaming() on Node.js environment for now, as while
|
|
2126
2317
|
// Node.js v18.1.0 implements it, it does not have a full fetch()
|
|
2127
2318
|
// implementation yet.
|
|
2128
2319
|
//
|
|
2129
2320
|
// Reference:
|
|
2130
2321
|
// https://github.com/emscripten-core/emscripten/pull/16917
|
|
2131
|
-
!ENVIRONMENT_IS_NODE
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
// We expect the most common failure cause to be a bad MIME type for the binary,
|
|
2145
|
-
// in which case falling back to ArrayBuffer instantiation should work.
|
|
2146
|
-
err(`wasm streaming compile failed: ${reason}`);
|
|
2147
|
-
err('falling back to ArrayBuffer instantiation');
|
|
2148
|
-
return instantiateArrayBuffer(binaryFile, imports, callback);
|
|
2149
|
-
});
|
|
2150
|
-
});
|
|
2322
|
+
&& !ENVIRONMENT_IS_NODE
|
|
2323
|
+
) {
|
|
2324
|
+
try {
|
|
2325
|
+
var response = fetch(binaryFile, { credentials: 'same-origin' });
|
|
2326
|
+
var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
|
|
2327
|
+
return instantiationResult;
|
|
2328
|
+
} catch (reason) {
|
|
2329
|
+
// We expect the most common failure cause to be a bad MIME type for the binary,
|
|
2330
|
+
// in which case falling back to ArrayBuffer instantiation should work.
|
|
2331
|
+
err(`wasm streaming compile failed: ${reason}`);
|
|
2332
|
+
err('falling back to ArrayBuffer instantiation');
|
|
2333
|
+
// fall back of instantiateArrayBuffer below
|
|
2334
|
+
};
|
|
2151
2335
|
}
|
|
2152
|
-
return instantiateArrayBuffer(binaryFile, imports
|
|
2336
|
+
return instantiateArrayBuffer(binaryFile, imports);
|
|
2153
2337
|
}
|
|
2154
2338
|
|
|
2155
2339
|
function getWasmImports() {
|
|
@@ -2162,8 +2346,7 @@ function getWasmImports() {
|
|
|
2162
2346
|
|
|
2163
2347
|
// Create the wasm instance.
|
|
2164
2348
|
// Receives the wasm imports, returns the exports.
|
|
2165
|
-
function createWasm() {
|
|
2166
|
-
var info = getWasmImports();
|
|
2349
|
+
async function createWasm() {
|
|
2167
2350
|
// Load the wasm module and create an instance of using native support in the JS engine.
|
|
2168
2351
|
// handle a generated wasm instance, receiving its exports and
|
|
2169
2352
|
// performing other necessary setup
|
|
@@ -2182,8 +2365,6 @@ function createWasm() {
|
|
|
2182
2365
|
|
|
2183
2366
|
assert(wasmTable, 'table not found in wasm exports');
|
|
2184
2367
|
|
|
2185
|
-
addOnInit(wasmExports['__wasm_call_ctors']);
|
|
2186
|
-
|
|
2187
2368
|
removeRunDependency('wasm-instantiate');
|
|
2188
2369
|
return wasmExports;
|
|
2189
2370
|
}
|
|
@@ -2202,9 +2383,11 @@ function createWasm() {
|
|
|
2202
2383
|
trueModule = null;
|
|
2203
2384
|
// TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193, the above line no longer optimizes out down to the following line.
|
|
2204
2385
|
// When the regression is fixed, can restore the above PTHREADS-enabled path.
|
|
2205
|
-
receiveInstance(result['instance']);
|
|
2386
|
+
return receiveInstance(result['instance']);
|
|
2206
2387
|
}
|
|
2207
2388
|
|
|
2389
|
+
var info = getWasmImports();
|
|
2390
|
+
|
|
2208
2391
|
// User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
|
|
2209
2392
|
// to manually instantiate the Wasm module themselves. This allows pages to
|
|
2210
2393
|
// run the instantiation parallel to any other async startup actions they are
|
|
@@ -2212,157 +2395,36 @@ function createWasm() {
|
|
|
2212
2395
|
// Also pthreads and wasm workers initialize the wasm instance through this
|
|
2213
2396
|
// path.
|
|
2214
2397
|
if (Module['instantiateWasm']) {
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult);
|
|
2226
|
-
return {}; // no exports yet; we'll fill them in later
|
|
2227
|
-
}
|
|
2228
|
-
|
|
2229
|
-
// Globals used by JS i64 conversions (see makeSetValue)
|
|
2230
|
-
var tempDouble;
|
|
2231
|
-
var tempI64;
|
|
2232
|
-
|
|
2233
|
-
// include: runtime_debug.js
|
|
2234
|
-
function legacyModuleProp(prop, newName, incoming=true) {
|
|
2235
|
-
if (!Object.getOwnPropertyDescriptor(Module, prop)) {
|
|
2236
|
-
Object.defineProperty(Module, prop, {
|
|
2237
|
-
configurable: true,
|
|
2238
|
-
get() {
|
|
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)' : '';
|
|
2240
|
-
abort(`\`Module.${prop}\` has been replaced by \`${newName}\`` + extra);
|
|
2241
|
-
|
|
2242
|
-
}
|
|
2243
|
-
});
|
|
2244
|
-
}
|
|
2245
|
-
}
|
|
2246
|
-
|
|
2247
|
-
function ignoredModuleProp(prop) {
|
|
2248
|
-
if (Object.getOwnPropertyDescriptor(Module, prop)) {
|
|
2249
|
-
abort(`\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API`);
|
|
2250
|
-
}
|
|
2251
|
-
}
|
|
2252
|
-
|
|
2253
|
-
// forcing the filesystem exports a few things by default
|
|
2254
|
-
function isExportedByForceFilesystem(name) {
|
|
2255
|
-
return name === 'FS_createPath' ||
|
|
2256
|
-
name === 'FS_createDataFile' ||
|
|
2257
|
-
name === 'FS_createPreloadedFile' ||
|
|
2258
|
-
name === 'FS_unlink' ||
|
|
2259
|
-
name === 'addRunDependency' ||
|
|
2260
|
-
// The old FS has some functionality that WasmFS lacks.
|
|
2261
|
-
name === 'FS_createLazyFile' ||
|
|
2262
|
-
name === 'FS_createDevice' ||
|
|
2263
|
-
name === 'removeRunDependency';
|
|
2264
|
-
}
|
|
2265
|
-
|
|
2266
|
-
function missingGlobal(sym, msg) {
|
|
2267
|
-
if (typeof globalThis != 'undefined') {
|
|
2268
|
-
Object.defineProperty(globalThis, sym, {
|
|
2269
|
-
configurable: true,
|
|
2270
|
-
get() {
|
|
2271
|
-
warnOnce(`\`${sym}\` is not longer defined by emscripten. ${msg}`);
|
|
2272
|
-
return undefined;
|
|
2273
|
-
}
|
|
2274
|
-
});
|
|
2275
|
-
}
|
|
2276
|
-
}
|
|
2277
|
-
|
|
2278
|
-
missingGlobal('buffer', 'Please use HEAP8.buffer or wasmMemory.buffer');
|
|
2279
|
-
missingGlobal('asm', 'Please use wasmExports instead');
|
|
2280
|
-
|
|
2281
|
-
function missingLibrarySymbol(sym) {
|
|
2282
|
-
if (typeof globalThis != 'undefined' && !Object.getOwnPropertyDescriptor(globalThis, sym)) {
|
|
2283
|
-
Object.defineProperty(globalThis, sym, {
|
|
2284
|
-
configurable: true,
|
|
2285
|
-
get() {
|
|
2286
|
-
// Can't `abort()` here because it would break code that does runtime
|
|
2287
|
-
// checks. e.g. `if (typeof SDL === 'undefined')`.
|
|
2288
|
-
var msg = `\`${sym}\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line`;
|
|
2289
|
-
// DEFAULT_LIBRARY_FUNCS_TO_INCLUDE requires the name as it appears in
|
|
2290
|
-
// library.js, which means $name for a JS name with no prefix, or name
|
|
2291
|
-
// for a JS name like _name.
|
|
2292
|
-
var librarySymbol = sym;
|
|
2293
|
-
if (!librarySymbol.startsWith('_')) {
|
|
2294
|
-
librarySymbol = '$' + sym;
|
|
2295
|
-
}
|
|
2296
|
-
msg += ` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${librarySymbol}')`;
|
|
2297
|
-
if (isExportedByForceFilesystem(sym)) {
|
|
2298
|
-
msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
|
|
2299
|
-
}
|
|
2300
|
-
warnOnce(msg);
|
|
2301
|
-
return undefined;
|
|
2302
|
-
}
|
|
2303
|
-
});
|
|
2304
|
-
}
|
|
2305
|
-
// Any symbol that is not included from the JS library is also (by definition)
|
|
2306
|
-
// not exported on the Module object.
|
|
2307
|
-
unexportedRuntimeSymbol(sym);
|
|
2308
|
-
}
|
|
2309
|
-
|
|
2310
|
-
function unexportedRuntimeSymbol(sym) {
|
|
2311
|
-
if (!Object.getOwnPropertyDescriptor(Module, sym)) {
|
|
2312
|
-
Object.defineProperty(Module, sym, {
|
|
2313
|
-
configurable: true,
|
|
2314
|
-
get() {
|
|
2315
|
-
var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;
|
|
2316
|
-
if (isExportedByForceFilesystem(sym)) {
|
|
2317
|
-
msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
|
|
2318
|
-
}
|
|
2319
|
-
abort(msg);
|
|
2398
|
+
return new Promise((resolve, reject) => {
|
|
2399
|
+
try {
|
|
2400
|
+
Module['instantiateWasm'](info, (mod, inst) => {
|
|
2401
|
+
receiveInstance(mod, inst);
|
|
2402
|
+
resolve(mod.exports);
|
|
2403
|
+
});
|
|
2404
|
+
} catch(e) {
|
|
2405
|
+
err(`Module.instantiateWasm callback failed with error: ${e}`);
|
|
2406
|
+
reject(e);
|
|
2320
2407
|
}
|
|
2321
2408
|
});
|
|
2322
2409
|
}
|
|
2323
|
-
}
|
|
2324
|
-
|
|
2325
|
-
var MAX_UINT8 = (2 ** 8) - 1;
|
|
2326
|
-
var MAX_UINT16 = (2 ** 16) - 1;
|
|
2327
|
-
var MAX_UINT32 = (2 ** 32) - 1;
|
|
2328
|
-
var MAX_UINT53 = (2 ** 53) - 1;
|
|
2329
|
-
var MAX_UINT64 = (2 ** 64) - 1;
|
|
2330
|
-
|
|
2331
|
-
var MIN_INT8 = - (2 ** ( 8 - 1)) + 1;
|
|
2332
|
-
var MIN_INT16 = - (2 ** (16 - 1)) + 1;
|
|
2333
|
-
var MIN_INT32 = - (2 ** (32 - 1)) + 1;
|
|
2334
|
-
var MIN_INT53 = - (2 ** (53 - 1)) + 1;
|
|
2335
|
-
var MIN_INT64 = - (2 ** (64 - 1)) + 1;
|
|
2336
2410
|
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2411
|
+
wasmBinaryFile ??= findWasmBinary();
|
|
2412
|
+
var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
|
|
2413
|
+
var exports = receiveInstantiationResult(result);
|
|
2414
|
+
return exports;
|
|
2341
2415
|
}
|
|
2342
2416
|
|
|
2343
|
-
var checkInt1 = (value) => checkInt(value, 1, 1);
|
|
2344
|
-
var checkInt8 = (value) => checkInt(value, 8, MIN_INT8, MAX_UINT8);
|
|
2345
|
-
var checkInt16 = (value) => checkInt(value, 16, MIN_INT16, MAX_UINT16);
|
|
2346
|
-
var checkInt32 = (value) => checkInt(value, 32, MIN_INT32, MAX_UINT32);
|
|
2347
|
-
var checkInt53 = (value) => checkInt(value, 53, MIN_INT53, MAX_UINT53);
|
|
2348
|
-
var checkInt64 = (value) => checkInt(value, 64, MIN_INT64, MAX_UINT64);
|
|
2349
|
-
|
|
2350
|
-
// Used by XXXXX_DEBUG settings to output debug messages.
|
|
2351
|
-
function dbg(...args) {
|
|
2352
|
-
// TODO(sbc): Make this configurable somehow. Its not always convenient for
|
|
2353
|
-
// logging to show up as warnings.
|
|
2354
|
-
console.warn(...args);
|
|
2355
|
-
}
|
|
2356
|
-
// end include: runtime_debug.js
|
|
2357
|
-
// === Body ===
|
|
2358
2417
|
// end include: preamble.js
|
|
2359
2418
|
|
|
2419
|
+
// Begin JS library code
|
|
2420
|
+
|
|
2360
2421
|
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2422
|
+
class ExitStatus {
|
|
2423
|
+
name = 'ExitStatus';
|
|
2424
|
+
constructor(status) {
|
|
2425
|
+
this.message = `Program terminated with exit(${status})`;
|
|
2426
|
+
this.status = status;
|
|
2427
|
+
}
|
|
2366
2428
|
}
|
|
2367
2429
|
|
|
2368
2430
|
var callRuntimeCallbacks = (callbacks) => {
|
|
@@ -2371,6 +2433,12 @@ function dbg(...args) {
|
|
|
2371
2433
|
callbacks.shift()(Module);
|
|
2372
2434
|
}
|
|
2373
2435
|
};
|
|
2436
|
+
var onPostRuns = [];
|
|
2437
|
+
var addOnPostRun = (cb) => onPostRuns.unshift(cb);
|
|
2438
|
+
|
|
2439
|
+
var onPreRuns = [];
|
|
2440
|
+
var addOnPreRun = (cb) => onPreRuns.unshift(cb);
|
|
2441
|
+
|
|
2374
2442
|
|
|
2375
2443
|
|
|
2376
2444
|
/**
|
|
@@ -2384,7 +2452,7 @@ function dbg(...args) {
|
|
|
2384
2452
|
case 'i8': return HEAP8[ptr];
|
|
2385
2453
|
case 'i16': return HEAP16[((ptr)>>1)];
|
|
2386
2454
|
case 'i32': return HEAP32[((ptr)>>2)];
|
|
2387
|
-
case 'i64':
|
|
2455
|
+
case 'i64': return HEAP64[((ptr)>>3)];
|
|
2388
2456
|
case 'float': return HEAPF32[((ptr)>>2)];
|
|
2389
2457
|
case 'double': return HEAPF64[((ptr)>>3)];
|
|
2390
2458
|
case '*': return HEAPU32[((ptr)>>2)];
|
|
@@ -2420,7 +2488,7 @@ function dbg(...args) {
|
|
|
2420
2488
|
case 'i8': HEAP8[ptr] = value;checkInt8(value); break;
|
|
2421
2489
|
case 'i16': HEAP16[((ptr)>>1)] = value;checkInt16(value); break;
|
|
2422
2490
|
case 'i32': HEAP32[((ptr)>>2)] = value;checkInt32(value); break;
|
|
2423
|
-
case 'i64':
|
|
2491
|
+
case 'i64': HEAP64[((ptr)>>3)] = BigInt(value);checkInt64(value); break;
|
|
2424
2492
|
case 'float': HEAPF32[((ptr)>>2)] = value; break;
|
|
2425
2493
|
case 'double': HEAPF64[((ptr)>>3)] = value; break;
|
|
2426
2494
|
case '*': HEAPU32[((ptr)>>2)] = value; break;
|
|
@@ -2448,18 +2516,18 @@ function dbg(...args) {
|
|
|
2448
2516
|
* array that contains uint8 values, returns a copy of that string as a
|
|
2449
2517
|
* Javascript String object.
|
|
2450
2518
|
* heapOrArray is either a regular array, or a JavaScript typed array view.
|
|
2451
|
-
* @param {number} idx
|
|
2519
|
+
* @param {number=} idx
|
|
2452
2520
|
* @param {number=} maxBytesToRead
|
|
2453
2521
|
* @return {string}
|
|
2454
2522
|
*/
|
|
2455
|
-
var UTF8ArrayToString = (heapOrArray, idx, maxBytesToRead) => {
|
|
2523
|
+
var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead = NaN) => {
|
|
2456
2524
|
var endIdx = idx + maxBytesToRead;
|
|
2457
2525
|
var endPtr = idx;
|
|
2458
2526
|
// TextDecoder needs to know the byte length in advance, it doesn't stop on
|
|
2459
2527
|
// null terminator by itself. Also, use the length info to avoid running tiny
|
|
2460
2528
|
// strings through TextDecoder, since .subarray() allocates garbage.
|
|
2461
2529
|
// (As a tiny code save trick, compare endPtr against endIdx using a negation,
|
|
2462
|
-
// so that undefined means Infinity)
|
|
2530
|
+
// so that undefined/NaN means Infinity)
|
|
2463
2531
|
while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
|
|
2464
2532
|
|
|
2465
2533
|
if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
|
|
@@ -2514,9 +2582,8 @@ function dbg(...args) {
|
|
|
2514
2582
|
assert(typeof ptr == 'number', `UTF8ToString expects a number (got ${typeof ptr})`);
|
|
2515
2583
|
return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
|
|
2516
2584
|
};
|
|
2517
|
-
var ___assert_fail = (condition, filename, line, func) =>
|
|
2585
|
+
var ___assert_fail = (condition, filename, line, func) =>
|
|
2518
2586
|
abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
|
|
2519
|
-
};
|
|
2520
2587
|
|
|
2521
2588
|
|
|
2522
2589
|
|
|
@@ -2559,7 +2626,7 @@ function dbg(...args) {
|
|
|
2559
2626
|
},
|
|
2560
2627
|
normalize:(path) => {
|
|
2561
2628
|
var isAbsolute = PATH.isAbs(path),
|
|
2562
|
-
trailingSlash = path.
|
|
2629
|
+
trailingSlash = path.slice(-1) === '/';
|
|
2563
2630
|
// Normalize the path
|
|
2564
2631
|
path = PATH.normalizeArray(path.split('/').filter((p) => !!p), !isAbsolute).join('/');
|
|
2565
2632
|
if (!path && !isAbsolute) {
|
|
@@ -2580,54 +2647,27 @@ function dbg(...args) {
|
|
|
2580
2647
|
}
|
|
2581
2648
|
if (dir) {
|
|
2582
2649
|
// It has a dirname, strip trailing slash
|
|
2583
|
-
dir = dir.
|
|
2650
|
+
dir = dir.slice(0, -1);
|
|
2584
2651
|
}
|
|
2585
2652
|
return root + dir;
|
|
2586
2653
|
},
|
|
2587
|
-
basename:(path) =>
|
|
2588
|
-
// EMSCRIPTEN return '/'' for '/', not an empty string
|
|
2589
|
-
if (path === '/') return '/';
|
|
2590
|
-
path = PATH.normalize(path);
|
|
2591
|
-
path = path.replace(/\/$/, "");
|
|
2592
|
-
var lastSlash = path.lastIndexOf('/');
|
|
2593
|
-
if (lastSlash === -1) return path;
|
|
2594
|
-
return path.substr(lastSlash+1);
|
|
2595
|
-
},
|
|
2654
|
+
basename:(path) => path && path.match(/([^\/]+|\/)\/*$/)[1],
|
|
2596
2655
|
join:(...paths) => PATH.normalize(paths.join('/')),
|
|
2597
2656
|
join2:(l, r) => PATH.normalize(l + '/' + r),
|
|
2598
2657
|
};
|
|
2599
2658
|
|
|
2600
2659
|
var initRandomFill = () => {
|
|
2601
|
-
|
|
2602
|
-
// for modern web browsers
|
|
2603
|
-
return (view) => crypto.getRandomValues(view);
|
|
2604
|
-
} else
|
|
2660
|
+
// This block is not needed on v19+ since crypto.getRandomValues is builtin
|
|
2605
2661
|
if (ENVIRONMENT_IS_NODE) {
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
var crypto_module = require('crypto');
|
|
2609
|
-
var randomFillSync = crypto_module['randomFillSync'];
|
|
2610
|
-
if (randomFillSync) {
|
|
2611
|
-
// nodejs with LTS crypto support
|
|
2612
|
-
return (view) => crypto_module['randomFillSync'](view);
|
|
2613
|
-
}
|
|
2614
|
-
// very old nodejs with the original crypto API
|
|
2615
|
-
var randomBytes = crypto_module['randomBytes'];
|
|
2616
|
-
return (view) => (
|
|
2617
|
-
view.set(randomBytes(view.byteLength)),
|
|
2618
|
-
// Return the original view to match modern native implementations.
|
|
2619
|
-
view
|
|
2620
|
-
);
|
|
2621
|
-
} catch (e) {
|
|
2622
|
-
// nodejs doesn't have crypto support
|
|
2623
|
-
}
|
|
2662
|
+
var nodeCrypto = require('crypto');
|
|
2663
|
+
return (view) => nodeCrypto.randomFillSync(view);
|
|
2624
2664
|
}
|
|
2625
|
-
|
|
2626
|
-
|
|
2665
|
+
|
|
2666
|
+
return (view) => crypto.getRandomValues(view);
|
|
2627
2667
|
};
|
|
2628
2668
|
var randomFill = (view) => {
|
|
2629
2669
|
// Lazily init on the first invocation.
|
|
2630
|
-
|
|
2670
|
+
(randomFill = initRandomFill())(view);
|
|
2631
2671
|
};
|
|
2632
2672
|
|
|
2633
2673
|
|
|
@@ -2653,8 +2693,8 @@ function dbg(...args) {
|
|
|
2653
2693
|
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
|
2654
2694
|
},
|
|
2655
2695
|
relative:(from, to) => {
|
|
2656
|
-
from = PATH_FS.resolve(from).
|
|
2657
|
-
to = PATH_FS.resolve(to).
|
|
2696
|
+
from = PATH_FS.resolve(from).slice(1);
|
|
2697
|
+
to = PATH_FS.resolve(to).slice(1);
|
|
2658
2698
|
function trim(arr) {
|
|
2659
2699
|
var start = 0;
|
|
2660
2700
|
for (; start < arr.length; start++) {
|
|
@@ -2759,13 +2799,13 @@ function dbg(...args) {
|
|
|
2759
2799
|
return outIdx - startIdx;
|
|
2760
2800
|
};
|
|
2761
2801
|
/** @type {function(string, boolean=, number=)} */
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2802
|
+
var intArrayFromString = (stringy, dontAddNull, length) => {
|
|
2803
|
+
var len = length > 0 ? length : lengthBytesUTF8(stringy)+1;
|
|
2804
|
+
var u8array = new Array(len);
|
|
2805
|
+
var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
|
|
2806
|
+
if (dontAddNull) u8array.length = numBytesWritten;
|
|
2807
|
+
return u8array;
|
|
2808
|
+
};
|
|
2769
2809
|
var FS_stdin_getChar = () => {
|
|
2770
2810
|
if (!FS_stdin_getChar_buffer.length) {
|
|
2771
2811
|
var result = null;
|
|
@@ -2877,7 +2917,7 @@ function dbg(...args) {
|
|
|
2877
2917
|
buffer[offset+i] = result;
|
|
2878
2918
|
}
|
|
2879
2919
|
if (bytesRead) {
|
|
2880
|
-
stream.node.
|
|
2920
|
+
stream.node.atime = Date.now();
|
|
2881
2921
|
}
|
|
2882
2922
|
return bytesRead;
|
|
2883
2923
|
},
|
|
@@ -2893,7 +2933,7 @@ function dbg(...args) {
|
|
|
2893
2933
|
throw new FS.ErrnoError(29);
|
|
2894
2934
|
}
|
|
2895
2935
|
if (length) {
|
|
2896
|
-
stream.node.
|
|
2936
|
+
stream.node.mtime = stream.node.ctime = Date.now();
|
|
2897
2937
|
}
|
|
2898
2938
|
return i;
|
|
2899
2939
|
},
|
|
@@ -2904,15 +2944,15 @@ function dbg(...args) {
|
|
|
2904
2944
|
},
|
|
2905
2945
|
put_char(tty, val) {
|
|
2906
2946
|
if (val === null || val === 10) {
|
|
2907
|
-
out(UTF8ArrayToString(tty.output
|
|
2947
|
+
out(UTF8ArrayToString(tty.output));
|
|
2908
2948
|
tty.output = [];
|
|
2909
2949
|
} else {
|
|
2910
2950
|
if (val != 0) tty.output.push(val); // val == 0 would cut text output off in the middle.
|
|
2911
2951
|
}
|
|
2912
2952
|
},
|
|
2913
2953
|
fsync(tty) {
|
|
2914
|
-
if (tty.output
|
|
2915
|
-
out(UTF8ArrayToString(tty.output
|
|
2954
|
+
if (tty.output?.length > 0) {
|
|
2955
|
+
out(UTF8ArrayToString(tty.output));
|
|
2916
2956
|
tty.output = [];
|
|
2917
2957
|
}
|
|
2918
2958
|
},
|
|
@@ -2941,15 +2981,15 @@ function dbg(...args) {
|
|
|
2941
2981
|
default_tty1_ops:{
|
|
2942
2982
|
put_char(tty, val) {
|
|
2943
2983
|
if (val === null || val === 10) {
|
|
2944
|
-
err(UTF8ArrayToString(tty.output
|
|
2984
|
+
err(UTF8ArrayToString(tty.output));
|
|
2945
2985
|
tty.output = [];
|
|
2946
2986
|
} else {
|
|
2947
2987
|
if (val != 0) tty.output.push(val);
|
|
2948
2988
|
}
|
|
2949
2989
|
},
|
|
2950
2990
|
fsync(tty) {
|
|
2951
|
-
if (tty.output
|
|
2952
|
-
err(UTF8ArrayToString(tty.output
|
|
2991
|
+
if (tty.output?.length > 0) {
|
|
2992
|
+
err(UTF8ArrayToString(tty.output));
|
|
2953
2993
|
tty.output = [];
|
|
2954
2994
|
}
|
|
2955
2995
|
},
|
|
@@ -2957,10 +2997,7 @@ function dbg(...args) {
|
|
|
2957
2997
|
};
|
|
2958
2998
|
|
|
2959
2999
|
|
|
2960
|
-
var zeroMemory = (
|
|
2961
|
-
HEAPU8.fill(0, address, address + size);
|
|
2962
|
-
return address;
|
|
2963
|
-
};
|
|
3000
|
+
var zeroMemory = (ptr, size) => HEAPU8.fill(0, ptr, ptr + size);
|
|
2964
3001
|
|
|
2965
3002
|
var alignMemory = (size, alignment) => {
|
|
2966
3003
|
assert(alignment, "alignment argument is required");
|
|
@@ -2969,13 +3006,13 @@ function dbg(...args) {
|
|
|
2969
3006
|
var mmapAlloc = (size) => {
|
|
2970
3007
|
size = alignMemory(size, 65536);
|
|
2971
3008
|
var ptr = _emscripten_builtin_memalign(65536, size);
|
|
2972
|
-
if (
|
|
2973
|
-
return
|
|
3009
|
+
if (ptr) zeroMemory(ptr, size);
|
|
3010
|
+
return ptr;
|
|
2974
3011
|
};
|
|
2975
3012
|
var MEMFS = {
|
|
2976
3013
|
ops_table:null,
|
|
2977
3014
|
mount(mount) {
|
|
2978
|
-
return MEMFS.createNode(null, '/',
|
|
3015
|
+
return MEMFS.createNode(null, '/', 16895, 0);
|
|
2979
3016
|
},
|
|
2980
3017
|
createNode(parent, name, mode, dev) {
|
|
2981
3018
|
if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
|
|
@@ -3008,7 +3045,6 @@ function dbg(...args) {
|
|
|
3008
3045
|
llseek: MEMFS.stream_ops.llseek,
|
|
3009
3046
|
read: MEMFS.stream_ops.read,
|
|
3010
3047
|
write: MEMFS.stream_ops.write,
|
|
3011
|
-
allocate: MEMFS.stream_ops.allocate,
|
|
3012
3048
|
mmap: MEMFS.stream_ops.mmap,
|
|
3013
3049
|
msync: MEMFS.stream_ops.msync
|
|
3014
3050
|
}
|
|
@@ -3049,11 +3085,11 @@ function dbg(...args) {
|
|
|
3049
3085
|
node.node_ops = MEMFS.ops_table.chrdev.node;
|
|
3050
3086
|
node.stream_ops = MEMFS.ops_table.chrdev.stream;
|
|
3051
3087
|
}
|
|
3052
|
-
node.
|
|
3088
|
+
node.atime = node.mtime = node.ctime = Date.now();
|
|
3053
3089
|
// add the new node to the parent
|
|
3054
3090
|
if (parent) {
|
|
3055
3091
|
parent.contents[name] = node;
|
|
3056
|
-
parent.
|
|
3092
|
+
parent.atime = parent.mtime = parent.ctime = node.atime;
|
|
3057
3093
|
}
|
|
3058
3094
|
return node;
|
|
3059
3095
|
},
|
|
@@ -3109,9 +3145,9 @@ function dbg(...args) {
|
|
|
3109
3145
|
} else {
|
|
3110
3146
|
attr.size = 0;
|
|
3111
3147
|
}
|
|
3112
|
-
attr.atime = new Date(node.
|
|
3113
|
-
attr.mtime = new Date(node.
|
|
3114
|
-
attr.ctime = new Date(node.
|
|
3148
|
+
attr.atime = new Date(node.atime);
|
|
3149
|
+
attr.mtime = new Date(node.mtime);
|
|
3150
|
+
attr.ctime = new Date(node.ctime);
|
|
3115
3151
|
// NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
|
|
3116
3152
|
// but this is not required by the standard.
|
|
3117
3153
|
attr.blksize = 4096;
|
|
@@ -3119,46 +3155,44 @@ function dbg(...args) {
|
|
|
3119
3155
|
return attr;
|
|
3120
3156
|
},
|
|
3121
3157
|
setattr(node, attr) {
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
node.timestamp = attr.timestamp;
|
|
3158
|
+
for (const key of ["mode", "atime", "mtime", "ctime"]) {
|
|
3159
|
+
if (attr[key] != null) {
|
|
3160
|
+
node[key] = attr[key];
|
|
3161
|
+
}
|
|
3127
3162
|
}
|
|
3128
3163
|
if (attr.size !== undefined) {
|
|
3129
3164
|
MEMFS.resizeFileStorage(node, attr.size);
|
|
3130
3165
|
}
|
|
3131
3166
|
},
|
|
3132
3167
|
lookup(parent, name) {
|
|
3133
|
-
throw FS.
|
|
3168
|
+
throw new FS.ErrnoError(44);
|
|
3134
3169
|
},
|
|
3135
3170
|
mknod(parent, name, mode, dev) {
|
|
3136
3171
|
return MEMFS.createNode(parent, name, mode, dev);
|
|
3137
3172
|
},
|
|
3138
3173
|
rename(old_node, new_dir, new_name) {
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
if (new_node) {
|
|
3174
|
+
var new_node;
|
|
3175
|
+
try {
|
|
3176
|
+
new_node = FS.lookupNode(new_dir, new_name);
|
|
3177
|
+
} catch (e) {}
|
|
3178
|
+
if (new_node) {
|
|
3179
|
+
if (FS.isDir(old_node.mode)) {
|
|
3180
|
+
// if we're overwriting a directory at new_name, make sure it's empty.
|
|
3147
3181
|
for (var i in new_node.contents) {
|
|
3148
3182
|
throw new FS.ErrnoError(55);
|
|
3149
3183
|
}
|
|
3150
3184
|
}
|
|
3185
|
+
FS.hashRemoveNode(new_node);
|
|
3151
3186
|
}
|
|
3152
3187
|
// do the internal rewiring
|
|
3153
3188
|
delete old_node.parent.contents[old_node.name];
|
|
3154
|
-
old_node.parent.timestamp = Date.now()
|
|
3155
|
-
old_node.name = new_name;
|
|
3156
3189
|
new_dir.contents[new_name] = old_node;
|
|
3157
|
-
|
|
3190
|
+
old_node.name = new_name;
|
|
3191
|
+
new_dir.ctime = new_dir.mtime = old_node.parent.ctime = old_node.parent.mtime = Date.now();
|
|
3158
3192
|
},
|
|
3159
3193
|
unlink(parent, name) {
|
|
3160
3194
|
delete parent.contents[name];
|
|
3161
|
-
parent.
|
|
3195
|
+
parent.ctime = parent.mtime = Date.now();
|
|
3162
3196
|
},
|
|
3163
3197
|
rmdir(parent, name) {
|
|
3164
3198
|
var node = FS.lookupNode(parent, name);
|
|
@@ -3166,17 +3200,13 @@ function dbg(...args) {
|
|
|
3166
3200
|
throw new FS.ErrnoError(55);
|
|
3167
3201
|
}
|
|
3168
3202
|
delete parent.contents[name];
|
|
3169
|
-
parent.
|
|
3203
|
+
parent.ctime = parent.mtime = Date.now();
|
|
3170
3204
|
},
|
|
3171
3205
|
readdir(node) {
|
|
3172
|
-
|
|
3173
|
-
for (var key of Object.keys(node.contents)) {
|
|
3174
|
-
entries.push(key);
|
|
3175
|
-
}
|
|
3176
|
-
return entries;
|
|
3206
|
+
return ['.', '..', ...Object.keys(node.contents)];
|
|
3177
3207
|
},
|
|
3178
3208
|
symlink(parent, newname, oldpath) {
|
|
3179
|
-
var node = MEMFS.createNode(parent, newname,
|
|
3209
|
+
var node = MEMFS.createNode(parent, newname, 0o777 | 40960, 0);
|
|
3180
3210
|
node.link = oldpath;
|
|
3181
3211
|
return node;
|
|
3182
3212
|
},
|
|
@@ -3213,7 +3243,7 @@ function dbg(...args) {
|
|
|
3213
3243
|
|
|
3214
3244
|
if (!length) return 0;
|
|
3215
3245
|
var node = stream.node;
|
|
3216
|
-
node.
|
|
3246
|
+
node.mtime = node.ctime = Date.now();
|
|
3217
3247
|
|
|
3218
3248
|
if (buffer.subarray && (!node.contents || node.contents.subarray)) { // This write is from a typed array to a typed array?
|
|
3219
3249
|
if (canOwn) {
|
|
@@ -3258,10 +3288,6 @@ function dbg(...args) {
|
|
|
3258
3288
|
}
|
|
3259
3289
|
return position;
|
|
3260
3290
|
},
|
|
3261
|
-
allocate(stream, offset, length) {
|
|
3262
|
-
MEMFS.expandFileStorage(stream.node, offset + length);
|
|
3263
|
-
stream.node.usedBytes = Math.max(stream.node.usedBytes, offset + length);
|
|
3264
|
-
},
|
|
3265
3291
|
mmap(stream, length, position, prot, flags) {
|
|
3266
3292
|
if (!FS.isFile(stream.node.mode)) {
|
|
3267
3293
|
throw new FS.ErrnoError(43);
|
|
@@ -3270,26 +3296,28 @@ function dbg(...args) {
|
|
|
3270
3296
|
var allocated;
|
|
3271
3297
|
var contents = stream.node.contents;
|
|
3272
3298
|
// Only make a new copy when MAP_PRIVATE is specified.
|
|
3273
|
-
if (!(flags & 2) && contents.buffer === HEAP8.buffer) {
|
|
3299
|
+
if (!(flags & 2) && contents && contents.buffer === HEAP8.buffer) {
|
|
3274
3300
|
// We can't emulate MAP_SHARED when the file is not backed by the
|
|
3275
3301
|
// buffer we're mapping to (e.g. the HEAP buffer).
|
|
3276
3302
|
allocated = false;
|
|
3277
3303
|
ptr = contents.byteOffset;
|
|
3278
3304
|
} else {
|
|
3279
|
-
// Try to avoid unnecessary slices.
|
|
3280
|
-
if (position > 0 || position + length < contents.length) {
|
|
3281
|
-
if (contents.subarray) {
|
|
3282
|
-
contents = contents.subarray(position, position + length);
|
|
3283
|
-
} else {
|
|
3284
|
-
contents = Array.prototype.slice.call(contents, position, position + length);
|
|
3285
|
-
}
|
|
3286
|
-
}
|
|
3287
3305
|
allocated = true;
|
|
3288
3306
|
ptr = mmapAlloc(length);
|
|
3289
3307
|
if (!ptr) {
|
|
3290
3308
|
throw new FS.ErrnoError(48);
|
|
3291
3309
|
}
|
|
3292
|
-
|
|
3310
|
+
if (contents) {
|
|
3311
|
+
// Try to avoid unnecessary slices.
|
|
3312
|
+
if (position > 0 || position + length < contents.length) {
|
|
3313
|
+
if (contents.subarray) {
|
|
3314
|
+
contents = contents.subarray(position, position + length);
|
|
3315
|
+
} else {
|
|
3316
|
+
contents = Array.prototype.slice.call(contents, position, position + length);
|
|
3317
|
+
}
|
|
3318
|
+
}
|
|
3319
|
+
HEAP8.set(contents, ptr);
|
|
3320
|
+
}
|
|
3293
3321
|
}
|
|
3294
3322
|
return { ptr, allocated };
|
|
3295
3323
|
},
|
|
@@ -3301,24 +3329,10 @@ function dbg(...args) {
|
|
|
3301
3329
|
},
|
|
3302
3330
|
};
|
|
3303
3331
|
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
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
|
-
}
|
|
3319
|
-
}
|
|
3320
|
-
);
|
|
3321
|
-
if (dep) addRunDependency(dep);
|
|
3332
|
+
var asyncLoad = async (url) => {
|
|
3333
|
+
var arrayBuffer = await readAsync(url);
|
|
3334
|
+
assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
|
|
3335
|
+
return new Uint8Array(arrayBuffer);
|
|
3322
3336
|
};
|
|
3323
3337
|
|
|
3324
3338
|
|
|
@@ -3365,7 +3379,7 @@ function dbg(...args) {
|
|
|
3365
3379
|
}
|
|
3366
3380
|
addRunDependency(dep);
|
|
3367
3381
|
if (typeof url == 'string') {
|
|
3368
|
-
asyncLoad(url
|
|
3382
|
+
asyncLoad(url).then(processData, onerror);
|
|
3369
3383
|
} else {
|
|
3370
3384
|
processData(url);
|
|
3371
3385
|
}
|
|
@@ -3399,9 +3413,7 @@ function dbg(...args) {
|
|
|
3399
3413
|
|
|
3400
3414
|
|
|
3401
3415
|
|
|
3402
|
-
var strError = (errno) =>
|
|
3403
|
-
return UTF8ToString(_strerror(errno));
|
|
3404
|
-
};
|
|
3416
|
+
var strError = (errno) => UTF8ToString(_strerror(errno));
|
|
3405
3417
|
|
|
3406
3418
|
var ERRNO_CODES = {
|
|
3407
3419
|
'EPERM': 63,
|
|
@@ -3537,7 +3549,12 @@ function dbg(...args) {
|
|
|
3537
3549
|
currentPath:"/",
|
|
3538
3550
|
initialized:false,
|
|
3539
3551
|
ignorePermissions:true,
|
|
3552
|
+
filesystems:null,
|
|
3553
|
+
syncFSRequests:0,
|
|
3554
|
+
readFiles:{
|
|
3555
|
+
},
|
|
3540
3556
|
ErrnoError:class extends Error {
|
|
3557
|
+
name = 'ErrnoError';
|
|
3541
3558
|
// We set the `name` property to be able to identify `FS.ErrnoError`
|
|
3542
3559
|
// - the `name` is a standard ECMA-262 property of error objects. Kind of good to have it anyway.
|
|
3543
3560
|
// - when using PROXYFS, an error can come from an underlying FS
|
|
@@ -3546,9 +3563,6 @@ function dbg(...args) {
|
|
|
3546
3563
|
// we'll use the reliable test `err.name == "ErrnoError"` instead
|
|
3547
3564
|
constructor(errno) {
|
|
3548
3565
|
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
3566
|
this.errno = errno;
|
|
3553
3567
|
for (var key in ERRNO_CODES) {
|
|
3554
3568
|
if (ERRNO_CODES[key] === errno) {
|
|
@@ -3558,16 +3572,8 @@ function dbg(...args) {
|
|
|
3558
3572
|
}
|
|
3559
3573
|
}
|
|
3560
3574
|
},
|
|
3561
|
-
genericErrors:{
|
|
3562
|
-
},
|
|
3563
|
-
filesystems:null,
|
|
3564
|
-
syncFSRequests:0,
|
|
3565
3575
|
FSStream:class {
|
|
3566
|
-
|
|
3567
|
-
// TODO(https://github.com/emscripten-core/emscripten/issues/21414):
|
|
3568
|
-
// Use inline field declarations.
|
|
3569
|
-
this.shared = {};
|
|
3570
|
-
}
|
|
3576
|
+
shared = {};
|
|
3571
3577
|
get object() {
|
|
3572
3578
|
return this.node;
|
|
3573
3579
|
}
|
|
@@ -3597,21 +3603,22 @@ function dbg(...args) {
|
|
|
3597
3603
|
}
|
|
3598
3604
|
},
|
|
3599
3605
|
FSNode:class {
|
|
3606
|
+
node_ops = {};
|
|
3607
|
+
stream_ops = {};
|
|
3608
|
+
readMode = 292 | 73;
|
|
3609
|
+
writeMode = 146;
|
|
3610
|
+
mounted = null;
|
|
3600
3611
|
constructor(parent, name, mode, rdev) {
|
|
3601
3612
|
if (!parent) {
|
|
3602
3613
|
parent = this; // root node sets parent to itself
|
|
3603
3614
|
}
|
|
3604
3615
|
this.parent = parent;
|
|
3605
3616
|
this.mount = parent.mount;
|
|
3606
|
-
this.mounted = null;
|
|
3607
3617
|
this.id = FS.nextInode++;
|
|
3608
3618
|
this.name = name;
|
|
3609
3619
|
this.mode = mode;
|
|
3610
|
-
this.node_ops = {};
|
|
3611
|
-
this.stream_ops = {};
|
|
3612
3620
|
this.rdev = rdev;
|
|
3613
|
-
this.
|
|
3614
|
-
this.writeMode = 146/*146*/;
|
|
3621
|
+
this.atime = this.mtime = this.ctime = Date.now();
|
|
3615
3622
|
}
|
|
3616
3623
|
get read() {
|
|
3617
3624
|
return (this.mode & this.readMode) === this.readMode;
|
|
@@ -3633,63 +3640,76 @@ function dbg(...args) {
|
|
|
3633
3640
|
}
|
|
3634
3641
|
},
|
|
3635
3642
|
lookupPath(path, opts = {}) {
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
var defaults = {
|
|
3641
|
-
follow_mount: true,
|
|
3642
|
-
recurse_count: 0
|
|
3643
|
-
};
|
|
3644
|
-
opts = Object.assign(defaults, opts)
|
|
3643
|
+
if (!path) {
|
|
3644
|
+
throw new FS.ErrnoError(44);
|
|
3645
|
+
}
|
|
3646
|
+
opts.follow_mount ??= true
|
|
3645
3647
|
|
|
3646
|
-
if (
|
|
3647
|
-
|
|
3648
|
+
if (!PATH.isAbs(path)) {
|
|
3649
|
+
path = FS.cwd() + '/' + path;
|
|
3648
3650
|
}
|
|
3649
3651
|
|
|
3650
|
-
//
|
|
3651
|
-
var
|
|
3652
|
+
// limit max consecutive symlinks to 40 (SYMLOOP_MAX).
|
|
3653
|
+
linkloop: for (var nlinks = 0; nlinks < 40; nlinks++) {
|
|
3654
|
+
// split the absolute path
|
|
3655
|
+
var parts = path.split('/').filter((p) => !!p);
|
|
3652
3656
|
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3657
|
+
// start at the root
|
|
3658
|
+
var current = FS.root;
|
|
3659
|
+
var current_path = '/';
|
|
3656
3660
|
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3661
|
+
for (var i = 0; i < parts.length; i++) {
|
|
3662
|
+
var islast = (i === parts.length-1);
|
|
3663
|
+
if (islast && opts.parent) {
|
|
3664
|
+
// stop resolving
|
|
3665
|
+
break;
|
|
3666
|
+
}
|
|
3663
3667
|
|
|
3664
|
-
|
|
3665
|
-
|
|
3668
|
+
if (parts[i] === '.') {
|
|
3669
|
+
continue;
|
|
3670
|
+
}
|
|
3666
3671
|
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3672
|
+
if (parts[i] === '..') {
|
|
3673
|
+
current_path = PATH.dirname(current_path);
|
|
3674
|
+
current = current.parent;
|
|
3675
|
+
continue;
|
|
3671
3676
|
}
|
|
3672
|
-
}
|
|
3673
3677
|
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3678
|
+
current_path = PATH.join2(current_path, parts[i]);
|
|
3679
|
+
try {
|
|
3680
|
+
current = FS.lookupNode(current, parts[i]);
|
|
3681
|
+
} catch (e) {
|
|
3682
|
+
// if noent_okay is true, suppress a ENOENT in the last component
|
|
3683
|
+
// and return an object with an undefined node. This is needed for
|
|
3684
|
+
// resolving symlinks in the path when creating a file.
|
|
3685
|
+
if ((e?.errno === 44) && islast && opts.noent_okay) {
|
|
3686
|
+
return { path: current_path };
|
|
3687
|
+
}
|
|
3688
|
+
throw e;
|
|
3689
|
+
}
|
|
3681
3690
|
|
|
3682
|
-
|
|
3683
|
-
|
|
3691
|
+
// jump to the mount's root node if this is a mountpoint
|
|
3692
|
+
if (FS.isMountpoint(current) && (!islast || opts.follow_mount)) {
|
|
3693
|
+
current = current.mounted.root;
|
|
3694
|
+
}
|
|
3684
3695
|
|
|
3685
|
-
|
|
3686
|
-
|
|
3696
|
+
// by default, lookupPath will not follow a symlink if it is the final path component.
|
|
3697
|
+
// setting opts.follow = true will override this behavior.
|
|
3698
|
+
if (FS.isLink(current.mode) && (!islast || opts.follow)) {
|
|
3699
|
+
if (!current.node_ops.readlink) {
|
|
3700
|
+
throw new FS.ErrnoError(52);
|
|
3701
|
+
}
|
|
3702
|
+
var link = current.node_ops.readlink(current);
|
|
3703
|
+
if (!PATH.isAbs(link)) {
|
|
3704
|
+
link = PATH.dirname(current_path) + '/' + link;
|
|
3687
3705
|
}
|
|
3706
|
+
path = link + '/' + parts.slice(i + 1).join('/');
|
|
3707
|
+
continue linkloop;
|
|
3688
3708
|
}
|
|
3689
3709
|
}
|
|
3710
|
+
return { path: current_path, node: current };
|
|
3690
3711
|
}
|
|
3691
|
-
|
|
3692
|
-
return { path: current_path, node: current };
|
|
3712
|
+
throw new FS.ErrnoError(32);
|
|
3693
3713
|
},
|
|
3694
3714
|
getPath(node) {
|
|
3695
3715
|
var path;
|
|
@@ -3813,6 +3833,9 @@ function dbg(...args) {
|
|
|
3813
3833
|
return 0;
|
|
3814
3834
|
},
|
|
3815
3835
|
mayCreate(dir, name) {
|
|
3836
|
+
if (!FS.isDir(dir.mode)) {
|
|
3837
|
+
return 54;
|
|
3838
|
+
}
|
|
3816
3839
|
try {
|
|
3817
3840
|
var node = FS.lookupNode(dir, name);
|
|
3818
3841
|
return 20;
|
|
@@ -3852,13 +3875,19 @@ function dbg(...args) {
|
|
|
3852
3875
|
if (FS.isLink(node.mode)) {
|
|
3853
3876
|
return 32;
|
|
3854
3877
|
} else if (FS.isDir(node.mode)) {
|
|
3855
|
-
if (FS.flagsToPermissionString(flags) !== 'r'
|
|
3856
|
-
(flags & 512)) { // TODO: check for O_SEARCH? (== search for dir only)
|
|
3878
|
+
if (FS.flagsToPermissionString(flags) !== 'r' // opening for write
|
|
3879
|
+
|| (flags & (512 | 64))) { // TODO: check for O_SEARCH? (== search for dir only)
|
|
3857
3880
|
return 31;
|
|
3858
3881
|
}
|
|
3859
3882
|
}
|
|
3860
3883
|
return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
|
|
3861
3884
|
},
|
|
3885
|
+
checkOpExists(op, err) {
|
|
3886
|
+
if (!op) {
|
|
3887
|
+
throw new FS.ErrnoError(err);
|
|
3888
|
+
}
|
|
3889
|
+
return op;
|
|
3890
|
+
},
|
|
3862
3891
|
MAX_OPEN_FDS:4096,
|
|
3863
3892
|
nextfd() {
|
|
3864
3893
|
for (var fd = 0; fd <= FS.MAX_OPEN_FDS; fd++) {
|
|
@@ -3896,6 +3925,13 @@ function dbg(...args) {
|
|
|
3896
3925
|
stream.stream_ops?.dup?.(stream);
|
|
3897
3926
|
return stream;
|
|
3898
3927
|
},
|
|
3928
|
+
doSetAttr(stream, node, attr) {
|
|
3929
|
+
var setattr = stream?.stream_ops.setattr;
|
|
3930
|
+
var arg = setattr ? stream : node;
|
|
3931
|
+
setattr ??= node.node_ops.setattr;
|
|
3932
|
+
FS.checkOpExists(setattr, 63)
|
|
3933
|
+
setattr(arg, attr);
|
|
3934
|
+
},
|
|
3899
3935
|
chrdev_stream_ops:{
|
|
3900
3936
|
open(stream) {
|
|
3901
3937
|
var device = FS.getDevice(stream.node.rdev);
|
|
@@ -4065,9 +4101,12 @@ function dbg(...args) {
|
|
|
4065
4101
|
var lookup = FS.lookupPath(path, { parent: true });
|
|
4066
4102
|
var parent = lookup.node;
|
|
4067
4103
|
var name = PATH.basename(path);
|
|
4068
|
-
if (!name
|
|
4104
|
+
if (!name) {
|
|
4069
4105
|
throw new FS.ErrnoError(28);
|
|
4070
4106
|
}
|
|
4107
|
+
if (name === '.' || name === '..') {
|
|
4108
|
+
throw new FS.ErrnoError(20);
|
|
4109
|
+
}
|
|
4071
4110
|
var errCode = FS.mayCreate(parent, name);
|
|
4072
4111
|
if (errCode) {
|
|
4073
4112
|
throw new FS.ErrnoError(errCode);
|
|
@@ -4077,14 +4116,43 @@ function dbg(...args) {
|
|
|
4077
4116
|
}
|
|
4078
4117
|
return parent.node_ops.mknod(parent, name, mode, dev);
|
|
4079
4118
|
},
|
|
4080
|
-
|
|
4081
|
-
|
|
4119
|
+
statfs(path) {
|
|
4120
|
+
return FS.statfsNode(FS.lookupPath(path, {follow: true}).node);
|
|
4121
|
+
},
|
|
4122
|
+
statfsStream(stream) {
|
|
4123
|
+
// We keep a separate statfsStream function because noderawfs overrides
|
|
4124
|
+
// it. In noderawfs, stream.node is sometimes null. Instead, we need to
|
|
4125
|
+
// look at stream.path.
|
|
4126
|
+
return FS.statfsNode(stream.node);
|
|
4127
|
+
},
|
|
4128
|
+
statfsNode(node) {
|
|
4129
|
+
// NOTE: None of the defaults here are true. We're just returning safe and
|
|
4130
|
+
// sane values. Currently nodefs and rawfs replace these defaults,
|
|
4131
|
+
// other file systems leave them alone.
|
|
4132
|
+
var rtn = {
|
|
4133
|
+
bsize: 4096,
|
|
4134
|
+
frsize: 4096,
|
|
4135
|
+
blocks: 1e6,
|
|
4136
|
+
bfree: 5e5,
|
|
4137
|
+
bavail: 5e5,
|
|
4138
|
+
files: FS.nextInode,
|
|
4139
|
+
ffree: FS.nextInode - 1,
|
|
4140
|
+
fsid: 42,
|
|
4141
|
+
flags: 2,
|
|
4142
|
+
namelen: 255,
|
|
4143
|
+
};
|
|
4144
|
+
|
|
4145
|
+
if (node.node_ops.statfs) {
|
|
4146
|
+
Object.assign(rtn, node.node_ops.statfs(node.mount.opts.root));
|
|
4147
|
+
}
|
|
4148
|
+
return rtn;
|
|
4149
|
+
},
|
|
4150
|
+
create(path, mode = 0o666) {
|
|
4082
4151
|
mode &= 4095;
|
|
4083
4152
|
mode |= 32768;
|
|
4084
4153
|
return FS.mknod(path, mode, 0);
|
|
4085
4154
|
},
|
|
4086
|
-
mkdir(path, mode) {
|
|
4087
|
-
mode = mode !== undefined ? mode : 511 /* 0777 */;
|
|
4155
|
+
mkdir(path, mode = 0o777) {
|
|
4088
4156
|
mode &= 511 | 512;
|
|
4089
4157
|
mode |= 16384;
|
|
4090
4158
|
return FS.mknod(path, mode, 0);
|
|
@@ -4092,9 +4160,9 @@ function dbg(...args) {
|
|
|
4092
4160
|
mkdirTree(path, mode) {
|
|
4093
4161
|
var dirs = path.split('/');
|
|
4094
4162
|
var d = '';
|
|
4095
|
-
for (var
|
|
4096
|
-
if (!
|
|
4097
|
-
d += '/' +
|
|
4163
|
+
for (var dir of dirs) {
|
|
4164
|
+
if (!dir) continue;
|
|
4165
|
+
d += '/' + dir;
|
|
4098
4166
|
try {
|
|
4099
4167
|
FS.mkdir(d, mode);
|
|
4100
4168
|
} catch(e) {
|
|
@@ -4105,7 +4173,7 @@ function dbg(...args) {
|
|
|
4105
4173
|
mkdev(path, mode, dev) {
|
|
4106
4174
|
if (typeof dev == 'undefined') {
|
|
4107
4175
|
dev = mode;
|
|
4108
|
-
mode =
|
|
4176
|
+
mode = 0o666;
|
|
4109
4177
|
}
|
|
4110
4178
|
mode |= 8192;
|
|
4111
4179
|
return FS.mknod(path, mode, dev);
|
|
@@ -4203,7 +4271,7 @@ function dbg(...args) {
|
|
|
4203
4271
|
// do the underlying fs rename
|
|
4204
4272
|
try {
|
|
4205
4273
|
old_dir.node_ops.rename(old_node, new_dir, new_name);
|
|
4206
|
-
// update old node (we do this here to avoid each backend
|
|
4274
|
+
// update old node (we do this here to avoid each backend
|
|
4207
4275
|
// needing to)
|
|
4208
4276
|
old_node.parent = new_dir;
|
|
4209
4277
|
} catch (e) {
|
|
@@ -4235,10 +4303,8 @@ function dbg(...args) {
|
|
|
4235
4303
|
readdir(path) {
|
|
4236
4304
|
var lookup = FS.lookupPath(path, { follow: true });
|
|
4237
4305
|
var node = lookup.node;
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
}
|
|
4241
|
-
return node.node_ops.readdir(node);
|
|
4306
|
+
var readdir = FS.checkOpExists(node.node_ops.readdir, 54);
|
|
4307
|
+
return readdir(node);
|
|
4242
4308
|
},
|
|
4243
4309
|
unlink(path) {
|
|
4244
4310
|
var lookup = FS.lookupPath(path, { parent: true });
|
|
@@ -4273,22 +4339,33 @@ function dbg(...args) {
|
|
|
4273
4339
|
if (!link.node_ops.readlink) {
|
|
4274
4340
|
throw new FS.ErrnoError(28);
|
|
4275
4341
|
}
|
|
4276
|
-
return
|
|
4342
|
+
return link.node_ops.readlink(link);
|
|
4277
4343
|
},
|
|
4278
4344
|
stat(path, dontFollow) {
|
|
4279
4345
|
var lookup = FS.lookupPath(path, { follow: !dontFollow });
|
|
4280
4346
|
var node = lookup.node;
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4347
|
+
var getattr = FS.checkOpExists(node.node_ops.getattr, 63);
|
|
4348
|
+
return getattr(node);
|
|
4349
|
+
},
|
|
4350
|
+
fstat(fd) {
|
|
4351
|
+
var stream = FS.getStreamChecked(fd);
|
|
4352
|
+
var node = stream.node;
|
|
4353
|
+
var getattr = stream.stream_ops.getattr;
|
|
4354
|
+
var arg = getattr ? stream : node;
|
|
4355
|
+
getattr ??= node.node_ops.getattr;
|
|
4356
|
+
FS.checkOpExists(getattr, 63)
|
|
4357
|
+
return getattr(arg);
|
|
4288
4358
|
},
|
|
4289
4359
|
lstat(path) {
|
|
4290
4360
|
return FS.stat(path, true);
|
|
4291
4361
|
},
|
|
4362
|
+
doChmod(stream, node, mode, dontFollow) {
|
|
4363
|
+
FS.doSetAttr(stream, node, {
|
|
4364
|
+
mode: (mode & 4095) | (node.mode & ~4095),
|
|
4365
|
+
ctime: Date.now(),
|
|
4366
|
+
dontFollow
|
|
4367
|
+
});
|
|
4368
|
+
},
|
|
4292
4369
|
chmod(path, mode, dontFollow) {
|
|
4293
4370
|
var node;
|
|
4294
4371
|
if (typeof path == 'string') {
|
|
@@ -4297,20 +4374,21 @@ function dbg(...args) {
|
|
|
4297
4374
|
} else {
|
|
4298
4375
|
node = path;
|
|
4299
4376
|
}
|
|
4300
|
-
|
|
4301
|
-
throw new FS.ErrnoError(63);
|
|
4302
|
-
}
|
|
4303
|
-
node.node_ops.setattr(node, {
|
|
4304
|
-
mode: (mode & 4095) | (node.mode & ~4095),
|
|
4305
|
-
timestamp: Date.now()
|
|
4306
|
-
});
|
|
4377
|
+
FS.doChmod(null, node, mode, dontFollow);
|
|
4307
4378
|
},
|
|
4308
4379
|
lchmod(path, mode) {
|
|
4309
4380
|
FS.chmod(path, mode, true);
|
|
4310
4381
|
},
|
|
4311
4382
|
fchmod(fd, mode) {
|
|
4312
4383
|
var stream = FS.getStreamChecked(fd);
|
|
4313
|
-
FS.
|
|
4384
|
+
FS.doChmod(stream, stream.node, mode, false);
|
|
4385
|
+
},
|
|
4386
|
+
doChown(stream, node, dontFollow) {
|
|
4387
|
+
FS.doSetAttr(stream, node, {
|
|
4388
|
+
timestamp: Date.now(),
|
|
4389
|
+
dontFollow
|
|
4390
|
+
// we ignore the uid / gid for now
|
|
4391
|
+
});
|
|
4314
4392
|
},
|
|
4315
4393
|
chown(path, uid, gid, dontFollow) {
|
|
4316
4394
|
var node;
|
|
@@ -4320,35 +4398,16 @@ function dbg(...args) {
|
|
|
4320
4398
|
} else {
|
|
4321
4399
|
node = path;
|
|
4322
4400
|
}
|
|
4323
|
-
|
|
4324
|
-
throw new FS.ErrnoError(63);
|
|
4325
|
-
}
|
|
4326
|
-
node.node_ops.setattr(node, {
|
|
4327
|
-
timestamp: Date.now()
|
|
4328
|
-
// we ignore the uid / gid for now
|
|
4329
|
-
});
|
|
4401
|
+
FS.doChown(null, node, dontFollow);
|
|
4330
4402
|
},
|
|
4331
4403
|
lchown(path, uid, gid) {
|
|
4332
4404
|
FS.chown(path, uid, gid, true);
|
|
4333
4405
|
},
|
|
4334
4406
|
fchown(fd, uid, gid) {
|
|
4335
4407
|
var stream = FS.getStreamChecked(fd);
|
|
4336
|
-
FS.
|
|
4408
|
+
FS.doChown(stream, stream.node, false);
|
|
4337
4409
|
},
|
|
4338
|
-
|
|
4339
|
-
if (len < 0) {
|
|
4340
|
-
throw new FS.ErrnoError(28);
|
|
4341
|
-
}
|
|
4342
|
-
var node;
|
|
4343
|
-
if (typeof path == 'string') {
|
|
4344
|
-
var lookup = FS.lookupPath(path, { follow: true });
|
|
4345
|
-
node = lookup.node;
|
|
4346
|
-
} else {
|
|
4347
|
-
node = path;
|
|
4348
|
-
}
|
|
4349
|
-
if (!node.node_ops.setattr) {
|
|
4350
|
-
throw new FS.ErrnoError(63);
|
|
4351
|
-
}
|
|
4410
|
+
doTruncate(stream, node, len) {
|
|
4352
4411
|
if (FS.isDir(node.mode)) {
|
|
4353
4412
|
throw new FS.ErrnoError(31);
|
|
4354
4413
|
}
|
|
@@ -4359,49 +4418,65 @@ function dbg(...args) {
|
|
|
4359
4418
|
if (errCode) {
|
|
4360
4419
|
throw new FS.ErrnoError(errCode);
|
|
4361
4420
|
}
|
|
4362
|
-
|
|
4421
|
+
FS.doSetAttr(stream, node, {
|
|
4363
4422
|
size: len,
|
|
4364
4423
|
timestamp: Date.now()
|
|
4365
4424
|
});
|
|
4366
4425
|
},
|
|
4426
|
+
truncate(path, len) {
|
|
4427
|
+
if (len < 0) {
|
|
4428
|
+
throw new FS.ErrnoError(28);
|
|
4429
|
+
}
|
|
4430
|
+
var node;
|
|
4431
|
+
if (typeof path == 'string') {
|
|
4432
|
+
var lookup = FS.lookupPath(path, { follow: true });
|
|
4433
|
+
node = lookup.node;
|
|
4434
|
+
} else {
|
|
4435
|
+
node = path;
|
|
4436
|
+
}
|
|
4437
|
+
FS.doTruncate(null, node, len);
|
|
4438
|
+
},
|
|
4367
4439
|
ftruncate(fd, len) {
|
|
4368
4440
|
var stream = FS.getStreamChecked(fd);
|
|
4369
|
-
if ((stream.flags & 2097155) === 0) {
|
|
4441
|
+
if (len < 0 || (stream.flags & 2097155) === 0) {
|
|
4370
4442
|
throw new FS.ErrnoError(28);
|
|
4371
4443
|
}
|
|
4372
|
-
FS.
|
|
4444
|
+
FS.doTruncate(stream, stream.node, len);
|
|
4373
4445
|
},
|
|
4374
4446
|
utime(path, atime, mtime) {
|
|
4375
4447
|
var lookup = FS.lookupPath(path, { follow: true });
|
|
4376
4448
|
var node = lookup.node;
|
|
4377
|
-
node.node_ops.setattr
|
|
4378
|
-
|
|
4449
|
+
var setattr = FS.checkOpExists(node.node_ops.setattr, 63);
|
|
4450
|
+
setattr(node, {
|
|
4451
|
+
atime: atime,
|
|
4452
|
+
mtime: mtime
|
|
4379
4453
|
});
|
|
4380
4454
|
},
|
|
4381
|
-
open(path, flags, mode) {
|
|
4455
|
+
open(path, flags, mode = 0o666) {
|
|
4382
4456
|
if (path === "") {
|
|
4383
4457
|
throw new FS.ErrnoError(44);
|
|
4384
4458
|
}
|
|
4385
4459
|
flags = typeof flags == 'string' ? FS_modeStringToFlags(flags) : flags;
|
|
4386
4460
|
if ((flags & 64)) {
|
|
4387
|
-
mode = typeof mode == 'undefined' ? 438 /* 0666 */ : mode;
|
|
4388
4461
|
mode = (mode & 4095) | 32768;
|
|
4389
4462
|
} else {
|
|
4390
4463
|
mode = 0;
|
|
4391
4464
|
}
|
|
4392
4465
|
var node;
|
|
4466
|
+
var isDirPath;
|
|
4393
4467
|
if (typeof path == 'object') {
|
|
4394
4468
|
node = path;
|
|
4395
4469
|
} else {
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4470
|
+
isDirPath = path.endsWith("/");
|
|
4471
|
+
// noent_okay makes it so that if the final component of the path
|
|
4472
|
+
// doesn't exist, lookupPath returns `node: undefined`. `path` will be
|
|
4473
|
+
// updated to point to the target of all symlinks.
|
|
4474
|
+
var lookup = FS.lookupPath(path, {
|
|
4475
|
+
follow: !(flags & 131072),
|
|
4476
|
+
noent_okay: true
|
|
4477
|
+
});
|
|
4478
|
+
node = lookup.node;
|
|
4479
|
+
path = lookup.path;
|
|
4405
4480
|
}
|
|
4406
4481
|
// perhaps we need to create the node
|
|
4407
4482
|
var created = false;
|
|
@@ -4411,9 +4486,14 @@ function dbg(...args) {
|
|
|
4411
4486
|
if ((flags & 128)) {
|
|
4412
4487
|
throw new FS.ErrnoError(20);
|
|
4413
4488
|
}
|
|
4489
|
+
} else if (isDirPath) {
|
|
4490
|
+
throw new FS.ErrnoError(31);
|
|
4414
4491
|
} else {
|
|
4415
4492
|
// node doesn't exist, try to create it
|
|
4416
|
-
|
|
4493
|
+
// Ignore the permission bits here to ensure we can `open` this new
|
|
4494
|
+
// file below. We use chmod below the apply the permissions once the
|
|
4495
|
+
// file is open.
|
|
4496
|
+
node = FS.mknod(path, mode | 0o777, 0);
|
|
4417
4497
|
created = true;
|
|
4418
4498
|
}
|
|
4419
4499
|
}
|
|
@@ -4460,8 +4540,10 @@ function dbg(...args) {
|
|
|
4460
4540
|
if (stream.stream_ops.open) {
|
|
4461
4541
|
stream.stream_ops.open(stream);
|
|
4462
4542
|
}
|
|
4543
|
+
if (created) {
|
|
4544
|
+
FS.chmod(node, mode & 0o777);
|
|
4545
|
+
}
|
|
4463
4546
|
if (Module['logReadFiles'] && !(flags & 1)) {
|
|
4464
|
-
if (!FS.readFiles) FS.readFiles = {};
|
|
4465
4547
|
if (!(path in FS.readFiles)) {
|
|
4466
4548
|
FS.readFiles[path] = 1;
|
|
4467
4549
|
}
|
|
@@ -4559,24 +4641,6 @@ function dbg(...args) {
|
|
|
4559
4641
|
if (!seeking) stream.position += bytesWritten;
|
|
4560
4642
|
return bytesWritten;
|
|
4561
4643
|
},
|
|
4562
|
-
allocate(stream, offset, length) {
|
|
4563
|
-
if (FS.isClosed(stream)) {
|
|
4564
|
-
throw new FS.ErrnoError(8);
|
|
4565
|
-
}
|
|
4566
|
-
if (offset < 0 || length <= 0) {
|
|
4567
|
-
throw new FS.ErrnoError(28);
|
|
4568
|
-
}
|
|
4569
|
-
if ((stream.flags & 2097155) === 0) {
|
|
4570
|
-
throw new FS.ErrnoError(8);
|
|
4571
|
-
}
|
|
4572
|
-
if (!FS.isFile(stream.node.mode) && !FS.isDir(stream.node.mode)) {
|
|
4573
|
-
throw new FS.ErrnoError(43);
|
|
4574
|
-
}
|
|
4575
|
-
if (!stream.stream_ops.allocate) {
|
|
4576
|
-
throw new FS.ErrnoError(138);
|
|
4577
|
-
}
|
|
4578
|
-
stream.stream_ops.allocate(stream, offset, length);
|
|
4579
|
-
},
|
|
4580
4644
|
mmap(stream, length, position, prot, flags) {
|
|
4581
4645
|
// User requests writing to file (prot & PROT_WRITE != 0).
|
|
4582
4646
|
// Checking if we have permissions to write to the file unless
|
|
@@ -4595,6 +4659,9 @@ function dbg(...args) {
|
|
|
4595
4659
|
if (!stream.stream_ops.mmap) {
|
|
4596
4660
|
throw new FS.ErrnoError(43);
|
|
4597
4661
|
}
|
|
4662
|
+
if (!length) {
|
|
4663
|
+
throw new FS.ErrnoError(28);
|
|
4664
|
+
}
|
|
4598
4665
|
return stream.stream_ops.mmap(stream, length, position, prot, flags);
|
|
4599
4666
|
},
|
|
4600
4667
|
msync(stream, buffer, offset, length, mmapFlags) {
|
|
@@ -4623,7 +4690,7 @@ function dbg(...args) {
|
|
|
4623
4690
|
var buf = new Uint8Array(length);
|
|
4624
4691
|
FS.read(stream, buf, 0, length, 0);
|
|
4625
4692
|
if (opts.encoding === 'utf8') {
|
|
4626
|
-
ret = UTF8ArrayToString(buf
|
|
4693
|
+
ret = UTF8ArrayToString(buf);
|
|
4627
4694
|
} else if (opts.encoding === 'binary') {
|
|
4628
4695
|
ret = buf;
|
|
4629
4696
|
}
|
|
@@ -4671,6 +4738,7 @@ function dbg(...args) {
|
|
|
4671
4738
|
FS.registerDevice(FS.makedev(1, 3), {
|
|
4672
4739
|
read: () => 0,
|
|
4673
4740
|
write: (stream, buffer, offset, length, pos) => length,
|
|
4741
|
+
llseek: () => 0,
|
|
4674
4742
|
});
|
|
4675
4743
|
FS.mkdev('/dev/null', FS.makedev(1, 3));
|
|
4676
4744
|
// setup /dev/tty and /dev/tty1
|
|
@@ -4685,7 +4753,8 @@ function dbg(...args) {
|
|
|
4685
4753
|
var randomBuffer = new Uint8Array(1024), randomLeft = 0;
|
|
4686
4754
|
var randomByte = () => {
|
|
4687
4755
|
if (randomLeft === 0) {
|
|
4688
|
-
|
|
4756
|
+
randomFill(randomBuffer);
|
|
4757
|
+
randomLeft = randomBuffer.byteLength;
|
|
4689
4758
|
}
|
|
4690
4759
|
return randomBuffer[--randomLeft];
|
|
4691
4760
|
};
|
|
@@ -4704,7 +4773,10 @@ function dbg(...args) {
|
|
|
4704
4773
|
FS.mkdir('/proc/self/fd');
|
|
4705
4774
|
FS.mount({
|
|
4706
4775
|
mount() {
|
|
4707
|
-
var node = FS.createNode(proc_self, 'fd',
|
|
4776
|
+
var node = FS.createNode(proc_self, 'fd', 16895, 73);
|
|
4777
|
+
node.stream_ops = {
|
|
4778
|
+
llseek: MEMFS.stream_ops.llseek,
|
|
4779
|
+
};
|
|
4708
4780
|
node.node_ops = {
|
|
4709
4781
|
lookup(parent, name) {
|
|
4710
4782
|
var fd = +name;
|
|
@@ -4713,16 +4785,22 @@ function dbg(...args) {
|
|
|
4713
4785
|
parent: null,
|
|
4714
4786
|
mount: { mountpoint: 'fake' },
|
|
4715
4787
|
node_ops: { readlink: () => stream.path },
|
|
4788
|
+
id: fd + 1,
|
|
4716
4789
|
};
|
|
4717
4790
|
ret.parent = ret; // make it look like a simple root node
|
|
4718
4791
|
return ret;
|
|
4792
|
+
},
|
|
4793
|
+
readdir() {
|
|
4794
|
+
return Array.from(FS.streams.entries())
|
|
4795
|
+
.filter(([k, v]) => v)
|
|
4796
|
+
.map(([k, v]) => k.toString());
|
|
4719
4797
|
}
|
|
4720
4798
|
};
|
|
4721
4799
|
return node;
|
|
4722
4800
|
}
|
|
4723
4801
|
}, {}, '/proc/self/fd');
|
|
4724
4802
|
},
|
|
4725
|
-
createStandardStreams() {
|
|
4803
|
+
createStandardStreams(input, output, error) {
|
|
4726
4804
|
// TODO deprecate the old functionality of a single
|
|
4727
4805
|
// input / output callback and that utilizes FS.createDevice
|
|
4728
4806
|
// and instead require a unique set of stream ops
|
|
@@ -4731,18 +4809,18 @@ function dbg(...args) {
|
|
|
4731
4809
|
// default tty devices. however, if the standard streams
|
|
4732
4810
|
// have been overwritten we create a unique device for
|
|
4733
4811
|
// them instead.
|
|
4734
|
-
if (
|
|
4735
|
-
FS.createDevice('/dev', 'stdin',
|
|
4812
|
+
if (input) {
|
|
4813
|
+
FS.createDevice('/dev', 'stdin', input);
|
|
4736
4814
|
} else {
|
|
4737
4815
|
FS.symlink('/dev/tty', '/dev/stdin');
|
|
4738
4816
|
}
|
|
4739
|
-
if (
|
|
4740
|
-
FS.createDevice('/dev', 'stdout', null,
|
|
4817
|
+
if (output) {
|
|
4818
|
+
FS.createDevice('/dev', 'stdout', null, output);
|
|
4741
4819
|
} else {
|
|
4742
4820
|
FS.symlink('/dev/tty', '/dev/stdout');
|
|
4743
4821
|
}
|
|
4744
|
-
if (
|
|
4745
|
-
FS.createDevice('/dev', 'stderr', null,
|
|
4822
|
+
if (error) {
|
|
4823
|
+
FS.createDevice('/dev', 'stderr', null, error);
|
|
4746
4824
|
} else {
|
|
4747
4825
|
FS.symlink('/dev/tty1', '/dev/stderr');
|
|
4748
4826
|
}
|
|
@@ -4756,12 +4834,6 @@ function dbg(...args) {
|
|
|
4756
4834
|
assert(stderr.fd === 2, `invalid handle for stderr (${stderr.fd})`);
|
|
4757
4835
|
},
|
|
4758
4836
|
staticInit() {
|
|
4759
|
-
// Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
|
|
4760
|
-
[44].forEach((code) => {
|
|
4761
|
-
FS.genericErrors[code] = new FS.ErrnoError(code);
|
|
4762
|
-
FS.genericErrors[code].stack = '<generic error, no stack>';
|
|
4763
|
-
});
|
|
4764
|
-
|
|
4765
4837
|
FS.nameTable = new Array(4096);
|
|
4766
4838
|
|
|
4767
4839
|
FS.mount(MEMFS, {}, '/');
|
|
@@ -4775,27 +4847,25 @@ function dbg(...args) {
|
|
|
4775
4847
|
};
|
|
4776
4848
|
},
|
|
4777
4849
|
init(input, output, error) {
|
|
4778
|
-
assert(!FS.
|
|
4779
|
-
FS.
|
|
4850
|
+
assert(!FS.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)');
|
|
4851
|
+
FS.initialized = true;
|
|
4780
4852
|
|
|
4781
4853
|
// Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4854
|
+
input ??= Module['stdin'];
|
|
4855
|
+
output ??= Module['stdout'];
|
|
4856
|
+
error ??= Module['stderr'];
|
|
4785
4857
|
|
|
4786
|
-
FS.createStandardStreams();
|
|
4858
|
+
FS.createStandardStreams(input, output, error);
|
|
4787
4859
|
},
|
|
4788
4860
|
quit() {
|
|
4789
|
-
FS.
|
|
4861
|
+
FS.initialized = false;
|
|
4790
4862
|
// force-flush all streams, so we get musl std streams printed out
|
|
4791
4863
|
_fflush(0);
|
|
4792
4864
|
// close all of our streams
|
|
4793
|
-
for (var
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
continue;
|
|
4865
|
+
for (var stream of FS.streams) {
|
|
4866
|
+
if (stream) {
|
|
4867
|
+
FS.close(stream);
|
|
4797
4868
|
}
|
|
4798
|
-
FS.close(stream);
|
|
4799
4869
|
}
|
|
4800
4870
|
},
|
|
4801
4871
|
findObject(path, dontResolveLastLink) {
|
|
@@ -4843,7 +4913,7 @@ function dbg(...args) {
|
|
|
4843
4913
|
try {
|
|
4844
4914
|
FS.mkdir(current);
|
|
4845
4915
|
} catch (e) {
|
|
4846
|
-
|
|
4916
|
+
if (e.errno != 20) throw e;
|
|
4847
4917
|
}
|
|
4848
4918
|
parent = current;
|
|
4849
4919
|
}
|
|
@@ -4879,7 +4949,7 @@ function dbg(...args) {
|
|
|
4879
4949
|
createDevice(parent, name, input, output) {
|
|
4880
4950
|
var path = PATH.join2(typeof parent == 'string' ? parent : FS.getPath(parent), name);
|
|
4881
4951
|
var mode = FS_getMode(!!input, !!output);
|
|
4882
|
-
|
|
4952
|
+
FS.createDevice.major ??= 64;
|
|
4883
4953
|
var dev = FS.makedev(FS.createDevice.major++, 0);
|
|
4884
4954
|
// Create a fake device that a set of stream ops to emulate
|
|
4885
4955
|
// the old behavior.
|
|
@@ -4910,7 +4980,7 @@ function dbg(...args) {
|
|
|
4910
4980
|
buffer[offset+i] = result;
|
|
4911
4981
|
}
|
|
4912
4982
|
if (bytesRead) {
|
|
4913
|
-
stream.node.
|
|
4983
|
+
stream.node.atime = Date.now();
|
|
4914
4984
|
}
|
|
4915
4985
|
return bytesRead;
|
|
4916
4986
|
},
|
|
@@ -4923,7 +4993,7 @@ function dbg(...args) {
|
|
|
4923
4993
|
}
|
|
4924
4994
|
}
|
|
4925
4995
|
if (length) {
|
|
4926
|
-
stream.node.
|
|
4996
|
+
stream.node.mtime = stream.node.ctime = Date.now();
|
|
4927
4997
|
}
|
|
4928
4998
|
return i;
|
|
4929
4999
|
}
|
|
@@ -4947,10 +5017,8 @@ function dbg(...args) {
|
|
|
4947
5017
|
// Lazy chunked Uint8Array (implements get and length from Uint8Array).
|
|
4948
5018
|
// Actual getting is abstracted away for eventual reuse.
|
|
4949
5019
|
class LazyUint8Array {
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
this.chunks = []; // Loaded chunks. Index is the chunk number
|
|
4953
|
-
}
|
|
5020
|
+
lengthKnown = false;
|
|
5021
|
+
chunks = []; // Loaded chunks. Index is the chunk number
|
|
4954
5022
|
get(idx) {
|
|
4955
5023
|
if (idx > this.length-1 || idx < 0) {
|
|
4956
5024
|
return undefined;
|
|
@@ -5147,31 +5215,42 @@ function dbg(...args) {
|
|
|
5147
5215
|
}
|
|
5148
5216
|
return dir;
|
|
5149
5217
|
}
|
|
5150
|
-
return
|
|
5218
|
+
return dir + '/' + path;
|
|
5151
5219
|
},
|
|
5152
|
-
|
|
5153
|
-
var stat = func(path);
|
|
5220
|
+
writeStat(buf, stat) {
|
|
5154
5221
|
HEAP32[((buf)>>2)] = stat.dev;checkInt32(stat.dev);
|
|
5155
5222
|
HEAP32[(((buf)+(4))>>2)] = stat.mode;checkInt32(stat.mode);
|
|
5156
5223
|
HEAPU32[(((buf)+(8))>>2)] = stat.nlink;checkInt32(stat.nlink);
|
|
5157
5224
|
HEAP32[(((buf)+(12))>>2)] = stat.uid;checkInt32(stat.uid);
|
|
5158
5225
|
HEAP32[(((buf)+(16))>>2)] = stat.gid;checkInt32(stat.gid);
|
|
5159
5226
|
HEAP32[(((buf)+(20))>>2)] = stat.rdev;checkInt32(stat.rdev);
|
|
5160
|
-
|
|
5227
|
+
HEAP64[(((buf)+(24))>>3)] = BigInt(stat.size);checkInt64(stat.size);
|
|
5161
5228
|
HEAP32[(((buf)+(32))>>2)] = 4096;checkInt32(4096);
|
|
5162
5229
|
HEAP32[(((buf)+(36))>>2)] = stat.blocks;checkInt32(stat.blocks);
|
|
5163
5230
|
var atime = stat.atime.getTime();
|
|
5164
5231
|
var mtime = stat.mtime.getTime();
|
|
5165
5232
|
var ctime = stat.ctime.getTime();
|
|
5166
|
-
|
|
5167
|
-
HEAPU32[(((buf)+(48))>>2)] = (atime % 1000) * 1000;checkInt32((atime % 1000) * 1000);
|
|
5168
|
-
|
|
5169
|
-
HEAPU32[(((buf)+(64))>>2)] = (mtime % 1000) * 1000;checkInt32((mtime % 1000) * 1000);
|
|
5170
|
-
|
|
5171
|
-
HEAPU32[(((buf)+(80))>>2)] = (ctime % 1000) * 1000;checkInt32((ctime % 1000) * 1000);
|
|
5172
|
-
|
|
5233
|
+
HEAP64[(((buf)+(40))>>3)] = BigInt(Math.floor(atime / 1000));checkInt64(Math.floor(atime / 1000));
|
|
5234
|
+
HEAPU32[(((buf)+(48))>>2)] = (atime % 1000) * 1000 * 1000;checkInt32((atime % 1000) * 1000 * 1000);
|
|
5235
|
+
HEAP64[(((buf)+(56))>>3)] = BigInt(Math.floor(mtime / 1000));checkInt64(Math.floor(mtime / 1000));
|
|
5236
|
+
HEAPU32[(((buf)+(64))>>2)] = (mtime % 1000) * 1000 * 1000;checkInt32((mtime % 1000) * 1000 * 1000);
|
|
5237
|
+
HEAP64[(((buf)+(72))>>3)] = BigInt(Math.floor(ctime / 1000));checkInt64(Math.floor(ctime / 1000));
|
|
5238
|
+
HEAPU32[(((buf)+(80))>>2)] = (ctime % 1000) * 1000 * 1000;checkInt32((ctime % 1000) * 1000 * 1000);
|
|
5239
|
+
HEAP64[(((buf)+(88))>>3)] = BigInt(stat.ino);checkInt64(stat.ino);
|
|
5173
5240
|
return 0;
|
|
5174
5241
|
},
|
|
5242
|
+
writeStatFs(buf, stats) {
|
|
5243
|
+
HEAP32[(((buf)+(4))>>2)] = stats.bsize;checkInt32(stats.bsize);
|
|
5244
|
+
HEAP32[(((buf)+(40))>>2)] = stats.bsize;checkInt32(stats.bsize);
|
|
5245
|
+
HEAP32[(((buf)+(8))>>2)] = stats.blocks;checkInt32(stats.blocks);
|
|
5246
|
+
HEAP32[(((buf)+(12))>>2)] = stats.bfree;checkInt32(stats.bfree);
|
|
5247
|
+
HEAP32[(((buf)+(16))>>2)] = stats.bavail;checkInt32(stats.bavail);
|
|
5248
|
+
HEAP32[(((buf)+(20))>>2)] = stats.files;checkInt32(stats.files);
|
|
5249
|
+
HEAP32[(((buf)+(24))>>2)] = stats.ffree;checkInt32(stats.ffree);
|
|
5250
|
+
HEAP32[(((buf)+(28))>>2)] = stats.fsid;checkInt32(stats.fsid);
|
|
5251
|
+
HEAP32[(((buf)+(44))>>2)] = stats.flags;checkInt32(stats.flags); // ST_NOSUID
|
|
5252
|
+
HEAP32[(((buf)+(36))>>2)] = stats.namelen;checkInt32(stats.namelen);
|
|
5253
|
+
},
|
|
5175
5254
|
doMsync(addr, stream, len, flags, offset) {
|
|
5176
5255
|
if (!FS.isFile(stream.node.mode)) {
|
|
5177
5256
|
throw new FS.ErrnoError(43);
|
|
@@ -5209,7 +5288,7 @@ function dbg(...args) {
|
|
|
5209
5288
|
try {
|
|
5210
5289
|
|
|
5211
5290
|
path = SYSCALLS.getStr(path);
|
|
5212
|
-
assert(flags === 0);
|
|
5291
|
+
assert(flags === 0 || flags == 512);
|
|
5213
5292
|
path = SYSCALLS.calculateAt(dirfd, path);
|
|
5214
5293
|
if (amode & ~7) {
|
|
5215
5294
|
// need a valid mode
|
|
@@ -5257,13 +5336,13 @@ function dbg(...args) {
|
|
|
5257
5336
|
}
|
|
5258
5337
|
|
|
5259
5338
|
/** @suppress {duplicate } */
|
|
5260
|
-
|
|
5339
|
+
var syscallGetVarargI = () => {
|
|
5261
5340
|
assert(SYSCALLS.varargs != undefined);
|
|
5262
5341
|
// the `+` prepended here is necessary to convince the JSCompiler that varargs is indeed a number.
|
|
5263
5342
|
var ret = HEAP32[((+SYSCALLS.varargs)>>2)];
|
|
5264
5343
|
SYSCALLS.varargs += 4;
|
|
5265
5344
|
return ret;
|
|
5266
|
-
}
|
|
5345
|
+
};
|
|
5267
5346
|
var syscallGetVarargP = syscallGetVarargI;
|
|
5268
5347
|
|
|
5269
5348
|
|
|
@@ -5304,7 +5383,11 @@ function dbg(...args) {
|
|
|
5304
5383
|
}
|
|
5305
5384
|
case 13:
|
|
5306
5385
|
case 14:
|
|
5307
|
-
|
|
5386
|
+
// Pretend that the locking is successful. These are process-level locks,
|
|
5387
|
+
// and Emscripten programs are a single process. If we supported linking a
|
|
5388
|
+
// filesystem between programs, we'd need to do more here.
|
|
5389
|
+
// See https://github.com/emscripten-core/emscripten/issues/23697
|
|
5390
|
+
return 0;
|
|
5308
5391
|
}
|
|
5309
5392
|
return -28;
|
|
5310
5393
|
} catch (e) {
|
|
@@ -5316,23 +5399,21 @@ function dbg(...args) {
|
|
|
5316
5399
|
function ___syscall_fstat64(fd, buf) {
|
|
5317
5400
|
try {
|
|
5318
5401
|
|
|
5319
|
-
|
|
5320
|
-
return SYSCALLS.doStat(FS.stat, stream.path, buf);
|
|
5402
|
+
return SYSCALLS.writeStat(buf, FS.fstat(fd));
|
|
5321
5403
|
} catch (e) {
|
|
5322
5404
|
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
5323
5405
|
return -e.errno;
|
|
5324
5406
|
}
|
|
5325
5407
|
}
|
|
5326
5408
|
|
|
5327
|
-
var
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5409
|
+
var INT53_MAX = 9007199254740992;
|
|
5410
|
+
|
|
5411
|
+
var INT53_MIN = -9007199254740992;
|
|
5412
|
+
var bigintToI53Checked = (num) => (num < INT53_MIN || num > INT53_MAX) ? NaN : Number(num);
|
|
5413
|
+
function ___syscall_ftruncate64(fd, length) {
|
|
5414
|
+
length = bigintToI53Checked(length);
|
|
5415
|
+
|
|
5334
5416
|
|
|
5335
|
-
|
|
5336
5417
|
try {
|
|
5337
5418
|
|
|
5338
5419
|
if (isNaN(length)) return 61;
|
|
@@ -5369,7 +5450,7 @@ function dbg(...args) {
|
|
|
5369
5450
|
try {
|
|
5370
5451
|
|
|
5371
5452
|
path = SYSCALLS.getStr(path);
|
|
5372
|
-
return SYSCALLS.
|
|
5453
|
+
return SYSCALLS.writeStat(buf, FS.lstat(path));
|
|
5373
5454
|
} catch (e) {
|
|
5374
5455
|
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
5375
5456
|
return -e.errno;
|
|
@@ -5381,10 +5462,6 @@ function dbg(...args) {
|
|
|
5381
5462
|
|
|
5382
5463
|
path = SYSCALLS.getStr(path);
|
|
5383
5464
|
path = SYSCALLS.calculateAt(dirfd, path);
|
|
5384
|
-
// remove a trailing slash, if one - /a/b/ has basename of '', but
|
|
5385
|
-
// we want to create b in the context of this function
|
|
5386
|
-
path = PATH.normalize(path);
|
|
5387
|
-
if (path[path.length-1] === '/') path = path.substr(0, path.length-1);
|
|
5388
5465
|
FS.mkdir(path, mode, 0);
|
|
5389
5466
|
return 0;
|
|
5390
5467
|
} catch (e) {
|
|
@@ -5402,7 +5479,7 @@ function dbg(...args) {
|
|
|
5402
5479
|
flags = flags & (~6400);
|
|
5403
5480
|
assert(!flags, `unknown flags in __syscall_newfstatat: ${flags}`);
|
|
5404
5481
|
path = SYSCALLS.calculateAt(dirfd, path, allowEmpty);
|
|
5405
|
-
return SYSCALLS.
|
|
5482
|
+
return SYSCALLS.writeStat(buf, nofollow ? FS.lstat(path) : FS.stat(path));
|
|
5406
5483
|
} catch (e) {
|
|
5407
5484
|
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
5408
5485
|
return -e.errno;
|
|
@@ -5463,7 +5540,7 @@ function dbg(...args) {
|
|
|
5463
5540
|
try {
|
|
5464
5541
|
|
|
5465
5542
|
path = SYSCALLS.getStr(path);
|
|
5466
|
-
return SYSCALLS.
|
|
5543
|
+
return SYSCALLS.writeStat(buf, FS.stat(path));
|
|
5467
5544
|
} catch (e) {
|
|
5468
5545
|
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
5469
5546
|
return -e.errno;
|
|
@@ -5499,19 +5576,36 @@ function dbg(...args) {
|
|
|
5499
5576
|
path = SYSCALLS.getStr(path);
|
|
5500
5577
|
assert(flags === 0);
|
|
5501
5578
|
path = SYSCALLS.calculateAt(dirfd, path, true);
|
|
5579
|
+
var now = Date.now(), atime, mtime;
|
|
5502
5580
|
if (!times) {
|
|
5503
|
-
|
|
5504
|
-
|
|
5581
|
+
atime = now;
|
|
5582
|
+
mtime = now;
|
|
5505
5583
|
} else {
|
|
5506
5584
|
var seconds = readI53FromI64(times);
|
|
5507
5585
|
var nanoseconds = HEAP32[(((times)+(8))>>2)];
|
|
5508
|
-
|
|
5586
|
+
if (nanoseconds == 1073741823) {
|
|
5587
|
+
atime = now;
|
|
5588
|
+
} else if (nanoseconds == 1073741822) {
|
|
5589
|
+
atime = null;
|
|
5590
|
+
} else {
|
|
5591
|
+
atime = (seconds*1000) + (nanoseconds/(1000*1000));
|
|
5592
|
+
}
|
|
5509
5593
|
times += 16;
|
|
5510
5594
|
seconds = readI53FromI64(times);
|
|
5511
5595
|
nanoseconds = HEAP32[(((times)+(8))>>2)];
|
|
5512
|
-
|
|
5596
|
+
if (nanoseconds == 1073741823) {
|
|
5597
|
+
mtime = now;
|
|
5598
|
+
} else if (nanoseconds == 1073741822) {
|
|
5599
|
+
mtime = null;
|
|
5600
|
+
} else {
|
|
5601
|
+
mtime = (seconds*1000) + (nanoseconds/(1000*1000));
|
|
5602
|
+
}
|
|
5603
|
+
}
|
|
5604
|
+
// null here means UTIME_OMIT was passed. If both were set to UTIME_OMIT then
|
|
5605
|
+
// we can skip the call completely.
|
|
5606
|
+
if ((mtime ?? atime) !== null) {
|
|
5607
|
+
FS.utime(path, atime, mtime);
|
|
5513
5608
|
}
|
|
5514
|
-
FS.utime(path, atime, mtime);
|
|
5515
5609
|
return 0;
|
|
5516
5610
|
} catch (e) {
|
|
5517
5611
|
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
@@ -5519,14 +5613,8 @@ function dbg(...args) {
|
|
|
5519
5613
|
}
|
|
5520
5614
|
}
|
|
5521
5615
|
|
|
5522
|
-
var __abort_js = () =>
|
|
5616
|
+
var __abort_js = () =>
|
|
5523
5617
|
abort('native code called abort()');
|
|
5524
|
-
};
|
|
5525
|
-
|
|
5526
|
-
var nowIsMonotonic = 1;
|
|
5527
|
-
var __emscripten_get_now_is_monotonic = () => nowIsMonotonic;
|
|
5528
|
-
|
|
5529
|
-
var __emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num);
|
|
5530
5618
|
|
|
5531
5619
|
var isLeapYear = (year) => year%4 === 0 && (year%100 !== 0 || year%400 === 0);
|
|
5532
5620
|
|
|
@@ -5541,10 +5629,10 @@ function dbg(...args) {
|
|
|
5541
5629
|
return yday;
|
|
5542
5630
|
};
|
|
5543
5631
|
|
|
5544
|
-
function __localtime_js(
|
|
5545
|
-
|
|
5632
|
+
function __localtime_js(time, tmPtr) {
|
|
5633
|
+
time = bigintToI53Checked(time);
|
|
5634
|
+
|
|
5546
5635
|
|
|
5547
|
-
|
|
5548
5636
|
var date = new Date(time*1000);
|
|
5549
5637
|
HEAP32[((tmPtr)>>2)] = date.getSeconds();checkInt32(date.getSeconds());
|
|
5550
5638
|
HEAP32[(((tmPtr)+(4))>>2)] = date.getMinutes();checkInt32(date.getMinutes());
|
|
@@ -5572,10 +5660,10 @@ function dbg(...args) {
|
|
|
5572
5660
|
|
|
5573
5661
|
|
|
5574
5662
|
|
|
5575
|
-
function __mmap_js(len,prot,flags,fd,
|
|
5576
|
-
|
|
5663
|
+
function __mmap_js(len, prot, flags, fd, offset, allocated, addr) {
|
|
5664
|
+
offset = bigintToI53Checked(offset);
|
|
5665
|
+
|
|
5577
5666
|
|
|
5578
|
-
|
|
5579
5667
|
try {
|
|
5580
5668
|
|
|
5581
5669
|
if (isNaN(offset)) return 61;
|
|
@@ -5593,10 +5681,10 @@ function dbg(...args) {
|
|
|
5593
5681
|
}
|
|
5594
5682
|
|
|
5595
5683
|
|
|
5596
|
-
function __munmap_js(addr,len,prot,flags,fd,
|
|
5597
|
-
|
|
5684
|
+
function __munmap_js(addr, len, prot, flags, fd, offset) {
|
|
5685
|
+
offset = bigintToI53Checked(offset);
|
|
5686
|
+
|
|
5598
5687
|
|
|
5599
|
-
|
|
5600
5688
|
try {
|
|
5601
5689
|
|
|
5602
5690
|
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
@@ -5664,7 +5752,37 @@ function dbg(...args) {
|
|
|
5664
5752
|
}
|
|
5665
5753
|
};
|
|
5666
5754
|
|
|
5755
|
+
var _emscripten_get_now = () => performance.now();
|
|
5756
|
+
|
|
5667
5757
|
var _emscripten_date_now = () => Date.now();
|
|
5758
|
+
|
|
5759
|
+
var nowIsMonotonic = 1;
|
|
5760
|
+
|
|
5761
|
+
var checkWasiClock = (clock_id) => clock_id >= 0 && clock_id <= 3;
|
|
5762
|
+
|
|
5763
|
+
function _clock_time_get(clk_id, ignored_precision, ptime) {
|
|
5764
|
+
ignored_precision = bigintToI53Checked(ignored_precision);
|
|
5765
|
+
|
|
5766
|
+
|
|
5767
|
+
if (!checkWasiClock(clk_id)) {
|
|
5768
|
+
return 28;
|
|
5769
|
+
}
|
|
5770
|
+
var now;
|
|
5771
|
+
// all wasi clocks but realtime are monotonic
|
|
5772
|
+
if (clk_id === 0) {
|
|
5773
|
+
now = _emscripten_date_now();
|
|
5774
|
+
} else if (nowIsMonotonic) {
|
|
5775
|
+
now = _emscripten_get_now();
|
|
5776
|
+
} else {
|
|
5777
|
+
return 52;
|
|
5778
|
+
}
|
|
5779
|
+
// "now" is in ms, and wasi times are in ns.
|
|
5780
|
+
var nsec = Math.round(now * 1000 * 1000);
|
|
5781
|
+
HEAP64[((ptime)>>3)] = BigInt(nsec);checkInt64(nsec);
|
|
5782
|
+
return 0;
|
|
5783
|
+
;
|
|
5784
|
+
}
|
|
5785
|
+
|
|
5668
5786
|
|
|
5669
5787
|
var getHeapMax = () =>
|
|
5670
5788
|
// Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
|
|
@@ -5674,18 +5792,13 @@ function dbg(...args) {
|
|
|
5674
5792
|
2147483648;
|
|
5675
5793
|
var _emscripten_get_heap_max = () => getHeapMax();
|
|
5676
5794
|
|
|
5677
|
-
var _emscripten_get_now;
|
|
5678
|
-
// Modern environment where performance.now() is supported:
|
|
5679
|
-
// N.B. a shorter form "_emscripten_get_now = performance.now;" is
|
|
5680
|
-
// unfortunately not allowed even in current browsers (e.g. FF Nightly 75).
|
|
5681
|
-
_emscripten_get_now = () => performance.now();
|
|
5682
|
-
;
|
|
5683
5795
|
|
|
5684
5796
|
|
|
5685
5797
|
|
|
5798
|
+
|
|
5686
5799
|
var growMemory = (size) => {
|
|
5687
5800
|
var b = wasmMemory.buffer;
|
|
5688
|
-
var pages = (size - b.byteLength + 65535) / 65536;
|
|
5801
|
+
var pages = ((size - b.byteLength + 65535) / 65536) | 0;
|
|
5689
5802
|
try {
|
|
5690
5803
|
// round size grow request up to wasm page size (fixed 64KB per spec)
|
|
5691
5804
|
wasmMemory.grow(pages); // .grow() takes a delta compared to the previous size
|
|
@@ -5730,8 +5843,6 @@ function dbg(...args) {
|
|
|
5730
5843
|
return false;
|
|
5731
5844
|
}
|
|
5732
5845
|
|
|
5733
|
-
var alignUp = (x, multiple) => x + (multiple - x % multiple) % multiple;
|
|
5734
|
-
|
|
5735
5846
|
// Loop through potential heap size increases. If we attempt a too eager
|
|
5736
5847
|
// reservation that fails, cut down on the attempted size and reserve a
|
|
5737
5848
|
// smaller bump instead. (max 3 times, chosen somewhat arbitrarily)
|
|
@@ -5740,7 +5851,7 @@ function dbg(...args) {
|
|
|
5740
5851
|
// but limit overreserving (default to capping at +96MB overgrowth at most)
|
|
5741
5852
|
overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296 );
|
|
5742
5853
|
|
|
5743
|
-
var newSize = Math.min(maxHeapSize,
|
|
5854
|
+
var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
|
|
5744
5855
|
|
|
5745
5856
|
var t0 = _emscripten_get_now();
|
|
5746
5857
|
var replacement = growMemory(newSize);
|
|
@@ -5758,9 +5869,7 @@ function dbg(...args) {
|
|
|
5758
5869
|
var ENV = {
|
|
5759
5870
|
};
|
|
5760
5871
|
|
|
5761
|
-
var getExecutableName = () =>
|
|
5762
|
-
return thisProgram || './this.program';
|
|
5763
|
-
};
|
|
5872
|
+
var getExecutableName = () => thisProgram || './this.program';
|
|
5764
5873
|
var getEnvStrings = () => {
|
|
5765
5874
|
if (!getEnvStrings.strings) {
|
|
5766
5875
|
// Default values.
|
|
@@ -5849,8 +5958,8 @@ function dbg(...args) {
|
|
|
5849
5958
|
}
|
|
5850
5959
|
HEAP8[pbuf] = type;checkInt8(type);
|
|
5851
5960
|
HEAP16[(((pbuf)+(2))>>1)] = flags;checkInt16(flags);
|
|
5852
|
-
|
|
5853
|
-
|
|
5961
|
+
HEAP64[(((pbuf)+(8))>>3)] = BigInt(rightsBase);checkInt64(rightsBase);
|
|
5962
|
+
HEAP64[(((pbuf)+(16))>>3)] = BigInt(rightsInheriting);checkInt64(rightsInheriting);
|
|
5854
5963
|
return 0;
|
|
5855
5964
|
} catch (e) {
|
|
5856
5965
|
if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
|
|
@@ -5890,16 +5999,16 @@ function dbg(...args) {
|
|
|
5890
5999
|
}
|
|
5891
6000
|
|
|
5892
6001
|
|
|
5893
|
-
function _fd_seek(fd,
|
|
5894
|
-
|
|
6002
|
+
function _fd_seek(fd, offset, whence, newOffset) {
|
|
6003
|
+
offset = bigintToI53Checked(offset);
|
|
6004
|
+
|
|
5895
6005
|
|
|
5896
|
-
|
|
5897
6006
|
try {
|
|
5898
6007
|
|
|
5899
6008
|
if (isNaN(offset)) return 61;
|
|
5900
6009
|
var stream = SYSCALLS.getStreamFromFD(fd);
|
|
5901
6010
|
FS.llseek(stream, offset, whence);
|
|
5902
|
-
|
|
6011
|
+
HEAP64[((newOffset)>>3)] = BigInt(stream.position);checkInt64(stream.position);
|
|
5903
6012
|
if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null; // reset readdir state
|
|
5904
6013
|
return 0;
|
|
5905
6014
|
} catch (e) {
|
|
@@ -5933,6 +6042,10 @@ function dbg(...args) {
|
|
|
5933
6042
|
var curr = FS.write(stream, HEAP8, ptr, len, offset);
|
|
5934
6043
|
if (curr < 0) return -1;
|
|
5935
6044
|
ret += curr;
|
|
6045
|
+
if (curr < len) {
|
|
6046
|
+
// No more space to write.
|
|
6047
|
+
break;
|
|
6048
|
+
}
|
|
5936
6049
|
if (typeof offset != 'undefined') {
|
|
5937
6050
|
offset += curr;
|
|
5938
6051
|
}
|
|
@@ -5991,7 +6104,6 @@ function dbg(...args) {
|
|
|
5991
6104
|
'string': (str) => {
|
|
5992
6105
|
var ret = 0;
|
|
5993
6106
|
if (str !== null && str !== undefined && str !== 0) { // null string
|
|
5994
|
-
// at most 4 bytes per UTF-8 code point, +1 for the trailing '\0'
|
|
5995
6107
|
ret = stringToUTF8OnStack(str);
|
|
5996
6108
|
}
|
|
5997
6109
|
return ret;
|
|
@@ -6005,7 +6117,6 @@ function dbg(...args) {
|
|
|
6005
6117
|
|
|
6006
6118
|
function convertReturnValue(ret) {
|
|
6007
6119
|
if (returnType === 'string') {
|
|
6008
|
-
|
|
6009
6120
|
return UTF8ToString(ret);
|
|
6010
6121
|
}
|
|
6011
6122
|
if (returnType === 'boolean') return Boolean(ret);
|
|
@@ -6089,19 +6200,22 @@ function dbg(...args) {
|
|
|
6089
6200
|
var getWasmTableEntry = (funcPtr) => {
|
|
6090
6201
|
var func = wasmTableMirror[funcPtr];
|
|
6091
6202
|
if (!func) {
|
|
6092
|
-
|
|
6203
|
+
/** @suppress {checkTypes} */
|
|
6093
6204
|
wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
|
|
6094
6205
|
}
|
|
6206
|
+
/** @suppress {checkTypes} */
|
|
6095
6207
|
assert(wasmTable.get(funcPtr) == func, 'JavaScript-side Wasm function table mirror is out of date!');
|
|
6096
6208
|
return func;
|
|
6097
6209
|
};
|
|
6098
6210
|
|
|
6099
6211
|
|
|
6100
6212
|
var setWasmTableEntry = (idx, func) => {
|
|
6213
|
+
/** @suppress {checkTypes} */
|
|
6101
6214
|
wasmTable.set(idx, func);
|
|
6102
6215
|
// With ABORT_ON_WASM_EXCEPTIONS wasmTable.get is overridden to return wrapped
|
|
6103
6216
|
// functions so we need to call it here to retrieve the potential wrapper correctly
|
|
6104
6217
|
// instead of just storing 'func' directly into wasmTableMirror
|
|
6218
|
+
/** @suppress {checkTypes} */
|
|
6105
6219
|
wasmTableMirror[idx] = wasmTable.get(idx);
|
|
6106
6220
|
};
|
|
6107
6221
|
|
|
@@ -6121,7 +6235,6 @@ function dbg(...args) {
|
|
|
6121
6235
|
};
|
|
6122
6236
|
|
|
6123
6237
|
var sigToWasmTypes = (sig) => {
|
|
6124
|
-
assert(!sig.includes('j'), 'i64 not permitted in function signatures when WASM_BIGINT is disabled');
|
|
6125
6238
|
var typeNames = {
|
|
6126
6239
|
'i': 'i32',
|
|
6127
6240
|
'j': 'i64',
|
|
@@ -6156,9 +6269,9 @@ function dbg(...args) {
|
|
|
6156
6269
|
// Parameters, length + signatures
|
|
6157
6270
|
target.push(0x60 /* form: func */);
|
|
6158
6271
|
uleb128Encode(sigParam.length, target);
|
|
6159
|
-
for (var
|
|
6160
|
-
assert(
|
|
6161
|
-
target.push(typeCodes[
|
|
6272
|
+
for (var paramType of sigParam) {
|
|
6273
|
+
assert(paramType in typeCodes, `invalid signature char: ${paramType}`);
|
|
6274
|
+
target.push(typeCodes[paramType]);
|
|
6162
6275
|
}
|
|
6163
6276
|
|
|
6164
6277
|
// Return values, length + signatures
|
|
@@ -6171,8 +6284,6 @@ function dbg(...args) {
|
|
|
6171
6284
|
};
|
|
6172
6285
|
var convertJsFunctionToWasm = (func, sig) => {
|
|
6173
6286
|
|
|
6174
|
-
assert(!sig.includes('j'), 'i64 not permitted in function signatures when WASM_BIGINT is disabled');
|
|
6175
|
-
|
|
6176
6287
|
// If the type reflection proposal is available, use the new
|
|
6177
6288
|
// "WebAssembly.Function" constructor.
|
|
6178
6289
|
// Otherwise, construct a minimal wasm module importing the JS function and
|
|
@@ -6248,6 +6359,7 @@ function dbg(...args) {
|
|
|
6248
6359
|
}
|
|
6249
6360
|
// Grow the table
|
|
6250
6361
|
try {
|
|
6362
|
+
/** @suppress {checkTypes} */
|
|
6251
6363
|
wasmTable.grow(1);
|
|
6252
6364
|
} catch (err) {
|
|
6253
6365
|
if (!(err instanceof RangeError)) {
|
|
@@ -6301,7 +6413,11 @@ function dbg(...args) {
|
|
|
6301
6413
|
};
|
|
6302
6414
|
|
|
6303
6415
|
FS.createPreloadedFile = FS_createPreloadedFile;
|
|
6304
|
-
FS.staticInit()
|
|
6416
|
+
FS.staticInit();
|
|
6417
|
+
// Set module methods based on EXPORTED_RUNTIME_METHODS
|
|
6418
|
+
;
|
|
6419
|
+
// End JS library code
|
|
6420
|
+
|
|
6305
6421
|
function checkIncomingModuleAPI() {
|
|
6306
6422
|
ignoredModuleProp('fetchSettings');
|
|
6307
6423
|
}
|
|
@@ -6347,10 +6463,6 @@ var wasmImports = {
|
|
|
6347
6463
|
/** @export */
|
|
6348
6464
|
_abort_js: __abort_js,
|
|
6349
6465
|
/** @export */
|
|
6350
|
-
_emscripten_get_now_is_monotonic: __emscripten_get_now_is_monotonic,
|
|
6351
|
-
/** @export */
|
|
6352
|
-
_emscripten_memcpy_js: __emscripten_memcpy_js,
|
|
6353
|
-
/** @export */
|
|
6354
6466
|
_localtime_js: __localtime_js,
|
|
6355
6467
|
/** @export */
|
|
6356
6468
|
_mmap_js: __mmap_js,
|
|
@@ -6359,6 +6471,8 @@ var wasmImports = {
|
|
|
6359
6471
|
/** @export */
|
|
6360
6472
|
_tzset_js: __tzset_js,
|
|
6361
6473
|
/** @export */
|
|
6474
|
+
clock_time_get: _clock_time_get,
|
|
6475
|
+
/** @export */
|
|
6362
6476
|
emscripten_date_now: _emscripten_date_now,
|
|
6363
6477
|
/** @export */
|
|
6364
6478
|
emscripten_get_heap_max: _emscripten_get_heap_max,
|
|
@@ -6383,7 +6497,8 @@ var wasmImports = {
|
|
|
6383
6497
|
/** @export */
|
|
6384
6498
|
fd_write: _fd_write
|
|
6385
6499
|
};
|
|
6386
|
-
var wasmExports
|
|
6500
|
+
var wasmExports;
|
|
6501
|
+
createWasm();
|
|
6387
6502
|
var ___wasm_call_ctors = createExportWrapper('__wasm_call_ctors', 0);
|
|
6388
6503
|
var _sqlite3_free = Module['_sqlite3_free'] = createExportWrapper('sqlite3_free', 1);
|
|
6389
6504
|
var _sqlite3_value_text = Module['_sqlite3_value_text'] = createExportWrapper('sqlite3_value_text', 1);
|
|
@@ -6406,7 +6521,7 @@ var _sqlite3_result_blob = Module['_sqlite3_result_blob'] = createExportWrapper(
|
|
|
6406
6521
|
var _sqlite3_result_double = Module['_sqlite3_result_double'] = createExportWrapper('sqlite3_result_double', 2);
|
|
6407
6522
|
var _sqlite3_result_error = Module['_sqlite3_result_error'] = createExportWrapper('sqlite3_result_error', 3);
|
|
6408
6523
|
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',
|
|
6524
|
+
var _sqlite3_result_int64 = Module['_sqlite3_result_int64'] = createExportWrapper('sqlite3_result_int64', 2);
|
|
6410
6525
|
var _sqlite3_result_null = Module['_sqlite3_result_null'] = createExportWrapper('sqlite3_result_null', 1);
|
|
6411
6526
|
var _sqlite3_result_text = Module['_sqlite3_result_text'] = createExportWrapper('sqlite3_result_text', 4);
|
|
6412
6527
|
var _sqlite3_aggregate_context = Module['_sqlite3_aggregate_context'] = createExportWrapper('sqlite3_aggregate_context', 2);
|
|
@@ -6425,6 +6540,7 @@ var _sqlite3_normalized_sql = Module['_sqlite3_normalized_sql'] = createExportWr
|
|
|
6425
6540
|
var _sqlite3_changes = Module['_sqlite3_changes'] = createExportWrapper('sqlite3_changes', 1);
|
|
6426
6541
|
var _sqlite3_close_v2 = Module['_sqlite3_close_v2'] = createExportWrapper('sqlite3_close_v2', 1);
|
|
6427
6542
|
var _sqlite3_create_function_v2 = Module['_sqlite3_create_function_v2'] = createExportWrapper('sqlite3_create_function_v2', 9);
|
|
6543
|
+
var _sqlite3_update_hook = Module['_sqlite3_update_hook'] = createExportWrapper('sqlite3_update_hook', 3);
|
|
6428
6544
|
var _sqlite3_open = Module['_sqlite3_open'] = createExportWrapper('sqlite3_open', 2);
|
|
6429
6545
|
var _strerror = createExportWrapper('strerror', 1);
|
|
6430
6546
|
var _malloc = Module['_malloc'] = createExportWrapper('malloc', 1);
|
|
@@ -6432,7 +6548,6 @@ var _free = Module['_free'] = createExportWrapper('free', 1);
|
|
|
6432
6548
|
var _RegisterExtensionFunctions = Module['_RegisterExtensionFunctions'] = createExportWrapper('RegisterExtensionFunctions', 1);
|
|
6433
6549
|
var _fflush = createExportWrapper('fflush', 1);
|
|
6434
6550
|
var _emscripten_builtin_memalign = createExportWrapper('emscripten_builtin_memalign', 2);
|
|
6435
|
-
var __emscripten_tempret_set = createExportWrapper('_emscripten_tempret_set', 1);
|
|
6436
6551
|
var _emscripten_stack_init = () => (_emscripten_stack_init = wasmExports['emscripten_stack_init'])();
|
|
6437
6552
|
var _emscripten_stack_get_free = () => (_emscripten_stack_get_free = wasmExports['emscripten_stack_get_free'])();
|
|
6438
6553
|
var _emscripten_stack_get_base = () => (_emscripten_stack_get_base = wasmExports['emscripten_stack_get_base'])();
|
|
@@ -6441,13 +6556,6 @@ var __emscripten_stack_restore = (a0) => (__emscripten_stack_restore = wasmExpor
|
|
|
6441
6556
|
var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc'])(a0);
|
|
6442
6557
|
var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
|
|
6443
6558
|
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);
|
|
6451
6559
|
|
|
6452
6560
|
|
|
6453
6561
|
// include: postamble.js
|
|
@@ -6471,12 +6579,11 @@ var missingLibrarySymbols = [
|
|
|
6471
6579
|
'writeI53ToU64Signaling',
|
|
6472
6580
|
'readI53FromU64',
|
|
6473
6581
|
'convertI32PairToI53',
|
|
6582
|
+
'convertI32PairToI53Checked',
|
|
6474
6583
|
'convertU32PairToI53',
|
|
6475
6584
|
'getTempRet0',
|
|
6476
6585
|
'setTempRet0',
|
|
6477
6586
|
'exitJS',
|
|
6478
|
-
'arraySum',
|
|
6479
|
-
'addDays',
|
|
6480
6587
|
'inetPton4',
|
|
6481
6588
|
'inetNtop4',
|
|
6482
6589
|
'inetPton6',
|
|
@@ -6488,7 +6595,6 @@ var missingLibrarySymbols = [
|
|
|
6488
6595
|
'jstoi_q',
|
|
6489
6596
|
'listenOnce',
|
|
6490
6597
|
'autoResumeAudioContext',
|
|
6491
|
-
'dynCallLegacy',
|
|
6492
6598
|
'getDynCaller',
|
|
6493
6599
|
'dynCall',
|
|
6494
6600
|
'handleException',
|
|
@@ -6500,6 +6606,10 @@ var missingLibrarySymbols = [
|
|
|
6500
6606
|
'asmjsMangle',
|
|
6501
6607
|
'HandleAllocator',
|
|
6502
6608
|
'getNativeTypeSize',
|
|
6609
|
+
'addOnInit',
|
|
6610
|
+
'addOnPostCtor',
|
|
6611
|
+
'addOnPreMain',
|
|
6612
|
+
'addOnExit',
|
|
6503
6613
|
'STACK_SIZE',
|
|
6504
6614
|
'STACK_ALIGN',
|
|
6505
6615
|
'POINTER_SIZE',
|
|
@@ -6562,14 +6672,14 @@ var missingLibrarySymbols = [
|
|
|
6562
6672
|
'jsStackTrace',
|
|
6563
6673
|
'getCallstack',
|
|
6564
6674
|
'convertPCtoSourceLocation',
|
|
6565
|
-
'checkWasiClock',
|
|
6566
6675
|
'wasiRightsToMuslOFlags',
|
|
6567
6676
|
'wasiOFlagsToMuslOFlags',
|
|
6568
|
-
'createDyncallWrapper',
|
|
6569
6677
|
'safeSetTimeout',
|
|
6570
6678
|
'setImmediateWrapped',
|
|
6679
|
+
'safeRequestAnimationFrame',
|
|
6571
6680
|
'clearImmediateWrapped',
|
|
6572
|
-
'
|
|
6681
|
+
'registerPostMainLoop',
|
|
6682
|
+
'registerPreMainLoop',
|
|
6573
6683
|
'getPromise',
|
|
6574
6684
|
'makePromise',
|
|
6575
6685
|
'idsToPromises',
|
|
@@ -6577,7 +6687,8 @@ var missingLibrarySymbols = [
|
|
|
6577
6687
|
'ExceptionInfo',
|
|
6578
6688
|
'findMatchingCatch',
|
|
6579
6689
|
'Browser_asyncPrepareDataCounter',
|
|
6580
|
-
'
|
|
6690
|
+
'arraySum',
|
|
6691
|
+
'addDays',
|
|
6581
6692
|
'getSocketFromFD',
|
|
6582
6693
|
'getSocketAddress',
|
|
6583
6694
|
'FS_unlink',
|
|
@@ -6589,6 +6700,9 @@ var missingLibrarySymbols = [
|
|
|
6589
6700
|
'webgl_enable_OES_vertex_array_object',
|
|
6590
6701
|
'webgl_enable_WEBGL_draw_buffers',
|
|
6591
6702
|
'webgl_enable_WEBGL_multi_draw',
|
|
6703
|
+
'webgl_enable_EXT_polygon_offset_clamp',
|
|
6704
|
+
'webgl_enable_EXT_clip_control',
|
|
6705
|
+
'webgl_enable_WEBGL_polygon_mode',
|
|
6592
6706
|
'emscriptenWebGLGet',
|
|
6593
6707
|
'computeUnpackAlignedImageSize',
|
|
6594
6708
|
'colorChannelsInGlTextureFormat',
|
|
@@ -6612,11 +6726,6 @@ missingLibrarySymbols.forEach(missingLibrarySymbol)
|
|
|
6612
6726
|
|
|
6613
6727
|
var unexportedSymbols = [
|
|
6614
6728
|
'run',
|
|
6615
|
-
'addOnPreRun',
|
|
6616
|
-
'addOnInit',
|
|
6617
|
-
'addOnPreMain',
|
|
6618
|
-
'addOnExit',
|
|
6619
|
-
'addOnPostRun',
|
|
6620
6729
|
'addRunDependency',
|
|
6621
6730
|
'removeRunDependency',
|
|
6622
6731
|
'out',
|
|
@@ -6628,26 +6737,20 @@ var unexportedSymbols = [
|
|
|
6628
6737
|
'writeStackCookie',
|
|
6629
6738
|
'checkStackCookie',
|
|
6630
6739
|
'readI53FromI64',
|
|
6631
|
-
'
|
|
6740
|
+
'INT53_MAX',
|
|
6741
|
+
'INT53_MIN',
|
|
6742
|
+
'bigintToI53Checked',
|
|
6632
6743
|
'ptrToString',
|
|
6633
6744
|
'zeroMemory',
|
|
6634
6745
|
'getHeapMax',
|
|
6635
6746
|
'growMemory',
|
|
6636
6747
|
'ENV',
|
|
6637
6748
|
'setStackLimits',
|
|
6638
|
-
'MONTH_DAYS_REGULAR',
|
|
6639
|
-
'MONTH_DAYS_LEAP',
|
|
6640
|
-
'MONTH_DAYS_REGULAR_CUMULATIVE',
|
|
6641
|
-
'MONTH_DAYS_LEAP_CUMULATIVE',
|
|
6642
|
-
'isLeapYear',
|
|
6643
|
-
'ydayFromDate',
|
|
6644
6749
|
'ERRNO_CODES',
|
|
6645
6750
|
'strError',
|
|
6646
6751
|
'DNS',
|
|
6647
6752
|
'Protocols',
|
|
6648
6753
|
'Sockets',
|
|
6649
|
-
'initRandomFill',
|
|
6650
|
-
'randomFill',
|
|
6651
6754
|
'timers',
|
|
6652
6755
|
'warnOnce',
|
|
6653
6756
|
'readEmAsmArgsArray',
|
|
@@ -6658,6 +6761,8 @@ var unexportedSymbols = [
|
|
|
6658
6761
|
'mmapAlloc',
|
|
6659
6762
|
'wasmTable',
|
|
6660
6763
|
'noExitRuntime',
|
|
6764
|
+
'addOnPreRun',
|
|
6765
|
+
'addOnPostRun',
|
|
6661
6766
|
'getCFunc',
|
|
6662
6767
|
'ccall',
|
|
6663
6768
|
'uleb128Encode',
|
|
@@ -6691,8 +6796,14 @@ var unexportedSymbols = [
|
|
|
6691
6796
|
'UNWIND_CACHE',
|
|
6692
6797
|
'ExitStatus',
|
|
6693
6798
|
'getEnvStrings',
|
|
6799
|
+
'checkWasiClock',
|
|
6694
6800
|
'doReadv',
|
|
6695
6801
|
'doWritev',
|
|
6802
|
+
'initRandomFill',
|
|
6803
|
+
'randomFill',
|
|
6804
|
+
'emSetImmediate',
|
|
6805
|
+
'emClearImmediate_deps',
|
|
6806
|
+
'emClearImmediate',
|
|
6696
6807
|
'promiseMap',
|
|
6697
6808
|
'uncaughtExceptionCount',
|
|
6698
6809
|
'exceptionLast',
|
|
@@ -6700,6 +6811,12 @@ var unexportedSymbols = [
|
|
|
6700
6811
|
'Browser',
|
|
6701
6812
|
'getPreloadedImageData__data',
|
|
6702
6813
|
'wget',
|
|
6814
|
+
'MONTH_DAYS_REGULAR',
|
|
6815
|
+
'MONTH_DAYS_LEAP',
|
|
6816
|
+
'MONTH_DAYS_REGULAR_CUMULATIVE',
|
|
6817
|
+
'MONTH_DAYS_LEAP_CUMULATIVE',
|
|
6818
|
+
'isLeapYear',
|
|
6819
|
+
'ydayFromDate',
|
|
6703
6820
|
'SYSCALLS',
|
|
6704
6821
|
'preloadPlugins',
|
|
6705
6822
|
'FS_createPreloadedFile',
|
|
@@ -6739,12 +6856,6 @@ unexportedSymbols.forEach(unexportedRuntimeSymbol);
|
|
|
6739
6856
|
|
|
6740
6857
|
var calledRun;
|
|
6741
6858
|
|
|
6742
|
-
dependenciesFulfilled = function runCaller() {
|
|
6743
|
-
// If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
|
|
6744
|
-
if (!calledRun) run();
|
|
6745
|
-
if (!calledRun) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
|
|
6746
|
-
};
|
|
6747
|
-
|
|
6748
6859
|
function stackCheckInit() {
|
|
6749
6860
|
// This is normally called automatically during __wasm_call_ctors but need to
|
|
6750
6861
|
// get these values before even running any of the ctors so we call it redundantly
|
|
@@ -6757,22 +6868,24 @@ function stackCheckInit() {
|
|
|
6757
6868
|
function run() {
|
|
6758
6869
|
|
|
6759
6870
|
if (runDependencies > 0) {
|
|
6871
|
+
dependenciesFulfilled = run;
|
|
6760
6872
|
return;
|
|
6761
6873
|
}
|
|
6762
6874
|
|
|
6763
|
-
|
|
6875
|
+
stackCheckInit();
|
|
6764
6876
|
|
|
6765
6877
|
preRun();
|
|
6766
6878
|
|
|
6767
6879
|
// a preRun added a dependency, run will be called later
|
|
6768
6880
|
if (runDependencies > 0) {
|
|
6881
|
+
dependenciesFulfilled = run;
|
|
6769
6882
|
return;
|
|
6770
6883
|
}
|
|
6771
6884
|
|
|
6772
6885
|
function doRun() {
|
|
6773
6886
|
// run may have just been called through dependencies being fulfilled just in this very frame,
|
|
6774
6887
|
// or while the async setStatus time below was happening
|
|
6775
|
-
|
|
6888
|
+
assert(!calledRun);
|
|
6776
6889
|
calledRun = true;
|
|
6777
6890
|
Module['calledRun'] = true;
|
|
6778
6891
|
|
|
@@ -6781,6 +6894,7 @@ function run() {
|
|
|
6781
6894
|
initRuntime();
|
|
6782
6895
|
|
|
6783
6896
|
Module['onRuntimeInitialized']?.();
|
|
6897
|
+
consumedModuleProp('onRuntimeInitialized');
|
|
6784
6898
|
|
|
6785
6899
|
assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');
|
|
6786
6900
|
|
|
@@ -6789,10 +6903,8 @@ function run() {
|
|
|
6789
6903
|
|
|
6790
6904
|
if (Module['setStatus']) {
|
|
6791
6905
|
Module['setStatus']('Running...');
|
|
6792
|
-
setTimeout(
|
|
6793
|
-
setTimeout(
|
|
6794
|
-
Module['setStatus']('');
|
|
6795
|
-
}, 1);
|
|
6906
|
+
setTimeout(() => {
|
|
6907
|
+
setTimeout(() => Module['setStatus'](''), 1);
|
|
6796
6908
|
doRun();
|
|
6797
6909
|
}, 1);
|
|
6798
6910
|
} else
|
|
@@ -6823,7 +6935,7 @@ function checkUnflushedContent() {
|
|
|
6823
6935
|
try { // it doesn't matter if it fails
|
|
6824
6936
|
_fflush(0);
|
|
6825
6937
|
// also flush in the JS FS layer
|
|
6826
|
-
['stdout', 'stderr'].forEach(
|
|
6938
|
+
['stdout', 'stderr'].forEach((name) => {
|
|
6827
6939
|
var info = FS.analyzePath('/dev/' + name);
|
|
6828
6940
|
if (!info) return;
|
|
6829
6941
|
var stream = info.object;
|
|
@@ -6847,6 +6959,7 @@ if (Module['preInit']) {
|
|
|
6847
6959
|
Module['preInit'].pop()();
|
|
6848
6960
|
}
|
|
6849
6961
|
}
|
|
6962
|
+
consumedModuleProp('preInit');
|
|
6850
6963
|
|
|
6851
6964
|
run();
|
|
6852
6965
|
|
|
@@ -6964,12 +7077,36 @@ function onError(err) {
|
|
|
6964
7077
|
});
|
|
6965
7078
|
}
|
|
6966
7079
|
|
|
7080
|
+
db = null;
|
|
7081
|
+
var sqlModuleReady = initSqlJs();
|
|
7082
|
+
|
|
7083
|
+
function global_sqljs_message_handler(event) {
|
|
7084
|
+
return sqlModuleReady
|
|
7085
|
+
.then(onModuleReady.bind(event))
|
|
7086
|
+
.catch(onError.bind(event));
|
|
7087
|
+
}
|
|
7088
|
+
|
|
6967
7089
|
if (typeof importScripts === "function") {
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
7090
|
+
self.onmessage = global_sqljs_message_handler;
|
|
7091
|
+
}
|
|
7092
|
+
|
|
7093
|
+
if (typeof require === "function") {
|
|
7094
|
+
// eslint-disable-next-line global-require
|
|
7095
|
+
var worker_threads = require("worker_threads");
|
|
7096
|
+
var parentPort = worker_threads.parentPort;
|
|
7097
|
+
// eslint-disable-next-line no-undef
|
|
7098
|
+
globalThis.postMessage = parentPort.postMessage.bind(parentPort);
|
|
7099
|
+
parentPort.on("message", function onmessage(data) {
|
|
7100
|
+
var event = { data: data };
|
|
7101
|
+
global_sqljs_message_handler(event);
|
|
7102
|
+
});
|
|
7103
|
+
|
|
7104
|
+
if (typeof process !== "undefined") {
|
|
7105
|
+
process.on("uncaughtException", function uncaughtException(err) {
|
|
7106
|
+
postMessage({ error: err.message });
|
|
7107
|
+
});
|
|
7108
|
+
process.on("unhandledRejection", function unhandledRejection(err) {
|
|
7109
|
+
postMessage({ error: err.message });
|
|
7110
|
+
});
|
|
7111
|
+
}
|
|
6975
7112
|
}
|