@lvce-editor/editor-worker 18.12.0 → 18.14.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 +104 -45
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1229,7 +1229,6 @@ const SetFocusContext$1 = 'Viewlet.setFocusContext';
|
|
|
1229
1229
|
const SetPatches = 'Viewlet.setPatches';
|
|
1230
1230
|
|
|
1231
1231
|
const FocusEditorText$1 = 12;
|
|
1232
|
-
const FocusExplorer = 13;
|
|
1233
1232
|
|
|
1234
1233
|
const {
|
|
1235
1234
|
invoke: invoke$f,
|
|
@@ -1572,7 +1571,6 @@ const editorStates = create$9();
|
|
|
1572
1571
|
const {
|
|
1573
1572
|
getCommandIds,
|
|
1574
1573
|
registerCommands,
|
|
1575
|
-
wrapCommand,
|
|
1576
1574
|
wrapGetter
|
|
1577
1575
|
} = editorStates;
|
|
1578
1576
|
const get$6 = id => {
|
|
@@ -1607,6 +1605,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1607
1605
|
completionState: '',
|
|
1608
1606
|
completionTriggerCharacters: [],
|
|
1609
1607
|
completionUid: 0,
|
|
1608
|
+
cursorInfos: [],
|
|
1610
1609
|
cursorWidth: 2,
|
|
1611
1610
|
debugEnabled: false,
|
|
1612
1611
|
decorations: [],
|
|
@@ -1655,6 +1654,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1655
1654
|
savedSelections: [],
|
|
1656
1655
|
scrollBarHeight: 0,
|
|
1657
1656
|
scrollBarWidth: 0,
|
|
1657
|
+
selectionInfos: [],
|
|
1658
1658
|
selections: new Uint32Array(),
|
|
1659
1659
|
tabSize: 0,
|
|
1660
1660
|
textInfos: [],
|
|
@@ -3666,6 +3666,7 @@ const setText$1 = (editor, text) => {
|
|
|
3666
3666
|
};
|
|
3667
3667
|
|
|
3668
3668
|
const emptyEditor = {
|
|
3669
|
+
cursorInfos: [],
|
|
3669
3670
|
debugEnabled: false,
|
|
3670
3671
|
decorations: [],
|
|
3671
3672
|
deltaX: 0,
|
|
@@ -3685,6 +3686,7 @@ const emptyEditor = {
|
|
|
3685
3686
|
maxLineY: 0,
|
|
3686
3687
|
minLineY: 0,
|
|
3687
3688
|
scrollBarHeight: 0,
|
|
3689
|
+
selectionInfos: [],
|
|
3688
3690
|
selections: new Uint32Array(),
|
|
3689
3691
|
textInfos: [],
|
|
3690
3692
|
tokenizerId: 0,
|
|
@@ -3973,6 +3975,7 @@ const createEditor = async ({
|
|
|
3973
3975
|
completionState: '',
|
|
3974
3976
|
completionTriggerCharacters,
|
|
3975
3977
|
completionUid: 0,
|
|
3978
|
+
cursorInfos: [],
|
|
3976
3979
|
cursorWidth: 2,
|
|
3977
3980
|
decorations: [],
|
|
3978
3981
|
deltaX: 0,
|
|
@@ -4016,6 +4019,7 @@ const createEditor = async ({
|
|
|
4016
4019
|
savedSelections,
|
|
4017
4020
|
scrollBarHeight: 0,
|
|
4018
4021
|
scrollBarWidth: 0,
|
|
4022
|
+
selectionInfos: [],
|
|
4019
4023
|
selections: new Uint32Array(),
|
|
4020
4024
|
tabSize,
|
|
4021
4025
|
textInfos: [],
|
|
@@ -4089,7 +4093,7 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
4089
4093
|
};
|
|
4090
4094
|
|
|
4091
4095
|
const isEqual = (oldState, newState) => {
|
|
4092
|
-
return oldState.lines === newState.lines && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial;
|
|
4096
|
+
return oldState.lines === newState.lines && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.selections === newState.selections;
|
|
4093
4097
|
};
|
|
4094
4098
|
|
|
4095
4099
|
const RenderFocus = 6;
|
|
@@ -6337,6 +6341,22 @@ const handlePointerCaptureLost = editor => {
|
|
|
6337
6341
|
return editor;
|
|
6338
6342
|
};
|
|
6339
6343
|
|
|
6344
|
+
const handlePointerDown$1 = (state, button, altKey, ctrlKey, x, y, detail) => {
|
|
6345
|
+
const modifier = 0;
|
|
6346
|
+
const clickDetail = Single; // TODO
|
|
6347
|
+
// console.log({ detail })
|
|
6348
|
+
switch (clickDetail) {
|
|
6349
|
+
case Double:
|
|
6350
|
+
return handleDoubleClick(state, modifier, x, y);
|
|
6351
|
+
case Single:
|
|
6352
|
+
return handleSingleClick(state, modifier, x, y);
|
|
6353
|
+
case Triple:
|
|
6354
|
+
return handleTripleClick(state, modifier, x, y);
|
|
6355
|
+
default:
|
|
6356
|
+
return state;
|
|
6357
|
+
}
|
|
6358
|
+
};
|
|
6359
|
+
|
|
6340
6360
|
const moveRectangleSelection = (editor, position) => {
|
|
6341
6361
|
// @ts-ignore
|
|
6342
6362
|
// const anchor = EditorMoveSelection.state.position
|
|
@@ -9531,29 +9551,28 @@ const InputBox = 'InputBox';
|
|
|
9531
9551
|
const MaskIcon = 'MaskIcon';
|
|
9532
9552
|
const Viewlet = 'Viewlet';
|
|
9533
9553
|
|
|
9534
|
-
const HandleBeforeInput =
|
|
9535
|
-
const HandleBlur =
|
|
9536
|
-
const HandleClose =
|
|
9537
|
-
const HandleCompositionEnd =
|
|
9538
|
-
const HandleCompositionStart =
|
|
9539
|
-
const HandleCompositionUpdate =
|
|
9540
|
-
const HandleContextMenu =
|
|
9541
|
-
const HandleCut =
|
|
9542
|
-
const HandleFocus =
|
|
9543
|
-
const
|
|
9544
|
-
const
|
|
9545
|
-
const
|
|
9546
|
-
const
|
|
9547
|
-
const
|
|
9548
|
-
const
|
|
9549
|
-
const
|
|
9550
|
-
const
|
|
9551
|
-
const
|
|
9552
|
-
const
|
|
9553
|
-
const
|
|
9554
|
-
const
|
|
9555
|
-
const
|
|
9556
|
-
const HandleWheel = 'handleWheel';
|
|
9554
|
+
const HandleBeforeInput = 1;
|
|
9555
|
+
const HandleBlur = 2;
|
|
9556
|
+
const HandleClose = 9;
|
|
9557
|
+
const HandleCompositionEnd = 10;
|
|
9558
|
+
const HandleCompositionStart = 11;
|
|
9559
|
+
const HandleCompositionUpdate = 12;
|
|
9560
|
+
const HandleContextMenu = 13;
|
|
9561
|
+
const HandleCut = 14;
|
|
9562
|
+
const HandleFocus = 15;
|
|
9563
|
+
const HandleMouseMove = 19;
|
|
9564
|
+
const HandlePaste = 20;
|
|
9565
|
+
const HandlePointerDown = 21;
|
|
9566
|
+
const HandlePointerMove = 22;
|
|
9567
|
+
const HandlePointerUp = 23;
|
|
9568
|
+
const HandleSashPointerDown = 26;
|
|
9569
|
+
const HandleScrollBarHorizontalPointerDown = 27;
|
|
9570
|
+
const HandleScrollBarHorizontalPointerMove = 28;
|
|
9571
|
+
const HandleScrollBarHorizontalPointerUp = 29;
|
|
9572
|
+
const HandleScrollBarVerticalPointerDown = 30;
|
|
9573
|
+
const HandleScrollBarVerticalPointerMove = 31;
|
|
9574
|
+
const HandleScrollBarVerticalPointerUp = 32;
|
|
9575
|
+
const HandleWheel = 33;
|
|
9557
9576
|
|
|
9558
9577
|
const Div = 4;
|
|
9559
9578
|
const Input = 6;
|
|
@@ -9878,6 +9897,24 @@ const unsetAdditionalFocus = async focusKey => {
|
|
|
9878
9897
|
await invoke$c('Focus.removeAdditionalFocus', focusKey);
|
|
9879
9898
|
};
|
|
9880
9899
|
|
|
9900
|
+
const shouldUpdateSelectionData = (oldState, newState) => {
|
|
9901
|
+
return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.cursorWidth !== newState.cursorWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
|
|
9902
|
+
};
|
|
9903
|
+
const updateDerivedState = async (oldState, newState) => {
|
|
9904
|
+
if (!shouldUpdateSelectionData(oldState, newState)) {
|
|
9905
|
+
return newState;
|
|
9906
|
+
}
|
|
9907
|
+
const {
|
|
9908
|
+
cursorInfos,
|
|
9909
|
+
selectionInfos
|
|
9910
|
+
} = await getVisible(newState);
|
|
9911
|
+
return {
|
|
9912
|
+
...newState,
|
|
9913
|
+
cursorInfos,
|
|
9914
|
+
selectionInfos
|
|
9915
|
+
};
|
|
9916
|
+
};
|
|
9917
|
+
|
|
9881
9918
|
const FocusEditor = 12;
|
|
9882
9919
|
const FocusEditorCompletions = 9;
|
|
9883
9920
|
const FocusEditorRename = 11;
|
|
@@ -9939,13 +9976,14 @@ const getSelections2 = editorUid => {
|
|
|
9939
9976
|
} = editor;
|
|
9940
9977
|
return selections;
|
|
9941
9978
|
};
|
|
9942
|
-
const setSelections2 = (editorUid, selections) => {
|
|
9979
|
+
const setSelections2 = async (editorUid, selections) => {
|
|
9943
9980
|
const editor = getEditor(editorUid);
|
|
9944
9981
|
const newEditor = {
|
|
9945
9982
|
...editor,
|
|
9946
9983
|
selections
|
|
9947
9984
|
};
|
|
9948
|
-
|
|
9985
|
+
const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
|
|
9986
|
+
set$7(editorUid, editor, newEditorWithDerivedState);
|
|
9949
9987
|
};
|
|
9950
9988
|
const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocus$1) => {
|
|
9951
9989
|
const editor = getEditor(editorUid);
|
|
@@ -9964,7 +10002,8 @@ const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocu
|
|
|
9964
10002
|
focused: true,
|
|
9965
10003
|
widgets: newWidgets
|
|
9966
10004
|
};
|
|
9967
|
-
|
|
10005
|
+
const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
|
|
10006
|
+
set$7(editorUid, editor, newEditorWithDerivedState);
|
|
9968
10007
|
await setFocus(FocusEditorText);
|
|
9969
10008
|
if (unsetAdditionalFocus$1) {
|
|
9970
10009
|
await unsetAdditionalFocus(unsetAdditionalFocus$1);
|
|
@@ -9976,7 +10015,8 @@ const closeFind2 = async editorUid => {
|
|
|
9976
10015
|
const applyEdits2 = async (editorUid, edits) => {
|
|
9977
10016
|
const editor = getEditor(editorUid);
|
|
9978
10017
|
const newEditor = await applyEdit(editor, edits);
|
|
9979
|
-
|
|
10018
|
+
const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
|
|
10019
|
+
set$7(editorUid, editor, newEditorWithDerivedState);
|
|
9980
10020
|
};
|
|
9981
10021
|
const getSourceActions = async editorUid => {
|
|
9982
10022
|
const actions = await getEditorSourceActions(editorUid);
|
|
@@ -10786,6 +10826,7 @@ const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
|
|
|
10786
10826
|
const kLineHeight = 'editor.lineHeight';
|
|
10787
10827
|
const kFontSize = 'editor.fontSize';
|
|
10788
10828
|
const kFontFamily = 'editor.fontFamily';
|
|
10829
|
+
const kLetterSpacing = 'editor.letterSpacing';
|
|
10789
10830
|
const kTabSize = 'editor.tabSize';
|
|
10790
10831
|
const kLineNumbers = 'editor.lineNumbers';
|
|
10791
10832
|
const kDiagnostics = 'editor.diagnostics';
|
|
@@ -10815,9 +10856,10 @@ const getFontFamily = async () => {
|
|
|
10815
10856
|
return (await get$1(kFontFamily)) || 'Fira Code';
|
|
10816
10857
|
};
|
|
10817
10858
|
const getLetterSpacing = async () => {
|
|
10818
|
-
{
|
|
10819
|
-
|
|
10820
|
-
}
|
|
10859
|
+
// if (!false) {
|
|
10860
|
+
// return 0
|
|
10861
|
+
// }
|
|
10862
|
+
return (await get$1(kLetterSpacing)) ?? 0.5;
|
|
10821
10863
|
};
|
|
10822
10864
|
const getTabSize = async () => {
|
|
10823
10865
|
return (await get$1(kTabSize)) || 2;
|
|
@@ -11049,7 +11091,7 @@ const renderFocus$2 = (oldState, newState) => {
|
|
|
11049
11091
|
};
|
|
11050
11092
|
|
|
11051
11093
|
const renderFocusContext$1 = (oldState, newState) => {
|
|
11052
|
-
return [SetFocusContext$1, newState.uid,
|
|
11094
|
+
return [SetFocusContext$1, newState.uid, FocusEditorText$1];
|
|
11053
11095
|
};
|
|
11054
11096
|
|
|
11055
11097
|
const SetText = 1;
|
|
@@ -11548,7 +11590,7 @@ const getEditorVirtualDom = ({
|
|
|
11548
11590
|
}, ...selectionsDom, {
|
|
11549
11591
|
childCount: textInfos.length,
|
|
11550
11592
|
className: 'EditorRows',
|
|
11551
|
-
onMouseDown: HandleMouseDown,
|
|
11593
|
+
// onMouseDown: DomEventListenerFunctions.HandleMouseDown,
|
|
11552
11594
|
onPointerDown: HandlePointerDown,
|
|
11553
11595
|
type: Div
|
|
11554
11596
|
}, ...rowsDom, {
|
|
@@ -11668,17 +11710,17 @@ const renderLines = {
|
|
|
11668
11710
|
}
|
|
11669
11711
|
};
|
|
11670
11712
|
const renderSelections = {
|
|
11671
|
-
apply:
|
|
11713
|
+
apply: (oldState, newState) => {
|
|
11672
11714
|
const {
|
|
11673
|
-
cursorInfos,
|
|
11674
|
-
selectionInfos
|
|
11675
|
-
} =
|
|
11715
|
+
cursorInfos = [],
|
|
11716
|
+
selectionInfos = []
|
|
11717
|
+
} = newState;
|
|
11676
11718
|
const cursorsDom = getCursorsVirtualDom(cursorInfos);
|
|
11677
11719
|
const selectionsDom = getSelectionsVirtualDom(selectionInfos);
|
|
11678
11720
|
return [/* method */'setSelections', cursorsDom, selectionsDom];
|
|
11679
11721
|
},
|
|
11680
11722
|
isEqual(oldState, newState) {
|
|
11681
|
-
return oldState.
|
|
11723
|
+
return oldState.cursorInfos === newState.cursorInfos && oldState.selectionInfos === newState.selectionInfos;
|
|
11682
11724
|
}
|
|
11683
11725
|
};
|
|
11684
11726
|
const renderScrollBarY = {
|
|
@@ -11872,12 +11914,9 @@ const renderEventListeners = () => {
|
|
|
11872
11914
|
name: HandlePaste,
|
|
11873
11915
|
params: ['paste', 'event.clipboardData ? event.clipboardData.getData("text/plain") : ""'],
|
|
11874
11916
|
preventDefault: true
|
|
11875
|
-
}, {
|
|
11876
|
-
name: HandleMouseDown,
|
|
11877
|
-
params: ['handleMouseDown', 'event.button === 2 ? -1 : (((event.metaKey || event.ctrlKey) ? 2048 : 0) | (event.shiftKey ? 1024 : 0) | (event.altKey ? 512 : 0))', ClientX, ClientY, 'event.button === 2 ? 0 : event.detail']
|
|
11878
11917
|
}, {
|
|
11879
11918
|
name: HandlePointerDown,
|
|
11880
|
-
params: [],
|
|
11919
|
+
params: ['handlePointerDown', 'event.button', 'event.altKey', 'event.ctrlKey', ClientX, ClientY],
|
|
11881
11920
|
trackPointerEvents: [HandlePointerMove, HandlePointerUp]
|
|
11882
11921
|
}, {
|
|
11883
11922
|
name: HandlePointerMove,
|
|
@@ -11974,6 +12013,25 @@ const updateDebugInfo = async debugId => {
|
|
|
11974
12013
|
await invoke$c('Editor.rerender', key);
|
|
11975
12014
|
};
|
|
11976
12015
|
|
|
12016
|
+
// TODO wrap commands globally, not per editor
|
|
12017
|
+
// TODO only store editor state in editor worker, not in renderer worker also
|
|
12018
|
+
|
|
12019
|
+
const wrapCommand = fn => async (editorUid, ...args) => {
|
|
12020
|
+
const oldInstance = get$6(editorUid);
|
|
12021
|
+
const state = oldInstance.newState;
|
|
12022
|
+
const newEditor = await fn(state, ...args);
|
|
12023
|
+
if (state === newEditor) {
|
|
12024
|
+
return newEditor;
|
|
12025
|
+
}
|
|
12026
|
+
const newEditorWithDerivedState = await updateDerivedState(state, newEditor);
|
|
12027
|
+
// TODO if editor did not change, no need to update furthur
|
|
12028
|
+
|
|
12029
|
+
// TODO combine neweditor with latest editor?
|
|
12030
|
+
|
|
12031
|
+
set$7(editorUid, state, newEditorWithDerivedState);
|
|
12032
|
+
return newEditorWithDerivedState;
|
|
12033
|
+
};
|
|
12034
|
+
|
|
11977
12035
|
const wrapCommandOld = wrapCommand;
|
|
11978
12036
|
const commandMap = {
|
|
11979
12037
|
'ActivateByEvent.activateByEvent': activateByEvent,
|
|
@@ -12060,7 +12118,7 @@ const commandMap = {
|
|
|
12060
12118
|
'Editor.handleBeforeInput': wrapCommandOld(handleBeforeInput),
|
|
12061
12119
|
'Editor.handleBeforeInputFromContentEditable': wrapCommandOld(handleBeforeInputFromContentEditable),
|
|
12062
12120
|
'Editor.handleBlur': wrapCommandOld(handleBlur$1),
|
|
12063
|
-
'Editor.handleClickAtPosition': handleClickAtPosition,
|
|
12121
|
+
'Editor.handleClickAtPosition': wrapCommandOld(handleClickAtPosition),
|
|
12064
12122
|
'Editor.handleContextMenu': wrapCommandOld(handleContextMenu),
|
|
12065
12123
|
'Editor.handleDoubleClick': wrapCommandOld(handleDoubleClick),
|
|
12066
12124
|
'Editor.handleFocus': wrapCommandOld(handleFocus$1),
|
|
@@ -12069,6 +12127,7 @@ const commandMap = {
|
|
|
12069
12127
|
'Editor.handleMouseMoveWithAltKey': wrapCommandOld(handleMouseMoveWithAltKey),
|
|
12070
12128
|
'Editor.handleNativeSelectionChange': editorHandleNativeSelectionChange,
|
|
12071
12129
|
'Editor.handlePointerCaptureLost': wrapCommandOld(handlePointerCaptureLost),
|
|
12130
|
+
'Editor.handlePointerDown': wrapCommandOld(handlePointerDown$1),
|
|
12072
12131
|
'Editor.handlePointerMove': wrapCommandOld(handlePointerMove),
|
|
12073
12132
|
'Editor.handlePointerUp': wrapCommandOld(handlePointerUp),
|
|
12074
12133
|
'Editor.handleScrollBarClick': handleScrollBarPointerDown,
|