@lvce-editor/iframe-worker 1.3.0 → 1.5.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/iframeWorkerMain.js +22 -26
- package/package.json +10 -4
package/dist/iframeWorkerMain.js
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
const commands = Object.create(null);
|
|
2
|
+
const registerCommand = (key, fn) => {
|
|
3
|
+
commands[key] = fn;
|
|
4
|
+
};
|
|
5
|
+
const register = commandMap => {
|
|
6
|
+
for (const [key, value] of Object.entries(commandMap)) {
|
|
7
|
+
registerCommand(key, value);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
const getCommand = key => {
|
|
11
|
+
return commands[key];
|
|
12
|
+
};
|
|
13
|
+
const execute = (command, ...args) => {
|
|
14
|
+
const fn = getCommand(command);
|
|
15
|
+
if (!fn) {
|
|
16
|
+
throw new Error(`command not found ${command}`);
|
|
17
|
+
}
|
|
18
|
+
return fn(...args);
|
|
19
|
+
};
|
|
20
|
+
|
|
1
21
|
const createUrl = (protocol, host) => {
|
|
2
22
|
return protocol + '//' + host;
|
|
3
23
|
};
|
|
@@ -319,8 +339,7 @@ const getIframeSandbox = (webView, platform) => {
|
|
|
319
339
|
if (platform === Web) {
|
|
320
340
|
return [AllowScripts, ...extensionSandbox];
|
|
321
341
|
}
|
|
322
|
-
|
|
323
|
-
return [...extensionSandbox];
|
|
342
|
+
return [AllowScripts, AllowSameOrigin, ...extensionSandbox];
|
|
324
343
|
};
|
|
325
344
|
|
|
326
345
|
const getOrigin = () => {
|
|
@@ -346,21 +365,6 @@ const commandMap = {
|
|
|
346
365
|
'WebView.getWebViewCsp': getWebViewCsp
|
|
347
366
|
};
|
|
348
367
|
|
|
349
|
-
const state = {
|
|
350
|
-
commands: Object.create(null)
|
|
351
|
-
};
|
|
352
|
-
const registerCommand = (key, fn) => {
|
|
353
|
-
state.commands[key] = fn;
|
|
354
|
-
};
|
|
355
|
-
const registerCommands = commandMap => {
|
|
356
|
-
for (const [key, value] of Object.entries(commandMap)) {
|
|
357
|
-
registerCommand(key, value);
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
const getCommand = key => {
|
|
361
|
-
return state.commands[key];
|
|
362
|
-
};
|
|
363
|
-
|
|
364
368
|
const Two = '2.0';
|
|
365
369
|
class AssertionError extends Error {
|
|
366
370
|
constructor(message) {
|
|
@@ -546,14 +550,6 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
546
550
|
throw new JsonRpcError('unexpected message');
|
|
547
551
|
};
|
|
548
552
|
|
|
549
|
-
const execute = (command, ...args) => {
|
|
550
|
-
const fn = getCommand(command);
|
|
551
|
-
if (!fn) {
|
|
552
|
-
throw new Error(`[iframe-worker] command not found ${command}`);
|
|
553
|
-
}
|
|
554
|
-
return fn(...args);
|
|
555
|
-
};
|
|
556
|
-
|
|
557
553
|
const requiresSocket = () => {
|
|
558
554
|
return false;
|
|
559
555
|
};
|
|
@@ -1000,7 +996,7 @@ const listen$1 = async ({
|
|
|
1000
996
|
};
|
|
1001
997
|
|
|
1002
998
|
const listen = async () => {
|
|
1003
|
-
|
|
999
|
+
register(commandMap);
|
|
1004
1000
|
const ipc = await listen$1({
|
|
1005
1001
|
method: Auto()
|
|
1006
1002
|
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/iframe-worker",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "Web Worker to manage creation and lifecycle of iframes in Lvce Editor",
|
|
5
5
|
"main": "dist/iframeWorkerMain.js",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"
|
|
8
|
-
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git@github.com:lvce-editor/iframe-worker.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"iframe"
|
|
13
|
+
],
|
|
14
|
+
"author": "Lvce Editor",
|
|
9
15
|
"license": "MIT"
|
|
10
16
|
}
|