@chhsiao1981/use-thunk 9.0.0 → 9.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chhsiao1981/use-thunk",
3
- "version": "9.0.0",
3
+ "version": "9.0.2",
4
4
  "type": "module",
5
5
  "description": "A framework easily using useThunk to manage the data-state.",
6
6
  "homepage": "https://github.com/chhsiao1981/use-thunk",
package/src/index.ts CHANGED
@@ -15,10 +15,11 @@ import { setData } from './setData'
15
15
  import { getNode, getRootID, getState } from './states'
16
16
  import type { ClassState, NodeMeta, NodeState, NodeStateMap, State } from './stateTypes'
17
17
  import type { ThunkModule, ThunkModuleToFunc } from './thunk'
18
- import useThunk from './useThunk'
18
+ import useThunk, { type UseThunk } from './useThunk'
19
19
 
20
20
  export {
21
21
  useThunk,
22
+ type UseThunk,
22
23
  // StateType, // XXX for global state
23
24
  type State,
24
25
  type NodeState,
package/src/useThunk.ts CHANGED
@@ -7,6 +7,8 @@ import type { ThunkModule, ThunkModuleFunc } from './thunk'
7
7
  import { DEFAULT_THUNK_MODULE_FUNC_MAP } from './thunkModuleFuncMap'
8
8
  import useThunkReducer from './thunkReducer'
9
9
 
10
+ export type UseThunk<S extends State, R extends ThunkModuleFunc<S>> = [ClassState<S>, DispatchFuncMap<S, R>]
11
+
10
12
  /**********
11
13
  * useThunk
12
14
  **********/
@@ -14,7 +16,7 @@ export default <S extends State, R extends ThunkModuleFunc<S>>(
14
16
  theDo: ThunkModule<S, R>,
15
17
  // biome-ignore lint/suspicious/noExplicitAny: params can by any types.
16
18
  init?: (...params: any[]) => S,
17
- ): [ClassState<S>, DispatchFuncMap<S, R>] => {
19
+ ): UseThunk<S, R> => {
18
20
  const { myClass } = theDo
19
21
 
20
22
  // 1. dispatchMapByClass
package/types/index.d.ts CHANGED
@@ -15,5 +15,5 @@ import { setData } from './setData';
15
15
  import { getNode, getRootID, getState } from './states';
16
16
  import type { ClassState, NodeMeta, NodeState, NodeStateMap, State } from './stateTypes';
17
17
  import type { ThunkModule, ThunkModuleToFunc } from './thunk';
18
- import useThunk from './useThunk';
19
- export { useThunk, type State, type NodeState, type NodeMeta, type NodeStateMap, type ClassState, type GetClassState, type Thunk, type ThunkModule, type ThunkModuleToFunc, type Dispatch, type DispatchFuncMap, getRootID, getNode, getState, getChildIDs, getChildID, getLinkIDs, getLinkID, init, type InitParams, setData, remove, addChild, removeChild, addLink, removeLink, type AddRelationAction, type RemoveRelationAction, genUUID, };
18
+ import useThunk, { type UseThunk } from './useThunk';
19
+ export { useThunk, type UseThunk, type State, type NodeState, type NodeMeta, type NodeStateMap, type ClassState, type GetClassState, type Thunk, type ThunkModule, type ThunkModuleToFunc, type Dispatch, type DispatchFuncMap, getRootID, getNode, getState, getChildIDs, getChildID, getLinkIDs, getLinkID, init, type InitParams, setData, remove, addChild, removeChild, addLink, removeLink, type AddRelationAction, type RemoveRelationAction, genUUID, };
@@ -1,8 +1,9 @@
1
1
  import type { DispatchFuncMap } from './dispatchFuncMap';
2
2
  import type { ClassState, State } from './stateTypes';
3
3
  import type { ThunkModule, ThunkModuleFunc } from './thunk';
4
+ export type UseThunk<S extends State, R extends ThunkModuleFunc<S>> = [ClassState<S>, DispatchFuncMap<S, R>];
4
5
  /**********
5
6
  * useThunk
6
7
  **********/
7
- declare const _default: <S extends State, R extends ThunkModuleFunc<S>>(theDo: ThunkModule<S, R>, init?: (...params: any[]) => S) => [ClassState<S>, DispatchFuncMap<S, R>];
8
+ declare const _default: <S extends State, R extends ThunkModuleFunc<S>>(theDo: ThunkModule<S, R>, init?: (...params: any[]) => S) => UseThunk<S, R>;
8
9
  export default _default;