@lvce-editor/hover-worker 1.0.0 → 1.1.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 +139 -16
- 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
|
|
|
@@ -1276,35 +1278,49 @@ const create = (uid, x, y, width, height, editorUid, editorLanguageId) => {
|
|
|
1276
1278
|
leadingWord: '',
|
|
1277
1279
|
version: 0,
|
|
1278
1280
|
editorUid,
|
|
1279
|
-
editorLanguageId
|
|
1281
|
+
editorLanguageId,
|
|
1282
|
+
fallbackDisplayStringLanguageId: 'typescript',
|
|
1283
|
+
hoverDocumentationFontSize: 15,
|
|
1284
|
+
hoverDocumentationFontFamily: 'Fira Code',
|
|
1285
|
+
hoverDocumentationLineHeight: '1.33333',
|
|
1286
|
+
hoverBorderLeft: 1,
|
|
1287
|
+
hoverBorderRight: 1,
|
|
1288
|
+
hoverPaddingLeft: 8,
|
|
1289
|
+
hoverPaddingRight: 8,
|
|
1290
|
+
hovverFullWidth: 400
|
|
1280
1291
|
};
|
|
1281
1292
|
set$1(uid, state, state);
|
|
1282
1293
|
};
|
|
1283
1294
|
|
|
1284
|
-
const isEqual$
|
|
1295
|
+
const isEqual$4 = (oldState, newState) => {
|
|
1285
1296
|
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
1286
1297
|
};
|
|
1287
1298
|
|
|
1299
|
+
const isEqual$3 = (oldState, newState) => {
|
|
1300
|
+
return oldState.version === newState.version;
|
|
1301
|
+
};
|
|
1302
|
+
|
|
1288
1303
|
const isEqual$2 = (oldState, newState) => {
|
|
1289
1304
|
return oldState.version === newState.version;
|
|
1290
1305
|
};
|
|
1291
1306
|
|
|
1292
1307
|
const isEqual$1 = (oldState, newState) => {
|
|
1293
|
-
return oldState.
|
|
1308
|
+
return oldState.leadingWord === newState.leadingWord;
|
|
1294
1309
|
};
|
|
1295
1310
|
|
|
1296
1311
|
const isEqual = (oldState, newState) => {
|
|
1297
1312
|
return oldState.version === newState.version;
|
|
1298
1313
|
};
|
|
1299
1314
|
|
|
1315
|
+
const RenderItems = 1;
|
|
1300
1316
|
const RenderBounds = 8;
|
|
1301
1317
|
const RenderEventListeners = 11;
|
|
1302
1318
|
const RenderUid = 12;
|
|
1303
1319
|
const RenderContent = 13;
|
|
1304
1320
|
const RenderFocusContext = 14;
|
|
1305
1321
|
|
|
1306
|
-
const modules = [isEqual$
|
|
1307
|
-
const numbers = [RenderEventListeners, RenderBounds, RenderUid, RenderFocusContext];
|
|
1322
|
+
const modules = [isEqual$3, isEqual$1, isEqual$4, isEqual, isEqual$2];
|
|
1323
|
+
const numbers = [RenderEventListeners, RenderItems, RenderBounds, RenderUid, RenderFocusContext];
|
|
1308
1324
|
|
|
1309
1325
|
const diff = (oldState, newState) => {
|
|
1310
1326
|
const diffResult = [];
|
|
@@ -1432,7 +1448,8 @@ const initialize = async () => {
|
|
|
1432
1448
|
|
|
1433
1449
|
const loadContent = async state => {
|
|
1434
1450
|
return {
|
|
1435
|
-
...state
|
|
1451
|
+
...state,
|
|
1452
|
+
leadingWord: 'abc'
|
|
1436
1453
|
};
|
|
1437
1454
|
};
|
|
1438
1455
|
|
|
@@ -1460,6 +1477,7 @@ const renderContent = (oldState, newState) => {
|
|
|
1460
1477
|
return [SetDom2, uid, dom];
|
|
1461
1478
|
};
|
|
1462
1479
|
|
|
1480
|
+
const HandleSashPointerDown = 'handleSashPointerDown';
|
|
1463
1481
|
const HandleWheel = 'handleWheel';
|
|
1464
1482
|
|
|
1465
1483
|
const getEventListeners = () => {
|
|
@@ -1482,6 +1500,109 @@ const renderFocusContext = (oldState, newState) => {
|
|
|
1482
1500
|
return [/* method */'Viewlet.setFocusContext', FocusEditorRename];
|
|
1483
1501
|
};
|
|
1484
1502
|
|
|
1503
|
+
const HoverDisplayString = 'HoverDisplayString';
|
|
1504
|
+
const HoverDocumentation = 'HoverDocumentation';
|
|
1505
|
+
const HoverEditorRow = 'HoverEditorRow';
|
|
1506
|
+
const HoverProblem = 'HoverProblem';
|
|
1507
|
+
const HoverProblemDetail = 'HoverProblemDetail';
|
|
1508
|
+
const HoverProblemMessage = 'HoverProblemMessage';
|
|
1509
|
+
|
|
1510
|
+
const Div = 4;
|
|
1511
|
+
const Span = 8;
|
|
1512
|
+
|
|
1513
|
+
const text = data => {
|
|
1514
|
+
return {
|
|
1515
|
+
type: Text,
|
|
1516
|
+
text: data,
|
|
1517
|
+
childCount: 0
|
|
1518
|
+
};
|
|
1519
|
+
};
|
|
1520
|
+
|
|
1521
|
+
const getLineInfoVirtualDom = lineInfo => {
|
|
1522
|
+
const dom = [{
|
|
1523
|
+
type: Div,
|
|
1524
|
+
className: HoverEditorRow,
|
|
1525
|
+
childCount: lineInfo.length / 2
|
|
1526
|
+
}];
|
|
1527
|
+
for (let i = 0; i < lineInfo.length; i += 2) {
|
|
1528
|
+
const tokenText = lineInfo[i];
|
|
1529
|
+
const tokenClass = lineInfo[i + 1];
|
|
1530
|
+
dom.push({
|
|
1531
|
+
type: Span,
|
|
1532
|
+
className: tokenClass,
|
|
1533
|
+
childCount: 1
|
|
1534
|
+
}, text(tokenText));
|
|
1535
|
+
}
|
|
1536
|
+
return dom;
|
|
1537
|
+
};
|
|
1538
|
+
const getLineInfosVirtualDom = lineInfos => {
|
|
1539
|
+
const dom = lineInfos.flatMap(getLineInfoVirtualDom);
|
|
1540
|
+
return dom;
|
|
1541
|
+
};
|
|
1542
|
+
|
|
1543
|
+
const hoverProblemMessage = {
|
|
1544
|
+
type: Span,
|
|
1545
|
+
className: HoverProblemMessage,
|
|
1546
|
+
childCount: 1
|
|
1547
|
+
};
|
|
1548
|
+
const hoverProblemDetail = {
|
|
1549
|
+
type: Span,
|
|
1550
|
+
className: HoverProblemDetail,
|
|
1551
|
+
childCount: 1
|
|
1552
|
+
};
|
|
1553
|
+
const getChildCount = (lineInfos, documentation, diagnostics) => {
|
|
1554
|
+
const diagnosticsCount = diagnostics && diagnostics.length > 0 ? 1 : 0;
|
|
1555
|
+
return lineInfos.length + documentation ? 1 : 0 + diagnosticsCount;
|
|
1556
|
+
};
|
|
1557
|
+
const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
|
|
1558
|
+
const dom = [];
|
|
1559
|
+
dom.push({
|
|
1560
|
+
type: Div,
|
|
1561
|
+
className: 'Viewlet EditorHover',
|
|
1562
|
+
childCount: getChildCount(lineInfos, documentation, diagnostics) + 1
|
|
1563
|
+
});
|
|
1564
|
+
if (diagnostics && diagnostics.length > 0) {
|
|
1565
|
+
dom.push({
|
|
1566
|
+
type: Div,
|
|
1567
|
+
className: `${HoverDisplayString} ${HoverProblem}`,
|
|
1568
|
+
childCount: diagnostics.length * 2
|
|
1569
|
+
});
|
|
1570
|
+
for (const diagnostic of diagnostics) {
|
|
1571
|
+
dom.push(hoverProblemMessage, text(diagnostic.message), hoverProblemDetail, text(`${diagnostic.source} (${diagnostic.code})`));
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
if (lineInfos.length > 0) {
|
|
1575
|
+
const lineInfosDom = getLineInfosVirtualDom(lineInfos);
|
|
1576
|
+
dom.push({
|
|
1577
|
+
type: Div,
|
|
1578
|
+
className: HoverDisplayString,
|
|
1579
|
+
childCount: lineInfos.length
|
|
1580
|
+
}, ...lineInfosDom);
|
|
1581
|
+
}
|
|
1582
|
+
if (documentation) {
|
|
1583
|
+
dom.push({
|
|
1584
|
+
type: Div,
|
|
1585
|
+
className: HoverDocumentation,
|
|
1586
|
+
childCount: 1
|
|
1587
|
+
}, text(documentation));
|
|
1588
|
+
}
|
|
1589
|
+
dom.push({
|
|
1590
|
+
type: Div,
|
|
1591
|
+
className: 'Sash SashVertical SashResize',
|
|
1592
|
+
childCount: 0,
|
|
1593
|
+
onPointerDown: HandleSashPointerDown
|
|
1594
|
+
});
|
|
1595
|
+
return dom;
|
|
1596
|
+
};
|
|
1597
|
+
|
|
1598
|
+
const renderItems = (oldState, newState) => {
|
|
1599
|
+
const {
|
|
1600
|
+
uid
|
|
1601
|
+
} = newState;
|
|
1602
|
+
const dom = getHoverVirtualDom([], {}, {});
|
|
1603
|
+
return [/* method */'Viewlet.setDom2', uid, dom];
|
|
1604
|
+
};
|
|
1605
|
+
|
|
1485
1606
|
const renderUid = (oldState, newState) => {
|
|
1486
1607
|
const {
|
|
1487
1608
|
uid,
|
|
@@ -1502,6 +1623,8 @@ const getRenderer = diffType => {
|
|
|
1502
1623
|
return renderUid;
|
|
1503
1624
|
case RenderFocusContext:
|
|
1504
1625
|
return renderFocusContext;
|
|
1626
|
+
case RenderItems:
|
|
1627
|
+
return renderItems;
|
|
1505
1628
|
default:
|
|
1506
1629
|
throw new Error('unknown renderer');
|
|
1507
1630
|
}
|
|
@@ -1531,16 +1654,16 @@ const terminate = () => {
|
|
|
1531
1654
|
};
|
|
1532
1655
|
|
|
1533
1656
|
const commandMap = {
|
|
1534
|
-
'
|
|
1535
|
-
'
|
|
1536
|
-
'
|
|
1537
|
-
'
|
|
1538
|
-
'
|
|
1539
|
-
'
|
|
1540
|
-
'
|
|
1541
|
-
'
|
|
1542
|
-
'
|
|
1543
|
-
'
|
|
1657
|
+
'Hover.close': wrapCommand(close),
|
|
1658
|
+
'Hover.create': create,
|
|
1659
|
+
'Hover.diff2': diff2,
|
|
1660
|
+
'Hover.dispose': dispose,
|
|
1661
|
+
'Hover.getCommandIds': getCommandIds,
|
|
1662
|
+
'Hover.getKeyBindings': getKeyBindings,
|
|
1663
|
+
'Hover.initialize': initialize,
|
|
1664
|
+
'Hover.loadContent': wrapCommand(loadContent),
|
|
1665
|
+
'Hover.render2': render2,
|
|
1666
|
+
'Hover.terminate': terminate
|
|
1544
1667
|
};
|
|
1545
1668
|
|
|
1546
1669
|
const listen = async () => {
|