@lvce-editor/editor-worker 19.2.0 → 19.4.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/README.md +144 -1
- package/dist/editorWorkerMain.js +269 -224
- package/dist/editorWorkerMain.min.js +1 -1
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1538,12 +1538,12 @@ const launchColorPickerWorker = async () => {
|
|
|
1538
1538
|
return launchWorker(name, url);
|
|
1539
1539
|
};
|
|
1540
1540
|
|
|
1541
|
-
const state$
|
|
1541
|
+
const state$d = {};
|
|
1542
1542
|
const getOrCreate$3 = () => {
|
|
1543
|
-
if (!state$
|
|
1544
|
-
state$
|
|
1543
|
+
if (!state$d.workerPromise) {
|
|
1544
|
+
state$d.workerPromise = launchColorPickerWorker();
|
|
1545
1545
|
}
|
|
1546
|
-
return state$
|
|
1546
|
+
return state$d.workerPromise;
|
|
1547
1547
|
};
|
|
1548
1548
|
const invoke$9 = async (method, ...params) => {
|
|
1549
1549
|
const worker = await getOrCreate$3();
|
|
@@ -1659,6 +1659,10 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1659
1659
|
savedSelections: [],
|
|
1660
1660
|
scrollBarHeight: 0,
|
|
1661
1661
|
scrollBarWidth: 0,
|
|
1662
|
+
selectionAnchorPosition: {
|
|
1663
|
+
columnIndex: 0,
|
|
1664
|
+
rowIndex: 0
|
|
1665
|
+
},
|
|
1662
1666
|
selectionAutoMovePosition: {
|
|
1663
1667
|
columnIndex: 0,
|
|
1664
1668
|
rowIndex: 0
|
|
@@ -1853,7 +1857,7 @@ const getInitialLineState = initialLineState => {
|
|
|
1853
1857
|
return deepCopy(initialLineState);
|
|
1854
1858
|
};
|
|
1855
1859
|
|
|
1856
|
-
const state$
|
|
1860
|
+
const state$c = {
|
|
1857
1861
|
warned: []
|
|
1858
1862
|
};
|
|
1859
1863
|
const flattenTokensArray = tokens => {
|
|
@@ -1865,10 +1869,10 @@ const flattenTokensArray = tokens => {
|
|
|
1865
1869
|
return flattened;
|
|
1866
1870
|
};
|
|
1867
1871
|
const warnDeprecatedArrayReturn = (languageId, fn) => {
|
|
1868
|
-
if (state$
|
|
1872
|
+
if (state$c.warned.includes(fn)) {
|
|
1869
1873
|
return;
|
|
1870
1874
|
}
|
|
1871
|
-
state$
|
|
1875
|
+
state$c.warned.push(fn);
|
|
1872
1876
|
console.warn(`tokenizers without hasArrayReturn=false are deprecated (language ${languageId})`);
|
|
1873
1877
|
};
|
|
1874
1878
|
const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
|
|
@@ -1929,14 +1933,14 @@ const TokenizePlainText = {
|
|
|
1929
1933
|
tokenizeLine
|
|
1930
1934
|
};
|
|
1931
1935
|
|
|
1932
|
-
const state$
|
|
1936
|
+
const state$b = {
|
|
1933
1937
|
enabled: false
|
|
1934
1938
|
};
|
|
1935
1939
|
const setEnabled$1 = value => {
|
|
1936
|
-
state$
|
|
1940
|
+
state$b.enabled = value;
|
|
1937
1941
|
};
|
|
1938
1942
|
const getEnabled$1 = () => {
|
|
1939
|
-
return state$
|
|
1943
|
+
return state$b.enabled;
|
|
1940
1944
|
};
|
|
1941
1945
|
|
|
1942
1946
|
const {
|
|
@@ -1944,25 +1948,25 @@ const {
|
|
|
1944
1948
|
set: set$6
|
|
1945
1949
|
} = SyntaxHighlightingWorker;
|
|
1946
1950
|
|
|
1947
|
-
const state$
|
|
1951
|
+
const state$a = {
|
|
1948
1952
|
pending: Object.create(null),
|
|
1949
1953
|
tokenizePaths: Object.create(null),
|
|
1950
1954
|
tokenizers: Object.create(null)
|
|
1951
1955
|
};
|
|
1952
1956
|
const has = languageId => {
|
|
1953
|
-
return Object.hasOwn(state$
|
|
1957
|
+
return Object.hasOwn(state$a.tokenizers, languageId);
|
|
1954
1958
|
};
|
|
1955
1959
|
const set$5 = (languageId, tokenizer) => {
|
|
1956
|
-
state$
|
|
1960
|
+
state$a.tokenizers[languageId] = tokenizer;
|
|
1957
1961
|
};
|
|
1958
1962
|
const get$5 = languageId => {
|
|
1959
|
-
return state$
|
|
1963
|
+
return state$a.tokenizers[languageId];
|
|
1960
1964
|
};
|
|
1961
1965
|
const setTokenizePath = (languageId, tokenizePath) => {
|
|
1962
|
-
state$
|
|
1966
|
+
state$a.tokenizePaths[languageId] = tokenizePath;
|
|
1963
1967
|
};
|
|
1964
1968
|
const getTokenizePath$1 = languageId => {
|
|
1965
|
-
return state$
|
|
1969
|
+
return state$a.tokenizePaths[languageId] || '';
|
|
1966
1970
|
};
|
|
1967
1971
|
const setTokenizePaths = languages => {
|
|
1968
1972
|
for (const language of languages) {
|
|
@@ -1972,7 +1976,7 @@ const setTokenizePaths = languages => {
|
|
|
1972
1976
|
}
|
|
1973
1977
|
};
|
|
1974
1978
|
const isPending = languageId => {
|
|
1975
|
-
return Object.hasOwn(state$
|
|
1979
|
+
return Object.hasOwn(state$a.pending, languageId);
|
|
1976
1980
|
};
|
|
1977
1981
|
|
|
1978
1982
|
const tokenMaps = Object.create(null);
|
|
@@ -2815,14 +2819,14 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
|
2815
2819
|
};
|
|
2816
2820
|
};
|
|
2817
2821
|
|
|
2818
|
-
const state$
|
|
2822
|
+
const state$9 = {
|
|
2819
2823
|
enabled: false
|
|
2820
2824
|
};
|
|
2821
2825
|
const setEnabled = value => {
|
|
2822
|
-
state$
|
|
2826
|
+
state$9.enabled = value;
|
|
2823
2827
|
};
|
|
2824
2828
|
const getEnabled = () => {
|
|
2825
|
-
return state$
|
|
2829
|
+
return state$9.enabled;
|
|
2826
2830
|
};
|
|
2827
2831
|
|
|
2828
2832
|
// TODO this should be in a separate scrolling module
|
|
@@ -3002,7 +3006,7 @@ const getUrlAtOffset = (editor, offset) => {
|
|
|
3002
3006
|
|
|
3003
3007
|
const EditorChange = 1;
|
|
3004
3008
|
|
|
3005
|
-
const state$
|
|
3009
|
+
const state$8 = Object.create(null);
|
|
3006
3010
|
|
|
3007
3011
|
/**
|
|
3008
3012
|
* Register a listener for a specific event type
|
|
@@ -3012,13 +3016,13 @@ const state$9 = Object.create(null);
|
|
|
3012
3016
|
const registerListener$1 = (listenerType, rpcId) => {
|
|
3013
3017
|
number(listenerType);
|
|
3014
3018
|
number(rpcId);
|
|
3015
|
-
if (!Object.hasOwn(state$
|
|
3016
|
-
state$
|
|
3019
|
+
if (!Object.hasOwn(state$8, listenerType)) {
|
|
3020
|
+
state$8[listenerType] = [];
|
|
3017
3021
|
}
|
|
3018
3022
|
|
|
3019
3023
|
// Avoid duplicate registrations
|
|
3020
|
-
if (!state$
|
|
3021
|
-
state$
|
|
3024
|
+
if (!state$8[listenerType].includes(rpcId)) {
|
|
3025
|
+
state$8[listenerType].push(rpcId);
|
|
3022
3026
|
}
|
|
3023
3027
|
};
|
|
3024
3028
|
|
|
@@ -3030,10 +3034,10 @@ const registerListener$1 = (listenerType, rpcId) => {
|
|
|
3030
3034
|
const unregisterListener$1 = (listenerType, rpcId) => {
|
|
3031
3035
|
number(listenerType);
|
|
3032
3036
|
number(rpcId);
|
|
3033
|
-
if (Object.hasOwn(state$
|
|
3034
|
-
const index = state$
|
|
3037
|
+
if (Object.hasOwn(state$8, listenerType)) {
|
|
3038
|
+
const index = state$8[listenerType].indexOf(rpcId);
|
|
3035
3039
|
if (index !== -1) {
|
|
3036
|
-
state$
|
|
3040
|
+
state$8[listenerType].splice(index, 1);
|
|
3037
3041
|
}
|
|
3038
3042
|
}
|
|
3039
3043
|
};
|
|
@@ -3045,7 +3049,7 @@ const unregisterListener$1 = (listenerType, rpcId) => {
|
|
|
3045
3049
|
*/
|
|
3046
3050
|
const getListeners = listenerType => {
|
|
3047
3051
|
number(listenerType);
|
|
3048
|
-
return state$
|
|
3052
|
+
return state$8[listenerType] || [];
|
|
3049
3053
|
};
|
|
3050
3054
|
|
|
3051
3055
|
/**
|
|
@@ -3713,6 +3717,10 @@ const emptyEditor = {
|
|
|
3713
3717
|
minLineY: 0,
|
|
3714
3718
|
redoStack: [],
|
|
3715
3719
|
scrollBarHeight: 0,
|
|
3720
|
+
selectionAnchorPosition: {
|
|
3721
|
+
columnIndex: 0,
|
|
3722
|
+
rowIndex: 0
|
|
3723
|
+
},
|
|
3716
3724
|
selectionAutoMovePosition: {
|
|
3717
3725
|
columnIndex: 0,
|
|
3718
3726
|
rowIndex: 0
|
|
@@ -4070,6 +4078,10 @@ const createEditor = async ({
|
|
|
4070
4078
|
savedSelections,
|
|
4071
4079
|
scrollBarHeight: 0,
|
|
4072
4080
|
scrollBarWidth: 0,
|
|
4081
|
+
selectionAnchorPosition: {
|
|
4082
|
+
columnIndex: 0,
|
|
4083
|
+
rowIndex: 0
|
|
4084
|
+
},
|
|
4073
4085
|
selectionAutoMovePosition: {
|
|
4074
4086
|
columnIndex: 0,
|
|
4075
4087
|
rowIndex: 0
|
|
@@ -4139,28 +4151,33 @@ const createEditor = async ({
|
|
|
4139
4151
|
});
|
|
4140
4152
|
};
|
|
4141
4153
|
|
|
4142
|
-
const isEqual$
|
|
4143
|
-
return oldState.rowHeight === newState.rowHeight && oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.scrollBarHeight === newState.scrollBarHeight;
|
|
4154
|
+
const isEqual$3 = (oldState, newState) => {
|
|
4155
|
+
return oldState.rowHeight === newState.rowHeight && oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.deltaX === newState.deltaX && oldState.longestLineWidth === newState.longestLineWidth && oldState.minimumSliderSize === newState.minimumSliderSize && oldState.width === newState.width && oldState.scrollBarHeight === newState.scrollBarHeight;
|
|
4144
4156
|
};
|
|
4145
4157
|
|
|
4146
|
-
const isEqual$
|
|
4158
|
+
const isEqual$2 = (oldState, newState) => {
|
|
4147
4159
|
if (!newState.focused) {
|
|
4148
4160
|
return true;
|
|
4149
4161
|
}
|
|
4150
4162
|
return oldState.focused === newState.focused && oldState.focus === newState.focus;
|
|
4151
4163
|
};
|
|
4152
4164
|
|
|
4153
|
-
const isEqual = (oldState, newState) => {
|
|
4154
|
-
return oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.highlightedLine === newState.highlightedLine && oldState.lineNumbers === newState.lineNumbers && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.
|
|
4165
|
+
const isEqual$1 = (oldState, newState) => {
|
|
4166
|
+
return oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.highlightedLine === newState.highlightedLine && oldState.lineNumbers === newState.lineNumbers && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.selectionInfos === newState.selectionInfos;
|
|
4155
4167
|
};
|
|
4156
4168
|
|
|
4157
4169
|
const RenderFocus = 6;
|
|
4158
4170
|
const RenderFocusContext = 7;
|
|
4159
4171
|
const RenderCss = 11;
|
|
4160
4172
|
const RenderIncremental = 12;
|
|
4173
|
+
const RenderWidgets = 13;
|
|
4174
|
+
|
|
4175
|
+
const isEqual = (oldState, newState) => {
|
|
4176
|
+
return oldState.widgets === newState.widgets;
|
|
4177
|
+
};
|
|
4161
4178
|
|
|
4162
|
-
const modules = [isEqual, isEqual$
|
|
4163
|
-
const numbers = [RenderIncremental, RenderFocus, RenderFocusContext, RenderCss];
|
|
4179
|
+
const modules = [isEqual$1, isEqual$2, isEqual$2, isEqual$3, isEqual];
|
|
4180
|
+
const numbers = [RenderIncremental, RenderFocus, RenderFocusContext, RenderCss, RenderWidgets];
|
|
4164
4181
|
|
|
4165
4182
|
const diff = (oldState, newState) => {
|
|
4166
4183
|
const diffResult = [];
|
|
@@ -4539,7 +4556,7 @@ const y = (editor, rowIndex) => {
|
|
|
4539
4556
|
return offsetY;
|
|
4540
4557
|
};
|
|
4541
4558
|
|
|
4542
|
-
const state$
|
|
4559
|
+
const state$7 = {
|
|
4543
4560
|
timeout: -1
|
|
4544
4561
|
};
|
|
4545
4562
|
|
|
@@ -4570,7 +4587,7 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError
|
|
|
4570
4587
|
|
|
4571
4588
|
// TODO use wrapper timing module instead of this
|
|
4572
4589
|
// @ts-ignore
|
|
4573
|
-
state$
|
|
4590
|
+
state$7.timeout = setTimeout(handleTimeout, 3000);
|
|
4574
4591
|
}
|
|
4575
4592
|
return editor;
|
|
4576
4593
|
};
|
|
@@ -4590,8 +4607,8 @@ const showErrorMessage = async (editor, rowIndex, columnIndex, message) => {
|
|
|
4590
4607
|
|
|
4591
4608
|
// @ts-ignore
|
|
4592
4609
|
const editorHideMessage = async editor => {
|
|
4593
|
-
clearTimeout(state$
|
|
4594
|
-
state$
|
|
4610
|
+
clearTimeout(state$7.timeout);
|
|
4611
|
+
state$7.timeout = -1;
|
|
4595
4612
|
// await RendererProcess.invoke(/* Viewlet.send */ 'Viewlet.send', /* id */ editor.uid, /* method */ 'hideOverlayMessage')
|
|
4596
4613
|
return editor;
|
|
4597
4614
|
};
|
|
@@ -4707,12 +4724,12 @@ const launchRenameWorker = async () => {
|
|
|
4707
4724
|
return rpc;
|
|
4708
4725
|
};
|
|
4709
4726
|
|
|
4710
|
-
const state$
|
|
4727
|
+
const state$6 = {};
|
|
4711
4728
|
const getOrCreate$2 = () => {
|
|
4712
|
-
if (!state$
|
|
4713
|
-
state$
|
|
4729
|
+
if (!state$6.workerPromise) {
|
|
4730
|
+
state$6.workerPromise = launchRenameWorker();
|
|
4714
4731
|
}
|
|
4715
|
-
return state$
|
|
4732
|
+
return state$6.workerPromise;
|
|
4716
4733
|
};
|
|
4717
4734
|
const invoke$5 = async (method, ...params) => {
|
|
4718
4735
|
const worker = await getOrCreate$2();
|
|
@@ -4832,12 +4849,12 @@ const openColorPicker = async editor => {
|
|
|
4832
4849
|
return addWidgetToEditor(ColorPicker$1, ColorPicker, editor, create$6, newStateGenerator$6);
|
|
4833
4850
|
};
|
|
4834
4851
|
|
|
4835
|
-
const state$
|
|
4852
|
+
const state$5 = {
|
|
4836
4853
|
compositionText: '',
|
|
4837
4854
|
isComposing: false
|
|
4838
4855
|
};
|
|
4839
4856
|
const compositionStart = (editor, event) => {
|
|
4840
|
-
state$
|
|
4857
|
+
state$5.isComposing = true;
|
|
4841
4858
|
return editor;
|
|
4842
4859
|
};
|
|
4843
4860
|
const getCompositionChanges = (selections, data) => {
|
|
@@ -4847,9 +4864,9 @@ const getCompositionChanges = (selections, data) => {
|
|
|
4847
4864
|
const selectionStartColumn = selections[i + 1];
|
|
4848
4865
|
const selectionEndRow = selections[i + 2];
|
|
4849
4866
|
const selectionEndColumn = selections[i + 3];
|
|
4850
|
-
const startColumnIndex = selectionStartColumn - state$
|
|
4867
|
+
const startColumnIndex = selectionStartColumn - state$5.compositionText.length;
|
|
4851
4868
|
changes.push({
|
|
4852
|
-
deleted: [state$
|
|
4869
|
+
deleted: [state$5.compositionText],
|
|
4853
4870
|
end: {
|
|
4854
4871
|
columnIndex: selectionEndColumn,
|
|
4855
4872
|
rowIndex: selectionEndRow
|
|
@@ -4869,7 +4886,7 @@ const compositionUpdate = (editor, data) => {
|
|
|
4869
4886
|
selections
|
|
4870
4887
|
} = editor;
|
|
4871
4888
|
const changes = getCompositionChanges(selections, data);
|
|
4872
|
-
state$
|
|
4889
|
+
state$5.compositionText = data;
|
|
4873
4890
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
4874
4891
|
};
|
|
4875
4892
|
const compositionEnd = (editor, data) => {
|
|
@@ -4877,8 +4894,8 @@ const compositionEnd = (editor, data) => {
|
|
|
4877
4894
|
selections
|
|
4878
4895
|
} = editor;
|
|
4879
4896
|
const changes = getCompositionChanges(selections, data);
|
|
4880
|
-
state$
|
|
4881
|
-
state$
|
|
4897
|
+
state$5.isComposing = false;
|
|
4898
|
+
state$5.compositionText = '';
|
|
4882
4899
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
4883
4900
|
};
|
|
4884
4901
|
|
|
@@ -5978,21 +5995,6 @@ const closeWidgetsMaybe = widgets => {
|
|
|
5978
5995
|
return widgets.filter(isPersistentWidget);
|
|
5979
5996
|
};
|
|
5980
5997
|
|
|
5981
|
-
const state$5 = {
|
|
5982
|
-
position: {
|
|
5983
|
-
columnIndex: 0,
|
|
5984
|
-
rowIndex: 0
|
|
5985
|
-
}
|
|
5986
|
-
};
|
|
5987
|
-
const getPosition = () => {
|
|
5988
|
-
return state$5.position;
|
|
5989
|
-
};
|
|
5990
|
-
|
|
5991
|
-
// @ts-ignore
|
|
5992
|
-
const setPosition = position => {
|
|
5993
|
-
state$5.position = position;
|
|
5994
|
-
};
|
|
5995
|
-
|
|
5996
5998
|
const openExternal = async (url, platform) => {
|
|
5997
5999
|
await openUrl(url, platform);
|
|
5998
6000
|
};
|
|
@@ -6056,12 +6058,11 @@ const Ctrl = 1;
|
|
|
6056
6058
|
const Alt = 2;
|
|
6057
6059
|
|
|
6058
6060
|
const handleSingleClickDefault = (editor, position) => {
|
|
6059
|
-
// TODO avoid global variables, add them to editor state
|
|
6060
|
-
setPosition(position);
|
|
6061
6061
|
const widgets = closeWidgetsMaybe(editor.widgets);
|
|
6062
6062
|
return {
|
|
6063
6063
|
...editor,
|
|
6064
6064
|
focused: true,
|
|
6065
|
+
selectionAnchorPosition: position,
|
|
6065
6066
|
selections: new Uint32Array([position.rowIndex, position.columnIndex, position.rowIndex, position.columnIndex]),
|
|
6066
6067
|
widgets
|
|
6067
6068
|
};
|
|
@@ -6150,6 +6151,16 @@ const Single = 1;
|
|
|
6150
6151
|
const Double = 2;
|
|
6151
6152
|
const Triple = 3;
|
|
6152
6153
|
|
|
6154
|
+
const getModifier = (altKey, ctrlKey) => {
|
|
6155
|
+
if (altKey) {
|
|
6156
|
+
return Alt;
|
|
6157
|
+
}
|
|
6158
|
+
if (ctrlKey) {
|
|
6159
|
+
return Ctrl;
|
|
6160
|
+
}
|
|
6161
|
+
return 0;
|
|
6162
|
+
};
|
|
6163
|
+
|
|
6153
6164
|
const handleSingleClick = async (editor, modifier, x, y) => {
|
|
6154
6165
|
object(editor);
|
|
6155
6166
|
number(modifier);
|
|
@@ -6187,27 +6198,26 @@ const handleTripleClick = (editor, modifier, x, y) => {
|
|
|
6187
6198
|
return selectLine(editor);
|
|
6188
6199
|
};
|
|
6189
6200
|
|
|
6190
|
-
const
|
|
6191
|
-
if (altKey) {
|
|
6192
|
-
return Alt;
|
|
6193
|
-
}
|
|
6194
|
-
if (ctrlKey) {
|
|
6195
|
-
return Ctrl;
|
|
6196
|
-
}
|
|
6197
|
-
return 0;
|
|
6198
|
-
};
|
|
6199
|
-
const handleMouseDown = (state, button, altKey, ctrlKey, x, y, detail) => {
|
|
6201
|
+
const handleMouseDown = async (state, button, altKey, ctrlKey, x, y, detail) => {
|
|
6200
6202
|
const modifier = getModifier(altKey, ctrlKey);
|
|
6203
|
+
let newState;
|
|
6201
6204
|
switch (detail) {
|
|
6202
6205
|
case Double:
|
|
6203
|
-
|
|
6206
|
+
newState = await handleDoubleClick(state, modifier, x, y);
|
|
6207
|
+
break;
|
|
6204
6208
|
case Single:
|
|
6205
|
-
|
|
6209
|
+
newState = await handleSingleClick(state, modifier, x, y);
|
|
6210
|
+
break;
|
|
6206
6211
|
case Triple:
|
|
6207
|
-
|
|
6212
|
+
newState = handleTripleClick(state, modifier, x, y);
|
|
6213
|
+
break;
|
|
6208
6214
|
default:
|
|
6209
6215
|
return state;
|
|
6210
6216
|
}
|
|
6217
|
+
return {
|
|
6218
|
+
...newState,
|
|
6219
|
+
isSelecting: true
|
|
6220
|
+
};
|
|
6211
6221
|
};
|
|
6212
6222
|
|
|
6213
6223
|
const state$4 = {
|
|
@@ -6378,11 +6388,7 @@ const handlePointerCaptureLost = editor => {
|
|
|
6378
6388
|
};
|
|
6379
6389
|
|
|
6380
6390
|
const handlePointerDown$1 = async (state, button, altKey, ctrlKey, x, y, detail) => {
|
|
6381
|
-
|
|
6382
|
-
return {
|
|
6383
|
-
...newState,
|
|
6384
|
-
isSelecting: true
|
|
6385
|
-
};
|
|
6391
|
+
return state;
|
|
6386
6392
|
};
|
|
6387
6393
|
|
|
6388
6394
|
const moveRectangleSelection = (editor, position) => {
|
|
@@ -6512,7 +6518,7 @@ const getNewSelections$5 = (anchor, position) => {
|
|
|
6512
6518
|
|
|
6513
6519
|
// @ts-ignore
|
|
6514
6520
|
const editorMoveSelection = (editor, position) => {
|
|
6515
|
-
const anchor =
|
|
6521
|
+
const anchor = editor.selectionAnchorPosition;
|
|
6516
6522
|
const newSelections = getNewSelections$5(anchor, position);
|
|
6517
6523
|
// TODO if selection equals previous selection -> do nothing
|
|
6518
6524
|
return scheduleSelections(editor, newSelections);
|
|
@@ -6530,7 +6536,7 @@ const getNewEditor$1 = (editor, position) => {
|
|
|
6530
6536
|
const newMinLineY = position.rowIndex;
|
|
6531
6537
|
const newMaxLineY = position.rowIndex + diff;
|
|
6532
6538
|
const newDeltaY = position.rowIndex * rowHeight;
|
|
6533
|
-
const anchor =
|
|
6539
|
+
const anchor = editor.selectionAnchorPosition;
|
|
6534
6540
|
const newSelections = new Uint32Array([position.rowIndex - 1, position.columnIndex, anchor.rowIndex, anchor.columnIndex]);
|
|
6535
6541
|
return {
|
|
6536
6542
|
...editor,
|
|
@@ -6545,7 +6551,7 @@ const getNewEditor$1 = (editor, position) => {
|
|
|
6545
6551
|
const newMinLineY = position.rowIndex - diff;
|
|
6546
6552
|
const newMaxLineY = position.rowIndex;
|
|
6547
6553
|
const newDeltaY = newMinLineY * rowHeight;
|
|
6548
|
-
const anchor =
|
|
6554
|
+
const anchor = editor.selectionAnchorPosition;
|
|
6549
6555
|
const newSelections = new Uint32Array([anchor.rowIndex, anchor.columnIndex, position.rowIndex + 1, position.columnIndex]);
|
|
6550
6556
|
return {
|
|
6551
6557
|
...editor,
|
|
@@ -7190,7 +7196,7 @@ const dispose = async () => {
|
|
|
7190
7196
|
// await rpc.dispose()
|
|
7191
7197
|
};
|
|
7192
7198
|
|
|
7193
|
-
const getEditor = editorUid => {
|
|
7199
|
+
const getEditor$1 = editorUid => {
|
|
7194
7200
|
const instance = get$7(editorUid);
|
|
7195
7201
|
if (!instance) {
|
|
7196
7202
|
throw new Error(`editor ${editorUid} not found`);
|
|
@@ -7205,7 +7211,7 @@ const loadContent$2 = async (state, parentUid) => {
|
|
|
7205
7211
|
const {
|
|
7206
7212
|
uid
|
|
7207
7213
|
} = state;
|
|
7208
|
-
const editor = getEditor(parentUid);
|
|
7214
|
+
const editor = getEditor$1(parentUid);
|
|
7209
7215
|
const {
|
|
7210
7216
|
height,
|
|
7211
7217
|
width,
|
|
@@ -8109,7 +8115,7 @@ const setLanguageId = async (editor, languageId, tokenizePath) => {
|
|
|
8109
8115
|
const tokenizer = getTokenizer(languageId);
|
|
8110
8116
|
const newTokenizerId = tokenizerId + 1;
|
|
8111
8117
|
set$3(newTokenizerId, tokenizer);
|
|
8112
|
-
const latest = getEditor(editor.uid);
|
|
8118
|
+
const latest = getEditor$1(editor.uid);
|
|
8113
8119
|
if (!latest) {
|
|
8114
8120
|
return editor;
|
|
8115
8121
|
}
|
|
@@ -8118,7 +8124,7 @@ const setLanguageId = async (editor, languageId, tokenizePath) => {
|
|
|
8118
8124
|
differences,
|
|
8119
8125
|
textInfos
|
|
8120
8126
|
} = await getVisible$1(editor, syncIncremental);
|
|
8121
|
-
const latest2 = getEditor(editor.uid);
|
|
8127
|
+
const latest2 = getEditor$1(editor.uid);
|
|
8122
8128
|
if (!latest2) {
|
|
8123
8129
|
return editor;
|
|
8124
8130
|
}
|
|
@@ -9213,6 +9219,8 @@ const getWidgetInvoke = widgetId => {
|
|
|
9213
9219
|
}
|
|
9214
9220
|
};
|
|
9215
9221
|
|
|
9222
|
+
const Close = 'Close';
|
|
9223
|
+
|
|
9216
9224
|
const updateWidget = (editor, widgetId, newState) => {
|
|
9217
9225
|
// TODO avoid closure
|
|
9218
9226
|
const isWidget = widget => {
|
|
@@ -9236,11 +9244,40 @@ const updateWidget = (editor, widgetId, newState) => {
|
|
|
9236
9244
|
};
|
|
9237
9245
|
};
|
|
9238
9246
|
|
|
9247
|
+
const getEditorByWidgetUid = (widgetUid, widgetId) => {
|
|
9248
|
+
for (const key of getKeys$2()) {
|
|
9249
|
+
const editor = get$7(Number(key)).newState;
|
|
9250
|
+
const widgets = editor.widgets || [];
|
|
9251
|
+
for (const widget of widgets) {
|
|
9252
|
+
if (widget.id === widgetId && widget.newState.uid === widgetUid) {
|
|
9253
|
+
return editor;
|
|
9254
|
+
}
|
|
9255
|
+
}
|
|
9256
|
+
}
|
|
9257
|
+
return undefined;
|
|
9258
|
+
};
|
|
9259
|
+
const getEditor = (editorOrUid, widgetId) => {
|
|
9260
|
+
if (editorOrUid && editorOrUid.widgets) {
|
|
9261
|
+
return editorOrUid;
|
|
9262
|
+
}
|
|
9263
|
+
const instance = get$7(editorOrUid);
|
|
9264
|
+
if (instance && instance.newState && instance.newState.widgets) {
|
|
9265
|
+
return instance.newState;
|
|
9266
|
+
}
|
|
9267
|
+
return getEditorByWidgetUid(editorOrUid, widgetId);
|
|
9268
|
+
};
|
|
9239
9269
|
const createFn = (key, name, widgetId) => {
|
|
9240
9270
|
const isWidget = widget => {
|
|
9241
9271
|
return widget.id === widgetId;
|
|
9242
9272
|
};
|
|
9243
|
-
const
|
|
9273
|
+
const isClose = args => {
|
|
9274
|
+
return key === 'close' || key === 'handleClickButton' && args.includes(Close);
|
|
9275
|
+
};
|
|
9276
|
+
const fn = async (editorOrUid, ...args) => {
|
|
9277
|
+
const editor = getEditor(editorOrUid, widgetId);
|
|
9278
|
+
if (!editor) {
|
|
9279
|
+
return editorOrUid;
|
|
9280
|
+
}
|
|
9244
9281
|
const childIndex = editor.widgets.findIndex(isWidget);
|
|
9245
9282
|
if (childIndex === -1) {
|
|
9246
9283
|
return editor;
|
|
@@ -9255,12 +9292,22 @@ const createFn = (key, name, widgetId) => {
|
|
|
9255
9292
|
await invoke(`${name}.${key}`, uid, ...args);
|
|
9256
9293
|
const diff = await invoke(`${name}.diff2`, uid);
|
|
9257
9294
|
const commands = await invoke(`${name}.render2`, uid, diff);
|
|
9295
|
+
const latest = get$7(editor.uid).newState;
|
|
9296
|
+
if (isClose(args)) {
|
|
9297
|
+
const newEditor = {
|
|
9298
|
+
...latest,
|
|
9299
|
+
focused: true,
|
|
9300
|
+
widgets: removeEditorWidget(latest.widgets, widgetId)
|
|
9301
|
+
};
|
|
9302
|
+
set$8(editor.uid, latest, newEditor);
|
|
9303
|
+
return newEditor;
|
|
9304
|
+
}
|
|
9258
9305
|
const newState = {
|
|
9259
9306
|
...state,
|
|
9260
9307
|
commands
|
|
9261
9308
|
};
|
|
9262
|
-
const latest = get$7(editor.uid).newState;
|
|
9263
9309
|
const newEditor = updateWidget(latest, widgetId, newState);
|
|
9310
|
+
set$8(editor.uid, latest, newEditor);
|
|
9264
9311
|
return newEditor;
|
|
9265
9312
|
};
|
|
9266
9313
|
return fn;
|
|
@@ -9952,7 +9999,7 @@ const executeWidgetCommand = async (editor, name, method, _uid, widgetId, ...par
|
|
|
9952
9999
|
const isWidget = widget => {
|
|
9953
10000
|
return widget.id === widgetId;
|
|
9954
10001
|
};
|
|
9955
|
-
const latestEditor = getEditor(editor.uid);
|
|
10002
|
+
const latestEditor = getEditor$1(editor.uid);
|
|
9956
10003
|
const childIndex1 = latestEditor.widgets.findIndex(isWidget);
|
|
9957
10004
|
if (childIndex1 === -1) {
|
|
9958
10005
|
return latestEditor;
|
|
@@ -10038,54 +10085,54 @@ const FocusFindWidgetPreviousMatchButton = 50;
|
|
|
10038
10085
|
const FocusEditorCodeGenerator = 52;
|
|
10039
10086
|
|
|
10040
10087
|
const getPositionAtCursor = editorUid => {
|
|
10041
|
-
const editor = getEditor(editorUid);
|
|
10088
|
+
const editor = getEditor$1(editorUid);
|
|
10042
10089
|
return getPositionAtCursor$1(editor);
|
|
10043
10090
|
};
|
|
10044
10091
|
const getUri = editorUid => {
|
|
10045
|
-
const editor = getEditor(editorUid);
|
|
10092
|
+
const editor = getEditor$1(editorUid);
|
|
10046
10093
|
return editor.uri;
|
|
10047
10094
|
};
|
|
10048
10095
|
const getLanguageId = editorUid => {
|
|
10049
|
-
const editor = getEditor(editorUid);
|
|
10096
|
+
const editor = getEditor$1(editorUid);
|
|
10050
10097
|
return editor.languageId;
|
|
10051
10098
|
};
|
|
10052
10099
|
const getOffsetAtCursor = editorUid => {
|
|
10053
|
-
const editor = getEditor(editorUid);
|
|
10100
|
+
const editor = getEditor$1(editorUid);
|
|
10054
10101
|
return getOffsetAtCursor$1(editor);
|
|
10055
10102
|
};
|
|
10056
10103
|
const getWordAt = (editorUid, rowIndex, columnIndex) => {
|
|
10057
|
-
const editor = getEditor(editorUid);
|
|
10104
|
+
const editor = getEditor$1(editorUid);
|
|
10058
10105
|
const {
|
|
10059
10106
|
word
|
|
10060
10107
|
} = getWordAt$1(editor, rowIndex, columnIndex);
|
|
10061
10108
|
return word;
|
|
10062
10109
|
};
|
|
10063
10110
|
const getWordAtOffset2 = editorUid => {
|
|
10064
|
-
const editor = getEditor(editorUid);
|
|
10111
|
+
const editor = getEditor$1(editorUid);
|
|
10065
10112
|
const word = getWordAtOffset(editor);
|
|
10066
10113
|
return word;
|
|
10067
10114
|
};
|
|
10068
10115
|
const getWordBefore2 = (editorUid, rowIndex, columnIndex) => {
|
|
10069
|
-
const editor = getEditor(editorUid);
|
|
10116
|
+
const editor = getEditor$1(editorUid);
|
|
10070
10117
|
const word = getWordBefore(editor, rowIndex, columnIndex);
|
|
10071
10118
|
return word;
|
|
10072
10119
|
};
|
|
10073
10120
|
const getLines2 = editorUid => {
|
|
10074
|
-
const editor = getEditor(editorUid);
|
|
10121
|
+
const editor = getEditor$1(editorUid);
|
|
10075
10122
|
const {
|
|
10076
10123
|
lines
|
|
10077
10124
|
} = editor;
|
|
10078
10125
|
return lines;
|
|
10079
10126
|
};
|
|
10080
10127
|
const getSelections2 = editorUid => {
|
|
10081
|
-
const editor = getEditor(editorUid);
|
|
10128
|
+
const editor = getEditor$1(editorUid);
|
|
10082
10129
|
const {
|
|
10083
10130
|
selections
|
|
10084
10131
|
} = editor;
|
|
10085
10132
|
return selections;
|
|
10086
10133
|
};
|
|
10087
10134
|
const setSelections2 = async (editorUid, selections) => {
|
|
10088
|
-
const editor = getEditor(editorUid);
|
|
10135
|
+
const editor = getEditor$1(editorUid);
|
|
10089
10136
|
const newEditor = {
|
|
10090
10137
|
...editor,
|
|
10091
10138
|
selections
|
|
@@ -10094,7 +10141,7 @@ const setSelections2 = async (editorUid, selections) => {
|
|
|
10094
10141
|
set$8(editorUid, editor, newEditorWithDerivedState);
|
|
10095
10142
|
};
|
|
10096
10143
|
const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocus$1) => {
|
|
10097
|
-
const editor = getEditor(editorUid);
|
|
10144
|
+
const editor = getEditor$1(editorUid);
|
|
10098
10145
|
const invoke = getWidgetInvoke(widgetId);
|
|
10099
10146
|
const {
|
|
10100
10147
|
widgets
|
|
@@ -10121,7 +10168,7 @@ const closeFind2 = async editorUid => {
|
|
|
10121
10168
|
await closeWidget2(editorUid, Find, 'FindWidget', 0);
|
|
10122
10169
|
};
|
|
10123
10170
|
const applyEdits2 = async (editorUid, edits) => {
|
|
10124
|
-
const editor = getEditor(editorUid);
|
|
10171
|
+
const editor = getEditor$1(editorUid);
|
|
10125
10172
|
const newEditor = await applyEdit(editor, edits);
|
|
10126
10173
|
const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
|
|
10127
10174
|
set$8(editorUid, editor, newEditorWithDerivedState);
|
|
@@ -10131,7 +10178,7 @@ const getSourceActions = async editorUid => {
|
|
|
10131
10178
|
return actions;
|
|
10132
10179
|
};
|
|
10133
10180
|
const getDiagnostics$1 = async editorUid => {
|
|
10134
|
-
const editor = getEditor(editorUid);
|
|
10181
|
+
const editor = getEditor$1(editorUid);
|
|
10135
10182
|
const {
|
|
10136
10183
|
diagnostics
|
|
10137
10184
|
} = editor;
|
|
@@ -10669,7 +10716,7 @@ const getQuickPickMenuEntries = () => {
|
|
|
10669
10716
|
};
|
|
10670
10717
|
|
|
10671
10718
|
const getSelections = editorUid => {
|
|
10672
|
-
const editor = getEditor(editorUid);
|
|
10719
|
+
const editor = getEditor$1(editorUid);
|
|
10673
10720
|
const {
|
|
10674
10721
|
selections
|
|
10675
10722
|
} = editor;
|
|
@@ -10678,7 +10725,7 @@ const getSelections = editorUid => {
|
|
|
10678
10725
|
|
|
10679
10726
|
const getText = editorUid => {
|
|
10680
10727
|
number(editorUid);
|
|
10681
|
-
const editor = getEditor(editorUid);
|
|
10728
|
+
const editor = getEditor$1(editorUid);
|
|
10682
10729
|
const {
|
|
10683
10730
|
lines
|
|
10684
10731
|
} = editor;
|
|
@@ -11106,11 +11153,13 @@ const registerListener = (listenerType, rpcId) => {
|
|
|
11106
11153
|
registerListener$1(listenerType, rpcId);
|
|
11107
11154
|
};
|
|
11108
11155
|
|
|
11109
|
-
const getCss = (rowHeight, scrollBarHeight, scrollBarTop) => {
|
|
11156
|
+
const getCss = (rowHeight, scrollBarHeight, scrollBarTop, scrollBarWidth, scrollBarLeft) => {
|
|
11110
11157
|
return `.Editor {
|
|
11111
11158
|
--EditorRowHeight: ${rowHeight}px;
|
|
11112
11159
|
--ScrollBarHeight: ${scrollBarHeight}px;
|
|
11113
11160
|
--ScrollBarTop: ${scrollBarTop}px;
|
|
11161
|
+
--ScrollBarWidth: ${scrollBarWidth}px;
|
|
11162
|
+
--ScrollBarLeft: ${scrollBarLeft}px;
|
|
11114
11163
|
}
|
|
11115
11164
|
.Editor .EditorRow {
|
|
11116
11165
|
height: var(--EditorRowHeight);
|
|
@@ -11120,20 +11169,37 @@ const getCss = (rowHeight, scrollBarHeight, scrollBarTop) => {
|
|
|
11120
11169
|
height: var(--ScrollBarHeight);
|
|
11121
11170
|
translate: 0px var(--ScrollBarTop);
|
|
11122
11171
|
}
|
|
11172
|
+
.Editor .ScrollBarThumbHorizontal {
|
|
11173
|
+
width: var(--ScrollBarWidth);
|
|
11174
|
+
translate: var(--ScrollBarLeft) 0px;
|
|
11175
|
+
}
|
|
11123
11176
|
`;
|
|
11124
11177
|
};
|
|
11125
11178
|
|
|
11126
|
-
const
|
|
11179
|
+
const getScrollBarLeft = (deltaX, longestLineWidth, width) => {
|
|
11180
|
+
const scrollBarLeft = deltaX / longestLineWidth * width;
|
|
11181
|
+
if (!Number.isFinite(scrollBarLeft)) {
|
|
11182
|
+
return 0;
|
|
11183
|
+
}
|
|
11184
|
+
return scrollBarLeft;
|
|
11185
|
+
};
|
|
11186
|
+
const renderCss$1 = (oldState, newState) => {
|
|
11127
11187
|
const {
|
|
11188
|
+
deltaX,
|
|
11128
11189
|
deltaY,
|
|
11129
11190
|
finalDeltaY,
|
|
11130
11191
|
height,
|
|
11192
|
+
longestLineWidth,
|
|
11193
|
+
minimumSliderSize,
|
|
11131
11194
|
rowHeight,
|
|
11132
11195
|
scrollBarHeight,
|
|
11133
|
-
uid
|
|
11196
|
+
uid,
|
|
11197
|
+
width
|
|
11134
11198
|
} = newState;
|
|
11135
11199
|
const scrollBarTop = getScrollBarY(deltaY, finalDeltaY, height, scrollBarHeight);
|
|
11136
|
-
const
|
|
11200
|
+
const scrollBarWidth = getScrollBarSize(width, longestLineWidth, minimumSliderSize);
|
|
11201
|
+
const scrollBarLeft = getScrollBarLeft(deltaX, longestLineWidth, width);
|
|
11202
|
+
const css = getCss(rowHeight, scrollBarHeight, scrollBarTop, scrollBarWidth, scrollBarLeft);
|
|
11137
11203
|
return [SetCss$1, uid, css];
|
|
11138
11204
|
};
|
|
11139
11205
|
|
|
@@ -11593,8 +11659,7 @@ const getEditorScrollBarDiagnosticsVirtualDom = scrollBarDiagnostics => {
|
|
|
11593
11659
|
}, ...getDiagnosticsVirtualDom([...scrollBarDiagnostics])];
|
|
11594
11660
|
};
|
|
11595
11661
|
|
|
11596
|
-
const getScrollBarVirtualDom = (
|
|
11597
|
-
const scrollBarY = getScrollBarY(deltaY, finalDeltaY, height, scrollBarHeight);
|
|
11662
|
+
const getScrollBarVirtualDom = () => {
|
|
11598
11663
|
return [{
|
|
11599
11664
|
childCount: 1,
|
|
11600
11665
|
className: 'ScrollBar ScrollBarVertical',
|
|
@@ -11604,8 +11669,6 @@ const getScrollBarVirtualDom = (deltaY, finalDeltaY, height, scrollBarHeight) =>
|
|
|
11604
11669
|
}, {
|
|
11605
11670
|
childCount: 0,
|
|
11606
11671
|
className: 'ScrollBarThumb ScrollBarThumbVertical',
|
|
11607
|
-
style: `height:${scrollBarHeight}px;`,
|
|
11608
|
-
translate: `0 ${scrollBarY}px`,
|
|
11609
11672
|
type: Div
|
|
11610
11673
|
}, {
|
|
11611
11674
|
childCount: 1,
|
|
@@ -11621,15 +11684,11 @@ const getScrollBarVirtualDom = (deltaY, finalDeltaY, height, scrollBarHeight) =>
|
|
|
11621
11684
|
|
|
11622
11685
|
const getEditorContentVirtualDom = ({
|
|
11623
11686
|
cursorInfos = [],
|
|
11624
|
-
deltaY = 0,
|
|
11625
11687
|
diagnostics = [],
|
|
11626
11688
|
differences,
|
|
11627
|
-
finalDeltaY = 0,
|
|
11628
|
-
height = 0,
|
|
11629
11689
|
highlightedLine = -1,
|
|
11630
11690
|
lineNumbers = true,
|
|
11631
11691
|
scrollBarDiagnostics = [],
|
|
11632
|
-
scrollBarHeight = 0,
|
|
11633
11692
|
selectionInfos = [],
|
|
11634
11693
|
textInfos
|
|
11635
11694
|
}) => {
|
|
@@ -11638,7 +11697,7 @@ const getEditorContentVirtualDom = ({
|
|
|
11638
11697
|
className: 'EditorContent',
|
|
11639
11698
|
onMouseMove: HandleMouseMove,
|
|
11640
11699
|
type: Div
|
|
11641
|
-
}, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom(
|
|
11700
|
+
}, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom()];
|
|
11642
11701
|
};
|
|
11643
11702
|
|
|
11644
11703
|
const getGutterInfoVirtualDom = gutterInfo => {
|
|
@@ -11664,16 +11723,12 @@ const getEditorGutterVirtualDom = gutterInfos => {
|
|
|
11664
11723
|
|
|
11665
11724
|
const getEditorVirtualDom = ({
|
|
11666
11725
|
cursorInfos = [],
|
|
11667
|
-
deltaY = 0,
|
|
11668
11726
|
diagnostics = [],
|
|
11669
11727
|
differences,
|
|
11670
|
-
finalDeltaY = 0,
|
|
11671
11728
|
gutterInfos = [],
|
|
11672
|
-
height = 0,
|
|
11673
11729
|
highlightedLine = -1,
|
|
11674
11730
|
lineNumbers = true,
|
|
11675
11731
|
scrollBarDiagnostics = [],
|
|
11676
|
-
scrollBarHeight = 0,
|
|
11677
11732
|
selectionInfos = [],
|
|
11678
11733
|
textInfos
|
|
11679
11734
|
}) => {
|
|
@@ -11686,15 +11741,11 @@ const getEditorVirtualDom = ({
|
|
|
11686
11741
|
type: Div
|
|
11687
11742
|
}, ...gutterDom, ...getEditorContentVirtualDom({
|
|
11688
11743
|
cursorInfos,
|
|
11689
|
-
deltaY,
|
|
11690
11744
|
diagnostics,
|
|
11691
11745
|
differences,
|
|
11692
|
-
finalDeltaY,
|
|
11693
|
-
height,
|
|
11694
11746
|
highlightedLine,
|
|
11695
11747
|
lineNumbers,
|
|
11696
11748
|
scrollBarDiagnostics,
|
|
11697
|
-
scrollBarHeight,
|
|
11698
11749
|
selectionInfos,
|
|
11699
11750
|
textInfos
|
|
11700
11751
|
})];
|
|
@@ -11739,16 +11790,91 @@ const renderIncremental = (oldState, newState) => {
|
|
|
11739
11790
|
return [SetPatches, newState.uid, patches];
|
|
11740
11791
|
};
|
|
11741
11792
|
|
|
11793
|
+
const addWidget = widget => {
|
|
11794
|
+
const module = get$6(widget.id);
|
|
11795
|
+
if (!module) {
|
|
11796
|
+
throw new Error('unsupported widget');
|
|
11797
|
+
}
|
|
11798
|
+
return module.add(widget);
|
|
11799
|
+
};
|
|
11800
|
+
const renderWidget = widget => {
|
|
11801
|
+
const module = get$6(widget.id);
|
|
11802
|
+
if (!module) {
|
|
11803
|
+
throw new Error('unsupported widget');
|
|
11804
|
+
}
|
|
11805
|
+
return module.render(widget);
|
|
11806
|
+
};
|
|
11807
|
+
const removeWidget = widget => {
|
|
11808
|
+
const module = get$6(widget.id);
|
|
11809
|
+
if (!module) {
|
|
11810
|
+
throw new Error('unsupported widget');
|
|
11811
|
+
}
|
|
11812
|
+
return module.remove(widget);
|
|
11813
|
+
};
|
|
11814
|
+
|
|
11815
|
+
const renderWidgets$1 = (oldState, newState) => {
|
|
11816
|
+
const addedWidgets = [];
|
|
11817
|
+
const changedWidgets = [];
|
|
11818
|
+
const removedWidgets = [];
|
|
11819
|
+
const oldWidgets = oldState.widgets || [];
|
|
11820
|
+
const newWidgets = newState.widgets || [];
|
|
11821
|
+
const oldWidgetMap = Object.create(null);
|
|
11822
|
+
const newWidgetMap = Object.create(null);
|
|
11823
|
+
for (const oldWidget of oldWidgets) {
|
|
11824
|
+
oldWidgetMap[oldWidget.id] = oldWidget;
|
|
11825
|
+
}
|
|
11826
|
+
for (const newWidget of newWidgets) {
|
|
11827
|
+
newWidgetMap[newWidget.id] = newWidget;
|
|
11828
|
+
}
|
|
11829
|
+
for (const oldWidget of oldWidgets) {
|
|
11830
|
+
if (Object.hasOwn(newWidgetMap, oldWidget.id)) {
|
|
11831
|
+
changedWidgets.push(newWidgetMap[oldWidget.id]);
|
|
11832
|
+
} else {
|
|
11833
|
+
removedWidgets.push(oldWidget);
|
|
11834
|
+
}
|
|
11835
|
+
}
|
|
11836
|
+
for (const newWidget of newWidgets) {
|
|
11837
|
+
if (Object.hasOwn(oldWidgetMap, newWidget.id)) ; else {
|
|
11838
|
+
addedWidgets.push(newWidget);
|
|
11839
|
+
}
|
|
11840
|
+
}
|
|
11841
|
+
const addCommands = [];
|
|
11842
|
+
for (const addedWidget of addedWidgets) {
|
|
11843
|
+
const childCommands = addWidget(addedWidget);
|
|
11844
|
+
if (childCommands.length > 0) {
|
|
11845
|
+
addCommands.push(...childCommands);
|
|
11846
|
+
}
|
|
11847
|
+
}
|
|
11848
|
+
const changeCommands = [];
|
|
11849
|
+
for (const changedWidget of changedWidgets) {
|
|
11850
|
+
const childCommands = renderWidget(changedWidget);
|
|
11851
|
+
if (childCommands.length > 0) {
|
|
11852
|
+
changeCommands.push(...childCommands);
|
|
11853
|
+
}
|
|
11854
|
+
}
|
|
11855
|
+
const removeCommands = [];
|
|
11856
|
+
for (const removedWidget of removedWidgets) {
|
|
11857
|
+
const childCommands = removeWidget(removedWidget);
|
|
11858
|
+
if (childCommands.length > 0) {
|
|
11859
|
+
removeCommands.push(...childCommands);
|
|
11860
|
+
}
|
|
11861
|
+
}
|
|
11862
|
+
const allCommands = [...addCommands, ...changeCommands, ...removeCommands];
|
|
11863
|
+
return allCommands.filter(item => item[0] !== 'Viewlet.setFocusContext');
|
|
11864
|
+
};
|
|
11865
|
+
|
|
11742
11866
|
const getRenderer = diffType => {
|
|
11743
11867
|
switch (diffType) {
|
|
11744
11868
|
case RenderCss:
|
|
11745
|
-
return renderCss;
|
|
11869
|
+
return renderCss$1;
|
|
11746
11870
|
case RenderFocus:
|
|
11747
11871
|
return renderFocus$2;
|
|
11748
11872
|
case RenderFocusContext:
|
|
11749
11873
|
return renderFocusContext$1;
|
|
11750
11874
|
case RenderIncremental:
|
|
11751
11875
|
return renderIncremental;
|
|
11876
|
+
case RenderWidgets:
|
|
11877
|
+
return renderWidgets$1;
|
|
11752
11878
|
default:
|
|
11753
11879
|
throw new Error('unknown renderer');
|
|
11754
11880
|
}
|
|
@@ -11760,7 +11886,11 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
11760
11886
|
const fn = getRenderer(item);
|
|
11761
11887
|
const result = fn(oldState, newState);
|
|
11762
11888
|
if (result.length > 0) {
|
|
11763
|
-
|
|
11889
|
+
if (item === RenderWidgets) {
|
|
11890
|
+
commands.push(...result);
|
|
11891
|
+
} else {
|
|
11892
|
+
commands.push(result);
|
|
11893
|
+
}
|
|
11764
11894
|
}
|
|
11765
11895
|
}
|
|
11766
11896
|
return commands;
|
|
@@ -11776,28 +11906,6 @@ const render2 = (uid, diffResult) => {
|
|
|
11776
11906
|
return commands;
|
|
11777
11907
|
};
|
|
11778
11908
|
|
|
11779
|
-
const addWidget = widget => {
|
|
11780
|
-
const module = get$6(widget.id);
|
|
11781
|
-
if (!module) {
|
|
11782
|
-
throw new Error('unsupported widget');
|
|
11783
|
-
}
|
|
11784
|
-
return module.add(widget);
|
|
11785
|
-
};
|
|
11786
|
-
const renderWidget = widget => {
|
|
11787
|
-
const module = get$6(widget.id);
|
|
11788
|
-
if (!module) {
|
|
11789
|
-
throw new Error('unsupported widget');
|
|
11790
|
-
}
|
|
11791
|
-
return module.render(widget);
|
|
11792
|
-
};
|
|
11793
|
-
const removeWidget = widget => {
|
|
11794
|
-
const module = get$6(widget.id);
|
|
11795
|
-
if (!module) {
|
|
11796
|
-
throw new Error('unsupported widget');
|
|
11797
|
-
}
|
|
11798
|
-
return module.remove(widget);
|
|
11799
|
-
};
|
|
11800
|
-
|
|
11801
11909
|
const renderLines = {
|
|
11802
11910
|
apply(oldState, newState) {
|
|
11803
11911
|
const {
|
|
@@ -11833,22 +11941,9 @@ const renderSelections = {
|
|
|
11833
11941
|
},
|
|
11834
11942
|
isEqual: (oldState, newState) => oldState.cursorInfos === newState.cursorInfos && oldState.selectionInfos === newState.selectionInfos
|
|
11835
11943
|
};
|
|
11836
|
-
const
|
|
11837
|
-
apply
|
|
11838
|
-
|
|
11839
|
-
const translate = `0 ${scrollBarY}px`;
|
|
11840
|
-
const heightPx = `${newState.scrollBarHeight}px`;
|
|
11841
|
-
return [/* method */'setScrollBar', translate, heightPx];
|
|
11842
|
-
},
|
|
11843
|
-
isEqual: (oldState, newState) => oldState.deltaY === newState.deltaY && oldState.scrollBarHeight === newState.scrollBarHeight
|
|
11844
|
-
};
|
|
11845
|
-
const renderScrollBarX = {
|
|
11846
|
-
apply(oldState, newState) {
|
|
11847
|
-
const scrollBarWidth = getScrollBarSize(newState.width, newState.longestLineWidth, newState.minimumSliderSize);
|
|
11848
|
-
const scrollBarX = newState.deltaX / newState.longestLineWidth * newState.width;
|
|
11849
|
-
return [/* method */'setScrollBarHorizontal', /* scrollBarX */scrollBarX, /* scrollBarWidth */scrollBarWidth, /* deltaX */newState.deltaX];
|
|
11850
|
-
},
|
|
11851
|
-
isEqual: (oldState, newState) => oldState.longestLineWidth === newState.longestLineWidth && oldState.deltaX === newState.deltaX
|
|
11944
|
+
const renderCss = {
|
|
11945
|
+
apply: renderCss$1,
|
|
11946
|
+
isEqual: isEqual$3
|
|
11852
11947
|
};
|
|
11853
11948
|
const renderFocus$1 = {
|
|
11854
11949
|
apply: (oldState, newState) => [/* method */'setFocused', newState.focused],
|
|
@@ -11894,61 +11989,11 @@ const renderGutterInfo = {
|
|
|
11894
11989
|
isEqual: (oldState, newState) => oldState.lineNumbers === newState.lineNumbers && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY
|
|
11895
11990
|
};
|
|
11896
11991
|
const renderWidgets = {
|
|
11897
|
-
apply
|
|
11898
|
-
const addedWidgets = [];
|
|
11899
|
-
const changedWidgets = [];
|
|
11900
|
-
const removedWidgets = [];
|
|
11901
|
-
const oldWidgets = oldState.widgets || [];
|
|
11902
|
-
const newWidgets = newState.widgets || [];
|
|
11903
|
-
const oldWidgetMap = Object.create(null);
|
|
11904
|
-
const newWidgetMap = Object.create(null);
|
|
11905
|
-
for (const oldWidget of oldWidgets) {
|
|
11906
|
-
oldWidgetMap[oldWidget.id] = oldWidget;
|
|
11907
|
-
}
|
|
11908
|
-
for (const newWidget of newWidgets) {
|
|
11909
|
-
newWidgetMap[newWidget.id] = newWidget;
|
|
11910
|
-
}
|
|
11911
|
-
for (const oldWidget of oldWidgets) {
|
|
11912
|
-
if (Object.hasOwn(newWidgetMap, oldWidget.id)) {
|
|
11913
|
-
changedWidgets.push(newWidgetMap[oldWidget.id]);
|
|
11914
|
-
} else {
|
|
11915
|
-
removedWidgets.push(oldWidget);
|
|
11916
|
-
}
|
|
11917
|
-
}
|
|
11918
|
-
for (const newWidget of newWidgets) {
|
|
11919
|
-
if (Object.hasOwn(oldWidgetMap, newWidget.id)) ; else {
|
|
11920
|
-
addedWidgets.push(newWidget);
|
|
11921
|
-
}
|
|
11922
|
-
}
|
|
11923
|
-
const addCommands = [];
|
|
11924
|
-
for (const addedWidget of addedWidgets) {
|
|
11925
|
-
const childCommands = addWidget(addedWidget);
|
|
11926
|
-
if (childCommands.length > 0) {
|
|
11927
|
-
addCommands.push(...childCommands);
|
|
11928
|
-
}
|
|
11929
|
-
}
|
|
11930
|
-
const changeCommands = [];
|
|
11931
|
-
for (const changedWidget of changedWidgets) {
|
|
11932
|
-
const childCommands = renderWidget(changedWidget);
|
|
11933
|
-
if (childCommands.length > 0) {
|
|
11934
|
-
changeCommands.push(...childCommands);
|
|
11935
|
-
}
|
|
11936
|
-
}
|
|
11937
|
-
const removeCommands = [];
|
|
11938
|
-
for (const removedWidget of removedWidgets) {
|
|
11939
|
-
const childCommands = removeWidget(removedWidget);
|
|
11940
|
-
if (childCommands.length > 0) {
|
|
11941
|
-
removeCommands.push(...childCommands);
|
|
11942
|
-
}
|
|
11943
|
-
}
|
|
11944
|
-
const allCommands = [...addCommands, ...changeCommands, ...removeCommands];
|
|
11945
|
-
const filteredCommands = allCommands.filter(item => item[0] !== 'Viewlet.setFocusContext');
|
|
11946
|
-
return filteredCommands;
|
|
11947
|
-
},
|
|
11992
|
+
apply: renderWidgets$1,
|
|
11948
11993
|
isEqual: (oldState, newState) => oldState.widgets === newState.widgets,
|
|
11949
11994
|
multiple: true
|
|
11950
11995
|
};
|
|
11951
|
-
const render$6 = [renderLines, renderSelections,
|
|
11996
|
+
const render$6 = [renderLines, renderSelections, renderCss, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets, renderFocusContext, renderAdditionalFocusContext];
|
|
11952
11997
|
const renderEditor = async id => {
|
|
11953
11998
|
const instance = get$7(id);
|
|
11954
11999
|
if (!instance) {
|