@lvce-editor/iframe-worker 5.25.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.
@@ -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$1 = platform, assetDir, webViewScheme, useNewWebViewHandler) => {
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$1 === Electron) {
1060
+ if (platform === Electron) {
1105
1061
  const webViewId = webView.id;
1106
1062
  iframeSrc = `${webViewScheme}://${webViewId}`;
1107
- } else if (platform$1 === Remote) {
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$1, webViewId, useNewWebViewHandler, root);
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: assetDir$1 = 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$1, webViewScheme, false);
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');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/iframe-worker",
3
- "version": "5.25.0",
3
+ "version": "5.26.0",
4
4
  "description": "Web Worker to manage creation and lifecycle of iframes in Lvce Editor",
5
5
  "keywords": [
6
6
  "iframe"