@lvce-editor/api 9.17.1 → 9.18.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.
- package/dist/parts/Rpc/Rpc.js +5 -4
- package/package.json +1 -1
package/dist/parts/Rpc/Rpc.js
CHANGED
|
@@ -6,6 +6,7 @@ const resolveRpcOptions = async (options) => {
|
|
|
6
6
|
return {
|
|
7
7
|
contentSecurityPolicy: info.contentSecurityPolicy || '',
|
|
8
8
|
name: info.name || '',
|
|
9
|
+
traceId: options.id,
|
|
9
10
|
url: info.url,
|
|
10
11
|
};
|
|
11
12
|
}
|
|
@@ -18,8 +19,8 @@ const resolveRpcOptions = async (options) => {
|
|
|
18
19
|
}
|
|
19
20
|
throw new TypeError('createRpc requires an id or url');
|
|
20
21
|
};
|
|
21
|
-
const sendMessagePortToWebWorker = async (port, contentSecurityPolicy, name, url) => {
|
|
22
|
-
await ExtensionManagementWorker.invokeAndTransfer('Extensions.createWebViewWorkerRpc2', { contentSecurityPolicy, name, url }, port);
|
|
22
|
+
const sendMessagePortToWebWorker = async (port, contentSecurityPolicy, name, traceId, url) => {
|
|
23
|
+
await ExtensionManagementWorker.invokeAndTransfer('Extensions.createWebViewWorkerRpc2', { contentSecurityPolicy, name, ...(traceId && { traceId }), url }, port);
|
|
23
24
|
};
|
|
24
25
|
const createMessagePortRpc = async (commandMap, send) => {
|
|
25
26
|
const { port1, port2 } = new MessageChannel();
|
|
@@ -34,8 +35,8 @@ const createMessagePortRpc = async (commandMap, send) => {
|
|
|
34
35
|
};
|
|
35
36
|
export const createRpc = async (options) => {
|
|
36
37
|
const { commandMap = {} } = options;
|
|
37
|
-
const { contentSecurityPolicy, name, url } = await resolveRpcOptions(options);
|
|
38
|
-
return createMessagePortRpc(commandMap, (port) => sendMessagePortToWebWorker(port, contentSecurityPolicy, name, url));
|
|
38
|
+
const { contentSecurityPolicy, name, traceId, url } = await resolveRpcOptions(options);
|
|
39
|
+
return createMessagePortRpc(commandMap, (port) => sendMessagePortToWebWorker(port, contentSecurityPolicy, name, traceId, url));
|
|
39
40
|
};
|
|
40
41
|
const isMissingCommand = (error, command) => {
|
|
41
42
|
return error instanceof Error && error.message.includes(command) && /command not found|not found/i.test(error.message);
|