@lvce-editor/running-extensions-view 1.7.0 → 1.8.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.
@@ -63,7 +63,7 @@ class AssertionError extends Error {
63
63
  const Object$1 = 1;
64
64
  const Number$1 = 2;
65
65
  const Array$1 = 3;
66
- const String = 4;
66
+ const String$1 = 4;
67
67
  const Boolean$1 = 5;
68
68
  const Function = 6;
69
69
  const Null = 7;
@@ -75,7 +75,7 @@ const getType = value => {
75
75
  case 'function':
76
76
  return Function;
77
77
  case 'string':
78
- return String;
78
+ return String$1;
79
79
  case 'object':
80
80
  if (value === null) {
81
81
  return Null;
@@ -586,7 +586,10 @@ const constructError = (message, type, name) => {
586
586
  if (ErrorConstructor === Error) {
587
587
  const error = new Error(message);
588
588
  if (name && name !== 'VError') {
589
- error.name = name;
589
+ Object.defineProperty(error, 'name', {
590
+ configurable: true,
591
+ value: name
592
+ });
590
593
  }
591
594
  return error;
592
595
  }
@@ -617,31 +620,45 @@ const getParentStack = error => {
617
620
  };
618
621
  const MethodNotFound = -32601;
619
622
  const Custom = -32001;
623
+ const setStack = (error, stack) => {
624
+ const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
625
+ if (descriptor) {
626
+ if (!descriptor.configurable && !descriptor.writable) {
627
+ return;
628
+ }
629
+ if (!descriptor.configurable && descriptor.writable) {
630
+ error.stack = stack;
631
+ return;
632
+ }
633
+ }
634
+ Object.defineProperty(error, 'stack', {
635
+ configurable: true,
636
+ value: stack,
637
+ writable: true
638
+ });
639
+ };
620
640
  const restoreExistingError = (error, currentStack) => {
621
641
  if (typeof error.stack === 'string') {
622
- error.stack = error.stack + NewLine + currentStack;
642
+ setStack(error, `${error.stack}${NewLine}${currentStack}`);
623
643
  }
624
644
  return error;
625
645
  };
626
646
  const restoreMethodNotFoundError = (error, currentStack) => {
627
647
  const restoredError = new JsonRpcError(error.message);
628
648
  const parentStack = getParentStack(error);
629
- restoredError.stack = parentStack + NewLine + currentStack;
649
+ setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
630
650
  return restoredError;
631
651
  };
632
652
  const restoreStackFromData = (restoredError, error, currentStack) => {
633
653
  if (error.data.stack && error.data.type && error.message) {
634
- restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
654
+ setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
635
655
  return;
636
656
  }
637
657
  if (error.data.stack) {
638
- restoredError.stack = error.data.stack;
658
+ setStack(restoredError, error.data.stack);
639
659
  }
640
660
  };
641
661
  const applyDataProperties = (restoredError, error) => {
642
- if (!error.data) {
643
- return;
644
- }
645
662
  restoreStackFromData(restoredError, error, getCurrentStack());
646
663
  if (error.data.codeFrame) {
647
664
  // @ts-ignore
@@ -662,7 +679,7 @@ const applyDirectProperties = (restoredError, error) => {
662
679
  const indexNewLine = getNewLineIndex(lowerStack);
663
680
  const parentStack = getParentStack(error);
664
681
  // @ts-ignore
665
- restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
682
+ setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
666
683
  }
667
684
  if (error.codeFrame) {
668
685
  // @ts-ignore
@@ -1372,7 +1389,7 @@ const getWindowId = async () => {
1372
1389
  return invoke('GetWindowId.getWindowId');
1373
1390
  };
1374
1391
 
1375
- const copyId = async (state, index) => {
1392
+ const copyId$1 = async (state, index) => {
1376
1393
  const {
1377
1394
  extensions
1378
1395
  } = state;
@@ -1654,7 +1671,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
1654
1671
  };
1655
1672
 
1656
1673
  const isDomEqual = (oldState, newState) => {
1657
- return oldState.extensions === newState.extensions && oldState.loaded === newState.loaded;
1674
+ return oldState.extensions === newState.extensions && oldState.focusedIndex === newState.focusedIndex && oldState.loaded === newState.loaded;
1658
1675
  };
1659
1676
  const isCssEqual = (oldState, newState) => {
1660
1677
  return oldState.width === newState.width && oldState.height === newState.height;
@@ -1667,7 +1684,7 @@ const diff2 = uid => {
1667
1684
  return diff(uid, [isDomEqual, isCssEqual], [RenderDom, RenderCss]);
1668
1685
  };
1669
1686
 
1670
- const disable = async (state, index) => {
1687
+ const disable$1 = async (state, index) => {
1671
1688
  const {
1672
1689
  extensions,
1673
1690
  platform
@@ -1679,7 +1696,7 @@ const disable = async (state, index) => {
1679
1696
  return state;
1680
1697
  };
1681
1698
 
1682
- const disableWorkspace = async (state, index) => {
1699
+ const disableWorkspace$1 = async (state, index) => {
1683
1700
  const {
1684
1701
  extensions
1685
1702
  } = state;
@@ -1690,6 +1707,86 @@ const disableWorkspace = async (state, index) => {
1690
1707
  return state;
1691
1708
  };
1692
1709
 
1710
+ const emptyObject = {};
1711
+ const i18nString = (key, placeholders = emptyObject) => {
1712
+ if (placeholders === emptyObject) {
1713
+ return key;
1714
+ }
1715
+ let result = key;
1716
+ for (const [placeholder, replacement] of Object.entries(placeholders)) {
1717
+ result = result.split(`{${placeholder}}`).join(String(replacement));
1718
+ }
1719
+ return result;
1720
+ };
1721
+
1722
+ const ActivationReason = 'Activation reason: {PH1}';
1723
+ const ActivationTime = 'Activation: {PH1}ms';
1724
+ const CopyId = 'Copy id ({PH1})';
1725
+ const Disable = 'Disable';
1726
+ const DisableWorkspace = 'Disable (Workspace)';
1727
+ const ExtensionApiElectron = 'Extension API (Electron): {PH1}';
1728
+ const ExtensionHostProfilingNotAvailable = 'Extension host profiling is not available yet.';
1729
+ const LoadingRunningExtensions = 'Loading running extensions…';
1730
+ const NoRunningExtensions = 'No running extensions';
1731
+ const ReportIssue = 'Report Issue';
1732
+ const ReportingIssuesForRunningExtensionsNotAvailable = 'Reporting issues for running extensions is not available yet.';
1733
+ const Ssh = 'SSH: {PH1}';
1734
+ const StartExtensionHostProfile = 'Start Extension Host Profile';
1735
+ const TakeHeapSnapshot = 'Take Heap Snapshot';
1736
+
1737
+ const activationReason = reason => {
1738
+ return i18nString(ActivationReason, {
1739
+ PH1: reason
1740
+ });
1741
+ };
1742
+ const activationTime = milliseconds => {
1743
+ return i18nString(ActivationTime, {
1744
+ PH1: milliseconds
1745
+ });
1746
+ };
1747
+ const copyId = id => {
1748
+ return i18nString(CopyId, {
1749
+ PH1: id
1750
+ });
1751
+ };
1752
+ const disable = () => {
1753
+ return i18nString(Disable);
1754
+ };
1755
+ const disableWorkspace = () => {
1756
+ return i18nString(DisableWorkspace);
1757
+ };
1758
+ const extensionApiElectron = id => {
1759
+ return i18nString(ExtensionApiElectron, {
1760
+ PH1: id
1761
+ });
1762
+ };
1763
+ const extensionHostProfilingNotAvailable = () => {
1764
+ return i18nString(ExtensionHostProfilingNotAvailable);
1765
+ };
1766
+ const loadingRunningExtensions = () => {
1767
+ return i18nString(LoadingRunningExtensions);
1768
+ };
1769
+ const noRunningExtensions = () => {
1770
+ return i18nString(NoRunningExtensions);
1771
+ };
1772
+ const reportIssue$1 = () => {
1773
+ return i18nString(ReportIssue);
1774
+ };
1775
+ const reportingIssuesForRunningExtensionsNotAvailable = () => {
1776
+ return i18nString(ReportingIssuesForRunningExtensionsNotAvailable);
1777
+ };
1778
+ const ssh = host => {
1779
+ return i18nString(Ssh, {
1780
+ PH1: host
1781
+ });
1782
+ };
1783
+ const startExtensionHostProfile = () => {
1784
+ return i18nString(StartExtensionHostProfile);
1785
+ };
1786
+ const takeHeapSnapshot$1 = () => {
1787
+ return i18nString(TakeHeapSnapshot);
1788
+ };
1789
+
1693
1790
  const getMenuEntries = state => {
1694
1791
  const {
1695
1792
  extensions,
@@ -1706,13 +1803,13 @@ const getMenuEntries = state => {
1706
1803
  command: 'RunningExtensions.copyId',
1707
1804
  flags: None$1,
1708
1805
  id: 'copyId',
1709
- label: `Copy id (${extension.id})`
1806
+ label: copyId(extension.id)
1710
1807
  }, {
1711
1808
  args,
1712
1809
  command: 'RunningExtensions.reportIssue',
1713
1810
  flags: None$1,
1714
1811
  id: 'reportIssue',
1715
- label: 'Report Issue'
1812
+ label: reportIssue$1()
1716
1813
  }, {
1717
1814
  command: '',
1718
1815
  flags: Separator,
@@ -1723,13 +1820,13 @@ const getMenuEntries = state => {
1723
1820
  command: 'RunningExtensions.disableWorkspace',
1724
1821
  flags: None$1,
1725
1822
  id: 'disableWorkspace',
1726
- label: 'Disable (Workspace)'
1823
+ label: disableWorkspace()
1727
1824
  }, {
1728
1825
  args,
1729
1826
  command: 'RunningExtensions.disable',
1730
1827
  flags: None$1,
1731
1828
  id: 'disable',
1732
- label: 'Disable'
1829
+ label: disable()
1733
1830
  }, {
1734
1831
  command: '',
1735
1832
  flags: Separator,
@@ -1739,7 +1836,7 @@ const getMenuEntries = state => {
1739
1836
  command: 'RunningExtensions.startProfile',
1740
1837
  flags: None$1,
1741
1838
  id: 'startProfile',
1742
- label: 'Start Extension Host Profile'
1839
+ label: startExtensionHostProfile()
1743
1840
  }];
1744
1841
  if (platform === Electron && extension.isolated) {
1745
1842
  menuEntries.push({
@@ -1747,16 +1844,16 @@ const getMenuEntries = state => {
1747
1844
  command: 'RunningExtensions.takeHeapSnapshot',
1748
1845
  flags: None$1,
1749
1846
  id: 'takeHeapSnapshot',
1750
- label: 'Take Heap Snapshot'
1847
+ label: takeHeapSnapshot$1()
1751
1848
  });
1752
1849
  }
1753
1850
  return menuEntries;
1754
1851
  };
1755
1852
 
1756
- const RunningExtensions = 32;
1853
+ const RunningExtensions$1 = 32;
1757
1854
 
1758
1855
  const getMenuEntryIds = () => {
1759
- return [RunningExtensions];
1856
+ return [RunningExtensions$1];
1760
1857
  };
1761
1858
 
1762
1859
  const show = async (uid, menuId, x, y, args) => {
@@ -1777,8 +1874,8 @@ const handleContextMenu = async (state, index, x = 0, y = 0) => {
1777
1874
  focusedIndex
1778
1875
  };
1779
1876
  set(uid, state, newState);
1780
- await show(uid, RunningExtensions, x, y, {
1781
- menuId: RunningExtensions
1877
+ await show(uid, RunningExtensions$1, x, y, {
1878
+ menuId: RunningExtensions$1
1782
1879
  });
1783
1880
  return newState;
1784
1881
  };
@@ -1801,12 +1898,17 @@ const loadContent = async state => {
1801
1898
  };
1802
1899
 
1803
1900
  const getCss = (width, height) => {
1804
- return `width: ${width}px; height: ${height}px;`;
1901
+ return `width: ${width}px; height: ${height}px; flex: 1;`;
1805
1902
  };
1806
1903
 
1807
1904
  const renderCss = (oldState, newState) => {
1808
- const css = getCss(newState.width, newState.height);
1809
- return [SetCss, newState.uid, css];
1905
+ const {
1906
+ height,
1907
+ uid,
1908
+ width
1909
+ } = newState;
1910
+ const css = getCss(width, height);
1911
+ return [SetCss, uid, css];
1810
1912
  };
1811
1913
 
1812
1914
  const mergeClassNames = (...classNames) => {
@@ -1827,13 +1929,31 @@ const List = 'list';
1827
1929
  const ListItem = 'listitem';
1828
1930
  const None = 'none';
1829
1931
 
1932
+ const FocusOutline = 'FocusOutline';
1933
+ const MaskIcon = 'MaskIcon';
1934
+ const MaskIconExtensions = 'MaskIconExtensions';
1935
+ const RunningExtension = 'RunningExtension';
1936
+ const RunningExtensionActivationDetails = 'RunningExtensionActivationDetails';
1937
+ const RunningExtensionActivationReason = 'RunningExtensionActivationReason';
1938
+ const RunningExtensionActivationTime = 'RunningExtensionActivationTime';
1939
+ const RunningExtensionDefaultIcon = 'RunningExtensionDefaultIcon';
1940
+ const RunningExtensionDetails = 'RunningExtensionDetails';
1941
+ const RunningExtensionIcon = 'RunningExtensionIcon';
1942
+ const RunningExtensionId = 'RunningExtensionId';
1943
+ const RunningExtensionName = 'RunningExtensionName';
1944
+ const RunningExtensionRemoteAuthority = 'RunningExtensionRemoteAuthority';
1945
+ const RunningExtensions = 'RunningExtensions';
1946
+ const RunningExtensionsEmpty = 'RunningExtensionsEmpty';
1947
+ const RunningExtensionTitle = 'RunningExtensionTitle';
1948
+ const RunningExtensionVersion = 'RunningExtensionVersion';
1949
+
1830
1950
  const HandleContextMenu = 3;
1831
1951
 
1832
1952
  const getIconVirtualDom = (extension, index) => {
1833
1953
  if (extension.icon) {
1834
1954
  return [{
1835
1955
  childCount: 0,
1836
- className: 'RunningExtensionIcon',
1956
+ className: RunningExtensionIcon,
1837
1957
  'data-index': index,
1838
1958
  src: extension.icon,
1839
1959
  type: Img
@@ -1841,7 +1961,7 @@ const getIconVirtualDom = (extension, index) => {
1841
1961
  }
1842
1962
  return [{
1843
1963
  childCount: 0,
1844
- className: mergeClassNames('RunningExtensionIcon', 'RunningExtensionDefaultIcon', 'MaskIcon', 'MaskIconExtensions'),
1964
+ className: mergeClassNames(RunningExtensionIcon, RunningExtensionDefaultIcon, MaskIcon, MaskIconExtensions),
1845
1965
  'data-index': index,
1846
1966
  role: None,
1847
1967
  type: Div
@@ -1849,6 +1969,17 @@ const getIconVirtualDom = (extension, index) => {
1849
1969
  };
1850
1970
 
1851
1971
  const sshRemotePrefix = 'ssh-remote+';
1972
+ const getActivationReasonVirtualDom = (activationEvent, index) => {
1973
+ if (!activationEvent) {
1974
+ return [];
1975
+ }
1976
+ return [{
1977
+ childCount: 1,
1978
+ className: RunningExtensionActivationReason,
1979
+ 'data-index': index,
1980
+ type: Div
1981
+ }, text(activationReason(activationEvent))];
1982
+ };
1852
1983
  const getRemoteAuthorityVirtualDom = (remoteAuthority, index) => {
1853
1984
  if (!remoteAuthority) {
1854
1985
  return [];
@@ -1856,75 +1987,83 @@ const getRemoteAuthorityVirtualDom = (remoteAuthority, index) => {
1856
1987
  const host = remoteAuthority.startsWith(sshRemotePrefix) ? remoteAuthority.slice(sshRemotePrefix.length) : remoteAuthority;
1857
1988
  return [{
1858
1989
  childCount: 1,
1859
- className: mergeClassNames('RunningExtensionId', 'RunningExtensionRemoteAuthority'),
1990
+ className: mergeClassNames(RunningExtensionId, RunningExtensionRemoteAuthority),
1860
1991
  'data-index': index,
1861
1992
  type: Div
1862
- }, text(`SSH: ${host}`)];
1993
+ }, text(ssh(host))];
1863
1994
  };
1864
- const getExtensionVirtualDom = (extension, index) => {
1995
+ const getExtensionVirtualDom = (extension, index, focused = false) => {
1865
1996
  const displayName = extension.name || extension.id;
1997
+ const activationReasonDom = getActivationReasonVirtualDom(extension.activationEvent, index);
1866
1998
  const remoteAuthorityDom = getRemoteAuthorityVirtualDom(extension.remoteAuthority, index);
1999
+ const className = focused ? mergeClassNames(RunningExtension, FocusOutline) : RunningExtension;
1867
2000
  return [{
1868
2001
  childCount: 3,
1869
- className: 'RunningExtension',
2002
+ className,
1870
2003
  'data-index': index,
1871
2004
  role: ListItem,
1872
2005
  type: Div
1873
2006
  }, ...getIconVirtualDom(extension, index), {
1874
2007
  childCount: remoteAuthorityDom.length > 0 ? 3 : 2,
1875
- className: 'RunningExtensionDetails',
2008
+ className: RunningExtensionDetails,
1876
2009
  'data-index': index,
1877
2010
  type: Div
1878
2011
  }, {
1879
2012
  childCount: 2,
1880
- className: 'RunningExtensionTitle',
2013
+ className: RunningExtensionTitle,
1881
2014
  'data-index': index,
1882
2015
  type: Div
1883
2016
  }, {
1884
2017
  childCount: 1,
1885
- className: 'RunningExtensionName',
2018
+ className: RunningExtensionName,
1886
2019
  'data-index': index,
1887
2020
  type: Strong
1888
2021
  }, text(displayName), {
1889
2022
  childCount: 1,
1890
- className: 'RunningExtensionVersion',
2023
+ className: RunningExtensionVersion,
1891
2024
  'data-index': index,
1892
2025
  type: Span
1893
2026
  }, text(extension.version), ...remoteAuthorityDom, {
1894
2027
  childCount: 1,
1895
- className: 'RunningExtensionId',
2028
+ className: RunningExtensionId,
1896
2029
  'data-index': index,
1897
2030
  type: Div
1898
2031
  }, text(extension.id), {
2032
+ childCount: activationReasonDom.length > 0 ? 2 : 1,
2033
+ className: RunningExtensionActivationDetails,
2034
+ 'data-index': index,
2035
+ type: Div
2036
+ }, {
1899
2037
  childCount: 1,
1900
- className: 'RunningExtensionActivationTime',
2038
+ className: RunningExtensionActivationTime,
1901
2039
  'data-index': index,
1902
2040
  type: Div
1903
- }, text(`Activation: ${Math.round(extension.activationTime)}ms`)];
2041
+ }, text(activationTime(Math.round(extension.activationTime))), ...activationReasonDom];
1904
2042
  };
1905
2043
 
1906
2044
  const getRunningExtensionsEmptyDom = loaded => {
1907
- const message = loaded ? 'No running extensions' : 'Loading running extensions…';
2045
+ const message = loaded ? noRunningExtensions() : loadingRunningExtensions();
1908
2046
  return [{
1909
2047
  childCount: 1,
1910
- className: 'RunningExtensions',
2048
+ className: RunningExtensions,
1911
2049
  onContextMenu: HandleContextMenu,
1912
2050
  role: List,
1913
2051
  type: Div
1914
2052
  }, {
1915
2053
  childCount: 1,
1916
- className: 'RunningExtensionsEmpty',
2054
+ className: RunningExtensionsEmpty,
1917
2055
  type: Div
1918
2056
  }, text(message)];
1919
2057
  };
1920
- const getRunningExtensionsVirtualDom = (extensions, loaded) => {
2058
+
2059
+ const getRunningExtensionsVirtualDom = (extensions, loaded, focusedIndex = -1) => {
1921
2060
  if (extensions.length === 0) {
1922
2061
  return getRunningExtensionsEmptyDom(loaded);
1923
2062
  }
1924
- const children = extensions.flatMap(getExtensionVirtualDom);
2063
+ const children = extensions.flatMap((extension, index) => getExtensionVirtualDom(extension, index, index === focusedIndex));
1925
2064
  return [{
1926
2065
  childCount: extensions.length,
1927
- className: 'RunningExtensions',
2066
+ className: RunningExtensions,
1928
2067
  onContextMenu: HandleContextMenu,
1929
2068
  role: List,
1930
2069
  type: Div
@@ -1932,7 +2071,7 @@ const getRunningExtensionsVirtualDom = (extensions, loaded) => {
1932
2071
  };
1933
2072
 
1934
2073
  const renderDom = (oldState, newState) => {
1935
- return [SetDom2, newState.uid, getRunningExtensionsVirtualDom(newState.extensions, newState.loaded)];
2074
+ return [SetDom2, newState.uid, getRunningExtensionsVirtualDom(newState.extensions, newState.loaded, newState.focusedIndex)];
1936
2075
  };
1937
2076
 
1938
2077
  const getRenderer = diffType => {
@@ -1963,7 +2102,7 @@ const renderEventListeners = () => {
1963
2102
  };
1964
2103
 
1965
2104
  const reportIssue = async state => {
1966
- await confirm('Reporting issues for running extensions is not available yet.');
2105
+ await confirm(reportingIssuesForRunningExtensionsNotAvailable());
1967
2106
  return state;
1968
2107
  };
1969
2108
 
@@ -1982,7 +2121,7 @@ const setExtensions = (state, extensions) => {
1982
2121
  };
1983
2122
 
1984
2123
  const startProfile = async state => {
1985
- await confirm('Extension host profiling is not available yet.');
2124
+ await confirm(extensionHostProfilingNotAvailable());
1986
2125
  return state;
1987
2126
  };
1988
2127
 
@@ -1995,17 +2134,17 @@ const takeHeapSnapshot = async (state, index) => {
1995
2134
  return state;
1996
2135
  }
1997
2136
  const windowId = await getWindowId();
1998
- const workerName = extension.workerName || `Extension API (Electron): ${extension.id}`;
2137
+ const workerName = extension.workerName || extensionApiElectron(extension.id);
1999
2138
  await invoke('Developer.takeWorkerHeapSnapshot', windowId, workerName);
2000
2139
  return state;
2001
2140
  };
2002
2141
 
2003
2142
  const commandMap = {
2004
- 'RunningExtensions.copyId': wrapCommand(copyId),
2143
+ 'RunningExtensions.copyId': wrapCommand(copyId$1),
2005
2144
  'RunningExtensions.create': create,
2006
2145
  'RunningExtensions.diff2': diff2,
2007
- 'RunningExtensions.disable': wrapCommand(disable),
2008
- 'RunningExtensions.disableWorkspace': wrapCommand(disableWorkspace),
2146
+ 'RunningExtensions.disable': wrapCommand(disable$1),
2147
+ 'RunningExtensions.disableWorkspace': wrapCommand(disableWorkspace$1),
2009
2148
  'RunningExtensions.dispose': dispose,
2010
2149
  'RunningExtensions.getCommandIds': getCommandIds,
2011
2150
  'RunningExtensions.getMenuEntries': wrapGetter(getMenuEntries),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/running-extensions-view",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Running Extensions View Worker",
5
5
  "repository": {
6
6
  "type": "git",