chayns-api 2.6.12 → 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.
|
@@ -50,13 +50,13 @@ const ChaynsProvider = ({
|
|
|
50
50
|
if (data && functions) {
|
|
51
51
|
customWrapper.current = new _ModuleFederationWrapper.ModuleFederationWrapper(data, functions, customFunctions);
|
|
52
52
|
} else {
|
|
53
|
-
console.
|
|
53
|
+
console.error('[chayns-api] ModuleFederationWrapper requires data and functions');
|
|
54
54
|
}
|
|
55
55
|
} else if (isServer) {
|
|
56
56
|
if (data && functions) {
|
|
57
57
|
customWrapper.current = new _SsrWrapper.SsrWrapper(data, functions, customFunctions);
|
|
58
58
|
} else {
|
|
59
|
-
console.
|
|
59
|
+
console.error('[chayns-api] SsrWrapper requires data and functions');
|
|
60
60
|
}
|
|
61
61
|
} else {
|
|
62
62
|
var _deviceInfo$app$name, _deviceInfo$app;
|
|
@@ -68,8 +68,9 @@ const ChaynsProvider = ({
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
_moduleWrapper.moduleWrapper.current = customWrapper.current;
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
if (customWrapper.current) {
|
|
72
|
+
customWrapper.current.chaynsApiId = idRef.current;
|
|
73
|
+
}
|
|
73
74
|
}
|
|
74
75
|
const [isInitialized, setIsInitialized] = (0, _react.useState)(!!((_customWrapper$curren = customWrapper.current) !== null && _customWrapper$curren !== void 0 && _customWrapper$curren.values));
|
|
75
76
|
(0, _react.useEffect)(() => {
|
|
@@ -99,9 +100,10 @@ const ChaynsProvider = ({
|
|
|
99
100
|
}
|
|
100
101
|
}, [customFunctions, isModule]);
|
|
101
102
|
(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(() => {
|
|
102
|
-
|
|
103
|
+
const id = idRef.current;
|
|
104
|
+
(0, _moduleWrapper.addModuleWrapper)(id, customWrapper.current);
|
|
103
105
|
return () => {
|
|
104
|
-
(0, _moduleWrapper.removeModuleWrapper)(customWrapper.current);
|
|
106
|
+
(0, _moduleWrapper.removeModuleWrapper)(id, customWrapper.current);
|
|
105
107
|
};
|
|
106
108
|
}, []);
|
|
107
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,
|
|
@@ -42,13 +42,13 @@ const ChaynsProvider = ({
|
|
|
42
42
|
if (data && functions) {
|
|
43
43
|
customWrapper.current = new ModuleFederationWrapper(data, functions, customFunctions);
|
|
44
44
|
} else {
|
|
45
|
-
console.
|
|
45
|
+
console.error('[chayns-api] ModuleFederationWrapper requires data and functions');
|
|
46
46
|
}
|
|
47
47
|
} else if (isServer) {
|
|
48
48
|
if (data && functions) {
|
|
49
49
|
customWrapper.current = new SsrWrapper(data, functions, customFunctions);
|
|
50
50
|
} else {
|
|
51
|
-
console.
|
|
51
|
+
console.error('[chayns-api] SsrWrapper requires data and functions');
|
|
52
52
|
}
|
|
53
53
|
} else {
|
|
54
54
|
var _deviceInfo$app$name, _deviceInfo$app;
|
|
@@ -60,8 +60,9 @@ const ChaynsProvider = ({
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
moduleWrapper.current = customWrapper.current;
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
if (customWrapper.current) {
|
|
64
|
+
customWrapper.current.chaynsApiId = idRef.current;
|
|
65
|
+
}
|
|
65
66
|
}
|
|
66
67
|
const [isInitialized, setIsInitialized] = useState(!!((_customWrapper$curren = customWrapper.current) !== null && _customWrapper$curren !== void 0 && _customWrapper$curren.values));
|
|
67
68
|
useEffect(() => {
|
|
@@ -91,9 +92,10 @@ const ChaynsProvider = ({
|
|
|
91
92
|
}
|
|
92
93
|
}, [customFunctions, isModule]);
|
|
93
94
|
useIsomorphicLayoutEffect(() => {
|
|
94
|
-
|
|
95
|
+
const id = idRef.current;
|
|
96
|
+
addModuleWrapper(id, customWrapper.current);
|
|
95
97
|
return () => {
|
|
96
|
-
removeModuleWrapper(customWrapper.current);
|
|
98
|
+
removeModuleWrapper(id, customWrapper.current);
|
|
97
99
|
};
|
|
98
100
|
}, []);
|
|
99
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;
|