atom.io 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/data/dist/index.cjs +139 -66
  2. package/data/dist/index.d.ts +6 -0
  3. package/data/dist/index.js +3 -3
  4. package/data/src/join.ts +135 -56
  5. package/data/src/struct-family.ts +2 -2
  6. package/dist/{chunk-RT43TVKP.js → chunk-GVHKIJ3G.js} +1 -1
  7. package/dist/{chunk-KGZGBCYS.js → chunk-JA4V7TJY.js} +135 -62
  8. package/dist/index.cjs +2 -7
  9. package/dist/index.d.ts +29 -14
  10. package/dist/index.js +4 -8
  11. package/ephemeral/dist/index.cjs +11 -0
  12. package/ephemeral/dist/index.js +9 -0
  13. package/ephemeral/package.json +16 -0
  14. package/ephemeral/src/index.ts +1 -0
  15. package/eslint-plugin/dist/index.cjs +156 -1
  16. package/eslint-plugin/dist/index.js +156 -1
  17. package/eslint-plugin/src/rules/index.ts +1 -0
  18. package/eslint-plugin/src/rules/lifespan.ts +204 -0
  19. package/eslint-plugin/src/rules/synchronous-selector-dependencies.ts +1 -65
  20. package/eslint-plugin/src/walk.ts +73 -0
  21. package/immortal/dist/index.cjs +100 -0
  22. package/immortal/dist/index.js +97 -0
  23. package/immortal/package.json +16 -0
  24. package/immortal/src/index.ts +2 -0
  25. package/immortal/src/molecule.ts +134 -0
  26. package/immortal/src/seek-state.ts +60 -0
  27. package/internal/dist/index.cjs +211 -194
  28. package/internal/dist/index.d.ts +30 -14
  29. package/internal/dist/index.js +210 -194
  30. package/internal/src/atom/dispose-atom.ts +4 -1
  31. package/internal/src/families/create-readonly-selector-family.ts +9 -9
  32. package/internal/src/families/create-regular-atom-family.ts +15 -20
  33. package/internal/src/families/create-writable-selector-family.ts +6 -7
  34. package/internal/src/families/find-in-store.ts +11 -5
  35. package/internal/src/families/index.ts +2 -0
  36. package/internal/src/families/init-family-member.ts +91 -0
  37. package/internal/src/families/seek-in-store.ts +106 -0
  38. package/internal/src/future.ts +6 -20
  39. package/internal/src/get-state/get-from-store.ts +2 -3
  40. package/internal/src/mutable/create-mutable-atom-family.ts +17 -23
  41. package/internal/src/mutable/create-mutable-atom.ts +3 -1
  42. package/internal/src/mutable/get-json-family.ts +2 -2
  43. package/internal/src/mutable/get-json-token.ts +27 -12
  44. package/internal/src/mutable/tracker-family.ts +14 -12
  45. package/internal/src/mutable/tracker.ts +2 -24
  46. package/internal/src/not-found-error.ts +11 -3
  47. package/internal/src/operation.ts +0 -1
  48. package/internal/src/selector/create-readonly-selector.ts +2 -2
  49. package/internal/src/selector/create-writable-selector.ts +2 -2
  50. package/internal/src/selector/dispose-selector.ts +40 -23
  51. package/internal/src/selector/register-selector.ts +8 -5
  52. package/internal/src/set-state/set-into-store.ts +2 -2
  53. package/internal/src/store/index.ts +0 -1
  54. package/internal/src/store/store.ts +18 -5
  55. package/internal/src/subscribe/recall-state.ts +3 -3
  56. package/internal/src/subscribe/subscribe-to-state.ts +18 -5
  57. package/internal/src/transaction/build-transaction.ts +7 -2
  58. package/introspection/dist/index.cjs +39 -65
  59. package/introspection/dist/index.js +39 -65
  60. package/introspection/src/attach-atom-index.ts +38 -48
  61. package/introspection/src/attach-introspection-states.ts +0 -1
  62. package/introspection/src/attach-selector-index.ts +45 -50
  63. package/introspection/src/attach-timeline-family.ts +2 -17
  64. package/json/dist/index.cjs +38 -4
  65. package/json/dist/index.js +40 -6
  66. package/json/src/select-json-family.ts +46 -7
  67. package/package.json +31 -11
  68. package/react/dist/index.cjs +1 -1
  69. package/react/dist/index.js +1 -1
  70. package/react/src/use-json.ts +1 -1
  71. package/react-devtools/dist/index.cjs +11 -10
  72. package/react-devtools/dist/index.js +2 -1
  73. package/react-devtools/src/StateIndex.tsx +2 -1
  74. package/react-devtools/src/TimelineIndex.tsx +2 -1
  75. package/react-devtools/src/TransactionIndex.tsx +7 -7
  76. package/realtime-client/dist/index.cjs +3 -3
  77. package/realtime-client/dist/index.js +3 -3
  78. package/realtime-client/src/pull-mutable-atom-family-member.ts +1 -1
  79. package/realtime-client/src/pull-mutable-atom.ts +1 -1
  80. package/realtime-client/src/sync-continuity.ts +1 -2
  81. package/realtime-react/dist/index.cjs +1 -1
  82. package/realtime-react/dist/index.js +1 -1
  83. package/realtime-server/dist/index.cjs +18 -17
  84. package/realtime-server/dist/index.js +7 -6
  85. package/realtime-server/src/realtime-continuity-synchronizer.ts +5 -3
  86. package/realtime-server/src/realtime-mutable-family-provider.ts +2 -1
  87. package/realtime-server/src/realtime-mutable-provider.ts +1 -1
  88. package/realtime-testing/dist/index.cjs +6 -2
  89. package/realtime-testing/dist/index.js +8 -5
  90. package/realtime-testing/src/setup-realtime-test.tsx +5 -2
  91. package/src/atom.ts +10 -4
  92. package/src/index.ts +1 -2
  93. package/src/selector.ts +10 -4
  94. package/src/silo.ts +3 -3
  95. package/src/transaction.ts +5 -2
  96. package/src/validators.ts +0 -6
  97. package/internal/src/store/withdraw-new-family-member.ts +0 -69
  98. /package/{src → ephemeral/src}/find-state.ts +0 -0
  99. /package/src/{dispose.ts → dispose-state.ts} +0 -0
package/data/src/join.ts CHANGED
@@ -2,15 +2,17 @@
2
2
  import type {
3
3
  MutableAtomFamily,
4
4
  MutableAtomFamilyToken,
5
- MutableAtomToken,
6
5
  Read,
6
+ ReadableFamilyToken,
7
7
  ReadonlySelectorFamily,
8
8
  ReadonlySelectorToken,
9
9
  RegularAtomFamily,
10
10
  Transactors,
11
11
  Write,
12
12
  } from "atom.io"
13
- import { disposeState, findState, getState, setState } from "atom.io"
13
+ import { disposeState } from "atom.io"
14
+ import type { findState } from "atom.io/ephemeral"
15
+ import type { Molecule, seekState } from "atom.io/immortal"
14
16
  import type { Store } from "atom.io/internal"
15
17
  import {
16
18
  createMutableAtomFamily,
@@ -20,11 +22,13 @@ import {
20
22
  getFromStore,
21
23
  getJsonFamily,
22
24
  IMPLICIT,
25
+ initFamilyMember,
23
26
  isChildStore,
24
27
  newest,
28
+ seekInStore,
25
29
  setIntoStore,
26
30
  } from "atom.io/internal"
27
- import type { Json } from "atom.io/json"
31
+ import { type Json, stringifyJson } from "atom.io/json"
28
32
  import type { SetRTXJson } from "atom.io/transceivers/set-rtx"
29
33
  import { SetRTX } from "atom.io/transceivers/set-rtx"
30
34
 
@@ -37,12 +41,6 @@ import type {
37
41
  import { Junction } from "~/packages/rel8/junction/src"
38
42
  import type * as Rel8 from "~/packages/rel8/types/src"
39
43
 
40
- const TRANSACTORS: Transactors = {
41
- get: getState,
42
- set: setState,
43
- find: findState,
44
- }
45
-
46
44
  function capitalize<S extends string>(string: S): Capitalize<S> {
47
45
  return (string[0].toUpperCase() + string.slice(1)) as Capitalize<S>
48
46
  }
@@ -135,6 +133,8 @@ export class Join<
135
133
  private options: JoinOptions<ASide, BSide, Cardinality, Content>
136
134
  private defaultContent: Content | undefined
137
135
  private transactors: Transactors
136
+ public retrieve: typeof findState
137
+ public molecules: Map<string, Molecule<any>> = new Map()
138
138
  public relations: Junction<ASide, BSide, Content>
139
139
  public states: JoinStateFamilies<ASide, BSide, Cardinality, Content>
140
140
  public core: {
@@ -154,7 +154,12 @@ export class Join<
154
154
  this.transactors = originalTransactors
155
155
  }
156
156
 
157
+ public store: Store
157
158
  public alternates: Map<string, Join<ASide, BSide, Cardinality, Content>>
159
+ public [Symbol.dispose](): void {
160
+ this.alternates.delete(this.store.config.name)
161
+ }
162
+
158
163
  public in(store: Store): Join<ASide, BSide, Cardinality, Content> {
159
164
  const key = store.config.name
160
165
  const alternate = this.alternates.get(key)
@@ -172,16 +177,38 @@ export class Join<
172
177
  defaultContent: Content | undefined,
173
178
  store: Store = IMPLICIT.STORE,
174
179
  ) {
180
+ this.store = store
175
181
  this.options = options
176
182
  this.defaultContent = defaultContent
177
183
  this.alternates = new Map()
178
184
  this.alternates.set(store.config.name, this)
185
+
186
+ this.store.miscResources.set(`join:${options.key}`, this)
187
+
179
188
  this.transactors = {
180
189
  get: (token) => getFromStore(token, store),
181
190
  set: (token, value) => {
182
191
  setIntoStore(token, value, store)
183
192
  },
184
193
  find: ((token, key) => findInStore(token, key, store)) as typeof findState,
194
+ seek: ((token, key) => seekInStore(token, key, store)) as typeof seekState,
195
+ }
196
+ this.retrieve = (
197
+ token: ReadableFamilyToken<any, any>,
198
+ key: Json.Serializable,
199
+ ) => {
200
+ const maybeToken = this.transactors.seek(token, key)
201
+ if (maybeToken) {
202
+ return maybeToken
203
+ }
204
+ const molecule = this.molecules.get(stringifyJson(key))
205
+ if (!molecule) {
206
+ if (store.config.lifespan === `immortal`) {
207
+ throw new Error(`No molecule found for key "${stringifyJson(key)}"`)
208
+ }
209
+ return initFamilyMember(token, key, store)
210
+ }
211
+ return molecule.bond(token) as any
185
212
  }
186
213
  const aSide: ASide = options.between[0]
187
214
  const bSide: BSide = options.between[1]
@@ -201,17 +228,17 @@ export class Join<
201
228
  )
202
229
  this.core = { findRelatedKeysState: relatedKeysAtoms }
203
230
  const getRelatedKeys: Read<(key: string) => SetRTX<string>> = (
204
- { find, get },
231
+ { get },
205
232
  key,
206
- ) => get(find(relatedKeysAtoms, key))
233
+ ) => get(this.retrieve(relatedKeysAtoms, key))
207
234
  const addRelation: Write<(a: string, b: string) => void> = (
208
235
  transactors,
209
236
  a,
210
237
  b,
211
238
  ) => {
212
- const { set, find } = transactors
213
- const aKeysState = find(relatedKeysAtoms, a)
214
- const bKeysState = find(relatedKeysAtoms, b)
239
+ const { set } = transactors
240
+ const aKeysState = this.retrieve(relatedKeysAtoms, a)
241
+ const bKeysState = this.retrieve(relatedKeysAtoms, b)
215
242
  set(aKeysState, (aKeys) => aKeys.add(b))
216
243
  set(bKeysState, (bKeys) => bKeys.add(a))
217
244
  }
@@ -220,24 +247,50 @@ export class Join<
220
247
  a,
221
248
  b,
222
249
  ) => {
223
- const { find, set } = transactors
224
- const aKeysState = find(relatedKeysAtoms, a)
225
- const bKeysState = find(relatedKeysAtoms, b)
226
- set(aKeysState, (aKeys) => (aKeys.delete(b), aKeys))
227
- set(bKeysState, (bKeys) => (bKeys.delete(a), bKeys))
250
+ const { set } = transactors
251
+ const aKeysState = this.retrieve(relatedKeysAtoms, a)
252
+ const bKeysState = this.retrieve(relatedKeysAtoms, b)
253
+ let stringA: string | undefined
254
+ let stringB: string | undefined
255
+ set(aKeysState, (aKeys) => {
256
+ aKeys.delete(b)
257
+ if (aKeys.size === 0) {
258
+ stringA = `"${a}"`
259
+ }
260
+ return aKeys
261
+ })
262
+ set(bKeysState, (bKeys) => {
263
+ bKeys.delete(a)
264
+ if (bKeys.size === 0) {
265
+ stringB = `"${b}"`
266
+ }
267
+ return bKeys
268
+ })
269
+
270
+ if (stringA && this.molecules.has(stringA)) {
271
+ this.molecules.get(stringA)?.clear()
272
+ this.molecules.delete(stringA)
273
+ }
274
+ if (stringB && this.molecules.has(stringB)) {
275
+ this.molecules.get(stringB)?.clear()
276
+ this.molecules.delete(stringB)
277
+ }
228
278
  }
229
279
  const replaceRelationsSafely: Write<
230
280
  (a: string, newRelationsOfA: string[]) => void
231
281
  > = (transactors, a, newRelationsOfA) => {
232
- const { find, get, set } = transactors
233
- const relationsOfAState = find(relatedKeysAtoms, a)
282
+ const { get, set } = transactors
283
+ const relationsOfAState = this.retrieve(relatedKeysAtoms, a)
234
284
  const currentRelationsOfA = get(relationsOfAState)
235
285
  for (const currentRelationB of currentRelationsOfA) {
236
286
  const remainsRelated = newRelationsOfA.includes(currentRelationB)
237
287
  if (remainsRelated) {
238
288
  continue
239
289
  }
240
- const relationsOfBState = find(relatedKeysAtoms, currentRelationB)
290
+ const relationsOfBState = this.retrieve(
291
+ relatedKeysAtoms,
292
+ currentRelationB,
293
+ )
241
294
  set(relationsOfBState, (relationsOfB) => {
242
295
  relationsOfB.delete(a)
243
296
  return relationsOfB
@@ -250,6 +303,7 @@ export class Join<
250
303
  const relationsOfB = getRelatedKeys(transactors, newRelationB)
251
304
  const newRelationBIsAlreadyRelated = relationsOfB.has(a)
252
305
  if (this.relations.cardinality === `1:n`) {
306
+ const previousOwnersToDispose: string[] = []
253
307
  for (const previousOwner of relationsOfB) {
254
308
  if (previousOwner === a) {
255
309
  continue
@@ -259,10 +313,21 @@ export class Join<
259
313
  previousOwner,
260
314
  )
261
315
  previousOwnerRelations.delete(newRelationB)
316
+ if (previousOwnerRelations.size === 0) {
317
+ previousOwnersToDispose.push(previousOwner)
318
+ }
262
319
  }
263
320
  if (!newRelationBIsAlreadyRelated && relationsOfB.size > 0) {
264
321
  relationsOfB.clear()
265
322
  }
323
+ for (const previousOwner of previousOwnersToDispose) {
324
+ const molecule = this.molecules.get(previousOwner)
325
+ molecule?.clear()
326
+ this.molecules.delete(previousOwner)
327
+ const sorted = [newRelationB, previousOwner].sort()
328
+ const compositeKey = `"${sorted[0]}:${sorted[1]}"`
329
+ this.molecules.delete(compositeKey)
330
+ }
266
331
  }
267
332
  if (!newRelationBIsAlreadyRelated) {
268
333
  relationsOfB.add(a)
@@ -277,8 +342,8 @@ export class Join<
277
342
  const replaceRelationsUnsafely: Write<
278
343
  (a: string, newRelationsOfA: string[]) => void
279
344
  > = (transactors, a, newRelationsOfA) => {
280
- const { find, set } = transactors
281
- const relationsOfAState = find(relatedKeysAtoms, a)
345
+ const { set } = transactors
346
+ const relationsOfAState = this.retrieve(relatedKeysAtoms, a)
282
347
  set(relationsOfAState, (relationsOfA) => {
283
348
  relationsOfA.transaction((nextRelationsOfA) => {
284
349
  for (const newRelationB of newRelationsOfA) {
@@ -289,7 +354,7 @@ export class Join<
289
354
  return relationsOfA
290
355
  })
291
356
  for (const newRelationB of newRelationsOfA) {
292
- const newRelationsBState = find(relatedKeysAtoms, newRelationB)
357
+ const newRelationsBState = this.retrieve(relatedKeysAtoms, newRelationB)
293
358
  set(newRelationsBState, (newRelationsB) => {
294
359
  newRelationsB.add(a)
295
360
  return newRelationsB
@@ -331,19 +396,21 @@ export class Join<
331
396
  },
332
397
  store,
333
398
  )
334
- const getContent: Read<(key: string) => Content | null> = (
335
- { find, get },
336
- key,
337
- ) => get(find(contentAtoms, key))
399
+ const getContent: Read<(key: string) => Content | null> = ({ get }, key) =>
400
+ get(this.retrieve(contentAtoms, key))
338
401
  const setContent: Write<(key: string, content: Content) => void> = (
339
- { find, set },
402
+ { set },
340
403
  key,
341
404
  content,
342
405
  ) => {
343
- set(find(contentAtoms, key), content)
406
+ set(this.retrieve(contentAtoms, key), content)
344
407
  }
345
- const deleteContent: Write<(key: string) => void> = ({ find }, key) => {
346
- disposeState(find(contentAtoms, key))
408
+ const deleteContent: Write<(compositeKey: string) => void> = (
409
+ _,
410
+ compositeKey,
411
+ ) => {
412
+ disposeState(this.retrieve(contentAtoms, compositeKey))
413
+ this.molecules.delete(`"${compositeKey}"`)
347
414
  }
348
415
  const externalStoreWithContentConfiguration = {
349
416
  getContent: (contentKey: string) => {
@@ -367,7 +434,18 @@ export class Join<
367
434
  }
368
435
  const relations = new Junction<ASide, BSide, Content>(options, {
369
436
  externalStore,
370
- makeContentKey: (...args) => args.sort().join(`:`),
437
+ makeContentKey: (...args) => {
438
+ const sorted = args.sort()
439
+ const compositeKey = `${sorted[0]}:${sorted[1]}`
440
+ const [m0, m1] = sorted.map((key) =>
441
+ this.molecules.get(stringifyJson(key)),
442
+ )
443
+ if (store.config.lifespan === `immortal` && m0 && m1) {
444
+ const composite = m0.with(m1)(compositeKey)
445
+ this.molecules.set(`"${compositeKey}"`, composite)
446
+ }
447
+ return compositeKey
448
+ },
371
449
  })
372
450
 
373
451
  const createSingleKeyStateFamily = () =>
@@ -376,8 +454,8 @@ export class Join<
376
454
  key: `${options.key}/singleRelatedKey`,
377
455
  get:
378
456
  (key) =>
379
- ({ find, get }) => {
380
- const relatedKeysState = find(relatedKeysAtoms, key)
457
+ ({ get }) => {
458
+ const relatedKeysState = this.retrieve(relatedKeysAtoms, key)
381
459
  const relatedKeys = get(relatedKeysState)
382
460
  for (const relatedKey of relatedKeys) {
383
461
  return relatedKey
@@ -393,9 +471,9 @@ export class Join<
393
471
  key: `${options.key}/multipleRelatedKeys`,
394
472
  get:
395
473
  (key) =>
396
- ({ find, get }) => {
474
+ ({ get }) => {
397
475
  const jsonFamily = getJsonFamily(relatedKeysAtoms, store)
398
- const jsonState = find(jsonFamily, key)
476
+ const jsonState = this.retrieve(jsonFamily, key)
399
477
  const json = get(jsonState)
400
478
  return json.members
401
479
  },
@@ -409,12 +487,12 @@ export class Join<
409
487
  key: `${options.key}/singleRelatedEntry`,
410
488
  get:
411
489
  (key) =>
412
- ({ find, get }) => {
413
- const relatedKeysState = find(relatedKeysAtoms, key)
490
+ ({ get }) => {
491
+ const relatedKeysState = this.retrieve(relatedKeysAtoms, key)
414
492
  const relatedKeys = get(relatedKeysState)
415
493
  for (const relatedKey of relatedKeys) {
416
494
  const contentKey = relations.makeContentKey(key, relatedKey)
417
- const contentState = find(contentAtoms, contentKey)
495
+ const contentState = this.retrieve(contentAtoms, contentKey)
418
496
  const content = get(contentState)
419
497
  return [relatedKey, content]
420
498
  }
@@ -429,12 +507,13 @@ export class Join<
429
507
  key: `${options.key}/multipleRelatedEntries`,
430
508
  get:
431
509
  (key) =>
432
- ({ find, get }) => {
510
+ ({ get }) => {
433
511
  const jsonFamily = getJsonFamily(relatedKeysAtoms, store)
434
- const json = get(jsonFamily(key))
512
+ const jsonState = this.retrieve(jsonFamily, key)
513
+ const json = get(jsonState)
435
514
  return json.members.map((relatedKey) => {
436
515
  const contentKey = relations.makeContentKey(key, relatedKey)
437
- const contentState = find(contentAtoms, contentKey)
516
+ const contentState = this.retrieve(contentAtoms, contentKey)
438
517
  const content = get(contentState)
439
518
  return [relatedKey, content]
440
519
  })
@@ -693,12 +772,12 @@ export function findRelationsInStore<
693
772
  relations = {
694
773
  get [keyAB]() {
695
774
  const familyAB = myJoin.states[keyAB as any]
696
- const state = findInStore(familyAB, key, store)
775
+ const state = myJoin.retrieve(familyAB, key)
697
776
  return state
698
777
  },
699
778
  get [keyBA]() {
700
779
  const familyBA = myJoin.states[keyBA as any]
701
- const state = findInStore(familyBA, key, store)
780
+ const state = myJoin.retrieve(familyBA, key)
702
781
  return state
703
782
  },
704
783
  } as JoinStates<ASide, BSide, Cardinality, Content>
@@ -708,12 +787,12 @@ export function findRelationsInStore<
708
787
  Object.assign(relations, {
709
788
  get [entryAB]() {
710
789
  const familyAB = myJoin.states[entryAB as any]
711
- const state = findInStore(familyAB, key, store)
790
+ const state = myJoin.retrieve(familyAB, key)
712
791
  return state
713
792
  },
714
793
  get [entryBA]() {
715
794
  const familyBA = myJoin.states[entryBA as any]
716
- const state = findInStore(familyBA, key, store)
795
+ const state = myJoin.retrieve(familyBA, key)
717
796
  return state
718
797
  },
719
798
  })
@@ -726,12 +805,12 @@ export function findRelationsInStore<
726
805
  relations = {
727
806
  get [keyAB]() {
728
807
  const familyAB = myJoin.states[keyAB as any]
729
- const state = findInStore(familyAB, key, store)
808
+ const state = myJoin.retrieve(familyAB, key)
730
809
  return state
731
810
  },
732
811
  get [keysBA]() {
733
812
  const familyBA = myJoin.states[keysBA as any]
734
- const state = findInStore(familyBA, key, store)
813
+ const state = myJoin.retrieve(familyBA, key)
735
814
  return state
736
815
  },
737
816
  } as JoinStates<ASide, BSide, Cardinality, Content>
@@ -741,12 +820,12 @@ export function findRelationsInStore<
741
820
  Object.assign(relations, {
742
821
  get [entryAB]() {
743
822
  const familyAB = myJoin.states[entryAB as any]
744
- const state = findInStore(familyAB, key, store)
823
+ const state = myJoin.retrieve(familyAB, key)
745
824
  return state
746
825
  },
747
826
  get [entriesBA]() {
748
827
  const familyBA = myJoin.states[entriesBA as any]
749
- const state = findInStore(familyBA, key, store)
828
+ const state = myJoin.retrieve(familyBA, key)
750
829
  return state
751
830
  },
752
831
  })
@@ -759,12 +838,12 @@ export function findRelationsInStore<
759
838
  relations = {
760
839
  get [keysAB]() {
761
840
  const familyAB = myJoin.states[keysAB as any]
762
- const state = findInStore(familyAB, key, store)
841
+ const state = myJoin.retrieve(familyAB, key)
763
842
  return state
764
843
  },
765
844
  get [keysBA]() {
766
845
  const familyBA = myJoin.states[keysBA as any]
767
- const state = findInStore(familyBA, key, store)
846
+ const state = myJoin.retrieve(familyBA, key)
768
847
  return state
769
848
  },
770
849
  } as JoinStates<ASide, BSide, Cardinality, Content>
@@ -774,12 +853,12 @@ export function findRelationsInStore<
774
853
  Object.assign(relations, {
775
854
  get [entriesAB]() {
776
855
  const familyAB = myJoin.states[entriesAB as any]
777
- const state = findInStore(familyAB, key, store)
856
+ const state = myJoin.retrieve(familyAB, key)
778
857
  return state
779
858
  },
780
859
  get [entriesBA]() {
781
860
  const familyBA = myJoin.states[entriesBA as any]
782
- const state = findInStore(familyBA, key, store)
861
+ const state = myJoin.retrieve(familyBA, key)
783
862
  return state
784
863
  },
785
864
  })
@@ -44,10 +44,10 @@ export function structFamily<
44
44
  key: options.key,
45
45
  get:
46
46
  (id) =>
47
- ({ get }) => {
47
+ ({ find, get }) => {
48
48
  return Object.keys(options.default).reduce((acc, subKey) => {
49
49
  acc[subKey] = get(
50
- (atoms as any)[nameFamily(options.key, subKey)](id),
50
+ find((atoms as any)[nameFamily(options.key, subKey)], id),
51
51
  )
52
52
  return acc
53
53
  }, {} as any)
@@ -17,7 +17,7 @@ function syncContinuity(continuity, socket, store) {
17
17
  } else {
18
18
  v = x;
19
19
  if (`type` in k && k.type === `mutable_atom`) {
20
- k = getJsonToken(k);
20
+ k = getJsonToken(k, store);
21
21
  }
22
22
  setIntoStore(k, v, store);
23
23
  }