chayns-api 1.0.20 → 1.0.21
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/host/module/ModuleHost.js +3 -2
- package/dist/cjs/host/module/utils/loadComponent.js +5 -1
- package/dist/esm/host/module/ModuleHost.js +3 -2
- package/dist/esm/host/module/utils/loadComponent.js +5 -0
- package/dist/types/host/module/ModuleHost.d.ts +1 -0
- package/dist/types/host/module/utils/loadComponent.d.ts +1 -1
- package/package.json +1 -1
|
@@ -28,7 +28,7 @@ const System = ({
|
|
|
28
28
|
if (!system || !ready || failed) {
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
|
-
return /*#__PURE__*/_react.default.lazy((0, _loadComponent.default)(system.scope, system.module, system.url));
|
|
31
|
+
return /*#__PURE__*/_react.default.lazy((0, _loadComponent.default)(system.scope, system.module, system.url, undefined, system.preventSingleton));
|
|
32
32
|
|
|
33
33
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
34
34
|
}, [system === null || system === void 0 ? void 0 : system.scope, ready, system === null || system === void 0 ? void 0 : system.url]);
|
|
@@ -80,7 +80,8 @@ const ModuleHost = ({
|
|
|
80
80
|
system: {
|
|
81
81
|
scope: system.scope,
|
|
82
82
|
url: (0, _url.replaceStagingUrl)(preventStagingReplacement, system.url, environment.buildEnvironment),
|
|
83
|
-
module: system.module
|
|
83
|
+
module: system.module,
|
|
84
|
+
preventSingleton: system.preventSingleton
|
|
84
85
|
},
|
|
85
86
|
data: initialData,
|
|
86
87
|
functions: functions,
|
|
@@ -12,7 +12,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
12
12
|
// @ts-nocheck
|
|
13
13
|
|
|
14
14
|
let instances = {};
|
|
15
|
-
function loadComponent(scope, module, url, skipCompatMode = false) {
|
|
15
|
+
function loadComponent(scope, module, url, skipCompatMode = false, preventSingleton = false) {
|
|
16
16
|
return async () => {
|
|
17
17
|
// Initializes the shared scope. Fills it with known provided modules from this build and all remotes
|
|
18
18
|
// eslint-disable-next-line no-undef
|
|
@@ -42,6 +42,10 @@ function loadComponent(scope, module, url, skipCompatMode = false) {
|
|
|
42
42
|
Module = factory();
|
|
43
43
|
ModuleMap[`${Module.default.buildEnv}__${Module.default.appVersion}`] = Module;
|
|
44
44
|
}
|
|
45
|
+
if (preventSingleton) {
|
|
46
|
+
// Intercom :)
|
|
47
|
+
window[scope + "_list"] = null;
|
|
48
|
+
}
|
|
45
49
|
if (skipCompatMode) return Module;
|
|
46
50
|
const hostVersion = _semver.default.minVersion(_react.default.version);
|
|
47
51
|
const {
|
|
@@ -20,7 +20,7 @@ const System = _ref => {
|
|
|
20
20
|
if (!system || !ready || failed) {
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
|
-
return /*#__PURE__*/React.lazy(loadComponent(system.scope, system.module, system.url));
|
|
23
|
+
return /*#__PURE__*/React.lazy(loadComponent(system.scope, system.module, system.url, undefined, system.preventSingleton));
|
|
24
24
|
|
|
25
25
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
26
26
|
}, [system === null || system === void 0 ? void 0 : system.scope, ready, system === null || system === void 0 ? void 0 : system.url]);
|
|
@@ -73,7 +73,8 @@ const ModuleHost = _ref2 => {
|
|
|
73
73
|
system: {
|
|
74
74
|
scope: system.scope,
|
|
75
75
|
url: replaceStagingUrl(preventStagingReplacement, system.url, environment.buildEnvironment),
|
|
76
|
-
module: system.module
|
|
76
|
+
module: system.module,
|
|
77
|
+
preventSingleton: system.preventSingleton
|
|
77
78
|
},
|
|
78
79
|
data: initialData,
|
|
79
80
|
functions: functions,
|
|
@@ -7,6 +7,7 @@ import { semaphore } from './useDynamicScript';
|
|
|
7
7
|
let instances = {};
|
|
8
8
|
export default function loadComponent(scope, module, url) {
|
|
9
9
|
let skipCompatMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
10
|
+
let preventSingleton = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
10
11
|
return async () => {
|
|
11
12
|
// Initializes the shared scope. Fills it with known provided modules from this build and all remotes
|
|
12
13
|
// eslint-disable-next-line no-undef
|
|
@@ -36,6 +37,10 @@ export default function loadComponent(scope, module, url) {
|
|
|
36
37
|
Module = factory();
|
|
37
38
|
ModuleMap[`${Module.default.buildEnv}__${Module.default.appVersion}`] = Module;
|
|
38
39
|
}
|
|
40
|
+
if (preventSingleton) {
|
|
41
|
+
// Intercom :)
|
|
42
|
+
window[scope + "_list"] = null;
|
|
43
|
+
}
|
|
39
44
|
if (skipCompatMode) return Module;
|
|
40
45
|
const hostVersion = semver.minVersion(React.version);
|
|
41
46
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function loadComponent(scope: any, module: any, url: any, skipCompatMode?: boolean): () => Promise<any>;
|
|
1
|
+
export default function loadComponent(scope: any, module: any, url: any, skipCompatMode?: boolean, preventSingleton?: boolean): () => Promise<any>;
|