@lvce-editor/search-process 13.1.0 → 15.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.js +201 -219
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ const searches$1 = Object.create(null);
|
|
|
13
13
|
const get$2 = id => {
|
|
14
14
|
return searches$1[id];
|
|
15
15
|
};
|
|
16
|
-
const set$
|
|
16
|
+
const set$1 = (id, search) => {
|
|
17
17
|
searches$1[id] = search;
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -28,7 +28,7 @@ const searches = Object.create(null);
|
|
|
28
28
|
const get$1 = id => {
|
|
29
29
|
return searches[id];
|
|
30
30
|
};
|
|
31
|
-
const set
|
|
31
|
+
const set = (id, search) => {
|
|
32
32
|
searches[id] = search;
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -337,8 +337,8 @@ const getModuleNotFoundError = stderr => {
|
|
|
337
337
|
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
338
338
|
const message = lines[messageIndex];
|
|
339
339
|
return {
|
|
340
|
-
|
|
341
|
-
|
|
340
|
+
code: ERR_MODULE_NOT_FOUND,
|
|
341
|
+
message
|
|
342
342
|
};
|
|
343
343
|
};
|
|
344
344
|
const isModuleNotFoundError = stderr => {
|
|
@@ -361,14 +361,14 @@ const isUnhelpfulNativeModuleError = stderr => {
|
|
|
361
361
|
const getNativeModuleErrorMessage = stderr => {
|
|
362
362
|
const message = getMessageCodeBlock(stderr);
|
|
363
363
|
return {
|
|
364
|
-
|
|
365
|
-
|
|
364
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
365
|
+
message: `Incompatible native node module: ${message}`
|
|
366
366
|
};
|
|
367
367
|
};
|
|
368
368
|
const getModuleSyntaxError = () => {
|
|
369
369
|
return {
|
|
370
|
-
|
|
371
|
-
|
|
370
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
371
|
+
message: `ES Modules are not supported in electron`
|
|
372
372
|
};
|
|
373
373
|
};
|
|
374
374
|
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
@@ -387,8 +387,8 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
387
387
|
rest
|
|
388
388
|
} = getDetails(lines);
|
|
389
389
|
return {
|
|
390
|
-
message: actualMessage,
|
|
391
390
|
code: '',
|
|
391
|
+
message: actualMessage,
|
|
392
392
|
stack: rest
|
|
393
393
|
};
|
|
394
394
|
};
|
|
@@ -398,8 +398,8 @@ class IpcError extends VError {
|
|
|
398
398
|
if (stdout || stderr) {
|
|
399
399
|
// @ts-ignore
|
|
400
400
|
const {
|
|
401
|
-
message,
|
|
402
401
|
code,
|
|
402
|
+
message,
|
|
403
403
|
stack
|
|
404
404
|
} = getHelpfulChildProcessError(stdout, stderr);
|
|
405
405
|
const cause = new Error(message);
|
|
@@ -637,8 +637,8 @@ const removeListener = (emitter, type, callback) => {
|
|
|
637
637
|
};
|
|
638
638
|
const getFirstEvent$1 = (eventEmitter, eventMap) => {
|
|
639
639
|
const {
|
|
640
|
-
|
|
641
|
-
|
|
640
|
+
promise,
|
|
641
|
+
resolve
|
|
642
642
|
} = Promise.withResolvers();
|
|
643
643
|
const listenerMap = Object.create(null);
|
|
644
644
|
const cleanup = value => {
|
|
@@ -650,8 +650,8 @@ const getFirstEvent$1 = (eventEmitter, eventMap) => {
|
|
|
650
650
|
for (const [event, type] of Object.entries(eventMap)) {
|
|
651
651
|
const listener = event => {
|
|
652
652
|
cleanup({
|
|
653
|
-
|
|
654
|
-
|
|
653
|
+
event,
|
|
654
|
+
type
|
|
655
655
|
});
|
|
656
656
|
};
|
|
657
657
|
addListener(eventEmitter, event, listener);
|
|
@@ -667,28 +667,28 @@ const getFirstWebSocketEvent = async webSocket => {
|
|
|
667
667
|
WebSocket
|
|
668
668
|
} = await import('ws');
|
|
669
669
|
switch (webSocket.readyState) {
|
|
670
|
-
case WebSocket.
|
|
670
|
+
case WebSocket.CLOSED:
|
|
671
671
|
return {
|
|
672
|
-
|
|
673
|
-
|
|
672
|
+
event: undefined,
|
|
673
|
+
type: Close
|
|
674
674
|
};
|
|
675
|
-
case WebSocket.
|
|
675
|
+
case WebSocket.OPEN:
|
|
676
676
|
return {
|
|
677
|
-
|
|
678
|
-
|
|
677
|
+
event: undefined,
|
|
678
|
+
type: Open
|
|
679
679
|
};
|
|
680
680
|
}
|
|
681
681
|
// @ts-ignore
|
|
682
682
|
const {
|
|
683
|
-
|
|
684
|
-
|
|
683
|
+
event,
|
|
684
|
+
type
|
|
685
685
|
} = await getFirstEvent$1(webSocket, {
|
|
686
|
-
|
|
687
|
-
|
|
686
|
+
close: Close,
|
|
687
|
+
open: Open
|
|
688
688
|
});
|
|
689
689
|
return {
|
|
690
|
-
|
|
691
|
-
|
|
690
|
+
event,
|
|
691
|
+
type
|
|
692
692
|
};
|
|
693
693
|
};
|
|
694
694
|
|
|
@@ -718,8 +718,8 @@ const handleUpgrade$1 = async (...args) => {
|
|
|
718
718
|
return module.handleUpgrade(...args);
|
|
719
719
|
};
|
|
720
720
|
const listen$1$1 = async ({
|
|
721
|
-
|
|
722
|
-
|
|
721
|
+
handle,
|
|
722
|
+
request
|
|
723
723
|
}) => {
|
|
724
724
|
if (!request) {
|
|
725
725
|
throw new IpcError('request must be defined');
|
|
@@ -739,14 +739,19 @@ const signal$4 = webSocket => {
|
|
|
739
739
|
};
|
|
740
740
|
const wrap$9 = webSocket => {
|
|
741
741
|
return {
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
742
|
+
dispose() {
|
|
743
|
+
this.webSocket.close();
|
|
744
|
+
},
|
|
745
|
+
// @ts-ignore
|
|
746
|
+
off(event, listener) {
|
|
747
|
+
this.webSocket.off(event, listener);
|
|
748
|
+
},
|
|
747
749
|
// @ts-ignore
|
|
748
750
|
on(event, listener) {
|
|
749
751
|
switch (event) {
|
|
752
|
+
case 'close':
|
|
753
|
+
webSocket.on('close', listener);
|
|
754
|
+
break;
|
|
750
755
|
case 'message':
|
|
751
756
|
// @ts-ignore
|
|
752
757
|
const wrappedListener = message => {
|
|
@@ -759,28 +764,23 @@ const wrap$9 = webSocket => {
|
|
|
759
764
|
};
|
|
760
765
|
webSocket.on('message', wrappedListener);
|
|
761
766
|
break;
|
|
762
|
-
case 'close':
|
|
763
|
-
webSocket.on('close', listener);
|
|
764
|
-
break;
|
|
765
767
|
default:
|
|
766
768
|
throw new Error('unknown event listener type');
|
|
767
769
|
}
|
|
768
770
|
},
|
|
769
771
|
// @ts-ignore
|
|
770
|
-
off(event, listener) {
|
|
771
|
-
this.webSocket.off(event, listener);
|
|
772
|
-
},
|
|
773
|
-
// @ts-ignore
|
|
774
772
|
send(message) {
|
|
775
773
|
const stringifiedMessage = serialize(message);
|
|
776
774
|
this.webSocket.send(stringifiedMessage);
|
|
777
775
|
},
|
|
778
|
-
dispose() {
|
|
779
|
-
this.webSocket.close();
|
|
780
|
-
},
|
|
781
776
|
start() {
|
|
782
777
|
throw new Error('start method is deprecated');
|
|
783
|
-
}
|
|
778
|
+
},
|
|
779
|
+
webSocket,
|
|
780
|
+
/**
|
|
781
|
+
* @type {any}
|
|
782
|
+
*/
|
|
783
|
+
wrappedListener: undefined
|
|
784
784
|
};
|
|
785
785
|
};
|
|
786
786
|
const IpcChildWithWebSocket = {
|
|
@@ -790,56 +790,35 @@ const IpcChildWithWebSocket = {
|
|
|
790
790
|
wrap: wrap$9
|
|
791
791
|
};
|
|
792
792
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
793
|
+
class CommandNotFoundError extends Error {
|
|
794
|
+
constructor(command) {
|
|
795
|
+
super(`Command not found ${command}`);
|
|
796
|
+
this.name = 'CommandNotFoundError';
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
const commands = Object.create(null);
|
|
800
|
+
const register = commandMap => {
|
|
801
|
+
Object.assign(commands, commandMap);
|
|
800
802
|
};
|
|
801
|
-
const
|
|
802
|
-
|
|
803
|
-
callbacks[id] = fn;
|
|
803
|
+
const getCommand = key => {
|
|
804
|
+
return commands[key];
|
|
804
805
|
};
|
|
806
|
+
const execute = (command, ...args) => {
|
|
807
|
+
const fn = getCommand(command);
|
|
808
|
+
if (!fn) {
|
|
809
|
+
throw new CommandNotFoundError(command);
|
|
810
|
+
}
|
|
811
|
+
return fn(...args);
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
const Two$1 = '2.0';
|
|
815
|
+
const callbacks = Object.create(null);
|
|
805
816
|
const get = id => {
|
|
806
817
|
return callbacks[id];
|
|
807
818
|
};
|
|
808
819
|
const remove = id => {
|
|
809
820
|
delete callbacks[id];
|
|
810
821
|
};
|
|
811
|
-
let id = 0;
|
|
812
|
-
const create$3 = () => {
|
|
813
|
-
return ++id;
|
|
814
|
-
};
|
|
815
|
-
const registerPromise = () => {
|
|
816
|
-
const id = create$3();
|
|
817
|
-
const {
|
|
818
|
-
resolve,
|
|
819
|
-
promise
|
|
820
|
-
} = Promise.withResolvers();
|
|
821
|
-
set(id, resolve);
|
|
822
|
-
return {
|
|
823
|
-
id,
|
|
824
|
-
promise
|
|
825
|
-
};
|
|
826
|
-
};
|
|
827
|
-
const create$2 = (method, params) => {
|
|
828
|
-
const {
|
|
829
|
-
id,
|
|
830
|
-
promise
|
|
831
|
-
} = registerPromise();
|
|
832
|
-
const message = {
|
|
833
|
-
jsonrpc: Two,
|
|
834
|
-
method,
|
|
835
|
-
params,
|
|
836
|
-
id
|
|
837
|
-
};
|
|
838
|
-
return {
|
|
839
|
-
message,
|
|
840
|
-
promise
|
|
841
|
-
};
|
|
842
|
-
};
|
|
843
822
|
class JsonRpcError extends Error {
|
|
844
823
|
constructor(message) {
|
|
845
824
|
super(message);
|
|
@@ -856,12 +835,12 @@ const getErrorConstructor = (message, type) => {
|
|
|
856
835
|
switch (type) {
|
|
857
836
|
case DomException:
|
|
858
837
|
return DOMException;
|
|
859
|
-
case TypeError$1:
|
|
860
|
-
return TypeError;
|
|
861
|
-
case SyntaxError$1:
|
|
862
|
-
return SyntaxError;
|
|
863
838
|
case ReferenceError$1:
|
|
864
839
|
return ReferenceError;
|
|
840
|
+
case SyntaxError$1:
|
|
841
|
+
return SyntaxError;
|
|
842
|
+
case TypeError$1:
|
|
843
|
+
return TypeError;
|
|
865
844
|
default:
|
|
866
845
|
return Error;
|
|
867
846
|
}
|
|
@@ -1017,56 +996,56 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
1017
996
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
1018
997
|
return {
|
|
1019
998
|
code: MethodNotFound,
|
|
1020
|
-
|
|
1021
|
-
|
|
999
|
+
data: error.stack,
|
|
1000
|
+
message: error.message
|
|
1022
1001
|
};
|
|
1023
1002
|
}
|
|
1024
1003
|
return {
|
|
1025
1004
|
code: Custom,
|
|
1026
|
-
message: prettyError.message,
|
|
1027
1005
|
data: {
|
|
1028
|
-
stack: getStack(prettyError),
|
|
1029
|
-
codeFrame: prettyError.codeFrame,
|
|
1030
|
-
type: getErrorType(prettyError),
|
|
1031
1006
|
code: prettyError.code,
|
|
1032
|
-
|
|
1033
|
-
|
|
1007
|
+
codeFrame: prettyError.codeFrame,
|
|
1008
|
+
name: prettyError.name,
|
|
1009
|
+
stack: getStack(prettyError),
|
|
1010
|
+
type: getErrorType(prettyError)
|
|
1011
|
+
},
|
|
1012
|
+
message: prettyError.message
|
|
1034
1013
|
};
|
|
1035
1014
|
};
|
|
1036
|
-
const create$1 = (id, error) => {
|
|
1015
|
+
const create$1$1 = (id, error) => {
|
|
1037
1016
|
return {
|
|
1038
|
-
|
|
1017
|
+
error,
|
|
1039
1018
|
id,
|
|
1040
|
-
|
|
1019
|
+
jsonrpc: Two$1
|
|
1041
1020
|
};
|
|
1042
1021
|
};
|
|
1043
1022
|
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
1044
1023
|
const prettyError = preparePrettyError(error);
|
|
1045
1024
|
logError(error, prettyError);
|
|
1046
1025
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
1047
|
-
return create$1(id, errorProperty);
|
|
1026
|
+
return create$1$1(id, errorProperty);
|
|
1048
1027
|
};
|
|
1049
|
-
const create = (message, result) => {
|
|
1028
|
+
const create$8 = (message, result) => {
|
|
1050
1029
|
return {
|
|
1051
|
-
jsonrpc: Two,
|
|
1052
1030
|
id: message.id,
|
|
1031
|
+
jsonrpc: Two$1,
|
|
1053
1032
|
result: result ?? null
|
|
1054
1033
|
};
|
|
1055
1034
|
};
|
|
1056
1035
|
const getSuccessResponse = (message, result) => {
|
|
1057
1036
|
const resultProperty = result ?? null;
|
|
1058
|
-
return create(message, resultProperty);
|
|
1037
|
+
return create$8(message, resultProperty);
|
|
1059
1038
|
};
|
|
1060
1039
|
const getErrorResponseSimple = (id, error) => {
|
|
1061
1040
|
return {
|
|
1062
|
-
jsonrpc: Two,
|
|
1063
|
-
id,
|
|
1064
1041
|
error: {
|
|
1065
1042
|
code: Custom,
|
|
1043
|
+
data: error,
|
|
1066
1044
|
// @ts-ignore
|
|
1067
|
-
message: error.message
|
|
1068
|
-
|
|
1069
|
-
|
|
1045
|
+
message: error.message
|
|
1046
|
+
},
|
|
1047
|
+
id,
|
|
1048
|
+
jsonrpc: Two$1
|
|
1070
1049
|
};
|
|
1071
1050
|
};
|
|
1072
1051
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
@@ -1096,35 +1075,35 @@ const normalizeParams = args => {
|
|
|
1096
1075
|
if (args.length === 1) {
|
|
1097
1076
|
const options = args[0];
|
|
1098
1077
|
return {
|
|
1078
|
+
execute: options.execute,
|
|
1099
1079
|
ipc: options.ipc,
|
|
1080
|
+
logError: options.logError || defaultLogError,
|
|
1100
1081
|
message: options.message,
|
|
1101
|
-
execute: options.execute,
|
|
1102
|
-
resolve: options.resolve || defaultResolve,
|
|
1103
1082
|
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
1104
|
-
|
|
1105
|
-
|
|
1083
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
1084
|
+
resolve: options.resolve || defaultResolve
|
|
1106
1085
|
};
|
|
1107
1086
|
}
|
|
1108
1087
|
return {
|
|
1088
|
+
execute: args[2],
|
|
1109
1089
|
ipc: args[0],
|
|
1090
|
+
logError: args[5],
|
|
1110
1091
|
message: args[1],
|
|
1111
|
-
execute: args[2],
|
|
1112
|
-
resolve: args[3],
|
|
1113
1092
|
preparePrettyError: args[4],
|
|
1114
|
-
|
|
1115
|
-
|
|
1093
|
+
requiresSocket: args[6],
|
|
1094
|
+
resolve: args[3]
|
|
1116
1095
|
};
|
|
1117
1096
|
};
|
|
1118
1097
|
const handleJsonRpcMessage = async (...args) => {
|
|
1119
1098
|
const options = normalizeParams(args);
|
|
1120
1099
|
const {
|
|
1121
|
-
message,
|
|
1122
|
-
ipc,
|
|
1123
1100
|
execute,
|
|
1124
|
-
|
|
1125
|
-
preparePrettyError,
|
|
1101
|
+
ipc,
|
|
1126
1102
|
logError,
|
|
1127
|
-
|
|
1103
|
+
message,
|
|
1104
|
+
preparePrettyError,
|
|
1105
|
+
requiresSocket,
|
|
1106
|
+
resolve
|
|
1128
1107
|
} = options;
|
|
1129
1108
|
if ('id' in message) {
|
|
1130
1109
|
if ('method' in message) {
|
|
@@ -1146,11 +1125,51 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
1146
1125
|
}
|
|
1147
1126
|
throw new JsonRpcError('unexpected message');
|
|
1148
1127
|
};
|
|
1149
|
-
|
|
1128
|
+
|
|
1129
|
+
const Two = '2.0';
|
|
1130
|
+
|
|
1131
|
+
const create$7 = (method, params) => {
|
|
1132
|
+
return {
|
|
1133
|
+
jsonrpc: Two,
|
|
1134
|
+
method,
|
|
1135
|
+
params
|
|
1136
|
+
};
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
const create$6 = (id, method, params) => {
|
|
1140
|
+
const message = {
|
|
1141
|
+
id,
|
|
1142
|
+
jsonrpc: Two,
|
|
1143
|
+
method,
|
|
1144
|
+
params
|
|
1145
|
+
};
|
|
1146
|
+
return message;
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1149
|
+
let id = 0;
|
|
1150
|
+
const create$5 = () => {
|
|
1151
|
+
return ++id;
|
|
1152
|
+
};
|
|
1153
|
+
|
|
1154
|
+
const registerPromise = map => {
|
|
1155
|
+
const id = create$5();
|
|
1150
1156
|
const {
|
|
1151
|
-
|
|
1157
|
+
promise,
|
|
1158
|
+
resolve
|
|
1159
|
+
} = Promise.withResolvers();
|
|
1160
|
+
map[id] = resolve;
|
|
1161
|
+
return {
|
|
1162
|
+
id,
|
|
1152
1163
|
promise
|
|
1153
|
-
}
|
|
1164
|
+
};
|
|
1165
|
+
};
|
|
1166
|
+
|
|
1167
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
1168
|
+
const {
|
|
1169
|
+
id,
|
|
1170
|
+
promise
|
|
1171
|
+
} = registerPromise(callbacks);
|
|
1172
|
+
const message = create$6(id, method, params);
|
|
1154
1173
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1155
1174
|
ipc.sendAndTransfer(message);
|
|
1156
1175
|
} else {
|
|
@@ -1159,60 +1178,40 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
1159
1178
|
const responseMessage = await promise;
|
|
1160
1179
|
return unwrapJsonRpcResult(responseMessage);
|
|
1161
1180
|
};
|
|
1162
|
-
const send = (transport, method, ...params) => {
|
|
1163
|
-
const message = create$4(method, params);
|
|
1164
|
-
transport.send(message);
|
|
1165
|
-
};
|
|
1166
|
-
const invoke = (ipc, method, ...params) => {
|
|
1167
|
-
return invokeHelper(ipc, method, params, false);
|
|
1168
|
-
};
|
|
1169
|
-
const invokeAndTransfer = (ipc, method, ...params) => {
|
|
1170
|
-
return invokeHelper(ipc, method, params, true);
|
|
1171
|
-
};
|
|
1172
|
-
|
|
1173
|
-
class CommandNotFoundError extends Error {
|
|
1174
|
-
constructor(command) {
|
|
1175
|
-
super(`Command not found ${command}`);
|
|
1176
|
-
this.name = 'CommandNotFoundError';
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
const commands = Object.create(null);
|
|
1180
|
-
const register = commandMap => {
|
|
1181
|
-
Object.assign(commands, commandMap);
|
|
1182
|
-
};
|
|
1183
|
-
const getCommand = key => {
|
|
1184
|
-
return commands[key];
|
|
1185
|
-
};
|
|
1186
|
-
const execute = (command, ...args) => {
|
|
1187
|
-
const fn = getCommand(command);
|
|
1188
|
-
if (!fn) {
|
|
1189
|
-
throw new CommandNotFoundError(command);
|
|
1190
|
-
}
|
|
1191
|
-
return fn(...args);
|
|
1192
|
-
};
|
|
1193
|
-
|
|
1194
1181
|
const createRpc = ipc => {
|
|
1182
|
+
const callbacks = Object.create(null);
|
|
1183
|
+
ipc._resolve = (id, response) => {
|
|
1184
|
+
const fn = callbacks[id];
|
|
1185
|
+
if (!fn) {
|
|
1186
|
+
console.warn(`callback ${id} may already be disposed`);
|
|
1187
|
+
return;
|
|
1188
|
+
}
|
|
1189
|
+
fn(response);
|
|
1190
|
+
delete callbacks[id];
|
|
1191
|
+
};
|
|
1195
1192
|
const rpc = {
|
|
1193
|
+
async dispose() {
|
|
1194
|
+
await ipc?.dispose();
|
|
1195
|
+
},
|
|
1196
|
+
invoke(method, ...params) {
|
|
1197
|
+
return invokeHelper(callbacks, ipc, method, params, false);
|
|
1198
|
+
},
|
|
1199
|
+
invokeAndTransfer(method, ...params) {
|
|
1200
|
+
return invokeHelper(callbacks, ipc, method, params, true);
|
|
1201
|
+
},
|
|
1196
1202
|
// @ts-ignore
|
|
1197
1203
|
ipc,
|
|
1198
1204
|
/**
|
|
1199
1205
|
* @deprecated
|
|
1200
1206
|
*/
|
|
1201
1207
|
send(method, ...params) {
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
invoke(method, ...params) {
|
|
1205
|
-
return invoke(ipc, method, ...params);
|
|
1206
|
-
},
|
|
1207
|
-
invokeAndTransfer(method, ...params) {
|
|
1208
|
-
return invokeAndTransfer(ipc, method, ...params);
|
|
1209
|
-
},
|
|
1210
|
-
async dispose() {
|
|
1211
|
-
await ipc?.dispose();
|
|
1208
|
+
const message = create$7(method, params);
|
|
1209
|
+
ipc.send(message);
|
|
1212
1210
|
}
|
|
1213
1211
|
};
|
|
1214
1212
|
return rpc;
|
|
1215
1213
|
};
|
|
1214
|
+
|
|
1216
1215
|
const requiresSocket$1 = () => {
|
|
1217
1216
|
return false;
|
|
1218
1217
|
};
|
|
@@ -1225,8 +1224,9 @@ const logError = () => {
|
|
|
1225
1224
|
const handleMessage = event => {
|
|
1226
1225
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket$1;
|
|
1227
1226
|
const actualExecute = event?.target?.execute || execute;
|
|
1228
|
-
return handleJsonRpcMessage(event.target, event.data, actualExecute,
|
|
1227
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
1229
1228
|
};
|
|
1229
|
+
|
|
1230
1230
|
const handleIpc = ipc => {
|
|
1231
1231
|
if ('addEventListener' in ipc) {
|
|
1232
1232
|
ipc.addEventListener('message', handleMessage);
|
|
@@ -1235,6 +1235,7 @@ const handleIpc = ipc => {
|
|
|
1235
1235
|
ipc.on('message', handleMessage);
|
|
1236
1236
|
}
|
|
1237
1237
|
};
|
|
1238
|
+
|
|
1238
1239
|
const listen$1 = async (module, options) => {
|
|
1239
1240
|
const rawIpc = await module.listen(options);
|
|
1240
1241
|
if (module.signal) {
|
|
@@ -1243,7 +1244,8 @@ const listen$1 = async (module, options) => {
|
|
|
1243
1244
|
const ipc = module.wrap(rawIpc);
|
|
1244
1245
|
return ipc;
|
|
1245
1246
|
};
|
|
1246
|
-
|
|
1247
|
+
|
|
1248
|
+
const create$4 = async ({
|
|
1247
1249
|
commandMap,
|
|
1248
1250
|
messagePort,
|
|
1249
1251
|
requiresSocket
|
|
@@ -1260,11 +1262,8 @@ const create$k = async ({
|
|
|
1260
1262
|
const rpc = createRpc(ipc);
|
|
1261
1263
|
return rpc;
|
|
1262
1264
|
};
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
create: create$k
|
|
1266
|
-
};
|
|
1267
|
-
const create$j = async ({
|
|
1265
|
+
|
|
1266
|
+
const create$3 = async ({
|
|
1268
1267
|
commandMap
|
|
1269
1268
|
}) => {
|
|
1270
1269
|
// TODO create a commandMap per rpc instance
|
|
@@ -1274,11 +1273,8 @@ const create$j = async ({
|
|
|
1274
1273
|
const rpc = createRpc(ipc);
|
|
1275
1274
|
return rpc;
|
|
1276
1275
|
};
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
create: create$j
|
|
1280
|
-
};
|
|
1281
|
-
const create$a = async ({
|
|
1276
|
+
|
|
1277
|
+
const create$2 = async ({
|
|
1282
1278
|
commandMap
|
|
1283
1279
|
}) => {
|
|
1284
1280
|
// TODO create a commandMap per rpc instance
|
|
@@ -1288,21 +1284,18 @@ const create$a = async ({
|
|
|
1288
1284
|
const rpc = createRpc(ipc);
|
|
1289
1285
|
return rpc;
|
|
1290
1286
|
};
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
create: create$a
|
|
1294
|
-
};
|
|
1295
|
-
const create$8 = async ({
|
|
1287
|
+
|
|
1288
|
+
const create$1 = async ({
|
|
1296
1289
|
commandMap,
|
|
1297
|
-
request,
|
|
1298
1290
|
handle,
|
|
1291
|
+
request,
|
|
1299
1292
|
requiresSocket
|
|
1300
1293
|
}) => {
|
|
1301
1294
|
// TODO create a commandMap per rpc instance
|
|
1302
1295
|
register(commandMap);
|
|
1303
1296
|
const ipc = await listen$1(IpcChildWithWebSocket, {
|
|
1304
|
-
|
|
1305
|
-
|
|
1297
|
+
handle,
|
|
1298
|
+
request
|
|
1306
1299
|
});
|
|
1307
1300
|
if (requiresSocket) {
|
|
1308
1301
|
ipc.requiresSocket = requiresSocket;
|
|
@@ -1311,11 +1304,8 @@ const create$8 = async ({
|
|
|
1311
1304
|
const rpc = createRpc(ipc);
|
|
1312
1305
|
return rpc;
|
|
1313
1306
|
};
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
create: create$8
|
|
1317
|
-
};
|
|
1318
|
-
const create$7 = async ({
|
|
1307
|
+
|
|
1308
|
+
const create = async ({
|
|
1319
1309
|
commandMap
|
|
1320
1310
|
}) => {
|
|
1321
1311
|
// TODO create a commandMap per rpc instance
|
|
@@ -1325,10 +1315,6 @@ const create$7 = async ({
|
|
|
1325
1315
|
const rpc = createRpc(ipc);
|
|
1326
1316
|
return rpc;
|
|
1327
1317
|
};
|
|
1328
|
-
const NodeWorkerRpcClient = {
|
|
1329
|
-
__proto__: null,
|
|
1330
|
-
create: create$7
|
|
1331
|
-
};
|
|
1332
1318
|
|
|
1333
1319
|
const requiresSocket = method => {
|
|
1334
1320
|
return method === 'TextSearch.searchPull';
|
|
@@ -1336,7 +1322,7 @@ const requiresSocket = method => {
|
|
|
1336
1322
|
|
|
1337
1323
|
const handleElectronMessagePort = async messagePort => {
|
|
1338
1324
|
object(messagePort);
|
|
1339
|
-
await
|
|
1325
|
+
await create$4({
|
|
1340
1326
|
commandMap: {},
|
|
1341
1327
|
messagePort,
|
|
1342
1328
|
requiresSocket
|
|
@@ -1350,7 +1336,7 @@ const handleWebSocket = async (handle, request) => {
|
|
|
1350
1336
|
}
|
|
1351
1337
|
object(handle);
|
|
1352
1338
|
object(request);
|
|
1353
|
-
await
|
|
1339
|
+
await create$1({
|
|
1354
1340
|
commandMap: {},
|
|
1355
1341
|
handle,
|
|
1356
1342
|
request,
|
|
@@ -1393,7 +1379,7 @@ const isEnoentError = error => {
|
|
|
1393
1379
|
return isEnoentErrorLinux(error) || isEnoentErrorWindows(error);
|
|
1394
1380
|
};
|
|
1395
1381
|
|
|
1396
|
-
const getNewLineIndex = (string, startIndex =
|
|
1382
|
+
const getNewLineIndex = (string, startIndex = 0) => {
|
|
1397
1383
|
return string.indexOf(NewLine, startIndex);
|
|
1398
1384
|
};
|
|
1399
1385
|
|
|
@@ -1775,11 +1761,9 @@ const collectStdoutIncremental = async (id, stdout, kill, maxSearchResults, char
|
|
|
1775
1761
|
const results = Object.values(allSearchResults).flat();
|
|
1776
1762
|
return results.slice(minLineY, maxLineY);
|
|
1777
1763
|
},
|
|
1778
|
-
getResultCount()
|
|
1779
|
-
return numberOfResults;
|
|
1780
|
-
}
|
|
1764
|
+
getResultCount: () => numberOfResults
|
|
1781
1765
|
};
|
|
1782
|
-
set$
|
|
1766
|
+
set$1(id, search);
|
|
1783
1767
|
stdout.setEncoding(Utf8);
|
|
1784
1768
|
const handleLine = line => {
|
|
1785
1769
|
const parsedLine = JSON.parse(line);
|
|
@@ -1839,7 +1823,7 @@ const collectStdoutIncremental = async (id, stdout, kill, maxSearchResults, char
|
|
|
1839
1823
|
// TODO maybe split text search and file search into two processes,
|
|
1840
1824
|
// so that long file text search cannot block file search and
|
|
1841
1825
|
// text and file search would be more independent
|
|
1842
|
-
// only the logic for ripgrep path and
|
|
1826
|
+
// only the logic for ripgrep path and WebSocket / messageport handling
|
|
1843
1827
|
// would need to be the same
|
|
1844
1828
|
// @deprecated use TextSearch.searchPull instead
|
|
1845
1829
|
const textSearchIncremental = async ({
|
|
@@ -1891,16 +1875,14 @@ const collectStdoutPull = async (searchId, stdout, kill, maxSearchResults, chars
|
|
|
1891
1875
|
hasUnfetchedResults = false;
|
|
1892
1876
|
return newItems;
|
|
1893
1877
|
},
|
|
1894
|
-
getProgress() {
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
};
|
|
1901
|
-
}
|
|
1878
|
+
getProgress: () => ({
|
|
1879
|
+
done,
|
|
1880
|
+
limitHit,
|
|
1881
|
+
resultCount: numberOfResults,
|
|
1882
|
+
stats
|
|
1883
|
+
})
|
|
1902
1884
|
};
|
|
1903
|
-
set
|
|
1885
|
+
set(searchId, search);
|
|
1904
1886
|
stdout.setEncoding(Utf8);
|
|
1905
1887
|
const handleLine = line => {
|
|
1906
1888
|
const parsedLine = JSON.parse(line);
|
|
@@ -2037,15 +2019,15 @@ const Auto = argv => {
|
|
|
2037
2019
|
const getModule = method => {
|
|
2038
2020
|
switch (method) {
|
|
2039
2021
|
case ElectronMessagePort:
|
|
2040
|
-
return
|
|
2022
|
+
return create$4;
|
|
2041
2023
|
case ElectronUtilityProcess:
|
|
2042
|
-
return
|
|
2024
|
+
return create$3;
|
|
2043
2025
|
case NodeForkedProcess:
|
|
2044
|
-
return
|
|
2026
|
+
return create$2;
|
|
2045
2027
|
case NodeWorker:
|
|
2046
|
-
return
|
|
2028
|
+
return create;
|
|
2047
2029
|
case WebSocket:
|
|
2048
|
-
return
|
|
2030
|
+
return create$1;
|
|
2049
2031
|
default:
|
|
2050
2032
|
throw new Error('unexpected ipc type');
|
|
2051
2033
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/search-process",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"description": "Search Process",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lvce Editor",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"search-process": "bin/searchProcess.js"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@lvce-editor/constants": "^
|
|
22
|
-
"execa": "^9.6.
|
|
23
|
-
"ws": "^8.
|
|
21
|
+
"@lvce-editor/constants": "^5.14.0",
|
|
22
|
+
"execa": "^9.6.1",
|
|
23
|
+
"ws": "^8.21.0"
|
|
24
24
|
},
|
|
25
25
|
"optionalDependencies": {
|
|
26
|
-
"@lvce-editor/ripgrep": "^
|
|
26
|
+
"@lvce-editor/ripgrep": "^5.1.0"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
29
|
"node": ">=24"
|