@lvce-editor/process-explorer 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/dist/index.js +47 -34
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -898,7 +898,10 @@ const constructError = (message, type, name) => {
|
|
|
898
898
|
if (ErrorConstructor === Error) {
|
|
899
899
|
const error = new Error(message);
|
|
900
900
|
if (name && name !== 'VError') {
|
|
901
|
-
error
|
|
901
|
+
Object.defineProperty(error, 'name', {
|
|
902
|
+
configurable: true,
|
|
903
|
+
value: name
|
|
904
|
+
});
|
|
902
905
|
}
|
|
903
906
|
return error;
|
|
904
907
|
}
|
|
@@ -929,31 +932,45 @@ const getParentStack = error => {
|
|
|
929
932
|
};
|
|
930
933
|
const MethodNotFound = -32601;
|
|
931
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
|
+
};
|
|
932
952
|
const restoreExistingError = (error, currentStack) => {
|
|
933
953
|
if (typeof error.stack === 'string') {
|
|
934
|
-
error
|
|
954
|
+
setStack(error, `${error.stack}${NewLine$1}${currentStack}`);
|
|
935
955
|
}
|
|
936
956
|
return error;
|
|
937
957
|
};
|
|
938
958
|
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
939
959
|
const restoredError = new JsonRpcError(error.message);
|
|
940
960
|
const parentStack = getParentStack(error);
|
|
941
|
-
restoredError
|
|
961
|
+
setStack(restoredError, `${parentStack}${NewLine$1}${currentStack}`);
|
|
942
962
|
return restoredError;
|
|
943
963
|
};
|
|
944
964
|
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
945
965
|
if (error.data.stack && error.data.type && error.message) {
|
|
946
|
-
restoredError
|
|
966
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine$1}${error.data.stack}${NewLine$1}${currentStack}`);
|
|
947
967
|
return;
|
|
948
968
|
}
|
|
949
969
|
if (error.data.stack) {
|
|
950
|
-
restoredError
|
|
970
|
+
setStack(restoredError, error.data.stack);
|
|
951
971
|
}
|
|
952
972
|
};
|
|
953
973
|
const applyDataProperties = (restoredError, error) => {
|
|
954
|
-
if (!error.data) {
|
|
955
|
-
return;
|
|
956
|
-
}
|
|
957
974
|
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
958
975
|
if (error.data.codeFrame) {
|
|
959
976
|
// @ts-ignore
|
|
@@ -974,7 +991,7 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
974
991
|
const indexNewLine = getNewLineIndex(lowerStack);
|
|
975
992
|
const parentStack = getParentStack(error);
|
|
976
993
|
// @ts-ignore
|
|
977
|
-
restoredError
|
|
994
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
978
995
|
}
|
|
979
996
|
if (error.codeFrame) {
|
|
980
997
|
// @ts-ignore
|
|
@@ -1658,9 +1675,9 @@ const getModule$1 = async () => {
|
|
|
1658
1675
|
return Promise.resolve().then(function () { return ListProcessesWithMemoryUsageUnix; });
|
|
1659
1676
|
};
|
|
1660
1677
|
|
|
1661
|
-
const listProcessesWithMemoryUsage$2 = async (rootPid, includeElectronData = true) => {
|
|
1678
|
+
const listProcessesWithMemoryUsage$2 = async (rootPid, includeElectronData = true, pidMap) => {
|
|
1662
1679
|
const module = await getModule$1();
|
|
1663
|
-
return module.listProcessesWithMemoryUsage(rootPid, includeElectronData);
|
|
1680
|
+
return module.listProcessesWithMemoryUsage(rootPid, includeElectronData, pidMap);
|
|
1664
1681
|
};
|
|
1665
1682
|
|
|
1666
1683
|
const execFile$1 = promisify(execFile$2);
|
|
@@ -2647,6 +2664,7 @@ function requireReceiver() {
|
|
|
2647
2664
|
this._opcode = 0;
|
|
2648
2665
|
this._totalPayloadLength = 0;
|
|
2649
2666
|
this._messageLength = 0;
|
|
2667
|
+
this._numFragments = 0;
|
|
2650
2668
|
this._fragments = [];
|
|
2651
2669
|
this._errored = false;
|
|
2652
2670
|
this._loop = false;
|
|
@@ -2914,18 +2932,17 @@ function requireReceiver() {
|
|
|
2914
2932
|
this.controlMessage(data, cb);
|
|
2915
2933
|
return;
|
|
2916
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
|
+
}
|
|
2917
2940
|
if (this._compressed) {
|
|
2918
2941
|
this._state = INFLATING;
|
|
2919
2942
|
this.decompress(data, cb);
|
|
2920
2943
|
return;
|
|
2921
2944
|
}
|
|
2922
2945
|
if (data.length) {
|
|
2923
|
-
if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
|
|
2924
|
-
const error = this.createError(RangeError, 'Too many message fragments', false, 1008, 'WS_ERR_TOO_MANY_BUFFERED_PARTS');
|
|
2925
|
-
cb(error);
|
|
2926
|
-
return;
|
|
2927
|
-
}
|
|
2928
|
-
|
|
2929
2946
|
//
|
|
2930
2947
|
// This message is not compressed so its length is the sum of the payload
|
|
2931
2948
|
// length of all fragments.
|
|
@@ -2954,11 +2971,6 @@ function requireReceiver() {
|
|
|
2954
2971
|
cb(error);
|
|
2955
2972
|
return;
|
|
2956
2973
|
}
|
|
2957
|
-
if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
|
|
2958
|
-
const error = this.createError(RangeError, 'Too many message fragments', false, 1008, 'WS_ERR_TOO_MANY_BUFFERED_PARTS');
|
|
2959
|
-
cb(error);
|
|
2960
|
-
return;
|
|
2961
|
-
}
|
|
2962
2974
|
this._fragments.push(buf);
|
|
2963
2975
|
}
|
|
2964
2976
|
this.dataMessage(cb);
|
|
@@ -2982,6 +2994,7 @@ function requireReceiver() {
|
|
|
2982
2994
|
this._totalPayloadLength = 0;
|
|
2983
2995
|
this._messageLength = 0;
|
|
2984
2996
|
this._fragmented = 0;
|
|
2997
|
+
this._numFragments = 0;
|
|
2985
2998
|
this._fragments = [];
|
|
2986
2999
|
if (this._opcode === 2) {
|
|
2987
3000
|
let data;
|
|
@@ -4728,9 +4741,9 @@ function requireWebsocket() {
|
|
|
4728
4741
|
* masking key
|
|
4729
4742
|
* @param {Number} [options.handshakeTimeout] Timeout in milliseconds for the
|
|
4730
4743
|
* handshake request
|
|
4731
|
-
* @param {Number} [options.maxBufferedChunks=
|
|
4744
|
+
* @param {Number} [options.maxBufferedChunks=262144] The maximum number of
|
|
4732
4745
|
* buffered data chunks
|
|
4733
|
-
* @param {Number} [options.maxFragments=
|
|
4746
|
+
* @param {Number} [options.maxFragments=16384] The maximum number of message
|
|
4734
4747
|
* fragments
|
|
4735
4748
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
4736
4749
|
* size
|
|
@@ -4752,8 +4765,8 @@ function requireWebsocket() {
|
|
|
4752
4765
|
autoPong: true,
|
|
4753
4766
|
closeTimeout: CLOSE_TIMEOUT,
|
|
4754
4767
|
protocolVersion: protocolVersions[1],
|
|
4755
|
-
maxBufferedChunks:
|
|
4756
|
-
maxFragments:
|
|
4768
|
+
maxBufferedChunks: 256 * 1024,
|
|
4769
|
+
maxFragments: 16 * 1024,
|
|
4757
4770
|
maxPayload: 100 * 1024 * 1024,
|
|
4758
4771
|
skipUTF8Validation: false,
|
|
4759
4772
|
perMessageDeflate: true,
|
|
@@ -5626,9 +5639,9 @@ function requireWebsocketServer() {
|
|
|
5626
5639
|
* called
|
|
5627
5640
|
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
|
5628
5641
|
* @param {String} [options.host] The hostname where to bind the server
|
|
5629
|
-
* @param {Number} [options.maxBufferedChunks=
|
|
5642
|
+
* @param {Number} [options.maxBufferedChunks=262144] The maximum number of
|
|
5630
5643
|
* buffered data chunks
|
|
5631
|
-
* @param {Number} [options.maxFragments=
|
|
5644
|
+
* @param {Number} [options.maxFragments=16384] The maximum number of message
|
|
5632
5645
|
* fragments
|
|
5633
5646
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
5634
5647
|
* size
|
|
@@ -5651,8 +5664,8 @@ function requireWebsocketServer() {
|
|
|
5651
5664
|
options = {
|
|
5652
5665
|
allowSynchronousEvents: true,
|
|
5653
5666
|
autoPong: true,
|
|
5654
|
-
maxBufferedChunks:
|
|
5655
|
-
maxFragments:
|
|
5667
|
+
maxBufferedChunks: 256 * 1024,
|
|
5668
|
+
maxFragments: 16 * 1024,
|
|
5656
5669
|
maxPayload: 100 * 1024 * 1024,
|
|
5657
5670
|
skipUTF8Validation: false,
|
|
5658
5671
|
perMessageDeflate: false,
|
|
@@ -6249,13 +6262,13 @@ const CommandLine = 2;
|
|
|
6249
6262
|
|
|
6250
6263
|
// listProcesses windows implementation based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/node/ps.ts (License MIT)
|
|
6251
6264
|
|
|
6252
|
-
const listProcessesWithMemoryUsage$1 = async (rootPid, includeElectronData = true) => {
|
|
6265
|
+
const listProcessesWithMemoryUsage$1 = async (rootPid, includeElectronData = true, electronPidMap) => {
|
|
6253
6266
|
try {
|
|
6254
6267
|
const processList = await getProcessList(rootPid, CommandLine | Memory);
|
|
6255
6268
|
if (!processList) {
|
|
6256
6269
|
throw new VError(`Root process ${rootPid} not found`);
|
|
6257
6270
|
}
|
|
6258
|
-
const pidMap = includeElectronData ? await createPidMap() : {};
|
|
6271
|
+
const pidMap = electronPidMap ?? (includeElectronData ? await createPidMap() : {});
|
|
6259
6272
|
const completeProcessList = await addCpuUsage(processList);
|
|
6260
6273
|
const result = toResult(completeProcessList, rootPid, pidMap);
|
|
6261
6274
|
return result;
|
|
@@ -6436,10 +6449,10 @@ const parsePsOutput = (stdout, rootPid, pidMap) => {
|
|
|
6436
6449
|
return result;
|
|
6437
6450
|
};
|
|
6438
6451
|
|
|
6439
|
-
const listProcessesWithMemoryUsage = async (rootPid, includeElectronData = true) => {
|
|
6452
|
+
const listProcessesWithMemoryUsage = async (rootPid, includeElectronData = true, electronPidMap) => {
|
|
6440
6453
|
// console.time('getPsOutput')
|
|
6441
6454
|
const stdout = await getPsOutput();
|
|
6442
|
-
const pidMap = includeElectronData ? await createPidMap() : {};
|
|
6455
|
+
const pidMap = electronPidMap ?? (includeElectronData ? await createPidMap() : {});
|
|
6443
6456
|
// console.log({ stdout })
|
|
6444
6457
|
// console.timeEnd('getPsOutput')
|
|
6445
6458
|
// console.time('parsePsOutput')
|