@lvce-editor/api 9.23.0 → 9.24.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.
@@ -13,8 +13,6 @@ interface CreateLegacyRpcOptions extends CreateRpcBaseOptions {
13
13
  export type CreateRpcOptions = CreateDeclaredRpcOptions | CreateLegacyRpcOptions;
14
14
  export interface CreateNodeRpcOptions {
15
15
  readonly id: string;
16
- readonly legacyName?: string;
17
- readonly legacyPath?: string;
18
16
  }
19
17
  export declare const createRpc: (options: CreateRpcOptions) => Promise<Rpc>;
20
18
  export declare const createNodeRpc: (options: CreateNodeRpcOptions) => Promise<Rpc>;
@@ -38,45 +38,11 @@ export const createRpc = async (options) => {
38
38
  const { contentSecurityPolicy, name, traceId, url } = await resolveRpcOptions(options);
39
39
  return createMessagePortRpc(commandMap, (port) => sendMessagePortToWebWorker(port, contentSecurityPolicy, name, traceId, url));
40
40
  };
41
- const isMissingCommand = (error, command) => {
42
- return error instanceof Error && error.message.includes(command) && /command not found|not found/i.test(error.message);
43
- };
44
- const getNodeRpcConnection = async ({ id, legacyName = '', legacyPath }) => {
41
+ const getNodeRpcConnection = async ({ id }) => {
45
42
  if (!id) {
46
43
  throw new TypeError('createNodeRpc requires an id');
47
44
  }
48
- try {
49
- const connectionInfo = (await ExtensionManagementWorker.invoke('Extensions.createNodeRpcConnection', id));
50
- return connectionInfo;
51
- }
52
- catch (error) {
53
- if (!isMissingCommand(error, 'Extensions.createNodeRpcConnection')) {
54
- throw error;
55
- }
56
- if (legacyPath) {
57
- return { name: legacyName, path: legacyPath, type: 'old-legacy-proxy' };
58
- }
59
- const { name, path } = (await ExtensionManagementWorker.invoke('Extensions.getNodeRpcInfo', id));
60
- return { name, path, type: 'old-legacy-proxy' };
61
- }
62
- };
63
- const createProxyRpc = (invoke, dispose) => {
64
- return {
65
- dispose,
66
- invoke,
67
- invokeAndTransfer: invoke,
68
- send(method, ...params) {
69
- void invoke(method, ...params);
70
- },
71
- };
72
- };
73
- const createLegacyProxyRpc = async (id) => {
74
- const rpcId = await ExtensionManagementWorker.invoke('Extensions.createLegacyNodeRpc', id);
75
- return createProxyRpc((method, ...params) => ExtensionManagementWorker.invoke('Extensions.invokeLegacyNodeRpc', rpcId, method, ...params), () => ExtensionManagementWorker.invoke('Extensions.disposeLegacyNodeRpc', rpcId));
76
- };
77
- const createOldLegacyProxyRpc = async (name, path) => {
78
- const rpcId = await ExtensionManagementWorker.invoke('Extensions.executeCommand', 'ExtensionNodeRpc.create', name, path);
79
- return createProxyRpc((method, ...params) => ExtensionManagementWorker.invoke('Extensions.executeCommand', 'ExtensionNodeRpc.invoke', rpcId, method, ...params), () => ExtensionManagementWorker.invoke('Extensions.executeCommand', 'ExtensionNodeRpc.dispose', rpcId));
45
+ return ExtensionManagementWorker.invoke('Extensions.createNodeRpcConnection', id);
80
46
  };
81
47
  export const createNodeRpc = async (options) => {
82
48
  const { id } = options;
@@ -84,12 +50,6 @@ export const createNodeRpc = async (options) => {
84
50
  if (connectionInfo.type === 'message-port') {
85
51
  return createMessagePortRpc({}, (port) => ExtensionManagementWorker.invokeAndTransfer('Extensions.createNodeRpcMessagePort', id, port));
86
52
  }
87
- if (connectionInfo.type === 'legacy-proxy') {
88
- return createLegacyProxyRpc(id);
89
- }
90
- if (connectionInfo.type === 'old-legacy-proxy') {
91
- return createOldLegacyProxyRpc(connectionInfo.name, connectionInfo.path);
92
- }
93
53
  const { protocols, url } = connectionInfo;
94
54
  const webSocket = new WebSocket(url, protocols);
95
55
  return WebSocketRpcParent.create({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/api",
3
- "version": "9.23.0",
3
+ "version": "9.24.0",
4
4
  "description": "Tree-shakeable extension API for Lvce Editor extensions.",
5
5
  "keywords": [
6
6
  "lvce-editor",