atom.io 0.6.5 → 0.6.7

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 (72) hide show
  1. package/README.md +32 -78
  2. package/dist/index.d.mts +11 -43
  3. package/dist/index.d.ts +11 -43
  4. package/dist/index.js +111 -291
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +108 -278
  7. package/dist/index.mjs.map +1 -1
  8. package/introspection/dist/index.d.mts +273 -0
  9. package/introspection/dist/index.d.ts +273 -0
  10. package/introspection/dist/index.js +350 -0
  11. package/introspection/dist/index.js.map +1 -0
  12. package/introspection/dist/index.mjs +327 -0
  13. package/introspection/dist/index.mjs.map +1 -0
  14. package/introspection/package.json +15 -0
  15. package/package.json +22 -12
  16. package/react-devtools/dist/index.css +22 -5
  17. package/react-devtools/dist/index.css.map +1 -1
  18. package/react-devtools/dist/index.d.mts +347 -10
  19. package/react-devtools/dist/index.d.ts +347 -10
  20. package/react-devtools/dist/index.js +2743 -696
  21. package/react-devtools/dist/index.js.map +1 -1
  22. package/react-devtools/dist/index.mjs +2739 -701
  23. package/react-devtools/dist/index.mjs.map +1 -1
  24. package/src/internal/atom-internal.ts +5 -6
  25. package/src/internal/get.ts +7 -9
  26. package/src/internal/index.ts +0 -1
  27. package/src/internal/operation.ts +15 -21
  28. package/src/internal/selector/create-read-write-selector.ts +8 -4
  29. package/src/internal/selector/create-readonly-selector.ts +1 -7
  30. package/src/internal/selector-internal.ts +1 -3
  31. package/src/internal/set.ts +1 -4
  32. package/src/internal/store.ts +22 -24
  33. package/src/internal/subscribe-internal.ts +7 -1
  34. package/src/internal/time-travel-internal.ts +2 -0
  35. package/src/internal/timeline/add-atom-to-timeline.ts +11 -12
  36. package/src/internal/timeline-internal.ts +6 -4
  37. package/src/internal/transaction/apply-transaction.ts +9 -6
  38. package/src/internal/transaction/build-transaction.ts +6 -6
  39. package/src/internal/transaction-internal.ts +1 -7
  40. package/src/introspection/attach-atom-index.ts +73 -0
  41. package/src/introspection/attach-introspection-states.ts +42 -0
  42. package/src/introspection/attach-selector-index.ts +77 -0
  43. package/src/introspection/attach-timeline-family.ts +59 -0
  44. package/src/introspection/attach-timeline-index.ts +36 -0
  45. package/src/introspection/attach-transaction-index.ts +38 -0
  46. package/src/introspection/attach-transaction-logs.ts +40 -0
  47. package/src/introspection/index.ts +20 -0
  48. package/src/react-devtools/AtomIODevtools.tsx +97 -97
  49. package/src/react-devtools/Button.tsx +24 -0
  50. package/src/react-devtools/StateEditor.tsx +14 -16
  51. package/src/react-devtools/StateIndex.tsx +153 -0
  52. package/src/react-devtools/TimelineIndex.tsx +92 -0
  53. package/src/react-devtools/TransactionIndex.tsx +70 -0
  54. package/src/react-devtools/Updates.tsx +145 -0
  55. package/src/react-devtools/devtools.scss +196 -15
  56. package/src/react-devtools/index.ts +71 -0
  57. package/src/react-explorer/AtomIOExplorer.tsx +3 -4
  58. package/src/react-explorer/explorer-states.ts +1 -1
  59. package/src/react-explorer/space-states.ts +3 -1
  60. package/src/react-explorer/view-states.ts +0 -2
  61. package/realtime-testing/dist/index.d.mts +0 -49
  62. package/realtime-testing/dist/index.d.ts +0 -49
  63. package/realtime-testing/dist/index.js +0 -165
  64. package/realtime-testing/dist/index.js.map +0 -1
  65. package/realtime-testing/dist/index.mjs +0 -129
  66. package/realtime-testing/dist/index.mjs.map +0 -1
  67. package/src/internal/meta/attach-meta.ts +0 -17
  68. package/src/internal/meta/index.ts +0 -4
  69. package/src/internal/meta/meta-state.ts +0 -135
  70. package/src/internal/meta/meta-timelines.ts +0 -1
  71. package/src/internal/meta/meta-transactions.ts +0 -1
  72. package/src/react-devtools/TokenList.tsx +0 -61
package/dist/index.js CHANGED
@@ -1,11 +1,9 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
6
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
- var __getProtoOf = Object.getPrototypeOf;
9
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
8
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
9
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -45,14 +43,6 @@ var __copyProps = (to, from, except, desc) => {
45
43
  }
46
44
  return to;
47
45
  };
48
- var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
49
- // If the importer is in node compatibility mode or this is not an ESM
50
- // file that has been converted to a CommonJS file using a Babel-
51
- // compatible transform (i.e. "__esModule" has not been set), then set
52
- // "default" to the CommonJS "module.exports" for node compatibility.
53
- isNodeMode || !mod || !mod.__esModule ? __defProp(target2, "default", { value: mod, enumerable: true }) : target2,
54
- mod
55
- ));
56
46
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
57
47
 
58
48
  // src/index.ts
@@ -88,7 +78,6 @@ var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
88
78
  var internal_exports = {};
89
79
  __export(internal_exports, {
90
80
  IMPLICIT: () => IMPLICIT,
91
- META: () => meta_exports,
92
81
  Subject: () => Subject,
93
82
  TRANSACTION_PHASES: () => TRANSACTION_PHASES,
94
83
  abortTransaction: () => abortTransaction,
@@ -145,21 +134,17 @@ __export(internal_exports, {
145
134
  withdraw: () => withdraw
146
135
  });
147
136
 
148
- // src/internal/atom-internal.ts
149
- var import_hamt_plus5 = __toESM(require("hamt_plus"));
150
-
151
137
  // src/internal/get.ts
152
- var import_hamt_plus = __toESM(require("hamt_plus"));
153
138
  var computeSelectorState = (selector2) => selector2.get();
154
139
  function lookup(key, store) {
155
140
  const core = target(store);
156
- const type = import_hamt_plus.default.has(key, core.atoms) ? `atom` : import_hamt_plus.default.has(key, core.selectors) ? `selector` : `readonly_selector`;
141
+ const type = core.atoms.has(key) ? `atom` : core.selectors.has(key) ? `selector` : `readonly_selector`;
157
142
  return { key, type };
158
143
  }
159
144
  function withdraw(token, store) {
160
145
  var _a, _b, _c, _d, _e;
161
146
  const core = target(store);
162
- return (_e = (_d = (_c = (_b = (_a = import_hamt_plus.default.get(token.key, core.atoms)) != null ? _a : import_hamt_plus.default.get(token.key, core.selectors)) != null ? _b : import_hamt_plus.default.get(token.key, core.readonlySelectors)) != null ? _c : import_hamt_plus.default.get(token.key, core.transactions)) != null ? _d : import_hamt_plus.default.get(token.key, core.timelines)) != null ? _e : null;
147
+ return (_e = (_d = (_c = (_b = (_a = core.atoms.get(token.key)) != null ? _a : core.selectors.get(token.key)) != null ? _b : core.readonlySelectors.get(token.key)) != null ? _c : core.transactions.get(token.key)) != null ? _d : core.timelines.get(token.key)) != null ? _e : null;
163
148
  }
164
149
  function deposit(state) {
165
150
  return __spreadValues({
@@ -202,12 +187,6 @@ var isSelectorDefault = (key, store = IMPLICIT.STORE) => {
202
187
  return roots.every((root) => isAtomDefault(root.key, store));
203
188
  };
204
189
 
205
- // src/internal/operation.ts
206
- var import_hamt_plus3 = __toESM(require("hamt_plus"));
207
-
208
- // src/internal/store.ts
209
- var import_hamt_plus2 = __toESM(require("hamt_plus"));
210
-
211
190
  // ../anvl/src/function/index.ts
212
191
  var doNothing = () => void 0;
213
192
  var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing instanceof Function ? nextVersionOfThing(
@@ -215,62 +194,8 @@ var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing insta
215
194
  ) : nextVersionOfThing;
216
195
  var pass = (...params) => (fn) => fn(...params);
217
196
 
218
- // ../../node_modules/.pnpm/fp-ts@2.16.0/node_modules/fp-ts/es6/function.js
219
- function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
220
- switch (arguments.length) {
221
- case 1:
222
- return a;
223
- case 2:
224
- return ab(a);
225
- case 3:
226
- return bc(ab(a));
227
- case 4:
228
- return cd(bc(ab(a)));
229
- case 5:
230
- return de(cd(bc(ab(a))));
231
- case 6:
232
- return ef(de(cd(bc(ab(a)))));
233
- case 7:
234
- return fg(ef(de(cd(bc(ab(a))))));
235
- case 8:
236
- return gh(fg(ef(de(cd(bc(ab(a)))))));
237
- case 9:
238
- return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
239
- default: {
240
- var ret = arguments[0];
241
- for (var i = 1; i < arguments.length; i++) {
242
- ret = arguments[i](ret);
243
- }
244
- return ret;
245
- }
246
- }
247
- }
248
-
249
- // ../../node_modules/.pnpm/fp-ts@2.16.0/node_modules/fp-ts/es6/string.js
250
- var Eq = {
251
- equals: function(first, second) {
252
- return first === second;
253
- }
254
- };
255
- var Semigroup = {
256
- concat: function(first, second) {
257
- return first + second;
258
- }
259
- };
260
- var empty = "";
261
- var Monoid = {
262
- concat: Semigroup.concat,
263
- empty
264
- };
265
- var Ord = {
266
- equals: Eq.equals,
267
- compare: function(first, second) {
268
- return first < second ? -1 : first > second ? 1 : 0;
269
- }
270
- };
271
- var isString = function(u) {
272
- return typeof u === "string";
273
- };
197
+ // ../anvl/src/join/core-relation-data.ts
198
+ var import_string = require("fp-ts/string");
274
199
 
275
200
  // ../anvl/src/array/venn.ts
276
201
  var includesAll = (items) => (array) => {
@@ -291,6 +216,9 @@ var addTo = (a) => (x) => a.includes(x) ? a : [...a, x];
291
216
  var isEmptyArray = (input) => Array.isArray(input) && input.length === 0;
292
217
  var isOneOf = (...args) => (input) => args.includes(input);
293
218
 
219
+ // ../anvl/src/object/refinement.ts
220
+ var import_function2 = require("fp-ts/function");
221
+
294
222
  // ../anvl/src/object/access.ts
295
223
  var access = (k) => Object.assign((obj) => obj[k], {
296
224
  in: (obj) => obj[k]
@@ -301,7 +229,8 @@ var recordToEntries = (obj) => Object.entries(obj);
301
229
  var entriesToRecord = (entries) => Object.fromEntries(entries);
302
230
 
303
231
  // ../anvl/src/object/mapObject.ts
304
- var mapObject = (obj, fn) => pipe(
232
+ var import_function = require("fp-ts/function");
233
+ var mapObject = (obj, fn) => (0, import_function.pipe)(
305
234
  obj,
306
235
  recordToEntries,
307
236
  map(([key, val]) => [key, fn(val, key)]),
@@ -323,14 +252,14 @@ var hasProperties = (isValue, options = { allowExtraProperties: false }) => {
323
252
  isValue
324
253
  ).map(([k, v]) => String(k) + `:` + v.name).join(`,`)}}`;
325
254
  const _ = {
326
- [name]: (input) => isPlainObject(input) && pipe(
255
+ [name]: (input) => isPlainObject(input) && (0, import_function2.pipe)(
327
256
  isValue,
328
257
  Object.entries,
329
258
  every(([key, val]) => key in input || val(void 0))
330
- ) && pipe(
259
+ ) && (0, import_function2.pipe)(
331
260
  input,
332
261
  mob(
333
- (val, key) => pipe(
262
+ (val, key) => (0, import_function2.pipe)(
334
263
  isValue,
335
264
  access(key),
336
265
  ifNullish(() => options.allowExtraProperties),
@@ -410,8 +339,8 @@ var isRelationData = ({
410
339
  isContent
411
340
  } = {}) => (input) => {
412
341
  return hasExactProperties({
413
- contents: isContent ? isRecord(isString, isContent) : hasExactProperties({}),
414
- relations: isRecord(isString, isArray(isString)),
342
+ contents: isContent ? isRecord(import_string.isString, isContent) : hasExactProperties({}),
343
+ relations: isRecord(import_string.isString, isArray(import_string.isString)),
415
344
  relationType: isRelationType,
416
345
  a: isLiteral(a),
417
346
  b: isLiteral(b)
@@ -448,6 +377,9 @@ var makeJsonInterface = (join, ...params) => {
448
377
  };
449
378
  };
450
379
 
380
+ // ../anvl/src/join/relation-contents.ts
381
+ var import_function6 = require("fp-ts/function");
382
+
451
383
  // ../anvl/src/join/relation-record.ts
452
384
  var getRelationEntries = (relationMap, idA) => getRelatedIds(relationMap, idA).map((idB) => [
453
385
  idB,
@@ -455,7 +387,12 @@ var getRelationEntries = (relationMap, idA) => getRelatedIds(relationMap, idA).m
455
387
  ]);
456
388
  var getRelationRecord = (relationMap, id) => Object.fromEntries(getRelationEntries(relationMap, id));
457
389
 
390
+ // ../anvl/src/join/remove-relation.ts
391
+ var import_function5 = require("fp-ts/function");
392
+ var import_string2 = require("fp-ts/string");
393
+
458
394
  // ../anvl/src/object/index.ts
395
+ var import_function4 = require("fp-ts/function");
459
396
  var treeShake = (shouldDiscard = isUndefined) => (obj) => {
460
397
  const newObj = {};
461
398
  const entries = Object.entries(obj);
@@ -472,7 +409,7 @@ var split = (separator) => (str) => str.split(separator);
472
409
  var removeSpecific = (current, idA, idB) => {
473
410
  const isIdForRemoval = isOneOf(idA, idB);
474
411
  return __spreadProps(__spreadValues({}, current), {
475
- relations: pipe(
412
+ relations: (0, import_function5.pipe)(
476
413
  current.relations,
477
414
  recordToEntries,
478
415
  map(([id, relations]) => [
@@ -482,17 +419,17 @@ var removeSpecific = (current, idA, idB) => {
482
419
  entriesToRecord,
483
420
  treeShake(isEmptyArray)
484
421
  ),
485
- contents: pipe(
422
+ contents: (0, import_function5.pipe)(
486
423
  current.contents,
487
424
  treeShake(
488
- (_, key) => isString(key) && pipe(key, split(`/`), comprises([idA, idB]))
425
+ (_, key) => (0, import_string2.isString)(key) && (0, import_function5.pipe)(key, split(`/`), comprises([idA, idB]))
489
426
  )
490
427
  )
491
428
  });
492
429
  };
493
430
  var removeAll = (current, idToRemove) => {
494
431
  const next = __spreadProps(__spreadValues({}, current), {
495
- relations: pipe(
432
+ relations: (0, import_function5.pipe)(
496
433
  current.relations,
497
434
  recordToEntries,
498
435
  map(([id, relations]) => [
@@ -502,10 +439,10 @@ var removeAll = (current, idToRemove) => {
502
439
  entriesToRecord,
503
440
  treeShake((val, key) => key === idToRemove || isEmptyArray(val))
504
441
  ),
505
- contents: pipe(
442
+ contents: (0, import_function5.pipe)(
506
443
  current.contents,
507
444
  treeShake(
508
- (_, key) => isString(key) && key.split(`/`).includes(idToRemove)
445
+ (_, key) => (0, import_string2.isString)(key) && key.split(`/`).includes(idToRemove)
509
446
  )
510
447
  )
511
448
  });
@@ -587,7 +524,7 @@ var getRelations = (relationMap, id) => getRelationEntries(relationMap, id).map(
587
524
  var setRelations = (current, subject, relations) => {
588
525
  const idA = subject[current.a];
589
526
  const idB = subject[current.b];
590
- return pipe(
527
+ return (0, import_function6.pipe)(
591
528
  current,
592
529
  (relationData) => {
593
530
  const relatedIds = getRelatedIds(current, idA);
@@ -702,24 +639,25 @@ var Join = class _Join {
702
639
  // src/internal/store.ts
703
640
  var createStore = (name, store = null) => {
704
641
  var _a;
705
- const copiedStore = __spreadProps(__spreadValues({}, store != null ? store : (() => ({
642
+ const created = __spreadProps(__spreadValues({}, store != null ? store : (() => ({
706
643
  atomsThatAreDefault: /* @__PURE__ */ new Set(),
707
644
  selectorAtoms: new Join({ relationType: `n:n` }).from(`selectorKey`).to(`atomKey`),
708
- selectorGraph: new Join({ relationType: `n:n` }),
709
- valueMap: import_hamt_plus2.default.make()
645
+ selectorGraph: new Join({ relationType: `n:n` })
710
646
  }))()), {
711
- atoms: import_hamt_plus2.default.make(),
712
- readonlySelectors: import_hamt_plus2.default.make(),
713
- selectors: import_hamt_plus2.default.make(),
714
- transactions: import_hamt_plus2.default.make(),
715
- timelines: import_hamt_plus2.default.make(),
647
+ valueMap: new Map(store == null ? void 0 : store.valueMap),
648
+ atoms: /* @__PURE__ */ new Map(),
649
+ readonlySelectors: /* @__PURE__ */ new Map(),
650
+ selectors: /* @__PURE__ */ new Map(),
651
+ transactions: /* @__PURE__ */ new Map(),
652
+ timelines: /* @__PURE__ */ new Map(),
716
653
  timelineAtoms: new Join({ relationType: `1:n` }).from(`timelineKey`).to(`atomKey`),
717
- subject: __spreadValues({
654
+ subject: {
718
655
  atomCreation: new Subject(),
719
656
  selectorCreation: new Subject(),
720
657
  transactionCreation: new Subject(),
721
- timelineCreation: new Subject()
722
- }, store == null ? void 0 : store.subject),
658
+ timelineCreation: new Subject(),
659
+ operationStatus: new Subject()
660
+ },
723
661
  operation: __spreadValues({
724
662
  open: false
725
663
  }, store == null ? void 0 : store.operation),
@@ -737,21 +675,21 @@ var createStore = (name, store = null) => {
737
675
  });
738
676
  store == null ? void 0 : store.atoms.forEach((atom2) => {
739
677
  const copiedAtom = __spreadProps(__spreadValues({}, atom2), { subject: new Subject() });
740
- copiedStore.atoms = import_hamt_plus2.default.set(atom2.key, copiedAtom, copiedStore.atoms);
678
+ created.atoms.set(atom2.key, copiedAtom);
741
679
  });
742
680
  store == null ? void 0 : store.readonlySelectors.forEach((selector2) => {
743
- selector2.install(copiedStore);
681
+ selector2.install(created);
744
682
  });
745
683
  store == null ? void 0 : store.selectors.forEach((selector2) => {
746
- selector2.install(copiedStore);
684
+ selector2.install(created);
747
685
  });
748
686
  store == null ? void 0 : store.transactions.forEach((tx) => {
749
- tx.install(copiedStore);
687
+ tx.install(created);
750
688
  });
751
689
  store == null ? void 0 : store.timelines.forEach((timeline2) => {
752
- timeline2.install(copiedStore);
690
+ timeline2.install(created);
753
691
  });
754
- return copiedStore;
692
+ return created;
755
693
  };
756
694
  var IMPLICIT = {
757
695
  STORE_INTERNAL: void 0,
@@ -779,7 +717,7 @@ var openOperation = (token, store) => {
779
717
  core.operation = {
780
718
  open: true,
781
719
  done: /* @__PURE__ */ new Set(),
782
- prev: store.valueMap,
720
+ prev: new Map(store.valueMap),
783
721
  time: Date.now(),
784
722
  token
785
723
  };
@@ -792,6 +730,7 @@ var closeOperation = (store) => {
792
730
  const core = target(store);
793
731
  core.operation = { open: false };
794
732
  (_a = store.config.logger) == null ? void 0 : _a.info(`\u{1F534} operation done`);
733
+ store.subject.operationStatus.next(core.operation);
795
734
  };
796
735
  var isDone = (key, store = IMPLICIT.STORE) => {
797
736
  var _a;
@@ -822,43 +761,38 @@ var recallState = (state, store = IMPLICIT.STORE) => {
822
761
  (_a = store.config.logger) == null ? void 0 : _a.warn(
823
762
  `recall called outside of an operation. This is probably a bug.`
824
763
  );
825
- return import_hamt_plus3.default.get(state.key, core.valueMap);
764
+ return core.valueMap.get(state.key);
826
765
  }
827
- return import_hamt_plus3.default.get(state.key, core.operation.prev);
766
+ return core.operation.prev.get(state.key);
828
767
  };
829
768
  var cacheValue = (key, value, store = IMPLICIT.STORE) => {
830
769
  const core = target(store);
831
- core.valueMap = import_hamt_plus3.default.set(key, value, core.valueMap);
770
+ core.valueMap.set(key, value);
832
771
  };
833
772
  var evictCachedValue = (key, store = IMPLICIT.STORE) => {
834
773
  const core = target(store);
835
- core.valueMap = import_hamt_plus3.default.remove(key, core.valueMap);
774
+ core.valueMap.delete(key);
836
775
  };
837
- var readCachedValue = (key, store = IMPLICIT.STORE) => import_hamt_plus3.default.get(key, target(store).valueMap);
838
- var isValueCached = (key, store = IMPLICIT.STORE) => import_hamt_plus3.default.has(key, target(store).valueMap);
776
+ var readCachedValue = (key, store = IMPLICIT.STORE) => target(store).valueMap.get(key);
777
+ var isValueCached = (key, store = IMPLICIT.STORE) => target(store).valueMap.has(key);
839
778
  var storeAtom = (atom2, store = IMPLICIT.STORE) => {
840
779
  const core = target(store);
841
- core.atoms = import_hamt_plus3.default.set(atom2.key, atom2, core.atoms);
780
+ core.atoms.set(atom2.key, atom2);
842
781
  };
843
782
  var storeSelector = (selector2, store = IMPLICIT.STORE) => {
844
783
  const core = target(store);
845
- core.selectors = import_hamt_plus3.default.set(selector2.key, selector2, core.selectors);
784
+ core.selectors.set(selector2.key, selector2);
846
785
  };
847
786
  var storeReadonlySelector = (selector2, store = IMPLICIT.STORE) => {
848
787
  const core = target(store);
849
- core.readonlySelectors = import_hamt_plus3.default.set(
850
- selector2.key,
851
- selector2,
852
- core.readonlySelectors
853
- );
788
+ core.readonlySelectors.set(selector2.key, selector2);
854
789
  };
855
790
  var hasKeyBeenUsed = (key, store = IMPLICIT.STORE) => {
856
791
  const core = target(store);
857
- return import_hamt_plus3.default.has(key, core.atoms) || import_hamt_plus3.default.has(key, core.selectors) || import_hamt_plus3.default.has(key, core.readonlySelectors);
792
+ return core.atoms.has(key) || core.selectors.has(key) || core.readonlySelectors.has(key);
858
793
  };
859
794
 
860
795
  // src/internal/transaction-internal.ts
861
- var import_hamt_plus4 = __toESM(require("hamt_plus"));
862
796
  function transaction__INTERNAL(options, store = IMPLICIT.STORE) {
863
797
  const newTransaction = {
864
798
  key: options.key,
@@ -886,11 +820,7 @@ function transaction__INTERNAL(options, store = IMPLICIT.STORE) {
886
820
  subject: new Subject()
887
821
  };
888
822
  const core = target(store);
889
- core.transactions = import_hamt_plus4.default.set(
890
- newTransaction.key,
891
- newTransaction,
892
- core.transactions
893
- );
823
+ core.transactions.set(newTransaction.key, newTransaction);
894
824
  const token = deposit(newTransaction);
895
825
  store.subject.transactionCreation.next(token);
896
826
  return token;
@@ -901,12 +831,13 @@ var target = (store = IMPLICIT.STORE) => store.transactionStatus.phase === `buil
901
831
  function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
902
832
  var _a, _b, _c;
903
833
  const core = target(store);
904
- if (hasKeyBeenUsed(options.key, store)) {
834
+ const existing = core.atoms.get(options.key);
835
+ if (existing) {
905
836
  (_b = (_a = store.config.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(
906
837
  _a,
907
838
  `Key "${options.key}" already exists in the store.`
908
839
  );
909
- return deposit(core.atoms.get(options.key));
840
+ return deposit(existing);
910
841
  }
911
842
  const subject = new Subject();
912
843
  const newAtom = __spreadValues(__spreadProps(__spreadValues({}, options), {
@@ -914,7 +845,7 @@ function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
914
845
  type: `atom`
915
846
  }), family && { family });
916
847
  const initialValue = options.default instanceof Function ? options.default() : options.default;
917
- core.atoms = import_hamt_plus5.default.set(newAtom.key, newAtom, core.atoms);
848
+ core.atoms.set(newAtom.key, newAtom);
918
849
  markAtomAsDefault(options.key, store);
919
850
  cacheValue(options.key, initialValue, store);
920
851
  const token = deposit(newAtom);
@@ -929,6 +860,7 @@ function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
929
860
  }
930
861
 
931
862
  // ../anvl/src/json/index.ts
863
+ var import_function8 = require("fp-ts/function");
932
864
  var stringifyJson = (json) => JSON.stringify(json);
933
865
 
934
866
  // src/internal/families-internal.ts
@@ -1023,125 +955,7 @@ function selectorFamily__INTERNAL(options, store = IMPLICIT.STORE) {
1023
955
  );
1024
956
  }
1025
957
 
1026
- // src/internal/meta/index.ts
1027
- var meta_exports = {};
1028
- __export(meta_exports, {
1029
- attachMetaAtoms: () => attachMetaAtoms,
1030
- attachMetaSelectors: () => attachMetaSelectors,
1031
- attachMetaState: () => attachMetaState
1032
- });
1033
-
1034
- // src/internal/meta/meta-state.ts
1035
- var attachMetaAtoms = (store = IMPLICIT.STORE) => {
1036
- const atomTokenIndexState__INTERNAL = atom({
1037
- key: `\u{1F441}\u200D\u{1F5E8}_atom_token_index__INTERNAL`,
1038
- default: () => [...store.atoms].reduce((acc, [key]) => {
1039
- acc[key] = { key, type: `atom` };
1040
- return acc;
1041
- }, {}),
1042
- effects: [
1043
- ({ setSelf }) => {
1044
- store.subject.atomCreation.subscribe((atomToken) => {
1045
- if (store.operation.open) {
1046
- return;
1047
- }
1048
- setSelf((state) => {
1049
- const { key, family } = atomToken;
1050
- if (family) {
1051
- const { key: familyKey, subKey } = family;
1052
- const current = state[familyKey];
1053
- if (current === void 0 || `familyMembers` in current) {
1054
- const familyKeyState = current || {
1055
- key: familyKey,
1056
- familyMembers: {}
1057
- };
1058
- return __spreadProps(__spreadValues({}, state), {
1059
- [familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
1060
- familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
1061
- [subKey]: atomToken
1062
- })
1063
- })
1064
- });
1065
- }
1066
- }
1067
- return __spreadProps(__spreadValues({}, state), {
1068
- [key]: atomToken
1069
- });
1070
- });
1071
- });
1072
- }
1073
- ]
1074
- });
1075
- return selector({
1076
- key: `\u{1F441}\u200D\u{1F5E8}_atom_token_index`,
1077
- get: ({ get }) => get(atomTokenIndexState__INTERNAL)
1078
- });
1079
- };
1080
- var attachMetaSelectors = (store = IMPLICIT.STORE) => {
1081
- const readonlySelectorTokenIndexState__INTERNAL = atom({
1082
- key: `\u{1F441}\u200D\u{1F5E8}_selector_token_index__INTERNAL`,
1083
- default: () => Object.assign(
1084
- [...store.readonlySelectors].reduce((acc, [key]) => {
1085
- acc[key] = { key, type: `readonly_selector` };
1086
- return acc;
1087
- }, {}),
1088
- [...store.selectors].reduce((acc, [key]) => {
1089
- acc[key] = { key, type: `selector` };
1090
- return acc;
1091
- }, {})
1092
- ),
1093
- effects: [
1094
- ({ setSelf }) => {
1095
- store.subject.selectorCreation.subscribe((selectorToken) => {
1096
- if (store.operation.open) {
1097
- return;
1098
- }
1099
- setSelf((state) => {
1100
- const { key, family } = selectorToken;
1101
- if (family) {
1102
- const { key: familyKey, subKey } = family;
1103
- const current = state[familyKey];
1104
- if (current === void 0 || `familyMembers` in current) {
1105
- const familyKeyState = current || {
1106
- key: familyKey,
1107
- familyMembers: {}
1108
- };
1109
- return __spreadProps(__spreadValues({}, state), {
1110
- [familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
1111
- familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
1112
- [subKey]: selectorToken
1113
- })
1114
- })
1115
- });
1116
- }
1117
- }
1118
- return __spreadProps(__spreadValues({}, state), {
1119
- [key]: selectorToken
1120
- });
1121
- });
1122
- });
1123
- }
1124
- ]
1125
- });
1126
- return selector({
1127
- key: `\u{1F441}\u200D\u{1F5E8}_selector_token_index`,
1128
- get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL)
1129
- });
1130
- };
1131
-
1132
- // src/internal/meta/attach-meta.ts
1133
- var attachMetaState = (store = IMPLICIT.STORE) => {
1134
- return {
1135
- atomTokenIndexState: attachMetaAtoms(store),
1136
- selectorTokenIndexState: attachMetaSelectors(store)
1137
- };
1138
- };
1139
-
1140
- // src/internal/selector-internal.ts
1141
- var import_hamt_plus9 = __toESM(require("hamt_plus"));
1142
-
1143
958
  // src/internal/selector/create-read-write-selector.ts
1144
- var import_hamt_plus6 = __toESM(require("hamt_plus"));
1145
959
  var createReadWriteSelector = (options, family, store, core) => {
1146
960
  var _a;
1147
961
  const subject = new Subject();
@@ -1153,8 +967,14 @@ var createReadWriteSelector = (options, family, store, core) => {
1153
967
  };
1154
968
  const setSelf = (next) => {
1155
969
  var _a2;
1156
- (_a2 = store.config.logger) == null ? void 0 : _a2.info(` <- "${options.key}" became`, next);
1157
970
  const oldValue = getSelf();
971
+ (_a2 = store.config.logger) == null ? void 0 : _a2.info(
972
+ ` <- "${options.key}" went (`,
973
+ oldValue,
974
+ `->`,
975
+ next,
976
+ `)`
977
+ );
1158
978
  const newValue = become(next)(oldValue);
1159
979
  cacheValue(options.key, newValue, store);
1160
980
  markDone(options.key, store);
@@ -1170,7 +990,7 @@ var createReadWriteSelector = (options, family, store, core) => {
1170
990
  set: setSelf,
1171
991
  type: `selector`
1172
992
  }), family && { family });
1173
- core.selectors = import_hamt_plus6.default.set(options.key, mySelector, core.selectors);
993
+ core.selectors.set(options.key, mySelector);
1174
994
  const initialValue = getSelf();
1175
995
  (_a = store.config.logger) == null ? void 0 : _a.info(` \u2728 "${options.key}" =`, initialValue);
1176
996
  const token = {
@@ -1182,9 +1002,6 @@ var createReadWriteSelector = (options, family, store, core) => {
1182
1002
  return token;
1183
1003
  };
1184
1004
 
1185
- // src/internal/selector/create-readonly-selector.ts
1186
- var import_hamt_plus8 = __toESM(require("hamt_plus"));
1187
-
1188
1005
  // src/internal/selector/lookup-selector-sources.ts
1189
1006
  var lookupSelectorSources = (key, store) => target(store).selectorGraph.getRelations(key).filter(({ source }) => source !== key).map(({ source }) => lookup(source, store));
1190
1007
 
@@ -1244,7 +1061,6 @@ var updateSelectorAtoms = (selectorKey, dependency, store) => {
1244
1061
  };
1245
1062
 
1246
1063
  // src/internal/set.ts
1247
- var import_hamt_plus7 = __toESM(require("hamt_plus"));
1248
1064
  var evictDownStream = (state, store = IMPLICIT.STORE) => {
1249
1065
  var _a, _b;
1250
1066
  const core = target(store);
@@ -1263,7 +1079,7 @@ var evictDownStream = (state, store = IMPLICIT.STORE) => {
1263
1079
  (_a2 = store.config.logger) == null ? void 0 : _a2.info(` || ${stateKey} already done`);
1264
1080
  return;
1265
1081
  }
1266
- const state2 = (_b2 = import_hamt_plus7.default.get(stateKey, core.selectors)) != null ? _b2 : import_hamt_plus7.default.get(stateKey, core.readonlySelectors);
1082
+ const state2 = (_b2 = core.selectors.get(stateKey)) != null ? _b2 : core.readonlySelectors.get(stateKey);
1267
1083
  if (!state2) {
1268
1084
  (_c = store.config.logger) == null ? void 0 : _c.info(
1269
1085
  ` || ${stateKey} is an atom, and can't be downstream`
@@ -1373,11 +1189,7 @@ var createReadonlySelector = (options, family, store, core) => {
1373
1189
  get: getSelf,
1374
1190
  type: `readonly_selector`
1375
1191
  }), family && { family });
1376
- core.readonlySelectors = import_hamt_plus8.default.set(
1377
- options.key,
1378
- readonlySelector,
1379
- core.readonlySelectors
1380
- );
1192
+ core.readonlySelectors.set(options.key, readonlySelector);
1381
1193
  const initialValue = getSelf();
1382
1194
  (_a = store.config.logger) == null ? void 0 : _a.info(` \u2728 "${options.key}" =`, initialValue);
1383
1195
  const token = {
@@ -1393,7 +1205,7 @@ var createReadonlySelector = (options, family, store, core) => {
1393
1205
  function selector__INTERNAL(options, family, store = IMPLICIT.STORE) {
1394
1206
  var _a;
1395
1207
  const core = target(store);
1396
- if (import_hamt_plus9.default.has(options.key, core.selectors)) {
1208
+ if (core.selectors.has(options.key)) {
1397
1209
  (_a = store.config.logger) == null ? void 0 : _a.error(
1398
1210
  `Key "${options.key}" already exists in the store.`
1399
1211
  );
@@ -1477,7 +1289,13 @@ var subscribeToRootAtoms = (state, store) => {
1477
1289
  );
1478
1290
  const oldValue = recallState(state, store);
1479
1291
  const newValue = getState__INTERNAL(state, store);
1480
- (_b = store.config.logger) == null ? void 0 : _b.info(` <- ${state.key} became`, newValue);
1292
+ (_b = store.config.logger) == null ? void 0 : _b.info(
1293
+ ` <- "${state.key}" went (`,
1294
+ oldValue,
1295
+ `->`,
1296
+ newValue,
1297
+ `)`
1298
+ );
1481
1299
  state.subject.next({ newValue, oldValue });
1482
1300
  });
1483
1301
  });
@@ -1519,6 +1337,7 @@ var redo__INTERNAL = (token, store = IMPLICIT.STORE) => {
1519
1337
  }
1520
1338
  }
1521
1339
  ++timelineData.at;
1340
+ timelineData.subject.next(`redo`);
1522
1341
  timelineData.timeTraveling = false;
1523
1342
  (_d = store.config.logger) == null ? void 0 : _d.info(
1524
1343
  `\u23F9\uFE0F "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
@@ -1558,15 +1377,13 @@ var undo__INTERNAL = (token, store = IMPLICIT.STORE) => {
1558
1377
  break;
1559
1378
  }
1560
1379
  }
1380
+ timelineData.subject.next(`undo`);
1561
1381
  timelineData.timeTraveling = false;
1562
1382
  (_d = store.config.logger) == null ? void 0 : _d.info(
1563
1383
  `\u23F9\uFE0F "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
1564
1384
  );
1565
1385
  };
1566
1386
 
1567
- // src/internal/timeline-internal.ts
1568
- var import_hamt_plus10 = __toESM(require("hamt_plus"));
1569
-
1570
1387
  // src/internal/timeline/add-atom-to-timeline.ts
1571
1388
  var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1572
1389
  const atom2 = withdraw(atomToken, store);
@@ -1596,9 +1413,6 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1596
1413
  `Timeline "${tl.key}" has a selectorTime, but no history. This is most likely a bug in AtomIO.`
1597
1414
  );
1598
1415
  }
1599
- if (mostRecentUpdate.type === `selector_update`) {
1600
- tl.subject.next(mostRecentUpdate);
1601
- }
1602
1416
  }
1603
1417
  if (currentTransactionKey && store.transactionStatus.phase === `applying`) {
1604
1418
  const currentTransaction = withdraw(
@@ -1619,6 +1433,7 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1619
1433
  tl.transactionKey = currentTransactionKey;
1620
1434
  const subscription = currentTransaction.subject.subscribe((update2) => {
1621
1435
  var _a2;
1436
+ subscription.unsubscribe();
1622
1437
  if (tl.timeTraveling === false && currentTransactionTime) {
1623
1438
  if (tl.at !== tl.history.length) {
1624
1439
  tl.history.splice(tl.at);
@@ -1632,10 +1447,9 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1632
1447
  )
1633
1448
  });
1634
1449
  tl.history.push(timelineTransactionUpdate);
1450
+ tl.at = tl.history.length;
1635
1451
  tl.subject.next(timelineTransactionUpdate);
1636
1452
  }
1637
- tl.at = tl.history.length;
1638
- subscription.unsubscribe();
1639
1453
  tl.transactionKey = null;
1640
1454
  (_a2 = store.config.logger) == null ? void 0 : _a2.info(
1641
1455
  `\u231B timeline "${tl.key}" got a transaction_update "${update2.key}"`
@@ -1643,29 +1457,29 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1643
1457
  });
1644
1458
  }
1645
1459
  } else if (currentSelectorKey && currentSelectorTime) {
1460
+ let latestUpdate = tl.history.at(-1);
1646
1461
  if (currentSelectorTime !== tl.selectorTime) {
1647
- const newSelectorUpdate = {
1462
+ latestUpdate = {
1648
1463
  type: `selector_update`,
1649
1464
  timestamp: currentSelectorTime,
1650
1465
  key: currentSelectorKey,
1651
1466
  atomUpdates: []
1652
1467
  };
1653
- newSelectorUpdate.atomUpdates.push(__spreadValues({
1468
+ latestUpdate.atomUpdates.push(__spreadValues({
1654
1469
  key: atom2.key,
1655
1470
  type: `atom_update`
1656
1471
  }, update));
1657
1472
  if (tl.at !== tl.history.length) {
1658
1473
  tl.history.splice(tl.at);
1659
1474
  }
1660
- tl.history.push(newSelectorUpdate);
1475
+ tl.history.push(latestUpdate);
1661
1476
  (_c = store.config.logger) == null ? void 0 : _c.info(
1662
1477
  `\u231B timeline "${tl.key}" got a selector_update "${currentSelectorKey}" with`,
1663
- newSelectorUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key)
1478
+ latestUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key)
1664
1479
  );
1665
1480
  tl.at = tl.history.length;
1666
1481
  tl.selectorTime = currentSelectorTime;
1667
1482
  } else {
1668
- const latestUpdate = tl.history.at(-1);
1669
1483
  if ((latestUpdate == null ? void 0 : latestUpdate.type) === `selector_update`) {
1670
1484
  latestUpdate.atomUpdates.push(__spreadValues({
1671
1485
  key: atom2.key,
@@ -1677,6 +1491,8 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1677
1491
  );
1678
1492
  }
1679
1493
  }
1494
+ if (latestUpdate)
1495
+ tl.subject.next(latestUpdate);
1680
1496
  } else {
1681
1497
  const timestamp = Date.now();
1682
1498
  tl.selectorTime = null;
@@ -1693,7 +1509,7 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1693
1509
  tl.history.push(atomUpdate);
1694
1510
  tl.subject.next(atomUpdate);
1695
1511
  (_e = store.config.logger) == null ? void 0 : _e.info(
1696
- `\u231B timeline "${tl.key}" got a state_update to "${atom2.key}"`
1512
+ `\u231B timeline "${tl.key}" got an atom_update to "${atom2.key}"`
1697
1513
  );
1698
1514
  tl.at = tl.history.length;
1699
1515
  }
@@ -1749,7 +1565,7 @@ function timeline__INTERNAL(options, store = IMPLICIT.STORE, data = null) {
1749
1565
  timelineKey: options.key
1750
1566
  });
1751
1567
  }
1752
- store.timelines = import_hamt_plus10.default.set(options.key, tl, store.timelines);
1568
+ store.timelines.set(options.key, tl);
1753
1569
  const token = {
1754
1570
  key: options.key,
1755
1571
  type: `timeline`
@@ -1772,7 +1588,6 @@ var abortTransaction = (store) => {
1772
1588
  };
1773
1589
 
1774
1590
  // src/internal/transaction/apply-transaction.ts
1775
- var import_hamt_plus11 = __toESM(require("hamt_plus"));
1776
1591
  var applyTransaction = (output, store) => {
1777
1592
  var _a, _b, _c, _d;
1778
1593
  if (store.transactionStatus.phase !== `building`) {
@@ -1789,10 +1604,15 @@ var applyTransaction = (output, store) => {
1789
1604
  const { atomUpdates } = store.transactionStatus;
1790
1605
  for (const { key, newValue } of atomUpdates) {
1791
1606
  const token = { key, type: `atom` };
1792
- if (!import_hamt_plus11.default.has(token.key, store.valueMap)) {
1793
- const newAtom = import_hamt_plus11.default.get(token.key, store.transactionStatus.core.atoms);
1794
- store.atoms = import_hamt_plus11.default.set(newAtom.key, newAtom, store.atoms);
1795
- store.valueMap = import_hamt_plus11.default.set(newAtom.key, newAtom.default, store.valueMap);
1607
+ if (!store.valueMap.has(token.key)) {
1608
+ const newAtom = store.transactionStatus.core.atoms.get(token.key);
1609
+ if (!newAtom) {
1610
+ throw new Error(
1611
+ `Absurd Error: Atom "${token.key}" not found while copying updates from transaction "${store.transactionStatus.key}" to store "${store.config.name}"`
1612
+ );
1613
+ }
1614
+ store.atoms.set(newAtom.key, newAtom);
1615
+ store.valueMap.set(newAtom.key, newAtom.default);
1796
1616
  (_c = store.config.logger) == null ? void 0 : _c.info(`\u{1F527}`, `add atom "${newAtom.key}"`);
1797
1617
  }
1798
1618
  setState(token, newValue, store);
@@ -1824,17 +1644,17 @@ var buildTransaction = (key, params, store) => {
1824
1644
  phase: `building`,
1825
1645
  time: Date.now(),
1826
1646
  core: {
1827
- atoms: store.atoms,
1647
+ atoms: new Map(store.atoms),
1828
1648
  atomsThatAreDefault: store.atomsThatAreDefault,
1829
1649
  operation: { open: false },
1830
- readonlySelectors: store.readonlySelectors,
1831
- timelines: store.timelines,
1650
+ readonlySelectors: new Map(store.readonlySelectors),
1651
+ timelines: new Map(store.timelines),
1832
1652
  timelineAtoms: store.timelineAtoms,
1833
- transactions: store.transactions,
1653
+ transactions: new Map(store.transactions),
1834
1654
  selectorAtoms: store.selectorAtoms,
1835
1655
  selectorGraph: store.selectorGraph,
1836
- selectors: store.selectors,
1837
- valueMap: store.valueMap
1656
+ selectors: new Map(store.selectors),
1657
+ valueMap: new Map(store.valueMap)
1838
1658
  },
1839
1659
  atomUpdates: [],
1840
1660
  params,