@lvce-editor/iframe-worker 5.24.0 → 5.26.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 +27 -61
- package/package.json +1 -1
package/dist/iframeWorkerMain.js
CHANGED
|
@@ -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');
|
|
@@ -1776,6 +1742,8 @@ const create3 = async ({
|
|
|
1776
1742
|
const permissionPolicyString = permissionPolicy.join('; ');
|
|
1777
1743
|
const iframeCsp = platform === Web ? csp : '';
|
|
1778
1744
|
const credentialless = getCredentialLess(locationHost);
|
|
1745
|
+
|
|
1746
|
+
// TODO remove this
|
|
1779
1747
|
await invoke$4('ExtensionHostManagement.activateByEvent', `onWebView:${webViewId}`);
|
|
1780
1748
|
const portId = create$1();
|
|
1781
1749
|
const remotePathPrefix = '/remote';
|
|
@@ -1814,17 +1782,15 @@ const getWebViewInfo = webViewId => {
|
|
|
1814
1782
|
const rpcs = getAll();
|
|
1815
1783
|
for (const value of Object.values(rpcs)) {
|
|
1816
1784
|
if (value.webViewId === webViewId) {
|
|
1817
|
-
return
|
|
1785
|
+
return {
|
|
1786
|
+
uid: value.webViewUid,
|
|
1787
|
+
origin: value.origin
|
|
1788
|
+
};
|
|
1818
1789
|
}
|
|
1819
1790
|
}
|
|
1820
1791
|
return undefined;
|
|
1821
1792
|
};
|
|
1822
1793
|
|
|
1823
|
-
const GetWebViewInfo = {
|
|
1824
|
-
__proto__: null,
|
|
1825
|
-
getWebViewInfo
|
|
1826
|
-
};
|
|
1827
|
-
|
|
1828
1794
|
const saveState = async () => {
|
|
1829
1795
|
const all = getAll();
|
|
1830
1796
|
const serialized = [];
|
|
@@ -1849,7 +1815,7 @@ const commandMap = {
|
|
|
1849
1815
|
'WebView.create3': create3,
|
|
1850
1816
|
'WebView.saveState': saveState,
|
|
1851
1817
|
'WebView.getSecret': getSecret,
|
|
1852
|
-
'WebView.getWebViewInfo':
|
|
1818
|
+
'WebView.getWebViewInfo': getWebViewInfo
|
|
1853
1819
|
};
|
|
1854
1820
|
|
|
1855
1821
|
const listen = async () => {
|