@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.
@@ -92,10 +92,12 @@ const getMicroFrontEndAppConfig = (appInfo) => {
92
92
  };
93
93
  const getPreloadableAppConfig = () => {
94
94
  const microFEs = (0, import_config.getAppConfigValue)("microFrontendApps");
95
- return microFEs.reduce((acc, microFE) => {
96
- const { preload = false } = microFE;
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(microFE));
100
+ acc.push(getMicroFrontEndAppConfig({ id: microFEId }));
99
101
  }
100
102
  return acc;
101
103
  }, []);
@@ -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
- return microFEs.reduce((acc, microFE) => {
58
- const { preload = false } = microFE;
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(microFE));
62
+ acc.push(getMicroFrontEndAppConfig({ id: microFEId }));
61
63
  }
62
64
  return acc;
63
65
  }, []);
@@ -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);
@@ -1,2 +1,3 @@
1
1
  export declare const getRedirectUrl: () => string;
2
+ export declare const isAbsoluteUrl: (url: string) => boolean;
2
3
  export declare const removeDoubleSlash: (url: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/pui-app-sdk",
3
- "version": "6.0.0-next.3",
3
+ "version": "6.0.0-next.4",
4
4
  "description": "ICE MT UI Platform Application SDK ",
5
5
  "sideEffects": [
6
6
  "*.css",