@chhsiao1981/use-thunk 9.0.1 → 9.0.3

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.1",
3
+ "version": "9.0.3",
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/addChild.ts CHANGED
@@ -8,6 +8,9 @@ export const addChild = (myID: string, child: NodeMeta): AddRelationAction => ({
8
8
  relaton: child,
9
9
  })
10
10
 
11
- export const reduceAddChild = <S extends State>(state: ClassState<S>, action: AddRelationAction): ClassState<S> => {
12
- return reduceAddRelation(state, action, Relation.CHILDREN)
11
+ export const reduceAddChild = <S extends State>(
12
+ classState: ClassState<S>,
13
+ action: AddRelationAction,
14
+ ): ClassState<S> => {
15
+ return reduceAddRelation(classState, action, Relation.CHILDREN)
13
16
  }
package/src/addLink.ts CHANGED
@@ -22,6 +22,6 @@ const addLinkCore = (myID: string, link: NodeMeta): AddRelationAction => ({
22
22
  relaton: link,
23
23
  })
24
24
 
25
- export const reduceAddLink = <S extends State>(state: ClassState<S>, action: AddRelationAction): ClassState<S> => {
26
- return reduceAddRelation(state, action, Relation.LINKS)
25
+ export const reduceAddLink = <S extends State>(classState: ClassState<S>, action: AddRelationAction): ClassState<S> => {
26
+ return reduceAddRelation(classState, action, Relation.LINKS)
27
27
  }
@@ -6,27 +6,27 @@ export interface AddRelationAction extends BaseAction {
6
6
  }
7
7
 
8
8
  export const reduceAddRelation = <S extends State>(
9
- state: ClassState<S>,
9
+ classState: ClassState<S>,
10
10
  action: AddRelationAction,
11
11
  relationName: Relation,
12
12
  ): ClassState<S> => {
13
13
  const { myID, relaton: relation } = action
14
- const me = state.nodes[myID]
15
- if (!me) {
16
- return state
14
+ const myNode = classState.nodes[myID]
15
+ if (!myNode) {
16
+ return classState
17
17
  }
18
18
 
19
19
  const { theClass, id: theID, do: theDo } = relation
20
20
 
21
- const relations = me[relationName] ?? {}
21
+ const relations = myNode[relationName] ?? {}
22
22
  const relationsByClass = relations[theClass] ?? { list: [] }
23
23
  const relationIDs = relationsByClass.list ?? []
24
24
  const newIDs = theID ? relationIDs.concat([theID]) : relationIDs
25
25
 
26
- const newRelations = Object.assign({}, me[relationName], { [theClass]: { list: newIDs, do: theDo } })
27
- const newMe = Object.assign({}, me, { [relationName]: newRelations })
28
- const newNodes = Object.assign({}, state.nodes, { [myID]: newMe })
29
- const newState = Object.assign({}, state, { nodes: newNodes })
26
+ const newRelations = Object.assign({}, myNode[relationName], { [theClass]: { list: newIDs, do: theDo } })
27
+ const newMyNode = Object.assign({}, myNode, { [relationName]: newRelations })
28
+ const newNodes = Object.assign({}, classState.nodes, { [myID]: newMyNode })
29
+ const newClassState = Object.assign({}, classState, { nodes: newNodes })
30
30
 
31
- return newState
31
+ return newClassState
32
32
  }
@@ -5,20 +5,20 @@ import type { Reducer } from './reducer'
5
5
  import type { ClassState, State } from './stateTypes'
6
6
 
7
7
  export const createReducer = <S extends State>(reduceMap?: ReduceMap<S>): Reducer<S> => {
8
- return (state: ClassState<S>, action: BaseAction): ClassState<S> => {
8
+ return (classState: ClassState<S>, action: BaseAction): ClassState<S> => {
9
9
  if (!action) {
10
- return state
10
+ return classState
11
11
  }
12
12
 
13
13
  if (reduceMap?.[action.type]) {
14
- return reduceMap[action.type](state, action)
14
+ return reduceMap[action.type](classState, action)
15
15
  }
16
16
 
17
17
  const defaultReduceMap = DEFAULT_REDUCE_MAP<S>()
18
18
  if (defaultReduceMap?.[action.type]) {
19
- return defaultReduceMap[action.type](state, action)
19
+ return defaultReduceMap[action.type](classState, action)
20
20
  }
21
21
 
22
- return state
22
+ return classState
23
23
  }
24
24
  }
@@ -1,23 +1,27 @@
1
1
  import { type NodeState, Relation, type State } from './stateTypes'
2
2
 
3
- export const getChildIDs = <S extends State>(me: NodeState<S>, childClass: string): string[] => {
4
- return getRelationIDs(me, childClass, Relation.CHILDREN)
3
+ export const getChildIDs = <S extends State>(myNode: NodeState<S>, childClass: string): string[] => {
4
+ return getRelationIDs(myNode, childClass, Relation.CHILDREN)
5
5
  }
6
6
 
7
- export const getChildID = <S extends State>(me: NodeState<S>, childClass: string): string => {
8
- return getRelationID(me, childClass, Relation.CHILDREN)
7
+ export const getChildID = <S extends State>(myNode: NodeState<S>, childClass: string): string => {
8
+ return getRelationID(myNode, childClass, Relation.CHILDREN)
9
9
  }
10
10
 
11
- export const getLinkIDs = <S extends State>(me: NodeState<S>, linkClass: string): string[] => {
12
- return getRelationIDs(me, linkClass, Relation.LINKS)
11
+ export const getLinkIDs = <S extends State>(myNode: NodeState<S>, linkClass: string): string[] => {
12
+ return getRelationIDs(myNode, linkClass, Relation.LINKS)
13
13
  }
14
14
 
15
- export const getLinkID = <S extends State>(me: NodeState<S>, linkClass: string): string => {
16
- return getRelationID(me, linkClass, Relation.LINKS)
15
+ export const getLinkID = <S extends State>(myNode: NodeState<S>, linkClass: string): string => {
16
+ return getRelationID(myNode, linkClass, Relation.LINKS)
17
17
  }
18
18
 
19
- const getRelationIDs = <S extends State>(me: NodeState<S>, relationClass: string, relationName: Relation): string[] => {
20
- const relations = me[relationName]
19
+ const getRelationIDs = <S extends State>(
20
+ myNode: NodeState<S>,
21
+ relationClass: string,
22
+ relationName: Relation,
23
+ ): string[] => {
24
+ const relations = myNode[relationName]
21
25
  if (!relations) {
22
26
  return []
23
27
  }
@@ -29,7 +33,11 @@ const getRelationIDs = <S extends State>(me: NodeState<S>, relationClass: string
29
33
  return relationsByClass.list
30
34
  }
31
35
 
32
- const getRelationID = <S extends State>(me: NodeState<S>, relationClass: string, relationName: Relation): string => {
33
- const ids = getRelationIDs(me, relationClass, relationName)
36
+ const getRelationID = <S extends State>(
37
+ myNode: NodeState<S>,
38
+ relationClass: string,
39
+ relationName: Relation,
40
+ ): string => {
41
+ const ids = getRelationIDs(myNode, relationClass, relationName)
34
42
  return ids.length ? ids[0] : ''
35
43
  }
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/init.ts CHANGED
@@ -62,21 +62,21 @@ const initCore = <S extends State>(
62
62
  }
63
63
  }
64
64
 
65
- export const reduceInit = <S extends State>(state: ClassState<S>, action: InitAction<S>): ClassState<S> => {
65
+ export const reduceInit = <S extends State>(classState: ClassState<S>, action: InitAction<S>): ClassState<S> => {
66
66
  const { myID, parentID, doParent, parentClass, state: initState } = action
67
67
 
68
- const me: NodeState<S> = {
68
+ const myNode: NodeState<S> = {
69
69
  id: myID,
70
70
  state: initState,
71
71
  [Relation.CHILDREN]: {},
72
72
  [Relation.LINKS]: {},
73
73
  }
74
74
  if (parentID && doParent) {
75
- me[PARENT] = { id: parentID, do: doParent, theClass: parentClass ?? '' }
75
+ myNode[PARENT] = { id: parentID, do: doParent, theClass: parentClass ?? '' }
76
76
  }
77
77
 
78
- const newNodes: NodeStateMap<S> = Object.assign({}, state.nodes, { [myID]: me })
79
- const newState: ClassState<S> = Object.assign({}, state, { nodes: newNodes })
78
+ const newNodes: NodeStateMap<S> = Object.assign({}, classState.nodes, { [myID]: myNode })
79
+ const newClassState: ClassState<S> = Object.assign({}, classState, { nodes: newNodes })
80
80
 
81
- return newState
81
+ return newClassState
82
82
  }
package/src/reducer.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Reducer as rReducer } from 'react'
2
- import type { ActionFunc, BaseAction } from './action'
2
+ import type { BaseAction } from './action'
3
3
  import type { ClassState, State } from './stateTypes'
4
4
 
5
5
  // Reducer
package/src/remove.ts CHANGED
@@ -51,23 +51,23 @@ const removeCore = (myID: string): BaseAction => ({
51
51
  type: REMOVE,
52
52
  })
53
53
 
54
- export const reduceRemove = <S extends State>(state: ClassState<S>, action: BaseAction): ClassState<S> => {
54
+ export const reduceRemove = <S extends State>(classState: ClassState<S>, action: BaseAction): ClassState<S> => {
55
55
  const { myID } = action
56
56
 
57
- const me = state.nodes[myID]
58
- if (!me) {
59
- return state
57
+ const myNode = classState.nodes[myID]
58
+ if (!myNode) {
59
+ return classState
60
60
  }
61
61
 
62
- const newNodes = Object.keys(state.nodes)
62
+ const newNodes = Object.keys(classState.nodes)
63
63
  .filter((each) => each !== myID)
64
64
  .reduce((r: NodeStateMap<S>, x) => {
65
- r[x] = state.nodes[x]
65
+ r[x] = classState.nodes[x]
66
66
  return r
67
67
  }, {})
68
68
 
69
69
  // root
70
- const newState = Object.assign({}, state, { nodes: newNodes })
70
+ const newState = Object.assign({}, classState, { nodes: newNodes })
71
71
  if (newState.root === myID) {
72
72
  newState.root = null
73
73
  }
@@ -37,10 +37,10 @@ const removeChildCore = (myID: string, childID: string, childClass: string): Rem
37
37
  })
38
38
 
39
39
  export const reduceRemoveChild = <S extends State>(
40
- state: ClassState<S>,
40
+ classState: ClassState<S>,
41
41
  action: RemoveRelationAction,
42
42
  ): ClassState<S> => {
43
43
  const { myID, relationID, relationClass } = action
44
44
 
45
- return reduceRemoveRelation(state, myID, relationID, relationClass, Relation.CHILDREN)
45
+ return reduceRemoveRelation(classState, myID, relationID, relationClass, Relation.CHILDREN)
46
46
  }
package/src/removeLink.ts CHANGED
@@ -38,10 +38,10 @@ const removeLinkCore = (myID: string, linkID: string, linkClass: string): Remove
38
38
  })
39
39
 
40
40
  export const reduceRemoveLink = <S extends State>(
41
- state: ClassState<S>,
41
+ classState: ClassState<S>,
42
42
  action: RemoveRelationAction,
43
43
  ): ClassState<S> => {
44
44
  const { myID, relationID, relationClass } = action
45
45
 
46
- return reduceRemoveRelation(state, myID, relationID, relationClass, Relation.LINKS)
46
+ return reduceRemoveRelation(classState, myID, relationID, relationClass, Relation.LINKS)
47
47
  }
@@ -22,14 +22,14 @@ export const removeRelation = <S extends State>(
22
22
  removeRelationCore: RemoveRelationCore,
23
23
  relationName: Relation,
24
24
  ) => {
25
- const state = getClassState()
25
+ const classState = getClassState()
26
26
 
27
- const me = state.nodes[myID]
28
- if (!me) {
27
+ const myNode = classState.nodes[myID]
28
+ if (!myNode) {
29
29
  return
30
30
  }
31
31
 
32
- const relation = me[relationName]
32
+ const relation = myNode[relationName]
33
33
  if (!relation) {
34
34
  return
35
35
  }
@@ -49,24 +49,24 @@ export const removeRelation = <S extends State>(
49
49
  }
50
50
 
51
51
  export const reduceRemoveRelation = <S extends State>(
52
- state: ClassState<S>,
52
+ classState: ClassState<S>,
53
53
  myID: string,
54
54
  relationID: string,
55
55
  relationClass: string,
56
56
  relationName: Relation.LINKS | Relation.CHILDREN,
57
57
  ): ClassState<S> => {
58
- const me = state.nodes[myID]
59
- if (!me) return state
58
+ const myNode = classState.nodes[myID]
59
+ if (!myNode) return classState
60
60
 
61
- const relation = me[relationName]
62
- if (!relation) return state
61
+ const relation = myNode[relationName]
62
+ if (!relation) return classState
63
63
 
64
64
  const relationByClass = relation[relationClass]
65
- if (!relationByClass) return state
65
+ if (!relationByClass) return classState
66
66
 
67
67
  const relationIDs = relationByClass.list || []
68
68
  const newIDs = relationIDs.filter((eachID: string) => eachID !== relationID)
69
- if (relationIDs.length === newIDs.length) return state
69
+ if (relationIDs.length === newIDs.length) return classState
70
70
 
71
71
  const newRelation = Object.assign({}, relation)
72
72
  if (newIDs.length === 0) {
@@ -76,9 +76,9 @@ export const reduceRemoveRelation = <S extends State>(
76
76
  newRelation[relationClass] = newRelationByClass
77
77
  }
78
78
 
79
- const newMe = Object.assign({}, me, { [relationName]: newRelation })
80
- const newNodes = Object.assign({}, state.nodes, { [myID]: newMe })
81
- const newState = Object.assign({}, state, { nodes: newNodes })
79
+ const newMyNode = Object.assign({}, myNode, { [relationName]: newRelation })
80
+ const newNodes = Object.assign({}, classState.nodes, { [myID]: newMyNode })
81
+ const newClassState = Object.assign({}, classState, { nodes: newNodes })
82
82
 
83
- return newState
83
+ return newClassState
84
84
  }
package/src/setData.ts CHANGED
@@ -8,16 +8,16 @@ export const setData = <S extends State>(myID: string, data: S): BaseAction => (
8
8
  data,
9
9
  })
10
10
 
11
- export const reduceSetData = <S extends State>(state: ClassState<S>, action: BaseAction): ClassState<S> => {
11
+ export const reduceSetData = <S extends State>(classState: ClassState<S>, action: BaseAction): ClassState<S> => {
12
12
  const { myID, data } = action
13
13
 
14
- const me = state.nodes[myID]
15
- if (!me) return state
14
+ const myNode = classState.nodes[myID]
15
+ if (!myNode) return classState
16
16
 
17
- const newMyState = Object.assign({}, me.state, data)
18
- const newMe = Object.assign({}, me, { state: newMyState })
19
- const newNodes = Object.assign({}, state.nodes, { [myID]: newMe })
20
- const newState = Object.assign({}, state, { nodes: newNodes })
17
+ const newMyState = Object.assign({}, myNode.state, data)
18
+ const newMyNode = Object.assign({}, myNode, { state: newMyState })
19
+ const newNodes = Object.assign({}, classState.nodes, { [myID]: newMyNode })
20
+ const newClassState = Object.assign({}, classState, { nodes: newNodes })
21
21
 
22
- return newState
22
+ return newClassState
23
23
  }
package/src/setRoot.ts CHANGED
@@ -7,8 +7,8 @@ export const setRoot = (myID: string): BaseAction => ({
7
7
  type: SET_ROOT,
8
8
  })
9
9
 
10
- export const reduceSetRoot = <S extends State>(state: ClassState<S>, action: BaseAction): ClassState<S> => {
10
+ export const reduceSetRoot = <S extends State>(classState: ClassState<S>, action: BaseAction): ClassState<S> => {
11
11
  const { myID } = action
12
12
 
13
- return Object.assign({}, state, { root: myID })
13
+ return Object.assign({}, classState, { root: myID })
14
14
  }
package/src/stateTypes.ts CHANGED
@@ -8,6 +8,9 @@ export enum Relation {
8
8
  LINKS = '_links',
9
9
  }
10
10
 
11
+ // XXX PARENT is considered as a special relation
12
+ // and is not part of the enum Relation.
13
+ // The relation-ops does not apply to PARENT.
11
14
  export const PARENT = '_parent'
12
15
 
13
16
  //State
package/src/states.ts CHANGED
@@ -1,43 +1,43 @@
1
1
  import type { ClassState, NodeState, State } from './stateTypes'
2
2
 
3
- export const getRootNode = <S extends State>(state: ClassState<S>): NodeState<S> | null => {
4
- const root = state.root
3
+ const getRootNode = <S extends State>(classState: ClassState<S>): NodeState<S> | null => {
4
+ const root = classState.root
5
5
  if (!root) {
6
6
  return null
7
7
  }
8
- return state.nodes[root] || null
8
+ return classState.nodes[root] || null
9
9
  }
10
10
 
11
- export const getRootID = <S extends State>(state: ClassState<S>): string => {
12
- return state.root ?? ''
11
+ export const getRootID = <S extends State>(classState: ClassState<S>): string => {
12
+ return classState.root ?? ''
13
13
  }
14
14
 
15
- export const getRoot = <S extends State>(state: ClassState<S>): S | null => {
16
- const root = state.root
15
+ const getRoot = <S extends State>(classState: ClassState<S>): S | null => {
16
+ const root = classState.root
17
17
  if (!root) {
18
18
  return null
19
19
  }
20
- const me = state.nodes[root]
20
+ const me = classState.nodes[root]
21
21
  if (!me) {
22
22
  return null
23
23
  }
24
24
  return me.state
25
25
  }
26
26
 
27
- export const getNode = <S extends State>(state: ClassState<S>, myID?: string): NodeState<S> | null => {
27
+ export const getNode = <S extends State>(classState: ClassState<S>, myID?: string): NodeState<S> | null => {
28
28
  if (!myID) {
29
- return getRootNode(state)
29
+ return getRootNode(classState)
30
30
  }
31
31
 
32
- return state.nodes[myID] || null
32
+ return classState.nodes[myID] || null
33
33
  }
34
34
 
35
- export const getState = <S extends State>(state: ClassState<S>, myID?: string): S | null => {
35
+ export const getState = <S extends State>(classState: ClassState<S>, myID?: string): S | null => {
36
36
  if (!myID) {
37
- return getRoot(state)
37
+ return getRoot(classState)
38
38
  }
39
39
 
40
- const me = state.nodes[myID]
40
+ const me = classState.nodes[myID]
41
41
  if (!me) {
42
42
  return null
43
43
  }
package/src/useThunk.ts CHANGED
@@ -2,7 +2,7 @@ import { useRef, useState } from 'react'
2
2
  import type { ActionFunc } from './action'
3
3
  import { createReducer } from './createReducer'
4
4
  import type { DispatchFuncMap, DispatchFuncMapByClassMap, RefDispatchFuncMapByClassMap } from './dispatchFuncMap'
5
- import type { ClassState, NodeStateMap, State, StateType } from './stateTypes'
5
+ import type { ClassState, NodeStateMap, State } from './stateTypes'
6
6
  import type { ThunkModule, ThunkModuleFunc } from './thunk'
7
7
  import { DEFAULT_THUNK_MODULE_FUNC_MAP } from './thunkModuleFuncMap'
8
8
  import useThunkReducer from './thunkReducer'
@@ -2,4 +2,4 @@ import { type AddRelationAction } from './addRelation';
2
2
  import { type ClassState, type NodeMeta, type State } from './stateTypes';
3
3
  export declare const ADD_CHILD = "@chhsiao1981/use-thunk/ADD_CHILD";
4
4
  export declare const addChild: (myID: string, child: NodeMeta) => AddRelationAction;
5
- export declare const reduceAddChild: <S extends State>(state: ClassState<S>, action: AddRelationAction) => ClassState<S>;
5
+ export declare const reduceAddChild: <S extends State>(classState: ClassState<S>, action: AddRelationAction) => ClassState<S>;
@@ -3,4 +3,4 @@ import { type AddRelationAction } from './addRelation';
3
3
  import { type ClassState, type NodeMeta, type State } from './stateTypes';
4
4
  export declare const addLink: <S extends State>(myID: string, link: NodeMeta, isFromLink?: boolean) => Thunk<S>;
5
5
  export declare const ADD_LINK = "@chhsiao1981/use-thunk/ADD_LINK";
6
- export declare const reduceAddLink: <S extends State>(state: ClassState<S>, action: AddRelationAction) => ClassState<S>;
6
+ export declare const reduceAddLink: <S extends State>(classState: ClassState<S>, action: AddRelationAction) => ClassState<S>;
@@ -3,4 +3,4 @@ import type { ClassState, NodeMeta, Relation, State } from './stateTypes';
3
3
  export interface AddRelationAction extends BaseAction {
4
4
  relaton: NodeMeta;
5
5
  }
6
- export declare const reduceAddRelation: <S extends State>(state: ClassState<S>, action: AddRelationAction, relationName: Relation) => ClassState<S>;
6
+ export declare const reduceAddRelation: <S extends State>(classState: ClassState<S>, action: AddRelationAction, relationName: Relation) => ClassState<S>;
@@ -1,5 +1,5 @@
1
1
  import { type NodeState, type State } from './stateTypes';
2
- export declare const getChildIDs: <S extends State>(me: NodeState<S>, childClass: string) => string[];
3
- export declare const getChildID: <S extends State>(me: NodeState<S>, childClass: string) => string;
4
- export declare const getLinkIDs: <S extends State>(me: NodeState<S>, linkClass: string) => string[];
5
- export declare const getLinkID: <S extends State>(me: NodeState<S>, linkClass: string) => string;
2
+ export declare const getChildIDs: <S extends State>(myNode: NodeState<S>, childClass: string) => string[];
3
+ export declare const getChildID: <S extends State>(myNode: NodeState<S>, childClass: string) => string;
4
+ export declare const getLinkIDs: <S extends State>(myNode: NodeState<S>, linkClass: string) => string[];
5
+ export declare const getLinkID: <S extends State>(myNode: NodeState<S>, linkClass: string) => string;
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, };
package/types/init.d.ts CHANGED
@@ -15,5 +15,5 @@ interface InitAction<S extends State> extends BaseAction {
15
15
  state: S;
16
16
  }
17
17
  export declare const INIT = "@chhsiao1981/use-thunk/INIT";
18
- export declare const reduceInit: <S extends State>(state: ClassState<S>, action: InitAction<S>) => ClassState<S>;
18
+ export declare const reduceInit: <S extends State>(classState: ClassState<S>, action: InitAction<S>) => ClassState<S>;
19
19
  export {};
package/types/remove.d.ts CHANGED
@@ -2,4 +2,4 @@ import type { BaseAction, Thunk } from './action';
2
2
  import { type ClassState, type State } from './stateTypes';
3
3
  export declare const remove: <S extends State>(myID: string, isFromParent?: boolean) => Thunk<S>;
4
4
  export declare const REMOVE = "@chhsiao1981/use-thunk/REMOVE";
5
- export declare const reduceRemove: <S extends State>(state: ClassState<S>, action: BaseAction) => ClassState<S>;
5
+ export declare const reduceRemove: <S extends State>(classState: ClassState<S>, action: BaseAction) => ClassState<S>;
@@ -6,4 +6,4 @@ import { type ClassState, type State } from './stateTypes';
6
6
  */
7
7
  export declare const removeChild: <S extends State>(myID: string, childID: string, childClass: string, isFromChild?: boolean) => Thunk<S>;
8
8
  export declare const REMOVE_CHILD = "@chhsiao1981/use-thunk/REMOVE_CHILD";
9
- export declare const reduceRemoveChild: <S extends State>(state: ClassState<S>, action: RemoveRelationAction) => ClassState<S>;
9
+ export declare const reduceRemoveChild: <S extends State>(classState: ClassState<S>, action: RemoveRelationAction) => ClassState<S>;
@@ -6,4 +6,4 @@ import { type ClassState, type State } from './stateTypes';
6
6
  */
7
7
  export declare const removeLink: <S extends State>(myID: string, linkID: string, linkClass: string, isFromLink?: boolean) => Thunk<S>;
8
8
  export declare const REMOVE_LINK = "@chhsiao1981/use-thunk/REMOVE_LINK";
9
- export declare const reduceRemoveLink: <S extends State>(state: ClassState<S>, action: RemoveRelationAction) => ClassState<S>;
9
+ export declare const reduceRemoveLink: <S extends State>(classState: ClassState<S>, action: RemoveRelationAction) => ClassState<S>;
@@ -8,5 +8,5 @@ export interface RemoveRelationAction extends BaseAction {
8
8
  type RelationRemove = (theDo: DispatchFuncMap) => void;
9
9
  type RemoveRelationCore = (myID: string, relationID: string, relationClass: string) => BaseAction;
10
10
  export declare const removeRelation: <S extends State>(dispatch: Dispatch<S>, getClassState: GetClassState<S>, myID: string, relationID: string, relationClass: string, isFromRelation: boolean, relationRemove: RelationRemove, removeRelationCore: RemoveRelationCore, relationName: Relation) => void;
11
- export declare const reduceRemoveRelation: <S extends State>(state: ClassState<S>, myID: string, relationID: string, relationClass: string, relationName: Relation.LINKS | Relation.CHILDREN) => ClassState<S>;
11
+ export declare const reduceRemoveRelation: <S extends State>(classState: ClassState<S>, myID: string, relationID: string, relationClass: string, relationName: Relation.LINKS | Relation.CHILDREN) => ClassState<S>;
12
12
  export {};
@@ -2,4 +2,4 @@ import type { BaseAction } from './action';
2
2
  import type { ClassState, State } from './stateTypes';
3
3
  export declare const SET_DATA = "@chhsiao1981/use-thunk/SET_DATA";
4
4
  export declare const setData: <S extends State>(myID: string, data: S) => BaseAction;
5
- export declare const reduceSetData: <S extends State>(state: ClassState<S>, action: BaseAction) => ClassState<S>;
5
+ export declare const reduceSetData: <S extends State>(classState: ClassState<S>, action: BaseAction) => ClassState<S>;
@@ -2,4 +2,4 @@ import type { BaseAction } from './action';
2
2
  import type { ClassState, State } from './stateTypes';
3
3
  export declare const SET_ROOT = "@chhsiao1981/use-thunk/SET_ROOT";
4
4
  export declare const setRoot: (myID: string) => BaseAction;
5
- export declare const reduceSetRoot: <S extends State>(state: ClassState<S>, action: BaseAction) => ClassState<S>;
5
+ export declare const reduceSetRoot: <S extends State>(classState: ClassState<S>, action: BaseAction) => ClassState<S>;
package/types/states.d.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  import type { ClassState, NodeState, State } from './stateTypes';
2
- export declare const getRootNode: <S extends State>(state: ClassState<S>) => NodeState<S> | null;
3
- export declare const getRootID: <S extends State>(state: ClassState<S>) => string;
4
- export declare const getRoot: <S extends State>(state: ClassState<S>) => S | null;
5
- export declare const getNode: <S extends State>(state: ClassState<S>, myID?: string) => NodeState<S> | null;
6
- export declare const getState: <S extends State>(state: ClassState<S>, myID?: string) => S | null;
2
+ export declare const getRootID: <S extends State>(classState: ClassState<S>) => string;
3
+ export declare const getNode: <S extends State>(classState: ClassState<S>, myID?: string) => NodeState<S> | null;
4
+ export declare const getState: <S extends State>(classState: ClassState<S>, myID?: string) => S | null;