@lvce-editor/panel-worker 1.5.0 → 1.7.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/panelWorkerMain.js +65 -27
- package/package.json +1 -1
package/dist/panelWorkerMain.js
CHANGED
|
@@ -64,7 +64,7 @@ const Object$1 = 1;
|
|
|
64
64
|
const Number$1 = 2;
|
|
65
65
|
const Array$1 = 3;
|
|
66
66
|
const String = 4;
|
|
67
|
-
const Boolean = 5;
|
|
67
|
+
const Boolean$1 = 5;
|
|
68
68
|
const Function = 6;
|
|
69
69
|
const Null = 7;
|
|
70
70
|
const Unknown = 8;
|
|
@@ -85,7 +85,7 @@ const getType = value => {
|
|
|
85
85
|
}
|
|
86
86
|
return Object$1;
|
|
87
87
|
case 'boolean':
|
|
88
|
-
return Boolean;
|
|
88
|
+
return Boolean$1;
|
|
89
89
|
default:
|
|
90
90
|
return Unknown;
|
|
91
91
|
}
|
|
@@ -886,15 +886,17 @@ const create$3 = async ({
|
|
|
886
886
|
};
|
|
887
887
|
|
|
888
888
|
const Tab = 'tab';
|
|
889
|
+
const ToolBar = 'toolbar';
|
|
889
890
|
|
|
890
891
|
const Button = 1;
|
|
891
892
|
const Div = 4;
|
|
892
893
|
const Text = 12;
|
|
893
894
|
const Reference = 100;
|
|
894
895
|
|
|
896
|
+
const TargetName = 'event.target.name';
|
|
897
|
+
|
|
895
898
|
const RendererWorker = 1;
|
|
896
899
|
|
|
897
|
-
const SetDom2 = 'Viewlet.setDom2';
|
|
898
900
|
const SetPatches = 'Viewlet.setPatches';
|
|
899
901
|
|
|
900
902
|
const createMockRpc = ({
|
|
@@ -1080,6 +1082,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1080
1082
|
initial: true,
|
|
1081
1083
|
platform,
|
|
1082
1084
|
selectedIndex: -1,
|
|
1085
|
+
tabs: [],
|
|
1083
1086
|
uid,
|
|
1084
1087
|
views: [],
|
|
1085
1088
|
warningCount: 0,
|
|
@@ -1091,7 +1094,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1091
1094
|
};
|
|
1092
1095
|
|
|
1093
1096
|
const isEqual = (oldState, newState) => {
|
|
1094
|
-
return oldState.assetDir === newState.assetDir && oldState.initial === newState.initial && oldState.currentViewletId === newState.currentViewletId && oldState.selectedIndex === newState.selectedIndex && oldState.views === newState.views;
|
|
1097
|
+
return oldState.assetDir === newState.assetDir && oldState.initial === newState.initial && oldState.currentViewletId === newState.currentViewletId && oldState.selectedIndex === newState.selectedIndex && oldState.views === newState.views && oldState.childUid === newState.childUid && oldState.actionsUid === newState.actionsUid;
|
|
1095
1098
|
};
|
|
1096
1099
|
|
|
1097
1100
|
const RenderItems = 4;
|
|
@@ -1126,6 +1129,7 @@ const handleClickClose = async state => {
|
|
|
1126
1129
|
};
|
|
1127
1130
|
|
|
1128
1131
|
const handleClickMaximize = async state => {
|
|
1132
|
+
await invoke('Layout.maximizePanel');
|
|
1129
1133
|
return state;
|
|
1130
1134
|
};
|
|
1131
1135
|
|
|
@@ -1201,7 +1205,10 @@ const loadContent = (state, savedState) => {
|
|
|
1201
1205
|
};
|
|
1202
1206
|
|
|
1203
1207
|
const selectIndex = async (state, index) => {
|
|
1204
|
-
|
|
1208
|
+
const {
|
|
1209
|
+
views
|
|
1210
|
+
} = state;
|
|
1211
|
+
await openViewlet(state, views[index]);
|
|
1205
1212
|
return {
|
|
1206
1213
|
...state,
|
|
1207
1214
|
selectedIndex: index
|
|
@@ -1236,6 +1243,21 @@ const toggleView = async (state, name) => {
|
|
|
1236
1243
|
return selectIndex(state, index);
|
|
1237
1244
|
};
|
|
1238
1245
|
|
|
1246
|
+
const selectName = async (state, name) => {
|
|
1247
|
+
if (!name) {
|
|
1248
|
+
return state;
|
|
1249
|
+
}
|
|
1250
|
+
const index = state.views.indexOf(name);
|
|
1251
|
+
if (index === -1) {
|
|
1252
|
+
return state;
|
|
1253
|
+
}
|
|
1254
|
+
return selectIndex(state, index);
|
|
1255
|
+
};
|
|
1256
|
+
|
|
1257
|
+
const mergeClassNames = (...classNames) => {
|
|
1258
|
+
return classNames.filter(Boolean).join(' ');
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1239
1261
|
const text = data => {
|
|
1240
1262
|
return {
|
|
1241
1263
|
childCount: 0,
|
|
@@ -1551,7 +1573,7 @@ const getActionsDom = newState => {
|
|
|
1551
1573
|
return [{
|
|
1552
1574
|
childCount: 0,
|
|
1553
1575
|
className: Actions,
|
|
1554
|
-
role:
|
|
1576
|
+
role: ToolBar,
|
|
1555
1577
|
type: Div
|
|
1556
1578
|
}];
|
|
1557
1579
|
}
|
|
@@ -1564,6 +1586,7 @@ const getActionsDom = newState => {
|
|
|
1564
1586
|
const HandleClickClose = 'handleClickClose';
|
|
1565
1587
|
const HandleClickMaximize = 'handleClickMaximize';
|
|
1566
1588
|
const HandleClickSelectTab = 'HandleClickSelectTab';
|
|
1589
|
+
const HandleClickTab = 'HandleClickTab';
|
|
1567
1590
|
|
|
1568
1591
|
const emptyObject = {};
|
|
1569
1592
|
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
@@ -1591,7 +1614,7 @@ const getGlobalActionsDom = () => {
|
|
|
1591
1614
|
return [{
|
|
1592
1615
|
childCount: 2,
|
|
1593
1616
|
className: PanelToolBar,
|
|
1594
|
-
role:
|
|
1617
|
+
role: ToolBar,
|
|
1595
1618
|
type: Div
|
|
1596
1619
|
}, {
|
|
1597
1620
|
ariaLabel: maximize(),
|
|
@@ -1602,7 +1625,7 @@ const getGlobalActionsDom = () => {
|
|
|
1602
1625
|
type: Button
|
|
1603
1626
|
}, {
|
|
1604
1627
|
childCount: 0,
|
|
1605
|
-
className:
|
|
1628
|
+
className: mergeClassNames(MaskIcon, MaskIconChevronUp),
|
|
1606
1629
|
type: Div
|
|
1607
1630
|
}, {
|
|
1608
1631
|
ariaLabel: close(),
|
|
@@ -1613,26 +1636,32 @@ const getGlobalActionsDom = () => {
|
|
|
1613
1636
|
type: Button
|
|
1614
1637
|
}, {
|
|
1615
1638
|
childCount: 0,
|
|
1616
|
-
className:
|
|
1639
|
+
className: mergeClassNames(MaskIcon, MaskIconClose),
|
|
1617
1640
|
type: Div
|
|
1618
1641
|
}];
|
|
1619
1642
|
};
|
|
1620
1643
|
|
|
1621
|
-
const
|
|
1622
|
-
const label = tab;
|
|
1644
|
+
const getTabClassName = isSelected => {
|
|
1623
1645
|
let className = PanelTab;
|
|
1624
1646
|
if (isSelected) {
|
|
1625
1647
|
className += ' ' + PanelTabSelected;
|
|
1626
1648
|
}
|
|
1649
|
+
return className;
|
|
1650
|
+
};
|
|
1651
|
+
|
|
1652
|
+
const createPanelTab = (tab, badgeCount, isSelected, index) => {
|
|
1653
|
+
const label = tab;
|
|
1654
|
+
const className = getTabClassName(isSelected);
|
|
1627
1655
|
const childCount = badgeCount ? 2 : 1;
|
|
1628
1656
|
const tabDom = {
|
|
1629
1657
|
ariaSelected: isSelected,
|
|
1630
1658
|
childCount,
|
|
1631
1659
|
className,
|
|
1632
1660
|
'data-index': index,
|
|
1661
|
+
name: tab,
|
|
1633
1662
|
onClick: HandleClickSelectTab,
|
|
1634
1663
|
role: Tab,
|
|
1635
|
-
type:
|
|
1664
|
+
type: Button
|
|
1636
1665
|
};
|
|
1637
1666
|
const dom = [tabDom, text(label)];
|
|
1638
1667
|
if (badgeCount) {
|
|
@@ -1644,6 +1673,7 @@ const createPanelTab = (tab, badgeCount, isSelected, index) => {
|
|
|
1644
1673
|
}
|
|
1645
1674
|
return dom;
|
|
1646
1675
|
};
|
|
1676
|
+
|
|
1647
1677
|
const getPanelTabsVirtualDom = (tabs, selectedIndex, badgeCounts) => {
|
|
1648
1678
|
const dom = [];
|
|
1649
1679
|
for (let i = 0; i < tabs.length; i++) {
|
|
@@ -1655,24 +1685,29 @@ const getPanelTabsVirtualDom = (tabs, selectedIndex, badgeCounts) => {
|
|
|
1655
1685
|
return dom;
|
|
1656
1686
|
};
|
|
1657
1687
|
|
|
1658
|
-
const
|
|
1659
|
-
const {
|
|
1660
|
-
childUid
|
|
1661
|
-
} = newState;
|
|
1688
|
+
const getPanelHeaderDom = newState => {
|
|
1662
1689
|
const tabsDom = getPanelTabsVirtualDom(newState.views, newState.selectedIndex, newState.badgeCounts);
|
|
1663
1690
|
return [{
|
|
1664
|
-
childCount: 2,
|
|
1665
|
-
className: Panel,
|
|
1666
|
-
type: Div
|
|
1667
|
-
}, {
|
|
1668
1691
|
childCount: 3,
|
|
1669
1692
|
className: PanelHeader,
|
|
1670
1693
|
type: Div
|
|
1671
1694
|
}, {
|
|
1672
1695
|
childCount: newState.views.length,
|
|
1673
1696
|
className: PanelTabs,
|
|
1697
|
+
role: 'tablist',
|
|
1698
|
+
type: Div
|
|
1699
|
+
}, ...tabsDom, ...getActionsDom(newState), ...getGlobalActionsDom()];
|
|
1700
|
+
};
|
|
1701
|
+
|
|
1702
|
+
const getPanelDom = newState => {
|
|
1703
|
+
const {
|
|
1704
|
+
childUid
|
|
1705
|
+
} = newState;
|
|
1706
|
+
return [{
|
|
1707
|
+
childCount: 2,
|
|
1708
|
+
className: Panel,
|
|
1674
1709
|
type: Div
|
|
1675
|
-
}, ...
|
|
1710
|
+
}, ...getPanelHeaderDom(newState), {
|
|
1676
1711
|
type: Reference,
|
|
1677
1712
|
uid: childUid
|
|
1678
1713
|
}];
|
|
@@ -1680,19 +1715,18 @@ const getPanelDom = newState => {
|
|
|
1680
1715
|
|
|
1681
1716
|
const renderItems = (oldState, newState) => {
|
|
1682
1717
|
const {
|
|
1683
|
-
initial
|
|
1684
|
-
uid
|
|
1718
|
+
initial
|
|
1685
1719
|
} = newState;
|
|
1686
1720
|
if (initial) {
|
|
1687
|
-
return [
|
|
1721
|
+
return [];
|
|
1688
1722
|
}
|
|
1689
1723
|
const dom = getPanelDom(newState);
|
|
1690
|
-
return
|
|
1724
|
+
return dom;
|
|
1691
1725
|
};
|
|
1692
1726
|
|
|
1693
1727
|
const renderIncremental = (oldState, newState) => {
|
|
1694
|
-
const oldDom = renderItems(oldState, oldState)
|
|
1695
|
-
const newDom = renderItems(newState, newState)
|
|
1728
|
+
const oldDom = renderItems(oldState, oldState);
|
|
1729
|
+
const newDom = renderItems(newState, newState);
|
|
1696
1730
|
const patches = diffTree(oldDom, newDom);
|
|
1697
1731
|
return [SetPatches, newState.uid, patches];
|
|
1698
1732
|
};
|
|
@@ -1740,6 +1774,9 @@ const renderEventListeners = () => {
|
|
|
1740
1774
|
}, {
|
|
1741
1775
|
name: HandleClickSelectTab,
|
|
1742
1776
|
params: ['selectIndexRaw', 'event.target.dataset.index']
|
|
1777
|
+
}, {
|
|
1778
|
+
name: HandleClickTab,
|
|
1779
|
+
params: ['selectName', TargetName]
|
|
1743
1780
|
}];
|
|
1744
1781
|
};
|
|
1745
1782
|
|
|
@@ -1790,6 +1827,7 @@ const commandMap = {
|
|
|
1790
1827
|
'Panel.saveState': wrapGetter(saveState),
|
|
1791
1828
|
'Panel.selectIndex': wrapCommand(selectIndex),
|
|
1792
1829
|
'Panel.selectIndexRaw': wrapCommand(selectRaw),
|
|
1830
|
+
'Panel.selectName': wrapCommand(selectName),
|
|
1793
1831
|
'Panel.setBadgeCount': wrapCommand(setBadgeCount),
|
|
1794
1832
|
'Panel.terminate': terminate,
|
|
1795
1833
|
'Panel.toggleView': wrapCommand(toggleView)
|