@lvce-editor/process-explorer-worker 3.12.0 → 3.12.1
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 +507 -387
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -235,12 +235,12 @@ const collapseAll = state => {
|
|
|
235
235
|
};
|
|
236
236
|
|
|
237
237
|
const {
|
|
238
|
-
dispose: dispose$
|
|
238
|
+
dispose: dispose$5,
|
|
239
239
|
get: get$2,
|
|
240
240
|
getCommandIds,
|
|
241
241
|
getKeys: getKeys$1,
|
|
242
242
|
registerCommands,
|
|
243
|
-
set: set$
|
|
243
|
+
set: set$7,
|
|
244
244
|
wrapCommand,
|
|
245
245
|
wrapGetter,
|
|
246
246
|
wrapLoadContent
|
|
@@ -289,7 +289,7 @@ const create$d = (id, _uri, x, y, width, height, args, parentUid, platform = 0,
|
|
|
289
289
|
x,
|
|
290
290
|
y
|
|
291
291
|
};
|
|
292
|
-
set$
|
|
292
|
+
set$7(state.uid, state, state);
|
|
293
293
|
return state;
|
|
294
294
|
};
|
|
295
295
|
|
|
@@ -944,7 +944,10 @@ const constructError = (message, type, name) => {
|
|
|
944
944
|
if (ErrorConstructor === Error) {
|
|
945
945
|
const error = new Error(message);
|
|
946
946
|
if (name && name !== 'VError') {
|
|
947
|
-
error
|
|
947
|
+
Object.defineProperty(error, 'name', {
|
|
948
|
+
configurable: true,
|
|
949
|
+
value: name
|
|
950
|
+
});
|
|
948
951
|
}
|
|
949
952
|
return error;
|
|
950
953
|
}
|
|
@@ -975,31 +978,45 @@ const getParentStack = error => {
|
|
|
975
978
|
};
|
|
976
979
|
const MethodNotFound = -32601;
|
|
977
980
|
const Custom = -32001;
|
|
981
|
+
const setStack = (error, stack) => {
|
|
982
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
983
|
+
if (descriptor) {
|
|
984
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
988
|
+
error.stack = stack;
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
Object.defineProperty(error, 'stack', {
|
|
993
|
+
configurable: true,
|
|
994
|
+
value: stack,
|
|
995
|
+
writable: true
|
|
996
|
+
});
|
|
997
|
+
};
|
|
978
998
|
const restoreExistingError = (error, currentStack) => {
|
|
979
999
|
if (typeof error.stack === 'string') {
|
|
980
|
-
error
|
|
1000
|
+
setStack(error, `${error.stack}${NewLine}${currentStack}`);
|
|
981
1001
|
}
|
|
982
1002
|
return error;
|
|
983
1003
|
};
|
|
984
1004
|
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
985
1005
|
const restoredError = new JsonRpcError(error.message);
|
|
986
1006
|
const parentStack = getParentStack(error);
|
|
987
|
-
restoredError
|
|
1007
|
+
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
988
1008
|
return restoredError;
|
|
989
1009
|
};
|
|
990
1010
|
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
991
1011
|
if (error.data.stack && error.data.type && error.message) {
|
|
992
|
-
restoredError
|
|
1012
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
|
|
993
1013
|
return;
|
|
994
1014
|
}
|
|
995
1015
|
if (error.data.stack) {
|
|
996
|
-
restoredError
|
|
1016
|
+
setStack(restoredError, error.data.stack);
|
|
997
1017
|
}
|
|
998
1018
|
};
|
|
999
1019
|
const applyDataProperties = (restoredError, error) => {
|
|
1000
|
-
if (!error.data) {
|
|
1001
|
-
return;
|
|
1002
|
-
}
|
|
1003
1020
|
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
1004
1021
|
if (error.data.codeFrame) {
|
|
1005
1022
|
// @ts-ignore
|
|
@@ -1020,7 +1037,7 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
1020
1037
|
const indexNewLine = getNewLineIndex(lowerStack);
|
|
1021
1038
|
const parentStack = getParentStack(error);
|
|
1022
1039
|
// @ts-ignore
|
|
1023
|
-
restoredError
|
|
1040
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
1024
1041
|
}
|
|
1025
1042
|
if (error.codeFrame) {
|
|
1026
1043
|
// @ts-ignore
|
|
@@ -1230,280 +1247,6 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
1230
1247
|
throw new JsonRpcError('unexpected message');
|
|
1231
1248
|
};
|
|
1232
1249
|
|
|
1233
|
-
const Two = '2.0';
|
|
1234
|
-
|
|
1235
|
-
const create$a = (method, params) => {
|
|
1236
|
-
return {
|
|
1237
|
-
jsonrpc: Two,
|
|
1238
|
-
method,
|
|
1239
|
-
params
|
|
1240
|
-
};
|
|
1241
|
-
};
|
|
1242
|
-
|
|
1243
|
-
const create$9 = (id, method, params) => {
|
|
1244
|
-
const message = {
|
|
1245
|
-
id,
|
|
1246
|
-
jsonrpc: Two,
|
|
1247
|
-
method,
|
|
1248
|
-
params
|
|
1249
|
-
};
|
|
1250
|
-
return message;
|
|
1251
|
-
};
|
|
1252
|
-
|
|
1253
|
-
let id = 0;
|
|
1254
|
-
const create$8 = () => {
|
|
1255
|
-
return ++id;
|
|
1256
|
-
};
|
|
1257
|
-
|
|
1258
|
-
const registerPromise = map => {
|
|
1259
|
-
const id = create$8();
|
|
1260
|
-
const {
|
|
1261
|
-
promise,
|
|
1262
|
-
resolve
|
|
1263
|
-
} = Promise.withResolvers();
|
|
1264
|
-
map[id] = resolve;
|
|
1265
|
-
return {
|
|
1266
|
-
id,
|
|
1267
|
-
promise
|
|
1268
|
-
};
|
|
1269
|
-
};
|
|
1270
|
-
|
|
1271
|
-
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
1272
|
-
const {
|
|
1273
|
-
id,
|
|
1274
|
-
promise
|
|
1275
|
-
} = registerPromise(callbacks);
|
|
1276
|
-
const message = create$9(id, method, params);
|
|
1277
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1278
|
-
ipc.sendAndTransfer(message);
|
|
1279
|
-
} else {
|
|
1280
|
-
ipc.send(message);
|
|
1281
|
-
}
|
|
1282
|
-
const responseMessage = await promise;
|
|
1283
|
-
return unwrapJsonRpcResult(responseMessage);
|
|
1284
|
-
};
|
|
1285
|
-
const createRpc = ipc => {
|
|
1286
|
-
const callbacks = Object.create(null);
|
|
1287
|
-
ipc._resolve = (id, response) => {
|
|
1288
|
-
const fn = callbacks[id];
|
|
1289
|
-
if (!fn) {
|
|
1290
|
-
console.warn(`callback ${id} may already be disposed`);
|
|
1291
|
-
return;
|
|
1292
|
-
}
|
|
1293
|
-
fn(response);
|
|
1294
|
-
delete callbacks[id];
|
|
1295
|
-
};
|
|
1296
|
-
const rpc = {
|
|
1297
|
-
async dispose() {
|
|
1298
|
-
await ipc?.dispose();
|
|
1299
|
-
},
|
|
1300
|
-
invoke(method, ...params) {
|
|
1301
|
-
return invokeHelper(callbacks, ipc, method, params, false);
|
|
1302
|
-
},
|
|
1303
|
-
invokeAndTransfer(method, ...params) {
|
|
1304
|
-
return invokeHelper(callbacks, ipc, method, params, true);
|
|
1305
|
-
},
|
|
1306
|
-
// @ts-ignore
|
|
1307
|
-
ipc,
|
|
1308
|
-
/**
|
|
1309
|
-
* @deprecated
|
|
1310
|
-
*/
|
|
1311
|
-
send(method, ...params) {
|
|
1312
|
-
const message = create$a(method, params);
|
|
1313
|
-
ipc.send(message);
|
|
1314
|
-
}
|
|
1315
|
-
};
|
|
1316
|
-
return rpc;
|
|
1317
|
-
};
|
|
1318
|
-
|
|
1319
|
-
const requiresSocket = () => {
|
|
1320
|
-
return false;
|
|
1321
|
-
};
|
|
1322
|
-
const preparePrettyError = error => {
|
|
1323
|
-
return error;
|
|
1324
|
-
};
|
|
1325
|
-
const logError = () => {
|
|
1326
|
-
// handled by renderer worker
|
|
1327
|
-
};
|
|
1328
|
-
const handleMessage = event => {
|
|
1329
|
-
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
1330
|
-
const actualExecute = event?.target?.execute || execute;
|
|
1331
|
-
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
1332
|
-
};
|
|
1333
|
-
|
|
1334
|
-
const handleIpc = ipc => {
|
|
1335
|
-
if ('addEventListener' in ipc) {
|
|
1336
|
-
ipc.addEventListener('message', handleMessage);
|
|
1337
|
-
} else if ('on' in ipc) {
|
|
1338
|
-
// deprecated
|
|
1339
|
-
ipc.on('message', handleMessage);
|
|
1340
|
-
}
|
|
1341
|
-
};
|
|
1342
|
-
|
|
1343
|
-
const listen$1 = async (module, options) => {
|
|
1344
|
-
const rawIpc = await module.listen(options);
|
|
1345
|
-
if (module.signal) {
|
|
1346
|
-
module.signal(rawIpc);
|
|
1347
|
-
}
|
|
1348
|
-
const ipc = module.wrap(rawIpc);
|
|
1349
|
-
return ipc;
|
|
1350
|
-
};
|
|
1351
|
-
|
|
1352
|
-
const create$7 = async ({
|
|
1353
|
-
commandMap,
|
|
1354
|
-
isMessagePortOpen = true,
|
|
1355
|
-
messagePort
|
|
1356
|
-
}) => {
|
|
1357
|
-
// TODO create a commandMap per rpc instance
|
|
1358
|
-
register(commandMap);
|
|
1359
|
-
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
1360
|
-
isMessagePortOpen,
|
|
1361
|
-
messagePort
|
|
1362
|
-
});
|
|
1363
|
-
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
1364
|
-
handleIpc(ipc);
|
|
1365
|
-
const rpc = createRpc(ipc);
|
|
1366
|
-
messagePort.start();
|
|
1367
|
-
return rpc;
|
|
1368
|
-
};
|
|
1369
|
-
|
|
1370
|
-
const create$6 = async ({
|
|
1371
|
-
commandMap,
|
|
1372
|
-
isMessagePortOpen,
|
|
1373
|
-
send
|
|
1374
|
-
}) => {
|
|
1375
|
-
const {
|
|
1376
|
-
port1,
|
|
1377
|
-
port2
|
|
1378
|
-
} = new MessageChannel();
|
|
1379
|
-
await send(port1);
|
|
1380
|
-
return create$7({
|
|
1381
|
-
commandMap,
|
|
1382
|
-
isMessagePortOpen,
|
|
1383
|
-
messagePort: port2
|
|
1384
|
-
});
|
|
1385
|
-
};
|
|
1386
|
-
|
|
1387
|
-
const createSharedLazyRpc = factory => {
|
|
1388
|
-
let rpcPromise;
|
|
1389
|
-
const getOrCreate = () => {
|
|
1390
|
-
if (!rpcPromise) {
|
|
1391
|
-
rpcPromise = factory();
|
|
1392
|
-
}
|
|
1393
|
-
return rpcPromise;
|
|
1394
|
-
};
|
|
1395
|
-
return {
|
|
1396
|
-
async dispose() {
|
|
1397
|
-
const rpc = await getOrCreate();
|
|
1398
|
-
await rpc.dispose();
|
|
1399
|
-
},
|
|
1400
|
-
async invoke(method, ...params) {
|
|
1401
|
-
const rpc = await getOrCreate();
|
|
1402
|
-
return rpc.invoke(method, ...params);
|
|
1403
|
-
},
|
|
1404
|
-
async invokeAndTransfer(method, ...params) {
|
|
1405
|
-
const rpc = await getOrCreate();
|
|
1406
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
1407
|
-
},
|
|
1408
|
-
async send(method, ...params) {
|
|
1409
|
-
const rpc = await getOrCreate();
|
|
1410
|
-
rpc.send(method, ...params);
|
|
1411
|
-
}
|
|
1412
|
-
};
|
|
1413
|
-
};
|
|
1414
|
-
|
|
1415
|
-
const create$5 = async ({
|
|
1416
|
-
commandMap,
|
|
1417
|
-
isMessagePortOpen,
|
|
1418
|
-
send
|
|
1419
|
-
}) => {
|
|
1420
|
-
return createSharedLazyRpc(() => {
|
|
1421
|
-
return create$6({
|
|
1422
|
-
commandMap,
|
|
1423
|
-
isMessagePortOpen,
|
|
1424
|
-
send
|
|
1425
|
-
});
|
|
1426
|
-
});
|
|
1427
|
-
};
|
|
1428
|
-
|
|
1429
|
-
const Https = 'https:';
|
|
1430
|
-
const Ws = 'ws:';
|
|
1431
|
-
const Wss = 'wss:';
|
|
1432
|
-
|
|
1433
|
-
const getWebSocketProtocol = locationProtocol => {
|
|
1434
|
-
return locationProtocol === Https ? Wss : Ws;
|
|
1435
|
-
};
|
|
1436
|
-
|
|
1437
|
-
const getWebSocketUrl = (type, host, locationProtocol) => {
|
|
1438
|
-
const wsProtocol = getWebSocketProtocol(locationProtocol);
|
|
1439
|
-
return `${wsProtocol}//${host}/websocket/${type}`;
|
|
1440
|
-
};
|
|
1441
|
-
|
|
1442
|
-
const getHost = () => {
|
|
1443
|
-
return location.host;
|
|
1444
|
-
};
|
|
1445
|
-
const getProtocol = () => {
|
|
1446
|
-
return location.protocol;
|
|
1447
|
-
};
|
|
1448
|
-
|
|
1449
|
-
const create$4 = async ({
|
|
1450
|
-
commandMap,
|
|
1451
|
-
webSocket
|
|
1452
|
-
}) => {
|
|
1453
|
-
// TODO create a commandMap per rpc instance
|
|
1454
|
-
register(commandMap);
|
|
1455
|
-
let rawIpc;
|
|
1456
|
-
try {
|
|
1457
|
-
rawIpc = await IpcParentWithWebSocket$1.create({
|
|
1458
|
-
webSocket
|
|
1459
|
-
});
|
|
1460
|
-
} catch (error) {
|
|
1461
|
-
throw new VError(error, 'Failed to create rpc connection');
|
|
1462
|
-
}
|
|
1463
|
-
const ipc = IpcParentWithWebSocket$1.wrap(rawIpc);
|
|
1464
|
-
handleIpc(ipc);
|
|
1465
|
-
const rpc = createRpc(ipc);
|
|
1466
|
-
return rpc;
|
|
1467
|
-
};
|
|
1468
|
-
|
|
1469
|
-
const create$3 = async ({
|
|
1470
|
-
commandMap,
|
|
1471
|
-
type
|
|
1472
|
-
}) => {
|
|
1473
|
-
const host = getHost();
|
|
1474
|
-
const protocol = getProtocol();
|
|
1475
|
-
const wsUrl = getWebSocketUrl(type, host, protocol);
|
|
1476
|
-
const webSocket = new WebSocket(wsUrl);
|
|
1477
|
-
const rpc = await create$4({
|
|
1478
|
-
commandMap,
|
|
1479
|
-
webSocket
|
|
1480
|
-
});
|
|
1481
|
-
return rpc;
|
|
1482
|
-
};
|
|
1483
|
-
|
|
1484
|
-
const create$2 = async ({
|
|
1485
|
-
commandMap,
|
|
1486
|
-
type
|
|
1487
|
-
}) => {
|
|
1488
|
-
return createSharedLazyRpc(() => {
|
|
1489
|
-
return create$3({
|
|
1490
|
-
commandMap,
|
|
1491
|
-
type
|
|
1492
|
-
});
|
|
1493
|
-
});
|
|
1494
|
-
};
|
|
1495
|
-
|
|
1496
|
-
const create$1 = async ({
|
|
1497
|
-
commandMap
|
|
1498
|
-
}) => {
|
|
1499
|
-
// TODO create a commandMap per rpc instance
|
|
1500
|
-
register(commandMap);
|
|
1501
|
-
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
1502
|
-
handleIpc(ipc);
|
|
1503
|
-
const rpc = createRpc(ipc);
|
|
1504
|
-
return rpc;
|
|
1505
|
-
};
|
|
1506
|
-
|
|
1507
1250
|
const createMockRpc = ({
|
|
1508
1251
|
commandMap
|
|
1509
1252
|
}) => {
|
|
@@ -1525,7 +1268,7 @@ const createMockRpc = ({
|
|
|
1525
1268
|
};
|
|
1526
1269
|
|
|
1527
1270
|
const rpcs = Object.create(null);
|
|
1528
|
-
const set$
|
|
1271
|
+
const set$6 = (id, rpc) => {
|
|
1529
1272
|
rpcs[id] = rpc;
|
|
1530
1273
|
};
|
|
1531
1274
|
const get = id => {
|
|
@@ -1536,7 +1279,7 @@ const remove = id => {
|
|
|
1536
1279
|
};
|
|
1537
1280
|
|
|
1538
1281
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1539
|
-
const create = rpcId => {
|
|
1282
|
+
const create$a = rpcId => {
|
|
1540
1283
|
return {
|
|
1541
1284
|
async dispose() {
|
|
1542
1285
|
const rpc = get(rpcId);
|
|
@@ -1558,7 +1301,7 @@ const create = rpcId => {
|
|
|
1558
1301
|
const mockRpc = createMockRpc({
|
|
1559
1302
|
commandMap
|
|
1560
1303
|
});
|
|
1561
|
-
set$
|
|
1304
|
+
set$6(rpcId, mockRpc);
|
|
1562
1305
|
// @ts-ignore
|
|
1563
1306
|
mockRpc[Symbol.dispose] = () => {
|
|
1564
1307
|
remove(rpcId);
|
|
@@ -1567,7 +1310,7 @@ const create = rpcId => {
|
|
|
1567
1310
|
return mockRpc;
|
|
1568
1311
|
},
|
|
1569
1312
|
set(rpc) {
|
|
1570
|
-
set$
|
|
1313
|
+
set$6(rpcId, rpc);
|
|
1571
1314
|
}
|
|
1572
1315
|
};
|
|
1573
1316
|
};
|
|
@@ -1764,6 +1507,7 @@ const Remote = 3;
|
|
|
1764
1507
|
|
|
1765
1508
|
const ErrorWorker = 3308;
|
|
1766
1509
|
const FileSystemWorker$1 = 209;
|
|
1510
|
+
const MainProcess = -5;
|
|
1767
1511
|
const ProcessExplorerRenderer = 33;
|
|
1768
1512
|
const RendererWorker = 1;
|
|
1769
1513
|
|
|
@@ -1776,27 +1520,33 @@ const Empty = 0;
|
|
|
1776
1520
|
const FocusExplorer = 13;
|
|
1777
1521
|
|
|
1778
1522
|
const {
|
|
1779
|
-
invoke: invoke$
|
|
1780
|
-
set: set$
|
|
1781
|
-
} = create(ErrorWorker);
|
|
1523
|
+
invoke: invoke$3,
|
|
1524
|
+
set: set$5
|
|
1525
|
+
} = create$a(ErrorWorker);
|
|
1782
1526
|
const prepare = async error => {
|
|
1783
|
-
return invoke$
|
|
1527
|
+
return invoke$3('Errors.prepare', error);
|
|
1784
1528
|
};
|
|
1785
1529
|
|
|
1786
1530
|
const {
|
|
1787
|
-
set: set$
|
|
1788
|
-
} = create(FileSystemWorker$1);
|
|
1531
|
+
set: set$4
|
|
1532
|
+
} = create$a(FileSystemWorker$1);
|
|
1789
1533
|
|
|
1790
1534
|
const FileSystemWorker = {
|
|
1791
1535
|
__proto__: null,
|
|
1792
|
-
set: set$
|
|
1536
|
+
set: set$4
|
|
1793
1537
|
};
|
|
1794
1538
|
|
|
1539
|
+
const {
|
|
1540
|
+
dispose: dispose$4,
|
|
1541
|
+
invoke: invoke$2,
|
|
1542
|
+
set: set$3
|
|
1543
|
+
} = create$a(MainProcess);
|
|
1544
|
+
|
|
1795
1545
|
const {
|
|
1796
1546
|
invoke: invoke$1,
|
|
1797
1547
|
invokeAndTransfer,
|
|
1798
1548
|
set: set$2
|
|
1799
|
-
} = create(RendererWorker);
|
|
1549
|
+
} = create$a(RendererWorker);
|
|
1800
1550
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1801
1551
|
number(uid);
|
|
1802
1552
|
number(menuId);
|
|
@@ -1804,120 +1554,451 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
1804
1554
|
number(y);
|
|
1805
1555
|
await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1806
1556
|
};
|
|
1807
|
-
const sendMessagePortToErrorWorker$1 = async (port, rpcId) => {
|
|
1808
|
-
const command = 'Errors.handleMessagePort';
|
|
1809
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
|
|
1557
|
+
const sendMessagePortToErrorWorker$1 = async (port, rpcId) => {
|
|
1558
|
+
const command = 'Errors.handleMessagePort';
|
|
1559
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
|
|
1560
|
+
};
|
|
1561
|
+
const sendMessagePortToFileSystemWorker$1 = async (port, rpcId) => {
|
|
1562
|
+
const command = 'FileSystem.handleMessagePort';
|
|
1563
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
1564
|
+
};
|
|
1565
|
+
const sendMessagePortToProcessExplorer$1 = async port => {
|
|
1566
|
+
const command = 'ProcessExplorer.handleMessagePort';
|
|
1567
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToProcessExplorer', port, command, 0);
|
|
1568
|
+
};
|
|
1569
|
+
|
|
1570
|
+
const debugProcess = async (state, index = state.focusedIndex) => {
|
|
1571
|
+
const process = state.visibleProcesses[index];
|
|
1572
|
+
if (!process) {
|
|
1573
|
+
return state;
|
|
1574
|
+
}
|
|
1575
|
+
await invoke$1('AttachDebugger.attachDebugger', process.pid);
|
|
1576
|
+
return state;
|
|
1577
|
+
};
|
|
1578
|
+
|
|
1579
|
+
const isEqual$1 = (oldState, newState) => {
|
|
1580
|
+
return oldState.focused === newState.focused && oldState.focusedIndex === newState.focusedIndex;
|
|
1581
|
+
};
|
|
1582
|
+
|
|
1583
|
+
const isEqual = (oldState, newState) => {
|
|
1584
|
+
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;
|
|
1585
|
+
};
|
|
1586
|
+
|
|
1587
|
+
const RenderItems = 1;
|
|
1588
|
+
const RenderFocus = 2;
|
|
1589
|
+
const RenderFocusContext = 3;
|
|
1590
|
+
const RenderIncremental = 4;
|
|
1591
|
+
|
|
1592
|
+
const modules = [isEqual, isEqual$1, isEqual$1];
|
|
1593
|
+
const numbers = [RenderIncremental, RenderFocus, RenderFocusContext];
|
|
1594
|
+
|
|
1595
|
+
const diff = (oldState, newState) => {
|
|
1596
|
+
const diffResult = [];
|
|
1597
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1598
|
+
const fn = modules[i];
|
|
1599
|
+
if (!fn(oldState, newState)) {
|
|
1600
|
+
diffResult.push(numbers[i]);
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
return diffResult;
|
|
1604
|
+
};
|
|
1605
|
+
|
|
1606
|
+
const diff2 = uid => {
|
|
1607
|
+
const {
|
|
1608
|
+
oldState,
|
|
1609
|
+
scheduledState
|
|
1610
|
+
} = get$2(uid);
|
|
1611
|
+
return diff(oldState, scheduledState);
|
|
1612
|
+
};
|
|
1613
|
+
|
|
1614
|
+
const intervals = new Map();
|
|
1615
|
+
const pending = new Set();
|
|
1616
|
+
const dispose$3 = uid => {
|
|
1617
|
+
const interval = intervals.get(uid);
|
|
1618
|
+
if (interval) {
|
|
1619
|
+
clearInterval(interval);
|
|
1620
|
+
intervals.delete(uid);
|
|
1621
|
+
}
|
|
1622
|
+
pending.delete(uid);
|
|
1623
|
+
};
|
|
1624
|
+
const update = async uid => {
|
|
1625
|
+
if (!getKeys$1().includes(uid)) {
|
|
1626
|
+
dispose$3(uid);
|
|
1627
|
+
return;
|
|
1628
|
+
}
|
|
1629
|
+
if (pending.has(uid)) {
|
|
1630
|
+
return;
|
|
1631
|
+
}
|
|
1632
|
+
pending.add(uid);
|
|
1633
|
+
try {
|
|
1634
|
+
await invoke$1('ProcessExplorer.update');
|
|
1635
|
+
} catch (error) {
|
|
1636
|
+
console.error(error);
|
|
1637
|
+
} finally {
|
|
1638
|
+
pending.delete(uid);
|
|
1639
|
+
}
|
|
1640
|
+
};
|
|
1641
|
+
const start = (uid, interval = processExplorerUpdateInterval) => {
|
|
1642
|
+
if (interval <= 0 || intervals.has(uid)) {
|
|
1643
|
+
return;
|
|
1644
|
+
}
|
|
1645
|
+
const intervalId = setInterval(() => {
|
|
1646
|
+
void update(uid);
|
|
1647
|
+
}, interval);
|
|
1648
|
+
intervals.set(uid, intervalId);
|
|
1649
|
+
};
|
|
1650
|
+
const restart = (uid, interval) => {
|
|
1651
|
+
dispose$3(uid);
|
|
1652
|
+
start(uid, interval);
|
|
1653
|
+
};
|
|
1654
|
+
|
|
1655
|
+
const processExplorerRpcClosedMessage = 'Process explorer RPC connection was closed';
|
|
1656
|
+
const toProcessExplorerRpcClosedState = state => {
|
|
1657
|
+
return {
|
|
1658
|
+
...state,
|
|
1659
|
+
errorCodeFrame: '',
|
|
1660
|
+
errorMessage: processExplorerRpcClosedMessage,
|
|
1661
|
+
errorStack: '',
|
|
1662
|
+
initial: false
|
|
1663
|
+
};
|
|
1664
|
+
};
|
|
1665
|
+
const handleProcessExplorerRpcClose = async () => {
|
|
1666
|
+
let didUpdate = false;
|
|
1667
|
+
for (const uid of getKeys$1()) {
|
|
1668
|
+
const viewletState = get$2(uid);
|
|
1669
|
+
if (!viewletState) {
|
|
1670
|
+
continue;
|
|
1671
|
+
}
|
|
1672
|
+
dispose$3(uid);
|
|
1673
|
+
const {
|
|
1674
|
+
oldState,
|
|
1675
|
+
scheduledState
|
|
1676
|
+
} = viewletState;
|
|
1677
|
+
const newState = toProcessExplorerRpcClosedState(scheduledState);
|
|
1678
|
+
set$7(uid, oldState, newState);
|
|
1679
|
+
didUpdate = true;
|
|
1680
|
+
}
|
|
1681
|
+
if (didUpdate) {
|
|
1682
|
+
await invoke$1('ProcessExplorer.rerender');
|
|
1683
|
+
}
|
|
1684
|
+
};
|
|
1685
|
+
|
|
1686
|
+
const Two = '2.0';
|
|
1687
|
+
|
|
1688
|
+
const create$9 = (method, params) => {
|
|
1689
|
+
return {
|
|
1690
|
+
jsonrpc: Two,
|
|
1691
|
+
method,
|
|
1692
|
+
params
|
|
1693
|
+
};
|
|
1694
|
+
};
|
|
1695
|
+
|
|
1696
|
+
const create$8 = (id, method, params) => {
|
|
1697
|
+
const message = {
|
|
1698
|
+
id,
|
|
1699
|
+
jsonrpc: Two,
|
|
1700
|
+
method,
|
|
1701
|
+
params
|
|
1702
|
+
};
|
|
1703
|
+
return message;
|
|
1704
|
+
};
|
|
1705
|
+
|
|
1706
|
+
let id = 0;
|
|
1707
|
+
const create$7 = () => {
|
|
1708
|
+
return ++id;
|
|
1709
|
+
};
|
|
1710
|
+
|
|
1711
|
+
const registerPromise = map => {
|
|
1712
|
+
const id = create$7();
|
|
1713
|
+
const {
|
|
1714
|
+
promise,
|
|
1715
|
+
resolve
|
|
1716
|
+
} = Promise.withResolvers();
|
|
1717
|
+
map[id] = resolve;
|
|
1718
|
+
return {
|
|
1719
|
+
id,
|
|
1720
|
+
promise
|
|
1721
|
+
};
|
|
1722
|
+
};
|
|
1723
|
+
|
|
1724
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
1725
|
+
const {
|
|
1726
|
+
id,
|
|
1727
|
+
promise
|
|
1728
|
+
} = registerPromise(callbacks);
|
|
1729
|
+
const message = create$8(id, method, params);
|
|
1730
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1731
|
+
ipc.sendAndTransfer(message);
|
|
1732
|
+
} else {
|
|
1733
|
+
ipc.send(message);
|
|
1734
|
+
}
|
|
1735
|
+
const responseMessage = await promise;
|
|
1736
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
1737
|
+
};
|
|
1738
|
+
const createRpc$1 = ipc => {
|
|
1739
|
+
const callbacks = Object.create(null);
|
|
1740
|
+
ipc._resolve = (id, response) => {
|
|
1741
|
+
const fn = callbacks[id];
|
|
1742
|
+
if (!fn) {
|
|
1743
|
+
console.warn(`callback ${id} may already be disposed`);
|
|
1744
|
+
return;
|
|
1745
|
+
}
|
|
1746
|
+
fn(response);
|
|
1747
|
+
delete callbacks[id];
|
|
1748
|
+
};
|
|
1749
|
+
const rpc = {
|
|
1750
|
+
async dispose() {
|
|
1751
|
+
await ipc?.dispose();
|
|
1752
|
+
},
|
|
1753
|
+
invoke(method, ...params) {
|
|
1754
|
+
return invokeHelper(callbacks, ipc, method, params, false);
|
|
1755
|
+
},
|
|
1756
|
+
invokeAndTransfer(method, ...params) {
|
|
1757
|
+
return invokeHelper(callbacks, ipc, method, params, true);
|
|
1758
|
+
},
|
|
1759
|
+
// @ts-ignore
|
|
1760
|
+
ipc,
|
|
1761
|
+
/**
|
|
1762
|
+
* @deprecated
|
|
1763
|
+
*/
|
|
1764
|
+
send(method, ...params) {
|
|
1765
|
+
const message = create$9(method, params);
|
|
1766
|
+
ipc.send(message);
|
|
1767
|
+
}
|
|
1768
|
+
};
|
|
1769
|
+
return rpc;
|
|
1770
|
+
};
|
|
1771
|
+
|
|
1772
|
+
const requiresSocket = () => {
|
|
1773
|
+
return false;
|
|
1810
1774
|
};
|
|
1811
|
-
const
|
|
1812
|
-
|
|
1813
|
-
|
|
1775
|
+
const preparePrettyError = error => {
|
|
1776
|
+
return error;
|
|
1777
|
+
};
|
|
1778
|
+
const logError = () => {
|
|
1779
|
+
// handled by renderer worker
|
|
1780
|
+
};
|
|
1781
|
+
const handleMessage = event => {
|
|
1782
|
+
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
1783
|
+
const actualExecute = event?.target?.execute || execute;
|
|
1784
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
1814
1785
|
};
|
|
1815
1786
|
|
|
1816
|
-
const
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1787
|
+
const handleIpc = ipc => {
|
|
1788
|
+
if ('addEventListener' in ipc) {
|
|
1789
|
+
ipc.addEventListener('message', handleMessage);
|
|
1790
|
+
} else if ('on' in ipc) {
|
|
1791
|
+
// deprecated
|
|
1792
|
+
ipc.on('message', handleMessage);
|
|
1820
1793
|
}
|
|
1821
|
-
await invoke$1('AttachDebugger.attachDebugger', process.pid);
|
|
1822
|
-
return state;
|
|
1823
1794
|
};
|
|
1824
1795
|
|
|
1825
|
-
const
|
|
1826
|
-
|
|
1796
|
+
const listen$1 = async (module, options) => {
|
|
1797
|
+
const rawIpc = await module.listen(options);
|
|
1798
|
+
if (module.signal) {
|
|
1799
|
+
module.signal(rawIpc);
|
|
1800
|
+
}
|
|
1801
|
+
const ipc = module.wrap(rawIpc);
|
|
1802
|
+
return ipc;
|
|
1827
1803
|
};
|
|
1828
1804
|
|
|
1829
|
-
const
|
|
1830
|
-
|
|
1805
|
+
const create$6 = async ({
|
|
1806
|
+
commandMap,
|
|
1807
|
+
isMessagePortOpen = true,
|
|
1808
|
+
messagePort
|
|
1809
|
+
}) => {
|
|
1810
|
+
// TODO create a commandMap per rpc instance
|
|
1811
|
+
register(commandMap);
|
|
1812
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
1813
|
+
isMessagePortOpen,
|
|
1814
|
+
messagePort
|
|
1815
|
+
});
|
|
1816
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
1817
|
+
handleIpc(ipc);
|
|
1818
|
+
const rpc = createRpc$1(ipc);
|
|
1819
|
+
messagePort.start();
|
|
1820
|
+
return rpc;
|
|
1831
1821
|
};
|
|
1832
1822
|
|
|
1833
|
-
const
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
const
|
|
1839
|
-
|
|
1823
|
+
const create$5 = async ({
|
|
1824
|
+
commandMap,
|
|
1825
|
+
isMessagePortOpen,
|
|
1826
|
+
send
|
|
1827
|
+
}) => {
|
|
1828
|
+
const {
|
|
1829
|
+
port1,
|
|
1830
|
+
port2
|
|
1831
|
+
} = new MessageChannel();
|
|
1832
|
+
await send(port1);
|
|
1833
|
+
return create$6({
|
|
1834
|
+
commandMap,
|
|
1835
|
+
isMessagePortOpen,
|
|
1836
|
+
messagePort: port2
|
|
1837
|
+
});
|
|
1838
|
+
};
|
|
1840
1839
|
|
|
1841
|
-
const
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
diffResult.push(numbers[i]);
|
|
1840
|
+
const createSharedLazyRpc = factory => {
|
|
1841
|
+
let rpcPromise;
|
|
1842
|
+
const getOrCreate = () => {
|
|
1843
|
+
if (!rpcPromise) {
|
|
1844
|
+
rpcPromise = factory();
|
|
1847
1845
|
}
|
|
1848
|
-
|
|
1849
|
-
|
|
1846
|
+
return rpcPromise;
|
|
1847
|
+
};
|
|
1848
|
+
return {
|
|
1849
|
+
async dispose() {
|
|
1850
|
+
const rpc = await getOrCreate();
|
|
1851
|
+
await rpc.dispose();
|
|
1852
|
+
},
|
|
1853
|
+
async invoke(method, ...params) {
|
|
1854
|
+
const rpc = await getOrCreate();
|
|
1855
|
+
return rpc.invoke(method, ...params);
|
|
1856
|
+
},
|
|
1857
|
+
async invokeAndTransfer(method, ...params) {
|
|
1858
|
+
const rpc = await getOrCreate();
|
|
1859
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1860
|
+
},
|
|
1861
|
+
async send(method, ...params) {
|
|
1862
|
+
const rpc = await getOrCreate();
|
|
1863
|
+
rpc.send(method, ...params);
|
|
1864
|
+
}
|
|
1865
|
+
};
|
|
1850
1866
|
};
|
|
1851
1867
|
|
|
1852
|
-
const
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
return
|
|
1868
|
+
const create$4 = async ({
|
|
1869
|
+
commandMap,
|
|
1870
|
+
isMessagePortOpen,
|
|
1871
|
+
send
|
|
1872
|
+
}) => {
|
|
1873
|
+
return createSharedLazyRpc(() => {
|
|
1874
|
+
return create$5({
|
|
1875
|
+
commandMap,
|
|
1876
|
+
isMessagePortOpen,
|
|
1877
|
+
send
|
|
1878
|
+
});
|
|
1879
|
+
});
|
|
1858
1880
|
};
|
|
1859
1881
|
|
|
1860
|
-
const
|
|
1861
|
-
const
|
|
1862
|
-
const
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
intervals.delete(uid);
|
|
1867
|
-
}
|
|
1868
|
-
pending.delete(uid);
|
|
1882
|
+
const Https = 'https:';
|
|
1883
|
+
const Ws = 'ws:';
|
|
1884
|
+
const Wss = 'wss:';
|
|
1885
|
+
|
|
1886
|
+
const getWebSocketProtocol = locationProtocol => {
|
|
1887
|
+
return locationProtocol === Https ? Wss : Ws;
|
|
1869
1888
|
};
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1889
|
+
|
|
1890
|
+
const getWebSocketUrl = (type, host, locationProtocol) => {
|
|
1891
|
+
const wsProtocol = getWebSocketProtocol(locationProtocol);
|
|
1892
|
+
return `${wsProtocol}//${host}/websocket/${type}`;
|
|
1893
|
+
};
|
|
1894
|
+
|
|
1895
|
+
const getHost = () => {
|
|
1896
|
+
return location.host;
|
|
1897
|
+
};
|
|
1898
|
+
const getProtocol = () => {
|
|
1899
|
+
return location.protocol;
|
|
1900
|
+
};
|
|
1901
|
+
|
|
1902
|
+
const create$3 = async ({
|
|
1903
|
+
commandMap,
|
|
1904
|
+
webSocket
|
|
1905
|
+
}) => {
|
|
1906
|
+
// TODO create a commandMap per rpc instance
|
|
1907
|
+
register(commandMap);
|
|
1908
|
+
let rawIpc;
|
|
1879
1909
|
try {
|
|
1880
|
-
await
|
|
1910
|
+
rawIpc = await IpcParentWithWebSocket$1.create({
|
|
1911
|
+
webSocket
|
|
1912
|
+
});
|
|
1881
1913
|
} catch (error) {
|
|
1882
|
-
|
|
1883
|
-
} finally {
|
|
1884
|
-
pending.delete(uid);
|
|
1914
|
+
throw new VError(error, 'Failed to create rpc connection');
|
|
1885
1915
|
}
|
|
1916
|
+
const ipc = IpcParentWithWebSocket$1.wrap(rawIpc);
|
|
1917
|
+
handleIpc(ipc);
|
|
1918
|
+
const rpc = createRpc$1(ipc);
|
|
1919
|
+
return rpc;
|
|
1886
1920
|
};
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1921
|
+
|
|
1922
|
+
const create$2 = async ({
|
|
1923
|
+
commandMap,
|
|
1924
|
+
onClose,
|
|
1925
|
+
type
|
|
1926
|
+
}) => {
|
|
1927
|
+
const host = getHost();
|
|
1928
|
+
const protocol = getProtocol();
|
|
1929
|
+
const wsUrl = getWebSocketUrl(type, host, protocol);
|
|
1930
|
+
const webSocket = new WebSocket(wsUrl);
|
|
1931
|
+
if (onClose) {
|
|
1932
|
+
webSocket.addEventListener('close', onClose, {
|
|
1933
|
+
once: true
|
|
1934
|
+
});
|
|
1890
1935
|
}
|
|
1891
|
-
const
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1936
|
+
const rpc = await create$3({
|
|
1937
|
+
commandMap,
|
|
1938
|
+
webSocket
|
|
1939
|
+
});
|
|
1940
|
+
return rpc;
|
|
1895
1941
|
};
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1942
|
+
|
|
1943
|
+
const create$1 = async ({
|
|
1944
|
+
commandMap,
|
|
1945
|
+
onClose,
|
|
1946
|
+
type
|
|
1947
|
+
}) => {
|
|
1948
|
+
return createSharedLazyRpc(() => {
|
|
1949
|
+
return create$2({
|
|
1950
|
+
commandMap,
|
|
1951
|
+
onClose,
|
|
1952
|
+
type
|
|
1953
|
+
});
|
|
1954
|
+
});
|
|
1955
|
+
};
|
|
1956
|
+
|
|
1957
|
+
const create = async ({
|
|
1958
|
+
commandMap
|
|
1959
|
+
}) => {
|
|
1960
|
+
// TODO create a commandMap per rpc instance
|
|
1961
|
+
register(commandMap);
|
|
1962
|
+
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
1963
|
+
handleIpc(ipc);
|
|
1964
|
+
const rpc = createRpc$1(ipc);
|
|
1965
|
+
return rpc;
|
|
1899
1966
|
};
|
|
1900
1967
|
|
|
1901
1968
|
const sendMessagePortToMainProcess = async port => {
|
|
1902
1969
|
await invokeAndTransfer('SendMessagePortToMainProcess.sendMessagePortToMainProcess', port, 'HandleElectronMessagePort.handleElectronMessagePort', ProcessExplorerRenderer);
|
|
1903
1970
|
};
|
|
1904
1971
|
|
|
1972
|
+
const sendMessagePortToProcessExplorer = async port => {
|
|
1973
|
+
await sendMessagePortToProcessExplorer$1(port);
|
|
1974
|
+
};
|
|
1975
|
+
|
|
1976
|
+
const createRpc = async send => {
|
|
1977
|
+
return create$4({
|
|
1978
|
+
commandMap: {},
|
|
1979
|
+
send
|
|
1980
|
+
});
|
|
1981
|
+
};
|
|
1905
1982
|
const launchProcessExplorerElectron = async () => {
|
|
1983
|
+
let processExplorerRpc;
|
|
1906
1984
|
try {
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1985
|
+
processExplorerRpc = await createRpc(sendMessagePortToProcessExplorer);
|
|
1986
|
+
const mainProcessRpc = await createRpc(sendMessagePortToMainProcess);
|
|
1987
|
+
return {
|
|
1988
|
+
mainProcessRpc,
|
|
1989
|
+
processExplorerRpc
|
|
1990
|
+
};
|
|
1912
1991
|
} catch (error) {
|
|
1913
|
-
|
|
1992
|
+
await processExplorerRpc?.dispose();
|
|
1993
|
+
throw new VError(error, 'Failed to create process explorer electron rpcs');
|
|
1914
1994
|
}
|
|
1915
1995
|
};
|
|
1916
1996
|
|
|
1917
|
-
const launchProcessExplorerNode = async
|
|
1997
|
+
const launchProcessExplorerNode = async onClose => {
|
|
1918
1998
|
try {
|
|
1919
|
-
const rpc = await create$
|
|
1999
|
+
const rpc = await create$1({
|
|
1920
2000
|
commandMap: {},
|
|
2001
|
+
onClose,
|
|
1921
2002
|
type: 'process-explorer'
|
|
1922
2003
|
});
|
|
1923
2004
|
return rpc;
|
|
@@ -1938,6 +2019,9 @@ const invoke = async (method, ...params) => {
|
|
|
1938
2019
|
const set$1 = newRpc => {
|
|
1939
2020
|
state$1.rpc = newRpc;
|
|
1940
2021
|
};
|
|
2022
|
+
const clear = () => {
|
|
2023
|
+
state$1.rpc = undefined;
|
|
2024
|
+
};
|
|
1941
2025
|
const dispose$2 = async () => {
|
|
1942
2026
|
const {
|
|
1943
2027
|
rpc
|
|
@@ -1949,30 +2033,48 @@ const dispose$2 = async () => {
|
|
|
1949
2033
|
const state = {
|
|
1950
2034
|
initializedPlatform: 0
|
|
1951
2035
|
};
|
|
2036
|
+
const handleClose = async () => {
|
|
2037
|
+
state.initializedPlatform = 0;
|
|
2038
|
+
clear();
|
|
2039
|
+
await handleProcessExplorerRpcClose();
|
|
2040
|
+
};
|
|
1952
2041
|
const initializeProcessExplorer = async platform => {
|
|
1953
2042
|
if (state.initializedPlatform === platform) {
|
|
1954
2043
|
return;
|
|
1955
2044
|
}
|
|
1956
2045
|
if (platform === Electron) {
|
|
1957
|
-
const
|
|
1958
|
-
|
|
2046
|
+
const {
|
|
2047
|
+
mainProcessRpc,
|
|
2048
|
+
processExplorerRpc
|
|
2049
|
+
} = await launchProcessExplorerElectron();
|
|
2050
|
+
set$3(mainProcessRpc);
|
|
2051
|
+
set$1(processExplorerRpc);
|
|
1959
2052
|
state.initializedPlatform = platform;
|
|
1960
2053
|
return;
|
|
1961
2054
|
}
|
|
1962
2055
|
if (platform === Remote) {
|
|
1963
|
-
const rpc = await launchProcessExplorerNode()
|
|
2056
|
+
const rpc = await launchProcessExplorerNode(() => {
|
|
2057
|
+
void handleClose();
|
|
2058
|
+
});
|
|
1964
2059
|
set$1(rpc);
|
|
1965
2060
|
state.initializedPlatform = platform;
|
|
1966
2061
|
}
|
|
1967
2062
|
};
|
|
1968
2063
|
const dispose$1 = async () => {
|
|
2064
|
+
const {
|
|
2065
|
+
initializedPlatform
|
|
2066
|
+
} = state;
|
|
1969
2067
|
state.initializedPlatform = 0;
|
|
2068
|
+
if (initializedPlatform === Electron) {
|
|
2069
|
+
await Promise.all([dispose$4(), dispose$2()]);
|
|
2070
|
+
return;
|
|
2071
|
+
}
|
|
1970
2072
|
await dispose$2();
|
|
1971
2073
|
};
|
|
1972
2074
|
|
|
1973
2075
|
const dispose = async uid => {
|
|
1974
2076
|
dispose$3(uid);
|
|
1975
|
-
dispose$
|
|
2077
|
+
dispose$5(uid);
|
|
1976
2078
|
if (getKeys$1().length === 0) {
|
|
1977
2079
|
await dispose$1();
|
|
1978
2080
|
}
|
|
@@ -2217,7 +2319,7 @@ const handleContextMenu = async (state, index = state.focusedIndex, x = 0, y = 0
|
|
|
2217
2319
|
focused: false,
|
|
2218
2320
|
focusedIndex: numericIndex
|
|
2219
2321
|
};
|
|
2220
|
-
set$
|
|
2322
|
+
set$7(state.uid, state, newState);
|
|
2221
2323
|
await show2(state.uid, ProcessExplorer$1, x, y, {
|
|
2222
2324
|
index: numericIndex,
|
|
2223
2325
|
menuId: ProcessExplorer$1
|
|
@@ -2241,7 +2343,13 @@ const killProcess = async (state, index = state.focusedIndex) => {
|
|
|
2241
2343
|
if (!process) {
|
|
2242
2344
|
return state;
|
|
2243
2345
|
}
|
|
2244
|
-
|
|
2346
|
+
const killPromise = invoke('Process.kill', process.pid);
|
|
2347
|
+
if (process.name === 'process-explorer') {
|
|
2348
|
+
dispose$3(state.uid);
|
|
2349
|
+
void killPromise.catch(() => {});
|
|
2350
|
+
return toProcessExplorerRpcClosedState(state);
|
|
2351
|
+
}
|
|
2352
|
+
await killPromise;
|
|
2245
2353
|
return state;
|
|
2246
2354
|
};
|
|
2247
2355
|
|
|
@@ -2360,6 +2468,13 @@ const getFocusedIndex = (oldFocusedIndex, visibleProcesses) => {
|
|
|
2360
2468
|
}
|
|
2361
2469
|
return Math.min(oldFocusedIndex, visibleProcesses.length - 1);
|
|
2362
2470
|
};
|
|
2471
|
+
const listProcesses = async (rootPid, platform) => {
|
|
2472
|
+
if (platform === Electron) {
|
|
2473
|
+
const pidMap = await invoke$2('CreatePidMap.createPidMap');
|
|
2474
|
+
return invoke('ListProcessesWithMemoryUsage.listProcessesWithMemoryUsage', rootPid, false, pidMap);
|
|
2475
|
+
}
|
|
2476
|
+
return invoke('ListProcessesWithMemoryUsage.listProcessesWithMemoryUsage', rootPid, false);
|
|
2477
|
+
};
|
|
2363
2478
|
const refresh = async state => {
|
|
2364
2479
|
try {
|
|
2365
2480
|
await initializeProcessExplorer(state.platform);
|
|
@@ -2367,7 +2482,7 @@ const refresh = async state => {
|
|
|
2367
2482
|
const rootPid = state.rootPid === -1 ? await invoke('ProcessId.getMainProcessId', {
|
|
2368
2483
|
includeElectronData
|
|
2369
2484
|
}) : state.rootPid;
|
|
2370
|
-
const processes = await
|
|
2485
|
+
const processes = await listProcesses(rootPid, state.platform);
|
|
2371
2486
|
const frontendMemoryProcesses = state.includeFrontendMemoryUsage ? await getFrontendMemoryUsage(rootPid) : [];
|
|
2372
2487
|
const allProcesses = [...processes, ...frontendMemoryProcesses];
|
|
2373
2488
|
const visibleProcesses = getVisibleProcesses(allProcesses, state.collapsedPids, rootPid);
|
|
@@ -2942,7 +3057,7 @@ const render2 = (uid, diffResult) => {
|
|
|
2942
3057
|
oldState,
|
|
2943
3058
|
scheduledState
|
|
2944
3059
|
} = get$2(uid);
|
|
2945
|
-
set$
|
|
3060
|
+
set$7(uid, scheduledState, scheduledState);
|
|
2946
3061
|
return applyRender(oldState, scheduledState, diffResult);
|
|
2947
3062
|
};
|
|
2948
3063
|
|
|
@@ -2971,6 +3086,10 @@ const renderEventListeners = () => {
|
|
|
2971
3086
|
}];
|
|
2972
3087
|
};
|
|
2973
3088
|
|
|
3089
|
+
const rerender = state => {
|
|
3090
|
+
return state;
|
|
3091
|
+
};
|
|
3092
|
+
|
|
2974
3093
|
const isRawError = value => {
|
|
2975
3094
|
return Boolean(value && typeof value === 'object');
|
|
2976
3095
|
};
|
|
@@ -3058,6 +3177,7 @@ const commandMap = {
|
|
|
3058
3177
|
'ProcessExplorer.refresh': wrapCommand(refresh),
|
|
3059
3178
|
'ProcessExplorer.render2': render2,
|
|
3060
3179
|
'ProcessExplorer.renderEventListeners': renderEventListeners,
|
|
3180
|
+
'ProcessExplorer.rerender': wrapCommand(rerender),
|
|
3061
3181
|
'ProcessExplorer.setError': wrapCommand(setError),
|
|
3062
3182
|
'ProcessExplorer.setRootProcessId': wrapCommand(setRootProcessId),
|
|
3063
3183
|
'ProcessExplorer.setUpdateInterval': wrapCommand(setUpdateInterval),
|
|
@@ -3071,7 +3191,7 @@ const sendMessagePortToErrorWorker = async port => {
|
|
|
3071
3191
|
|
|
3072
3192
|
const createErrorWorkerRpc = async () => {
|
|
3073
3193
|
try {
|
|
3074
|
-
const rpc = await create$
|
|
3194
|
+
const rpc = await create$4({
|
|
3075
3195
|
commandMap: {},
|
|
3076
3196
|
send: sendMessagePortToErrorWorker
|
|
3077
3197
|
});
|
|
@@ -3083,7 +3203,7 @@ const createErrorWorkerRpc = async () => {
|
|
|
3083
3203
|
|
|
3084
3204
|
const initializeErrorWorker = async () => {
|
|
3085
3205
|
const rpc = await createErrorWorkerRpc();
|
|
3086
|
-
set$
|
|
3206
|
+
set$5(rpc);
|
|
3087
3207
|
};
|
|
3088
3208
|
|
|
3089
3209
|
const sendMessagePortToFileSystemWorker = async port => {
|
|
@@ -3092,7 +3212,7 @@ const sendMessagePortToFileSystemWorker = async port => {
|
|
|
3092
3212
|
|
|
3093
3213
|
const createFileSystemWorkerRpc = async () => {
|
|
3094
3214
|
try {
|
|
3095
|
-
const rpc = await create$
|
|
3215
|
+
const rpc = await create$4({
|
|
3096
3216
|
commandMap: {},
|
|
3097
3217
|
send: sendMessagePortToFileSystemWorker
|
|
3098
3218
|
});
|
|
@@ -3112,7 +3232,7 @@ const initializeFileSystemWorker = async () => {
|
|
|
3112
3232
|
};
|
|
3113
3233
|
|
|
3114
3234
|
const initializeRendererWorker = async () => {
|
|
3115
|
-
const rpc = await create
|
|
3235
|
+
const rpc = await create({
|
|
3116
3236
|
commandMap: commandMap
|
|
3117
3237
|
});
|
|
3118
3238
|
set$2(rpc);
|