atom.io 0.34.2 → 0.35.0

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 (51) hide show
  1. package/dist/internal/index.d.ts +32 -41
  2. package/dist/internal/index.d.ts.map +1 -1
  3. package/dist/internal/index.js +106 -128
  4. package/dist/internal/index.js.map +1 -1
  5. package/dist/json/index.d.ts +7 -7
  6. package/dist/json/index.js +2 -2
  7. package/dist/json/index.js.map +1 -1
  8. package/dist/main/index.d.ts +779 -886
  9. package/dist/main/index.d.ts.map +1 -1
  10. package/dist/main/index.js +46 -14
  11. package/dist/main/index.js.map +1 -1
  12. package/dist/react-devtools/index.js +10 -10
  13. package/dist/react-devtools/index.js.map +1 -1
  14. package/dist/realtime/index.d.ts.map +1 -1
  15. package/dist/realtime/index.js +3 -5
  16. package/dist/realtime/index.js.map +1 -1
  17. package/dist/realtime-client/index.js +10 -10
  18. package/dist/realtime-client/index.js.map +1 -1
  19. package/dist/realtime-server/index.d.ts.map +1 -1
  20. package/dist/realtime-server/index.js +8 -10
  21. package/dist/realtime-server/index.js.map +1 -1
  22. package/package.json +4 -4
  23. package/src/internal/atom/create-regular-atom.ts +1 -0
  24. package/src/internal/atom/index.ts +0 -1
  25. package/src/internal/families/index.ts +0 -1
  26. package/src/internal/index.ts +111 -89
  27. package/src/internal/join/join-internal.ts +3 -4
  28. package/src/internal/mutable/create-mutable-atom-family.ts +0 -1
  29. package/src/internal/mutable/create-mutable-atom.ts +1 -1
  30. package/src/internal/selector/register-selector.ts +2 -2
  31. package/src/json/entries.ts +7 -7
  32. package/src/main/atom.ts +67 -114
  33. package/src/main/dispose-state.ts +0 -2
  34. package/src/main/find-state.ts +3 -9
  35. package/src/main/get-state.ts +0 -2
  36. package/src/main/index.ts +1 -176
  37. package/src/main/join.ts +0 -7
  38. package/src/main/reset-state.ts +0 -2
  39. package/src/main/selector.ts +5 -72
  40. package/src/main/set-state.ts +1 -4
  41. package/src/main/silo.ts +14 -5
  42. package/src/main/subscribe.ts +0 -7
  43. package/src/main/timeline.ts +1 -18
  44. package/src/main/tokens.ts +247 -0
  45. package/src/main/transaction.ts +17 -55
  46. package/src/main/validators.ts +1 -1
  47. package/src/react-devtools/store.ts +61 -45
  48. package/src/realtime/shared-room-store.ts +3 -5
  49. package/src/realtime-server/realtime-server-stores/server-user-store.ts +3 -5
  50. package/src/internal/atom/create-standalone-atom.ts +0 -39
  51. package/src/internal/families/create-atom-family.ts +0 -38
@@ -23,6 +23,7 @@ import type { Store } from "./store"
23
23
  import type { Subject } from "./subject"
24
24
  import type { Timeline } from "./timeline"
25
25
  import type { Transaction } from "./transaction"
26
+ import type { Flat } from "./utility-types"
26
27
 
27
28
  export * from "./arbitrary"
28
29
  export * from "./atom"
@@ -61,45 +62,56 @@ export type AtomIOState = {
61
62
  install: (store: Store) => void
62
63
  subject: Subject<{ newValue: any; oldValue: any }>
63
64
  }
64
-
65
- export type RegularAtom<T> = AtomIOState & {
66
- type: `atom`
67
- default: T | (() => T)
68
- cleanup?: () => void
69
- }
65
+ export type RegularAtom<T> = Flat<
66
+ AtomIOState & {
67
+ type: `atom`
68
+ default: T | (() => T)
69
+ cleanup?: () => void
70
+ }
71
+ >
70
72
  export type MutableAtom<
71
73
  T extends Transceiver<any>,
72
74
  J extends Json.Serializable,
73
- > = AtomIOState &
74
- JsonInterface<T, J> & {
75
- type: `mutable_atom`
76
- default: () => T
77
- cleanup?: () => void
78
- }
75
+ > = Flat<
76
+ AtomIOState &
77
+ JsonInterface<T, J> & {
78
+ type: `mutable_atom`
79
+ default: () => T
80
+ cleanup?: () => void
81
+ }
82
+ >
79
83
  export type Atom<T> =
80
84
  | RegularAtom<T>
81
85
  | (T extends Transceiver<any> ? MutableAtom<T, any> : never)
82
86
 
83
- export type WritableHeldSelector<T> = AtomIOState & {
84
- type: `writable_held_selector`
85
- const: T
86
- get: () => T
87
- set: (newValue: T | ((oldValue: T) => T)) => void
88
- }
89
- export type ReadonlyHeldSelector<T> = AtomIOState & {
90
- type: `readonly_held_selector`
91
- const: T
92
- get: () => T
93
- }
94
- export type WritablePureSelector<T> = AtomIOState & {
95
- type: `writable_pure_selector`
96
- get: () => T
97
- set: (newValue: T | ((oldValue: T) => T)) => void
98
- }
99
- export type ReadonlyPureSelector<T> = AtomIOState & {
100
- type: `readonly_pure_selector`
101
- get: () => T
102
- }
87
+ export type WritableHeldSelector<T> = Flat<
88
+ AtomIOState & {
89
+ type: `writable_held_selector`
90
+ const: T
91
+ get: () => T
92
+ set: (newValue: T | ((oldValue: T) => T)) => void
93
+ }
94
+ >
95
+ export type ReadonlyHeldSelector<T> = Flat<
96
+ AtomIOState & {
97
+ type: `readonly_held_selector`
98
+ const: T
99
+ get: () => T
100
+ }
101
+ >
102
+ export type WritablePureSelector<T> = Flat<
103
+ AtomIOState & {
104
+ type: `writable_pure_selector`
105
+ get: () => T
106
+ set: (newValue: T | ((oldValue: T) => T)) => void
107
+ }
108
+ >
109
+ export type ReadonlyPureSelector<T> = Flat<
110
+ AtomIOState & {
111
+ type: `readonly_pure_selector`
112
+ get: () => T
113
+ }
114
+ >
103
115
  export type ReadonlySelector<T> =
104
116
  | ReadonlyHeldSelector<T>
105
117
  | ReadonlyPureSelector<T>
@@ -118,13 +130,13 @@ export type WritableState<T> = Atom<T> | WritableSelector<T>
118
130
  export type ReadableState<T> = Atom<T> | Selector<T>
119
131
 
120
132
  // biome-ignore format: intersection
121
- export type RegularAtomFamily<T, K extends Canonical> =
133
+ export type RegularAtomFamily<T, K extends Canonical> =
122
134
  & RegularAtomFamilyToken<T, K>
123
135
  & {
124
136
  (key: K): RegularAtomToken<T>
125
- subject: Subject<StateCreation<AtomToken<T>> | StateDisposal<AtomToken<T>>>
126
137
  install: (store: Store) => void
127
138
  internalRoles: string[] | undefined
139
+ subject: Subject<StateCreation<AtomToken<T>> | StateDisposal<AtomToken<T>>>
128
140
  }
129
141
 
130
142
  // biome-ignore format: intersection
@@ -132,75 +144,85 @@ export type MutableAtomFamily<
132
144
  T extends Transceiver<any>,
133
145
  J extends Json.Serializable,
134
146
  K extends Canonical,
135
- > =
136
- & JsonInterface<T, J>
137
- & MutableAtomFamilyToken<T, J, K>
138
- & {
139
- (key: K): MutableAtomToken<T, J>
140
- subject: Subject<StateCreation<MutableAtomToken<T, J>> | StateDisposal<MutableAtomToken<T, J>>>
141
- install: (store: Store) => void
142
- internalRoles: string[] | undefined
143
- }
147
+ > =
148
+ & Flat<
149
+ & JsonInterface<T, J>
150
+ & MutableAtomFamilyToken<T, J, K>
151
+ & {
152
+ install: (store: Store) => void
153
+ internalRoles: string[] | undefined
154
+ subject: Subject<StateCreation<MutableAtomToken<T, J>> | StateDisposal<MutableAtomToken<T, J>>>
155
+ }
156
+ >
157
+ & ((key: K) => MutableAtomToken<T, J>)
144
158
 
145
159
  export type AtomFamily<T, K extends Canonical = Canonical> =
146
160
  | MutableAtomFamily<T extends Transceiver<any> ? T : never, any, K>
147
161
  | RegularAtomFamily<T, K>
148
162
 
149
163
  // biome-ignore format: intersection
150
- export type WritablePureSelectorFamily<T, K extends Canonical> =
151
- & WritablePureSelectorFamilyToken<T, K>
152
- & ((key: K) => WritablePureSelectorToken<T>)
153
- & {
154
- default: (key: K) => T,
155
- subject: Subject<
156
- | StateCreation<WritablePureSelectorToken<T>>
157
- | StateDisposal<WritablePureSelectorToken<T>>
158
- >
159
- install: (store: Store) => void
160
- internalRoles : string[] | undefined
161
- }
164
+ export type WritablePureSelectorFamily<T, K extends Canonical> =
165
+ & Flat<
166
+ & WritablePureSelectorFamilyToken<T, K>
167
+ & {
168
+ default: (key: K) => T,
169
+ install: (store: Store) => void
170
+ internalRoles: string[] | undefined
171
+ subject: Subject<
172
+ | StateCreation<WritablePureSelectorToken<T>>
173
+ | StateDisposal<WritablePureSelectorToken<T>>
174
+ >
175
+ }
176
+ >
177
+ & ((key: K) => WritablePureSelectorToken<T>)
162
178
 
163
179
  // biome-ignore format: intersection
164
- export type WritableHeldSelectorFamily<T , K extends Canonical> =
165
- & WritableHeldSelectorFamilyToken<T, K>
166
- & ((key: K) => WritableHeldSelectorToken<T>)
167
- & {
168
- default: (key: K) => T,
169
- subject: Subject<
170
- | StateCreation<WritableHeldSelectorToken<T>>
171
- | StateDisposal<WritableHeldSelectorToken<T>>
172
- >
173
- install: (store: Store) => void
174
- internalRoles : string[] | undefined
175
- }
180
+ export type WritableHeldSelectorFamily<T , K extends Canonical> =
181
+ & Flat<
182
+ & WritableHeldSelectorFamilyToken<T, K>
183
+ & {
184
+ default: (key: K) => T,
185
+ install: (store: Store) => void
186
+ internalRoles: string[] | undefined
187
+ subject: Subject<
188
+ | StateCreation<WritableHeldSelectorToken<T>>
189
+ | StateDisposal<WritableHeldSelectorToken<T>>
190
+ >
191
+ }
192
+ >
193
+ & ((key: K) => WritableHeldSelectorToken<T>)
176
194
 
177
195
  // biome-ignore format: intersection
178
- export type ReadonlyPureSelectorFamily<T, K extends Canonical> =
179
- & ReadonlyPureSelectorFamilyToken<T, K>
196
+ export type ReadonlyPureSelectorFamily<T, K extends Canonical> =
197
+ & Flat<
198
+ & ReadonlyPureSelectorFamilyToken<T, K>
199
+ & {
200
+ default: (key: K) => T,
201
+ install: (store: Store) => void
202
+ internalRoles: string[] | undefined
203
+ subject: Subject<
204
+ | StateCreation<ReadonlyPureSelectorToken<T>>
205
+ | StateDisposal<ReadonlyPureSelectorToken<T>>
206
+ >
207
+ }
208
+ >
180
209
  & ((key: K) => ReadonlyPureSelectorToken<T>)
181
- & {
182
- default: (key: K) => T,
183
- subject: Subject<
184
- | StateCreation<ReadonlyPureSelectorToken<T>>
185
- | StateDisposal<ReadonlyPureSelectorToken<T>>
186
- >
187
- install: (store: Store) => void
188
- internalRoles : string[] | undefined
189
- }
190
210
 
191
211
  // biome-ignore format: intersection
192
- export type ReadonlyHeldSelectorFamily<T , K extends Canonical> =
193
- & ReadonlyHeldSelectorFamilyToken<T, K>
212
+ export type ReadonlyHeldSelectorFamily<T , K extends Canonical> =
213
+ & Flat<
214
+ & ReadonlyHeldSelectorFamilyToken<T, K>
215
+ & {
216
+ default: (key: K) => T,
217
+ install: (store: Store) => void
218
+ internalRoles: string[] | undefined
219
+ subject: Subject<
220
+ | StateCreation<ReadonlyHeldSelectorToken<T>>
221
+ | StateDisposal<ReadonlyHeldSelectorToken<T>>
222
+ >
223
+ }
224
+ >
194
225
  & ((key: K) => ReadonlyHeldSelectorToken<T>)
195
- & {
196
- default: (key: K) => T,
197
- subject: Subject<
198
- | StateCreation<ReadonlyHeldSelectorToken<T>>
199
- | StateDisposal<ReadonlyHeldSelectorToken<T>>
200
- >
201
- install: (store: Store) => void
202
- internalRoles : string[] | undefined
203
- }
204
226
 
205
227
  export type PureSelectorFamily<T, K extends Canonical> =
206
228
  | ReadonlyPureSelectorFamily<T, K>
@@ -8,8 +8,8 @@ import type {
8
8
  ReadonlyPureSelectorFamilyToken,
9
9
  RegularAtomFamilyToken,
10
10
  setState,
11
- SetterToolkit,
12
11
  Write,
12
+ WriterToolkit,
13
13
  } from "atom.io"
14
14
  import { Anarchy } from "atom.io"
15
15
  import type { Canonical, Json, stringified } from "atom.io/json"
@@ -129,7 +129,7 @@ export class Join<
129
129
  BSide
130
130
  > = CompoundTypedKey<`content`, ASide, BSide>,
131
131
  > {
132
- private toolkit: SetterToolkit
132
+ private toolkit: WriterToolkit
133
133
  public options: JoinOptions<ASide, AType, BSide, BType, Cardinality, Content>
134
134
  public defaultContent: Content | undefined
135
135
  public molecules: Map<string, Molecule<any>> = new Map()
@@ -150,7 +150,7 @@ export class Join<
150
150
  >
151
151
  }
152
152
  public transact(
153
- toolkit: SetterToolkit,
153
+ toolkit: WriterToolkit,
154
154
  run: (join: Join<ASide, AType, BSide, BType, Cardinality, Content>) => void,
155
155
  ): void {
156
156
  const originalToolkit = this.toolkit
@@ -202,7 +202,6 @@ export class Join<
202
202
  {
203
203
  key: `${options.key}/relatedKeys`,
204
204
  default: () => new SetRTX(),
205
- mutable: true,
206
205
  fromJson: (json) => SetRTX.fromJSON(json),
207
206
  toJson: (set) => set.toJSON(),
208
207
  },
@@ -59,7 +59,6 @@ export function createMutableAtomFamily<
59
59
  default: () => options.default(key),
60
60
  toJson: options.toJson,
61
61
  fromJson: options.fromJson,
62
- mutable: true,
63
62
  }
64
63
  if (options.effects) {
65
64
  individualOptions.effects = options.effects(key)
@@ -88,6 +88,6 @@ export function createMutableAtom<
88
88
  if (!family) {
89
89
  selectJson(token, options, store)
90
90
  }
91
-
91
+ store.on.atomCreation.next(token)
92
92
  return token
93
93
  }
@@ -3,9 +3,9 @@ import type {
3
3
  ReadableFamilyToken,
4
4
  ReadableToken,
5
5
  setState,
6
- SetterToolkit,
7
6
  WritableFamilyToken,
8
7
  WritableToken,
8
+ WriterToolkit,
9
9
  } from "atom.io"
10
10
  import type { Json } from "atom.io/json"
11
11
 
@@ -27,7 +27,7 @@ export const registerSelector = (
27
27
  | `writable_pure_selector`,
28
28
  selectorKey: string,
29
29
  covered: Set<string>,
30
- ): SetterToolkit => ({
30
+ ): WriterToolkit => ({
31
31
  get: (
32
32
  ...params:
33
33
  | [ReadableFamilyToken<any, any>, Json.Serializable]
@@ -1,32 +1,32 @@
1
1
  import type { Count, Flat } from "atom.io/internal"
2
2
 
3
- /** @public Tuples of `[key, value]` pairs, as returned from `Object.entries` */
3
+ /** Tuples of `[key, value]` pairs, as returned from `Object.entries` */
4
4
  export type Entries<K extends PropertyKey = PropertyKey, V = any> = [K, V][]
5
5
 
6
- /** @public The collective or "union" type of the keys in a set of entries */
6
+ /** The collective or "union" type of the keys in a set of entries */
7
7
  export type KeyOfEntries<E extends Entries> = E extends [infer K, any][]
8
8
  ? K
9
9
  : never
10
10
 
11
- /** @public The type of the value of entry `K` in a set of entries `E` */
11
+ /** The type of the value of entry `K` in a set of entries `E` */
12
12
  export type ValueOfEntry<E extends Entries, K extends KeyOfEntries<E>> = {
13
13
  [P in Count<E[`length`]>]: E[P] extends [K, infer V] ? V : never
14
14
  }[Count<E[`length`]>]
15
15
 
16
- /** @public The type of a set of entries `E` in object form */
16
+ /** The type of a set of entries `E` in object form */
17
17
  export type FromEntries<E extends Entries> = Flat<{
18
18
  [K in KeyOfEntries<E>]: ValueOfEntry<E, K>
19
19
  }>
20
20
 
21
- /** @public Typed form of `Object.fromEntries` */
21
+ /** Typed form of `Object.fromEntries` */
22
22
  export function fromEntries<E extends Entries>(entries: E): FromEntries<E> {
23
23
  return Object.fromEntries(entries) as FromEntries<E>
24
24
  }
25
25
 
26
- /** @public The type of an object T in {@link Entries} form */
26
+ /** The type of an object T in {@link Entries} form */
27
27
  export type ToEntries<T extends object> = Entries<keyof T, T[keyof T]>
28
28
 
29
- /** @public Typed form of `Object.entries` */
29
+ /** Typed form of `Object.entries` */
30
30
  export function toEntries<T extends object>(obj: T): ToEntries<T> {
31
31
  return Object.entries(obj) as Entries<keyof T, T[keyof T]>
32
32
  }
package/src/main/atom.ts CHANGED
@@ -1,15 +1,54 @@
1
1
  import type { Transceiver } from "atom.io/internal"
2
2
  import {
3
- createAtomFamily,
4
- createStandaloneAtom,
3
+ createMutableAtom,
4
+ createMutableAtomFamily,
5
+ createRegularAtom,
6
+ createRegularAtomFamily,
5
7
  IMPLICIT,
6
8
  } from "atom.io/internal"
7
9
  import type { Canonical, Json, JsonInterface } from "atom.io/json"
8
10
 
9
- import type { AtomToken, MutableAtomToken, RegularAtomToken, Setter } from "."
11
+ import type { Setter } from "./set-state"
12
+ import type {
13
+ MutableAtomFamilyToken,
14
+ MutableAtomToken,
15
+ RegularAtomFamilyToken,
16
+ RegularAtomToken,
17
+ } from "./tokens"
10
18
 
19
+ export type RegularAtomOptions<T> = {
20
+ /** The unique identifier of the atom */
21
+ key: string
22
+ /** The starting value of the atom */
23
+ default: T | (() => T)
24
+ /** Hooks used to run side effects when the atom is set */
25
+ effects?: AtomEffect<T>[]
26
+ }
27
+ /**
28
+ * Create a regular atom, a global reactive variable in the implicit store
29
+ * @param options - {@link RegularAtomOptions}.
30
+ * @returns
31
+ * A reference to the atom created: a {@link RegularAtomToken}
32
+ */
33
+ export function atom<T>(options: RegularAtomOptions<T>): RegularAtomToken<T> {
34
+ return createRegularAtom(IMPLICIT.STORE, options, undefined)
35
+ }
36
+
37
+ // biome-ignore format: intersection
38
+ export type MutableAtomOptions<
39
+ T extends Transceiver<any>,
40
+ J extends Json.Serializable,
41
+ > =
42
+ & JsonInterface<T, J>
43
+ & {
44
+ /** The unique identifier of the atom */
45
+ key: string
46
+ /** A function to create an initial value for the atom */
47
+ default: () => T
48
+ /** Hooks used to run side effects when the atom is set */
49
+ effects?: AtomEffect<T>[]
50
+ }
11
51
  /**
12
- * @public
13
52
  * Create a mutable atom, a global reactive variable in the implicit store
14
53
  *
15
54
  * The value of a mutable atom must be some kind of {@link Transceiver}.
@@ -17,27 +56,21 @@ import type { AtomToken, MutableAtomToken, RegularAtomToken, Setter } from "."
17
56
  * @param options - {@link MutableAtomOptions}.
18
57
  * @returns
19
58
  * A reference to the atom created: a {@link MutableAtomToken}
20
- * @overload Mutable
21
59
  */
22
- export function atom<T extends Transceiver<any>, J extends Json.Serializable>(
23
- options: MutableAtomOptions<T, J>,
24
- ): MutableAtomToken<T, J>
60
+ export function mutableAtom<
61
+ T extends Transceiver<any>,
62
+ J extends Json.Serializable,
63
+ >(options: MutableAtomOptions<T, J>): MutableAtomToken<T, J> {
64
+ return createMutableAtom(IMPLICIT.STORE, options, undefined)
65
+ }
66
+
25
67
  /**
26
- * @public
27
- * Create a regular atom, a global reactive variable in the implicit store
28
- * @param options - {@link RegularAtomOptions}.
68
+ * A function that runs side effects when the atom is set
69
+ * @param tools - {@link Effectors} that can be used to run side effects
29
70
  * @returns
30
- * A reference to the atom created: a {@link RegularAtomToken}
31
- * @overload Regular
71
+ * Optionally, a cleanup function that will be called when the atom is disposed
32
72
  */
33
- export function atom<T>(options: RegularAtomOptions<T>): RegularAtomToken<T>
34
- export function atom(
35
- options: MutableAtomOptions<any, any> | RegularAtomOptions<any>,
36
- ): AtomToken<any> {
37
- return createStandaloneAtom(IMPLICIT.STORE, options)
38
- }
39
-
40
- /** @public */
73
+ export type AtomEffect<T> = (tools: Effectors<T>) => (() => void) | void
41
74
  export type Effectors<T> = {
42
75
  /**
43
76
  * Reset the value of the atom to its default
@@ -52,44 +85,6 @@ export type Effectors<T> = {
52
85
  onSet: (callback: (options: { newValue: T; oldValue: T }) => void) => void
53
86
  }
54
87
 
55
- /**
56
- * @public
57
- * A function that runs side effects when the atom is set
58
- * @param tools - {@link Effectors} that can be used to run side effects
59
- * @returns
60
- * Optionally, a cleanup function that will be called when the atom is disposed
61
- */
62
- export type AtomEffect<T> = (tools: Effectors<T>) => (() => void) | void
63
-
64
- /** @public */
65
- export type RegularAtomOptions<T> = {
66
- /** The unique identifier of the atom */
67
- key: string
68
- /** The starting value of the atom */
69
- default: T | (() => T)
70
- /** Hooks used to run side effects when the atom is set */
71
- effects?: AtomEffect<T>[]
72
- }
73
-
74
- /** @public */
75
- // biome-ignore format: intersection
76
- export type MutableAtomOptions<
77
- T extends Transceiver<any>,
78
- J extends Json.Serializable,
79
- > =
80
- & JsonInterface<T, J>
81
- & {
82
- /** Used to signal that the atom is mutable */
83
- mutable: true
84
- /** The unique identifier of the atom */
85
- key: string
86
- /** A function to create an initial value for the atom */
87
- default: () => T
88
- /** Hooks used to run side effects when the atom is set */
89
- effects?: AtomEffect<T>[]
90
- }
91
-
92
- /** @public */
93
88
  export type RegularAtomFamilyOptions<T, K extends Canonical> = {
94
89
  /** The unique identifier of the atom family */
95
90
  key: string
@@ -98,19 +93,18 @@ export type RegularAtomFamilyOptions<T, K extends Canonical> = {
98
93
  /** Hooks used to run side effects when an atom in the family is set */
99
94
  effects?: (key: K) => AtomEffect<T>[]
100
95
  }
101
-
102
- export type RegularAtomFamilyToken<T, K extends Canonical> = {
103
- /** The unique identifier of the atom family */
104
- key: string
105
- /** Discriminator */
106
- type: `atom_family`
107
- /** Never present. This is a marker that preserves the type of atoms in this family */
108
- __T?: T
109
- /** Never present. This is a marker that preserves the type of keys used for atoms in this family */
110
- __K?: K
96
+ /**
97
+ * Create a family of regular atoms, allowing for the dynamic creation and disposal of atoms.
98
+ * @param options - {@link RegularAtomFamilyOptions}
99
+ * @returns
100
+ * A reference to the atom family created: a {@link RegularAtomFamilyToken}
101
+ */
102
+ export function atomFamily<T, K extends Canonical>(
103
+ options: RegularAtomFamilyOptions<T, K>,
104
+ ): RegularAtomFamilyToken<T, K> {
105
+ return createRegularAtomFamily(IMPLICIT.STORE, options)
111
106
  }
112
107
 
113
- /** @public */
114
108
  // biome-ignore format: intersection
115
109
  export type MutableAtomFamilyOptions<
116
110
  T extends Transceiver<any>,
@@ -119,8 +113,6 @@ export type MutableAtomFamilyOptions<
119
113
  > =
120
114
  & JsonInterface<T, J>
121
115
  & {
122
- /** Used to signal that the atoms created from this family are mutable */
123
- mutable: true
124
116
  /** The unique identifier of the atom family */
125
117
  key: string
126
118
  /** A function to create an initial value for each atom in the family */
@@ -128,29 +120,7 @@ export type MutableAtomFamilyOptions<
128
120
  /** Hooks used to run side effects when an atom in the family is set */
129
121
  effects?: (key: K) => AtomEffect<T>[]
130
122
  }
131
-
132
- export type MutableAtomFamilyToken<
133
- T extends Transceiver<any>,
134
- J extends Json.Serializable,
135
- K extends Canonical,
136
- > = {
137
- /** The unique identifier of the atom family */
138
- key: string
139
- /** Discriminator */
140
- type: `mutable_atom_family`
141
- /** Never present. This is a marker that preserves the type of atoms in this family */
142
- __T?: T
143
- /** Never present. This is a marker that preserves the type of the JSON form of atoms in this family */
144
- __J?: J
145
- /** Never present. This is a marker that preserves the type of keys used for atoms in this family */
146
- __K?: K
147
- }
148
- export type AtomFamilyToken<T, K extends Canonical = Canonical> =
149
- | MutableAtomFamilyToken<T extends Transceiver<any> ? T : never, any, K>
150
- | RegularAtomFamilyToken<T, K>
151
-
152
123
  /**
153
- * @public
154
124
  * Create a family of mutable atoms, allowing for the dynamic creation and disposal of atoms.
155
125
  *
156
126
  * The value of a mutable atom must be some kind of {@link Transceiver}.
@@ -158,28 +128,11 @@ export type AtomFamilyToken<T, K extends Canonical = Canonical> =
158
128
  * @param options - {@link MutableAtomFamilyOptions}
159
129
  * @returns
160
130
  * A reference to the atom family created: a {@link MutableAtomFamilyToken}
161
- * @overload Mutable
162
131
  */
163
- export function atomFamily<
132
+ export function mutableAtomFamily<
164
133
  T extends Transceiver<any>,
165
134
  J extends Json.Serializable,
166
135
  K extends Canonical,
167
- >(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamilyToken<T, J, K>
168
- /**
169
- * @public
170
- * Create a family of regular atoms, allowing for the dynamic creation and disposal of atoms.
171
- * @param options - {@link RegularAtomFamilyOptions}
172
- * @returns
173
- * A reference to the atom family created: a {@link RegularAtomFamilyToken}
174
- * @overload Regular
175
- */
176
- export function atomFamily<T, K extends Canonical>(
177
- options: RegularAtomFamilyOptions<T, K>,
178
- ): RegularAtomFamilyToken<T, K>
179
- export function atomFamily<T, K extends Canonical>(
180
- options:
181
- | MutableAtomFamilyOptions<any, any, any>
182
- | RegularAtomFamilyOptions<T, K>,
183
- ): MutableAtomFamilyToken<any, any, any> | RegularAtomFamilyToken<T, K> {
184
- return createAtomFamily(IMPLICIT.STORE, options)
136
+ >(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamilyToken<T, J, K> {
137
+ return createMutableAtomFamily(IMPLICIT.STORE, options)
185
138
  }
@@ -4,7 +4,6 @@ import type { Canonical } from "atom.io/json"
4
4
  import type { ReadableFamilyToken, ReadableToken } from "."
5
5
 
6
6
  /**
7
- * @public
8
7
  * Disposes of a state in the implicit store.
9
8
  *
10
9
  * Only family members can be disposed of.
@@ -14,7 +13,6 @@ import type { ReadableFamilyToken, ReadableToken } from "."
14
13
  */
15
14
  export function disposeState(token: ReadableToken<any>): void
16
15
  /**
17
- * @public
18
16
  * Disposes of a state in the implicit store.
19
17
  *
20
18
  * Only family members can be disposed of.