@lvce-editor/main-process 6.8.2 → 6.9.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/dist/mainProcessMain.js +851 -1270
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -1343,12 +1343,12 @@ function requireLib () {
|
|
|
1343
1343
|
|
|
1344
1344
|
var libExports = requireLib();
|
|
1345
1345
|
|
|
1346
|
-
const NewLine$
|
|
1347
|
-
const splitLines$
|
|
1348
|
-
return lines.split(NewLine$
|
|
1346
|
+
const NewLine$3 = '\n';
|
|
1347
|
+
const splitLines$2 = lines => {
|
|
1348
|
+
return lines.split(NewLine$3);
|
|
1349
1349
|
};
|
|
1350
|
-
const RE_AT$
|
|
1351
|
-
const RE_AT_PROMISE_INDEX$
|
|
1350
|
+
const RE_AT$1 = /^\s+at/;
|
|
1351
|
+
const RE_AT_PROMISE_INDEX$1 = /^\s*at async Promise.all \(index \d+\)$/;
|
|
1352
1352
|
const RE_OBJECT_AS = /^\s*at (async )?Object\.\w+ \[as ([\w\.]+)\]/;
|
|
1353
1353
|
const RE_GET_RESPONSE = /^\s*at async getResponse/;
|
|
1354
1354
|
const RE_WEBSOCKET_HANDLE_MESSAGE = /^\s*at async WebSocket.handleMessage/;
|
|
@@ -1356,7 +1356,7 @@ const RE_EXECUTE_COMMAND_ASYNC = /^\s*at executeCommandAsync/;
|
|
|
1356
1356
|
const RE_HANDLE_OTHER_MESSAGES_FROM_MESSAGE_PORT = /^\s*at async MessagePort\.handleOtherMessagesFromMessagePort/;
|
|
1357
1357
|
const RE_ASSERT = /^\s*at .*\/Assert\.js/;
|
|
1358
1358
|
const isInternalLine = line => {
|
|
1359
|
-
return line.includes('node:') || RE_AT_PROMISE_INDEX$
|
|
1359
|
+
return line.includes('node:') || RE_AT_PROMISE_INDEX$1.test(line) || line.includes('node_modules/ws');
|
|
1360
1360
|
};
|
|
1361
1361
|
const isRelevantLine = line => {
|
|
1362
1362
|
return !isInternalLine(line);
|
|
@@ -1382,8 +1382,8 @@ const isApplicationUsefulLine = (line, index) => {
|
|
|
1382
1382
|
}
|
|
1383
1383
|
return true;
|
|
1384
1384
|
};
|
|
1385
|
-
const isNormalStackLine$
|
|
1386
|
-
return RE_AT$
|
|
1385
|
+
const isNormalStackLine$1 = line => {
|
|
1386
|
+
return RE_AT$1.test(line) && !RE_AT_PROMISE_INDEX$1.test(line);
|
|
1387
1387
|
};
|
|
1388
1388
|
const cleanLine = line => {
|
|
1389
1389
|
if (line.startsWith(' at exports.')) {
|
|
@@ -1408,8 +1408,8 @@ const cleanLine = line => {
|
|
|
1408
1408
|
}
|
|
1409
1409
|
return line;
|
|
1410
1410
|
};
|
|
1411
|
-
const getDetails$
|
|
1412
|
-
const index = lines.findIndex(isNormalStackLine$
|
|
1411
|
+
const getDetails$1 = lines => {
|
|
1412
|
+
const index = lines.findIndex(isNormalStackLine$1);
|
|
1413
1413
|
return {
|
|
1414
1414
|
custom: lines.slice(0, index),
|
|
1415
1415
|
actualStack: lines.slice(index).map(cleanLine)
|
|
@@ -1427,25 +1427,25 @@ const mergeCustom = (custom, relevantStack) => {
|
|
|
1427
1427
|
return relevantStack;
|
|
1428
1428
|
};
|
|
1429
1429
|
const cleanStack = stack => {
|
|
1430
|
-
const lines = splitLines$
|
|
1430
|
+
const lines = splitLines$2(stack);
|
|
1431
1431
|
const {
|
|
1432
1432
|
custom,
|
|
1433
1433
|
actualStack
|
|
1434
|
-
} = getDetails$
|
|
1434
|
+
} = getDetails$1(lines);
|
|
1435
1435
|
const relevantStack = actualStack.filter(isRelevantLine).filter(isApplicationUsefulLine);
|
|
1436
1436
|
const merged = mergeCustom(custom, relevantStack);
|
|
1437
1437
|
return merged;
|
|
1438
1438
|
};
|
|
1439
1439
|
const Utf8 = 'utf8';
|
|
1440
|
-
const ERR_MODULE_NOT_FOUND$
|
|
1440
|
+
const ERR_MODULE_NOT_FOUND$1 = 'ERR_MODULE_NOT_FOUND';
|
|
1441
1441
|
const getActualPath$1 = fileUri => {
|
|
1442
1442
|
if (fileUri.startsWith('file://')) {
|
|
1443
1443
|
return fileURLToPath(fileUri);
|
|
1444
1444
|
}
|
|
1445
1445
|
return fileUri;
|
|
1446
1446
|
};
|
|
1447
|
-
const joinLines$
|
|
1448
|
-
return lines.join(NewLine$
|
|
1447
|
+
const joinLines$2 = lines => {
|
|
1448
|
+
return lines.join(NewLine$3);
|
|
1449
1449
|
};
|
|
1450
1450
|
const warn$1 = (...args) => {
|
|
1451
1451
|
console.warn(...args);
|
|
@@ -1468,7 +1468,7 @@ const prepareModuleNotFoundError = error => {
|
|
|
1468
1468
|
const rawLines = readFileSync(importedFrom, Utf8);
|
|
1469
1469
|
let line = 0;
|
|
1470
1470
|
let column = 0;
|
|
1471
|
-
const splittedLines = splitLines$
|
|
1471
|
+
const splittedLines = splitLines$2(rawLines);
|
|
1472
1472
|
for (let i = 0; i < splittedLines.length; i++) {
|
|
1473
1473
|
const splittedLine = splittedLines[i];
|
|
1474
1474
|
const index = splittedLine.indexOf(notFoundModule);
|
|
@@ -1485,9 +1485,9 @@ const prepareModuleNotFoundError = error => {
|
|
|
1485
1485
|
}
|
|
1486
1486
|
};
|
|
1487
1487
|
const codeFrame = libExports.codeFrameColumns(rawLines, location);
|
|
1488
|
-
const stackLines = splitLines$
|
|
1488
|
+
const stackLines = splitLines$2(error.stack);
|
|
1489
1489
|
const newStackLines = [stackLines[0], ` at ${importedFrom}:${line}:${column}`, ...stackLines.slice(1)];
|
|
1490
|
-
const newStack = joinLines$
|
|
1490
|
+
const newStack = joinLines$2(newStackLines);
|
|
1491
1491
|
return {
|
|
1492
1492
|
message,
|
|
1493
1493
|
stack: newStack,
|
|
@@ -1496,7 +1496,7 @@ const prepareModuleNotFoundError = error => {
|
|
|
1496
1496
|
};
|
|
1497
1497
|
const prepare = error => {
|
|
1498
1498
|
try {
|
|
1499
|
-
if (error && error.code === ERR_MODULE_NOT_FOUND$
|
|
1499
|
+
if (error && error.code === ERR_MODULE_NOT_FOUND$1) {
|
|
1500
1500
|
return prepareModuleNotFoundError(error);
|
|
1501
1501
|
}
|
|
1502
1502
|
const {
|
|
@@ -1531,7 +1531,7 @@ const prepare = error => {
|
|
|
1531
1531
|
codeFrame = libExports.codeFrameColumns(rawLines, location);
|
|
1532
1532
|
}
|
|
1533
1533
|
}
|
|
1534
|
-
const relevantStack = joinLines$
|
|
1534
|
+
const relevantStack = joinLines$2(lines);
|
|
1535
1535
|
return {
|
|
1536
1536
|
message,
|
|
1537
1537
|
stack: relevantStack,
|
|
@@ -1638,6 +1638,14 @@ const getPid = () => {
|
|
|
1638
1638
|
const getArgv = () => {
|
|
1639
1639
|
return process.argv;
|
|
1640
1640
|
};
|
|
1641
|
+
const writeStdout = value => {
|
|
1642
|
+
string(value);
|
|
1643
|
+
process.stdout.write(value);
|
|
1644
|
+
};
|
|
1645
|
+
const writeStderr = value => {
|
|
1646
|
+
string(value);
|
|
1647
|
+
process.stderr.write(value);
|
|
1648
|
+
};
|
|
1641
1649
|
process;
|
|
1642
1650
|
const {
|
|
1643
1651
|
execPath
|
|
@@ -1682,8 +1690,12 @@ const handleUnhandledRejection = (reason, promise) => {
|
|
|
1682
1690
|
}
|
|
1683
1691
|
};
|
|
1684
1692
|
|
|
1685
|
-
const exit =
|
|
1686
|
-
|
|
1693
|
+
const exit = code => {
|
|
1694
|
+
if (code === undefined) {
|
|
1695
|
+
app.quit();
|
|
1696
|
+
return;
|
|
1697
|
+
}
|
|
1698
|
+
app.exit(code);
|
|
1687
1699
|
};
|
|
1688
1700
|
|
|
1689
1701
|
const NodeWorker$1 = 1;
|
|
@@ -1708,9 +1720,9 @@ const getCombinedMessage = (error, message) => {
|
|
|
1708
1720
|
}
|
|
1709
1721
|
return stringifiedError;
|
|
1710
1722
|
};
|
|
1711
|
-
const NewLine$
|
|
1723
|
+
const NewLine$2 = '\n';
|
|
1712
1724
|
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
1713
|
-
return string.indexOf(NewLine$
|
|
1725
|
+
return string.indexOf(NewLine$2, startIndex);
|
|
1714
1726
|
};
|
|
1715
1727
|
const mergeStacks = (parent, child) => {
|
|
1716
1728
|
if (!child) {
|
|
@@ -1748,31 +1760,31 @@ class VError extends Error {
|
|
|
1748
1760
|
}
|
|
1749
1761
|
}
|
|
1750
1762
|
|
|
1751
|
-
const isMessagePort
|
|
1763
|
+
const isMessagePort = value => {
|
|
1752
1764
|
return value && value instanceof MessagePort;
|
|
1753
1765
|
};
|
|
1754
|
-
const isMessagePortMain
|
|
1766
|
+
const isMessagePortMain = value => {
|
|
1755
1767
|
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
1756
1768
|
};
|
|
1757
|
-
const isOffscreenCanvas
|
|
1769
|
+
const isOffscreenCanvas = value => {
|
|
1758
1770
|
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
1759
1771
|
};
|
|
1760
|
-
const isInstanceOf
|
|
1772
|
+
const isInstanceOf = (value, constructorName) => {
|
|
1761
1773
|
return value?.constructor?.name === constructorName;
|
|
1762
1774
|
};
|
|
1763
|
-
const isSocket
|
|
1764
|
-
return isInstanceOf
|
|
1775
|
+
const isSocket = value => {
|
|
1776
|
+
return isInstanceOf(value, 'Socket');
|
|
1765
1777
|
};
|
|
1766
|
-
const transferrables
|
|
1767
|
-
const isTransferrable
|
|
1768
|
-
for (const fn of transferrables
|
|
1778
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
1779
|
+
const isTransferrable = value => {
|
|
1780
|
+
for (const fn of transferrables) {
|
|
1769
1781
|
if (fn(value)) {
|
|
1770
1782
|
return true;
|
|
1771
1783
|
}
|
|
1772
1784
|
}
|
|
1773
1785
|
return false;
|
|
1774
1786
|
};
|
|
1775
|
-
const walkValue
|
|
1787
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
1776
1788
|
if (!value) {
|
|
1777
1789
|
return;
|
|
1778
1790
|
}
|
|
@@ -1782,23 +1794,22 @@ const walkValue$1 = (value, transferrables, isTransferrable) => {
|
|
|
1782
1794
|
}
|
|
1783
1795
|
if (Array.isArray(value)) {
|
|
1784
1796
|
for (const item of value) {
|
|
1785
|
-
walkValue
|
|
1797
|
+
walkValue(item, transferrables, isTransferrable);
|
|
1786
1798
|
}
|
|
1787
1799
|
return;
|
|
1788
1800
|
}
|
|
1789
1801
|
if (typeof value === 'object') {
|
|
1790
1802
|
for (const property of Object.values(value)) {
|
|
1791
|
-
walkValue
|
|
1803
|
+
walkValue(property, transferrables, isTransferrable);
|
|
1792
1804
|
}
|
|
1793
|
-
return;
|
|
1794
1805
|
}
|
|
1795
1806
|
};
|
|
1796
|
-
const getTransferrables
|
|
1807
|
+
const getTransferrables = value => {
|
|
1797
1808
|
const transferrables = [];
|
|
1798
|
-
walkValue
|
|
1809
|
+
walkValue(value, transferrables, isTransferrable);
|
|
1799
1810
|
return transferrables;
|
|
1800
1811
|
};
|
|
1801
|
-
const removeValues
|
|
1812
|
+
const removeValues = (value, toRemove) => {
|
|
1802
1813
|
if (!value) {
|
|
1803
1814
|
return value;
|
|
1804
1815
|
}
|
|
@@ -1806,7 +1817,7 @@ const removeValues$1 = (value, toRemove) => {
|
|
|
1806
1817
|
const newItems = [];
|
|
1807
1818
|
for (const item of value) {
|
|
1808
1819
|
if (!toRemove.includes(item)) {
|
|
1809
|
-
newItems.push(removeValues
|
|
1820
|
+
newItems.push(removeValues(item, toRemove));
|
|
1810
1821
|
}
|
|
1811
1822
|
}
|
|
1812
1823
|
return newItems;
|
|
@@ -1815,7 +1826,7 @@ const removeValues$1 = (value, toRemove) => {
|
|
|
1815
1826
|
const newObject = Object.create(null);
|
|
1816
1827
|
for (const [key, property] of Object.entries(value)) {
|
|
1817
1828
|
if (!toRemove.includes(property)) {
|
|
1818
|
-
newObject[key] = removeValues
|
|
1829
|
+
newObject[key] = removeValues(property, toRemove);
|
|
1819
1830
|
}
|
|
1820
1831
|
}
|
|
1821
1832
|
return newObject;
|
|
@@ -1826,15 +1837,15 @@ const removeValues$1 = (value, toRemove) => {
|
|
|
1826
1837
|
// workaround for electron not supporting transferrable objects
|
|
1827
1838
|
// as parameters. If the transferrable object is a parameter, in electron
|
|
1828
1839
|
// only an empty objected is received in the main process
|
|
1829
|
-
const fixElectronParameters
|
|
1830
|
-
const transfer = getTransferrables
|
|
1831
|
-
const newValue = removeValues
|
|
1840
|
+
const fixElectronParameters = value => {
|
|
1841
|
+
const transfer = getTransferrables(value);
|
|
1842
|
+
const newValue = removeValues(value, transfer);
|
|
1832
1843
|
return {
|
|
1833
1844
|
newValue,
|
|
1834
1845
|
transfer
|
|
1835
1846
|
};
|
|
1836
1847
|
};
|
|
1837
|
-
const getActualDataElectron
|
|
1848
|
+
const getActualDataElectron = event => {
|
|
1838
1849
|
const {
|
|
1839
1850
|
data,
|
|
1840
1851
|
ports
|
|
@@ -1847,7 +1858,7 @@ const getActualDataElectron$1 = event => {
|
|
|
1847
1858
|
params: [...ports, ...data.params]
|
|
1848
1859
|
};
|
|
1849
1860
|
};
|
|
1850
|
-
const attachEvents
|
|
1861
|
+
const attachEvents = that => {
|
|
1851
1862
|
const handleMessage = (...args) => {
|
|
1852
1863
|
const data = that.getData(...args);
|
|
1853
1864
|
that.dispatchEvent(new MessageEvent('message', {
|
|
@@ -1860,36 +1871,36 @@ const attachEvents$1 = that => {
|
|
|
1860
1871
|
};
|
|
1861
1872
|
that.onClose(handleClose);
|
|
1862
1873
|
};
|
|
1863
|
-
|
|
1874
|
+
class Ipc extends EventTarget {
|
|
1864
1875
|
constructor(rawIpc) {
|
|
1865
1876
|
super();
|
|
1866
1877
|
this._rawIpc = rawIpc;
|
|
1867
|
-
attachEvents
|
|
1878
|
+
attachEvents(this);
|
|
1868
1879
|
}
|
|
1880
|
+
}
|
|
1881
|
+
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
1882
|
+
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
1883
|
+
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
1884
|
+
const NewLine$1 = '\n';
|
|
1885
|
+
const joinLines$1 = lines => {
|
|
1886
|
+
return lines.join(NewLine$1);
|
|
1869
1887
|
};
|
|
1870
|
-
const
|
|
1871
|
-
const
|
|
1872
|
-
const
|
|
1873
|
-
|
|
1874
|
-
const joinLines$2 = lines => {
|
|
1875
|
-
return lines.join(NewLine$2);
|
|
1876
|
-
};
|
|
1877
|
-
const RE_AT$1 = /^\s+at/;
|
|
1878
|
-
const RE_AT_PROMISE_INDEX$1 = /^\s*at async Promise.all \(index \d+\)$/;
|
|
1879
|
-
const isNormalStackLine$1 = line => {
|
|
1880
|
-
return RE_AT$1.test(line) && !RE_AT_PROMISE_INDEX$1.test(line);
|
|
1888
|
+
const RE_AT = /^\s+at/;
|
|
1889
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
1890
|
+
const isNormalStackLine = line => {
|
|
1891
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
1881
1892
|
};
|
|
1882
|
-
const getDetails
|
|
1883
|
-
const index = lines.findIndex(isNormalStackLine
|
|
1893
|
+
const getDetails = lines => {
|
|
1894
|
+
const index = lines.findIndex(isNormalStackLine);
|
|
1884
1895
|
if (index === -1) {
|
|
1885
1896
|
return {
|
|
1886
|
-
actualMessage: joinLines$
|
|
1897
|
+
actualMessage: joinLines$1(lines),
|
|
1887
1898
|
rest: []
|
|
1888
1899
|
};
|
|
1889
1900
|
}
|
|
1890
1901
|
let lastIndex = index - 1;
|
|
1891
1902
|
while (++lastIndex < lines.length) {
|
|
1892
|
-
if (!isNormalStackLine
|
|
1903
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
1893
1904
|
break;
|
|
1894
1905
|
}
|
|
1895
1906
|
}
|
|
@@ -1898,89 +1909,89 @@ const getDetails$1 = lines => {
|
|
|
1898
1909
|
rest: lines.slice(index, lastIndex)
|
|
1899
1910
|
};
|
|
1900
1911
|
};
|
|
1901
|
-
const splitLines$
|
|
1902
|
-
return lines.split(NewLine$
|
|
1912
|
+
const splitLines$1 = lines => {
|
|
1913
|
+
return lines.split(NewLine$1);
|
|
1903
1914
|
};
|
|
1904
|
-
const RE_MESSAGE_CODE_BLOCK_START
|
|
1905
|
-
const RE_MESSAGE_CODE_BLOCK_END
|
|
1906
|
-
const isMessageCodeBlockStartIndex
|
|
1907
|
-
return RE_MESSAGE_CODE_BLOCK_START
|
|
1915
|
+
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
1916
|
+
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
1917
|
+
const isMessageCodeBlockStartIndex = line => {
|
|
1918
|
+
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
1908
1919
|
};
|
|
1909
|
-
const isMessageCodeBlockEndIndex
|
|
1910
|
-
return RE_MESSAGE_CODE_BLOCK_END
|
|
1920
|
+
const isMessageCodeBlockEndIndex = line => {
|
|
1921
|
+
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
1911
1922
|
};
|
|
1912
|
-
const getMessageCodeBlock
|
|
1913
|
-
const lines = splitLines$
|
|
1914
|
-
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex
|
|
1915
|
-
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex
|
|
1923
|
+
const getMessageCodeBlock = stderr => {
|
|
1924
|
+
const lines = splitLines$1(stderr);
|
|
1925
|
+
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
1926
|
+
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
1916
1927
|
const relevantLines = lines.slice(startIndex, endIndex);
|
|
1917
1928
|
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
1918
1929
|
return relevantMessage;
|
|
1919
1930
|
};
|
|
1920
|
-
const isModuleNotFoundMessage
|
|
1931
|
+
const isModuleNotFoundMessage = line => {
|
|
1921
1932
|
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
1922
1933
|
};
|
|
1923
|
-
const getModuleNotFoundError
|
|
1924
|
-
const lines = splitLines$
|
|
1925
|
-
const messageIndex = lines.findIndex(isModuleNotFoundMessage
|
|
1934
|
+
const getModuleNotFoundError = stderr => {
|
|
1935
|
+
const lines = splitLines$1(stderr);
|
|
1936
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
1926
1937
|
const message = lines[messageIndex];
|
|
1927
1938
|
return {
|
|
1928
|
-
code: ERR_MODULE_NOT_FOUND
|
|
1939
|
+
code: ERR_MODULE_NOT_FOUND,
|
|
1929
1940
|
message
|
|
1930
1941
|
};
|
|
1931
1942
|
};
|
|
1932
|
-
const isModuleNotFoundError
|
|
1943
|
+
const isModuleNotFoundError = stderr => {
|
|
1933
1944
|
if (!stderr) {
|
|
1934
1945
|
return false;
|
|
1935
1946
|
}
|
|
1936
1947
|
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
1937
1948
|
};
|
|
1938
|
-
const isModulesSyntaxError
|
|
1949
|
+
const isModulesSyntaxError = stderr => {
|
|
1939
1950
|
if (!stderr) {
|
|
1940
1951
|
return false;
|
|
1941
1952
|
}
|
|
1942
1953
|
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
1943
1954
|
};
|
|
1944
|
-
const RE_NATIVE_MODULE_ERROR
|
|
1945
|
-
const RE_NATIVE_MODULE_ERROR_2
|
|
1946
|
-
const isUnhelpfulNativeModuleError
|
|
1947
|
-
return RE_NATIVE_MODULE_ERROR
|
|
1955
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
1956
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
1957
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
|
1958
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
1948
1959
|
};
|
|
1949
|
-
const getNativeModuleErrorMessage
|
|
1950
|
-
const message = getMessageCodeBlock
|
|
1960
|
+
const getNativeModuleErrorMessage = stderr => {
|
|
1961
|
+
const message = getMessageCodeBlock(stderr);
|
|
1951
1962
|
return {
|
|
1952
|
-
code: E_INCOMPATIBLE_NATIVE_MODULE
|
|
1963
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
1953
1964
|
message: `Incompatible native node module: ${message}`
|
|
1954
1965
|
};
|
|
1955
1966
|
};
|
|
1956
|
-
const getModuleSyntaxError
|
|
1967
|
+
const getModuleSyntaxError = () => {
|
|
1957
1968
|
return {
|
|
1958
|
-
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
1969
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
1959
1970
|
message: `ES Modules are not supported in electron`
|
|
1960
1971
|
};
|
|
1961
1972
|
};
|
|
1962
|
-
const getHelpfulChildProcessError
|
|
1963
|
-
if (isUnhelpfulNativeModuleError
|
|
1964
|
-
return getNativeModuleErrorMessage
|
|
1973
|
+
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
1974
|
+
if (isUnhelpfulNativeModuleError(stderr)) {
|
|
1975
|
+
return getNativeModuleErrorMessage(stderr);
|
|
1965
1976
|
}
|
|
1966
|
-
if (isModulesSyntaxError
|
|
1967
|
-
return getModuleSyntaxError
|
|
1977
|
+
if (isModulesSyntaxError(stderr)) {
|
|
1978
|
+
return getModuleSyntaxError();
|
|
1968
1979
|
}
|
|
1969
|
-
if (isModuleNotFoundError
|
|
1970
|
-
return getModuleNotFoundError
|
|
1980
|
+
if (isModuleNotFoundError(stderr)) {
|
|
1981
|
+
return getModuleNotFoundError(stderr);
|
|
1971
1982
|
}
|
|
1972
|
-
const lines = splitLines$
|
|
1983
|
+
const lines = splitLines$1(stderr);
|
|
1973
1984
|
const {
|
|
1974
1985
|
actualMessage,
|
|
1975
1986
|
rest
|
|
1976
|
-
} = getDetails
|
|
1987
|
+
} = getDetails(lines);
|
|
1977
1988
|
return {
|
|
1978
1989
|
code: '',
|
|
1979
1990
|
message: actualMessage,
|
|
1980
1991
|
stack: rest
|
|
1981
1992
|
};
|
|
1982
1993
|
};
|
|
1983
|
-
|
|
1994
|
+
class IpcError extends VError {
|
|
1984
1995
|
// @ts-ignore
|
|
1985
1996
|
constructor(betterMessage, stdout = '', stderr = '') {
|
|
1986
1997
|
if (stdout || stderr) {
|
|
@@ -1989,11 +2000,18 @@ let IpcError$1 = class IpcError extends VError {
|
|
|
1989
2000
|
code,
|
|
1990
2001
|
message,
|
|
1991
2002
|
stack
|
|
1992
|
-
} = getHelpfulChildProcessError
|
|
2003
|
+
} = getHelpfulChildProcessError(stdout, stderr);
|
|
1993
2004
|
const cause = new Error(message);
|
|
1994
2005
|
// @ts-ignore
|
|
1995
2006
|
cause.code = code;
|
|
1996
|
-
|
|
2007
|
+
if (stack) {
|
|
2008
|
+
Object.defineProperty(cause, 'stack', {
|
|
2009
|
+
configurable: true,
|
|
2010
|
+
enumerable: false,
|
|
2011
|
+
value: stack,
|
|
2012
|
+
writable: true
|
|
2013
|
+
});
|
|
2014
|
+
}
|
|
1997
2015
|
super(cause, betterMessage);
|
|
1998
2016
|
} else {
|
|
1999
2017
|
super(betterMessage);
|
|
@@ -2005,20 +2023,20 @@ let IpcError$1 = class IpcError extends VError {
|
|
|
2005
2023
|
// @ts-ignore
|
|
2006
2024
|
this.stderr = stderr;
|
|
2007
2025
|
}
|
|
2008
|
-
}
|
|
2009
|
-
const listen$b
|
|
2026
|
+
}
|
|
2027
|
+
const listen$b = ({
|
|
2010
2028
|
messagePort
|
|
2011
2029
|
}) => {
|
|
2012
|
-
if (!isMessagePortMain
|
|
2013
|
-
throw new IpcError
|
|
2030
|
+
if (!isMessagePortMain(messagePort)) {
|
|
2031
|
+
throw new IpcError('port must be of type MessagePortMain');
|
|
2014
2032
|
}
|
|
2015
2033
|
return messagePort;
|
|
2016
2034
|
};
|
|
2017
|
-
const signal$c
|
|
2035
|
+
const signal$c = messagePort => {
|
|
2018
2036
|
messagePort.start();
|
|
2019
2037
|
};
|
|
2020
|
-
|
|
2021
|
-
getData = getActualDataElectron
|
|
2038
|
+
class IpcChildWithElectronMessagePort extends Ipc {
|
|
2039
|
+
getData = getActualDataElectron;
|
|
2022
2040
|
send(message) {
|
|
2023
2041
|
this._rawIpc.postMessage(message);
|
|
2024
2042
|
}
|
|
@@ -2026,7 +2044,7 @@ let IpcChildWithElectronMessagePort$2 = class IpcChildWithElectronMessagePort ex
|
|
|
2026
2044
|
const {
|
|
2027
2045
|
newValue,
|
|
2028
2046
|
transfer
|
|
2029
|
-
} = fixElectronParameters
|
|
2047
|
+
} = fixElectronParameters(message);
|
|
2030
2048
|
this._rawIpc.postMessage(newValue, transfer);
|
|
2031
2049
|
}
|
|
2032
2050
|
dispose() {
|
|
@@ -2038,92 +2056,332 @@ let IpcChildWithElectronMessagePort$2 = class IpcChildWithElectronMessagePort ex
|
|
|
2038
2056
|
onClose(callback) {
|
|
2039
2057
|
this._rawIpc.on('close', callback);
|
|
2040
2058
|
}
|
|
2059
|
+
}
|
|
2060
|
+
const wrap$j = messagePort => {
|
|
2061
|
+
return new IpcChildWithElectronMessagePort(messagePort);
|
|
2041
2062
|
};
|
|
2042
|
-
const
|
|
2043
|
-
return new IpcChildWithElectronMessagePort$2(messagePort);
|
|
2044
|
-
};
|
|
2045
|
-
const IpcChildWithElectronMessagePort$1$1 = {
|
|
2063
|
+
const IpcChildWithElectronMessagePort$1 = {
|
|
2046
2064
|
__proto__: null,
|
|
2047
|
-
listen: listen$b
|
|
2048
|
-
signal: signal$c
|
|
2049
|
-
wrap: wrap$j
|
|
2050
|
-
};
|
|
2051
|
-
const preloadChannelType$1 = 'port';
|
|
2052
|
-
const listen$2$1 = ({
|
|
2053
|
-
webContents
|
|
2054
|
-
}) => {
|
|
2055
|
-
return webContents;
|
|
2065
|
+
listen: listen$b,
|
|
2066
|
+
signal: signal$c,
|
|
2067
|
+
wrap: wrap$j
|
|
2056
2068
|
};
|
|
2057
|
-
|
|
2069
|
+
|
|
2070
|
+
// @ts-ignore
|
|
2071
|
+
const getUtilityProcessPortData = event => {
|
|
2058
2072
|
const {
|
|
2059
|
-
|
|
2060
|
-
|
|
2073
|
+
data,
|
|
2074
|
+
ports
|
|
2061
2075
|
} = event;
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2076
|
+
if (ports.length === 0) {
|
|
2077
|
+
return data;
|
|
2078
|
+
}
|
|
2079
|
+
return {
|
|
2080
|
+
...data,
|
|
2081
|
+
params: [...ports, ...data.params]
|
|
2065
2082
|
};
|
|
2066
|
-
return data;
|
|
2067
2083
|
};
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2084
|
+
const readyMessage = 'ready';
|
|
2085
|
+
const listen$a = () => {
|
|
2086
|
+
// @ts-ignore
|
|
2087
|
+
const {
|
|
2088
|
+
parentPort
|
|
2089
|
+
} = process;
|
|
2090
|
+
if (!parentPort) {
|
|
2091
|
+
throw new IpcError('parent port must be defined');
|
|
2092
|
+
}
|
|
2093
|
+
return parentPort;
|
|
2094
|
+
};
|
|
2095
|
+
const signal$b = parentPort => {
|
|
2096
|
+
parentPort.postMessage(readyMessage);
|
|
2097
|
+
};
|
|
2098
|
+
class IpcChildWithElectronUtilityProcess extends Ipc {
|
|
2099
|
+
getData(event) {
|
|
2100
|
+
return getUtilityProcessPortData(event);
|
|
2071
2101
|
}
|
|
2072
2102
|
send(message) {
|
|
2073
|
-
this._rawIpc.postMessage(
|
|
2103
|
+
this._rawIpc.postMessage(message);
|
|
2074
2104
|
}
|
|
2075
2105
|
sendAndTransfer(message) {
|
|
2076
|
-
const
|
|
2077
|
-
|
|
2106
|
+
const {
|
|
2107
|
+
newValue,
|
|
2108
|
+
transfer
|
|
2109
|
+
} = fixElectronParameters(message);
|
|
2110
|
+
this._rawIpc.postMessage(newValue, transfer);
|
|
2078
2111
|
}
|
|
2079
2112
|
dispose() {
|
|
2080
|
-
|
|
2113
|
+
this._rawIpc.close();
|
|
2114
|
+
}
|
|
2115
|
+
onClose(callback) {
|
|
2116
|
+
this._rawIpc.on('close', callback);
|
|
2081
2117
|
}
|
|
2082
2118
|
onMessage(callback) {
|
|
2083
|
-
this._rawIpc.
|
|
2119
|
+
this._rawIpc.on('message', callback);
|
|
2084
2120
|
}
|
|
2085
|
-
|
|
2086
|
-
|
|
2121
|
+
}
|
|
2122
|
+
const wrap$i = parentPort => {
|
|
2123
|
+
return new IpcChildWithElectronUtilityProcess(parentPort);
|
|
2124
|
+
};
|
|
2125
|
+
const IpcChildWithElectronUtilityProcess$1 = {
|
|
2126
|
+
__proto__: null,
|
|
2127
|
+
listen: listen$a,
|
|
2128
|
+
signal: signal$b,
|
|
2129
|
+
wrap: wrap$i
|
|
2130
|
+
};
|
|
2131
|
+
const getActualData = (message, handle) => {
|
|
2132
|
+
if (handle) {
|
|
2133
|
+
return {
|
|
2134
|
+
...message,
|
|
2135
|
+
params: [handle, ...message.params]
|
|
2136
|
+
};
|
|
2087
2137
|
}
|
|
2138
|
+
return message;
|
|
2139
|
+
};
|
|
2140
|
+
const getTransferrablesNode = value => {
|
|
2141
|
+
const transferrables = getTransferrables(value);
|
|
2142
|
+
if (transferrables.length === 0) {
|
|
2143
|
+
throw new Error(`no transferrables found`);
|
|
2144
|
+
}
|
|
2145
|
+
return transferrables[0];
|
|
2146
|
+
};
|
|
2147
|
+
const listen$5 = async () => {
|
|
2148
|
+
if (!process.send) {
|
|
2149
|
+
throw new IpcError('process.send must be defined');
|
|
2150
|
+
}
|
|
2151
|
+
return process;
|
|
2152
|
+
};
|
|
2153
|
+
const signal$7 = process => {
|
|
2154
|
+
process.send(readyMessage);
|
|
2088
2155
|
};
|
|
2089
|
-
|
|
2090
|
-
|
|
2156
|
+
class IpcChildWithNodeForkedProcess extends Ipc {
|
|
2157
|
+
getData(message, handle) {
|
|
2158
|
+
return getActualData(message, handle);
|
|
2159
|
+
}
|
|
2160
|
+
onClose(callback) {
|
|
2161
|
+
this._rawIpc.on('close', callback);
|
|
2162
|
+
}
|
|
2163
|
+
send(message) {
|
|
2164
|
+
this._rawIpc.send(message);
|
|
2165
|
+
}
|
|
2166
|
+
onMessage(callback) {
|
|
2167
|
+
this._rawIpc.on('message', callback);
|
|
2168
|
+
}
|
|
2169
|
+
sendAndTransfer(message) {
|
|
2170
|
+
const transfer = getTransferrablesNode(message);
|
|
2171
|
+
this._rawIpc.send(message, transfer);
|
|
2172
|
+
}
|
|
2173
|
+
dispose() {
|
|
2174
|
+
// ignore
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
const wrap$d = process => {
|
|
2178
|
+
return new IpcChildWithNodeForkedProcess(process);
|
|
2091
2179
|
};
|
|
2092
|
-
const
|
|
2180
|
+
const IpcChildWithNodeForkedProcess$1 = {
|
|
2093
2181
|
__proto__: null,
|
|
2094
|
-
listen: listen$
|
|
2095
|
-
|
|
2182
|
+
listen: listen$5,
|
|
2183
|
+
signal: signal$7,
|
|
2184
|
+
wrap: wrap$d
|
|
2096
2185
|
};
|
|
2097
|
-
const
|
|
2098
|
-
const Message$1$1 = 3;
|
|
2099
|
-
const getFirstUtilityProcessEvent$1 = async utilityProcess => {
|
|
2186
|
+
const listen$3 = async () => {
|
|
2100
2187
|
const {
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
}
|
|
2118
|
-
|
|
2119
|
-
|
|
2188
|
+
parentPort
|
|
2189
|
+
} = await import('node:worker_threads');
|
|
2190
|
+
if (!parentPort) {
|
|
2191
|
+
throw new IpcError('parentPort is required for node worker threads ipc');
|
|
2192
|
+
}
|
|
2193
|
+
return parentPort;
|
|
2194
|
+
};
|
|
2195
|
+
const signal$5 = parentPort => {
|
|
2196
|
+
parentPort.postMessage(readyMessage);
|
|
2197
|
+
};
|
|
2198
|
+
class IpcChildWithNodeWorker extends Ipc {
|
|
2199
|
+
getData(data) {
|
|
2200
|
+
return data;
|
|
2201
|
+
}
|
|
2202
|
+
onClose(callback) {
|
|
2203
|
+
this._rawIpc.on('close', callback);
|
|
2204
|
+
}
|
|
2205
|
+
send(message) {
|
|
2206
|
+
this._rawIpc.postMessage(message);
|
|
2207
|
+
}
|
|
2208
|
+
onMessage(callback) {
|
|
2209
|
+
this._rawIpc.on('message', callback);
|
|
2210
|
+
}
|
|
2211
|
+
sendAndTransfer(message) {
|
|
2212
|
+
const transfer = getTransferrablesNode(message);
|
|
2213
|
+
this._rawIpc.postMessage(message, transfer);
|
|
2214
|
+
}
|
|
2215
|
+
dispose() {
|
|
2216
|
+
this._rawIpc.close();
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
const wrap$b = parentPort => {
|
|
2220
|
+
return new IpcChildWithNodeWorker(parentPort);
|
|
2221
|
+
};
|
|
2222
|
+
const IpcChildWithNodeWorker$1 = {
|
|
2223
|
+
__proto__: null,
|
|
2224
|
+
listen: listen$3,
|
|
2225
|
+
signal: signal$5,
|
|
2226
|
+
wrap: wrap$b
|
|
2227
|
+
};
|
|
2228
|
+
const preloadChannelType = 'port';
|
|
2229
|
+
const listen$2 = ({
|
|
2230
|
+
webContents
|
|
2231
|
+
}) => {
|
|
2232
|
+
return webContents;
|
|
2233
|
+
};
|
|
2234
|
+
const getData$1 = (event, message) => {
|
|
2235
|
+
const {
|
|
2236
|
+
ports,
|
|
2237
|
+
sender
|
|
2238
|
+
} = event;
|
|
2239
|
+
const data = {
|
|
2240
|
+
...message,
|
|
2241
|
+
params: [...message.params, ...ports, sender.id]
|
|
2242
|
+
};
|
|
2243
|
+
return data;
|
|
2244
|
+
};
|
|
2245
|
+
class IpcChildWithRendererProcess2 extends Ipc {
|
|
2246
|
+
getData(event, message) {
|
|
2247
|
+
return getData$1(event, message);
|
|
2248
|
+
}
|
|
2249
|
+
send(message) {
|
|
2250
|
+
this._rawIpc.postMessage(preloadChannelType, message);
|
|
2251
|
+
}
|
|
2252
|
+
sendAndTransfer(message) {
|
|
2253
|
+
const transfer = getTransferrables(message);
|
|
2254
|
+
this._rawIpc.postMessage(preloadChannelType, message, transfer);
|
|
2255
|
+
}
|
|
2256
|
+
dispose() {
|
|
2257
|
+
// ignore
|
|
2258
|
+
}
|
|
2259
|
+
onMessage(callback) {
|
|
2260
|
+
this._rawIpc.ipc.on(preloadChannelType, callback);
|
|
2261
|
+
}
|
|
2262
|
+
onClose(callback) {
|
|
2263
|
+
this._rawIpc.on('destroyed', callback);
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
const wrap$a = webContents => {
|
|
2267
|
+
return new IpcChildWithRendererProcess2(webContents);
|
|
2268
|
+
};
|
|
2269
|
+
const IpcChildWithRendererProcess2$1 = {
|
|
2270
|
+
__proto__: null,
|
|
2271
|
+
listen: listen$2,
|
|
2272
|
+
wrap: wrap$a
|
|
2273
|
+
};
|
|
2274
|
+
const addListener = (emitter, type, callback) => {
|
|
2275
|
+
if ('addEventListener' in emitter) {
|
|
2276
|
+
emitter.addEventListener(type, callback);
|
|
2277
|
+
} else {
|
|
2278
|
+
emitter.on(type, callback);
|
|
2279
|
+
}
|
|
2280
|
+
};
|
|
2281
|
+
const removeListener = (emitter, type, callback) => {
|
|
2282
|
+
if ('removeEventListener' in emitter) {
|
|
2283
|
+
emitter.removeEventListener(type, callback);
|
|
2284
|
+
} else {
|
|
2285
|
+
emitter.off(type, callback);
|
|
2286
|
+
}
|
|
2287
|
+
};
|
|
2288
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
2289
|
+
const {
|
|
2290
|
+
promise,
|
|
2291
|
+
resolve
|
|
2292
|
+
} = Promise.withResolvers();
|
|
2293
|
+
const listenerMap = Object.create(null);
|
|
2294
|
+
const cleanup = value => {
|
|
2295
|
+
for (const event of Object.keys(eventMap)) {
|
|
2296
|
+
removeListener(eventEmitter, event, listenerMap[event]);
|
|
2297
|
+
}
|
|
2298
|
+
resolve(value);
|
|
2299
|
+
};
|
|
2300
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
2301
|
+
const listener = event => {
|
|
2302
|
+
cleanup({
|
|
2303
|
+
event,
|
|
2304
|
+
type
|
|
2305
|
+
});
|
|
2306
|
+
};
|
|
2307
|
+
addListener(eventEmitter, event, listener);
|
|
2308
|
+
listenerMap[event] = listener;
|
|
2309
|
+
}
|
|
2310
|
+
return promise;
|
|
2311
|
+
};
|
|
2312
|
+
const create$7$1 = ({
|
|
2313
|
+
messagePort
|
|
2314
|
+
}) => {
|
|
2315
|
+
if (!isMessagePortMain(messagePort)) {
|
|
2316
|
+
throw new IpcError('port must be of type MessagePortMain');
|
|
2317
|
+
}
|
|
2318
|
+
return messagePort;
|
|
2319
|
+
};
|
|
2320
|
+
const signal$2 = messagePort => {
|
|
2321
|
+
messagePort.start();
|
|
2322
|
+
};
|
|
2323
|
+
class IpcParentWithElectronMessagePort extends Ipc {
|
|
2324
|
+
getData = getActualDataElectron;
|
|
2325
|
+
send(message) {
|
|
2326
|
+
this._rawIpc.postMessage(message);
|
|
2327
|
+
}
|
|
2328
|
+
sendAndTransfer(message) {
|
|
2329
|
+
const {
|
|
2330
|
+
newValue,
|
|
2331
|
+
transfer
|
|
2332
|
+
} = fixElectronParameters(message);
|
|
2333
|
+
this._rawIpc.postMessage(newValue, transfer);
|
|
2334
|
+
}
|
|
2335
|
+
dispose() {
|
|
2336
|
+
this._rawIpc.close();
|
|
2337
|
+
}
|
|
2338
|
+
onMessage(callback) {
|
|
2339
|
+
this._rawIpc.on('message', callback);
|
|
2340
|
+
}
|
|
2341
|
+
onClose(callback) {
|
|
2342
|
+
this._rawIpc.on('close', callback);
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
const wrap$7 = messagePort => {
|
|
2346
|
+
return new IpcParentWithElectronMessagePort(messagePort);
|
|
2347
|
+
};
|
|
2348
|
+
const IpcParentWithElectronMessagePort$1 = {
|
|
2349
|
+
__proto__: null,
|
|
2350
|
+
create: create$7$1,
|
|
2351
|
+
signal: signal$2,
|
|
2352
|
+
wrap: wrap$7
|
|
2353
|
+
};
|
|
2354
|
+
const Exit = 1;
|
|
2355
|
+
const Error$2 = 2;
|
|
2356
|
+
const Message$1 = 3;
|
|
2357
|
+
const getFirstUtilityProcessEvent = async utilityProcess => {
|
|
2358
|
+
const {
|
|
2359
|
+
promise,
|
|
2360
|
+
resolve
|
|
2361
|
+
} = Promise.withResolvers();
|
|
2362
|
+
let stdout = '';
|
|
2363
|
+
let stderr = '';
|
|
2364
|
+
const cleanup = value => {
|
|
2365
|
+
// @ts-ignore
|
|
2366
|
+
utilityProcess.stderr.off('data', handleStdErrData);
|
|
2367
|
+
// @ts-ignore
|
|
2368
|
+
utilityProcess.stdout.off('data', handleStdoutData);
|
|
2369
|
+
utilityProcess.off('message', handleMessage);
|
|
2370
|
+
utilityProcess.off('exit', handleExit);
|
|
2371
|
+
resolve(value);
|
|
2372
|
+
};
|
|
2373
|
+
const handleStdErrData = data => {
|
|
2374
|
+
stderr += data;
|
|
2375
|
+
};
|
|
2376
|
+
const handleStdoutData = data => {
|
|
2377
|
+
stdout += data;
|
|
2120
2378
|
};
|
|
2121
2379
|
const handleMessage = event => {
|
|
2122
2380
|
cleanup({
|
|
2123
2381
|
event,
|
|
2124
2382
|
stderr,
|
|
2125
2383
|
stdout,
|
|
2126
|
-
type: Message$1
|
|
2384
|
+
type: Message$1
|
|
2127
2385
|
});
|
|
2128
2386
|
};
|
|
2129
2387
|
const handleExit = event => {
|
|
@@ -2131,7 +2389,7 @@ const getFirstUtilityProcessEvent$1 = async utilityProcess => {
|
|
|
2131
2389
|
event,
|
|
2132
2390
|
stderr,
|
|
2133
2391
|
stdout,
|
|
2134
|
-
type: Exit
|
|
2392
|
+
type: Exit
|
|
2135
2393
|
});
|
|
2136
2394
|
};
|
|
2137
2395
|
// @ts-ignore
|
|
@@ -2182,15 +2440,15 @@ const create$6$1 = async ({
|
|
|
2182
2440
|
stderr,
|
|
2183
2441
|
stdout,
|
|
2184
2442
|
type
|
|
2185
|
-
} = await getFirstUtilityProcessEvent
|
|
2186
|
-
if (type === Exit
|
|
2187
|
-
throw new IpcError
|
|
2443
|
+
} = await getFirstUtilityProcessEvent(childProcess);
|
|
2444
|
+
if (type === Exit) {
|
|
2445
|
+
throw new IpcError(`Utility process exited before ipc connection was established`, stdout, stderr);
|
|
2188
2446
|
}
|
|
2189
2447
|
// @ts-ignore
|
|
2190
2448
|
childProcess.stderr.pipe(process.stderr);
|
|
2191
2449
|
return childProcess;
|
|
2192
2450
|
};
|
|
2193
|
-
let IpcParentWithElectronUtilityProcess$
|
|
2451
|
+
let IpcParentWithElectronUtilityProcess$1 = class IpcParentWithElectronUtilityProcess extends Ipc {
|
|
2194
2452
|
getData(data) {
|
|
2195
2453
|
return data;
|
|
2196
2454
|
}
|
|
@@ -2201,7 +2459,7 @@ let IpcParentWithElectronUtilityProcess$2 = class IpcParentWithElectronUtilityPr
|
|
|
2201
2459
|
const {
|
|
2202
2460
|
newValue,
|
|
2203
2461
|
transfer
|
|
2204
|
-
} = fixElectronParameters
|
|
2462
|
+
} = fixElectronParameters(message);
|
|
2205
2463
|
this._rawIpc.postMessage(newValue, transfer);
|
|
2206
2464
|
}
|
|
2207
2465
|
dispose() {
|
|
@@ -2214,40 +2472,311 @@ let IpcParentWithElectronUtilityProcess$2 = class IpcParentWithElectronUtilityPr
|
|
|
2214
2472
|
this._rawIpc.on('message', callback);
|
|
2215
2473
|
}
|
|
2216
2474
|
};
|
|
2217
|
-
const wrap$6
|
|
2218
|
-
return new IpcParentWithElectronUtilityProcess$
|
|
2475
|
+
const wrap$6 = process => {
|
|
2476
|
+
return new IpcParentWithElectronUtilityProcess$1(process);
|
|
2219
2477
|
};
|
|
2220
|
-
const IpcParentWithElectronUtilityProcess$1$
|
|
2478
|
+
const IpcParentWithElectronUtilityProcess$1$1 = {
|
|
2221
2479
|
__proto__: null,
|
|
2222
2480
|
create: create$6$1,
|
|
2223
|
-
wrap: wrap$6
|
|
2481
|
+
wrap: wrap$6
|
|
2224
2482
|
};
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
constructor(
|
|
2228
|
-
|
|
2229
|
-
|
|
2483
|
+
class ChildProcessError extends Error {
|
|
2484
|
+
// @ts-ignore
|
|
2485
|
+
constructor(stderr) {
|
|
2486
|
+
// @ts-ignore
|
|
2487
|
+
const {
|
|
2488
|
+
code,
|
|
2489
|
+
message,
|
|
2490
|
+
stack
|
|
2491
|
+
} = getHelpfulChildProcessError('', stderr);
|
|
2492
|
+
super(message || 'child process error');
|
|
2493
|
+
this.name = 'ChildProcessError';
|
|
2494
|
+
if (code) {
|
|
2495
|
+
// @ts-ignore
|
|
2496
|
+
this.code = code;
|
|
2497
|
+
}
|
|
2498
|
+
if (stack) {
|
|
2499
|
+
// @ts-ignore
|
|
2500
|
+
const lines = splitLines$1(this.stack);
|
|
2501
|
+
const [firstLine, ...stackLines] = lines;
|
|
2502
|
+
const newStackLines = [firstLine, ...stack, ...stackLines];
|
|
2503
|
+
const newStack = joinLines$1(newStackLines);
|
|
2504
|
+
this.stack = newStack;
|
|
2505
|
+
}
|
|
2230
2506
|
}
|
|
2231
2507
|
}
|
|
2232
|
-
const commands = Object.create(null);
|
|
2233
|
-
const register = commandMap => {
|
|
2234
|
-
Object.assign(commands, commandMap);
|
|
2235
|
-
};
|
|
2236
|
-
const getCommand = key => {
|
|
2237
|
-
return commands[key];
|
|
2238
|
-
};
|
|
2239
|
-
const execute$1 = (command, ...args) => {
|
|
2240
|
-
const fn = getCommand(command);
|
|
2241
|
-
if (!fn) {
|
|
2242
|
-
throw new CommandNotFoundError(command);
|
|
2243
|
-
}
|
|
2244
|
-
return fn(...args);
|
|
2245
|
-
};
|
|
2246
2508
|
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2509
|
+
// workaround for node not supporting transferrable objects
|
|
2510
|
+
// as parameters. If the transferrable object is a parameter,
|
|
2511
|
+
// it is received as a plain object is received in the receiving process
|
|
2512
|
+
const fixNodeChildProcessParameters = value => {
|
|
2513
|
+
const transfer = getTransferrables(value);
|
|
2514
|
+
if (transfer.length === 0) {
|
|
2515
|
+
throw new IpcError('no transferrables found');
|
|
2516
|
+
}
|
|
2517
|
+
const newValue = removeValues(value, transfer);
|
|
2518
|
+
return {
|
|
2519
|
+
newValue,
|
|
2520
|
+
transfer: transfer[0]
|
|
2521
|
+
};
|
|
2522
|
+
};
|
|
2523
|
+
const getFirstNodeChildProcessEvent = async childProcess => {
|
|
2524
|
+
const {
|
|
2525
|
+
event,
|
|
2526
|
+
stderr,
|
|
2527
|
+
stdout,
|
|
2528
|
+
type
|
|
2529
|
+
} = await new Promise((resolve, reject) => {
|
|
2530
|
+
let stderr = '';
|
|
2531
|
+
let stdout = '';
|
|
2532
|
+
const cleanup = value => {
|
|
2533
|
+
if (childProcess.stdout && childProcess.stderr) {
|
|
2534
|
+
childProcess.stderr.off('data', handleStdErrData);
|
|
2535
|
+
childProcess.stdout.off('data', handleStdoutData);
|
|
2536
|
+
}
|
|
2537
|
+
childProcess.off('message', handleMessage);
|
|
2538
|
+
childProcess.off('exit', handleExit);
|
|
2539
|
+
childProcess.off('error', handleError);
|
|
2540
|
+
resolve(value);
|
|
2541
|
+
};
|
|
2542
|
+
const handleStdErrData = data => {
|
|
2543
|
+
stderr += data;
|
|
2544
|
+
};
|
|
2545
|
+
const handleStdoutData = data => {
|
|
2546
|
+
stdout += data;
|
|
2547
|
+
};
|
|
2548
|
+
const handleMessage = event => {
|
|
2549
|
+
cleanup({
|
|
2550
|
+
event,
|
|
2551
|
+
stderr,
|
|
2552
|
+
stdout,
|
|
2553
|
+
type: Message$1
|
|
2554
|
+
});
|
|
2555
|
+
};
|
|
2556
|
+
const handleExit = event => {
|
|
2557
|
+
cleanup({
|
|
2558
|
+
event,
|
|
2559
|
+
stderr,
|
|
2560
|
+
stdout,
|
|
2561
|
+
type: Exit
|
|
2562
|
+
});
|
|
2563
|
+
};
|
|
2564
|
+
const handleError = event => {
|
|
2565
|
+
cleanup({
|
|
2566
|
+
event,
|
|
2567
|
+
stderr,
|
|
2568
|
+
stdout,
|
|
2569
|
+
type: Error$2
|
|
2570
|
+
});
|
|
2571
|
+
};
|
|
2572
|
+
if (childProcess.stdout && childProcess.stderr) {
|
|
2573
|
+
childProcess.stderr.on('data', handleStdErrData);
|
|
2574
|
+
childProcess.stdout.on('data', handleStdoutData);
|
|
2575
|
+
}
|
|
2576
|
+
childProcess.on('message', handleMessage);
|
|
2577
|
+
childProcess.on('exit', handleExit);
|
|
2578
|
+
childProcess.on('error', handleError);
|
|
2579
|
+
});
|
|
2580
|
+
return {
|
|
2581
|
+
event,
|
|
2582
|
+
stderr,
|
|
2583
|
+
stdout,
|
|
2584
|
+
type
|
|
2585
|
+
};
|
|
2586
|
+
};
|
|
2587
|
+
|
|
2588
|
+
// @ts-ignore
|
|
2589
|
+
const create$2$2 = async ({
|
|
2590
|
+
argv = [],
|
|
2591
|
+
env,
|
|
2592
|
+
execArgv = [],
|
|
2593
|
+
name = 'child process',
|
|
2594
|
+
path,
|
|
2595
|
+
stdio = 'inherit'
|
|
2596
|
+
}) => {
|
|
2597
|
+
try {
|
|
2598
|
+
string(path);
|
|
2599
|
+
const actualArgv = ['--ipc-type=node-forked-process', ...argv];
|
|
2600
|
+
const {
|
|
2601
|
+
fork
|
|
2602
|
+
} = await import('node:child_process');
|
|
2603
|
+
const childProcess = fork(path, actualArgv, {
|
|
2604
|
+
env,
|
|
2605
|
+
execArgv,
|
|
2606
|
+
stdio: 'pipe'
|
|
2607
|
+
});
|
|
2608
|
+
const {
|
|
2609
|
+
event,
|
|
2610
|
+
stderr,
|
|
2611
|
+
type
|
|
2612
|
+
} = await getFirstNodeChildProcessEvent(childProcess);
|
|
2613
|
+
if (type === Exit) {
|
|
2614
|
+
throw new ChildProcessError(stderr);
|
|
2615
|
+
}
|
|
2616
|
+
if (type === Error$2) {
|
|
2617
|
+
throw new IpcError(`child process had an error ${event}`);
|
|
2618
|
+
}
|
|
2619
|
+
if (stdio === 'inherit' && childProcess.stdout && childProcess.stderr) {
|
|
2620
|
+
childProcess.stdout.pipe(process.stdout);
|
|
2621
|
+
childProcess.stderr.pipe(process.stderr);
|
|
2622
|
+
}
|
|
2623
|
+
return childProcess;
|
|
2624
|
+
} catch (error) {
|
|
2625
|
+
throw new VError(error, `Failed to launch ${name}`);
|
|
2626
|
+
}
|
|
2627
|
+
};
|
|
2628
|
+
class IpcParentWithNodeForkedProcess extends Ipc {
|
|
2629
|
+
constructor(childProcess) {
|
|
2630
|
+
super(childProcess);
|
|
2631
|
+
this.pid = childProcess.pid;
|
|
2632
|
+
}
|
|
2633
|
+
getData(message) {
|
|
2634
|
+
return message;
|
|
2635
|
+
}
|
|
2636
|
+
send(message) {
|
|
2637
|
+
this._rawIpc.send(message);
|
|
2638
|
+
}
|
|
2639
|
+
sendAndTransfer(message) {
|
|
2640
|
+
const {
|
|
2641
|
+
newValue,
|
|
2642
|
+
transfer
|
|
2643
|
+
} = fixNodeChildProcessParameters(message);
|
|
2644
|
+
this._rawIpc.send(newValue, transfer);
|
|
2645
|
+
}
|
|
2646
|
+
dispose() {
|
|
2647
|
+
this._rawIpc.kill();
|
|
2648
|
+
}
|
|
2649
|
+
onClose(callback) {
|
|
2650
|
+
this._rawIpc.on('close', callback);
|
|
2651
|
+
}
|
|
2652
|
+
onMessage(callback) {
|
|
2653
|
+
this._rawIpc.on('message', callback);
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
const wrap$2 = childProcess => {
|
|
2657
|
+
return new IpcParentWithNodeForkedProcess(childProcess);
|
|
2658
|
+
};
|
|
2659
|
+
const IpcParentWithNodeForkedProcess$1 = {
|
|
2660
|
+
__proto__: null,
|
|
2661
|
+
create: create$2$2,
|
|
2662
|
+
wrap: wrap$2
|
|
2663
|
+
};
|
|
2664
|
+
const fixNodeWorkerParameters = value => {
|
|
2665
|
+
const transfer = getTransferrables(value);
|
|
2666
|
+
if (transfer.length === 0) {
|
|
2667
|
+
throw new IpcError('no transferrables found');
|
|
2668
|
+
}
|
|
2669
|
+
return {
|
|
2670
|
+
newValue: value,
|
|
2671
|
+
transfer: transfer
|
|
2672
|
+
};
|
|
2673
|
+
};
|
|
2674
|
+
const getFirstNodeWorkerEvent = worker => {
|
|
2675
|
+
return getFirstEvent(worker, {
|
|
2676
|
+
error: Error$2,
|
|
2677
|
+
exit: Exit,
|
|
2678
|
+
message: Message$1
|
|
2679
|
+
});
|
|
2680
|
+
};
|
|
2681
|
+
const create$1$2 = async ({
|
|
2682
|
+
argv = [],
|
|
2683
|
+
env = process.env,
|
|
2684
|
+
execArgv = [],
|
|
2685
|
+
name,
|
|
2686
|
+
path,
|
|
2687
|
+
stdio
|
|
2688
|
+
}) => {
|
|
2689
|
+
string(path);
|
|
2690
|
+
const actualArgv = ['--ipc-type=node-worker', ...argv];
|
|
2691
|
+
const actualEnv = {
|
|
2692
|
+
...env,
|
|
2693
|
+
ELECTRON_RUN_AS_NODE: '1'
|
|
2694
|
+
};
|
|
2695
|
+
const ignoreStdio = stdio === 'inherit' ? undefined : true;
|
|
2696
|
+
const {
|
|
2697
|
+
Worker
|
|
2698
|
+
} = await import('node:worker_threads');
|
|
2699
|
+
const worker = new Worker(path, {
|
|
2700
|
+
argv: actualArgv,
|
|
2701
|
+
env: actualEnv,
|
|
2702
|
+
execArgv,
|
|
2703
|
+
name,
|
|
2704
|
+
stderr: ignoreStdio,
|
|
2705
|
+
stdout: ignoreStdio
|
|
2706
|
+
});
|
|
2707
|
+
const {
|
|
2708
|
+
event,
|
|
2709
|
+
type
|
|
2710
|
+
} = await getFirstNodeWorkerEvent(worker);
|
|
2711
|
+
if (type === Exit) {
|
|
2712
|
+
throw new IpcError(`Worker exited before ipc connection was established`);
|
|
2713
|
+
}
|
|
2714
|
+
if (type === Error$2) {
|
|
2715
|
+
throw new IpcError(`Worker threw an error before ipc connection was established: ${event}`);
|
|
2716
|
+
}
|
|
2717
|
+
if (event !== readyMessage) {
|
|
2718
|
+
throw new IpcError('unexpected first message from worker');
|
|
2719
|
+
}
|
|
2720
|
+
return worker;
|
|
2721
|
+
};
|
|
2722
|
+
class IpcParentWithNodeWorker extends Ipc {
|
|
2723
|
+
getData(message) {
|
|
2724
|
+
return message;
|
|
2725
|
+
}
|
|
2726
|
+
send(message) {
|
|
2727
|
+
this._rawIpc.postMessage(message);
|
|
2728
|
+
}
|
|
2729
|
+
sendAndTransfer(message) {
|
|
2730
|
+
const {
|
|
2731
|
+
newValue,
|
|
2732
|
+
transfer
|
|
2733
|
+
} = fixNodeWorkerParameters(message);
|
|
2734
|
+
this._rawIpc.postMessage(newValue, transfer);
|
|
2735
|
+
}
|
|
2736
|
+
async dispose() {
|
|
2737
|
+
await this._rawIpc.terminate();
|
|
2738
|
+
}
|
|
2739
|
+
onClose(callback) {
|
|
2740
|
+
this._rawIpc.on('exit', callback);
|
|
2741
|
+
}
|
|
2742
|
+
onMessage(callback) {
|
|
2743
|
+
this._rawIpc.on('message', callback);
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
const wrap$1 = worker => {
|
|
2747
|
+
return new IpcParentWithNodeWorker(worker);
|
|
2748
|
+
};
|
|
2749
|
+
const IpcParentWithNodeWorker$1 = {
|
|
2750
|
+
__proto__: null,
|
|
2751
|
+
create: create$1$2,
|
|
2752
|
+
wrap: wrap$1
|
|
2753
|
+
};
|
|
2754
|
+
|
|
2755
|
+
class CommandNotFoundError extends Error {
|
|
2756
|
+
constructor(command) {
|
|
2757
|
+
super(`Command not found ${command}`);
|
|
2758
|
+
this.name = 'CommandNotFoundError';
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
const commands = Object.create(null);
|
|
2762
|
+
const register = commandMap => {
|
|
2763
|
+
Object.assign(commands, commandMap);
|
|
2764
|
+
};
|
|
2765
|
+
const getCommand = key => {
|
|
2766
|
+
return commands[key];
|
|
2767
|
+
};
|
|
2768
|
+
const execute$1 = (command, ...args) => {
|
|
2769
|
+
const fn = getCommand(command);
|
|
2770
|
+
if (!fn) {
|
|
2771
|
+
throw new CommandNotFoundError(command);
|
|
2772
|
+
}
|
|
2773
|
+
return fn(...args);
|
|
2774
|
+
};
|
|
2775
|
+
|
|
2776
|
+
const Two$1 = '2.0';
|
|
2777
|
+
const callbacks = Object.create(null);
|
|
2778
|
+
const set$2 = (id, fn) => {
|
|
2779
|
+
callbacks[id] = fn;
|
|
2251
2780
|
};
|
|
2252
2781
|
const get$4 = id => {
|
|
2253
2782
|
return callbacks[id];
|
|
@@ -2293,7 +2822,7 @@ class JsonRpcError extends Error {
|
|
|
2293
2822
|
this.name = 'JsonRpcError';
|
|
2294
2823
|
}
|
|
2295
2824
|
}
|
|
2296
|
-
const NewLine
|
|
2825
|
+
const NewLine = '\n';
|
|
2297
2826
|
const DomException = 'DOMException';
|
|
2298
2827
|
const ReferenceError$1 = 'ReferenceError';
|
|
2299
2828
|
const SyntaxError$1 = 'SyntaxError';
|
|
@@ -2338,78 +2867,102 @@ const constructError = (message, type, name) => {
|
|
|
2338
2867
|
}
|
|
2339
2868
|
return new ErrorConstructor(message);
|
|
2340
2869
|
};
|
|
2341
|
-
const joinLines
|
|
2342
|
-
return lines.join(NewLine
|
|
2870
|
+
const joinLines = lines => {
|
|
2871
|
+
return lines.join(NewLine);
|
|
2343
2872
|
};
|
|
2344
|
-
const splitLines
|
|
2345
|
-
return lines.split(NewLine
|
|
2873
|
+
const splitLines = lines => {
|
|
2874
|
+
return lines.split(NewLine);
|
|
2346
2875
|
};
|
|
2347
2876
|
const getCurrentStack = () => {
|
|
2348
2877
|
const stackLinesToSkip = 3;
|
|
2349
|
-
const currentStack = joinLines
|
|
2878
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
2350
2879
|
return currentStack;
|
|
2351
2880
|
};
|
|
2352
|
-
const getNewLineIndex = (string, startIndex
|
|
2353
|
-
|
|
2881
|
+
const getNewLineIndex = (string, startIndex) => {
|
|
2882
|
+
{
|
|
2883
|
+
return string.indexOf(NewLine);
|
|
2884
|
+
}
|
|
2354
2885
|
};
|
|
2355
2886
|
const getParentStack = error => {
|
|
2356
2887
|
let parentStack = error.stack || error.data || error.message || '';
|
|
2357
2888
|
if (parentStack.startsWith(' at')) {
|
|
2358
|
-
parentStack = error.message + NewLine
|
|
2889
|
+
parentStack = error.message + NewLine + parentStack;
|
|
2359
2890
|
}
|
|
2360
2891
|
return parentStack;
|
|
2361
2892
|
};
|
|
2362
2893
|
const MethodNotFound = -32601;
|
|
2363
2894
|
const Custom = -32001;
|
|
2895
|
+
const restoreExistingError = (error, currentStack) => {
|
|
2896
|
+
if (typeof error.stack === 'string') {
|
|
2897
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
2898
|
+
}
|
|
2899
|
+
return error;
|
|
2900
|
+
};
|
|
2901
|
+
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
2902
|
+
const restoredError = new JsonRpcError(error.message);
|
|
2903
|
+
const parentStack = getParentStack(error);
|
|
2904
|
+
restoredError.stack = parentStack + NewLine + currentStack;
|
|
2905
|
+
return restoredError;
|
|
2906
|
+
};
|
|
2907
|
+
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
2908
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
2909
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
2910
|
+
return;
|
|
2911
|
+
}
|
|
2912
|
+
if (error.data.stack) {
|
|
2913
|
+
restoredError.stack = error.data.stack;
|
|
2914
|
+
}
|
|
2915
|
+
};
|
|
2916
|
+
const applyDataProperties = (restoredError, error) => {
|
|
2917
|
+
if (!error.data) {
|
|
2918
|
+
return;
|
|
2919
|
+
}
|
|
2920
|
+
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
2921
|
+
if (error.data.codeFrame) {
|
|
2922
|
+
// @ts-ignore
|
|
2923
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
2924
|
+
}
|
|
2925
|
+
if (error.data.code) {
|
|
2926
|
+
// @ts-ignore
|
|
2927
|
+
restoredError.code = error.data.code;
|
|
2928
|
+
}
|
|
2929
|
+
if (error.data.type) {
|
|
2930
|
+
// @ts-ignore
|
|
2931
|
+
restoredError.name = error.data.type;
|
|
2932
|
+
}
|
|
2933
|
+
};
|
|
2934
|
+
const applyDirectProperties = (restoredError, error) => {
|
|
2935
|
+
if (error.stack) {
|
|
2936
|
+
const lowerStack = restoredError.stack || '';
|
|
2937
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
2938
|
+
const parentStack = getParentStack(error);
|
|
2939
|
+
// @ts-ignore
|
|
2940
|
+
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
2941
|
+
}
|
|
2942
|
+
if (error.codeFrame) {
|
|
2943
|
+
// @ts-ignore
|
|
2944
|
+
restoredError.codeFrame = error.codeFrame;
|
|
2945
|
+
}
|
|
2946
|
+
};
|
|
2947
|
+
const restoreMessageError = (error, _currentStack) => {
|
|
2948
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
2949
|
+
if (error.data) {
|
|
2950
|
+
applyDataProperties(restoredError, error);
|
|
2951
|
+
} else {
|
|
2952
|
+
applyDirectProperties(restoredError, error);
|
|
2953
|
+
}
|
|
2954
|
+
return restoredError;
|
|
2955
|
+
};
|
|
2364
2956
|
const restoreJsonRpcError = error => {
|
|
2365
2957
|
const currentStack = getCurrentStack();
|
|
2366
2958
|
if (error && error instanceof Error) {
|
|
2367
|
-
|
|
2368
|
-
error.stack = error.stack + NewLine$1 + currentStack;
|
|
2369
|
-
}
|
|
2370
|
-
return error;
|
|
2959
|
+
return restoreExistingError(error, currentStack);
|
|
2371
2960
|
}
|
|
2372
2961
|
if (error && error.code && error.code === MethodNotFound) {
|
|
2373
|
-
|
|
2374
|
-
const parentStack = getParentStack(error);
|
|
2375
|
-
restoredError.stack = parentStack + NewLine$1 + currentStack;
|
|
2376
|
-
return restoredError;
|
|
2962
|
+
return restoreMethodNotFoundError(error, currentStack);
|
|
2377
2963
|
}
|
|
2378
2964
|
if (error && error.message) {
|
|
2379
|
-
|
|
2380
|
-
if (error.data) {
|
|
2381
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
2382
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine$1 + error.data.stack + NewLine$1 + currentStack;
|
|
2383
|
-
} else if (error.data.stack) {
|
|
2384
|
-
restoredError.stack = error.data.stack;
|
|
2385
|
-
}
|
|
2386
|
-
if (error.data.codeFrame) {
|
|
2387
|
-
// @ts-ignore
|
|
2388
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
2389
|
-
}
|
|
2390
|
-
if (error.data.code) {
|
|
2391
|
-
// @ts-ignore
|
|
2392
|
-
restoredError.code = error.data.code;
|
|
2393
|
-
}
|
|
2394
|
-
if (error.data.type) {
|
|
2395
|
-
// @ts-ignore
|
|
2396
|
-
restoredError.name = error.data.type;
|
|
2397
|
-
}
|
|
2398
|
-
} else {
|
|
2399
|
-
if (error.stack) {
|
|
2400
|
-
const lowerStack = restoredError.stack || '';
|
|
2401
|
-
// @ts-ignore
|
|
2402
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
2403
|
-
const parentStack = getParentStack(error);
|
|
2404
|
-
// @ts-ignore
|
|
2405
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
2406
|
-
}
|
|
2407
|
-
if (error.codeFrame) {
|
|
2408
|
-
// @ts-ignore
|
|
2409
|
-
restoredError.codeFrame = error.codeFrame;
|
|
2410
|
-
}
|
|
2411
|
-
}
|
|
2412
|
-
return restoredError;
|
|
2965
|
+
return restoreMessageError(error);
|
|
2413
2966
|
}
|
|
2414
2967
|
if (typeof error === 'string') {
|
|
2415
2968
|
return new Error(`JsonRpc Error: ${error}`);
|
|
@@ -2480,7 +3033,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
2480
3033
|
message: prettyError.message
|
|
2481
3034
|
};
|
|
2482
3035
|
};
|
|
2483
|
-
const create$1$
|
|
3036
|
+
const create$1$1 = (id, error) => {
|
|
2484
3037
|
return {
|
|
2485
3038
|
error,
|
|
2486
3039
|
id,
|
|
@@ -2491,9 +3044,9 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
2491
3044
|
const prettyError = preparePrettyError(error);
|
|
2492
3045
|
logError(error, prettyError);
|
|
2493
3046
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
2494
|
-
return create$1$
|
|
3047
|
+
return create$1$1(id, errorProperty);
|
|
2495
3048
|
};
|
|
2496
|
-
const create$
|
|
3049
|
+
const create$9 = (message, result) => {
|
|
2497
3050
|
return {
|
|
2498
3051
|
id: message.id,
|
|
2499
3052
|
jsonrpc: Two$1,
|
|
@@ -2502,7 +3055,7 @@ const create$c = (message, result) => {
|
|
|
2502
3055
|
};
|
|
2503
3056
|
const getSuccessResponse = (message, result) => {
|
|
2504
3057
|
const resultProperty = result ?? null;
|
|
2505
|
-
return create$
|
|
3058
|
+
return create$9(message, resultProperty);
|
|
2506
3059
|
};
|
|
2507
3060
|
const getErrorResponseSimple = (id, error) => {
|
|
2508
3061
|
return {
|
|
@@ -2612,7 +3165,7 @@ const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
|
2612
3165
|
|
|
2613
3166
|
const Two = '2.0';
|
|
2614
3167
|
|
|
2615
|
-
const create$
|
|
3168
|
+
const create$8 = (method, params) => {
|
|
2616
3169
|
return {
|
|
2617
3170
|
jsonrpc: Two,
|
|
2618
3171
|
method,
|
|
@@ -2620,7 +3173,7 @@ const create$b = (method, params) => {
|
|
|
2620
3173
|
};
|
|
2621
3174
|
};
|
|
2622
3175
|
|
|
2623
|
-
const create$
|
|
3176
|
+
const create$7 = (id, method, params) => {
|
|
2624
3177
|
const message = {
|
|
2625
3178
|
id,
|
|
2626
3179
|
jsonrpc: Two,
|
|
@@ -2631,12 +3184,12 @@ const create$a = (id, method, params) => {
|
|
|
2631
3184
|
};
|
|
2632
3185
|
|
|
2633
3186
|
let id = 0;
|
|
2634
|
-
const create$
|
|
3187
|
+
const create$6 = () => {
|
|
2635
3188
|
return ++id;
|
|
2636
3189
|
};
|
|
2637
3190
|
|
|
2638
3191
|
const registerPromise = map => {
|
|
2639
|
-
const id = create$
|
|
3192
|
+
const id = create$6();
|
|
2640
3193
|
const {
|
|
2641
3194
|
promise,
|
|
2642
3195
|
resolve
|
|
@@ -2653,7 +3206,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
2653
3206
|
id,
|
|
2654
3207
|
promise
|
|
2655
3208
|
} = registerPromise(callbacks);
|
|
2656
|
-
const message = create$
|
|
3209
|
+
const message = create$7(id, method, params);
|
|
2657
3210
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
2658
3211
|
ipc.sendAndTransfer(message);
|
|
2659
3212
|
} else {
|
|
@@ -2689,7 +3242,7 @@ const createRpc = ipc => {
|
|
|
2689
3242
|
* @deprecated
|
|
2690
3243
|
*/
|
|
2691
3244
|
send(method, ...params) {
|
|
2692
|
-
const message = create$
|
|
3245
|
+
const message = create$8(method, params);
|
|
2693
3246
|
ipc.send(message);
|
|
2694
3247
|
}
|
|
2695
3248
|
};
|
|
@@ -2729,14 +3282,14 @@ const listen$1 = async (module, options) => {
|
|
|
2729
3282
|
return ipc;
|
|
2730
3283
|
};
|
|
2731
3284
|
|
|
2732
|
-
const create$
|
|
3285
|
+
const create$5 = async ({
|
|
2733
3286
|
commandMap,
|
|
2734
3287
|
messagePort,
|
|
2735
3288
|
requiresSocket
|
|
2736
3289
|
}) => {
|
|
2737
3290
|
// TODO create a commandMap per rpc instance
|
|
2738
3291
|
register(commandMap);
|
|
2739
|
-
const ipc = await listen$1(IpcChildWithElectronMessagePort$1
|
|
3292
|
+
const ipc = await listen$1(IpcChildWithElectronMessagePort$1, {
|
|
2740
3293
|
messagePort
|
|
2741
3294
|
});
|
|
2742
3295
|
if (requiresSocket) {
|
|
@@ -2747,7 +3300,7 @@ const create$8 = async ({
|
|
|
2747
3300
|
return rpc;
|
|
2748
3301
|
};
|
|
2749
3302
|
|
|
2750
|
-
const create$
|
|
3303
|
+
const create$4 = async ({
|
|
2751
3304
|
argv,
|
|
2752
3305
|
commandMap,
|
|
2753
3306
|
env,
|
|
@@ -2758,14 +3311,14 @@ const create$5 = async ({
|
|
|
2758
3311
|
}) => {
|
|
2759
3312
|
// TODO create a commandMap per rpc instance
|
|
2760
3313
|
register(commandMap);
|
|
2761
|
-
const rawIpc = await IpcParentWithElectronUtilityProcess$1$
|
|
3314
|
+
const rawIpc = await IpcParentWithElectronUtilityProcess$1$1.create({
|
|
2762
3315
|
argv,
|
|
2763
3316
|
env,
|
|
2764
3317
|
execArgv,
|
|
2765
3318
|
name,
|
|
2766
3319
|
path
|
|
2767
3320
|
});
|
|
2768
|
-
const ipc = IpcParentWithElectronUtilityProcess$1$
|
|
3321
|
+
const ipc = IpcParentWithElectronUtilityProcess$1$1.wrap(rawIpc);
|
|
2769
3322
|
if (requiresSocket) {
|
|
2770
3323
|
// @ts-ignore
|
|
2771
3324
|
ipc.requiresSocket = requiresSocket;
|
|
@@ -2775,14 +3328,14 @@ const create$5 = async ({
|
|
|
2775
3328
|
return rpc;
|
|
2776
3329
|
};
|
|
2777
3330
|
|
|
2778
|
-
const create$
|
|
3331
|
+
const create$3 = async ({
|
|
2779
3332
|
commandMap,
|
|
2780
3333
|
requiresSocket,
|
|
2781
3334
|
webContents
|
|
2782
3335
|
}) => {
|
|
2783
3336
|
// TODO create a commandMap per rpc instance
|
|
2784
3337
|
register(commandMap);
|
|
2785
|
-
const ipc = IpcChildWithRendererProcess2$1
|
|
3338
|
+
const ipc = IpcChildWithRendererProcess2$1.wrap(webContents);
|
|
2786
3339
|
if (requiresSocket) {
|
|
2787
3340
|
// @ts-ignore
|
|
2788
3341
|
ipc.requiresSocket = requiresSocket;
|
|
@@ -2860,7 +3413,7 @@ const trackUtilityProcess = (rawIpc, name) => {
|
|
|
2860
3413
|
};
|
|
2861
3414
|
|
|
2862
3415
|
const createElectronUtilityProcessRpc = async options => {
|
|
2863
|
-
const rpc = await create$
|
|
3416
|
+
const rpc = await create$4(options);
|
|
2864
3417
|
const rpcWithRawIpc = rpc;
|
|
2865
3418
|
trackUtilityProcess(rpcWithRawIpc.ipc?._rawIpc, options.name);
|
|
2866
3419
|
return rpc;
|
|
@@ -3005,7 +3558,7 @@ const launchSharedProcess = async ({
|
|
|
3005
3558
|
port2
|
|
3006
3559
|
} = getPortTuple();
|
|
3007
3560
|
await sharedProcessRpc.invokeAndTransfer('HandleElectronMessagePort.handleElectronMessagePort', port2, MainProcess);
|
|
3008
|
-
await create$
|
|
3561
|
+
await create$5({
|
|
3009
3562
|
commandMap: commandMapRef,
|
|
3010
3563
|
messagePort: port1,
|
|
3011
3564
|
requiresSocket: requiresSocket
|
|
@@ -3093,6 +3646,7 @@ const Wait = 'wait';
|
|
|
3093
3646
|
const BuiltinSelfTest = 'built-in-self-test';
|
|
3094
3647
|
const Web = 'web';
|
|
3095
3648
|
const SandBox = 'sandbox';
|
|
3649
|
+
const Prompt = 'prompt';
|
|
3096
3650
|
const Install = 'install';
|
|
3097
3651
|
const List = 'list';
|
|
3098
3652
|
const Link = 'link';
|
|
@@ -3455,7 +4009,8 @@ const parseCliArgs = argv => {
|
|
|
3455
4009
|
boolean: [Version, Help, Wait, BuiltinSelfTest, Web, SandBox],
|
|
3456
4010
|
default: {
|
|
3457
4011
|
sandbox: false
|
|
3458
|
-
}
|
|
4012
|
+
},
|
|
4013
|
+
string: [Prompt]
|
|
3459
4014
|
};
|
|
3460
4015
|
const relevantArgv = argv.slice(1);
|
|
3461
4016
|
const parsedArgs = minimist(relevantArgv, CLI_OPTIONS);
|
|
@@ -3576,6 +4131,10 @@ const handleWindowAllClosed = async () => {
|
|
|
3576
4131
|
await send$1('HandleWindowAllClosed.handleWindowAllClosed');
|
|
3577
4132
|
};
|
|
3578
4133
|
|
|
4134
|
+
const isPromptMode = parsedArgs => {
|
|
4135
|
+
return typeof parsedArgs.prompt === 'string';
|
|
4136
|
+
};
|
|
4137
|
+
|
|
3579
4138
|
const isProtocolHandleApiSupported = protocol => {
|
|
3580
4139
|
return !!protocol.handle;
|
|
3581
4140
|
};
|
|
@@ -3640,6 +4199,7 @@ const hydrate = async (isLinux, chromeUserDataPath, argv) => {
|
|
|
3640
4199
|
// see https://github.com/microsoft/playwright/issues/12345
|
|
3641
4200
|
|
|
3642
4201
|
const parsedCliArgs = parseCliArgs(argv);
|
|
4202
|
+
const isPromptMode$1 = isPromptMode(parsedCliArgs);
|
|
3643
4203
|
const moduleId = canHandleFastCliArgs(parsedCliArgs);
|
|
3644
4204
|
if (moduleId) {
|
|
3645
4205
|
await handleFastCliArgs(moduleId, parsedCliArgs);
|
|
@@ -3651,14 +4211,16 @@ const hydrate = async (isLinux, chromeUserDataPath, argv) => {
|
|
|
3651
4211
|
setCrashDumpsPath(chromeUserDataPath);
|
|
3652
4212
|
setLogsPath(chromeUserDataPath);
|
|
3653
4213
|
}
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
4214
|
+
if (!isPromptMode$1) {
|
|
4215
|
+
const hasLock = requestSingleInstanceLock(argv);
|
|
4216
|
+
if (!hasLock) {
|
|
4217
|
+
exit();
|
|
4218
|
+
return;
|
|
4219
|
+
}
|
|
3658
4220
|
}
|
|
3659
4221
|
|
|
3660
4222
|
// TODO tree shake out the .env.DEV check: reading from env variables is expensive
|
|
3661
|
-
if (process.stdout.isTTY && !parsedCliArgs.wait && !process.env.DEV) {
|
|
4223
|
+
if (process.stdout.isTTY && !parsedCliArgs.wait && !isPromptMode$1 && !process.env.DEV) {
|
|
3662
4224
|
spawn(execPath, argv.slice(1), {
|
|
3663
4225
|
detached: true,
|
|
3664
4226
|
stdio: 'ignore'
|
|
@@ -3863,7 +4425,7 @@ const set$1 = value => {
|
|
|
3863
4425
|
state$1.session = value;
|
|
3864
4426
|
};
|
|
3865
4427
|
|
|
3866
|
-
const create$
|
|
4428
|
+
const create$2 = rpc => {
|
|
3867
4429
|
const handleRequest = async request => {
|
|
3868
4430
|
const {
|
|
3869
4431
|
method,
|
|
@@ -3886,13 +4448,13 @@ const get$1 = () => {
|
|
|
3886
4448
|
};
|
|
3887
4449
|
const registerWebviewProtocol = async port => {
|
|
3888
4450
|
object(port);
|
|
3889
|
-
const rpc = await create$
|
|
4451
|
+
const rpc = await create$5({
|
|
3890
4452
|
commandMap: {},
|
|
3891
4453
|
messagePort: port,
|
|
3892
4454
|
requiresSocket: requiresSocket
|
|
3893
4455
|
});
|
|
3894
4456
|
const session = get$1();
|
|
3895
|
-
const handleRequest = create$
|
|
4457
|
+
const handleRequest = create$2(rpc);
|
|
3896
4458
|
handle(session.protocol, WebView, handleRequest);
|
|
3897
4459
|
};
|
|
3898
4460
|
|
|
@@ -3956,7 +4518,9 @@ const createAppWindow = async (windowOptions, parsedArgs, workingDirectory, titl
|
|
|
3956
4518
|
// window .webContents.setZoomLevel(zoomLevel)
|
|
3957
4519
|
window.show();
|
|
3958
4520
|
};
|
|
3959
|
-
|
|
4521
|
+
if (!isPromptMode(parsedArgs)) {
|
|
4522
|
+
window.once('ready-to-show', handleReadyToShow);
|
|
4523
|
+
}
|
|
3960
4524
|
// TODO query applicarion menu items from shared process
|
|
3961
4525
|
const menu = createTitleBar(titleBarItems);
|
|
3962
4526
|
setMenu(menu);
|
|
@@ -3973,7 +4537,7 @@ const createAppWindow = async (windowOptions, parsedArgs, workingDirectory, titl
|
|
|
3973
4537
|
}
|
|
3974
4538
|
};
|
|
3975
4539
|
window.on('close', handleWindowClose);
|
|
3976
|
-
await create$
|
|
4540
|
+
await create$3({
|
|
3977
4541
|
commandMap: commandMapRef,
|
|
3978
4542
|
webContents: window.webContents
|
|
3979
4543
|
});
|
|
@@ -5729,991 +6293,6 @@ const unhandleIpc = ipc => {
|
|
|
5729
6293
|
}
|
|
5730
6294
|
};
|
|
5731
6295
|
|
|
5732
|
-
const isMessagePort = value => {
|
|
5733
|
-
return value && value instanceof MessagePort;
|
|
5734
|
-
};
|
|
5735
|
-
const isMessagePortMain = value => {
|
|
5736
|
-
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
5737
|
-
};
|
|
5738
|
-
const isOffscreenCanvas = value => {
|
|
5739
|
-
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
5740
|
-
};
|
|
5741
|
-
const isInstanceOf = (value, constructorName) => {
|
|
5742
|
-
return value?.constructor?.name === constructorName;
|
|
5743
|
-
};
|
|
5744
|
-
const isSocket = value => {
|
|
5745
|
-
return isInstanceOf(value, 'Socket');
|
|
5746
|
-
};
|
|
5747
|
-
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
5748
|
-
const isTransferrable = value => {
|
|
5749
|
-
for (const fn of transferrables) {
|
|
5750
|
-
if (fn(value)) {
|
|
5751
|
-
return true;
|
|
5752
|
-
}
|
|
5753
|
-
}
|
|
5754
|
-
return false;
|
|
5755
|
-
};
|
|
5756
|
-
const walkValue = (value, transferrables, isTransferrable) => {
|
|
5757
|
-
if (!value) {
|
|
5758
|
-
return;
|
|
5759
|
-
}
|
|
5760
|
-
if (isTransferrable(value)) {
|
|
5761
|
-
transferrables.push(value);
|
|
5762
|
-
return;
|
|
5763
|
-
}
|
|
5764
|
-
if (Array.isArray(value)) {
|
|
5765
|
-
for (const item of value) {
|
|
5766
|
-
walkValue(item, transferrables, isTransferrable);
|
|
5767
|
-
}
|
|
5768
|
-
return;
|
|
5769
|
-
}
|
|
5770
|
-
if (typeof value === 'object') {
|
|
5771
|
-
for (const property of Object.values(value)) {
|
|
5772
|
-
walkValue(property, transferrables, isTransferrable);
|
|
5773
|
-
}
|
|
5774
|
-
}
|
|
5775
|
-
};
|
|
5776
|
-
const getTransferrables = value => {
|
|
5777
|
-
const transferrables = [];
|
|
5778
|
-
walkValue(value, transferrables, isTransferrable);
|
|
5779
|
-
return transferrables;
|
|
5780
|
-
};
|
|
5781
|
-
const removeValues = (value, toRemove) => {
|
|
5782
|
-
if (!value) {
|
|
5783
|
-
return value;
|
|
5784
|
-
}
|
|
5785
|
-
if (Array.isArray(value)) {
|
|
5786
|
-
const newItems = [];
|
|
5787
|
-
for (const item of value) {
|
|
5788
|
-
if (!toRemove.includes(item)) {
|
|
5789
|
-
newItems.push(removeValues(item, toRemove));
|
|
5790
|
-
}
|
|
5791
|
-
}
|
|
5792
|
-
return newItems;
|
|
5793
|
-
}
|
|
5794
|
-
if (typeof value === 'object') {
|
|
5795
|
-
const newObject = Object.create(null);
|
|
5796
|
-
for (const [key, property] of Object.entries(value)) {
|
|
5797
|
-
if (!toRemove.includes(property)) {
|
|
5798
|
-
newObject[key] = removeValues(property, toRemove);
|
|
5799
|
-
}
|
|
5800
|
-
}
|
|
5801
|
-
return newObject;
|
|
5802
|
-
}
|
|
5803
|
-
return value;
|
|
5804
|
-
};
|
|
5805
|
-
|
|
5806
|
-
// workaround for electron not supporting transferrable objects
|
|
5807
|
-
// as parameters. If the transferrable object is a parameter, in electron
|
|
5808
|
-
// only an empty objected is received in the main process
|
|
5809
|
-
const fixElectronParameters = value => {
|
|
5810
|
-
const transfer = getTransferrables(value);
|
|
5811
|
-
const newValue = removeValues(value, transfer);
|
|
5812
|
-
return {
|
|
5813
|
-
newValue,
|
|
5814
|
-
transfer
|
|
5815
|
-
};
|
|
5816
|
-
};
|
|
5817
|
-
const getActualDataElectron = event => {
|
|
5818
|
-
const {
|
|
5819
|
-
data,
|
|
5820
|
-
ports
|
|
5821
|
-
} = event;
|
|
5822
|
-
if (ports.length === 0) {
|
|
5823
|
-
return data;
|
|
5824
|
-
}
|
|
5825
|
-
return {
|
|
5826
|
-
...data,
|
|
5827
|
-
params: [...ports, ...data.params]
|
|
5828
|
-
};
|
|
5829
|
-
};
|
|
5830
|
-
const attachEvents = that => {
|
|
5831
|
-
const handleMessage = (...args) => {
|
|
5832
|
-
const data = that.getData(...args);
|
|
5833
|
-
that.dispatchEvent(new MessageEvent('message', {
|
|
5834
|
-
data
|
|
5835
|
-
}));
|
|
5836
|
-
};
|
|
5837
|
-
that.onMessage(handleMessage);
|
|
5838
|
-
const handleClose = event => {
|
|
5839
|
-
that.dispatchEvent(new Event('close'));
|
|
5840
|
-
};
|
|
5841
|
-
that.onClose(handleClose);
|
|
5842
|
-
};
|
|
5843
|
-
class Ipc extends EventTarget {
|
|
5844
|
-
constructor(rawIpc) {
|
|
5845
|
-
super();
|
|
5846
|
-
this._rawIpc = rawIpc;
|
|
5847
|
-
attachEvents(this);
|
|
5848
|
-
}
|
|
5849
|
-
}
|
|
5850
|
-
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
5851
|
-
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
5852
|
-
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
5853
|
-
const NewLine = '\n';
|
|
5854
|
-
const joinLines = lines => {
|
|
5855
|
-
return lines.join(NewLine);
|
|
5856
|
-
};
|
|
5857
|
-
const RE_AT = /^\s+at/;
|
|
5858
|
-
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
5859
|
-
const isNormalStackLine = line => {
|
|
5860
|
-
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
5861
|
-
};
|
|
5862
|
-
const getDetails = lines => {
|
|
5863
|
-
const index = lines.findIndex(isNormalStackLine);
|
|
5864
|
-
if (index === -1) {
|
|
5865
|
-
return {
|
|
5866
|
-
actualMessage: joinLines(lines),
|
|
5867
|
-
rest: []
|
|
5868
|
-
};
|
|
5869
|
-
}
|
|
5870
|
-
let lastIndex = index - 1;
|
|
5871
|
-
while (++lastIndex < lines.length) {
|
|
5872
|
-
if (!isNormalStackLine(lines[lastIndex])) {
|
|
5873
|
-
break;
|
|
5874
|
-
}
|
|
5875
|
-
}
|
|
5876
|
-
return {
|
|
5877
|
-
actualMessage: lines[index - 1],
|
|
5878
|
-
rest: lines.slice(index, lastIndex)
|
|
5879
|
-
};
|
|
5880
|
-
};
|
|
5881
|
-
const splitLines = lines => {
|
|
5882
|
-
return lines.split(NewLine);
|
|
5883
|
-
};
|
|
5884
|
-
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
5885
|
-
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
5886
|
-
const isMessageCodeBlockStartIndex = line => {
|
|
5887
|
-
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
5888
|
-
};
|
|
5889
|
-
const isMessageCodeBlockEndIndex = line => {
|
|
5890
|
-
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
5891
|
-
};
|
|
5892
|
-
const getMessageCodeBlock = stderr => {
|
|
5893
|
-
const lines = splitLines(stderr);
|
|
5894
|
-
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
5895
|
-
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
5896
|
-
const relevantLines = lines.slice(startIndex, endIndex);
|
|
5897
|
-
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
5898
|
-
return relevantMessage;
|
|
5899
|
-
};
|
|
5900
|
-
const isModuleNotFoundMessage = line => {
|
|
5901
|
-
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
5902
|
-
};
|
|
5903
|
-
const getModuleNotFoundError = stderr => {
|
|
5904
|
-
const lines = splitLines(stderr);
|
|
5905
|
-
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
5906
|
-
const message = lines[messageIndex];
|
|
5907
|
-
return {
|
|
5908
|
-
code: ERR_MODULE_NOT_FOUND,
|
|
5909
|
-
message
|
|
5910
|
-
};
|
|
5911
|
-
};
|
|
5912
|
-
const isModuleNotFoundError = stderr => {
|
|
5913
|
-
if (!stderr) {
|
|
5914
|
-
return false;
|
|
5915
|
-
}
|
|
5916
|
-
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
5917
|
-
};
|
|
5918
|
-
const isModulesSyntaxError = stderr => {
|
|
5919
|
-
if (!stderr) {
|
|
5920
|
-
return false;
|
|
5921
|
-
}
|
|
5922
|
-
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
5923
|
-
};
|
|
5924
|
-
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
5925
|
-
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
5926
|
-
const isUnhelpfulNativeModuleError = stderr => {
|
|
5927
|
-
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
5928
|
-
};
|
|
5929
|
-
const getNativeModuleErrorMessage = stderr => {
|
|
5930
|
-
const message = getMessageCodeBlock(stderr);
|
|
5931
|
-
return {
|
|
5932
|
-
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
5933
|
-
message: `Incompatible native node module: ${message}`
|
|
5934
|
-
};
|
|
5935
|
-
};
|
|
5936
|
-
const getModuleSyntaxError = () => {
|
|
5937
|
-
return {
|
|
5938
|
-
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
5939
|
-
message: `ES Modules are not supported in electron`
|
|
5940
|
-
};
|
|
5941
|
-
};
|
|
5942
|
-
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
5943
|
-
if (isUnhelpfulNativeModuleError(stderr)) {
|
|
5944
|
-
return getNativeModuleErrorMessage(stderr);
|
|
5945
|
-
}
|
|
5946
|
-
if (isModulesSyntaxError(stderr)) {
|
|
5947
|
-
return getModuleSyntaxError();
|
|
5948
|
-
}
|
|
5949
|
-
if (isModuleNotFoundError(stderr)) {
|
|
5950
|
-
return getModuleNotFoundError(stderr);
|
|
5951
|
-
}
|
|
5952
|
-
const lines = splitLines(stderr);
|
|
5953
|
-
const {
|
|
5954
|
-
actualMessage,
|
|
5955
|
-
rest
|
|
5956
|
-
} = getDetails(lines);
|
|
5957
|
-
return {
|
|
5958
|
-
code: '',
|
|
5959
|
-
message: actualMessage,
|
|
5960
|
-
stack: rest
|
|
5961
|
-
};
|
|
5962
|
-
};
|
|
5963
|
-
class IpcError extends VError {
|
|
5964
|
-
// @ts-ignore
|
|
5965
|
-
constructor(betterMessage, stdout = '', stderr = '') {
|
|
5966
|
-
if (stdout || stderr) {
|
|
5967
|
-
// @ts-ignore
|
|
5968
|
-
const {
|
|
5969
|
-
code,
|
|
5970
|
-
message,
|
|
5971
|
-
stack
|
|
5972
|
-
} = getHelpfulChildProcessError(stdout, stderr);
|
|
5973
|
-
const cause = new Error(message);
|
|
5974
|
-
// @ts-ignore
|
|
5975
|
-
cause.code = code;
|
|
5976
|
-
cause.stack = stack;
|
|
5977
|
-
super(cause, betterMessage);
|
|
5978
|
-
} else {
|
|
5979
|
-
super(betterMessage);
|
|
5980
|
-
}
|
|
5981
|
-
// @ts-ignore
|
|
5982
|
-
this.name = 'IpcError';
|
|
5983
|
-
// @ts-ignore
|
|
5984
|
-
this.stdout = stdout;
|
|
5985
|
-
// @ts-ignore
|
|
5986
|
-
this.stderr = stderr;
|
|
5987
|
-
}
|
|
5988
|
-
}
|
|
5989
|
-
const listen$b = ({
|
|
5990
|
-
messagePort
|
|
5991
|
-
}) => {
|
|
5992
|
-
if (!isMessagePortMain(messagePort)) {
|
|
5993
|
-
throw new IpcError('port must be of type MessagePortMain');
|
|
5994
|
-
}
|
|
5995
|
-
return messagePort;
|
|
5996
|
-
};
|
|
5997
|
-
const signal$c = messagePort => {
|
|
5998
|
-
messagePort.start();
|
|
5999
|
-
};
|
|
6000
|
-
class IpcChildWithElectronMessagePort extends Ipc {
|
|
6001
|
-
getData = getActualDataElectron;
|
|
6002
|
-
send(message) {
|
|
6003
|
-
this._rawIpc.postMessage(message);
|
|
6004
|
-
}
|
|
6005
|
-
sendAndTransfer(message) {
|
|
6006
|
-
const {
|
|
6007
|
-
newValue,
|
|
6008
|
-
transfer
|
|
6009
|
-
} = fixElectronParameters(message);
|
|
6010
|
-
this._rawIpc.postMessage(newValue, transfer);
|
|
6011
|
-
}
|
|
6012
|
-
dispose() {
|
|
6013
|
-
this._rawIpc.close();
|
|
6014
|
-
}
|
|
6015
|
-
onMessage(callback) {
|
|
6016
|
-
this._rawIpc.on('message', callback);
|
|
6017
|
-
}
|
|
6018
|
-
onClose(callback) {
|
|
6019
|
-
this._rawIpc.on('close', callback);
|
|
6020
|
-
}
|
|
6021
|
-
}
|
|
6022
|
-
const wrap$j = messagePort => {
|
|
6023
|
-
return new IpcChildWithElectronMessagePort(messagePort);
|
|
6024
|
-
};
|
|
6025
|
-
const IpcChildWithElectronMessagePort$1 = {
|
|
6026
|
-
__proto__: null,
|
|
6027
|
-
listen: listen$b,
|
|
6028
|
-
signal: signal$c,
|
|
6029
|
-
wrap: wrap$j
|
|
6030
|
-
};
|
|
6031
|
-
|
|
6032
|
-
// @ts-ignore
|
|
6033
|
-
const getUtilityProcessPortData = event => {
|
|
6034
|
-
const {
|
|
6035
|
-
data,
|
|
6036
|
-
ports
|
|
6037
|
-
} = event;
|
|
6038
|
-
if (ports.length === 0) {
|
|
6039
|
-
return data;
|
|
6040
|
-
}
|
|
6041
|
-
return {
|
|
6042
|
-
...data,
|
|
6043
|
-
params: [...ports, ...data.params]
|
|
6044
|
-
};
|
|
6045
|
-
};
|
|
6046
|
-
const readyMessage = 'ready';
|
|
6047
|
-
const listen$a = () => {
|
|
6048
|
-
// @ts-ignore
|
|
6049
|
-
const {
|
|
6050
|
-
parentPort
|
|
6051
|
-
} = process;
|
|
6052
|
-
if (!parentPort) {
|
|
6053
|
-
throw new IpcError('parent port must be defined');
|
|
6054
|
-
}
|
|
6055
|
-
return parentPort;
|
|
6056
|
-
};
|
|
6057
|
-
const signal$b = parentPort => {
|
|
6058
|
-
parentPort.postMessage(readyMessage);
|
|
6059
|
-
};
|
|
6060
|
-
class IpcChildWithElectronUtilityProcess extends Ipc {
|
|
6061
|
-
getData(event) {
|
|
6062
|
-
return getUtilityProcessPortData(event);
|
|
6063
|
-
}
|
|
6064
|
-
send(message) {
|
|
6065
|
-
this._rawIpc.postMessage(message);
|
|
6066
|
-
}
|
|
6067
|
-
sendAndTransfer(message) {
|
|
6068
|
-
const {
|
|
6069
|
-
newValue,
|
|
6070
|
-
transfer
|
|
6071
|
-
} = fixElectronParameters(message);
|
|
6072
|
-
this._rawIpc.postMessage(newValue, transfer);
|
|
6073
|
-
}
|
|
6074
|
-
dispose() {
|
|
6075
|
-
this._rawIpc.close();
|
|
6076
|
-
}
|
|
6077
|
-
onClose(callback) {
|
|
6078
|
-
this._rawIpc.on('close', callback);
|
|
6079
|
-
}
|
|
6080
|
-
onMessage(callback) {
|
|
6081
|
-
this._rawIpc.on('message', callback);
|
|
6082
|
-
}
|
|
6083
|
-
}
|
|
6084
|
-
const wrap$i = parentPort => {
|
|
6085
|
-
return new IpcChildWithElectronUtilityProcess(parentPort);
|
|
6086
|
-
};
|
|
6087
|
-
const IpcChildWithElectronUtilityProcess$1 = {
|
|
6088
|
-
__proto__: null,
|
|
6089
|
-
listen: listen$a,
|
|
6090
|
-
signal: signal$b,
|
|
6091
|
-
wrap: wrap$i
|
|
6092
|
-
};
|
|
6093
|
-
const getActualData = (message, handle) => {
|
|
6094
|
-
if (handle) {
|
|
6095
|
-
return {
|
|
6096
|
-
...message,
|
|
6097
|
-
params: [handle, ...message.params]
|
|
6098
|
-
};
|
|
6099
|
-
}
|
|
6100
|
-
return message;
|
|
6101
|
-
};
|
|
6102
|
-
const getTransferrablesNode = value => {
|
|
6103
|
-
const transferrables = getTransferrables(value);
|
|
6104
|
-
if (transferrables.length === 0) {
|
|
6105
|
-
throw new Error(`no transferrables found`);
|
|
6106
|
-
}
|
|
6107
|
-
return transferrables[0];
|
|
6108
|
-
};
|
|
6109
|
-
const listen$5 = async () => {
|
|
6110
|
-
if (!process.send) {
|
|
6111
|
-
throw new IpcError('process.send must be defined');
|
|
6112
|
-
}
|
|
6113
|
-
return process;
|
|
6114
|
-
};
|
|
6115
|
-
const signal$7 = process => {
|
|
6116
|
-
process.send(readyMessage);
|
|
6117
|
-
};
|
|
6118
|
-
class IpcChildWithNodeForkedProcess extends Ipc {
|
|
6119
|
-
getData(message, handle) {
|
|
6120
|
-
return getActualData(message, handle);
|
|
6121
|
-
}
|
|
6122
|
-
onClose(callback) {
|
|
6123
|
-
this._rawIpc.on('close', callback);
|
|
6124
|
-
}
|
|
6125
|
-
send(message) {
|
|
6126
|
-
this._rawIpc.send(message);
|
|
6127
|
-
}
|
|
6128
|
-
onMessage(callback) {
|
|
6129
|
-
this._rawIpc.on('message', callback);
|
|
6130
|
-
}
|
|
6131
|
-
sendAndTransfer(message) {
|
|
6132
|
-
const transfer = getTransferrablesNode(message);
|
|
6133
|
-
this._rawIpc.send(message, transfer);
|
|
6134
|
-
}
|
|
6135
|
-
dispose() {
|
|
6136
|
-
// ignore
|
|
6137
|
-
}
|
|
6138
|
-
}
|
|
6139
|
-
const wrap$d = process => {
|
|
6140
|
-
return new IpcChildWithNodeForkedProcess(process);
|
|
6141
|
-
};
|
|
6142
|
-
const IpcChildWithNodeForkedProcess$1 = {
|
|
6143
|
-
__proto__: null,
|
|
6144
|
-
listen: listen$5,
|
|
6145
|
-
signal: signal$7,
|
|
6146
|
-
wrap: wrap$d
|
|
6147
|
-
};
|
|
6148
|
-
const listen$3 = async () => {
|
|
6149
|
-
const {
|
|
6150
|
-
parentPort
|
|
6151
|
-
} = await import('node:worker_threads');
|
|
6152
|
-
if (!parentPort) {
|
|
6153
|
-
throw new IpcError('parentPort is required for node worker threads ipc');
|
|
6154
|
-
}
|
|
6155
|
-
return parentPort;
|
|
6156
|
-
};
|
|
6157
|
-
const signal$5 = parentPort => {
|
|
6158
|
-
parentPort.postMessage(readyMessage);
|
|
6159
|
-
};
|
|
6160
|
-
class IpcChildWithNodeWorker extends Ipc {
|
|
6161
|
-
getData(data) {
|
|
6162
|
-
return data;
|
|
6163
|
-
}
|
|
6164
|
-
onClose(callback) {
|
|
6165
|
-
this._rawIpc.on('close', callback);
|
|
6166
|
-
}
|
|
6167
|
-
send(message) {
|
|
6168
|
-
this._rawIpc.postMessage(message);
|
|
6169
|
-
}
|
|
6170
|
-
onMessage(callback) {
|
|
6171
|
-
this._rawIpc.on('message', callback);
|
|
6172
|
-
}
|
|
6173
|
-
sendAndTransfer(message) {
|
|
6174
|
-
const transfer = getTransferrablesNode(message);
|
|
6175
|
-
this._rawIpc.postMessage(message, transfer);
|
|
6176
|
-
}
|
|
6177
|
-
dispose() {
|
|
6178
|
-
this._rawIpc.close();
|
|
6179
|
-
}
|
|
6180
|
-
}
|
|
6181
|
-
const wrap$b = parentPort => {
|
|
6182
|
-
return new IpcChildWithNodeWorker(parentPort);
|
|
6183
|
-
};
|
|
6184
|
-
const IpcChildWithNodeWorker$1 = {
|
|
6185
|
-
__proto__: null,
|
|
6186
|
-
listen: listen$3,
|
|
6187
|
-
signal: signal$5,
|
|
6188
|
-
wrap: wrap$b
|
|
6189
|
-
};
|
|
6190
|
-
const preloadChannelType = 'port';
|
|
6191
|
-
const listen$2 = ({
|
|
6192
|
-
webContents
|
|
6193
|
-
}) => {
|
|
6194
|
-
return webContents;
|
|
6195
|
-
};
|
|
6196
|
-
const getData$1 = (event, message) => {
|
|
6197
|
-
const {
|
|
6198
|
-
ports,
|
|
6199
|
-
sender
|
|
6200
|
-
} = event;
|
|
6201
|
-
const data = {
|
|
6202
|
-
...message,
|
|
6203
|
-
params: [...message.params, ...ports, sender.id]
|
|
6204
|
-
};
|
|
6205
|
-
return data;
|
|
6206
|
-
};
|
|
6207
|
-
class IpcChildWithRendererProcess2 extends Ipc {
|
|
6208
|
-
getData(event, message) {
|
|
6209
|
-
return getData$1(event, message);
|
|
6210
|
-
}
|
|
6211
|
-
send(message) {
|
|
6212
|
-
this._rawIpc.postMessage(preloadChannelType, message);
|
|
6213
|
-
}
|
|
6214
|
-
sendAndTransfer(message) {
|
|
6215
|
-
const transfer = getTransferrables(message);
|
|
6216
|
-
this._rawIpc.postMessage(preloadChannelType, message, transfer);
|
|
6217
|
-
}
|
|
6218
|
-
dispose() {
|
|
6219
|
-
// ignore
|
|
6220
|
-
}
|
|
6221
|
-
onMessage(callback) {
|
|
6222
|
-
this._rawIpc.ipc.on(preloadChannelType, callback);
|
|
6223
|
-
}
|
|
6224
|
-
onClose(callback) {
|
|
6225
|
-
this._rawIpc.on('destroyed', callback);
|
|
6226
|
-
}
|
|
6227
|
-
}
|
|
6228
|
-
const wrap$a = webContents => {
|
|
6229
|
-
return new IpcChildWithRendererProcess2(webContents);
|
|
6230
|
-
};
|
|
6231
|
-
const IpcChildWithRendererProcess2$1 = {
|
|
6232
|
-
__proto__: null,
|
|
6233
|
-
listen: listen$2,
|
|
6234
|
-
wrap: wrap$a
|
|
6235
|
-
};
|
|
6236
|
-
const addListener = (emitter, type, callback) => {
|
|
6237
|
-
if ('addEventListener' in emitter) {
|
|
6238
|
-
emitter.addEventListener(type, callback);
|
|
6239
|
-
} else {
|
|
6240
|
-
emitter.on(type, callback);
|
|
6241
|
-
}
|
|
6242
|
-
};
|
|
6243
|
-
const removeListener = (emitter, type, callback) => {
|
|
6244
|
-
if ('removeEventListener' in emitter) {
|
|
6245
|
-
emitter.removeEventListener(type, callback);
|
|
6246
|
-
} else {
|
|
6247
|
-
emitter.off(type, callback);
|
|
6248
|
-
}
|
|
6249
|
-
};
|
|
6250
|
-
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
6251
|
-
const {
|
|
6252
|
-
promise,
|
|
6253
|
-
resolve
|
|
6254
|
-
} = Promise.withResolvers();
|
|
6255
|
-
const listenerMap = Object.create(null);
|
|
6256
|
-
const cleanup = value => {
|
|
6257
|
-
for (const event of Object.keys(eventMap)) {
|
|
6258
|
-
removeListener(eventEmitter, event, listenerMap[event]);
|
|
6259
|
-
}
|
|
6260
|
-
resolve(value);
|
|
6261
|
-
};
|
|
6262
|
-
for (const [event, type] of Object.entries(eventMap)) {
|
|
6263
|
-
const listener = event => {
|
|
6264
|
-
cleanup({
|
|
6265
|
-
event,
|
|
6266
|
-
type
|
|
6267
|
-
});
|
|
6268
|
-
};
|
|
6269
|
-
addListener(eventEmitter, event, listener);
|
|
6270
|
-
listenerMap[event] = listener;
|
|
6271
|
-
}
|
|
6272
|
-
return promise;
|
|
6273
|
-
};
|
|
6274
|
-
const create$7 = ({
|
|
6275
|
-
messagePort
|
|
6276
|
-
}) => {
|
|
6277
|
-
if (!isMessagePortMain(messagePort)) {
|
|
6278
|
-
throw new IpcError('port must be of type MessagePortMain');
|
|
6279
|
-
}
|
|
6280
|
-
return messagePort;
|
|
6281
|
-
};
|
|
6282
|
-
const signal$2 = messagePort => {
|
|
6283
|
-
messagePort.start();
|
|
6284
|
-
};
|
|
6285
|
-
class IpcParentWithElectronMessagePort extends Ipc {
|
|
6286
|
-
getData = getActualDataElectron;
|
|
6287
|
-
send(message) {
|
|
6288
|
-
this._rawIpc.postMessage(message);
|
|
6289
|
-
}
|
|
6290
|
-
sendAndTransfer(message) {
|
|
6291
|
-
const {
|
|
6292
|
-
newValue,
|
|
6293
|
-
transfer
|
|
6294
|
-
} = fixElectronParameters(message);
|
|
6295
|
-
this._rawIpc.postMessage(newValue, transfer);
|
|
6296
|
-
}
|
|
6297
|
-
dispose() {
|
|
6298
|
-
this._rawIpc.close();
|
|
6299
|
-
}
|
|
6300
|
-
onMessage(callback) {
|
|
6301
|
-
this._rawIpc.on('message', callback);
|
|
6302
|
-
}
|
|
6303
|
-
onClose(callback) {
|
|
6304
|
-
this._rawIpc.on('close', callback);
|
|
6305
|
-
}
|
|
6306
|
-
}
|
|
6307
|
-
const wrap$7 = messagePort => {
|
|
6308
|
-
return new IpcParentWithElectronMessagePort(messagePort);
|
|
6309
|
-
};
|
|
6310
|
-
const IpcParentWithElectronMessagePort$1 = {
|
|
6311
|
-
__proto__: null,
|
|
6312
|
-
create: create$7,
|
|
6313
|
-
signal: signal$2,
|
|
6314
|
-
wrap: wrap$7
|
|
6315
|
-
};
|
|
6316
|
-
const Exit = 1;
|
|
6317
|
-
const Error$2 = 2;
|
|
6318
|
-
const Message$1 = 3;
|
|
6319
|
-
const getFirstUtilityProcessEvent = async utilityProcess => {
|
|
6320
|
-
const {
|
|
6321
|
-
promise,
|
|
6322
|
-
resolve
|
|
6323
|
-
} = Promise.withResolvers();
|
|
6324
|
-
let stdout = '';
|
|
6325
|
-
let stderr = '';
|
|
6326
|
-
const cleanup = value => {
|
|
6327
|
-
// @ts-ignore
|
|
6328
|
-
utilityProcess.stderr.off('data', handleStdErrData);
|
|
6329
|
-
// @ts-ignore
|
|
6330
|
-
utilityProcess.stdout.off('data', handleStdoutData);
|
|
6331
|
-
utilityProcess.off('message', handleMessage);
|
|
6332
|
-
utilityProcess.off('exit', handleExit);
|
|
6333
|
-
resolve(value);
|
|
6334
|
-
};
|
|
6335
|
-
const handleStdErrData = data => {
|
|
6336
|
-
stderr += data;
|
|
6337
|
-
};
|
|
6338
|
-
const handleStdoutData = data => {
|
|
6339
|
-
stdout += data;
|
|
6340
|
-
};
|
|
6341
|
-
const handleMessage = event => {
|
|
6342
|
-
cleanup({
|
|
6343
|
-
event,
|
|
6344
|
-
stderr,
|
|
6345
|
-
stdout,
|
|
6346
|
-
type: Message$1
|
|
6347
|
-
});
|
|
6348
|
-
};
|
|
6349
|
-
const handleExit = event => {
|
|
6350
|
-
cleanup({
|
|
6351
|
-
event,
|
|
6352
|
-
stderr,
|
|
6353
|
-
stdout,
|
|
6354
|
-
type: Exit
|
|
6355
|
-
});
|
|
6356
|
-
};
|
|
6357
|
-
// @ts-ignore
|
|
6358
|
-
utilityProcess.stderr.on('data', handleStdErrData);
|
|
6359
|
-
// @ts-ignore
|
|
6360
|
-
utilityProcess.stdout.on('data', handleStdoutData);
|
|
6361
|
-
utilityProcess.on('message', handleMessage);
|
|
6362
|
-
utilityProcess.on('exit', handleExit);
|
|
6363
|
-
const {
|
|
6364
|
-
event,
|
|
6365
|
-
type
|
|
6366
|
-
} = await promise;
|
|
6367
|
-
return {
|
|
6368
|
-
event,
|
|
6369
|
-
stderr,
|
|
6370
|
-
stdout,
|
|
6371
|
-
type
|
|
6372
|
-
};
|
|
6373
|
-
};
|
|
6374
|
-
const create$6 = async ({
|
|
6375
|
-
argv = [],
|
|
6376
|
-
env = process.env,
|
|
6377
|
-
execArgv = [],
|
|
6378
|
-
name,
|
|
6379
|
-
path
|
|
6380
|
-
}) => {
|
|
6381
|
-
string(path);
|
|
6382
|
-
const actualArgv = ['--ipc-type=electron-utility-process', ...argv];
|
|
6383
|
-
const {
|
|
6384
|
-
utilityProcess
|
|
6385
|
-
} = await import('electron');
|
|
6386
|
-
const childProcess = utilityProcess.fork(path, actualArgv, {
|
|
6387
|
-
env,
|
|
6388
|
-
execArgv,
|
|
6389
|
-
serviceName: name,
|
|
6390
|
-
stdio: 'pipe'
|
|
6391
|
-
});
|
|
6392
|
-
const handleExit = () => {
|
|
6393
|
-
// @ts-ignore
|
|
6394
|
-
childProcess.stdout.unpipe(process.stdout);
|
|
6395
|
-
// @ts-ignore
|
|
6396
|
-
childProcess.stderr.unpipe(process.stderr);
|
|
6397
|
-
};
|
|
6398
|
-
childProcess.once('exit', handleExit);
|
|
6399
|
-
// @ts-ignore
|
|
6400
|
-
childProcess.stdout.pipe(process.stdout);
|
|
6401
|
-
const {
|
|
6402
|
-
stderr,
|
|
6403
|
-
stdout,
|
|
6404
|
-
type
|
|
6405
|
-
} = await getFirstUtilityProcessEvent(childProcess);
|
|
6406
|
-
if (type === Exit) {
|
|
6407
|
-
throw new IpcError(`Utility process exited before ipc connection was established`, stdout, stderr);
|
|
6408
|
-
}
|
|
6409
|
-
// @ts-ignore
|
|
6410
|
-
childProcess.stderr.pipe(process.stderr);
|
|
6411
|
-
return childProcess;
|
|
6412
|
-
};
|
|
6413
|
-
let IpcParentWithElectronUtilityProcess$1 = class IpcParentWithElectronUtilityProcess extends Ipc {
|
|
6414
|
-
getData(data) {
|
|
6415
|
-
return data;
|
|
6416
|
-
}
|
|
6417
|
-
send(message) {
|
|
6418
|
-
this._rawIpc.postMessage(message);
|
|
6419
|
-
}
|
|
6420
|
-
sendAndTransfer(message) {
|
|
6421
|
-
const {
|
|
6422
|
-
newValue,
|
|
6423
|
-
transfer
|
|
6424
|
-
} = fixElectronParameters(message);
|
|
6425
|
-
this._rawIpc.postMessage(newValue, transfer);
|
|
6426
|
-
}
|
|
6427
|
-
dispose() {
|
|
6428
|
-
this._rawIpc.kill();
|
|
6429
|
-
}
|
|
6430
|
-
onClose(callback) {
|
|
6431
|
-
this._rawIpc.on('exit', callback);
|
|
6432
|
-
}
|
|
6433
|
-
onMessage(callback) {
|
|
6434
|
-
this._rawIpc.on('message', callback);
|
|
6435
|
-
}
|
|
6436
|
-
};
|
|
6437
|
-
const wrap$6 = process => {
|
|
6438
|
-
return new IpcParentWithElectronUtilityProcess$1(process);
|
|
6439
|
-
};
|
|
6440
|
-
const IpcParentWithElectronUtilityProcess$1$1 = {
|
|
6441
|
-
__proto__: null,
|
|
6442
|
-
create: create$6,
|
|
6443
|
-
wrap: wrap$6
|
|
6444
|
-
};
|
|
6445
|
-
class ChildProcessError extends Error {
|
|
6446
|
-
// @ts-ignore
|
|
6447
|
-
constructor(stderr) {
|
|
6448
|
-
// @ts-ignore
|
|
6449
|
-
const {
|
|
6450
|
-
code,
|
|
6451
|
-
message,
|
|
6452
|
-
stack
|
|
6453
|
-
} = getHelpfulChildProcessError('', stderr);
|
|
6454
|
-
super(message || 'child process error');
|
|
6455
|
-
this.name = 'ChildProcessError';
|
|
6456
|
-
if (code) {
|
|
6457
|
-
// @ts-ignore
|
|
6458
|
-
this.code = code;
|
|
6459
|
-
}
|
|
6460
|
-
if (stack) {
|
|
6461
|
-
// @ts-ignore
|
|
6462
|
-
const lines = splitLines(this.stack);
|
|
6463
|
-
const [firstLine, ...stackLines] = lines;
|
|
6464
|
-
const newStackLines = [firstLine, ...stack, ...stackLines];
|
|
6465
|
-
const newStack = joinLines(newStackLines);
|
|
6466
|
-
this.stack = newStack;
|
|
6467
|
-
}
|
|
6468
|
-
}
|
|
6469
|
-
}
|
|
6470
|
-
|
|
6471
|
-
// workaround for node not supporting transferrable objects
|
|
6472
|
-
// as parameters. If the transferrable object is a parameter,
|
|
6473
|
-
// it is received as a plain object is received in the receiving process
|
|
6474
|
-
const fixNodeChildProcessParameters = value => {
|
|
6475
|
-
const transfer = getTransferrables(value);
|
|
6476
|
-
if (transfer.length === 0) {
|
|
6477
|
-
throw new IpcError('no transferrables found');
|
|
6478
|
-
}
|
|
6479
|
-
const newValue = removeValues(value, transfer);
|
|
6480
|
-
return {
|
|
6481
|
-
newValue,
|
|
6482
|
-
transfer: transfer[0]
|
|
6483
|
-
};
|
|
6484
|
-
};
|
|
6485
|
-
const getFirstNodeChildProcessEvent = async childProcess => {
|
|
6486
|
-
const {
|
|
6487
|
-
event,
|
|
6488
|
-
stderr,
|
|
6489
|
-
stdout,
|
|
6490
|
-
type
|
|
6491
|
-
} = await new Promise((resolve, reject) => {
|
|
6492
|
-
let stderr = '';
|
|
6493
|
-
let stdout = '';
|
|
6494
|
-
const cleanup = value => {
|
|
6495
|
-
if (childProcess.stdout && childProcess.stderr) {
|
|
6496
|
-
childProcess.stderr.off('data', handleStdErrData);
|
|
6497
|
-
childProcess.stdout.off('data', handleStdoutData);
|
|
6498
|
-
}
|
|
6499
|
-
childProcess.off('message', handleMessage);
|
|
6500
|
-
childProcess.off('exit', handleExit);
|
|
6501
|
-
childProcess.off('error', handleError);
|
|
6502
|
-
resolve(value);
|
|
6503
|
-
};
|
|
6504
|
-
const handleStdErrData = data => {
|
|
6505
|
-
stderr += data;
|
|
6506
|
-
};
|
|
6507
|
-
const handleStdoutData = data => {
|
|
6508
|
-
stdout += data;
|
|
6509
|
-
};
|
|
6510
|
-
const handleMessage = event => {
|
|
6511
|
-
cleanup({
|
|
6512
|
-
event,
|
|
6513
|
-
stderr,
|
|
6514
|
-
stdout,
|
|
6515
|
-
type: Message$1
|
|
6516
|
-
});
|
|
6517
|
-
};
|
|
6518
|
-
const handleExit = event => {
|
|
6519
|
-
cleanup({
|
|
6520
|
-
event,
|
|
6521
|
-
stderr,
|
|
6522
|
-
stdout,
|
|
6523
|
-
type: Exit
|
|
6524
|
-
});
|
|
6525
|
-
};
|
|
6526
|
-
const handleError = event => {
|
|
6527
|
-
cleanup({
|
|
6528
|
-
event,
|
|
6529
|
-
stderr,
|
|
6530
|
-
stdout,
|
|
6531
|
-
type: Error$2
|
|
6532
|
-
});
|
|
6533
|
-
};
|
|
6534
|
-
if (childProcess.stdout && childProcess.stderr) {
|
|
6535
|
-
childProcess.stderr.on('data', handleStdErrData);
|
|
6536
|
-
childProcess.stdout.on('data', handleStdoutData);
|
|
6537
|
-
}
|
|
6538
|
-
childProcess.on('message', handleMessage);
|
|
6539
|
-
childProcess.on('exit', handleExit);
|
|
6540
|
-
childProcess.on('error', handleError);
|
|
6541
|
-
});
|
|
6542
|
-
return {
|
|
6543
|
-
event,
|
|
6544
|
-
stderr,
|
|
6545
|
-
stdout,
|
|
6546
|
-
type
|
|
6547
|
-
};
|
|
6548
|
-
};
|
|
6549
|
-
|
|
6550
|
-
// @ts-ignore
|
|
6551
|
-
const create$2 = async ({
|
|
6552
|
-
argv = [],
|
|
6553
|
-
env,
|
|
6554
|
-
execArgv = [],
|
|
6555
|
-
name = 'child process',
|
|
6556
|
-
path,
|
|
6557
|
-
stdio = 'inherit'
|
|
6558
|
-
}) => {
|
|
6559
|
-
try {
|
|
6560
|
-
string(path);
|
|
6561
|
-
const actualArgv = ['--ipc-type=node-forked-process', ...argv];
|
|
6562
|
-
const {
|
|
6563
|
-
fork
|
|
6564
|
-
} = await import('node:child_process');
|
|
6565
|
-
const childProcess = fork(path, actualArgv, {
|
|
6566
|
-
env,
|
|
6567
|
-
execArgv,
|
|
6568
|
-
stdio: 'pipe'
|
|
6569
|
-
});
|
|
6570
|
-
const {
|
|
6571
|
-
event,
|
|
6572
|
-
stderr,
|
|
6573
|
-
type
|
|
6574
|
-
} = await getFirstNodeChildProcessEvent(childProcess);
|
|
6575
|
-
if (type === Exit) {
|
|
6576
|
-
throw new ChildProcessError(stderr);
|
|
6577
|
-
}
|
|
6578
|
-
if (type === Error$2) {
|
|
6579
|
-
throw new IpcError(`child process had an error ${event}`);
|
|
6580
|
-
}
|
|
6581
|
-
if (stdio === 'inherit' && childProcess.stdout && childProcess.stderr) {
|
|
6582
|
-
childProcess.stdout.pipe(process.stdout);
|
|
6583
|
-
childProcess.stderr.pipe(process.stderr);
|
|
6584
|
-
}
|
|
6585
|
-
return childProcess;
|
|
6586
|
-
} catch (error) {
|
|
6587
|
-
throw new VError(error, `Failed to launch ${name}`);
|
|
6588
|
-
}
|
|
6589
|
-
};
|
|
6590
|
-
class IpcParentWithNodeForkedProcess extends Ipc {
|
|
6591
|
-
constructor(childProcess) {
|
|
6592
|
-
super(childProcess);
|
|
6593
|
-
this.pid = childProcess.pid;
|
|
6594
|
-
}
|
|
6595
|
-
getData(message) {
|
|
6596
|
-
return message;
|
|
6597
|
-
}
|
|
6598
|
-
send(message) {
|
|
6599
|
-
this._rawIpc.send(message);
|
|
6600
|
-
}
|
|
6601
|
-
sendAndTransfer(message) {
|
|
6602
|
-
const {
|
|
6603
|
-
newValue,
|
|
6604
|
-
transfer
|
|
6605
|
-
} = fixNodeChildProcessParameters(message);
|
|
6606
|
-
this._rawIpc.send(newValue, transfer);
|
|
6607
|
-
}
|
|
6608
|
-
dispose() {
|
|
6609
|
-
this._rawIpc.kill();
|
|
6610
|
-
}
|
|
6611
|
-
onClose(callback) {
|
|
6612
|
-
this._rawIpc.on('close', callback);
|
|
6613
|
-
}
|
|
6614
|
-
onMessage(callback) {
|
|
6615
|
-
this._rawIpc.on('message', callback);
|
|
6616
|
-
}
|
|
6617
|
-
}
|
|
6618
|
-
const wrap$2 = childProcess => {
|
|
6619
|
-
return new IpcParentWithNodeForkedProcess(childProcess);
|
|
6620
|
-
};
|
|
6621
|
-
const IpcParentWithNodeForkedProcess$1 = {
|
|
6622
|
-
__proto__: null,
|
|
6623
|
-
create: create$2,
|
|
6624
|
-
wrap: wrap$2
|
|
6625
|
-
};
|
|
6626
|
-
const fixNodeWorkerParameters = value => {
|
|
6627
|
-
const transfer = getTransferrables(value);
|
|
6628
|
-
if (transfer.length === 0) {
|
|
6629
|
-
throw new IpcError('no transferrables found');
|
|
6630
|
-
}
|
|
6631
|
-
return {
|
|
6632
|
-
newValue: value,
|
|
6633
|
-
transfer: transfer
|
|
6634
|
-
};
|
|
6635
|
-
};
|
|
6636
|
-
const getFirstNodeWorkerEvent = worker => {
|
|
6637
|
-
return getFirstEvent(worker, {
|
|
6638
|
-
error: Error$2,
|
|
6639
|
-
exit: Exit,
|
|
6640
|
-
message: Message$1
|
|
6641
|
-
});
|
|
6642
|
-
};
|
|
6643
|
-
const create$1$1 = async ({
|
|
6644
|
-
argv = [],
|
|
6645
|
-
env = process.env,
|
|
6646
|
-
execArgv = [],
|
|
6647
|
-
name,
|
|
6648
|
-
path,
|
|
6649
|
-
stdio
|
|
6650
|
-
}) => {
|
|
6651
|
-
string(path);
|
|
6652
|
-
const actualArgv = ['--ipc-type=node-worker', ...argv];
|
|
6653
|
-
const actualEnv = {
|
|
6654
|
-
...env,
|
|
6655
|
-
ELECTRON_RUN_AS_NODE: '1'
|
|
6656
|
-
};
|
|
6657
|
-
const ignoreStdio = stdio === 'inherit' ? undefined : true;
|
|
6658
|
-
const {
|
|
6659
|
-
Worker
|
|
6660
|
-
} = await import('node:worker_threads');
|
|
6661
|
-
const worker = new Worker(path, {
|
|
6662
|
-
argv: actualArgv,
|
|
6663
|
-
env: actualEnv,
|
|
6664
|
-
execArgv,
|
|
6665
|
-
name,
|
|
6666
|
-
stderr: ignoreStdio,
|
|
6667
|
-
stdout: ignoreStdio
|
|
6668
|
-
});
|
|
6669
|
-
const {
|
|
6670
|
-
event,
|
|
6671
|
-
type
|
|
6672
|
-
} = await getFirstNodeWorkerEvent(worker);
|
|
6673
|
-
if (type === Exit) {
|
|
6674
|
-
throw new IpcError(`Worker exited before ipc connection was established`);
|
|
6675
|
-
}
|
|
6676
|
-
if (type === Error$2) {
|
|
6677
|
-
throw new IpcError(`Worker threw an error before ipc connection was established: ${event}`);
|
|
6678
|
-
}
|
|
6679
|
-
if (event !== readyMessage) {
|
|
6680
|
-
throw new IpcError('unexpected first message from worker');
|
|
6681
|
-
}
|
|
6682
|
-
return worker;
|
|
6683
|
-
};
|
|
6684
|
-
class IpcParentWithNodeWorker extends Ipc {
|
|
6685
|
-
getData(message) {
|
|
6686
|
-
return message;
|
|
6687
|
-
}
|
|
6688
|
-
send(message) {
|
|
6689
|
-
this._rawIpc.postMessage(message);
|
|
6690
|
-
}
|
|
6691
|
-
sendAndTransfer(message) {
|
|
6692
|
-
const {
|
|
6693
|
-
newValue,
|
|
6694
|
-
transfer
|
|
6695
|
-
} = fixNodeWorkerParameters(message);
|
|
6696
|
-
this._rawIpc.postMessage(newValue, transfer);
|
|
6697
|
-
}
|
|
6698
|
-
async dispose() {
|
|
6699
|
-
await this._rawIpc.terminate();
|
|
6700
|
-
}
|
|
6701
|
-
onClose(callback) {
|
|
6702
|
-
this._rawIpc.on('exit', callback);
|
|
6703
|
-
}
|
|
6704
|
-
onMessage(callback) {
|
|
6705
|
-
this._rawIpc.on('message', callback);
|
|
6706
|
-
}
|
|
6707
|
-
}
|
|
6708
|
-
const wrap$1 = worker => {
|
|
6709
|
-
return new IpcParentWithNodeWorker(worker);
|
|
6710
|
-
};
|
|
6711
|
-
const IpcParentWithNodeWorker$1 = {
|
|
6712
|
-
__proto__: null,
|
|
6713
|
-
create: create$1$1,
|
|
6714
|
-
wrap: wrap$1
|
|
6715
|
-
};
|
|
6716
|
-
|
|
6717
6296
|
const getModule$1 = method => {
|
|
6718
6297
|
switch (method) {
|
|
6719
6298
|
case ElectronMessagePort$1:
|
|
@@ -6804,7 +6383,7 @@ const getWindowId = webContentsId => {
|
|
|
6804
6383
|
|
|
6805
6384
|
const handleElectronMessagePort = async (messagePort, rpcId) => {
|
|
6806
6385
|
object(messagePort);
|
|
6807
|
-
const rpc = await create$
|
|
6386
|
+
const rpc = await create$5({
|
|
6808
6387
|
commandMap: commandMapRef,
|
|
6809
6388
|
messagePort: messagePort,
|
|
6810
6389
|
requiresSocket: requiresSocket
|
|
@@ -7020,6 +6599,8 @@ const commandMap = {
|
|
|
7020
6599
|
'Process.getNodeVersion': getNodeVersion,
|
|
7021
6600
|
'Process.getPid': getPid,
|
|
7022
6601
|
'Process.getV8Version': getV8Version,
|
|
6602
|
+
'Process.writeStderr': writeStderr,
|
|
6603
|
+
'Process.writeStdout': writeStdout,
|
|
7023
6604
|
'TemporaryMessagePort.createPortTuple': createPortTuple,
|
|
7024
6605
|
'TemporaryMessagePort.dispose': dispose,
|
|
7025
6606
|
'TemporaryMessagePort.sendTo': sendTo,
|