@lvce-editor/panel-worker 2.12.0 → 2.13.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.
@@ -1581,12 +1581,8 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
1581
1581
  set$1(uid, state, state);
1582
1582
  };
1583
1583
 
1584
- const isEqual$2 = (oldState, newState) => {
1585
- return oldState.actionsUid === newState.actionsUid;
1586
- };
1587
-
1588
1584
  const isEqual$1 = (oldState, newState) => {
1589
- return oldState.childUid === newState.childUid;
1585
+ return oldState.actionsUid === newState.actionsUid;
1590
1586
  };
1591
1587
 
1592
1588
  const areBadgeCountsEqual = (oldBadgeCounts, newBadgeCounts) => {
@@ -1600,11 +1596,10 @@ const isEqual = (oldState, newState) => {
1600
1596
 
1601
1597
  const RenderItems = 4;
1602
1598
  const RenderIncremental = 11;
1603
- const RenderChildUid = 12;
1604
1599
  const RenderActionsUid = 13;
1605
1600
 
1606
- const modules = [isEqual, isEqual$1, isEqual$2];
1607
- const numbers = [RenderIncremental, RenderChildUid, RenderActionsUid];
1601
+ const modules = [isEqual, isEqual$1];
1602
+ const numbers = [RenderIncremental, RenderActionsUid];
1608
1603
 
1609
1604
  const diff = (oldState, newState) => {
1610
1605
  const diffResult = [];
@@ -1759,8 +1754,12 @@ const handleFilterInput = async (state, value) => {
1759
1754
  return state;
1760
1755
  };
1761
1756
 
1762
- const getPanelViews = () => {
1763
- const views = [Problems, Output, DebugConsole, Terminals, Ports];
1757
+ const remoteSshWorkspacePrefix = 'remote-ssh://';
1758
+ const getPanelViews = (workspaceUri = '') => {
1759
+ const views = [Problems, Output, DebugConsole, Terminals];
1760
+ if (workspaceUri.startsWith(remoteSshWorkspacePrefix)) {
1761
+ views.push(Ports);
1762
+ }
1764
1763
  return views;
1765
1764
  };
1766
1765
 
@@ -1815,6 +1814,9 @@ const openViewlet = async (state, id, focus = false, uri = '') => {
1815
1814
  currentViewletId,
1816
1815
  views
1817
1816
  } = state;
1817
+ if (!views.includes(id)) {
1818
+ return state;
1819
+ }
1818
1820
  await saveViewletState(currentChildUid, currentViewletId);
1819
1821
  const childDimensions = getContentDimensions(state);
1820
1822
  const childUid = getUid();
@@ -1822,6 +1824,9 @@ const openViewlet = async (state, id, focus = false, uri = '') => {
1822
1824
  const actionsUid = getUid();
1823
1825
  const index = views.indexOf(id);
1824
1826
  await createViewlet(id, childUid, tabId, actionsUid, childDimensions, uri, focus);
1827
+ if (currentChildUid > 0) {
1828
+ await invoke$1('Viewlet.dispose', currentChildUid);
1829
+ }
1825
1830
  return {
1826
1831
  ...state,
1827
1832
  actionsUid,
@@ -1832,21 +1837,31 @@ const openViewlet = async (state, id, focus = false, uri = '') => {
1832
1837
  };
1833
1838
  };
1834
1839
 
1835
- const loadContent = (state, savedState) => {
1840
+ const loadContent = (state, savedState, workspaceUri = '') => {
1841
+ const {
1842
+ currentViewletId: activeViewletId
1843
+ } = state;
1836
1844
  const savedViewletId = getSavedViewletId(savedState);
1837
- const views = getPanelViews();
1845
+ const views = getPanelViews(workspaceUri);
1846
+ let currentViewletId = savedViewletId;
1847
+ if (!views.includes(currentViewletId)) {
1848
+ currentViewletId = views.includes(activeViewletId) ? activeViewletId : views[0];
1849
+ }
1838
1850
  const loaded = {
1839
1851
  ...state,
1840
- currentViewletId: savedViewletId,
1852
+ currentViewletId,
1841
1853
  views
1842
1854
  };
1843
- return openViewlet(loaded, savedViewletId);
1855
+ return openViewlet(loaded, currentViewletId);
1844
1856
  };
1845
1857
 
1846
1858
  const selectIndex = async (state, index, uri = '') => {
1847
1859
  const {
1848
1860
  views
1849
1861
  } = state;
1862
+ if (index < 0 || index >= views.length) {
1863
+ return state;
1864
+ }
1850
1865
  return openViewlet(state, views[index], true, uri);
1851
1866
  };
1852
1867
 
@@ -1877,15 +1892,6 @@ const renderActionsUid = (oldState, newState) => {
1877
1892
  return ['Viewlet.dispose', oldActionsUid];
1878
1893
  };
1879
1894
 
1880
- // TODO also need to dispose child when panel becomes hidden
1881
- const renderChildUid = (oldState, newState) => {
1882
- const oldChildUid = oldState.childUid;
1883
- if (oldChildUid <= 0 || oldChildUid === newState.childUid) {
1884
- return [];
1885
- }
1886
- return ['Viewlet.dispose', oldChildUid];
1887
- };
1888
-
1889
1895
  const mergeClassNames = (...classNames) => {
1890
1896
  return classNames.filter(Boolean).join(' ');
1891
1897
  };
@@ -2354,8 +2360,6 @@ const getRenderer = diffType => {
2354
2360
  switch (diffType) {
2355
2361
  case RenderActionsUid:
2356
2362
  return renderActionsUid;
2357
- case RenderChildUid:
2358
- return renderChildUid;
2359
2363
  case RenderIncremental:
2360
2364
  return renderIncremental;
2361
2365
  case RenderItems:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/panel-worker",
3
- "version": "2.12.0",
3
+ "version": "2.13.0",
4
4
  "description": "Panel Worker",
5
5
  "repository": {
6
6
  "type": "git",