@elliemae/pui-app-sdk 6.0.0-next.3 → 6.0.0-next.4
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/cjs/utils/micro-frontend/index.js +5 -3
- package/dist/cjs/utils/url.js +2 -0
- package/dist/cjs/view/micro-app/resources/script.js +1 -1
- package/dist/cjs/view/micro-app/resources/style.js +1 -1
- package/dist/esm/utils/micro-frontend/index.js +5 -3
- package/dist/esm/utils/url.js +2 -0
- package/dist/esm/view/micro-app/resources/script.js +2 -2
- package/dist/esm/view/micro-app/resources/style.js +2 -2
- package/dist/types/lib/utils/url.d.ts +1 -0
- package/package.json +1 -1
|
@@ -92,10 +92,12 @@ const getMicroFrontEndAppConfig = (appInfo) => {
|
|
|
92
92
|
};
|
|
93
93
|
const getPreloadableAppConfig = () => {
|
|
94
94
|
const microFEs = (0, import_config.getAppConfigValue)("microFrontendApps");
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
if (!microFEs)
|
|
96
|
+
return [];
|
|
97
|
+
return Object.keys(microFEs).reduce((acc, microFEId) => {
|
|
98
|
+
const { preload = false } = microFEs[microFEId];
|
|
97
99
|
if (preload) {
|
|
98
|
-
acc.push(getMicroFrontEndAppConfig(
|
|
100
|
+
acc.push(getMicroFrontEndAppConfig({ id: microFEId }));
|
|
99
101
|
}
|
|
100
102
|
return acc;
|
|
101
103
|
}, []);
|
package/dist/cjs/utils/url.js
CHANGED
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var url_exports = {};
|
|
20
20
|
__export(url_exports, {
|
|
21
21
|
getRedirectUrl: () => getRedirectUrl,
|
|
22
|
+
isAbsoluteUrl: () => isAbsoluteUrl,
|
|
22
23
|
removeDoubleSlash: () => removeDoubleSlash
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(url_exports);
|
|
@@ -27,4 +28,5 @@ const getRedirectUrl = () => {
|
|
|
27
28
|
url.search = "";
|
|
28
29
|
return url.href;
|
|
29
30
|
};
|
|
31
|
+
const isAbsoluteUrl = (url) => new URL(document.baseURI).origin !== new URL(url, document.baseURI).origin;
|
|
30
32
|
const removeDoubleSlash = (url) => url.replace(/([^:]\/)\/+/g, "$1");
|
|
@@ -36,7 +36,7 @@ const addScriptToDOM = ({ name, hostUrl, documentEle }, fileName, index) => {
|
|
|
36
36
|
if (!ele)
|
|
37
37
|
reject(new Error("Unable to insert Application scripts."));
|
|
38
38
|
ele.id = `${APP_SCRIPT_ID_PREFIX}${name}-${index}`;
|
|
39
|
-
const url = new URL(fileName, hostUrl);
|
|
39
|
+
const url = (0, import_url.isAbsoluteUrl)(fileName) ? new URL(fileName) : new URL(fileName, hostUrl);
|
|
40
40
|
ele.src = (0, import_url.removeDoubleSlash)(url.href);
|
|
41
41
|
ele.onload = resolve.bind(null, ele.id);
|
|
42
42
|
ele.onerror = reject.bind(null, ele.id);
|
|
@@ -36,7 +36,7 @@ const addStylesToDOM = ({ name, hostUrl, documentEle }, fileName, index) => {
|
|
|
36
36
|
reject(new Error("Unable to insert Application styles."));
|
|
37
37
|
ele.id = `${APP_STYLE_ID_PREFIX}${name}-${index}`;
|
|
38
38
|
ele.rel = "stylesheet";
|
|
39
|
-
const url = new URL(fileName, hostUrl);
|
|
39
|
+
const url = (0, import_url.isAbsoluteUrl)(fileName) ? new URL(fileName) : new URL(fileName, hostUrl);
|
|
40
40
|
ele.href = (0, import_url.removeDoubleSlash)(url.href);
|
|
41
41
|
ele.onload = resolve.bind(null, ele.id);
|
|
42
42
|
documentEle.head.appendChild(ele);
|
|
@@ -54,10 +54,12 @@ const getMicroFrontEndAppConfig = (appInfo) => {
|
|
|
54
54
|
};
|
|
55
55
|
const getPreloadableAppConfig = () => {
|
|
56
56
|
const microFEs = getAppConfigValue("microFrontendApps");
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
if (!microFEs)
|
|
58
|
+
return [];
|
|
59
|
+
return Object.keys(microFEs).reduce((acc, microFEId) => {
|
|
60
|
+
const { preload = false } = microFEs[microFEId];
|
|
59
61
|
if (preload) {
|
|
60
|
-
acc.push(getMicroFrontEndAppConfig(
|
|
62
|
+
acc.push(getMicroFrontEndAppConfig({ id: microFEId }));
|
|
61
63
|
}
|
|
62
64
|
return acc;
|
|
63
65
|
}, []);
|
package/dist/esm/utils/url.js
CHANGED
|
@@ -3,8 +3,10 @@ const getRedirectUrl = () => {
|
|
|
3
3
|
url.search = "";
|
|
4
4
|
return url.href;
|
|
5
5
|
};
|
|
6
|
+
const isAbsoluteUrl = (url) => new URL(document.baseURI).origin !== new URL(url, document.baseURI).origin;
|
|
6
7
|
const removeDoubleSlash = (url) => url.replace(/([^:]\/)\/+/g, "$1");
|
|
7
8
|
export {
|
|
8
9
|
getRedirectUrl,
|
|
10
|
+
isAbsoluteUrl,
|
|
9
11
|
removeDoubleSlash
|
|
10
12
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { removeDoubleSlash } from "../../../utils/url.js";
|
|
1
|
+
import { removeDoubleSlash, isAbsoluteUrl } from "../../../utils/url.js";
|
|
2
2
|
const APP_SCRIPT_ID_PREFIX = "emui-script-";
|
|
3
3
|
const addScriptToDOM = ({ name, hostUrl, documentEle }, fileName, index) => {
|
|
4
4
|
if (!hostUrl)
|
|
@@ -8,7 +8,7 @@ const addScriptToDOM = ({ name, hostUrl, documentEle }, fileName, index) => {
|
|
|
8
8
|
if (!ele)
|
|
9
9
|
reject(new Error("Unable to insert Application scripts."));
|
|
10
10
|
ele.id = `${APP_SCRIPT_ID_PREFIX}${name}-${index}`;
|
|
11
|
-
const url = new URL(fileName, hostUrl);
|
|
11
|
+
const url = isAbsoluteUrl(fileName) ? new URL(fileName) : new URL(fileName, hostUrl);
|
|
12
12
|
ele.src = removeDoubleSlash(url.href);
|
|
13
13
|
ele.onload = resolve.bind(null, ele.id);
|
|
14
14
|
ele.onerror = reject.bind(null, ele.id);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { removeDoubleSlash } from "../../../utils/url.js";
|
|
1
|
+
import { removeDoubleSlash, isAbsoluteUrl } from "../../../utils/url.js";
|
|
2
2
|
const APP_STYLE_ID_PREFIX = "emui-style-";
|
|
3
3
|
const addStylesToDOM = ({ name, hostUrl, documentEle }, fileName, index) => {
|
|
4
4
|
if (!hostUrl)
|
|
@@ -9,7 +9,7 @@ const addStylesToDOM = ({ name, hostUrl, documentEle }, fileName, index) => {
|
|
|
9
9
|
reject(new Error("Unable to insert Application styles."));
|
|
10
10
|
ele.id = `${APP_STYLE_ID_PREFIX}${name}-${index}`;
|
|
11
11
|
ele.rel = "stylesheet";
|
|
12
|
-
const url = new URL(fileName, hostUrl);
|
|
12
|
+
const url = isAbsoluteUrl(fileName) ? new URL(fileName) : new URL(fileName, hostUrl);
|
|
13
13
|
ele.href = removeDoubleSlash(url.href);
|
|
14
14
|
ele.onload = resolve.bind(null, ele.id);
|
|
15
15
|
documentEle.head.appendChild(ele);
|