@lvce-editor/extension-management-worker 4.31.3 → 4.31.4

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.
@@ -581,12 +581,12 @@ const IpcParentWithWebSocket$1 = {
581
581
  wrap
582
582
  };
583
583
 
584
- class CommandNotFoundError extends Error {
584
+ let CommandNotFoundError$1 = class CommandNotFoundError extends Error {
585
585
  constructor(command) {
586
586
  super(`Command not found ${command}`);
587
587
  this.name = 'CommandNotFoundError';
588
588
  }
589
- }
589
+ };
590
590
  const commands = Object.create(null);
591
591
  const register = commandMap => {
592
592
  Object.assign(commands, commandMap);
@@ -597,7 +597,7 @@ const getCommand = key => {
597
597
  const execute = (command, ...args) => {
598
598
  const fn = getCommand(command);
599
599
  if (!fn) {
600
- throw new CommandNotFoundError(command);
600
+ throw new CommandNotFoundError$1(command);
601
601
  }
602
602
  return fn(...args);
603
603
  };
@@ -1642,6 +1642,14 @@ const getNodeRpcInfo = async (extensionId, rpcId) => {
1642
1642
  };
1643
1643
  };
1644
1644
 
1645
+ class CommandNotFoundError extends Error {
1646
+ constructor(command) {
1647
+ super(`Command not found ${command}`);
1648
+ Object.defineProperty(this, 'name', {
1649
+ value: 'CommandNotFoundError'
1650
+ });
1651
+ }
1652
+ }
1645
1653
  const createExtensionCommandMap = extensionId => {
1646
1654
  return {
1647
1655
  ...commandMapRef,
@@ -1650,6 +1658,15 @@ const createExtensionCommandMap = extensionId => {
1650
1658
  }
1651
1659
  };
1652
1660
  };
1661
+ const createExtensionCommandExecutor = commandMap => {
1662
+ return (method, ...params) => {
1663
+ const command = commandMap[method];
1664
+ if (!command) {
1665
+ throw new CommandNotFoundError(method);
1666
+ }
1667
+ return command(...params);
1668
+ };
1669
+ };
1653
1670
 
1654
1671
  const rpcs$1 = Object.create(null);
1655
1672
  const get$3 = extensionId => {
@@ -1670,15 +1687,25 @@ const invokeAndTransfer = (method, ...params) => {
1670
1687
  return invokeAndTransfer$1(method, ...params);
1671
1688
  };
1672
1689
 
1690
+ /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
1691
+
1673
1692
  const pendingRpcs = Object.create(null);
1693
+ const bindCommandMap = (rpc, commandMap) => {
1694
+ if (rpc.ipc) {
1695
+ rpc.ipc.execute = createExtensionCommandExecutor(commandMap);
1696
+ }
1697
+ return rpc;
1698
+ };
1674
1699
  const createIsolatedExtensionHostWorker = async (extensionId, absolutePath, workerName, createRpc, invokeAndTransfer) => {
1675
- return createRpc({
1676
- commandMap: createExtensionCommandMap(extensionId),
1700
+ const commandMap = createExtensionCommandMap(extensionId);
1701
+ const rpc = await createRpc({
1702
+ commandMap,
1677
1703
  isMessagePortOpen: true,
1678
1704
  send(port) {
1679
1705
  return invokeAndTransfer('LaunchIsolatedExtensionHostWorker.launchIsolatedExtensionHostWorker', port, extensionId, absolutePath, workerName);
1680
1706
  }
1681
1707
  });
1708
+ return bindCommandMap(rpc, commandMap);
1682
1709
  };
1683
1710
  const createWorker = (extensionId, absolutePath, workerName) => {
1684
1711
  return createIsolatedExtensionHostWorker(extensionId, absolutePath, workerName, create$7, invokeAndTransfer);
@@ -2585,6 +2612,7 @@ const getRpc$1 = async (extension, assetDir, platform) => {
2585
2612
  if (existingRpc) {
2586
2613
  return existingRpc;
2587
2614
  }
2615
+ handleRpcInfos(extension, platform);
2588
2616
  const absolutePath = getAbsolutePath(extension, assetDir, platform);
2589
2617
  return getOrCreateIsolatedExtensionHostWorker(extensionId, absolutePath, extension.workerName || '');
2590
2618
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-management-worker",
3
- "version": "4.31.3",
3
+ "version": "4.31.4",
4
4
  "description": "Webworker for the Extension Management functionality in Lvce Editor.",
5
5
  "keywords": [
6
6
  "web-worker"