@lvce-editor/completion-worker 1.21.0 → 1.22.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/completionWorkerMain.js +191 -128
- package/package.json +1 -1
|
@@ -964,7 +964,7 @@ const listen$1 = async (module, options) => {
|
|
|
964
964
|
const ipc = module.wrap(rawIpc);
|
|
965
965
|
return ipc;
|
|
966
966
|
};
|
|
967
|
-
const create$
|
|
967
|
+
const create$4 = async ({
|
|
968
968
|
commandMap,
|
|
969
969
|
messagePort
|
|
970
970
|
}) => {
|
|
@@ -982,18 +982,23 @@ const create$3 = async ({
|
|
|
982
982
|
};
|
|
983
983
|
const create$2$1 = async ({
|
|
984
984
|
commandMap,
|
|
985
|
-
|
|
985
|
+
send
|
|
986
986
|
}) => {
|
|
987
|
-
|
|
987
|
+
const {
|
|
988
|
+
port1,
|
|
989
|
+
port2
|
|
990
|
+
} = new MessageChannel();
|
|
991
|
+
await send(port1);
|
|
992
|
+
return create$4({
|
|
988
993
|
commandMap,
|
|
989
|
-
messagePort
|
|
994
|
+
messagePort: port2
|
|
990
995
|
});
|
|
991
996
|
};
|
|
992
|
-
const
|
|
997
|
+
const TransferMessagePortRpcParent = {
|
|
993
998
|
__proto__: null,
|
|
994
999
|
create: create$2$1
|
|
995
1000
|
};
|
|
996
|
-
const create$
|
|
1001
|
+
const create$3 = async ({
|
|
997
1002
|
commandMap
|
|
998
1003
|
}) => {
|
|
999
1004
|
// TODO create a commandMap per rpc instance
|
|
@@ -1005,7 +1010,69 @@ const create$4 = async ({
|
|
|
1005
1010
|
};
|
|
1006
1011
|
const WebWorkerRpcClient = {
|
|
1007
1012
|
__proto__: null,
|
|
1008
|
-
create: create$
|
|
1013
|
+
create: create$3
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1016
|
+
const create$2 = () => {
|
|
1017
|
+
const states = Object.create(null);
|
|
1018
|
+
return {
|
|
1019
|
+
get(uid) {
|
|
1020
|
+
return states[uid];
|
|
1021
|
+
},
|
|
1022
|
+
set(uid, oldState, newState) {
|
|
1023
|
+
states[uid] = {
|
|
1024
|
+
oldState,
|
|
1025
|
+
newState
|
|
1026
|
+
};
|
|
1027
|
+
},
|
|
1028
|
+
dispose(uid) {
|
|
1029
|
+
delete states[uid];
|
|
1030
|
+
},
|
|
1031
|
+
getKeys() {
|
|
1032
|
+
return Object.keys(states).map(key => {
|
|
1033
|
+
return Number.parseInt(key);
|
|
1034
|
+
});
|
|
1035
|
+
},
|
|
1036
|
+
clear() {
|
|
1037
|
+
for (const key of Object.keys(states)) {
|
|
1038
|
+
delete states[key];
|
|
1039
|
+
}
|
|
1040
|
+
},
|
|
1041
|
+
wrapCommand(fn) {
|
|
1042
|
+
const wrapped = async (uid, ...args) => {
|
|
1043
|
+
const {
|
|
1044
|
+
newState
|
|
1045
|
+
} = states[uid];
|
|
1046
|
+
const newerState = await fn(newState, ...args);
|
|
1047
|
+
if (newState === newerState) {
|
|
1048
|
+
return;
|
|
1049
|
+
}
|
|
1050
|
+
const latest = states[uid];
|
|
1051
|
+
states[uid] = {
|
|
1052
|
+
oldState: latest.oldState,
|
|
1053
|
+
newState: newerState
|
|
1054
|
+
};
|
|
1055
|
+
};
|
|
1056
|
+
return wrapped;
|
|
1057
|
+
},
|
|
1058
|
+
diff(uid, modules, numbers) {
|
|
1059
|
+
const {
|
|
1060
|
+
oldState,
|
|
1061
|
+
newState
|
|
1062
|
+
} = states[uid];
|
|
1063
|
+
const diffResult = [];
|
|
1064
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1065
|
+
const fn = modules[i];
|
|
1066
|
+
if (!fn(oldState, newState)) {
|
|
1067
|
+
diffResult.push(numbers[i]);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
return diffResult;
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
};
|
|
1074
|
+
const terminate = () => {
|
|
1075
|
+
globalThis.close();
|
|
1009
1076
|
};
|
|
1010
1077
|
|
|
1011
1078
|
const rpcs = Object.create(null);
|
|
@@ -1018,7 +1085,7 @@ const get$1 = id => {
|
|
|
1018
1085
|
|
|
1019
1086
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1020
1087
|
|
|
1021
|
-
const create$
|
|
1088
|
+
const create$1 = rpcId => {
|
|
1022
1089
|
return {
|
|
1023
1090
|
// @ts-ignore
|
|
1024
1091
|
invoke(method, ...params) {
|
|
@@ -1041,21 +1108,78 @@ const create$2 = rpcId => {
|
|
|
1041
1108
|
}
|
|
1042
1109
|
};
|
|
1043
1110
|
};
|
|
1044
|
-
const EditorWorker$
|
|
1111
|
+
const EditorWorker$2 = 99;
|
|
1045
1112
|
const ExtensionHostWorker = 44;
|
|
1046
1113
|
const {
|
|
1047
1114
|
invoke: invoke$d,
|
|
1048
1115
|
invokeAndTransfer: invokeAndTransfer$c,
|
|
1049
|
-
set: set$c
|
|
1050
|
-
|
|
1116
|
+
set: set$c,
|
|
1117
|
+
dispose: dispose$c
|
|
1118
|
+
} = create$1(EditorWorker$2);
|
|
1119
|
+
const sendMessagePortToExtensionHostWorker$1$1 = async port => {
|
|
1120
|
+
const command = 'HandleMessagePort.handleMessagePort2';
|
|
1121
|
+
await invokeAndTransfer$c(
|
|
1122
|
+
// @ts-ignore
|
|
1123
|
+
'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, 0 // TODO
|
|
1124
|
+
);
|
|
1125
|
+
};
|
|
1126
|
+
|
|
1127
|
+
// TODO add tests for this
|
|
1128
|
+
const activateByEvent$1$1 = async event => {
|
|
1129
|
+
// @ts-ignore
|
|
1130
|
+
await invoke$d('ActivateByEvent.activateByEvent', event);
|
|
1131
|
+
};
|
|
1132
|
+
const applyEdit$2 = async (editorUid, changes) => {
|
|
1133
|
+
// @ts-ignore
|
|
1134
|
+
await EditorWorker.invoke('Editor.applyEdit2', editorUid, changes);
|
|
1135
|
+
};
|
|
1136
|
+
const closeWidget$1 = async (editorUid, widgetId, widgetName, focusId) => {
|
|
1137
|
+
// @ts-ignore
|
|
1138
|
+
await invoke$d('Editor.closeWidget2', editorUid, widgetId, widgetName, focusId);
|
|
1139
|
+
};
|
|
1140
|
+
const getWordAt$1 = async (uid, rowIndex, columnIndex) => {
|
|
1141
|
+
// @ts-ignore
|
|
1142
|
+
const word = await invoke$d('Editor.getWordAt2', uid, rowIndex, columnIndex);
|
|
1143
|
+
return word;
|
|
1144
|
+
};
|
|
1145
|
+
const getLines$2 = async editorUid => {
|
|
1146
|
+
const lines = await invoke$d('Editor.getLines2', editorUid);
|
|
1147
|
+
return lines;
|
|
1148
|
+
};
|
|
1149
|
+
const getPositionAtCursor$2 = async parentUid => {
|
|
1150
|
+
const position = await invoke$d('Editor.getPositionAtCursor', parentUid);
|
|
1151
|
+
return position;
|
|
1152
|
+
};
|
|
1153
|
+
const getSelections$2 = async editorUid => {
|
|
1154
|
+
const selections = await invoke$d('Editor.getSelections2', editorUid);
|
|
1155
|
+
return selections;
|
|
1156
|
+
};
|
|
1157
|
+
const getWordAtOffset2$1 = async editorUid => {
|
|
1158
|
+
return invoke$d('Editor.getWordAtOffset2', editorUid);
|
|
1159
|
+
};
|
|
1160
|
+
const getWordBefore$2 = async (editorUid, rowIndex, columnIndex) => {
|
|
1161
|
+
return invoke$d('Editor.getWordBefore2', editorUid, rowIndex, columnIndex);
|
|
1162
|
+
};
|
|
1163
|
+
const EditorWorker$1$1 = {
|
|
1051
1164
|
__proto__: null,
|
|
1165
|
+
activateByEvent: activateByEvent$1$1,
|
|
1166
|
+
applyEdit: applyEdit$2,
|
|
1167
|
+
closeWidget: closeWidget$1,
|
|
1168
|
+
dispose: dispose$c,
|
|
1169
|
+
getLines: getLines$2,
|
|
1170
|
+
getPositionAtCursor: getPositionAtCursor$2,
|
|
1171
|
+
getSelections: getSelections$2,
|
|
1172
|
+
getWordAt: getWordAt$1,
|
|
1173
|
+
getWordAtOffset2: getWordAtOffset2$1,
|
|
1174
|
+
getWordBefore: getWordBefore$2,
|
|
1052
1175
|
invoke: invoke$d,
|
|
1053
1176
|
invokeAndTransfer: invokeAndTransfer$c,
|
|
1177
|
+
sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1$1,
|
|
1054
1178
|
set: set$c
|
|
1055
1179
|
};
|
|
1056
1180
|
const {
|
|
1057
1181
|
invoke: invoke$a,
|
|
1058
|
-
set: set$9} = create$
|
|
1182
|
+
set: set$9} = create$1(ExtensionHostWorker);
|
|
1059
1183
|
const ExtensionHost = {
|
|
1060
1184
|
__proto__: null,
|
|
1061
1185
|
invoke: invoke$a,
|
|
@@ -1065,7 +1189,37 @@ const ExtensionHost = {
|
|
|
1065
1189
|
const {
|
|
1066
1190
|
invoke: invoke$1,
|
|
1067
1191
|
set: set$2,
|
|
1068
|
-
|
|
1192
|
+
dispose: dispose$2,
|
|
1193
|
+
sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1,
|
|
1194
|
+
activateByEvent: activateByEvent$1,
|
|
1195
|
+
applyEdit: applyEdit$1,
|
|
1196
|
+
closeWidget,
|
|
1197
|
+
getLines: getLines$1,
|
|
1198
|
+
getPositionAtCursor: getPositionAtCursor$1,
|
|
1199
|
+
getSelections: getSelections$1,
|
|
1200
|
+
getWordAt,
|
|
1201
|
+
getWordAtOffset2,
|
|
1202
|
+
getWordBefore: getWordBefore$1,
|
|
1203
|
+
invokeAndTransfer
|
|
1204
|
+
} = EditorWorker$1$1;
|
|
1205
|
+
|
|
1206
|
+
const EditorWorker$1 = {
|
|
1207
|
+
__proto__: null,
|
|
1208
|
+
activateByEvent: activateByEvent$1,
|
|
1209
|
+
applyEdit: applyEdit$1,
|
|
1210
|
+
closeWidget,
|
|
1211
|
+
dispose: dispose$2,
|
|
1212
|
+
getLines: getLines$1,
|
|
1213
|
+
getPositionAtCursor: getPositionAtCursor$1,
|
|
1214
|
+
getSelections: getSelections$1,
|
|
1215
|
+
getWordAt,
|
|
1216
|
+
getWordAtOffset2,
|
|
1217
|
+
getWordBefore: getWordBefore$1,
|
|
1218
|
+
invoke: invoke$1,
|
|
1219
|
+
invokeAndTransfer,
|
|
1220
|
+
sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1,
|
|
1221
|
+
set: set$2
|
|
1222
|
+
};
|
|
1069
1223
|
|
|
1070
1224
|
const FocusEditorCompletions = 9;
|
|
1071
1225
|
const FocusEditorRename = 11;
|
|
@@ -1076,76 +1230,16 @@ const close = async state => {
|
|
|
1076
1230
|
const {
|
|
1077
1231
|
editorUid
|
|
1078
1232
|
} = state;
|
|
1079
|
-
|
|
1080
|
-
await invoke$1('Editor.closeWidget2', editorUid, Completion, 'Completions', FocusEditorCompletions);
|
|
1233
|
+
await closeWidget(editorUid, Completion, 'Completions', FocusEditorCompletions);
|
|
1081
1234
|
return state;
|
|
1082
1235
|
};
|
|
1083
1236
|
|
|
1084
|
-
const create$1 = () => {
|
|
1085
|
-
const states = Object.create(null);
|
|
1086
|
-
return {
|
|
1087
|
-
get(uid) {
|
|
1088
|
-
return states[uid];
|
|
1089
|
-
},
|
|
1090
|
-
set(uid, oldState, newState) {
|
|
1091
|
-
states[uid] = {
|
|
1092
|
-
oldState,
|
|
1093
|
-
newState
|
|
1094
|
-
};
|
|
1095
|
-
},
|
|
1096
|
-
dispose(uid) {
|
|
1097
|
-
delete states[uid];
|
|
1098
|
-
},
|
|
1099
|
-
getKeys() {
|
|
1100
|
-
return Object.keys(states).map(key => {
|
|
1101
|
-
return Number.parseInt(key);
|
|
1102
|
-
});
|
|
1103
|
-
},
|
|
1104
|
-
clear() {
|
|
1105
|
-
for (const key of Object.keys(states)) {
|
|
1106
|
-
delete states[key];
|
|
1107
|
-
}
|
|
1108
|
-
},
|
|
1109
|
-
wrapCommand(fn) {
|
|
1110
|
-
const wrapped = async (uid, ...args) => {
|
|
1111
|
-
const {
|
|
1112
|
-
newState
|
|
1113
|
-
} = states[uid];
|
|
1114
|
-
const newerState = await fn(newState, ...args);
|
|
1115
|
-
if (newState === newerState) {
|
|
1116
|
-
return;
|
|
1117
|
-
}
|
|
1118
|
-
const latest = states[uid];
|
|
1119
|
-
states[uid] = {
|
|
1120
|
-
oldState: latest.oldState,
|
|
1121
|
-
newState: newerState
|
|
1122
|
-
};
|
|
1123
|
-
};
|
|
1124
|
-
return wrapped;
|
|
1125
|
-
},
|
|
1126
|
-
diff(uid, modules, numbers) {
|
|
1127
|
-
const {
|
|
1128
|
-
oldState,
|
|
1129
|
-
newState
|
|
1130
|
-
} = states[uid];
|
|
1131
|
-
const diffResult = [];
|
|
1132
|
-
for (let i = 0; i < modules.length; i++) {
|
|
1133
|
-
const fn = modules[i];
|
|
1134
|
-
if (!fn(oldState, newState)) {
|
|
1135
|
-
diffResult.push(numbers[i]);
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
return diffResult;
|
|
1139
|
-
}
|
|
1140
|
-
};
|
|
1141
|
-
};
|
|
1142
|
-
|
|
1143
1237
|
const {
|
|
1144
1238
|
get,
|
|
1145
1239
|
set: set$1,
|
|
1146
1240
|
wrapCommand,
|
|
1147
1241
|
dispose: dispose$1
|
|
1148
|
-
} = create$
|
|
1242
|
+
} = create$2();
|
|
1149
1243
|
|
|
1150
1244
|
const create = (uid, x, y, width, height, editorUid, editorLanguageId) => {
|
|
1151
1245
|
const state = {
|
|
@@ -1265,15 +1359,13 @@ const applyEdit = async (editorUid, changes) => {
|
|
|
1265
1359
|
await invoke$1('Editor.applyEdit2', editorUid, changes);
|
|
1266
1360
|
};
|
|
1267
1361
|
|
|
1268
|
-
const
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
};
|
|
1362
|
+
const {
|
|
1363
|
+
getLines
|
|
1364
|
+
} = EditorWorker$1;
|
|
1272
1365
|
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
};
|
|
1366
|
+
const {
|
|
1367
|
+
getSelections
|
|
1368
|
+
} = EditorWorker$1;
|
|
1277
1369
|
|
|
1278
1370
|
const getSelectionPairs = (selections, i) => {
|
|
1279
1371
|
const first = selections[i];
|
|
@@ -1331,11 +1423,9 @@ const OnCompletion = 'onCompletion';
|
|
|
1331
1423
|
const CompletionExecute = 'ExtensionHostCompletion.execute';
|
|
1332
1424
|
const CompletionResolveExecute = 'ExtensionHostCompletion.executeResolve';
|
|
1333
1425
|
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
await invoke$1('ActivateByEvent.activateByEvent', event);
|
|
1338
|
-
};
|
|
1426
|
+
const {
|
|
1427
|
+
activateByEvent
|
|
1428
|
+
} = EditorWorker$1;
|
|
1339
1429
|
|
|
1340
1430
|
const {
|
|
1341
1431
|
invoke,
|
|
@@ -1732,14 +1822,11 @@ const getListHeight = (itemsLength, itemHeight, maxHeight) => {
|
|
|
1732
1822
|
return Math.min(totalHeight, maxHeight);
|
|
1733
1823
|
};
|
|
1734
1824
|
|
|
1735
|
-
const
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
};
|
|
1825
|
+
const {
|
|
1826
|
+
getPositionAtCursor
|
|
1827
|
+
} = EditorWorker$1;
|
|
1739
1828
|
|
|
1740
|
-
const getWordAtOffset =
|
|
1741
|
-
return invoke$1('Editor.getWordAtOffset2', editorUid);
|
|
1742
|
-
};
|
|
1829
|
+
const getWordAtOffset = getWordAtOffset2;
|
|
1743
1830
|
|
|
1744
1831
|
const handleEditorDeleteLeft = async state => {
|
|
1745
1832
|
const {
|
|
@@ -1774,9 +1861,9 @@ const handleEditorDeleteLeft = async state => {
|
|
|
1774
1861
|
};
|
|
1775
1862
|
};
|
|
1776
1863
|
|
|
1777
|
-
const
|
|
1778
|
-
|
|
1779
|
-
};
|
|
1864
|
+
const {
|
|
1865
|
+
getWordBefore
|
|
1866
|
+
} = EditorWorker$1;
|
|
1780
1867
|
|
|
1781
1868
|
const handleEditorType = async state => {
|
|
1782
1869
|
const {
|
|
@@ -1880,36 +1967,15 @@ const handleWheel = (state, deltaMode, deltaY) => {
|
|
|
1880
1967
|
return setDeltaY(state, state.deltaY + deltaY);
|
|
1881
1968
|
};
|
|
1882
1969
|
|
|
1883
|
-
const
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
port2
|
|
1887
|
-
} = new MessageChannel();
|
|
1888
|
-
return {
|
|
1889
|
-
port1,
|
|
1890
|
-
port2
|
|
1891
|
-
};
|
|
1892
|
-
};
|
|
1893
|
-
|
|
1894
|
-
const sendMessagePortToExtensionHostWorker = async port => {
|
|
1895
|
-
const command = 'HandleMessagePort.handleMessagePort2';
|
|
1896
|
-
// @ts-ignore
|
|
1897
|
-
await invokeAndTransfer(
|
|
1898
|
-
// @ts-ignore
|
|
1899
|
-
'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, 0 // TODO
|
|
1900
|
-
);
|
|
1901
|
-
};
|
|
1970
|
+
const {
|
|
1971
|
+
sendMessagePortToExtensionHostWorker
|
|
1972
|
+
} = EditorWorker$1;
|
|
1902
1973
|
|
|
1903
1974
|
const createExtensionHostRpc = async () => {
|
|
1904
1975
|
try {
|
|
1905
|
-
const {
|
|
1906
|
-
port1,
|
|
1907
|
-
port2
|
|
1908
|
-
} = getPortTuple();
|
|
1909
|
-
await sendMessagePortToExtensionHostWorker(port2);
|
|
1910
|
-
const rpc = await PlainMessagePortRpcParent.create({
|
|
1976
|
+
const rpc = await TransferMessagePortRpcParent.create({
|
|
1911
1977
|
commandMap: {},
|
|
1912
|
-
|
|
1978
|
+
send: sendMessagePortToExtensionHostWorker
|
|
1913
1979
|
});
|
|
1914
1980
|
return rpc;
|
|
1915
1981
|
} catch (error) {
|
|
@@ -1924,6 +1990,7 @@ const initialize = async () => {
|
|
|
1924
1990
|
|
|
1925
1991
|
const error = message => {
|
|
1926
1992
|
// TODO send this to error worker for logging
|
|
1993
|
+
// @ts-ignore
|
|
1927
1994
|
console.error(message);
|
|
1928
1995
|
};
|
|
1929
1996
|
|
|
@@ -2395,10 +2462,6 @@ const render2 = (uid, diffResult) => {
|
|
|
2395
2462
|
return commands;
|
|
2396
2463
|
};
|
|
2397
2464
|
|
|
2398
|
-
const terminate = () => {
|
|
2399
|
-
globalThis.close();
|
|
2400
|
-
};
|
|
2401
|
-
|
|
2402
2465
|
const commandMap = {
|
|
2403
2466
|
'Completions.close': wrapCommand(close),
|
|
2404
2467
|
'Completions.create': create,
|