@lvce-editor/editor-worker 3.27.0 → 3.29.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 +571 -502
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -2,7 +2,7 @@ const commands = Object.create(null);
|
|
|
2
2
|
const registerCommand = (key, fn) => {
|
|
3
3
|
commands[key] = fn;
|
|
4
4
|
};
|
|
5
|
-
const register
|
|
5
|
+
const register = commandMap => {
|
|
6
6
|
for (const [key, value] of Object.entries(commandMap)) {
|
|
7
7
|
registerCommand(key, value);
|
|
8
8
|
}
|
|
@@ -131,8 +131,8 @@ const handleSliderPointerMove = (state, x, y) => {
|
|
|
131
131
|
// TODO use numeric enum
|
|
132
132
|
const CompositionUpdate = 'compositionUpdate';
|
|
133
133
|
const ContentEditableInput = 'contentEditableInput';
|
|
134
|
-
const DeleteLeft = 'deleteLeft';
|
|
135
134
|
const DeleteHorizontalRight = 'deleteHorizontalRight';
|
|
135
|
+
const DeleteLeft = 'deleteLeft';
|
|
136
136
|
const EditorCut = 'editorCut';
|
|
137
137
|
const EditorPasteText = 'editorPasteText';
|
|
138
138
|
const EditorSnippet = 'editorSnippet';
|
|
@@ -142,18 +142,19 @@ const Format = 'format';
|
|
|
142
142
|
const IndentLess = 'indentLess';
|
|
143
143
|
const IndentMore = 'indentMore';
|
|
144
144
|
const InsertLineBreak = 'insertLineBreak';
|
|
145
|
+
const ReplaceAll$2 = 'replaceAll';
|
|
145
146
|
const ToggleBlockComment = 'toggleBlockComment';
|
|
146
147
|
|
|
147
|
-
const
|
|
148
|
-
const
|
|
149
|
-
|
|
148
|
+
const map$1 = Object.create(null);
|
|
149
|
+
const set$7 = (id, widget) => {
|
|
150
|
+
map$1[id] = widget;
|
|
150
151
|
};
|
|
151
|
-
const get$
|
|
152
|
-
return
|
|
152
|
+
const get$7 = id => {
|
|
153
|
+
return map$1[id];
|
|
153
154
|
};
|
|
154
155
|
|
|
155
156
|
const getModule$2 = id => {
|
|
156
|
-
return get$
|
|
157
|
+
return get$7(id);
|
|
157
158
|
};
|
|
158
159
|
|
|
159
160
|
const applyWidgetChange = (editor, widget, changes) => {
|
|
@@ -587,7 +588,7 @@ const alloc = length => {
|
|
|
587
588
|
const clone = selections => {
|
|
588
589
|
return alloc(selections.length);
|
|
589
590
|
};
|
|
590
|
-
const map
|
|
591
|
+
const map = (selections, fn) => {
|
|
591
592
|
const newSelections = clone(selections);
|
|
592
593
|
for (let i = 0; i < newSelections.length; i += 4) {
|
|
593
594
|
const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
|
|
@@ -866,7 +867,7 @@ const scheduleSelections = (editor, selectionEdits) => {
|
|
|
866
867
|
};
|
|
867
868
|
|
|
868
869
|
/**
|
|
869
|
-
*
|
|
870
|
+
* TODO make this synchronous maybe?
|
|
870
871
|
* @param {any} editor
|
|
871
872
|
* @param {any[]} changes
|
|
872
873
|
* @param {Uint32Array|undefined} selectionChanges
|
|
@@ -1021,11 +1022,11 @@ const setText = (editor, text) => {
|
|
|
1021
1022
|
};
|
|
1022
1023
|
|
|
1023
1024
|
const editors = Object.create(null);
|
|
1024
|
-
const get$
|
|
1025
|
+
const get$6 = id => {
|
|
1025
1026
|
number$1(id);
|
|
1026
1027
|
return editors[id];
|
|
1027
1028
|
};
|
|
1028
|
-
const set$
|
|
1029
|
+
const set$6 = (id, oldEditor, newEditor) => {
|
|
1029
1030
|
number$1(id);
|
|
1030
1031
|
object(oldEditor);
|
|
1031
1032
|
object(newEditor);
|
|
@@ -1073,10 +1074,10 @@ const number = value => {
|
|
|
1073
1074
|
const state$1$1 = {
|
|
1074
1075
|
callbacks: Object.create(null)
|
|
1075
1076
|
};
|
|
1076
|
-
const set$
|
|
1077
|
+
const set$5 = (id, fn) => {
|
|
1077
1078
|
state$1$1.callbacks[id] = fn;
|
|
1078
1079
|
};
|
|
1079
|
-
const get$
|
|
1080
|
+
const get$5 = id => {
|
|
1080
1081
|
return state$1$1.callbacks[id];
|
|
1081
1082
|
};
|
|
1082
1083
|
const remove$6 = id => {
|
|
@@ -1110,7 +1111,7 @@ const registerPromise = () => {
|
|
|
1110
1111
|
resolve,
|
|
1111
1112
|
promise
|
|
1112
1113
|
} = withResolvers$2();
|
|
1113
|
-
set$
|
|
1114
|
+
set$5(id, resolve);
|
|
1114
1115
|
return {
|
|
1115
1116
|
id,
|
|
1116
1117
|
promise
|
|
@@ -1118,7 +1119,7 @@ const registerPromise = () => {
|
|
|
1118
1119
|
};
|
|
1119
1120
|
const resolve = (id, args) => {
|
|
1120
1121
|
number(id);
|
|
1121
|
-
const fn = get$
|
|
1122
|
+
const fn = get$5(id);
|
|
1122
1123
|
if (!fn) {
|
|
1123
1124
|
console.log(args);
|
|
1124
1125
|
warn$1(`callback ${id} may already be disposed`);
|
|
@@ -1468,23 +1469,23 @@ const state$8 = {
|
|
|
1468
1469
|
*/
|
|
1469
1470
|
ipc: undefined
|
|
1470
1471
|
};
|
|
1471
|
-
const get$
|
|
1472
|
+
const get$4 = () => {
|
|
1472
1473
|
return state$8.ipc;
|
|
1473
1474
|
};
|
|
1474
|
-
const set$
|
|
1475
|
+
const set$4 = ipc => {
|
|
1475
1476
|
state$8.ipc = ipc;
|
|
1476
1477
|
};
|
|
1477
1478
|
|
|
1478
1479
|
const invoke$4 = (method, ...params) => {
|
|
1479
|
-
const ipc = get$
|
|
1480
|
+
const ipc = get$4();
|
|
1480
1481
|
return invoke$5(ipc, method, ...params);
|
|
1481
1482
|
};
|
|
1482
1483
|
const invokeAndTransfer$1 = async (method, ...params) => {
|
|
1483
|
-
const ipc = get$
|
|
1484
|
+
const ipc = get$4();
|
|
1484
1485
|
return invokeAndTransfer$2(ipc, method, ...params);
|
|
1485
1486
|
};
|
|
1486
1487
|
const listen$8 = ipc => {
|
|
1487
|
-
set$
|
|
1488
|
+
set$4(ipc);
|
|
1488
1489
|
};
|
|
1489
1490
|
|
|
1490
1491
|
const invoke$3 = async (method, ...params) => {
|
|
@@ -1860,7 +1861,7 @@ const createEditor = async ({
|
|
|
1860
1861
|
...newEditor3,
|
|
1861
1862
|
focused: true
|
|
1862
1863
|
};
|
|
1863
|
-
set$
|
|
1864
|
+
set$6(id, emptyEditor, newEditor4);
|
|
1864
1865
|
await invoke$2(TextDocumentSyncFull, uri, id, languageId, content);
|
|
1865
1866
|
};
|
|
1866
1867
|
|
|
@@ -2883,7 +2884,7 @@ const moveSelectionDown = (selections, i, selectionStartRow, selectionStartColum
|
|
|
2883
2884
|
moveRangeToPosition$1(selections, i, selectionEndRow + 1, selectionEndColumn);
|
|
2884
2885
|
};
|
|
2885
2886
|
const getNewSelections$9 = selections => {
|
|
2886
|
-
return map
|
|
2887
|
+
return map(selections, moveSelectionDown);
|
|
2887
2888
|
};
|
|
2888
2889
|
const cursorDown = editor => {
|
|
2889
2890
|
const {
|
|
@@ -2919,7 +2920,7 @@ const moveSelectionWithoutIntlSegmenter = (selections, i, selectionStartRow, sel
|
|
|
2919
2920
|
}
|
|
2920
2921
|
};
|
|
2921
2922
|
const getNewSelections$8 = selections => {
|
|
2922
|
-
return map
|
|
2923
|
+
return map(selections, moveSelectionWithoutIntlSegmenter);
|
|
2923
2924
|
};
|
|
2924
2925
|
const cursorVertical = (editor, getPosition, getEdgePosition, delta) => {
|
|
2925
2926
|
const {
|
|
@@ -3698,10 +3699,10 @@ const state$4 = {
|
|
|
3698
3699
|
y: 0,
|
|
3699
3700
|
editor: undefined
|
|
3700
3701
|
};
|
|
3701
|
-
const get$
|
|
3702
|
+
const get$3 = () => {
|
|
3702
3703
|
return state$4;
|
|
3703
3704
|
};
|
|
3704
|
-
const set$
|
|
3705
|
+
const set$3 = (editor, timeout, x, y) => {
|
|
3705
3706
|
state$4.editor = editor;
|
|
3706
3707
|
state$4.timeout = timeout;
|
|
3707
3708
|
state$4.x = x;
|
|
@@ -3727,7 +3728,7 @@ const onHoverIdle = async () => {
|
|
|
3727
3728
|
x,
|
|
3728
3729
|
y,
|
|
3729
3730
|
editor
|
|
3730
|
-
} = get$
|
|
3731
|
+
} = get$3();
|
|
3731
3732
|
at(editor, x, y);
|
|
3732
3733
|
await showHover$1();
|
|
3733
3734
|
};
|
|
@@ -3738,12 +3739,12 @@ const handleMouseMove = (editor, x, y) => {
|
|
|
3738
3739
|
if (!editor.hoverEnabled) {
|
|
3739
3740
|
return editor;
|
|
3740
3741
|
}
|
|
3741
|
-
const oldState = get$
|
|
3742
|
+
const oldState = get$3();
|
|
3742
3743
|
if (oldState.timeout !== -1) {
|
|
3743
3744
|
clearTimeout(oldState.timeout);
|
|
3744
3745
|
}
|
|
3745
3746
|
const timeout = setTimeout(onHoverIdle, hoverDelay);
|
|
3746
|
-
set$
|
|
3747
|
+
set$3(editor, timeout, x, y);
|
|
3747
3748
|
return editor;
|
|
3748
3749
|
};
|
|
3749
3750
|
|
|
@@ -4800,7 +4801,7 @@ const filterCompletionItems = (completionItems, word) => {
|
|
|
4800
4801
|
};
|
|
4801
4802
|
|
|
4802
4803
|
const getEditor = editorUid => {
|
|
4803
|
-
const instance = get$
|
|
4804
|
+
const instance = get$6(editorUid);
|
|
4804
4805
|
if (!instance) {
|
|
4805
4806
|
throw new Error(`editor ${editorUid} not found`);
|
|
4806
4807
|
}
|
|
@@ -4843,7 +4844,7 @@ const getWordAtOffset = editor => {
|
|
|
4843
4844
|
}
|
|
4844
4845
|
return '';
|
|
4845
4846
|
};
|
|
4846
|
-
const handleEditorType$
|
|
4847
|
+
const handleEditorType$2 = (editorUid, state, text) => {
|
|
4847
4848
|
const editor = getEditor(editorUid);
|
|
4848
4849
|
const {
|
|
4849
4850
|
unfilteredItems,
|
|
@@ -4873,7 +4874,7 @@ const handleEditorType$1 = (editorUid, state, text) => {
|
|
|
4873
4874
|
finalDeltaY
|
|
4874
4875
|
};
|
|
4875
4876
|
};
|
|
4876
|
-
const handleEditorDeleteLeft$
|
|
4877
|
+
const handleEditorDeleteLeft$2 = (editorUid, state) => {
|
|
4877
4878
|
const editor = getEditor(editorUid);
|
|
4878
4879
|
const {
|
|
4879
4880
|
unfilteredItems,
|
|
@@ -4981,7 +4982,7 @@ const openCompletion = async editor => {
|
|
|
4981
4982
|
...editor,
|
|
4982
4983
|
widgets: newWidgets
|
|
4983
4984
|
};
|
|
4984
|
-
set$
|
|
4985
|
+
set$6(uid, editor, newEditor);
|
|
4985
4986
|
const newCompletionWidget = await loadContent$2(uid, completionWidget.newState);
|
|
4986
4987
|
const FocusEditorCompletions = EditorCompletion;
|
|
4987
4988
|
await setAdditionalFocus(FocusEditorCompletions);
|
|
@@ -5351,9 +5352,11 @@ const handleToggleReplaceFocus = async state => {
|
|
|
5351
5352
|
focus: FocusFindWidgetToggleReplace
|
|
5352
5353
|
};
|
|
5353
5354
|
};
|
|
5354
|
-
const handleReplaceInput = state => {
|
|
5355
|
-
|
|
5356
|
-
|
|
5355
|
+
const handleReplaceInput = (state, value) => {
|
|
5356
|
+
return {
|
|
5357
|
+
...state,
|
|
5358
|
+
replacement: value
|
|
5359
|
+
};
|
|
5357
5360
|
};
|
|
5358
5361
|
|
|
5359
5362
|
const getFindWidgetPosition = editor => {
|
|
@@ -6145,10 +6148,10 @@ const state$1 = {
|
|
|
6145
6148
|
const has = languageId => {
|
|
6146
6149
|
return languageId in state$1.tokenizers;
|
|
6147
6150
|
};
|
|
6148
|
-
const set$
|
|
6151
|
+
const set$2 = (languageId, tokenizer) => {
|
|
6149
6152
|
state$1.tokenizers[languageId] = tokenizer;
|
|
6150
6153
|
};
|
|
6151
|
-
const get$
|
|
6154
|
+
const get$2 = languageId => {
|
|
6152
6155
|
return state$1.tokenizers[languageId];
|
|
6153
6156
|
};
|
|
6154
6157
|
const isPending = languageId => {
|
|
@@ -6169,10 +6172,10 @@ const {
|
|
|
6169
6172
|
} = createRpc(SyntaxHighlightingWorker);
|
|
6170
6173
|
|
|
6171
6174
|
const tokenMaps = Object.create(null);
|
|
6172
|
-
const set$
|
|
6175
|
+
const set$1 = (languageId, tokenMap) => {
|
|
6173
6176
|
tokenMaps[languageId] = tokenMap;
|
|
6174
6177
|
};
|
|
6175
|
-
const get$
|
|
6178
|
+
const get$1 = languageId => {
|
|
6176
6179
|
return tokenMaps[languageId] || {};
|
|
6177
6180
|
};
|
|
6178
6181
|
|
|
@@ -6183,7 +6186,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
6183
6186
|
}
|
|
6184
6187
|
if (getEnabled$1()) {
|
|
6185
6188
|
const tokenMap = await invoke$1('Tokenizer.load', languageId, tokenizePath);
|
|
6186
|
-
set$
|
|
6189
|
+
set$1(languageId, tokenMap);
|
|
6187
6190
|
return;
|
|
6188
6191
|
}
|
|
6189
6192
|
try {
|
|
@@ -6199,8 +6202,8 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
6199
6202
|
console.warn(`tokenizer.TokenMap should be an object in "${tokenizePath}"`);
|
|
6200
6203
|
return;
|
|
6201
6204
|
}
|
|
6202
|
-
set$
|
|
6203
|
-
set$
|
|
6205
|
+
set$1(languageId, tokenizer.TokenMap);
|
|
6206
|
+
set$2(languageId, tokenizer);
|
|
6204
6207
|
} catch (error) {
|
|
6205
6208
|
// TODO better error handling
|
|
6206
6209
|
console.error(error);
|
|
@@ -6209,7 +6212,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
6209
6212
|
};
|
|
6210
6213
|
const getTokenizer = languageId => {
|
|
6211
6214
|
if (has(languageId)) {
|
|
6212
|
-
return get$
|
|
6215
|
+
return get$2(languageId);
|
|
6213
6216
|
}
|
|
6214
6217
|
if (isPending(languageId)) {
|
|
6215
6218
|
return TokenizePlainText;
|
|
@@ -6218,10 +6221,10 @@ const getTokenizer = languageId => {
|
|
|
6218
6221
|
};
|
|
6219
6222
|
|
|
6220
6223
|
const tokenizers = Object.create(null);
|
|
6221
|
-
const set
|
|
6224
|
+
const set = (id, value) => {
|
|
6222
6225
|
tokenizers[id] = value;
|
|
6223
6226
|
};
|
|
6224
|
-
const get
|
|
6227
|
+
const get = id => {
|
|
6225
6228
|
return tokenizers[id] || TokenizePlainText;
|
|
6226
6229
|
};
|
|
6227
6230
|
|
|
@@ -6238,7 +6241,7 @@ const setLanguageId = async (editor, languageId, tokenizePath) => {
|
|
|
6238
6241
|
await loadTokenizer(languageId, tokenizePath);
|
|
6239
6242
|
const tokenizer = getTokenizer(languageId);
|
|
6240
6243
|
const newTokenizerId = tokenizerId + 1;
|
|
6241
|
-
set
|
|
6244
|
+
set(newTokenizerId, tokenizer);
|
|
6242
6245
|
const latest = getEditor(editor.uid);
|
|
6243
6246
|
if (!latest) {
|
|
6244
6247
|
return editor;
|
|
@@ -6497,7 +6500,7 @@ const getHoverPositionXy = (editor, rowIndex, wordStart, documentationHeight) =>
|
|
|
6497
6500
|
};
|
|
6498
6501
|
const getEditorHoverInfo = async (editorUid, position) => {
|
|
6499
6502
|
number$1(editorUid);
|
|
6500
|
-
const instance = get$
|
|
6503
|
+
const instance = get$6(editorUid);
|
|
6501
6504
|
const editor = instance.newState;
|
|
6502
6505
|
const {
|
|
6503
6506
|
selections
|
|
@@ -7511,7 +7514,8 @@ const create = () => {
|
|
|
7511
7514
|
x: 0,
|
|
7512
7515
|
y: 0,
|
|
7513
7516
|
width: 0,
|
|
7514
|
-
height: 0
|
|
7517
|
+
height: 0,
|
|
7518
|
+
borderSize: 1
|
|
7515
7519
|
},
|
|
7516
7520
|
newState: {
|
|
7517
7521
|
content: '',
|
|
@@ -7519,7 +7523,8 @@ const create = () => {
|
|
|
7519
7523
|
x: 0,
|
|
7520
7524
|
y: 0,
|
|
7521
7525
|
width: 0,
|
|
7522
|
-
height: 0
|
|
7526
|
+
height: 0,
|
|
7527
|
+
borderSize: 1
|
|
7523
7528
|
}
|
|
7524
7529
|
};
|
|
7525
7530
|
return completionWidget;
|
|
@@ -7869,6 +7874,34 @@ const renderHover = (oldState, newState) => {
|
|
|
7869
7874
|
return commands;
|
|
7870
7875
|
};
|
|
7871
7876
|
|
|
7877
|
+
const replaceTextOccurrences = (editor, matches, oldValue, newValue) => {
|
|
7878
|
+
const ranges = [];
|
|
7879
|
+
const oldValueLength = oldValue.length;
|
|
7880
|
+
for (let i = 0; i < matches.length; i += 2) {
|
|
7881
|
+
const startRowIndex = matches[i];
|
|
7882
|
+
const startColumnIndex = matches[i + 1];
|
|
7883
|
+
const endRowIndex = matches[i];
|
|
7884
|
+
const endColumnIndex = matches[i] + oldValueLength;
|
|
7885
|
+
ranges.push(startRowIndex, startColumnIndex, endRowIndex, endColumnIndex);
|
|
7886
|
+
}
|
|
7887
|
+
return replaceRange(editor, ranges, [newValue], ReplaceAll$2);
|
|
7888
|
+
};
|
|
7889
|
+
|
|
7890
|
+
const replaceAll$1 = async editor => {
|
|
7891
|
+
const state = getFindState(editor);
|
|
7892
|
+
if (!state) {
|
|
7893
|
+
return editor;
|
|
7894
|
+
}
|
|
7895
|
+
const {
|
|
7896
|
+
matches,
|
|
7897
|
+
value,
|
|
7898
|
+
replacement
|
|
7899
|
+
} = state;
|
|
7900
|
+
const edits = replaceTextOccurrences(editor, matches, value, replacement);
|
|
7901
|
+
const newEditor = await applyEdit(editor, edits);
|
|
7902
|
+
return newEditor;
|
|
7903
|
+
};
|
|
7904
|
+
|
|
7872
7905
|
const pending = Object.create(null);
|
|
7873
7906
|
const loaded = Object.create(null);
|
|
7874
7907
|
const setPending = (id, promise) => {
|
|
@@ -8188,7 +8221,7 @@ const getTokensViewport = (editor, startLineIndex, endLineIndex) => {
|
|
|
8188
8221
|
lines,
|
|
8189
8222
|
languageId
|
|
8190
8223
|
} = editor;
|
|
8191
|
-
const tokenizer = get
|
|
8224
|
+
const tokenizer = get(tokenizerId);
|
|
8192
8225
|
const {
|
|
8193
8226
|
hasArrayReturn,
|
|
8194
8227
|
tokenizeLine,
|
|
@@ -8452,7 +8485,7 @@ const getLineInfosViewport = (editor, tokens, embeddedResults, minLineY, maxLine
|
|
|
8452
8485
|
decorations,
|
|
8453
8486
|
languageId
|
|
8454
8487
|
} = editor;
|
|
8455
|
-
const tokenMap = get$
|
|
8488
|
+
const tokenMap = get$1(languageId);
|
|
8456
8489
|
let offset = minLineOffset;
|
|
8457
8490
|
const tabSize = 2;
|
|
8458
8491
|
for (let i = minLineY; i < maxLineY; i++) {
|
|
@@ -8637,30 +8670,22 @@ const getSelectionsVirtualDom = selections => {
|
|
|
8637
8670
|
return dom;
|
|
8638
8671
|
};
|
|
8639
8672
|
|
|
8640
|
-
const map = Object.create(null);
|
|
8641
|
-
const set = (id, widget) => {
|
|
8642
|
-
map[id] = widget;
|
|
8643
|
-
};
|
|
8644
|
-
const get = id => {
|
|
8645
|
-
return map[id];
|
|
8646
|
-
};
|
|
8647
|
-
|
|
8648
8673
|
const addWidget$1 = widget => {
|
|
8649
|
-
const module = get(widget.id);
|
|
8674
|
+
const module = get$7(widget.id);
|
|
8650
8675
|
if (!module) {
|
|
8651
8676
|
throw new Error('unsupported widget');
|
|
8652
8677
|
}
|
|
8653
8678
|
return module.add(widget);
|
|
8654
8679
|
};
|
|
8655
8680
|
const renderWidget = widget => {
|
|
8656
|
-
const module = get(widget.id);
|
|
8681
|
+
const module = get$7(widget.id);
|
|
8657
8682
|
if (!module) {
|
|
8658
8683
|
throw new Error(`unsupported widget`);
|
|
8659
8684
|
}
|
|
8660
8685
|
return module.render(widget);
|
|
8661
8686
|
};
|
|
8662
8687
|
const removeWidget$1 = widget => {
|
|
8663
|
-
const module = get(widget.id);
|
|
8688
|
+
const module = get$7(widget.id);
|
|
8664
8689
|
if (!module) {
|
|
8665
8690
|
throw new Error(`unsupported widget`);
|
|
8666
8691
|
}
|
|
@@ -8821,7 +8846,7 @@ const renderWidgets = {
|
|
|
8821
8846
|
};
|
|
8822
8847
|
const render$b = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
|
|
8823
8848
|
const renderEditor = async id => {
|
|
8824
|
-
const instance = get$
|
|
8849
|
+
const instance = get$6(id);
|
|
8825
8850
|
if (!instance) {
|
|
8826
8851
|
return [];
|
|
8827
8852
|
}
|
|
@@ -8830,7 +8855,7 @@ const renderEditor = async id => {
|
|
|
8830
8855
|
newState
|
|
8831
8856
|
} = instance;
|
|
8832
8857
|
const commands = [];
|
|
8833
|
-
set$
|
|
8858
|
+
set$6(id, newState, newState);
|
|
8834
8859
|
for (const item of render$b) {
|
|
8835
8860
|
if (!item.isEqual(oldState, newState)) {
|
|
8836
8861
|
const result = await item.apply(oldState, newState);
|
|
@@ -8911,9 +8936,9 @@ const widgetCommands = {
|
|
|
8911
8936
|
// TODO wrap commands globally, not per editor
|
|
8912
8937
|
// TODO only store editor state in editor worker, not in renderer worker also
|
|
8913
8938
|
const wrapCommand = fn => async (editorUid, ...args) => {
|
|
8914
|
-
const oldInstance = get$
|
|
8939
|
+
const oldInstance = get$6(editorUid);
|
|
8915
8940
|
const newEditor = await fn(oldInstance.newState, ...args);
|
|
8916
|
-
set$
|
|
8941
|
+
set$6(editorUid, oldInstance.newState, newEditor);
|
|
8917
8942
|
// TODO if possible, rendering should be sync
|
|
8918
8943
|
const commands = await renderEditor(editorUid);
|
|
8919
8944
|
newEditor.commands = commands;
|
|
@@ -9070,8 +9095,8 @@ const commandMap = {
|
|
|
9070
9095
|
'EditorCompletion.focusPrevious': focusPrevious,
|
|
9071
9096
|
'EditorCompletion.handleEditorBlur': handleEditorBlur,
|
|
9072
9097
|
'EditorCompletion.handleEditorClick': handleEditorClick,
|
|
9073
|
-
'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$
|
|
9074
|
-
'EditorCompletion.handleEditorType': handleEditorType$
|
|
9098
|
+
'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$2,
|
|
9099
|
+
'EditorCompletion.handleEditorType': handleEditorType$2,
|
|
9075
9100
|
'EditorCompletion.handleWheel': handelWheel,
|
|
9076
9101
|
'EditorCompletion.loadContent': loadContent$2,
|
|
9077
9102
|
'EditorCompletion.openDetails': openDetails,
|
|
@@ -9101,6 +9126,7 @@ const commandMap = {
|
|
|
9101
9126
|
'FindWidget.handleToggleReplaceFocus': handleToggleReplaceFocus,
|
|
9102
9127
|
'FindWidget.loadContent': loadContent$1,
|
|
9103
9128
|
'FindWidget.toggleReplace': toggleReplace,
|
|
9129
|
+
'FindWidget.replaceAll': replaceAll$1,
|
|
9104
9130
|
'Font.ensure': ensure,
|
|
9105
9131
|
'Hover.getHoverInfo': getEditorHoverInfo,
|
|
9106
9132
|
'Hover.handleSashPointerDown': handleSashPointerDown,
|
|
@@ -9112,430 +9138,74 @@ const commandMap = {
|
|
|
9112
9138
|
};
|
|
9113
9139
|
wrapCommands(commandMap);
|
|
9114
9140
|
|
|
9115
|
-
const
|
|
9116
|
-
const
|
|
9117
|
-
const
|
|
9118
|
-
const
|
|
9119
|
-
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
className: FileIcon,
|
|
9124
|
-
src: icon,
|
|
9125
|
-
role: None,
|
|
9126
|
-
childCount: 0
|
|
9127
|
-
};
|
|
9128
|
-
};
|
|
9129
|
-
|
|
9130
|
-
const getIconDom = (fileIcon, symbolName) => {
|
|
9131
|
-
if (fileIcon) {
|
|
9132
|
-
return getFileIconVirtualDom(fileIcon);
|
|
9141
|
+
const MessagePort$1 = 1;
|
|
9142
|
+
const ModuleWorker = 2;
|
|
9143
|
+
const ReferencePort = 3;
|
|
9144
|
+
const ModuleWorkerAndMessagePort = 8;
|
|
9145
|
+
const Auto = () => {
|
|
9146
|
+
// @ts-ignore
|
|
9147
|
+
if (globalThis.acceptPort) {
|
|
9148
|
+
return MessagePort$1;
|
|
9133
9149
|
}
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9150
|
+
// @ts-ignore
|
|
9151
|
+
if (globalThis.acceptReferencePort) {
|
|
9152
|
+
return ReferencePort;
|
|
9153
|
+
}
|
|
9154
|
+
return ModuleWorkerAndMessagePort;
|
|
9139
9155
|
};
|
|
9140
9156
|
|
|
9141
|
-
const
|
|
9142
|
-
|
|
9143
|
-
className: Label,
|
|
9144
|
-
childCount: 1
|
|
9145
|
-
};
|
|
9146
|
-
const completionHighlight = {
|
|
9147
|
-
type: Span,
|
|
9148
|
-
className: EditorCompletionItemHighlight,
|
|
9149
|
-
childCount: 1
|
|
9157
|
+
const getData$1 = event => {
|
|
9158
|
+
return event.data;
|
|
9150
9159
|
};
|
|
9151
|
-
const
|
|
9152
|
-
if (
|
|
9153
|
-
return
|
|
9160
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
9161
|
+
if (!value) {
|
|
9162
|
+
return;
|
|
9154
9163
|
}
|
|
9155
|
-
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
|
|
9159
|
-
|
|
9160
|
-
|
|
9161
|
-
|
|
9162
|
-
let position = 0;
|
|
9163
|
-
for (let i = 0; i < highlights.length; i += 2) {
|
|
9164
|
-
const highlightStart = highlights[i];
|
|
9165
|
-
const highlightEnd = highlights[i + 1];
|
|
9166
|
-
if (position < highlightStart) {
|
|
9167
|
-
const beforeText = label.slice(position, highlightStart);
|
|
9168
|
-
labelDom.childCount++;
|
|
9169
|
-
dom.push(text(beforeText));
|
|
9164
|
+
if (isTransferrable(value)) {
|
|
9165
|
+
transferrables.push(value);
|
|
9166
|
+
return;
|
|
9167
|
+
}
|
|
9168
|
+
if (Array.isArray(value)) {
|
|
9169
|
+
for (const item of value) {
|
|
9170
|
+
walkValue(item, transferrables, isTransferrable);
|
|
9170
9171
|
}
|
|
9171
|
-
|
|
9172
|
-
labelDom.childCount++;
|
|
9173
|
-
dom.push(completionHighlight, text(highlightText));
|
|
9174
|
-
position = highlightEnd;
|
|
9172
|
+
return;
|
|
9175
9173
|
}
|
|
9176
|
-
if (
|
|
9177
|
-
const
|
|
9178
|
-
|
|
9179
|
-
|
|
9174
|
+
if (typeof value === 'object') {
|
|
9175
|
+
for (const property of Object.values(value)) {
|
|
9176
|
+
walkValue(property, transferrables, isTransferrable);
|
|
9177
|
+
}
|
|
9178
|
+
return;
|
|
9180
9179
|
}
|
|
9181
|
-
return dom;
|
|
9182
9180
|
};
|
|
9183
|
-
|
|
9184
|
-
|
|
9185
|
-
const {
|
|
9186
|
-
top,
|
|
9187
|
-
label,
|
|
9188
|
-
symbolName,
|
|
9189
|
-
highlights,
|
|
9190
|
-
focused,
|
|
9191
|
-
deprecated,
|
|
9192
|
-
fileIcon
|
|
9193
|
-
} = visibleItem;
|
|
9194
|
-
let className = EditorCompletionItem;
|
|
9195
|
-
if (focused) {
|
|
9196
|
-
className += ' ' + EditorCompletionItemFocused;
|
|
9197
|
-
}
|
|
9198
|
-
if (deprecated) {
|
|
9199
|
-
className += ' ' + EditorCompletionItemDeprecated;
|
|
9200
|
-
}
|
|
9201
|
-
return [{
|
|
9202
|
-
type: Div,
|
|
9203
|
-
role: Option,
|
|
9204
|
-
className,
|
|
9205
|
-
top,
|
|
9206
|
-
childCount: 2
|
|
9207
|
-
}, getIconDom(fileIcon, symbolName), ...getHighlightedLabelDom(label, highlights)];
|
|
9181
|
+
const isMessagePort = value => {
|
|
9182
|
+
return value && value instanceof MessagePort;
|
|
9208
9183
|
};
|
|
9209
|
-
|
|
9210
|
-
|
|
9211
|
-
if (visibleItems.length === 0) {
|
|
9212
|
-
return [{
|
|
9213
|
-
type: Div,
|
|
9214
|
-
childCount: 1
|
|
9215
|
-
}, text(noResults$1())];
|
|
9216
|
-
}
|
|
9217
|
-
const root = {
|
|
9218
|
-
type: Div,
|
|
9219
|
-
childCount: visibleItems.length
|
|
9220
|
-
};
|
|
9221
|
-
const dom = [root, ...visibleItems.flatMap(getCompletionItemVirtualDom)];
|
|
9222
|
-
return dom;
|
|
9184
|
+
const isMessagePortMain = value => {
|
|
9185
|
+
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
9223
9186
|
};
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
const Value = 2;
|
|
9227
|
-
const Function = 3;
|
|
9228
|
-
const Variable = 4;
|
|
9229
|
-
const Keyword = 5;
|
|
9230
|
-
const Folder = 6;
|
|
9231
|
-
const File = 7;
|
|
9232
|
-
const Field = 8;
|
|
9233
|
-
|
|
9234
|
-
const SymbolProperty = 'SymbolProperty';
|
|
9235
|
-
const SymbolValue = 'SymbolValue';
|
|
9236
|
-
const SymbolFunction = 'SymbolFunction';
|
|
9237
|
-
const SymbolVariable = 'SymbolVariable';
|
|
9238
|
-
const SymbolKeyword = 'SymbolKeyword';
|
|
9239
|
-
const SymbolDefault = 'SymbolDefault';
|
|
9240
|
-
const SymbolField = 'SymbolField';
|
|
9241
|
-
const SymbolNone = '';
|
|
9242
|
-
|
|
9243
|
-
const getSymbolName = kind => {
|
|
9244
|
-
switch (kind) {
|
|
9245
|
-
case Property:
|
|
9246
|
-
return SymbolProperty;
|
|
9247
|
-
case Value:
|
|
9248
|
-
return SymbolValue;
|
|
9249
|
-
case Function:
|
|
9250
|
-
return SymbolFunction;
|
|
9251
|
-
case Variable:
|
|
9252
|
-
return SymbolVariable;
|
|
9253
|
-
case Keyword:
|
|
9254
|
-
return SymbolKeyword;
|
|
9255
|
-
case Field:
|
|
9256
|
-
return SymbolField;
|
|
9257
|
-
case File:
|
|
9258
|
-
return SymbolNone;
|
|
9259
|
-
default:
|
|
9260
|
-
return SymbolDefault;
|
|
9261
|
-
}
|
|
9187
|
+
const isOffscreenCanvas = value => {
|
|
9188
|
+
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
9262
9189
|
};
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
const getCompletionFileIcon = kind => {
|
|
9266
|
-
switch (kind) {
|
|
9267
|
-
case File:
|
|
9268
|
-
return EmptyString$1;
|
|
9269
|
-
case Folder:
|
|
9270
|
-
return EmptyString$1;
|
|
9271
|
-
default:
|
|
9272
|
-
return EmptyString$1;
|
|
9273
|
-
}
|
|
9190
|
+
const isInstanceOf = (value, constructorName) => {
|
|
9191
|
+
return value?.constructor?.name === constructorName;
|
|
9274
9192
|
};
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
const {
|
|
9278
|
-
matches
|
|
9279
|
-
} = item;
|
|
9280
|
-
return matches.slice(1);
|
|
9193
|
+
const isSocket = value => {
|
|
9194
|
+
return isInstanceOf(value, 'Socket');
|
|
9281
9195
|
};
|
|
9282
|
-
|
|
9283
|
-
const
|
|
9284
|
-
|
|
9196
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
9197
|
+
const isTransferrable = value => {
|
|
9198
|
+
for (const fn of transferrables) {
|
|
9199
|
+
if (fn(value)) {
|
|
9200
|
+
return true;
|
|
9201
|
+
}
|
|
9202
|
+
}
|
|
9203
|
+
return false;
|
|
9285
9204
|
};
|
|
9286
|
-
const
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
top: i * itemHeight,
|
|
9291
|
-
highlights: getHighlights(item),
|
|
9292
|
-
focused: i === focusedIndex,
|
|
9293
|
-
deprecated: item.flags & Deprecated,
|
|
9294
|
-
fileIcon: getCompletionFileIcon(item.kind)
|
|
9295
|
-
};
|
|
9296
|
-
};
|
|
9297
|
-
|
|
9298
|
-
const getVisibleItems = (filteredItems, itemHeight, leadingWord, minLineY, maxLineY, focusedIndex) => {
|
|
9299
|
-
const visibleItems = [];
|
|
9300
|
-
for (let i = minLineY; i < maxLineY; i++) {
|
|
9301
|
-
const filteredItem = filteredItems[i];
|
|
9302
|
-
visibleItems.push(getVisibleIem(filteredItem, itemHeight, leadingWord, i, focusedIndex));
|
|
9303
|
-
}
|
|
9304
|
-
return visibleItems;
|
|
9305
|
-
};
|
|
9306
|
-
|
|
9307
|
-
const renderItems = {
|
|
9308
|
-
isEqual(oldState, newState) {
|
|
9309
|
-
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex;
|
|
9310
|
-
},
|
|
9311
|
-
apply(oldState, newState) {
|
|
9312
|
-
const visibleItems = getVisibleItems(newState.items, newState.itemHeight, newState.leadingWord, newState.minLineY, newState.maxLineY, newState.focusedIndex);
|
|
9313
|
-
const dom = getCompletionItemsVirtualDom(visibleItems);
|
|
9314
|
-
return ['setDom', dom];
|
|
9315
|
-
}
|
|
9316
|
-
};
|
|
9317
|
-
const renderBounds$4 = {
|
|
9318
|
-
isEqual(oldState, newState) {
|
|
9319
|
-
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.x === newState.x && oldState.y === newState.y;
|
|
9320
|
-
},
|
|
9321
|
-
apply(oldState, newState) {
|
|
9322
|
-
const {
|
|
9323
|
-
x,
|
|
9324
|
-
y,
|
|
9325
|
-
width,
|
|
9326
|
-
height
|
|
9327
|
-
} = newState;
|
|
9328
|
-
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
9329
|
-
}
|
|
9330
|
-
};
|
|
9331
|
-
const renderHeight = {
|
|
9332
|
-
isEqual(oldState, newState) {
|
|
9333
|
-
return oldState.items.length === newState.items.length;
|
|
9334
|
-
},
|
|
9335
|
-
apply(oldState, newState) {
|
|
9336
|
-
const {
|
|
9337
|
-
itemHeight
|
|
9338
|
-
} = newState;
|
|
9339
|
-
const contentHeight = newState.items.length * itemHeight;
|
|
9340
|
-
return [/* method */SetContentHeight, /* contentHeight */contentHeight];
|
|
9341
|
-
}
|
|
9342
|
-
};
|
|
9343
|
-
const renderNegativeMargin = {
|
|
9344
|
-
isEqual(oldState, newState) {
|
|
9345
|
-
return oldState.deltaY === newState.deltaY;
|
|
9346
|
-
},
|
|
9347
|
-
apply(oldState, newState) {
|
|
9348
|
-
return [/* method */SetNegativeMargin, /* negativeMargin */-newState.deltaY];
|
|
9349
|
-
}
|
|
9350
|
-
};
|
|
9351
|
-
const renderScrollBar = {
|
|
9352
|
-
isEqual(oldState, newState) {
|
|
9353
|
-
return oldState.negativeMargin === newState.negativeMargin && oldState.deltaY === newState.deltaY && oldState.height === newState.height && oldState.finalDeltaY === newState.finalDeltaY && oldState.items.length === newState.items.length;
|
|
9354
|
-
},
|
|
9355
|
-
apply(oldState, newState) {
|
|
9356
|
-
const total = newState.items.length;
|
|
9357
|
-
const contentHeight = total * newState.itemHeight;
|
|
9358
|
-
const scrollBarHeight = getScrollBarSize(newState.height, contentHeight, newState.minimumSliderSize);
|
|
9359
|
-
const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, scrollBarHeight);
|
|
9360
|
-
return [/* method */SetScrollBar, /* scrollBarY */scrollBarY, /* scrollBarHeight */scrollBarHeight];
|
|
9361
|
-
}
|
|
9362
|
-
};
|
|
9363
|
-
const render$a = [renderItems, renderBounds$4, renderHeight, renderNegativeMargin, renderScrollBar];
|
|
9364
|
-
const renderCompletion = (oldState, newState) => {
|
|
9365
|
-
const commands = [];
|
|
9366
|
-
for (const item of render$a) {
|
|
9367
|
-
if (!item.isEqual(oldState, newState)) {
|
|
9368
|
-
commands.push(item.apply(oldState, newState));
|
|
9369
|
-
}
|
|
9370
|
-
}
|
|
9371
|
-
return commands;
|
|
9372
|
-
};
|
|
9373
|
-
|
|
9374
|
-
const removeWidget = widget => {
|
|
9375
|
-
// @ts-ignore
|
|
9376
|
-
return [['Viewlet.send', widget.newState.uid, 'dispose']];
|
|
9377
|
-
};
|
|
9378
|
-
|
|
9379
|
-
const render$9 = widget => {
|
|
9380
|
-
const commands = renderCompletion(widget.oldState, widget.newState);
|
|
9381
|
-
const wrappedCommands = [];
|
|
9382
|
-
const uid = widget.newState.uid;
|
|
9383
|
-
for (const command of commands) {
|
|
9384
|
-
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
9385
|
-
}
|
|
9386
|
-
return wrappedCommands;
|
|
9387
|
-
};
|
|
9388
|
-
const add$5 = widget => {
|
|
9389
|
-
const commands = render$9(widget);
|
|
9390
|
-
const id = 'EditorCompletion';
|
|
9391
|
-
// TODO how to generate a unique integer id
|
|
9392
|
-
// that doesn't collide with ids created in renderer worker?
|
|
9393
|
-
const uid = widget.newState.uid;
|
|
9394
|
-
const allCommands = [];
|
|
9395
|
-
allCommands.push(['Viewlet.create', id, uid]);
|
|
9396
|
-
allCommands.push(...commands);
|
|
9397
|
-
return allCommands;
|
|
9398
|
-
};
|
|
9399
|
-
const remove$5 = removeWidget;
|
|
9400
|
-
const handleEditorType = (editor, state) => {
|
|
9401
|
-
const {
|
|
9402
|
-
unfilteredItems,
|
|
9403
|
-
itemHeight,
|
|
9404
|
-
maxHeight
|
|
9405
|
-
} = state;
|
|
9406
|
-
const {
|
|
9407
|
-
selections
|
|
9408
|
-
} = editor;
|
|
9409
|
-
const rowIndex = selections[0];
|
|
9410
|
-
const columnIndex = selections[1];
|
|
9411
|
-
const x$1 = x(editor, rowIndex, columnIndex);
|
|
9412
|
-
const y$1 = y(editor, rowIndex);
|
|
9413
|
-
const wordAtOffset = getWordBefore(editor, rowIndex, columnIndex);
|
|
9414
|
-
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
9415
|
-
const newMinLineY = 0;
|
|
9416
|
-
const newMaxLineY = Math.min(items.length, 8);
|
|
9417
|
-
const height = getListHeight(items.length, itemHeight, maxHeight);
|
|
9418
|
-
const finalDeltaY = items.length * itemHeight - height;
|
|
9419
|
-
return {
|
|
9420
|
-
...state,
|
|
9421
|
-
items,
|
|
9422
|
-
x: x$1,
|
|
9423
|
-
y: y$1,
|
|
9424
|
-
minLineY: newMinLineY,
|
|
9425
|
-
maxLineY: newMaxLineY,
|
|
9426
|
-
leadingWord: wordAtOffset,
|
|
9427
|
-
height,
|
|
9428
|
-
finalDeltaY
|
|
9429
|
-
};
|
|
9430
|
-
};
|
|
9431
|
-
const handleEditorDeleteLeft = (editor, state) => {
|
|
9432
|
-
const {
|
|
9433
|
-
unfilteredItems,
|
|
9434
|
-
itemHeight,
|
|
9435
|
-
maxHeight
|
|
9436
|
-
} = state;
|
|
9437
|
-
const {
|
|
9438
|
-
selections
|
|
9439
|
-
} = editor;
|
|
9440
|
-
const rowIndex = selections[0];
|
|
9441
|
-
const columnIndex = selections[1];
|
|
9442
|
-
const x$1 = x(editor, rowIndex, columnIndex);
|
|
9443
|
-
const y$1 = y(editor, rowIndex);
|
|
9444
|
-
const wordAtOffset = getWordBefore(editor, rowIndex, columnIndex);
|
|
9445
|
-
if (!wordAtOffset) {
|
|
9446
|
-
return undefined;
|
|
9447
|
-
}
|
|
9448
|
-
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
9449
|
-
const newMaxLineY = Math.min(items.length, 8);
|
|
9450
|
-
const height = getListHeight(items.length, itemHeight, maxHeight);
|
|
9451
|
-
return {
|
|
9452
|
-
...state,
|
|
9453
|
-
items,
|
|
9454
|
-
x: x$1,
|
|
9455
|
-
y: y$1,
|
|
9456
|
-
maxLineY: newMaxLineY,
|
|
9457
|
-
leadingWord: wordAtOffset,
|
|
9458
|
-
height
|
|
9459
|
-
};
|
|
9460
|
-
};
|
|
9461
|
-
|
|
9462
|
-
const EditorCompletionWidget = {
|
|
9463
|
-
__proto__: null,
|
|
9464
|
-
add: add$5,
|
|
9465
|
-
handleEditorDeleteLeft,
|
|
9466
|
-
handleEditorType,
|
|
9467
|
-
remove: remove$5,
|
|
9468
|
-
render: render$9
|
|
9469
|
-
};
|
|
9470
|
-
|
|
9471
|
-
const MessagePort$1 = 1;
|
|
9472
|
-
const ModuleWorker = 2;
|
|
9473
|
-
const ReferencePort = 3;
|
|
9474
|
-
const ModuleWorkerAndMessagePort = 8;
|
|
9475
|
-
const Auto = () => {
|
|
9476
|
-
// @ts-ignore
|
|
9477
|
-
if (globalThis.acceptPort) {
|
|
9478
|
-
return MessagePort$1;
|
|
9479
|
-
}
|
|
9480
|
-
// @ts-ignore
|
|
9481
|
-
if (globalThis.acceptReferencePort) {
|
|
9482
|
-
return ReferencePort;
|
|
9483
|
-
}
|
|
9484
|
-
return ModuleWorkerAndMessagePort;
|
|
9485
|
-
};
|
|
9486
|
-
|
|
9487
|
-
const getData$1 = event => {
|
|
9488
|
-
return event.data;
|
|
9489
|
-
};
|
|
9490
|
-
const walkValue = (value, transferrables, isTransferrable) => {
|
|
9491
|
-
if (!value) {
|
|
9492
|
-
return;
|
|
9493
|
-
}
|
|
9494
|
-
if (isTransferrable(value)) {
|
|
9495
|
-
transferrables.push(value);
|
|
9496
|
-
return;
|
|
9497
|
-
}
|
|
9498
|
-
if (Array.isArray(value)) {
|
|
9499
|
-
for (const item of value) {
|
|
9500
|
-
walkValue(item, transferrables, isTransferrable);
|
|
9501
|
-
}
|
|
9502
|
-
return;
|
|
9503
|
-
}
|
|
9504
|
-
if (typeof value === 'object') {
|
|
9505
|
-
for (const property of Object.values(value)) {
|
|
9506
|
-
walkValue(property, transferrables, isTransferrable);
|
|
9507
|
-
}
|
|
9508
|
-
return;
|
|
9509
|
-
}
|
|
9510
|
-
};
|
|
9511
|
-
const isMessagePort = value => {
|
|
9512
|
-
return value && value instanceof MessagePort;
|
|
9513
|
-
};
|
|
9514
|
-
const isMessagePortMain = value => {
|
|
9515
|
-
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
9516
|
-
};
|
|
9517
|
-
const isOffscreenCanvas = value => {
|
|
9518
|
-
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
9519
|
-
};
|
|
9520
|
-
const isInstanceOf = (value, constructorName) => {
|
|
9521
|
-
return value?.constructor?.name === constructorName;
|
|
9522
|
-
};
|
|
9523
|
-
const isSocket = value => {
|
|
9524
|
-
return isInstanceOf(value, 'Socket');
|
|
9525
|
-
};
|
|
9526
|
-
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
9527
|
-
const isTransferrable = value => {
|
|
9528
|
-
for (const fn of transferrables) {
|
|
9529
|
-
if (fn(value)) {
|
|
9530
|
-
return true;
|
|
9531
|
-
}
|
|
9532
|
-
}
|
|
9533
|
-
return false;
|
|
9534
|
-
};
|
|
9535
|
-
const getTransferrables = value => {
|
|
9536
|
-
const transferrables = [];
|
|
9537
|
-
walkValue(value, transferrables, isTransferrable);
|
|
9538
|
-
return transferrables;
|
|
9205
|
+
const getTransferrables = value => {
|
|
9206
|
+
const transferrables = [];
|
|
9207
|
+
walkValue(value, transferrables, isTransferrable);
|
|
9208
|
+
return transferrables;
|
|
9539
9209
|
};
|
|
9540
9210
|
const attachEvents = that => {
|
|
9541
9211
|
const handleMessage = (...args) => {
|
|
@@ -9944,8 +9614,7 @@ const listen$1 = async ({
|
|
|
9944
9614
|
};
|
|
9945
9615
|
|
|
9946
9616
|
const listen = async () => {
|
|
9947
|
-
register
|
|
9948
|
-
register(Completion, EditorCompletionWidget);
|
|
9617
|
+
register(commandMap);
|
|
9949
9618
|
const ipc = await listen$1({
|
|
9950
9619
|
method: Auto()
|
|
9951
9620
|
});
|
|
@@ -10039,7 +9708,7 @@ const renderContent$1 = {
|
|
|
10039
9708
|
return ['Viewlet.setDom2', newState.uid, dom];
|
|
10040
9709
|
}
|
|
10041
9710
|
};
|
|
10042
|
-
const renderBounds$
|
|
9711
|
+
const renderBounds$4 = {
|
|
10043
9712
|
isEqual(oldState, newState) {
|
|
10044
9713
|
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
10045
9714
|
},
|
|
@@ -10053,10 +9722,10 @@ const renderBounds$3 = {
|
|
|
10053
9722
|
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
10054
9723
|
}
|
|
10055
9724
|
};
|
|
10056
|
-
const render$
|
|
9725
|
+
const render$a = [renderContent$1, renderBounds$4, renderColor, renderOffsetX];
|
|
10057
9726
|
const renderFull$1 = (oldState, newState) => {
|
|
10058
9727
|
const commands = [];
|
|
10059
|
-
for (const item of render$
|
|
9728
|
+
for (const item of render$a) {
|
|
10060
9729
|
if (!item.isEqual(oldState, newState)) {
|
|
10061
9730
|
commands.push(item.apply(oldState, newState));
|
|
10062
9731
|
}
|
|
@@ -10064,7 +9733,12 @@ const renderFull$1 = (oldState, newState) => {
|
|
|
10064
9733
|
return commands;
|
|
10065
9734
|
};
|
|
10066
9735
|
|
|
10067
|
-
const
|
|
9736
|
+
const removeWidget = widget => {
|
|
9737
|
+
// @ts-ignore
|
|
9738
|
+
return [['Viewlet.send', widget.newState.uid, 'dispose']];
|
|
9739
|
+
};
|
|
9740
|
+
|
|
9741
|
+
const render$9 = widget => {
|
|
10068
9742
|
const commands = renderFull$1(widget.oldState, widget.newState);
|
|
10069
9743
|
const wrappedCommands = [];
|
|
10070
9744
|
const uid = widget.newState.uid;
|
|
@@ -10077,10 +9751,10 @@ const render$7 = widget => {
|
|
|
10077
9751
|
}
|
|
10078
9752
|
return wrappedCommands;
|
|
10079
9753
|
};
|
|
10080
|
-
const add$
|
|
10081
|
-
return addWidget(widget, 'ColorPicker', render$
|
|
9754
|
+
const add$5 = widget => {
|
|
9755
|
+
return addWidget(widget, 'ColorPicker', render$9);
|
|
10082
9756
|
};
|
|
10083
|
-
const remove$
|
|
9757
|
+
const remove$5 = removeWidget;
|
|
10084
9758
|
const Commands$1 = {
|
|
10085
9759
|
'ColorPicker.handleSliderPointerDown': handleSliderPointerDown,
|
|
10086
9760
|
'ColorPicker.handleSliderPointerMove': handleSliderPointerMove
|
|
@@ -10089,9 +9763,9 @@ const Commands$1 = {
|
|
|
10089
9763
|
const EditorColorPickerWidget = {
|
|
10090
9764
|
__proto__: null,
|
|
10091
9765
|
Commands: Commands$1,
|
|
10092
|
-
add: add$
|
|
10093
|
-
remove: remove$
|
|
10094
|
-
render: render$
|
|
9766
|
+
add: add$5,
|
|
9767
|
+
remove: remove$5,
|
|
9768
|
+
render: render$9
|
|
10095
9769
|
};
|
|
10096
9770
|
|
|
10097
9771
|
const getCompletionDetailVirtualDom = content => {
|
|
@@ -10135,7 +9809,7 @@ const renderContent = {
|
|
|
10135
9809
|
return ['Viewlet.setDom2', newState.uid, dom];
|
|
10136
9810
|
}
|
|
10137
9811
|
};
|
|
10138
|
-
const renderBounds$
|
|
9812
|
+
const renderBounds$3 = {
|
|
10139
9813
|
isEqual(oldState, newState) {
|
|
10140
9814
|
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
10141
9815
|
},
|
|
@@ -10149,12 +9823,28 @@ const renderBounds$2 = {
|
|
|
10149
9823
|
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
10150
9824
|
}
|
|
10151
9825
|
};
|
|
10152
|
-
const render$
|
|
9826
|
+
const render$8 = [renderContent, renderBounds$3];
|
|
10153
9827
|
const renderFull = (oldState, newState) => {
|
|
10154
|
-
return renderParts(render$
|
|
9828
|
+
return renderParts(render$8, oldState, newState);
|
|
10155
9829
|
};
|
|
10156
9830
|
|
|
10157
|
-
const
|
|
9831
|
+
const getPositionAtCursor = editor => {
|
|
9832
|
+
const {
|
|
9833
|
+
selections
|
|
9834
|
+
} = editor;
|
|
9835
|
+
const rowIndex = selections[0];
|
|
9836
|
+
const columnIndex = selections[1];
|
|
9837
|
+
const x$1 = x(editor, rowIndex, columnIndex);
|
|
9838
|
+
const y$1 = y(editor, rowIndex);
|
|
9839
|
+
return {
|
|
9840
|
+
x: x$1,
|
|
9841
|
+
y: y$1,
|
|
9842
|
+
rowIndex,
|
|
9843
|
+
columnIndex
|
|
9844
|
+
};
|
|
9845
|
+
};
|
|
9846
|
+
|
|
9847
|
+
const render$7 = widget => {
|
|
10158
9848
|
const commands = renderFull(widget.oldState, widget.newState);
|
|
10159
9849
|
const wrappedCommands = [];
|
|
10160
9850
|
const uid = widget.newState.uid;
|
|
@@ -10167,14 +9857,393 @@ const render$5 = widget => {
|
|
|
10167
9857
|
}
|
|
10168
9858
|
return wrappedCommands;
|
|
10169
9859
|
};
|
|
9860
|
+
const add$4 = widget => {
|
|
9861
|
+
return addWidget(widget, 'EditorCompletionDetails', render$7);
|
|
9862
|
+
};
|
|
9863
|
+
const remove$4 = removeWidget;
|
|
9864
|
+
const handleEditorType$1 = (editor, state) => {
|
|
9865
|
+
const completionState = getCompletionState(editor);
|
|
9866
|
+
if (!completionState) {
|
|
9867
|
+
return editor;
|
|
9868
|
+
}
|
|
9869
|
+
const {
|
|
9870
|
+
x
|
|
9871
|
+
} = getPositionAtCursor(editor);
|
|
9872
|
+
const detailX = x + completionState.width - state.borderSize;
|
|
9873
|
+
return {
|
|
9874
|
+
...state,
|
|
9875
|
+
x: detailX
|
|
9876
|
+
};
|
|
9877
|
+
};
|
|
9878
|
+
const handleEditorDeleteLeft$1 = (editor, state) => {
|
|
9879
|
+
const completionState = getCompletionState(editor);
|
|
9880
|
+
if (!completionState) {
|
|
9881
|
+
return editor;
|
|
9882
|
+
}
|
|
9883
|
+
const {
|
|
9884
|
+
x
|
|
9885
|
+
} = getPositionAtCursor(editor);
|
|
9886
|
+
const detailX = x + completionState.width - state.borderSize;
|
|
9887
|
+
return {
|
|
9888
|
+
...state,
|
|
9889
|
+
x: detailX
|
|
9890
|
+
};
|
|
9891
|
+
};
|
|
9892
|
+
|
|
9893
|
+
const EditorCompletionDetailWidget = {
|
|
9894
|
+
__proto__: null,
|
|
9895
|
+
add: add$4,
|
|
9896
|
+
handleEditorDeleteLeft: handleEditorDeleteLeft$1,
|
|
9897
|
+
handleEditorType: handleEditorType$1,
|
|
9898
|
+
remove: remove$4,
|
|
9899
|
+
render: render$7
|
|
9900
|
+
};
|
|
9901
|
+
|
|
9902
|
+
const CheckBox = 'checkbox';
|
|
9903
|
+
const Group = 'group';
|
|
9904
|
+
const None = 'none';
|
|
9905
|
+
const Option = 'option';
|
|
9906
|
+
|
|
9907
|
+
const getFileIconVirtualDom = icon => {
|
|
9908
|
+
return {
|
|
9909
|
+
type: Img,
|
|
9910
|
+
className: FileIcon,
|
|
9911
|
+
src: icon,
|
|
9912
|
+
role: None,
|
|
9913
|
+
childCount: 0
|
|
9914
|
+
};
|
|
9915
|
+
};
|
|
9916
|
+
|
|
9917
|
+
const getIconDom = (fileIcon, symbolName) => {
|
|
9918
|
+
if (fileIcon) {
|
|
9919
|
+
return getFileIconVirtualDom(fileIcon);
|
|
9920
|
+
}
|
|
9921
|
+
return {
|
|
9922
|
+
type: Div,
|
|
9923
|
+
className: `${ColoredMaskIcon} ${symbolName}`,
|
|
9924
|
+
childCount: 0
|
|
9925
|
+
};
|
|
9926
|
+
};
|
|
9927
|
+
|
|
9928
|
+
const label1 = {
|
|
9929
|
+
type: Div,
|
|
9930
|
+
className: Label,
|
|
9931
|
+
childCount: 1
|
|
9932
|
+
};
|
|
9933
|
+
const completionHighlight = {
|
|
9934
|
+
type: Span,
|
|
9935
|
+
className: EditorCompletionItemHighlight,
|
|
9936
|
+
childCount: 1
|
|
9937
|
+
};
|
|
9938
|
+
const getHighlightedLabelDom = (label, highlights) => {
|
|
9939
|
+
if (highlights.length === 0) {
|
|
9940
|
+
return [label1, text(label)];
|
|
9941
|
+
}
|
|
9942
|
+
const dom = [];
|
|
9943
|
+
const labelDom = {
|
|
9944
|
+
type: Div,
|
|
9945
|
+
className: Label,
|
|
9946
|
+
childCount: 0
|
|
9947
|
+
};
|
|
9948
|
+
dom.push(labelDom);
|
|
9949
|
+
let position = 0;
|
|
9950
|
+
for (let i = 0; i < highlights.length; i += 2) {
|
|
9951
|
+
const highlightStart = highlights[i];
|
|
9952
|
+
const highlightEnd = highlights[i + 1];
|
|
9953
|
+
if (position < highlightStart) {
|
|
9954
|
+
const beforeText = label.slice(position, highlightStart);
|
|
9955
|
+
labelDom.childCount++;
|
|
9956
|
+
dom.push(text(beforeText));
|
|
9957
|
+
}
|
|
9958
|
+
const highlightText = label.slice(highlightStart, highlightEnd);
|
|
9959
|
+
labelDom.childCount++;
|
|
9960
|
+
dom.push(completionHighlight, text(highlightText));
|
|
9961
|
+
position = highlightEnd;
|
|
9962
|
+
}
|
|
9963
|
+
if (position < label.length) {
|
|
9964
|
+
const afterText = label.slice(position);
|
|
9965
|
+
labelDom.childCount++;
|
|
9966
|
+
dom.push(text(afterText));
|
|
9967
|
+
}
|
|
9968
|
+
return dom;
|
|
9969
|
+
};
|
|
9970
|
+
|
|
9971
|
+
const getCompletionItemVirtualDom = visibleItem => {
|
|
9972
|
+
const {
|
|
9973
|
+
top,
|
|
9974
|
+
label,
|
|
9975
|
+
symbolName,
|
|
9976
|
+
highlights,
|
|
9977
|
+
focused,
|
|
9978
|
+
deprecated,
|
|
9979
|
+
fileIcon
|
|
9980
|
+
} = visibleItem;
|
|
9981
|
+
let className = EditorCompletionItem;
|
|
9982
|
+
if (focused) {
|
|
9983
|
+
className += ' ' + EditorCompletionItemFocused;
|
|
9984
|
+
}
|
|
9985
|
+
if (deprecated) {
|
|
9986
|
+
className += ' ' + EditorCompletionItemDeprecated;
|
|
9987
|
+
}
|
|
9988
|
+
return [{
|
|
9989
|
+
type: Div,
|
|
9990
|
+
role: Option,
|
|
9991
|
+
className,
|
|
9992
|
+
top,
|
|
9993
|
+
childCount: 2
|
|
9994
|
+
}, getIconDom(fileIcon, symbolName), ...getHighlightedLabelDom(label, highlights)];
|
|
9995
|
+
};
|
|
9996
|
+
|
|
9997
|
+
const getCompletionItemsVirtualDom = visibleItems => {
|
|
9998
|
+
if (visibleItems.length === 0) {
|
|
9999
|
+
return [{
|
|
10000
|
+
type: Div,
|
|
10001
|
+
childCount: 1
|
|
10002
|
+
}, text(noResults$1())];
|
|
10003
|
+
}
|
|
10004
|
+
const root = {
|
|
10005
|
+
type: Div,
|
|
10006
|
+
childCount: visibleItems.length
|
|
10007
|
+
};
|
|
10008
|
+
const dom = [root, ...visibleItems.flatMap(getCompletionItemVirtualDom)];
|
|
10009
|
+
return dom;
|
|
10010
|
+
};
|
|
10011
|
+
|
|
10012
|
+
const Property = 1;
|
|
10013
|
+
const Value = 2;
|
|
10014
|
+
const Function = 3;
|
|
10015
|
+
const Variable = 4;
|
|
10016
|
+
const Keyword = 5;
|
|
10017
|
+
const Folder = 6;
|
|
10018
|
+
const File = 7;
|
|
10019
|
+
const Field = 8;
|
|
10020
|
+
|
|
10021
|
+
const SymbolProperty = 'SymbolProperty';
|
|
10022
|
+
const SymbolValue = 'SymbolValue';
|
|
10023
|
+
const SymbolFunction = 'SymbolFunction';
|
|
10024
|
+
const SymbolVariable = 'SymbolVariable';
|
|
10025
|
+
const SymbolKeyword = 'SymbolKeyword';
|
|
10026
|
+
const SymbolDefault = 'SymbolDefault';
|
|
10027
|
+
const SymbolField = 'SymbolField';
|
|
10028
|
+
const SymbolNone = '';
|
|
10029
|
+
|
|
10030
|
+
const getSymbolName = kind => {
|
|
10031
|
+
switch (kind) {
|
|
10032
|
+
case Property:
|
|
10033
|
+
return SymbolProperty;
|
|
10034
|
+
case Value:
|
|
10035
|
+
return SymbolValue;
|
|
10036
|
+
case Function:
|
|
10037
|
+
return SymbolFunction;
|
|
10038
|
+
case Variable:
|
|
10039
|
+
return SymbolVariable;
|
|
10040
|
+
case Keyword:
|
|
10041
|
+
return SymbolKeyword;
|
|
10042
|
+
case Field:
|
|
10043
|
+
return SymbolField;
|
|
10044
|
+
case File:
|
|
10045
|
+
return SymbolNone;
|
|
10046
|
+
default:
|
|
10047
|
+
return SymbolDefault;
|
|
10048
|
+
}
|
|
10049
|
+
};
|
|
10050
|
+
|
|
10051
|
+
// TODO
|
|
10052
|
+
const getCompletionFileIcon = kind => {
|
|
10053
|
+
switch (kind) {
|
|
10054
|
+
case File:
|
|
10055
|
+
return EmptyString$1;
|
|
10056
|
+
case Folder:
|
|
10057
|
+
return EmptyString$1;
|
|
10058
|
+
default:
|
|
10059
|
+
return EmptyString$1;
|
|
10060
|
+
}
|
|
10061
|
+
};
|
|
10062
|
+
|
|
10063
|
+
const getHighlights = item => {
|
|
10064
|
+
const {
|
|
10065
|
+
matches
|
|
10066
|
+
} = item;
|
|
10067
|
+
return matches.slice(1);
|
|
10068
|
+
};
|
|
10069
|
+
|
|
10070
|
+
const getLabel = item => {
|
|
10071
|
+
return item.label;
|
|
10072
|
+
};
|
|
10073
|
+
const getVisibleIem = (item, itemHeight, leadingWord, i, focusedIndex) => {
|
|
10074
|
+
return {
|
|
10075
|
+
label: getLabel(item),
|
|
10076
|
+
symbolName: getSymbolName(item.kind),
|
|
10077
|
+
top: i * itemHeight,
|
|
10078
|
+
highlights: getHighlights(item),
|
|
10079
|
+
focused: i === focusedIndex,
|
|
10080
|
+
deprecated: item.flags & Deprecated,
|
|
10081
|
+
fileIcon: getCompletionFileIcon(item.kind)
|
|
10082
|
+
};
|
|
10083
|
+
};
|
|
10084
|
+
|
|
10085
|
+
const getVisibleItems = (filteredItems, itemHeight, leadingWord, minLineY, maxLineY, focusedIndex) => {
|
|
10086
|
+
const visibleItems = [];
|
|
10087
|
+
for (let i = minLineY; i < maxLineY; i++) {
|
|
10088
|
+
const filteredItem = filteredItems[i];
|
|
10089
|
+
visibleItems.push(getVisibleIem(filteredItem, itemHeight, leadingWord, i, focusedIndex));
|
|
10090
|
+
}
|
|
10091
|
+
return visibleItems;
|
|
10092
|
+
};
|
|
10093
|
+
|
|
10094
|
+
const renderItems = {
|
|
10095
|
+
isEqual(oldState, newState) {
|
|
10096
|
+
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex;
|
|
10097
|
+
},
|
|
10098
|
+
apply(oldState, newState) {
|
|
10099
|
+
const visibleItems = getVisibleItems(newState.items, newState.itemHeight, newState.leadingWord, newState.minLineY, newState.maxLineY, newState.focusedIndex);
|
|
10100
|
+
const dom = getCompletionItemsVirtualDom(visibleItems);
|
|
10101
|
+
return ['setDom', dom];
|
|
10102
|
+
}
|
|
10103
|
+
};
|
|
10104
|
+
const renderBounds$2 = {
|
|
10105
|
+
isEqual(oldState, newState) {
|
|
10106
|
+
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.x === newState.x && oldState.y === newState.y;
|
|
10107
|
+
},
|
|
10108
|
+
apply(oldState, newState) {
|
|
10109
|
+
const {
|
|
10110
|
+
x,
|
|
10111
|
+
y,
|
|
10112
|
+
width,
|
|
10113
|
+
height
|
|
10114
|
+
} = newState;
|
|
10115
|
+
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
10116
|
+
}
|
|
10117
|
+
};
|
|
10118
|
+
const renderHeight = {
|
|
10119
|
+
isEqual(oldState, newState) {
|
|
10120
|
+
return oldState.items.length === newState.items.length;
|
|
10121
|
+
},
|
|
10122
|
+
apply(oldState, newState) {
|
|
10123
|
+
const {
|
|
10124
|
+
itemHeight
|
|
10125
|
+
} = newState;
|
|
10126
|
+
const contentHeight = newState.items.length * itemHeight;
|
|
10127
|
+
return [/* method */SetContentHeight, /* contentHeight */contentHeight];
|
|
10128
|
+
}
|
|
10129
|
+
};
|
|
10130
|
+
const renderNegativeMargin = {
|
|
10131
|
+
isEqual(oldState, newState) {
|
|
10132
|
+
return oldState.deltaY === newState.deltaY;
|
|
10133
|
+
},
|
|
10134
|
+
apply(oldState, newState) {
|
|
10135
|
+
return [/* method */SetNegativeMargin, /* negativeMargin */-newState.deltaY];
|
|
10136
|
+
}
|
|
10137
|
+
};
|
|
10138
|
+
const renderScrollBar = {
|
|
10139
|
+
isEqual(oldState, newState) {
|
|
10140
|
+
return oldState.negativeMargin === newState.negativeMargin && oldState.deltaY === newState.deltaY && oldState.height === newState.height && oldState.finalDeltaY === newState.finalDeltaY && oldState.items.length === newState.items.length;
|
|
10141
|
+
},
|
|
10142
|
+
apply(oldState, newState) {
|
|
10143
|
+
const total = newState.items.length;
|
|
10144
|
+
const contentHeight = total * newState.itemHeight;
|
|
10145
|
+
const scrollBarHeight = getScrollBarSize(newState.height, contentHeight, newState.minimumSliderSize);
|
|
10146
|
+
const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, scrollBarHeight);
|
|
10147
|
+
return [/* method */SetScrollBar, /* scrollBarY */scrollBarY, /* scrollBarHeight */scrollBarHeight];
|
|
10148
|
+
}
|
|
10149
|
+
};
|
|
10150
|
+
const render$6 = [renderItems, renderBounds$2, renderHeight, renderNegativeMargin, renderScrollBar];
|
|
10151
|
+
const renderCompletion = (oldState, newState) => {
|
|
10152
|
+
const commands = [];
|
|
10153
|
+
for (const item of render$6) {
|
|
10154
|
+
if (!item.isEqual(oldState, newState)) {
|
|
10155
|
+
commands.push(item.apply(oldState, newState));
|
|
10156
|
+
}
|
|
10157
|
+
}
|
|
10158
|
+
return commands;
|
|
10159
|
+
};
|
|
10160
|
+
|
|
10161
|
+
const render$5 = widget => {
|
|
10162
|
+
const commands = renderCompletion(widget.oldState, widget.newState);
|
|
10163
|
+
const wrappedCommands = [];
|
|
10164
|
+
const uid = widget.newState.uid;
|
|
10165
|
+
for (const command of commands) {
|
|
10166
|
+
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
10167
|
+
}
|
|
10168
|
+
return wrappedCommands;
|
|
10169
|
+
};
|
|
10170
10170
|
const add$3 = widget => {
|
|
10171
|
-
|
|
10171
|
+
const commands = render$5(widget);
|
|
10172
|
+
const id = 'EditorCompletion';
|
|
10173
|
+
// TODO how to generate a unique integer id
|
|
10174
|
+
// that doesn't collide with ids created in renderer worker?
|
|
10175
|
+
const uid = widget.newState.uid;
|
|
10176
|
+
const allCommands = [];
|
|
10177
|
+
allCommands.push(['Viewlet.create', id, uid]);
|
|
10178
|
+
allCommands.push(...commands);
|
|
10179
|
+
return allCommands;
|
|
10172
10180
|
};
|
|
10173
10181
|
const remove$3 = removeWidget;
|
|
10182
|
+
const handleEditorType = (editor, state) => {
|
|
10183
|
+
const {
|
|
10184
|
+
unfilteredItems,
|
|
10185
|
+
itemHeight,
|
|
10186
|
+
maxHeight
|
|
10187
|
+
} = state;
|
|
10188
|
+
const {
|
|
10189
|
+
x,
|
|
10190
|
+
y,
|
|
10191
|
+
rowIndex,
|
|
10192
|
+
columnIndex
|
|
10193
|
+
} = getPositionAtCursor(editor);
|
|
10194
|
+
const wordAtOffset = getWordBefore(editor, rowIndex, columnIndex);
|
|
10195
|
+
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
10196
|
+
const newMinLineY = 0;
|
|
10197
|
+
const newMaxLineY = Math.min(items.length, 8);
|
|
10198
|
+
const height = getListHeight(items.length, itemHeight, maxHeight);
|
|
10199
|
+
const finalDeltaY = items.length * itemHeight - height;
|
|
10200
|
+
return {
|
|
10201
|
+
...state,
|
|
10202
|
+
items,
|
|
10203
|
+
x,
|
|
10204
|
+
y,
|
|
10205
|
+
minLineY: newMinLineY,
|
|
10206
|
+
maxLineY: newMaxLineY,
|
|
10207
|
+
leadingWord: wordAtOffset,
|
|
10208
|
+
height,
|
|
10209
|
+
finalDeltaY
|
|
10210
|
+
};
|
|
10211
|
+
};
|
|
10212
|
+
const handleEditorDeleteLeft = (editor, state) => {
|
|
10213
|
+
const {
|
|
10214
|
+
unfilteredItems,
|
|
10215
|
+
itemHeight,
|
|
10216
|
+
maxHeight
|
|
10217
|
+
} = state;
|
|
10218
|
+
const {
|
|
10219
|
+
x,
|
|
10220
|
+
y,
|
|
10221
|
+
rowIndex,
|
|
10222
|
+
columnIndex
|
|
10223
|
+
} = getPositionAtCursor(editor);
|
|
10224
|
+
const wordAtOffset = getWordBefore(editor, rowIndex, columnIndex);
|
|
10225
|
+
if (!wordAtOffset) {
|
|
10226
|
+
return undefined;
|
|
10227
|
+
}
|
|
10228
|
+
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
10229
|
+
const newMaxLineY = Math.min(items.length, 8);
|
|
10230
|
+
const height = getListHeight(items.length, itemHeight, maxHeight);
|
|
10231
|
+
return {
|
|
10232
|
+
...state,
|
|
10233
|
+
items,
|
|
10234
|
+
x,
|
|
10235
|
+
y,
|
|
10236
|
+
maxLineY: newMaxLineY,
|
|
10237
|
+
leadingWord: wordAtOffset,
|
|
10238
|
+
height
|
|
10239
|
+
};
|
|
10240
|
+
};
|
|
10174
10241
|
|
|
10175
|
-
const
|
|
10242
|
+
const EditorCompletionWidget = {
|
|
10176
10243
|
__proto__: null,
|
|
10177
10244
|
add: add$3,
|
|
10245
|
+
handleEditorDeleteLeft,
|
|
10246
|
+
handleEditorType,
|
|
10178
10247
|
remove: remove$3,
|
|
10179
10248
|
render: render$5
|
|
10180
10249
|
};
|
|
@@ -10702,12 +10771,12 @@ const EditorSourceActionWidget = {
|
|
|
10702
10771
|
};
|
|
10703
10772
|
|
|
10704
10773
|
const registerWidgets = () => {
|
|
10705
|
-
set(ColorPicker$2, EditorColorPickerWidget);
|
|
10706
|
-
set(Completion, EditorCompletionWidget);
|
|
10707
|
-
set(CompletionDetail$1, EditorCompletionDetailWidget);
|
|
10708
|
-
set(Find, EditorFindWidget);
|
|
10709
|
-
set(Hover, EditorHoverWidget);
|
|
10710
|
-
set(SourceAction, EditorSourceActionWidget);
|
|
10774
|
+
set$7(ColorPicker$2, EditorColorPickerWidget);
|
|
10775
|
+
set$7(Completion, EditorCompletionWidget);
|
|
10776
|
+
set$7(CompletionDetail$1, EditorCompletionDetailWidget);
|
|
10777
|
+
set$7(Find, EditorFindWidget);
|
|
10778
|
+
set$7(Hover, EditorHoverWidget);
|
|
10779
|
+
set$7(SourceAction, EditorSourceActionWidget);
|
|
10711
10780
|
};
|
|
10712
10781
|
|
|
10713
10782
|
const main = async () => {
|