@lvce-editor/process-explorer 1.0.0 → 2.0.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/bin/processExplorer.js +3 -0
- package/dist/index.js +50 -17
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -140,7 +140,6 @@ const getErrorConstructor = (message, type) => {
|
|
|
140
140
|
if (type) {
|
|
141
141
|
switch (type) {
|
|
142
142
|
case DomException:
|
|
143
|
-
// @ts-ignore
|
|
144
143
|
return DOMException;
|
|
145
144
|
case TypeError$1:
|
|
146
145
|
return TypeError;
|
|
@@ -166,7 +165,6 @@ const getErrorConstructor = (message, type) => {
|
|
|
166
165
|
|
|
167
166
|
const constructError = (message, type, name) => {
|
|
168
167
|
const ErrorConstructor = getErrorConstructor(message, type);
|
|
169
|
-
// @ts-ignore
|
|
170
168
|
if (ErrorConstructor === DOMException && name) {
|
|
171
169
|
return new ErrorConstructor(message, name);
|
|
172
170
|
}
|
|
@@ -184,6 +182,14 @@ const getNewLineIndex = (string, startIndex = undefined) => {
|
|
|
184
182
|
return string.indexOf(NewLine$1, startIndex);
|
|
185
183
|
};
|
|
186
184
|
|
|
185
|
+
const getParentStack = error => {
|
|
186
|
+
let parentStack = error.stack || error.data || error.message || '';
|
|
187
|
+
if (parentStack.startsWith(' at')) {
|
|
188
|
+
parentStack = error.message + NewLine$1 + parentStack;
|
|
189
|
+
}
|
|
190
|
+
return parentStack;
|
|
191
|
+
};
|
|
192
|
+
|
|
187
193
|
const joinLines = lines => {
|
|
188
194
|
return lines.join(NewLine$1);
|
|
189
195
|
};
|
|
@@ -195,18 +201,11 @@ const splitLines$1 = lines => {
|
|
|
195
201
|
return lines.split(NewLine$1);
|
|
196
202
|
};
|
|
197
203
|
|
|
198
|
-
const getParentStack = error => {
|
|
199
|
-
let parentStack = error.stack || error.data || error.message || '';
|
|
200
|
-
if (parentStack.startsWith(' at')) {
|
|
201
|
-
parentStack = error.message + NewLine$1 + parentStack;
|
|
202
|
-
}
|
|
203
|
-
return parentStack;
|
|
204
|
-
};
|
|
205
204
|
const restoreJsonRpcError = error => {
|
|
206
205
|
if (error && error instanceof Error) {
|
|
207
206
|
return error;
|
|
208
207
|
}
|
|
209
|
-
const currentStack = joinLines(splitLines$1(new Error().stack).slice(1));
|
|
208
|
+
const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(1));
|
|
210
209
|
if (error && error.code && error.code === MethodNotFound) {
|
|
211
210
|
const restoredError = new JsonRpcError(error.message);
|
|
212
211
|
const parentStack = getParentStack(error);
|
|
@@ -235,7 +234,6 @@ const restoreJsonRpcError = error => {
|
|
|
235
234
|
}
|
|
236
235
|
} else {
|
|
237
236
|
if (error.stack) {
|
|
238
|
-
// TODO accessing stack might be slow
|
|
239
237
|
const lowerStack = restoredError.stack || '';
|
|
240
238
|
// @ts-ignore
|
|
241
239
|
const indexNewLine = getNewLineIndex(lowerStack);
|
|
@@ -296,7 +294,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
296
294
|
}
|
|
297
295
|
};
|
|
298
296
|
};
|
|
299
|
-
const getErrorResponse = (message, error,
|
|
297
|
+
const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
300
298
|
const prettyError = preparePrettyError(error);
|
|
301
299
|
logError(error, prettyError);
|
|
302
300
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
@@ -321,18 +319,53 @@ const getResponse = async (message, ipc, execute, preparePrettyError, logError,
|
|
|
321
319
|
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
322
320
|
return getSuccessResponse(message, result);
|
|
323
321
|
} catch (error) {
|
|
324
|
-
return getErrorResponse(message, error,
|
|
322
|
+
return getErrorResponse(message, error, preparePrettyError, logError);
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
const defaultPreparePrettyError = error => {
|
|
327
|
+
return error;
|
|
328
|
+
};
|
|
329
|
+
const defaultLogError = () => {
|
|
330
|
+
// ignore
|
|
331
|
+
};
|
|
332
|
+
const defaultRequiresSocket = () => {
|
|
333
|
+
return false;
|
|
334
|
+
};
|
|
335
|
+
const defaultResolve = resolve;
|
|
336
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
337
|
+
let message;
|
|
338
|
+
let ipc;
|
|
339
|
+
let execute;
|
|
340
|
+
let preparePrettyError;
|
|
341
|
+
let logError;
|
|
342
|
+
let resolve;
|
|
343
|
+
let requiresSocket;
|
|
344
|
+
if (args.length === 1) {
|
|
345
|
+
const arg = args[0];
|
|
346
|
+
message = arg.message;
|
|
347
|
+
ipc = arg.ipc;
|
|
348
|
+
execute = arg.execute;
|
|
349
|
+
preparePrettyError = arg.preparePrettyError || defaultPreparePrettyError;
|
|
350
|
+
logError = arg.logError || defaultLogError;
|
|
351
|
+
requiresSocket = arg.requiresSocket || defaultRequiresSocket;
|
|
352
|
+
resolve = arg.resolve || defaultResolve;
|
|
353
|
+
} else {
|
|
354
|
+
ipc = args[0];
|
|
355
|
+
message = args[1];
|
|
356
|
+
execute = args[2];
|
|
357
|
+
resolve = args[3];
|
|
358
|
+
preparePrettyError = args[4];
|
|
359
|
+
logError = args[5];
|
|
360
|
+
requiresSocket = args[6];
|
|
325
361
|
}
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
const handleJsonRpcMessage = async (ipc, message, execute, resolve, preparePrettyError, logError, requiresSocket) => {
|
|
329
362
|
if ('id' in message) {
|
|
330
363
|
if ('method' in message) {
|
|
331
364
|
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
332
365
|
try {
|
|
333
366
|
ipc.send(response);
|
|
334
367
|
} catch (error) {
|
|
335
|
-
const errorResponse = getErrorResponse(message, error,
|
|
368
|
+
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
336
369
|
ipc.send(errorResponse);
|
|
337
370
|
}
|
|
338
371
|
return;
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/process-explorer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Process Explorer",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"bin": "bin/processExplorer.js",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"keywords": [
|
|
8
9
|
"Lvce Editor"
|
|
@@ -11,17 +12,16 @@
|
|
|
11
12
|
"license": "MIT",
|
|
12
13
|
"repository": {
|
|
13
14
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/lvce-editor/
|
|
15
|
-
"directory": "packages/process-explorer"
|
|
15
|
+
"url": "https://github.com/lvce-editor/process-explorer.git"
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
18
|
"node": ">=18"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@lvce-editor/assert": "^1.2.0",
|
|
22
|
-
"@lvce-editor/ipc": "^
|
|
23
|
-
"@lvce-editor/json-rpc": "^
|
|
24
|
-
"@lvce-editor/verror": "^1.
|
|
22
|
+
"@lvce-editor/ipc": "^10.0.2",
|
|
23
|
+
"@lvce-editor/json-rpc": "^3.0.0",
|
|
24
|
+
"@lvce-editor/verror": "^1.4.0"
|
|
25
25
|
},
|
|
26
26
|
"optionalDependencies": {
|
|
27
27
|
"@vscode/windows-process-tree": "^0.6.0"
|