@aiszlab/relax 1.2.23 → 1.2.24
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/hooks/use-mount.mjs +2 -2
- package/dist/hooks/use-mounted.mjs +2 -2
- package/dist/hooks/use-refs.d.ts +1 -1
- package/dist/hooks/use-toggleable.d.ts +1 -1
- package/dist/hooks/use-update-effect.d.ts +1 -1
- package/dist/hooks/use-update-effect.mjs +2 -2
- package/dist/index.d.ts +1 -4
- package/dist/index.mjs +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/{utils → types}/thenable-effect-callback.d.ts +0 -5
- package/dist/utils/chain.d.ts +1 -1
- package/dist/utils/effect.d.ts +7 -0
- package/dist/utils/{thenable-effect-callback.mjs → effect.mjs} +3 -3
- package/dist/utils/to-array.d.ts +5 -0
- package/package.json +4 -3
- /package/dist/{utils → types}/arguments.d.ts +0 -0
- /package/dist/{utils/null-able.d.ts → types/nullable.d.ts} +0 -0
- /package/dist/{utils/partial-able.d.ts → types/partialable.d.ts} +0 -0
- /package/dist/{utils → types}/required-in.d.ts +0 -0
package/dist/hooks/use-mount.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useLayoutEffect } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { effect } from '../utils/effect.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @author murukal
|
|
@@ -9,7 +9,7 @@ import { callAsEffect } from '../utils/thenable-effect-callback.mjs';
|
|
|
9
9
|
*/
|
|
10
10
|
const useMount = (callable) => {
|
|
11
11
|
useLayoutEffect(() => {
|
|
12
|
-
return
|
|
12
|
+
return effect(callable);
|
|
13
13
|
}, []);
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { effect } from '../utils/effect.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @author murukal
|
|
@@ -9,7 +9,7 @@ import { callAsEffect } from '../utils/thenable-effect-callback.mjs';
|
|
|
9
9
|
*/
|
|
10
10
|
const useMounted = (callable) => {
|
|
11
11
|
useEffect(() => {
|
|
12
|
-
return
|
|
12
|
+
return effect(callable);
|
|
13
13
|
}, []);
|
|
14
14
|
};
|
|
15
15
|
|
package/dist/hooks/use-refs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MutableRefObject, type RefCallback } from 'react';
|
|
2
|
-
import type { Nullable } from '../
|
|
2
|
+
import type { Nullable } from '../types';
|
|
3
3
|
type Refable<T> = RefCallback<T> | MutableRefObject<T>;
|
|
4
4
|
export declare const useRefs: <T>(...refs: Nullable<Refable<Nullable<T>>>[]) => (trigger: T) => void;
|
|
5
5
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DependencyList } from 'react';
|
|
2
|
-
import { ThenableEffectCallback } from '../
|
|
2
|
+
import type { ThenableEffectCallback } from '../types';
|
|
3
3
|
export declare const useUpdateEffect: (callable: ThenableEffectCallback, deps?: DependencyList) => void;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useRef, useEffect } from 'react';
|
|
2
2
|
import { useMounted } from './use-mounted.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { effect } from '../utils/effect.mjs';
|
|
4
4
|
|
|
5
5
|
const useUpdateEffect = (callable, deps) => {
|
|
6
6
|
const isMounted = useRef(false);
|
|
7
7
|
useEffect(() => {
|
|
8
8
|
if (!isMounted.current)
|
|
9
9
|
return;
|
|
10
|
-
return
|
|
10
|
+
return effect(callable);
|
|
11
11
|
}, deps);
|
|
12
12
|
useMounted(() => {
|
|
13
13
|
isMounted.current = true;
|
package/dist/index.d.ts
CHANGED
|
@@ -41,10 +41,7 @@ export { isThenable } from './is/is-thenable';
|
|
|
41
41
|
* @description
|
|
42
42
|
* utils
|
|
43
43
|
*/
|
|
44
|
-
export {
|
|
45
|
-
export { type Partialable } from './utils/partial-able';
|
|
46
|
-
export { type RequiredIn } from './utils/required-in';
|
|
47
|
-
export { type ThenableEffectCallback, callAsEffect } from './utils/thenable-effect-callback';
|
|
44
|
+
export { effect } from './utils/effect';
|
|
48
45
|
export { unique, uniqueBy } from './utils/unique';
|
|
49
46
|
export { range } from './utils/range';
|
|
50
47
|
export { clamp } from './utils/clamp';
|
package/dist/index.mjs
CHANGED
|
@@ -29,7 +29,7 @@ export { isOverflow } from './is/is-overflow.mjs';
|
|
|
29
29
|
export { isStyleElement } from './is/is-style-element.mjs';
|
|
30
30
|
export { isFunction } from './is/is-function.mjs';
|
|
31
31
|
export { isThenable } from './is/is-thenable.mjs';
|
|
32
|
-
export {
|
|
32
|
+
export { effect } from './utils/effect.mjs';
|
|
33
33
|
export { unique, uniqueBy } from './utils/unique.mjs';
|
|
34
34
|
export { range } from './utils/range.mjs';
|
|
35
35
|
export { clamp } from './utils/clamp.mjs';
|
|
@@ -4,8 +4,3 @@ import type { EffectCallback } from 'react';
|
|
|
4
4
|
* thenable effect callback
|
|
5
5
|
*/
|
|
6
6
|
export type ThenableEffectCallback = () => ReturnType<EffectCallback> | PromiseLike<ReturnType<EffectCallback>>;
|
|
7
|
-
/**
|
|
8
|
-
* @description
|
|
9
|
-
* call thenable effect callback
|
|
10
|
-
*/
|
|
11
|
-
export declare const callAsEffect: (callable: ThenableEffectCallback) => ReturnType<EffectCallback>;
|
package/dist/utils/chain.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { isThenable } from '../is/is-thenable.mjs';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @description
|
|
5
|
-
* call thenable effect
|
|
5
|
+
* call thenable effect
|
|
6
6
|
*/
|
|
7
|
-
const
|
|
7
|
+
const effect = (callable) => {
|
|
8
8
|
const called = callable();
|
|
9
9
|
// if result is void
|
|
10
10
|
if (!called)
|
|
@@ -15,4 +15,4 @@ const callAsEffect = (callable) => {
|
|
|
15
15
|
return called;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export {
|
|
18
|
+
export { effect };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiszlab/relax",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.24",
|
|
4
4
|
"description": "react utils collection",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"./dom": {
|
|
12
12
|
"types": "./dist/dom/index.d.ts",
|
|
13
13
|
"default": "./dist/dom/index.mjs"
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
|
+
"./types": "./dist/types/index.d.ts"
|
|
15
16
|
},
|
|
16
17
|
"scripts": {
|
|
17
18
|
"dev": "rollup -c -w",
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"@types/react": "^18",
|
|
34
35
|
"@types/react-dom": "^18",
|
|
35
36
|
"@types/react-is": "^18",
|
|
36
|
-
"rollup": "^
|
|
37
|
+
"rollup": "^4.12.0",
|
|
37
38
|
"typescript": "^5.1.3"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|