atom.io 0.14.0 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/data/dist/index.cjs +1421 -52
  2. package/data/dist/index.cjs.map +1 -1
  3. package/data/dist/index.d.cts +317 -16
  4. package/data/dist/index.js +10 -267
  5. package/data/dist/index.js.map +1 -1
  6. package/data/package.json +5 -5
  7. package/data/src/join.ts +3 -3
  8. package/dist/chunk-C4YZZNRH.js +67 -0
  9. package/dist/chunk-C4YZZNRH.js.map +1 -0
  10. package/dist/chunk-CWKKQKVQ.js +68 -0
  11. package/dist/chunk-CWKKQKVQ.js.map +1 -0
  12. package/dist/chunk-GMN5KH6A.js +309 -0
  13. package/dist/chunk-GMN5KH6A.js.map +1 -0
  14. package/dist/chunk-N7ADBQJG.js +176 -0
  15. package/dist/chunk-N7ADBQJG.js.map +1 -0
  16. package/dist/chunk-NYCVSXQB.js +181 -0
  17. package/dist/chunk-NYCVSXQB.js.map +1 -0
  18. package/dist/chunk-PURABO5G.js +2581 -0
  19. package/dist/chunk-PURABO5G.js.map +1 -0
  20. package/dist/index.cjs +2330 -55
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +272 -22
  23. package/dist/index.js +1 -152
  24. package/dist/index.js.map +1 -1
  25. package/dist/metafile-cjs.json +1 -1
  26. package/internal/dist/index.cjs +299 -106
  27. package/internal/dist/index.cjs.map +1 -1
  28. package/internal/dist/index.d.cts +231 -30
  29. package/internal/dist/index.js +1 -2240
  30. package/internal/dist/index.js.map +1 -1
  31. package/internal/package.json +5 -5
  32. package/internal/src/atom/create-atom.ts +3 -1
  33. package/internal/src/families/create-atom-family.ts +3 -4
  34. package/internal/src/mutable/get-update-family.ts +23 -0
  35. package/internal/src/mutable/index.ts +1 -4
  36. package/internal/src/mutable/is-mutable.ts +44 -0
  37. package/internal/src/mutable/tracker.ts +9 -2
  38. package/internal/src/subject.ts +2 -1
  39. package/internal/src/timeline/add-atom-to-timeline.ts +10 -1
  40. package/internal/src/timeline/create-timeline.ts +44 -16
  41. package/introspection/dist/index.cjs +1566 -46
  42. package/introspection/dist/index.cjs.map +1 -1
  43. package/introspection/dist/index.d.cts +376 -4
  44. package/introspection/dist/index.js +2 -316
  45. package/introspection/dist/index.js.map +1 -1
  46. package/introspection/package.json +5 -5
  47. package/json/dist/index.cjs +1505 -8
  48. package/json/dist/index.cjs.map +1 -1
  49. package/json/dist/index.d.cts +373 -7
  50. package/json/dist/index.js +1 -76
  51. package/json/dist/index.js.map +1 -1
  52. package/json/package.json +5 -5
  53. package/package.json +5 -4
  54. package/react/dist/index.cjs +1549 -14
  55. package/react/dist/index.cjs.map +1 -1
  56. package/react/dist/index.d.cts +377 -4
  57. package/react/dist/index.js +2 -68
  58. package/react/dist/index.js.map +1 -1
  59. package/react/package.json +5 -5
  60. package/react-devtools/dist/index.cjs +2216 -198
  61. package/react-devtools/dist/index.cjs.map +1 -1
  62. package/react-devtools/dist/index.css +2 -2
  63. package/react-devtools/dist/index.d.cts +150 -24
  64. package/react-devtools/dist/index.js +57 -297
  65. package/react-devtools/dist/index.js.map +1 -1
  66. package/react-devtools/package.json +5 -5
  67. package/realtime-client/dist/index.cjs +1530 -35
  68. package/realtime-client/dist/index.cjs.map +1 -1
  69. package/realtime-client/dist/index.d.cts +384 -12
  70. package/realtime-client/dist/index.js +2 -165
  71. package/realtime-client/dist/index.js.map +1 -1
  72. package/realtime-client/package.json +5 -5
  73. package/realtime-react/dist/index.cjs +1727 -35
  74. package/realtime-react/dist/index.cjs.map +1 -1
  75. package/realtime-react/dist/index.d.cts +49 -9
  76. package/realtime-react/dist/index.js +4 -66
  77. package/realtime-react/dist/index.js.map +1 -1
  78. package/realtime-react/package.json +5 -5
  79. package/realtime-server/dist/index.cjs +1549 -58
  80. package/realtime-server/dist/index.cjs.map +1 -1
  81. package/realtime-server/dist/index.d.cts +394 -11
  82. package/realtime-server/dist/index.js +27 -21
  83. package/realtime-server/dist/index.js.map +1 -1
  84. package/realtime-server/package.json +6 -6
  85. package/realtime-testing/dist/index.cjs +2377 -16
  86. package/realtime-testing/dist/index.cjs.map +1 -1
  87. package/realtime-testing/dist/index.d.cts +489 -3
  88. package/realtime-testing/dist/index.js +10 -31
  89. package/realtime-testing/dist/index.js.map +1 -1
  90. package/realtime-testing/package.json +5 -5
  91. package/src/atom.ts +3 -1
  92. package/transceivers/set-rtx/dist/index.cjs +32 -10
  93. package/transceivers/set-rtx/dist/index.cjs.map +1 -1
  94. package/transceivers/set-rtx/dist/index.d.cts +29 -3
  95. package/transceivers/set-rtx/dist/index.js +2 -3
  96. package/transceivers/set-rtx/dist/index.js.map +1 -1
  97. package/transceivers/set-rtx/package.json +6 -6
  98. package/data/dist/index.d.ts +0 -158
  99. package/data/dist/metafile-cjs.json +0 -1
  100. package/data/dist/metafile-esm.json +0 -1
  101. package/dist/index.d.ts +0 -243
  102. package/dist/metafile-esm.json +0 -1
  103. package/internal/dist/index.d.ts +0 -421
  104. package/internal/dist/metafile-cjs.json +0 -1
  105. package/internal/dist/metafile-esm.json +0 -1
  106. package/internal/src/mutable/is-atom-token-mutable.ts +0 -7
  107. package/introspection/dist/index.d.ts +0 -24
  108. package/introspection/dist/metafile-cjs.json +0 -1
  109. package/introspection/dist/metafile-esm.json +0 -1
  110. package/json/dist/index.d.ts +0 -51
  111. package/json/dist/metafile-cjs.json +0 -1
  112. package/json/dist/metafile-esm.json +0 -1
  113. package/react/dist/index.d.ts +0 -23
  114. package/react/dist/metafile-cjs.json +0 -1
  115. package/react/dist/metafile-esm.json +0 -1
  116. package/react-devtools/dist/index.d.ts +0 -341
  117. package/react-devtools/dist/metafile-cjs.json +0 -1
  118. package/react-devtools/dist/metafile-esm.json +0 -1
  119. package/realtime-client/dist/index.d.ts +0 -22
  120. package/realtime-client/dist/metafile-cjs.json +0 -1
  121. package/realtime-client/dist/metafile-esm.json +0 -1
  122. package/realtime-react/dist/index.d.ts +0 -27
  123. package/realtime-react/dist/metafile-cjs.json +0 -1
  124. package/realtime-react/dist/metafile-esm.json +0 -1
  125. package/realtime-server/dist/index.d.ts +0 -25
  126. package/realtime-server/dist/metafile-cjs.json +0 -1
  127. package/realtime-server/dist/metafile-esm.json +0 -1
  128. package/realtime-testing/dist/index.d.ts +0 -49
  129. package/realtime-testing/dist/metafile-cjs.json +0 -1
  130. package/realtime-testing/dist/metafile-esm.json +0 -1
  131. package/transceivers/set-rtx/dist/index.d.ts +0 -40
  132. package/transceivers/set-rtx/dist/metafile-cjs.json +0 -1
  133. package/transceivers/set-rtx/dist/metafile-esm.json +0 -1
@@ -1,9 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var atom_io = require('atom.io');
4
- var json = require('atom.io/json');
5
- var internal = require('atom.io/internal');
6
-
7
3
  var __defProp = Object.defineProperty;
8
4
  var __defProps = Object.defineProperties;
9
5
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -24,7 +20,78 @@ var __spreadValues = (a, b) => {
24
20
  };
25
21
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
26
22
 
27
- // src/future.ts
23
+ // src/get-state.ts
24
+ function getState(token, store = IMPLICIT.STORE) {
25
+ var _a;
26
+ const state = (_a = withdraw(token, store)) != null ? _a : withdrawNewFamilyMember(token, store);
27
+ if (state === void 0) {
28
+ throw new NotFoundError(token, store);
29
+ }
30
+ return readOrComputeValue(state, store);
31
+ }
32
+
33
+ // src/logger.ts
34
+ var simpleLog = (logLevel) => (icon, tokenType, tokenKey, message, ...rest) => {
35
+ console[logLevel](`${icon} ${tokenType} "${tokenKey}" ${message}`, ...rest);
36
+ };
37
+ var simpleLogger = {
38
+ error: simpleLog(`error`),
39
+ info: simpleLog(`info`),
40
+ warn: simpleLog(`warn`)
41
+ };
42
+ var AtomIOLogger = class {
43
+ constructor(logLevel, filter, logger = simpleLogger) {
44
+ this.logLevel = logLevel;
45
+ this.filter = filter;
46
+ this.logger = logger;
47
+ this.error = (...args) => {
48
+ var _a, _b;
49
+ if (((_b = (_a = this.filter) == null ? void 0 : _a.call(this, ...args)) != null ? _b : true) && this.logLevel !== null) {
50
+ this.logger.error(...args);
51
+ }
52
+ };
53
+ this.info = (...args) => {
54
+ var _a, _b;
55
+ if (((_b = (_a = this.filter) == null ? void 0 : _a.call(this, ...args)) != null ? _b : true) && this.logLevel === `info`) {
56
+ this.logger.info(...args);
57
+ }
58
+ };
59
+ this.warn = (...args) => {
60
+ var _a, _b;
61
+ if (((_b = (_a = this.filter) == null ? void 0 : _a.call(this, ...args)) != null ? _b : true) && this.logLevel !== `error` && this.logLevel !== null) {
62
+ this.logger.warn(...args);
63
+ }
64
+ };
65
+ }
66
+ };
67
+
68
+ // src/set-state.ts
69
+ function setState(token, value, store = IMPLICIT.STORE) {
70
+ var _a;
71
+ const rejection = openOperation(token, store);
72
+ if (rejection) {
73
+ return;
74
+ }
75
+ const state = (_a = withdraw(token, store)) != null ? _a : withdrawNewFamilyMember(token, store);
76
+ if (state === void 0) {
77
+ throw new NotFoundError(token, store);
78
+ }
79
+ setAtomOrSelector(state, value, store);
80
+ closeOperation(store);
81
+ }
82
+
83
+ // src/transaction.ts
84
+ var runTransaction = (token, store = IMPLICIT.STORE) => (...parameters) => {
85
+ const tx = withdraw(token, store);
86
+ if (tx) {
87
+ return tx.run(...parameters);
88
+ }
89
+ throw new Error(
90
+ `Cannot run transaction "${token.key}": transaction not found in store "${store.config.name}".`
91
+ );
92
+ };
93
+
94
+ // internal/src/future.ts
28
95
  var Future = class extends Promise {
29
96
  constructor(executor) {
30
97
  super((resolve, reject) => {
@@ -43,7 +110,7 @@ var Future = class extends Promise {
43
110
  }
44
111
  };
45
112
 
46
- // src/lineage.ts
113
+ // internal/src/lineage.ts
47
114
  function newest(scion) {
48
115
  while (scion.child !== null) {
49
116
  scion = scion.child;
@@ -57,7 +124,7 @@ function eldest(scion) {
57
124
  return scion;
58
125
  }
59
126
 
60
- // src/caching.ts
127
+ // internal/src/caching.ts
61
128
  function cacheValue(key, value, subject, store) {
62
129
  const target = newest(store);
63
130
  const currentValue = target.valueMap.get(key);
@@ -102,7 +169,45 @@ var evictCachedValue = (key, store) => {
102
169
  store.logger.info(`\u{1F5D1}`, `state`, key, `evicted`);
103
170
  };
104
171
 
105
- // src/read-or-compute-value.ts
172
+ // ../anvl/src/json/index.ts
173
+ var parseJson = (str) => JSON.parse(str);
174
+ var stringifyJson = (json) => JSON.stringify(json);
175
+
176
+ // json/src/select-json.ts
177
+ var selectJson = (atom, transform, store = IMPLICIT.STORE) => {
178
+ return createSelector(
179
+ {
180
+ key: `${atom.key}:JSON`,
181
+ get: ({ get }) => transform.toJson(get(atom)),
182
+ set: ({ set }, newValue) => set(atom, transform.fromJson(newValue))
183
+ },
184
+ void 0,
185
+ store
186
+ );
187
+ };
188
+
189
+ // json/src/select-json-family.ts
190
+ var selectJsonFamily = (atomFamily, transform, store = IMPLICIT.STORE) => {
191
+ const jsonFamily = createSelectorFamily(
192
+ {
193
+ key: `${atomFamily.key}:JSON`,
194
+ get: (key) => ({ get }) => transform.toJson(get(atomFamily(key))),
195
+ set: (key) => ({ set }, newValue) => set(atomFamily(key), transform.fromJson(newValue))
196
+ },
197
+ store
198
+ );
199
+ atomFamily.subject.subscribe(
200
+ `store=${store.config.name}::json-selector-family`,
201
+ (token) => {
202
+ if (token.family) {
203
+ jsonFamily(parseJson(token.family.subKey));
204
+ }
205
+ }
206
+ );
207
+ return jsonFamily;
208
+ };
209
+
210
+ // internal/src/read-or-compute-value.ts
106
211
  var readOrComputeValue = (state, store) => {
107
212
  if (isValueCached(state.key, store)) {
108
213
  store.logger.info(`\u{1F4D6}`, state.type, state.key, `reading cached value`);
@@ -123,7 +228,7 @@ var readOrComputeValue = (state, store) => {
123
228
  return state.default instanceof Function ? state.default() : state.default;
124
229
  };
125
230
 
126
- // src/operation.ts
231
+ // internal/src/operation.ts
127
232
  var openOperation = (token, store) => {
128
233
  const target = newest(store);
129
234
  if (target.operation.open) {
@@ -189,12 +294,12 @@ var markDone = (key, store) => {
189
294
  target.operation.done.add(key);
190
295
  };
191
296
 
192
- // src/set-state/become.ts
297
+ // internal/src/set-state/become.ts
193
298
  var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing instanceof Function ? nextVersionOfThing(
194
299
  originalThing instanceof Function ? originalThing() : originalThing
195
300
  ) : nextVersionOfThing;
196
301
 
197
- // src/subject.ts
302
+ // internal/src/subject.ts
198
303
  var Subject = class {
199
304
  constructor() {
200
305
  this.subscribers = /* @__PURE__ */ new Map();
@@ -208,7 +313,8 @@ var Subject = class {
208
313
  this.subscribers.delete(key);
209
314
  }
210
315
  next(value) {
211
- for (const subscriber of this.subscribers.values()) {
316
+ const subscribers = this.subscribers.values();
317
+ for (const subscriber of subscribers) {
212
318
  subscriber(value);
213
319
  }
214
320
  }
@@ -224,7 +330,7 @@ var StatefulSubject = class extends Subject {
224
330
  }
225
331
  };
226
332
 
227
- // src/set-state/copy-mutable-if-needed.ts
333
+ // internal/src/set-state/copy-mutable-if-needed.ts
228
334
  function copyMutableIfNeeded(atom, transform, origin, target) {
229
335
  const originValue = origin.valueMap.get(atom.key);
230
336
  const targetValue = target.valueMap.get(atom.key);
@@ -239,7 +345,7 @@ function copyMutableIfNeeded(atom, transform, origin, target) {
239
345
  return targetValue;
240
346
  }
241
347
 
242
- // src/set-state/copy-mutable-in-transaction.ts
348
+ // internal/src/set-state/copy-mutable-in-transaction.ts
243
349
  function copyMutableIfWithinTransaction(oldValue, atom, store) {
244
350
  const target = newest(store);
245
351
  const parent = target.parent;
@@ -273,7 +379,7 @@ function copyMutableFamilyMemberWithinTransaction(atom, family, origin, target)
273
379
  return null;
274
380
  }
275
381
 
276
- // src/set-state/emit-update.ts
382
+ // internal/src/set-state/emit-update.ts
277
383
  var emitUpdate = (state, update, store) => {
278
384
  store.logger.info(
279
385
  `\u{1F4E2}`,
@@ -289,7 +395,7 @@ var emitUpdate = (state, update, store) => {
289
395
  state.subject.next(update);
290
396
  };
291
397
 
292
- // src/set-state/evict-downstream.ts
398
+ // internal/src/set-state/evict-downstream.ts
293
399
  var evictDownStream = (atom, store) => {
294
400
  const target = newest(store);
295
401
  const downstreamKeys = target.selectorAtoms.getRelatedKeys(atom.key);
@@ -319,7 +425,7 @@ var evictDownStream = (atom, store) => {
319
425
  }
320
426
  };
321
427
 
322
- // src/set-state/stow-update.ts
428
+ // internal/src/set-state/stow-update.ts
323
429
  function shouldUpdateBeStowed(key, update) {
324
430
  if (isTransceiver(update.newValue)) {
325
431
  return false;
@@ -362,7 +468,7 @@ var stowUpdate = (state, update, store) => {
362
468
  );
363
469
  };
364
470
 
365
- // src/set-state/set-atom.ts
471
+ // internal/src/set-state/set-atom.ts
366
472
  var setAtom = (atom, next, store) => {
367
473
  const target = newest(store);
368
474
  const oldValue = readOrComputeValue(atom, store);
@@ -383,7 +489,7 @@ var setAtom = (atom, next, store) => {
383
489
  }
384
490
  };
385
491
 
386
- // src/set-state/set-atom-or-selector.ts
492
+ // internal/src/set-state/set-atom-or-selector.ts
387
493
  var setAtomOrSelector = (state, value, store) => {
388
494
  if (state.type === `selector`) {
389
495
  state.set(value);
@@ -392,7 +498,7 @@ var setAtomOrSelector = (state, value, store) => {
392
498
  }
393
499
  };
394
500
 
395
- // src/store/deposit.ts
501
+ // internal/src/store/deposit.ts
396
502
  function deposit(state) {
397
503
  const token = {
398
504
  key: state.key,
@@ -404,7 +510,7 @@ function deposit(state) {
404
510
  return token;
405
511
  }
406
512
 
407
- // ../../rel8/junction/src/junction.ts
513
+ // ../rel8/junction/src/junction.ts
408
514
  var Junction = class {
409
515
  constructor(data, config) {
410
516
  this.relations = /* @__PURE__ */ new Map();
@@ -662,7 +768,7 @@ var Junction = class {
662
768
  }
663
769
  };
664
770
 
665
- // src/store/store.ts
771
+ // internal/src/store/store.ts
666
772
  var Store = class {
667
773
  constructor(name, store = null) {
668
774
  this.parent = null;
@@ -707,7 +813,7 @@ var Store = class {
707
813
  name: `IMPLICIT_STORE`
708
814
  };
709
815
  this.loggers = [
710
- new atom_io.AtomIOLogger(`warn`, (_, __, key) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`))
816
+ new AtomIOLogger(`warn`, (_, __, key) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`))
711
817
  ];
712
818
  this.logger = {
713
819
  error: (...messages) => {
@@ -761,7 +867,7 @@ var clearStore = (store) => {
761
867
  store.config = config;
762
868
  };
763
869
 
764
- // src/store/withdraw.ts
870
+ // internal/src/store/withdraw.ts
765
871
  function withdraw(token, store) {
766
872
  var _a, _b, _c, _d;
767
873
  const target = newest(store);
@@ -772,7 +878,7 @@ function withdraw(token, store) {
772
878
  return void 0;
773
879
  }
774
880
 
775
- // src/store/withdraw-new-family-member.ts
881
+ // internal/src/store/withdraw-new-family-member.ts
776
882
  function withdrawNewFamilyMember(token, store) {
777
883
  if (token.family) {
778
884
  store.logger.info(
@@ -793,19 +899,19 @@ function withdrawNewFamilyMember(token, store) {
793
899
  return void 0;
794
900
  }
795
901
 
796
- // src/keys.ts
902
+ // internal/src/keys.ts
797
903
  var isAtomKey = (key, store) => newest(store).atoms.has(key);
798
904
  var isSelectorKey = (key, store) => newest(store).selectors.has(key);
799
905
  var isReadonlySelectorKey = (key, store) => newest(store).readonlySelectors.has(key);
800
906
  var isStateKey = (key, store) => isAtomKey(key, store) || isSelectorKey(key, store) || isReadonlySelectorKey(key, store);
801
907
 
802
- // src/selector/get-selector-dependency-keys.ts
908
+ // internal/src/selector/get-selector-dependency-keys.ts
803
909
  var getSelectorDependencyKeys = (key, store) => {
804
910
  const sources = newest(store).selectorGraph.getRelationEntries({ downstreamSelectorKey: key }).filter(([_, { source }]) => source !== key).map(([_, { source }]) => source).filter((source) => isStateKey(source, store));
805
911
  return sources;
806
912
  };
807
913
 
808
- // src/selector/trace-selector-atoms.ts
914
+ // internal/src/selector/trace-selector-atoms.ts
809
915
  var traceSelectorAtoms = (selectorKey, directDependencyKey, store) => {
810
916
  const rootKeys = [];
811
917
  const indirectDependencyKeys = getSelectorDependencyKeys(
@@ -838,7 +944,7 @@ var traceAllSelectorAtoms = (selectorKey, store) => {
838
944
  );
839
945
  };
840
946
 
841
- // src/selector/update-selector-atoms.ts
947
+ // internal/src/selector/update-selector-atoms.ts
842
948
  var updateSelectorAtoms = (selectorKey, dependency, store) => {
843
949
  const target = newest(store);
844
950
  if (dependency.type === `atom`) {
@@ -869,7 +975,7 @@ var updateSelectorAtoms = (selectorKey, dependency, store) => {
869
975
  }
870
976
  };
871
977
 
872
- // src/selector/register-selector.ts
978
+ // internal/src/selector/register-selector.ts
873
979
  var registerSelector = (selectorKey, store) => ({
874
980
  get: (dependency) => {
875
981
  const target = newest(store);
@@ -914,7 +1020,7 @@ var registerSelector = (selectorKey, store) => ({
914
1020
  }
915
1021
  });
916
1022
 
917
- // src/selector/create-read-write-selector.ts
1023
+ // internal/src/selector/create-read-write-selector.ts
918
1024
  var createReadWriteSelector = (options, family, store) => {
919
1025
  const target = newest(store);
920
1026
  const subject = new Subject();
@@ -965,7 +1071,7 @@ var createReadWriteSelector = (options, family, store) => {
965
1071
  return token;
966
1072
  };
967
1073
 
968
- // src/selector/create-readonly-selector.ts
1074
+ // internal/src/selector/create-readonly-selector.ts
969
1075
  var createReadonlySelector = (options, family, store) => {
970
1076
  const target = newest(store);
971
1077
  const subject = new Subject();
@@ -1001,7 +1107,7 @@ var createReadonlySelector = (options, family, store) => {
1001
1107
  return token;
1002
1108
  };
1003
1109
 
1004
- // src/selector/create-selector.ts
1110
+ // internal/src/selector/create-selector.ts
1005
1111
  function createSelector(options, family, store) {
1006
1112
  const target = newest(store);
1007
1113
  const existingWritable = target.selectors.get(options.key);
@@ -1020,7 +1126,7 @@ function createSelector(options, family, store) {
1020
1126
  return createReadonlySelector(options, family, store);
1021
1127
  }
1022
1128
 
1023
- // src/selector/delete-selector.ts
1129
+ // internal/src/selector/delete-selector.ts
1024
1130
  function deleteSelector(selectorToken, store) {
1025
1131
  const target = newest(store);
1026
1132
  const { key } = selectorToken;
@@ -1049,7 +1155,7 @@ function deleteSelector(selectorToken, store) {
1049
1155
  store.logger.info(`\u{1F525}`, selectorToken.type, `${key}`, `deleted`);
1050
1156
  }
1051
1157
 
1052
- // src/subscribe/recall-state.ts
1158
+ // internal/src/subscribe/recall-state.ts
1053
1159
  var recallState = (state, store) => {
1054
1160
  const target = newest(store);
1055
1161
  if (!target.operation.open) {
@@ -1058,7 +1164,7 @@ var recallState = (state, store) => {
1058
1164
  return target.operation.prev.get(state.key);
1059
1165
  };
1060
1166
 
1061
- // src/subscribe/subscribe-to-root-atoms.ts
1167
+ // internal/src/subscribe/subscribe-to-root-atoms.ts
1062
1168
  var subscribeToRootAtoms = (state, store) => {
1063
1169
  const dependencySubscriptions = `default` in state ? null : traceAllSelectorAtoms(state.key, store).map((atomKey) => {
1064
1170
  const atom = store.atoms.get(atomKey);
@@ -1098,8 +1204,10 @@ var subscribeToRootAtoms = (state, store) => {
1098
1204
  });
1099
1205
  return dependencySubscriptions;
1100
1206
  };
1207
+
1208
+ // internal/src/subscribe/subscribe-to-state.ts
1101
1209
  function subscribeToState(token, handleUpdate, key, store) {
1102
- const state = internal.withdraw(token, store);
1210
+ const state = withdraw(token, store);
1103
1211
  if (state === void 0) {
1104
1212
  throw new Error(
1105
1213
  `State "${token.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
@@ -1107,7 +1215,7 @@ function subscribeToState(token, handleUpdate, key, store) {
1107
1215
  }
1108
1216
  const unsubFunction = state.subject.subscribe(key, handleUpdate);
1109
1217
  store.logger.info(`\u{1F440}`, state.type, state.key, `Adding subscription "${key}"`);
1110
- const dependencyUnsubFunctions = state.type !== `atom` ? internal.subscribeToRootAtoms(state, store) : null;
1218
+ const dependencyUnsubFunctions = state.type !== `atom` ? subscribeToRootAtoms(state, store) : null;
1111
1219
  const unsubscribe = dependencyUnsubFunctions === null ? () => {
1112
1220
  store.logger.info(
1113
1221
  `\u{1F648}`,
@@ -1130,8 +1238,10 @@ function subscribeToState(token, handleUpdate, key, store) {
1130
1238
  };
1131
1239
  return unsubscribe;
1132
1240
  }
1241
+
1242
+ // internal/src/subscribe/subscribe-to-timeline.ts
1133
1243
  var subscribeToTimeline = (token, handleUpdate, key, store) => {
1134
- const tl = internal.withdraw(token, store);
1244
+ const tl = withdraw(token, store);
1135
1245
  if (tl === void 0) {
1136
1246
  throw new Error(
1137
1247
  `Cannot subscribe to timeline "${token.key}": timeline not found in store "${store.config.name}".`
@@ -1149,8 +1259,10 @@ var subscribeToTimeline = (token, handleUpdate, key, store) => {
1149
1259
  unsubscribe();
1150
1260
  };
1151
1261
  };
1262
+
1263
+ // internal/src/subscribe/subscribe-to-transaction.ts
1152
1264
  var subscribeToTransaction = (token, handleUpdate, key, store) => {
1153
- const tx = internal.withdraw(token, store);
1265
+ const tx = withdraw(token, store);
1154
1266
  if (tx === void 0) {
1155
1267
  throw new Error(
1156
1268
  `Cannot subscribe to transaction "${token.key}": transaction not found in store "${store.config.name}".`
@@ -1173,6 +1285,8 @@ var subscribeToTransaction = (token, handleUpdate, key, store) => {
1173
1285
  unsubscribe();
1174
1286
  };
1175
1287
  };
1288
+
1289
+ // internal/src/mutable/tracker.ts
1176
1290
  var Tracker = class {
1177
1291
  constructor(mutableState, store) {
1178
1292
  this.unsubscribeFromInnerValue = null;
@@ -1185,7 +1299,8 @@ var Tracker = class {
1185
1299
  }
1186
1300
  initializeState(mutableState, store) {
1187
1301
  const latestUpdateStateKey = `*${mutableState.key}`;
1188
- deleteAtom({ type: `atom`, key: latestUpdateStateKey }, store);
1302
+ store.atoms.delete(latestUpdateStateKey);
1303
+ store.valueMap.delete(latestUpdateStateKey);
1189
1304
  const familyMetaData = mutableState.family ? {
1190
1305
  key: `*${mutableState.family.key}`,
1191
1306
  subKey: mutableState.family.subKey
@@ -1198,10 +1313,14 @@ var Tracker = class {
1198
1313
  familyMetaData,
1199
1314
  store
1200
1315
  );
1316
+ if (store.parent) {
1317
+ const parentValue = store.parent.valueMap.get(latestUpdateStateKey);
1318
+ store.valueMap.set(latestUpdateStateKey, parentValue);
1319
+ }
1201
1320
  return latestUpdateState;
1202
1321
  }
1203
1322
  observeCore(mutableState, latestUpdateState, store) {
1204
- const originalInnerValue = atom_io.getState(mutableState, store);
1323
+ const originalInnerValue = getState(mutableState, store);
1205
1324
  const target = newest(store);
1206
1325
  this.unsubscribeFromInnerValue = originalInnerValue.subscribe(
1207
1326
  `tracker:${store.config.name}:${target.transactionMeta === null ? `main` : target.transactionMeta.update.key}`,
@@ -1210,7 +1329,7 @@ var Tracker = class {
1210
1329
  mutableState.key,
1211
1330
  () => {
1212
1331
  unsubscribe();
1213
- atom_io.setState(latestUpdateState, update, store);
1332
+ setState(latestUpdateState, update, store);
1214
1333
  }
1215
1334
  );
1216
1335
  }
@@ -1229,7 +1348,7 @@ var Tracker = class {
1229
1348
  mutableState.key,
1230
1349
  () => {
1231
1350
  unsubscribe();
1232
- atom_io.setState(latestUpdateState, update2, store);
1351
+ setState(latestUpdateState, update2, store);
1233
1352
  }
1234
1353
  );
1235
1354
  }
@@ -1254,7 +1373,7 @@ var Tracker = class {
1254
1373
  { key: timelineId, type: `timeline` },
1255
1374
  (update) => {
1256
1375
  unsubscribe2();
1257
- atom_io.setState(
1376
+ setState(
1258
1377
  mutableState,
1259
1378
  (transceiver) => {
1260
1379
  if (update === `redo` && newValue) {
@@ -1277,11 +1396,11 @@ var Tracker = class {
1277
1396
  latestUpdateState.key,
1278
1397
  () => {
1279
1398
  unsubscribe();
1280
- const mutable = atom_io.getState(mutableState, store);
1281
- const updateNumber = mutable.getUpdateNumber(newValue);
1399
+ const mutable = getState(mutableState, store);
1400
+ const updateNumber = newValue === null ? -1 : mutable.getUpdateNumber(newValue);
1282
1401
  const eventOffset = updateNumber - mutable.cacheUpdateNumber;
1283
1402
  if (newValue && eventOffset === 1) {
1284
- atom_io.setState(
1403
+ setState(
1285
1404
  mutableState,
1286
1405
  (transceiver) => (transceiver.do(newValue), transceiver),
1287
1406
  store
@@ -1296,7 +1415,7 @@ var Tracker = class {
1296
1415
  }
1297
1416
  };
1298
1417
 
1299
- // src/mutable/create-mutable-atom.ts
1418
+ // internal/src/mutable/create-mutable-atom.ts
1300
1419
  function createMutableAtom(options, store) {
1301
1420
  store.logger.info(
1302
1421
  `\u{1F527}`,
@@ -1306,7 +1425,7 @@ function createMutableAtom(options, store) {
1306
1425
  );
1307
1426
  const coreState = createAtom(options, void 0, store);
1308
1427
  new Tracker(coreState, store);
1309
- const jsonState = json.selectJson(coreState, options, store);
1428
+ const jsonState = selectJson(coreState, options, store);
1310
1429
  const target = newest(store);
1311
1430
  subscribeToState(
1312
1431
  jsonState,
@@ -1321,11 +1440,13 @@ function createMutableAtom(options, store) {
1321
1440
  );
1322
1441
  return coreState;
1323
1442
  }
1443
+
1444
+ // internal/src/families/create-atom-family.ts
1324
1445
  function createAtomFamily(options, store) {
1325
1446
  const subject = new Subject();
1326
1447
  const atomFamily = Object.assign(
1327
1448
  (key) => {
1328
- const subKey = json.stringifyJson(key);
1449
+ const subKey = stringifyJson(key);
1329
1450
  const family = { key: options.key, subKey };
1330
1451
  const fullKey = `${options.key}(${subKey})`;
1331
1452
  const existing = withdraw({ key: fullKey, type: `atom` }, store);
@@ -1351,16 +1472,21 @@ function createAtomFamily(options, store) {
1351
1472
  subject
1352
1473
  }
1353
1474
  );
1475
+ if (`mutable` in options && typeof options.mutable === `boolean`) {
1476
+ Object.assign(atomFamily, { mutable: options.mutable });
1477
+ }
1354
1478
  const target = newest(store);
1355
1479
  target.families.set(options.key, atomFamily);
1356
1480
  return atomFamily;
1357
1481
  }
1482
+
1483
+ // internal/src/families/create-readonly-selector-family.ts
1358
1484
  function createReadonlySelectorFamily(options, store) {
1359
1485
  const subject = new Subject();
1360
1486
  return Object.assign(
1361
1487
  (key) => {
1362
1488
  const target = newest(store);
1363
- const subKey = json.stringifyJson(key);
1489
+ const subKey = stringifyJson(key);
1364
1490
  const family = { key: options.key, subKey };
1365
1491
  const fullKey = `${options.key}(${subKey})`;
1366
1492
  const existing = target.readonlySelectors.get(fullKey);
@@ -1383,6 +1509,8 @@ function createReadonlySelectorFamily(options, store) {
1383
1509
  }
1384
1510
  );
1385
1511
  }
1512
+
1513
+ // internal/src/families/create-selector-family.ts
1386
1514
  function createSelectorFamily(options, store) {
1387
1515
  const isReadonly = !(`set` in options);
1388
1516
  if (isReadonly) {
@@ -1392,7 +1520,7 @@ function createSelectorFamily(options, store) {
1392
1520
  const subject = new Subject();
1393
1521
  const selectorFamily = Object.assign(
1394
1522
  (key) => {
1395
- const subKey = json.stringifyJson(key);
1523
+ const subKey = stringifyJson(key);
1396
1524
  const family = { key: options.key, subKey };
1397
1525
  const fullKey = `${options.key}(${subKey})`;
1398
1526
  const existing = target.selectors.get(fullKey);
@@ -1420,7 +1548,7 @@ function createSelectorFamily(options, store) {
1420
1548
  return selectorFamily;
1421
1549
  }
1422
1550
 
1423
- // src/mutable/tracker-family.ts
1551
+ // internal/src/mutable/tracker-family.ts
1424
1552
  var FamilyTracker = class {
1425
1553
  constructor(findMutableState, store) {
1426
1554
  this.findLatestUpdateState = createAtomFamily(
@@ -1435,7 +1563,7 @@ var FamilyTracker = class {
1435
1563
  `store=${store.config.name}::tracker-atom-family`,
1436
1564
  (atomToken) => {
1437
1565
  if (atomToken.family) {
1438
- const key = json.parseJson(atomToken.family.subKey);
1566
+ const key = parseJson(atomToken.family.subKey);
1439
1567
  this.findLatestUpdateState(key);
1440
1568
  new Tracker(atomToken, store);
1441
1569
  }
@@ -1445,7 +1573,7 @@ var FamilyTracker = class {
1445
1573
  `store=${store.config.name}::tracker-atom-family`,
1446
1574
  (atomToken) => {
1447
1575
  if (atomToken.family) {
1448
- const key = json.parseJson(atomToken.family.subKey);
1576
+ const key = parseJson(atomToken.family.subKey);
1449
1577
  const mutableAtomToken = this.findMutableState(key);
1450
1578
  new Tracker(mutableAtomToken, store);
1451
1579
  }
@@ -1454,18 +1582,18 @@ var FamilyTracker = class {
1454
1582
  }
1455
1583
  };
1456
1584
 
1457
- // src/mutable/create-mutable-atom-family.ts
1585
+ // internal/src/mutable/create-mutable-atom-family.ts
1458
1586
  function createMutableAtomFamily(options, store) {
1459
1587
  const coreFamily = Object.assign(
1460
1588
  createAtomFamily(options, store),
1461
1589
  options
1462
1590
  );
1463
- json.selectJsonFamily(coreFamily, options);
1591
+ selectJsonFamily(coreFamily, options);
1464
1592
  new FamilyTracker(coreFamily, store);
1465
1593
  return coreFamily;
1466
1594
  }
1467
1595
 
1468
- // src/mutable/get-json-family.ts
1596
+ // internal/src/mutable/get-json-family.ts
1469
1597
  var getJsonFamily = (mutableAtomFamily, store) => {
1470
1598
  const target = newest(store);
1471
1599
  const key = `${mutableAtomFamily.key}:JSON`;
@@ -1475,7 +1603,7 @@ var getJsonFamily = (mutableAtomFamily, store) => {
1475
1603
  return jsonFamily;
1476
1604
  };
1477
1605
 
1478
- // src/mutable/get-json-token.ts
1606
+ // internal/src/mutable/get-json-token.ts
1479
1607
  var getJsonToken = (mutableAtomToken) => {
1480
1608
  const key = mutableAtomToken.family ? `${mutableAtomToken.family.key}:JSON(${mutableAtomToken.family.subKey})` : `${mutableAtomToken.key}:JSON`;
1481
1609
  const jsonToken = { type: `selector`, key };
@@ -1488,7 +1616,7 @@ var getJsonToken = (mutableAtomToken) => {
1488
1616
  return jsonToken;
1489
1617
  };
1490
1618
 
1491
- // src/mutable/get-update-token.ts
1619
+ // internal/src/mutable/get-update-token.ts
1492
1620
  var getUpdateToken = (mutableAtomToken) => {
1493
1621
  const key = `*${mutableAtomToken.key}`;
1494
1622
  const updateToken = { type: `atom`, key };
@@ -1501,20 +1629,20 @@ var getUpdateToken = (mutableAtomToken) => {
1501
1629
  return updateToken;
1502
1630
  };
1503
1631
 
1504
- // src/mutable/is-atom-token-mutable.ts
1505
- function isAtomTokenMutable(token) {
1506
- return token.key.endsWith(`::mutable`);
1507
- }
1632
+ // internal/src/mutable/get-update-family.ts
1633
+ var getUpdateFamily = (mutableAtomFamily, store) => {
1634
+ const target = newest(store);
1635
+ const key = `*${mutableAtomFamily.key}`;
1636
+ const updateFamily = target.families.get(key);
1637
+ return updateFamily;
1638
+ };
1508
1639
 
1509
- // src/mutable/transceiver.ts
1640
+ // internal/src/mutable/transceiver.ts
1510
1641
  function isTransceiver(value) {
1511
1642
  return typeof value === `object` && value !== null && `do` in value && `undo` in value && `subscribe` in value;
1512
1643
  }
1513
1644
 
1514
- // src/mutable/index.ts
1515
- var isAtomMutable = (atom) => `isMutable` in atom;
1516
-
1517
- // src/atom/is-default.ts
1645
+ // internal/src/atom/is-default.ts
1518
1646
  var isAtomDefault = (key, store) => {
1519
1647
  const core = newest(store);
1520
1648
  return core.atomsThatAreDefault.has(key);
@@ -1533,7 +1661,7 @@ var isSelectorDefault = (key, store) => {
1533
1661
  return rootKeys.every((rootKey) => isAtomDefault(rootKey, store));
1534
1662
  };
1535
1663
 
1536
- // src/atom/create-atom.ts
1664
+ // internal/src/atom/create-atom.ts
1537
1665
  function createAtom(options, family, store) {
1538
1666
  store.logger.info(
1539
1667
  `\u{1F528}`,
@@ -1580,7 +1708,7 @@ function createAtom(options, family, store) {
1580
1708
  const cleanupFunctions = [];
1581
1709
  for (const effect of options.effects) {
1582
1710
  const cleanup = effect({
1583
- setSelf: (next) => atom_io.setState(token, next, store),
1711
+ setSelf: (next) => setState(token, next, store),
1584
1712
  onSet: (handle) => subscribeToState(token, handle, `effect[${effectIndex}]`, store)
1585
1713
  });
1586
1714
  if (cleanup) {
@@ -1598,8 +1726,8 @@ function createAtom(options, family, store) {
1598
1726
  return token;
1599
1727
  }
1600
1728
 
1601
- // src/atom/delete-atom.ts
1602
- function deleteAtom(atomToken, store) {
1729
+ // internal/src/atom/delete-atom.ts
1730
+ function deleteAtom2(atomToken, store) {
1603
1731
  var _a, _b;
1604
1732
  const target = newest(store);
1605
1733
  const { key } = atomToken;
@@ -1630,7 +1758,7 @@ function deleteAtom(atomToken, store) {
1630
1758
  store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
1631
1759
  }
1632
1760
 
1633
- // src/lazy-map.ts
1761
+ // internal/src/lazy-map.ts
1634
1762
  var LazyMap = class extends Map {
1635
1763
  constructor(source) {
1636
1764
  super();
@@ -1664,7 +1792,7 @@ var LazyMap = class extends Map {
1664
1792
  }
1665
1793
  };
1666
1794
 
1667
- // src/not-found-error.ts
1795
+ // internal/src/not-found-error.ts
1668
1796
  var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
1669
1797
  function prettyPrintTokenType(token) {
1670
1798
  if (token.type === `readonly_selector`) {
@@ -1680,9 +1808,15 @@ var NotFoundError = class extends Error {
1680
1808
  }
1681
1809
  };
1682
1810
 
1683
- // src/timeline/add-atom-to-timeline.ts
1811
+ // internal/src/timeline/add-atom-to-timeline.ts
1684
1812
  var addAtomToTimeline = (atomToken, tl, store) => {
1685
- const atom = withdraw(atomToken, store);
1813
+ let maybeAtom = withdraw(atomToken, store);
1814
+ if (maybeAtom == null ? void 0 : maybeAtom.mutable) {
1815
+ console.log(`adding transceiver to timeline`, atomToken.key);
1816
+ const updateToken = getUpdateToken(atomToken);
1817
+ maybeAtom = withdraw(updateToken, store);
1818
+ }
1819
+ const atom = maybeAtom;
1686
1820
  if (atom === void 0) {
1687
1821
  throw new Error(
1688
1822
  `Cannot subscribe to atom "${atomToken.key}" because it has not been initialized in store "${store.config.name}"`
@@ -1872,7 +2006,31 @@ var addAtomToTimeline = (atomToken, tl, store) => {
1872
2006
  });
1873
2007
  };
1874
2008
 
1875
- // src/timeline/create-timeline.ts
2009
+ // internal/src/mutable/is-mutable.ts
2010
+ function isMutable(atomOrTokenOrFamily, store) {
2011
+ if (`mutable` in atomOrTokenOrFamily) {
2012
+ return atomOrTokenOrFamily.mutable;
2013
+ }
2014
+ if (atomOrTokenOrFamily.type === `atom_family`) {
2015
+ return false;
2016
+ }
2017
+ if (`default` in atomOrTokenOrFamily) {
2018
+ return false;
2019
+ }
2020
+ if (!store) {
2021
+ throw new Error(`Cannot check mutability without a store`);
2022
+ }
2023
+ const atom = withdraw(atomOrTokenOrFamily, store);
2024
+ if (!atom) {
2025
+ throw new Error(`Cannot check mutability without an atom`);
2026
+ }
2027
+ if (`mutable` in atom) {
2028
+ return atom.mutable;
2029
+ }
2030
+ return false;
2031
+ }
2032
+
2033
+ // internal/src/timeline/create-timeline.ts
1876
2034
  function createTimeline(options, store, data) {
1877
2035
  var _a, _b;
1878
2036
  const tl = __spreadProps(__spreadValues({
@@ -1890,20 +2048,26 @@ function createTimeline(options, store, data) {
1890
2048
  if (options.shouldCapture) {
1891
2049
  tl.shouldCapture = options.shouldCapture;
1892
2050
  }
2051
+ const timelineKey = options.key;
1893
2052
  const target = newest(store);
1894
2053
  for (const tokenOrFamily of options.atoms) {
1895
- const timelineKey = target.timelineAtoms.getRelatedKey(tokenOrFamily.key);
1896
- if (timelineKey) {
2054
+ let atomKey = tokenOrFamily.key;
2055
+ const existingTimelineKey = target.timelineAtoms.getRelatedKey(atomKey);
2056
+ if (existingTimelineKey) {
1897
2057
  store.logger.error(
1898
2058
  `\u274C`,
1899
2059
  `timeline`,
1900
2060
  options.key,
1901
- `Failed to add atom "${tokenOrFamily.key}" because it already belongs to timeline "${timelineKey}"`
2061
+ `Failed to add atom "${atomKey}" because it already belongs to timeline "${existingTimelineKey}"`
1902
2062
  );
1903
2063
  continue;
1904
2064
  }
1905
2065
  if (tokenOrFamily.type === `atom_family`) {
1906
- const family = tokenOrFamily;
2066
+ let family = tokenOrFamily;
2067
+ if (isMutable(family)) {
2068
+ family = getUpdateFamily(family, store);
2069
+ atomKey = family.key;
2070
+ }
1907
2071
  family.subject.subscribe(`timeline:${options.key}`, (token2) => {
1908
2072
  addAtomToTimeline(token2, tl, store);
1909
2073
  });
@@ -1913,36 +2077,58 @@ function createTimeline(options, store, data) {
1913
2077
  }
1914
2078
  }
1915
2079
  } else {
1916
- const token2 = tokenOrFamily;
1917
- if (`family` in token2 && token2.family) {
2080
+ let atom = withdraw(tokenOrFamily, store);
2081
+ if (atom === void 0) {
2082
+ store.logger.error(
2083
+ `\u274C`,
2084
+ `timeline`,
2085
+ options.key,
2086
+ `Failed to add atom "${atomKey}" because it does not exist in the store`
2087
+ );
2088
+ continue;
2089
+ }
2090
+ if (isMutable(atom)) {
2091
+ const updateAtom = withdraw(getUpdateToken(atom), store);
2092
+ if (updateAtom === void 0) {
2093
+ store.logger.error(
2094
+ `\u274C`,
2095
+ `timeline`,
2096
+ options.key,
2097
+ `Failed to add update atom "${atomKey}" because it does not exist in the store`
2098
+ );
2099
+ continue;
2100
+ }
2101
+ atom = updateAtom;
2102
+ atomKey = atom.key;
2103
+ }
2104
+ if (`family` in atom) {
1918
2105
  const familyTimelineKey = target.timelineAtoms.getRelatedKey(
1919
- token2.family.key
2106
+ atom.family.key
1920
2107
  );
1921
2108
  if (familyTimelineKey) {
1922
2109
  store.logger.error(
1923
2110
  `\u274C`,
1924
2111
  `timeline`,
1925
2112
  options.key,
1926
- `Failed to add atom "${token2.key}" because its family "${token2.family.key}" already belongs to timeline "${familyTimelineKey}"`
2113
+ `Failed to add atom "${atom.key}" because its family "${atom.family.key}" already belongs to timeline "${familyTimelineKey}"`
1927
2114
  );
1928
2115
  continue;
1929
2116
  }
1930
2117
  }
1931
- addAtomToTimeline(token2, tl, store);
2118
+ addAtomToTimeline(atom, tl, store);
1932
2119
  }
1933
- target.timelineAtoms = target.timelineAtoms.set({
1934
- atomKey: tokenOrFamily.key,
1935
- timelineKey: options.key
1936
- });
2120
+ target.timelineAtoms.set({ atomKey, timelineKey });
1937
2121
  }
1938
2122
  store.timelines.set(options.key, tl);
1939
2123
  const token = {
1940
- key: options.key,
2124
+ key: timelineKey,
1941
2125
  type: `timeline`
1942
2126
  };
1943
2127
  store.subject.timelineCreation.next(token);
1944
2128
  return token;
1945
2129
  }
2130
+
2131
+ // internal/src/timeline/time-travel.ts
1946
2132
  var timeTravel = (direction, token, store) => {
1947
2133
  const action = direction === `forward` ? `redo` : `undo`;
1948
2134
  store.logger.info(
@@ -1978,7 +2164,7 @@ var timeTravel = (direction, token, store) => {
1978
2164
  const updateValues = (atomUpdate) => {
1979
2165
  const { key, newValue, oldValue } = atomUpdate;
1980
2166
  const value = direction === `forward` ? newValue : oldValue;
1981
- atom_io.setState({ key, type: `atom` }, value, store);
2167
+ setState({ key, type: `atom` }, value, store);
1982
2168
  };
1983
2169
  const updateValuesFromTransactionUpdate = (transactionUpdate) => {
1984
2170
  const updates = direction === `forward` ? transactionUpdate.updates : [...transactionUpdate.updates].reverse();
@@ -2020,7 +2206,7 @@ var timeTravel = (direction, token, store) => {
2020
2206
  );
2021
2207
  };
2022
2208
 
2023
- // src/transaction/abort-transaction.ts
2209
+ // internal/src/transaction/abort-transaction.ts
2024
2210
  var abortTransaction = (store) => {
2025
2211
  const target = newest(store);
2026
2212
  if (target.transactionMeta === null || target.parent === null) {
@@ -2040,6 +2226,8 @@ var abortTransaction = (store) => {
2040
2226
  );
2041
2227
  target.parent.child = null;
2042
2228
  };
2229
+
2230
+ // internal/src/transaction/apply-transaction.ts
2043
2231
  function ingestAtomUpdate(update, parent, child) {
2044
2232
  var _a, _b, _c;
2045
2233
  const { key, newValue } = update;
@@ -2067,7 +2255,7 @@ function ingestAtomUpdate(update, parent, child) {
2067
2255
  );
2068
2256
  }
2069
2257
  }
2070
- atom_io.setState(token, newValue, parent);
2258
+ setState(token, newValue, parent);
2071
2259
  }
2072
2260
  function ingestTransactionUpdate(transactionUpdate, parent, child) {
2073
2261
  for (const update of transactionUpdate.updates) {
@@ -2123,7 +2311,7 @@ var applyTransaction = (output, store) => {
2123
2311
  parent.subject.transactionApplying.next(null);
2124
2312
  };
2125
2313
 
2126
- // src/transaction/build-transaction.ts
2314
+ // internal/src/transaction/build-transaction.ts
2127
2315
  var buildTransaction = (key, params, store) => {
2128
2316
  const parent = newest(store);
2129
2317
  parent.child = {
@@ -2167,6 +2355,8 @@ var buildTransaction = (key, params, store) => {
2167
2355
  params
2168
2356
  );
2169
2357
  };
2358
+
2359
+ // internal/src/transaction/create-transaction.ts
2170
2360
  function createTransaction(options, store) {
2171
2361
  const newTransaction = {
2172
2362
  key: options.key,
@@ -2176,9 +2366,9 @@ function createTransaction(options, store) {
2176
2366
  try {
2177
2367
  const output = options.do(
2178
2368
  {
2179
- get: (token2) => atom_io.getState(token2, store),
2180
- set: (token2, value) => atom_io.setState(token2, value, store),
2181
- run: (token2) => atom_io.runTransaction(token2, store)
2369
+ get: (token2) => getState(token2, store),
2370
+ set: (token2, value) => setState(token2, value, store),
2371
+ run: (token2) => runTransaction(token2, store)
2182
2372
  },
2183
2373
  ...params
2184
2374
  );
@@ -2199,6 +2389,8 @@ function createTransaction(options, store) {
2199
2389
  store.subject.transactionCreation.next(token);
2200
2390
  return token;
2201
2391
  }
2392
+
2393
+ // internal/src/transaction/redo-transaction.ts
2202
2394
  var redoTransactionUpdate = (transactionUpdate, store) => {
2203
2395
  store.logger.info(`\u23ED\uFE0F`, `transaction`, transactionUpdate.key, `Redo`);
2204
2396
  for (const update of transactionUpdate.updates) {
@@ -2211,12 +2403,14 @@ var redoTransactionUpdate = (transactionUpdate, store) => {
2211
2403
  `State "${token.key}" not found in this store. This is surprising, because we are navigating the history of the store.`
2212
2404
  );
2213
2405
  }
2214
- atom_io.setState(state, newValue, store);
2406
+ setState(state, newValue, store);
2215
2407
  } else {
2216
2408
  redoTransactionUpdate(update, store);
2217
2409
  }
2218
2410
  }
2219
2411
  };
2412
+
2413
+ // internal/src/transaction/undo-transaction.ts
2220
2414
  var undoTransactionUpdate = (transactionUpdate, store) => {
2221
2415
  store.logger.info(`\u23EE\uFE0F`, `transaction`, transactionUpdate.key, `Undo`);
2222
2416
  for (const update of transactionUpdate.updates.reverse()) {
@@ -2229,14 +2423,14 @@ var undoTransactionUpdate = (transactionUpdate, store) => {
2229
2423
  `State "${token.key}" not found in this store. This is surprising, because we are navigating the history of the store.`
2230
2424
  );
2231
2425
  }
2232
- atom_io.setState(state, newValue, store);
2426
+ setState(state, newValue, store);
2233
2427
  } else {
2234
2428
  undoTransactionUpdate(update, store);
2235
2429
  }
2236
2430
  }
2237
2431
  };
2238
2432
 
2239
- // src/transaction/index.ts
2433
+ // internal/src/transaction/index.ts
2240
2434
  var TRANSACTION_PHASES = [`idle`, `building`, `applying`];
2241
2435
 
2242
2436
  exports.FamilyTracker = FamilyTracker;
@@ -2266,7 +2460,7 @@ exports.createSelector = createSelector;
2266
2460
  exports.createSelectorFamily = createSelectorFamily;
2267
2461
  exports.createTimeline = createTimeline;
2268
2462
  exports.createTransaction = createTransaction;
2269
- exports.deleteAtom = deleteAtom;
2463
+ exports.deleteAtom = deleteAtom2;
2270
2464
  exports.deleteSelector = deleteSelector;
2271
2465
  exports.deposit = deposit;
2272
2466
  exports.eldest = eldest;
@@ -2274,11 +2468,10 @@ exports.evictCachedValue = evictCachedValue;
2274
2468
  exports.getJsonFamily = getJsonFamily;
2275
2469
  exports.getJsonToken = getJsonToken;
2276
2470
  exports.getSelectorDependencyKeys = getSelectorDependencyKeys;
2471
+ exports.getUpdateFamily = getUpdateFamily;
2277
2472
  exports.getUpdateToken = getUpdateToken;
2278
2473
  exports.isAtomDefault = isAtomDefault;
2279
2474
  exports.isAtomKey = isAtomKey;
2280
- exports.isAtomMutable = isAtomMutable;
2281
- exports.isAtomTokenMutable = isAtomTokenMutable;
2282
2475
  exports.isDone = isDone;
2283
2476
  exports.isReadonlySelectorKey = isReadonlySelectorKey;
2284
2477
  exports.isSelectorDefault = isSelectorDefault;