@lvce-editor/process-explorer 3.10.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/dist/index.js +69 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -168,7 +168,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
|
|
|
168
168
|
for (const property of Object.values(value)) {
|
|
169
169
|
walkValue(property, transferrables, isTransferrable);
|
|
170
170
|
}
|
|
171
|
-
return;
|
|
172
171
|
}
|
|
173
172
|
};
|
|
174
173
|
const getTransferrables = value => {
|
|
@@ -371,7 +370,14 @@ class IpcError extends VError {
|
|
|
371
370
|
const cause = new Error(message);
|
|
372
371
|
// @ts-ignore
|
|
373
372
|
cause.code = code;
|
|
374
|
-
|
|
373
|
+
if (stack) {
|
|
374
|
+
Object.defineProperty(cause, 'stack', {
|
|
375
|
+
configurable: true,
|
|
376
|
+
enumerable: false,
|
|
377
|
+
value: stack,
|
|
378
|
+
writable: true
|
|
379
|
+
});
|
|
380
|
+
}
|
|
375
381
|
super(cause, betterMessage);
|
|
376
382
|
} else {
|
|
377
383
|
super(betterMessage);
|
|
@@ -705,13 +711,13 @@ const signal$4 = webSocket => {
|
|
|
705
711
|
webSocket.resume();
|
|
706
712
|
};
|
|
707
713
|
const wrap$9 = webSocket => {
|
|
708
|
-
|
|
714
|
+
const wrap = {
|
|
709
715
|
dispose() {
|
|
710
|
-
|
|
716
|
+
wrap.webSocket.close();
|
|
711
717
|
},
|
|
712
718
|
// @ts-ignore
|
|
713
719
|
off(event, listener) {
|
|
714
|
-
|
|
720
|
+
wrap.webSocket.off(event, listener);
|
|
715
721
|
},
|
|
716
722
|
// @ts-ignore
|
|
717
723
|
on(event, listener) {
|
|
@@ -725,7 +731,7 @@ const wrap$9 = webSocket => {
|
|
|
725
731
|
const data = deserialize(message);
|
|
726
732
|
const event = {
|
|
727
733
|
data,
|
|
728
|
-
target:
|
|
734
|
+
target: wrap
|
|
729
735
|
};
|
|
730
736
|
listener(event);
|
|
731
737
|
};
|
|
@@ -738,7 +744,7 @@ const wrap$9 = webSocket => {
|
|
|
738
744
|
// @ts-ignore
|
|
739
745
|
send(message) {
|
|
740
746
|
const stringifiedMessage = serialize(message);
|
|
741
|
-
|
|
747
|
+
wrap.webSocket.send(stringifiedMessage);
|
|
742
748
|
},
|
|
743
749
|
start() {
|
|
744
750
|
throw new Error('start method is deprecated');
|
|
@@ -749,6 +755,7 @@ const wrap$9 = webSocket => {
|
|
|
749
755
|
*/
|
|
750
756
|
wrappedListener: undefined
|
|
751
757
|
};
|
|
758
|
+
return wrap;
|
|
752
759
|
};
|
|
753
760
|
const IpcChildWithWebSocket = {
|
|
754
761
|
__proto__: null,
|
|
@@ -891,7 +898,10 @@ const constructError = (message, type, name) => {
|
|
|
891
898
|
if (ErrorConstructor === Error) {
|
|
892
899
|
const error = new Error(message);
|
|
893
900
|
if (name && name !== 'VError') {
|
|
894
|
-
error
|
|
901
|
+
Object.defineProperty(error, 'name', {
|
|
902
|
+
configurable: true,
|
|
903
|
+
value: name
|
|
904
|
+
});
|
|
895
905
|
}
|
|
896
906
|
return error;
|
|
897
907
|
}
|
|
@@ -922,31 +932,45 @@ const getParentStack = error => {
|
|
|
922
932
|
};
|
|
923
933
|
const MethodNotFound = -32601;
|
|
924
934
|
const Custom = -32001;
|
|
935
|
+
const setStack = (error, stack) => {
|
|
936
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
937
|
+
if (descriptor) {
|
|
938
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
942
|
+
error.stack = stack;
|
|
943
|
+
return;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
Object.defineProperty(error, 'stack', {
|
|
947
|
+
configurable: true,
|
|
948
|
+
value: stack,
|
|
949
|
+
writable: true
|
|
950
|
+
});
|
|
951
|
+
};
|
|
925
952
|
const restoreExistingError = (error, currentStack) => {
|
|
926
953
|
if (typeof error.stack === 'string') {
|
|
927
|
-
error
|
|
954
|
+
setStack(error, `${error.stack}${NewLine$1}${currentStack}`);
|
|
928
955
|
}
|
|
929
956
|
return error;
|
|
930
957
|
};
|
|
931
958
|
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
932
959
|
const restoredError = new JsonRpcError(error.message);
|
|
933
960
|
const parentStack = getParentStack(error);
|
|
934
|
-
restoredError
|
|
961
|
+
setStack(restoredError, `${parentStack}${NewLine$1}${currentStack}`);
|
|
935
962
|
return restoredError;
|
|
936
963
|
};
|
|
937
964
|
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
938
965
|
if (error.data.stack && error.data.type && error.message) {
|
|
939
|
-
restoredError
|
|
966
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine$1}${error.data.stack}${NewLine$1}${currentStack}`);
|
|
940
967
|
return;
|
|
941
968
|
}
|
|
942
969
|
if (error.data.stack) {
|
|
943
|
-
restoredError
|
|
970
|
+
setStack(restoredError, error.data.stack);
|
|
944
971
|
}
|
|
945
972
|
};
|
|
946
973
|
const applyDataProperties = (restoredError, error) => {
|
|
947
|
-
if (!error.data) {
|
|
948
|
-
return;
|
|
949
|
-
}
|
|
950
974
|
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
951
975
|
if (error.data.codeFrame) {
|
|
952
976
|
// @ts-ignore
|
|
@@ -967,7 +991,7 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
967
991
|
const indexNewLine = getNewLineIndex(lowerStack);
|
|
968
992
|
const parentStack = getParentStack(error);
|
|
969
993
|
// @ts-ignore
|
|
970
|
-
restoredError
|
|
994
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
971
995
|
}
|
|
972
996
|
if (error.codeFrame) {
|
|
973
997
|
// @ts-ignore
|
|
@@ -1331,9 +1355,14 @@ const create$4 = async ({
|
|
|
1331
1355
|
}) => {
|
|
1332
1356
|
// TODO create a commandMap per rpc instance
|
|
1333
1357
|
register(commandMap);
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1358
|
+
let rawIpc;
|
|
1359
|
+
try {
|
|
1360
|
+
rawIpc = await IpcParentWithWebSocket$1.create({
|
|
1361
|
+
webSocket
|
|
1362
|
+
});
|
|
1363
|
+
} catch (error) {
|
|
1364
|
+
throw new VError(error, 'Failed to create rpc connection');
|
|
1365
|
+
}
|
|
1337
1366
|
const ipc = IpcParentWithWebSocket$1.wrap(rawIpc);
|
|
1338
1367
|
handleIpc(ipc);
|
|
1339
1368
|
const rpc = createRpc(ipc);
|
|
@@ -1646,9 +1675,9 @@ const getModule$1 = async () => {
|
|
|
1646
1675
|
return Promise.resolve().then(function () { return ListProcessesWithMemoryUsageUnix; });
|
|
1647
1676
|
};
|
|
1648
1677
|
|
|
1649
|
-
const listProcessesWithMemoryUsage$2 = async (rootPid, includeElectronData = true) => {
|
|
1678
|
+
const listProcessesWithMemoryUsage$2 = async (rootPid, includeElectronData = true, pidMap) => {
|
|
1650
1679
|
const module = await getModule$1();
|
|
1651
|
-
return module.listProcessesWithMemoryUsage(rootPid, includeElectronData);
|
|
1680
|
+
return module.listProcessesWithMemoryUsage(rootPid, includeElectronData, pidMap);
|
|
1652
1681
|
};
|
|
1653
1682
|
|
|
1654
1683
|
const execFile$1 = promisify(execFile$2);
|
|
@@ -2635,6 +2664,7 @@ function requireReceiver() {
|
|
|
2635
2664
|
this._opcode = 0;
|
|
2636
2665
|
this._totalPayloadLength = 0;
|
|
2637
2666
|
this._messageLength = 0;
|
|
2667
|
+
this._numFragments = 0;
|
|
2638
2668
|
this._fragments = [];
|
|
2639
2669
|
this._errored = false;
|
|
2640
2670
|
this._loop = false;
|
|
@@ -2902,18 +2932,17 @@ function requireReceiver() {
|
|
|
2902
2932
|
this.controlMessage(data, cb);
|
|
2903
2933
|
return;
|
|
2904
2934
|
}
|
|
2935
|
+
if (this._maxFragments > 0 && ++this._numFragments > this._maxFragments) {
|
|
2936
|
+
const error = this.createError(RangeError, 'Too many message fragments', false, 1008, 'WS_ERR_TOO_MANY_BUFFERED_PARTS');
|
|
2937
|
+
cb(error);
|
|
2938
|
+
return;
|
|
2939
|
+
}
|
|
2905
2940
|
if (this._compressed) {
|
|
2906
2941
|
this._state = INFLATING;
|
|
2907
2942
|
this.decompress(data, cb);
|
|
2908
2943
|
return;
|
|
2909
2944
|
}
|
|
2910
2945
|
if (data.length) {
|
|
2911
|
-
if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
|
|
2912
|
-
const error = this.createError(RangeError, 'Too many message fragments', false, 1008, 'WS_ERR_TOO_MANY_BUFFERED_PARTS');
|
|
2913
|
-
cb(error);
|
|
2914
|
-
return;
|
|
2915
|
-
}
|
|
2916
|
-
|
|
2917
2946
|
//
|
|
2918
2947
|
// This message is not compressed so its length is the sum of the payload
|
|
2919
2948
|
// length of all fragments.
|
|
@@ -2942,11 +2971,6 @@ function requireReceiver() {
|
|
|
2942
2971
|
cb(error);
|
|
2943
2972
|
return;
|
|
2944
2973
|
}
|
|
2945
|
-
if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
|
|
2946
|
-
const error = this.createError(RangeError, 'Too many message fragments', false, 1008, 'WS_ERR_TOO_MANY_BUFFERED_PARTS');
|
|
2947
|
-
cb(error);
|
|
2948
|
-
return;
|
|
2949
|
-
}
|
|
2950
2974
|
this._fragments.push(buf);
|
|
2951
2975
|
}
|
|
2952
2976
|
this.dataMessage(cb);
|
|
@@ -2970,6 +2994,7 @@ function requireReceiver() {
|
|
|
2970
2994
|
this._totalPayloadLength = 0;
|
|
2971
2995
|
this._messageLength = 0;
|
|
2972
2996
|
this._fragmented = 0;
|
|
2997
|
+
this._numFragments = 0;
|
|
2973
2998
|
this._fragments = [];
|
|
2974
2999
|
if (this._opcode === 2) {
|
|
2975
3000
|
let data;
|
|
@@ -4716,9 +4741,9 @@ function requireWebsocket() {
|
|
|
4716
4741
|
* masking key
|
|
4717
4742
|
* @param {Number} [options.handshakeTimeout] Timeout in milliseconds for the
|
|
4718
4743
|
* handshake request
|
|
4719
|
-
* @param {Number} [options.maxBufferedChunks=
|
|
4744
|
+
* @param {Number} [options.maxBufferedChunks=262144] The maximum number of
|
|
4720
4745
|
* buffered data chunks
|
|
4721
|
-
* @param {Number} [options.maxFragments=
|
|
4746
|
+
* @param {Number} [options.maxFragments=16384] The maximum number of message
|
|
4722
4747
|
* fragments
|
|
4723
4748
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
4724
4749
|
* size
|
|
@@ -4740,8 +4765,8 @@ function requireWebsocket() {
|
|
|
4740
4765
|
autoPong: true,
|
|
4741
4766
|
closeTimeout: CLOSE_TIMEOUT,
|
|
4742
4767
|
protocolVersion: protocolVersions[1],
|
|
4743
|
-
maxBufferedChunks:
|
|
4744
|
-
maxFragments:
|
|
4768
|
+
maxBufferedChunks: 256 * 1024,
|
|
4769
|
+
maxFragments: 16 * 1024,
|
|
4745
4770
|
maxPayload: 100 * 1024 * 1024,
|
|
4746
4771
|
skipUTF8Validation: false,
|
|
4747
4772
|
perMessageDeflate: true,
|
|
@@ -5614,9 +5639,9 @@ function requireWebsocketServer() {
|
|
|
5614
5639
|
* called
|
|
5615
5640
|
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
|
5616
5641
|
* @param {String} [options.host] The hostname where to bind the server
|
|
5617
|
-
* @param {Number} [options.maxBufferedChunks=
|
|
5642
|
+
* @param {Number} [options.maxBufferedChunks=262144] The maximum number of
|
|
5618
5643
|
* buffered data chunks
|
|
5619
|
-
* @param {Number} [options.maxFragments=
|
|
5644
|
+
* @param {Number} [options.maxFragments=16384] The maximum number of message
|
|
5620
5645
|
* fragments
|
|
5621
5646
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
5622
5647
|
* size
|
|
@@ -5639,8 +5664,8 @@ function requireWebsocketServer() {
|
|
|
5639
5664
|
options = {
|
|
5640
5665
|
allowSynchronousEvents: true,
|
|
5641
5666
|
autoPong: true,
|
|
5642
|
-
maxBufferedChunks:
|
|
5643
|
-
maxFragments:
|
|
5667
|
+
maxBufferedChunks: 256 * 1024,
|
|
5668
|
+
maxFragments: 16 * 1024,
|
|
5644
5669
|
maxPayload: 100 * 1024 * 1024,
|
|
5645
5670
|
skipUTF8Validation: false,
|
|
5646
5671
|
perMessageDeflate: false,
|
|
@@ -6237,13 +6262,13 @@ const CommandLine = 2;
|
|
|
6237
6262
|
|
|
6238
6263
|
// listProcesses windows implementation based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/node/ps.ts (License MIT)
|
|
6239
6264
|
|
|
6240
|
-
const listProcessesWithMemoryUsage$1 = async (rootPid, includeElectronData = true) => {
|
|
6265
|
+
const listProcessesWithMemoryUsage$1 = async (rootPid, includeElectronData = true, electronPidMap) => {
|
|
6241
6266
|
try {
|
|
6242
6267
|
const processList = await getProcessList(rootPid, CommandLine | Memory);
|
|
6243
6268
|
if (!processList) {
|
|
6244
6269
|
throw new VError(`Root process ${rootPid} not found`);
|
|
6245
6270
|
}
|
|
6246
|
-
const pidMap = includeElectronData ? await createPidMap() : {};
|
|
6271
|
+
const pidMap = electronPidMap ?? (includeElectronData ? await createPidMap() : {});
|
|
6247
6272
|
const completeProcessList = await addCpuUsage(processList);
|
|
6248
6273
|
const result = toResult(completeProcessList, rootPid, pidMap);
|
|
6249
6274
|
return result;
|
|
@@ -6424,10 +6449,10 @@ const parsePsOutput = (stdout, rootPid, pidMap) => {
|
|
|
6424
6449
|
return result;
|
|
6425
6450
|
};
|
|
6426
6451
|
|
|
6427
|
-
const listProcessesWithMemoryUsage = async (rootPid, includeElectronData = true) => {
|
|
6452
|
+
const listProcessesWithMemoryUsage = async (rootPid, includeElectronData = true, electronPidMap) => {
|
|
6428
6453
|
// console.time('getPsOutput')
|
|
6429
6454
|
const stdout = await getPsOutput();
|
|
6430
|
-
const pidMap = includeElectronData ? await createPidMap() : {};
|
|
6455
|
+
const pidMap = electronPidMap ?? (includeElectronData ? await createPidMap() : {});
|
|
6431
6456
|
// console.log({ stdout })
|
|
6432
6457
|
// console.timeEnd('getPsOutput')
|
|
6433
6458
|
// console.time('parsePsOutput')
|