@lvce-editor/hover-worker 1.0.0 → 1.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/hoverWorkerMain.js +177 -21
- package/package.json +1 -1
package/dist/hoverWorkerMain.js
CHANGED
|
@@ -979,6 +979,8 @@ const createMockRpc = ({
|
|
|
979
979
|
return mockRpc;
|
|
980
980
|
};
|
|
981
981
|
|
|
982
|
+
const Text = 12;
|
|
983
|
+
|
|
982
984
|
const EditorWorker$1 = 99;
|
|
983
985
|
const ExtensionHostWorker = 44;
|
|
984
986
|
|
|
@@ -1052,7 +1054,7 @@ const getLines = async editorUid => {
|
|
|
1052
1054
|
const lines = await invoke$2('Editor.getLines2', editorUid);
|
|
1053
1055
|
return lines;
|
|
1054
1056
|
};
|
|
1055
|
-
const getPositionAtCursor = async parentUid => {
|
|
1057
|
+
const getPositionAtCursor$1 = async parentUid => {
|
|
1056
1058
|
const position = await invoke$2('Editor.getPositionAtCursor', parentUid);
|
|
1057
1059
|
return position;
|
|
1058
1060
|
};
|
|
@@ -1064,7 +1066,7 @@ const getSelections = async editorUid => {
|
|
|
1064
1066
|
const selections = await invoke$2('Editor.getSelections2', editorUid);
|
|
1065
1067
|
return selections;
|
|
1066
1068
|
};
|
|
1067
|
-
const getWordAtOffset2 = async editorUid => {
|
|
1069
|
+
const getWordAtOffset2$1 = async editorUid => {
|
|
1068
1070
|
return invoke$2('Editor.getWordAtOffset2', editorUid);
|
|
1069
1071
|
};
|
|
1070
1072
|
const getWordBefore = async (editorUid, rowIndex, columnIndex) => {
|
|
@@ -1103,12 +1105,12 @@ const EditorWorker = {
|
|
|
1103
1105
|
getLanguageId,
|
|
1104
1106
|
getLines,
|
|
1105
1107
|
getOffsetAtCursor,
|
|
1106
|
-
getPositionAtCursor,
|
|
1108
|
+
getPositionAtCursor: getPositionAtCursor$1,
|
|
1107
1109
|
getProblems,
|
|
1108
1110
|
getSelections,
|
|
1109
1111
|
getUri,
|
|
1110
1112
|
getWordAt,
|
|
1111
|
-
getWordAtOffset2,
|
|
1113
|
+
getWordAtOffset2: getWordAtOffset2$1,
|
|
1112
1114
|
getWordBefore,
|
|
1113
1115
|
invoke: invoke$2,
|
|
1114
1116
|
invokeAndTransfer: invokeAndTransfer$2,
|
|
@@ -1159,7 +1161,8 @@ const ExtensionHost = {
|
|
|
1159
1161
|
const {
|
|
1160
1162
|
invoke,
|
|
1161
1163
|
set: set$2,
|
|
1162
|
-
invokeAndTransfer
|
|
1164
|
+
invokeAndTransfer,
|
|
1165
|
+
getWordAtOffset2
|
|
1163
1166
|
} = EditorWorker;
|
|
1164
1167
|
|
|
1165
1168
|
const FocusEditorHovers = 9;
|
|
@@ -1276,35 +1279,49 @@ const create = (uid, x, y, width, height, editorUid, editorLanguageId) => {
|
|
|
1276
1279
|
leadingWord: '',
|
|
1277
1280
|
version: 0,
|
|
1278
1281
|
editorUid,
|
|
1279
|
-
editorLanguageId
|
|
1282
|
+
editorLanguageId,
|
|
1283
|
+
fallbackDisplayStringLanguageId: 'typescript',
|
|
1284
|
+
hoverDocumentationFontSize: 15,
|
|
1285
|
+
hoverDocumentationFontFamily: 'Fira Code',
|
|
1286
|
+
hoverDocumentationLineHeight: '1.33333',
|
|
1287
|
+
hoverBorderLeft: 1,
|
|
1288
|
+
hoverBorderRight: 1,
|
|
1289
|
+
hoverPaddingLeft: 8,
|
|
1290
|
+
hoverPaddingRight: 8,
|
|
1291
|
+
hovverFullWidth: 400
|
|
1280
1292
|
};
|
|
1281
1293
|
set$1(uid, state, state);
|
|
1282
1294
|
};
|
|
1283
1295
|
|
|
1284
|
-
const isEqual$
|
|
1296
|
+
const isEqual$4 = (oldState, newState) => {
|
|
1285
1297
|
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
1286
1298
|
};
|
|
1287
1299
|
|
|
1300
|
+
const isEqual$3 = (oldState, newState) => {
|
|
1301
|
+
return oldState.version === newState.version;
|
|
1302
|
+
};
|
|
1303
|
+
|
|
1288
1304
|
const isEqual$2 = (oldState, newState) => {
|
|
1289
1305
|
return oldState.version === newState.version;
|
|
1290
1306
|
};
|
|
1291
1307
|
|
|
1292
1308
|
const isEqual$1 = (oldState, newState) => {
|
|
1293
|
-
return oldState.
|
|
1309
|
+
return oldState.leadingWord === newState.leadingWord && oldState.x === newState.x && oldState.y === newState.y;
|
|
1294
1310
|
};
|
|
1295
1311
|
|
|
1296
1312
|
const isEqual = (oldState, newState) => {
|
|
1297
1313
|
return oldState.version === newState.version;
|
|
1298
1314
|
};
|
|
1299
1315
|
|
|
1316
|
+
const RenderItems = 1;
|
|
1300
1317
|
const RenderBounds = 8;
|
|
1301
1318
|
const RenderEventListeners = 11;
|
|
1302
1319
|
const RenderUid = 12;
|
|
1303
1320
|
const RenderContent = 13;
|
|
1304
1321
|
const RenderFocusContext = 14;
|
|
1305
1322
|
|
|
1306
|
-
const modules = [isEqual$
|
|
1307
|
-
const numbers = [RenderEventListeners, RenderBounds, RenderUid, RenderFocusContext];
|
|
1323
|
+
const modules = [isEqual$3, isEqual$1, isEqual$4, isEqual, isEqual$2];
|
|
1324
|
+
const numbers = [RenderEventListeners, RenderItems, RenderBounds, RenderUid, RenderFocusContext];
|
|
1308
1325
|
|
|
1309
1326
|
const diff = (oldState, newState) => {
|
|
1310
1327
|
const diffResult = [];
|
|
@@ -1384,6 +1401,18 @@ const getKeyBindings = () => {
|
|
|
1384
1401
|
}];
|
|
1385
1402
|
};
|
|
1386
1403
|
|
|
1404
|
+
const handleSashPointerDown = (state, eventX, eventY) => {
|
|
1405
|
+
return state;
|
|
1406
|
+
};
|
|
1407
|
+
|
|
1408
|
+
const handleSashPointerMove = (state, eventX, eventY) => {
|
|
1409
|
+
return state;
|
|
1410
|
+
};
|
|
1411
|
+
|
|
1412
|
+
const handleSashPointerUp = (state, eventX, eventY) => {
|
|
1413
|
+
return state;
|
|
1414
|
+
};
|
|
1415
|
+
|
|
1387
1416
|
const getPortTuple = () => {
|
|
1388
1417
|
const {
|
|
1389
1418
|
port1,
|
|
@@ -1430,9 +1459,27 @@ const initialize = async () => {
|
|
|
1430
1459
|
set(rpc);
|
|
1431
1460
|
};
|
|
1432
1461
|
|
|
1462
|
+
const getPositionAtCursor = async editorUid => {
|
|
1463
|
+
const position = await invoke('Editor.getPositionAtCursor', editorUid);
|
|
1464
|
+
return position;
|
|
1465
|
+
};
|
|
1466
|
+
|
|
1467
|
+
const getWordAtOffset = getWordAtOffset2;
|
|
1468
|
+
|
|
1433
1469
|
const loadContent = async state => {
|
|
1470
|
+
const {
|
|
1471
|
+
editorUid
|
|
1472
|
+
} = state;
|
|
1473
|
+
const wordAtOffset = await getWordAtOffset(editorUid);
|
|
1474
|
+
const {
|
|
1475
|
+
x,
|
|
1476
|
+
y
|
|
1477
|
+
} = await getPositionAtCursor(editorUid);
|
|
1434
1478
|
return {
|
|
1435
|
-
...state
|
|
1479
|
+
...state,
|
|
1480
|
+
leadingWord: wordAtOffset,
|
|
1481
|
+
x,
|
|
1482
|
+
y
|
|
1436
1483
|
};
|
|
1437
1484
|
};
|
|
1438
1485
|
|
|
@@ -1460,6 +1507,7 @@ const renderContent = (oldState, newState) => {
|
|
|
1460
1507
|
return [SetDom2, uid, dom];
|
|
1461
1508
|
};
|
|
1462
1509
|
|
|
1510
|
+
const HandleSashPointerDown = 'handleSashPointerDown';
|
|
1463
1511
|
const HandleWheel = 'handleWheel';
|
|
1464
1512
|
|
|
1465
1513
|
const getEventListeners = () => {
|
|
@@ -1482,6 +1530,109 @@ const renderFocusContext = (oldState, newState) => {
|
|
|
1482
1530
|
return [/* method */'Viewlet.setFocusContext', FocusEditorRename];
|
|
1483
1531
|
};
|
|
1484
1532
|
|
|
1533
|
+
const HoverDisplayString = 'HoverDisplayString';
|
|
1534
|
+
const HoverDocumentation = 'HoverDocumentation';
|
|
1535
|
+
const HoverEditorRow = 'HoverEditorRow';
|
|
1536
|
+
const HoverProblem = 'HoverProblem';
|
|
1537
|
+
const HoverProblemDetail = 'HoverProblemDetail';
|
|
1538
|
+
const HoverProblemMessage = 'HoverProblemMessage';
|
|
1539
|
+
|
|
1540
|
+
const Div = 4;
|
|
1541
|
+
const Span = 8;
|
|
1542
|
+
|
|
1543
|
+
const text = data => {
|
|
1544
|
+
return {
|
|
1545
|
+
type: Text,
|
|
1546
|
+
text: data,
|
|
1547
|
+
childCount: 0
|
|
1548
|
+
};
|
|
1549
|
+
};
|
|
1550
|
+
|
|
1551
|
+
const getLineInfoVirtualDom = lineInfo => {
|
|
1552
|
+
const dom = [{
|
|
1553
|
+
type: Div,
|
|
1554
|
+
className: HoverEditorRow,
|
|
1555
|
+
childCount: lineInfo.length / 2
|
|
1556
|
+
}];
|
|
1557
|
+
for (let i = 0; i < lineInfo.length; i += 2) {
|
|
1558
|
+
const tokenText = lineInfo[i];
|
|
1559
|
+
const tokenClass = lineInfo[i + 1];
|
|
1560
|
+
dom.push({
|
|
1561
|
+
type: Span,
|
|
1562
|
+
className: tokenClass,
|
|
1563
|
+
childCount: 1
|
|
1564
|
+
}, text(tokenText));
|
|
1565
|
+
}
|
|
1566
|
+
return dom;
|
|
1567
|
+
};
|
|
1568
|
+
const getLineInfosVirtualDom = lineInfos => {
|
|
1569
|
+
const dom = lineInfos.flatMap(getLineInfoVirtualDom);
|
|
1570
|
+
return dom;
|
|
1571
|
+
};
|
|
1572
|
+
|
|
1573
|
+
const hoverProblemMessage = {
|
|
1574
|
+
type: Span,
|
|
1575
|
+
className: HoverProblemMessage,
|
|
1576
|
+
childCount: 1
|
|
1577
|
+
};
|
|
1578
|
+
const hoverProblemDetail = {
|
|
1579
|
+
type: Span,
|
|
1580
|
+
className: HoverProblemDetail,
|
|
1581
|
+
childCount: 1
|
|
1582
|
+
};
|
|
1583
|
+
const getChildCount = (lineInfos, documentation, diagnostics) => {
|
|
1584
|
+
const diagnosticsCount = diagnostics && diagnostics.length > 0 ? 1 : 0;
|
|
1585
|
+
return lineInfos.length + documentation ? 1 : 0 + diagnosticsCount;
|
|
1586
|
+
};
|
|
1587
|
+
const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
|
|
1588
|
+
const dom = [];
|
|
1589
|
+
dom.push({
|
|
1590
|
+
type: Div,
|
|
1591
|
+
className: 'Viewlet EditorHover',
|
|
1592
|
+
childCount: getChildCount(lineInfos, documentation, diagnostics) + 1
|
|
1593
|
+
});
|
|
1594
|
+
if (diagnostics && diagnostics.length > 0) {
|
|
1595
|
+
dom.push({
|
|
1596
|
+
type: Div,
|
|
1597
|
+
className: `${HoverDisplayString} ${HoverProblem}`,
|
|
1598
|
+
childCount: diagnostics.length * 2
|
|
1599
|
+
});
|
|
1600
|
+
for (const diagnostic of diagnostics) {
|
|
1601
|
+
dom.push(hoverProblemMessage, text(diagnostic.message), hoverProblemDetail, text(`${diagnostic.source} (${diagnostic.code})`));
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
if (lineInfos.length > 0) {
|
|
1605
|
+
const lineInfosDom = getLineInfosVirtualDom(lineInfos);
|
|
1606
|
+
dom.push({
|
|
1607
|
+
type: Div,
|
|
1608
|
+
className: HoverDisplayString,
|
|
1609
|
+
childCount: lineInfos.length
|
|
1610
|
+
}, ...lineInfosDom);
|
|
1611
|
+
}
|
|
1612
|
+
if (documentation) {
|
|
1613
|
+
dom.push({
|
|
1614
|
+
type: Div,
|
|
1615
|
+
className: HoverDocumentation,
|
|
1616
|
+
childCount: 1
|
|
1617
|
+
}, text(documentation));
|
|
1618
|
+
}
|
|
1619
|
+
dom.push({
|
|
1620
|
+
type: Div,
|
|
1621
|
+
className: 'Sash SashVertical SashResize',
|
|
1622
|
+
childCount: 0,
|
|
1623
|
+
onPointerDown: HandleSashPointerDown
|
|
1624
|
+
});
|
|
1625
|
+
return dom;
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1628
|
+
const renderItems = (oldState, newState) => {
|
|
1629
|
+
const {
|
|
1630
|
+
uid
|
|
1631
|
+
} = newState;
|
|
1632
|
+
const dom = getHoverVirtualDom([], {}, {});
|
|
1633
|
+
return [/* method */'Viewlet.setDom2', uid, dom];
|
|
1634
|
+
};
|
|
1635
|
+
|
|
1485
1636
|
const renderUid = (oldState, newState) => {
|
|
1486
1637
|
const {
|
|
1487
1638
|
uid,
|
|
@@ -1502,6 +1653,8 @@ const getRenderer = diffType => {
|
|
|
1502
1653
|
return renderUid;
|
|
1503
1654
|
case RenderFocusContext:
|
|
1504
1655
|
return renderFocusContext;
|
|
1656
|
+
case RenderItems:
|
|
1657
|
+
return renderItems;
|
|
1505
1658
|
default:
|
|
1506
1659
|
throw new Error('unknown renderer');
|
|
1507
1660
|
}
|
|
@@ -1531,16 +1684,19 @@ const terminate = () => {
|
|
|
1531
1684
|
};
|
|
1532
1685
|
|
|
1533
1686
|
const commandMap = {
|
|
1534
|
-
'
|
|
1535
|
-
'
|
|
1536
|
-
'
|
|
1537
|
-
'
|
|
1538
|
-
'
|
|
1539
|
-
'
|
|
1540
|
-
'
|
|
1541
|
-
'
|
|
1542
|
-
'
|
|
1543
|
-
'
|
|
1687
|
+
'Hover.close': wrapCommand(close),
|
|
1688
|
+
'Hover.create': create,
|
|
1689
|
+
'Hover.diff2': diff2,
|
|
1690
|
+
'Hover.dispose': dispose,
|
|
1691
|
+
'Hover.getCommandIds': getCommandIds,
|
|
1692
|
+
'Hover.getKeyBindings': getKeyBindings,
|
|
1693
|
+
'Hover.initialize': initialize,
|
|
1694
|
+
'Hover.loadContent': wrapCommand(loadContent),
|
|
1695
|
+
'Hover.render2': render2,
|
|
1696
|
+
'Hover.handleSashPointerUp': wrapCommand(handleSashPointerUp),
|
|
1697
|
+
'Hover.handleSashPointerDown': wrapCommand(handleSashPointerDown),
|
|
1698
|
+
'Hover.handleSashPointerMove': wrapCommand(handleSashPointerMove),
|
|
1699
|
+
'Hover.terminate': terminate
|
|
1544
1700
|
};
|
|
1545
1701
|
|
|
1546
1702
|
const listen = async () => {
|