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.
- package/dist/cjs/hooks/context.js +5 -2
- package/dist/esm/hooks/context.js +6 -3
- package/dist/types/hooks/context.d.ts +2 -2
- package/dist/types/hooks/useCurrentPage.d.ts +1 -4
- package/dist/types/hooks/useCustomCallbackFunction.d.ts +1 -1
- package/dist/types/hooks/useFunctions.d.ts +1 -1
- package/dist/types/hooks/useUser.d.ts +1 -1
- package/dist/types/hooks/useValues.d.ts +1 -1
- package/package.json +2 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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) =>
|
|
3
|
-
export declare const useFunctionsSelector: <Result>(selector: (value: IChaynsReact["functions"]) => 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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chayns-api",
|
|
3
|
-
"version": "2.0.9-
|
|
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": {
|