chayns-api 2.4.6 → 2.4.7-beta.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.
|
@@ -94,6 +94,12 @@ const ChaynsProvider = ({
|
|
|
94
94
|
customWrapper.current.emitChange();
|
|
95
95
|
}
|
|
96
96
|
}, [customFunctions, isModule]);
|
|
97
|
+
(0, _react.useEffect)(() => {
|
|
98
|
+
(0, _moduleWrapper.addModuleWrapper)(customWrapper.current);
|
|
99
|
+
return () => {
|
|
100
|
+
(0, _moduleWrapper.removeModuleWrapper)(customWrapper.current);
|
|
101
|
+
};
|
|
102
|
+
}, []);
|
|
97
103
|
return _react.default.createElement(_react.default.Fragment, null, isInitialized && _react.default.createElement(_ChaynsContext.ChaynsContext.Provider, {
|
|
98
104
|
value: customWrapper.current
|
|
99
105
|
}, children), _react.default.createElement(InitialDataProvider, {
|
|
@@ -3,7 +3,28 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.moduleWrapper = void 0;
|
|
6
|
+
exports.removeModuleWrapper = exports.moduleWrapper = exports.addModuleWrapper = void 0;
|
|
7
|
+
const moduleWrapperStack = [];
|
|
8
|
+
let current = undefined;
|
|
7
9
|
const moduleWrapper = exports.moduleWrapper = {
|
|
8
|
-
current
|
|
9
|
-
|
|
10
|
+
get current() {
|
|
11
|
+
if (moduleWrapperStack.length === 0 && !current) {
|
|
12
|
+
throw new Error("No chayns api instance intialized");
|
|
13
|
+
}
|
|
14
|
+
return moduleWrapperStack.at(-1) || current;
|
|
15
|
+
},
|
|
16
|
+
set current(chayns) {
|
|
17
|
+
current = chayns;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const addModuleWrapper = chayns => {
|
|
21
|
+
moduleWrapperStack.push(chayns);
|
|
22
|
+
};
|
|
23
|
+
exports.addModuleWrapper = addModuleWrapper;
|
|
24
|
+
const removeModuleWrapper = chayns => {
|
|
25
|
+
const index = moduleWrapperStack.indexOf(chayns);
|
|
26
|
+
if (index > -1) {
|
|
27
|
+
moduleWrapperStack.splice(index, 1);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.removeModuleWrapper = removeModuleWrapper;
|
|
@@ -7,7 +7,7 @@ import { FrameWrapper } from '../wrapper/FrameWrapper';
|
|
|
7
7
|
import { ModuleFederationWrapper } from '../wrapper/ModuleFederationWrapper';
|
|
8
8
|
import { SsrWrapper } from '../wrapper/SsrWrapper';
|
|
9
9
|
import { ChaynsContext } from './ChaynsContext';
|
|
10
|
-
import { moduleWrapper } from './moduleWrapper';
|
|
10
|
+
import { addModuleWrapper, moduleWrapper, removeModuleWrapper } from './moduleWrapper';
|
|
11
11
|
const isServer = typeof window === 'undefined';
|
|
12
12
|
const InitialDataProvider = React.memo(_ref => {
|
|
13
13
|
let {
|
|
@@ -88,6 +88,12 @@ const ChaynsProvider = _ref2 => {
|
|
|
88
88
|
customWrapper.current.emitChange();
|
|
89
89
|
}
|
|
90
90
|
}, [customFunctions, isModule]);
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
addModuleWrapper(customWrapper.current);
|
|
93
|
+
return () => {
|
|
94
|
+
removeModuleWrapper(customWrapper.current);
|
|
95
|
+
};
|
|
96
|
+
}, []);
|
|
91
97
|
return React.createElement(React.Fragment, null, isInitialized && React.createElement(ChaynsContext.Provider, {
|
|
92
98
|
value: customWrapper.current
|
|
93
99
|
}, children), React.createElement(InitialDataProvider, {
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
const moduleWrapperStack = [];
|
|
2
|
+
let current = undefined;
|
|
1
3
|
export const moduleWrapper = {
|
|
2
|
-
current
|
|
4
|
+
get current() {
|
|
5
|
+
if (moduleWrapperStack.length === 0 && !current) {
|
|
6
|
+
throw new Error("No chayns api instance intialized");
|
|
7
|
+
}
|
|
8
|
+
return moduleWrapperStack.at(-1) || current;
|
|
9
|
+
},
|
|
10
|
+
set current(chayns) {
|
|
11
|
+
current = chayns;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export const addModuleWrapper = chayns => {
|
|
15
|
+
moduleWrapperStack.push(chayns);
|
|
16
|
+
};
|
|
17
|
+
export const removeModuleWrapper = chayns => {
|
|
18
|
+
const index = moduleWrapperStack.indexOf(chayns);
|
|
19
|
+
if (index > -1) {
|
|
20
|
+
moduleWrapperStack.splice(index, 1);
|
|
21
|
+
}
|
|
3
22
|
};
|