@lvce-editor/iframe-worker 5.25.0 → 5.27.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 +43 -57
- package/package.json +1 -1
package/dist/iframeWorkerMain.js
CHANGED
|
@@ -489,7 +489,7 @@ const set$2 = (id, fn) => {
|
|
|
489
489
|
const get$2 = id => {
|
|
490
490
|
return callbacks[id];
|
|
491
491
|
};
|
|
492
|
-
const remove = id => {
|
|
492
|
+
const remove$1 = id => {
|
|
493
493
|
delete callbacks[id];
|
|
494
494
|
};
|
|
495
495
|
let id = 0;
|
|
@@ -666,7 +666,7 @@ const resolve = (id, response) => {
|
|
|
666
666
|
return;
|
|
667
667
|
}
|
|
668
668
|
fn(response);
|
|
669
|
-
remove(id);
|
|
669
|
+
remove$1(id);
|
|
670
670
|
};
|
|
671
671
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
672
672
|
const getErrorType = prettyError => {
|
|
@@ -919,54 +919,6 @@ const WebWorkerRpcClient = {
|
|
|
919
919
|
create: create$2
|
|
920
920
|
};
|
|
921
921
|
|
|
922
|
-
const Web = 1;
|
|
923
|
-
const Electron = 2;
|
|
924
|
-
const Remote = 3;
|
|
925
|
-
const Test = 4;
|
|
926
|
-
|
|
927
|
-
/* istanbul ignore file */
|
|
928
|
-
|
|
929
|
-
// TODO this should always be completely tree shaken out during build, maybe need to be marked as @__Pure for terser to work
|
|
930
|
-
|
|
931
|
-
// TODO treeshake this function out when targeting electron
|
|
932
|
-
|
|
933
|
-
/**
|
|
934
|
-
* @returns {number}
|
|
935
|
-
*/
|
|
936
|
-
const getPlatform = () => {
|
|
937
|
-
// @ts-ignore
|
|
938
|
-
if (typeof PLATFORM !== 'undefined') {
|
|
939
|
-
// @ts-ignore
|
|
940
|
-
return PLATFORM;
|
|
941
|
-
}
|
|
942
|
-
// @ts-ignore
|
|
943
|
-
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'test') {
|
|
944
|
-
return Test;
|
|
945
|
-
}
|
|
946
|
-
// TODO find a better way to pass runtime environment
|
|
947
|
-
if (typeof name !== 'undefined' && name.endsWith('(Electron)')) {
|
|
948
|
-
return Electron;
|
|
949
|
-
}
|
|
950
|
-
if (typeof name !== 'undefined' && name.endsWith('(Web)')) {
|
|
951
|
-
return Web;
|
|
952
|
-
}
|
|
953
|
-
return Remote;
|
|
954
|
-
};
|
|
955
|
-
const platform = getPlatform();
|
|
956
|
-
|
|
957
|
-
const getAssetDir = () => {
|
|
958
|
-
// @ts-ignore
|
|
959
|
-
if (typeof ASSET_DIR !== 'undefined') {
|
|
960
|
-
// @ts-ignore
|
|
961
|
-
return ASSET_DIR;
|
|
962
|
-
}
|
|
963
|
-
if (platform === Electron) {
|
|
964
|
-
return '';
|
|
965
|
-
}
|
|
966
|
-
return '';
|
|
967
|
-
};
|
|
968
|
-
const assetDir = getAssetDir();
|
|
969
|
-
|
|
970
922
|
const RendererWorker = 1;
|
|
971
923
|
|
|
972
924
|
const rpcs$1 = Object.create(null);
|
|
@@ -1015,6 +967,10 @@ const createLocalHostUrl = (locationProtocol, locationHost, isGitpod, webViewPor
|
|
|
1015
967
|
return `http://localhost:${webViewPort}`;
|
|
1016
968
|
};
|
|
1017
969
|
|
|
970
|
+
const Web = 1;
|
|
971
|
+
const Electron = 2;
|
|
972
|
+
const Remote = 3;
|
|
973
|
+
|
|
1018
974
|
const getIframeSrcRemoteBaseUrl = (webViewRoot, locationOrigin, platform, webViewId, useNewWebViewHandler, root) => {
|
|
1019
975
|
if (webViewRoot && (webViewRoot.startsWith('http:') || webViewRoot.startsWith('https:'))) {
|
|
1020
976
|
if (webViewRoot.startsWith(locationOrigin)) {
|
|
@@ -1088,7 +1044,7 @@ const getWebViewUri = (webViews, webViewId) => {
|
|
|
1088
1044
|
return webViewPath;
|
|
1089
1045
|
};
|
|
1090
1046
|
|
|
1091
|
-
const getIframeSrcRemote = (webViews, webViewPort, webViewId, locationProtocol, locationOrigin, locationHost, isGitpod, root, platform
|
|
1047
|
+
const getIframeSrcRemote = (webViews, webViewPort, webViewId, locationProtocol, locationOrigin, locationHost, isGitpod, root, platform, assetDir, webViewScheme, useNewWebViewHandler) => {
|
|
1092
1048
|
const webView = getWebView(webViews, webViewId);
|
|
1093
1049
|
const webViewUri = getWebViewUri(webViews, webViewId);
|
|
1094
1050
|
if (!webViewUri) {
|
|
@@ -1101,14 +1057,14 @@ const getIframeSrcRemote = (webViews, webViewPort, webViewId, locationProtocol,
|
|
|
1101
1057
|
let webViewRoot = webViewUri;
|
|
1102
1058
|
|
|
1103
1059
|
// TODO when running in remote, try scope webviews by path or if possible by domain
|
|
1104
|
-
if (platform
|
|
1060
|
+
if (platform === Electron) {
|
|
1105
1061
|
const webViewId = webView.id;
|
|
1106
1062
|
iframeSrc = `${webViewScheme}://${webViewId}`;
|
|
1107
|
-
} else if (platform
|
|
1063
|
+
} else if (platform === Remote) {
|
|
1108
1064
|
webViewRoot = webView.uri;
|
|
1109
1065
|
iframeSrc = createLocalHostUrl(locationProtocol, locationHost, isGitpod, webViewPort, webViewId, useNewWebViewHandler);
|
|
1110
1066
|
}
|
|
1111
|
-
const baseUrl = getIframeSrcRemoteBaseUrl(webViewRoot, locationOrigin, platform
|
|
1067
|
+
const baseUrl = getIframeSrcRemoteBaseUrl(webViewRoot, locationOrigin, platform, webViewId, useNewWebViewHandler, root);
|
|
1112
1068
|
const iframeContent = getWebViewHtml(baseUrl, '', webView.elements, assetDir);
|
|
1113
1069
|
// TODO either
|
|
1114
1070
|
// - load webviews the same as in web using blob urls
|
|
@@ -1406,7 +1362,7 @@ const create2 = async ({
|
|
|
1406
1362
|
uri,
|
|
1407
1363
|
platform,
|
|
1408
1364
|
isGitpod,
|
|
1409
|
-
assetDir
|
|
1365
|
+
assetDir = '',
|
|
1410
1366
|
webViewScheme = WebView
|
|
1411
1367
|
}) => {
|
|
1412
1368
|
let root = '';
|
|
@@ -1417,7 +1373,7 @@ const create2 = async ({
|
|
|
1417
1373
|
const locationProtocol = getProtocol$1();
|
|
1418
1374
|
const locationHost = getHost();
|
|
1419
1375
|
const locationOrigin = getOrigin();
|
|
1420
|
-
const iframeResult = getIframeSrc(webViews, webViewId, webViewPort, root, isGitpod, locationProtocol, locationHost, locationOrigin, platform, assetDir
|
|
1376
|
+
const iframeResult = getIframeSrc(webViews, webViewId, webViewPort, root, isGitpod, locationProtocol, locationHost, locationOrigin, platform, assetDir, webViewScheme, false);
|
|
1421
1377
|
if (!iframeResult) {
|
|
1422
1378
|
return undefined;
|
|
1423
1379
|
}
|
|
@@ -1551,10 +1507,19 @@ const getRemoteUrlForWebView = async options => {
|
|
|
1551
1507
|
return objectUrl;
|
|
1552
1508
|
};
|
|
1553
1509
|
|
|
1510
|
+
let platform = 0;
|
|
1511
|
+
const setPlatform = value => {
|
|
1512
|
+
platform = value;
|
|
1513
|
+
};
|
|
1514
|
+
const getPlatform = () => {
|
|
1515
|
+
return platform;
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1554
1518
|
const getRemoteUrl = async options => {
|
|
1555
1519
|
const {
|
|
1556
1520
|
uri
|
|
1557
1521
|
} = options;
|
|
1522
|
+
const platform = getPlatform() || Web;
|
|
1558
1523
|
// TODO uri should always have protocol
|
|
1559
1524
|
// then ask file system provider for remote url, for example disk file system provider or html file system provider
|
|
1560
1525
|
const protocol = getProtocol(uri);
|
|
@@ -1740,6 +1705,7 @@ const create3 = async ({
|
|
|
1740
1705
|
webViewScheme,
|
|
1741
1706
|
useNewWebViewHandler
|
|
1742
1707
|
}) => {
|
|
1708
|
+
setPlatform(platform);
|
|
1743
1709
|
let root = '';
|
|
1744
1710
|
if (platform === Remote) {
|
|
1745
1711
|
root = await invoke$1('Platform.getRoot');
|
|
@@ -1844,12 +1810,32 @@ const saveState = async () => {
|
|
|
1844
1810
|
return serialized;
|
|
1845
1811
|
};
|
|
1846
1812
|
|
|
1813
|
+
const interceptors = Object.create(null);
|
|
1814
|
+
|
|
1815
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
1816
|
+
const add = (id, port) => {
|
|
1817
|
+
interceptors[id] = port;
|
|
1818
|
+
};
|
|
1819
|
+
const remove = id => {
|
|
1820
|
+
delete interceptors[id];
|
|
1821
|
+
};
|
|
1822
|
+
|
|
1823
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
1824
|
+
const registerInterceptor = async (id, port) => {
|
|
1825
|
+
add(id, port);
|
|
1826
|
+
};
|
|
1827
|
+
const unregisterInterceptor = async id => {
|
|
1828
|
+
remove(id);
|
|
1829
|
+
};
|
|
1830
|
+
|
|
1847
1831
|
const commandMap = {
|
|
1848
1832
|
'WebView.create2': create2,
|
|
1849
1833
|
'WebView.create3': create3,
|
|
1850
1834
|
'WebView.saveState': saveState,
|
|
1851
1835
|
'WebView.getSecret': getSecret,
|
|
1852
|
-
'WebView.getWebViewInfo': getWebViewInfo
|
|
1836
|
+
'WebView.getWebViewInfo': getWebViewInfo,
|
|
1837
|
+
'WebView.registerInterceptor': registerInterceptor,
|
|
1838
|
+
'WebView.unregisterInterceptor': unregisterInterceptor
|
|
1853
1839
|
};
|
|
1854
1840
|
|
|
1855
1841
|
const listen = async () => {
|