@lvce-editor/panel-worker 1.10.0 → 1.12.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.
@@ -1093,15 +1093,20 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
1093
1093
  set(uid, state, state);
1094
1094
  };
1095
1095
 
1096
+ const isEqual$1 = (oldState, newState) => {
1097
+ return oldState.childUid === newState.childUid;
1098
+ };
1099
+
1096
1100
  const isEqual = (oldState, newState) => {
1097
1101
  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;
1098
1102
  };
1099
1103
 
1100
1104
  const RenderItems = 4;
1101
1105
  const RenderIncremental = 11;
1106
+ const RenderChildUid = 12;
1102
1107
 
1103
- const modules = [isEqual];
1104
- const numbers = [RenderIncremental];
1108
+ const modules = [isEqual, isEqual$1];
1109
+ const numbers = [RenderIncremental, RenderChildUid];
1105
1110
 
1106
1111
  const diff = (oldState, newState) => {
1107
1112
  const diffResult = [];
@@ -1241,6 +1246,15 @@ const toggleView = async (state, name) => {
1241
1246
  return selectIndex(state, index);
1242
1247
  };
1243
1248
 
1249
+ // TODO also need to dispose child when panel becomes hidden
1250
+ const renderChildUid = (oldState, newState) => {
1251
+ const oldChildUid = oldState.childUid;
1252
+ if (oldChildUid <= 0 || oldChildUid === newState.childUid) {
1253
+ return [];
1254
+ }
1255
+ return ['Viewlet.dispose', oldChildUid];
1256
+ };
1257
+
1244
1258
  const mergeClassNames = (...classNames) => {
1245
1259
  return classNames.filter(Boolean).join(' ');
1246
1260
  };
@@ -1636,7 +1650,7 @@ const getTabClassName = isSelected => {
1636
1650
  return className;
1637
1651
  };
1638
1652
 
1639
- const createPanelTab = (tab, badgeCount, isSelected, index) => {
1653
+ const createPanelTab = (tab, badgeCount, isSelected) => {
1640
1654
  const label = tab;
1641
1655
  const className = getTabClassName(isSelected);
1642
1656
  const childCount = badgeCount ? 2 : 1;
@@ -1644,7 +1658,6 @@ const createPanelTab = (tab, badgeCount, isSelected, index) => {
1644
1658
  ariaSelected: isSelected,
1645
1659
  childCount,
1646
1660
  className,
1647
- 'data-index': index,
1648
1661
  name: tab,
1649
1662
  onClick: HandleClickTab,
1650
1663
  role: Tab,
@@ -1667,7 +1680,7 @@ const getPanelTabsVirtualDom = (tabs, selectedIndex, badgeCounts) => {
1667
1680
  const isSelected = i === selectedIndex;
1668
1681
  const tab = tabs[i];
1669
1682
  const badgeCount = badgeCounts[tab] || 0;
1670
- dom.push(...createPanelTab(tab, badgeCount, isSelected, i));
1683
+ dom.push(...createPanelTab(tab, badgeCount, isSelected));
1671
1684
  }
1672
1685
  return dom;
1673
1686
  };
@@ -1720,6 +1733,8 @@ const renderIncremental = (oldState, newState) => {
1720
1733
 
1721
1734
  const getRenderer = diffType => {
1722
1735
  switch (diffType) {
1736
+ case RenderChildUid:
1737
+ return renderChildUid;
1723
1738
  case RenderIncremental:
1724
1739
  return renderIncremental;
1725
1740
  case RenderItems:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/panel-worker",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "description": "Panel Worker",
5
5
  "repository": {
6
6
  "type": "git",