@lvce-editor/process-explorer-worker 3.21.0 → 3.22.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/index.js +243 -85
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -177,29 +177,41 @@ const None$2 = 0;
|
|
|
177
177
|
const Collapsed = 1;
|
|
178
178
|
const Expanded = 2;
|
|
179
179
|
|
|
180
|
-
const
|
|
180
|
+
const getTreeId = process => {
|
|
181
|
+
return process.treeId ?? process.pid;
|
|
182
|
+
};
|
|
183
|
+
const getParentTreeId = process => {
|
|
184
|
+
return process.parentTreeId ?? process.ppid;
|
|
185
|
+
};
|
|
186
|
+
const getRootProcesses = (processes, rootPid) => {
|
|
187
|
+
const groupedProcesses = processes.filter(process => process.parentTreeId === '');
|
|
188
|
+
if (groupedProcesses.length > 0) {
|
|
189
|
+
return groupedProcesses;
|
|
190
|
+
}
|
|
181
191
|
if (rootPid) {
|
|
182
|
-
|
|
192
|
+
const rootProcess = processes.find(process => process.pid === rootPid);
|
|
193
|
+
return rootProcess ? [rootProcess] : [];
|
|
183
194
|
}
|
|
184
|
-
return processes[0];
|
|
195
|
+
return processes.length > 0 ? [processes[0]] : [];
|
|
185
196
|
};
|
|
186
197
|
const hasChildren = (processes, pid) => {
|
|
187
|
-
return processes.some(process => process
|
|
198
|
+
return processes.some(process => getParentTreeId(process) === pid);
|
|
188
199
|
};
|
|
189
200
|
const getChildren = (processes, collapsedPids, process, depth) => {
|
|
190
|
-
const children = processes.filter(otherProcess => otherProcess
|
|
201
|
+
const children = processes.filter(otherProcess => getParentTreeId(otherProcess) === getTreeId(process));
|
|
191
202
|
if (children.length === 0) {
|
|
192
203
|
return [];
|
|
193
204
|
}
|
|
194
|
-
if (collapsedPids.includes(process
|
|
205
|
+
if (collapsedPids.includes(getTreeId(process))) {
|
|
195
206
|
return [];
|
|
196
207
|
}
|
|
197
208
|
return children.flatMap(child => withChildren(processes, collapsedPids, child, depth + 1));
|
|
198
209
|
};
|
|
199
210
|
const withChildren = (processes, collapsedPids, process, depth) => {
|
|
200
|
-
const
|
|
211
|
+
const treeId = getTreeId(process);
|
|
212
|
+
const processHasChildren = hasChildren(processes, treeId);
|
|
201
213
|
let flags = None$2;
|
|
202
|
-
if (processHasChildren && collapsedPids.includes(
|
|
214
|
+
if (processHasChildren && collapsedPids.includes(treeId)) {
|
|
203
215
|
flags = Collapsed;
|
|
204
216
|
} else if (processHasChildren) {
|
|
205
217
|
flags = Expanded;
|
|
@@ -212,19 +224,16 @@ const withChildren = (processes, collapsedPids, process, depth) => {
|
|
|
212
224
|
return [visibleProcess, ...getChildren(processes, collapsedPids, process, depth)];
|
|
213
225
|
};
|
|
214
226
|
const getVisibleProcesses = (processes, collapsedPids, rootPid) => {
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
return [];
|
|
218
|
-
}
|
|
219
|
-
return withChildren(processes, collapsedPids, rootProcess, 1);
|
|
227
|
+
const rootProcesses = getRootProcesses(processes, rootPid);
|
|
228
|
+
return rootProcesses.flatMap(rootProcess => withChildren(processes, collapsedPids, rootProcess, 1));
|
|
220
229
|
};
|
|
221
230
|
|
|
222
231
|
const collapseAll = state => {
|
|
223
232
|
const parentPids = new Set();
|
|
224
233
|
for (const process of state.processes) {
|
|
225
|
-
parentPids.add(process.ppid);
|
|
234
|
+
parentPids.add(process.parentTreeId ?? process.ppid);
|
|
226
235
|
}
|
|
227
|
-
const collapsedPids = state.processes.filter(process => parentPids.has(process.pid)).map(process => process.pid);
|
|
236
|
+
const collapsedPids = state.processes.filter(process => parentPids.has(process.treeId ?? process.pid)).map(process => process.treeId ?? process.pid);
|
|
228
237
|
const visibleProcesses = getVisibleProcesses(state.processes, collapsedPids, state.rootPid);
|
|
229
238
|
return {
|
|
230
239
|
...state,
|
|
@@ -235,12 +244,12 @@ const collapseAll = state => {
|
|
|
235
244
|
};
|
|
236
245
|
|
|
237
246
|
const {
|
|
238
|
-
dispose: dispose$
|
|
247
|
+
dispose: dispose$6,
|
|
239
248
|
get: get$2,
|
|
240
249
|
getCommandIds,
|
|
241
250
|
getKeys: getKeys$1,
|
|
242
251
|
registerCommands,
|
|
243
|
-
set: set$
|
|
252
|
+
set: set$a,
|
|
244
253
|
wrapCommand,
|
|
245
254
|
wrapGetter,
|
|
246
255
|
wrapLoadContent
|
|
@@ -269,6 +278,7 @@ const create$d = (id, _uri, x, y, width, height, args, parentUid, platform = 0,
|
|
|
269
278
|
const state = {
|
|
270
279
|
assetDir,
|
|
271
280
|
collapsedPids: [],
|
|
281
|
+
errorCode: '',
|
|
272
282
|
errorCodeFrame: '',
|
|
273
283
|
errorMessage: '',
|
|
274
284
|
errorStack: '',
|
|
@@ -289,7 +299,7 @@ const create$d = (id, _uri, x, y, width, height, args, parentUid, platform = 0,
|
|
|
289
299
|
x,
|
|
290
300
|
y
|
|
291
301
|
};
|
|
292
|
-
set$
|
|
302
|
+
set$a(state.uid, state, state);
|
|
293
303
|
return state;
|
|
294
304
|
};
|
|
295
305
|
|
|
@@ -1268,7 +1278,7 @@ const createMockRpc = ({
|
|
|
1268
1278
|
};
|
|
1269
1279
|
|
|
1270
1280
|
const rpcs = Object.create(null);
|
|
1271
|
-
const set$
|
|
1281
|
+
const set$9 = (id, rpc) => {
|
|
1272
1282
|
rpcs[id] = rpc;
|
|
1273
1283
|
};
|
|
1274
1284
|
const get = id => {
|
|
@@ -1301,7 +1311,7 @@ const create$a = rpcId => {
|
|
|
1301
1311
|
const mockRpc = createMockRpc({
|
|
1302
1312
|
commandMap
|
|
1303
1313
|
});
|
|
1304
|
-
set$
|
|
1314
|
+
set$9(rpcId, mockRpc);
|
|
1305
1315
|
// @ts-ignore
|
|
1306
1316
|
mockRpc[Symbol.dispose] = () => {
|
|
1307
1317
|
remove(rpcId);
|
|
@@ -1310,7 +1320,7 @@ const create$a = rpcId => {
|
|
|
1310
1320
|
return mockRpc;
|
|
1311
1321
|
},
|
|
1312
1322
|
set(rpc) {
|
|
1313
|
-
set$
|
|
1323
|
+
set$9(rpcId, rpc);
|
|
1314
1324
|
}
|
|
1315
1325
|
};
|
|
1316
1326
|
};
|
|
@@ -1521,44 +1531,44 @@ const Empty = 0;
|
|
|
1521
1531
|
const FocusExplorer = 13;
|
|
1522
1532
|
|
|
1523
1533
|
const {
|
|
1524
|
-
invoke: invoke$
|
|
1525
|
-
set: set$
|
|
1534
|
+
invoke: invoke$6,
|
|
1535
|
+
set: set$8
|
|
1526
1536
|
} = create$a(ErrorWorker);
|
|
1527
1537
|
const prepare = async error => {
|
|
1528
|
-
return invoke$
|
|
1538
|
+
return invoke$6('Errors.prepare', error);
|
|
1529
1539
|
};
|
|
1530
1540
|
|
|
1531
1541
|
const {
|
|
1532
|
-
set: set$
|
|
1542
|
+
set: set$7
|
|
1533
1543
|
} = create$a(FileSystemWorker$1);
|
|
1534
1544
|
|
|
1535
1545
|
const FileSystemWorker = {
|
|
1536
1546
|
__proto__: null,
|
|
1537
|
-
set: set$
|
|
1547
|
+
set: set$7
|
|
1538
1548
|
};
|
|
1539
1549
|
|
|
1540
1550
|
const {
|
|
1541
|
-
dispose: dispose$
|
|
1542
|
-
invoke: invoke$
|
|
1543
|
-
set: set$
|
|
1551
|
+
dispose: dispose$5,
|
|
1552
|
+
invoke: invoke$5,
|
|
1553
|
+
set: set$6
|
|
1544
1554
|
} = create$a(MainProcess);
|
|
1545
1555
|
|
|
1546
1556
|
const {
|
|
1547
|
-
invoke: invoke$
|
|
1548
|
-
set: set$
|
|
1557
|
+
invoke: invoke$4,
|
|
1558
|
+
set: set$5
|
|
1549
1559
|
} = create$a(RendererProcess);
|
|
1550
1560
|
|
|
1551
1561
|
const {
|
|
1552
|
-
invoke: invoke$
|
|
1562
|
+
invoke: invoke$3,
|
|
1553
1563
|
invokeAndTransfer,
|
|
1554
|
-
set: set$
|
|
1564
|
+
set: set$4
|
|
1555
1565
|
} = create$a(RendererWorker);
|
|
1556
1566
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1557
1567
|
number(uid);
|
|
1558
1568
|
number(menuId);
|
|
1559
1569
|
number(x);
|
|
1560
1570
|
number(y);
|
|
1561
|
-
await invoke$
|
|
1571
|
+
await invoke$3('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1562
1572
|
};
|
|
1563
1573
|
const sendMessagePortToErrorWorker$1 = async (port, rpcId) => {
|
|
1564
1574
|
const command = 'Errors.handleMessagePort';
|
|
@@ -1578,7 +1588,7 @@ const debugProcess = async (state, index = state.focusedIndex) => {
|
|
|
1578
1588
|
if (!process) {
|
|
1579
1589
|
return state;
|
|
1580
1590
|
}
|
|
1581
|
-
await invoke$
|
|
1591
|
+
await invoke$3('AttachDebugger.attachDebugger', process.pid);
|
|
1582
1592
|
return state;
|
|
1583
1593
|
};
|
|
1584
1594
|
|
|
@@ -1587,7 +1597,7 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
1587
1597
|
};
|
|
1588
1598
|
|
|
1589
1599
|
const isEqual = (oldState, newState) => {
|
|
1590
|
-
return oldState.initial === newState.initial && oldState.errorCodeFrame === newState.errorCodeFrame && oldState.errorMessage === newState.errorMessage && oldState.errorStack === newState.errorStack && oldState.focusedIndex === newState.focusedIndex && oldState.visibleProcesses === newState.visibleProcesses;
|
|
1600
|
+
return oldState.initial === newState.initial && oldState.errorCode === newState.errorCode && oldState.errorCodeFrame === newState.errorCodeFrame && oldState.errorMessage === newState.errorMessage && oldState.errorStack === newState.errorStack && oldState.focusedIndex === newState.focusedIndex && oldState.visibleProcesses === newState.visibleProcesses;
|
|
1591
1601
|
};
|
|
1592
1602
|
|
|
1593
1603
|
const RenderItems = 1;
|
|
@@ -1619,7 +1629,7 @@ const diff2 = uid => {
|
|
|
1619
1629
|
|
|
1620
1630
|
const intervals = new Map();
|
|
1621
1631
|
const pending = new Set();
|
|
1622
|
-
const dispose$
|
|
1632
|
+
const dispose$4 = uid => {
|
|
1623
1633
|
const interval = intervals.get(uid);
|
|
1624
1634
|
if (interval) {
|
|
1625
1635
|
clearInterval(interval);
|
|
@@ -1629,7 +1639,7 @@ const dispose$3 = uid => {
|
|
|
1629
1639
|
};
|
|
1630
1640
|
const update = async uid => {
|
|
1631
1641
|
if (!getKeys$1().includes(uid)) {
|
|
1632
|
-
dispose$
|
|
1642
|
+
dispose$4(uid);
|
|
1633
1643
|
return;
|
|
1634
1644
|
}
|
|
1635
1645
|
if (pending.has(uid)) {
|
|
@@ -1637,7 +1647,7 @@ const update = async uid => {
|
|
|
1637
1647
|
}
|
|
1638
1648
|
pending.add(uid);
|
|
1639
1649
|
try {
|
|
1640
|
-
await invoke$
|
|
1650
|
+
await invoke$3('ProcessExplorer.update');
|
|
1641
1651
|
} catch (error) {
|
|
1642
1652
|
console.error(error);
|
|
1643
1653
|
} finally {
|
|
@@ -1654,14 +1664,19 @@ const start = (uid, interval = processExplorerUpdateInterval) => {
|
|
|
1654
1664
|
intervals.set(uid, intervalId);
|
|
1655
1665
|
};
|
|
1656
1666
|
const restart = (uid, interval) => {
|
|
1657
|
-
dispose$
|
|
1667
|
+
dispose$4(uid);
|
|
1658
1668
|
start(uid, interval);
|
|
1659
1669
|
};
|
|
1660
1670
|
|
|
1671
|
+
const ProcessExplorerError = 'E_PROCESS_EXPLORER_ERROR';
|
|
1672
|
+
const ProcessExplorerRefreshFailed = 'E_PROCESS_EXPLORER_REFRESH_FAILED';
|
|
1673
|
+
const ProcessExplorerRpcConnectionClosed = 'E_PROCESS_EXPLORER_RPC_CONNECTION_CLOSED';
|
|
1674
|
+
|
|
1661
1675
|
const processExplorerRpcClosedMessage = 'Process explorer RPC connection was closed';
|
|
1662
1676
|
const toProcessExplorerRpcClosedState = state => {
|
|
1663
1677
|
return {
|
|
1664
1678
|
...state,
|
|
1679
|
+
errorCode: ProcessExplorerRpcConnectionClosed,
|
|
1665
1680
|
errorCodeFrame: '',
|
|
1666
1681
|
errorMessage: processExplorerRpcClosedMessage,
|
|
1667
1682
|
errorStack: '',
|
|
@@ -1675,17 +1690,17 @@ const handleProcessExplorerRpcClose = async () => {
|
|
|
1675
1690
|
if (!viewletState) {
|
|
1676
1691
|
continue;
|
|
1677
1692
|
}
|
|
1678
|
-
dispose$
|
|
1693
|
+
dispose$4(uid);
|
|
1679
1694
|
const {
|
|
1680
1695
|
oldState,
|
|
1681
1696
|
scheduledState
|
|
1682
1697
|
} = viewletState;
|
|
1683
1698
|
const newState = toProcessExplorerRpcClosedState(scheduledState);
|
|
1684
|
-
set$
|
|
1699
|
+
set$a(uid, oldState, newState);
|
|
1685
1700
|
didUpdate = true;
|
|
1686
1701
|
}
|
|
1687
1702
|
if (didUpdate) {
|
|
1688
|
-
await invoke$
|
|
1703
|
+
await invoke$3('ProcessExplorer.rerender');
|
|
1689
1704
|
}
|
|
1690
1705
|
};
|
|
1691
1706
|
|
|
@@ -2007,7 +2022,7 @@ const launchProcessExplorerNode = async onClose => {
|
|
|
2007
2022
|
const {
|
|
2008
2023
|
protocols,
|
|
2009
2024
|
url
|
|
2010
|
-
} = await invoke$
|
|
2025
|
+
} = await invoke$3('WebSocketCapability.create', 'process-explorer');
|
|
2011
2026
|
const webSocket = new WebSocket(url, protocols);
|
|
2012
2027
|
webSocket.addEventListener('close', onClose);
|
|
2013
2028
|
return await create$3({
|
|
@@ -2030,18 +2045,58 @@ const launchProcessExplorerNode = async onClose => {
|
|
|
2030
2045
|
}
|
|
2031
2046
|
};
|
|
2032
2047
|
|
|
2048
|
+
const state$3 = {
|
|
2049
|
+
rpc: undefined
|
|
2050
|
+
};
|
|
2051
|
+
const invoke$2 = async (method, ...params) => {
|
|
2052
|
+
if (!state$3.rpc) {
|
|
2053
|
+
throw new Error('ProcessExplorerModule is not initialized');
|
|
2054
|
+
}
|
|
2055
|
+
return state$3.rpc.invoke(method, ...params);
|
|
2056
|
+
};
|
|
2057
|
+
const set$3 = newRpc => {
|
|
2058
|
+
state$3.rpc = newRpc;
|
|
2059
|
+
};
|
|
2060
|
+
const clear$1 = () => {
|
|
2061
|
+
state$3.rpc = undefined;
|
|
2062
|
+
};
|
|
2063
|
+
const dispose$3 = async () => {
|
|
2064
|
+
const {
|
|
2065
|
+
rpc
|
|
2066
|
+
} = state$3;
|
|
2067
|
+
state$3.rpc = undefined;
|
|
2068
|
+
await rpc?.dispose();
|
|
2069
|
+
};
|
|
2070
|
+
|
|
2071
|
+
const ProcessExplorerModule = {
|
|
2072
|
+
__proto__: null,
|
|
2073
|
+
clear: clear$1,
|
|
2074
|
+
dispose: dispose$3,
|
|
2075
|
+
invoke: invoke$2,
|
|
2076
|
+
set: set$3
|
|
2077
|
+
};
|
|
2078
|
+
|
|
2033
2079
|
const state$2 = {
|
|
2034
2080
|
rpc: undefined
|
|
2035
2081
|
};
|
|
2036
2082
|
const invoke$1 = async (method, ...params) => {
|
|
2037
|
-
|
|
2038
|
-
|
|
2083
|
+
const {
|
|
2084
|
+
rpc
|
|
2085
|
+
} = state$2;
|
|
2086
|
+
if (!rpc) {
|
|
2087
|
+
throw new Error('RemoteProcessExplorerModule is not initialized');
|
|
2039
2088
|
}
|
|
2040
|
-
return
|
|
2089
|
+
return rpc.invoke(method, ...params);
|
|
2041
2090
|
};
|
|
2042
2091
|
const set$2 = newRpc => {
|
|
2043
2092
|
state$2.rpc = newRpc;
|
|
2044
2093
|
};
|
|
2094
|
+
const has = () => {
|
|
2095
|
+
const {
|
|
2096
|
+
rpc
|
|
2097
|
+
} = state$2;
|
|
2098
|
+
return Boolean(rpc);
|
|
2099
|
+
};
|
|
2045
2100
|
const clear = () => {
|
|
2046
2101
|
state$2.rpc = undefined;
|
|
2047
2102
|
};
|
|
@@ -2053,16 +2108,61 @@ const dispose$2 = async () => {
|
|
|
2053
2108
|
await rpc?.dispose();
|
|
2054
2109
|
};
|
|
2055
2110
|
|
|
2111
|
+
const RemoteProcessExplorer = {
|
|
2112
|
+
__proto__: null,
|
|
2113
|
+
clear,
|
|
2114
|
+
dispose: dispose$2,
|
|
2115
|
+
has,
|
|
2116
|
+
invoke: invoke$1,
|
|
2117
|
+
set: set$2
|
|
2118
|
+
};
|
|
2119
|
+
|
|
2056
2120
|
const state$1 = {
|
|
2057
|
-
initializedPlatform: 0
|
|
2121
|
+
initializedPlatform: 0,
|
|
2122
|
+
remoteInitialized: false
|
|
2058
2123
|
};
|
|
2059
2124
|
const handleClose = async () => {
|
|
2060
2125
|
state$1.initializedPlatform = 0;
|
|
2061
|
-
clear();
|
|
2126
|
+
clear$1();
|
|
2062
2127
|
await handleProcessExplorerRpcClose();
|
|
2063
2128
|
};
|
|
2129
|
+
const handleRemoteClose = () => {
|
|
2130
|
+
state$1.remoteInitialized = false;
|
|
2131
|
+
clear();
|
|
2132
|
+
void invoke$3('ProcessExplorer.update').catch(() => {});
|
|
2133
|
+
};
|
|
2134
|
+
const isRemoteWorkspace = async () => {
|
|
2135
|
+
try {
|
|
2136
|
+
return await invoke$3('WebSocketCapability.isActive');
|
|
2137
|
+
} catch {
|
|
2138
|
+
return false;
|
|
2139
|
+
}
|
|
2140
|
+
};
|
|
2141
|
+
const initializeRemoteProcessExplorer = async () => {
|
|
2142
|
+
const remoteWorkspace = await isRemoteWorkspace();
|
|
2143
|
+
if (!remoteWorkspace) {
|
|
2144
|
+
if (state$1.remoteInitialized) {
|
|
2145
|
+
state$1.remoteInitialized = false;
|
|
2146
|
+
await dispose$2();
|
|
2147
|
+
}
|
|
2148
|
+
return;
|
|
2149
|
+
}
|
|
2150
|
+
if (state$1.remoteInitialized) {
|
|
2151
|
+
return;
|
|
2152
|
+
}
|
|
2153
|
+
try {
|
|
2154
|
+
const remoteRpc = await launchProcessExplorerNode(handleRemoteClose);
|
|
2155
|
+
set$2(remoteRpc);
|
|
2156
|
+
state$1.remoteInitialized = true;
|
|
2157
|
+
} catch {
|
|
2158
|
+
clear();
|
|
2159
|
+
}
|
|
2160
|
+
};
|
|
2064
2161
|
const initializeProcessExplorer = async platform => {
|
|
2065
2162
|
if (state$1.initializedPlatform === platform) {
|
|
2163
|
+
if (platform === Electron) {
|
|
2164
|
+
await initializeRemoteProcessExplorer();
|
|
2165
|
+
}
|
|
2066
2166
|
return;
|
|
2067
2167
|
}
|
|
2068
2168
|
if (platform === Electron) {
|
|
@@ -2070,16 +2170,17 @@ const initializeProcessExplorer = async platform => {
|
|
|
2070
2170
|
mainProcessRpc,
|
|
2071
2171
|
processExplorerRpc
|
|
2072
2172
|
} = await launchProcessExplorerElectron();
|
|
2073
|
-
set$
|
|
2074
|
-
set$
|
|
2173
|
+
set$6(mainProcessRpc);
|
|
2174
|
+
set$3(processExplorerRpc);
|
|
2075
2175
|
state$1.initializedPlatform = platform;
|
|
2176
|
+
await initializeRemoteProcessExplorer();
|
|
2076
2177
|
return;
|
|
2077
2178
|
}
|
|
2078
2179
|
if (platform === Remote) {
|
|
2079
2180
|
const rpc = await launchProcessExplorerNode(() => {
|
|
2080
2181
|
void handleClose();
|
|
2081
2182
|
});
|
|
2082
|
-
set$
|
|
2183
|
+
set$3(rpc);
|
|
2083
2184
|
state$1.initializedPlatform = platform;
|
|
2084
2185
|
}
|
|
2085
2186
|
};
|
|
@@ -2088,30 +2189,31 @@ const dispose$1 = async () => {
|
|
|
2088
2189
|
initializedPlatform
|
|
2089
2190
|
} = state$1;
|
|
2090
2191
|
state$1.initializedPlatform = 0;
|
|
2192
|
+
state$1.remoteInitialized = false;
|
|
2091
2193
|
if (initializedPlatform === Electron) {
|
|
2092
|
-
await Promise.all([dispose$
|
|
2194
|
+
await Promise.all([dispose$5(), dispose$3(), dispose$2()]);
|
|
2093
2195
|
return;
|
|
2094
2196
|
}
|
|
2095
|
-
await dispose$2();
|
|
2197
|
+
await Promise.all([dispose$3(), dispose$2()]);
|
|
2096
2198
|
};
|
|
2097
2199
|
|
|
2098
2200
|
const dispose = async uid => {
|
|
2099
|
-
dispose$
|
|
2100
|
-
dispose$
|
|
2201
|
+
dispose$4(uid);
|
|
2202
|
+
dispose$6(uid);
|
|
2101
2203
|
if (getKeys$1().length === 0) {
|
|
2102
2204
|
await dispose$1();
|
|
2103
2205
|
}
|
|
2104
2206
|
};
|
|
2105
2207
|
|
|
2106
2208
|
const createE2eFixtureProcess = async (state, marker) => {
|
|
2107
|
-
const pid = await invoke$
|
|
2209
|
+
const pid = await invoke$2('Process.createE2eFixtureProcess', marker);
|
|
2108
2210
|
return {
|
|
2109
2211
|
...state,
|
|
2110
2212
|
rootPid: pid
|
|
2111
2213
|
};
|
|
2112
2214
|
};
|
|
2113
2215
|
const disposeE2eFixtureProcess = async (_uid, pidOrMarker) => {
|
|
2114
|
-
await invoke$
|
|
2216
|
+
await invoke$2('Process.disposeE2eFixtureProcess', pidOrMarker);
|
|
2115
2217
|
};
|
|
2116
2218
|
|
|
2117
2219
|
const expandAll = state => {
|
|
@@ -2226,7 +2328,7 @@ const DebugProcess = 'Debug Process';
|
|
|
2226
2328
|
|
|
2227
2329
|
const getMenuEntries = state => {
|
|
2228
2330
|
const process = state.visibleProcesses[state.focusedIndex];
|
|
2229
|
-
if (!process) {
|
|
2331
|
+
if (!process || process.synthetic) {
|
|
2230
2332
|
return [];
|
|
2231
2333
|
}
|
|
2232
2334
|
const menuEntries = [{
|
|
@@ -2259,7 +2361,8 @@ const toggleIndex = (state, index) => {
|
|
|
2259
2361
|
if (!process || process.flags === None$2) {
|
|
2260
2362
|
return state;
|
|
2261
2363
|
}
|
|
2262
|
-
const
|
|
2364
|
+
const treeId = process.treeId ?? process.pid;
|
|
2365
|
+
const collapsedPids = state.collapsedPids.includes(treeId) ? state.collapsedPids.filter(pid => pid !== treeId) : [...state.collapsedPids, treeId];
|
|
2263
2366
|
const visibleProcesses = getVisibleProcesses(state.processes, collapsedPids, state.rootPid);
|
|
2264
2367
|
return {
|
|
2265
2368
|
...state,
|
|
@@ -2342,7 +2445,7 @@ const handleContextMenu = async (state, index = state.focusedIndex, x = 0, y = 0
|
|
|
2342
2445
|
focused: false,
|
|
2343
2446
|
focusedIndex: numericIndex
|
|
2344
2447
|
};
|
|
2345
|
-
set$
|
|
2448
|
+
set$a(state.uid, state, newState);
|
|
2346
2449
|
await show2(state.uid, ProcessExplorer$1, x, y, {
|
|
2347
2450
|
index: numericIndex,
|
|
2348
2451
|
menuId: ProcessExplorer$1
|
|
@@ -2370,9 +2473,9 @@ const isConnected = () => {
|
|
|
2370
2473
|
} = state;
|
|
2371
2474
|
return connected;
|
|
2372
2475
|
};
|
|
2373
|
-
const invoke = (method, ...params) => invoke$
|
|
2476
|
+
const invoke = (method, ...params) => invoke$4(method, ...params);
|
|
2374
2477
|
const set$1 = rpc => {
|
|
2375
|
-
set$
|
|
2478
|
+
set$5(rpc);
|
|
2376
2479
|
state.connected = true;
|
|
2377
2480
|
};
|
|
2378
2481
|
|
|
@@ -2383,7 +2486,7 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
|
|
|
2383
2486
|
throw new TypeError(`Viewlet command not found: ${command}`);
|
|
2384
2487
|
}
|
|
2385
2488
|
await fn(uid, ...args);
|
|
2386
|
-
await invoke$
|
|
2489
|
+
await invoke$3('Viewlet.requestRender', uid);
|
|
2387
2490
|
};
|
|
2388
2491
|
const rpc = await create$6({
|
|
2389
2492
|
commandMap: {
|
|
@@ -2398,12 +2501,13 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
|
|
|
2398
2501
|
|
|
2399
2502
|
const killProcess = async (state, index = state.focusedIndex) => {
|
|
2400
2503
|
const process = state.visibleProcesses[index];
|
|
2401
|
-
if (!process) {
|
|
2504
|
+
if (!process || process.synthetic) {
|
|
2402
2505
|
return state;
|
|
2403
2506
|
}
|
|
2404
|
-
const
|
|
2507
|
+
const processExplorer = process.source === 'remote' ? RemoteProcessExplorer : ProcessExplorerModule;
|
|
2508
|
+
const killPromise = processExplorer.invoke('Process.kill', process.pid);
|
|
2405
2509
|
if (process.name === 'process-explorer') {
|
|
2406
|
-
dispose$
|
|
2510
|
+
dispose$4(state.uid);
|
|
2407
2511
|
void killPromise.catch(() => {});
|
|
2408
2512
|
return toProcessExplorerRpcClosedState(state);
|
|
2409
2513
|
}
|
|
@@ -2411,6 +2515,17 @@ const killProcess = async (state, index = state.focusedIndex) => {
|
|
|
2411
2515
|
return state;
|
|
2412
2516
|
};
|
|
2413
2517
|
|
|
2518
|
+
const getErrorCode = (error, fallback) => {
|
|
2519
|
+
if (!error || typeof error !== 'object') {
|
|
2520
|
+
return fallback;
|
|
2521
|
+
}
|
|
2522
|
+
const code = 'code' in error ? error.code : undefined;
|
|
2523
|
+
if (typeof code !== 'string' || !code) {
|
|
2524
|
+
return fallback;
|
|
2525
|
+
}
|
|
2526
|
+
return code;
|
|
2527
|
+
};
|
|
2528
|
+
|
|
2414
2529
|
const getMeasureMemory = () => {
|
|
2415
2530
|
const {
|
|
2416
2531
|
measureUserAgentSpecificMemory
|
|
@@ -2499,6 +2614,31 @@ const getFrontendMemoryUsage = async rootPid => {
|
|
|
2499
2614
|
}
|
|
2500
2615
|
};
|
|
2501
2616
|
|
|
2617
|
+
const createGroup = (name, source, processes, rootPid) => {
|
|
2618
|
+
const groupId = `${source}:group`;
|
|
2619
|
+
const group = {
|
|
2620
|
+
cmd: name,
|
|
2621
|
+
memory: 0,
|
|
2622
|
+
name,
|
|
2623
|
+
parentTreeId: '',
|
|
2624
|
+
pid: 0,
|
|
2625
|
+
ppid: 0,
|
|
2626
|
+
source,
|
|
2627
|
+
synthetic: true,
|
|
2628
|
+
treeId: groupId
|
|
2629
|
+
};
|
|
2630
|
+
const groupedProcesses = processes.map(process => ({
|
|
2631
|
+
...process,
|
|
2632
|
+
parentTreeId: process.pid === rootPid ? groupId : `${source}:${process.ppid}`,
|
|
2633
|
+
source,
|
|
2634
|
+
treeId: `${source}:${process.pid}`
|
|
2635
|
+
}));
|
|
2636
|
+
return [group, ...groupedProcesses];
|
|
2637
|
+
};
|
|
2638
|
+
const groupProcesses = (localProcesses, localRootPid, remoteProcesses, remoteRootPid) => {
|
|
2639
|
+
return [...createGroup('Local', 'local', localProcesses, localRootPid), ...createGroup('Remote', 'remote', remoteProcesses, remoteRootPid)];
|
|
2640
|
+
};
|
|
2641
|
+
|
|
2502
2642
|
const getErrorMessage = error => {
|
|
2503
2643
|
if (error instanceof Error) {
|
|
2504
2644
|
return error.message;
|
|
@@ -2543,27 +2683,40 @@ const getFocusedIndex = (oldFocusedIndex, visibleProcesses) => {
|
|
|
2543
2683
|
}
|
|
2544
2684
|
return Math.min(oldFocusedIndex, visibleProcesses.length - 1);
|
|
2545
2685
|
};
|
|
2546
|
-
const listProcesses = async (rootPid,
|
|
2547
|
-
if (
|
|
2548
|
-
|
|
2549
|
-
return invoke$1('ListProcessesWithMemoryUsage.listProcessesWithMemoryUsage', rootPid, false, pidMap);
|
|
2686
|
+
const listProcesses = async (processExplorer, rootPid, pidMap) => {
|
|
2687
|
+
if (pidMap) {
|
|
2688
|
+
return processExplorer.invoke('ListProcessesWithMemoryUsage.listProcessesWithMemoryUsage', rootPid, false, pidMap);
|
|
2550
2689
|
}
|
|
2551
|
-
return invoke
|
|
2690
|
+
return processExplorer.invoke('ListProcessesWithMemoryUsage.listProcessesWithMemoryUsage', rootPid, false);
|
|
2691
|
+
};
|
|
2692
|
+
const getRootPid = async (processExplorer, rootPid, includeElectronData) => {
|
|
2693
|
+
if (rootPid !== -1) {
|
|
2694
|
+
return rootPid;
|
|
2695
|
+
}
|
|
2696
|
+
return processExplorer.invoke('ProcessId.getMainProcessId', {
|
|
2697
|
+
includeElectronData
|
|
2698
|
+
});
|
|
2552
2699
|
};
|
|
2553
2700
|
const refresh = async state => {
|
|
2554
2701
|
try {
|
|
2555
2702
|
await initializeProcessExplorer(state.platform);
|
|
2556
2703
|
const includeElectronData = state.platform === Electron;
|
|
2557
|
-
const rootPid =
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
const processes = await listProcesses(rootPid, state.platform);
|
|
2704
|
+
const rootPid = await getRootPid(ProcessExplorerModule, state.rootPid, includeElectronData);
|
|
2705
|
+
const pidMap = includeElectronData ? await invoke$5('CreatePidMap.createPidMap') : undefined;
|
|
2706
|
+
const processes = await listProcesses(ProcessExplorerModule, rootPid, pidMap);
|
|
2561
2707
|
const frontendMemoryProcesses = state.includeFrontendMemoryUsage ? await getFrontendMemoryUsage(rootPid) : [];
|
|
2562
2708
|
const allProcesses = [...processes, ...frontendMemoryProcesses];
|
|
2563
|
-
const
|
|
2709
|
+
const localProcesses = state.platform === Electron ? reparentSharedProcessChildren(allProcesses) : allProcesses;
|
|
2710
|
+
let displayedProcesses = localProcesses;
|
|
2711
|
+
if (state.platform === Electron && has()) {
|
|
2712
|
+
const remoteRootPid = await getRootPid(RemoteProcessExplorer, -1, false);
|
|
2713
|
+
const remoteProcesses = await listProcesses(RemoteProcessExplorer, remoteRootPid);
|
|
2714
|
+
displayedProcesses = groupProcesses(localProcesses, rootPid, remoteProcesses, remoteRootPid);
|
|
2715
|
+
}
|
|
2564
2716
|
const visibleProcesses = getVisibleProcesses(displayedProcesses, state.collapsedPids, rootPid);
|
|
2565
2717
|
return {
|
|
2566
2718
|
...state,
|
|
2719
|
+
errorCode: '',
|
|
2567
2720
|
errorCodeFrame: '',
|
|
2568
2721
|
errorMessage: '',
|
|
2569
2722
|
errorStack: '',
|
|
@@ -2577,6 +2730,7 @@ const refresh = async state => {
|
|
|
2577
2730
|
const prettyError = await prepareError(error);
|
|
2578
2731
|
return {
|
|
2579
2732
|
...state,
|
|
2733
|
+
errorCode: getErrorCode(error, ProcessExplorerRefreshFailed),
|
|
2580
2734
|
errorCodeFrame: prettyError.codeFrame || '',
|
|
2581
2735
|
errorMessage: prettyError.message || getErrorMessage(error),
|
|
2582
2736
|
errorStack: prettyError.stack || '',
|
|
@@ -2586,7 +2740,7 @@ const refresh = async state => {
|
|
|
2586
2740
|
};
|
|
2587
2741
|
|
|
2588
2742
|
const hasError$1 = state => {
|
|
2589
|
-
return Boolean(state.errorMessage || state.errorCodeFrame || state.errorStack);
|
|
2743
|
+
return Boolean(state.errorCode || state.errorMessage || state.errorCodeFrame || state.errorStack);
|
|
2590
2744
|
};
|
|
2591
2745
|
const loadContent = async state => {
|
|
2592
2746
|
const newState = await refresh(state);
|
|
@@ -3007,7 +3161,7 @@ const getRowDom = (process, index, focused) => {
|
|
|
3007
3161
|
tabIndex: focused ? 0 : -1,
|
|
3008
3162
|
title: process.cmd,
|
|
3009
3163
|
type: Tr
|
|
3010
|
-
}, ...getCellDom(mergeClassNames(Cell, NameCell), process.name, index, getPaddingLeft(process)), ...getCellDom(Cell, String(process.pid), index), ...getCellDom(Cell, formatMemory(process.memory), index)];
|
|
3164
|
+
}, ...getCellDom(mergeClassNames(Cell, NameCell), process.name, index, getPaddingLeft(process)), ...getCellDom(Cell, process.synthetic ? '' : String(process.pid), index), ...getCellDom(Cell, process.synthetic ? '' : formatMemory(process.memory), index)];
|
|
3011
3165
|
};
|
|
3012
3166
|
const getBodyDom = state => {
|
|
3013
3167
|
const {
|
|
@@ -3032,27 +3186,30 @@ const getErrorSectionDom = (value, type) => {
|
|
|
3032
3186
|
};
|
|
3033
3187
|
const hasError = state => {
|
|
3034
3188
|
const {
|
|
3189
|
+
errorCode,
|
|
3035
3190
|
errorCodeFrame,
|
|
3036
3191
|
errorMessage,
|
|
3037
3192
|
errorStack
|
|
3038
3193
|
} = state;
|
|
3039
|
-
return Boolean(errorMessage || errorCodeFrame || errorStack);
|
|
3194
|
+
return Boolean(errorCode || errorMessage || errorCodeFrame || errorStack);
|
|
3040
3195
|
};
|
|
3041
3196
|
const getErrorDom = state => {
|
|
3042
3197
|
const {
|
|
3198
|
+
errorCode,
|
|
3043
3199
|
errorCodeFrame,
|
|
3044
3200
|
errorMessage,
|
|
3045
3201
|
errorStack
|
|
3046
3202
|
} = state;
|
|
3203
|
+
const errorCodeDom = getErrorSectionDom(errorCode, Div);
|
|
3047
3204
|
const messageDom = getErrorSectionDom(errorMessage, Div);
|
|
3048
3205
|
const codeFrameDom = getErrorSectionDom(errorCodeFrame, Pre);
|
|
3049
3206
|
const stackDom = getErrorSectionDom(errorStack, Pre);
|
|
3050
|
-
const childCount = messageDom.length / 2 + codeFrameDom.length / 2 + stackDom.length / 2;
|
|
3207
|
+
const childCount = errorCodeDom.length / 2 + messageDom.length / 2 + codeFrameDom.length / 2 + stackDom.length / 2;
|
|
3051
3208
|
return [processExplorer, {
|
|
3052
3209
|
childCount,
|
|
3053
3210
|
className: Error$1,
|
|
3054
3211
|
type: Div
|
|
3055
|
-
}, ...messageDom, ...codeFrameDom, ...stackDom];
|
|
3212
|
+
}, ...errorCodeDom, ...messageDom, ...codeFrameDom, ...stackDom];
|
|
3056
3213
|
};
|
|
3057
3214
|
const getTableDom = state => {
|
|
3058
3215
|
const {
|
|
@@ -3129,7 +3286,7 @@ const render2 = (uid, diffResult) => {
|
|
|
3129
3286
|
oldState,
|
|
3130
3287
|
scheduledState
|
|
3131
3288
|
} = get$2(uid);
|
|
3132
|
-
set$
|
|
3289
|
+
set$a(uid, scheduledState, scheduledState);
|
|
3133
3290
|
const commands = applyRender(oldState, scheduledState, diffResult);
|
|
3134
3291
|
if (!isConnected()) return commands;
|
|
3135
3292
|
return renderDirect(uid, commands);
|
|
@@ -3206,6 +3363,7 @@ const setError = async (state, rawError) => {
|
|
|
3206
3363
|
const prettyError = await prepareError(error);
|
|
3207
3364
|
return {
|
|
3208
3365
|
...state,
|
|
3366
|
+
errorCode: getErrorCode(error, ProcessExplorerError),
|
|
3209
3367
|
errorCodeFrame: prettyError.codeFrame || '',
|
|
3210
3368
|
errorMessage: prettyError.message || getErrorMessage(error),
|
|
3211
3369
|
errorStack: prettyError.stack || '',
|
|
@@ -3285,7 +3443,7 @@ const createErrorWorkerRpc = async () => {
|
|
|
3285
3443
|
|
|
3286
3444
|
const initializeErrorWorker = async () => {
|
|
3287
3445
|
const rpc = await createErrorWorkerRpc();
|
|
3288
|
-
set$
|
|
3446
|
+
set$8(rpc);
|
|
3289
3447
|
};
|
|
3290
3448
|
|
|
3291
3449
|
const sendMessagePortToFileSystemWorker = async port => {
|
|
@@ -3317,7 +3475,7 @@ const initializeRendererWorker = async () => {
|
|
|
3317
3475
|
const rpc = await create({
|
|
3318
3476
|
commandMap: commandMap
|
|
3319
3477
|
});
|
|
3320
|
-
set$
|
|
3478
|
+
set$4(rpc);
|
|
3321
3479
|
};
|
|
3322
3480
|
|
|
3323
3481
|
const listen = async () => {
|