chayns-api 2.6.13 → 2.6.15

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
- (0, _moduleWrapper.addModuleWrapper)(customWrapper.current);
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,6 +8,7 @@ var _react = _interopRequireDefault(require("react"));
8
8
  var _reactDom = _interopRequireDefault(require("react-dom"));
9
9
  var _SequentialLoadPlugin = require("../plugins/SequentialLoadPlugin");
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
12
  let ReactDOMClient;
12
13
  try {
13
14
  ReactDOMClient = require('react-dom/client');
@@ -34,6 +35,11 @@ const initModuleFederationSharing = ({
34
35
  version: _react.default.version,
35
36
  scope: 'chayns-api',
36
37
  lib: () => _reactDom.default
38
+ },
39
+ 'react-dom/server': {
40
+ version: _react.default.version,
41
+ scope: 'chayns-api',
42
+ lib: () => Promise.resolve().then(() => _interopRequireWildcard(require('react-dom/server')))
37
43
  }
38
44
  };
39
45
  if (ReactDOMClient) {
@@ -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, chaynsApis, moduleWrapper, removeModuleWrapper } from './moduleWrapper';
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
- addModuleWrapper(customWrapper.current);
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
  };
@@ -27,6 +27,11 @@ export const initModuleFederationSharing = ({
27
27
  version: React.version,
28
28
  scope: 'chayns-api',
29
29
  lib: () => ReactDOM
30
+ },
31
+ 'react-dom/server': {
32
+ version: React.version,
33
+ scope: 'chayns-api',
34
+ lib: () => import('react-dom/server')
30
35
  }
31
36
  };
32
37
  if (ReactDOMClient) {
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "2.6.13",
3
+ "version": "2.6.15",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",