@lvce-editor/running-extensions-view 1.8.0 → 1.10.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.
@@ -1388,6 +1388,12 @@ const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
1388
1388
  const getWindowId = async () => {
1389
1389
  return invoke('GetWindowId.getWindowId');
1390
1390
  };
1391
+ const openExternal = async uri => {
1392
+ await invoke('Open.openExternal', uri);
1393
+ };
1394
+ const openUrl = async uri => {
1395
+ await invoke('Open.openUrl', uri);
1396
+ };
1391
1397
 
1392
1398
  const copyId$1 = async (state, index) => {
1393
1399
  const {
@@ -1660,8 +1666,10 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
1660
1666
  extensions: [],
1661
1667
  focusedIndex: -1,
1662
1668
  height,
1669
+ itemHeight: 72,
1663
1670
  loaded: false,
1664
1671
  platform,
1672
+ selectedIndex: -1,
1665
1673
  uid,
1666
1674
  width,
1667
1675
  x,
@@ -1671,7 +1679,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
1671
1679
  };
1672
1680
 
1673
1681
  const isDomEqual = (oldState, newState) => {
1674
- return oldState.extensions === newState.extensions && oldState.focusedIndex === newState.focusedIndex && oldState.loaded === newState.loaded;
1682
+ return oldState.extensions === newState.extensions && oldState.focusedIndex === newState.focusedIndex && oldState.loaded === newState.loaded && oldState.selectedIndex === newState.selectedIndex;
1675
1683
  };
1676
1684
  const isCssEqual = (oldState, newState) => {
1677
1685
  return oldState.width === newState.width && oldState.height === newState.height;
@@ -1729,7 +1737,7 @@ const ExtensionHostProfilingNotAvailable = 'Extension host profiling is not avai
1729
1737
  const LoadingRunningExtensions = 'Loading running extensions…';
1730
1738
  const NoRunningExtensions = 'No running extensions';
1731
1739
  const ReportIssue = 'Report Issue';
1732
- const ReportingIssuesForRunningExtensionsNotAvailable = 'Reporting issues for running extensions is not available yet.';
1740
+ const ReportingIssuesNotSupported = 'Reporting issues is not supported for this extension.';
1733
1741
  const Ssh = 'SSH: {PH1}';
1734
1742
  const StartExtensionHostProfile = 'Start Extension Host Profile';
1735
1743
  const TakeHeapSnapshot = 'Take Heap Snapshot';
@@ -1772,8 +1780,8 @@ const noRunningExtensions = () => {
1772
1780
  const reportIssue$1 = () => {
1773
1781
  return i18nString(ReportIssue);
1774
1782
  };
1775
- const reportingIssuesForRunningExtensionsNotAvailable = () => {
1776
- return i18nString(ReportingIssuesForRunningExtensionsNotAvailable);
1783
+ const reportingIssuesNotSupported = () => {
1784
+ return i18nString(ReportingIssuesNotSupported);
1777
1785
  };
1778
1786
  const ssh = host => {
1779
1787
  return i18nString(Ssh, {
@@ -1856,6 +1864,19 @@ const getMenuEntryIds = () => {
1856
1864
  return [RunningExtensions$1];
1857
1865
  };
1858
1866
 
1867
+ const handleClickAt = (state, eventY) => {
1868
+ const {
1869
+ extensions,
1870
+ itemHeight,
1871
+ y
1872
+ } = state;
1873
+ const index = Math.floor((eventY - y) / itemHeight);
1874
+ return {
1875
+ ...state,
1876
+ selectedIndex: extensions[index] ? index : -1
1877
+ };
1878
+ };
1879
+
1859
1880
  const show = async (uid, menuId, x, y, args) => {
1860
1881
  await showContextMenu2(uid, menuId, x, y, args);
1861
1882
  };
@@ -1930,8 +1951,10 @@ const ListItem = 'listitem';
1930
1951
  const None = 'none';
1931
1952
 
1932
1953
  const FocusOutline = 'FocusOutline';
1954
+ const Grow = 'Grow';
1933
1955
  const MaskIcon = 'MaskIcon';
1934
1956
  const MaskIconExtensions = 'MaskIconExtensions';
1957
+ const ExtensionActive = 'ExtensionActive';
1935
1958
  const RunningExtension = 'RunningExtension';
1936
1959
  const RunningExtensionActivationDetails = 'RunningExtensionActivationDetails';
1937
1960
  const RunningExtensionActivationReason = 'RunningExtensionActivationReason';
@@ -1948,6 +1971,7 @@ const RunningExtensionTitle = 'RunningExtensionTitle';
1948
1971
  const RunningExtensionVersion = 'RunningExtensionVersion';
1949
1972
 
1950
1973
  const HandleContextMenu = 3;
1974
+ const HandleClick = 4;
1951
1975
 
1952
1976
  const getIconVirtualDom = (extension, index) => {
1953
1977
  if (extension.icon) {
@@ -1992,11 +2016,17 @@ const getRemoteAuthorityVirtualDom = (remoteAuthority, index) => {
1992
2016
  type: Div
1993
2017
  }, text(ssh(host))];
1994
2018
  };
1995
- const getExtensionVirtualDom = (extension, index, focused = false) => {
2019
+ const getExtensionVirtualDom = (extension, index, focused = false, selected = false) => {
1996
2020
  const displayName = extension.name || extension.id;
1997
2021
  const activationReasonDom = getActivationReasonVirtualDom(extension.activationEvent, index);
1998
2022
  const remoteAuthorityDom = getRemoteAuthorityVirtualDom(extension.remoteAuthority, index);
1999
- const className = focused ? mergeClassNames(RunningExtension, FocusOutline) : RunningExtension;
2023
+ let className = RunningExtension;
2024
+ if (focused) {
2025
+ className = mergeClassNames(className, FocusOutline);
2026
+ }
2027
+ if (selected) {
2028
+ className = mergeClassNames(className, ExtensionActive);
2029
+ }
2000
2030
  return [{
2001
2031
  childCount: 3,
2002
2032
  className,
@@ -2041,29 +2071,32 @@ const getExtensionVirtualDom = (extension, index, focused = false) => {
2041
2071
  }, text(activationTime(Math.round(extension.activationTime))), ...activationReasonDom];
2042
2072
  };
2043
2073
 
2074
+ const emptyNode = {
2075
+ childCount: 1,
2076
+ className: RunningExtensionsEmpty,
2077
+ type: Div
2078
+ };
2044
2079
  const getRunningExtensionsEmptyDom = loaded => {
2045
2080
  const message = loaded ? noRunningExtensions() : loadingRunningExtensions();
2046
2081
  return [{
2047
2082
  childCount: 1,
2048
- className: RunningExtensions,
2083
+ className: mergeClassNames(RunningExtensions, Grow),
2084
+ onClick: HandleClick,
2049
2085
  onContextMenu: HandleContextMenu,
2050
2086
  role: List,
2051
2087
  type: Div
2052
- }, {
2053
- childCount: 1,
2054
- className: RunningExtensionsEmpty,
2055
- type: Div
2056
- }, text(message)];
2088
+ }, emptyNode, text(message)];
2057
2089
  };
2058
2090
 
2059
- const getRunningExtensionsVirtualDom = (extensions, loaded, focusedIndex = -1) => {
2091
+ const getRunningExtensionsVirtualDom = (extensions, loaded, focusedIndex = -1, selectedIndex = -1) => {
2060
2092
  if (extensions.length === 0) {
2061
2093
  return getRunningExtensionsEmptyDom(loaded);
2062
2094
  }
2063
- const children = extensions.flatMap((extension, index) => getExtensionVirtualDom(extension, index, index === focusedIndex));
2095
+ const children = extensions.flatMap((extension, index) => getExtensionVirtualDom(extension, index, index === focusedIndex, index === selectedIndex));
2064
2096
  return [{
2065
2097
  childCount: extensions.length,
2066
- className: RunningExtensions,
2098
+ className: mergeClassNames(RunningExtensions, Grow),
2099
+ onClick: HandleClick,
2067
2100
  onContextMenu: HandleContextMenu,
2068
2101
  role: List,
2069
2102
  type: Div
@@ -2071,7 +2104,7 @@ const getRunningExtensionsVirtualDom = (extensions, loaded, focusedIndex = -1) =
2071
2104
  };
2072
2105
 
2073
2106
  const renderDom = (oldState, newState) => {
2074
- return [SetDom2, newState.uid, getRunningExtensionsVirtualDom(newState.extensions, newState.loaded, newState.focusedIndex)];
2107
+ return [SetDom2, newState.uid, getRunningExtensionsVirtualDom(newState.extensions, newState.loaded, newState.focusedIndex, newState.selectedIndex)];
2075
2108
  };
2076
2109
 
2077
2110
  const getRenderer = diffType => {
@@ -2098,11 +2131,53 @@ const renderEventListeners = () => {
2098
2131
  name: HandleContextMenu,
2099
2132
  params: ['handleContextMenu', 'event.target.dataset.index', ClientX, ClientY],
2100
2133
  preventDefault: true
2134
+ }, {
2135
+ name: HandleClick,
2136
+ params: ['handleClickAt', ClientY],
2137
+ preventDefault: true
2101
2138
  }];
2102
2139
  };
2103
2140
 
2104
- const reportIssue = async state => {
2105
- await confirm(reportingIssuesForRunningExtensionsNotAvailable());
2141
+ const gitSuffixRegex = /\.git$/;
2142
+ const getIssuesUrl = repository => {
2143
+ if (typeof repository !== 'string') {
2144
+ return '';
2145
+ }
2146
+ let url;
2147
+ try {
2148
+ url = new URL(repository);
2149
+ } catch {
2150
+ return '';
2151
+ }
2152
+ if (url.protocol !== 'https:' || url.hostname !== 'github.com') {
2153
+ return '';
2154
+ }
2155
+ const [owner, repositoryWithSuffix] = url.pathname.split('/').filter(Boolean);
2156
+ if (!owner || !repositoryWithSuffix) {
2157
+ return '';
2158
+ }
2159
+ const repositoryName = repositoryWithSuffix.replace(gitSuffixRegex, '');
2160
+ if (!repositoryName) {
2161
+ return '';
2162
+ }
2163
+ return `https://github.com/${owner}/${repositoryName}/issues`;
2164
+ };
2165
+
2166
+ const reportIssue = async (state, index) => {
2167
+ const {
2168
+ extensions,
2169
+ platform
2170
+ } = state;
2171
+ const issuesUrl = getIssuesUrl(extensions[index]?.repository);
2172
+ if (!issuesUrl) {
2173
+ await confirm(reportingIssuesNotSupported());
2174
+ return state;
2175
+ }
2176
+ if (platform === Electron) {
2177
+ await openExternal(issuesUrl);
2178
+ } else {
2179
+ await openUrl(issuesUrl);
2180
+ }
2106
2181
  return state;
2107
2182
  };
2108
2183
 
@@ -2127,15 +2202,21 @@ const startProfile = async state => {
2127
2202
 
2128
2203
  const takeHeapSnapshot = async (state, index) => {
2129
2204
  const {
2130
- extensions
2205
+ extensions,
2206
+ platform
2131
2207
  } = state;
2132
2208
  const extension = extensions[index];
2133
- if (!extension) {
2209
+ if (!extension || platform !== Electron || !extension.isolated) {
2134
2210
  return state;
2135
2211
  }
2136
2212
  const windowId = await getWindowId();
2137
2213
  const workerName = extension.workerName || extensionApiElectron(extension.id);
2138
- await invoke('Developer.takeWorkerHeapSnapshot', windowId, workerName);
2214
+ const result = await invoke('Developer.takeWorkerHeapSnapshot', windowId, workerName);
2215
+ if (!result.ok) {
2216
+ await confirm(result.error);
2217
+ return state;
2218
+ }
2219
+ await invoke('Main.openUri', result.uri);
2139
2220
  return state;
2140
2221
  };
2141
2222
 
@@ -2149,6 +2230,7 @@ const commandMap = {
2149
2230
  'RunningExtensions.getCommandIds': getCommandIds,
2150
2231
  'RunningExtensions.getMenuEntries': wrapGetter(getMenuEntries),
2151
2232
  'RunningExtensions.getMenuEntryIds': getMenuEntryIds,
2233
+ 'RunningExtensions.handleClickAt': wrapCommand(handleClickAt),
2152
2234
  'RunningExtensions.handleContextMenu': wrapCommand(handleContextMenu),
2153
2235
  'RunningExtensions.loadContent': wrapCommand(loadContent),
2154
2236
  'RunningExtensions.render2': render2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/running-extensions-view",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "description": "Running Extensions View Worker",
5
5
  "repository": {
6
6
  "type": "git",