@lvce-editor/process-explorer-worker 3.21.1 → 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 +215 -80
- 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
|
|
@@ -290,7 +299,7 @@ const create$d = (id, _uri, x, y, width, height, args, parentUid, platform = 0,
|
|
|
290
299
|
x,
|
|
291
300
|
y
|
|
292
301
|
};
|
|
293
|
-
set$
|
|
302
|
+
set$a(state.uid, state, state);
|
|
294
303
|
return state;
|
|
295
304
|
};
|
|
296
305
|
|
|
@@ -1269,7 +1278,7 @@ const createMockRpc = ({
|
|
|
1269
1278
|
};
|
|
1270
1279
|
|
|
1271
1280
|
const rpcs = Object.create(null);
|
|
1272
|
-
const set$
|
|
1281
|
+
const set$9 = (id, rpc) => {
|
|
1273
1282
|
rpcs[id] = rpc;
|
|
1274
1283
|
};
|
|
1275
1284
|
const get = id => {
|
|
@@ -1302,7 +1311,7 @@ const create$a = rpcId => {
|
|
|
1302
1311
|
const mockRpc = createMockRpc({
|
|
1303
1312
|
commandMap
|
|
1304
1313
|
});
|
|
1305
|
-
set$
|
|
1314
|
+
set$9(rpcId, mockRpc);
|
|
1306
1315
|
// @ts-ignore
|
|
1307
1316
|
mockRpc[Symbol.dispose] = () => {
|
|
1308
1317
|
remove(rpcId);
|
|
@@ -1311,7 +1320,7 @@ const create$a = rpcId => {
|
|
|
1311
1320
|
return mockRpc;
|
|
1312
1321
|
},
|
|
1313
1322
|
set(rpc) {
|
|
1314
|
-
set$
|
|
1323
|
+
set$9(rpcId, rpc);
|
|
1315
1324
|
}
|
|
1316
1325
|
};
|
|
1317
1326
|
};
|
|
@@ -1522,44 +1531,44 @@ const Empty = 0;
|
|
|
1522
1531
|
const FocusExplorer = 13;
|
|
1523
1532
|
|
|
1524
1533
|
const {
|
|
1525
|
-
invoke: invoke$
|
|
1526
|
-
set: set$
|
|
1534
|
+
invoke: invoke$6,
|
|
1535
|
+
set: set$8
|
|
1527
1536
|
} = create$a(ErrorWorker);
|
|
1528
1537
|
const prepare = async error => {
|
|
1529
|
-
return invoke$
|
|
1538
|
+
return invoke$6('Errors.prepare', error);
|
|
1530
1539
|
};
|
|
1531
1540
|
|
|
1532
1541
|
const {
|
|
1533
|
-
set: set$
|
|
1542
|
+
set: set$7
|
|
1534
1543
|
} = create$a(FileSystemWorker$1);
|
|
1535
1544
|
|
|
1536
1545
|
const FileSystemWorker = {
|
|
1537
1546
|
__proto__: null,
|
|
1538
|
-
set: set$
|
|
1547
|
+
set: set$7
|
|
1539
1548
|
};
|
|
1540
1549
|
|
|
1541
1550
|
const {
|
|
1542
|
-
dispose: dispose$
|
|
1543
|
-
invoke: invoke$
|
|
1544
|
-
set: set$
|
|
1551
|
+
dispose: dispose$5,
|
|
1552
|
+
invoke: invoke$5,
|
|
1553
|
+
set: set$6
|
|
1545
1554
|
} = create$a(MainProcess);
|
|
1546
1555
|
|
|
1547
1556
|
const {
|
|
1548
|
-
invoke: invoke$
|
|
1549
|
-
set: set$
|
|
1557
|
+
invoke: invoke$4,
|
|
1558
|
+
set: set$5
|
|
1550
1559
|
} = create$a(RendererProcess);
|
|
1551
1560
|
|
|
1552
1561
|
const {
|
|
1553
|
-
invoke: invoke$
|
|
1562
|
+
invoke: invoke$3,
|
|
1554
1563
|
invokeAndTransfer,
|
|
1555
|
-
set: set$
|
|
1564
|
+
set: set$4
|
|
1556
1565
|
} = create$a(RendererWorker);
|
|
1557
1566
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1558
1567
|
number(uid);
|
|
1559
1568
|
number(menuId);
|
|
1560
1569
|
number(x);
|
|
1561
1570
|
number(y);
|
|
1562
|
-
await invoke$
|
|
1571
|
+
await invoke$3('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1563
1572
|
};
|
|
1564
1573
|
const sendMessagePortToErrorWorker$1 = async (port, rpcId) => {
|
|
1565
1574
|
const command = 'Errors.handleMessagePort';
|
|
@@ -1579,7 +1588,7 @@ const debugProcess = async (state, index = state.focusedIndex) => {
|
|
|
1579
1588
|
if (!process) {
|
|
1580
1589
|
return state;
|
|
1581
1590
|
}
|
|
1582
|
-
await invoke$
|
|
1591
|
+
await invoke$3('AttachDebugger.attachDebugger', process.pid);
|
|
1583
1592
|
return state;
|
|
1584
1593
|
};
|
|
1585
1594
|
|
|
@@ -1620,7 +1629,7 @@ const diff2 = uid => {
|
|
|
1620
1629
|
|
|
1621
1630
|
const intervals = new Map();
|
|
1622
1631
|
const pending = new Set();
|
|
1623
|
-
const dispose$
|
|
1632
|
+
const dispose$4 = uid => {
|
|
1624
1633
|
const interval = intervals.get(uid);
|
|
1625
1634
|
if (interval) {
|
|
1626
1635
|
clearInterval(interval);
|
|
@@ -1630,7 +1639,7 @@ const dispose$3 = uid => {
|
|
|
1630
1639
|
};
|
|
1631
1640
|
const update = async uid => {
|
|
1632
1641
|
if (!getKeys$1().includes(uid)) {
|
|
1633
|
-
dispose$
|
|
1642
|
+
dispose$4(uid);
|
|
1634
1643
|
return;
|
|
1635
1644
|
}
|
|
1636
1645
|
if (pending.has(uid)) {
|
|
@@ -1638,7 +1647,7 @@ const update = async uid => {
|
|
|
1638
1647
|
}
|
|
1639
1648
|
pending.add(uid);
|
|
1640
1649
|
try {
|
|
1641
|
-
await invoke$
|
|
1650
|
+
await invoke$3('ProcessExplorer.update');
|
|
1642
1651
|
} catch (error) {
|
|
1643
1652
|
console.error(error);
|
|
1644
1653
|
} finally {
|
|
@@ -1655,7 +1664,7 @@ const start = (uid, interval = processExplorerUpdateInterval) => {
|
|
|
1655
1664
|
intervals.set(uid, intervalId);
|
|
1656
1665
|
};
|
|
1657
1666
|
const restart = (uid, interval) => {
|
|
1658
|
-
dispose$
|
|
1667
|
+
dispose$4(uid);
|
|
1659
1668
|
start(uid, interval);
|
|
1660
1669
|
};
|
|
1661
1670
|
|
|
@@ -1681,17 +1690,17 @@ const handleProcessExplorerRpcClose = async () => {
|
|
|
1681
1690
|
if (!viewletState) {
|
|
1682
1691
|
continue;
|
|
1683
1692
|
}
|
|
1684
|
-
dispose$
|
|
1693
|
+
dispose$4(uid);
|
|
1685
1694
|
const {
|
|
1686
1695
|
oldState,
|
|
1687
1696
|
scheduledState
|
|
1688
1697
|
} = viewletState;
|
|
1689
1698
|
const newState = toProcessExplorerRpcClosedState(scheduledState);
|
|
1690
|
-
set$
|
|
1699
|
+
set$a(uid, oldState, newState);
|
|
1691
1700
|
didUpdate = true;
|
|
1692
1701
|
}
|
|
1693
1702
|
if (didUpdate) {
|
|
1694
|
-
await invoke$
|
|
1703
|
+
await invoke$3('ProcessExplorer.rerender');
|
|
1695
1704
|
}
|
|
1696
1705
|
};
|
|
1697
1706
|
|
|
@@ -2013,7 +2022,7 @@ const launchProcessExplorerNode = async onClose => {
|
|
|
2013
2022
|
const {
|
|
2014
2023
|
protocols,
|
|
2015
2024
|
url
|
|
2016
|
-
} = await invoke$
|
|
2025
|
+
} = await invoke$3('WebSocketCapability.create', 'process-explorer');
|
|
2017
2026
|
const webSocket = new WebSocket(url, protocols);
|
|
2018
2027
|
webSocket.addEventListener('close', onClose);
|
|
2019
2028
|
return await create$3({
|
|
@@ -2036,18 +2045,58 @@ const launchProcessExplorerNode = async onClose => {
|
|
|
2036
2045
|
}
|
|
2037
2046
|
};
|
|
2038
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
|
+
|
|
2039
2079
|
const state$2 = {
|
|
2040
2080
|
rpc: undefined
|
|
2041
2081
|
};
|
|
2042
2082
|
const invoke$1 = async (method, ...params) => {
|
|
2043
|
-
|
|
2044
|
-
|
|
2083
|
+
const {
|
|
2084
|
+
rpc
|
|
2085
|
+
} = state$2;
|
|
2086
|
+
if (!rpc) {
|
|
2087
|
+
throw new Error('RemoteProcessExplorerModule is not initialized');
|
|
2045
2088
|
}
|
|
2046
|
-
return
|
|
2089
|
+
return rpc.invoke(method, ...params);
|
|
2047
2090
|
};
|
|
2048
2091
|
const set$2 = newRpc => {
|
|
2049
2092
|
state$2.rpc = newRpc;
|
|
2050
2093
|
};
|
|
2094
|
+
const has = () => {
|
|
2095
|
+
const {
|
|
2096
|
+
rpc
|
|
2097
|
+
} = state$2;
|
|
2098
|
+
return Boolean(rpc);
|
|
2099
|
+
};
|
|
2051
2100
|
const clear = () => {
|
|
2052
2101
|
state$2.rpc = undefined;
|
|
2053
2102
|
};
|
|
@@ -2059,16 +2108,61 @@ const dispose$2 = async () => {
|
|
|
2059
2108
|
await rpc?.dispose();
|
|
2060
2109
|
};
|
|
2061
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
|
+
|
|
2062
2120
|
const state$1 = {
|
|
2063
|
-
initializedPlatform: 0
|
|
2121
|
+
initializedPlatform: 0,
|
|
2122
|
+
remoteInitialized: false
|
|
2064
2123
|
};
|
|
2065
2124
|
const handleClose = async () => {
|
|
2066
2125
|
state$1.initializedPlatform = 0;
|
|
2067
|
-
clear();
|
|
2126
|
+
clear$1();
|
|
2068
2127
|
await handleProcessExplorerRpcClose();
|
|
2069
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
|
+
};
|
|
2070
2161
|
const initializeProcessExplorer = async platform => {
|
|
2071
2162
|
if (state$1.initializedPlatform === platform) {
|
|
2163
|
+
if (platform === Electron) {
|
|
2164
|
+
await initializeRemoteProcessExplorer();
|
|
2165
|
+
}
|
|
2072
2166
|
return;
|
|
2073
2167
|
}
|
|
2074
2168
|
if (platform === Electron) {
|
|
@@ -2076,16 +2170,17 @@ const initializeProcessExplorer = async platform => {
|
|
|
2076
2170
|
mainProcessRpc,
|
|
2077
2171
|
processExplorerRpc
|
|
2078
2172
|
} = await launchProcessExplorerElectron();
|
|
2079
|
-
set$
|
|
2080
|
-
set$
|
|
2173
|
+
set$6(mainProcessRpc);
|
|
2174
|
+
set$3(processExplorerRpc);
|
|
2081
2175
|
state$1.initializedPlatform = platform;
|
|
2176
|
+
await initializeRemoteProcessExplorer();
|
|
2082
2177
|
return;
|
|
2083
2178
|
}
|
|
2084
2179
|
if (platform === Remote) {
|
|
2085
2180
|
const rpc = await launchProcessExplorerNode(() => {
|
|
2086
2181
|
void handleClose();
|
|
2087
2182
|
});
|
|
2088
|
-
set$
|
|
2183
|
+
set$3(rpc);
|
|
2089
2184
|
state$1.initializedPlatform = platform;
|
|
2090
2185
|
}
|
|
2091
2186
|
};
|
|
@@ -2094,30 +2189,31 @@ const dispose$1 = async () => {
|
|
|
2094
2189
|
initializedPlatform
|
|
2095
2190
|
} = state$1;
|
|
2096
2191
|
state$1.initializedPlatform = 0;
|
|
2192
|
+
state$1.remoteInitialized = false;
|
|
2097
2193
|
if (initializedPlatform === Electron) {
|
|
2098
|
-
await Promise.all([dispose$
|
|
2194
|
+
await Promise.all([dispose$5(), dispose$3(), dispose$2()]);
|
|
2099
2195
|
return;
|
|
2100
2196
|
}
|
|
2101
|
-
await dispose$2();
|
|
2197
|
+
await Promise.all([dispose$3(), dispose$2()]);
|
|
2102
2198
|
};
|
|
2103
2199
|
|
|
2104
2200
|
const dispose = async uid => {
|
|
2105
|
-
dispose$
|
|
2106
|
-
dispose$
|
|
2201
|
+
dispose$4(uid);
|
|
2202
|
+
dispose$6(uid);
|
|
2107
2203
|
if (getKeys$1().length === 0) {
|
|
2108
2204
|
await dispose$1();
|
|
2109
2205
|
}
|
|
2110
2206
|
};
|
|
2111
2207
|
|
|
2112
2208
|
const createE2eFixtureProcess = async (state, marker) => {
|
|
2113
|
-
const pid = await invoke$
|
|
2209
|
+
const pid = await invoke$2('Process.createE2eFixtureProcess', marker);
|
|
2114
2210
|
return {
|
|
2115
2211
|
...state,
|
|
2116
2212
|
rootPid: pid
|
|
2117
2213
|
};
|
|
2118
2214
|
};
|
|
2119
2215
|
const disposeE2eFixtureProcess = async (_uid, pidOrMarker) => {
|
|
2120
|
-
await invoke$
|
|
2216
|
+
await invoke$2('Process.disposeE2eFixtureProcess', pidOrMarker);
|
|
2121
2217
|
};
|
|
2122
2218
|
|
|
2123
2219
|
const expandAll = state => {
|
|
@@ -2232,7 +2328,7 @@ const DebugProcess = 'Debug Process';
|
|
|
2232
2328
|
|
|
2233
2329
|
const getMenuEntries = state => {
|
|
2234
2330
|
const process = state.visibleProcesses[state.focusedIndex];
|
|
2235
|
-
if (!process) {
|
|
2331
|
+
if (!process || process.synthetic) {
|
|
2236
2332
|
return [];
|
|
2237
2333
|
}
|
|
2238
2334
|
const menuEntries = [{
|
|
@@ -2265,7 +2361,8 @@ const toggleIndex = (state, index) => {
|
|
|
2265
2361
|
if (!process || process.flags === None$2) {
|
|
2266
2362
|
return state;
|
|
2267
2363
|
}
|
|
2268
|
-
const
|
|
2364
|
+
const treeId = process.treeId ?? process.pid;
|
|
2365
|
+
const collapsedPids = state.collapsedPids.includes(treeId) ? state.collapsedPids.filter(pid => pid !== treeId) : [...state.collapsedPids, treeId];
|
|
2269
2366
|
const visibleProcesses = getVisibleProcesses(state.processes, collapsedPids, state.rootPid);
|
|
2270
2367
|
return {
|
|
2271
2368
|
...state,
|
|
@@ -2348,7 +2445,7 @@ const handleContextMenu = async (state, index = state.focusedIndex, x = 0, y = 0
|
|
|
2348
2445
|
focused: false,
|
|
2349
2446
|
focusedIndex: numericIndex
|
|
2350
2447
|
};
|
|
2351
|
-
set$
|
|
2448
|
+
set$a(state.uid, state, newState);
|
|
2352
2449
|
await show2(state.uid, ProcessExplorer$1, x, y, {
|
|
2353
2450
|
index: numericIndex,
|
|
2354
2451
|
menuId: ProcessExplorer$1
|
|
@@ -2376,9 +2473,9 @@ const isConnected = () => {
|
|
|
2376
2473
|
} = state;
|
|
2377
2474
|
return connected;
|
|
2378
2475
|
};
|
|
2379
|
-
const invoke = (method, ...params) => invoke$
|
|
2476
|
+
const invoke = (method, ...params) => invoke$4(method, ...params);
|
|
2380
2477
|
const set$1 = rpc => {
|
|
2381
|
-
set$
|
|
2478
|
+
set$5(rpc);
|
|
2382
2479
|
state.connected = true;
|
|
2383
2480
|
};
|
|
2384
2481
|
|
|
@@ -2389,7 +2486,7 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
|
|
|
2389
2486
|
throw new TypeError(`Viewlet command not found: ${command}`);
|
|
2390
2487
|
}
|
|
2391
2488
|
await fn(uid, ...args);
|
|
2392
|
-
await invoke$
|
|
2489
|
+
await invoke$3('Viewlet.requestRender', uid);
|
|
2393
2490
|
};
|
|
2394
2491
|
const rpc = await create$6({
|
|
2395
2492
|
commandMap: {
|
|
@@ -2404,12 +2501,13 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
|
|
|
2404
2501
|
|
|
2405
2502
|
const killProcess = async (state, index = state.focusedIndex) => {
|
|
2406
2503
|
const process = state.visibleProcesses[index];
|
|
2407
|
-
if (!process) {
|
|
2504
|
+
if (!process || process.synthetic) {
|
|
2408
2505
|
return state;
|
|
2409
2506
|
}
|
|
2410
|
-
const
|
|
2507
|
+
const processExplorer = process.source === 'remote' ? RemoteProcessExplorer : ProcessExplorerModule;
|
|
2508
|
+
const killPromise = processExplorer.invoke('Process.kill', process.pid);
|
|
2411
2509
|
if (process.name === 'process-explorer') {
|
|
2412
|
-
dispose$
|
|
2510
|
+
dispose$4(state.uid);
|
|
2413
2511
|
void killPromise.catch(() => {});
|
|
2414
2512
|
return toProcessExplorerRpcClosedState(state);
|
|
2415
2513
|
}
|
|
@@ -2516,6 +2614,31 @@ const getFrontendMemoryUsage = async rootPid => {
|
|
|
2516
2614
|
}
|
|
2517
2615
|
};
|
|
2518
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
|
+
|
|
2519
2642
|
const getErrorMessage = error => {
|
|
2520
2643
|
if (error instanceof Error) {
|
|
2521
2644
|
return error.message;
|
|
@@ -2560,24 +2683,36 @@ const getFocusedIndex = (oldFocusedIndex, visibleProcesses) => {
|
|
|
2560
2683
|
}
|
|
2561
2684
|
return Math.min(oldFocusedIndex, visibleProcesses.length - 1);
|
|
2562
2685
|
};
|
|
2563
|
-
const listProcesses = async (rootPid,
|
|
2564
|
-
if (
|
|
2565
|
-
|
|
2566
|
-
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);
|
|
2567
2689
|
}
|
|
2568
|
-
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
|
+
});
|
|
2569
2699
|
};
|
|
2570
2700
|
const refresh = async state => {
|
|
2571
2701
|
try {
|
|
2572
2702
|
await initializeProcessExplorer(state.platform);
|
|
2573
2703
|
const includeElectronData = state.platform === Electron;
|
|
2574
|
-
const rootPid =
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
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);
|
|
2578
2707
|
const frontendMemoryProcesses = state.includeFrontendMemoryUsage ? await getFrontendMemoryUsage(rootPid) : [];
|
|
2579
2708
|
const allProcesses = [...processes, ...frontendMemoryProcesses];
|
|
2580
|
-
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
|
+
}
|
|
2581
2716
|
const visibleProcesses = getVisibleProcesses(displayedProcesses, state.collapsedPids, rootPid);
|
|
2582
2717
|
return {
|
|
2583
2718
|
...state,
|
|
@@ -3026,7 +3161,7 @@ const getRowDom = (process, index, focused) => {
|
|
|
3026
3161
|
tabIndex: focused ? 0 : -1,
|
|
3027
3162
|
title: process.cmd,
|
|
3028
3163
|
type: Tr
|
|
3029
|
-
}, ...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)];
|
|
3030
3165
|
};
|
|
3031
3166
|
const getBodyDom = state => {
|
|
3032
3167
|
const {
|
|
@@ -3151,7 +3286,7 @@ const render2 = (uid, diffResult) => {
|
|
|
3151
3286
|
oldState,
|
|
3152
3287
|
scheduledState
|
|
3153
3288
|
} = get$2(uid);
|
|
3154
|
-
set$
|
|
3289
|
+
set$a(uid, scheduledState, scheduledState);
|
|
3155
3290
|
const commands = applyRender(oldState, scheduledState, diffResult);
|
|
3156
3291
|
if (!isConnected()) return commands;
|
|
3157
3292
|
return renderDirect(uid, commands);
|
|
@@ -3308,7 +3443,7 @@ const createErrorWorkerRpc = async () => {
|
|
|
3308
3443
|
|
|
3309
3444
|
const initializeErrorWorker = async () => {
|
|
3310
3445
|
const rpc = await createErrorWorkerRpc();
|
|
3311
|
-
set$
|
|
3446
|
+
set$8(rpc);
|
|
3312
3447
|
};
|
|
3313
3448
|
|
|
3314
3449
|
const sendMessagePortToFileSystemWorker = async port => {
|
|
@@ -3340,7 +3475,7 @@ const initializeRendererWorker = async () => {
|
|
|
3340
3475
|
const rpc = await create({
|
|
3341
3476
|
commandMap: commandMap
|
|
3342
3477
|
});
|
|
3343
|
-
set$
|
|
3478
|
+
set$4(rpc);
|
|
3344
3479
|
};
|
|
3345
3480
|
|
|
3346
3481
|
const listen = async () => {
|