atom.io 0.6.1 → 0.6.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/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -2
- package/dist/index.mjs.map +1 -1
- package/json/dist/index.js.map +1 -1
- package/json/dist/index.mjs.map +1 -1
- package/package.json +13 -3
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs.map +1 -1
- package/react-devtools/dist/index.js +32 -18
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +32 -18
- package/react-devtools/dist/index.mjs.map +1 -1
- package/realtime/dist/index.js.map +1 -1
- package/realtime/dist/index.mjs.map +1 -1
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/dist/index.mjs.map +1 -1
- package/realtime-testing/dist/index.d.mts +49 -0
- package/realtime-testing/dist/index.d.ts +49 -0
- package/realtime-testing/dist/index.js +153 -0
- package/realtime-testing/dist/index.js.map +1 -0
- package/realtime-testing/dist/index.mjs +117 -0
- package/realtime-testing/dist/index.mjs.map +1 -0
- package/realtime-testing/package.json +15 -0
- package/src/atom.ts +15 -15
- package/src/index.ts +59 -59
- package/src/internal/atom-internal.ts +36 -36
- package/src/internal/families-internal.ts +114 -114
- package/src/internal/get.ts +83 -83
- package/src/internal/is-default.ts +17 -17
- package/src/internal/meta/attach-meta.ts +7 -7
- package/src/internal/meta/meta-state.ts +115 -115
- package/src/internal/operation.ts +93 -93
- package/src/internal/selector/create-read-write-selector.ts +46 -46
- package/src/internal/selector/create-readonly-selector.ts +37 -37
- package/src/internal/selector/lookup-selector-sources.ts +9 -9
- package/src/internal/selector/register-selector.ts +44 -44
- package/src/internal/selector/trace-selector-atoms.ts +30 -30
- package/src/internal/selector/update-selector-atoms.ts +25 -25
- package/src/internal/selector-internal.ts +37 -37
- package/src/internal/set.ts +78 -78
- package/src/internal/store.ts +118 -118
- package/src/internal/subscribe-internal.ts +62 -62
- package/src/internal/time-travel-internal.ts +76 -76
- package/src/internal/timeline/add-atom-to-timeline.ts +158 -153
- package/src/internal/timeline-internal.ts +80 -80
- package/src/internal/transaction/abort-transaction.ts +8 -8
- package/src/internal/transaction/apply-transaction.ts +41 -41
- package/src/internal/transaction/build-transaction.ts +28 -28
- package/src/internal/transaction/index.ts +7 -7
- package/src/internal/transaction/redo-transaction.ts +13 -13
- package/src/internal/transaction/undo-transaction.ts +13 -13
- package/src/internal/transaction-internal.ts +48 -48
- package/src/json/select-json.ts +12 -12
- package/src/logger.ts +30 -30
- package/src/react/store-context.tsx +4 -4
- package/src/react/store-hooks.ts +18 -18
- package/src/react-devtools/AtomIODevtools.tsx +83 -82
- package/src/react-devtools/StateEditor.tsx +53 -53
- package/src/react-devtools/TokenList.tsx +47 -42
- package/src/react-explorer/AtomIOExplorer.tsx +197 -185
- package/src/react-explorer/explorer-effects.ts +11 -11
- package/src/react-explorer/explorer-states.ts +186 -193
- package/src/react-explorer/index.ts +11 -11
- package/src/react-explorer/space-states.ts +48 -50
- package/src/react-explorer/view-states.ts +25 -25
- package/src/realtime/hook-composition/expose-family.ts +81 -81
- package/src/realtime/hook-composition/expose-single.ts +26 -26
- package/src/realtime/hook-composition/expose-timeline.ts +60 -0
- package/src/realtime/hook-composition/index.ts +2 -2
- package/src/realtime/hook-composition/receive-state.ts +18 -18
- package/src/realtime/hook-composition/receive-transaction.ts +8 -8
- package/src/realtime-react/realtime-context.tsx +17 -17
- package/src/realtime-react/realtime-hooks.ts +17 -17
- package/src/realtime-react/realtime-state.ts +4 -4
- package/src/realtime-react/use-pull-family-member.ts +15 -15
- package/src/realtime-react/use-pull-family.ts +13 -13
- package/src/realtime-react/use-pull.ts +12 -12
- package/src/realtime-react/use-push.ts +15 -15
- package/src/realtime-react/use-server-action.ts +21 -21
- package/src/realtime-testing/index.ts +1 -0
- package/src/realtime-testing/setup-realtime-test.tsx +160 -0
- package/src/selector.ts +25 -25
- package/src/silo.ts +38 -38
- package/src/subscribe.ts +68 -68
- package/src/timeline.ts +13 -13
- package/src/transaction.ts +28 -28
- package/src/web-effects/storage.ts +17 -17
package/src/internal/get.ts
CHANGED
|
@@ -3,85 +3,85 @@ import HAMT from "hamt_plus"
|
|
|
3
3
|
import type { ƒn } from "~/packages/anvl/src/function"
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
Atom,
|
|
7
|
+
ReadonlySelector,
|
|
8
|
+
Selector,
|
|
9
|
+
Store,
|
|
10
|
+
Timeline,
|
|
11
|
+
Transaction,
|
|
12
12
|
} from "."
|
|
13
13
|
import { target, isValueCached, readCachedValue, IMPLICIT } from "."
|
|
14
14
|
import type {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
AtomToken,
|
|
16
|
+
ReadonlySelectorToken,
|
|
17
|
+
SelectorToken,
|
|
18
|
+
StateToken,
|
|
19
|
+
TimelineToken,
|
|
20
|
+
TransactionToken,
|
|
21
21
|
} from ".."
|
|
22
22
|
|
|
23
23
|
export const computeSelectorState = <T>(
|
|
24
|
-
|
|
24
|
+
selector: ReadonlySelector<T> | Selector<T>,
|
|
25
25
|
): T => selector.get()
|
|
26
26
|
|
|
27
27
|
export function lookup(
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
key: string,
|
|
29
|
+
store: Store,
|
|
30
30
|
): AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown> {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
const core = target(store)
|
|
32
|
+
const type = HAMT.has(key, core.atoms)
|
|
33
|
+
? `atom`
|
|
34
|
+
: HAMT.has(key, core.selectors)
|
|
35
|
+
? `selector`
|
|
36
|
+
: `readonly_selector`
|
|
37
|
+
return { key, type } as any
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export function withdraw<T>(token: AtomToken<T>, store: Store): Atom<T> | null
|
|
41
41
|
export function withdraw<T>(
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
token: SelectorToken<T>,
|
|
43
|
+
store: Store,
|
|
44
44
|
): Selector<T> | null
|
|
45
45
|
export function withdraw<T>(
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
token: StateToken<T>,
|
|
47
|
+
store: Store,
|
|
48
48
|
): Atom<T> | Selector<T> | null
|
|
49
49
|
export function withdraw<T>(
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
token: ReadonlySelectorToken<T>,
|
|
51
|
+
store: Store,
|
|
52
52
|
): ReadonlySelector<T> | null
|
|
53
53
|
export function withdraw<T>(
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
token: TransactionToken<T>,
|
|
55
|
+
store: Store,
|
|
56
56
|
): Transaction<T extends ƒn ? T : never> | null
|
|
57
57
|
export function withdraw<T>(
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
token: ReadonlySelectorToken<T> | StateToken<T>,
|
|
59
|
+
store: Store,
|
|
60
60
|
): Atom<T> | ReadonlySelector<T> | Selector<T> | null
|
|
61
61
|
export function withdraw<T>(token: TimelineToken, store: Store): Timeline | null
|
|
62
62
|
export function withdraw<T>(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
token:
|
|
64
|
+
| ReadonlySelectorToken<T>
|
|
65
|
+
| StateToken<T>
|
|
66
|
+
| TimelineToken
|
|
67
|
+
| TransactionToken<T>,
|
|
68
|
+
store: Store,
|
|
69
69
|
):
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
70
|
+
| Atom<T>
|
|
71
|
+
| ReadonlySelector<T>
|
|
72
|
+
| Selector<T>
|
|
73
|
+
| Timeline
|
|
74
|
+
| Transaction<T extends ƒn ? T : never>
|
|
75
|
+
| null {
|
|
76
|
+
const core = target(store)
|
|
77
|
+
return (
|
|
78
|
+
HAMT.get(token.key, core.atoms) ??
|
|
79
|
+
HAMT.get(token.key, core.selectors) ??
|
|
80
|
+
HAMT.get(token.key, core.readonlySelectors) ??
|
|
81
|
+
HAMT.get(token.key, core.transactions) ??
|
|
82
|
+
HAMT.get(token.key, core.timelines) ??
|
|
83
|
+
null
|
|
84
|
+
)
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export function deposit<T>(state: Atom<T>): AtomToken<T>
|
|
@@ -89,43 +89,43 @@ export function deposit<T>(state: Selector<T>): SelectorToken<T>
|
|
|
89
89
|
export function deposit<T>(state: Atom<T> | Selector<T>): StateToken<T>
|
|
90
90
|
export function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>
|
|
91
91
|
export function deposit<T>(
|
|
92
|
-
|
|
92
|
+
state: Transaction<T extends ƒn ? T : never>,
|
|
93
93
|
): TransactionToken<T>
|
|
94
94
|
export function deposit<T>(
|
|
95
|
-
|
|
95
|
+
state: Atom<T> | ReadonlySelector<T> | Selector<T>,
|
|
96
96
|
): ReadonlySelectorToken<T> | StateToken<T>
|
|
97
97
|
export function deposit<T>(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
state:
|
|
99
|
+
| Atom<T>
|
|
100
|
+
| ReadonlySelector<T>
|
|
101
|
+
| Selector<T>
|
|
102
|
+
| Transaction<T extends ƒn ? T : never>,
|
|
103
103
|
):
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
104
|
+
| AtomToken<T>
|
|
105
|
+
| ReadonlySelectorToken<T>
|
|
106
|
+
| SelectorToken<T>
|
|
107
|
+
| TransactionToken<T> {
|
|
108
|
+
return {
|
|
109
|
+
key: state.key,
|
|
110
|
+
type: state.type,
|
|
111
|
+
...(`family` in state && { family: state.family }),
|
|
112
|
+
} as any
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
export const getState__INTERNAL = <T>(
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
state: Atom<T> | ReadonlySelector<T> | Selector<T>,
|
|
117
|
+
store: Store = IMPLICIT.STORE,
|
|
118
118
|
): T => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
119
|
+
if (isValueCached(state.key, store)) {
|
|
120
|
+
store.config.logger?.info(`>> read "${state.key}"`)
|
|
121
|
+
return readCachedValue(state.key, store)
|
|
122
|
+
}
|
|
123
|
+
if (state.type !== `atom`) {
|
|
124
|
+
store.config.logger?.info(`-> calc "${state.key}"`)
|
|
125
|
+
return computeSelectorState(state)
|
|
126
|
+
}
|
|
127
|
+
store.config.logger?.error(
|
|
128
|
+
`Attempted to get atom "${state.key}", which was never initialized in store "${store.config.name}".`,
|
|
129
|
+
)
|
|
130
|
+
return state.default
|
|
131
131
|
}
|
|
@@ -2,34 +2,34 @@ import type { Store } from "."
|
|
|
2
2
|
import { target, IMPLICIT, traceAllSelectorAtoms } from "."
|
|
3
3
|
|
|
4
4
|
export const isAtomDefault = (
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
key: string,
|
|
6
|
+
store: Store = IMPLICIT.STORE,
|
|
7
7
|
): boolean => {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const core = target(store)
|
|
9
|
+
return core.atomsThatAreDefault.has(key)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const markAtomAsDefault = (
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
key: string,
|
|
14
|
+
store: Store = IMPLICIT.STORE,
|
|
15
15
|
): void => {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const core = target(store)
|
|
17
|
+
core.atomsThatAreDefault = new Set(core.atomsThatAreDefault).add(key)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export const markAtomAsNotDefault = (
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
key: string,
|
|
22
|
+
store: Store = IMPLICIT.STORE,
|
|
23
23
|
): void => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const core = target(store)
|
|
25
|
+
core.atomsThatAreDefault = new Set(target(store).atomsThatAreDefault)
|
|
26
|
+
core.atomsThatAreDefault.delete(key)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export const isSelectorDefault = (
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
key: string,
|
|
31
|
+
store: Store = IMPLICIT.STORE,
|
|
32
32
|
): boolean => {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const roots = traceAllSelectorAtoms(key, store)
|
|
34
|
+
return roots.every((root) => isAtomDefault(root.key, store))
|
|
35
35
|
}
|
|
@@ -5,13 +5,13 @@ import type { Store } from "../store"
|
|
|
5
5
|
import { IMPLICIT } from "../store"
|
|
6
6
|
|
|
7
7
|
export const attachMetaState = (
|
|
8
|
-
|
|
8
|
+
store: Store = IMPLICIT.STORE,
|
|
9
9
|
): {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
atomTokenIndexState: ReadonlySelectorToken<AtomTokenIndex>
|
|
11
|
+
selectorTokenIndexState: ReadonlySelectorToken<SelectorTokenIndex>
|
|
12
12
|
} => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
return {
|
|
14
|
+
atomTokenIndexState: attachMetaAtoms(store),
|
|
15
|
+
selectorTokenIndexState: attachMetaSelectors(store),
|
|
16
|
+
}
|
|
17
17
|
}
|
|
@@ -4,132 +4,132 @@ import type { Store } from "../store"
|
|
|
4
4
|
import { IMPLICIT } from "../store"
|
|
5
5
|
|
|
6
6
|
export type StateTokenIndex<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
Token extends
|
|
8
|
+
| AtomToken<unknown>
|
|
9
|
+
| ReadonlySelectorToken<unknown>
|
|
10
|
+
| SelectorToken<unknown>,
|
|
11
11
|
> = Record<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
string,
|
|
13
|
+
| Token
|
|
14
|
+
| {
|
|
15
|
+
key: string
|
|
16
|
+
familyMembers: Record<string, Token>
|
|
17
|
+
}
|
|
18
18
|
>
|
|
19
19
|
|
|
20
20
|
export type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>
|
|
21
21
|
export type SelectorTokenIndex = StateTokenIndex<
|
|
22
|
-
|
|
22
|
+
ReadonlySelectorToken<unknown> | SelectorToken<unknown>
|
|
23
23
|
>
|
|
24
24
|
|
|
25
25
|
export const attachMetaAtoms = (
|
|
26
|
-
|
|
26
|
+
store: Store = IMPLICIT.STORE,
|
|
27
27
|
): ReadonlySelectorToken<AtomTokenIndex> => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
28
|
+
const atomTokenIndexState__INTERNAL = atom<AtomTokenIndex>({
|
|
29
|
+
key: `👁🗨_atom_token_index__INTERNAL`,
|
|
30
|
+
default: () =>
|
|
31
|
+
[...store.atoms].reduce<AtomTokenIndex>((acc, [key]) => {
|
|
32
|
+
acc[key] = { key, type: `atom` }
|
|
33
|
+
return acc
|
|
34
|
+
}, {}),
|
|
35
|
+
effects: [
|
|
36
|
+
({ setSelf }) => {
|
|
37
|
+
store.subject.atomCreation.subscribe((atomToken) => {
|
|
38
|
+
if (store.operation.open) {
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
setSelf((state) => {
|
|
42
|
+
const { key, family } = atomToken
|
|
43
|
+
if (family) {
|
|
44
|
+
const { key: familyKey, subKey } = family
|
|
45
|
+
const current = state[familyKey]
|
|
46
|
+
if (current === undefined || `familyMembers` in current) {
|
|
47
|
+
const familyKeyState = current || {
|
|
48
|
+
key: familyKey,
|
|
49
|
+
familyMembers: {},
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
...state,
|
|
53
|
+
[familyKey]: {
|
|
54
|
+
...familyKeyState,
|
|
55
|
+
familyMembers: {
|
|
56
|
+
...familyKeyState.familyMembers,
|
|
57
|
+
[subKey]: atomToken,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
...state,
|
|
65
|
+
[key]: atomToken,
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
})
|
|
72
|
+
return selector({
|
|
73
|
+
key: `👁🗨_atom_token_index`,
|
|
74
|
+
get: ({ get }) => get(atomTokenIndexState__INTERNAL),
|
|
75
|
+
})
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
export const attachMetaSelectors = (
|
|
79
|
-
|
|
79
|
+
store: Store = IMPLICIT.STORE,
|
|
80
80
|
): ReadonlySelectorToken<SelectorTokenIndex> => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
81
|
+
const readonlySelectorTokenIndexState__INTERNAL = atom<SelectorTokenIndex>({
|
|
82
|
+
key: `👁🗨_selector_token_index__INTERNAL`,
|
|
83
|
+
default: () =>
|
|
84
|
+
Object.assign(
|
|
85
|
+
[...store.readonlySelectors].reduce<SelectorTokenIndex>((acc, [key]) => {
|
|
86
|
+
acc[key] = { key, type: `readonly_selector` }
|
|
87
|
+
return acc
|
|
88
|
+
}, {}),
|
|
89
|
+
[...store.selectors].reduce<SelectorTokenIndex>((acc, [key]) => {
|
|
90
|
+
acc[key] = { key, type: `selector` }
|
|
91
|
+
return acc
|
|
92
|
+
}, {}),
|
|
93
|
+
),
|
|
94
|
+
effects: [
|
|
95
|
+
({ setSelf }) => {
|
|
96
|
+
store.subject.selectorCreation.subscribe((selectorToken) => {
|
|
97
|
+
if (store.operation.open) {
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
setSelf((state) => {
|
|
101
|
+
const { key, family } = selectorToken
|
|
102
|
+
if (family) {
|
|
103
|
+
const { key: familyKey, subKey } = family
|
|
104
|
+
const current = state[familyKey]
|
|
105
|
+
if (current === undefined || `familyMembers` in current) {
|
|
106
|
+
const familyKeyState = current || {
|
|
107
|
+
key: familyKey,
|
|
108
|
+
familyMembers: {},
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
...state,
|
|
112
|
+
[familyKey]: {
|
|
113
|
+
...familyKeyState,
|
|
114
|
+
familyMembers: {
|
|
115
|
+
...familyKeyState.familyMembers,
|
|
116
|
+
[subKey]: selectorToken,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
...state,
|
|
124
|
+
[key]: selectorToken,
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
})
|
|
131
|
+
return selector({
|
|
132
|
+
key: `👁🗨_selector_token_index`,
|
|
133
|
+
get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL),
|
|
134
|
+
})
|
|
135
135
|
}
|