@lvce-editor/editor-worker 3.0.0 → 3.2.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/api/api.d.ts +3 -0
- package/dist/editorWorkerMain.js +302 -83
- package/package.json +1 -1
package/dist/api/api.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ interface EventMap {
|
|
|
9
9
|
'EditorCompletion.loadContent': (editorUid: number, state: any) => Promise<any>
|
|
10
10
|
'EditorCompletion.selectCurrent': (editorUid: number, state: any) => Promise<any>
|
|
11
11
|
'EditorCompletion.selectIndex': (editorUid: number, state: any, index: number) => Promise<any>
|
|
12
|
+
'EditorCompletion.openDetails': (editorUid: number, state: any) => Promise<any>
|
|
13
|
+
'EditorCompletion.closeDetails': (editorUid: number, state: any) => Promise<any>
|
|
14
|
+
'EditorCompletion.toggleDetails': (editorUid: number, state: any) => Promise<any>
|
|
12
15
|
'FindWidget.focusFirst': (state: any) => Promise<any>
|
|
13
16
|
'FindWidget.focusIndex': (state: any, index: number) => Promise<any>
|
|
14
17
|
'FindWidget.focusLast': (state: any) => Promise<any>
|
package/dist/editorWorkerMain.js
CHANGED
|
@@ -4,7 +4,7 @@ let AssertionError$1 = class AssertionError extends Error {
|
|
|
4
4
|
this.name = 'AssertionError';
|
|
5
5
|
}
|
|
6
6
|
};
|
|
7
|
-
const getType$
|
|
7
|
+
const getType$2 = value => {
|
|
8
8
|
switch (typeof value) {
|
|
9
9
|
case 'number':
|
|
10
10
|
return 'number';
|
|
@@ -27,31 +27,31 @@ const getType$1 = value => {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
const object = value => {
|
|
30
|
-
const type = getType$
|
|
30
|
+
const type = getType$2(value);
|
|
31
31
|
if (type !== 'object') {
|
|
32
32
|
throw new AssertionError$1('expected value to be of type object');
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
const number$1 = value => {
|
|
36
|
-
const type = getType$
|
|
36
|
+
const type = getType$2(value);
|
|
37
37
|
if (type !== 'number') {
|
|
38
38
|
throw new AssertionError$1('expected value to be of type number');
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
const array = value => {
|
|
42
|
-
const type = getType$
|
|
42
|
+
const type = getType$2(value);
|
|
43
43
|
if (type !== 'array') {
|
|
44
44
|
throw new AssertionError$1('expected value to be of type array');
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
const string = value => {
|
|
48
|
-
const type = getType$
|
|
48
|
+
const type = getType$2(value);
|
|
49
49
|
if (type !== 'string') {
|
|
50
50
|
throw new AssertionError$1('expected value to be of type string');
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
const boolean = value => {
|
|
54
|
-
const type = getType$
|
|
54
|
+
const type = getType$2(value);
|
|
55
55
|
if (type !== 'boolean') {
|
|
56
56
|
throw new AssertionError$1('expected value to be of type boolean');
|
|
57
57
|
}
|
|
@@ -116,6 +116,8 @@ const ColorPickerLight = 'ColorPickerLight';
|
|
|
116
116
|
const ColorPickerRectangle = 'ColorPickerRectangle';
|
|
117
117
|
const ColorPickerSlider = 'ColorPickerSlider';
|
|
118
118
|
const ColorPickerSliderThumb = 'ColorPickerSliderThumb';
|
|
119
|
+
const CompletionDetailCloseButton = 'CompletionDetailCloseButton';
|
|
120
|
+
const CompletionDetailContent = 'CompletionDetailContent';
|
|
119
121
|
const Diagnostic = 'Diagnostic';
|
|
120
122
|
const EditorCompletionItem = 'EditorCompletionItem';
|
|
121
123
|
const EditorCompletionItemDeprecated = 'EditorCompletionItemDeprecated';
|
|
@@ -131,11 +133,14 @@ const HoverEditorRow = 'HoverEditorRow';
|
|
|
131
133
|
const HoverProblem = 'HoverProblem';
|
|
132
134
|
const HoverProblemDetail = 'HoverProblemDetail';
|
|
133
135
|
const HoverProblemMessage = 'HoverProblemMessage';
|
|
136
|
+
const IconClose = 'IconClose';
|
|
134
137
|
const Label = 'Label';
|
|
138
|
+
const MaskIcon = 'MaskIcon';
|
|
135
139
|
const Viewlet = 'Viewlet';
|
|
136
140
|
|
|
137
141
|
const HandlePointerDown = 'handlePointerDown';
|
|
138
142
|
const HandleSashPointerDown = 'handleSashPointerDown';
|
|
143
|
+
const HandleClose = 'handleClose';
|
|
139
144
|
|
|
140
145
|
const mergeClassNames = (...classNames) => {
|
|
141
146
|
return classNames.filter(Boolean).join(' ');
|
|
@@ -211,10 +216,10 @@ const renderColorPickerDom = {
|
|
|
211
216
|
return ['Viewlet.setDom2', dom];
|
|
212
217
|
}
|
|
213
218
|
};
|
|
214
|
-
const render$
|
|
219
|
+
const render$6 = [renderColorPickerDom, renderColor, renderOffsetX];
|
|
215
220
|
const renderColorPicker = async (oldState, newState) => {
|
|
216
221
|
const commands = [];
|
|
217
|
-
for (const item of render$
|
|
222
|
+
for (const item of render$6) {
|
|
218
223
|
if (!item.isEqual(oldState, newState)) {
|
|
219
224
|
commands.push(item.apply(oldState, newState));
|
|
220
225
|
}
|
|
@@ -1140,7 +1145,7 @@ class AssertionError extends Error {
|
|
|
1140
1145
|
this.name = 'AssertionError';
|
|
1141
1146
|
}
|
|
1142
1147
|
}
|
|
1143
|
-
const getType = value => {
|
|
1148
|
+
const getType$1 = value => {
|
|
1144
1149
|
switch (typeof value) {
|
|
1145
1150
|
case 'number':
|
|
1146
1151
|
return 'number';
|
|
@@ -1163,7 +1168,7 @@ const getType = value => {
|
|
|
1163
1168
|
}
|
|
1164
1169
|
};
|
|
1165
1170
|
const number = value => {
|
|
1166
|
-
const type = getType(value);
|
|
1171
|
+
const type = getType$1(value);
|
|
1167
1172
|
if (type !== 'number') {
|
|
1168
1173
|
throw new AssertionError('expected value to be of type number');
|
|
1169
1174
|
}
|
|
@@ -1177,7 +1182,7 @@ const set$5 = (id, fn) => {
|
|
|
1177
1182
|
const get$5 = id => {
|
|
1178
1183
|
return state$1$1.callbacks[id];
|
|
1179
1184
|
};
|
|
1180
|
-
const remove$
|
|
1185
|
+
const remove$2 = id => {
|
|
1181
1186
|
delete state$1$1.callbacks[id];
|
|
1182
1187
|
};
|
|
1183
1188
|
const state$a = {
|
|
@@ -1223,7 +1228,7 @@ const resolve = (id, args) => {
|
|
|
1223
1228
|
return;
|
|
1224
1229
|
}
|
|
1225
1230
|
fn(args);
|
|
1226
|
-
remove$
|
|
1231
|
+
remove$2(id);
|
|
1227
1232
|
};
|
|
1228
1233
|
const create$2$1 = (method, params) => {
|
|
1229
1234
|
const {
|
|
@@ -1372,14 +1377,16 @@ const unwrapJsonRpcResult = responseMessage => {
|
|
|
1372
1377
|
}
|
|
1373
1378
|
throw new JsonRpcError('unexpected response message');
|
|
1374
1379
|
};
|
|
1375
|
-
const create$1$1 = (message, error) => {
|
|
1376
|
-
return {
|
|
1377
|
-
jsonrpc: Two,
|
|
1378
|
-
id: message.id,
|
|
1379
|
-
error
|
|
1380
|
-
};
|
|
1381
|
-
};
|
|
1382
1380
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
1381
|
+
const getType = prettyError => {
|
|
1382
|
+
if (prettyError && prettyError.type) {
|
|
1383
|
+
return prettyError.type;
|
|
1384
|
+
}
|
|
1385
|
+
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
1386
|
+
return prettyError.constructor.name;
|
|
1387
|
+
}
|
|
1388
|
+
return undefined;
|
|
1389
|
+
};
|
|
1383
1390
|
const getErrorProperty = (error, prettyError) => {
|
|
1384
1391
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
1385
1392
|
return {
|
|
@@ -1394,18 +1401,26 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
1394
1401
|
data: {
|
|
1395
1402
|
stack: prettyError.stack,
|
|
1396
1403
|
codeFrame: prettyError.codeFrame,
|
|
1397
|
-
type: prettyError
|
|
1398
|
-
code: prettyError.code
|
|
1404
|
+
type: getType(prettyError),
|
|
1405
|
+
code: prettyError.code,
|
|
1406
|
+
name: prettyError.name
|
|
1399
1407
|
}
|
|
1400
1408
|
};
|
|
1401
1409
|
};
|
|
1410
|
+
const create$1$1 = (message, error) => {
|
|
1411
|
+
return {
|
|
1412
|
+
jsonrpc: Two,
|
|
1413
|
+
id: message.id,
|
|
1414
|
+
error
|
|
1415
|
+
};
|
|
1416
|
+
};
|
|
1402
1417
|
const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
1403
1418
|
const prettyError = preparePrettyError(error);
|
|
1404
1419
|
logError(error, prettyError);
|
|
1405
1420
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
1406
1421
|
return create$1$1(message, errorProperty);
|
|
1407
1422
|
};
|
|
1408
|
-
const create$
|
|
1423
|
+
const create$8 = (message, result) => {
|
|
1409
1424
|
return {
|
|
1410
1425
|
jsonrpc: Two,
|
|
1411
1426
|
id: message.id,
|
|
@@ -1414,7 +1429,7 @@ const create$5 = (message, result) => {
|
|
|
1414
1429
|
};
|
|
1415
1430
|
const getSuccessResponse = (message, result) => {
|
|
1416
1431
|
const resultProperty = result ?? null;
|
|
1417
|
-
return create$
|
|
1432
|
+
return create$8(message, resultProperty);
|
|
1418
1433
|
};
|
|
1419
1434
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
1420
1435
|
try {
|
|
@@ -1490,14 +1505,7 @@ const invoke$5 = async (ipc, method, ...params) => {
|
|
|
1490
1505
|
const result = unwrapJsonRpcResult(responseMessage);
|
|
1491
1506
|
return result;
|
|
1492
1507
|
};
|
|
1493
|
-
|
|
1494
|
-
// TODO deprecated old typings,
|
|
1495
|
-
// always use automatic transferrable detection
|
|
1496
|
-
const invokeAndTransfer$2 = async (ipc, handle, method, ...params) => {
|
|
1497
|
-
if (typeof handle === 'string') {
|
|
1498
|
-
params = [method, ...params];
|
|
1499
|
-
method = handle;
|
|
1500
|
-
}
|
|
1508
|
+
const invokeAndTransfer$2 = async (ipc, method, ...params) => {
|
|
1501
1509
|
const {
|
|
1502
1510
|
message,
|
|
1503
1511
|
promise
|
|
@@ -1653,7 +1661,7 @@ const waitForFirstMessage$1 = async port => {
|
|
|
1653
1661
|
return event;
|
|
1654
1662
|
};
|
|
1655
1663
|
|
|
1656
|
-
const create$
|
|
1664
|
+
const create$7 = async () => {
|
|
1657
1665
|
const {
|
|
1658
1666
|
port1,
|
|
1659
1667
|
port2
|
|
@@ -1698,7 +1706,7 @@ const wrap$3 = port => {
|
|
|
1698
1706
|
|
|
1699
1707
|
const IpcParentWithExtensionHostWorker = {
|
|
1700
1708
|
__proto__: null,
|
|
1701
|
-
create: create$
|
|
1709
|
+
create: create$7,
|
|
1702
1710
|
wrap: wrap$3
|
|
1703
1711
|
};
|
|
1704
1712
|
|
|
@@ -1706,7 +1714,7 @@ const sendMessagePortToSyntaxHighlightingWorker = async port => {
|
|
|
1706
1714
|
await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
|
|
1707
1715
|
};
|
|
1708
1716
|
|
|
1709
|
-
const create$
|
|
1717
|
+
const create$6 = async () => {
|
|
1710
1718
|
const {
|
|
1711
1719
|
port1,
|
|
1712
1720
|
port2
|
|
@@ -1751,7 +1759,7 @@ const wrap$1 = port => {
|
|
|
1751
1759
|
|
|
1752
1760
|
const IpcParentWithSyntaxHighlightingWorker = {
|
|
1753
1761
|
__proto__: null,
|
|
1754
|
-
create: create$
|
|
1762
|
+
create: create$6,
|
|
1755
1763
|
wrap: wrap$1
|
|
1756
1764
|
};
|
|
1757
1765
|
|
|
@@ -1759,7 +1767,7 @@ const sendMessagePortToRendererProcess = async port => {
|
|
|
1759
1767
|
await invokeAndTransfer('SendMessagePortToRendererProcess.sendMessagePortToRendererProcess', port, 'HandleMessagePort.handleMessagePort');
|
|
1760
1768
|
};
|
|
1761
1769
|
|
|
1762
|
-
const create$
|
|
1770
|
+
const create$5 = async () => {
|
|
1763
1771
|
const {
|
|
1764
1772
|
port1,
|
|
1765
1773
|
port2
|
|
@@ -1804,7 +1812,7 @@ const wrap = port => {
|
|
|
1804
1812
|
|
|
1805
1813
|
const IpcParentWithRendererProcess = {
|
|
1806
1814
|
__proto__: null,
|
|
1807
|
-
create: create$
|
|
1815
|
+
create: create$5,
|
|
1808
1816
|
wrap
|
|
1809
1817
|
};
|
|
1810
1818
|
|
|
@@ -1821,7 +1829,7 @@ const getModule$1 = method => {
|
|
|
1821
1829
|
}
|
|
1822
1830
|
};
|
|
1823
1831
|
|
|
1824
|
-
const create$
|
|
1832
|
+
const create$4 = async ({
|
|
1825
1833
|
method,
|
|
1826
1834
|
...options
|
|
1827
1835
|
}) => {
|
|
@@ -1839,7 +1847,7 @@ const create$1 = async ({
|
|
|
1839
1847
|
const createRpc = method => {
|
|
1840
1848
|
let _ipc;
|
|
1841
1849
|
const listen = async () => {
|
|
1842
|
-
const ipc = await create$
|
|
1850
|
+
const ipc = await create$4({
|
|
1843
1851
|
method
|
|
1844
1852
|
});
|
|
1845
1853
|
handleIpc(ipc);
|
|
@@ -2116,7 +2124,7 @@ const getAccurateColumnIndexAscii = (line, guess, averageCharWidth, eventX, font
|
|
|
2116
2124
|
const supported = () => {
|
|
2117
2125
|
return 'Segmenter' in Intl;
|
|
2118
2126
|
};
|
|
2119
|
-
const create = () => {
|
|
2127
|
+
const create$3 = () => {
|
|
2120
2128
|
// @ts-ignore
|
|
2121
2129
|
const segmenter = new Intl.Segmenter();
|
|
2122
2130
|
return {
|
|
@@ -2154,7 +2162,7 @@ const create = () => {
|
|
|
2154
2162
|
|
|
2155
2163
|
// @ts-ignore
|
|
2156
2164
|
const getAccurateColumnIndexUnicode = (line, guess, averageCharWidth, eventX, fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
2157
|
-
const segmenter = create();
|
|
2165
|
+
const segmenter = create$3();
|
|
2158
2166
|
const segments = segmenter.getSegments(line);
|
|
2159
2167
|
const isMonospaceFont = false;
|
|
2160
2168
|
const charWidth = 0;
|
|
@@ -2383,7 +2391,9 @@ const cancelSelection = editor => {
|
|
|
2383
2391
|
return scheduleSelections(editor, newSelections);
|
|
2384
2392
|
};
|
|
2385
2393
|
|
|
2394
|
+
// TODO use numeric widget id
|
|
2386
2395
|
const Completion = 'completion';
|
|
2396
|
+
const CompletionDetail = 'completionDetail';
|
|
2387
2397
|
|
|
2388
2398
|
const isCompletionWidget = widget => {
|
|
2389
2399
|
return widget.id === Completion;
|
|
@@ -2697,7 +2707,7 @@ const characterLeft = (line, columnIndex) => {
|
|
|
2697
2707
|
if (!supported()) {
|
|
2698
2708
|
return 1;
|
|
2699
2709
|
}
|
|
2700
|
-
const segmenter = create();
|
|
2710
|
+
const segmenter = create$3();
|
|
2701
2711
|
const last = segmenter.at(line, columnIndex - 1);
|
|
2702
2712
|
return columnIndex - last.index;
|
|
2703
2713
|
};
|
|
@@ -2708,7 +2718,7 @@ const characterRight = (line, columnIndex) => {
|
|
|
2708
2718
|
if (!supported()) {
|
|
2709
2719
|
return 1;
|
|
2710
2720
|
}
|
|
2711
|
-
const segmenter = create();
|
|
2721
|
+
const segmenter = create$3();
|
|
2712
2722
|
const next = segmenter.at(line, columnIndex);
|
|
2713
2723
|
return next.segment.length;
|
|
2714
2724
|
};
|
|
@@ -4465,6 +4475,44 @@ const moveSelectionPx = (editor, x, y) => {
|
|
|
4465
4475
|
return editorMoveSelection(editor, position);
|
|
4466
4476
|
};
|
|
4467
4477
|
|
|
4478
|
+
const create$2 = () => {
|
|
4479
|
+
return Math.random();
|
|
4480
|
+
};
|
|
4481
|
+
|
|
4482
|
+
const create$1 = () => {
|
|
4483
|
+
const completionUid = create$2();
|
|
4484
|
+
const completionWidget = {
|
|
4485
|
+
id: Completion,
|
|
4486
|
+
oldState: {
|
|
4487
|
+
items: [],
|
|
4488
|
+
itemHeight: 20,
|
|
4489
|
+
maxHeight: 150,
|
|
4490
|
+
minLineY: 0,
|
|
4491
|
+
maxLineY: 0,
|
|
4492
|
+
uid: completionUid,
|
|
4493
|
+
focusedIndex: -1,
|
|
4494
|
+
x: 0,
|
|
4495
|
+
y: 0,
|
|
4496
|
+
width: 0,
|
|
4497
|
+
height: 0
|
|
4498
|
+
},
|
|
4499
|
+
newState: {
|
|
4500
|
+
items: [],
|
|
4501
|
+
itemHeight: 20,
|
|
4502
|
+
maxHeight: 150,
|
|
4503
|
+
minLineY: 0,
|
|
4504
|
+
maxLineY: 10,
|
|
4505
|
+
uid: completionUid,
|
|
4506
|
+
focusedIndex: -1,
|
|
4507
|
+
x: 0,
|
|
4508
|
+
y: 0,
|
|
4509
|
+
width: 0,
|
|
4510
|
+
height: 0
|
|
4511
|
+
}
|
|
4512
|
+
};
|
|
4513
|
+
return completionWidget;
|
|
4514
|
+
};
|
|
4515
|
+
|
|
4468
4516
|
const OnCompletion = 'onCompletion';
|
|
4469
4517
|
const OnHover = 'onHover';
|
|
4470
4518
|
|
|
@@ -4922,26 +4970,7 @@ const openCompletion = async editor => {
|
|
|
4922
4970
|
if (hasWidget(widgets, Completion)) {
|
|
4923
4971
|
return editor;
|
|
4924
4972
|
}
|
|
4925
|
-
const
|
|
4926
|
-
const completionWidget = {
|
|
4927
|
-
id: Completion,
|
|
4928
|
-
oldState: {
|
|
4929
|
-
items: [],
|
|
4930
|
-
itemHeight: 20,
|
|
4931
|
-
maxHeight: 150,
|
|
4932
|
-
minLineY: 0,
|
|
4933
|
-
maxLineY: 0,
|
|
4934
|
-
uid: completionUid
|
|
4935
|
-
},
|
|
4936
|
-
newState: {
|
|
4937
|
-
items: [],
|
|
4938
|
-
itemHeight: 20,
|
|
4939
|
-
maxHeight: 150,
|
|
4940
|
-
minLineY: 0,
|
|
4941
|
-
maxLineY: 10,
|
|
4942
|
-
uid: completionUid
|
|
4943
|
-
}
|
|
4944
|
-
};
|
|
4973
|
+
const completionWidget = create$1();
|
|
4945
4974
|
const newWidgets = [...widgets, completionWidget];
|
|
4946
4975
|
const newEditor = {
|
|
4947
4976
|
...editor,
|
|
@@ -6652,15 +6681,32 @@ const editorUnindent = editor => {
|
|
|
6652
6681
|
|
|
6653
6682
|
// editor.lines //?
|
|
6654
6683
|
|
|
6655
|
-
const
|
|
6656
|
-
return widget.id === Completion;
|
|
6657
|
-
};
|
|
6658
|
-
const getCompletionState = editor => {
|
|
6684
|
+
const getWidgetState = (editor, id) => {
|
|
6659
6685
|
const {
|
|
6660
6686
|
widgets
|
|
6661
6687
|
} = editor;
|
|
6662
|
-
const
|
|
6663
|
-
|
|
6688
|
+
for (const widget of widgets) {
|
|
6689
|
+
if (widget.id === id) {
|
|
6690
|
+
return widget.newState;
|
|
6691
|
+
}
|
|
6692
|
+
}
|
|
6693
|
+
return undefined;
|
|
6694
|
+
};
|
|
6695
|
+
|
|
6696
|
+
const getCompletionState = editor => {
|
|
6697
|
+
return getWidgetState(editor, Completion);
|
|
6698
|
+
};
|
|
6699
|
+
|
|
6700
|
+
const closeDetails = editor => {
|
|
6701
|
+
const child = getCompletionState(editor);
|
|
6702
|
+
if (!child) {
|
|
6703
|
+
return editor;
|
|
6704
|
+
}
|
|
6705
|
+
console.log('open details');
|
|
6706
|
+
// TODO when completion details are open, close them
|
|
6707
|
+
// TODO when completion details are opening, close them
|
|
6708
|
+
// TODO when completion details are closed, open them
|
|
6709
|
+
return editor;
|
|
6664
6710
|
};
|
|
6665
6711
|
|
|
6666
6712
|
const isCompletion$1 = widget => {
|
|
@@ -6696,16 +6742,78 @@ const focusFirst$1 = editor => {
|
|
|
6696
6742
|
|
|
6697
6743
|
const focusNext$1 = editor => {
|
|
6698
6744
|
const child = getCompletionState(editor);
|
|
6745
|
+
if (!child) {
|
|
6746
|
+
return editor;
|
|
6747
|
+
}
|
|
6699
6748
|
const nextIndex = child.focusedIndex + 1;
|
|
6700
6749
|
return focusIndex$1(editor, nextIndex);
|
|
6701
6750
|
};
|
|
6702
6751
|
|
|
6703
6752
|
const focusPrevious$1 = editor => {
|
|
6704
6753
|
const child = getCompletionState(editor);
|
|
6754
|
+
if (!child) {
|
|
6755
|
+
return editor;
|
|
6756
|
+
}
|
|
6705
6757
|
const previousIndex = child.focusedIndex - 1;
|
|
6706
6758
|
return focusIndex$1(editor, previousIndex);
|
|
6707
6759
|
};
|
|
6708
6760
|
|
|
6761
|
+
const create = () => {
|
|
6762
|
+
const completionUid = create$2();
|
|
6763
|
+
const completionWidget = {
|
|
6764
|
+
id: CompletionDetail,
|
|
6765
|
+
oldState: {
|
|
6766
|
+
content: '',
|
|
6767
|
+
uid: completionUid,
|
|
6768
|
+
x: 0,
|
|
6769
|
+
y: 0,
|
|
6770
|
+
width: 0,
|
|
6771
|
+
height: 0
|
|
6772
|
+
},
|
|
6773
|
+
newState: {
|
|
6774
|
+
content: '',
|
|
6775
|
+
uid: completionUid,
|
|
6776
|
+
x: 0,
|
|
6777
|
+
y: 0,
|
|
6778
|
+
width: 0,
|
|
6779
|
+
height: 0
|
|
6780
|
+
}
|
|
6781
|
+
};
|
|
6782
|
+
return completionWidget;
|
|
6783
|
+
};
|
|
6784
|
+
|
|
6785
|
+
const getCompletionDetailState = editor => {
|
|
6786
|
+
return getWidgetState(editor, CompletionDetail);
|
|
6787
|
+
};
|
|
6788
|
+
|
|
6789
|
+
const openDetails = editor => {
|
|
6790
|
+
const child = getCompletionState(editor);
|
|
6791
|
+
if (!child) {
|
|
6792
|
+
return editor;
|
|
6793
|
+
}
|
|
6794
|
+
const detailState = getCompletionDetailState(editor);
|
|
6795
|
+
if (detailState) {
|
|
6796
|
+
return editor;
|
|
6797
|
+
}
|
|
6798
|
+
const widget = create();
|
|
6799
|
+
const newestState = {
|
|
6800
|
+
...widget.newState,
|
|
6801
|
+
content: 'abc',
|
|
6802
|
+
x: child.x + child.width,
|
|
6803
|
+
y: child.y,
|
|
6804
|
+
width: 100,
|
|
6805
|
+
height: 100
|
|
6806
|
+
};
|
|
6807
|
+
const latestWidgets = [...editor.widgets, {
|
|
6808
|
+
...widget,
|
|
6809
|
+
newState: newestState
|
|
6810
|
+
}];
|
|
6811
|
+
return {
|
|
6812
|
+
...editor,
|
|
6813
|
+
widgets: latestWidgets
|
|
6814
|
+
};
|
|
6815
|
+
};
|
|
6816
|
+
|
|
6709
6817
|
const getEdits = async (editor, completionItem) => {
|
|
6710
6818
|
const child = getCompletionState(editor);
|
|
6711
6819
|
// @ts-ignore
|
|
@@ -6755,6 +6863,9 @@ const select = async (editor, completionItem) => {
|
|
|
6755
6863
|
};
|
|
6756
6864
|
const selectIndex = (editor, index) => {
|
|
6757
6865
|
const child = getCompletionState(editor);
|
|
6866
|
+
if (!child) {
|
|
6867
|
+
return editor;
|
|
6868
|
+
}
|
|
6758
6869
|
const {
|
|
6759
6870
|
items
|
|
6760
6871
|
} = child;
|
|
@@ -6771,12 +6882,26 @@ const selectIndex = (editor, index) => {
|
|
|
6771
6882
|
|
|
6772
6883
|
const selectCurrent = editor => {
|
|
6773
6884
|
const child = getCompletionState(editor);
|
|
6885
|
+
if (!child) {
|
|
6886
|
+
return editor;
|
|
6887
|
+
}
|
|
6774
6888
|
const {
|
|
6775
6889
|
focusedIndex
|
|
6776
6890
|
} = child;
|
|
6777
6891
|
return selectIndex(editor, focusedIndex);
|
|
6778
6892
|
};
|
|
6779
6893
|
|
|
6894
|
+
const toggleDetails = editor => {
|
|
6895
|
+
const child = getCompletionState(editor);
|
|
6896
|
+
if (!child) {
|
|
6897
|
+
return editor;
|
|
6898
|
+
}
|
|
6899
|
+
// TODO when completion details are open, close them
|
|
6900
|
+
// TODO when completion details are opening, close them
|
|
6901
|
+
// TODO when completion details are closed, open them
|
|
6902
|
+
return editor;
|
|
6903
|
+
};
|
|
6904
|
+
|
|
6780
6905
|
const executeHoverProvider = (editor, offset) => {
|
|
6781
6906
|
object(editor);
|
|
6782
6907
|
number$1(offset);
|
|
@@ -6799,7 +6924,7 @@ const getHover = async (editor, offset) => {
|
|
|
6799
6924
|
|
|
6800
6925
|
let _ipc;
|
|
6801
6926
|
const listen$5 = async () => {
|
|
6802
|
-
const ipc = await create$
|
|
6927
|
+
const ipc = await create$4({
|
|
6803
6928
|
method: RendererProcess
|
|
6804
6929
|
});
|
|
6805
6930
|
handleIpc(ipc);
|
|
@@ -7123,7 +7248,7 @@ const renderHoverDom = {
|
|
|
7123
7248
|
return [/* method */'Viewlet.setDom2', dom];
|
|
7124
7249
|
}
|
|
7125
7250
|
};
|
|
7126
|
-
const renderBounds$
|
|
7251
|
+
const renderBounds$2 = {
|
|
7127
7252
|
isEqual(oldState, newState) {
|
|
7128
7253
|
return oldState.x === newState.x && oldState.y === newState.y && oldState.resizedWidth === newState.resizedWidth;
|
|
7129
7254
|
},
|
|
@@ -7141,10 +7266,10 @@ const renderBounds$1 = {
|
|
|
7141
7266
|
return [SetBounds, x, y, resizedWidth, height];
|
|
7142
7267
|
}
|
|
7143
7268
|
};
|
|
7144
|
-
const render$
|
|
7269
|
+
const render$5 = [renderHoverDom, renderBounds$2];
|
|
7145
7270
|
const renderHover = async (oldState, newState) => {
|
|
7146
7271
|
const commands = [];
|
|
7147
|
-
for (const item of render$
|
|
7272
|
+
for (const item of render$5) {
|
|
7148
7273
|
if (!item.isEqual(oldState, newState)) {
|
|
7149
7274
|
commands.push(item.apply(oldState, newState));
|
|
7150
7275
|
}
|
|
@@ -8262,7 +8387,7 @@ const renderItems = {
|
|
|
8262
8387
|
return ['setDom', dom];
|
|
8263
8388
|
}
|
|
8264
8389
|
};
|
|
8265
|
-
const renderBounds = {
|
|
8390
|
+
const renderBounds$1 = {
|
|
8266
8391
|
isEqual(oldState, newState) {
|
|
8267
8392
|
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.x === newState.x && oldState.y === newState.y;
|
|
8268
8393
|
},
|
|
@@ -8308,10 +8433,10 @@ const renderScrollBar = {
|
|
|
8308
8433
|
return [/* method */SetScrollBar, /* scrollBarY */scrollBarY, /* scrollBarHeight */scrollBarHeight];
|
|
8309
8434
|
}
|
|
8310
8435
|
};
|
|
8311
|
-
const render$
|
|
8436
|
+
const render$4 = [renderItems, renderBounds$1, renderHeight, renderNegativeMargin, renderScrollBar];
|
|
8312
8437
|
const renderCompletion = (oldState, newState) => {
|
|
8313
8438
|
const commands = [];
|
|
8314
|
-
for (const item of render$
|
|
8439
|
+
for (const item of render$4) {
|
|
8315
8440
|
if (!item.isEqual(oldState, newState)) {
|
|
8316
8441
|
commands.push(item.apply(oldState, newState));
|
|
8317
8442
|
}
|
|
@@ -8319,7 +8444,7 @@ const renderCompletion = (oldState, newState) => {
|
|
|
8319
8444
|
return commands;
|
|
8320
8445
|
};
|
|
8321
8446
|
|
|
8322
|
-
const render$
|
|
8447
|
+
const render$3 = (oldState, newState) => {
|
|
8323
8448
|
const commands = renderCompletion(oldState, newState);
|
|
8324
8449
|
const wrappedCommands = [];
|
|
8325
8450
|
const uid = newState.uid;
|
|
@@ -8328,8 +8453,8 @@ const render$1 = (oldState, newState) => {
|
|
|
8328
8453
|
}
|
|
8329
8454
|
return wrappedCommands;
|
|
8330
8455
|
};
|
|
8331
|
-
const add = widget => {
|
|
8332
|
-
const commands = render$
|
|
8456
|
+
const add$1 = widget => {
|
|
8457
|
+
const commands = render$3(widget.oldState, widget.newState);
|
|
8333
8458
|
const id = 'EditorCompletion';
|
|
8334
8459
|
// TODO how to generate a unique integer id
|
|
8335
8460
|
// that doesn't collide with ids created in renderer worker?
|
|
@@ -8339,7 +8464,7 @@ const add = widget => {
|
|
|
8339
8464
|
allCommands.push(...commands);
|
|
8340
8465
|
return allCommands;
|
|
8341
8466
|
};
|
|
8342
|
-
const remove = widget => {
|
|
8467
|
+
const remove$1 = widget => {
|
|
8343
8468
|
return [['Viewlet.send', widget.newState.uid, 'dispose']];
|
|
8344
8469
|
};
|
|
8345
8470
|
const handleEditorType = (editor, state) => {
|
|
@@ -8406,11 +8531,96 @@ const handleEditorDeleteLeft = (editor, state) => {
|
|
|
8406
8531
|
|
|
8407
8532
|
const EditorCompletionWidget = {
|
|
8408
8533
|
__proto__: null,
|
|
8409
|
-
add,
|
|
8534
|
+
add: add$1,
|
|
8410
8535
|
handleEditorDeleteLeft,
|
|
8411
8536
|
handleEditorType,
|
|
8412
|
-
remove,
|
|
8413
|
-
render: render$
|
|
8537
|
+
remove: remove$1,
|
|
8538
|
+
render: render$3
|
|
8539
|
+
};
|
|
8540
|
+
|
|
8541
|
+
const getCompletionDetailVirtualDom = content => {
|
|
8542
|
+
const dom = [{
|
|
8543
|
+
type: Div,
|
|
8544
|
+
className: 'Viewlet EditorCompletionDetails',
|
|
8545
|
+
childCount: 2
|
|
8546
|
+
}, {
|
|
8547
|
+
type: Div,
|
|
8548
|
+
className: CompletionDetailContent,
|
|
8549
|
+
childCount: 1
|
|
8550
|
+
}, text(content), {
|
|
8551
|
+
type: Div,
|
|
8552
|
+
className: CompletionDetailCloseButton,
|
|
8553
|
+
onClick: HandleClose,
|
|
8554
|
+
childCount: 1
|
|
8555
|
+
}, {
|
|
8556
|
+
type: Div,
|
|
8557
|
+
className: `${MaskIcon} ${IconClose}`,
|
|
8558
|
+
childCount: 0
|
|
8559
|
+
}];
|
|
8560
|
+
return dom;
|
|
8561
|
+
};
|
|
8562
|
+
|
|
8563
|
+
const renderContent = {
|
|
8564
|
+
isEqual(oldState, newState) {
|
|
8565
|
+
return oldState.content === newState.content;
|
|
8566
|
+
},
|
|
8567
|
+
apply(oldState, newState) {
|
|
8568
|
+
const dom = getCompletionDetailVirtualDom(newState.content);
|
|
8569
|
+
return ['Viewlet.setDom2', newState.uid, dom];
|
|
8570
|
+
}
|
|
8571
|
+
};
|
|
8572
|
+
const renderBounds = {
|
|
8573
|
+
isEqual(oldState, newState) {
|
|
8574
|
+
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
8575
|
+
},
|
|
8576
|
+
apply(oldState, newState) {
|
|
8577
|
+
const {
|
|
8578
|
+
x,
|
|
8579
|
+
y,
|
|
8580
|
+
width,
|
|
8581
|
+
height
|
|
8582
|
+
} = newState;
|
|
8583
|
+
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
8584
|
+
}
|
|
8585
|
+
};
|
|
8586
|
+
const render$2 = [renderContent, renderBounds];
|
|
8587
|
+
const renderFull = (oldState, newState) => {
|
|
8588
|
+
const commands = [];
|
|
8589
|
+
for (const item of render$2) {
|
|
8590
|
+
if (!item.isEqual(oldState, newState)) {
|
|
8591
|
+
commands.push(item.apply(oldState, newState));
|
|
8592
|
+
}
|
|
8593
|
+
}
|
|
8594
|
+
return commands;
|
|
8595
|
+
};
|
|
8596
|
+
|
|
8597
|
+
const render$1 = (oldState, newState) => {
|
|
8598
|
+
const commands = renderFull(oldState, newState);
|
|
8599
|
+
const wrappedCommands = [];
|
|
8600
|
+
const uid = newState.uid;
|
|
8601
|
+
for (const command of commands) {
|
|
8602
|
+
if (command[0] === 'Viewlet.setDom2') {
|
|
8603
|
+
wrappedCommands.push(command);
|
|
8604
|
+
} else {
|
|
8605
|
+
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
8606
|
+
}
|
|
8607
|
+
}
|
|
8608
|
+
return wrappedCommands;
|
|
8609
|
+
};
|
|
8610
|
+
const add = widget => {
|
|
8611
|
+
const commands = render$1(widget.oldState, widget.newState);
|
|
8612
|
+
const id = 'EditorCompletionDetails';
|
|
8613
|
+
// TODO how to generate a unique integer id
|
|
8614
|
+
// that doesn't collide with ids created in renderer worker?
|
|
8615
|
+
const uid = widget.newState.uid;
|
|
8616
|
+
const allCommands = [];
|
|
8617
|
+
allCommands.push(['Viewlet.createFunctionalRoot', id, uid]);
|
|
8618
|
+
allCommands.push(...commands);
|
|
8619
|
+
allCommands.push(['Viewlet.send', uid, 'appendWidget']);
|
|
8620
|
+
return allCommands;
|
|
8621
|
+
};
|
|
8622
|
+
const remove = widget => {
|
|
8623
|
+
return [['Viewlet.send', widget.newState.uid, 'dispose']];
|
|
8414
8624
|
};
|
|
8415
8625
|
|
|
8416
8626
|
const addWidget = widget => {
|
|
@@ -8419,6 +8629,8 @@ const addWidget = widget => {
|
|
|
8419
8629
|
} = widget;
|
|
8420
8630
|
switch (id) {
|
|
8421
8631
|
case Completion:
|
|
8632
|
+
return add$1(widget);
|
|
8633
|
+
case CompletionDetail:
|
|
8422
8634
|
return add(widget);
|
|
8423
8635
|
default:
|
|
8424
8636
|
throw new Error('unsupported widget');
|
|
@@ -8430,6 +8642,8 @@ const renderWidget = widget => {
|
|
|
8430
8642
|
} = widget;
|
|
8431
8643
|
switch (id) {
|
|
8432
8644
|
case Completion:
|
|
8645
|
+
return render$3(widget.oldState, widget.newState);
|
|
8646
|
+
case CompletionDetail:
|
|
8433
8647
|
return render$1(widget.oldState, widget.newState);
|
|
8434
8648
|
default:
|
|
8435
8649
|
throw new Error(`unsupported widget`);
|
|
@@ -8441,6 +8655,8 @@ const removeWidget = widget => {
|
|
|
8441
8655
|
} = widget;
|
|
8442
8656
|
switch (id) {
|
|
8443
8657
|
case Completion:
|
|
8658
|
+
return remove$1(widget);
|
|
8659
|
+
case CompletionDetail:
|
|
8444
8660
|
return remove(widget);
|
|
8445
8661
|
default:
|
|
8446
8662
|
throw new Error('unsupported widget');
|
|
@@ -8783,6 +8999,7 @@ const commandMap = {
|
|
|
8783
8999
|
'Editor.undo': undo,
|
|
8784
9000
|
'Editor.unIndent': editorUnindent,
|
|
8785
9001
|
'EditorCompletion.advance': advance,
|
|
9002
|
+
'EditorCompletion.closeDetails': closeDetails,
|
|
8786
9003
|
'EditorCompletion.focusFirst': focusFirst$1,
|
|
8787
9004
|
'EditorCompletion.focusIndex': focusIndex$1,
|
|
8788
9005
|
'EditorCompletion.focusNext': focusNext$1,
|
|
@@ -8792,8 +9009,10 @@ const commandMap = {
|
|
|
8792
9009
|
'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$1,
|
|
8793
9010
|
'EditorCompletion.handleEditorType': handleEditorType$1,
|
|
8794
9011
|
'EditorCompletion.loadContent': loadContent$2,
|
|
9012
|
+
'EditorCompletion.openDetails': openDetails,
|
|
8795
9013
|
'EditorCompletion.selectCurrent': selectCurrent,
|
|
8796
9014
|
'EditorCompletion.selectIndex': selectIndex,
|
|
9015
|
+
'EditorCompletion.toggleDetails': toggleDetails,
|
|
8797
9016
|
'FindWidget.focusFirst': focusFirst,
|
|
8798
9017
|
'FindWidget.focusIndex': focusIndex,
|
|
8799
9018
|
'FindWidget.focusLast': focusLast,
|