@lvce-editor/output-view 1.4.0 → 1.6.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/outputViewWorkerMain.js +147 -37
- package/package.json +1 -1
|
@@ -934,7 +934,8 @@ const Script = 2;
|
|
|
934
934
|
const {
|
|
935
935
|
get: get$1,
|
|
936
936
|
set: set$1,
|
|
937
|
-
wrapCommand
|
|
937
|
+
wrapCommand,
|
|
938
|
+
wrapGetter
|
|
938
939
|
} = create$2();
|
|
939
940
|
|
|
940
941
|
const create$1 = (id, uri, x, y, width, height, workspaceUri) => {
|
|
@@ -1045,11 +1046,17 @@ const KeyCode = {
|
|
|
1045
1046
|
const mergeClassNames = (...classNames) => {
|
|
1046
1047
|
return classNames.filter(Boolean).join(' ');
|
|
1047
1048
|
};
|
|
1049
|
+
const Button$1 = 1;
|
|
1048
1050
|
const Div = 4;
|
|
1049
1051
|
const Text = 12;
|
|
1052
|
+
const Select$2 = 63;
|
|
1053
|
+
const Option$1 = 64;
|
|
1050
1054
|
const VirtualDomElements = {
|
|
1051
1055
|
__proto__: null,
|
|
1052
|
-
|
|
1056
|
+
Button: Button$1,
|
|
1057
|
+
Div,
|
|
1058
|
+
Option: Option$1,
|
|
1059
|
+
Select: Select$2};
|
|
1053
1060
|
const text = data => {
|
|
1054
1061
|
return {
|
|
1055
1062
|
type: Text,
|
|
@@ -1122,12 +1129,6 @@ const handleError = async state => {
|
|
|
1122
1129
|
};
|
|
1123
1130
|
};
|
|
1124
1131
|
|
|
1125
|
-
const initialize = async () => {};
|
|
1126
|
-
|
|
1127
|
-
const getSelectedItem = platform => {
|
|
1128
|
-
return 'file:///tmp/log-main-process.txt';
|
|
1129
|
-
};
|
|
1130
|
-
|
|
1131
1132
|
const rpcs = Object.create(null);
|
|
1132
1133
|
const set$g = (id, rpc) => {
|
|
1133
1134
|
rpcs[id] = rpc;
|
|
@@ -1522,6 +1523,51 @@ const loadLines = async uri => {
|
|
|
1522
1523
|
}
|
|
1523
1524
|
};
|
|
1524
1525
|
|
|
1526
|
+
const handleSelect = async (state, id) => {
|
|
1527
|
+
const {
|
|
1528
|
+
options
|
|
1529
|
+
} = state;
|
|
1530
|
+
const matchingOption = options.find(option => option.id === id);
|
|
1531
|
+
if (!matchingOption) {
|
|
1532
|
+
return state;
|
|
1533
|
+
}
|
|
1534
|
+
// TODO potential race condtion when switching output channels fast
|
|
1535
|
+
const {
|
|
1536
|
+
lines,
|
|
1537
|
+
error,
|
|
1538
|
+
code
|
|
1539
|
+
} = await loadLines(matchingOption.uri);
|
|
1540
|
+
return {
|
|
1541
|
+
...state,
|
|
1542
|
+
listItems: lines,
|
|
1543
|
+
error,
|
|
1544
|
+
errorCode: code
|
|
1545
|
+
};
|
|
1546
|
+
};
|
|
1547
|
+
|
|
1548
|
+
const initialize = async () => {};
|
|
1549
|
+
|
|
1550
|
+
const getSelectedItem = platform => {
|
|
1551
|
+
return 'file:///tmp/log-main-process.txt';
|
|
1552
|
+
};
|
|
1553
|
+
|
|
1554
|
+
const Filter = 'filter';
|
|
1555
|
+
const Output$2 = 'output';
|
|
1556
|
+
const MainProcess = 'MainProcess';
|
|
1557
|
+
const SharedProcess = 'SharedProcess';
|
|
1558
|
+
|
|
1559
|
+
const loadOptions = async platform => {
|
|
1560
|
+
return [{
|
|
1561
|
+
id: MainProcess,
|
|
1562
|
+
label: 'Main Process',
|
|
1563
|
+
uri: 'file:///tmp/log-main-process.txt'
|
|
1564
|
+
}, {
|
|
1565
|
+
id: SharedProcess,
|
|
1566
|
+
label: 'Shared Process',
|
|
1567
|
+
uri: 'file:///tmp/log-shared-process.txt'
|
|
1568
|
+
}];
|
|
1569
|
+
};
|
|
1570
|
+
|
|
1525
1571
|
const isString = value => {
|
|
1526
1572
|
return typeof value === 'string';
|
|
1527
1573
|
};
|
|
@@ -1534,6 +1580,7 @@ const getSavedCollapsedUris = savedState => {
|
|
|
1534
1580
|
const loadContent = async (state, savedState) => {
|
|
1535
1581
|
const collapsedUris = getSavedCollapsedUris(savedState);
|
|
1536
1582
|
const selectedUri = getSelectedItem();
|
|
1583
|
+
const options = await loadOptions();
|
|
1537
1584
|
const {
|
|
1538
1585
|
lines,
|
|
1539
1586
|
error,
|
|
@@ -1546,7 +1593,7 @@ const loadContent = async (state, savedState) => {
|
|
|
1546
1593
|
errorCode: code,
|
|
1547
1594
|
inputSource: Script,
|
|
1548
1595
|
listItems: lines,
|
|
1549
|
-
options
|
|
1596
|
+
options,
|
|
1550
1597
|
selectedOption: selectedUri
|
|
1551
1598
|
};
|
|
1552
1599
|
};
|
|
@@ -1559,7 +1606,7 @@ const openFindWidget = async state => {
|
|
|
1559
1606
|
};
|
|
1560
1607
|
|
|
1561
1608
|
const Button = 1;
|
|
1562
|
-
const Select = 2;
|
|
1609
|
+
const Select$1 = 2;
|
|
1563
1610
|
|
|
1564
1611
|
const Blank = 'Blank';
|
|
1565
1612
|
const ClearAll = 'ClearAll';
|
|
@@ -1609,7 +1656,7 @@ const getActions = state => {
|
|
|
1609
1656
|
options
|
|
1610
1657
|
} = state;
|
|
1611
1658
|
return [{
|
|
1612
|
-
type: Select,
|
|
1659
|
+
type: Select$1,
|
|
1613
1660
|
id: output(),
|
|
1614
1661
|
options: toSelectOptions(options)
|
|
1615
1662
|
}, {
|
|
@@ -1627,15 +1674,17 @@ const getActions = state => {
|
|
|
1627
1674
|
}];
|
|
1628
1675
|
};
|
|
1629
1676
|
|
|
1630
|
-
const Filter = 'filter';
|
|
1631
|
-
|
|
1632
1677
|
const renderFilterValue = (oldState, newState) => {
|
|
1633
1678
|
return ['Viewlet.setValueByName', Filter, newState.filterValue];
|
|
1634
1679
|
};
|
|
1635
1680
|
|
|
1681
|
+
const IconButton = 'IconButton';
|
|
1682
|
+
const MaskIcon = 'MaskIcon';
|
|
1636
1683
|
const Actions = 'Actions';
|
|
1637
1684
|
const Viewlet = 'Viewlet';
|
|
1638
1685
|
const Output = 'Output';
|
|
1686
|
+
const Option = 'Option';
|
|
1687
|
+
const Select = 'Select';
|
|
1639
1688
|
|
|
1640
1689
|
const parentNode = {
|
|
1641
1690
|
type: VirtualDomElements.Div,
|
|
@@ -1728,28 +1777,26 @@ const render2 = (uid, diffResult) => {
|
|
|
1728
1777
|
return commands;
|
|
1729
1778
|
};
|
|
1730
1779
|
|
|
1731
|
-
const
|
|
1780
|
+
const getActionButtonVirtualDom = button => {
|
|
1781
|
+
const {
|
|
1782
|
+
id,
|
|
1783
|
+
label,
|
|
1784
|
+
icon
|
|
1785
|
+
} = button;
|
|
1732
1786
|
return [{
|
|
1733
|
-
type: VirtualDomElements.
|
|
1787
|
+
type: VirtualDomElements.Button,
|
|
1788
|
+
className: IconButton,
|
|
1789
|
+
name: id,
|
|
1790
|
+
title: label,
|
|
1734
1791
|
childCount: 1
|
|
1735
|
-
},
|
|
1736
|
-
};
|
|
1737
|
-
const getActionsVirtualDom = actions => {
|
|
1738
|
-
return [{
|
|
1792
|
+
}, {
|
|
1739
1793
|
type: VirtualDomElements.Div,
|
|
1740
|
-
className:
|
|
1741
|
-
|
|
1742
|
-
childCount: actions.length
|
|
1743
|
-
}, ...actions.flatMap(getActionDom)];
|
|
1794
|
+
className: mergeClassNames(MaskIcon, icon)
|
|
1795
|
+
}];
|
|
1744
1796
|
};
|
|
1745
1797
|
|
|
1746
|
-
const
|
|
1747
|
-
|
|
1748
|
-
id: 'test',
|
|
1749
|
-
name: 'test'
|
|
1750
|
-
}];
|
|
1751
|
-
const dom = getActionsVirtualDom(actions);
|
|
1752
|
-
return dom;
|
|
1798
|
+
const getActionButtonsVirtualDom = buttons => {
|
|
1799
|
+
return buttons.flatMap(getActionButtonVirtualDom);
|
|
1753
1800
|
};
|
|
1754
1801
|
|
|
1755
1802
|
const HandleBlur = 'handleBlur';
|
|
@@ -1757,11 +1804,73 @@ const HandleClearFilterClick = 'handleClearFilterClick';
|
|
|
1757
1804
|
const HandleContextMenu = 'handleContextMenu';
|
|
1758
1805
|
const HandleFilterInput = 'handleFilterInput';
|
|
1759
1806
|
const HandlePointerDown = 'handlePointerDown';
|
|
1807
|
+
const HandleSelect = 'handleSelect';
|
|
1808
|
+
|
|
1809
|
+
const getOptionVirtualDom = option => {
|
|
1810
|
+
const {
|
|
1811
|
+
id,
|
|
1812
|
+
label
|
|
1813
|
+
} = option;
|
|
1814
|
+
return [{
|
|
1815
|
+
type: VirtualDomElements.Option,
|
|
1816
|
+
className: Option,
|
|
1817
|
+
childCount: 1,
|
|
1818
|
+
value: id
|
|
1819
|
+
}, text(label)];
|
|
1820
|
+
};
|
|
1821
|
+
|
|
1822
|
+
const getSelectVirtualDom = options => {
|
|
1823
|
+
return [{
|
|
1824
|
+
type: VirtualDomElements.Select,
|
|
1825
|
+
className: Select,
|
|
1826
|
+
childCount: options.length,
|
|
1827
|
+
name: Output$2,
|
|
1828
|
+
onChange: HandleSelect
|
|
1829
|
+
}, ...options.flatMap(getOptionVirtualDom)];
|
|
1830
|
+
};
|
|
1831
|
+
|
|
1832
|
+
const getChildCount = buttonsLength => {
|
|
1833
|
+
const selectLength = 1;
|
|
1834
|
+
return buttonsLength + selectLength;
|
|
1835
|
+
};
|
|
1836
|
+
const getActionsVirtualDom = options => {
|
|
1837
|
+
const buttons = [{
|
|
1838
|
+
id: 'Clear',
|
|
1839
|
+
label: 'Clear',
|
|
1840
|
+
icon: 'MaskIconClearAll'
|
|
1841
|
+
}, {
|
|
1842
|
+
id: 'Scroll Lock',
|
|
1843
|
+
label: 'Scroll Lock',
|
|
1844
|
+
icon: 'MaskIconListFlat'
|
|
1845
|
+
}, {
|
|
1846
|
+
id: 'Settings',
|
|
1847
|
+
label: 'Settings',
|
|
1848
|
+
icon: 'MaskIconListFlat'
|
|
1849
|
+
}];
|
|
1850
|
+
const childCount = getChildCount(buttons.length);
|
|
1851
|
+
return [{
|
|
1852
|
+
type: VirtualDomElements.Div,
|
|
1853
|
+
className: Actions,
|
|
1854
|
+
role: AriaRoles.ToolBar,
|
|
1855
|
+
childCount
|
|
1856
|
+
}, ...getSelectVirtualDom(options), ...getActionButtonsVirtualDom(buttons)];
|
|
1857
|
+
};
|
|
1858
|
+
|
|
1859
|
+
const renderActions = state => {
|
|
1860
|
+
const {
|
|
1861
|
+
options
|
|
1862
|
+
} = state;
|
|
1863
|
+
const dom = getActionsVirtualDom(options);
|
|
1864
|
+
return dom;
|
|
1865
|
+
};
|
|
1760
1866
|
|
|
1761
1867
|
const renderEventListeners = () => {
|
|
1762
1868
|
return [{
|
|
1763
1869
|
name: HandleBlur,
|
|
1764
1870
|
params: ['handleBlur']
|
|
1871
|
+
}, {
|
|
1872
|
+
name: HandleSelect,
|
|
1873
|
+
params: ['handleSelect', 'event.target.value']
|
|
1765
1874
|
}, {
|
|
1766
1875
|
name: HandleContextMenu,
|
|
1767
1876
|
params: ['handleContextMenu', 'event.clientX', 'event.clientY'],
|
|
@@ -1805,25 +1914,26 @@ const setOutputChannel = async state => {
|
|
|
1805
1914
|
};
|
|
1806
1915
|
|
|
1807
1916
|
const commandMap = {
|
|
1808
|
-
'Output.closeFindWidget': closeFindWidget,
|
|
1917
|
+
'Output.closeFindWidget': wrapCommand(closeFindWidget),
|
|
1809
1918
|
'Output.create': create$1,
|
|
1810
1919
|
'Output.diff2': diff2,
|
|
1811
1920
|
'Output.focusIndex': wrapCommand(focusIndex),
|
|
1812
1921
|
'Output.getCommandIds': getCommandIds,
|
|
1813
1922
|
'Output.getKeyBindings': getKeyBindings$1,
|
|
1814
|
-
'Output.handleData': handleData,
|
|
1815
|
-
'Output.handleError': handleError,
|
|
1923
|
+
'Output.handleData': wrapCommand(handleData),
|
|
1924
|
+
'Output.handleError': wrapCommand(handleError),
|
|
1816
1925
|
'Output.initialize': initialize,
|
|
1817
1926
|
'Output.loadContent2': wrapCommand(loadContent),
|
|
1818
|
-
'Output.openFindWidget': openFindWidget,
|
|
1927
|
+
'Output.openFindWidget': wrapCommand(openFindWidget),
|
|
1819
1928
|
'Output.render2': render2,
|
|
1820
|
-
'Output.renderActions': renderActions,
|
|
1929
|
+
'Output.renderActions': wrapGetter(renderActions),
|
|
1821
1930
|
'Output.renderEventListeners': renderEventListeners,
|
|
1822
1931
|
'Output.resize': resize,
|
|
1823
1932
|
'Output.saveState': saveState,
|
|
1824
|
-
'Output.setOutputChannel': setOutputChannel,
|
|
1933
|
+
'Output.setOutputChannel': wrapCommand(setOutputChannel),
|
|
1825
1934
|
'Output.getActions': getActions,
|
|
1826
|
-
'Output.terminate': terminate
|
|
1935
|
+
'Output.terminate': terminate,
|
|
1936
|
+
'Output.handleSelect': wrapCommand(handleSelect)
|
|
1827
1937
|
};
|
|
1828
1938
|
|
|
1829
1939
|
const {
|