@lvce-editor/iframe-worker 3.5.0 → 3.6.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.
@@ -804,6 +804,54 @@ const WebWorkerRpcClient = {
804
804
  create: create$2
805
805
  };
806
806
 
807
+ const Web = 1;
808
+ const Electron = 2;
809
+ const Remote = 3;
810
+ const Test = 4;
811
+
812
+ /* istanbul ignore file */
813
+
814
+ // TODO this should always be completely tree shaken out during build, maybe need to be marked as @__Pure for terser to work
815
+
816
+ // TODO treeshake this function out when targeting electron
817
+
818
+ /**
819
+ * @returns {number}
820
+ */
821
+ const getPlatform = () => {
822
+ // @ts-ignore
823
+ if (typeof PLATFORM !== 'undefined') {
824
+ // @ts-ignore
825
+ return PLATFORM;
826
+ }
827
+ // @ts-ignore
828
+ if (typeof process !== 'undefined' && process.env.NODE_ENV === 'test') {
829
+ return Test;
830
+ }
831
+ // TODO find a better way to pass runtime environment
832
+ if (typeof name !== 'undefined' && name.endsWith('(Electron)')) {
833
+ return Electron;
834
+ }
835
+ if (typeof name !== 'undefined' && name.endsWith('(Web)')) {
836
+ return Web;
837
+ }
838
+ return Remote;
839
+ };
840
+ const platform = getPlatform();
841
+
842
+ const getAssetDir = () => {
843
+ // @ts-ignore
844
+ if (typeof ASSET_DIR !== 'undefined') {
845
+ // @ts-ignore
846
+ return ASSET_DIR;
847
+ }
848
+ if (platform === Electron) {
849
+ return '';
850
+ }
851
+ return '';
852
+ };
853
+ const assetDir = getAssetDir();
854
+
807
855
  const state$1 = {
808
856
  rpc: undefined
809
857
  };
@@ -826,6 +874,14 @@ const invokeAndTransfer$1 = async (method, ...params) => {
826
874
  return invokeAndTransfer$2('WebView.compatExtensionHostWorkerInvokeAndTransfer', method, ...params);
827
875
  };
828
876
 
877
+ const getCredentialLess = locationHost => {
878
+ if (locationHost.startsWith('localhost:')) {
879
+ // disabled to improve performance and make testing easier
880
+ return false;
881
+ }
882
+ return true;
883
+ };
884
+
829
885
  const createUrl = (protocol, host) => {
830
886
  return protocol + '//' + host;
831
887
  };
@@ -864,41 +920,6 @@ const getWebViewHtml = (baseUrl, locationOrigin, elements, assetDir) => {
864
920
  return html;
865
921
  };
866
922
 
867
- const Web = 1;
868
- const Electron = 2;
869
- const Remote = 3;
870
- const Test = 4;
871
-
872
- /* istanbul ignore file */
873
-
874
- // TODO this should always be completely tree shaken out during build, maybe need to be marked as @__Pure for terser to work
875
-
876
- // TODO treeshake this function out when targeting electron
877
-
878
- /**
879
- * @returns {number}
880
- */
881
- const getPlatform = () => {
882
- // @ts-ignore
883
- if (typeof PLATFORM !== 'undefined') {
884
- // @ts-ignore
885
- return PLATFORM;
886
- }
887
- // @ts-ignore
888
- if (typeof process !== 'undefined' && process.env.NODE_ENV === 'test') {
889
- return Test;
890
- }
891
- // TODO find a better way to pass runtime environment
892
- if (typeof name !== 'undefined' && name.endsWith('(Electron)')) {
893
- return Electron;
894
- }
895
- if (typeof name !== 'undefined' && name.endsWith('(Web)')) {
896
- return Web;
897
- }
898
- return Remote;
899
- };
900
- const platform = getPlatform();
901
-
902
923
  const WebView = 'lvce-oss-webview';
903
924
 
904
925
  const getWebView$1 = (webViews, webViewId) => {
@@ -1103,6 +1124,11 @@ const getWebViewOrigin = (webViewPort, platform) => {
1103
1124
  return origin;
1104
1125
  };
1105
1126
 
1127
+ const getIframePermissionPolicy = webView => {
1128
+ const extensionAllow = webView.allow || [];
1129
+ return extensionAllow;
1130
+ };
1131
+
1106
1132
  const getWebViews = async () => {
1107
1133
  return invoke$3('WebView.getWebViews');
1108
1134
  };
@@ -1121,11 +1147,6 @@ const getIframeSandbox = (webView, platform) => {
1121
1147
  return [AllowScripts, AllowSameOrigin, ...extensionSandbox];
1122
1148
  };
1123
1149
 
1124
- const getIframePermissionPolicy = webView => {
1125
- const extensionAllow = webView.allow || [];
1126
- return extensionAllow;
1127
- };
1128
-
1129
1150
  const state = {
1130
1151
  id: 0
1131
1152
  };
@@ -1158,19 +1179,6 @@ const invoke = async (method, ...params) => {
1158
1179
  return invoke$3('WebView.compatSharedProcessInvoke', method, ...params);
1159
1180
  };
1160
1181
 
1161
- const getAssetDir = () => {
1162
- // @ts-ignore
1163
- if (typeof ASSET_DIR !== 'undefined') {
1164
- // @ts-ignore
1165
- return ASSET_DIR;
1166
- }
1167
- if (platform === Electron) {
1168
- return '';
1169
- }
1170
- return '';
1171
- };
1172
- const assetDir = getAssetDir();
1173
-
1174
1182
  const registerProtocol = async () => {
1175
1183
  await invoke('WebViewServer.registerProtocol');
1176
1184
  };
@@ -1265,7 +1273,7 @@ const create2 = async ({
1265
1273
  const permissionPolicy = getIframePermissionPolicy(webView);
1266
1274
  const permissionPolicyString = permissionPolicy.join('; ');
1267
1275
  const iframeCsp = platform === Web ? csp : '';
1268
- const credentialless = true;
1276
+ const credentialless = getCredentialLess(locationHost);
1269
1277
  await invoke$3('ExtensionHostManagement.activateByEvent', `onWebView:${webViewId}`);
1270
1278
  const {
1271
1279
  port1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/iframe-worker",
3
- "version": "3.5.0",
3
+ "version": "3.6.0",
4
4
  "description": "Web Worker to manage creation and lifecycle of iframes in Lvce Editor",
5
5
  "main": "dist/iframeWorkerMain.js",
6
6
  "type": "module",