atom.io 0.40.6 → 0.40.8

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 (186) hide show
  1. package/README.md +1 -1
  2. package/dist/data/index.d.ts +1 -1
  3. package/dist/data/index.js +1 -2
  4. package/dist/data/index.js.map +1 -1
  5. package/dist/employ-socket-D6wgByWh.js +12 -0
  6. package/dist/employ-socket-D6wgByWh.js.map +1 -0
  7. package/dist/eslint-plugin/index.js.map +1 -1
  8. package/dist/has-role-CMlaUlaf.js +1133 -0
  9. package/dist/has-role-CMlaUlaf.js.map +1 -0
  10. package/dist/internal/index.d.ts +248 -248
  11. package/dist/internal/index.d.ts.map +1 -1
  12. package/dist/internal/index.js +590 -1803
  13. package/dist/internal/index.js.map +1 -1
  14. package/dist/introspection/index.d.ts +1 -1
  15. package/dist/introspection/index.d.ts.map +1 -1
  16. package/dist/introspection/index.js +13 -32
  17. package/dist/introspection/index.js.map +1 -1
  18. package/dist/is-fn-DY1wZ-md.js +10 -0
  19. package/dist/is-fn-DY1wZ-md.js.map +1 -0
  20. package/dist/json/index.d.ts.map +1 -1
  21. package/dist/json/index.js.map +1 -1
  22. package/dist/main/index.d.ts +33 -33
  23. package/dist/main/index.d.ts.map +1 -1
  24. package/dist/main/index.js +3 -4
  25. package/dist/main/index.js.map +1 -1
  26. package/dist/mutex-store-CSvxY9i3.js +11 -0
  27. package/dist/mutex-store-CSvxY9i3.js.map +1 -0
  28. package/dist/react/index.d.ts +5 -5
  29. package/dist/react/index.d.ts.map +1 -1
  30. package/dist/react/index.js.map +1 -1
  31. package/dist/react-devtools/index.d.ts.map +1 -1
  32. package/dist/react-devtools/index.js +9 -11
  33. package/dist/react-devtools/index.js.map +1 -1
  34. package/dist/realtime/index.d.ts +7 -15
  35. package/dist/realtime/index.d.ts.map +1 -1
  36. package/dist/realtime/index.js +4 -35
  37. package/dist/realtime/index.js.map +1 -1
  38. package/dist/realtime-client/index.d.ts +6 -9
  39. package/dist/realtime-client/index.d.ts.map +1 -1
  40. package/dist/realtime-client/index.js +96 -88
  41. package/dist/realtime-client/index.js.map +1 -1
  42. package/dist/realtime-react/index.d.ts +17 -13
  43. package/dist/realtime-react/index.d.ts.map +1 -1
  44. package/dist/realtime-react/index.js +39 -50
  45. package/dist/realtime-react/index.js.map +1 -1
  46. package/dist/realtime-server/index.d.ts +83 -84
  47. package/dist/realtime-server/index.d.ts.map +1 -1
  48. package/dist/realtime-server/index.js +604 -543
  49. package/dist/realtime-server/index.js.map +1 -1
  50. package/dist/realtime-testing/index.d.ts +5 -4
  51. package/dist/realtime-testing/index.d.ts.map +1 -1
  52. package/dist/realtime-testing/index.js +35 -22
  53. package/dist/realtime-testing/index.js.map +1 -1
  54. package/dist/shared-room-store-BfW3nWif.js +31 -0
  55. package/dist/shared-room-store-BfW3nWif.js.map +1 -0
  56. package/dist/shared-room-store-D2o4ZLjC.d.ts +15 -0
  57. package/dist/shared-room-store-D2o4ZLjC.d.ts.map +1 -0
  58. package/dist/transceivers/set-rtx/index.d.ts.map +1 -1
  59. package/dist/transceivers/set-rtx/index.js +4 -8
  60. package/dist/transceivers/set-rtx/index.js.map +1 -1
  61. package/dist/web/index.d.ts +3 -3
  62. package/dist/web/index.d.ts.map +1 -1
  63. package/dist/web/index.js +4 -3
  64. package/dist/web/index.js.map +1 -1
  65. package/package.json +13 -13
  66. package/src/internal/atom/create-regular-atom.ts +5 -4
  67. package/src/internal/atom/dispose-atom.ts +7 -2
  68. package/src/internal/atom/has-role.ts +3 -3
  69. package/src/internal/caching.ts +4 -2
  70. package/src/internal/families/create-readonly-held-selector-family.ts +2 -1
  71. package/src/internal/families/create-readonly-pure-selector-family.ts +5 -2
  72. package/src/internal/families/create-regular-atom-family.ts +2 -1
  73. package/src/internal/families/create-writable-held-selector-family.ts +2 -1
  74. package/src/internal/families/create-writable-pure-selector-family.ts +5 -2
  75. package/src/internal/families/dispose-from-store.ts +4 -4
  76. package/src/internal/families/find-in-store.ts +10 -10
  77. package/src/internal/families/get-family-of-token.ts +2 -2
  78. package/src/internal/families/index.ts +1 -0
  79. package/src/internal/families/mint-in-store.ts +54 -19
  80. package/src/internal/families/seek-in-store.ts +1 -1
  81. package/src/internal/get-state/get-fallback.ts +2 -2
  82. package/src/internal/get-state/get-from-store.ts +5 -5
  83. package/src/internal/get-state/read-or-compute-value.ts +1 -1
  84. package/src/internal/get-state/reduce-reference.ts +8 -6
  85. package/src/internal/index.ts +2 -220
  86. package/src/internal/molecule.ts +1 -2
  87. package/src/internal/mutable/create-mutable-atom-family.ts +3 -2
  88. package/src/internal/mutable/create-mutable-atom.ts +4 -2
  89. package/src/internal/mutable/get-json-family.ts +1 -1
  90. package/src/internal/mutable/get-update-family.ts +1 -1
  91. package/src/internal/mutable/tracker-family.ts +2 -1
  92. package/src/internal/mutable/tracker.ts +71 -59
  93. package/src/internal/safe-compute.ts +1 -1
  94. package/src/internal/selector/create-readonly-held-selector.ts +2 -1
  95. package/src/internal/selector/create-readonly-pure-selector.ts +2 -1
  96. package/src/internal/selector/create-writable-held-selector.ts +2 -1
  97. package/src/internal/selector/create-writable-pure-selector.ts +2 -1
  98. package/src/internal/selector/dispose-selector.ts +3 -2
  99. package/src/internal/selector/register-selector.ts +8 -5
  100. package/src/internal/selector/trace-selector-atoms.ts +2 -1
  101. package/src/internal/set-state/dispatch-state-update.ts +3 -2
  102. package/src/internal/set-state/evict-downstream.ts +1 -1
  103. package/src/internal/set-state/operate-on-store.ts +16 -22
  104. package/src/internal/set-state/reset-atom-or-selector.ts +5 -3
  105. package/src/internal/set-state/reset-in-store.ts +5 -5
  106. package/src/internal/set-state/set-atom-or-selector.ts +2 -2
  107. package/src/internal/set-state/set-atom.ts +4 -2
  108. package/src/internal/set-state/set-into-store.ts +21 -39
  109. package/src/internal/set-state/set-selector.ts +3 -2
  110. package/src/internal/state-types.ts +228 -0
  111. package/src/internal/store/deposit.ts +4 -4
  112. package/src/internal/store/index.ts +0 -1
  113. package/src/internal/store/store.ts +9 -9
  114. package/src/internal/store/withdraw.ts +4 -4
  115. package/src/internal/subscribe/recall-state.ts +1 -1
  116. package/src/internal/subscribe/subscribe-to-root-atoms.ts +1 -12
  117. package/src/internal/subscribe/subscribe-to-state.ts +9 -0
  118. package/src/internal/subscribe/subscribe-to-transaction.ts +3 -2
  119. package/src/internal/transaction/build-transaction.ts +3 -2
  120. package/src/internal/transaction/index.ts +1 -23
  121. package/src/internal/transaction/is-root-store.ts +4 -1
  122. package/src/internal/transaction/transaction-meta-progress.ts +22 -0
  123. package/src/main/atom.ts +1 -2
  124. package/src/main/find-state.ts +5 -5
  125. package/src/main/get-state.ts +4 -4
  126. package/src/main/realm.ts +2 -2
  127. package/src/main/set-state.ts +10 -10
  128. package/src/react/parse-state-overloads.ts +3 -3
  129. package/src/react/use-i.ts +6 -4
  130. package/src/react/use-loadable.ts +4 -10
  131. package/src/react/use-o.ts +6 -4
  132. package/src/react-devtools/store.ts +6 -6
  133. package/src/realtime/index.ts +1 -0
  134. package/src/realtime/mutex-store.ts +11 -0
  135. package/src/realtime/realtime-continuity.ts +1 -5
  136. package/src/realtime-client/index.ts +0 -1
  137. package/src/realtime-client/pull-atom-family-member.ts +14 -17
  138. package/src/realtime-client/pull-atom.ts +1 -1
  139. package/src/realtime-client/pull-mutable-atom-family-member.ts +16 -12
  140. package/src/realtime-client/pull-selector-family-member.ts +8 -35
  141. package/src/realtime-client/pull-selector-roots.ts +90 -0
  142. package/src/realtime-client/pull-selector.ts +2 -27
  143. package/src/realtime-client/push-state.ts +33 -5
  144. package/src/realtime-client/realtime-client-stores/client-main-store.ts +2 -5
  145. package/src/realtime-react/index.ts +2 -2
  146. package/src/realtime-react/realtime-context.tsx +9 -5
  147. package/src/realtime-react/use-pull-atom-family-member.ts +2 -3
  148. package/src/realtime-react/use-pull-mutable-family-member.ts +2 -3
  149. package/src/realtime-react/use-pull-selector-family-member.ts +5 -6
  150. package/src/realtime-react/use-push.ts +7 -3
  151. package/src/realtime-react/use-realtime-service.ts +11 -11
  152. package/src/realtime-react/use-single-effect.ts +11 -14
  153. package/src/realtime-server/{realtime-server-stores/server-sync-store.ts → continuity/continuity-store.ts} +2 -27
  154. package/src/realtime-server/continuity/provide-continuity.ts +50 -0
  155. package/src/realtime-server/continuity/{subscribe-to-continuity-actions.ts → provide-outcomes.ts} +15 -13
  156. package/src/realtime-server/continuity/{subscribe-to-continuity-perpectives.ts → provide-perspectives.ts} +10 -8
  157. package/src/realtime-server/continuity/{prepare-to-send-initial-payload.ts → provide-startup-payloads.ts} +6 -4
  158. package/src/realtime-server/continuity/receive-action-requests.ts +68 -0
  159. package/src/realtime-server/continuity/track-acknowledgements.ts +46 -0
  160. package/src/realtime-server/employ-socket.ts +14 -0
  161. package/src/realtime-server/index.ts +3 -22
  162. package/src/realtime-server/ipc-sockets/child-socket.ts +125 -66
  163. package/src/realtime-server/ipc-sockets/custom-socket.ts +16 -14
  164. package/src/realtime-server/ipc-sockets/parent-socket.ts +98 -69
  165. package/src/realtime-server/realtime-family-provider.ts +78 -29
  166. package/src/realtime-server/realtime-mutable-family-provider.ts +80 -31
  167. package/src/realtime-server/realtime-mutable-provider.ts +30 -22
  168. package/src/realtime-server/realtime-server-stores/index.ts +0 -2
  169. package/src/realtime-server/realtime-server-stores/server-room-external-store.ts +77 -36
  170. package/src/realtime-server/realtime-server-stores/server-user-store.ts +12 -1
  171. package/src/realtime-server/realtime-state-provider.ts +30 -29
  172. package/src/realtime-server/realtime-state-receiver.ts +62 -16
  173. package/src/realtime-server/server-config.ts +8 -0
  174. package/src/realtime-server/socket-interface.ts +14 -0
  175. package/src/realtime-testing/setup-realtime-test.tsx +70 -31
  176. package/src/web/index.ts +1 -1
  177. package/src/web/{persist-sync.ts → storage-sync.ts} +5 -2
  178. package/src/internal/store/mint-or-counterfeit.ts +0 -108
  179. package/src/realtime-client/server-action.ts +0 -23
  180. package/src/realtime-react/on-mount.ts +0 -5
  181. package/src/realtime-react/use-server-action.ts +0 -19
  182. package/src/realtime-server/continuity/prepare-to-serve-transaction-request.ts +0 -59
  183. package/src/realtime-server/continuity/prepare-to-sync-realtime-continuity.ts +0 -145
  184. package/src/realtime-server/continuity/prepare-to-track-client-acknowledgement.ts +0 -41
  185. package/src/realtime-server/realtime-action-receiver.ts +0 -40
  186. package/src/realtime-server/realtime-server-stores/server-room-external-actions.ts +0 -79
@@ -1,14 +1,14 @@
1
1
  import type { ReadableToken, ViewOf } from "atom.io"
2
2
  import { type Canonical, stringifyJson } from "atom.io/json"
3
3
 
4
- import type { ReadableFamily } from ".."
4
+ import type { ReadableFamily } from "../state-types"
5
5
  import type { Store } from "../store"
6
6
 
7
7
  export function getFallback<T, K extends Canonical, E>(
8
8
  store: Store,
9
9
  token: ReadableToken<T, K, E>,
10
10
  family: ReadableFamily<T, K, E>,
11
- subKey: K,
11
+ subKey: NoInfer<K>,
12
12
  ): ViewOf<E | T> {
13
13
  const disposal = store.disposalTraces.buffer.find(
14
14
  (item) => item?.key === stringifyJson(subKey),
@@ -16,20 +16,20 @@ export function getFromStore<T, E>(
16
16
  export function getFromStore<T, K extends Canonical, E>(
17
17
  store: Store,
18
18
  token: ReadableFamilyToken<T, K, E>,
19
- key: K,
19
+ key: NoInfer<K>,
20
20
  ): ViewOf<E | T>
21
21
 
22
- export function getFromStore<T, K extends Canonical, Key extends K, E>(
22
+ export function getFromStore<T, K extends Canonical, E>(
23
23
  store: Store,
24
24
  ...params:
25
- | [token: ReadableFamilyToken<T, K, E>, key: Key]
25
+ | [token: ReadableFamilyToken<T, K, E>, key: NoInfer<K>]
26
26
  | [token: ReadableToken<T, any, E>]
27
27
  ): ViewOf<E | T>
28
28
 
29
- export function getFromStore<T, K extends Canonical, Key extends K, E>(
29
+ export function getFromStore<T, K extends Canonical, E>(
30
30
  store: Store,
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
  const { token, family, subKey } = reduceReference(store, ...params)
@@ -1,8 +1,8 @@
1
1
  import type { ViewOf } from "atom.io"
2
2
 
3
- import type { ReadableState } from ".."
4
3
  import { readFromCache, writeToCache } from "../caching"
5
4
  import { safeCompute } from "../safe-compute"
5
+ import type { ReadableState } from "../state-types"
6
6
  import type { Store } from "../store"
7
7
 
8
8
  export function readOrComputeValue<T, E>(
@@ -5,23 +5,25 @@ import type {
5
5
  } from "atom.io"
6
6
  import { type Canonical, parseJson } from "atom.io/json"
7
7
 
8
- import type { ReadableFamily, Subject } from ".."
9
- import { isChildStore, isRootStore, newest } from ".."
10
8
  import { seekInStore } from "../families"
11
9
  import { getFamilyOfToken } from "../families/get-family-of-token"
12
10
  import { mintInStore, MUST_CREATE } from "../families/mint-in-store"
11
+ import { newest } from "../lineage"
12
+ import type { ReadableFamily } from "../state-types"
13
13
  import type { Store } from "../store"
14
14
  import { withdraw } from "../store"
15
+ import type { Subject } from "../subject"
16
+ import { isChildStore, isRootStore } from "../transaction"
15
17
 
16
18
  export function reduceReference<T, K extends Canonical, E>(
17
19
  store: Store,
18
20
  ...params:
19
- | [token: ReadableFamilyToken<T, K, E>, key: K]
21
+ | [token: ReadableFamilyToken<T, K, E>, key: NoInfer<K>]
20
22
  | [token: ReadableToken<T, K, E>]
21
23
  ): {
22
24
  token: ReadableToken<T, K, E>
23
25
  family: ReadableFamily<T, K, E> | undefined
24
- subKey: K | undefined
26
+ subKey: NoInfer<K> | undefined
25
27
  isNew: boolean
26
28
  } {
27
29
  let existingToken: ReadableToken<T, K, E> | undefined
@@ -45,7 +47,7 @@ export function reduceReference<T, K extends Canonical, E>(
45
47
  }
46
48
  }
47
49
  if (!existingToken) {
48
- brandNewToken = mintInStore(store, familyToken, subKey, MUST_CREATE)
50
+ brandNewToken = mintInStore(MUST_CREATE, store, familyToken, subKey)
49
51
  token = brandNewToken
50
52
  } else {
51
53
  token = existingToken
@@ -56,7 +58,7 @@ export function reduceReference<T, K extends Canonical, E>(
56
58
  subKey = params[1]
57
59
  existingToken = seekInStore(store, family, subKey)
58
60
  if (!existingToken) {
59
- brandNewToken = mintInStore(store, family, subKey, MUST_CREATE)
61
+ brandNewToken = mintInStore(MUST_CREATE, store, family, subKey)
60
62
  token = brandNewToken
61
63
  } else {
62
64
  token = existingToken
@@ -1,30 +1,3 @@
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/has-role"
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
1
  export * from "./arbitrary"
29
2
  export * from "./atom"
30
3
  export * from "./caching"
@@ -36,6 +9,7 @@ export * from "./get-environment-data"
36
9
  export * from "./get-state"
37
10
  export * from "./get-trace"
38
11
  export * from "./install-into-store"
12
+ export * from "./is-fn"
39
13
  export * from "./join"
40
14
  export * from "./junction"
41
15
  export * from "./keys"
@@ -48,202 +22,10 @@ export * from "./overlays"
48
22
  export * from "./reserved-keys"
49
23
  export * from "./selector"
50
24
  export * from "./set-state"
25
+ export type * from "./state-types"
51
26
  export * from "./store"
52
27
  export * from "./subject"
53
28
  export * from "./subscribe"
54
29
  export * from "./timeline"
55
30
  export * from "./transaction"
56
31
  export type * from "./utility-types"
57
-
58
- export type AtomIOState = {
59
- key: string
60
- family?: FamilyMetadata
61
- install: (store: RootStore) => void
62
- subject: Subject<StateUpdate<any>>
63
- }
64
- export type RegularAtom<T, E> = Flat<
65
- AtomIOState & {
66
- type: `atom`
67
- default: T | (() => T)
68
- cleanup?: () => void
69
- internalRoles?: internalRole[]
70
- catch?: readonly Ctor<E>[]
71
- }
72
- >
73
- export type MutableAtom<T extends Transceiver<any, any, any>> = Flat<
74
- AtomIOState & {
75
- type: `mutable_atom`
76
- class: ConstructorOf<T>
77
- cleanup?: () => void
78
- }
79
- >
80
- export type Atom<T, E> =
81
- | RegularAtom<T, E>
82
- | (T extends Transceiver<any, any, any> ? MutableAtom<T> : never)
83
-
84
- export type WritableHeldSelector<T> = Flat<
85
- AtomIOState & {
86
- type: `writable_held_selector`
87
- const: T
88
- getFrom: (target: Store) => T
89
- setSelf: (newValue: T) => void
90
- }
91
- >
92
- export type ReadonlyHeldSelector<T> = Flat<
93
- AtomIOState & {
94
- type: `readonly_held_selector`
95
- const: T
96
- getFrom: (target: Store) => T
97
- }
98
- >
99
- export type WritablePureSelector<T, E> = Flat<
100
- AtomIOState & {
101
- type: `writable_pure_selector`
102
- getFrom: (target: Store) => E | T
103
- setSelf: (newValue: T) => void
104
- catch?: readonly Ctor<E>[]
105
- }
106
- >
107
- export type ReadonlyPureSelector<T, E> = Flat<
108
- AtomIOState & {
109
- type: `readonly_pure_selector`
110
- getFrom: (target: Store) => E | T
111
- catch?: readonly Ctor<E>[]
112
- }
113
- >
114
- export type ReadonlySelector<T, E> =
115
- | ReadonlyHeldSelector<T>
116
- | ReadonlyPureSelector<T, E>
117
- export type WritableSelector<T, E> =
118
- | WritableHeldSelector<T>
119
- | WritablePureSelector<T, E>
120
- export type HeldSelector<T> = ReadonlyHeldSelector<T> | WritableHeldSelector<T>
121
- export type PureSelector<T, E> =
122
- | ReadonlyPureSelector<T, E>
123
- | WritablePureSelector<T, E>
124
- export type Selector<T, E> =
125
- | ReadonlyHeldSelector<T>
126
- | ReadonlyPureSelector<T, E>
127
- | WritableHeldSelector<T>
128
- | WritablePureSelector<T, E>
129
-
130
- export type WritableState<T, E> = Atom<T, E> | WritableSelector<T, E>
131
- export type ReadableState<T, E> = Atom<T, E> | Selector<T, E>
132
-
133
- // biome-ignore format: intersection
134
- export type RegularAtomFamily<T, K extends Canonical, E = never> =
135
- & Flat<
136
- & RegularAtomFamilyToken<T, K, E>
137
- & {
138
- create: <Key extends K>(key: Key) => RegularAtomToken<T, Key, E>
139
- default: T | ((key: K) => T)
140
- install: (store: RootStore) => void
141
- internalRoles: string[] | undefined
142
- subject: Subject<StateLifecycleEvent<RegularAtomToken<T, K, E>>>
143
- }
144
- >
145
-
146
- // biome-ignore format: intersection
147
- export type MutableAtomFamily<
148
- T extends Transceiver<any, any, any>,
149
- K extends Canonical,
150
- > =
151
- & Flat<
152
- & MutableAtomFamilyToken<T, K>
153
- & {
154
- create: <Key extends K>(key: Key) => MutableAtomToken<T, Key>
155
- class: ConstructorOf<T>
156
- install: (store: RootStore) => void
157
- internalRoles: string[] | undefined
158
- subject: Subject<StateLifecycleEvent<MutableAtomToken<T>>>
159
- }
160
- >
161
-
162
- export type AtomFamily<T, K extends Canonical, E> =
163
- | MutableAtomFamily<T extends Transceiver<any, any, any> ? T : never, K>
164
- | RegularAtomFamily<T, K, E>
165
-
166
- // biome-ignore format: intersection
167
- export type WritablePureSelectorFamily<T, K extends Canonical, E> =
168
- & Flat<
169
- & WritablePureSelectorFamilyToken<T, K, E>
170
- & {
171
- create: <Key extends K>(key: Key) => WritablePureSelectorToken<T, Key, E>
172
- default: (key: K) => T,
173
- install: (store: RootStore) => void
174
- internalRoles: string[] | undefined
175
- subject: Subject<StateLifecycleEvent<WritablePureSelectorToken<T, K, E>>>
176
- }
177
- >
178
-
179
- // biome-ignore format: intersection
180
- export type WritableHeldSelectorFamily<T , K extends Canonical> =
181
- & Flat<
182
- & WritableHeldSelectorFamilyToken<T, K>
183
- & {
184
- create: <Key extends K>(key: Key) => WritableHeldSelectorToken<T, Key>
185
- default: (key: K) => T,
186
- install: (store: RootStore) => void
187
- internalRoles: string[] | undefined
188
- subject: Subject<StateLifecycleEvent<WritableHeldSelectorToken<T, K>>>
189
- }
190
- >
191
-
192
- // biome-ignore format: intersection
193
- export type ReadonlyPureSelectorFamily<T, K extends Canonical, E> =
194
- & Flat<
195
- & ReadonlyPureSelectorFamilyToken<T, K, E>
196
- & {
197
- create: <Key extends K>(key: Key) => ReadonlyPureSelectorToken<T, Key, E>
198
- default: (key: K) => T,
199
- install: (store: RootStore) => void
200
- internalRoles: string[] | undefined
201
- subject: Subject<StateLifecycleEvent<ReadonlyPureSelectorToken<T, K, E>>>
202
- }
203
- >
204
-
205
- // biome-ignore format: intersection
206
- export type ReadonlyHeldSelectorFamily<T , K extends Canonical> =
207
- & Flat<
208
- & ReadonlyHeldSelectorFamilyToken<T, K>
209
- & {
210
- create: <Key extends K>(key: Key) => ReadonlyHeldSelectorToken<T, Key>
211
- default: (key: K) => T,
212
- install: (store: RootStore) => void
213
- internalRoles: string[] | undefined
214
- subject: Subject<StateLifecycleEvent<ReadonlyHeldSelectorToken<T>>>
215
- }
216
- >
217
-
218
- export type PureSelectorFamily<T, K extends Canonical, E> =
219
- | ReadonlyPureSelectorFamily<T, K, E>
220
- | WritablePureSelectorFamily<T, K, E>
221
-
222
- export type HeldSelectorFamily<T, K extends Canonical> =
223
- | ReadonlyHeldSelectorFamily<T, K>
224
- | WritableHeldSelectorFamily<T, K>
225
-
226
- export type ReadonlySelectorFamily<T, K extends Canonical, E> =
227
- | ReadonlyHeldSelectorFamily<T, K>
228
- | ReadonlyPureSelectorFamily<T, K, E>
229
-
230
- export type WritableSelectorFamily<T, K extends Canonical, E> =
231
- | WritableHeldSelectorFamily<T, K>
232
- | WritablePureSelectorFamily<T, K, E>
233
-
234
- export type SelectorFamily<T, K extends Canonical, E> =
235
- | HeldSelectorFamily<T, K>
236
- | PureSelectorFamily<T, K, E>
237
-
238
- export type WritableFamily<T, K extends Canonical, E> =
239
- | AtomFamily<T, K, E>
240
- | WritableSelectorFamily<T, K, E>
241
- export type ReadableFamily<T, K extends Canonical, E> =
242
- | AtomFamily<T, K, E>
243
- | SelectorFamily<T, K, E>
244
-
245
- export type AtomIOInternalResource =
246
- | ReadableFamily<any, any, any>
247
- | ReadableState<any, any>
248
- | Timeline<any>
249
- | Transaction<any>
@@ -19,7 +19,6 @@ import { getFromStore } from "./get-state"
19
19
  import { getTrace } from "./get-trace"
20
20
  import { newest } from "./lineage"
21
21
  import type { Store } from "./store"
22
- import { IMPLICIT } from "./store"
23
22
  import type { RootStore } from "./transaction"
24
23
  import { createTransaction, isChildStore } from "./transaction"
25
24
 
@@ -30,8 +29,8 @@ export type Molecule<K extends Canonical> = {
30
29
  }
31
30
 
32
31
  export function makeRootMoleculeInStore<S extends string>(
32
+ store: Store,
33
33
  key: S,
34
- store: Store = IMPLICIT.STORE,
35
34
  ): S {
36
35
  const molecule = {
37
36
  key,
@@ -10,11 +10,12 @@ import { PRETTY_TOKEN_TYPES } from "atom.io"
10
10
  import type { Canonical } from "atom.io/json"
11
11
  import { stringifyJson } from "atom.io/json"
12
12
 
13
- import type { MutableAtomFamily, RootStore } from ".."
14
- import { createWritablePureSelectorFamily } from ".."
13
+ import { createWritablePureSelectorFamily } from "../families"
15
14
  import { newest } from "../lineage"
16
15
  import { createMutableAtom } from "../mutable"
16
+ import type { MutableAtomFamily } from "../state-types"
17
17
  import { Subject } from "../subject"
18
+ import type { RootStore } from "../transaction"
18
19
  import { FamilyTracker } from "./tracker-family"
19
20
  import type { AsJSON, Transceiver } from "./transceiver"
20
21
 
@@ -5,12 +5,14 @@ import type {
5
5
  UpdateHandler,
6
6
  } from "atom.io"
7
7
 
8
- import type { MutableAtom, RootStore } from ".."
9
- import { createStandaloneSelector, resetInStore, setIntoStore } from ".."
10
8
  import { newest } from "../lineage"
9
+ import { createStandaloneSelector } from "../selector"
10
+ import { resetInStore, setIntoStore } from "../set-state"
11
+ import type { MutableAtom } from "../state-types"
11
12
  import { deposit, type Store } from "../store"
12
13
  import { Subject } from "../subject"
13
14
  import { subscribeToState } from "../subscribe"
15
+ import type { RootStore } from "../transaction"
14
16
  import { Tracker } from "./tracker"
15
17
  import type { Transceiver } from "./transceiver"
16
18
 
@@ -1,8 +1,8 @@
1
1
  import type { MutableAtomFamilyToken } from "atom.io"
2
2
  import type { Canonical, Json } from "atom.io/json"
3
3
 
4
- import type { WritablePureSelectorFamily } from ".."
5
4
  import { newest } from "../lineage"
5
+ import type { WritablePureSelectorFamily } from "../state-types"
6
6
  import type { Store } from "../store"
7
7
  import type { Transceiver } from "./transceiver"
8
8
 
@@ -1,8 +1,8 @@
1
1
  import type { MutableAtomFamilyToken } from "atom.io"
2
2
  import type { Json } from "atom.io/json"
3
3
 
4
- import type { RegularAtomFamily } from ".."
5
4
  import { newest } from "../lineage"
5
+ import type { RegularAtomFamily } from "../state-types"
6
6
  import type { Store } from "../store"
7
7
  import type { SignalFrom, Transceiver } from "./transceiver"
8
8
 
@@ -2,9 +2,10 @@ import type { MutableAtomToken, StateLifecycleEvent } from "atom.io"
2
2
  import type { Canonical } from "atom.io/json"
3
3
  import { parseJson } from "atom.io/json"
4
4
 
5
- import type { MutableAtomFamily, RegularAtomFamily, RootStore } from ".."
6
5
  import { createRegularAtomFamily } from "../families"
6
+ import type { MutableAtomFamily, RegularAtomFamily } from "../state-types"
7
7
  import { withdraw } from "../store"
8
+ import type { RootStore } from "../transaction"
8
9
  import { Tracker } from "./tracker"
9
10
  import type { SignalFrom, Transceiver } from "./transceiver"
10
11
 
@@ -1,14 +1,17 @@
1
- import type { FamilyMetadata, MutableAtomToken, RegularAtomToken } from "atom.io"
1
+ import type {
2
+ FamilyMetadata,
3
+ MutableAtomToken,
4
+ RegularAtomToken,
5
+ StateUpdate,
6
+ } from "atom.io"
2
7
 
3
- import type { Store } from ".."
4
- import {
5
- getFromStore,
6
- newest,
7
- setIntoStore,
8
- subscribeToState,
9
- subscribeToTimeline,
10
- } from ".."
11
8
  import { createRegularAtom } from "../atom"
9
+ import { getFromStore } from "../get-state"
10
+ import { newest } from "../lineage"
11
+ import { setIntoStore } from "../set-state"
12
+ import { JOIN_OP, operateOnStore } from "../set-state/operate-on-store"
13
+ import type { Store } from "../store"
14
+ import { subscribeToState, subscribeToTimeline } from "../subscribe"
12
15
  import { isChildStore } from "../transaction/is-root-store"
13
16
  import type { SignalFrom, Transceiver } from "./transceiver"
14
17
 
@@ -64,9 +67,9 @@ export class Tracker<T extends Transceiver<any, any, any>> {
64
67
  const storeStatus = isChildStore(target)
65
68
  ? target.transactionMeta.update.token.key
66
69
  : `main`
67
- const subscriptionKey = `tracker:${storeName}:${storeStatus}:${stateKey}`
70
+ const subscriptionKey = `tracker-from-core:${storeName}:${storeStatus}:${stateKey}`
68
71
  const trackerCapturesOutboundSignal = (update: SignalFrom<T>) => {
69
- setIntoStore(target, latestSignalState, update)
72
+ operateOnStore(JOIN_OP, target, latestSignalState, update)
70
73
  }
71
74
  const originalInnerValue = getFromStore(target, mutableState)
72
75
  this.unsubscribeFromInnerValue = originalInnerValue.subscribe(
@@ -94,60 +97,69 @@ export class Tracker<T extends Transceiver<any, any, any>> {
94
97
  latestSignalState: RegularAtomToken<SignalFrom<T> | null>,
95
98
  target: Store,
96
99
  ): void {
97
- const subscriptionKey = `tracker:${target.config.name}:${
98
- isChildStore(target) ? target.transactionMeta.update.token.key : `main`
99
- }:${mutableState.key}`
100
+ const stateKey = mutableState.key
101
+ const storeName = target.config.name
102
+ const storeStatus = isChildStore(target)
103
+ ? target.transactionMeta.update.token.key
104
+ : `main`
105
+ const subscriptionKey = `tracker-to-core:${storeName}:${storeStatus}:${stateKey}`
100
106
  subscribeToState(
101
107
  target,
102
108
  latestSignalState,
103
109
  subscriptionKey,
104
- function trackerCapturesInboundSignal({ newValue, oldValue }) {
105
- const timelineId = target.timelineTopics.getRelatedKey(
106
- latestSignalState.key,
107
- )
108
-
109
- if (timelineId && target.timelines.get(timelineId)?.timeTraveling) {
110
- const unsubscribe = subscribeToTimeline(
111
- target,
112
- { key: timelineId, type: `timeline` },
113
- subscriptionKey,
114
- function trackerWaitsForTimeTravelToFinish(update) {
115
- unsubscribe()
116
- setIntoStore(target, mutableState, (transceiver) => {
117
- if (update === `redo` && newValue) {
118
- transceiver.do(newValue)
119
- } else if (update === `undo` && oldValue) {
120
- transceiver.undo(oldValue)
121
- }
122
- return transceiver
123
- })
124
- },
110
+ Object.assign(
111
+ function trackerCapturesInboundSignal({
112
+ newValue,
113
+ oldValue,
114
+ }: StateUpdate<SignalFrom<T> | null>) {
115
+ const timelineId = target.timelineTopics.getRelatedKey(
116
+ latestSignalState.key,
125
117
  )
126
- return
127
- }
128
118
 
129
- const mutable = getFromStore(target, mutableState)
130
- const updateNumber = mutable.getUpdateNumber(newValue)
131
- const eventOffset = updateNumber - mutable.cacheUpdateNumber
132
- if (newValue && eventOffset === 1) {
133
- setIntoStore(
134
- target,
135
- mutableState,
136
- (transceiver) => (transceiver.do(newValue), transceiver),
137
- )
138
- } else {
139
- const expected = mutable.cacheUpdateNumber + 1
140
- target.logger.info(
141
- `❌`,
142
- `mutable_atom`,
143
- mutableState.key,
144
- `could not be updated. Expected update number`,
145
- expected,
146
- `but got`,
147
- updateNumber,
148
- )
149
- }
150
- },
119
+ if (timelineId && target.timelines.get(timelineId)?.timeTraveling) {
120
+ const unsubscribe = subscribeToTimeline(
121
+ target,
122
+ { key: timelineId, type: `timeline` },
123
+ subscriptionKey,
124
+ function trackerWaitsForTimeTravelToFinish(update) {
125
+ unsubscribe()
126
+ setIntoStore(target, mutableState, (transceiver) => {
127
+ if (update === `redo` && newValue) {
128
+ transceiver.do(newValue)
129
+ } else if (update === `undo` && oldValue) {
130
+ transceiver.undo(oldValue)
131
+ }
132
+ return transceiver
133
+ })
134
+ },
135
+ )
136
+ return
137
+ }
138
+
139
+ const mutable = getFromStore(target, mutableState)
140
+ const updateNumber = mutable.getUpdateNumber(newValue)
141
+ const eventOffset = updateNumber - mutable.cacheUpdateNumber
142
+ if (newValue && eventOffset === 1) {
143
+ setIntoStore(
144
+ target,
145
+ mutableState,
146
+ (transceiver) => (transceiver.do(newValue), transceiver),
147
+ )
148
+ } else {
149
+ const expected = mutable.cacheUpdateNumber + 1
150
+ target.logger.info(
151
+ `❌`,
152
+ `mutable_atom`,
153
+ mutableState.key,
154
+ `could not be updated. Expected update number`,
155
+ expected,
156
+ `but got`,
157
+ updateNumber,
158
+ )
159
+ }
160
+ },
161
+ { inboundTracker: true },
162
+ ),
151
163
  )
152
164
  }
153
165
 
@@ -1,6 +1,6 @@
1
- import type { PureSelector, RegularAtom } from "."
2
1
  import { writeToCache } from "./caching"
3
2
  import { isFn } from "./is-fn"
3
+ import type { PureSelector, RegularAtom } from "./state-types"
4
4
  import type { Store } from "./store"
5
5
 
6
6
  export function safeCompute<T, E>(
@@ -4,11 +4,12 @@ import type {
4
4
  ReadonlyHeldSelectorToken,
5
5
  } from "atom.io"
6
6
 
7
- import type { ReadonlyHeldSelector, RootStore } from ".."
8
7
  import { writeToCache } from "../caching"
9
8
  import { newest } from "../lineage"
9
+ import type { ReadonlyHeldSelector } from "../state-types"
10
10
  import type { Store } from "../store"
11
11
  import { Subject } from "../subject"
12
+ import type { RootStore } from "../transaction"
12
13
  import { registerSelector } from "./register-selector"
13
14
 
14
15
  export function createReadonlyHeldSelector<T extends object>(
@@ -6,11 +6,12 @@ import type {
6
6
  } from "atom.io"
7
7
  import type { Canonical } from "atom.io/json"
8
8
 
9
- import type { ReadonlyPureSelector, RootStore } from ".."
10
9
  import { writeToCache } from "../caching"
11
10
  import { newest } from "../lineage"
11
+ import type { ReadonlyPureSelector } from "../state-types"
12
12
  import type { Store } from "../store"
13
13
  import { Subject } from "../subject"
14
+ import type { RootStore } from "../transaction"
14
15
  import { registerSelector } from "./register-selector"
15
16
 
16
17
  export function createReadonlyPureSelector<T, K extends Canonical, E>(
@@ -4,11 +4,12 @@ import type {
4
4
  WritableHeldSelectorToken,
5
5
  } from "atom.io"
6
6
 
7
- import type { RootStore, WritableHeldSelector } from ".."
8
7
  import { writeToCache } from "../caching"
9
8
  import { newest } from "../lineage"
9
+ import type { WritableHeldSelector } from "../state-types"
10
10
  import type { Store } from "../store"
11
11
  import { Subject } from "../subject"
12
+ import type { RootStore } from "../transaction"
12
13
  import { registerSelector } from "./register-selector"
13
14
 
14
15
  export function createWritableHeldSelector<T extends object>(
@@ -6,11 +6,12 @@ import type {
6
6
  } from "atom.io"
7
7
  import type { Canonical } from "atom.io/json"
8
8
 
9
- import type { RootStore, WritablePureSelector } from ".."
10
9
  import { writeToCache } from "../caching"
11
10
  import { newest } from "../lineage"
11
+ import type { WritablePureSelector } from "../state-types"
12
12
  import type { Store } from "../store"
13
13
  import { Subject } from "../subject"
14
+ import type { RootStore } from "../transaction"
14
15
  import { registerSelector } from "./register-selector"
15
16
 
16
17
  export function createWritablePureSelector<T, K extends Canonical, E>(
@@ -1,7 +1,8 @@
1
1
  import type { SelectorFamilyToken, SelectorToken } from "atom.io"
2
2
 
3
- import type { Store } from ".."
4
- import { isChildStore, newest, withdraw } from ".."
3
+ import { newest } from "../lineage"
4
+ import { type Store, withdraw } from "../store"
5
+ import { isChildStore } from "../transaction"
5
6
 
6
7
  export function disposeSelector(
7
8
  store: Store,