chayns-api 2.1.0 → 2.1.2

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.
@@ -9,8 +9,5 @@ const empty = {};
9
9
  /**
10
10
  * @category Hooks
11
11
  */
12
- const useUser = () => (0, _context.useValuesSelector)(v => {
13
- var _v$user;
14
- return (_v$user = v.user) !== null && _v$user !== void 0 ? _v$user : empty;
15
- });
12
+ const useUser = () => (0, _context.useValuesSelector)(v => v.user || empty);
16
13
  exports.useUser = useUser;
@@ -7,6 +7,12 @@ exports.initModuleFederationSharing = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _reactDom = _interopRequireDefault(require("react-dom"));
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ let ReactDOMClient;
11
+ try {
12
+ ReactDOMClient = require('react-dom/client');
13
+ } catch (e) {
14
+ // do nothing
15
+ }
10
16
  const initModuleFederationSharing = ({
11
17
  name
12
18
  }) => {
@@ -23,22 +29,30 @@ const initModuleFederationSharing = ({
23
29
  const {
24
30
  init
25
31
  } = globalThis.moduleFederationRuntime;
32
+ const shared = {
33
+ react: {
34
+ version: _react.default.version,
35
+ scope: 'chayns-api',
36
+ lib: () => _react.default
37
+ },
38
+ 'react-dom': {
39
+ version: _react.default.version,
40
+ // intended, because react dom.version is not identical to package json react version (hash in version)
41
+ scope: 'chayns-api',
42
+ lib: () => _reactDom.default
43
+ }
44
+ };
45
+ if (ReactDOMClient) {
46
+ shared['react-dom/client'] = {
47
+ version: _react.default.version,
48
+ scope: 'chayns-api',
49
+ lib: () => ReactDOMClient
50
+ };
51
+ }
26
52
  init({
27
53
  name: name !== null && name !== void 0 ? name : '',
28
54
  remotes: [],
29
- shared: {
30
- react: {
31
- version: _react.default.version,
32
- scope: 'chayns-api',
33
- lib: () => _react.default
34
- },
35
- 'react-dom': {
36
- version: _react.default.version,
37
- // intended, because react dom.version is not identical to package json react version (hash in version)
38
- scope: 'chayns-api',
39
- lib: () => _reactDom.default
40
- }
41
- }
55
+ shared
42
56
  });
43
57
  };
44
58
  exports.initModuleFederationSharing = initModuleFederationSharing;
@@ -3,7 +3,4 @@ const empty = {};
3
3
  /**
4
4
  * @category Hooks
5
5
  */
6
- export const useUser = () => useValuesSelector(v => {
7
- var _v$user;
8
- return (_v$user = v.user) !== null && _v$user !== void 0 ? _v$user : empty;
9
- });
6
+ export const useUser = () => useValuesSelector(v => v.user || empty);
@@ -1,5 +1,11 @@
1
1
  import React from 'react';
2
2
  import ReactDOM from 'react-dom';
3
+ let ReactDOMClient;
4
+ try {
5
+ ReactDOMClient = require('react-dom/client');
6
+ } catch (e) {
7
+ // do nothing
8
+ }
3
9
  export const initModuleFederationSharing = _ref => {
4
10
  let {
5
11
  name
@@ -17,21 +23,29 @@ export const initModuleFederationSharing = _ref => {
17
23
  const {
18
24
  init
19
25
  } = globalThis.moduleFederationRuntime;
26
+ const shared = {
27
+ react: {
28
+ version: React.version,
29
+ scope: 'chayns-api',
30
+ lib: () => React
31
+ },
32
+ 'react-dom': {
33
+ version: React.version,
34
+ // intended, because react dom.version is not identical to package json react version (hash in version)
35
+ scope: 'chayns-api',
36
+ lib: () => ReactDOM
37
+ }
38
+ };
39
+ if (ReactDOMClient) {
40
+ shared['react-dom/client'] = {
41
+ version: React.version,
42
+ scope: 'chayns-api',
43
+ lib: () => ReactDOMClient
44
+ };
45
+ }
20
46
  init({
21
47
  name: name !== null && name !== void 0 ? name : '',
22
48
  remotes: [],
23
- shared: {
24
- react: {
25
- version: React.version,
26
- scope: 'chayns-api',
27
- lib: () => React
28
- },
29
- 'react-dom': {
30
- version: React.version,
31
- // intended, because react dom.version is not identical to package json react version (hash in version)
32
- scope: 'chayns-api',
33
- lib: () => ReactDOM
34
- }
35
- }
49
+ shared
36
50
  });
37
51
  };
@@ -1,3 +1,3 @@
1
1
  import { IChaynsReact } from '../types/IChaynsReact';
2
- export declare const useValuesSelector: <Result>(selector: (value: IChaynsReact["values"]) => Result) => any;
3
- export declare const useFunctionsSelector: <Result>(selector: (value: IChaynsReact["functions"]) => Result) => any;
2
+ export declare const useValuesSelector: <Result>(selector: (value: IChaynsReact["values"]) => Result) => Result;
3
+ export declare const useFunctionsSelector: <Result>(selector: (value: IChaynsReact["functions"]) => Result) => Result;
@@ -1,4 +1,5 @@
1
+ import { ChaynsReactValues } from '../types/IChaynsReact';
1
2
  /**
2
3
  * @category Hooks
3
4
  */
4
- export declare const useCurrentPage: () => any;
5
+ export declare const useCurrentPage: () => ChaynsReactValues["currentPage"];
@@ -2,4 +2,4 @@
2
2
  * @category Hooks
3
3
  * Returns customCallbackFunction
4
4
  */
5
- export declare const useCustomCallbackFunction: () => any;
5
+ export declare const useCustomCallbackFunction: () => (type: string, data: unknown) => Promise<unknown>;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * @category Hooks
3
3
  */
4
- export declare const useFunctions: () => any;
4
+ export declare const useFunctions: () => import("..").ChaynsReactFunctions;
@@ -1,4 +1,5 @@
1
+ import { ChaynsApiUser } from '../types/IChaynsReact';
1
2
  /**
2
3
  * @category Hooks
3
4
  */
4
- export declare const useUser: () => any;
5
+ export declare const useUser: () => ChaynsApiUser;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * @category Hooks
3
3
  */
4
- export declare const useValues: () => any;
4
+ export declare const useValues: () => import("..").ChaynsReactValues;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -31,7 +31,8 @@
31
31
  "dev": "npm link && npm run watch",
32
32
  "format": "prettier . --write",
33
33
  "lint": "eslint src",
34
- "prepublishOnly": "npm run build:cjs && npm run build:esm && npm run build:typescript"
34
+ "prepublishOnly": "npm run build:cjs && npm run build:esm && npm run build:typescript",
35
+ "preversion": "npm run build:typescript -- --noEmit --emitDeclarationOnly false"
35
36
  },
36
37
  "prettier": {
37
38
  "proseWrap": "always",