atom.io 0.36.0 → 0.36.1

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 (100) hide show
  1. package/dist/internal/index.d.ts +83 -67
  2. package/dist/internal/index.d.ts.map +1 -1
  3. package/dist/internal/index.js +98 -98
  4. package/dist/internal/index.js.map +1 -1
  5. package/dist/introspection/index.d.ts +5 -6
  6. package/dist/introspection/index.d.ts.map +1 -1
  7. package/dist/introspection/index.js +2 -3
  8. package/dist/introspection/index.js.map +1 -1
  9. package/dist/main/index.d.ts +27 -29
  10. package/dist/main/index.d.ts.map +1 -1
  11. package/dist/main/index.js +8 -9
  12. package/dist/main/index.js.map +1 -1
  13. package/dist/react/index.d.ts +2 -2
  14. package/dist/react/index.d.ts.map +1 -1
  15. package/dist/react/index.js.map +1 -1
  16. package/dist/react-devtools/index.d.ts.map +1 -1
  17. package/dist/react-devtools/index.js.map +1 -1
  18. package/dist/realtime-client/index.d.ts +7 -8
  19. package/dist/realtime-client/index.d.ts.map +1 -1
  20. package/dist/realtime-client/index.js +3 -4
  21. package/dist/realtime-client/index.js.map +1 -1
  22. package/dist/realtime-react/index.d.ts +4 -4
  23. package/dist/realtime-react/index.d.ts.map +1 -1
  24. package/dist/realtime-react/index.js.map +1 -1
  25. package/dist/realtime-server/index.d.ts +2 -2
  26. package/dist/realtime-server/index.d.ts.map +1 -1
  27. package/dist/realtime-server/index.js.map +1 -1
  28. package/dist/transceivers/set-rtx/index.d.ts +9 -2
  29. package/dist/transceivers/set-rtx/index.d.ts.map +1 -1
  30. package/dist/transceivers/set-rtx/index.js +3 -0
  31. package/dist/transceivers/set-rtx/index.js.map +1 -1
  32. package/package.json +3 -3
  33. package/src/internal/atom/create-regular-atom.ts +5 -5
  34. package/src/internal/atom/has-role.ts +12 -0
  35. package/src/internal/atom/index.ts +1 -0
  36. package/src/internal/caching.ts +38 -16
  37. package/src/internal/families/find-in-store.ts +1 -1
  38. package/src/internal/families/get-family-of-token.ts +1 -1
  39. package/src/internal/families/init-family-member.ts +1 -1
  40. package/src/internal/families/seek-in-store.ts +1 -1
  41. package/src/internal/get-state/read-or-compute-value.ts +29 -20
  42. package/src/internal/index.ts +8 -8
  43. package/src/internal/join/join-internal.ts +7 -4
  44. package/src/internal/mutable/create-mutable-atom-family.ts +6 -5
  45. package/src/internal/mutable/create-mutable-atom.ts +1 -1
  46. package/src/internal/mutable/get-json-family.ts +1 -1
  47. package/src/internal/mutable/get-json-token.ts +1 -1
  48. package/src/internal/mutable/get-update-family.ts +1 -1
  49. package/src/internal/mutable/get-update-token.ts +1 -1
  50. package/src/internal/mutable/tracker-family.ts +27 -31
  51. package/src/internal/mutable/tracker.ts +29 -23
  52. package/src/internal/mutable/transceiver.ts +11 -10
  53. package/src/internal/selector/create-readonly-held-selector.ts +2 -2
  54. package/src/internal/selector/create-readonly-pure-selector.ts +2 -2
  55. package/src/internal/selector/create-writable-held-selector.ts +3 -3
  56. package/src/internal/selector/create-writable-pure-selector.ts +3 -3
  57. package/src/internal/set-state/set-atom.ts +15 -22
  58. package/src/internal/set-state/set-into-store.ts +5 -4
  59. package/src/internal/store/counterfeit.ts +1 -1
  60. package/src/internal/store/deposit.ts +7 -8
  61. package/src/internal/store/store.ts +6 -6
  62. package/src/internal/store/withdraw.ts +8 -8
  63. package/src/internal/subscribe/subscribe-in-store.ts +2 -2
  64. package/src/internal/subscribe/subscribe-to-transaction.ts +2 -2
  65. package/src/internal/timeline/create-timeline.ts +3 -3
  66. package/src/internal/transaction/act-upon-store.ts +2 -2
  67. package/src/internal/transaction/apply-transaction.ts +2 -2
  68. package/src/internal/transaction/build-transaction.ts +2 -2
  69. package/src/internal/transaction/create-transaction.ts +3 -3
  70. package/src/internal/transaction/index.ts +2 -2
  71. package/src/internal/transaction/is-root-store.ts +4 -2
  72. package/src/internal/utility-types.ts +1 -1
  73. package/src/introspection/attach-introspection-states.ts +3 -3
  74. package/src/introspection/attach-transaction-index.ts +4 -4
  75. package/src/introspection/attach-transaction-logs.ts +4 -4
  76. package/src/introspection/auditor.ts +3 -3
  77. package/src/main/atom.ts +4 -4
  78. package/src/main/dispose-state.ts +4 -3
  79. package/src/main/find-state.ts +1 -1
  80. package/src/main/get-state.ts +6 -5
  81. package/src/main/reset-state.ts +3 -3
  82. package/src/main/set-state.ts +3 -3
  83. package/src/main/subscribe.ts +3 -3
  84. package/src/main/tokens.ts +6 -10
  85. package/src/main/transaction.ts +13 -15
  86. package/src/react/use-json.ts +5 -5
  87. package/src/react-devtools/TransactionIndex.tsx +3 -3
  88. package/src/react-devtools/Updates.tsx +2 -2
  89. package/src/realtime-client/continuity/register-and-attempt-confirmed-update.ts +2 -2
  90. package/src/realtime-client/pull-mutable-atom-family-member.ts +8 -13
  91. package/src/realtime-client/pull-mutable-atom.ts +5 -8
  92. package/src/realtime-client/push-state.ts +6 -5
  93. package/src/realtime-client/server-action.ts +5 -4
  94. package/src/realtime-react/use-pull-mutable-atom.ts +1 -1
  95. package/src/realtime-react/use-pull-mutable-family-member.ts +1 -1
  96. package/src/realtime-react/use-server-action.ts +2 -2
  97. package/src/realtime-server/realtime-mutable-family-provider.ts +1 -1
  98. package/src/realtime-server/realtime-mutable-provider.ts +1 -1
  99. package/src/transceivers/set-rtx/set-rtx.ts +14 -1
  100. package/src/internal/set-state/copy-mutable-if-needed.ts +0 -29
@@ -5,7 +5,7 @@ import type {
5
5
  } from "atom.io"
6
6
 
7
7
  import type { ReadonlyHeldSelector } from ".."
8
- import { cacheValue } from "../caching"
8
+ import { writeToCache } from "../caching"
9
9
  import { newest } from "../lineage"
10
10
  import type { Store } from "../store"
11
11
  import { Subject } from "../subject"
@@ -34,7 +34,7 @@ export const createReadonlyHeldSelector = <T extends object>(
34
34
  }
35
35
  innerTarget.selectorAtoms.delete(key)
36
36
  options.get({ get, find, json }, constant)
37
- cacheValue(newest(store), key, constant, subject)
37
+ writeToCache(newest(store), key, constant, subject)
38
38
  covered.clear()
39
39
  return constant
40
40
  }
@@ -5,7 +5,7 @@ import type {
5
5
  } from "atom.io"
6
6
 
7
7
  import type { ReadonlyPureSelector } from ".."
8
- import { cacheValue } from "../caching"
8
+ import { writeToCache } from "../caching"
9
9
  import { newest } from "../lineage"
10
10
  import type { Store } from "../store"
11
11
  import { Subject } from "../subject"
@@ -34,7 +34,7 @@ export const createReadonlyPureSelector = <T>(
34
34
  }
35
35
  innerTarget.selectorAtoms.delete(key)
36
36
  const value = options.get({ get, find, json })
37
- const cached = cacheValue(innerTarget, key, value, subject)
37
+ const cached = writeToCache(innerTarget, key, value, subject)
38
38
  store.logger.info(`✨`, type, key, `=`, cached)
39
39
  covered.clear()
40
40
  return cached
@@ -5,7 +5,7 @@ import type {
5
5
  } from "atom.io"
6
6
 
7
7
  import type { WritableHeldSelector } from ".."
8
- import { cacheValue } from "../caching"
8
+ import { writeToCache } from "../caching"
9
9
  import { newest } from "../lineage"
10
10
  import { markDone } from "../operation"
11
11
  import { become } from "../set-state"
@@ -39,7 +39,7 @@ export const createWritableHeldSelector = <T extends object>(
39
39
  }
40
40
  innerTarget.selectorAtoms.delete(key)
41
41
  getFn(getterToolkit, constant)
42
- cacheValue(innerTarget, key, constant, subject)
42
+ writeToCache(innerTarget, key, constant, subject)
43
43
  store.logger.info(`✨`, type, key, `=`, constant)
44
44
  covered.clear()
45
45
  return constant
@@ -50,7 +50,7 @@ export const createWritableHeldSelector = <T extends object>(
50
50
  const oldValue = getSelf(options.get, innerTarget)
51
51
  const newValue = become(next)(oldValue)
52
52
  store.logger.info(`📝`, type, key, `set (`, oldValue, `->`, newValue, `)`)
53
- cacheValue(innerTarget, key, newValue, subject)
53
+ writeToCache(innerTarget, key, newValue, subject)
54
54
  markDone(innerTarget, key)
55
55
  if (isRootStore(innerTarget)) {
56
56
  subject.next({ newValue, oldValue })
@@ -5,7 +5,7 @@ import type {
5
5
  } from "atom.io"
6
6
 
7
7
  import type { WritablePureSelector } from ".."
8
- import { cacheValue } from "../caching"
8
+ import { writeToCache } from "../caching"
9
9
  import { newest } from "../lineage"
10
10
  import { markDone } from "../operation"
11
11
  import { become } from "../set-state"
@@ -39,7 +39,7 @@ export const createWritablePureSelector = <T>(
39
39
  }
40
40
  innerTarget.selectorAtoms.delete(key)
41
41
  const value = getFn(getterToolkit)
42
- const cached = cacheValue(innerTarget, key, value, subject)
42
+ const cached = writeToCache(innerTarget, key, value, subject)
43
43
  store.logger.info(`✨`, type, key, `=`, cached)
44
44
  covered.clear()
45
45
  return value
@@ -50,7 +50,7 @@ export const createWritablePureSelector = <T>(
50
50
  const oldValue = getSelf(options.get, innerTarget)
51
51
  const newValue = become(next)(oldValue)
52
52
  store.logger.info(`📝`, type, key, `set (`, oldValue, `->`, newValue, `)`)
53
- cacheValue(innerTarget, options.key, newValue, subject)
53
+ writeToCache(innerTarget, options.key, newValue, subject)
54
54
  markDone(innerTarget, options.key)
55
55
  if (isRootStore(innerTarget)) {
56
56
  subject.next({ newValue, oldValue })
@@ -1,13 +1,13 @@
1
1
  import type { KeyedStateUpdate } from "atom.io"
2
2
 
3
- import type { Atom, Store } from ".."
4
- import { cacheValue } from "../caching"
3
+ import type { Atom, MutableAtom, Store } from ".."
4
+ import { hasRole } from "../atom/has-role"
5
+ import { writeToCache } from "../caching"
5
6
  import { readOrComputeValue } from "../get-state/read-or-compute-value"
6
7
  import { isTransceiver, type Transceiver } from "../mutable"
7
8
  import { markDone } from "../operation"
8
9
  import { isChildStore } from "../transaction/is-root-store"
9
10
  import { become } from "./become"
10
- import { copyMutableIfNeeded } from "./copy-mutable-if-needed"
11
11
  import { emitUpdate } from "./emit-update"
12
12
  import { evictDownStream } from "./evict-downstream"
13
13
 
@@ -16,16 +16,10 @@ export const setAtom = <T>(
16
16
  atom: Atom<T>,
17
17
  next: T | ((oldValue: T) => T),
18
18
  ): void => {
19
- const oldValue = readOrComputeValue(target, atom)
20
- let newValue = oldValue
21
- if (atom.type === `mutable_atom` && isChildStore(target)) {
22
- const { parent } = target
23
- const copiedValue = copyMutableIfNeeded(target, atom, parent)
24
- newValue = copiedValue
25
- }
26
- newValue = become(next)(newValue)
19
+ const oldValue = readOrComputeValue(target, atom, `mut`)
20
+ let newValue = become(next)(oldValue)
27
21
  target.logger.info(`📝`, `atom`, atom.key, `set to`, newValue)
28
- newValue = cacheValue(target, atom.key, newValue, atom.subject)
22
+ newValue = writeToCache(target, atom.key, newValue, atom.subject)
29
23
  markDone(target, atom.key)
30
24
  evictDownStream(target, atom)
31
25
  const update = { oldValue, newValue }
@@ -57,16 +51,15 @@ export const setAtom = <T>(
57
51
  update.newValue,
58
52
  `)`,
59
53
  )
60
- } else if (atom.key.startsWith(`*`)) {
61
- const mutableKey = atom.key.slice(1)
62
- const mutableAtom = target.atoms.get(mutableKey) as Atom<any>
63
- let transceiver: Transceiver<any, any> = target.valueMap.get(mutableKey)
64
- if (mutableAtom.type === `mutable_atom` && isChildStore(target)) {
65
- const { parent } = target
66
- const copiedValue = copyMutableIfNeeded(target, mutableAtom, parent)
67
- transceiver = copiedValue
68
- }
54
+ } else if (hasRole(atom, `tracker:signal`)) {
55
+ const key = atom.key.slice(1)
56
+ const mutable = target.atoms.get(key) as MutableAtom<
57
+ Transceiver<unknown, any, any>
58
+ >
59
+ const transceiver = readOrComputeValue(target, mutable, `mut`)
69
60
  const accepted = transceiver.do(update.newValue) === null
70
- if (accepted) evictDownStream(target, mutableAtom)
61
+ if (accepted === true) {
62
+ evictDownStream(target, mutable)
63
+ }
71
64
  }
72
65
  }
@@ -38,9 +38,10 @@ export function setIntoStore<T, New extends T>(
38
38
  if (params.length === 2) {
39
39
  token = params[0]
40
40
  value = params[1]
41
- family = getFamilyOfToken(store, token) ?? null
42
- if (family) {
43
- key = token.family ? parseJson(token.family.subKey) : null
41
+ if (token.family) {
42
+ // biome-ignore lint/style/noNonNullAssertion: this token belongs to a family
43
+ family = getFamilyOfToken(store, token)!
44
+ key = parseJson(token.family.subKey)
44
45
  token = findInStore(store, family, key)
45
46
  }
46
47
  } else {
@@ -71,7 +72,7 @@ export function setIntoStore<T, New extends T>(
71
72
  if (rejectionTime) {
72
73
  const unsubscribe = store.on.operationClose.subscribe(
73
74
  `waiting to set "${token.key}" at T-${rejectionTime}`,
74
- () => {
75
+ function waitUntilOperationCloseToSetState() {
75
76
  unsubscribe()
76
77
  store.logger.info(
77
78
  `🟢`,
@@ -32,7 +32,7 @@ export const FAMILY_MEMBER_TOKEN_TYPES = {
32
32
  } as const
33
33
 
34
34
  export function counterfeit<
35
- T extends Transceiver<any, any>,
35
+ T extends Transceiver<any, any, any>,
36
36
  K extends Canonical,
37
37
  Key extends K,
38
38
  >(token: MutableAtomFamilyToken<T, K>, key: Key): MutableAtomToken<T>
@@ -26,7 +26,7 @@ import type {
26
26
  Atom,
27
27
  AtomFamily,
28
28
  AtomIOInternalResource,
29
- Func,
29
+ Fn,
30
30
  MutableAtom,
31
31
  MutableAtomFamily,
32
32
  ReadableFamily,
@@ -47,7 +47,7 @@ import type {
47
47
  import type { Transaction } from "../transaction"
48
48
 
49
49
  export function deposit<T>(state: RegularAtom<T>): RegularAtomToken<T>
50
- export function deposit<T extends Transceiver<any, any>>(
50
+ export function deposit<T extends Transceiver<any, any, any>>(
51
51
  state: MutableAtom<T>,
52
52
  ): MutableAtomToken<T>
53
53
  export function deposit<T>(state: Atom<T>): AtomToken<T>
@@ -64,9 +64,10 @@ export function deposit<T>(state: ReadableState<T>): ReadableToken<T>
64
64
  export function deposit<T, K extends Canonical>(
65
65
  state: RegularAtomFamily<T, K>,
66
66
  ): RegularAtomFamilyToken<T, K>
67
- export function deposit<T extends Transceiver<any, any>, K extends Canonical>(
68
- state: MutableAtomFamily<T, K>,
69
- ): MutableAtomFamilyToken<T, K>
67
+ export function deposit<
68
+ T extends Transceiver<any, any, any>,
69
+ K extends Canonical,
70
+ >(state: MutableAtomFamily<T, K>): MutableAtomFamilyToken<T, K>
70
71
  export function deposit<T>(state: AtomFamily<T, any>): AtomFamilyToken<T, any>
71
72
  export function deposit<T>(
72
73
  state: WritablePureSelectorFamily<T, any>,
@@ -84,9 +85,7 @@ export function deposit<T>(
84
85
  state: ReadableFamily<T, any>,
85
86
  ): ReadableFamilyToken<T, any>
86
87
 
87
- export function deposit<T extends Func>(
88
- state: Transaction<T>,
89
- ): TransactionToken<T>
88
+ export function deposit<T extends Fn>(state: Transaction<T>): TransactionToken<T>
90
89
  export function deposit<M extends TimelineManageable>(
91
90
  state: Timeline<M>,
92
91
  ): TimelineToken<M>
@@ -35,7 +35,7 @@ import type {
35
35
  TransactionProgress,
36
36
  } from "../transaction"
37
37
  import { isRootStore } from "../transaction"
38
- import type { Func } from "../utility-types"
38
+ import type { Fn } from "../utility-types"
39
39
  import { CircularBuffer } from "./circular-buffer"
40
40
 
41
41
  export class Store implements Lineage {
@@ -70,7 +70,7 @@ export class Store implements Lineage {
70
70
  makeContentKey: (...keys) => keys.sort().join(`:`),
71
71
  },
72
72
  )
73
- public trackers: Map<string, Tracker<Transceiver<any, any>>> = new Map()
73
+ public trackers: Map<string, Tracker<Transceiver<any, any, any>>> = new Map()
74
74
  public families: Map<
75
75
  string,
76
76
  | HeldSelectorFamily<any, any>
@@ -80,8 +80,8 @@ export class Store implements Lineage {
80
80
  > = new Map()
81
81
  public joins: Map<string, Join<any, any, any, any, any, any>> = new Map()
82
82
 
83
- public transactions: Map<string, Transaction<Func>> = new Map()
84
- public transactionMeta: TransactionEpoch | TransactionProgress<Func> = {
83
+ public transactions: Map<string, Transaction<Fn>> = new Map()
84
+ public transactionMeta: TransactionEpoch | TransactionProgress<Fn> = {
85
85
  epoch: new Map<string, number>(),
86
86
  actionContinuities: new Junction({
87
87
  between: [`continuity`, `action`],
@@ -250,8 +250,8 @@ export type StoreEventCarrier = {
250
250
  selectorCreation: Subject<SelectorToken<unknown>>
251
251
  selectorDisposal: Subject<SelectorToken<unknown>>
252
252
  timelineCreation: Subject<TimelineToken<unknown>>
253
- transactionCreation: Subject<TransactionToken<Func>>
254
- transactionApplying: StatefulSubject<TransactionProgress<Func> | null>
253
+ transactionCreation: Subject<TransactionToken<Fn>>
254
+ transactionApplying: StatefulSubject<TransactionProgress<Fn> | null>
255
255
  operationClose: Subject<OperationProgress>
256
256
  moleculeCreation: Subject<MoleculeCreation>
257
257
  moleculeDisposal: Subject<MoleculeDisposal>
@@ -38,7 +38,7 @@ import type {
38
38
  Atom,
39
39
  AtomFamily,
40
40
  AtomIOInternalResource,
41
- Func,
41
+ Fn,
42
42
  HeldSelector,
43
43
  HeldSelectorFamily,
44
44
  MutableAtom,
@@ -76,7 +76,7 @@ export function withdraw<T>(
76
76
  store: Store,
77
77
  token: RegularAtomToken<T>,
78
78
  ): RegularAtom<T>
79
- export function withdraw<T extends Transceiver<any, any>>(
79
+ export function withdraw<T extends Transceiver<any, any, any>>(
80
80
  store: Store,
81
81
  token: MutableAtomToken<T, any>,
82
82
  ): MutableAtom<T>
@@ -127,10 +127,10 @@ export function withdraw<T, K extends Canonical>(
127
127
  store: Store,
128
128
  token: RegularAtomFamilyToken<T, K>,
129
129
  ): RegularAtomFamily<T, K>
130
- export function withdraw<T extends Transceiver<any, any>, K extends Canonical>(
131
- store: Store,
132
- token: MutableAtomFamilyToken<T, K>,
133
- ): MutableAtomFamily<T, K>
130
+ export function withdraw<
131
+ T extends Transceiver<any, any, any>,
132
+ K extends Canonical,
133
+ >(store: Store, token: MutableAtomFamilyToken<T, K>): MutableAtomFamily<T, K>
134
134
  export function withdraw<T, K extends Canonical>(
135
135
  store: Store,
136
136
  token: AtomFamilyToken<T, K>,
@@ -180,10 +180,10 @@ export function withdraw<T, K extends Canonical>(
180
180
  token: WritableFamilyToken<T, K>,
181
181
  ): WritableFamily<T, K>
182
182
 
183
- export function withdraw<T extends Func>(
183
+ export function withdraw<T extends Fn>(
184
184
  store: Store,
185
185
  token: TransactionToken<T>,
186
- ): Transaction<T extends Func ? T : never>
186
+ ): Transaction<T extends Fn ? T : never>
187
187
  export function withdraw<T>(
188
188
  store: Store,
189
189
  token: TimelineToken<T>,
@@ -7,7 +7,7 @@ import type {
7
7
  TransactionUpdateHandler,
8
8
  UpdateHandler,
9
9
  } from "atom.io"
10
- import type { Func, Store } from "atom.io/internal"
10
+ import type { Fn, Store } from "atom.io/internal"
11
11
  import {
12
12
  arbitrary,
13
13
  subscribeToState,
@@ -21,7 +21,7 @@ export function subscribeInStore<T>(
21
21
  handleUpdate: UpdateHandler<T>,
22
22
  key?: string,
23
23
  ): () => void
24
- export function subscribeInStore<F extends Func>(
24
+ export function subscribeInStore<F extends Fn>(
25
25
  store: Store,
26
26
  token: TransactionToken<F>,
27
27
  handleUpdate: TransactionUpdateHandler<F>,
@@ -1,9 +1,9 @@
1
1
  import type { TransactionToken, TransactionUpdateHandler } from "atom.io"
2
2
 
3
- import type { Func, Store } from ".."
3
+ import type { Fn, Store } from ".."
4
4
  import { withdraw } from ".."
5
5
 
6
- export const subscribeToTransaction = <F extends Func>(
6
+ export const subscribeToTransaction = <F extends Fn>(
7
7
  store: Store,
8
8
  token: TransactionToken<F>,
9
9
  key: string,
@@ -23,7 +23,7 @@ import { getUpdateToken } from "../mutable"
23
23
  import { type Store, withdraw } from "../store"
24
24
  import { Subject } from "../subject"
25
25
  import { isChildStore } from "../transaction"
26
- import type { Flat, Func } from "../utility-types"
26
+ import type { Flat, Fn } from "../utility-types"
27
27
 
28
28
  export type TimelineAtomUpdate<ManagedAtom extends TimelineManageable> = Flat<
29
29
  StateUpdate<TokenType<ManagedAtom>> & {
@@ -40,7 +40,7 @@ export type TimelineSelectorUpdate<ManagedAtom extends TimelineManageable> = {
40
40
  atomUpdates: Omit<TimelineAtomUpdate<ManagedAtom>, `timestamp`>[]
41
41
  }
42
42
  export type TimelineTransactionUpdate = Flat<
43
- TransactionUpdate<Func> & {
43
+ TransactionUpdate<Fn> & {
44
44
  key: string
45
45
  type: `transaction_update`
46
46
  timestamp: number
@@ -340,7 +340,7 @@ function addAtomFamilyToTimeline(
340
340
  function joinTransaction(
341
341
  store: Store,
342
342
  tl: Timeline<any>,
343
- txUpdateInProgress: TransactionUpdate<Func>,
343
+ txUpdateInProgress: TransactionUpdate<Fn>,
344
344
  ) {
345
345
  const currentTxKey = txUpdateInProgress.key
346
346
  const currentTxInstanceId = txUpdateInProgress.id
@@ -3,9 +3,9 @@ import type { TransactionToken } from "atom.io"
3
3
  import { NotFoundError } from "../not-found-error"
4
4
  import type { Store } from "../store"
5
5
  import { withdraw } from "../store"
6
- import type { Func } from "../utility-types"
6
+ import type { Fn } from "../utility-types"
7
7
 
8
- export function actUponStore<F extends Func>(
8
+ export function actUponStore<F extends Fn>(
9
9
  store: Store,
10
10
  token: TransactionToken<F>,
11
11
  id: string,
@@ -2,11 +2,11 @@ import { ingestTransactionUpdate } from "../ingest-updates"
2
2
  import { newest } from "../lineage"
3
3
  import type { Store } from "../store"
4
4
  import { withdraw } from "../store"
5
- import type { Func } from "../utility-types"
5
+ import type { Fn } from "../utility-types"
6
6
  import { isChildStore, isRootStore } from "./is-root-store"
7
7
  import { setEpochNumberOfAction } from "./set-epoch-number"
8
8
 
9
- export const applyTransaction = <F extends Func>(
9
+ export const applyTransaction = <F extends Fn>(
10
10
  output: ReturnType<F>,
11
11
  store: Store,
12
12
  ): void => {
@@ -16,7 +16,7 @@ import { newest } from "../lineage"
16
16
  import { getJsonToken } from "../mutable"
17
17
  import { resetInStore, setIntoStore } from "../set-state"
18
18
  import type { Store } from "../store"
19
- import type { Func } from "../utility-types"
19
+ import type { Fn } from "../utility-types"
20
20
  import type { TransactionProgress } from "."
21
21
  import { actUponStore, getEpochNumberOfAction } from "."
22
22
  import type { ChildStore, RootStore } from "./is-root-store"
@@ -66,7 +66,7 @@ export const buildTransaction = (
66
66
  miscResources: new LazyMap(parent.miscResources),
67
67
  }
68
68
  const epoch = getEpochNumberOfAction(store, key)
69
- const transactionMeta: TransactionProgress<Func> = {
69
+ const transactionMeta: TransactionProgress<Fn> = {
70
70
  phase: `building`,
71
71
  update: {
72
72
  type: `transaction_update`,
@@ -8,12 +8,12 @@ import { newest } from "../lineage"
8
8
  import type { Store } from "../store"
9
9
  import { deposit } from "../store"
10
10
  import { Subject } from "../subject"
11
- import type { Func } from "../utility-types"
11
+ import type { Fn } from "../utility-types"
12
12
  import { abortTransaction } from "./abort-transaction"
13
13
  import { applyTransaction } from "./apply-transaction"
14
14
  import { buildTransaction } from "./build-transaction"
15
15
 
16
- export type Transaction<F extends Func> = {
16
+ export type Transaction<F extends Fn> = {
17
17
  key: string
18
18
  type: `transaction`
19
19
  install: (store: Store) => void
@@ -21,7 +21,7 @@ export type Transaction<F extends Func> = {
21
21
  run: (parameters: Parameters<F>, id?: string) => ReturnType<F>
22
22
  }
23
23
 
24
- export function createTransaction<F extends Func>(
24
+ export function createTransaction<F extends Fn>(
25
25
  store: Store,
26
26
  options: TransactionOptions<F>,
27
27
  ): TransactionToken<F> {
@@ -1,7 +1,7 @@
1
1
  import type { ActorToolkit, TransactionUpdate } from "atom.io"
2
2
 
3
3
  import type { Junction } from "../junction"
4
- import type { Func } from "../utility-types"
4
+ import type { Fn } from "../utility-types"
5
5
 
6
6
  export * from "./abort-transaction"
7
7
  export * from "./act-upon-store"
@@ -16,7 +16,7 @@ export * from "./set-epoch-number"
16
16
  export const TRANSACTION_PHASES = [`idle`, `building`, `applying`] as const
17
17
  export type TransactionPhase = (typeof TRANSACTION_PHASES)[number]
18
18
 
19
- export type TransactionProgress<F extends Func> = {
19
+ export type TransactionProgress<F extends Fn> = {
20
20
  phase: `applying` | `building`
21
21
  update: TransactionUpdate<F>
22
22
  toolkit: ActorToolkit
@@ -1,5 +1,6 @@
1
+ import type { LazyMap } from "../lazy-map"
1
2
  import type { Store } from "../store"
2
- import type { Func } from "../utility-types"
3
+ import type { Fn } from "../utility-types"
3
4
  import type { TransactionEpoch, TransactionProgress } from "."
4
5
 
5
6
  export interface RootStore extends Store {
@@ -8,9 +9,10 @@ export interface RootStore extends Store {
8
9
  child: ChildStore | null
9
10
  }
10
11
  export interface ChildStore extends Store {
11
- transactionMeta: TransactionProgress<Func>
12
+ transactionMeta: TransactionProgress<Fn>
12
13
  parent: ChildStore | RootStore
13
14
  child: ChildStore | null
15
+ valueMap: LazyMap<string, any>
14
16
  }
15
17
 
16
18
  export function isRootStore(store: Store): store is RootStore {
@@ -1,4 +1,4 @@
1
- export type Func = (...parameters: any[]) => any
1
+ export type Fn = (...parameters: any[]) => any
2
2
 
3
3
  export type Flat<R extends { [K in PropertyKey]: any }> = {
4
4
  [K in keyof R]: R[K]
@@ -6,7 +6,7 @@ import type {
6
6
  TransactionToken,
7
7
  TransactionUpdate,
8
8
  } from "atom.io"
9
- import type { Func, Store, Timeline } from "atom.io/internal"
9
+ import type { Fn, Store, Timeline } from "atom.io/internal"
10
10
 
11
11
  import { type AtomTokenIndex, attachAtomIndex } from "./attach-atom-index"
12
12
  import type { SelectorTokenIndex } from "./attach-selector-index"
@@ -20,9 +20,9 @@ import { attachTypeSelectors } from "./attach-type-selectors"
20
20
  export type IntrospectionStates = {
21
21
  atomIndex: AtomToken<AtomTokenIndex>
22
22
  selectorIndex: AtomToken<SelectorTokenIndex>
23
- transactionIndex: AtomToken<TransactionToken<Func>[]>
23
+ transactionIndex: AtomToken<TransactionToken<Fn>[]>
24
24
  transactionLogSelectors: ReadonlyPureSelectorFamilyToken<
25
- TransactionUpdate<Func>[],
25
+ TransactionUpdate<Fn>[],
26
26
  string
27
27
  >
28
28
  timelineIndex: AtomToken<TimelineToken<any>[]>
@@ -1,16 +1,16 @@
1
1
  import type { AtomToken, TransactionToken } from "atom.io"
2
- import type { Func, Store } from "atom.io/internal"
2
+ import type { Fn, Store } from "atom.io/internal"
3
3
  import { createRegularAtom, isReservedIntrospectionKey } from "atom.io/internal"
4
4
 
5
5
  export const attachTransactionIndex = (
6
6
  store: Store,
7
- ): AtomToken<TransactionToken<Func>[]> => {
8
- return createRegularAtom<TransactionToken<Func>[]>(
7
+ ): AtomToken<TransactionToken<Fn>[]> => {
8
+ return createRegularAtom<TransactionToken<Fn>[]>(
9
9
  store,
10
10
  {
11
11
  key: `🔍 Transaction Token Index`,
12
12
  default: () => {
13
- const tokens: TransactionToken<Func>[] = []
13
+ const tokens: TransactionToken<Fn>[] = []
14
14
  for (const [key] of store.transactions) {
15
15
  if (isReservedIntrospectionKey(key)) {
16
16
  continue
@@ -1,12 +1,12 @@
1
1
  import type { ReadonlyPureSelectorFamilyToken, TransactionUpdate } from "atom.io"
2
- import type { Func, Store } from "atom.io/internal"
2
+ import type { Fn, Store } from "atom.io/internal"
3
3
  import { createRegularAtomFamily, createSelectorFamily } from "atom.io/internal"
4
4
 
5
5
  export const attachTransactionLogs = (
6
6
  store: Store,
7
- ): ReadonlyPureSelectorFamilyToken<TransactionUpdate<Func>[], string> => {
7
+ ): ReadonlyPureSelectorFamilyToken<TransactionUpdate<Fn>[], string> => {
8
8
  const transactionUpdateLogAtoms = createRegularAtomFamily<
9
- TransactionUpdate<Func>[],
9
+ TransactionUpdate<Fn>[],
10
10
  string
11
11
  >(store, {
12
12
  key: `🔍 Transaction Update Log (Internal)`,
@@ -23,7 +23,7 @@ export const attachTransactionLogs = (
23
23
  ],
24
24
  })
25
25
  const findTransactionUpdateLogState = createSelectorFamily<
26
- TransactionUpdate<Func>[],
26
+ TransactionUpdate<Fn>[],
27
27
  string
28
28
  >(store, {
29
29
  key: `🔍 Transaction Update Log`,
@@ -4,7 +4,7 @@ import {
4
4
  type ReadableToken,
5
5
  type SelectorToken,
6
6
  } from "atom.io"
7
- import * as Internal from "atom.io/internal"
7
+ import { IMPLICIT, type Store } from "atom.io/internal"
8
8
 
9
9
  import type { FamilyNode } from "."
10
10
  import type { AtomTokenIndex } from "./attach-atom-index"
@@ -22,7 +22,7 @@ export type ListResourcesParam = {
22
22
  * @experimental
23
23
  */
24
24
  export class Auditor {
25
- public readonly store: Internal.Store
25
+ public readonly store: Store
26
26
  public auditorCreatedAt: number = performance.now()
27
27
  public statesCreatedAt: Map<string, number> = new Map()
28
28
  public readonly atomIndex: AtomToken<AtomTokenIndex>
@@ -37,7 +37,7 @@ export class Auditor {
37
37
  /**
38
38
  * @param {Store} store - The store to audit.
39
39
  */
40
- public constructor(store: Internal.Store = Internal.IMPLICIT.STORE) {
40
+ public constructor(store: Store = IMPLICIT.STORE) {
41
41
  this.store = store
42
42
  this.atomIndex = attachAtomIndex(this.store)
43
43
  this.selectorIndex = attachSelectorIndex(this.store)
package/src/main/atom.ts CHANGED
@@ -34,7 +34,7 @@ export function atom<T>(options: RegularAtomOptions<T>): RegularAtomToken<T> {
34
34
  return createRegularAtom(IMPLICIT.STORE, options, undefined)
35
35
  }
36
36
 
37
- export type MutableAtomOptions<T extends Transceiver<any, any>> = {
37
+ export type MutableAtomOptions<T extends Transceiver<any, any, any>> = {
38
38
  /** The unique identifier of the atom */
39
39
  key: string
40
40
  /** A constructor for the atom's value */
@@ -51,7 +51,7 @@ export type MutableAtomOptions<T extends Transceiver<any, any>> = {
51
51
  * @returns
52
52
  * A reference to the atom created: a {@link MutableAtomToken}
53
53
  */
54
- export function mutableAtom<T extends Transceiver<any, any>>(
54
+ export function mutableAtom<T extends Transceiver<any, any, any>>(
55
55
  options: MutableAtomOptions<T>,
56
56
  ): MutableAtomToken<T> {
57
57
  return createMutableAtom(IMPLICIT.STORE, options, undefined)
@@ -99,7 +99,7 @@ export function atomFamily<T, K extends Canonical>(
99
99
  }
100
100
 
101
101
  export type MutableAtomFamilyOptions<
102
- T extends Transceiver<any, any>,
102
+ T extends Transceiver<any, any, any>,
103
103
  K extends Canonical,
104
104
  > = {
105
105
  /** The unique identifier of the atom family */
@@ -119,7 +119,7 @@ export type MutableAtomFamilyOptions<
119
119
  * A reference to the atom family created: a {@link MutableAtomFamilyToken}
120
120
  */
121
121
  export function mutableAtomFamily<
122
- T extends Transceiver<any, any>,
122
+ T extends Transceiver<any, any, any>,
123
123
  K extends Canonical,
124
124
  >(options: MutableAtomFamilyOptions<T, K>): MutableAtomFamilyToken<T, K> {
125
125
  return createMutableAtomFamily(IMPLICIT.STORE, options)
@@ -1,4 +1,4 @@
1
- import * as Internal from "atom.io/internal"
1
+ import { disposeFromStore, IMPLICIT } from "atom.io/internal"
2
2
  import type { Canonical } from "atom.io/json"
3
3
 
4
4
  import type { ReadableFamilyToken, ReadableToken } from "."
@@ -19,6 +19,7 @@ export function disposeState(token: ReadableToken<any>): void
19
19
  *
20
20
  * @param token - The token of the state family to dispose
21
21
  * @param key - The unique key of the state to dispose
22
+ * @overload Streamlined
22
23
  */
23
24
  export function disposeState<K extends Canonical>(
24
25
  token: ReadableFamilyToken<any, K>,
@@ -30,8 +31,8 @@ export function disposeState(
30
31
  | [token: ReadableToken<any>]
31
32
  ): void {
32
33
  if (params.length === 2) {
33
- Internal.disposeFromStore(Internal.IMPLICIT.STORE, ...params)
34
+ disposeFromStore(IMPLICIT.STORE, ...params)
34
35
  } else {
35
- Internal.disposeFromStore(Internal.IMPLICIT.STORE, ...params)
36
+ disposeFromStore(IMPLICIT.STORE, ...params)
36
37
  }
37
38
  }