atom.io 0.40.5 → 0.40.7

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.
Files changed (163) hide show
  1. package/README.md +1 -1
  2. package/dist/data/index.d.ts +1 -1
  3. package/dist/employ-socket-D6wgByWh.js +12 -0
  4. package/dist/employ-socket-D6wgByWh.js.map +1 -0
  5. package/dist/has-role-hv4-hJMw.js +1149 -0
  6. package/dist/has-role-hv4-hJMw.js.map +1 -0
  7. package/dist/internal/index.d.ts +248 -248
  8. package/dist/internal/index.d.ts.map +1 -1
  9. package/dist/internal/index.js +570 -1712
  10. package/dist/internal/index.js.map +1 -1
  11. package/dist/introspection/index.d.ts +1 -1
  12. package/dist/is-fn-DY1wZ-md.js +10 -0
  13. package/dist/is-fn-DY1wZ-md.js.map +1 -0
  14. package/dist/main/index.d.ts +33 -33
  15. package/dist/main/index.d.ts.map +1 -1
  16. package/dist/main/index.js +2 -2
  17. package/dist/main/index.js.map +1 -1
  18. package/dist/mutex-store-CSvxY9i3.js +11 -0
  19. package/dist/mutex-store-CSvxY9i3.js.map +1 -0
  20. package/dist/react/index.d.ts +5 -21
  21. package/dist/react/index.d.ts.map +1 -1
  22. package/dist/react/index.js.map +1 -1
  23. package/dist/react-devtools/index.js +7 -7
  24. package/dist/react-devtools/index.js.map +1 -1
  25. package/dist/realtime/index.d.ts +7 -15
  26. package/dist/realtime/index.d.ts.map +1 -1
  27. package/dist/realtime/index.js +3 -33
  28. package/dist/realtime/index.js.map +1 -1
  29. package/dist/realtime-client/index.d.ts +5 -5
  30. package/dist/realtime-client/index.d.ts.map +1 -1
  31. package/dist/realtime-client/index.js +92 -69
  32. package/dist/realtime-client/index.js.map +1 -1
  33. package/dist/realtime-react/index.d.ts +17 -10
  34. package/dist/realtime-react/index.d.ts.map +1 -1
  35. package/dist/realtime-react/index.js +41 -41
  36. package/dist/realtime-react/index.js.map +1 -1
  37. package/dist/realtime-server/index.d.ts +60 -53
  38. package/dist/realtime-server/index.d.ts.map +1 -1
  39. package/dist/realtime-server/index.js +592 -485
  40. package/dist/realtime-server/index.js.map +1 -1
  41. package/dist/realtime-testing/index.d.ts +1 -2
  42. package/dist/realtime-testing/index.d.ts.map +1 -1
  43. package/dist/realtime-testing/index.js +25 -18
  44. package/dist/realtime-testing/index.js.map +1 -1
  45. package/dist/shared-room-store-COGGKqes.js +32 -0
  46. package/dist/shared-room-store-COGGKqes.js.map +1 -0
  47. package/dist/shared-room-store-D2o4ZLjC.d.ts +15 -0
  48. package/dist/shared-room-store-D2o4ZLjC.d.ts.map +1 -0
  49. package/dist/web/index.d.ts +3 -3
  50. package/dist/web/index.d.ts.map +1 -1
  51. package/dist/web/index.js +4 -3
  52. package/dist/web/index.js.map +1 -1
  53. package/package.json +12 -12
  54. package/src/internal/atom/create-regular-atom.ts +5 -4
  55. package/src/internal/atom/dispose-atom.ts +7 -2
  56. package/src/internal/atom/has-role.ts +3 -3
  57. package/src/internal/caching.ts +4 -2
  58. package/src/internal/families/create-readonly-held-selector-family.ts +2 -1
  59. package/src/internal/families/create-readonly-pure-selector-family.ts +5 -2
  60. package/src/internal/families/create-regular-atom-family.ts +2 -1
  61. package/src/internal/families/create-writable-held-selector-family.ts +2 -1
  62. package/src/internal/families/create-writable-pure-selector-family.ts +5 -2
  63. package/src/internal/families/dispose-from-store.ts +4 -4
  64. package/src/internal/families/find-in-store.ts +10 -10
  65. package/src/internal/families/get-family-of-token.ts +2 -2
  66. package/src/internal/families/index.ts +1 -0
  67. package/src/internal/families/mint-in-store.ts +54 -19
  68. package/src/internal/families/seek-in-store.ts +1 -1
  69. package/src/internal/get-state/get-fallback.ts +2 -2
  70. package/src/internal/get-state/get-from-store.ts +5 -5
  71. package/src/internal/get-state/read-or-compute-value.ts +1 -1
  72. package/src/internal/get-state/reduce-reference.ts +8 -6
  73. package/src/internal/index.ts +2 -220
  74. package/src/internal/molecule.ts +1 -2
  75. package/src/internal/mutable/create-mutable-atom-family.ts +3 -2
  76. package/src/internal/mutable/create-mutable-atom.ts +4 -2
  77. package/src/internal/mutable/get-json-family.ts +1 -1
  78. package/src/internal/mutable/get-update-family.ts +1 -1
  79. package/src/internal/mutable/tracker-family.ts +2 -1
  80. package/src/internal/mutable/tracker.ts +5 -8
  81. package/src/internal/safe-compute.ts +1 -1
  82. package/src/internal/selector/create-readonly-held-selector.ts +2 -1
  83. package/src/internal/selector/create-readonly-pure-selector.ts +2 -1
  84. package/src/internal/selector/create-writable-held-selector.ts +2 -1
  85. package/src/internal/selector/create-writable-pure-selector.ts +2 -1
  86. package/src/internal/selector/dispose-selector.ts +3 -2
  87. package/src/internal/selector/register-selector.ts +8 -5
  88. package/src/internal/selector/trace-selector-atoms.ts +2 -1
  89. package/src/internal/set-state/dispatch-state-update.ts +3 -2
  90. package/src/internal/set-state/evict-downstream.ts +1 -1
  91. package/src/internal/set-state/operate-on-store.ts +16 -22
  92. package/src/internal/set-state/reset-atom-or-selector.ts +5 -3
  93. package/src/internal/set-state/reset-in-store.ts +5 -5
  94. package/src/internal/set-state/set-atom-or-selector.ts +2 -2
  95. package/src/internal/set-state/set-atom.ts +4 -2
  96. package/src/internal/set-state/set-into-store.ts +21 -39
  97. package/src/internal/set-state/set-selector.ts +3 -2
  98. package/src/internal/state-types.ts +228 -0
  99. package/src/internal/store/deposit.ts +4 -4
  100. package/src/internal/store/index.ts +0 -1
  101. package/src/internal/store/store.ts +9 -9
  102. package/src/internal/store/withdraw.ts +4 -4
  103. package/src/internal/subscribe/recall-state.ts +1 -1
  104. package/src/internal/subscribe/subscribe-to-root-atoms.ts +1 -12
  105. package/src/internal/subscribe/subscribe-to-transaction.ts +3 -2
  106. package/src/internal/transaction/build-transaction.ts +3 -2
  107. package/src/internal/transaction/index.ts +1 -23
  108. package/src/internal/transaction/is-root-store.ts +4 -1
  109. package/src/internal/transaction/transaction-meta-progress.ts +22 -0
  110. package/src/main/atom.ts +1 -2
  111. package/src/main/find-state.ts +5 -5
  112. package/src/main/get-state.ts +4 -4
  113. package/src/main/realm.ts +2 -2
  114. package/src/main/set-state.ts +10 -10
  115. package/src/react/parse-state-overloads.ts +3 -3
  116. package/src/react/use-i.ts +6 -4
  117. package/src/react/use-loadable.ts +4 -30
  118. package/src/react/use-o.ts +6 -4
  119. package/src/react-devtools/store.ts +6 -6
  120. package/src/realtime/index.ts +1 -0
  121. package/src/realtime/mutex-store.ts +11 -0
  122. package/src/realtime/realtime-continuity.ts +1 -5
  123. package/src/realtime-client/pull-atom-family-member.ts +14 -17
  124. package/src/realtime-client/pull-atom.ts +1 -1
  125. package/src/realtime-client/pull-mutable-atom-family-member.ts +16 -12
  126. package/src/realtime-client/pull-selector-family-member.ts +8 -35
  127. package/src/realtime-client/pull-selector-roots.ts +90 -0
  128. package/src/realtime-client/pull-selector.ts +2 -27
  129. package/src/realtime-client/push-state.ts +33 -5
  130. package/src/realtime-client/realtime-client-stores/client-main-store.ts +2 -5
  131. package/src/realtime-react/index.ts +2 -1
  132. package/src/realtime-react/realtime-context.tsx +9 -5
  133. package/src/realtime-react/use-pull-atom-family-member.ts +2 -3
  134. package/src/realtime-react/use-pull-mutable-family-member.ts +2 -3
  135. package/src/realtime-react/use-pull-selector-family-member.ts +5 -6
  136. package/src/realtime-react/use-push.ts +7 -3
  137. package/src/realtime-react/use-realtime-service.ts +11 -11
  138. package/src/realtime-react/use-single-effect.ts +11 -14
  139. package/src/realtime-server/{realtime-server-stores/server-sync-store.ts → continuity/continuity-store.ts} +1 -1
  140. package/src/realtime-server/continuity/prepare-to-sync-realtime-continuity.ts +1 -1
  141. package/src/realtime-server/continuity/prepare-to-track-client-acknowledgement.ts +3 -5
  142. package/src/realtime-server/continuity/subscribe-to-continuity-actions.ts +1 -1
  143. package/src/realtime-server/employ-socket.ts +14 -0
  144. package/src/realtime-server/index.ts +2 -20
  145. package/src/realtime-server/ipc-sockets/child-socket.ts +125 -66
  146. package/src/realtime-server/ipc-sockets/custom-socket.ts +16 -14
  147. package/src/realtime-server/ipc-sockets/parent-socket.ts +81 -58
  148. package/src/realtime-server/realtime-family-provider.ts +78 -29
  149. package/src/realtime-server/realtime-mutable-family-provider.ts +80 -31
  150. package/src/realtime-server/realtime-mutable-provider.ts +30 -22
  151. package/src/realtime-server/realtime-server-stores/index.ts +0 -2
  152. package/src/realtime-server/realtime-server-stores/server-room-external-store.ts +77 -36
  153. package/src/realtime-server/realtime-server-stores/server-user-store.ts +12 -1
  154. package/src/realtime-server/realtime-state-provider.ts +30 -29
  155. package/src/realtime-server/realtime-state-receiver.ts +62 -16
  156. package/src/realtime-server/server-config.ts +9 -0
  157. package/src/realtime-server/socket-interface.ts +14 -0
  158. package/src/realtime-testing/setup-realtime-test.tsx +56 -23
  159. package/src/web/index.ts +1 -1
  160. package/src/web/{persist-sync.ts → storage-sync.ts} +5 -2
  161. package/src/internal/store/mint-or-counterfeit.ts +0 -108
  162. package/src/realtime-react/on-mount.ts +0 -5
  163. package/src/realtime-server/realtime-server-stores/server-room-external-actions.ts +0 -79
@@ -1,67 +1,49 @@
1
- import type { WritableFamilyToken, WritableToken } from "atom.io"
1
+ import type { Setter, WritableFamilyToken, WritableToken } from "atom.io"
2
2
  import type { Canonical } from "atom.io/json"
3
3
 
4
4
  import type { Store } from "../store"
5
5
  import { operateOnStore, OWN_OP } from "./operate-on-store"
6
6
  import type { RESET_STATE } from "./reset-in-store"
7
7
 
8
- export function setIntoStore<T, New extends T, E>(
8
+ export function setIntoStore<T, TT extends T>(
9
9
  store: Store,
10
- token: WritableToken<T, any, E>,
11
- value: New | typeof RESET_STATE | ((oldValue: T) => New),
10
+ token: WritableToken<T, any, any>,
11
+ value: Setter<TT> | TT | typeof RESET_STATE,
12
12
  ): void
13
13
 
14
- export function setIntoStore<
15
- T,
16
- K extends Canonical,
17
- New extends T,
18
- Key extends K,
19
- E,
20
- >(
14
+ export function setIntoStore<T, TT extends T, K extends Canonical>(
21
15
  store: Store,
22
- token: WritableFamilyToken<T, K, E>,
23
- key: Key,
24
- value: New | typeof RESET_STATE | ((oldValue: T) => New),
16
+ token: WritableFamilyToken<T, K, any>,
17
+ key: NoInfer<K>,
18
+ value: Setter<TT> | TT | typeof RESET_STATE,
25
19
  ): void
26
20
 
27
- export function setIntoStore<
28
- T,
29
- K extends Canonical,
30
- New extends T,
31
- Key extends K,
32
- E,
33
- >(
21
+ export function setIntoStore<T, TT extends T, K extends Canonical>(
34
22
  store: Store,
35
23
  ...params:
36
24
  | [
37
- token: WritableFamilyToken<T, K, E>,
38
- key: Key,
39
- value: New | typeof RESET_STATE | ((oldValue: T) => New),
25
+ token: WritableFamilyToken<T, K, any>,
26
+ key: NoInfer<K>,
27
+ value: Setter<TT> | TT | typeof RESET_STATE,
40
28
  ]
41
29
  | [
42
- token: WritableToken<T, any, E>,
43
- value: New | typeof RESET_STATE | ((oldValue: T) => New),
30
+ token: WritableToken<T, any, any>,
31
+ value: Setter<TT> | TT | typeof RESET_STATE,
44
32
  ]
45
33
  ): void
46
34
 
47
- export function setIntoStore<
48
- T,
49
- K extends Canonical,
50
- New extends T,
51
- Key extends K,
52
- E,
53
- >(
35
+ export function setIntoStore<T, TT extends T, K extends Canonical>(
54
36
  store: Store,
55
37
  ...params:
56
38
  | [
57
- token: WritableFamilyToken<T, K, E>,
58
- key: Key,
59
- value: New | typeof RESET_STATE | ((oldValue: T) => New),
39
+ token: WritableFamilyToken<T, K, any>,
40
+ key: NoInfer<K>,
41
+ value: Setter<TT> | TT | typeof RESET_STATE,
60
42
  ]
61
43
  | [
62
- token: WritableToken<T, any, E>,
63
- value: New | typeof RESET_STATE | ((oldValue: T) => New),
44
+ token: WritableToken<T, any, any>,
45
+ value: Setter<TT> | TT | typeof RESET_STATE,
64
46
  ]
65
47
  ): void {
66
- operateOnStore(store, OWN_OP, ...params)
48
+ operateOnStore(OWN_OP, store, ...params)
67
49
  }
@@ -1,6 +1,7 @@
1
- import { readOrComputeValue, type WritableSelector } from ".."
2
1
  import { writeToCache } from "../caching"
2
+ import { readOrComputeValue } from "../get-state"
3
3
  import { markDone, type OpenOperation } from "../operation"
4
+ import type { WritableSelector } from "../state-types"
4
5
  import type { Store } from "../store"
5
6
  import { become } from "./become"
6
7
  import type { ProtoUpdate } from "./operate-on-store"
@@ -8,7 +9,7 @@ import type { ProtoUpdate } from "./operate-on-store"
8
9
  export function setSelector<T>(
9
10
  target: Store & { operation: OpenOperation<any> },
10
11
  selector: WritableSelector<T, any>,
11
- next: T | ((oldValue: T) => T),
12
+ next: NoInfer<T> | ((oldValue: T) => NoInfer<T>),
12
13
  ): ProtoUpdate<T> {
13
14
  let oldValue: T
14
15
  let newValue: T
@@ -0,0 +1,228 @@
1
+ import type {
2
+ FamilyMetadata,
3
+ MutableAtomFamilyToken,
4
+ MutableAtomToken,
5
+ ReadonlyHeldSelectorFamilyToken,
6
+ ReadonlyHeldSelectorToken,
7
+ ReadonlyPureSelectorFamilyToken,
8
+ ReadonlyPureSelectorToken,
9
+ RegularAtomFamilyToken,
10
+ RegularAtomToken,
11
+ StateLifecycleEvent,
12
+ StateUpdate,
13
+ WritableHeldSelectorFamilyToken,
14
+ WritableHeldSelectorToken,
15
+ WritablePureSelectorFamilyToken,
16
+ WritablePureSelectorToken,
17
+ } from "atom.io"
18
+ import type { Canonical } from "atom.io/json"
19
+
20
+ import type { InternalRole } from "./atom"
21
+ import type { ConstructorOf, Transceiver } from "./mutable"
22
+ import type { Store } from "./store"
23
+ import type { Subject } from "./subject"
24
+ import type { Timeline } from "./timeline"
25
+ import type { RootStore, Transaction } from "./transaction"
26
+ import type { Ctor, Flat } from "./utility-types"
27
+
28
+ export type AtomIOState = {
29
+ key: string
30
+ family?: FamilyMetadata
31
+ install: (store: RootStore) => void
32
+ subject: Subject<StateUpdate<any>>
33
+ }
34
+ export type RegularAtom<T, E> = Flat<
35
+ AtomIOState & {
36
+ type: `atom`
37
+ default: T | (() => T)
38
+ cleanup?: () => void
39
+ internalRoles?: InternalRole[]
40
+ catch?: readonly Ctor<E>[]
41
+ __T?: T
42
+ __E?: E
43
+ }
44
+ >
45
+ export type MutableAtom<T extends Transceiver<any, any, any>> = Flat<
46
+ AtomIOState & {
47
+ type: `mutable_atom`
48
+ class: ConstructorOf<T>
49
+ cleanup?: () => void
50
+ __T?: T
51
+ }
52
+ >
53
+ export type Atom<T, E> =
54
+ | RegularAtom<T, E>
55
+ | (T extends Transceiver<any, any, any> ? MutableAtom<T> : never)
56
+
57
+ export type WritableHeldSelector<T> = Flat<
58
+ AtomIOState & {
59
+ type: `writable_held_selector`
60
+ const: T
61
+ getFrom: (target: Store) => T
62
+ setSelf: (newValue: T) => void
63
+ __T?: T
64
+ }
65
+ >
66
+ export type ReadonlyHeldSelector<T> = Flat<
67
+ AtomIOState & {
68
+ type: `readonly_held_selector`
69
+ const: T
70
+ getFrom: (target: Store) => T
71
+ __T?: T
72
+ }
73
+ >
74
+ export type WritablePureSelector<T, E> = Flat<
75
+ AtomIOState & {
76
+ type: `writable_pure_selector`
77
+ getFrom: (target: Store) => E | T
78
+ setSelf: (newValue: T) => void
79
+ catch?: readonly Ctor<E>[]
80
+ __T?: T
81
+ __E?: E
82
+ }
83
+ >
84
+ export type ReadonlyPureSelector<T, E> = Flat<
85
+ AtomIOState & {
86
+ type: `readonly_pure_selector`
87
+ getFrom: (target: Store) => E | T
88
+ catch?: readonly Ctor<E>[]
89
+ __T?: T
90
+ __E?: E
91
+ }
92
+ >
93
+ export type ReadonlySelector<T, E> =
94
+ | ReadonlyHeldSelector<T>
95
+ | ReadonlyPureSelector<T, E>
96
+ export type WritableSelector<T, E> =
97
+ | WritableHeldSelector<T>
98
+ | WritablePureSelector<T, E>
99
+ export type HeldSelector<T> = ReadonlyHeldSelector<T> | WritableHeldSelector<T>
100
+ export type PureSelector<T, E> =
101
+ | ReadonlyPureSelector<T, E>
102
+ | WritablePureSelector<T, E>
103
+ export type Selector<T, E> =
104
+ | ReadonlyHeldSelector<T>
105
+ | ReadonlyPureSelector<T, E>
106
+ | WritableHeldSelector<T>
107
+ | WritablePureSelector<T, E>
108
+
109
+ export type WritableState<T, E> = Atom<T, E> | WritableSelector<T, E>
110
+ export type ReadableState<T, E> = Atom<T, E> | Selector<T, E>
111
+
112
+ // biome-ignore format: intersection
113
+ export type RegularAtomFamily<T, K extends Canonical, E = never> =
114
+ & Flat<
115
+ & RegularAtomFamilyToken<T, K, E>
116
+ & {
117
+ create: <Key extends K>(key: Key) => RegularAtomToken<T, Key, E>
118
+ default: T | ((key: K) => T)
119
+ install: (store: RootStore) => void
120
+ internalRoles: string[] | undefined
121
+ subject: Subject<StateLifecycleEvent<RegularAtomToken<T, K, E>>>
122
+ }
123
+ >
124
+
125
+ // biome-ignore format: intersection
126
+ export type MutableAtomFamily<
127
+ T extends Transceiver<any, any, any>,
128
+ K extends Canonical,
129
+ > =
130
+ & Flat<
131
+ & MutableAtomFamilyToken<T, K>
132
+ & {
133
+ create: <Key extends K>(key: Key) => MutableAtomToken<T, Key>
134
+ class: ConstructorOf<T>
135
+ install: (store: RootStore) => void
136
+ internalRoles: string[] | undefined
137
+ subject: Subject<StateLifecycleEvent<MutableAtomToken<T>>>
138
+ }
139
+ >
140
+
141
+ export type AtomFamily<T, K extends Canonical, E> =
142
+ | MutableAtomFamily<T extends Transceiver<any, any, any> ? T : never, K>
143
+ | RegularAtomFamily<T, K, E>
144
+
145
+ // biome-ignore format: intersection
146
+ export type WritablePureSelectorFamily<T, K extends Canonical, E> =
147
+ & Flat<
148
+ & WritablePureSelectorFamilyToken<T, K, E>
149
+ & {
150
+ create: <Key extends K>(key: Key) => WritablePureSelectorToken<T, Key, E>
151
+ default: (key: K) => T,
152
+ install: (store: RootStore) => void
153
+ internalRoles: string[] | undefined
154
+ subject: Subject<StateLifecycleEvent<WritablePureSelectorToken<T, K, E>>>
155
+ }
156
+ >
157
+
158
+ // biome-ignore format: intersection
159
+ export type WritableHeldSelectorFamily<T , K extends Canonical> =
160
+ & Flat<
161
+ & WritableHeldSelectorFamilyToken<T, K>
162
+ & {
163
+ create: <Key extends K>(key: Key) => WritableHeldSelectorToken<T, Key>
164
+ default: (key: K) => T,
165
+ install: (store: RootStore) => void
166
+ internalRoles: string[] | undefined
167
+ subject: Subject<StateLifecycleEvent<WritableHeldSelectorToken<T, K>>>
168
+ }
169
+ >
170
+
171
+ // biome-ignore format: intersection
172
+ export type ReadonlyPureSelectorFamily<T, K extends Canonical, E> =
173
+ & Flat<
174
+ & ReadonlyPureSelectorFamilyToken<T, K, E>
175
+ & {
176
+ create: <Key extends K>(key: Key) => ReadonlyPureSelectorToken<T, Key, E>
177
+ default: (key: K) => T,
178
+ install: (store: RootStore) => void
179
+ internalRoles: string[] | undefined
180
+ subject: Subject<StateLifecycleEvent<ReadonlyPureSelectorToken<T, K, E>>>
181
+ }
182
+ >
183
+
184
+ // biome-ignore format: intersection
185
+ export type ReadonlyHeldSelectorFamily<T , K extends Canonical> =
186
+ & Flat<
187
+ & ReadonlyHeldSelectorFamilyToken<T, K>
188
+ & {
189
+ create: <Key extends K>(key: Key) => ReadonlyHeldSelectorToken<T, Key>
190
+ default: (key: K) => T,
191
+ install: (store: RootStore) => void
192
+ internalRoles: string[] | undefined
193
+ subject: Subject<StateLifecycleEvent<ReadonlyHeldSelectorToken<T>>>
194
+ }
195
+ >
196
+
197
+ export type PureSelectorFamily<T, K extends Canonical, E> =
198
+ | ReadonlyPureSelectorFamily<T, K, E>
199
+ | WritablePureSelectorFamily<T, K, E>
200
+
201
+ export type HeldSelectorFamily<T, K extends Canonical> =
202
+ | ReadonlyHeldSelectorFamily<T, K>
203
+ | WritableHeldSelectorFamily<T, K>
204
+
205
+ export type ReadonlySelectorFamily<T, K extends Canonical, E> =
206
+ | ReadonlyHeldSelectorFamily<T, K>
207
+ | ReadonlyPureSelectorFamily<T, K, E>
208
+
209
+ export type WritableSelectorFamily<T, K extends Canonical, E> =
210
+ | WritableHeldSelectorFamily<T, K>
211
+ | WritablePureSelectorFamily<T, K, E>
212
+
213
+ export type SelectorFamily<T, K extends Canonical, E> =
214
+ | HeldSelectorFamily<T, K>
215
+ | PureSelectorFamily<T, K, E>
216
+
217
+ export type WritableFamily<T, K extends Canonical, E> =
218
+ | AtomFamily<T, K, E>
219
+ | WritableSelectorFamily<T, K, E>
220
+ export type ReadableFamily<T, K extends Canonical, E> =
221
+ | AtomFamily<T, K, E>
222
+ | SelectorFamily<T, K, E>
223
+
224
+ export type AtomIOInternalResource =
225
+ | ReadableFamily<any, any, any>
226
+ | ReadableState<any, any>
227
+ | Timeline<any>
228
+ | Transaction<any>
@@ -22,11 +22,11 @@ import type {
22
22
  } from "atom.io"
23
23
  import type { Canonical } from "atom.io/json"
24
24
 
25
+ import type { Transceiver } from "../mutable"
25
26
  import type {
26
27
  Atom,
27
28
  AtomFamily,
28
29
  AtomIOInternalResource,
29
- Fn,
30
30
  MutableAtom,
31
31
  MutableAtomFamily,
32
32
  ReadableFamily,
@@ -37,14 +37,14 @@ import type {
37
37
  RegularAtomFamily,
38
38
  Selector,
39
39
  SelectorFamily,
40
- Timeline,
41
- Transceiver,
42
40
  WritableFamily,
43
41
  WritablePureSelector,
44
42
  WritablePureSelectorFamily,
45
43
  WritableState,
46
- } from ".."
44
+ } from "../state-types"
45
+ import type { Timeline } from "../timeline"
47
46
  import type { Transaction } from "../transaction"
47
+ import type { Fn } from "../utility-types"
48
48
 
49
49
  export function deposit<T, E>(
50
50
  state: RegularAtom<T, E>,
@@ -1,5 +1,4 @@
1
1
  export * from "./circular-buffer"
2
2
  export * from "./deposit"
3
- export * from "./mint-or-counterfeit"
4
3
  export * from "./store"
5
4
  export * from "./withdraw"
@@ -10,6 +10,14 @@ import type {
10
10
  import { AtomIOLogger } from "atom.io"
11
11
  import type { Canonical, stringified } from "atom.io/json"
12
12
 
13
+ import type { Join } from "../join"
14
+ import { Junction } from "../junction"
15
+ import type { Lineage } from "../lineage"
16
+ import type { Molecule } from "../molecule"
17
+ import type { Tracker, Transceiver } from "../mutable"
18
+ import { getJsonToken, getUpdateToken } from "../mutable"
19
+ import type { OperationProgress } from "../operation"
20
+ import { isReservedIntrospectionKey } from "../reserved-keys"
13
21
  import type {
14
22
  Atom,
15
23
  HeldSelectorFamily,
@@ -18,15 +26,7 @@ import type {
18
26
  ReadonlySelector,
19
27
  RegularAtomFamily,
20
28
  WritableSelector,
21
- } from ".."
22
- import { isReservedIntrospectionKey } from ".."
23
- import type { Join } from "../join"
24
- import { Junction } from "../junction"
25
- import type { Lineage } from "../lineage"
26
- import type { Molecule } from "../molecule"
27
- import type { Tracker, Transceiver } from "../mutable"
28
- import { getJsonToken, getUpdateToken } from "../mutable"
29
- import type { OperationProgress } from "../operation"
29
+ } from "../state-types"
30
30
  import { StatefulSubject, Subject } from "../subject"
31
31
  import type { Timeline } from "../timeline"
32
32
  import type {
@@ -34,11 +34,12 @@ import type {
34
34
  } from "atom.io"
35
35
  import type { Canonical } from "atom.io/json"
36
36
 
37
+ import type { Transceiver } from "../mutable"
38
+ import { NotFoundError } from "../not-found-error"
37
39
  import type {
38
40
  Atom,
39
41
  AtomFamily,
40
42
  AtomIOInternalResource,
41
- Fn,
42
43
  HeldSelector,
43
44
  HeldSelectorFamily,
44
45
  MutableAtom,
@@ -57,7 +58,6 @@ import type {
57
58
  RegularAtomFamily,
58
59
  Selector,
59
60
  SelectorFamily,
60
- Transceiver,
61
61
  WritableFamily,
62
62
  WritableHeldSelector,
63
63
  WritableHeldSelectorFamily,
@@ -66,10 +66,10 @@ import type {
66
66
  WritableSelector,
67
67
  WritableSelectorFamily,
68
68
  WritableState,
69
- } from ".."
70
- import { NotFoundError } from ".."
69
+ } from "../state-types"
71
70
  import type { Timeline } from "../timeline"
72
71
  import type { Transaction } from "../transaction"
72
+ import type { Fn } from "../utility-types"
73
73
  import type { Store } from "./store"
74
74
 
75
75
  export function withdraw<T, E>(
@@ -1,5 +1,5 @@
1
- import type { ReadableState } from ".."
2
1
  import { newest } from "../lineage"
2
+ import type { ReadableState } from "../state-types"
3
3
  import type { Store } from "../store"
4
4
 
5
5
  export const recallState = <T, E>(
@@ -1,5 +1,5 @@
1
- import type { Atom, Selector } from ".."
2
1
  import { readOrComputeValue } from "../get-state/read-or-compute-value"
2
+ import type { Atom, Selector } from "../state-types"
3
3
  import type { Store } from "../store"
4
4
  import { recallState } from "./recall-state"
5
5
 
@@ -37,14 +37,3 @@ export const subscribeToRootDependency = (
37
37
  },
38
38
  )
39
39
  }
40
-
41
- // export const subscribeToRootAtoms = (
42
- // store: Store,
43
- // selector: Selector<any>,
44
- // ): (() => void)[] => {
45
- // const target = newest(store)
46
- // const dependencySubscriptions = traceAllSelectorAtoms(selector, store).map(
47
- // (atom) => subscribeToRootDependency(target, selector, atom),
48
- // )
49
- // return dependencySubscriptions
50
- // }
@@ -1,7 +1,8 @@
1
1
  import type { TransactionToken, TransactionUpdateHandler } from "atom.io"
2
2
 
3
- import type { Fn, Store } from ".."
4
- import { withdraw } from ".."
3
+ import type { Store } from "../store"
4
+ import { withdraw } from "../store"
5
+ import type { Fn } from "../utility-types"
5
6
 
6
7
  export const subscribeToTransaction = <F extends Fn>(
7
8
  store: Store,
@@ -16,9 +16,10 @@ import { getJsonToken } from "../mutable"
16
16
  import { MapOverlay } from "../overlays/map-overlay"
17
17
  import { resetInStore, setIntoStore } from "../set-state"
18
18
  import type { Fn } from "../utility-types"
19
- import type { TransactionProgress } from "."
20
- import { actUponStore, getEpochNumberOfAction } from "."
19
+ import { actUponStore } from "./act-upon-store"
20
+ import { getEpochNumberOfAction } from "./get-epoch-number"
21
21
  import type { ChildStore, RootStore } from "./is-root-store"
22
+ import type { TransactionProgress } from "./transaction-meta-progress"
22
23
 
23
24
  export const buildTransaction = (
24
25
  store: RootStore,
@@ -1,12 +1,3 @@
1
- import type {
2
- ActorToolkit,
3
- TransactionOutcomeEvent,
4
- TransactionToken,
5
- } from "atom.io"
6
-
7
- import type { Junction } from "../junction"
8
- import type { Fn } from "../utility-types"
9
-
10
1
  export * from "./abort-transaction"
11
2
  export * from "./act-upon-store"
12
3
  export * from "./apply-transaction"
@@ -16,17 +7,4 @@ export * from "./create-transaction"
16
7
  export * from "./get-epoch-number"
17
8
  export * from "./is-root-store"
18
9
  export * from "./set-epoch-number"
19
-
20
- export const TRANSACTION_PHASES = [`idle`, `building`, `applying`] as const
21
- export type TransactionPhase = (typeof TRANSACTION_PHASES)[number]
22
-
23
- export type TransactionProgress<F extends Fn> = {
24
- phase: `applying` | `building`
25
- update: TransactionOutcomeEvent<TransactionToken<F>>
26
- toolkit: ActorToolkit
27
- }
28
-
29
- export type TransactionEpoch = {
30
- epoch: Map<string, number>
31
- actionContinuities: Junction<`continuity`, string, `action`, string>
32
- }
10
+ export * from "./transaction-meta-progress"
@@ -1,7 +1,10 @@
1
1
  import type { MapOverlay } from "../overlays/map-overlay"
2
2
  import type { Store } from "../store"
3
3
  import type { Fn } from "../utility-types"
4
- import type { TransactionEpoch, TransactionProgress } from "."
4
+ import type {
5
+ TransactionEpoch,
6
+ TransactionProgress,
7
+ } from "./transaction-meta-progress"
5
8
 
6
9
  export interface RootStore extends Store {
7
10
  transactionMeta: TransactionEpoch
@@ -0,0 +1,22 @@
1
+ import type {
2
+ ActorToolkit,
3
+ TransactionOutcomeEvent,
4
+ TransactionToken,
5
+ } from "atom.io"
6
+
7
+ import type { Junction } from "../junction"
8
+ import type { Fn } from "../utility-types"
9
+
10
+ export const TRANSACTION_PHASES = [`idle`, `building`, `applying`] as const
11
+ export type TransactionPhase = (typeof TRANSACTION_PHASES)[number]
12
+
13
+ export type TransactionProgress<F extends Fn> = {
14
+ phase: `applying` | `building`
15
+ update: TransactionOutcomeEvent<TransactionToken<F>>
16
+ toolkit: ActorToolkit
17
+ }
18
+
19
+ export type TransactionEpoch = {
20
+ epoch: Map<string, number>
21
+ actionContinuities: Junction<`continuity`, string, `action`, string>
22
+ }
package/src/main/atom.ts CHANGED
@@ -9,7 +9,6 @@ import {
9
9
  import type { Canonical } from "atom.io/json"
10
10
 
11
11
  import type { StateUpdate } from "./events"
12
- import type { Setter } from "./set-state"
13
12
  import type {
14
13
  MutableAtomFamilyToken,
15
14
  MutableAtomToken,
@@ -78,7 +77,7 @@ export type Effectors<T> = {
78
77
  * Set the value of the atom
79
78
  * @param next - The new value of the atom, or a setter function
80
79
  */
81
- setSelf: <New extends T>(next: New | Setter<T, New>) => void
80
+ setSelf: <New extends T>(next: New | ((old: T) => New)) => void
82
81
  /** Subscribe to changes to the atom */
83
82
  onSet: (callback: (options: StateUpdate<T>) => void) => void
84
83
  }
@@ -50,7 +50,7 @@ export function findState<
50
50
  export function findState<T, K extends Canonical, Key extends K>(
51
51
  token: RegularAtomFamilyToken<T, K>,
52
52
  key: Key,
53
- ): RegularAtomToken<T, K>
53
+ ): RegularAtomToken<T, Key>
54
54
  /**
55
55
  * Finds a {@link WritableSelectorToken} in the store, without accessing its value.
56
56
  *
@@ -67,7 +67,7 @@ export function findState<T, K extends Canonical, Key extends K>(
67
67
  export function findState<T, K extends Canonical, Key extends K>(
68
68
  token: WritableSelectorFamilyToken<T, K>,
69
69
  key: Key,
70
- ): WritableSelectorToken<T, K>
70
+ ): WritableSelectorToken<T, Key>
71
71
  /**
72
72
  * Finds a {@link ReadonlySelectorToken} in the store, without accessing its value.
73
73
  *
@@ -84,7 +84,7 @@ export function findState<T, K extends Canonical, Key extends K>(
84
84
  export function findState<T, K extends Canonical, Key extends K>(
85
85
  token: ReadonlySelectorFamilyToken<T, K>,
86
86
  key: Key,
87
- ): ReadonlySelectorToken<T, K>
87
+ ): ReadonlySelectorToken<T, Key>
88
88
  /**
89
89
  * Finds a {@link WritableToken} in the store, without accessing its value.
90
90
  *
@@ -101,7 +101,7 @@ export function findState<T, K extends Canonical, Key extends K>(
101
101
  export function findState<T, K extends Canonical, Key extends K>(
102
102
  token: WritableFamilyToken<T, K>,
103
103
  key: Key,
104
- ): WritableToken<T, K>
104
+ ): WritableToken<T, Key>
105
105
  /**
106
106
  * Finds a {@link MutableAtomToken} in the store, without accessing its value.
107
107
  *
@@ -119,7 +119,7 @@ export function findState<T, K extends Canonical, Key extends K>(
119
119
  export function findState<T, K extends Canonical, Key extends K>(
120
120
  token: ReadableFamilyToken<T, K>,
121
121
  key: Key,
122
- ): ReadableToken<T, K>
122
+ ): ReadableToken<T, Key>
123
123
 
124
124
  export function findState(
125
125
  token: ReadableFamilyToken<any, any>,
@@ -22,14 +22,14 @@ export function getState<T, E = never>(
22
22
  * @return The current value of the state
23
23
  * @overload Streamlined
24
24
  */
25
- export function getState<T, K extends Canonical, Key extends K, E = never>(
25
+ export function getState<T, K extends Canonical, E = never>(
26
26
  token: ReadableFamilyToken<T, K, E>,
27
- key: Key,
27
+ key: NoInfer<K>,
28
28
  ): ViewOf<E | T>
29
29
 
30
- export function getState<T, K extends Canonical, Key extends K, E = never>(
30
+ export function getState<T, K extends Canonical, E = never>(
31
31
  ...params:
32
- | [token: ReadableFamilyToken<T, K, E>, key: Key]
32
+ | [token: ReadableFamilyToken<T, K, E>, key: NoInfer<K>]
33
33
  | [token: ReadableToken<T, any, E>]
34
34
  ): ViewOf<E | T> {
35
35
  return getFromStore(IMPLICIT.STORE, ...params)
package/src/main/realm.ts CHANGED
@@ -34,7 +34,7 @@ export class Realm<H extends Hierarchy> {
34
34
  this.store = store
35
35
  this.deallocateTX = createDeallocateTX(store)
36
36
  this.claimTX = createClaimTX(store)
37
- makeRootMoleculeInStore(`root`, store)
37
+ makeRootMoleculeInStore(store, `root`)
38
38
  }
39
39
  /**
40
40
  * Make space for a new subject of the realm
@@ -117,7 +117,7 @@ export class Anarchy {
117
117
  this.store = store
118
118
  this.deallocateTX = createDeallocateTX(store)
119
119
  this.claimTX = createClaimTX(store)
120
- makeRootMoleculeInStore(`root`, store)
120
+ makeRootMoleculeInStore(store, `root`)
121
121
  }
122
122
  /**
123
123
  * Declare a new entity