@lvce-editor/api 8.79.0 → 8.80.1

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.
@@ -7,6 +7,8 @@ export interface CreateRpcOptions {
7
7
  }
8
8
  export interface CreateNodeRpcOptions {
9
9
  readonly id: string;
10
+ readonly legacyName?: string;
11
+ readonly legacyPath?: string;
10
12
  }
11
13
  export declare const createRpc: ({ commandMap, contentSecurityPolicy, name, url }: CreateRpcOptions) => Promise<Rpc>;
12
- export declare const createNodeRpc: ({ id }: CreateNodeRpcOptions) => Promise<Rpc>;
14
+ export declare const createNodeRpc: (options: CreateNodeRpcOptions) => Promise<Rpc>;
@@ -20,7 +20,7 @@ export const createRpc = async ({ commandMap = {}, contentSecurityPolicy = '', n
20
20
  const isMissingCommand = (error, command) => {
21
21
  return error instanceof Error && error.message.includes(command) && /command not found|not found/i.test(error.message);
22
22
  };
23
- const getNodeRpcConnection = async (id) => {
23
+ const getNodeRpcConnection = async ({ id, legacyName = '', legacyPath }) => {
24
24
  if (!id) {
25
25
  throw new TypeError('createNodeRpc requires an id');
26
26
  }
@@ -32,6 +32,9 @@ const getNodeRpcConnection = async (id) => {
32
32
  if (!isMissingCommand(error, 'Extensions.createNodeRpcConnection')) {
33
33
  throw error;
34
34
  }
35
+ if (legacyPath) {
36
+ return { name: legacyName, path: legacyPath, type: 'old-legacy-proxy' };
37
+ }
35
38
  const { name, path } = (await ExtensionManagementWorker.invoke('Extensions.getNodeRpcInfo', id));
36
39
  return { name, path, type: 'old-legacy-proxy' };
37
40
  }
@@ -54,8 +57,9 @@ const createOldLegacyProxyRpc = async (name, path) => {
54
57
  const rpcId = await ExtensionManagementWorker.invoke('Extensions.executeCommand', 'ExtensionNodeRpc.create', name, path);
55
58
  return createProxyRpc((method, ...params) => ExtensionManagementWorker.invoke('Extensions.executeCommand', 'ExtensionNodeRpc.invoke', rpcId, method, ...params), () => ExtensionManagementWorker.invoke('Extensions.executeCommand', 'ExtensionNodeRpc.dispose', rpcId));
56
59
  };
57
- export const createNodeRpc = async ({ id }) => {
58
- const connectionInfo = await getNodeRpcConnection(id);
60
+ export const createNodeRpc = async (options) => {
61
+ const { id } = options;
62
+ const connectionInfo = await getNodeRpcConnection(options);
59
63
  if (connectionInfo.type === 'message-port') {
60
64
  return createMessagePortRpc({}, (port) => ExtensionManagementWorker.invokeAndTransfer('Extensions.createNodeRpcMessagePort', id, port));
61
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/api",
3
- "version": "8.79.0",
3
+ "version": "8.80.1",
4
4
  "description": "Tree-shakeable extension API for Lvce Editor extensions.",
5
5
  "keywords": [
6
6
  "lvce-editor",