@lvce-editor/search-process 9.2.0 → 9.3.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.js +54 -31
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -84,49 +84,57 @@ class AssertionError extends Error {
|
|
|
84
84
|
this.name = 'AssertionError';
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
const Object$1 = 1;
|
|
88
|
+
const Number = 2;
|
|
89
|
+
const Array$1 = 3;
|
|
90
|
+
const String = 4;
|
|
91
|
+
const Boolean = 5;
|
|
92
|
+
const Function = 6;
|
|
93
|
+
const Null = 7;
|
|
94
|
+
const Unknown = 8;
|
|
87
95
|
const getType = value => {
|
|
88
96
|
switch (typeof value) {
|
|
89
97
|
case 'number':
|
|
90
|
-
return
|
|
98
|
+
return Number;
|
|
91
99
|
case 'function':
|
|
92
|
-
return
|
|
100
|
+
return Function;
|
|
93
101
|
case 'string':
|
|
94
|
-
return
|
|
102
|
+
return String;
|
|
95
103
|
case 'object':
|
|
96
104
|
if (value === null) {
|
|
97
|
-
return
|
|
105
|
+
return Null;
|
|
98
106
|
}
|
|
99
107
|
if (Array.isArray(value)) {
|
|
100
|
-
return
|
|
108
|
+
return Array$1;
|
|
101
109
|
}
|
|
102
|
-
return
|
|
110
|
+
return Object$1;
|
|
103
111
|
case 'boolean':
|
|
104
|
-
return
|
|
112
|
+
return Boolean;
|
|
105
113
|
default:
|
|
106
|
-
return
|
|
114
|
+
return Unknown;
|
|
107
115
|
}
|
|
108
116
|
};
|
|
109
117
|
const object = value => {
|
|
110
118
|
const type = getType(value);
|
|
111
|
-
if (type !==
|
|
119
|
+
if (type !== Object$1) {
|
|
112
120
|
throw new AssertionError('expected value to be of type object');
|
|
113
121
|
}
|
|
114
122
|
};
|
|
115
123
|
const number = value => {
|
|
116
124
|
const type = getType(value);
|
|
117
|
-
if (type !==
|
|
125
|
+
if (type !== Number) {
|
|
118
126
|
throw new AssertionError('expected value to be of type number');
|
|
119
127
|
}
|
|
120
128
|
};
|
|
121
129
|
const array = value => {
|
|
122
130
|
const type = getType(value);
|
|
123
|
-
if (type !==
|
|
131
|
+
if (type !== Array$1) {
|
|
124
132
|
throw new AssertionError('expected value to be of type array');
|
|
125
133
|
}
|
|
126
134
|
};
|
|
127
135
|
const string = value => {
|
|
128
136
|
const type = getType(value);
|
|
129
|
-
if (type !==
|
|
137
|
+
if (type !== String) {
|
|
130
138
|
throw new AssertionError('expected value to be of type string');
|
|
131
139
|
}
|
|
132
140
|
};
|
|
@@ -553,7 +561,7 @@ const listen$3 = async () => {
|
|
|
553
561
|
parentPort
|
|
554
562
|
} = await import('node:worker_threads');
|
|
555
563
|
if (!parentPort) {
|
|
556
|
-
throw new IpcError('parentPort is required');
|
|
564
|
+
throw new IpcError('parentPort is required for node worker threads ipc');
|
|
557
565
|
}
|
|
558
566
|
return parentPort;
|
|
559
567
|
};
|
|
@@ -762,7 +770,7 @@ const IpcChildWithWebSocket = {
|
|
|
762
770
|
};
|
|
763
771
|
|
|
764
772
|
const Two = '2.0';
|
|
765
|
-
const create$4
|
|
773
|
+
const create$4 = (method, params) => {
|
|
766
774
|
return {
|
|
767
775
|
jsonrpc: Two,
|
|
768
776
|
method,
|
|
@@ -1003,18 +1011,18 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
1003
1011
|
}
|
|
1004
1012
|
};
|
|
1005
1013
|
};
|
|
1006
|
-
const create$1 = (
|
|
1014
|
+
const create$1 = (id, error) => {
|
|
1007
1015
|
return {
|
|
1008
1016
|
jsonrpc: Two,
|
|
1009
|
-
id
|
|
1017
|
+
id,
|
|
1010
1018
|
error
|
|
1011
1019
|
};
|
|
1012
1020
|
};
|
|
1013
|
-
const getErrorResponse = (
|
|
1021
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
1014
1022
|
const prettyError = preparePrettyError(error);
|
|
1015
1023
|
logError(error, prettyError);
|
|
1016
1024
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
1017
|
-
return create$1(
|
|
1025
|
+
return create$1(id, errorProperty);
|
|
1018
1026
|
};
|
|
1019
1027
|
const create = (message, result) => {
|
|
1020
1028
|
return {
|
|
@@ -1027,12 +1035,27 @@ const getSuccessResponse = (message, result) => {
|
|
|
1027
1035
|
const resultProperty = result ?? null;
|
|
1028
1036
|
return create(message, resultProperty);
|
|
1029
1037
|
};
|
|
1038
|
+
const getErrorResponseSimple = (id, error) => {
|
|
1039
|
+
return {
|
|
1040
|
+
jsonrpc: Two,
|
|
1041
|
+
id,
|
|
1042
|
+
error: {
|
|
1043
|
+
code: Custom,
|
|
1044
|
+
// @ts-ignore
|
|
1045
|
+
message: error.message,
|
|
1046
|
+
data: error
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
};
|
|
1030
1050
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
1031
1051
|
try {
|
|
1032
1052
|
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
1033
1053
|
return getSuccessResponse(message, result);
|
|
1034
1054
|
} catch (error) {
|
|
1035
|
-
|
|
1055
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
1056
|
+
return getErrorResponseSimple(message.id, error);
|
|
1057
|
+
}
|
|
1058
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
1036
1059
|
}
|
|
1037
1060
|
};
|
|
1038
1061
|
const defaultPreparePrettyError = error => {
|
|
@@ -1087,7 +1110,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
1087
1110
|
try {
|
|
1088
1111
|
ipc.send(response);
|
|
1089
1112
|
} catch (error) {
|
|
1090
|
-
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
1113
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
1091
1114
|
ipc.send(errorResponse);
|
|
1092
1115
|
}
|
|
1093
1116
|
return;
|
|
@@ -1115,7 +1138,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
1115
1138
|
return unwrapJsonRpcResult(responseMessage);
|
|
1116
1139
|
};
|
|
1117
1140
|
const send = (transport, method, ...params) => {
|
|
1118
|
-
const message = create$4
|
|
1141
|
+
const message = create$4(method, params);
|
|
1119
1142
|
transport.send(message);
|
|
1120
1143
|
};
|
|
1121
1144
|
const invoke = (ipc, method, ...params) => {
|
|
@@ -1192,7 +1215,7 @@ const listen$1 = async (module, options) => {
|
|
|
1192
1215
|
const ipc = module.wrap(rawIpc);
|
|
1193
1216
|
return ipc;
|
|
1194
1217
|
};
|
|
1195
|
-
const create$
|
|
1218
|
+
const create$j = async ({
|
|
1196
1219
|
commandMap,
|
|
1197
1220
|
messagePort,
|
|
1198
1221
|
requiresSocket
|
|
@@ -1211,9 +1234,9 @@ const create$e = async ({
|
|
|
1211
1234
|
};
|
|
1212
1235
|
const ElectronMessagePortRpcClient = {
|
|
1213
1236
|
__proto__: null,
|
|
1214
|
-
create: create$
|
|
1237
|
+
create: create$j
|
|
1215
1238
|
};
|
|
1216
|
-
const create$
|
|
1239
|
+
const create$i = async ({
|
|
1217
1240
|
commandMap
|
|
1218
1241
|
}) => {
|
|
1219
1242
|
// TODO create a commandMap per rpc instance
|
|
@@ -1225,9 +1248,9 @@ const create$d = async ({
|
|
|
1225
1248
|
};
|
|
1226
1249
|
const ElectronUtilityProcessRpcClient = {
|
|
1227
1250
|
__proto__: null,
|
|
1228
|
-
create: create$
|
|
1251
|
+
create: create$i
|
|
1229
1252
|
};
|
|
1230
|
-
const create$
|
|
1253
|
+
const create$9 = async ({
|
|
1231
1254
|
commandMap
|
|
1232
1255
|
}) => {
|
|
1233
1256
|
// TODO create a commandMap per rpc instance
|
|
@@ -1239,9 +1262,9 @@ const create$7 = async ({
|
|
|
1239
1262
|
};
|
|
1240
1263
|
const NodeForkedProcessRpcClient = {
|
|
1241
1264
|
__proto__: null,
|
|
1242
|
-
create: create$
|
|
1265
|
+
create: create$9
|
|
1243
1266
|
};
|
|
1244
|
-
const create$
|
|
1267
|
+
const create$7 = async ({
|
|
1245
1268
|
commandMap,
|
|
1246
1269
|
request,
|
|
1247
1270
|
handle,
|
|
@@ -1262,9 +1285,9 @@ const create$5 = async ({
|
|
|
1262
1285
|
};
|
|
1263
1286
|
const NodeWebSocketRpcClient = {
|
|
1264
1287
|
__proto__: null,
|
|
1265
|
-
create: create$
|
|
1288
|
+
create: create$7
|
|
1266
1289
|
};
|
|
1267
|
-
const create$
|
|
1290
|
+
const create$6 = async ({
|
|
1268
1291
|
commandMap
|
|
1269
1292
|
}) => {
|
|
1270
1293
|
// TODO create a commandMap per rpc instance
|
|
@@ -1276,7 +1299,7 @@ const create$4 = async ({
|
|
|
1276
1299
|
};
|
|
1277
1300
|
const NodeWorkerRpcClient = {
|
|
1278
1301
|
__proto__: null,
|
|
1279
|
-
create: create$
|
|
1302
|
+
create: create$6
|
|
1280
1303
|
};
|
|
1281
1304
|
|
|
1282
1305
|
const handleElectronMessagePort = async messagePort => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/search-process",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0",
|
|
4
4
|
"description": "Search Process",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lvce Editor",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"execa": "^9.6.0",
|
|
22
|
-
"ws": "^8.18.
|
|
22
|
+
"ws": "^8.18.3"
|
|
23
23
|
},
|
|
24
24
|
"optionalDependencies": {
|
|
25
25
|
"@lvce-editor/ripgrep": "^2.1.0"
|