@lvce-editor/iframe-worker 3.5.0 → 3.6.1
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 +67 -54
- package/package.json +1 -1
package/dist/iframeWorkerMain.js
CHANGED
|
@@ -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) => {
|
|
@@ -935,6 +956,9 @@ const getIframeSrcRemote = (webViews, webViewPort, webViewId, locationProtocol,
|
|
|
935
956
|
}
|
|
936
957
|
let iframeSrc = webViewUri;
|
|
937
958
|
let webViewRoot = webViewUri;
|
|
959
|
+
|
|
960
|
+
// TODO simplify path handling, always use uris so that paths on windows, linux and macos are the same
|
|
961
|
+
|
|
938
962
|
if (platform$1 === Electron) {
|
|
939
963
|
const relativePath = new URL(webViewUri).pathname.replace('/index.html', '');
|
|
940
964
|
iframeSrc = `${WebView}://-${relativePath}/`;
|
|
@@ -944,6 +968,8 @@ const getIframeSrcRemote = (webViews, webViewPort, webViewId, locationProtocol,
|
|
|
944
968
|
if (webViewUri.startsWith('file://')) {
|
|
945
969
|
// ignore
|
|
946
970
|
webViewRoot = webViewUri.slice('file://'.length).replace('/index.html', '');
|
|
971
|
+
} else if (relativePath.startsWith('C:/')) {
|
|
972
|
+
webViewRoot = relativePath;
|
|
947
973
|
} else {
|
|
948
974
|
webViewRoot = root + relativePath;
|
|
949
975
|
}
|
|
@@ -1103,6 +1129,11 @@ const getWebViewOrigin = (webViewPort, platform) => {
|
|
|
1103
1129
|
return origin;
|
|
1104
1130
|
};
|
|
1105
1131
|
|
|
1132
|
+
const getIframePermissionPolicy = webView => {
|
|
1133
|
+
const extensionAllow = webView.allow || [];
|
|
1134
|
+
return extensionAllow;
|
|
1135
|
+
};
|
|
1136
|
+
|
|
1106
1137
|
const getWebViews = async () => {
|
|
1107
1138
|
return invoke$3('WebView.getWebViews');
|
|
1108
1139
|
};
|
|
@@ -1121,11 +1152,6 @@ const getIframeSandbox = (webView, platform) => {
|
|
|
1121
1152
|
return [AllowScripts, AllowSameOrigin, ...extensionSandbox];
|
|
1122
1153
|
};
|
|
1123
1154
|
|
|
1124
|
-
const getIframePermissionPolicy = webView => {
|
|
1125
|
-
const extensionAllow = webView.allow || [];
|
|
1126
|
-
return extensionAllow;
|
|
1127
|
-
};
|
|
1128
|
-
|
|
1129
1155
|
const state = {
|
|
1130
1156
|
id: 0
|
|
1131
1157
|
};
|
|
@@ -1158,19 +1184,6 @@ const invoke = async (method, ...params) => {
|
|
|
1158
1184
|
return invoke$3('WebView.compatSharedProcessInvoke', method, ...params);
|
|
1159
1185
|
};
|
|
1160
1186
|
|
|
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
1187
|
const registerProtocol = async () => {
|
|
1175
1188
|
await invoke('WebViewServer.registerProtocol');
|
|
1176
1189
|
};
|
|
@@ -1265,7 +1278,7 @@ const create2 = async ({
|
|
|
1265
1278
|
const permissionPolicy = getIframePermissionPolicy(webView);
|
|
1266
1279
|
const permissionPolicyString = permissionPolicy.join('; ');
|
|
1267
1280
|
const iframeCsp = platform === Web ? csp : '';
|
|
1268
|
-
const credentialless =
|
|
1281
|
+
const credentialless = getCredentialLess(locationHost);
|
|
1269
1282
|
await invoke$3('ExtensionHostManagement.activateByEvent', `onWebView:${webViewId}`);
|
|
1270
1283
|
const {
|
|
1271
1284
|
port1,
|