@lvce-editor/json-rpc 7.2.0 → 8.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/dist/index.d.ts +4 -0
- package/dist/index.js +37 -37
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -32,8 +32,8 @@ const create$3 = () => {
|
|
|
32
32
|
const registerPromise = () => {
|
|
33
33
|
const id = create$3();
|
|
34
34
|
const {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
promise,
|
|
36
|
+
resolve
|
|
37
37
|
} = Promise.withResolvers();
|
|
38
38
|
set(id, resolve);
|
|
39
39
|
return {
|
|
@@ -48,10 +48,10 @@ const create$2 = (method, params) => {
|
|
|
48
48
|
promise
|
|
49
49
|
} = registerPromise();
|
|
50
50
|
const message = {
|
|
51
|
+
id,
|
|
51
52
|
jsonrpc: Two,
|
|
52
53
|
method,
|
|
53
|
-
params
|
|
54
|
-
id
|
|
54
|
+
params
|
|
55
55
|
};
|
|
56
56
|
return {
|
|
57
57
|
message,
|
|
@@ -83,12 +83,12 @@ const getErrorConstructor = (message, type) => {
|
|
|
83
83
|
switch (type) {
|
|
84
84
|
case DomException:
|
|
85
85
|
return DOMException;
|
|
86
|
-
case TypeError$1:
|
|
87
|
-
return TypeError;
|
|
88
|
-
case SyntaxError$1:
|
|
89
|
-
return SyntaxError;
|
|
90
86
|
case ReferenceError$1:
|
|
91
87
|
return ReferenceError;
|
|
88
|
+
case SyntaxError$1:
|
|
89
|
+
return SyntaxError;
|
|
90
|
+
case TypeError$1:
|
|
91
|
+
return TypeError;
|
|
92
92
|
default:
|
|
93
93
|
return Error;
|
|
94
94
|
}
|
|
@@ -258,28 +258,28 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
258
258
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
259
259
|
return {
|
|
260
260
|
code: MethodNotFound,
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
data: error.stack,
|
|
262
|
+
message: error.message
|
|
263
263
|
};
|
|
264
264
|
}
|
|
265
265
|
return {
|
|
266
266
|
code: Custom,
|
|
267
|
-
message: prettyError.message,
|
|
268
267
|
data: {
|
|
269
|
-
stack: getStack(prettyError),
|
|
270
|
-
codeFrame: prettyError.codeFrame,
|
|
271
|
-
type: getErrorType(prettyError),
|
|
272
268
|
code: prettyError.code,
|
|
273
|
-
|
|
274
|
-
|
|
269
|
+
codeFrame: prettyError.codeFrame,
|
|
270
|
+
name: prettyError.name,
|
|
271
|
+
stack: getStack(prettyError),
|
|
272
|
+
type: getErrorType(prettyError)
|
|
273
|
+
},
|
|
274
|
+
message: prettyError.message
|
|
275
275
|
};
|
|
276
276
|
};
|
|
277
277
|
|
|
278
278
|
const create$1 = (id, error) => {
|
|
279
279
|
return {
|
|
280
|
-
|
|
280
|
+
error,
|
|
281
281
|
id,
|
|
282
|
-
|
|
282
|
+
jsonrpc: Two
|
|
283
283
|
};
|
|
284
284
|
};
|
|
285
285
|
|
|
@@ -292,8 +292,8 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
292
292
|
|
|
293
293
|
const create = (message, result) => {
|
|
294
294
|
return {
|
|
295
|
-
jsonrpc: Two,
|
|
296
295
|
id: message.id,
|
|
296
|
+
jsonrpc: Two,
|
|
297
297
|
result: result ?? null
|
|
298
298
|
};
|
|
299
299
|
};
|
|
@@ -305,14 +305,14 @@ const getSuccessResponse = (message, result) => {
|
|
|
305
305
|
|
|
306
306
|
const getErrorResponseSimple = (id, error) => {
|
|
307
307
|
return {
|
|
308
|
-
jsonrpc: Two,
|
|
309
|
-
id,
|
|
310
308
|
error: {
|
|
311
309
|
code: Custom,
|
|
310
|
+
data: error,
|
|
312
311
|
// @ts-ignore
|
|
313
|
-
message: error.message
|
|
314
|
-
|
|
315
|
-
|
|
312
|
+
message: error.message
|
|
313
|
+
},
|
|
314
|
+
id,
|
|
315
|
+
jsonrpc: Two
|
|
316
316
|
};
|
|
317
317
|
};
|
|
318
318
|
|
|
@@ -344,36 +344,36 @@ const normalizeParams = args => {
|
|
|
344
344
|
if (args.length === 1) {
|
|
345
345
|
const options = args[0];
|
|
346
346
|
return {
|
|
347
|
+
execute: options.execute,
|
|
347
348
|
ipc: options.ipc,
|
|
349
|
+
logError: options.logError || defaultLogError,
|
|
348
350
|
message: options.message,
|
|
349
|
-
execute: options.execute,
|
|
350
|
-
resolve: options.resolve || defaultResolve,
|
|
351
351
|
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
352
|
-
|
|
353
|
-
|
|
352
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
353
|
+
resolve: options.resolve || defaultResolve
|
|
354
354
|
};
|
|
355
355
|
}
|
|
356
356
|
return {
|
|
357
|
+
execute: args[2],
|
|
357
358
|
ipc: args[0],
|
|
359
|
+
logError: args[5],
|
|
358
360
|
message: args[1],
|
|
359
|
-
execute: args[2],
|
|
360
|
-
resolve: args[3],
|
|
361
361
|
preparePrettyError: args[4],
|
|
362
|
-
|
|
363
|
-
|
|
362
|
+
requiresSocket: args[6],
|
|
363
|
+
resolve: args[3]
|
|
364
364
|
};
|
|
365
365
|
};
|
|
366
366
|
|
|
367
367
|
const handleJsonRpcMessage = async (...args) => {
|
|
368
368
|
const options = normalizeParams(args);
|
|
369
369
|
const {
|
|
370
|
-
message,
|
|
371
|
-
ipc,
|
|
372
370
|
execute,
|
|
373
|
-
|
|
374
|
-
preparePrettyError,
|
|
371
|
+
ipc,
|
|
375
372
|
logError,
|
|
376
|
-
|
|
373
|
+
message,
|
|
374
|
+
preparePrettyError,
|
|
375
|
+
requiresSocket,
|
|
376
|
+
resolve
|
|
377
377
|
} = options;
|
|
378
378
|
if ('id' in message) {
|
|
379
379
|
if ('method' in message) {
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/json-rpc",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "JsonRpc implementation",
|
|
5
5
|
"repository": {
|
|
6
|
+
"type": "git",
|
|
6
7
|
"url": "https://github.com/lvce-editor/json-rpc"
|
|
7
8
|
},
|
|
8
9
|
"main": "dist/index.js",
|
|
@@ -12,5 +13,6 @@
|
|
|
12
13
|
"json-rpc"
|
|
13
14
|
],
|
|
14
15
|
"author": "Lvce Editor",
|
|
15
|
-
"license": "MIT"
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"exports": "./dist/index.js"
|
|
16
18
|
}
|