@lvce-editor/output-view 1.2.0 → 1.4.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 +107 -33
- package/package.json +1 -1
|
@@ -957,7 +957,9 @@ const create$1 = (id, uri, x, y, width, height, workspaceUri) => {
|
|
|
957
957
|
selectedOption: '',
|
|
958
958
|
smallWidthBreakPoint: 650,
|
|
959
959
|
workspaceUri,
|
|
960
|
-
options: []
|
|
960
|
+
options: [],
|
|
961
|
+
error: '',
|
|
962
|
+
errorCode: 0
|
|
961
963
|
};
|
|
962
964
|
set$1(id, state, state);
|
|
963
965
|
};
|
|
@@ -1490,11 +1492,34 @@ const RendererWorker = {
|
|
|
1490
1492
|
writeClipBoardText
|
|
1491
1493
|
};
|
|
1492
1494
|
|
|
1495
|
+
const isFileNotFoundError = error => {
|
|
1496
|
+
return error.message.includes('File not found');
|
|
1497
|
+
};
|
|
1498
|
+
|
|
1493
1499
|
const loadLines = async uri => {
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1500
|
+
try {
|
|
1501
|
+
// TODO use log stream, updating the output when the file is changed
|
|
1502
|
+
const content = await RendererWorker.invoke('FileSystem.readFile', uri);
|
|
1503
|
+
const lines = content.split('\n');
|
|
1504
|
+
return {
|
|
1505
|
+
error: '',
|
|
1506
|
+
lines,
|
|
1507
|
+
code: 0
|
|
1508
|
+
};
|
|
1509
|
+
} catch (error) {
|
|
1510
|
+
if (isFileNotFoundError(error)) {
|
|
1511
|
+
return {
|
|
1512
|
+
error: `log file not found`,
|
|
1513
|
+
lines: [],
|
|
1514
|
+
code: 1
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1517
|
+
return {
|
|
1518
|
+
error: `${error}`,
|
|
1519
|
+
lines: [],
|
|
1520
|
+
code: 2
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1498
1523
|
};
|
|
1499
1524
|
|
|
1500
1525
|
const isString = value => {
|
|
@@ -1509,12 +1534,18 @@ const getSavedCollapsedUris = savedState => {
|
|
|
1509
1534
|
const loadContent = async (state, savedState) => {
|
|
1510
1535
|
const collapsedUris = getSavedCollapsedUris(savedState);
|
|
1511
1536
|
const selectedUri = getSelectedItem();
|
|
1512
|
-
const
|
|
1537
|
+
const {
|
|
1538
|
+
lines,
|
|
1539
|
+
error,
|
|
1540
|
+
code
|
|
1541
|
+
} = await loadLines(selectedUri);
|
|
1513
1542
|
return {
|
|
1514
1543
|
...state,
|
|
1544
|
+
collapsedUris,
|
|
1545
|
+
error,
|
|
1546
|
+
errorCode: code,
|
|
1515
1547
|
inputSource: Script,
|
|
1516
1548
|
listItems: lines,
|
|
1517
|
-
collapsedUris,
|
|
1518
1549
|
options: [],
|
|
1519
1550
|
selectedOption: selectedUri
|
|
1520
1551
|
};
|
|
@@ -1545,26 +1576,26 @@ const i18nString = (key, placeholders = emptyObject) => {
|
|
|
1545
1576
|
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1546
1577
|
};
|
|
1547
1578
|
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
const
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
TurnOffAutoScroll: 'Turn auto scrolling off',
|
|
1555
|
-
OpenLogFile: 'open output log file'
|
|
1556
|
-
};
|
|
1579
|
+
const Output$1 = 'output';
|
|
1580
|
+
const ClearOutput = 'clear output';
|
|
1581
|
+
const TurnOffAutoScroll = 'Turn auto scrolling off';
|
|
1582
|
+
const OpenLogFile = 'open output log file';
|
|
1583
|
+
const LogFileNotFound$1 = 'The log file was not found.';
|
|
1584
|
+
|
|
1557
1585
|
const output = () => {
|
|
1558
|
-
return i18nString(
|
|
1586
|
+
return i18nString(Output$1);
|
|
1559
1587
|
};
|
|
1560
1588
|
const clearOutput = () => {
|
|
1561
|
-
return i18nString(
|
|
1589
|
+
return i18nString(ClearOutput);
|
|
1562
1590
|
};
|
|
1563
1591
|
const turnOffAutoScroll = () => {
|
|
1564
|
-
return i18nString(
|
|
1592
|
+
return i18nString(TurnOffAutoScroll);
|
|
1565
1593
|
};
|
|
1566
1594
|
const openLogFile = () => {
|
|
1567
|
-
return i18nString(
|
|
1595
|
+
return i18nString(OpenLogFile);
|
|
1596
|
+
};
|
|
1597
|
+
const logFileNotFound = () => {
|
|
1598
|
+
return i18nString(LogFileNotFound$1);
|
|
1568
1599
|
};
|
|
1569
1600
|
|
|
1570
1601
|
const toSelectOption = option => {
|
|
@@ -1606,20 +1637,20 @@ const Actions = 'Actions';
|
|
|
1606
1637
|
const Viewlet = 'Viewlet';
|
|
1607
1638
|
const Output = 'Output';
|
|
1608
1639
|
|
|
1640
|
+
const parentNode = {
|
|
1641
|
+
type: VirtualDomElements.Div,
|
|
1642
|
+
className: 'Line',
|
|
1643
|
+
childCount: 1
|
|
1644
|
+
};
|
|
1609
1645
|
const getLineDom = line => {
|
|
1610
|
-
return [
|
|
1611
|
-
type: VirtualDomElements.Div,
|
|
1612
|
-
className: 'Line',
|
|
1613
|
-
childCount: 1
|
|
1614
|
-
}, text(line)];
|
|
1646
|
+
return [parentNode, text(line)];
|
|
1615
1647
|
};
|
|
1616
1648
|
|
|
1617
|
-
const
|
|
1649
|
+
const getContentDom = (lines, error) => {
|
|
1650
|
+
if (error) {
|
|
1651
|
+
return [];
|
|
1652
|
+
}
|
|
1618
1653
|
return [{
|
|
1619
|
-
type: VirtualDomElements.Div,
|
|
1620
|
-
className: mergeClassNames(Viewlet, Output),
|
|
1621
|
-
childCount: 1
|
|
1622
|
-
}, {
|
|
1623
1654
|
type: VirtualDomElements.Div,
|
|
1624
1655
|
className: 'OutputContent',
|
|
1625
1656
|
role: 'log',
|
|
@@ -1628,8 +1659,42 @@ const getOutputVirtualDom = lines => {
|
|
|
1628
1659
|
}, ...lines.flatMap(getLineDom)];
|
|
1629
1660
|
};
|
|
1630
1661
|
|
|
1662
|
+
const LogFileNotFound = 1;
|
|
1663
|
+
|
|
1664
|
+
const getLogFileNotFoundDom = () => {
|
|
1665
|
+
return [{
|
|
1666
|
+
type: VirtualDomElements.Div,
|
|
1667
|
+
className: 'Message',
|
|
1668
|
+
tabIndex: 0,
|
|
1669
|
+
childCount: 1
|
|
1670
|
+
}, text(logFileNotFound())];
|
|
1671
|
+
};
|
|
1672
|
+
|
|
1673
|
+
const getErrorDom = (errorCode, error) => {
|
|
1674
|
+
if (!error) {
|
|
1675
|
+
return [];
|
|
1676
|
+
}
|
|
1677
|
+
if (errorCode === LogFileNotFound) {
|
|
1678
|
+
return getLogFileNotFoundDom();
|
|
1679
|
+
}
|
|
1680
|
+
return [{
|
|
1681
|
+
type: VirtualDomElements.Div,
|
|
1682
|
+
className: 'Error',
|
|
1683
|
+
tabIndex: 0,
|
|
1684
|
+
childCount: 1
|
|
1685
|
+
}, text(error)];
|
|
1686
|
+
};
|
|
1687
|
+
|
|
1688
|
+
const getOutputVirtualDom = (lines, errorCode, error) => {
|
|
1689
|
+
return [{
|
|
1690
|
+
type: VirtualDomElements.Div,
|
|
1691
|
+
className: mergeClassNames(Viewlet, Output),
|
|
1692
|
+
childCount: 1
|
|
1693
|
+
}, ...getContentDom(lines, error), ...getErrorDom(errorCode, error)];
|
|
1694
|
+
};
|
|
1695
|
+
|
|
1631
1696
|
const renderItems = (oldState, newState) => {
|
|
1632
|
-
const dom = getOutputVirtualDom(newState.listItems);
|
|
1697
|
+
const dom = getOutputVirtualDom(newState.listItems, newState.errorCode, newState.error);
|
|
1633
1698
|
return ['Viewlet.setDom2', dom];
|
|
1634
1699
|
};
|
|
1635
1700
|
|
|
@@ -1663,17 +1728,26 @@ const render2 = (uid, diffResult) => {
|
|
|
1663
1728
|
return commands;
|
|
1664
1729
|
};
|
|
1665
1730
|
|
|
1731
|
+
const getActionDom = () => {
|
|
1732
|
+
return [{
|
|
1733
|
+
type: VirtualDomElements.Div,
|
|
1734
|
+
childCount: 1
|
|
1735
|
+
}, text('test action')];
|
|
1736
|
+
};
|
|
1666
1737
|
const getActionsVirtualDom = actions => {
|
|
1667
1738
|
return [{
|
|
1668
1739
|
type: VirtualDomElements.Div,
|
|
1669
1740
|
className: Actions,
|
|
1670
1741
|
role: AriaRoles.ToolBar,
|
|
1671
1742
|
childCount: actions.length
|
|
1672
|
-
}];
|
|
1743
|
+
}, ...actions.flatMap(getActionDom)];
|
|
1673
1744
|
};
|
|
1674
1745
|
|
|
1675
1746
|
const renderActions = uid => {
|
|
1676
|
-
const actions = [
|
|
1747
|
+
const actions = [{
|
|
1748
|
+
id: 'test',
|
|
1749
|
+
name: 'test'
|
|
1750
|
+
}];
|
|
1677
1751
|
const dom = getActionsVirtualDom(actions);
|
|
1678
1752
|
return dom;
|
|
1679
1753
|
};
|