atom.io 0.27.3 → 0.27.5

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 (96) hide show
  1. package/data/dist/index.js +57 -72
  2. package/data/src/dict.ts +9 -12
  3. package/data/src/join.ts +25 -26
  4. package/data/src/struct-family.ts +17 -23
  5. package/data/src/struct.ts +9 -12
  6. package/dist/{chunk-ETCFHO7J.js → chunk-6ABWLAGY.js} +246 -159
  7. package/dist/index.d.ts +4 -4
  8. package/dist/index.js +33 -53
  9. package/ephemeral/dist/index.js +1 -1
  10. package/ephemeral/src/find-state.ts +1 -1
  11. package/immortal/dist/index.js +2 -2
  12. package/immortal/src/seek-state.ts +2 -2
  13. package/internal/dist/index.d.ts +88 -73
  14. package/internal/dist/index.js +1 -1
  15. package/internal/src/atom/create-regular-atom.ts +3 -3
  16. package/internal/src/atom/create-standalone-atom.ts +7 -5
  17. package/internal/src/families/create-atom-family.ts +5 -5
  18. package/internal/src/families/create-readonly-selector-family.ts +35 -7
  19. package/internal/src/families/create-regular-atom-family.ts +16 -6
  20. package/internal/src/families/create-selector-family.ts +5 -5
  21. package/internal/src/families/create-writable-selector-family.ts +35 -8
  22. package/internal/src/families/dispose-from-store.ts +22 -16
  23. package/internal/src/families/find-in-store.ts +11 -11
  24. package/internal/src/families/init-family-member.ts +9 -9
  25. package/internal/src/families/seek-in-store.ts +10 -13
  26. package/internal/src/get-state/get-from-store.ts +58 -20
  27. package/internal/src/get-state/read-or-compute-value.ts +1 -1
  28. package/internal/src/index.ts +5 -3
  29. package/internal/src/ingest-updates/ingest-atom-update.ts +1 -1
  30. package/internal/src/ingest-updates/ingest-creation-disposal.ts +5 -5
  31. package/internal/src/molecule/create-molecule-family.ts +1 -1
  32. package/internal/src/molecule/dispose-molecule.ts +1 -1
  33. package/internal/src/molecule/grow-molecule-in-store.ts +1 -1
  34. package/internal/src/molecule/make-molecule-in-store.ts +5 -5
  35. package/internal/src/mutable/create-mutable-atom-family.ts +15 -6
  36. package/internal/src/mutable/create-mutable-atom.ts +3 -3
  37. package/internal/src/mutable/get-json-token.ts +2 -2
  38. package/internal/src/mutable/tracker-family.ts +3 -3
  39. package/internal/src/mutable/tracker.ts +14 -18
  40. package/internal/src/selector/create-readonly-selector.ts +2 -2
  41. package/internal/src/selector/create-standalone-selector.ts +5 -5
  42. package/internal/src/selector/create-writable-selector.ts +8 -8
  43. package/internal/src/selector/register-selector.ts +9 -9
  44. package/internal/src/set-state/set-into-store.ts +21 -18
  45. package/internal/src/store/deposit.ts +62 -21
  46. package/internal/src/store/store.ts +2 -1
  47. package/internal/src/subscribe/index.ts +2 -0
  48. package/internal/src/subscribe/subscribe-in-store.ts +62 -0
  49. package/internal/src/timeline/time-travel.ts +1 -1
  50. package/internal/src/transaction/build-transaction.ts +7 -6
  51. package/introspection/dist/index.js +66 -87
  52. package/introspection/src/attach-atom-index.ts +5 -8
  53. package/introspection/src/attach-selector-index.ts +6 -8
  54. package/introspection/src/attach-timeline-family.ts +25 -28
  55. package/introspection/src/attach-timeline-index.ts +5 -8
  56. package/introspection/src/attach-transaction-index.ts +5 -8
  57. package/introspection/src/attach-transaction-logs.ts +21 -27
  58. package/json/dist/index.js +12 -15
  59. package/json/src/select-json-family.ts +4 -4
  60. package/json/src/select-json.ts +6 -9
  61. package/package.json +4 -4
  62. package/react/dist/index.js +7 -7
  63. package/react/src/parse-state-overloads.ts +2 -2
  64. package/react/src/use-i.ts +1 -1
  65. package/react/src/use-json.ts +2 -2
  66. package/react/src/use-o.ts +2 -2
  67. package/realtime-client/dist/index.js +35 -55
  68. package/realtime-client/src/pull-atom-family-member.ts +1 -1
  69. package/realtime-client/src/pull-atom.ts +1 -1
  70. package/realtime-client/src/pull-mutable-atom-family-member.ts +3 -3
  71. package/realtime-client/src/pull-mutable-atom.ts +3 -3
  72. package/realtime-client/src/sync-continuity.ts +27 -47
  73. package/realtime-react/dist/index.js +3 -3
  74. package/realtime-react/src/use-pull-atom-family-member.ts +1 -1
  75. package/realtime-react/src/use-pull-mutable-family-member.ts +1 -1
  76. package/realtime-react/src/use-pull-selector-family-member.ts +1 -1
  77. package/realtime-server/dist/index.js +32 -32
  78. package/realtime-server/src/realtime-continuity-synchronizer.ts +16 -16
  79. package/realtime-server/src/realtime-family-provider.ts +3 -3
  80. package/realtime-server/src/realtime-mutable-family-provider.ts +5 -5
  81. package/realtime-server/src/realtime-mutable-provider.ts +2 -2
  82. package/realtime-server/src/realtime-state-provider.ts +1 -1
  83. package/realtime-server/src/realtime-state-receiver.ts +1 -1
  84. package/realtime-testing/dist/index.js +7 -7
  85. package/realtime-testing/src/setup-realtime-test.tsx +7 -7
  86. package/src/atom.ts +2 -2
  87. package/src/dispose-state.ts +2 -2
  88. package/src/get-state.ts +9 -13
  89. package/src/logger.ts +4 -0
  90. package/src/molecule.ts +1 -1
  91. package/src/selector.ts +2 -2
  92. package/src/set-state.ts +10 -7
  93. package/src/silo.ts +23 -53
  94. package/src/subscribe.ts +3 -23
  95. package/src/timeline.ts +2 -2
  96. package/internal/src/families/throw-in-case-of-conflicting-family.ts +0 -18
@@ -1,30 +1,47 @@
1
1
  import type {
2
+ AtomFamilyToken,
2
3
  AtomToken,
4
+ MoleculeConstructor,
3
5
  MoleculeFamily,
4
6
  MoleculeFamilyToken,
5
7
  MoleculeToken,
8
+ MutableAtomFamilyToken,
6
9
  MutableAtomToken,
10
+ ReadableFamilyToken,
7
11
  ReadableToken,
12
+ ReadonlySelectorFamilyToken,
8
13
  ReadonlySelectorToken,
14
+ RegularAtomFamilyToken,
9
15
  RegularAtomToken,
16
+ SelectorFamilyToken,
10
17
  SelectorToken,
11
18
  TransactionToken,
19
+ WritableFamilyToken,
20
+ WritableSelectorFamilyToken,
12
21
  WritableSelectorToken,
13
22
  WritableToken,
14
23
  } from "atom.io"
15
- import type { Canonical } from "atom.io/json"
24
+ import type { Canonical, Json } from "atom.io/json"
16
25
 
17
26
  import type {
18
27
  Atom,
28
+ AtomFamily,
19
29
  Func,
20
30
  Molecule,
21
31
  MutableAtom,
32
+ MutableAtomFamily,
33
+ ReadableFamily,
22
34
  ReadableState,
23
35
  ReadonlySelector,
36
+ ReadonlySelectorFamily,
24
37
  RegularAtom,
38
+ RegularAtomFamily,
25
39
  Selector,
40
+ SelectorFamily,
26
41
  Transceiver,
42
+ WritableFamily,
27
43
  WritableSelector,
44
+ WritableSelectorFamily,
28
45
  WritableState,
29
46
  } from ".."
30
47
  import type { Transaction } from "../transaction"
@@ -38,37 +55,61 @@ export function deposit<T>(state: WritableSelector<T>): WritableSelectorToken<T>
38
55
  export function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>
39
56
  export function deposit<T>(state: Selector<T>): SelectorToken<T>
40
57
  export function deposit<T>(state: WritableState<T>): WritableToken<T>
58
+ export function deposit<T>(state: ReadableState<T>): ReadableToken<T>
59
+
60
+ export function deposit<T, K extends Canonical>(
61
+ state: RegularAtomFamily<T, K>,
62
+ ): RegularAtomFamilyToken<T, K>
41
63
  export function deposit<
64
+ T extends Transceiver<any>,
65
+ J extends Json.Serializable,
42
66
  K extends Canonical,
43
- S extends { [key: string]: any },
44
- P extends any[],
45
- >(state: Molecule<any>): MoleculeToken<any>
46
- export function deposit<
47
- K extends Canonical,
48
- S extends { [key: string]: any },
49
- P extends any[],
50
- >(state: MoleculeFamily<any>): MoleculeFamilyToken<any>
67
+ >(state: MutableAtomFamily<T, J, K>): MutableAtomFamilyToken<T, J, K>
68
+ export function deposit<T>(state: AtomFamily<T, any>): AtomFamilyToken<T, any>
69
+ export function deposit<T>(
70
+ state: WritableSelectorFamily<T, any>,
71
+ ): WritableSelectorFamilyToken<T, any>
72
+ export function deposit<T>(
73
+ state: ReadonlySelectorFamily<T, any>,
74
+ ): ReadonlySelectorFamilyToken<T, any>
75
+ export function deposit<T>(
76
+ state: SelectorFamily<T, any>,
77
+ ): SelectorFamilyToken<T, any>
78
+ export function deposit<T>(
79
+ state: WritableFamily<T, any>,
80
+ ): WritableFamilyToken<T, any>
81
+ export function deposit<T>(
82
+ state: ReadableFamily<T, any>,
83
+ ): ReadableFamilyToken<T, any>
84
+
85
+ export function deposit<M extends MoleculeConstructor>(
86
+ state: MoleculeFamily<M>,
87
+ ): MoleculeFamilyToken<M>
88
+ export function deposit<M extends MoleculeConstructor>(
89
+ state: Molecule<M>,
90
+ ): MoleculeToken<M>
91
+
51
92
  export function deposit<T extends Func>(
52
93
  state: Transaction<T>,
53
94
  ): TransactionToken<T>
54
- export function deposit<T>(state: ReadableState<T>): ReadableToken<T>
55
- export function deposit<T>(
95
+
96
+ export function deposit(
97
+ state: Molecule<any> | ReadableState<any>,
98
+ ): MoleculeToken<any> | ReadableToken<any>
99
+
100
+ export function deposit(
56
101
  state:
57
102
  | Molecule<any>
58
103
  | MoleculeFamily<any>
59
- | ReadableState<T>
60
- | ReadonlySelector<T>
61
- | RegularAtom<T>
62
- | Transaction<T extends Func ? T : never>
63
- | WritableSelector<T>
64
- | (T extends Transceiver<any> ? MutableAtom<T, any> : never),
104
+ | ReadableFamily<any, any>
105
+ | ReadableState<any>
106
+ | Transaction<Func>,
65
107
  ):
66
108
  | MoleculeFamilyToken<any>
67
109
  | MoleculeToken<any>
68
- | MutableAtomToken<T extends Transceiver<any> ? T : never, any>
69
- | RegularAtomToken<T>
70
- | SelectorToken<T>
71
- | TransactionToken<T extends Func ? T : never> {
110
+ | ReadableFamilyToken<any, any>
111
+ | ReadableToken<any>
112
+ | TransactionToken<Func> {
72
113
  const token = {
73
114
  key: state.key,
74
115
  type: state.type,
@@ -42,6 +42,7 @@ export class Store implements Lineage {
42
42
  public child: Store | null = null
43
43
 
44
44
  public valueMap = new Map<string, any>()
45
+ public defaults = new Map<string, any>()
45
46
 
46
47
  public atoms = new Map<string, Atom<any>>()
47
48
  public selectors = new Map<string, WritableSelector<any>>()
@@ -175,7 +176,7 @@ export class Store implements Lineage {
175
176
  }
176
177
  atom.install(this)
177
178
  if (atom.type === `mutable_atom`) {
178
- const originalJsonToken = getJsonToken(atom, store)
179
+ const originalJsonToken = getJsonToken(store, atom)
179
180
  const originalUpdateToken = getUpdateToken(atom)
180
181
  mutableHelpers.add(originalJsonToken.key)
181
182
  mutableHelpers.add(originalUpdateToken.key)
@@ -1,3 +1,5 @@
1
+ export * from "./recall-state"
2
+ export * from "./subscribe-in-store"
1
3
  export * from "./subscribe-to-root-atoms"
2
4
  export * from "./subscribe-to-state"
3
5
  export * from "./subscribe-to-timeline"
@@ -0,0 +1,62 @@
1
+ import type {
2
+ ReadableToken,
3
+ TimelineManageable,
4
+ TimelineToken,
5
+ TimelineUpdate,
6
+ TransactionToken,
7
+ TransactionUpdateHandler,
8
+ UpdateHandler,
9
+ } from "atom.io"
10
+ import type { Func, Store } from "atom.io/internal"
11
+ import {
12
+ arbitrary,
13
+ subscribeToState,
14
+ subscribeToTimeline,
15
+ subscribeToTransaction,
16
+ } from "atom.io/internal"
17
+
18
+ export function subscribeInStore<T>(
19
+ store: Store,
20
+ token: ReadableToken<T>,
21
+ handleUpdate: UpdateHandler<T>,
22
+ key?: string,
23
+ ): () => void
24
+ export function subscribeInStore<F extends Func>(
25
+ store: Store,
26
+ token: TransactionToken<F>,
27
+ handleUpdate: TransactionUpdateHandler<F>,
28
+ key?: string,
29
+ ): () => void
30
+ export function subscribeInStore<M extends TimelineManageable>(
31
+ store: Store,
32
+ token: TimelineToken<M>,
33
+ handleUpdate: (update: TimelineUpdate<M> | `redo` | `undo`) => void,
34
+ key?: string,
35
+ ): () => void
36
+ export function subscribeInStore<M extends TimelineManageable>(
37
+ store: Store,
38
+ token: ReadableToken<any> | TimelineToken<M> | TransactionToken<any>,
39
+ handleUpdate:
40
+ | TransactionUpdateHandler<any>
41
+ | UpdateHandler<any>
42
+ | ((update: TimelineUpdate<M> | `redo` | `undo`) => void),
43
+ key?: string,
44
+ ): () => void
45
+ export function subscribeInStore(
46
+ store: Store,
47
+ token: ReadableToken<any> | TimelineToken<any> | TransactionToken<any>,
48
+ handleUpdate: (update: any) => void,
49
+ key: string = arbitrary(),
50
+ ): () => void {
51
+ switch (token.type) {
52
+ case `atom`:
53
+ case `mutable_atom`:
54
+ case `readonly_selector`:
55
+ case `selector`:
56
+ return subscribeToState(token, handleUpdate, key, store)
57
+ case `transaction`:
58
+ return subscribeToTransaction(token, handleUpdate, key, store)
59
+ case `timeline`:
60
+ return subscribeToTimeline(token, handleUpdate, key, store)
61
+ }
62
+ }
@@ -12,9 +12,9 @@ import {
12
12
  import type { Store } from "../store"
13
13
 
14
14
  export const timeTravel = (
15
+ store: Store,
15
16
  action: `redo` | `undo`,
16
17
  token: TimelineToken<any>,
17
- store: Store,
18
18
  ): void => {
19
19
  store.logger.info(
20
20
  action === `redo` ? `⏩` : `⏪`,
@@ -48,6 +48,7 @@ export const buildTransaction = (
48
48
  }),
49
49
  selectors: new LazyMap(parent.selectors),
50
50
  valueMap: new LazyMap(parent.valueMap),
51
+ defaults: parent.defaults,
51
52
  molecules: new LazyMap(parent.molecules),
52
53
  moleculeFamilies: new LazyMap(parent.moleculeFamilies),
53
54
  moleculeInProgress: parent.moleculeInProgress,
@@ -67,19 +68,19 @@ export const buildTransaction = (
67
68
  },
68
69
  toolkit: {
69
70
  get: ((...ps: Parameters<typeof getState>) =>
70
- getFromStore(...ps, child)) as typeof getState,
71
+ getFromStore(child, ...ps)) as typeof getState,
71
72
  set: ((...ps: Parameters<typeof setState>) => {
72
- setIntoStore(...ps, child)
73
+ setIntoStore(child, ...ps)
73
74
  }) as typeof setState,
74
75
  run: (token, identifier = arbitrary()) =>
75
76
  actUponStore(token, identifier, child),
76
- find: ((token, k) => findInStore(token, k, child)) as typeof findState,
77
- seek: ((token, k) => seekInStore(token, k, child)) as typeof seekState,
78
- json: (token) => getJsonToken(token, child),
77
+ find: ((token, k) => findInStore(child, token, k)) as typeof findState,
78
+ seek: ((token, k) => seekInStore(child, token, k)) as typeof seekState,
79
+ json: (token) => getJsonToken(child, token),
79
80
  make: (context, family, k, ...args) =>
80
81
  makeMoleculeInStore(child, context, family, k, ...args),
81
82
  dispose: ((...ps: Parameters<typeof disposeState>) => {
82
- disposeFromStore(...ps, child)
83
+ disposeFromStore(child, ...ps)
83
84
  }) as typeof disposeState,
84
85
  env: () => getEnvironmentData(child),
85
86
  },
@@ -5,6 +5,7 @@ import { getState } from 'atom.io';
5
5
 
6
6
  var attachAtomIndex = (store = IMPLICIT.STORE) => {
7
7
  const atomTokenIndexState__INTERNAL = createRegularAtom(
8
+ store,
8
9
  {
9
10
  key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index (Internal)`,
10
11
  default: () => {
@@ -73,19 +74,16 @@ var attachAtomIndex = (store = IMPLICIT.STORE) => {
73
74
  }
74
75
  ]
75
76
  },
76
- void 0,
77
- store
78
- );
79
- return createStandaloneSelector(
80
- {
81
- key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index`,
82
- get: ({ get }) => get(atomTokenIndexState__INTERNAL)
83
- },
84
- store
77
+ void 0
85
78
  );
79
+ return createStandaloneSelector(store, {
80
+ key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index`,
81
+ get: ({ get }) => get(atomTokenIndexState__INTERNAL)
82
+ });
86
83
  };
87
84
  var attachSelectorIndex = (store = IMPLICIT.STORE) => {
88
85
  const readonlySelectorTokenIndexState__INTERNAL = createRegularAtom(
86
+ store,
89
87
  {
90
88
  key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index (Internal)`,
91
89
  default: () => {
@@ -162,56 +160,50 @@ var attachSelectorIndex = (store = IMPLICIT.STORE) => {
162
160
  }
163
161
  ]
164
162
  },
165
- void 0,
166
- store
167
- );
168
- return createStandaloneSelector(
169
- {
170
- key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index`,
171
- get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL)
172
- },
173
- IMPLICIT.STORE
163
+ void 0
174
164
  );
165
+ return createStandaloneSelector(IMPLICIT.STORE, {
166
+ key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index`,
167
+ get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL)
168
+ });
175
169
  };
176
170
  var attachTimelineFamily = (store = IMPLICIT.STORE) => {
177
- const findTimelineLogState__INTERNAL = createRegularAtomFamily(
178
- {
179
- key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log (Internal)`,
180
- default: (key) => store.timelines.get(key) ?? {
181
- type: `timeline`,
182
- key: ``,
183
- at: 0,
184
- timeTraveling: null,
185
- history: [],
186
- selectorTime: null,
187
- transactionKey: null,
188
- install: () => {
189
- },
190
- subject: new Subject(),
191
- subscriptions: /* @__PURE__ */ new Map()
171
+ const findTimelineLogState__INTERNAL = createRegularAtomFamily(store, {
172
+ key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log (Internal)`,
173
+ default: (key) => store.timelines.get(key) ?? {
174
+ type: `timeline`,
175
+ key: ``,
176
+ at: 0,
177
+ timeTraveling: null,
178
+ history: [],
179
+ selectorTime: null,
180
+ transactionKey: null,
181
+ install: () => {
192
182
  },
193
- effects: (key) => [
194
- ({ setSelf }) => {
195
- const tl = store.timelines.get(key);
196
- tl?.subject.subscribe(`introspection`, (_) => {
197
- setSelf({ ...tl });
198
- });
199
- }
200
- ]
183
+ subject: new Subject(),
184
+ subscriptions: /* @__PURE__ */ new Map()
201
185
  },
202
- store
203
- );
186
+ effects: (key) => [
187
+ ({ setSelf }) => {
188
+ const tl = store.timelines.get(key);
189
+ tl?.subject.subscribe(`introspection`, (_) => {
190
+ setSelf({ ...tl });
191
+ });
192
+ }
193
+ ]
194
+ });
204
195
  const findTimelineLogState = createSelectorFamily(
196
+ store,
205
197
  {
206
198
  key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log`,
207
199
  get: (key) => ({ get }) => get(findTimelineLogState__INTERNAL, key)
208
- },
209
- store
200
+ }
210
201
  );
211
202
  return findTimelineLogState;
212
203
  };
213
204
  var attachTimelineIndex = (store = IMPLICIT.STORE) => {
214
205
  const timelineTokenIndexState__INTERNAL = createRegularAtom(
206
+ store,
215
207
  {
216
208
  key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index (Internal)`,
217
209
  default: () => [...store.timelines].map(([key]) => {
@@ -228,20 +220,17 @@ var attachTimelineIndex = (store = IMPLICIT.STORE) => {
228
220
  }
229
221
  ]
230
222
  },
231
- void 0,
232
- store
233
- );
234
- const timelineTokenIndex = createStandaloneSelector(
235
- {
236
- key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index`,
237
- get: ({ get }) => get(timelineTokenIndexState__INTERNAL)
238
- },
239
- store
223
+ void 0
240
224
  );
225
+ const timelineTokenIndex = createStandaloneSelector(store, {
226
+ key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index`,
227
+ get: ({ get }) => get(timelineTokenIndexState__INTERNAL)
228
+ });
241
229
  return timelineTokenIndex;
242
230
  };
243
231
  var attachTransactionIndex = (store = IMPLICIT.STORE) => {
244
232
  const transactionTokenIndexState__INTERNAL = createRegularAtom(
233
+ store,
245
234
  {
246
235
  key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index (Internal)`,
247
236
  default: () => [...store.transactions].map(([key]) => {
@@ -258,43 +247,33 @@ var attachTransactionIndex = (store = IMPLICIT.STORE) => {
258
247
  }
259
248
  ]
260
249
  },
261
- void 0,
262
- store
263
- );
264
- const transactionTokenIndex = createStandaloneSelector(
265
- {
266
- key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index`,
267
- get: ({ get }) => get(transactionTokenIndexState__INTERNAL)
268
- },
269
- store
250
+ void 0
270
251
  );
252
+ const transactionTokenIndex = createStandaloneSelector(store, {
253
+ key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index`,
254
+ get: ({ get }) => get(transactionTokenIndexState__INTERNAL)
255
+ });
271
256
  return transactionTokenIndex;
272
257
  };
273
258
  var attachTransactionLogs = (store = IMPLICIT.STORE) => {
274
- const transactionUpdateLogAtoms = createRegularAtomFamily(
275
- {
276
- key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log (Internal)`,
277
- default: () => [],
278
- effects: (key) => [
279
- ({ setSelf }) => {
280
- const tx = store.transactions.get(key);
281
- tx?.subject.subscribe(`introspection`, (transactionUpdate) => {
282
- if (transactionUpdate.key === key) {
283
- setSelf((state) => [...state, transactionUpdate]);
284
- }
285
- });
286
- }
287
- ]
288
- },
289
- store
290
- );
291
- const findTransactionUpdateLogState = createSelectorFamily(
292
- {
293
- key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log`,
294
- get: (key) => ({ get }) => get(transactionUpdateLogAtoms, key)
295
- },
296
- store
297
- );
259
+ const transactionUpdateLogAtoms = createRegularAtomFamily(store, {
260
+ key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log (Internal)`,
261
+ default: () => [],
262
+ effects: (key) => [
263
+ ({ setSelf }) => {
264
+ const tx = store.transactions.get(key);
265
+ tx?.subject.subscribe(`introspection`, (transactionUpdate) => {
266
+ if (transactionUpdate.key === key) {
267
+ setSelf((state) => [...state, transactionUpdate]);
268
+ }
269
+ });
270
+ }
271
+ ]
272
+ });
273
+ const findTransactionUpdateLogState = createSelectorFamily(store, {
274
+ key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log`,
275
+ get: (key) => ({ get }) => get(transactionUpdateLogAtoms, key)
276
+ });
298
277
  return findTransactionUpdateLogState;
299
278
  };
300
279
 
@@ -15,6 +15,7 @@ export const attachAtomIndex = (
15
15
  store: Store = IMPLICIT.STORE,
16
16
  ): ReadonlySelectorToken<AtomTokenIndex> => {
17
17
  const atomTokenIndexState__INTERNAL = createRegularAtom<AtomTokenIndex>(
18
+ store,
18
19
  {
19
20
  key: `👁‍🗨 Atom Token Index (Internal)`,
20
21
  default: () => {
@@ -88,13 +89,9 @@ export const attachAtomIndex = (
88
89
  ],
89
90
  },
90
91
  undefined,
91
- store,
92
- )
93
- return createStandaloneSelector(
94
- {
95
- key: `👁‍🗨 Atom Token Index`,
96
- get: ({ get }) => get(atomTokenIndexState__INTERNAL),
97
- },
98
- store,
99
92
  )
93
+ return createStandaloneSelector(store, {
94
+ key: `👁‍🗨 Atom Token Index`,
95
+ get: ({ get }) => get(atomTokenIndexState__INTERNAL),
96
+ })
100
97
  }
@@ -16,6 +16,8 @@ export const attachSelectorIndex = (
16
16
  ): ReadonlySelectorToken<SelectorTokenIndex> => {
17
17
  const readonlySelectorTokenIndexState__INTERNAL =
18
18
  createRegularAtom<SelectorTokenIndex>(
19
+ store,
20
+
19
21
  {
20
22
  key: `👁‍🗨 Selector Token Index (Internal)`,
21
23
  default: () => {
@@ -98,13 +100,9 @@ export const attachSelectorIndex = (
98
100
  ],
99
101
  },
100
102
  undefined,
101
- store,
102
103
  )
103
- return createStandaloneSelector(
104
- {
105
- key: `👁‍🗨 Selector Token Index`,
106
- get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL),
107
- },
108
- IMPLICIT.STORE,
109
- )
104
+ return createStandaloneSelector(IMPLICIT.STORE, {
105
+ key: `👁‍🗨 Selector Token Index`,
106
+ get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL),
107
+ })
110
108
  }
@@ -13,34 +13,32 @@ export const attachTimelineFamily = (
13
13
  const findTimelineLogState__INTERNAL = createRegularAtomFamily<
14
14
  Timeline<any>,
15
15
  string
16
- >(
17
- {
18
- key: `👁‍🗨 Timeline Update Log (Internal)`,
19
- default: (key) =>
20
- store.timelines.get(key) ?? {
21
- type: `timeline`,
22
- key: ``,
23
- at: 0,
24
- timeTraveling: null,
25
- history: [],
26
- selectorTime: null,
27
- transactionKey: null,
28
- install: () => {},
29
- subject: new Subject(),
30
- subscriptions: new Map(),
31
- },
32
- effects: (key) => [
33
- ({ setSelf }) => {
34
- const tl = store.timelines.get(key)
35
- tl?.subject.subscribe(`introspection`, (_) => {
36
- setSelf({ ...tl })
37
- })
38
- },
39
- ],
40
- },
41
- store,
42
- )
16
+ >(store, {
17
+ key: `👁‍🗨 Timeline Update Log (Internal)`,
18
+ default: (key) =>
19
+ store.timelines.get(key) ?? {
20
+ type: `timeline`,
21
+ key: ``,
22
+ at: 0,
23
+ timeTraveling: null,
24
+ history: [],
25
+ selectorTime: null,
26
+ transactionKey: null,
27
+ install: () => {},
28
+ subject: new Subject(),
29
+ subscriptions: new Map(),
30
+ },
31
+ effects: (key) => [
32
+ ({ setSelf }) => {
33
+ const tl = store.timelines.get(key)
34
+ tl?.subject.subscribe(`introspection`, (_) => {
35
+ setSelf({ ...tl })
36
+ })
37
+ },
38
+ ],
39
+ })
43
40
  const findTimelineLogState = createSelectorFamily<Timeline<any>, string>(
41
+ store,
44
42
  {
45
43
  key: `👁‍🗨 Timeline Update Log`,
46
44
  get:
@@ -48,7 +46,6 @@ export const attachTimelineFamily = (
48
46
  ({ get }) =>
49
47
  get(findTimelineLogState__INTERNAL, key),
50
48
  },
51
- store,
52
49
  )
53
50
  return findTimelineLogState
54
51
  }
@@ -12,6 +12,7 @@ export const attachTimelineIndex = (
12
12
  const timelineTokenIndexState__INTERNAL = createRegularAtom<
13
13
  TimelineToken<any>[]
14
14
  >(
15
+ store,
15
16
  {
16
17
  key: `👁‍🗨 Timeline Token Index (Internal)`,
17
18
  default: () =>
@@ -30,14 +31,10 @@ export const attachTimelineIndex = (
30
31
  ],
31
32
  },
32
33
  undefined,
33
- store,
34
- )
35
- const timelineTokenIndex = createStandaloneSelector(
36
- {
37
- key: `👁‍🗨 Timeline Token Index`,
38
- get: ({ get }) => get(timelineTokenIndexState__INTERNAL),
39
- },
40
- store,
41
34
  )
35
+ const timelineTokenIndex = createStandaloneSelector(store, {
36
+ key: `👁‍🗨 Timeline Token Index`,
37
+ get: ({ get }) => get(timelineTokenIndexState__INTERNAL),
38
+ })
42
39
  return timelineTokenIndex
43
40
  }
@@ -12,6 +12,7 @@ export const attachTransactionIndex = (
12
12
  const transactionTokenIndexState__INTERNAL = createRegularAtom<
13
13
  TransactionToken<Func>[]
14
14
  >(
15
+ store,
15
16
  {
16
17
  key: `👁‍🗨 Transaction Token Index (Internal)`,
17
18
  default: () =>
@@ -30,14 +31,10 @@ export const attachTransactionIndex = (
30
31
  ],
31
32
  },
32
33
  undefined,
33
- store,
34
- )
35
- const transactionTokenIndex = createStandaloneSelector(
36
- {
37
- key: `👁‍🗨 Transaction Token Index`,
38
- get: ({ get }) => get(transactionTokenIndexState__INTERNAL),
39
- },
40
- store,
41
34
  )
35
+ const transactionTokenIndex = createStandaloneSelector(store, {
36
+ key: `👁‍🗨 Transaction Token Index`,
37
+ get: ({ get }) => get(transactionTokenIndexState__INTERNAL),
38
+ })
42
39
  return transactionTokenIndex
43
40
  }