@lvce-editor/file-search-worker 7.2.0 → 7.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/fileSearchWorkerMain.js +106 -56
- package/package.json +1 -1
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
const EditorWorker = 99;
|
|
2
|
+
const RendererWorker = 1;
|
|
3
|
+
|
|
4
|
+
const SetDom2 = 'Viewlet.setDom2';
|
|
5
|
+
|
|
6
|
+
const FocusQuickPickInput = 20;
|
|
7
|
+
|
|
8
|
+
const rpcs = Object.create(null);
|
|
9
|
+
const set$3 = (id, rpc) => {
|
|
10
|
+
rpcs[id] = rpc;
|
|
11
|
+
};
|
|
12
|
+
const get$2 = id => {
|
|
13
|
+
return rpcs[id];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const create$7 = rpcId => {
|
|
17
|
+
return {
|
|
18
|
+
async dispose() {
|
|
19
|
+
const rpc = get$2(rpcId);
|
|
20
|
+
await rpc.dispose();
|
|
21
|
+
},
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
invoke(method, ...params) {
|
|
24
|
+
const rpc = get$2(rpcId);
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
return rpc.invoke(method, ...params);
|
|
27
|
+
},
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
invokeAndTransfer(method, ...params) {
|
|
30
|
+
const rpc = get$2(rpcId);
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
33
|
+
},
|
|
34
|
+
set(rpc) {
|
|
35
|
+
set$3(rpcId, rpc);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
1
40
|
const normalizeLine = line => {
|
|
2
41
|
if (line.startsWith('Error: ')) {
|
|
3
42
|
return line.slice('Error: '.length);
|
|
@@ -526,7 +565,7 @@ const IpcParentWithMessagePort$1 = {
|
|
|
526
565
|
|
|
527
566
|
const Two$1 = '2.0';
|
|
528
567
|
const callbacks$1 = Object.create(null);
|
|
529
|
-
const get$
|
|
568
|
+
const get$1 = id => {
|
|
530
569
|
return callbacks$1[id];
|
|
531
570
|
};
|
|
532
571
|
const remove = id => {
|
|
@@ -675,7 +714,7 @@ const warn$1 = (...args) => {
|
|
|
675
714
|
console.warn(...args);
|
|
676
715
|
};
|
|
677
716
|
const resolve = (id, response) => {
|
|
678
|
-
const fn = get$
|
|
717
|
+
const fn = get$1(id);
|
|
679
718
|
if (!fn) {
|
|
680
719
|
console.log(response);
|
|
681
720
|
warn$1(`callback ${id} may already be disposed`);
|
|
@@ -1012,9 +1051,35 @@ const create$6 = async ({
|
|
|
1012
1051
|
messagePort: port2
|
|
1013
1052
|
});
|
|
1014
1053
|
};
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1054
|
+
|
|
1055
|
+
/* eslint-disable @typescript-eslint/no-misused-promises */
|
|
1056
|
+
|
|
1057
|
+
const createSharedLazyRpc = factory => {
|
|
1058
|
+
let rpcPromise;
|
|
1059
|
+
const getOrCreate = () => {
|
|
1060
|
+
if (!rpcPromise) {
|
|
1061
|
+
rpcPromise = factory();
|
|
1062
|
+
}
|
|
1063
|
+
return rpcPromise;
|
|
1064
|
+
};
|
|
1065
|
+
return {
|
|
1066
|
+
async dispose() {
|
|
1067
|
+
const rpc = await getOrCreate();
|
|
1068
|
+
await rpc.dispose();
|
|
1069
|
+
},
|
|
1070
|
+
async invoke(method, ...params) {
|
|
1071
|
+
const rpc = await getOrCreate();
|
|
1072
|
+
return rpc.invoke(method, ...params);
|
|
1073
|
+
},
|
|
1074
|
+
async invokeAndTransfer(method, ...params) {
|
|
1075
|
+
const rpc = await getOrCreate();
|
|
1076
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1077
|
+
},
|
|
1078
|
+
async send(method, ...params) {
|
|
1079
|
+
const rpc = await getOrCreate();
|
|
1080
|
+
rpc.send(method, ...params);
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1018
1083
|
};
|
|
1019
1084
|
const create$2$1 = async ({
|
|
1020
1085
|
commandMap
|
|
@@ -1030,50 +1095,28 @@ const WebWorkerRpcClient = {
|
|
|
1030
1095
|
__proto__: null,
|
|
1031
1096
|
create: create$2$1
|
|
1032
1097
|
};
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
};
|
|
1045
|
-
const get$1 = id => {
|
|
1046
|
-
return rpcs[id];
|
|
1098
|
+
const create$3 = async ({
|
|
1099
|
+
commandMap,
|
|
1100
|
+
isMessagePortOpen,
|
|
1101
|
+
send
|
|
1102
|
+
}) => {
|
|
1103
|
+
return createSharedLazyRpc(() => {
|
|
1104
|
+
return create$6({
|
|
1105
|
+
commandMap,
|
|
1106
|
+
isMessagePortOpen,
|
|
1107
|
+
send
|
|
1108
|
+
});
|
|
1109
|
+
});
|
|
1047
1110
|
};
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
async dispose() {
|
|
1052
|
-
const rpc = get$1(rpcId);
|
|
1053
|
-
await rpc.dispose();
|
|
1054
|
-
},
|
|
1055
|
-
// @ts-ignore
|
|
1056
|
-
invoke(method, ...params) {
|
|
1057
|
-
const rpc = get$1(rpcId);
|
|
1058
|
-
// @ts-ignore
|
|
1059
|
-
return rpc.invoke(method, ...params);
|
|
1060
|
-
},
|
|
1061
|
-
// @ts-ignore
|
|
1062
|
-
invokeAndTransfer(method, ...params) {
|
|
1063
|
-
const rpc = get$1(rpcId);
|
|
1064
|
-
// @ts-ignore
|
|
1065
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
1066
|
-
},
|
|
1067
|
-
set(rpc) {
|
|
1068
|
-
set$3(rpcId, rpc);
|
|
1069
|
-
}
|
|
1070
|
-
};
|
|
1111
|
+
const LazyTransferMessagePortRpcParent = {
|
|
1112
|
+
__proto__: null,
|
|
1113
|
+
create: create$3
|
|
1071
1114
|
};
|
|
1072
1115
|
|
|
1073
1116
|
const {
|
|
1074
1117
|
invoke: invoke$2,
|
|
1075
1118
|
set: set$2
|
|
1076
|
-
} = create$
|
|
1119
|
+
} = create$7(EditorWorker);
|
|
1077
1120
|
const getLines = async editorUid => {
|
|
1078
1121
|
const lines = await invoke$2('Editor.getLines2', editorUid);
|
|
1079
1122
|
return lines;
|
|
@@ -1083,7 +1126,7 @@ const {
|
|
|
1083
1126
|
invoke: invoke$1,
|
|
1084
1127
|
invokeAndTransfer,
|
|
1085
1128
|
set: set$1
|
|
1086
|
-
} = create$
|
|
1129
|
+
} = create$7(RendererWorker);
|
|
1087
1130
|
const sendMessagePortToEditorWorker = async (port, rpcId) => {
|
|
1088
1131
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1089
1132
|
// @ts-ignore
|
|
@@ -2951,14 +2994,7 @@ const handleMessagePort = async port => {
|
|
|
2951
2994
|
};
|
|
2952
2995
|
|
|
2953
2996
|
const initialize = async () => {
|
|
2954
|
-
//
|
|
2955
|
-
const rpc = await TransferMessagePortRpcParent.create({
|
|
2956
|
-
commandMap: {},
|
|
2957
|
-
async send(port) {
|
|
2958
|
-
await sendMessagePortToEditorWorker(port, 0);
|
|
2959
|
-
}
|
|
2960
|
-
});
|
|
2961
|
-
set$2(rpc);
|
|
2997
|
+
// not needed anymore
|
|
2962
2998
|
};
|
|
2963
2999
|
|
|
2964
3000
|
const getDefaultValue = id => {
|
|
@@ -3637,6 +3673,23 @@ const commandMap = {
|
|
|
3637
3673
|
'QuickPick.showQuickInput': showQuickInput
|
|
3638
3674
|
};
|
|
3639
3675
|
|
|
3676
|
+
const initializeEditorWorker = async () => {
|
|
3677
|
+
const rpc = await LazyTransferMessagePortRpcParent.create({
|
|
3678
|
+
commandMap: {},
|
|
3679
|
+
async send(port) {
|
|
3680
|
+
await sendMessagePortToEditorWorker(port, 0);
|
|
3681
|
+
}
|
|
3682
|
+
});
|
|
3683
|
+
set$2(rpc);
|
|
3684
|
+
};
|
|
3685
|
+
|
|
3686
|
+
const initializeRendererWorker = async () => {
|
|
3687
|
+
const rpc = await WebWorkerRpcClient.create({
|
|
3688
|
+
commandMap: commandMap
|
|
3689
|
+
});
|
|
3690
|
+
set$1(rpc);
|
|
3691
|
+
};
|
|
3692
|
+
|
|
3640
3693
|
const Memfs = 'memfs';
|
|
3641
3694
|
const Html = 'html';
|
|
3642
3695
|
const Fetch = 'fetch';
|
|
@@ -3693,10 +3746,7 @@ const listen = async () => {
|
|
|
3693
3746
|
Object.assign(commandMapRef, commandMap);
|
|
3694
3747
|
registerCommands(commandMap);
|
|
3695
3748
|
register(searchModules);
|
|
3696
|
-
|
|
3697
|
-
commandMap: commandMap
|
|
3698
|
-
});
|
|
3699
|
-
set$1(rpc);
|
|
3749
|
+
await Promise.all([initializeRendererWorker(), initializeEditorWorker()]);
|
|
3700
3750
|
};
|
|
3701
3751
|
|
|
3702
3752
|
const main = async () => {
|