@lvce-editor/iframe-worker 5.7.0 → 5.8.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 +14 -9
- package/package.json +1 -1
package/dist/iframeWorkerMain.js
CHANGED
|
@@ -893,6 +893,16 @@ const createLocalHostUrl = (locationProtocol, locationHost, isGitpod, webViewPor
|
|
|
893
893
|
return `http://localhost:${webViewPort}`;
|
|
894
894
|
};
|
|
895
895
|
|
|
896
|
+
const getIframeSrcRemoteBaseUrl = (webViewRoot, locationOrigin) => {
|
|
897
|
+
if (webViewRoot && (webViewRoot.startsWith('http:') || webViewRoot.startsWith('https:'))) {
|
|
898
|
+
if (webViewRoot.startsWith(locationOrigin)) {
|
|
899
|
+
return webViewRoot.slice(locationOrigin.length);
|
|
900
|
+
}
|
|
901
|
+
return webViewRoot;
|
|
902
|
+
}
|
|
903
|
+
return '';
|
|
904
|
+
};
|
|
905
|
+
|
|
896
906
|
const getWebView = (webViews, webViewId) => {
|
|
897
907
|
for (const webView of webViews) {
|
|
898
908
|
if (webView.id === webViewId) {
|
|
@@ -948,7 +958,7 @@ const getWebViewUri = (webViews, webViewId) => {
|
|
|
948
958
|
return webViewPath;
|
|
949
959
|
};
|
|
950
960
|
|
|
951
|
-
const getIframeSrcRemote = (webViews, webViewPort, webViewId, locationProtocol, locationHost, isGitpod, root, platform$1 = platform, assetDir, webViewScheme) => {
|
|
961
|
+
const getIframeSrcRemote = (webViews, webViewPort, webViewId, locationProtocol, locationOrigin, locationHost, isGitpod, root, platform$1 = platform, assetDir, webViewScheme) => {
|
|
952
962
|
const webView = getWebView(webViews, webViewId);
|
|
953
963
|
const webViewUri = getWebViewUri(webViews, webViewId);
|
|
954
964
|
if (!webViewUri) {
|
|
@@ -965,12 +975,12 @@ const getIframeSrcRemote = (webViews, webViewPort, webViewId, locationProtocol,
|
|
|
965
975
|
webViewRoot = webView.uri;
|
|
966
976
|
iframeSrc = createLocalHostUrl(locationProtocol, locationHost, isGitpod, webViewPort);
|
|
967
977
|
}
|
|
968
|
-
const
|
|
978
|
+
const baseUrl = getIframeSrcRemoteBaseUrl(webViewRoot, locationOrigin);
|
|
979
|
+
const iframeContent = getWebViewHtml(baseUrl, '', webView.elements, assetDir);
|
|
969
980
|
// TODO either
|
|
970
981
|
// - load webviews the same as in web using blob urls
|
|
971
982
|
// - load webviews from a pattern like /webviews/:id/:fileName
|
|
972
983
|
return {
|
|
973
|
-
srcDoc: '',
|
|
974
984
|
iframeSrc,
|
|
975
985
|
webViewRoot,
|
|
976
986
|
iframeContent
|
|
@@ -1019,7 +1029,6 @@ const getIframeSrc$1 = (webView, locationOrigin, assetDir) => {
|
|
|
1019
1029
|
if (srcHtml) {
|
|
1020
1030
|
const blobUrl = getBlobUrl(srcHtml, 'text/html');
|
|
1021
1031
|
return {
|
|
1022
|
-
srcDoc: '',
|
|
1023
1032
|
iframeSrc: blobUrl,
|
|
1024
1033
|
webViewRoot: '',
|
|
1025
1034
|
iframeContent: ''
|
|
@@ -1034,7 +1043,7 @@ const getIframeSrc = (webViews, webViewId, webViewPort, root, isGitpod, location
|
|
|
1034
1043
|
if (platform === Web) {
|
|
1035
1044
|
return getIframeSrc$1(webView, locationOrigin, assetDir);
|
|
1036
1045
|
}
|
|
1037
|
-
return getIframeSrcRemote(webViews, webViewPort, webViewId, locationProtocol, locationHost, isGitpod, root, platform, assetDir, webViewScheme);
|
|
1046
|
+
return getIframeSrcRemote(webViews, webViewPort, webViewId, locationProtocol, locationOrigin, locationHost, isGitpod, root, platform, assetDir, webViewScheme);
|
|
1038
1047
|
} catch (error) {
|
|
1039
1048
|
throw new VError(error, `Failed to construct webview iframe src`);
|
|
1040
1049
|
}
|
|
@@ -1273,7 +1282,6 @@ const create2 = async ({
|
|
|
1273
1282
|
const {
|
|
1274
1283
|
iframeSrc,
|
|
1275
1284
|
webViewRoot,
|
|
1276
|
-
srcDoc,
|
|
1277
1285
|
iframeContent
|
|
1278
1286
|
} = iframeResult;
|
|
1279
1287
|
const frameAncestors = getWebViewFrameAncestors(locationProtocol, locationHost);
|
|
@@ -1310,7 +1318,6 @@ const create2 = async ({
|
|
|
1310
1318
|
const savedState = await getSavedWebViewState(webViewId);
|
|
1311
1319
|
await invoke$2('ExtensionHostWebView.load', webViewId, savedState);
|
|
1312
1320
|
return {
|
|
1313
|
-
srcDoc,
|
|
1314
1321
|
iframeSrc,
|
|
1315
1322
|
sandbox,
|
|
1316
1323
|
portId,
|
|
@@ -1377,7 +1384,6 @@ const create3 = async ({
|
|
|
1377
1384
|
const {
|
|
1378
1385
|
iframeSrc,
|
|
1379
1386
|
webViewRoot,
|
|
1380
|
-
srcDoc,
|
|
1381
1387
|
iframeContent
|
|
1382
1388
|
} = iframeResult;
|
|
1383
1389
|
const frameAncestors = getWebViewFrameAncestors(locationProtocol, locationHost);
|
|
@@ -1414,7 +1420,6 @@ const create3 = async ({
|
|
|
1414
1420
|
const savedState = await getSavedWebViewState(webViewId);
|
|
1415
1421
|
await invoke$2('ExtensionHostWebView.load', webViewId, savedState);
|
|
1416
1422
|
return {
|
|
1417
|
-
srcDoc,
|
|
1418
1423
|
iframeSrc,
|
|
1419
1424
|
sandbox,
|
|
1420
1425
|
portId,
|