chayns-api 2.0.9-0 → 2.0.9-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.
@@ -5,13 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useValuesSelector = exports.useFunctionsSelector = void 0;
7
7
  var _react = require("react");
8
+ var _shim = require("use-sync-external-store/shim");
8
9
  var _ChaynsContext = require("../components/ChaynsContext");
9
10
  const useValuesSelector = selector => {
10
11
  const store = (0, _react.useContext)(_ChaynsContext.ChaynsContext);
11
12
  if (!store) {
12
13
  throw new Error('Could not find chayns context. Did you forget to add ChaynsProvider?');
13
14
  }
14
- return (0, _react.useSyncExternalStore)(store.subscribe, () => selector(store.values));
15
+ const getSnapshot = () => selector(store.values);
16
+ return (0, _shim.useSyncExternalStore)(store.subscribe, getSnapshot, getSnapshot);
15
17
  };
16
18
  exports.useValuesSelector = useValuesSelector;
17
19
  const useFunctionsSelector = selector => {
@@ -19,6 +21,7 @@ const useFunctionsSelector = selector => {
19
21
  if (!store) {
20
22
  throw new Error('Could not find chayns context. Did you forget to add ChaynsProvider?');
21
23
  }
22
- return (0, _react.useSyncExternalStore)(store.subscribe, () => selector(store.functions));
24
+ const getSnapshot = () => selector(store.functions);
25
+ return (0, _shim.useSyncExternalStore)(store.subscribe, getSnapshot, getSnapshot);
23
26
  };
24
27
  exports.useFunctionsSelector = useFunctionsSelector;
@@ -1,16 +1,19 @@
1
- import { useContext, useSyncExternalStore } from 'react';
1
+ import { useContext } from 'react';
2
+ import { useSyncExternalStore } from 'use-sync-external-store/shim';
2
3
  import { ChaynsContext } from '../components/ChaynsContext';
3
4
  export const useValuesSelector = selector => {
4
5
  const store = useContext(ChaynsContext);
5
6
  if (!store) {
6
7
  throw new Error('Could not find chayns context. Did you forget to add ChaynsProvider?');
7
8
  }
8
- return useSyncExternalStore(store.subscribe, () => selector(store.values));
9
+ const getSnapshot = () => selector(store.values);
10
+ return useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
9
11
  };
10
12
  export const useFunctionsSelector = selector => {
11
13
  const store = useContext(ChaynsContext);
12
14
  if (!store) {
13
15
  throw new Error('Could not find chayns context. Did you forget to add ChaynsProvider?');
14
16
  }
15
- return useSyncExternalStore(store.subscribe, () => selector(store.functions));
17
+ const getSnapshot = () => selector(store.functions);
18
+ return useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
16
19
  };
@@ -1,3 +1,3 @@
1
1
  import { IChaynsReact } from '../types/IChaynsReact';
2
- export declare const useValuesSelector: <Result>(selector: (value: IChaynsReact["values"]) => Result) => Result;
3
- export declare const useFunctionsSelector: <Result>(selector: (value: IChaynsReact["functions"]) => Result) => Result;
2
+ export declare const useValuesSelector: <Result>(selector: (value: IChaynsReact["values"]) => Result) => any;
3
+ export declare const useFunctionsSelector: <Result>(selector: (value: IChaynsReact["functions"]) => Result) => any;
@@ -1,7 +1,4 @@
1
1
  /**
2
2
  * @category Hooks
3
3
  */
4
- export declare const useCurrentPage: () => {
5
- id: number;
6
- siteId: string;
7
- };
4
+ export declare const useCurrentPage: () => any;
@@ -2,4 +2,4 @@
2
2
  * @category Hooks
3
3
  * Returns customCallbackFunction
4
4
  */
5
- export declare const useCustomCallbackFunction: () => (type: string, data: unknown) => Promise<unknown>;
5
+ export declare const useCustomCallbackFunction: () => any;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * @category Hooks
3
3
  */
4
- export declare const useFunctions: () => import("..").ChaynsReactFunctions;
4
+ export declare const useFunctions: () => any;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * @category Hooks
3
3
  */
4
- export declare const useUser: () => {};
4
+ export declare const useUser: () => any;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * @category Hooks
3
3
  */
4
- export declare const useValues: () => import("..").ChaynsReactValues;
4
+ export declare const useValues: () => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "2.0.9-0",
3
+ "version": "2.0.9-1",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -53,6 +53,7 @@
53
53
  "semaphore-async-await": "^1.5.1",
54
54
  "semver": "^7.6.0",
55
55
  "ua-parser-js": "^1.0.38",
56
+ "use-sync-external-store": "^1.4.0",
56
57
  "util": "^0.12.5"
57
58
  },
58
59
  "devDependencies": {