atom.io 0.40.1 → 0.40.2

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 (94) hide show
  1. package/dist/data/index.d.ts +1 -1
  2. package/dist/data/index.d.ts.map +1 -1
  3. package/dist/data/index.js.map +1 -1
  4. package/dist/internal/index.d.ts +146 -142
  5. package/dist/internal/index.d.ts.map +1 -1
  6. package/dist/internal/index.js +64 -14
  7. package/dist/internal/index.js.map +1 -1
  8. package/dist/introspection/index.d.ts +4 -4
  9. package/dist/introspection/index.d.ts.map +1 -1
  10. package/dist/introspection/index.js.map +1 -1
  11. package/dist/main/index.d.ts +79 -55
  12. package/dist/main/index.d.ts.map +1 -1
  13. package/dist/main/index.js.map +1 -1
  14. package/dist/react/index.d.ts +11 -11
  15. package/dist/react/index.d.ts.map +1 -1
  16. package/dist/react/index.js.map +1 -1
  17. package/dist/react-devtools/index.js.map +1 -1
  18. package/package.json +1 -1
  19. package/src/data/struct.ts +2 -2
  20. package/src/internal/atom/create-regular-atom.ts +8 -7
  21. package/src/internal/atom/dispose-atom.ts +6 -3
  22. package/src/internal/atom/has-role.ts +1 -1
  23. package/src/internal/caching.ts +15 -15
  24. package/src/internal/events/ingest-creation-disposal.ts +1 -1
  25. package/src/internal/families/create-readonly-pure-selector-family.ts +21 -14
  26. package/src/internal/families/create-regular-atom-family.ts +18 -11
  27. package/src/internal/families/create-selector-family.ts +9 -9
  28. package/src/internal/families/create-writable-pure-selector-family.ts +22 -14
  29. package/src/internal/families/dispose-from-store.ts +10 -7
  30. package/src/internal/families/find-in-store.ts +23 -23
  31. package/src/internal/families/get-family-of-token.ts +17 -17
  32. package/src/internal/families/mint-in-store.ts +10 -10
  33. package/src/internal/families/seek-in-store.ts +26 -26
  34. package/src/internal/get-state/get-fallback.ts +8 -8
  35. package/src/internal/get-state/get-from-store.ts +17 -12
  36. package/src/internal/get-state/read-or-compute-value.ts +78 -14
  37. package/src/internal/get-state/reduce-reference.ts +10 -10
  38. package/src/internal/index.ts +57 -52
  39. package/src/internal/join/join-internal.ts +15 -6
  40. package/src/internal/mutable/create-mutable-atom-family.ts +1 -1
  41. package/src/internal/mutable/get-json-family.ts +3 -2
  42. package/src/internal/mutable/get-update-family.ts +7 -5
  43. package/src/internal/mutable/tracker-family.ts +5 -1
  44. package/src/internal/mutable/tracker.ts +5 -1
  45. package/src/internal/operation.ts +4 -2
  46. package/src/internal/selector/create-readonly-pure-selector.ts +8 -6
  47. package/src/internal/selector/create-standalone-selector.ts +10 -10
  48. package/src/internal/selector/create-writable-pure-selector.ts +9 -7
  49. package/src/internal/selector/dispose-selector.ts +2 -2
  50. package/src/internal/selector/register-selector.ts +2 -2
  51. package/src/internal/selector/trace-selector-atoms.ts +3 -3
  52. package/src/internal/selector/update-selector-atoms.ts +1 -1
  53. package/src/internal/set-state/dispatch-state-update.ts +9 -5
  54. package/src/internal/set-state/evict-downstream.ts +4 -1
  55. package/src/internal/set-state/operate-on-store.ts +16 -10
  56. package/src/internal/set-state/reset-atom-or-selector.ts +7 -7
  57. package/src/internal/set-state/reset-in-store.ts +9 -6
  58. package/src/internal/set-state/set-atom-or-selector.ts +1 -1
  59. package/src/internal/set-state/set-atom.ts +1 -1
  60. package/src/internal/set-state/set-into-store.ts +10 -7
  61. package/src/internal/set-state/set-selector.ts +1 -1
  62. package/src/internal/store/deposit.ts +38 -30
  63. package/src/internal/store/mint-or-counterfeit.ts +23 -23
  64. package/src/internal/store/store.ts +9 -9
  65. package/src/internal/store/withdraw.ts +68 -62
  66. package/src/internal/subscribe/recall-state.ts +4 -1
  67. package/src/internal/subscribe/subscribe-to-root-atoms.ts +2 -2
  68. package/src/internal/subscribe/subscribe-to-state.ts +4 -4
  69. package/src/internal/timeline/create-timeline.ts +5 -5
  70. package/src/introspection/attach-atom-index.ts +2 -2
  71. package/src/introspection/attach-selector-index.ts +4 -2
  72. package/src/introspection/attach-timeline-family.ts +13 -11
  73. package/src/introspection/attach-timeline-index.ts +1 -1
  74. package/src/introspection/attach-transaction-index.ts +1 -1
  75. package/src/introspection/attach-transaction-logs.ts +4 -2
  76. package/src/introspection/attach-type-selectors.ts +2 -1
  77. package/src/introspection/index.ts +3 -5
  78. package/src/main/atom.ts +14 -8
  79. package/src/main/events.ts +25 -23
  80. package/src/main/get-state.ts +10 -8
  81. package/src/main/reset-state.ts +4 -4
  82. package/src/main/selector.ts +40 -24
  83. package/src/main/set-state.ts +8 -4
  84. package/src/main/timeline.ts +5 -3
  85. package/src/main/tokens.ts +72 -44
  86. package/src/main/validators.ts +4 -4
  87. package/src/react/parse-state-overloads.ts +10 -10
  88. package/src/react/use-i.ts +6 -6
  89. package/src/react/use-loadable.ts +15 -15
  90. package/src/react/use-o.ts +9 -9
  91. package/src/react-devtools/StateEditor.tsx +5 -3
  92. package/src/react-devtools/StateIndex.tsx +6 -4
  93. package/src/react-devtools/Updates.tsx +1 -1
  94. package/src/react-devtools/store.ts +16 -7
@@ -23,26 +23,26 @@ export function createStandaloneSelector<T extends object>(
23
23
  store: Store,
24
24
  options: ReadonlyHeldSelectorOptions<T>,
25
25
  ): ReadonlyHeldSelectorToken<T>
26
- export function createStandaloneSelector<T>(
26
+ export function createStandaloneSelector<T, E>(
27
27
  store: Store,
28
- options: WritablePureSelectorOptions<T>,
29
- ): WritablePureSelectorToken<T>
30
- export function createStandaloneSelector<T>(
28
+ options: WritablePureSelectorOptions<T, E>,
29
+ ): WritablePureSelectorToken<T, any, E>
30
+ export function createStandaloneSelector<T, E>(
31
31
  store: Store,
32
- options: ReadonlyPureSelectorOptions<T>,
33
- ): ReadonlyPureSelectorToken<T>
32
+ options: ReadonlyPureSelectorOptions<T, E>,
33
+ ): ReadonlyPureSelectorToken<T, any, E>
34
34
  export function createStandaloneSelector(
35
35
  store: Store,
36
36
  options:
37
37
  | ReadonlyHeldSelectorOptions<any>
38
- | ReadonlyPureSelectorOptions<any>
38
+ | ReadonlyPureSelectorOptions<any, any>
39
39
  | WritableHeldSelectorOptions<any>
40
- | WritablePureSelectorOptions<any>,
40
+ | WritablePureSelectorOptions<any, any>,
41
41
  ):
42
42
  | ReadonlyHeldSelectorToken<any>
43
- | ReadonlyPureSelectorToken<any>
43
+ | ReadonlyPureSelectorToken<any, any, any>
44
44
  | WritableHeldSelectorToken<any>
45
- | WritablePureSelectorToken<any> {
45
+ | WritablePureSelectorToken<any, any, any> {
46
46
  const isWritable = `set` in options
47
47
  const isHeld = `const` in options
48
48
 
@@ -1,8 +1,10 @@
1
1
  import type {
2
2
  FamilyMetadata,
3
+ StateUpdate,
3
4
  WritablePureSelectorOptions,
4
5
  WritablePureSelectorToken,
5
6
  } from "atom.io"
7
+ import type { Canonical } from "atom.io/json"
6
8
 
7
9
  import type { RootStore, WritablePureSelector } from ".."
8
10
  import { writeToCache } from "../caching"
@@ -11,13 +13,13 @@ import type { Store } from "../store"
11
13
  import { Subject } from "../subject"
12
14
  import { registerSelector } from "./register-selector"
13
15
 
14
- export function createWritablePureSelector<T>(
16
+ export function createWritablePureSelector<T, K extends Canonical, E>(
15
17
  store: Store,
16
- options: WritablePureSelectorOptions<T>,
17
- family: FamilyMetadata | undefined,
18
- ): WritablePureSelectorToken<T> {
18
+ options: WritablePureSelectorOptions<T, E>,
19
+ family: FamilyMetadata<K> | undefined,
20
+ ): WritablePureSelectorToken<T, K, E> {
19
21
  const target = newest(store)
20
- const subject = new Subject<{ newValue: T; oldValue: T }>()
22
+ const subject = new Subject<StateUpdate<E | T>>()
21
23
  const covered = new Set<string>()
22
24
  const key = options.key
23
25
  const type = `writable_pure_selector` as const
@@ -27,7 +29,7 @@ export function createWritablePureSelector<T>(
27
29
  const { find, get, json } = setterToolkit
28
30
  const getterToolkit = { find, get, json }
29
31
 
30
- const getFrom = (innerTarget: Store): T => {
32
+ const getFrom = (innerTarget: Store): E | T => {
31
33
  const upstreamStates = innerTarget.selectorGraph.getRelationEntries({
32
34
  downstreamSelectorKey: key,
33
35
  })
@@ -48,7 +50,7 @@ export function createWritablePureSelector<T>(
48
50
  options.set(setterToolkit, newValue)
49
51
  }
50
52
 
51
- const mySelector: WritablePureSelector<T> = {
53
+ const mySelector: WritablePureSelector<T, E> = {
52
54
  ...options,
53
55
  type,
54
56
  subject,
@@ -5,7 +5,7 @@ import { isChildStore, newest, withdraw } from ".."
5
5
 
6
6
  export function disposeSelector(
7
7
  store: Store,
8
- selectorToken: SelectorToken<unknown>,
8
+ selectorToken: SelectorToken<unknown, any, any>,
9
9
  ): void {
10
10
  const target = newest(store)
11
11
  const { key, type, family: familyMeta } = selectorToken
@@ -21,7 +21,7 @@ export function disposeSelector(
21
21
  if (molecule) {
22
22
  target.moleculeData.delete(familyMeta.subKey, familyMeta.key)
23
23
  }
24
- let familyToken: SelectorFamilyToken<any, any>
24
+ let familyToken: SelectorFamilyToken<any, any, any>
25
25
  switch (selectorToken.type) {
26
26
  case `writable_held_selector`:
27
27
  {
@@ -33,8 +33,8 @@ export function registerSelector(
33
33
  return {
34
34
  get: (
35
35
  ...params:
36
- | [ReadableFamilyToken<any, any>, Canonical]
37
- | [ReadableToken<any>]
36
+ | [ReadableFamilyToken<any, any, any>, Canonical]
37
+ | [ReadableToken<any, any, any>]
38
38
  ) => {
39
39
  const target = newest(store)
40
40
  const { token, family, subKey } = reduceReference(store, ...params)
@@ -6,10 +6,10 @@ export function traceRootSelectorAtoms(
6
6
  store: Store,
7
7
  selectorKey: string,
8
8
  covered: Set<string> = new Set<string>(),
9
- ): Map<string, Atom<unknown>> {
9
+ ): Map<string, Atom<any, any>> {
10
10
  const dependencies = getSelectorDependencyKeys(store, selectorKey)
11
11
 
12
- const roots = new Map<string, Atom<unknown>>()
12
+ const roots = new Map<string, Atom<unknown, unknown>>()
13
13
 
14
14
  while (dependencies.length > 0) {
15
15
  // biome-ignore lint/style/noNonNullAssertion: just checked length ^^^
@@ -19,7 +19,7 @@ export function traceRootSelectorAtoms(
19
19
  }
20
20
  covered.add(dependencyKey)
21
21
  if (isAtomKey(store, dependencyKey)) {
22
- const atom = store.atoms.get(dependencyKey) as Atom<unknown>
22
+ const atom = store.atoms.get(dependencyKey) as Atom<unknown, unknown>
23
23
  roots.set(atom.key, atom)
24
24
  } else {
25
25
  dependencies.push(...getSelectorDependencyKeys(store, dependencyKey))
@@ -12,7 +12,7 @@ export function updateSelectorAtoms(
12
12
  | `writable_held_selector`
13
13
  | `writable_pure_selector`,
14
14
  selectorKey: string,
15
- dependency: ReadableToken<unknown>,
15
+ dependency: ReadableToken<unknown, any, unknown>,
16
16
  covered: Set<string>,
17
17
  ): void {
18
18
  const target = newest(store)
@@ -17,12 +17,12 @@ import { isChildStore, isRootStore } from "../transaction"
17
17
  import { evictDownstreamFromAtom } from "./evict-downstream"
18
18
  import type { ProtoUpdate } from "./operate-on-store"
19
19
 
20
- export function dispatchOrDeferStateUpdate<T>(
20
+ export function dispatchOrDeferStateUpdate<T, E>(
21
21
  target: Store & { operation: OpenOperation<any> },
22
- state: WritableState<T>,
23
- { oldValue, newValue }: ProtoUpdate<T>,
22
+ state: WritableState<T, E>,
23
+ { oldValue, newValue }: ProtoUpdate<E | T>,
24
24
  stateIsNewlyCreated: boolean,
25
- family?: WritableFamily<T, any>,
25
+ family?: WritableFamily<T, any, E>,
26
26
  ): void {
27
27
  const token = deposit(state)
28
28
  if (stateIsNewlyCreated && family) {
@@ -128,7 +128,11 @@ export function dispatchOrDeferStateUpdate<T>(
128
128
  const mutable = target.atoms.get(keyOfMutable) as MutableAtom<
129
129
  Transceiver<unknown, any, any>
130
130
  >
131
- const transceiver = readOrComputeValue(target, mutable, `mut`)
131
+ const transceiver = readOrComputeValue<Transceiver<any, any, any>, never>(
132
+ target,
133
+ mutable,
134
+ `mut`,
135
+ )
132
136
  const accepted = transceiver.do(update.newValue) === null
133
137
  if (accepted === true) {
134
138
  evictDownstreamFromAtom(target, mutable)
@@ -4,7 +4,10 @@ import { newest } from "../lineage"
4
4
  import { isDone, markDone } from "../operation"
5
5
  import type { Store } from "../store"
6
6
 
7
- export function evictDownstreamFromAtom(store: Store, atom: Atom<any>): void {
7
+ export function evictDownstreamFromAtom(
8
+ store: Store,
9
+ atom: Atom<any, any>,
10
+ ): void {
8
11
  const target = newest(store)
9
12
  const { key, type } = atom
10
13
  const downstreamKeys = target.selectorAtoms.getRelatedKeys(key)
@@ -18,25 +18,31 @@ export type ProtoUpdate<T> = { oldValue: T; newValue: T }
18
18
  export const OWN_OP: unique symbol = Symbol(`OWN_OP`)
19
19
  export const JOIN_OP: unique symbol = Symbol(`JOIN_OP`)
20
20
 
21
- export function operateOnStore<T, New extends T>(
21
+ export function operateOnStore<
22
+ T,
23
+ K extends Canonical,
24
+ New extends T,
25
+ Key extends K,
26
+ E,
27
+ >(
22
28
  store: Store,
23
29
  opMode: typeof JOIN_OP | typeof OWN_OP,
24
30
  ...params:
25
31
  | [
26
- token: WritableFamilyToken<T, Canonical>,
27
- key: Canonical,
32
+ token: WritableFamilyToken<T, K, E>,
33
+ key: Key,
28
34
  value: New | typeof RESET_STATE | ((oldValue: T) => New),
29
35
  ]
30
36
  | [
31
- token: WritableToken<T>,
37
+ token: WritableToken<T, Key, E>,
32
38
  value: New | typeof RESET_STATE | ((oldValue: T) => New),
33
39
  ]
34
40
  ): void {
35
- let existingToken: WritableToken<T> | undefined
36
- let brandNewToken: WritableToken<T> | undefined
37
- let token: WritableToken<T>
38
- let family: WritableFamily<T, Canonical> | undefined
39
- let key: Canonical | null
41
+ let existingToken: WritableToken<T, Key, E> | undefined
42
+ let brandNewToken: WritableToken<T, Key, E> | undefined
43
+ let token: WritableToken<T, Key, E>
44
+ let family: WritableFamily<T, K, E> | undefined
45
+ let key: Key | null
40
46
  let value: New | typeof RESET_STATE | ((oldValue: T) => New)
41
47
  if (params.length === 2) {
42
48
  token = params[0]
@@ -116,7 +122,7 @@ export function operateOnStore<T, New extends T>(
116
122
  }
117
123
 
118
124
  const state = withdraw(target, token)
119
- let protoUpdate: ProtoUpdate<T>
125
+ let protoUpdate: ProtoUpdate<E | T>
120
126
  if (value === RESET_STATE) {
121
127
  protoUpdate = resetAtomOrSelector(target, state)
122
128
  } else {
@@ -5,10 +5,10 @@ import { dispatchOrDeferStateUpdate } from "./dispatch-state-update"
5
5
  import type { ProtoUpdate } from "./operate-on-store"
6
6
  import { setAtom } from "./set-atom"
7
7
 
8
- function resetAtom<T>(
8
+ function resetAtom<T, E>(
9
9
  target: Store & { operation: OpenOperation },
10
- atom: Atom<T>,
11
- ): ProtoUpdate<T> {
10
+ atom: Atom<T, E>,
11
+ ): ProtoUpdate<E | T> {
12
12
  switch (atom.type) {
13
13
  case `mutable_atom`:
14
14
  return setAtom(target, atom, new atom.class())
@@ -20,11 +20,11 @@ function resetAtom<T>(
20
20
  }
21
21
  }
22
22
 
23
- export function resetAtomOrSelector<T>(
23
+ export function resetAtomOrSelector<T, E>(
24
24
  target: Store & { operation: OpenOperation },
25
- state: WritableState<T>,
26
- ): ProtoUpdate<T> {
27
- let protoUpdate: ProtoUpdate<T>
25
+ state: WritableState<T, E>,
26
+ ): ProtoUpdate<E | T> {
27
+ let protoUpdate: ProtoUpdate<E | T>
28
28
  switch (state.type) {
29
29
  case `atom`:
30
30
  case `mutable_atom`:
@@ -6,26 +6,29 @@ import { setIntoStore } from "./set-into-store"
6
6
 
7
7
  export const RESET_STATE: unique symbol = Symbol(`RESET`)
8
8
 
9
- export function resetInStore(store: Store, token: WritableToken<any>): void
9
+ export function resetInStore(
10
+ store: Store,
11
+ token: WritableToken<any, any, any>,
12
+ ): void
10
13
 
11
14
  export function resetInStore<K extends Canonical>(
12
15
  store: Store,
13
- token: WritableFamilyToken<any, K>,
16
+ token: WritableFamilyToken<any, K, any>,
14
17
  key: K,
15
18
  ): void
16
19
 
17
20
  export function resetInStore<T, K extends Canonical, Key extends K>(
18
21
  store: Store,
19
22
  ...params:
20
- | [token: WritableFamilyToken<T, K>, key: Key]
21
- | [token: WritableToken<T>]
23
+ | [token: WritableFamilyToken<T, K, any>, key: Key]
24
+ | [token: WritableToken<T, any, any>]
22
25
  ): void
23
26
 
24
27
  export function resetInStore<T, K extends Canonical, Key extends K>(
25
28
  store: Store,
26
29
  ...params:
27
- | [token: WritableFamilyToken<T, K>, key: Key]
28
- | [token: WritableToken<T>]
30
+ | [token: WritableFamilyToken<T, K, any>, key: Key]
31
+ | [token: WritableToken<T, any, any>]
29
32
  ): void {
30
33
  const subParams = [...params, RESET_STATE] as const
31
34
  setIntoStore(store, ...subParams)
@@ -7,7 +7,7 @@ import { setSelector } from "./set-selector"
7
7
 
8
8
  export const setAtomOrSelector = <T>(
9
9
  target: Store & { operation: OpenOperation },
10
- state: WritableState<T>,
10
+ state: WritableState<T, any>,
11
11
  value: T | ((oldValue: T) => T),
12
12
  ): ProtoUpdate<T> => {
13
13
  let protoUpdate: ProtoUpdate<T>
@@ -8,7 +8,7 @@ import type { ProtoUpdate } from "./operate-on-store"
8
8
 
9
9
  export const setAtom = <T>(
10
10
  target: Store & { operation: OpenOperation<any> },
11
- atom: Atom<T>,
11
+ atom: Atom<T, any>,
12
12
  next: T | ((oldValue: T) => T),
13
13
  ): ProtoUpdate<T> => {
14
14
  const oldValue = readOrComputeValue(target, atom, `mut`)
@@ -5,9 +5,9 @@ import type { Store } from "../store"
5
5
  import { operateOnStore, OWN_OP } from "./operate-on-store"
6
6
  import type { RESET_STATE } from "./reset-in-store"
7
7
 
8
- export function setIntoStore<T, New extends T>(
8
+ export function setIntoStore<T, New extends T, E>(
9
9
  store: Store,
10
- token: WritableToken<T>,
10
+ token: WritableToken<T, any, E>,
11
11
  value: New | typeof RESET_STATE | ((oldValue: T) => New),
12
12
  ): void
13
13
 
@@ -16,9 +16,10 @@ export function setIntoStore<
16
16
  K extends Canonical,
17
17
  New extends T,
18
18
  Key extends K,
19
+ E,
19
20
  >(
20
21
  store: Store,
21
- token: WritableFamilyToken<T, K>,
22
+ token: WritableFamilyToken<T, K, E>,
22
23
  key: Key,
23
24
  value: New | typeof RESET_STATE | ((oldValue: T) => New),
24
25
  ): void
@@ -28,16 +29,17 @@ export function setIntoStore<
28
29
  K extends Canonical,
29
30
  New extends T,
30
31
  Key extends K,
32
+ E,
31
33
  >(
32
34
  store: Store,
33
35
  ...params:
34
36
  | [
35
- token: WritableFamilyToken<T, K>,
37
+ token: WritableFamilyToken<T, K, E>,
36
38
  key: Key,
37
39
  value: New | typeof RESET_STATE | ((oldValue: T) => New),
38
40
  ]
39
41
  | [
40
- token: WritableToken<T>,
42
+ token: WritableToken<T, any, E>,
41
43
  value: New | typeof RESET_STATE | ((oldValue: T) => New),
42
44
  ]
43
45
  ): void
@@ -47,16 +49,17 @@ export function setIntoStore<
47
49
  K extends Canonical,
48
50
  New extends T,
49
51
  Key extends K,
52
+ E,
50
53
  >(
51
54
  store: Store,
52
55
  ...params:
53
56
  | [
54
- token: WritableFamilyToken<T, K>,
57
+ token: WritableFamilyToken<T, K, E>,
55
58
  key: Key,
56
59
  value: New | typeof RESET_STATE | ((oldValue: T) => New),
57
60
  ]
58
61
  | [
59
- token: WritableToken<T>,
62
+ token: WritableToken<T, any, E>,
60
63
  value: New | typeof RESET_STATE | ((oldValue: T) => New),
61
64
  ]
62
65
  ): void {
@@ -7,7 +7,7 @@ import type { ProtoUpdate } from "./operate-on-store"
7
7
 
8
8
  export function setSelector<T>(
9
9
  target: Store & { operation: OpenOperation<any> },
10
- selector: WritableSelector<T>,
10
+ selector: WritableSelector<T, any>,
11
11
  next: T | ((oldValue: T) => T),
12
12
  ): ProtoUpdate<T> {
13
13
  let oldValue: T
@@ -46,44 +46,52 @@ import type {
46
46
  } from ".."
47
47
  import type { Transaction } from "../transaction"
48
48
 
49
- export function deposit<T>(state: RegularAtom<T>): RegularAtomToken<T>
49
+ export function deposit<T, E>(
50
+ state: RegularAtom<T, E>,
51
+ ): RegularAtomToken<T, Canonical, E>
50
52
  export function deposit<T extends Transceiver<any, any, any>>(
51
53
  state: MutableAtom<T>,
52
54
  ): MutableAtomToken<T>
53
- export function deposit<T>(state: Atom<T>): AtomToken<T>
54
- export function deposit<T>(
55
- state: WritablePureSelector<T>,
56
- ): WritablePureSelectorToken<T>
57
- export function deposit<T>(
58
- state: ReadonlyPureSelector<T>,
59
- ): ReadonlyPureSelectorToken<T>
60
- export function deposit<T>(state: Selector<T>): SelectorToken<T>
61
- export function deposit<T>(state: WritableState<T>): WritableToken<T>
62
- export function deposit<T>(state: ReadableState<T>): ReadableToken<T>
55
+ export function deposit<T, E>(state: Atom<T, E>): AtomToken<T, Canonical, E>
56
+ export function deposit<T, E>(
57
+ state: WritablePureSelector<T, E>,
58
+ ): WritablePureSelectorToken<T, any, E>
59
+ export function deposit<T, E>(
60
+ state: ReadonlyPureSelector<T, E>,
61
+ ): ReadonlyPureSelectorToken<T, any, E>
62
+ export function deposit<T, E>(state: Selector<T, E>): SelectorToken<T, any, E>
63
+ export function deposit<T, E>(
64
+ state: WritableState<T, E>,
65
+ ): WritableToken<T, any, E>
66
+ export function deposit<T, E>(
67
+ state: ReadableState<T, E>,
68
+ ): ReadableToken<T, any, E>
63
69
 
64
- export function deposit<T, K extends Canonical>(
65
- state: RegularAtomFamily<T, K>,
66
- ): RegularAtomFamilyToken<T, K>
70
+ export function deposit<T, K extends Canonical, E>(
71
+ state: RegularAtomFamily<T, K, E>,
72
+ ): RegularAtomFamilyToken<T, K, E>
67
73
  export function deposit<
68
74
  T extends Transceiver<any, any, any>,
69
75
  K extends Canonical,
70
76
  >(state: MutableAtomFamily<T, K>): MutableAtomFamilyToken<T, K>
71
- export function deposit<T>(state: AtomFamily<T, any>): AtomFamilyToken<T, any>
72
- export function deposit<T>(
73
- state: WritablePureSelectorFamily<T, any>,
74
- ): WritablePureSelectorFamilyToken<T, any>
75
- export function deposit<T>(
76
- state: ReadonlyPureSelectorFamily<T, any>,
77
- ): ReadonlyPureSelectorFamilyToken<T, any>
78
- export function deposit<T>(
79
- state: SelectorFamily<T, any>,
80
- ): SelectorFamilyToken<T, any>
81
- export function deposit<T>(
82
- state: WritableFamily<T, any>,
83
- ): WritableFamilyToken<T, any>
84
- export function deposit<T>(
85
- state: ReadableFamily<T, any>,
86
- ): ReadableFamilyToken<T, any>
77
+ export function deposit<T, E>(
78
+ state: AtomFamily<T, any, E>,
79
+ ): AtomFamilyToken<T, any, E>
80
+ export function deposit<T, E>(
81
+ state: WritablePureSelectorFamily<T, any, E>,
82
+ ): WritablePureSelectorFamilyToken<T, any, E>
83
+ export function deposit<T, E>(
84
+ state: ReadonlyPureSelectorFamily<T, any, E>,
85
+ ): ReadonlyPureSelectorFamilyToken<T, any, E>
86
+ export function deposit<T, E>(
87
+ state: SelectorFamily<T, any, E>,
88
+ ): SelectorFamilyToken<T, any, E>
89
+ export function deposit<T, E>(
90
+ state: WritableFamily<T, any, E>,
91
+ ): WritableFamilyToken<T, any, E>
92
+ export function deposit<T, E>(
93
+ state: ReadableFamily<T, any, E>,
94
+ ): ReadableFamilyToken<T, any, E>
87
95
 
88
96
  export function deposit<T extends Fn>(state: Transaction<T>): TransactionToken<T>
89
97
  export function deposit<M extends TimelineManageable>(
@@ -39,53 +39,53 @@ export function mint<
39
39
  Key extends K,
40
40
  >(token: MutableAtomFamilyToken<T, K>, key: Key): MutableAtomToken<T>
41
41
 
42
- export function mint<T, K extends Canonical, Key extends K>(
43
- token: RegularAtomFamilyToken<T, K>,
42
+ export function mint<T, K extends Canonical, Key extends K, E>(
43
+ token: RegularAtomFamilyToken<T, K, E>,
44
44
  key: Key,
45
45
  counterfeit?: typeof COUNTERFEIT,
46
- ): RegularAtomToken<T>
46
+ ): RegularAtomToken<T, Key, E>
47
47
 
48
- export function mint<T, K extends Canonical, Key extends K>(
49
- token: AtomFamilyToken<T, K>,
48
+ export function mint<T, K extends Canonical, Key extends K, E>(
49
+ token: AtomFamilyToken<T, K, E>,
50
50
  key: Key,
51
51
  counterfeit?: typeof COUNTERFEIT,
52
- ): AtomToken<T>
52
+ ): AtomToken<T, Key, E>
53
53
 
54
- export function mint<T, K extends Canonical, Key extends K>(
55
- token: WritablePureSelectorFamilyToken<T, K>,
54
+ export function mint<T, K extends Canonical, Key extends K, E>(
55
+ token: WritablePureSelectorFamilyToken<T, K, E>,
56
56
  key: Key,
57
57
  counterfeit?: typeof COUNTERFEIT,
58
- ): WritablePureSelectorToken<T>
58
+ ): WritablePureSelectorToken<T, Key, E>
59
59
 
60
- export function mint<T, K extends Canonical, Key extends K>(
61
- token: ReadonlyPureSelectorFamilyToken<T, K>,
60
+ export function mint<T, K extends Canonical, Key extends K, E>(
61
+ token: ReadonlyPureSelectorFamilyToken<T, K, E>,
62
62
  key: Key,
63
63
  counterfeit?: typeof COUNTERFEIT,
64
- ): ReadonlyPureSelectorToken<T>
64
+ ): ReadonlyPureSelectorToken<T, Key, E>
65
65
 
66
- export function mint<T, K extends Canonical, Key extends K>(
67
- token: SelectorFamilyToken<T, K>,
66
+ export function mint<T, K extends Canonical, Key extends K, E>(
67
+ token: SelectorFamilyToken<T, K, E>,
68
68
  key: Key,
69
69
  counterfeit?: typeof COUNTERFEIT,
70
- ): SelectorToken<T>
70
+ ): SelectorToken<T, Key, E>
71
71
 
72
- export function mint<T, K extends Canonical, Key extends K>(
73
- token: WritableFamilyToken<T, K>,
72
+ export function mint<T, K extends Canonical, Key extends K, E>(
73
+ token: WritableFamilyToken<T, K, E>,
74
74
  key: Key,
75
75
  counterfeit?: typeof COUNTERFEIT,
76
- ): WritableToken<T>
76
+ ): WritableToken<T, Key, E>
77
77
 
78
- export function mint<T, K extends Canonical, Key extends K>(
79
- token: ReadableFamilyToken<T, K>,
78
+ export function mint<T, K extends Canonical, Key extends K, E>(
79
+ token: ReadableFamilyToken<T, K, E>,
80
80
  key: Key,
81
81
  counterfeit?: typeof COUNTERFEIT,
82
- ): ReadableToken<T>
82
+ ): ReadableToken<T, Key, E>
83
83
 
84
84
  export function mint(
85
- token: ReadableFamilyToken<any, any>,
85
+ token: ReadableFamilyToken<any, any, any>,
86
86
  key: Canonical,
87
87
  counterfeit?: typeof COUNTERFEIT,
88
- ): ReadableToken<any> {
88
+ ): ReadableToken<any, any, any> {
89
89
  const subKey = stringifyJson(key)
90
90
  const fullKey = `${token.key}(${subKey})`
91
91
  const type = FAMILY_MEMBER_TOKEN_TYPES[token.type]
@@ -47,9 +47,9 @@ export class Store implements Lineage {
47
47
  public valueMap: Map<string, any> = new Map()
48
48
  public defaults: Map<string, any> = new Map()
49
49
 
50
- public atoms: Map<string, Atom<any>> = new Map()
51
- public writableSelectors: Map<string, WritableSelector<any>> = new Map()
52
- public readonlySelectors: Map<string, ReadonlySelector<any>> = new Map()
50
+ public atoms: Map<string, Atom<any, any>> = new Map()
51
+ public writableSelectors: Map<string, WritableSelector<any, any>> = new Map()
52
+ public readonlySelectors: Map<string, ReadonlySelector<any, any>> = new Map()
53
53
 
54
54
  public atomsThatAreDefault: Set<string> = new Set()
55
55
  public selectorAtoms: Junction<`selectorKey`, string, `atomKey`, string> =
@@ -77,8 +77,8 @@ export class Store implements Lineage {
77
77
  string,
78
78
  | HeldSelectorFamily<any, any>
79
79
  | MutableAtomFamily<any, any>
80
- | PureSelectorFamily<any, any>
81
- | RegularAtomFamily<any, any>
80
+ | PureSelectorFamily<any, any, any>
81
+ | RegularAtomFamily<any, any, any>
82
82
  > = new Map()
83
83
  public joins: Map<string, Join<any, any, any, any, any, any>> = new Map()
84
84
 
@@ -247,10 +247,10 @@ export class Store implements Lineage {
247
247
  }
248
248
 
249
249
  export type StoreEventCarrier = {
250
- atomCreation: Subject<AtomToken<unknown>>
251
- atomDisposal: Subject<AtomToken<unknown>>
252
- selectorCreation: Subject<SelectorToken<unknown>>
253
- selectorDisposal: Subject<SelectorToken<unknown>>
250
+ atomCreation: Subject<AtomToken<unknown, any, any>>
251
+ atomDisposal: Subject<AtomToken<unknown, any, any>>
252
+ selectorCreation: Subject<SelectorToken<unknown, any, any>>
253
+ selectorDisposal: Subject<SelectorToken<unknown, any, any>>
254
254
  timelineCreation: Subject<TimelineToken<unknown>>
255
255
  transactionCreation: Subject<TransactionToken<Fn>>
256
256
  transactionApplying: StatefulSubject<TransactionProgress<Fn> | null>