@lvce-editor/output-view 1.3.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 +65 -26
- package/package.json +1 -1
|
@@ -958,7 +958,8 @@ const create$1 = (id, uri, x, y, width, height, workspaceUri) => {
|
|
|
958
958
|
smallWidthBreakPoint: 650,
|
|
959
959
|
workspaceUri,
|
|
960
960
|
options: [],
|
|
961
|
-
error: ''
|
|
961
|
+
error: '',
|
|
962
|
+
errorCode: 0
|
|
962
963
|
};
|
|
963
964
|
set$1(id, state, state);
|
|
964
965
|
};
|
|
@@ -1491,6 +1492,10 @@ const RendererWorker = {
|
|
|
1491
1492
|
writeClipBoardText
|
|
1492
1493
|
};
|
|
1493
1494
|
|
|
1495
|
+
const isFileNotFoundError = error => {
|
|
1496
|
+
return error.message.includes('File not found');
|
|
1497
|
+
};
|
|
1498
|
+
|
|
1494
1499
|
const loadLines = async uri => {
|
|
1495
1500
|
try {
|
|
1496
1501
|
// TODO use log stream, updating the output when the file is changed
|
|
@@ -1498,12 +1503,21 @@ const loadLines = async uri => {
|
|
|
1498
1503
|
const lines = content.split('\n');
|
|
1499
1504
|
return {
|
|
1500
1505
|
error: '',
|
|
1501
|
-
lines
|
|
1506
|
+
lines,
|
|
1507
|
+
code: 0
|
|
1502
1508
|
};
|
|
1503
1509
|
} catch (error) {
|
|
1510
|
+
if (isFileNotFoundError(error)) {
|
|
1511
|
+
return {
|
|
1512
|
+
error: `log file not found`,
|
|
1513
|
+
lines: [],
|
|
1514
|
+
code: 1
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1504
1517
|
return {
|
|
1505
1518
|
error: `${error}`,
|
|
1506
|
-
lines: []
|
|
1519
|
+
lines: [],
|
|
1520
|
+
code: 2
|
|
1507
1521
|
};
|
|
1508
1522
|
}
|
|
1509
1523
|
};
|
|
@@ -1522,16 +1536,18 @@ const loadContent = async (state, savedState) => {
|
|
|
1522
1536
|
const selectedUri = getSelectedItem();
|
|
1523
1537
|
const {
|
|
1524
1538
|
lines,
|
|
1525
|
-
error
|
|
1539
|
+
error,
|
|
1540
|
+
code
|
|
1526
1541
|
} = await loadLines(selectedUri);
|
|
1527
1542
|
return {
|
|
1528
1543
|
...state,
|
|
1544
|
+
collapsedUris,
|
|
1545
|
+
error,
|
|
1546
|
+
errorCode: code,
|
|
1529
1547
|
inputSource: Script,
|
|
1530
1548
|
listItems: lines,
|
|
1531
|
-
collapsedUris,
|
|
1532
1549
|
options: [],
|
|
1533
|
-
selectedOption: selectedUri
|
|
1534
|
-
error
|
|
1550
|
+
selectedOption: selectedUri
|
|
1535
1551
|
};
|
|
1536
1552
|
};
|
|
1537
1553
|
|
|
@@ -1560,26 +1576,26 @@ const i18nString = (key, placeholders = emptyObject) => {
|
|
|
1560
1576
|
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1561
1577
|
};
|
|
1562
1578
|
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
const
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
TurnOffAutoScroll: 'Turn auto scrolling off',
|
|
1570
|
-
OpenLogFile: 'open output log file'
|
|
1571
|
-
};
|
|
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
|
+
|
|
1572
1585
|
const output = () => {
|
|
1573
|
-
return i18nString(
|
|
1586
|
+
return i18nString(Output$1);
|
|
1574
1587
|
};
|
|
1575
1588
|
const clearOutput = () => {
|
|
1576
|
-
return i18nString(
|
|
1589
|
+
return i18nString(ClearOutput);
|
|
1577
1590
|
};
|
|
1578
1591
|
const turnOffAutoScroll = () => {
|
|
1579
|
-
return i18nString(
|
|
1592
|
+
return i18nString(TurnOffAutoScroll);
|
|
1580
1593
|
};
|
|
1581
1594
|
const openLogFile = () => {
|
|
1582
|
-
return i18nString(
|
|
1595
|
+
return i18nString(OpenLogFile);
|
|
1596
|
+
};
|
|
1597
|
+
const logFileNotFound = () => {
|
|
1598
|
+
return i18nString(LogFileNotFound$1);
|
|
1583
1599
|
};
|
|
1584
1600
|
|
|
1585
1601
|
const toSelectOption = option => {
|
|
@@ -1643,10 +1659,24 @@ const getContentDom = (lines, error) => {
|
|
|
1643
1659
|
}, ...lines.flatMap(getLineDom)];
|
|
1644
1660
|
};
|
|
1645
1661
|
|
|
1646
|
-
const
|
|
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) => {
|
|
1647
1674
|
if (!error) {
|
|
1648
1675
|
return [];
|
|
1649
1676
|
}
|
|
1677
|
+
if (errorCode === LogFileNotFound) {
|
|
1678
|
+
return getLogFileNotFoundDom();
|
|
1679
|
+
}
|
|
1650
1680
|
return [{
|
|
1651
1681
|
type: VirtualDomElements.Div,
|
|
1652
1682
|
className: 'Error',
|
|
@@ -1655,16 +1685,16 @@ const getErrorDom = error => {
|
|
|
1655
1685
|
}, text(error)];
|
|
1656
1686
|
};
|
|
1657
1687
|
|
|
1658
|
-
const getOutputVirtualDom = (lines, error) => {
|
|
1688
|
+
const getOutputVirtualDom = (lines, errorCode, error) => {
|
|
1659
1689
|
return [{
|
|
1660
1690
|
type: VirtualDomElements.Div,
|
|
1661
1691
|
className: mergeClassNames(Viewlet, Output),
|
|
1662
1692
|
childCount: 1
|
|
1663
|
-
}, ...getContentDom(lines, error), ...getErrorDom(error)];
|
|
1693
|
+
}, ...getContentDom(lines, error), ...getErrorDom(errorCode, error)];
|
|
1664
1694
|
};
|
|
1665
1695
|
|
|
1666
1696
|
const renderItems = (oldState, newState) => {
|
|
1667
|
-
const dom = getOutputVirtualDom(newState.listItems, newState.error);
|
|
1697
|
+
const dom = getOutputVirtualDom(newState.listItems, newState.errorCode, newState.error);
|
|
1668
1698
|
return ['Viewlet.setDom2', dom];
|
|
1669
1699
|
};
|
|
1670
1700
|
|
|
@@ -1698,17 +1728,26 @@ const render2 = (uid, diffResult) => {
|
|
|
1698
1728
|
return commands;
|
|
1699
1729
|
};
|
|
1700
1730
|
|
|
1731
|
+
const getActionDom = () => {
|
|
1732
|
+
return [{
|
|
1733
|
+
type: VirtualDomElements.Div,
|
|
1734
|
+
childCount: 1
|
|
1735
|
+
}, text('test action')];
|
|
1736
|
+
};
|
|
1701
1737
|
const getActionsVirtualDom = actions => {
|
|
1702
1738
|
return [{
|
|
1703
1739
|
type: VirtualDomElements.Div,
|
|
1704
1740
|
className: Actions,
|
|
1705
1741
|
role: AriaRoles.ToolBar,
|
|
1706
1742
|
childCount: actions.length
|
|
1707
|
-
}];
|
|
1743
|
+
}, ...actions.flatMap(getActionDom)];
|
|
1708
1744
|
};
|
|
1709
1745
|
|
|
1710
1746
|
const renderActions = uid => {
|
|
1711
|
-
const actions = [
|
|
1747
|
+
const actions = [{
|
|
1748
|
+
id: 'test',
|
|
1749
|
+
name: 'test'
|
|
1750
|
+
}];
|
|
1712
1751
|
const dom = getActionsVirtualDom(actions);
|
|
1713
1752
|
return dom;
|
|
1714
1753
|
};
|