atom.io 0.39.1 → 0.40.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 (88) hide show
  1. package/dist/internal/index.d.ts +68 -63
  2. package/dist/internal/index.d.ts.map +1 -1
  3. package/dist/internal/index.js +171 -161
  4. package/dist/internal/index.js.map +1 -1
  5. package/dist/introspection/index.d.ts +2 -2
  6. package/dist/introspection/index.d.ts.map +1 -1
  7. package/dist/introspection/index.js.map +1 -1
  8. package/dist/main/index.d.ts +19 -15
  9. package/dist/main/index.d.ts.map +1 -1
  10. package/dist/main/index.js +16 -13
  11. package/dist/main/index.js.map +1 -1
  12. package/dist/react/index.d.ts +3 -3
  13. package/dist/react/index.d.ts.map +1 -1
  14. package/dist/react/index.js.map +1 -1
  15. package/dist/react-devtools/index.js +9 -6
  16. package/dist/react-devtools/index.js.map +1 -1
  17. package/dist/realtime-client/index.d.ts +3 -3
  18. package/dist/realtime-client/index.d.ts.map +1 -1
  19. package/dist/realtime-client/index.js +3 -4
  20. package/dist/realtime-client/index.js.map +1 -1
  21. package/dist/realtime-server/index.d.ts +2 -2
  22. package/dist/realtime-server/index.d.ts.map +1 -1
  23. package/package.json +2 -2
  24. package/src/internal/atom/create-regular-atom.ts +3 -2
  25. package/src/internal/atom/dispose-atom.ts +6 -6
  26. package/src/internal/events/ingest-selector-update.ts +13 -4
  27. package/src/internal/families/create-readonly-held-selector-family.ts +3 -4
  28. package/src/internal/families/create-readonly-pure-selector-family.ts +4 -9
  29. package/src/internal/families/create-regular-atom-family.ts +3 -4
  30. package/src/internal/families/create-selector-family.ts +6 -6
  31. package/src/internal/families/create-writable-held-selector-family.ts +2 -2
  32. package/src/internal/families/create-writable-pure-selector-family.ts +3 -7
  33. package/src/internal/families/dispose-from-store.ts +9 -2
  34. package/src/internal/get-state/get-from-store.ts +10 -3
  35. package/src/internal/get-state/reduce-reference.ts +15 -2
  36. package/src/internal/index.ts +8 -8
  37. package/src/internal/install-into-store.ts +2 -1
  38. package/src/internal/join/create-join.ts +2 -2
  39. package/src/internal/join/find-relations-in-store.ts +2 -2
  40. package/src/internal/join/get-internal-relations-from-store.ts +2 -2
  41. package/src/internal/join/get-join.ts +5 -2
  42. package/src/internal/join/join-internal.ts +15 -20
  43. package/src/internal/lineage.ts +12 -1
  44. package/src/internal/molecule.ts +64 -36
  45. package/src/internal/mutable/create-mutable-atom-family.ts +4 -4
  46. package/src/internal/mutable/create-mutable-atom.ts +2 -2
  47. package/src/internal/mutable/tracker-family.ts +3 -3
  48. package/src/internal/operation.ts +3 -1
  49. package/src/internal/selector/create-readonly-held-selector.ts +2 -2
  50. package/src/internal/selector/create-readonly-pure-selector.ts +2 -2
  51. package/src/internal/selector/create-writable-held-selector.ts +2 -2
  52. package/src/internal/selector/create-writable-pure-selector.ts +2 -2
  53. package/src/internal/set-state/become.ts +1 -3
  54. package/src/internal/set-state/dispatch-state-update.ts +13 -11
  55. package/src/internal/set-state/reset-in-store.ts +11 -13
  56. package/src/internal/set-state/set-into-store.ts +27 -3
  57. package/src/internal/store/store.ts +14 -12
  58. package/src/internal/timeline/create-timeline.ts +136 -100
  59. package/src/internal/timeline/time-travel.ts +43 -31
  60. package/src/internal/transaction/abort-transaction.ts +3 -15
  61. package/src/internal/transaction/act-upon-store.ts +1 -5
  62. package/src/internal/transaction/apply-transaction.ts +5 -17
  63. package/src/internal/transaction/assign-transaction-to-continuity.ts +2 -7
  64. package/src/internal/transaction/build-transaction.ts +3 -4
  65. package/src/internal/transaction/create-transaction.ts +5 -6
  66. package/src/internal/transaction/get-epoch-number.ts +1 -7
  67. package/src/internal/transaction/set-epoch-number.ts +4 -12
  68. package/src/introspection/attach-introspection-states.ts +4 -2
  69. package/src/introspection/attach-timeline-family.ts +2 -2
  70. package/src/introspection/attach-transaction-logs.ts +2 -2
  71. package/src/introspection/attach-type-selectors.ts +2 -2
  72. package/src/main/dispose-state.ts +1 -5
  73. package/src/main/events.ts +8 -4
  74. package/src/main/get-state.ts +3 -6
  75. package/src/main/logger.ts +1 -1
  76. package/src/main/realm.ts +36 -12
  77. package/src/main/reset-state.ts +1 -5
  78. package/src/main/set-state.ts +4 -11
  79. package/src/main/silo.ts +4 -3
  80. package/src/main/timeline.ts +1 -7
  81. package/src/react/store-context.tsx +3 -3
  82. package/src/react-devtools/Button.tsx +3 -2
  83. package/src/react-devtools/TimelineIndex.tsx +0 -2
  84. package/src/react-devtools/Updates.tsx +14 -9
  85. package/src/react-devtools/store.ts +2 -2
  86. package/src/realtime-client/continuity/register-and-attempt-confirmed-update.ts +4 -8
  87. package/src/realtime-client/sync-continuity.ts +2 -2
  88. package/src/realtime-server/index.ts +2 -2
@@ -15,19 +15,18 @@ import { newest } from "../lineage"
15
15
  import { getJsonToken } from "../mutable"
16
16
  import { MapOverlay } from "../overlays/map-overlay"
17
17
  import { resetInStore, setIntoStore } from "../set-state"
18
- import type { Store } from "../store"
19
18
  import type { Fn } from "../utility-types"
20
19
  import type { TransactionProgress } from "."
21
20
  import { actUponStore, getEpochNumberOfAction } from "."
22
21
  import type { ChildStore, RootStore } from "./is-root-store"
23
22
 
24
23
  export const buildTransaction = (
25
- store: Store,
24
+ store: RootStore,
26
25
  token: TransactionToken<any>,
27
26
  params: any[],
28
27
  id: string,
29
28
  ): ChildStore => {
30
- const parent = newest(store) as ChildStore | RootStore
29
+ const parent = newest(store)
31
30
  const childBase: Omit<ChildStore, `transactionMeta`> = {
32
31
  parent,
33
32
  child: null,
@@ -97,7 +96,7 @@ export const buildTransaction = (
97
96
  `🛫`,
98
97
  `transaction`,
99
98
  token.key,
100
- `Building transaction with params:`,
99
+ `building with params:`,
101
100
  params,
102
101
  )
103
102
  return child
@@ -5,24 +5,24 @@ import type {
5
5
  } from "atom.io"
6
6
 
7
7
  import { newest } from "../lineage"
8
- import type { Store } from "../store"
9
8
  import { deposit } from "../store"
10
9
  import { Subject } from "../subject"
11
10
  import type { Fn } from "../utility-types"
12
11
  import { abortTransaction } from "./abort-transaction"
13
12
  import { applyTransaction } from "./apply-transaction"
14
13
  import { buildTransaction } from "./build-transaction"
14
+ import type { RootStore } from "./is-root-store"
15
15
 
16
16
  export type Transaction<F extends Fn> = {
17
17
  key: string
18
18
  type: `transaction`
19
- install: (store: Store) => void
19
+ install: (store: RootStore) => void
20
20
  subject: Subject<TransactionOutcomeEvent<TransactionToken<F>>>
21
21
  run: (parameters: Parameters<F>, id?: string) => ReturnType<F>
22
22
  }
23
23
 
24
24
  export function createTransaction<F extends Fn>(
25
- store: Store,
25
+ store: RootStore,
26
26
  options: TransactionOptions<F>,
27
27
  ): TransactionToken<F> {
28
28
  const { key } = options
@@ -32,10 +32,9 @@ export function createTransaction<F extends Fn>(
32
32
  type: `transaction`,
33
33
  run: (params: Parameters<F>, id: string) => {
34
34
  const token = deposit(newTransaction)
35
- const childStore = buildTransaction(store, token, params, id)
35
+ const target = buildTransaction(store, token, params, id)
36
36
  try {
37
- const target = newest(store)
38
- const { toolkit } = childStore.transactionMeta
37
+ const { toolkit } = target.transactionMeta
39
38
  const output = options.do(toolkit, ...params)
40
39
  applyTransaction<F>(target, output)
41
40
  return output
@@ -1,6 +1,4 @@
1
- import type { Store } from "../store"
2
1
  import type { RootStore } from "./is-root-store"
3
- import { isRootStore } from "./is-root-store"
4
2
 
5
3
  export function getContinuityKey(
6
4
  store: RootStore,
@@ -21,13 +19,9 @@ export function getEpochNumberOfContinuity(
21
19
  }
22
20
 
23
21
  export function getEpochNumberOfAction(
24
- store: Store,
22
+ store: RootStore,
25
23
  transactionKey: string,
26
24
  ): number | undefined {
27
- const isRoot = isRootStore(store)
28
- if (!isRoot) {
29
- return undefined
30
- }
31
25
  const continuityKey = getContinuityKey(store, transactionKey)
32
26
  if (continuityKey === undefined) {
33
27
  return undefined
@@ -1,27 +1,19 @@
1
- import type { Store } from "../store"
2
1
  import { getContinuityKey } from "./get-epoch-number"
3
- import { isRootStore } from "./is-root-store"
2
+ import type { RootStore } from "./is-root-store"
4
3
 
5
4
  export function setEpochNumberOfContinuity(
6
- store: Store,
5
+ store: RootStore,
7
6
  continuityKey: string,
8
7
  newEpoch: number,
9
8
  ): void {
10
- const isRoot = isRootStore(store)
11
- if (isRoot && continuityKey) {
12
- store.transactionMeta.epoch.set(continuityKey, newEpoch)
13
- }
9
+ store.transactionMeta.epoch.set(continuityKey, newEpoch)
14
10
  }
15
11
 
16
12
  export function setEpochNumberOfAction(
17
- store: Store,
13
+ store: RootStore,
18
14
  transactionKey: string,
19
15
  newEpoch: number,
20
16
  ): void {
21
- const isRoot = isRootStore(store)
22
- if (!isRoot) {
23
- return
24
- }
25
17
  const continuityKey = getContinuityKey(store, transactionKey)
26
18
 
27
19
  if (continuityKey !== undefined) {
@@ -6,7 +6,7 @@ import type {
6
6
  TransactionOutcomeEvent,
7
7
  TransactionToken,
8
8
  } from "atom.io"
9
- import type { Fn, Store, Timeline } from "atom.io/internal"
9
+ import type { Fn, RootStore, 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"
@@ -30,7 +30,9 @@ export type IntrospectionStates = {
30
30
  typeSelectors: ReadonlyPureSelectorFamilyToken<Loadable<string>, string>
31
31
  }
32
32
 
33
- export const attachIntrospectionStates = (store: Store): IntrospectionStates => {
33
+ export const attachIntrospectionStates = (
34
+ store: RootStore,
35
+ ): IntrospectionStates => {
34
36
  return {
35
37
  atomIndex: attachAtomIndex(store),
36
38
  selectorIndex: attachSelectorIndex(store),
@@ -1,5 +1,5 @@
1
1
  import type { ReadonlyPureSelectorFamilyToken } from "atom.io"
2
- import type { Store, Timeline } from "atom.io/internal"
2
+ import type { RootStore, Timeline } from "atom.io/internal"
3
3
  import {
4
4
  createRegularAtomFamily,
5
5
  createSelectorFamily,
@@ -7,7 +7,7 @@ import {
7
7
  } from "atom.io/internal"
8
8
 
9
9
  export const attachTimelineFamily = (
10
- store: Store,
10
+ store: RootStore,
11
11
  ): ReadonlyPureSelectorFamilyToken<Timeline<any>, string> => {
12
12
  const findTimelineLogState__INTERNAL = createRegularAtomFamily<
13
13
  Timeline<any>,
@@ -3,11 +3,11 @@ import type {
3
3
  TransactionOutcomeEvent,
4
4
  TransactionToken,
5
5
  } from "atom.io"
6
- import type { Store } from "atom.io/internal"
6
+ import type { RootStore } from "atom.io/internal"
7
7
  import { createRegularAtomFamily, createSelectorFamily } from "atom.io/internal"
8
8
 
9
9
  export const attachTransactionLogs = (
10
- store: Store,
10
+ store: RootStore,
11
11
  ): ReadonlyPureSelectorFamilyToken<
12
12
  TransactionOutcomeEvent<TransactionToken<any>>[],
13
13
  string
@@ -1,11 +1,11 @@
1
1
  import type { Loadable, ReadonlyPureSelectorFamilyToken } from "atom.io"
2
- import type { Store } from "atom.io/internal"
2
+ import type { RootStore } from "atom.io/internal"
3
3
  import { createReadonlyPureSelectorFamily } from "atom.io/internal"
4
4
 
5
5
  import { discoverType } from "./refinery"
6
6
 
7
7
  export const attachTypeSelectors = (
8
- store: Store,
8
+ store: RootStore,
9
9
  ): ReadonlyPureSelectorFamilyToken<Loadable<string>, string> => {
10
10
  const typeSelectors = createReadonlyPureSelectorFamily<
11
11
  Loadable<string>,
@@ -30,9 +30,5 @@ export function disposeState(
30
30
  | [token: ReadableFamilyToken<any, any>, key: Canonical]
31
31
  | [token: ReadableToken<any>]
32
32
  ): void {
33
- if (params.length === 2) {
34
- disposeFromStore(IMPLICIT.STORE, ...params)
35
- } else {
36
- disposeFromStore(IMPLICIT.STORE, ...params)
37
- }
33
+ disposeFromStore(IMPLICIT.STORE, ...params)
38
34
  }
@@ -23,10 +23,13 @@ export type AtomUpdateEvent<A extends AtomToken<any>> = {
23
23
  timestamp: number
24
24
  }
25
25
 
26
+ export type SelectorUpdateSubEvent<A extends AtomToken<any>> =
27
+ | AtomUpdateEvent<A>
28
+ | StateCreationEvent<any>
26
29
  export type TimelineSelectorUpdateEvent<A extends TimelineManageable> = {
27
30
  type: `selector_update`
28
31
  token: SelectorToken<any>
29
- atomUpdates: AtomUpdateEvent<AtomOnly<A>>[]
32
+ subEvents: SelectorUpdateSubEvent<AtomOnly<A>>[]
30
33
  timestamp: number
31
34
  }
32
35
 
@@ -110,11 +113,12 @@ export type TransactionOutcomeEvent<T extends TransactionToken<any>> = {
110
113
  output: ReturnType<TokenType<T>>
111
114
  }
112
115
 
113
- export type TimelineEvent<ManagedAtom extends TimelineManageable> =
116
+ export type TimelineEvent<ManagedAtom extends TimelineManageable> = {
117
+ checkpoint?: true
118
+ } & (
114
119
  | AtomUpdateEvent<AtomOnly<ManagedAtom>>
115
- | MoleculeCreationEvent
116
- | MoleculeDisposalEvent
117
120
  | StateCreationEvent<AtomOnly<ManagedAtom>>
118
121
  | StateDisposalEvent<AtomOnly<ManagedAtom>>
119
122
  | TimelineSelectorUpdateEvent<ManagedAtom>
120
123
  | TransactionOutcomeEvent<TransactionToken<any>>
124
+ )
@@ -25,13 +25,10 @@ export function getState<T, K extends Canonical, Key extends K>(
25
25
  key: Key,
26
26
  ): ViewOf<T>
27
27
 
28
- export function getState(
28
+ export function getState<T, K extends Canonical, Key extends K>(
29
29
  ...params:
30
- | [token: ReadableFamilyToken<any, any>, key: Canonical]
31
- | [token: ReadableToken<any>]
30
+ | [token: ReadableFamilyToken<T, K>, key: Key]
31
+ | [token: ReadableToken<T>]
32
32
  ): any {
33
- if (params.length === 2) {
34
- return getFromStore(IMPLICIT.STORE, ...params)
35
- }
36
33
  return getFromStore(IMPLICIT.STORE, ...params)
37
34
  }
@@ -37,7 +37,7 @@ const LOGGER_ICON_DICTIONARY = {
37
37
  "⏭️": `Transaction redo`,
38
38
  "⏮️": `Transaction undo`,
39
39
  "⏳": `Timeline event partially captured`,
40
- "⏹️": `Time-travel complete`,
40
+ "⏸️": `Time-travel complete`,
41
41
  // Problems
42
42
  "💣": `Dangerous action likely to cause bad errors down the line`,
43
43
  "❗": `Dangerous action unless in development mode`,
package/src/main/realm.ts CHANGED
@@ -1,24 +1,39 @@
1
- import type { Each, Store } from "atom.io/internal"
1
+ import type { Each, RootStore } from "atom.io/internal"
2
2
  import {
3
+ actUponStore,
3
4
  allocateIntoStore,
5
+ arbitrary,
4
6
  claimWithinStore,
5
- deallocateFromStore,
7
+ createClaimTX,
8
+ createDeallocateTX,
6
9
  fuseWithinStore,
7
10
  IMPLICIT,
8
11
  makeRootMoleculeInStore,
9
12
  } from "atom.io/internal"
10
13
  import type { Canonical } from "atom.io/json"
11
14
 
15
+ import type { TransactionToken } from "./tokens"
16
+
12
17
  export const $claim: unique symbol = Symbol.for(`claim`)
13
18
  export type Claim<K extends Canonical> = K & { [$claim]?: true }
14
19
 
15
20
  export class Realm<H extends Hierarchy> {
16
- public store: Store
21
+ public store: RootStore
22
+ public deallocateTX: TransactionToken<(claim: Claim<Vassal<H>>) => void>
23
+ public claimTX: TransactionToken<
24
+ <V extends Exclude<Vassal<H>, CompoundTypedKey>, A extends Above<V, H>>(
25
+ newProvenance: A,
26
+ claim: Claim<V>,
27
+ exclusive?: `exclusive`,
28
+ ) => void
29
+ >
17
30
  /**
18
31
  * @param store - The store to which the realm will be attached
19
32
  */
20
- public constructor(store: Store = IMPLICIT.STORE) {
33
+ public constructor(store: RootStore = IMPLICIT.STORE) {
21
34
  this.store = store
35
+ this.deallocateTX = createDeallocateTX(store)
36
+ this.claimTX = createClaimTX(store)
22
37
  makeRootMoleculeInStore(`root`, store)
23
38
  }
24
39
  /**
@@ -66,7 +81,7 @@ export class Realm<H extends Hierarchy> {
66
81
  * @param claim - The subject to be deallocated
67
82
  */
68
83
  public deallocate<V extends Vassal<H>>(claim: Claim<V>): void {
69
- deallocateFromStore<H, V>(this.store, claim)
84
+ actUponStore(this.store, this.deallocateTX, arbitrary())(claim)
70
85
  }
71
86
  /**
72
87
  * Transfer a subject of the realm from one owner to another
@@ -79,21 +94,30 @@ export class Realm<H extends Hierarchy> {
79
94
  public claim<
80
95
  V extends Exclude<Vassal<H>, CompoundTypedKey>,
81
96
  A extends Above<V, H>,
82
- >(newProvenance: A, claim: Claim<V>, exclusive?: `exclusive`): Claim<V> {
83
- return claimWithinStore<H, V, A>(this.store, newProvenance, claim, exclusive)
97
+ >(newProvenance: A, claim: Claim<V>, exclusive?: `exclusive`): void {
98
+ actUponStore(this.store, this.claimTX, arbitrary())(
99
+ newProvenance,
100
+ claim,
101
+ exclusive,
102
+ )
84
103
  }
85
104
  }
86
105
 
87
106
  export class Anarchy {
88
- public store: Store
89
- public realm: Realm<any>
107
+ public store: RootStore
108
+ public deallocateTX: TransactionToken<(key: Canonical) => void>
109
+ public claimTX: TransactionToken<
110
+ (newProvenance: Canonical, key: Canonical, exclusive?: `exclusive`) => void
111
+ >
90
112
 
91
113
  /**
92
114
  * @param store - The store to which the anarchy-realm will be attached
93
115
  */
94
- public constructor(store: Store = IMPLICIT.STORE) {
116
+ public constructor(store: RootStore = IMPLICIT.STORE) {
95
117
  this.store = store
96
- this.realm = new Realm(store)
118
+ this.deallocateTX = createDeallocateTX(store)
119
+ this.claimTX = createClaimTX(store)
120
+ makeRootMoleculeInStore(`root`, store)
97
121
  }
98
122
  /**
99
123
  * Declare a new entity
@@ -118,7 +142,7 @@ export class Anarchy {
118
142
  * @param key - The entity to be deallocated
119
143
  */
120
144
  public deallocate(key: Canonical): void {
121
- deallocateFromStore<any, any>(this.store, key)
145
+ actUponStore(this.store, this.deallocateTX, arbitrary())(key)
122
146
  }
123
147
  /**
124
148
  * Transfer an entity from one owner to another
@@ -25,9 +25,5 @@ export function resetState(
25
25
  | [token: WritableFamilyToken<any, Canonical>, key: Canonical]
26
26
  | [token: WritableToken<any>]
27
27
  ): void {
28
- if (params.length === 2) {
29
- resetInStore(IMPLICIT.STORE, ...params)
30
- } else {
31
- resetInStore(IMPLICIT.STORE, ...params)
32
- }
28
+ resetInStore(IMPLICIT.STORE, ...params)
33
29
  }
@@ -35,18 +35,11 @@ export function setState<T, K extends Canonical, New extends T, Key extends K>(
35
35
  key: Key,
36
36
  value: New | Setter<T, New>,
37
37
  ): void
38
- export function setState<T, New extends T>(
38
+
39
+ export function setState<T, K extends Canonical, New extends T, Key extends K>(
39
40
  ...params:
40
- | [
41
- token: WritableFamilyToken<T, Canonical>,
42
- key: Canonical,
43
- value: New | Setter<T, New>,
44
- ]
41
+ | [token: WritableFamilyToken<T, K>, key: Key, value: New | Setter<T, New>]
45
42
  | [token: WritableToken<T>, value: New | Setter<T, New>]
46
43
  ): void {
47
- if (params.length === 2) {
48
- setIntoStore(IMPLICIT.STORE, ...params)
49
- } else {
50
- setIntoStore(IMPLICIT.STORE, ...params)
51
- }
44
+ setIntoStore(IMPLICIT.STORE, ...params)
52
45
  }
package/src/main/silo.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { findState } from "atom.io"
2
+ import type { RootStore } from "atom.io/internal"
2
3
  import {
3
4
  actUponStore,
4
5
  arbitrary,
@@ -38,7 +39,7 @@ import type { selector, selectorFamily } from "./selector"
38
39
  import type { runTransaction, transaction } from "./transaction"
39
40
 
40
41
  export class Silo {
41
- public store: Store
42
+ public store: RootStore
42
43
  public atom: typeof atom
43
44
  public mutableAtom: typeof mutableAtom
44
45
  public atomFamily: typeof atomFamily
@@ -56,10 +57,10 @@ export class Silo {
56
57
  public undo: typeof undo
57
58
  public redo: typeof redo
58
59
  public runTransaction: typeof runTransaction
59
- public install: (tokens: AtomIOToken[], store?: Store) => void
60
+ public install: (tokens: AtomIOToken[], store?: RootStore) => void
60
61
 
61
62
  public constructor(config: Store[`config`], fromStore: Store | null = null) {
62
- const s = (this.store = new Store(config, fromStore))
63
+ const s = (this.store = new Store(config, fromStore) as RootStore)
63
64
  this.atom = ((options: Parameters<typeof atom>[0]) =>
64
65
  createRegularAtom(s, options, undefined)) as typeof atom
65
66
  this.mutableAtom = ((options: Parameters<typeof mutableAtom>[0]) =>
@@ -1,7 +1,6 @@
1
- import type { Timeline } from "atom.io/internal"
2
1
  import { createTimeline, IMPLICIT, timeTravel } from "atom.io/internal"
3
2
 
4
- import type { AtomFamilyToken, AtomToken, TimelineEvent, TimelineToken } from "."
3
+ import type { AtomFamilyToken, AtomToken, TimelineToken } from "."
5
4
 
6
5
  export type TimelineManageable = AtomFamilyToken<any, any> | AtomToken<any>
7
6
  export type AtomOnly<M extends TimelineManageable> = M extends AtomFamilyToken<
@@ -33,11 +32,6 @@ export type TimelineOptions<ManagedAtom extends TimelineManageable> = {
33
32
  key: string
34
33
  /** The managed atoms (and families of atoms) to record */
35
34
  scope: ManagedAtom[]
36
- /** A function that determines whether a given update should be recorded */
37
- shouldCapture?: (
38
- update: TimelineEvent<ManagedAtom>,
39
- timeline: Timeline<TimelineManageable>,
40
- ) => boolean
41
35
  }
42
36
 
43
37
  /**
@@ -1,14 +1,14 @@
1
- import type { Store } from "atom.io/internal"
1
+ import type { RootStore } from "atom.io/internal"
2
2
  import { IMPLICIT } from "atom.io/internal"
3
3
  import * as React from "react"
4
4
 
5
- export const StoreContext: React.Context<Store> = React.createContext(
5
+ export const StoreContext: React.Context<RootStore> = React.createContext(
6
6
  IMPLICIT.STORE,
7
7
  )
8
8
 
9
9
  export const StoreProvider: React.FC<{
10
10
  children: React.ReactNode
11
- store?: Store
11
+ store?: RootStore
12
12
  }> = ({ children, store = IMPLICIT.STORE }) => (
13
13
  <StoreContext.Provider value={store}>{children}</StoreContext.Provider>
14
14
  )
@@ -1,9 +1,10 @@
1
- import type { Modify } from "atom.io/internal"
2
1
  import type { FC } from "react"
3
2
 
4
3
  export const OpenClose: FC<{
5
4
  isOpen: boolean
6
- setIsOpen?: ((next: Modify<boolean> | boolean) => void) | undefined
5
+ setIsOpen?:
6
+ | ((next: boolean | ((prev: boolean) => boolean)) => void)
7
+ | undefined
7
8
  onShiftClick?: (
8
9
  event: React.MouseEvent<HTMLButtonElement, MouseEvent>,
9
10
  ) => boolean
@@ -64,8 +64,6 @@ export const TimelineLog: FC<{
64
64
  {isOpen ? (
65
65
  <main>
66
66
  {timeline.history.map((update, index) =>
67
- update.type !== `molecule_creation` &&
68
- update.type !== `molecule_disposal` &&
69
67
  update.type !== `state_creation` &&
70
68
  update.type !== `state_disposal` ? (
71
69
  <Fragment key={update.token.key + index + timeline.at}>
@@ -192,18 +192,23 @@ export const TimelineUpdateFC: React.FC<{
192
192
  }
193
193
  })
194
194
  ) : timelineUpdate.type === `selector_update` ? (
195
- timelineUpdate.atomUpdates
195
+ timelineUpdate.subEvents
196
196
  .filter(
197
197
  (atomUpdateEvent) => !atomUpdateEvent.token.key.startsWith(`👁‍🗨`),
198
198
  )
199
- .map((atomUpdate, index) => {
200
- return (
201
- <article.AtomUpdate
202
- key={`${timelineUpdate.token.key}:${index}:${atomUpdate.token.key}`}
203
- serialNumber={index}
204
- atomUpdate={atomUpdate}
205
- />
206
- )
199
+ .map((event, index) => {
200
+ switch (event.type) {
201
+ case `atom_update`:
202
+ return (
203
+ <article.AtomUpdate
204
+ key={`${timelineUpdate.token.key}:${index}:${event.token.key}`}
205
+ serialNumber={index}
206
+ atomUpdate={event}
207
+ />
208
+ )
209
+ case `state_creation`:
210
+ return null
211
+ }
207
212
  })
208
213
  ) : timelineUpdate.type === `atom_update` ? (
209
214
  <article.AtomUpdate
@@ -5,11 +5,11 @@ import type {
5
5
  SelectorToken,
6
6
  TransactionToken,
7
7
  } from "atom.io"
8
+ import type { RootStore, Store } from "atom.io/internal"
8
9
  import {
9
10
  createRegularAtom,
10
11
  createRegularAtomFamily,
11
12
  createTransaction,
12
- type Store,
13
13
  } from "atom.io/internal"
14
14
  import type {
15
15
  IntrospectionStates,
@@ -34,7 +34,7 @@ export type DevtoolsStates = {
34
34
  }
35
35
 
36
36
  export function attachDevtoolsStates(
37
- store: Store,
37
+ store: RootStore,
38
38
  hideByDefault = false,
39
39
  ): DevtoolsStates & IntrospectionStates & { store: Store } {
40
40
  const introspectionStates = attachIntrospectionStates(store)
@@ -1,10 +1,9 @@
1
1
  import type * as AtomIO from "atom.io"
2
- import type { Fn, Store } from "atom.io/internal"
2
+ import type { Fn, RootStore } from "atom.io/internal"
3
3
  import {
4
4
  actUponStore,
5
5
  getEpochNumberOfContinuity,
6
6
  ingestTransactionOutcomeEvent,
7
- isRootStore,
8
7
  setEpochNumberOfContinuity,
9
8
  setIntoStore,
10
9
  } from "atom.io/internal"
@@ -16,7 +15,7 @@ import type { Socket } from "atom.io/realtime-server"
16
15
 
17
16
  export const useRegisterAndAttemptConfirmedUpdate =
18
17
  (
19
- store: Store,
18
+ store: RootStore,
20
19
  continuityKey: string,
21
20
  socket: Socket,
22
21
  optimisticUpdates: AtomIO.TransactionOutcomeEvent<
@@ -187,11 +186,8 @@ export const useRegisterAndAttemptConfirmedUpdate =
187
186
  continuityKey,
188
187
  `has no optimistic updates to deal with`,
189
188
  )
190
- const isRoot = isRootStore(store)
191
189
  let continuityEpoch: number | undefined
192
- if (isRoot) {
193
- continuityEpoch = getEpochNumberOfContinuity(store, continuityKey)
194
- }
190
+ continuityEpoch = getEpochNumberOfContinuity(store, continuityKey)
195
191
 
196
192
  if (continuityEpoch === confirmed.epoch - 1) {
197
193
  store.logger.info(
@@ -203,7 +199,7 @@ export const useRegisterAndAttemptConfirmedUpdate =
203
199
  ingestTransactionOutcomeEvent(store, confirmed, `newValue`)
204
200
  socket.emit(`ack:${continuityKey}`, confirmed.epoch)
205
201
  setEpochNumberOfContinuity(store, continuityKey, confirmed.epoch)
206
- } else if (isRoot && continuityEpoch !== undefined) {
202
+ } else if (continuityEpoch !== undefined) {
207
203
  store.logger.info(
208
204
  `🧑‍⚖️`,
209
205
  `continuity`,
@@ -1,4 +1,4 @@
1
- import type { Store } from "atom.io/internal"
1
+ import type { RootStore } from "atom.io/internal"
2
2
  import {
3
3
  assignTransactionToContinuity,
4
4
  getFromStore,
@@ -20,7 +20,7 @@ import { useConcealState } from "./continuity/use-conceal-state"
20
20
  import { useRevealState } from "./continuity/use-reveal-state"
21
21
 
22
22
  export function syncContinuity(
23
- store: Store,
23
+ store: RootStore,
24
24
  socket: Socket,
25
25
  continuity: ContinuityToken,
26
26
  ): () => void {
@@ -1,4 +1,4 @@
1
- import type { Store } from "atom.io/internal"
1
+ import type { RootStore } from "atom.io/internal"
2
2
  import type { Json } from "atom.io/json"
3
3
 
4
4
  export * from "./continuity/prepare-to-sync-realtime-continuity"
@@ -25,5 +25,5 @@ export type Socket = {
25
25
  }
26
26
  export type ServerConfig = {
27
27
  socket: Socket
28
- store?: Store
28
+ store?: RootStore
29
29
  }