@lvce-editor/running-extensions-view 1.14.0 → 1.15.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.
@@ -1755,6 +1755,7 @@ const ActivationTime = 'Activation: {PH1}ms';
1755
1755
  const CopyId = 'Copy id ({PH1})';
1756
1756
  const Disable = 'Disable';
1757
1757
  const DisableWorkspace = 'Disable (Workspace)';
1758
+ const ErrorStatus = 'Error: {PH1}';
1758
1759
  const ExtensionApiElectron = 'Extension API (Electron): {PH1}';
1759
1760
  const ExtensionHostProfilingNotAvailable = 'Extension host profiling is not available yet.';
1760
1761
  const LoadingRunningExtensions = 'Loading running extensions…';
@@ -1764,6 +1765,7 @@ const ReportingIssuesNotSupported = 'Reporting issues is not supported for this
1764
1765
  const Ssh = 'SSH: {PH1}';
1765
1766
  const StartExtensionHostProfile = 'Start Extension Host Profile';
1766
1767
  const TakeHeapSnapshot = 'Take Heap Snapshot';
1768
+ const TerminatedStatus = 'Terminated: {PH1}';
1767
1769
 
1768
1770
  const activationReason = reason => {
1769
1771
  return i18nString(ActivationReason, {
@@ -1786,6 +1788,11 @@ const disable = () => {
1786
1788
  const disableWorkspace = () => {
1787
1789
  return i18nString(DisableWorkspace);
1788
1790
  };
1791
+ const errorStatus = message => {
1792
+ return i18nString(ErrorStatus, {
1793
+ PH1: message
1794
+ });
1795
+ };
1789
1796
  const extensionApiElectron = id => {
1790
1797
  return i18nString(ExtensionApiElectron, {
1791
1798
  PH1: id
@@ -1817,6 +1824,11 @@ const startExtensionHostProfile = () => {
1817
1824
  const takeHeapSnapshot$1 = () => {
1818
1825
  return i18nString(TakeHeapSnapshot);
1819
1826
  };
1827
+ const terminatedStatus = message => {
1828
+ return i18nString(TerminatedStatus, {
1829
+ PH1: message
1830
+ });
1831
+ };
1820
1832
 
1821
1833
  const getMenuEntries = state => {
1822
1834
  const {
@@ -1894,11 +1906,19 @@ const handleBlur = state => {
1894
1906
  };
1895
1907
  };
1896
1908
 
1897
- const handleClickAt = (state, index) => {
1909
+ const getIndex = (state, eventY) => {
1910
+ const {
1911
+ itemHeight,
1912
+ y
1913
+ } = state;
1914
+ return Math.floor((eventY - y) / itemHeight);
1915
+ };
1916
+
1917
+ const handleClickAt = (state, eventY) => {
1898
1918
  const {
1899
1919
  extensions
1900
1920
  } = state;
1901
- const selectedIndex = Number(index);
1921
+ const selectedIndex = getIndex(state, eventY);
1902
1922
  return {
1903
1923
  ...state,
1904
1924
  focusOutline: false,
@@ -1910,12 +1930,12 @@ const show = async (uid, menuId, x, y, args) => {
1910
1930
  await showContextMenu2(uid, menuId, x, y, args);
1911
1931
  };
1912
1932
 
1913
- const handleContextMenu = async (state, index, x = 0, y = 0) => {
1933
+ const handleContextMenu = async (state, eventX, eventY) => {
1914
1934
  const {
1915
1935
  extensions,
1916
1936
  uid
1917
1937
  } = state;
1918
- const focusedIndex = Number(index);
1938
+ const focusedIndex = getIndex(state, eventY);
1919
1939
  if (!extensions[focusedIndex]) {
1920
1940
  return state;
1921
1941
  }
@@ -1925,7 +1945,7 @@ const handleContextMenu = async (state, index, x = 0, y = 0) => {
1925
1945
  focusOutline: true
1926
1946
  };
1927
1947
  set(uid, state, newState);
1928
- await show(uid, RunningExtensions$1, x, y, {
1948
+ await show(uid, RunningExtensions$1, eventX, eventY, {
1929
1949
  menuId: RunningExtensions$1
1930
1950
  });
1931
1951
  return newState;
@@ -2254,6 +2274,9 @@ const RunningExtensionIcon = 'RunningExtensionIcon';
2254
2274
  const RunningExtensionId = 'RunningExtensionId';
2255
2275
  const RunningExtensionName = 'RunningExtensionName';
2256
2276
  const RunningExtensionRemoteAuthority = 'RunningExtensionRemoteAuthority';
2277
+ const RunningExtensionStatus = 'RunningExtensionStatus';
2278
+ const RunningExtensionStatusError = 'RunningExtensionStatusError';
2279
+ const RunningExtensionStatusTerminated = 'RunningExtensionStatusTerminated';
2257
2280
  const RunningExtensions = 'RunningExtensions';
2258
2281
  const RunningExtensionsEmpty = 'RunningExtensionsEmpty';
2259
2282
  const RunningExtensionTitle = 'RunningExtensionTitle';
@@ -2263,12 +2286,11 @@ const HandleContextMenu = 3;
2263
2286
  const HandleClick = 4;
2264
2287
  const HandleBlur = 5;
2265
2288
 
2266
- const getIconVirtualDom = (extension, index) => {
2289
+ const getIconVirtualDom = extension => {
2267
2290
  if (extension.icon) {
2268
2291
  return [{
2269
2292
  childCount: 0,
2270
2293
  className: RunningExtensionIcon,
2271
- 'data-index': index,
2272
2294
  src: extension.icon,
2273
2295
  type: Img
2274
2296
  }];
@@ -2276,25 +2298,68 @@ const getIconVirtualDom = (extension, index) => {
2276
2298
  return [{
2277
2299
  childCount: 0,
2278
2300
  className: mergeClassNames(RunningExtensionIcon, RunningExtensionDefaultIcon, MaskIcon, MaskIconExtensions),
2279
- 'data-index': index,
2280
2301
  role: None,
2281
2302
  type: Div
2282
2303
  }];
2283
2304
  };
2284
2305
 
2285
2306
  const sshRemotePrefix = 'ssh-remote+';
2286
- const getActivationReasonVirtualDom = (activationEvent, index) => {
2307
+ const activationReasonNode = {
2308
+ childCount: 1,
2309
+ className: RunningExtensionActivationReason,
2310
+ type: Div
2311
+ };
2312
+ const titleNode = {
2313
+ childCount: 2,
2314
+ className: RunningExtensionTitle,
2315
+ type: Div
2316
+ };
2317
+ const nameNode = {
2318
+ childCount: 1,
2319
+ className: RunningExtensionName,
2320
+ type: Strong
2321
+ };
2322
+ const versionNode = {
2323
+ childCount: 1,
2324
+ className: RunningExtensionVersion,
2325
+ type: Span
2326
+ };
2327
+ const idNode = {
2328
+ childCount: 1,
2329
+ className: RunningExtensionId,
2330
+ type: Div
2331
+ };
2332
+ const activationTimeNode = {
2333
+ childCount: 1,
2334
+ className: RunningExtensionActivationTime,
2335
+ type: Div
2336
+ };
2337
+ const errorStatusNode = {
2338
+ childCount: 1,
2339
+ className: mergeClassNames(RunningExtensionStatus, RunningExtensionStatusError),
2340
+ type: Div
2341
+ };
2342
+ const terminatedStatusNode = {
2343
+ childCount: 1,
2344
+ className: mergeClassNames(RunningExtensionStatus, RunningExtensionStatusTerminated),
2345
+ type: Div
2346
+ };
2347
+ const getStatusVirtualDom = extension => {
2348
+ if (extension.status === 'error') {
2349
+ return [errorStatusNode, text(errorStatus(extension.error || 'Activation failed'))];
2350
+ }
2351
+ if (extension.status === 'terminated') {
2352
+ return [terminatedStatusNode, text(terminatedStatus(extension.error || 'Extension worker stopped'))];
2353
+ }
2354
+ return [activationTimeNode, text(activationTime(Math.round(extension.activationTime)))];
2355
+ };
2356
+ const getActivationReasonVirtualDom = activationEvent => {
2287
2357
  if (!activationEvent) {
2288
2358
  return [];
2289
2359
  }
2290
- return [{
2291
- childCount: 1,
2292
- className: RunningExtensionActivationReason,
2293
- 'data-index': index,
2294
- type: Div
2295
- }, text(activationReason(activationEvent))];
2360
+ return [activationReasonNode, text(activationReason(activationEvent))];
2296
2361
  };
2297
- const getRemoteAuthorityVirtualDom = (remoteAuthority, index) => {
2362
+ const getRemoteAuthorityVirtualDom = remoteAuthority => {
2298
2363
  if (!remoteAuthority) {
2299
2364
  return [];
2300
2365
  }
@@ -2302,7 +2367,6 @@ const getRemoteAuthorityVirtualDom = (remoteAuthority, index) => {
2302
2367
  return [{
2303
2368
  childCount: 1,
2304
2369
  className: mergeClassNames(RunningExtensionId, RunningExtensionRemoteAuthority),
2305
- 'data-index': index,
2306
2370
  type: Div
2307
2371
  }, text(ssh(host))];
2308
2372
  };
@@ -2316,53 +2380,27 @@ const getClassName = (focused, selected) => {
2316
2380
  }
2317
2381
  return className;
2318
2382
  };
2319
- const getExtensionVirtualDom = (extension, index, focused = false, selected = false) => {
2320
- const displayName = extension.name || extension.id;
2321
- const activationReasonDom = getActivationReasonVirtualDom(extension.activationEvent, index);
2322
- const remoteAuthorityDom = getRemoteAuthorityVirtualDom(extension.remoteAuthority, index);
2383
+ const getExtensionVirtualDom = (extension, focused = false, selected = false) => {
2384
+ const displayName = typeof extension.name === 'string' && extension.name ? extension.name : extension.id;
2385
+ const displayVersion = typeof extension.version === 'string' ? extension.version : '';
2386
+ const activationReasonDom = getActivationReasonVirtualDom(extension.activationEvent);
2387
+ const statusDom = getStatusVirtualDom(extension);
2388
+ const remoteAuthorityDom = getRemoteAuthorityVirtualDom(extension.remoteAuthority);
2323
2389
  const className = getClassName(focused, selected);
2324
2390
  return [{
2325
2391
  childCount: 3,
2326
2392
  className,
2327
- 'data-index': index,
2328
2393
  role: ListItem,
2329
2394
  type: Div
2330
- }, ...getIconVirtualDom(extension, index), {
2395
+ }, ...getIconVirtualDom(extension), {
2331
2396
  childCount: remoteAuthorityDom.length > 0 ? 3 : 2,
2332
2397
  className: RunningExtensionDetails,
2333
- 'data-index': index,
2334
- type: Div
2335
- }, {
2336
- childCount: 2,
2337
- className: RunningExtensionTitle,
2338
- 'data-index': index,
2339
2398
  type: Div
2340
- }, {
2341
- childCount: 1,
2342
- className: RunningExtensionName,
2343
- 'data-index': index,
2344
- type: Strong
2345
- }, text(displayName), {
2346
- childCount: 1,
2347
- className: RunningExtensionVersion,
2348
- 'data-index': index,
2349
- type: Span
2350
- }, text(extension.version), ...remoteAuthorityDom, {
2351
- childCount: 1,
2352
- className: RunningExtensionId,
2353
- 'data-index': index,
2354
- type: Div
2355
- }, text(extension.id), {
2399
+ }, titleNode, nameNode, text(displayName), versionNode, text(displayVersion), ...remoteAuthorityDom, idNode, text(extension.id), {
2356
2400
  childCount: activationReasonDom.length > 0 ? 2 : 1,
2357
2401
  className: RunningExtensionActivationDetails,
2358
- 'data-index': index,
2359
- type: Div
2360
- }, {
2361
- childCount: 1,
2362
- className: RunningExtensionActivationTime,
2363
- 'data-index': index,
2364
2402
  type: Div
2365
- }, text(activationTime(Math.round(extension.activationTime))), ...activationReasonDom];
2403
+ }, ...statusDom, ...activationReasonDom];
2366
2404
  };
2367
2405
 
2368
2406
  const Focusable = 0;
@@ -2403,7 +2441,7 @@ const getRunningExtensionsVirtualDom = (extensions, loaded, focusedIndex = -1, s
2403
2441
  role: List,
2404
2442
  tabIndex: Focusable,
2405
2443
  type: Div
2406
- }, ...extensions.flatMap((extension, index) => getExtensionVirtualDom(extension, index, focusOutline && index === focusedIndex, index === selectedIndex))];
2444
+ }, ...extensions.flatMap((extension, index) => getExtensionVirtualDom(extension, focusOutline && index === focusedIndex, index === selectedIndex))];
2407
2445
  };
2408
2446
 
2409
2447
  const renderDom = (oldState, newState) => {
@@ -2441,11 +2479,11 @@ const render2 = (uid, diffResult) => {
2441
2479
  const renderEventListeners = () => {
2442
2480
  return [{
2443
2481
  name: HandleContextMenu,
2444
- params: ['handleContextMenu', 'event.target.dataset.index', ClientX, ClientY],
2482
+ params: ['handleContextMenu', ClientX, ClientY],
2445
2483
  preventDefault: true
2446
2484
  }, {
2447
2485
  name: HandleClick,
2448
- params: ['handleClickAt', 'event.target.dataset.index'],
2486
+ params: ['handleClickAt', ClientY],
2449
2487
  preventDefault: true
2450
2488
  }, {
2451
2489
  name: HandleBlur,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/running-extensions-view",
3
- "version": "1.14.0",
3
+ "version": "1.15.0",
4
4
  "description": "Running Extensions View Worker",
5
5
  "repository": {
6
6
  "type": "git",