@chhsiao1981/use-thunk 9.0.2 → 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 +1 -1
- package/src/addChild.ts +5 -2
- package/src/addLink.ts +2 -2
- package/src/addRelation.ts +10 -10
- package/src/createReducer.ts +5 -5
- package/src/getRelation.ts +20 -12
- package/src/init.ts +6 -6
- package/src/reducer.ts +1 -1
- package/src/remove.ts +7 -7
- package/src/removeChild.ts +2 -2
- package/src/removeLink.ts +2 -2
- package/src/removeRelation.ts +15 -15
- package/src/setData.ts +8 -8
- package/src/setRoot.ts +2 -2
- package/src/stateTypes.ts +3 -0
- package/src/states.ts +14 -14
- package/src/useThunk.ts +1 -1
- package/types/addChild.d.ts +1 -1
- package/types/addLink.d.ts +1 -1
- package/types/addRelation.d.ts +1 -1
- package/types/getRelation.d.ts +4 -4
- package/types/init.d.ts +1 -1
- package/types/remove.d.ts +1 -1
- package/types/removeChild.d.ts +1 -1
- package/types/removeLink.d.ts +1 -1
- package/types/removeRelation.d.ts +1 -1
- package/types/setData.d.ts +1 -1
- package/types/setRoot.d.ts +1 -1
- package/types/states.d.ts +3 -5
package/package.json
CHANGED
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>(
|
|
12
|
-
|
|
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>(
|
|
26
|
-
return reduceAddRelation(
|
|
25
|
+
export const reduceAddLink = <S extends State>(classState: ClassState<S>, action: AddRelationAction): ClassState<S> => {
|
|
26
|
+
return reduceAddRelation(classState, action, Relation.LINKS)
|
|
27
27
|
}
|
package/src/addRelation.ts
CHANGED
|
@@ -6,27 +6,27 @@ export interface AddRelationAction extends BaseAction {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export const reduceAddRelation = <S extends State>(
|
|
9
|
-
|
|
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
|
|
15
|
-
if (!
|
|
16
|
-
return
|
|
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 =
|
|
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({},
|
|
27
|
-
const
|
|
28
|
-
const newNodes = Object.assign({},
|
|
29
|
-
const
|
|
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
|
|
31
|
+
return newClassState
|
|
32
32
|
}
|
package/src/createReducer.ts
CHANGED
|
@@ -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 (
|
|
8
|
+
return (classState: ClassState<S>, action: BaseAction): ClassState<S> => {
|
|
9
9
|
if (!action) {
|
|
10
|
-
return
|
|
10
|
+
return classState
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
if (reduceMap?.[action.type]) {
|
|
14
|
-
return reduceMap[action.type](
|
|
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](
|
|
19
|
+
return defaultReduceMap[action.type](classState, action)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
return
|
|
22
|
+
return classState
|
|
23
23
|
}
|
|
24
24
|
}
|
package/src/getRelation.ts
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import { type NodeState, Relation, type State } from './stateTypes'
|
|
2
2
|
|
|
3
|
-
export const getChildIDs = <S extends State>(
|
|
4
|
-
return getRelationIDs(
|
|
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>(
|
|
8
|
-
return getRelationID(
|
|
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>(
|
|
12
|
-
return getRelationIDs(
|
|
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>(
|
|
16
|
-
return getRelationID(
|
|
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>(
|
|
20
|
-
|
|
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>(
|
|
33
|
-
|
|
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/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>(
|
|
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
|
|
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
|
-
|
|
75
|
+
myNode[PARENT] = { id: parentID, do: doParent, theClass: parentClass ?? '' }
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
const newNodes: NodeStateMap<S> = Object.assign({},
|
|
79
|
-
const
|
|
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
|
|
81
|
+
return newClassState
|
|
82
82
|
}
|
package/src/reducer.ts
CHANGED
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>(
|
|
54
|
+
export const reduceRemove = <S extends State>(classState: ClassState<S>, action: BaseAction): ClassState<S> => {
|
|
55
55
|
const { myID } = action
|
|
56
56
|
|
|
57
|
-
const
|
|
58
|
-
if (!
|
|
59
|
-
return
|
|
57
|
+
const myNode = classState.nodes[myID]
|
|
58
|
+
if (!myNode) {
|
|
59
|
+
return classState
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const newNodes = Object.keys(
|
|
62
|
+
const newNodes = Object.keys(classState.nodes)
|
|
63
63
|
.filter((each) => each !== myID)
|
|
64
64
|
.reduce((r: NodeStateMap<S>, x) => {
|
|
65
|
-
r[x] =
|
|
65
|
+
r[x] = classState.nodes[x]
|
|
66
66
|
return r
|
|
67
67
|
}, {})
|
|
68
68
|
|
|
69
69
|
// root
|
|
70
|
-
const newState = Object.assign({},
|
|
70
|
+
const newState = Object.assign({}, classState, { nodes: newNodes })
|
|
71
71
|
if (newState.root === myID) {
|
|
72
72
|
newState.root = null
|
|
73
73
|
}
|
package/src/removeChild.ts
CHANGED
|
@@ -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
|
-
|
|
40
|
+
classState: ClassState<S>,
|
|
41
41
|
action: RemoveRelationAction,
|
|
42
42
|
): ClassState<S> => {
|
|
43
43
|
const { myID, relationID, relationClass } = action
|
|
44
44
|
|
|
45
|
-
return reduceRemoveRelation(
|
|
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
|
-
|
|
41
|
+
classState: ClassState<S>,
|
|
42
42
|
action: RemoveRelationAction,
|
|
43
43
|
): ClassState<S> => {
|
|
44
44
|
const { myID, relationID, relationClass } = action
|
|
45
45
|
|
|
46
|
-
return reduceRemoveRelation(
|
|
46
|
+
return reduceRemoveRelation(classState, myID, relationID, relationClass, Relation.LINKS)
|
|
47
47
|
}
|
package/src/removeRelation.ts
CHANGED
|
@@ -22,14 +22,14 @@ export const removeRelation = <S extends State>(
|
|
|
22
22
|
removeRelationCore: RemoveRelationCore,
|
|
23
23
|
relationName: Relation,
|
|
24
24
|
) => {
|
|
25
|
-
const
|
|
25
|
+
const classState = getClassState()
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
27
|
+
const myNode = classState.nodes[myID]
|
|
28
|
+
if (!myNode) {
|
|
29
29
|
return
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const relation =
|
|
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
|
-
|
|
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
|
|
59
|
-
if (!
|
|
58
|
+
const myNode = classState.nodes[myID]
|
|
59
|
+
if (!myNode) return classState
|
|
60
60
|
|
|
61
|
-
const relation =
|
|
62
|
-
if (!relation) return
|
|
61
|
+
const relation = myNode[relationName]
|
|
62
|
+
if (!relation) return classState
|
|
63
63
|
|
|
64
64
|
const relationByClass = relation[relationClass]
|
|
65
|
-
if (!relationByClass) return
|
|
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
|
|
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
|
|
80
|
-
const newNodes = Object.assign({},
|
|
81
|
-
const
|
|
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
|
|
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>(
|
|
11
|
+
export const reduceSetData = <S extends State>(classState: ClassState<S>, action: BaseAction): ClassState<S> => {
|
|
12
12
|
const { myID, data } = action
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
14
|
+
const myNode = classState.nodes[myID]
|
|
15
|
+
if (!myNode) return classState
|
|
16
16
|
|
|
17
|
-
const newMyState = Object.assign({},
|
|
18
|
-
const
|
|
19
|
-
const newNodes = Object.assign({},
|
|
20
|
-
const
|
|
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
|
|
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>(
|
|
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({},
|
|
13
|
+
return Object.assign({}, classState, { root: myID })
|
|
14
14
|
}
|
package/src/stateTypes.ts
CHANGED
package/src/states.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
import type { ClassState, NodeState, State } from './stateTypes'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
const 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
|
|
8
|
+
return classState.nodes[root] || null
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const getRootID = <S extends State>(
|
|
12
|
-
return
|
|
11
|
+
export const getRootID = <S extends State>(classState: ClassState<S>): string => {
|
|
12
|
+
return classState.root ?? ''
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
const 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 =
|
|
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>(
|
|
27
|
+
export const getNode = <S extends State>(classState: ClassState<S>, myID?: string): NodeState<S> | null => {
|
|
28
28
|
if (!myID) {
|
|
29
|
-
return getRootNode(
|
|
29
|
+
return getRootNode(classState)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
return
|
|
32
|
+
return classState.nodes[myID] || null
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export const getState = <S extends State>(
|
|
35
|
+
export const getState = <S extends State>(classState: ClassState<S>, myID?: string): S | null => {
|
|
36
36
|
if (!myID) {
|
|
37
|
-
return getRoot(
|
|
37
|
+
return getRoot(classState)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
const me =
|
|
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
|
|
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'
|
package/types/addChild.d.ts
CHANGED
|
@@ -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>(
|
|
5
|
+
export declare const reduceAddChild: <S extends State>(classState: ClassState<S>, action: AddRelationAction) => ClassState<S>;
|
package/types/addLink.d.ts
CHANGED
|
@@ -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>(
|
|
6
|
+
export declare const reduceAddLink: <S extends State>(classState: ClassState<S>, action: AddRelationAction) => ClassState<S>;
|
package/types/addRelation.d.ts
CHANGED
|
@@ -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>(
|
|
6
|
+
export declare const reduceAddRelation: <S extends State>(classState: ClassState<S>, action: AddRelationAction, relationName: Relation) => ClassState<S>;
|
package/types/getRelation.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type NodeState, type State } from './stateTypes';
|
|
2
|
-
export declare const getChildIDs: <S extends State>(
|
|
3
|
-
export declare const getChildID: <S extends State>(
|
|
4
|
-
export declare const getLinkIDs: <S extends State>(
|
|
5
|
-
export declare const getLinkID: <S extends State>(
|
|
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/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>(
|
|
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>(
|
|
5
|
+
export declare const reduceRemove: <S extends State>(classState: ClassState<S>, action: BaseAction) => ClassState<S>;
|
package/types/removeChild.d.ts
CHANGED
|
@@ -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>(
|
|
9
|
+
export declare const reduceRemoveChild: <S extends State>(classState: ClassState<S>, action: RemoveRelationAction) => ClassState<S>;
|
package/types/removeLink.d.ts
CHANGED
|
@@ -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>(
|
|
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>(
|
|
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 {};
|
package/types/setData.d.ts
CHANGED
|
@@ -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>(
|
|
5
|
+
export declare const reduceSetData: <S extends State>(classState: ClassState<S>, action: BaseAction) => ClassState<S>;
|
package/types/setRoot.d.ts
CHANGED
|
@@ -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>(
|
|
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
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
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;
|