@lvce-editor/extension-management-worker 4.34.0 → 4.36.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.
@@ -1748,26 +1748,26 @@ const bindCommandMap = (rpc, commandMap) => {
1748
1748
  }
1749
1749
  return rpc;
1750
1750
  };
1751
- const createIsolatedExtensionHostWorker = async (extensionId, absolutePath, workerName, createRpc, invokeAndTransfer) => {
1751
+ const createIsolatedExtensionHostWorker = async (extensionId, absolutePath, workerName, contentSecurityPolicy, createRpc, invokeAndTransfer) => {
1752
1752
  const commandMap = createExtensionCommandMap(extensionId);
1753
1753
  const rpc = await createRpc({
1754
1754
  commandMap,
1755
1755
  isMessagePortOpen: true,
1756
1756
  send(port) {
1757
- return invokeAndTransfer('LaunchIsolatedExtensionHostWorker.launchIsolatedExtensionHostWorker', port, extensionId, absolutePath, workerName);
1757
+ return invokeAndTransfer('LaunchIsolatedExtensionHostWorker.launchIsolatedExtensionHostWorker', port, extensionId, absolutePath, workerName, contentSecurityPolicy);
1758
1758
  }
1759
1759
  });
1760
1760
  return bindCommandMap(rpc, commandMap);
1761
1761
  };
1762
- const createWorker = (extensionId, absolutePath, workerName) => {
1763
- return createIsolatedExtensionHostWorker(extensionId, absolutePath, workerName, create$7, invokeAndTransfer);
1762
+ const createWorker = (extensionId, absolutePath, workerName, contentSecurityPolicy) => {
1763
+ return createIsolatedExtensionHostWorker(extensionId, absolutePath, workerName, contentSecurityPolicy, create$7, invokeAndTransfer);
1764
1764
  };
1765
- const createAndStoreRpc = async (extensionId, absolutePath, workerName, create) => {
1766
- const rpc = await create(extensionId, absolutePath, workerName);
1765
+ const createAndStoreRpc = async (extensionId, absolutePath, workerName, contentSecurityPolicy, create) => {
1766
+ const rpc = await create(extensionId, absolutePath, workerName, contentSecurityPolicy);
1767
1767
  set$2(extensionId, rpc);
1768
1768
  return rpc;
1769
1769
  };
1770
- const getOrCreateIsolatedExtensionHostWorker = async (extensionId, absolutePath, workerName = '', create = createWorker) => {
1770
+ const getOrCreateIsolatedExtensionHostWorker = async (extensionId, absolutePath, workerName = '', contentSecurityPolicy = '', create = createWorker) => {
1771
1771
  const existingRpc = get$3(extensionId);
1772
1772
  if (existingRpc) {
1773
1773
  return existingRpc;
@@ -1776,7 +1776,7 @@ const getOrCreateIsolatedExtensionHostWorker = async (extensionId, absolutePath,
1776
1776
  if (pendingRpc !== undefined) {
1777
1777
  return pendingRpc;
1778
1778
  }
1779
- const newRpc = createAndStoreRpc(extensionId, absolutePath, workerName, create);
1779
+ const newRpc = createAndStoreRpc(extensionId, absolutePath, workerName, contentSecurityPolicy, create);
1780
1780
  pendingRpcs[extensionId] = newRpc;
1781
1781
  try {
1782
1782
  return await newRpc;
@@ -1785,7 +1785,7 @@ const getOrCreateIsolatedExtensionHostWorker = async (extensionId, absolutePath,
1785
1785
  }
1786
1786
  };
1787
1787
 
1788
- const activateIsolatedExtension = async (extensionId, absolutePath, workerName, activationEvent, getOrCreate = getOrCreateIsolatedExtensionHostWorker) => {
1788
+ const activateIsolatedExtension = async (extensionId, absolutePath, workerName, contentSecurityPolicy, activationEvent, getOrCreate = getOrCreateIsolatedExtensionHostWorker) => {
1789
1789
  const startTime = performance.now();
1790
1790
  updateRuntimeStatus(extensionId, {
1791
1791
  activationEvent,
@@ -1793,7 +1793,7 @@ const activateIsolatedExtension = async (extensionId, absolutePath, workerName,
1793
1793
  status: Activating
1794
1794
  });
1795
1795
  try {
1796
- await getOrCreate(extensionId, absolutePath, workerName);
1796
+ await getOrCreate(extensionId, absolutePath, workerName, contentSecurityPolicy);
1797
1797
  const endTime = performance.now();
1798
1798
  updateRuntimeStatus(extensionId, {
1799
1799
  activationEndTime: endTime,
@@ -1808,6 +1808,16 @@ const activateIsolatedExtension = async (extensionId, absolutePath, workerName,
1808
1808
  }
1809
1809
  };
1810
1810
 
1811
+ const addSemicolon = directive => {
1812
+ return directive.endsWith(';') ? directive : `${directive};`;
1813
+ };
1814
+ const getContentSecurityPolicy = directives => {
1815
+ if (!directives) {
1816
+ return '';
1817
+ }
1818
+ return directives.map(addSemicolon).join(' ');
1819
+ };
1820
+
1811
1821
  const rpcs = Object.create(null);
1812
1822
  const add = (id, rpc) => {
1813
1823
  rpcs[id] = rpc;
@@ -1918,7 +1928,8 @@ const activateExtension3 = async (extension, absolutePath, activationEvent, plat
1918
1928
  handleRpcInfos(extension, platform);
1919
1929
  const extensionId = extension.id || interExtensionId(extension.uri);
1920
1930
  if (isExtensionIsolated(extension)) {
1921
- await activateIsolatedExtension(extensionId, absolutePath, extension.workerName || '', activationEvent);
1931
+ const contentSecurityPolicy = getContentSecurityPolicy(extension.contentSecurityPolicy);
1932
+ await activateIsolatedExtension(extensionId, absolutePath, extension.workerName || '', contentSecurityPolicy, activationEvent);
1922
1933
  return;
1923
1934
  }
1924
1935
  await importExtension(extensionId, absolutePath, activationEvent);
@@ -2666,7 +2677,8 @@ const getRpc$1 = async (extension, assetDir, platform) => {
2666
2677
  }
2667
2678
  handleRpcInfos(extension, platform);
2668
2679
  const absolutePath = getAbsolutePath(extension, assetDir, platform);
2669
- return getOrCreateIsolatedExtensionHostWorker(extensionId, absolutePath, extension.workerName || '');
2680
+ const contentSecurityPolicy = getContentSecurityPolicy(extension.contentSecurityPolicy);
2681
+ return getOrCreateIsolatedExtensionHostWorker(extensionId, absolutePath, extension.workerName || '', contentSecurityPolicy);
2670
2682
  };
2671
2683
 
2672
2684
  /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
@@ -3058,6 +3070,13 @@ const getViewActions = async (viewId, uid, assetDir, platform) => {
3058
3070
  }
3059
3071
  return instance.rpc.invoke('ExtensionApi.getViewActions', uid);
3060
3072
  };
3073
+ const getViewActionsDom = async (viewId, uid, assetDir, platform) => {
3074
+ const instance = get$1(uid);
3075
+ if (!instance || instance.status === 'error') {
3076
+ return undefined;
3077
+ }
3078
+ return instance.rpc.invoke('ExtensionApi.getViewActionsDom', uid);
3079
+ };
3061
3080
  const requestViewRerender = async uid => {
3062
3081
  await invoke$2('Viewlet.executeViewletCommand', uid, 'rerender');
3063
3082
  };
@@ -3807,6 +3826,7 @@ const commandMap = {
3807
3826
  'Extensions.getRuntimeStatus': getRuntimeStatus,
3808
3827
  'Extensions.getStatusBarItems': getStatusBarItems,
3809
3828
  'Extensions.getViewActions': getViewActions,
3829
+ 'Extensions.getViewActionsDom': getViewActionsDom,
3810
3830
  'Extensions.getViewMenuEntries': getViewMenuEntries,
3811
3831
  'Extensions.getViews': getViews,
3812
3832
  'Extensions.handleData': handleData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-management-worker",
3
- "version": "4.34.0",
3
+ "version": "4.36.0",
4
4
  "description": "Webworker for the Extension Management functionality in Lvce Editor.",
5
5
  "keywords": [
6
6
  "web-worker"