@lvce-editor/extension-management-worker 4.1.0 → 4.3.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.
@@ -1,7 +1,3 @@
1
- const activateByEvent = async () => {
2
- // TODO
3
- };
4
-
5
1
  class AssertionError extends Error {
6
2
  constructor(message) {
7
3
  super(message);
@@ -1216,7 +1212,7 @@ const createMockRpc = ({
1216
1212
  };
1217
1213
 
1218
1214
  const rpcs$2 = Object.create(null);
1219
- const set$7 = (id, rpc) => {
1215
+ const set$8 = (id, rpc) => {
1220
1216
  rpcs$2[id] = rpc;
1221
1217
  };
1222
1218
  const get$4 = id => {
@@ -1249,7 +1245,7 @@ const create$1 = rpcId => {
1249
1245
  const mockRpc = createMockRpc({
1250
1246
  commandMap
1251
1247
  });
1252
- set$7(rpcId, mockRpc);
1248
+ set$8(rpcId, mockRpc);
1253
1249
  // @ts-ignore
1254
1250
  mockRpc[Symbol.dispose] = () => {
1255
1251
  remove(rpcId);
@@ -1258,7 +1254,7 @@ const create$1 = rpcId => {
1258
1254
  return mockRpc;
1259
1255
  },
1260
1256
  set(rpc) {
1261
- set$7(rpcId, rpc);
1257
+ set$8(rpcId, rpc);
1262
1258
  }
1263
1259
  };
1264
1260
  };
@@ -1275,25 +1271,25 @@ const SharedProcess = 1492;
1275
1271
 
1276
1272
  const {
1277
1273
  dispose,
1278
- invoke: invoke$4,
1274
+ invoke: invoke$5,
1279
1275
  invokeAndTransfer: invokeAndTransfer$2,
1280
1276
  registerMockRpc,
1281
- set: set$6
1277
+ set: set$7
1282
1278
  } = create$1(ExtensionHostWorker);
1283
1279
  const executeReferenceProvider = async (id, offset) => {
1284
1280
  // @ts-ignore
1285
- return invoke$4('ExtensionHostReference.executeReferenceProvider', id, offset);
1281
+ return invoke$5('ExtensionHostReference.executeReferenceProvider', id, offset);
1286
1282
  };
1287
1283
  const executeFileReferenceProvider = async id => {
1288
1284
  // @ts-ignore
1289
- return invoke$4('ExtensionHostReference.executeFileReferenceProvider', id);
1285
+ return invoke$5('ExtensionHostReference.executeFileReferenceProvider', id);
1290
1286
  };
1291
1287
  const getRuntimeStatus$2 = async extensionId => {
1292
1288
  // @ts-ignore
1293
- return invoke$4('ExtensionHost.getRuntimeStatus', extensionId);
1289
+ return invoke$5('ExtensionHost.getRuntimeStatus', extensionId);
1294
1290
  };
1295
1291
  const getEnabledOutputProviderIds = async () => {
1296
- const channels = await invoke$4('Output.getEnabledProviders');
1292
+ const channels = await invoke$5('Output.getEnabledProviders');
1297
1293
  return channels;
1298
1294
  };
1299
1295
 
@@ -1304,30 +1300,30 @@ const ExtensionHost = {
1304
1300
  executeReferenceProvider,
1305
1301
  getEnabledOutputProviderIds,
1306
1302
  getRuntimeStatus: getRuntimeStatus$2,
1307
- invoke: invoke$4,
1303
+ invoke: invoke$5,
1308
1304
  invokeAndTransfer: invokeAndTransfer$2,
1309
1305
  registerMockRpc,
1310
- set: set$6
1306
+ set: set$7
1311
1307
  };
1312
1308
 
1313
1309
  const {
1314
- invoke: invoke$3,
1315
- set: set$5
1310
+ invoke: invoke$4,
1311
+ set: set$6
1316
1312
  } = create$1(FileSystemWorker);
1317
1313
  const readFile = async uri => {
1318
- return invoke$3('FileSystem.readFile', uri);
1314
+ return invoke$4('FileSystem.readFile', uri);
1319
1315
  };
1320
1316
  const writeFile = async (uri, content) => {
1321
- return invoke$3('FileSystem.writeFile', uri, content);
1317
+ return invoke$4('FileSystem.writeFile', uri, content);
1322
1318
  };
1323
1319
  const exists = async uri => {
1324
- return invoke$3('FileSystem.exists', uri);
1320
+ return invoke$4('FileSystem.exists', uri);
1325
1321
  };
1326
1322
 
1327
1323
  const {
1328
- invoke: invoke$2,
1324
+ invoke: invoke$3,
1329
1325
  invokeAndTransfer: invokeAndTransfer$1,
1330
- set: set$4
1326
+ set: set$5
1331
1327
  } = create$1(RendererWorker);
1332
1328
  const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1333
1329
  const command = 'IconTheme.handleMessagePort';
@@ -1347,8 +1343,8 @@ const sendMessagePortToSharedProcess = async port => {
1347
1343
  };
1348
1344
 
1349
1345
  const {
1350
- invoke: invoke$1,
1351
- set: set$3
1346
+ invoke: invoke$2,
1347
+ set: set$4
1352
1348
  } = create$1(SharedProcess);
1353
1349
 
1354
1350
  const create = () => {
@@ -1399,11 +1395,11 @@ let extensionsState = createInitialState();
1399
1395
  const get$3 = () => {
1400
1396
  return extensionsState;
1401
1397
  };
1402
- const set$2 = newState => {
1398
+ const set$3 = newState => {
1403
1399
  extensionsState = newState;
1404
1400
  };
1405
1401
  const update = newState => {
1406
- set$2({
1402
+ set$3({
1407
1403
  ...extensionsState,
1408
1404
  ...newState
1409
1405
  });
@@ -1452,7 +1448,7 @@ const baseName = path => {
1452
1448
  const slashIndex = path.lastIndexOf('/');
1453
1449
  return path.slice(slashIndex + 1);
1454
1450
  };
1455
- const getExtensionId = extension => {
1451
+ const getExtensionId$4 = extension => {
1456
1452
  if (extension && extension.id) {
1457
1453
  return extension.id;
1458
1454
  }
@@ -1540,7 +1536,7 @@ const activateExtension2 = async (extensionId, extension, absolutePath, extensio
1540
1536
  status: Activated
1541
1537
  });
1542
1538
  } catch (error) {
1543
- const id = getExtensionId(extension);
1539
+ const id = getExtensionId$4(extension);
1544
1540
  if (isImportError(error)) {
1545
1541
  const actualErrorMessage = await tryToGetActualImportErrorMessage(absolutePath, error);
1546
1542
  throw new Error(`Failed to activate extension ${id}: ${actualErrorMessage}`, {
@@ -1565,30 +1561,34 @@ const get$2 = extensionId => {
1565
1561
  const getAll = () => {
1566
1562
  return Object.values(rpcs$1);
1567
1563
  };
1568
- const set$1 = (extensionId, rpc) => {
1564
+ const set$2 = (extensionId, rpc) => {
1569
1565
  rpcs$1[extensionId] = rpc;
1570
1566
  };
1571
1567
 
1572
1568
  /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
1573
- const invoke = (method, ...params) => {
1574
- return invoke$2(method, ...params);
1569
+ const invoke$1 = (method, ...params) => {
1570
+ return invoke$3(method, ...params);
1575
1571
  };
1576
1572
  const invokeAndTransfer = (method, ...params) => {
1577
1573
  return invokeAndTransfer$1(method, ...params);
1578
1574
  };
1579
1575
 
1580
- const getOrCreateIsolatedExtensionHostWorker = async extensionId => {
1581
- const existingRpc = get$2(extensionId);
1582
- if (existingRpc) {
1583
- return existingRpc;
1584
- }
1585
- const rpc = await create$7({
1576
+ const createIsolatedExtensionHostWorker = async (extensionId, absolutePath, createRpc, invokeAndTransfer) => {
1577
+ return createRpc({
1586
1578
  commandMap: commandMapRef,
1579
+ isMessagePortOpen: true,
1587
1580
  send(port) {
1588
- return invokeAndTransfer('LaunchIsolatedExtensionHostWorker.launchIsolatedExtensionHostWorker', port, extensionId);
1581
+ return invokeAndTransfer('LaunchIsolatedExtensionHostWorker.launchIsolatedExtensionHostWorker', port, extensionId, absolutePath);
1589
1582
  }
1590
1583
  });
1591
- set$1(extensionId, rpc);
1584
+ };
1585
+ const getOrCreateIsolatedExtensionHostWorker = async (extensionId, absolutePath) => {
1586
+ const existingRpc = get$2(extensionId);
1587
+ if (existingRpc) {
1588
+ return existingRpc;
1589
+ }
1590
+ const rpc = await createIsolatedExtensionHostWorker(extensionId, absolutePath, create$7, invokeAndTransfer);
1591
+ set$2(extensionId, rpc);
1592
1592
  return rpc;
1593
1593
  };
1594
1594
 
@@ -1690,9 +1690,38 @@ const isExtensionIsolated = extension => {
1690
1690
  const activateExtension3 = async (extension, absolutePath, activationEvent, platform) => {
1691
1691
  handleRpcInfos(extension, platform);
1692
1692
  const extensionId = extension.id || interExtensionId(extension.uri);
1693
- const extensionHost = isExtensionIsolated(extension) ? await getOrCreateIsolatedExtensionHostWorker(extensionId) : undefined;
1694
- await importExtension(extensionId, absolutePath, activationEvent, extensionHost);
1695
- await activateExtension2(extensionId, extension, absolutePath, extensionHost);
1693
+ if (isExtensionIsolated(extension)) {
1694
+ await getOrCreateIsolatedExtensionHostWorker(extensionId, absolutePath);
1695
+ return;
1696
+ }
1697
+ await importExtension(extensionId, absolutePath, activationEvent);
1698
+ await activateExtension2(extensionId, extension, absolutePath);
1699
+ };
1700
+
1701
+ const getExtensionAbsolutePath = (id, isWeb, isBuiltin, path, relativePath, origin, platform, assetDir) => {
1702
+ if (path.startsWith('http')) {
1703
+ if (path.endsWith('/')) {
1704
+ return new URL(relativePath, path).toString();
1705
+ }
1706
+ return new URL(relativePath, path + '/').toString();
1707
+ }
1708
+ if (!path.startsWith('/')) {
1709
+ path = '/' + path;
1710
+ }
1711
+ if (isWeb) {
1712
+ return path + '/' + relativePath;
1713
+ }
1714
+ if (platform === Web) {
1715
+ return path + '/' + relativePath;
1716
+ }
1717
+ if (isBuiltin) {
1718
+ return `${assetDir}/extensions/${id}/${relativePath}`;
1719
+ }
1720
+ return new URL('/remote' + path + '/' + relativePath, origin).toString();
1721
+ };
1722
+
1723
+ const getDynamicWebExtensions = () => {
1724
+ return get$3().webExtensions;
1696
1725
  };
1697
1726
 
1698
1727
  const getJson$1 = async url => {
@@ -1708,6 +1737,74 @@ const getJson$1 = async url => {
1708
1737
  }
1709
1738
  };
1710
1739
 
1740
+ const getWebExtensionsUrl = assetDir => {
1741
+ return `${assetDir}/config/extensions.json`;
1742
+ };
1743
+
1744
+ const getWebExtensions = async assetDir => {
1745
+ try {
1746
+ return await getJson$1(getWebExtensionsUrl(assetDir));
1747
+ } catch {
1748
+ return [];
1749
+ }
1750
+ };
1751
+
1752
+ const getAllExtensions = async (assetDir, platform) => {
1753
+ if (typeof assetDir !== 'string') {
1754
+ assetDir = await invoke$3('Layout.getAssetDir');
1755
+ }
1756
+ if (!platform) {
1757
+ platform = await invoke$3('Layout.getPlatform');
1758
+ }
1759
+ string(assetDir);
1760
+ number(platform);
1761
+ const meta = getDynamicWebExtensions();
1762
+ if (platform === Web) {
1763
+ const webExtensions = await getWebExtensions(assetDir);
1764
+ return [...webExtensions, ...meta];
1765
+ }
1766
+ const local = await invoke$2('ExtensionManagement.getAllExtensions');
1767
+ return [...local, ...meta];
1768
+ };
1769
+
1770
+ const activatingExtensions = Object.create(null);
1771
+ const runningExtensions = Object.create(null);
1772
+ const matchesEvent = (extension, event) => {
1773
+ return isExtensionIsolated(extension) && Array.isArray(extension.activation) && extension.activation.includes(event);
1774
+ };
1775
+ const getExtensionId$3 = extension => {
1776
+ return extension.id;
1777
+ };
1778
+ const getAbsolutePath$2 = (extension, assetDir, platform) => {
1779
+ return getExtensionAbsolutePath(extension.id, extension.isWeb, extension.builtin, extension.uri || extension.path, extension.browser, globalThis.location.origin, platform, assetDir);
1780
+ };
1781
+ const activateExtension = async (extension, event, assetDir, platform) => {
1782
+ const extensionId = getExtensionId$3(extension);
1783
+ if (runningExtensions[extensionId]) {
1784
+ return;
1785
+ }
1786
+ if (!Object.hasOwn(activatingExtensions, extensionId)) {
1787
+ const absolutePath = getAbsolutePath$2(extension, assetDir, platform);
1788
+ activatingExtensions[extensionId] = activateExtension3(extension, absolutePath, event, platform).then(() => {
1789
+ runningExtensions[extensionId] = true;
1790
+ }).finally(() => {
1791
+ delete activatingExtensions[extensionId];
1792
+ });
1793
+ }
1794
+ await activatingExtensions[extensionId];
1795
+ };
1796
+ const activateByEvent = async (event, assetDir, platform) => {
1797
+ if (event === 'none') {
1798
+ await Promise.all(Object.values(activatingExtensions));
1799
+ return;
1800
+ }
1801
+ const extensions = await getAllExtensions(assetDir, platform);
1802
+ const matchingExtensions = extensions.filter(extension => matchesEvent(extension, event));
1803
+ for (const extension of matchingExtensions) {
1804
+ await activateExtension(extension, event, assetDir, platform);
1805
+ }
1806
+ };
1807
+
1711
1808
  const getWebExtensionManifest = async (path, manifestPath) => {
1712
1809
  try {
1713
1810
  const manifest = await getJson$1(manifestPath);
@@ -1727,6 +1824,24 @@ const getWebManifestPath = path => {
1727
1824
  return manifestPath;
1728
1825
  };
1729
1826
 
1827
+ let rpc;
1828
+ const set$1 = value => {
1829
+ rpc = value;
1830
+ };
1831
+ const invoke = async (method, ...params) => {
1832
+ if (!rpc) {
1833
+ return undefined;
1834
+ }
1835
+ return rpc.invoke(method, ...params);
1836
+ };
1837
+
1838
+ const handleChange = async id => {
1839
+ await invoke('StatusBar.handleChange', id);
1840
+ };
1841
+
1842
+ const hasStatusBarItems = manifest => {
1843
+ return Array.isArray(manifest.statusBarItems) && manifest.statusBarItems.length > 0;
1844
+ };
1730
1845
  const addWebExtension = async path => {
1731
1846
  if (hasWebExtensionUri(path)) {
1732
1847
  return undefined;
@@ -1735,6 +1850,9 @@ const addWebExtension = async path => {
1735
1850
  const manifest = await getWebExtensionManifest(path, manifestPath);
1736
1851
  addWebExtension$1(manifest);
1737
1852
  clearCachedExtensions();
1853
+ if (hasStatusBarItems(manifest)) {
1854
+ await handleChange(manifest.id || path);
1855
+ }
1738
1856
  return manifest;
1739
1857
  };
1740
1858
 
@@ -1835,7 +1953,7 @@ const disableExtension2$1 = async (id, platform) => {
1835
1953
  ...oldState,
1836
1954
  disabledIds: [...oldState.disabledIds, id]
1837
1955
  };
1838
- set$2(newState);
1956
+ set$3(newState);
1839
1957
  } else if (isWeb) {
1840
1958
  const cached = await getJson(disabledExtensionsCacheKey);
1841
1959
  const oldDisabled = cached?.disabledExtensions || [];
@@ -1845,7 +1963,7 @@ const disableExtension2$1 = async (id, platform) => {
1845
1963
  };
1846
1964
  await setJson(disabledExtensionsCacheKey, newData);
1847
1965
  } else {
1848
- await invoke$1('ExtensionManagement.disable', id);
1966
+ await invoke$2('ExtensionManagement.disable', id);
1849
1967
  }
1850
1968
  };
1851
1969
  const enableExtension2$1 = async (id, platform) => {
@@ -1857,7 +1975,7 @@ const enableExtension2$1 = async (id, platform) => {
1857
1975
  ...oldState,
1858
1976
  disabledIds: oldState.disabledIds.filter(existing => existing !== id)
1859
1977
  };
1860
- set$2(newState);
1978
+ set$3(newState);
1861
1979
  } else if (isWeb) {
1862
1980
  const cached = await getJson(disabledExtensionsCacheKey);
1863
1981
  const oldDisabled = cached?.disabledExtensions || [];
@@ -1870,7 +1988,7 @@ const enableExtension2$1 = async (id, platform) => {
1870
1988
  };
1871
1989
 
1872
1990
  const invalidateExtensionsCache = async () => {
1873
- await invoke$2('ExtensionManagement.invalidateExtensionsCache');
1991
+ await invoke$3('ExtensionManagement.invalidateExtensionsCache');
1874
1992
  };
1875
1993
 
1876
1994
  const disableExtension2 = async (id, platform) => {
@@ -1894,7 +2012,7 @@ const enableExtension2 = async (id, platform) => {
1894
2012
  string(id);
1895
2013
  number(platform);
1896
2014
  if (platform === Remote || platform === Electron) {
1897
- const disabledExtensionsJsonPath = await invoke$2('WebView.compatSharedProcessInvoke', 'PlatformPaths.getDisabledExtensionsJsonUri');
2015
+ const disabledExtensionsJsonPath = await invoke$3('WebView.compatSharedProcessInvoke', 'PlatformPaths.getDisabledExtensionsJsonUri');
1898
2016
  const exists$1 = await exists(disabledExtensionsJsonPath);
1899
2017
  if (!exists$1) {
1900
2018
  return undefined;
@@ -1917,6 +2035,134 @@ const enableExtension = async (id, isTest) => {
1917
2035
  return enableExtension2(id, oldState.platform);
1918
2036
  };
1919
2037
 
2038
+ const getExtensionId$2 = extension => {
2039
+ return extension.id || interExtensionId(extension.uri || extension.path || '');
2040
+ };
2041
+ const contributesCommand = (extension, id) => {
2042
+ return Array.isArray(extension.commands) && extension.commands.some(command => command.id === id);
2043
+ };
2044
+ const getContributingExtension = async (id, platform) => {
2045
+ const extensions = await getAllExtensions('', platform);
2046
+ return extensions.find(extension => isExtensionIsolated(extension) && contributesCommand(extension, id));
2047
+ };
2048
+ const getRpcForCommand = async (id, platform) => {
2049
+ const extension = await getContributingExtension(id, platform);
2050
+ if (!extension) {
2051
+ return undefined;
2052
+ }
2053
+ const extensionId = getExtensionId$2(extension);
2054
+ const existingRpc = get$2(extensionId);
2055
+ if (existingRpc) {
2056
+ return existingRpc;
2057
+ }
2058
+ await activateByEvent(`onCommand:${id}`, '', platform);
2059
+ return get$2(extensionId);
2060
+ };
2061
+ const executeRendererCommand = (id, args) => {
2062
+ return invoke$3(id, ...args);
2063
+ };
2064
+ const executeCommand = async (id, ...args) => {
2065
+ const {
2066
+ platform
2067
+ } = get$3();
2068
+ const rpc = await getRpcForCommand(id, platform);
2069
+ if (rpc) {
2070
+ return rpc.invoke('ExtensionApi.executeCommand', id, ...args);
2071
+ }
2072
+ return executeRendererCommand(id, args);
2073
+ };
2074
+
2075
+ const getExtensionId$1 = extension => {
2076
+ return extension.id || interExtensionId(extension.uri || extension.path || '');
2077
+ };
2078
+ const contributesCompletionProvider = (extension, languageId) => {
2079
+ return Array.isArray(extension.completionProviders) && extension.completionProviders.some(provider => provider.languageId === languageId);
2080
+ };
2081
+ const getOrigin$1 = () => {
2082
+ return globalThis.location?.origin || 'http://localhost';
2083
+ };
2084
+ const getAbsolutePath$1 = (extension, assetDir, platform) => {
2085
+ return getExtensionAbsolutePath(getExtensionId$1(extension), extension.isWeb === true, extension.builtin === true, extension.uri || extension.path || '', extension.browser || '', getOrigin$1(), platform, assetDir);
2086
+ };
2087
+ const getMatchingExtensions$1 = async (textDocument, assetDir, platform) => {
2088
+ const extensions = await getAllExtensions(assetDir, platform);
2089
+ return extensions.filter(extension => isExtensionIsolated(extension) && contributesCompletionProvider(extension, textDocument.languageId));
2090
+ };
2091
+ const getRpc$2 = async (extension, assetDir, platform) => {
2092
+ const extensionId = getExtensionId$1(extension);
2093
+ const existingRpc = get$2(extensionId);
2094
+ if (existingRpc) {
2095
+ return existingRpc;
2096
+ }
2097
+ const absolutePath = getAbsolutePath$1(extension, assetDir, platform);
2098
+ return getOrCreateIsolatedExtensionHostWorker(extensionId, absolutePath);
2099
+ };
2100
+ const executeRpcCompletionProvider = async (rpc, textDocument, args) => {
2101
+ return rpc.invoke('ExtensionApi.executeCompletionProvider', textDocument, ...args);
2102
+ };
2103
+ const executeRpcResolveCompletionItemProvider = async (rpc, textDocument, args) => {
2104
+ return rpc.invoke('ExtensionApi.executeResolveCompletionItemProvider', textDocument, ...args);
2105
+ };
2106
+ const executeCompletionProvider = async (textDocument, ...args) => {
2107
+ const {
2108
+ platform
2109
+ } = get$3();
2110
+ const assetDir = '';
2111
+ const extensions = await getMatchingExtensions$1(textDocument, assetDir, platform);
2112
+ const rpcs = await Promise.all(extensions.map(extension => getRpc$2(extension, assetDir, platform)));
2113
+ const results = await Promise.all(rpcs.map(rpc => executeRpcCompletionProvider(rpc, textDocument, args)));
2114
+ return results[0] || [];
2115
+ };
2116
+ const executeResolveCompletionItemProvider = async (textDocument, ...args) => {
2117
+ const {
2118
+ platform
2119
+ } = get$3();
2120
+ const assetDir = '';
2121
+ const extensions = await getMatchingExtensions$1(textDocument, assetDir, platform);
2122
+ const rpcs = await Promise.all(extensions.map(extension => getRpc$2(extension, assetDir, platform)));
2123
+ const results = await Promise.all(rpcs.map(rpc => executeRpcResolveCompletionItemProvider(rpc, textDocument, args)));
2124
+ return results[0];
2125
+ };
2126
+
2127
+ const getExtensionId = extension => {
2128
+ return extension.id || interExtensionId(extension.uri || extension.path || '');
2129
+ };
2130
+ const contributesFormattingProvider = (extension, languageId) => {
2131
+ return Array.isArray(extension.formattingProviders) && extension.formattingProviders.some(provider => provider.languageId === languageId);
2132
+ };
2133
+ const getOrigin = () => {
2134
+ return globalThis.location?.origin || 'http://localhost';
2135
+ };
2136
+ const getAbsolutePath = (extension, assetDir, platform) => {
2137
+ return getExtensionAbsolutePath(getExtensionId(extension), extension.isWeb === true, extension.builtin === true, extension.uri || extension.path || '', extension.browser || '', getOrigin(), platform, assetDir);
2138
+ };
2139
+ const getMatchingExtensions = async (textDocument, assetDir, platform) => {
2140
+ const extensions = await getAllExtensions(assetDir, platform);
2141
+ return extensions.filter(extension => isExtensionIsolated(extension) && contributesFormattingProvider(extension, textDocument.languageId));
2142
+ };
2143
+ const getRpc$1 = async (extension, assetDir, platform) => {
2144
+ const extensionId = getExtensionId(extension);
2145
+ const existingRpc = get$2(extensionId);
2146
+ if (existingRpc) {
2147
+ return existingRpc;
2148
+ }
2149
+ const absolutePath = getAbsolutePath(extension, assetDir, platform);
2150
+ return getOrCreateIsolatedExtensionHostWorker(extensionId, absolutePath);
2151
+ };
2152
+ const executeRpcFormattingProvider = async (rpc, textDocument, args) => {
2153
+ return rpc.invoke('ExtensionApi.executeFormattingProvider', textDocument, ...args);
2154
+ };
2155
+ const executeFormattingProvider = async (textDocument, ...args) => {
2156
+ const {
2157
+ platform
2158
+ } = get$3();
2159
+ const assetDir = '';
2160
+ const extensions = await getMatchingExtensions(textDocument, assetDir, platform);
2161
+ const rpcs = await Promise.all(extensions.map(extension => getRpc$1(extension, assetDir, platform)));
2162
+ const results = await Promise.all(rpcs.map(rpc => executeRpcFormattingProvider(rpc, textDocument, args)));
2163
+ return results[0] || [];
2164
+ };
2165
+
1920
2166
  /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
1921
2167
  const warn = (...args) => {
1922
2168
  console.warn(...args);
@@ -2058,7 +2304,7 @@ const getColorThemeCssCached = async (colorThemeId, platform, getData) => {
2058
2304
  };
2059
2305
 
2060
2306
  const readJson = url => {
2061
- return invoke$2('FileSystem.readJson', url);
2307
+ return invoke$3('FileSystem.readJson', url);
2062
2308
  };
2063
2309
 
2064
2310
  const join = (pathSeparator, ...parts) => {
@@ -2081,40 +2327,6 @@ const getColorThemeUri = (extensions, colorThemeId) => {
2081
2327
  return '';
2082
2328
  };
2083
2329
 
2084
- const getDynamicWebExtensions = () => {
2085
- return get$3().webExtensions;
2086
- };
2087
-
2088
- const getWebExtensionsUrl = assetDir => {
2089
- return `${assetDir}/config/extensions.json`;
2090
- };
2091
-
2092
- const getWebExtensions = async assetDir => {
2093
- try {
2094
- return await getJson$1(getWebExtensionsUrl(assetDir));
2095
- } catch {
2096
- return [];
2097
- }
2098
- };
2099
-
2100
- const getAllExtensions = async (assetDir, platform) => {
2101
- if (typeof assetDir !== 'string') {
2102
- assetDir = await invoke$2('Layout.getAssetDir');
2103
- }
2104
- if (!platform) {
2105
- platform = await invoke$2('Layout.getPlatform');
2106
- }
2107
- string(assetDir);
2108
- number(platform);
2109
- const meta = getDynamicWebExtensions();
2110
- if (platform === Web) {
2111
- const webExtensions = await getWebExtensions(assetDir);
2112
- return [...webExtensions, ...meta];
2113
- }
2114
- const local = await invoke$1('ExtensionManagement.getAllExtensions');
2115
- return [...local, ...meta];
2116
- };
2117
-
2118
2330
  const getColorThemeJson$2 = async (colorThemeId, assetDir, platform) => {
2119
2331
  const extensions = await getAllExtensions(assetDir, platform);
2120
2332
  const colorThemeUri = getColorThemeUri(extensions, colorThemeId);
@@ -2238,7 +2450,7 @@ const getRemoteUrlForWebView = async (uri, options = {}) => {
2238
2450
  if (!webView) {
2239
2451
  throw new Error(`webview ${options.webViewId} not found`);
2240
2452
  }
2241
- const [rpc, blob] = await Promise.all([createWebViewIpc(webView), invoke('FileSystem.getBlob', uri)]);
2453
+ const [rpc, blob] = await Promise.all([createWebViewIpc(webView), invoke$1('FileSystem.getBlob', uri)]);
2242
2454
  const objectUrl = await rpc.invoke('createObjectUrl', blob);
2243
2455
  return objectUrl;
2244
2456
  };
@@ -2275,11 +2487,16 @@ const getStatusBarItems = async () => {
2275
2487
  return results.flat();
2276
2488
  };
2277
2489
 
2278
- const handleMessagePort = async port => {
2279
- await create$8({
2490
+ const StatusBarWorker = 200;
2491
+
2492
+ const handleMessagePort = async (port, rpcId) => {
2493
+ const rpc = await create$8({
2280
2494
  commandMap: commandMapRef,
2281
2495
  messagePort: port
2282
2496
  });
2497
+ if (rpcId === StatusBarWorker) {
2498
+ set$1(rpc);
2499
+ }
2283
2500
  };
2284
2501
 
2285
2502
  const getRpcRemote = async () => {
@@ -2311,7 +2528,7 @@ const getRpc = async platform => {
2311
2528
  const initializeSharedProcess = async platform => {
2312
2529
  const rpc = await getRpc(platform);
2313
2530
  if (rpc) {
2314
- set$3(rpc);
2531
+ set$4(rpc);
2315
2532
  }
2316
2533
  };
2317
2534
 
@@ -2392,6 +2609,10 @@ const commandMap = {
2392
2609
  'Extensions.disable2': disableExtension2,
2393
2610
  'Extensions.enable': enableExtension,
2394
2611
  'Extensions.enable2': enableExtension2,
2612
+ 'Extensions.executeCommand': executeCommand,
2613
+ 'Extensions.executeCompletionProvider': executeCompletionProvider,
2614
+ 'Extensions.executeFormattingProvider': executeFormattingProvider,
2615
+ 'Extensions.executeResolveCompletionItemProvider': executeResolveCompletionItemProvider,
2395
2616
  'Extensions.getAllExtensions': getAllExtensions,
2396
2617
  'Extensions.getColorThemeCss': getColorThemeCss,
2397
2618
  'Extensions.getColorThemeCssFromJson': getColorThemeCssFromJson,
@@ -2409,7 +2630,8 @@ const commandMap = {
2409
2630
  'Extensions.initialize': initialize,
2410
2631
  'Extensions.install': installExtension,
2411
2632
  'Extensions.invalidateExtensionsCache': invalidateExtensionsCache,
2412
- 'Extensions.uninstall': uninstallExtension
2633
+ 'Extensions.uninstall': uninstallExtension,
2634
+ 'StatusBar.handleChange': handleChange
2413
2635
  };
2414
2636
 
2415
2637
  const initializeExtensionHostWorker = async () => {
@@ -2419,7 +2641,7 @@ const initializeExtensionHostWorker = async () => {
2419
2641
  await sendMessagePortToExtensionHostWorker(port, 0);
2420
2642
  }
2421
2643
  });
2422
- set$6(rpc);
2644
+ set$7(rpc);
2423
2645
  };
2424
2646
 
2425
2647
  const initializeFileSystemWorker = async () => {
@@ -2429,7 +2651,7 @@ const initializeFileSystemWorker = async () => {
2429
2651
  await sendMessagePortToFileSystemWorker(port, 0);
2430
2652
  }
2431
2653
  });
2432
- set$5(rpc);
2654
+ set$6(rpc);
2433
2655
  };
2434
2656
 
2435
2657
  const initializeIframeWorker = async () => {
@@ -2446,7 +2668,7 @@ const initializeRendererWorker = async () => {
2446
2668
  const rpc = await create$2({
2447
2669
  commandMap: commandMap
2448
2670
  });
2449
- set$4(rpc);
2671
+ set$5(rpc);
2450
2672
  };
2451
2673
 
2452
2674
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-management-worker",
3
- "version": "4.1.0",
3
+ "version": "4.3.0",
4
4
  "description": "Webworker for the Extension Management functionality in Lvce Editor.",
5
5
  "keywords": [
6
6
  "web-worker"