chayns-api 2.6.13 → 2.6.14
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.
|
@@ -69,7 +69,6 @@ const ChaynsProvider = ({
|
|
|
69
69
|
}
|
|
70
70
|
_moduleWrapper.moduleWrapper.current = customWrapper.current;
|
|
71
71
|
if (customWrapper.current) {
|
|
72
|
-
_moduleWrapper.chaynsApis[idRef.current] = customWrapper.current.functions;
|
|
73
72
|
customWrapper.current.chaynsApiId = idRef.current;
|
|
74
73
|
}
|
|
75
74
|
}
|
|
@@ -101,9 +100,10 @@ const ChaynsProvider = ({
|
|
|
101
100
|
}
|
|
102
101
|
}, [customFunctions, isModule]);
|
|
103
102
|
(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(() => {
|
|
104
|
-
|
|
103
|
+
const id = idRef.current;
|
|
104
|
+
(0, _moduleWrapper.addModuleWrapper)(id, customWrapper.current);
|
|
105
105
|
return () => {
|
|
106
|
-
(0, _moduleWrapper.removeModuleWrapper)(customWrapper.current);
|
|
106
|
+
(0, _moduleWrapper.removeModuleWrapper)(id, customWrapper.current);
|
|
107
107
|
};
|
|
108
108
|
}, []);
|
|
109
109
|
return _react.default.createElement(_react.default.Fragment, null, isInitialized && _react.default.createElement(_ChaynsContext.ChaynsContext.Provider, {
|
|
@@ -22,14 +22,16 @@ const getChaynsApi = id => {
|
|
|
22
22
|
return chaynsApis[id];
|
|
23
23
|
};
|
|
24
24
|
exports.getChaynsApi = getChaynsApi;
|
|
25
|
-
const addModuleWrapper = chayns => {
|
|
25
|
+
const addModuleWrapper = (id, chayns) => {
|
|
26
26
|
moduleWrapperStack.push(chayns);
|
|
27
|
+
chaynsApis[id] = chayns.functions;
|
|
27
28
|
};
|
|
28
29
|
exports.addModuleWrapper = addModuleWrapper;
|
|
29
|
-
const removeModuleWrapper = chayns => {
|
|
30
|
+
const removeModuleWrapper = (id, chayns) => {
|
|
30
31
|
const index = moduleWrapperStack.indexOf(chayns);
|
|
31
32
|
if (index > -1) {
|
|
32
33
|
moduleWrapperStack.splice(index, 1);
|
|
33
34
|
}
|
|
35
|
+
delete moduleWrapperStack[id];
|
|
34
36
|
};
|
|
35
37
|
exports.removeModuleWrapper = removeModuleWrapper;
|
|
@@ -8,7 +8,7 @@ import { FrameWrapper } from '../wrapper/FrameWrapper';
|
|
|
8
8
|
import { ModuleFederationWrapper } from '../wrapper/ModuleFederationWrapper';
|
|
9
9
|
import { SsrWrapper } from '../wrapper/SsrWrapper';
|
|
10
10
|
import { ChaynsContext } from './ChaynsContext';
|
|
11
|
-
import { addModuleWrapper,
|
|
11
|
+
import { addModuleWrapper, moduleWrapper, removeModuleWrapper } from './moduleWrapper';
|
|
12
12
|
const isServer = typeof window === 'undefined';
|
|
13
13
|
const InitialDataProvider = React.memo(({
|
|
14
14
|
data,
|
|
@@ -61,7 +61,6 @@ const ChaynsProvider = ({
|
|
|
61
61
|
}
|
|
62
62
|
moduleWrapper.current = customWrapper.current;
|
|
63
63
|
if (customWrapper.current) {
|
|
64
|
-
chaynsApis[idRef.current] = customWrapper.current.functions;
|
|
65
64
|
customWrapper.current.chaynsApiId = idRef.current;
|
|
66
65
|
}
|
|
67
66
|
}
|
|
@@ -93,9 +92,10 @@ const ChaynsProvider = ({
|
|
|
93
92
|
}
|
|
94
93
|
}, [customFunctions, isModule]);
|
|
95
94
|
useIsomorphicLayoutEffect(() => {
|
|
96
|
-
|
|
95
|
+
const id = idRef.current;
|
|
96
|
+
addModuleWrapper(id, customWrapper.current);
|
|
97
97
|
return () => {
|
|
98
|
-
removeModuleWrapper(customWrapper.current);
|
|
98
|
+
removeModuleWrapper(id, customWrapper.current);
|
|
99
99
|
};
|
|
100
100
|
}, []);
|
|
101
101
|
return React.createElement(React.Fragment, null, isInitialized && React.createElement(ChaynsContext.Provider, {
|
|
@@ -15,12 +15,14 @@ export const chaynsApis = {};
|
|
|
15
15
|
export const getChaynsApi = id => {
|
|
16
16
|
return chaynsApis[id];
|
|
17
17
|
};
|
|
18
|
-
export const addModuleWrapper = chayns => {
|
|
18
|
+
export const addModuleWrapper = (id, chayns) => {
|
|
19
19
|
moduleWrapperStack.push(chayns);
|
|
20
|
+
chaynsApis[id] = chayns.functions;
|
|
20
21
|
};
|
|
21
|
-
export const removeModuleWrapper = chayns => {
|
|
22
|
+
export const removeModuleWrapper = (id, chayns) => {
|
|
22
23
|
const index = moduleWrapperStack.indexOf(chayns);
|
|
23
24
|
if (index > -1) {
|
|
24
25
|
moduleWrapperStack.splice(index, 1);
|
|
25
26
|
}
|
|
27
|
+
delete moduleWrapperStack[id];
|
|
26
28
|
};
|
|
@@ -4,5 +4,5 @@ export declare const moduleWrapper: {
|
|
|
4
4
|
};
|
|
5
5
|
export declare const chaynsApis: Record<string, ChaynsReactFunctions>;
|
|
6
6
|
export declare const getChaynsApi: (id: string) => ChaynsReactFunctions;
|
|
7
|
-
export declare const addModuleWrapper: (chayns: IChaynsReact) => void;
|
|
8
|
-
export declare const removeModuleWrapper: (chayns: IChaynsReact) => void;
|
|
7
|
+
export declare const addModuleWrapper: (id: string, chayns: IChaynsReact) => void;
|
|
8
|
+
export declare const removeModuleWrapper: (id: string, chayns: IChaynsReact) => void;
|