@lvce-editor/extension-detail-view 6.6.0 → 6.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.
@@ -1045,15 +1045,17 @@ const RendererWorker = 1;
1045
1045
  const FocusElementByName = 'Viewlet.focusElementByName';
1046
1046
  const SetFocusContext = 'Viewlet.setFocusContext';
1047
1047
 
1048
+ const FocusExtensionDetailTabs = 451;
1049
+
1048
1050
  const rpcs = Object.create(null);
1049
- const set$b = (id, rpc) => {
1051
+ const set$a = (id, rpc) => {
1050
1052
  rpcs[id] = rpc;
1051
1053
  };
1052
1054
  const get$3 = id => {
1053
1055
  return rpcs[id];
1054
1056
  };
1055
1057
 
1056
- const create$7 = rpcId => {
1058
+ const create$4 = rpcId => {
1057
1059
  return {
1058
1060
  async dispose() {
1059
1061
  const rpc = get$3(rpcId);
@@ -1072,7 +1074,7 @@ const create$7 = rpcId => {
1072
1074
  return rpc.invokeAndTransfer(method, ...params);
1073
1075
  },
1074
1076
  set(rpc) {
1075
- set$b(rpcId, rpc);
1077
+ set$a(rpcId, rpc);
1076
1078
  }
1077
1079
  };
1078
1080
  };
@@ -1591,56 +1593,14 @@ const IpcParentWithMessagePort$1 = {
1591
1593
  wrap: wrap$5
1592
1594
  };
1593
1595
 
1594
- const Two = '2.0';
1595
- const create$4 = (method, params) => {
1596
- return {
1597
- jsonrpc: Two,
1598
- method,
1599
- params
1600
- };
1601
- };
1596
+ const Two$1 = '2.0';
1602
1597
  const callbacks = Object.create(null);
1603
- const set$a = (id, fn) => {
1604
- callbacks[id] = fn;
1605
- };
1606
1598
  const get$2 = id => {
1607
1599
  return callbacks[id];
1608
1600
  };
1609
1601
  const remove$1 = id => {
1610
1602
  delete callbacks[id];
1611
1603
  };
1612
- let id = 0;
1613
- const create$3$1 = () => {
1614
- return ++id;
1615
- };
1616
- const registerPromise = () => {
1617
- const id = create$3$1();
1618
- const {
1619
- resolve,
1620
- promise
1621
- } = Promise.withResolvers();
1622
- set$a(id, resolve);
1623
- return {
1624
- id,
1625
- promise
1626
- };
1627
- };
1628
- const create$2$1 = (method, params) => {
1629
- const {
1630
- id,
1631
- promise
1632
- } = registerPromise();
1633
- const message = {
1634
- jsonrpc: Two,
1635
- method,
1636
- params,
1637
- id
1638
- };
1639
- return {
1640
- message,
1641
- promise
1642
- };
1643
- };
1644
1604
  class JsonRpcError extends Error {
1645
1605
  constructor(message) {
1646
1606
  super(message);
@@ -1836,7 +1796,7 @@ const getErrorProperty = (error, prettyError) => {
1836
1796
  };
1837
1797
  const create$1$1 = (id, error) => {
1838
1798
  return {
1839
- jsonrpc: Two,
1799
+ jsonrpc: Two$1,
1840
1800
  id,
1841
1801
  error
1842
1802
  };
@@ -1847,20 +1807,20 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
1847
1807
  const errorProperty = getErrorProperty(error, prettyError);
1848
1808
  return create$1$1(id, errorProperty);
1849
1809
  };
1850
- const create$6 = (message, result) => {
1810
+ const create$3 = (message, result) => {
1851
1811
  return {
1852
- jsonrpc: Two,
1812
+ jsonrpc: Two$1,
1853
1813
  id: message.id,
1854
1814
  result: result ?? null
1855
1815
  };
1856
1816
  };
1857
1817
  const getSuccessResponse = (message, result) => {
1858
1818
  const resultProperty = result ?? null;
1859
- return create$6(message, resultProperty);
1819
+ return create$3(message, resultProperty);
1860
1820
  };
1861
1821
  const getErrorResponseSimple = (id, error) => {
1862
1822
  return {
1863
- jsonrpc: Two,
1823
+ jsonrpc: Two$1,
1864
1824
  id,
1865
1825
  error: {
1866
1826
  code: Custom,
@@ -1947,29 +1907,6 @@ const handleJsonRpcMessage = async (...args) => {
1947
1907
  }
1948
1908
  throw new JsonRpcError('unexpected message');
1949
1909
  };
1950
- const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
1951
- const {
1952
- message,
1953
- promise
1954
- } = create$2$1(method, params);
1955
- if (useSendAndTransfer && ipc.sendAndTransfer) {
1956
- ipc.sendAndTransfer(message);
1957
- } else {
1958
- ipc.send(message);
1959
- }
1960
- const responseMessage = await promise;
1961
- return unwrapJsonRpcResult(responseMessage);
1962
- };
1963
- const send = (transport, method, ...params) => {
1964
- const message = create$4(method, params);
1965
- transport.send(message);
1966
- };
1967
- const invoke$6 = (ipc, method, ...params) => {
1968
- return invokeHelper(ipc, method, params, false);
1969
- };
1970
- const invokeAndTransfer$4 = (ipc, method, ...params) => {
1971
- return invokeHelper(ipc, method, params, true);
1972
- };
1973
1910
 
1974
1911
  class CommandNotFoundError extends Error {
1975
1912
  constructor(command) {
@@ -1992,24 +1929,87 @@ const execute = (command, ...args) => {
1992
1929
  return fn(...args);
1993
1930
  };
1994
1931
 
1932
+ const Two = '2.0';
1933
+ const create$p = (method, params) => {
1934
+ return {
1935
+ jsonrpc: Two,
1936
+ method,
1937
+ params
1938
+ };
1939
+ };
1940
+ const create$o = (id, method, params) => {
1941
+ const message = {
1942
+ id,
1943
+ jsonrpc: Two,
1944
+ method,
1945
+ params
1946
+ };
1947
+ return message;
1948
+ };
1949
+ let id = 0;
1950
+ const create$n = () => {
1951
+ return ++id;
1952
+ };
1953
+
1954
+ /* eslint-disable n/no-unsupported-features/es-syntax */
1955
+
1956
+ const registerPromise = map => {
1957
+ const id = create$n();
1958
+ const {
1959
+ promise,
1960
+ resolve
1961
+ } = Promise.withResolvers();
1962
+ map[id] = resolve;
1963
+ return {
1964
+ id,
1965
+ promise
1966
+ };
1967
+ };
1968
+
1969
+ // @ts-ignore
1970
+ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
1971
+ const {
1972
+ id,
1973
+ promise
1974
+ } = registerPromise(callbacks);
1975
+ const message = create$o(id, method, params);
1976
+ if (useSendAndTransfer && ipc.sendAndTransfer) {
1977
+ ipc.sendAndTransfer(message);
1978
+ } else {
1979
+ ipc.send(message);
1980
+ }
1981
+ const responseMessage = await promise;
1982
+ return unwrapJsonRpcResult(responseMessage);
1983
+ };
1995
1984
  const createRpc = ipc => {
1985
+ const callbacks = Object.create(null);
1986
+ ipc._resolve = (id, response) => {
1987
+ const fn = callbacks[id];
1988
+ if (!fn) {
1989
+ console.warn(`callback ${id} may already be disposed`);
1990
+ return;
1991
+ }
1992
+ fn(response);
1993
+ delete callbacks[id];
1994
+ };
1996
1995
  const rpc = {
1996
+ async dispose() {
1997
+ await ipc?.dispose();
1998
+ },
1999
+ invoke(method, ...params) {
2000
+ return invokeHelper(callbacks, ipc, method, params, false);
2001
+ },
2002
+ invokeAndTransfer(method, ...params) {
2003
+ return invokeHelper(callbacks, ipc, method, params, true);
2004
+ },
1997
2005
  // @ts-ignore
1998
2006
  ipc,
1999
2007
  /**
2000
2008
  * @deprecated
2001
2009
  */
2002
2010
  send(method, ...params) {
2003
- send(ipc, method, ...params);
2004
- },
2005
- invoke(method, ...params) {
2006
- return invoke$6(ipc, method, ...params);
2007
- },
2008
- invokeAndTransfer(method, ...params) {
2009
- return invokeAndTransfer$4(ipc, method, ...params);
2010
- },
2011
- async dispose() {
2012
- await ipc?.dispose();
2011
+ const message = create$p(method, params);
2012
+ ipc.send(message);
2013
2013
  }
2014
2014
  };
2015
2015
  return rpc;
@@ -2026,7 +2026,7 @@ const logError = () => {
2026
2026
  const handleMessage = event => {
2027
2027
  const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
2028
2028
  const actualExecute = event?.target?.execute || execute;
2029
- return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
2029
+ return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
2030
2030
  };
2031
2031
  const handleIpc = ipc => {
2032
2032
  if ('addEventListener' in ipc) {
@@ -2044,15 +2044,16 @@ const listen$1 = async (module, options) => {
2044
2044
  const ipc = module.wrap(rawIpc);
2045
2045
  return ipc;
2046
2046
  };
2047
- const create$5 = async ({
2047
+ const create$7 = async ({
2048
2048
  commandMap,
2049
+ isMessagePortOpen = true,
2049
2050
  messagePort
2050
2051
  }) => {
2051
2052
  // TODO create a commandMap per rpc instance
2052
2053
  register(commandMap);
2053
2054
  const rawIpc = await IpcParentWithMessagePort$1.create({
2054
- messagePort,
2055
- isMessagePortOpen: true
2055
+ isMessagePortOpen,
2056
+ messagePort
2056
2057
  });
2057
2058
  const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
2058
2059
  handleIpc(ipc);
@@ -2060,8 +2061,9 @@ const create$5 = async ({
2060
2061
  messagePort.start();
2061
2062
  return rpc;
2062
2063
  };
2063
- const create$3 = async ({
2064
+ const create$5 = async ({
2064
2065
  commandMap,
2066
+ isMessagePortOpen,
2065
2067
  send
2066
2068
  }) => {
2067
2069
  const {
@@ -2069,14 +2071,15 @@ const create$3 = async ({
2069
2071
  port2
2070
2072
  } = new MessageChannel();
2071
2073
  await send(port1);
2072
- return create$5({
2074
+ return create$7({
2073
2075
  commandMap,
2076
+ isMessagePortOpen,
2074
2077
  messagePort: port2
2075
2078
  });
2076
2079
  };
2077
2080
  const TransferMessagePortRpcParent = {
2078
2081
  __proto__: null,
2079
- create: create$3
2082
+ create: create$5
2080
2083
  };
2081
2084
  const create$2 = async ({
2082
2085
  commandMap
@@ -2105,9 +2108,9 @@ const createMockRpc = ({
2105
2108
  return command(...params);
2106
2109
  };
2107
2110
  const mockRpc = {
2111
+ invocations,
2108
2112
  invoke,
2109
- invokeAndTransfer: invoke,
2110
- invocations
2113
+ invokeAndTransfer: invoke
2111
2114
  };
2112
2115
  return mockRpc;
2113
2116
  };
@@ -2117,7 +2120,7 @@ const {
2117
2120
  invoke: invoke$5,
2118
2121
  invokeAndTransfer: invokeAndTransfer$3,
2119
2122
  set: set$9
2120
- } = create$7(ExtensionHostWorker);
2123
+ } = create$4(ExtensionHostWorker);
2121
2124
  const executeReferenceProvider = async (id, offset) => {
2122
2125
  // @ts-ignore
2123
2126
  return invoke$5('ExtensionHostReference.executeReferenceProvider', id, offset);
@@ -2153,7 +2156,7 @@ const ExtensionHost = {
2153
2156
  const {
2154
2157
  invoke: invoke$4,
2155
2158
  set: set$8
2156
- } = create$7(ExtensionManagementWorker);
2159
+ } = create$4(ExtensionManagementWorker);
2157
2160
  const enable2 = (id, platform) => {
2158
2161
  return invoke$4(`Extensions.enable2`, id, platform);
2159
2162
  };
@@ -2166,7 +2169,7 @@ const {
2166
2169
  invoke: invoke$3,
2167
2170
  invokeAndTransfer: invokeAndTransfer$2,
2168
2171
  set: set$7
2169
- } = create$7(FileSystemWorker$1);
2172
+ } = create$4(FileSystemWorker$1);
2170
2173
  const remove = async dirent => {
2171
2174
  return invoke$3('FileSystem.remove', dirent);
2172
2175
  };
@@ -2254,7 +2257,7 @@ const {
2254
2257
  invoke: invoke$2,
2255
2258
  invokeAndTransfer: invokeAndTransfer$1,
2256
2259
  set: set$6
2257
- } = create$7(MarkdownWorker$1);
2260
+ } = create$4(MarkdownWorker$1);
2258
2261
  const getVirtualDom$1 = async html => {
2259
2262
  // @ts-ignore
2260
2263
  return invoke$2('Markdown.getVirtualDom', html);
@@ -2286,7 +2289,7 @@ const {
2286
2289
  invoke: invoke$1,
2287
2290
  invokeAndTransfer,
2288
2291
  set: set$5
2289
- } = create$7(RendererWorker);
2292
+ } = create$4(RendererWorker);
2290
2293
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
2291
2294
  number(uid);
2292
2295
  number(menuId);
@@ -3279,16 +3282,15 @@ const focusPreviousTab = state => {
3279
3282
  };
3280
3283
  };
3281
3284
 
3282
- const focusId$1 = 451;
3283
3285
  const getKeyBindings = () => {
3284
3286
  return [{
3285
3287
  command: 'ExtensionDetail.focusNextTab',
3286
3288
  key: RightArrow,
3287
- when: focusId$1
3289
+ when: FocusExtensionDetailTabs
3288
3290
  }, {
3289
3291
  command: 'ExtensionDetail.focusPreviousTab',
3290
3292
  key: LeftArrow,
3291
- when: focusId$1
3293
+ when: FocusExtensionDetailTabs
3292
3294
  }];
3293
3295
  };
3294
3296
 
@@ -4096,7 +4098,7 @@ const formatLastUpdated = lastUpdated => {
4096
4098
  return 'n/a';
4097
4099
  }
4098
4100
  try {
4099
- const date = new Date(lastUpdated);
4101
+ const date = new Date(lastUpdated * 1000);
4100
4102
  if (Number.isNaN(date.getTime())) {
4101
4103
  return 'n/a';
4102
4104
  }
@@ -4581,13 +4583,16 @@ const handleSelectionChange = async (state, selection) => {
4581
4583
  return state;
4582
4584
  };
4583
4585
 
4584
- const focusId = 451;
4585
4586
  const handleTabFocus = (state, name) => {
4586
- const tabIndex = state.tabs.findIndex(tab => tab.name === name);
4587
- const newFocusedTabIndex = tabIndex === -1 ? state.focusedTabIndex : tabIndex;
4587
+ const {
4588
+ focusedTabIndex,
4589
+ tabs
4590
+ } = state;
4591
+ const tabIndex = tabs.findIndex(tab => tab.name === name);
4592
+ const newFocusedTabIndex = tabIndex === -1 ? focusedTabIndex : tabIndex;
4588
4593
  return {
4589
4594
  ...state,
4590
- focus: focusId,
4595
+ focus: FocusExtensionDetailTabs,
4591
4596
  focusedTabIndex: newFocusedTabIndex
4592
4597
  };
4593
4598
  };
@@ -5075,8 +5080,8 @@ const getAdditionalDetailsVirtualDom = (showAdditionalDetails, firstHeading, ent
5075
5080
  if (!showAdditionalDetails) {
5076
5081
  return [];
5077
5082
  }
5078
- const sections = [...getAdditionalDetailsEntryVirtualDom(firstHeading, entries, getMoreInfoVirtualDom), ...(secondEntries.length > 0 ? getAdditionalDetailsEntryVirtualDom(secondHeading, secondEntries, getMoreInfoVirtualDom) : []), ...getAdditionalDetailsEntryVirtualDom(thirdHeading, categories, getCategoriesDom), ...getAdditionalDetailsEntryVirtualDom(fourthHeading, resources, getResourcesVirtualDom)];
5079
- const childCount = secondEntries.length > 0 ? 4 : 3;
5083
+ const sections = [...getAdditionalDetailsEntryVirtualDom(firstHeading, entries, getMoreInfoVirtualDom), ...(secondEntries.length > 0 ? getAdditionalDetailsEntryVirtualDom(secondHeading, secondEntries, getMoreInfoVirtualDom) : []), ...(categories.length > 0 ? getAdditionalDetailsEntryVirtualDom(thirdHeading, categories, getCategoriesDom) : []), ...getAdditionalDetailsEntryVirtualDom(fourthHeading, resources, getResourcesVirtualDom)];
5084
+ const childCount = 1 + (secondEntries.length > 0 ? 1 : 0) + (categories.length > 0 ? 1 : 0) + 1;
5080
5085
  return [{
5081
5086
  childCount: 1,
5082
5087
  className: Aside,
@@ -5407,7 +5412,7 @@ const renderFocusContext = (oldState, newState) => {
5407
5412
  focus,
5408
5413
  uid
5409
5414
  } = newState;
5410
- if (focus === 451) {
5415
+ if (focus === FocusExtensionDetailTabs) {
5411
5416
  return [SetFocusContext, uid, focus];
5412
5417
  }
5413
5418
  // TODO set focus context
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "6.6.0",
3
+ "version": "6.8.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,6 +11,6 @@
11
11
  "type": "module",
12
12
  "main": "dist/extensionDetailViewWorkerMain.js",
13
13
  "dependencies": {
14
- "@lvce-editor/constants": "^2.4.0"
14
+ "@lvce-editor/constants": "^2.7.0"
15
15
  }
16
16
  }