atom.io 0.21.1 → 0.23.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 (116) hide show
  1. package/data/dist/index.cjs +152 -63
  2. package/data/dist/index.d.ts +6 -0
  3. package/data/dist/index.js +3 -3
  4. package/data/src/join.ts +164 -51
  5. package/data/src/struct-family.ts +2 -2
  6. package/dist/chunk-6MLFYN32.js +18 -0
  7. package/dist/{chunk-HITX3MO4.js → chunk-7DT3PVS3.js} +151 -62
  8. package/dist/{chunk-RT43TVKP.js → chunk-GVHKIJ3G.js} +1 -1
  9. package/dist/chunk-OAYGID5B.js +27 -0
  10. package/dist/index.cjs +4 -18
  11. package/dist/index.d.ts +71 -28
  12. package/dist/index.js +6 -19
  13. package/ephemeral/dist/index.cjs +11 -0
  14. package/ephemeral/dist/index.js +9 -0
  15. package/ephemeral/package.json +16 -0
  16. package/ephemeral/src/index.ts +1 -0
  17. package/eslint-plugin/dist/index.cjs +155 -1
  18. package/eslint-plugin/dist/index.js +155 -1
  19. package/eslint-plugin/src/rules/index.ts +1 -0
  20. package/eslint-plugin/src/rules/lifespan.ts +203 -0
  21. package/eslint-plugin/src/rules/synchronous-selector-dependencies.ts +1 -65
  22. package/eslint-plugin/src/walk.ts +73 -0
  23. package/immortal/dist/index.cjs +260 -0
  24. package/immortal/dist/index.js +212 -0
  25. package/immortal/package.json +16 -0
  26. package/immortal/src/index.ts +3 -0
  27. package/immortal/src/make-molecule.ts +222 -0
  28. package/immortal/src/molecule.ts +167 -0
  29. package/immortal/src/seek-state.ts +73 -0
  30. package/internal/dist/index.cjs +1242 -837
  31. package/internal/dist/index.d.ts +135 -22
  32. package/internal/dist/index.js +1215 -838
  33. package/internal/src/atom/create-regular-atom.ts +0 -2
  34. package/internal/src/atom/create-standalone-atom.ts +6 -2
  35. package/internal/src/atom/dispose-atom.ts +26 -3
  36. package/internal/src/families/create-readonly-selector-family.ts +15 -10
  37. package/internal/src/families/create-regular-atom-family.ts +20 -21
  38. package/internal/src/families/create-writable-selector-family.ts +13 -9
  39. package/{src/dispose.ts → internal/src/families/dispose-from-store.ts} +7 -4
  40. package/internal/src/families/find-in-store.ts +11 -6
  41. package/internal/src/families/index.ts +3 -0
  42. package/internal/src/families/init-family-member.ts +112 -0
  43. package/internal/src/families/seek-in-store.ts +123 -0
  44. package/internal/src/get-state/get-from-store.ts +2 -2
  45. package/internal/src/ingest-updates/index.ts +1 -0
  46. package/internal/src/ingest-updates/ingest-creation-disposal.ts +104 -0
  47. package/internal/src/ingest-updates/ingest-transaction-update.ts +26 -4
  48. package/internal/src/mutable/create-mutable-atom-family.ts +22 -24
  49. package/internal/src/mutable/create-mutable-atom.ts +3 -3
  50. package/internal/src/mutable/get-json-family.ts +2 -2
  51. package/internal/src/mutable/get-json-token.ts +26 -12
  52. package/internal/src/mutable/tracker-family.ts +21 -19
  53. package/internal/src/not-found-error.ts +16 -3
  54. package/internal/src/selector/create-readonly-selector.ts +2 -3
  55. package/internal/src/selector/create-standalone-selector.ts +6 -2
  56. package/internal/src/selector/create-writable-selector.ts +2 -3
  57. package/internal/src/selector/dispose-selector.ts +68 -24
  58. package/internal/src/selector/register-selector.ts +10 -5
  59. package/internal/src/set-state/set-into-store.ts +2 -2
  60. package/internal/src/set-state/stow-update.ts +5 -1
  61. package/internal/src/store/deposit.ts +41 -7
  62. package/internal/src/store/index.ts +0 -1
  63. package/internal/src/store/store.ts +29 -5
  64. package/internal/src/store/withdraw.ts +28 -1
  65. package/internal/src/subscribe/subscribe-to-state.ts +2 -2
  66. package/internal/src/timeline/add-atom-to-timeline.ts +206 -182
  67. package/internal/src/timeline/create-timeline.ts +181 -60
  68. package/internal/src/timeline/time-travel.ts +20 -0
  69. package/internal/src/transaction/apply-transaction.ts +2 -12
  70. package/internal/src/transaction/build-transaction.ts +16 -2
  71. package/introspection/dist/index.cjs +40 -53
  72. package/introspection/dist/index.js +40 -53
  73. package/introspection/src/attach-atom-index.ts +38 -48
  74. package/introspection/src/attach-selector-index.ts +45 -50
  75. package/introspection/src/attach-timeline-family.ts +1 -0
  76. package/json/dist/index.cjs +40 -6
  77. package/json/dist/index.js +44 -9
  78. package/json/src/select-json-family.ts +47 -9
  79. package/package.json +30 -10
  80. package/react/dist/index.cjs +1 -1
  81. package/react/dist/index.js +1 -1
  82. package/react/src/use-json.ts +1 -1
  83. package/react-devtools/dist/index.cjs +69 -57
  84. package/react-devtools/dist/index.js +62 -49
  85. package/react-devtools/src/StateIndex.tsx +2 -1
  86. package/react-devtools/src/TimelineIndex.tsx +17 -14
  87. package/react-devtools/src/TransactionIndex.tsx +7 -7
  88. package/react-devtools/src/Updates.tsx +41 -32
  89. package/realtime-client/dist/index.cjs +3 -3
  90. package/realtime-client/dist/index.js +3 -3
  91. package/realtime-client/src/pull-mutable-atom-family-member.ts +1 -1
  92. package/realtime-client/src/pull-mutable-atom.ts +1 -1
  93. package/realtime-client/src/sync-continuity.ts +1 -2
  94. package/realtime-react/dist/index.cjs +1 -1
  95. package/realtime-react/dist/index.js +1 -1
  96. package/realtime-server/dist/index.cjs +39 -27
  97. package/realtime-server/dist/index.d.ts +1 -1
  98. package/realtime-server/dist/index.js +27 -16
  99. package/realtime-server/src/realtime-continuity-synchronizer.ts +5 -3
  100. package/realtime-server/src/realtime-mutable-family-provider.ts +2 -1
  101. package/realtime-server/src/realtime-mutable-provider.ts +1 -1
  102. package/realtime-server/src/realtime-server-stores/server-sync-store.ts +21 -11
  103. package/realtime-testing/dist/index.cjs +7 -2
  104. package/realtime-testing/dist/index.js +8 -5
  105. package/realtime-testing/src/setup-realtime-test.tsx +5 -2
  106. package/src/atom.ts +19 -7
  107. package/src/dispose-state.ts +10 -0
  108. package/src/index.ts +5 -2
  109. package/src/selector.ts +13 -7
  110. package/src/silo.ts +3 -3
  111. package/src/subscribe.ts +8 -4
  112. package/src/timeline.ts +18 -1
  113. package/src/transaction.ts +59 -4
  114. package/dist/chunk-BF4MVQF6.js +0 -44
  115. package/internal/src/store/withdraw-new-family-member.ts +0 -69
  116. /package/{src → ephemeral/src}/find-state.ts +0 -0
@@ -1,40 +1,44 @@
1
1
  import { Junction } from './chunk-FTONNX2R.js';
2
2
  import { disposeState } from 'atom.io';
3
- import { getFromStore, setIntoStore, findInStore, createMutableAtomFamily, createRegularAtomFamily, IMPLICIT, newest, isChildStore, createSelectorFamily, getJsonFamily } from 'atom.io/internal';
3
+ import { createMoleculeFamily, Molecule, makeMoleculeInStore } from 'atom.io/immortal';
4
+ import { getFromStore, setIntoStore, findInStore, seekInStore, getJsonToken, initFamilyMember, createMutableAtomFamily, createRegularAtomFamily, newest, IMPLICIT, isChildStore, createSelectorFamily, getJsonFamily } from 'atom.io/internal';
5
+ import { stringifyJson } from 'atom.io/json';
4
6
  import { SetRTX } from 'atom.io/transceivers/set-rtx';
5
7
 
6
8
  function capitalize(string) {
7
9
  return string[0].toUpperCase() + string.slice(1);
8
10
  }
9
11
  var Join = class _Join {
10
- transact(transactors, run) {
11
- const originalTransactors = this.transactors;
12
- this.transactors = transactors;
13
- run(this);
14
- this.transactors = originalTransactors;
15
- }
16
- in(store) {
17
- const key = store.config.name;
18
- const alternate = this.alternates.get(key);
19
- if (alternate) {
20
- return alternate;
21
- }
22
- const join2 = new _Join(this.options, this.defaultContent, store);
23
- this.alternates.set(key, join2);
24
- join2.alternates = this.alternates;
25
- return join2;
26
- }
27
12
  constructor(options, defaultContent, store = IMPLICIT.STORE) {
13
+ this.molecules = /* @__PURE__ */ new Map();
14
+ this.store = store;
28
15
  this.options = options;
29
16
  this.defaultContent = defaultContent;
30
17
  this.alternates = /* @__PURE__ */ new Map();
31
18
  this.alternates.set(store.config.name, this);
19
+ this.store.miscResources.set(`join:${options.key}`, this);
32
20
  this.transactors = {
33
21
  get: (token) => getFromStore(token, store),
34
22
  set: (token, value) => {
35
23
  setIntoStore(token, value, store);
36
24
  },
37
- find: (token, key) => findInStore(token, key, store)
25
+ find: (token, key) => findInStore(token, key, store),
26
+ seek: (token, key) => seekInStore(token, key, store),
27
+ json: (token) => getJsonToken(token, store)
28
+ };
29
+ this.retrieve = (token, key) => {
30
+ const maybeToken = this.transactors.seek(token, key);
31
+ if (maybeToken) {
32
+ return maybeToken;
33
+ }
34
+ const molecule = this.molecules.get(stringifyJson(key));
35
+ if (!molecule) {
36
+ if (store.config.lifespan === `immortal`) {
37
+ throw new Error(`No molecule found for key "${stringifyJson(key)}"`);
38
+ }
39
+ return initFamilyMember(token, key, store);
40
+ }
41
+ return molecule.bond(token);
38
42
  };
39
43
  const aSide = options.between[0];
40
44
  const bSide = options.between[1];
@@ -49,31 +53,57 @@ var Join = class _Join {
49
53
  store
50
54
  );
51
55
  this.core = { findRelatedKeysState: relatedKeysAtoms };
52
- const getRelatedKeys = ({ find, get }, key) => get(find(relatedKeysAtoms, key));
56
+ const getRelatedKeys = ({ get }, key) => get(this.retrieve(relatedKeysAtoms, key));
53
57
  const addRelation = (transactors, a, b) => {
54
- const { set, find } = transactors;
55
- const aKeysState = find(relatedKeysAtoms, a);
56
- const bKeysState = find(relatedKeysAtoms, b);
58
+ const { set } = transactors;
59
+ const aKeysState = this.retrieve(relatedKeysAtoms, a);
60
+ const bKeysState = this.retrieve(relatedKeysAtoms, b);
57
61
  set(aKeysState, (aKeys) => aKeys.add(b));
58
62
  set(bKeysState, (bKeys) => bKeys.add(a));
59
63
  };
60
64
  const deleteRelation = (transactors, a, b) => {
61
- const { find, set } = transactors;
62
- const aKeysState = find(relatedKeysAtoms, a);
63
- const bKeysState = find(relatedKeysAtoms, b);
64
- set(aKeysState, (aKeys) => (aKeys.delete(b), aKeys));
65
- set(bKeysState, (bKeys) => (bKeys.delete(a), bKeys));
65
+ var _a, _b;
66
+ const { set } = transactors;
67
+ const aKeysState = this.retrieve(relatedKeysAtoms, a);
68
+ const bKeysState = this.retrieve(relatedKeysAtoms, b);
69
+ let stringA;
70
+ let stringB;
71
+ set(aKeysState, (aKeys) => {
72
+ aKeys.delete(b);
73
+ if (aKeys.size === 0) {
74
+ stringA = `"${a}"`;
75
+ }
76
+ return aKeys;
77
+ });
78
+ set(bKeysState, (bKeys) => {
79
+ bKeys.delete(a);
80
+ if (bKeys.size === 0) {
81
+ stringB = `"${b}"`;
82
+ }
83
+ return bKeys;
84
+ });
85
+ if (stringA && this.molecules.has(stringA)) {
86
+ (_a = this.molecules.get(stringA)) == null ? void 0 : _a.clear();
87
+ this.molecules.delete(stringA);
88
+ }
89
+ if (stringB && this.molecules.has(stringB)) {
90
+ (_b = this.molecules.get(stringB)) == null ? void 0 : _b.clear();
91
+ this.molecules.delete(stringB);
92
+ }
66
93
  };
67
94
  const replaceRelationsSafely = (transactors, a, newRelationsOfA) => {
68
- const { find, get, set } = transactors;
69
- const relationsOfAState = find(relatedKeysAtoms, a);
95
+ const { get, set } = transactors;
96
+ const relationsOfAState = this.retrieve(relatedKeysAtoms, a);
70
97
  const currentRelationsOfA = get(relationsOfAState);
71
98
  for (const currentRelationB of currentRelationsOfA) {
72
99
  const remainsRelated = newRelationsOfA.includes(currentRelationB);
73
100
  if (remainsRelated) {
74
101
  continue;
75
102
  }
76
- const relationsOfBState = find(relatedKeysAtoms, currentRelationB);
103
+ const relationsOfBState = this.retrieve(
104
+ relatedKeysAtoms,
105
+ currentRelationB
106
+ );
77
107
  set(relationsOfBState, (relationsOfB) => {
78
108
  relationsOfB.delete(a);
79
109
  return relationsOfB;
@@ -86,6 +116,7 @@ var Join = class _Join {
86
116
  const relationsOfB = getRelatedKeys(transactors, newRelationB);
87
117
  const newRelationBIsAlreadyRelated = relationsOfB.has(a);
88
118
  if (this.relations.cardinality === `1:n`) {
119
+ const previousOwnersToDispose = [];
89
120
  for (const previousOwner of relationsOfB) {
90
121
  if (previousOwner === a) {
91
122
  continue;
@@ -95,10 +126,21 @@ var Join = class _Join {
95
126
  previousOwner
96
127
  );
97
128
  previousOwnerRelations.delete(newRelationB);
129
+ if (previousOwnerRelations.size === 0) {
130
+ previousOwnersToDispose.push(previousOwner);
131
+ }
98
132
  }
99
133
  if (!newRelationBIsAlreadyRelated && relationsOfB.size > 0) {
100
134
  relationsOfB.clear();
101
135
  }
136
+ for (const previousOwner of previousOwnersToDispose) {
137
+ const molecule = this.molecules.get(previousOwner);
138
+ molecule == null ? void 0 : molecule.clear();
139
+ this.molecules.delete(previousOwner);
140
+ const sorted = [newRelationB, previousOwner].sort();
141
+ const compositeKey = `"${sorted[0]}:${sorted[1]}"`;
142
+ this.molecules.delete(compositeKey);
143
+ }
102
144
  }
103
145
  if (!newRelationBIsAlreadyRelated) {
104
146
  relationsOfB.add(a);
@@ -111,8 +153,8 @@ var Join = class _Join {
111
153
  });
112
154
  };
113
155
  const replaceRelationsUnsafely = (transactors, a, newRelationsOfA) => {
114
- const { find, set } = transactors;
115
- const relationsOfAState = find(relatedKeysAtoms, a);
156
+ const { set } = transactors;
157
+ const relationsOfAState = this.retrieve(relatedKeysAtoms, a);
116
158
  set(relationsOfAState, (relationsOfA) => {
117
159
  relationsOfA.transaction((nextRelationsOfA) => {
118
160
  for (const newRelationB of newRelationsOfA) {
@@ -123,7 +165,7 @@ var Join = class _Join {
123
165
  return relationsOfA;
124
166
  });
125
167
  for (const newRelationB of newRelationsOfA) {
126
- const newRelationsBState = find(relatedKeysAtoms, newRelationB);
168
+ const newRelationsBState = this.retrieve(relatedKeysAtoms, newRelationB);
127
169
  set(newRelationsBState, (newRelationsB) => {
128
170
  newRelationsB.add(a);
129
171
  return newRelationsB;
@@ -153,6 +195,7 @@ var Join = class _Join {
153
195
  };
154
196
  let externalStore;
155
197
  let contentAtoms;
198
+ let contentMolecules;
156
199
  if (defaultContent) {
157
200
  contentAtoms = createRegularAtomFamily(
158
201
  {
@@ -161,12 +204,24 @@ var Join = class _Join {
161
204
  },
162
205
  store
163
206
  );
164
- const getContent = ({ find, get }, key) => get(find(contentAtoms, key));
165
- const setContent = ({ find, set }, key, content) => {
166
- set(find(contentAtoms, key), content);
207
+ contentMolecules = createMoleculeFamily(
208
+ {
209
+ key: `${options.key}/content-molecules`,
210
+ new: (s) => class ContentMolecule extends Molecule {
211
+ constructor(context, token) {
212
+ super(s, context, token);
213
+ }
214
+ }
215
+ },
216
+ store
217
+ );
218
+ const getContent = ({ get }, key) => get(this.retrieve(contentAtoms, key));
219
+ const setContent = ({ set }, key, content) => {
220
+ set(this.retrieve(contentAtoms, key), content);
167
221
  };
168
- const deleteContent = ({ find }, key) => {
169
- disposeState(find(contentAtoms, key));
222
+ const deleteContent = (_, compositeKey) => {
223
+ disposeState(this.retrieve(contentAtoms, compositeKey));
224
+ this.molecules.delete(`"${compositeKey}"`);
170
225
  };
171
226
  const externalStoreWithContentConfiguration = {
172
227
  getContent: (contentKey) => {
@@ -189,13 +244,26 @@ var Join = class _Join {
189
244
  }
190
245
  const relations = new Junction(options, {
191
246
  externalStore,
192
- makeContentKey: (...args) => args.sort().join(`:`)
247
+ makeContentKey: (...args) => {
248
+ const sorted = args.sort();
249
+ const compositeKey = `${sorted[0]}:${sorted[1]}`;
250
+ const [m0, m1] = sorted.map(
251
+ (key) => this.molecules.get(stringifyJson(key))
252
+ );
253
+ if (store.config.lifespan === `immortal` && m0 && m1) {
254
+ const composite = m0.with(m1)(compositeKey);
255
+ this.molecules.set(`"${compositeKey}"`, composite);
256
+ const target = newest(store);
257
+ makeMoleculeInStore(target, [m0, m1], contentMolecules, compositeKey);
258
+ }
259
+ return compositeKey;
260
+ }
193
261
  });
194
262
  const createSingleKeyStateFamily = () => createSelectorFamily(
195
263
  {
196
264
  key: `${options.key}/singleRelatedKey`,
197
- get: (key) => ({ find, get }) => {
198
- const relatedKeysState = find(relatedKeysAtoms, key);
265
+ get: (key) => ({ get }) => {
266
+ const relatedKeysState = this.retrieve(relatedKeysAtoms, key);
199
267
  const relatedKeys = get(relatedKeysState);
200
268
  for (const relatedKey of relatedKeys) {
201
269
  return relatedKey;
@@ -209,9 +277,9 @@ var Join = class _Join {
209
277
  return createSelectorFamily(
210
278
  {
211
279
  key: `${options.key}/multipleRelatedKeys`,
212
- get: (key) => ({ find, get }) => {
280
+ get: (key) => ({ get }) => {
213
281
  const jsonFamily = getJsonFamily(relatedKeysAtoms, store);
214
- const jsonState = find(jsonFamily, key);
282
+ const jsonState = this.retrieve(jsonFamily, key);
215
283
  const json = get(jsonState);
216
284
  return json.members;
217
285
  }
@@ -222,12 +290,12 @@ var Join = class _Join {
222
290
  const createSingleEntryStateFamily = () => createSelectorFamily(
223
291
  {
224
292
  key: `${options.key}/singleRelatedEntry`,
225
- get: (key) => ({ find, get }) => {
226
- const relatedKeysState = find(relatedKeysAtoms, key);
293
+ get: (key) => ({ get }) => {
294
+ const relatedKeysState = this.retrieve(relatedKeysAtoms, key);
227
295
  const relatedKeys = get(relatedKeysState);
228
296
  for (const relatedKey of relatedKeys) {
229
297
  const contentKey = relations.makeContentKey(key, relatedKey);
230
- const contentState = find(contentAtoms, contentKey);
298
+ const contentState = this.retrieve(contentAtoms, contentKey);
231
299
  const content = get(contentState);
232
300
  return [relatedKey, content];
233
301
  }
@@ -239,12 +307,13 @@ var Join = class _Join {
239
307
  const getMultipleEntryStateFamily = () => createSelectorFamily(
240
308
  {
241
309
  key: `${options.key}/multipleRelatedEntries`,
242
- get: (key) => ({ find, get }) => {
310
+ get: (key) => ({ get }) => {
243
311
  const jsonFamily = getJsonFamily(relatedKeysAtoms, store);
244
- const json = get(jsonFamily(key));
312
+ const jsonState = this.retrieve(jsonFamily, key);
313
+ const json = get(jsonState);
245
314
  return json.members.map((relatedKey) => {
246
315
  const contentKey = relations.makeContentKey(key, relatedKey);
247
- const contentState = find(contentAtoms, contentKey);
316
+ const contentState = this.retrieve(contentAtoms, contentKey);
248
317
  const content = get(contentState);
249
318
  return [relatedKey, content];
250
319
  });
@@ -337,6 +406,26 @@ var Join = class _Join {
337
406
  }
338
407
  }
339
408
  }
409
+ transact(transactors, run) {
410
+ const originalTransactors = this.transactors;
411
+ this.transactors = transactors;
412
+ run(this);
413
+ this.transactors = originalTransactors;
414
+ }
415
+ [Symbol.dispose]() {
416
+ this.alternates.delete(this.store.config.name);
417
+ }
418
+ in(store) {
419
+ const key = store.config.name;
420
+ const alternate = this.alternates.get(key);
421
+ if (alternate) {
422
+ return alternate;
423
+ }
424
+ const join2 = new _Join(this.options, this.defaultContent, store);
425
+ this.alternates.set(key, join2);
426
+ join2.alternates = this.alternates;
427
+ return join2;
428
+ }
340
429
  };
341
430
  function join(options, defaultContent, store = IMPLICIT.STORE) {
342
431
  const joins = getJoinMap(store);
@@ -384,12 +473,12 @@ function findRelationsInStore(token, key, store) {
384
473
  relations = {
385
474
  get [keyAB]() {
386
475
  const familyAB = myJoin.states[keyAB];
387
- const state = findInStore(familyAB, key, store);
476
+ const state = myJoin.retrieve(familyAB, key);
388
477
  return state;
389
478
  },
390
479
  get [keyBA]() {
391
480
  const familyBA = myJoin.states[keyBA];
392
- const state = findInStore(familyBA, key, store);
481
+ const state = myJoin.retrieve(familyBA, key);
393
482
  return state;
394
483
  }
395
484
  };
@@ -399,12 +488,12 @@ function findRelationsInStore(token, key, store) {
399
488
  Object.assign(relations, {
400
489
  get [entryAB]() {
401
490
  const familyAB = myJoin.states[entryAB];
402
- const state = findInStore(familyAB, key, store);
491
+ const state = myJoin.retrieve(familyAB, key);
403
492
  return state;
404
493
  },
405
494
  get [entryBA]() {
406
495
  const familyBA = myJoin.states[entryBA];
407
- const state = findInStore(familyBA, key, store);
496
+ const state = myJoin.retrieve(familyBA, key);
408
497
  return state;
409
498
  }
410
499
  });
@@ -417,12 +506,12 @@ function findRelationsInStore(token, key, store) {
417
506
  relations = {
418
507
  get [keyAB]() {
419
508
  const familyAB = myJoin.states[keyAB];
420
- const state = findInStore(familyAB, key, store);
509
+ const state = myJoin.retrieve(familyAB, key);
421
510
  return state;
422
511
  },
423
512
  get [keysBA]() {
424
513
  const familyBA = myJoin.states[keysBA];
425
- const state = findInStore(familyBA, key, store);
514
+ const state = myJoin.retrieve(familyBA, key);
426
515
  return state;
427
516
  }
428
517
  };
@@ -432,12 +521,12 @@ function findRelationsInStore(token, key, store) {
432
521
  Object.assign(relations, {
433
522
  get [entryAB]() {
434
523
  const familyAB = myJoin.states[entryAB];
435
- const state = findInStore(familyAB, key, store);
524
+ const state = myJoin.retrieve(familyAB, key);
436
525
  return state;
437
526
  },
438
527
  get [entriesBA]() {
439
528
  const familyBA = myJoin.states[entriesBA];
440
- const state = findInStore(familyBA, key, store);
529
+ const state = myJoin.retrieve(familyBA, key);
441
530
  return state;
442
531
  }
443
532
  });
@@ -450,12 +539,12 @@ function findRelationsInStore(token, key, store) {
450
539
  relations = {
451
540
  get [keysAB]() {
452
541
  const familyAB = myJoin.states[keysAB];
453
- const state = findInStore(familyAB, key, store);
542
+ const state = myJoin.retrieve(familyAB, key);
454
543
  return state;
455
544
  },
456
545
  get [keysBA]() {
457
546
  const familyBA = myJoin.states[keysBA];
458
- const state = findInStore(familyBA, key, store);
547
+ const state = myJoin.retrieve(familyBA, key);
459
548
  return state;
460
549
  }
461
550
  };
@@ -465,12 +554,12 @@ function findRelationsInStore(token, key, store) {
465
554
  Object.assign(relations, {
466
555
  get [entriesAB]() {
467
556
  const familyAB = myJoin.states[entriesAB];
468
- const state = findInStore(familyAB, key, store);
557
+ const state = myJoin.retrieve(familyAB, key);
469
558
  return state;
470
559
  },
471
560
  get [entriesBA]() {
472
561
  const familyBA = myJoin.states[entriesBA];
473
- const state = findInStore(familyBA, key, store);
562
+ const state = myJoin.retrieve(familyBA, key);
474
563
  return state;
475
564
  }
476
565
  });
@@ -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
  }
@@ -0,0 +1,27 @@
1
+ // ../anvl/src/json/json-interface.ts
2
+ var stringSetJsonInterface = {
3
+ toJson: (stringSet) => Array.from(stringSet),
4
+ fromJson: (json) => new Set(json)
5
+ };
6
+
7
+ // ../anvl/src/json/index.ts
8
+ var parseJson = (str) => JSON.parse(str);
9
+ var stringifyJson = (json) => JSON.stringify(json);
10
+ var JSON_TYPE_NAMES = [
11
+ `array`,
12
+ `boolean`,
13
+ `null`,
14
+ `number`,
15
+ `object`,
16
+ `string`
17
+ ];
18
+ var JSON_DEFAULTS = {
19
+ array: [],
20
+ boolean: false,
21
+ null: null,
22
+ number: 0,
23
+ object: {},
24
+ string: ``
25
+ };
26
+
27
+ export { JSON_DEFAULTS, JSON_TYPE_NAMES, parseJson, stringSetJsonInterface, stringifyJson };
package/dist/index.cjs CHANGED
@@ -29,21 +29,8 @@ function atom(options) {
29
29
  function atomFamily(options) {
30
30
  return Internal.createAtomFamily(options, Internal.IMPLICIT.STORE);
31
31
  }
32
- function disposeState(token, store = Internal__namespace.IMPLICIT.STORE) {
33
- switch (token.type) {
34
- case `atom`:
35
- case `mutable_atom`:
36
- Internal__namespace.disposeAtom(token, store);
37
- break;
38
- case `selector`:
39
- case `readonly_selector`:
40
- Internal__namespace.disposeSelector(token, store);
41
- break;
42
- }
43
- }
44
- function findState(token, key) {
45
- const state = Internal.findInStore(token, key, Internal.IMPLICIT.STORE);
46
- return state;
32
+ function disposeState(token) {
33
+ Internal__namespace.disposeFromStore(token, Internal__namespace.IMPLICIT.STORE);
47
34
  }
48
35
  function getState(token) {
49
36
  return Internal__namespace.getFromStore(token, Internal__namespace.IMPLICIT.STORE);
@@ -97,8 +84,8 @@ function setState(token, value) {
97
84
  Internal__namespace.setIntoStore(token, value, Internal__namespace.IMPLICIT.STORE);
98
85
  }
99
86
  var Silo = class {
100
- constructor(name, fromStore = null) {
101
- const s = new Internal.Store(name, fromStore);
87
+ constructor(config, fromStore = null) {
88
+ const s = new Internal.Store(config, fromStore);
102
89
  function _atom(options) {
103
90
  return Internal.createStandaloneAtom(options, s);
104
91
  }
@@ -171,7 +158,6 @@ exports.atom = atom;
171
158
  exports.atomFamily = atomFamily;
172
159
  exports.belongsTo = belongsTo;
173
160
  exports.disposeState = disposeState;
174
- exports.findState = findState;
175
161
  exports.getState = getState;
176
162
  exports.isToken = isToken;
177
163
  exports.redo = redo;