atom.io 0.25.6 → 0.27.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 (108) hide show
  1. package/data/dist/index.d.ts +3 -3
  2. package/data/dist/index.js +33 -25
  3. package/data/package.json +1 -4
  4. package/data/src/dict.ts +3 -3
  5. package/dist/chunk-AK23DRMD.js +21 -0
  6. package/dist/{chunk-HYXKCFVY.js → chunk-IBTHB2PI.js} +59 -60
  7. package/dist/{chunk-MR5NETHW.js → chunk-IW6WYRS7.js} +4 -5
  8. package/dist/chunk-XWL6SNVU.js +7 -0
  9. package/dist/index.d.ts +32 -54
  10. package/dist/index.js +33 -21
  11. package/ephemeral/dist/index.d.ts +7 -7
  12. package/ephemeral/dist/index.js +1 -1
  13. package/ephemeral/package.json +1 -4
  14. package/ephemeral/src/find-state.ts +7 -7
  15. package/eslint-plugin/dist/index.js +7 -8
  16. package/eslint-plugin/package.json +1 -4
  17. package/immortal/dist/index.d.ts +7 -7
  18. package/immortal/dist/index.js +1 -1
  19. package/immortal/package.json +1 -4
  20. package/immortal/src/seek-state.ts +8 -8
  21. package/internal/dist/index.d.ts +56 -59
  22. package/internal/dist/index.js +178 -170
  23. package/internal/package.json +1 -4
  24. package/internal/src/families/create-atom-family.ts +4 -4
  25. package/internal/src/families/create-readonly-selector-family.ts +2 -2
  26. package/internal/src/families/create-regular-atom-family.ts +2 -2
  27. package/internal/src/families/create-selector-family.ts +4 -4
  28. package/internal/src/families/create-writable-selector-family.ts +2 -2
  29. package/internal/src/families/dispose-from-store.ts +3 -7
  30. package/internal/src/families/find-in-store.ts +9 -9
  31. package/internal/src/families/init-family-member.ts +25 -37
  32. package/internal/src/families/seek-in-store.ts +11 -10
  33. package/internal/src/get-state/get-from-store.ts +3 -3
  34. package/internal/src/molecule/grow-molecule-in-store.ts +9 -9
  35. package/internal/src/mutable/index.ts +0 -1
  36. package/internal/src/mutable/tracker-family.ts +2 -2
  37. package/internal/src/set-state/set-into-store.ts +4 -4
  38. package/internal/src/store/deposit.ts +3 -3
  39. package/internal/src/store/withdraw.ts +10 -9
  40. package/introspection/dist/index.js +32 -30
  41. package/introspection/package.json +1 -4
  42. package/json/dist/index.d.ts +10 -27
  43. package/json/dist/index.js +3 -3
  44. package/json/package.json +1 -4
  45. package/json/src/index.ts +8 -3
  46. package/json/src/select-json-family.ts +4 -4
  47. package/package.json +36 -65
  48. package/react/dist/index.d.ts +4 -4
  49. package/react/dist/index.js +2 -2
  50. package/react/package.json +1 -4
  51. package/react/src/parse-state-overloads.ts +4 -4
  52. package/react/src/use-i.ts +3 -3
  53. package/react/src/use-json.ts +3 -3
  54. package/react/src/use-o.ts +3 -3
  55. package/react-devtools/dist/index.d.ts +1 -1
  56. package/react-devtools/dist/index.js +90 -72
  57. package/react-devtools/package.json +1 -4
  58. package/react-devtools/src/StateIndex.tsx +5 -4
  59. package/realtime/dist/index.d.ts +3 -3
  60. package/realtime/dist/index.js +8 -9
  61. package/realtime/package.json +1 -4
  62. package/realtime/src/realtime-continuity.ts +2 -2
  63. package/realtime-client/dist/index.js +6 -6
  64. package/realtime-client/package.json +1 -4
  65. package/realtime-react/dist/index.d.ts +4 -4
  66. package/realtime-react/dist/index.js +9 -11
  67. package/realtime-react/package.json +1 -4
  68. package/realtime-react/src/use-pull-atom-family-member.ts +2 -2
  69. package/realtime-react/src/use-pull-mutable-family-member.ts +2 -2
  70. package/realtime-react/src/use-pull-selector-family-member.ts +2 -2
  71. package/realtime-server/dist/index.d.ts +9 -9
  72. package/realtime-server/dist/index.js +59 -54
  73. package/realtime-server/package.json +1 -4
  74. package/realtime-server/src/ipc-sockets/custom-socket.ts +2 -2
  75. package/realtime-server/src/realtime-family-provider.ts +3 -2
  76. package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
  77. package/realtime-testing/dist/index.js +3 -3
  78. package/realtime-testing/package.json +1 -4
  79. package/src/atom.ts +15 -42
  80. package/src/dispose-state.ts +2 -2
  81. package/src/get-state.ts +4 -4
  82. package/src/index.ts +5 -5
  83. package/src/molecule.ts +4 -3
  84. package/src/selector.ts +17 -39
  85. package/src/set-state.ts +3 -2
  86. package/src/silo.ts +4 -4
  87. package/transceivers/set-rtx/dist/index.js +11 -11
  88. package/transceivers/set-rtx/package.json +1 -4
  89. package/transceivers/set-rtx/src/set-rtx.ts +5 -5
  90. package/data/dist/index.cjs +0 -953
  91. package/dist/chunk-BF4MVQF6.js +0 -44
  92. package/dist/chunk-S4N6XNPH.js +0 -38
  93. package/dist/index.cjs +0 -215
  94. package/ephemeral/dist/index.cjs +0 -11
  95. package/eslint-plugin/dist/index.cjs +0 -388
  96. package/immortal/dist/index.cjs +0 -14
  97. package/internal/dist/index.cjs +0 -3405
  98. package/internal/src/mutable/is-mutable.ts +0 -16
  99. package/introspection/dist/index.cjs +0 -449
  100. package/json/dist/index.cjs +0 -128
  101. package/react/dist/index.cjs +0 -118
  102. package/react-devtools/dist/index.cjs +0 -2191
  103. package/realtime/dist/index.cjs +0 -120
  104. package/realtime-client/dist/index.cjs +0 -569
  105. package/realtime-react/dist/index.cjs +0 -189
  106. package/realtime-server/dist/index.cjs +0 -965
  107. package/realtime-testing/dist/index.cjs +0 -201
  108. package/transceivers/set-rtx/dist/index.cjs +0 -215
@@ -1,5 +1,5 @@
1
- import { Junction } from '../../dist/chunk-HYXKCFVY.js';
2
- import { __spreadValues, __spreadProps } from '../../dist/chunk-S4N6XNPH.js';
1
+ import { Junction } from '../../dist/chunk-IBTHB2PI.js';
2
+ import '../../dist/chunk-XWL6SNVU.js';
3
3
  import { stringifyJson, parseJson, selectJson, selectJsonFamily } from 'atom.io/json';
4
4
  import { AtomIOLogger } from 'atom.io';
5
5
  import { getJoin, findRelations } from 'atom.io/data';
@@ -11,6 +11,9 @@ function arbitrary(random = Math.random) {
11
11
 
12
12
  // internal/src/future.ts
13
13
  var Future = class extends Promise {
14
+ fate;
15
+ resolve;
16
+ reject;
14
17
  constructor(executor) {
15
18
  let superResolve;
16
19
  let superReject;
@@ -79,9 +82,8 @@ function deposit(state) {
79
82
 
80
83
  // internal/src/subject.ts
81
84
  var Subject = class {
82
- constructor() {
83
- this.subscribers = /* @__PURE__ */ new Map();
84
- }
85
+ Subscriber;
86
+ subscribers = /* @__PURE__ */ new Map();
85
87
  subscribe(key, subscriber) {
86
88
  this.subscribers.set(key, subscriber);
87
89
  const unsubscribe = () => {
@@ -100,6 +102,7 @@ var Subject = class {
100
102
  }
101
103
  };
102
104
  var StatefulSubject = class extends Subject {
105
+ state;
103
106
  constructor(initialState) {
104
107
  super();
105
108
  this.state = initialState;
@@ -311,7 +314,7 @@ var evictDownStream = (atom, store) => {
311
314
  atom.type,
312
315
  atom.key,
313
316
  downstreamKeys ? `evicting ${downstreamKeys.size} states downstream:` : `no downstream states`,
314
- downstreamKeys != null ? downstreamKeys : `to evict`
317
+ downstreamKeys ?? `to evict`
315
318
  );
316
319
  if (downstreamKeys) {
317
320
  if (target.operation.open) {
@@ -358,10 +361,11 @@ var stowUpdate = (state, update, store) => {
358
361
  if (!shouldStow) {
359
362
  return;
360
363
  }
361
- const atomUpdate = __spreadValues({
364
+ const atomUpdate = {
362
365
  type: `atom_update`,
363
- key
364
- }, update);
366
+ key,
367
+ ...update
368
+ };
365
369
  if (state.family) {
366
370
  atomUpdate.family = state.family;
367
371
  }
@@ -461,8 +465,8 @@ function createRegularAtomFamily(options, store) {
461
465
 
462
466
  // internal/src/families/create-atom-family.ts
463
467
  function createAtomFamily(options, store) {
464
- const isMutable2 = `mutable` in options;
465
- if (isMutable2) {
468
+ const isMutable = `mutable` in options;
469
+ if (isMutable) {
466
470
  return createMutableAtomFamily(options, store);
467
471
  }
468
472
  return createRegularAtomFamily(options, store);
@@ -663,12 +667,14 @@ var createReadonlySelector = (options, family, store) => {
663
667
  covered.clear();
664
668
  return value;
665
669
  };
666
- const readonlySelector = __spreadValues(__spreadProps(__spreadValues({}, options), {
670
+ const readonlySelector = {
671
+ ...options,
667
672
  subject,
668
673
  install: (s) => createReadonlySelector(options, family, s),
669
674
  get: getSelf,
670
- type: `readonly_selector`
671
- }), family && { family });
675
+ type: `readonly_selector`,
676
+ ...family && { family }
677
+ };
672
678
  target.readonlySelectors.set(options.key, readonlySelector);
673
679
  const initialValue = getSelf();
674
680
  store.logger.info(
@@ -723,13 +729,15 @@ var createWritableSelector = (options, family, store) => {
723
729
  }
724
730
  options.set(toolkit, newValue);
725
731
  };
726
- const mySelector = __spreadValues(__spreadProps(__spreadValues({}, options), {
732
+ const mySelector = {
733
+ ...options,
727
734
  subject,
728
735
  install: (s) => createWritableSelector(options, family, s),
729
736
  get: getSelf,
730
737
  set: setSelf,
731
- type: `selector`
732
- }), family && { family });
738
+ type: `selector`,
739
+ ...family && { family }
740
+ };
733
741
  target.selectors.set(options.key, mySelector);
734
742
  const initialValue = getSelf();
735
743
  store.logger.info(`\u2728`, mySelector.type, mySelector.key, `=`, initialValue);
@@ -758,10 +766,9 @@ function createStandaloneSelector(options, store) {
758
766
 
759
767
  // internal/src/selector/dispose-selector.ts
760
768
  function disposeSelector(selectorToken, store) {
761
- var _a;
762
769
  const target = newest(store);
763
770
  const { key } = selectorToken;
764
- const selector = (_a = target.selectors.get(key)) != null ? _a : target.readonlySelectors.get(key);
771
+ const selector = target.selectors.get(key) ?? target.readonlySelectors.get(key);
765
772
  if (!selector) {
766
773
  store.logger.info(
767
774
  `\u274C`,
@@ -812,10 +819,7 @@ function disposeSelector(selectorToken, store) {
812
819
  target.valueMap.delete(key);
813
820
  target.selectorAtoms.delete(key);
814
821
  const downstreamTokens = target.selectorGraph.getRelationEntries({ upstreamSelectorKey: key }).filter(([_, { source }]) => source === key).map(
815
- ([downstreamSelectorKey]) => {
816
- var _a2;
817
- return (_a2 = target.selectors.get(downstreamSelectorKey)) != null ? _a2 : target.readonlySelectors.get(downstreamSelectorKey);
818
- }
822
+ ([downstreamSelectorKey]) => target.selectors.get(downstreamSelectorKey) ?? target.readonlySelectors.get(downstreamSelectorKey)
819
823
  );
820
824
  for (const downstreamToken of downstreamTokens) {
821
825
  if (downstreamToken) {
@@ -907,7 +911,6 @@ function createSelectorFamily(options, store) {
907
911
 
908
912
  // internal/src/molecule/dispose-molecule.ts
909
913
  function disposeMolecule(token, store) {
910
- var _a;
911
914
  let molecule;
912
915
  try {
913
916
  molecule = withdraw(token, store);
@@ -949,7 +952,7 @@ function disposeMolecule(token, store) {
949
952
  disposeFromStore(state, store);
950
953
  }
951
954
  for (const child of molecule.below.values()) {
952
- if (((_a = child.family) == null ? void 0 : _a.dependsOn) === `all`) {
955
+ if (child.family?.dependsOn === `all`) {
953
956
  disposeMolecule(child, store);
954
957
  } else {
955
958
  child.above.delete(molecule.stringKey);
@@ -1135,17 +1138,17 @@ function ingestAtomUpdate(applying, atomUpdate, store) {
1135
1138
 
1136
1139
  // internal/src/molecule/create-molecule-family.ts
1137
1140
  function createMoleculeFamily(options, store) {
1138
- var _a;
1139
1141
  const subject = new Subject();
1140
1142
  const token = {
1141
1143
  type: `molecule_family`,
1142
1144
  key: options.key,
1143
- dependsOn: (_a = options.dependsOn) != null ? _a : `all`
1145
+ dependsOn: options.dependsOn ?? `all`
1144
1146
  };
1145
- const family = __spreadProps(__spreadValues({}, token), {
1147
+ const family = {
1148
+ ...token,
1146
1149
  subject,
1147
1150
  new: options.new
1148
- });
1151
+ };
1149
1152
  store.moleculeFamilies.set(options.key, family);
1150
1153
  return token;
1151
1154
  }
@@ -1171,12 +1174,6 @@ function getEnvironmentData(store) {
1171
1174
  var Molecule = class {
1172
1175
  constructor(ctx, key, family) {
1173
1176
  this.key = key;
1174
- this.type = `molecule`;
1175
- this.subject = new Subject();
1176
- this.tokens = /* @__PURE__ */ new Map();
1177
- this.above = /* @__PURE__ */ new Map();
1178
- this.below = /* @__PURE__ */ new Map();
1179
- this.joins = /* @__PURE__ */ new Map();
1180
1177
  this.stringKey = stringifyJson(key);
1181
1178
  if (family) {
1182
1179
  this.family = family;
@@ -1191,6 +1188,15 @@ var Molecule = class {
1191
1188
  }
1192
1189
  }
1193
1190
  }
1191
+ type = `molecule`;
1192
+ stringKey;
1193
+ family;
1194
+ subject = new Subject();
1195
+ tokens = /* @__PURE__ */ new Map();
1196
+ above = /* @__PURE__ */ new Map();
1197
+ below = /* @__PURE__ */ new Map();
1198
+ joins = /* @__PURE__ */ new Map();
1199
+ instance;
1194
1200
  };
1195
1201
 
1196
1202
  // internal/src/molecule/make-molecule-in-store.ts
@@ -1459,10 +1465,9 @@ function setEpochNumberOfAction(transactionKey, newEpoch, store) {
1459
1465
 
1460
1466
  // internal/src/transaction/apply-transaction.ts
1461
1467
  var applyTransaction = (output, store) => {
1462
- var _a;
1463
1468
  const child = newest(store);
1464
1469
  const { parent } = child;
1465
- if (parent === null || !isChildStore(child) || ((_a = child.transactionMeta) == null ? void 0 : _a.phase) !== `building`) {
1470
+ if (parent === null || !isChildStore(child) || child.transactionMeta?.phase !== `building`) {
1466
1471
  store.logger.warn(
1467
1472
  `\u{1F41E}`,
1468
1473
  `transaction`,
@@ -1494,7 +1499,7 @@ var applyTransaction = (output, store) => {
1494
1499
  { key: child.transactionMeta.update.key, type: `transaction` },
1495
1500
  store
1496
1501
  );
1497
- myTransaction == null ? void 0 : myTransaction.subject.next(child.transactionMeta.update);
1502
+ myTransaction?.subject.next(child.transactionMeta.update);
1498
1503
  store.logger.info(
1499
1504
  `\u{1F6EC}`,
1500
1505
  `transaction`,
@@ -1525,8 +1530,8 @@ var LazyMap = class extends Map {
1525
1530
  constructor(source) {
1526
1531
  super();
1527
1532
  this.source = source;
1528
- this.deleted = /* @__PURE__ */ new Set();
1529
1533
  }
1534
+ deleted = /* @__PURE__ */ new Set();
1530
1535
  get(key) {
1531
1536
  const has = super.has(key);
1532
1537
  if (has) {
@@ -1678,89 +1683,92 @@ var TRANSACTION_PHASES = [`idle`, `building`, `applying`];
1678
1683
 
1679
1684
  // internal/src/store/store.ts
1680
1685
  var Store = class {
1681
- constructor(config, store = null) {
1682
- this.parent = null;
1683
- this.child = null;
1684
- this.valueMap = /* @__PURE__ */ new Map();
1685
- this.atoms = /* @__PURE__ */ new Map();
1686
- this.selectors = /* @__PURE__ */ new Map();
1687
- this.readonlySelectors = /* @__PURE__ */ new Map();
1688
- this.atomsThatAreDefault = /* @__PURE__ */ new Set();
1689
- this.selectorAtoms = new Junction({
1690
- between: [`selectorKey`, `atomKey`],
1686
+ parent = null;
1687
+ child = null;
1688
+ valueMap = /* @__PURE__ */ new Map();
1689
+ atoms = /* @__PURE__ */ new Map();
1690
+ selectors = /* @__PURE__ */ new Map();
1691
+ readonlySelectors = /* @__PURE__ */ new Map();
1692
+ atomsThatAreDefault = /* @__PURE__ */ new Set();
1693
+ selectorAtoms = new Junction({
1694
+ between: [`selectorKey`, `atomKey`],
1695
+ cardinality: `n:n`
1696
+ });
1697
+ selectorGraph = new Junction(
1698
+ {
1699
+ between: [`upstreamSelectorKey`, `downstreamSelectorKey`],
1691
1700
  cardinality: `n:n`
1692
- });
1693
- this.selectorGraph = new Junction(
1694
- {
1695
- between: [`upstreamSelectorKey`, `downstreamSelectorKey`],
1696
- cardinality: `n:n`
1697
- },
1698
- {
1699
- makeContentKey: (...keys) => keys.sort().join(`:`)
1700
- }
1701
- );
1702
- this.trackers = /* @__PURE__ */ new Map();
1703
- this.families = /* @__PURE__ */ new Map();
1704
- this.transactions = /* @__PURE__ */ new Map();
1705
- this.transactionMeta = {
1706
- epoch: /* @__PURE__ */ new Map(),
1707
- actionContinuities: new Junction({
1708
- between: [`continuity`, `action`],
1709
- cardinality: `1:n`
1710
- })
1711
- };
1712
- this.timelines = /* @__PURE__ */ new Map();
1713
- this.timelineTopics = new Junction({
1714
- between: [`timelineKey`, `topicKey`],
1701
+ },
1702
+ {
1703
+ makeContentKey: (...keys) => keys.sort().join(`:`)
1704
+ }
1705
+ );
1706
+ trackers = /* @__PURE__ */ new Map();
1707
+ families = /* @__PURE__ */ new Map();
1708
+ transactions = /* @__PURE__ */ new Map();
1709
+ transactionMeta = {
1710
+ epoch: /* @__PURE__ */ new Map(),
1711
+ actionContinuities: new Junction({
1712
+ between: [`continuity`, `action`],
1715
1713
  cardinality: `1:n`
1716
- });
1717
- this.molecules = /* @__PURE__ */ new Map();
1718
- this.moleculeFamilies = /* @__PURE__ */ new Map();
1719
- this.moleculeInProgress = null;
1720
- this.miscResources = /* @__PURE__ */ new Map();
1721
- this.on = {
1722
- atomCreation: new Subject(),
1723
- atomDisposal: new Subject(),
1724
- selectorCreation: new Subject(),
1725
- selectorDisposal: new Subject(),
1726
- timelineCreation: new Subject(),
1727
- transactionCreation: new Subject(),
1728
- transactionApplying: new StatefulSubject(
1729
- null
1730
- ),
1731
- operationClose: new Subject(),
1732
- moleculeCreationStart: new Subject(),
1733
- moleculeCreationDone: new Subject(),
1734
- moleculeDisposal: new Subject()
1735
- };
1736
- this.operation = { open: false };
1714
+ })
1715
+ };
1716
+ timelines = /* @__PURE__ */ new Map();
1717
+ timelineTopics = new Junction({
1718
+ between: [`timelineKey`, `topicKey`],
1719
+ cardinality: `1:n`
1720
+ });
1721
+ molecules = /* @__PURE__ */ new Map();
1722
+ moleculeFamilies = /* @__PURE__ */ new Map();
1723
+ moleculeInProgress = null;
1724
+ miscResources = /* @__PURE__ */ new Map();
1725
+ on = {
1726
+ atomCreation: new Subject(),
1727
+ atomDisposal: new Subject(),
1728
+ selectorCreation: new Subject(),
1729
+ selectorDisposal: new Subject(),
1730
+ timelineCreation: new Subject(),
1731
+ transactionCreation: new Subject(),
1732
+ transactionApplying: new StatefulSubject(
1733
+ null
1734
+ ),
1735
+ operationClose: new Subject(),
1736
+ moleculeCreationStart: new Subject(),
1737
+ moleculeCreationDone: new Subject(),
1738
+ moleculeDisposal: new Subject()
1739
+ };
1740
+ operation = { open: false };
1741
+ config = {
1742
+ name: `IMPLICIT_STORE`,
1743
+ lifespan: `ephemeral`
1744
+ };
1745
+ loggers = [
1746
+ new AtomIOLogger(`warn`, (_, __, key) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`))
1747
+ ];
1748
+ logger = {
1749
+ error: (...messages) => {
1750
+ for (const logger of this.loggers) logger.error(...messages);
1751
+ },
1752
+ info: (...messages) => {
1753
+ for (const logger of this.loggers) logger.info(...messages);
1754
+ },
1755
+ warn: (...messages) => {
1756
+ for (const logger of this.loggers) logger.warn(...messages);
1757
+ }
1758
+ };
1759
+ constructor(config, store = null) {
1737
1760
  this.config = {
1738
- name: `IMPLICIT_STORE`,
1739
- lifespan: `ephemeral`
1761
+ ...store?.config,
1762
+ ...config
1740
1763
  };
1741
- this.loggers = [
1742
- new AtomIOLogger(`warn`, (_, __, key) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`))
1743
- ];
1744
- this.logger = {
1745
- error: (...messages) => {
1746
- for (const logger of this.loggers) logger.error(...messages);
1747
- },
1748
- info: (...messages) => {
1749
- for (const logger of this.loggers) logger.info(...messages);
1750
- },
1751
- warn: (...messages) => {
1752
- for (const logger of this.loggers) logger.warn(...messages);
1753
- }
1754
- };
1755
- this.config = __spreadValues(__spreadValues({}, store == null ? void 0 : store.config), config);
1756
1764
  if (store !== null) {
1757
- this.valueMap = new Map(store == null ? void 0 : store.valueMap);
1758
- this.operation = __spreadValues({}, store == null ? void 0 : store.operation);
1765
+ this.valueMap = new Map(store?.valueMap);
1766
+ this.operation = { ...store?.operation };
1759
1767
  if (isRootStore(store)) {
1760
1768
  this.transactionMeta = {
1761
- epoch: new Map(store == null ? void 0 : store.transactionMeta.epoch),
1769
+ epoch: new Map(store?.transactionMeta.epoch),
1762
1770
  actionContinuities: new Junction(
1763
- store == null ? void 0 : store.transactionMeta.actionContinuities.toJSON()
1771
+ store?.transactionMeta.actionContinuities.toJSON()
1764
1772
  )
1765
1773
  };
1766
1774
  }
@@ -1999,8 +2007,8 @@ var subscribeToTransaction = (token, handleUpdate, key, store) => {
1999
2007
 
2000
2008
  // internal/src/mutable/tracker.ts
2001
2009
  var Tracker = class {
2010
+ Update;
2002
2011
  initializeState(mutableState, store) {
2003
- var _a;
2004
2012
  const latestUpdateStateKey = `*${mutableState.key}`;
2005
2013
  store.atoms.delete(latestUpdateStateKey);
2006
2014
  store.valueMap.delete(latestUpdateStateKey);
@@ -2016,12 +2024,14 @@ var Tracker = class {
2016
2024
  familyMetaData,
2017
2025
  store
2018
2026
  );
2019
- if ((_a = store.parent) == null ? void 0 : _a.valueMap.has(latestUpdateStateKey)) {
2027
+ if (store.parent?.valueMap.has(latestUpdateStateKey)) {
2020
2028
  const parentValue = store.parent.valueMap.get(latestUpdateStateKey);
2021
2029
  store.valueMap.set(latestUpdateStateKey, parentValue);
2022
2030
  }
2023
2031
  return latestUpdateState;
2024
2032
  }
2033
+ unsubscribeFromInnerValue;
2034
+ unsubscribeFromState;
2025
2035
  observeCore(mutableState, latestUpdateState, target) {
2026
2036
  const subscriptionKey = `tracker:${target.config.name}:${isChildStore(target) ? target.transactionMeta.update.key : `main`}:${mutableState.key}`;
2027
2037
  const originalInnerValue = getFromStore(mutableState, target);
@@ -2058,7 +2068,7 @@ var Tracker = class {
2058
2068
  );
2059
2069
  if (timelineId) {
2060
2070
  const timelineData = target.timelines.get(timelineId);
2061
- if (timelineData == null ? void 0 : timelineData.timeTraveling) {
2071
+ if (timelineData?.timeTraveling) {
2062
2072
  const unsubscribe2 = subscribeToTimeline(
2063
2073
  { key: timelineId, type: `timeline` },
2064
2074
  (update) => {
@@ -2110,6 +2120,9 @@ var Tracker = class {
2110
2120
  target
2111
2121
  );
2112
2122
  }
2123
+ mutableState;
2124
+ latestUpdateState;
2125
+ dispose;
2113
2126
  constructor(mutableState, store) {
2114
2127
  this.mutableState = mutableState;
2115
2128
  const target = newest(store);
@@ -2145,7 +2158,8 @@ function createMutableAtom(options, family, store) {
2145
2158
  return deposit(existing);
2146
2159
  }
2147
2160
  const subject = new Subject();
2148
- const newAtom = __spreadProps(__spreadValues({}, options), {
2161
+ const newAtom = {
2162
+ ...options,
2149
2163
  type: `mutable_atom`,
2150
2164
  install: (s) => {
2151
2165
  s.logger.info(
@@ -2157,7 +2171,7 @@ function createMutableAtom(options, family, store) {
2157
2171
  return createMutableAtom(options, family, s);
2158
2172
  },
2159
2173
  subject
2160
- });
2174
+ };
2161
2175
  if (family) {
2162
2176
  newAtom.family = family;
2163
2177
  }
@@ -2194,6 +2208,9 @@ function createMutableAtom(options, family, store) {
2194
2208
  return token;
2195
2209
  }
2196
2210
  var FamilyTracker = class {
2211
+ Update;
2212
+ latestUpdateAtoms;
2213
+ mutableAtoms;
2197
2214
  constructor(mutableAtoms, store) {
2198
2215
  this.latestUpdateAtoms = createRegularAtomFamily(
2199
2216
  {
@@ -2308,11 +2325,6 @@ var getUpdateToken = (mutableAtomToken) => {
2308
2325
  return updateToken;
2309
2326
  };
2310
2327
 
2311
- // internal/src/mutable/is-mutable.ts
2312
- function isMutable(atomOrTokenOrFamily) {
2313
- return atomOrTokenOrFamily.type === `mutable_atom` || atomOrTokenOrFamily.type === `mutable_atom_family`;
2314
- }
2315
-
2316
2328
  // internal/src/mutable/transceiver.ts
2317
2329
  function isTransceiver(value) {
2318
2330
  return typeof value === `object` && value !== null && `do` in value && `undo` in value && `subscribe` in value;
@@ -2367,11 +2379,10 @@ var readCachedValue = (token, target) => {
2367
2379
  return value;
2368
2380
  };
2369
2381
  var evictCachedValue = (key, target) => {
2370
- var _a;
2371
2382
  const currentValue = target.valueMap.get(key);
2372
2383
  if (currentValue instanceof Future) {
2373
2384
  const future = currentValue;
2374
- const selector = (_a = target.selectors.get(key)) != null ? _a : target.readonlySelectors.get(key);
2385
+ const selector = target.selectors.get(key) ?? target.readonlySelectors.get(key);
2375
2386
  if (selector) {
2376
2387
  future.use(selector.get());
2377
2388
  }
@@ -2419,7 +2430,8 @@ function createRegularAtom(options, family, store) {
2419
2430
  return deposit(existing);
2420
2431
  }
2421
2432
  const subject = new Subject();
2422
- const newAtom = __spreadProps(__spreadValues({}, options), {
2433
+ const newAtom = {
2434
+ ...options,
2423
2435
  type: `atom`,
2424
2436
  install: (s) => {
2425
2437
  s.logger.info(
@@ -2431,7 +2443,7 @@ function createRegularAtom(options, family, store) {
2431
2443
  return createRegularAtom(options, family, s);
2432
2444
  },
2433
2445
  subject
2434
- });
2446
+ };
2435
2447
  if (family) {
2436
2448
  newAtom.family = family;
2437
2449
  }
@@ -2469,8 +2481,8 @@ function createRegularAtom(options, family, store) {
2469
2481
 
2470
2482
  // internal/src/atom/create-standalone-atom.ts
2471
2483
  function createStandaloneAtom(options, store) {
2472
- const isMutable2 = `mutable` in options;
2473
- if (isMutable2) {
2484
+ const isMutable = `mutable` in options;
2485
+ if (isMutable) {
2474
2486
  const state2 = createMutableAtom(options, void 0, store);
2475
2487
  store.on.atomCreation.next(state2);
2476
2488
  return state2;
@@ -2482,7 +2494,6 @@ function createStandaloneAtom(options, store) {
2482
2494
 
2483
2495
  // internal/src/atom/dispose-atom.ts
2484
2496
  function disposeAtom(atomToken, store) {
2485
- var _a, _b;
2486
2497
  const target = newest(store);
2487
2498
  const { key } = atomToken;
2488
2499
  const atom = target.atoms.get(key);
@@ -2496,7 +2507,7 @@ function disposeAtom(atomToken, store) {
2496
2507
  } else if (!atom.family) {
2497
2508
  store.logger.error(`\u274C`, `atom`, key, `Standalone atoms cannot be disposed.`);
2498
2509
  } else {
2499
- (_a = atom.cleanup) == null ? void 0 : _a.call(atom);
2510
+ atom.cleanup?.();
2500
2511
  const lastValue = store.valueMap.get(atom.key);
2501
2512
  const family = withdraw({ key: atom.family.key, type: `atom_family` }, store);
2502
2513
  family.subject.next({
@@ -2513,7 +2524,7 @@ function disposeAtom(atomToken, store) {
2513
2524
  const selectorKeys = target.selectorAtoms.getRelatedKeys(key);
2514
2525
  if (selectorKeys) {
2515
2526
  for (const selectorKey of selectorKeys) {
2516
- const token = (_b = target.selectors.get(selectorKey)) != null ? _b : target.readonlySelectors.get(selectorKey);
2527
+ const token = target.selectors.get(selectorKey) ?? target.readonlySelectors.get(selectorKey);
2517
2528
  if (token) {
2518
2529
  disposeSelector(token, store);
2519
2530
  }
@@ -2539,20 +2550,19 @@ function disposeAtom(atomToken, store) {
2539
2550
  }
2540
2551
  }
2541
2552
  function createTimeline(options, store, data) {
2542
- var _a;
2543
- const tl = __spreadProps(__spreadValues({
2553
+ const tl = {
2544
2554
  type: `timeline`,
2545
2555
  key: options.key,
2546
2556
  at: 0,
2547
2557
  timeTraveling: null,
2548
2558
  selectorTime: null,
2549
- transactionKey: null
2550
- }, data), {
2551
- history: (_a = data == null ? void 0 : data.history.map((update) => __spreadValues({}, update))) != null ? _a : [],
2559
+ transactionKey: null,
2560
+ ...data,
2561
+ history: data?.history.map((update) => ({ ...update })) ?? [],
2552
2562
  install: (s) => createTimeline(options, s, tl),
2553
2563
  subject: new Subject(),
2554
2564
  subscriptions: /* @__PURE__ */ new Map()
2555
- });
2565
+ };
2556
2566
  if (options.shouldCapture) {
2557
2567
  tl.shouldCapture = options.shouldCapture;
2558
2568
  }
@@ -2650,11 +2660,10 @@ function addAtomToTimeline(atomToken, tl, store) {
2650
2660
  tl.subscriptions.set(
2651
2661
  atom.key,
2652
2662
  atom.subject.subscribe(`timeline`, (update) => {
2653
- var _a, _b, _c, _d, _e;
2654
2663
  const target = newest(store);
2655
2664
  const currentSelectorKey = store.operation.open && store.operation.token.type === `selector` ? store.operation.token.key : null;
2656
2665
  const currentSelectorTime = store.operation.open && store.operation.token.type === `selector` ? store.operation.time : null;
2657
- const txUpdateInProgress = (_a = target.on.transactionApplying.state) == null ? void 0 : _a.update;
2666
+ const txUpdateInProgress = target.on.transactionApplying.state?.update;
2658
2667
  store.logger.info(
2659
2668
  `\u23F3`,
2660
2669
  `timeline`,
@@ -2679,10 +2688,11 @@ function addAtomToTimeline(atomToken, tl, store) {
2679
2688
  key: currentSelectorKey,
2680
2689
  atomUpdates: []
2681
2690
  };
2682
- latestUpdate.atomUpdates.push(__spreadValues({
2691
+ latestUpdate.atomUpdates.push({
2683
2692
  key: atom.key,
2684
- type: `atom_update`
2685
- }, update));
2693
+ type: `atom_update`,
2694
+ ...update
2695
+ });
2686
2696
  if (tl.at !== tl.history.length) {
2687
2697
  tl.history.splice(tl.at);
2688
2698
  }
@@ -2697,22 +2707,23 @@ function addAtomToTimeline(atomToken, tl, store) {
2697
2707
  tl.at = tl.history.length;
2698
2708
  tl.selectorTime = currentSelectorTime;
2699
2709
  } else {
2700
- if ((latestUpdate == null ? void 0 : latestUpdate.type) === `selector_update`) {
2701
- latestUpdate.atomUpdates.push(__spreadValues({
2710
+ if (latestUpdate?.type === `selector_update`) {
2711
+ latestUpdate.atomUpdates.push({
2702
2712
  key: atom.key,
2703
- type: `atom_update`
2704
- }, update));
2713
+ type: `atom_update`,
2714
+ ...update
2715
+ });
2705
2716
  store.logger.info(
2706
2717
  `\u231B`,
2707
2718
  `timeline`,
2708
2719
  tl.key,
2709
2720
  `set selector_update "${currentSelectorKey}" to`,
2710
- latestUpdate == null ? void 0 : latestUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key)
2721
+ latestUpdate?.atomUpdates.map((atomUpdate) => atomUpdate.key)
2711
2722
  );
2712
2723
  }
2713
2724
  }
2714
2725
  if (latestUpdate) {
2715
- const willCaptureSelectorUpdate = (_c = (_b = tl.shouldCapture) == null ? void 0 : _b.call(tl, latestUpdate, tl)) != null ? _c : true;
2726
+ const willCaptureSelectorUpdate = tl.shouldCapture?.(latestUpdate, tl) ?? true;
2716
2727
  if (willCaptureSelectorUpdate) {
2717
2728
  tl.subject.next(latestUpdate);
2718
2729
  } else {
@@ -2736,7 +2747,7 @@ function addAtomToTimeline(atomToken, tl, store) {
2736
2747
  if (atom.family) {
2737
2748
  atomUpdate.family = atom.family;
2738
2749
  }
2739
- const willCapture = (_e = (_d = tl.shouldCapture) == null ? void 0 : _d.call(tl, atomUpdate, tl)) != null ? _e : true;
2750
+ const willCapture = tl.shouldCapture?.(atomUpdate, tl) ?? true;
2740
2751
  store.logger.info(
2741
2752
  `\u231B`,
2742
2753
  `timeline`,
@@ -2754,7 +2765,6 @@ function addAtomToTimeline(atomToken, tl, store) {
2754
2765
  );
2755
2766
  }
2756
2767
  function addAtomFamilyToTimeline(atomFamilyToken, tl, store) {
2757
- var _a;
2758
2768
  const family = withdraw(atomFamilyToken, store);
2759
2769
  store.timelineTopics.set(
2760
2770
  { topicKey: family.key, timelineKey: tl.key },
@@ -2767,7 +2777,7 @@ function addAtomFamilyToTimeline(atomFamilyToken, tl, store) {
2767
2777
  })
2768
2778
  );
2769
2779
  for (const atom of store.atoms.values()) {
2770
- if (((_a = atom.family) == null ? void 0 : _a.key) === family.key) {
2780
+ if (atom.family?.key === family.key) {
2771
2781
  addAtomToTimeline(atom, tl, store);
2772
2782
  }
2773
2783
  }
@@ -2782,7 +2792,6 @@ function addMoleculeFamilyToTimeline(familyToken, tl, store) {
2782
2792
  tl.subscriptions.set(
2783
2793
  familyToken.key,
2784
2794
  family.subject.subscribe(`timeline:${tl.key}`, (creationOrDisposal) => {
2785
- var _a, _b, _c, _d;
2786
2795
  store.logger.info(
2787
2796
  `\u{1F41E}`,
2788
2797
  `timeline`,
@@ -2800,7 +2809,7 @@ function addMoleculeFamilyToTimeline(familyToken, tl, store) {
2800
2809
  },
2801
2810
  { topicType: `molecule` }
2802
2811
  );
2803
- const txUpdateInProgress = (_a = newest(store).on.transactionApplying.state) == null ? void 0 : _a.update;
2812
+ const txUpdateInProgress = newest(store).on.transactionApplying.state?.update;
2804
2813
  if (txUpdateInProgress) {
2805
2814
  joinTransaction(tl, txUpdateInProgress, store);
2806
2815
  } else if (tl.timeTraveling === null) {
@@ -2833,7 +2842,7 @@ function addMoleculeFamilyToTimeline(familyToken, tl, store) {
2833
2842
  break;
2834
2843
  case `molecule_disposal`:
2835
2844
  {
2836
- const txUpdateInProgress = (_b = newest(store).on.transactionApplying.state) == null ? void 0 : _b.update;
2845
+ const txUpdateInProgress = newest(store).on.transactionApplying.state?.update;
2837
2846
  if (txUpdateInProgress) {
2838
2847
  joinTransaction(tl, txUpdateInProgress, store);
2839
2848
  } else if (tl.timeTraveling === null) {
@@ -2845,11 +2854,11 @@ function addMoleculeFamilyToTimeline(familyToken, tl, store) {
2845
2854
  tl.subject.next(event);
2846
2855
  }
2847
2856
  const moleculeKey = creationOrDisposal.token.key;
2848
- (_c = tl.subscriptions.get(moleculeKey)) == null ? void 0 : _c();
2857
+ tl.subscriptions.get(moleculeKey)?.();
2849
2858
  tl.subscriptions.delete(moleculeKey);
2850
2859
  for (const [familyKey] of creationOrDisposal.values) {
2851
2860
  const stateKey = `${familyKey}(${stringifyJson(moleculeKey)})`;
2852
- (_d = tl.subscriptions.get(stateKey)) == null ? void 0 : _d();
2861
+ tl.subscriptions.get(stateKey)?.();
2853
2862
  tl.subscriptions.delete(stateKey);
2854
2863
  store.timelineTopics.delete(stateKey);
2855
2864
  }
@@ -2873,7 +2882,6 @@ function joinTransaction(tl, txUpdateInProgress, store) {
2873
2882
  const unsubscribe = currentTransaction.subject.subscribe(
2874
2883
  `timeline:${tl.key}`,
2875
2884
  (transactionUpdate) => {
2876
- var _a, _b;
2877
2885
  unsubscribe();
2878
2886
  tl.transactionKey = null;
2879
2887
  if (tl.timeTraveling === null && currentTxInstanceId) {
@@ -2885,12 +2893,12 @@ function joinTransaction(tl, txUpdateInProgress, store) {
2885
2893
  transactionUpdate.updates,
2886
2894
  timelineTopics
2887
2895
  );
2888
- const timelineTransactionUpdate = __spreadProps(__spreadValues({
2889
- timestamp: Date.now()
2890
- }, transactionUpdate), {
2896
+ const timelineTransactionUpdate = {
2897
+ timestamp: Date.now(),
2898
+ ...transactionUpdate,
2891
2899
  updates
2892
- });
2893
- const willCapture = (_b = (_a = tl.shouldCapture) == null ? void 0 : _a.call(tl, timelineTransactionUpdate, tl)) != null ? _b : true;
2900
+ };
2901
+ const willCapture = tl.shouldCapture?.(timelineTransactionUpdate, tl) ?? true;
2894
2902
  if (willCapture) {
2895
2903
  tl.history.push(timelineTransactionUpdate);
2896
2904
  tl.at = tl.history.length;
@@ -2921,24 +2929,24 @@ function filterTransactionUpdates(updates, timelineTopics) {
2921
2929
  return timelineTopics.has(key);
2922
2930
  }).map((updateFromTx) => {
2923
2931
  if (`updates` in updateFromTx) {
2924
- return __spreadProps(__spreadValues({}, updateFromTx), {
2932
+ return {
2933
+ ...updateFromTx,
2925
2934
  updates: filterTransactionUpdates(
2926
2935
  updateFromTx.updates,
2927
2936
  timelineTopics
2928
2937
  )
2929
- });
2938
+ };
2930
2939
  }
2931
2940
  return updateFromTx;
2932
2941
  });
2933
2942
  }
2934
2943
  function handleStateLifecycleEvent(event, tl, store) {
2935
- var _a, _b;
2936
2944
  const timestamp = Date.now();
2937
2945
  const timelineEvent = Object.assign(event, {
2938
2946
  timestamp
2939
2947
  });
2940
2948
  if (!tl.timeTraveling) {
2941
- const txUpdateInProgress = (_a = newest(store).on.transactionApplying.state) == null ? void 0 : _a.update;
2949
+ const txUpdateInProgress = newest(store).on.transactionApplying.state?.update;
2942
2950
  if (txUpdateInProgress) {
2943
2951
  joinTransaction(tl, txUpdateInProgress, store);
2944
2952
  } else {
@@ -2952,7 +2960,7 @@ function handleStateLifecycleEvent(event, tl, store) {
2952
2960
  addAtomToTimeline(event.token, tl, store);
2953
2961
  break;
2954
2962
  case `state_disposal`:
2955
- (_b = tl.subscriptions.get(event.token.key)) == null ? void 0 : _b();
2963
+ tl.subscriptions.get(event.token.key)?.();
2956
2964
  tl.subscriptions.delete(event.token.key);
2957
2965
  break;
2958
2966
  }
@@ -3034,4 +3042,4 @@ var timeTravel = (action, token, store) => {
3034
3042
  );
3035
3043
  };
3036
3044
 
3037
- export { FamilyTracker, Future, IMPLICIT, LazyMap, Molecule, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isMutable, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, readCachedValue, readOrComputeValue, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw };
3045
+ export { FamilyTracker, Future, IMPLICIT, LazyMap, Molecule, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtomFamily, createMoleculeFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeFromStore, disposeMolecule, disposeSelector, eldest, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, growMoleculeInStore, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, readCachedValue, readOrComputeValue, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw };