@lvce-editor/editor-worker 7.4.0 → 7.6.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/editorWorkerMain.js +110 -60
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1033,7 +1033,7 @@ const WebWorkerRpcClient = {
|
|
|
1033
1033
|
};
|
|
1034
1034
|
|
|
1035
1035
|
const rpcs = Object.create(null);
|
|
1036
|
-
const set$
|
|
1036
|
+
const set$d = (id, rpc) => {
|
|
1037
1037
|
rpcs[id] = rpc;
|
|
1038
1038
|
};
|
|
1039
1039
|
const get$6 = id => {
|
|
@@ -1057,11 +1057,11 @@ const create$9 = rpcId => {
|
|
|
1057
1057
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1058
1058
|
},
|
|
1059
1059
|
set(rpc) {
|
|
1060
|
-
set$
|
|
1060
|
+
set$d(rpcId, rpc);
|
|
1061
1061
|
}
|
|
1062
1062
|
};
|
|
1063
1063
|
};
|
|
1064
|
-
const DebugWorker = 55;
|
|
1064
|
+
const DebugWorker$1 = 55;
|
|
1065
1065
|
const EditorWorker$1 = 99;
|
|
1066
1066
|
const ExtensionHostWorker = 44;
|
|
1067
1067
|
const MainProcess$1 = -5;
|
|
@@ -1084,7 +1084,7 @@ const RpcId = {
|
|
|
1084
1084
|
__proto__: null,
|
|
1085
1085
|
ColorPickerWorker,
|
|
1086
1086
|
CompletionWorker,
|
|
1087
|
-
DebugWorker,
|
|
1087
|
+
DebugWorker: DebugWorker$1,
|
|
1088
1088
|
EditorWorker: EditorWorker$1,
|
|
1089
1089
|
EmbedsProcess: EmbedsProcess$1,
|
|
1090
1090
|
EmbedsWorker,
|
|
@@ -1189,15 +1189,15 @@ const launchColorPickerWorker = async () => {
|
|
|
1189
1189
|
return launchWorker(name, url);
|
|
1190
1190
|
};
|
|
1191
1191
|
|
|
1192
|
-
let workerPromise$
|
|
1193
|
-
const getOrCreate$
|
|
1194
|
-
if (!workerPromise$
|
|
1195
|
-
workerPromise$
|
|
1192
|
+
let workerPromise$3;
|
|
1193
|
+
const getOrCreate$4 = () => {
|
|
1194
|
+
if (!workerPromise$3) {
|
|
1195
|
+
workerPromise$3 = launchColorPickerWorker();
|
|
1196
1196
|
}
|
|
1197
|
-
return workerPromise$
|
|
1197
|
+
return workerPromise$3;
|
|
1198
1198
|
};
|
|
1199
1199
|
const invoke$6 = async (method, ...params) => {
|
|
1200
|
-
const worker = await getOrCreate$
|
|
1200
|
+
const worker = await getOrCreate$4();
|
|
1201
1201
|
return await worker.invoke(method, ...params);
|
|
1202
1202
|
};
|
|
1203
1203
|
|
|
@@ -1287,6 +1287,9 @@ const get$4 = id => {
|
|
|
1287
1287
|
number(id);
|
|
1288
1288
|
return editors[id];
|
|
1289
1289
|
};
|
|
1290
|
+
const getKeys = () => {
|
|
1291
|
+
return Object.keys(editors);
|
|
1292
|
+
};
|
|
1290
1293
|
const set$6 = (id, oldEditor, newEditor) => {
|
|
1291
1294
|
object(oldEditor);
|
|
1292
1295
|
object(newEditor);
|
|
@@ -1617,7 +1620,7 @@ const createMeasureContext = () => {
|
|
|
1617
1620
|
const state$8 = {
|
|
1618
1621
|
ctx: undefined
|
|
1619
1622
|
};
|
|
1620
|
-
const getOrCreate$
|
|
1623
|
+
const getOrCreate$3 = createCtx => {
|
|
1621
1624
|
if (state$8.ctx) {
|
|
1622
1625
|
return state$8.ctx;
|
|
1623
1626
|
}
|
|
@@ -1626,7 +1629,7 @@ const getOrCreate$4 = createCtx => {
|
|
|
1626
1629
|
};
|
|
1627
1630
|
|
|
1628
1631
|
const getContext = () => {
|
|
1629
|
-
const ctx = getOrCreate$
|
|
1632
|
+
const ctx = getOrCreate$3(createMeasureContext);
|
|
1630
1633
|
return ctx;
|
|
1631
1634
|
};
|
|
1632
1635
|
|
|
@@ -2324,7 +2327,9 @@ const createEditor = async ({
|
|
|
2324
2327
|
fontFamily,
|
|
2325
2328
|
isMonospaceFont,
|
|
2326
2329
|
uri,
|
|
2327
|
-
diagnosticsEnabled
|
|
2330
|
+
diagnosticsEnabled,
|
|
2331
|
+
lineToReveal,
|
|
2332
|
+
columnToReveal
|
|
2328
2333
|
}) => {
|
|
2329
2334
|
number(id);
|
|
2330
2335
|
string(content);
|
|
@@ -2390,7 +2395,14 @@ const createEditor = async ({
|
|
|
2390
2395
|
// TODO avoid creating intermediate editors here
|
|
2391
2396
|
const newEditor1 = setBounds(editor, x, y, width, height, 9);
|
|
2392
2397
|
const newEditor2 = setText(newEditor1, content);
|
|
2393
|
-
|
|
2398
|
+
let newEditor3;
|
|
2399
|
+
if (lineToReveal && columnToReveal) {
|
|
2400
|
+
const delta = lineToReveal * rowHeight;
|
|
2401
|
+
// TODO scroll to this line
|
|
2402
|
+
newEditor3 = setDeltaY$2(newEditor2, delta);
|
|
2403
|
+
} else {
|
|
2404
|
+
newEditor3 = setDeltaY$2(newEditor2, 0);
|
|
2405
|
+
}
|
|
2394
2406
|
const newEditor4 = {
|
|
2395
2407
|
...newEditor3,
|
|
2396
2408
|
focused: true
|
|
@@ -2863,15 +2875,15 @@ const launchRenameWorker = async () => {
|
|
|
2863
2875
|
return launchWorker(name, url);
|
|
2864
2876
|
};
|
|
2865
2877
|
|
|
2866
|
-
let workerPromise$
|
|
2867
|
-
const getOrCreate$
|
|
2868
|
-
if (!workerPromise$
|
|
2869
|
-
workerPromise$
|
|
2878
|
+
let workerPromise$2;
|
|
2879
|
+
const getOrCreate$2 = () => {
|
|
2880
|
+
if (!workerPromise$2) {
|
|
2881
|
+
workerPromise$2 = launchRenameWorker();
|
|
2870
2882
|
}
|
|
2871
|
-
return workerPromise$
|
|
2883
|
+
return workerPromise$2;
|
|
2872
2884
|
};
|
|
2873
2885
|
const invoke$4 = async (method, ...params) => {
|
|
2874
|
-
const worker = await getOrCreate$
|
|
2886
|
+
const worker = await getOrCreate$2();
|
|
2875
2887
|
return await worker.invoke(method, ...params);
|
|
2876
2888
|
};
|
|
2877
2889
|
|
|
@@ -5173,15 +5185,15 @@ const launchCompletionWorker = async () => {
|
|
|
5173
5185
|
return launchWorker(name, url);
|
|
5174
5186
|
};
|
|
5175
5187
|
|
|
5176
|
-
let workerPromise$
|
|
5177
|
-
const getOrCreate$
|
|
5178
|
-
if (!workerPromise$
|
|
5179
|
-
workerPromise$
|
|
5188
|
+
let workerPromise$1;
|
|
5189
|
+
const getOrCreate$1 = () => {
|
|
5190
|
+
if (!workerPromise$1) {
|
|
5191
|
+
workerPromise$1 = launchCompletionWorker();
|
|
5180
5192
|
}
|
|
5181
|
-
return workerPromise$
|
|
5193
|
+
return workerPromise$1;
|
|
5182
5194
|
};
|
|
5183
5195
|
const invoke$3 = async (method, ...params) => {
|
|
5184
|
-
const worker = await getOrCreate$
|
|
5196
|
+
const worker = await getOrCreate$1();
|
|
5185
5197
|
return await worker.invoke(method, ...params);
|
|
5186
5198
|
};
|
|
5187
5199
|
|
|
@@ -5243,15 +5255,15 @@ const launchFindWidgetWorker = async () => {
|
|
|
5243
5255
|
return launchWorker(name, url);
|
|
5244
5256
|
};
|
|
5245
5257
|
|
|
5246
|
-
let workerPromise
|
|
5247
|
-
const getOrCreate
|
|
5248
|
-
if (!workerPromise
|
|
5249
|
-
workerPromise
|
|
5258
|
+
let workerPromise;
|
|
5259
|
+
const getOrCreate = () => {
|
|
5260
|
+
if (!workerPromise) {
|
|
5261
|
+
workerPromise = launchFindWidgetWorker();
|
|
5250
5262
|
}
|
|
5251
|
-
return workerPromise
|
|
5263
|
+
return workerPromise;
|
|
5252
5264
|
};
|
|
5253
5265
|
const invoke$2 = async (method, ...params) => {
|
|
5254
|
-
const worker = await getOrCreate
|
|
5266
|
+
const worker = await getOrCreate();
|
|
5255
5267
|
return await worker.invoke(method, ...params);
|
|
5256
5268
|
};
|
|
5257
5269
|
|
|
@@ -8602,6 +8614,16 @@ const handleBeforeInput = (editor, inputType, data) => {
|
|
|
8602
8614
|
}
|
|
8603
8615
|
};
|
|
8604
8616
|
|
|
8617
|
+
const handleMessagePort = async (port, rpcId) => {
|
|
8618
|
+
const rpc = await PlainMessagePortRpcParent.create({
|
|
8619
|
+
messagePort: port,
|
|
8620
|
+
commandMap: {}
|
|
8621
|
+
});
|
|
8622
|
+
if (rpcId) {
|
|
8623
|
+
set$d(rpcId, rpc);
|
|
8624
|
+
}
|
|
8625
|
+
};
|
|
8626
|
+
|
|
8605
8627
|
const applyTabCompletion = (editor, result) => {
|
|
8606
8628
|
return editorSnippet(editor, result);
|
|
8607
8629
|
};
|
|
@@ -8642,26 +8664,38 @@ const initializeExtensionHost = async () => {
|
|
|
8642
8664
|
set$5(extensionHostRpc);
|
|
8643
8665
|
};
|
|
8644
8666
|
|
|
8645
|
-
const sendMessagePortToSyntaxHighlightingWorker = async
|
|
8646
|
-
await invokeAndTransfer(
|
|
8647
|
-
// @ts-ignore
|
|
8648
|
-
'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
|
|
8649
|
-
};
|
|
8650
|
-
|
|
8651
|
-
const createSyntaxHighlightingWorkerRpc = async () => {
|
|
8667
|
+
const sendMessagePortToSyntaxHighlightingWorker = async () => {
|
|
8652
8668
|
try {
|
|
8653
8669
|
const {
|
|
8654
8670
|
port1,
|
|
8655
8671
|
port2
|
|
8656
8672
|
} = getPortTuple();
|
|
8657
|
-
await
|
|
8673
|
+
await invokeAndTransfer(
|
|
8674
|
+
// @ts-ignore
|
|
8675
|
+
'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port1, 'HandleMessagePort.handleMessagePort2');
|
|
8676
|
+
return port2;
|
|
8677
|
+
} catch {
|
|
8678
|
+
const {
|
|
8679
|
+
port1,
|
|
8680
|
+
port2
|
|
8681
|
+
} = getPortTuple();
|
|
8682
|
+
await invokeAndTransfer(
|
|
8683
|
+
// @ts-ignore
|
|
8684
|
+
'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port1, 'HandleMessagePort.handleMessagePort');
|
|
8685
|
+
return port2;
|
|
8686
|
+
}
|
|
8687
|
+
};
|
|
8688
|
+
|
|
8689
|
+
const createSyntaxHighlightingWorkerRpc = async () => {
|
|
8690
|
+
try {
|
|
8691
|
+
const port = await sendMessagePortToSyntaxHighlightingWorker();
|
|
8658
8692
|
const rpc = await PlainMessagePortRpcParent.create({
|
|
8659
8693
|
commandMap: {},
|
|
8660
|
-
messagePort:
|
|
8694
|
+
messagePort: port
|
|
8661
8695
|
});
|
|
8662
8696
|
return rpc;
|
|
8663
8697
|
} catch (error) {
|
|
8664
|
-
throw new VError(error, `Failed to create
|
|
8698
|
+
throw new VError(error, `Failed to create syntax highlighting worker rpc`);
|
|
8665
8699
|
}
|
|
8666
8700
|
};
|
|
8667
8701
|
|
|
@@ -8743,21 +8777,8 @@ const moveLineUp = editor => {
|
|
|
8743
8777
|
return editor;
|
|
8744
8778
|
};
|
|
8745
8779
|
|
|
8746
|
-
const launchDebugWorker = async () => {
|
|
8747
|
-
const name = 'Debug Worker';
|
|
8748
|
-
const url = 'debugWorkerMain.js';
|
|
8749
|
-
return launchWorker(name, url);
|
|
8750
|
-
};
|
|
8751
|
-
|
|
8752
|
-
let workerPromise;
|
|
8753
|
-
const getOrCreate = async () => {
|
|
8754
|
-
if (!workerPromise) {
|
|
8755
|
-
workerPromise = launchDebugWorker();
|
|
8756
|
-
}
|
|
8757
|
-
return workerPromise;
|
|
8758
|
-
};
|
|
8759
8780
|
const invoke = async (method, ...params) => {
|
|
8760
|
-
const worker =
|
|
8781
|
+
const worker = get$6(RpcId.DebugWorker);
|
|
8761
8782
|
return worker.invoke(method, ...params);
|
|
8762
8783
|
};
|
|
8763
8784
|
|
|
@@ -9371,7 +9392,10 @@ const getIncrementalEdits = async (oldState, newState) => {
|
|
|
9371
9392
|
} = newState;
|
|
9372
9393
|
const oldLine = oldState.lines[rowIndex];
|
|
9373
9394
|
const newLine = lines[rowIndex];
|
|
9374
|
-
|
|
9395
|
+
// @ts-ignore
|
|
9396
|
+
const incrementalEdits = await invoke$1(
|
|
9397
|
+
// @ts-ignore
|
|
9398
|
+
'TokenizeIncremental.tokenizeIncremental', newState.uid,
|
|
9375
9399
|
// @ts-ignore
|
|
9376
9400
|
newState.languageId, oldLine, newLine, rowIndex, newState.minLineY);
|
|
9377
9401
|
if (incrementalEdits && incrementalEdits.length === 1) {
|
|
@@ -9643,6 +9667,31 @@ const setDebugEnabled = (state, enabled) => {
|
|
|
9643
9667
|
return state;
|
|
9644
9668
|
};
|
|
9645
9669
|
|
|
9670
|
+
const getDebugHighlight = async debugId => {
|
|
9671
|
+
const newInfo = await invoke('RunAndDebug.getHighlight', debugId);
|
|
9672
|
+
return newInfo;
|
|
9673
|
+
};
|
|
9674
|
+
|
|
9675
|
+
const getKey = () => {
|
|
9676
|
+
const keys = getKeys();
|
|
9677
|
+
return parseInt(keys[0]);
|
|
9678
|
+
};
|
|
9679
|
+
const updateDebugInfo = async debugId => {
|
|
9680
|
+
const newInfo = await getDebugHighlight(debugId);
|
|
9681
|
+
const key = getKey();
|
|
9682
|
+
const {
|
|
9683
|
+
oldState,
|
|
9684
|
+
newState
|
|
9685
|
+
} = get$4(key);
|
|
9686
|
+
const newEditor = {
|
|
9687
|
+
...newState,
|
|
9688
|
+
highlightedLine: newInfo.rowIndex
|
|
9689
|
+
};
|
|
9690
|
+
set$6(key, oldState, newEditor);
|
|
9691
|
+
// @ts-ignore
|
|
9692
|
+
await invoke$7('Editor.rerender', key);
|
|
9693
|
+
};
|
|
9694
|
+
|
|
9646
9695
|
const editorDiagnosticEffect = {
|
|
9647
9696
|
isActive(oldEditor, newEditor) {
|
|
9648
9697
|
// TODO avoid slow comparison
|
|
@@ -9654,13 +9703,12 @@ const editorDiagnosticEffect = {
|
|
|
9654
9703
|
}
|
|
9655
9704
|
};
|
|
9656
9705
|
|
|
9657
|
-
const keep = [
|
|
9706
|
+
const keep = ['ActivateByEvent.activateByEvent', 'Editor.applyEdit2', 'Editor.applyEdits2', 'Editor.closeFind2', 'Editor.closeWidget2', 'Editor.create', 'Editor.getKeyBindings', 'Editor.getLines2', 'Editor.getPositionAtCursor', 'Editor.getQuickPickMenuEntries', 'Editor.getSelections', 'Editor.getSelections2', 'Editor.getText', 'Editor.getWordAt', 'Editor.getWordAt2', 'Editor.getWordAtOffset2', 'Editor.getWordBefore', 'Editor.getWordBefore2', 'Editor.offsetAt', 'Editor.render', 'Editor.setSelections2', 'Editor.updateDebugInfo', 'Font.ensure', 'HandleMessagePort.handleMessagePort', 'Hover.getHoverInfo', 'Hover.handleSashPointerDown', 'Hover.handleSashPointerMove', 'Hover.handleSashPointerUp', 'Hover.loadContent', 'Hover.render', 'Initialize.initialize', 'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker'
|
|
9658
9707
|
// 'ColorPicker.handleSliderPointerDown',
|
|
9659
9708
|
// 'ColorPicker.handleSliderPointerMove',
|
|
9660
9709
|
// 'ColorPicker.loadContent',
|
|
9661
|
-
'Editor.create', 'Editor.getWordAt', 'Editor.getWordBefore', 'Editor.offsetAt', 'Editor.render', 'Editor.getKeyBindings', 'Editor.getPositionAtCursor', 'Editor.getWordAt2', 'Editor.getWordAtOffset2', 'Editor.getWordBefore2', 'Editor.getLines2', 'Editor.applyEdit2', 'Editor.applyEdits2', 'Editor.closeFind2', 'Editor.closeWidget2', 'Editor.getSelections2', 'Editor.getQuickPickMenuEntries',
|
|
9662
9710
|
// 'ColorPicker.render',
|
|
9663
|
-
|
|
9711
|
+
];
|
|
9664
9712
|
|
|
9665
9713
|
const wrapWidgetCommand = (widgetId, fn) => {
|
|
9666
9714
|
const isWidget = widget => {
|
|
@@ -9893,6 +9941,7 @@ const commandMap = {
|
|
|
9893
9941
|
'Editor.typeWithAutoClosing': typeWithAutoClosing,
|
|
9894
9942
|
'Editor.undo': undo,
|
|
9895
9943
|
'Editor.unIndent': editorUnindent,
|
|
9944
|
+
'Editor.updateDebugInfo': updateDebugInfo,
|
|
9896
9945
|
'Editor.updateDiagnostics': updateDiagnostics,
|
|
9897
9946
|
'EditorCompletion.close': close$1,
|
|
9898
9947
|
'EditorCompletion.closeDetails': closeDetails,
|
|
@@ -9930,6 +9979,7 @@ const commandMap = {
|
|
|
9930
9979
|
'FindWidget.loadContent': loadContent$1,
|
|
9931
9980
|
'FindWidget.toggleReplace': toggleReplace,
|
|
9932
9981
|
'Font.ensure': ensure,
|
|
9982
|
+
'HandleMessagePort.handleMessagePort': handleMessagePort,
|
|
9933
9983
|
'Hover.getHoverInfo': getEditorHoverInfo,
|
|
9934
9984
|
'Hover.handleSashPointerDown': handleSashPointerDown,
|
|
9935
9985
|
'Hover.handleSashPointerMove': handleSashPointerMove,
|