atom.io 0.15.3 → 0.15.5

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 (125) hide show
  1. package/data/dist/index.cjs +29 -16
  2. package/data/dist/index.cjs.map +1 -1
  3. package/data/dist/index.js +30 -17
  4. package/data/dist/index.js.map +1 -1
  5. package/data/src/join.ts +15 -2
  6. package/dist/index.cjs +32 -6
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.ts +153 -85
  9. package/dist/index.js +157 -1
  10. package/dist/index.js.map +1 -1
  11. package/internal/dist/index.cjs +98 -159
  12. package/internal/dist/index.cjs.map +1 -1
  13. package/internal/dist/index.d.ts +44 -32
  14. package/internal/dist/index.js +89 -105
  15. package/internal/dist/index.js.map +1 -1
  16. package/internal/src/atom/create-regular-atom.ts +1 -1
  17. package/internal/src/get-environment-data.ts +18 -0
  18. package/internal/src/index.ts +2 -0
  19. package/internal/src/ingest-updates/index.ts +3 -0
  20. package/internal/src/ingest-updates/ingest-atom-update.ts +14 -0
  21. package/internal/src/ingest-updates/ingest-selector-update.ts +17 -0
  22. package/internal/src/ingest-updates/ingest-transaction-update.ts +22 -0
  23. package/internal/src/mutable/tracker.ts +4 -4
  24. package/internal/src/not-found-error.ts +3 -8
  25. package/internal/src/operation.ts +4 -4
  26. package/internal/src/selector/create-read-write-selector.ts +6 -4
  27. package/internal/src/selector/create-readonly-selector.ts +3 -3
  28. package/internal/src/selector/register-selector.ts +6 -4
  29. package/internal/src/selector/update-selector-atoms.ts +2 -2
  30. package/internal/src/store/deposit.ts +5 -5
  31. package/internal/src/store/store.ts +4 -4
  32. package/internal/src/store/withdraw-new-family-member.ts +8 -11
  33. package/internal/src/store/withdraw.ts +11 -12
  34. package/internal/src/subscribe/subscribe-to-state.ts +2 -2
  35. package/internal/src/subscribe/subscribe-to-timeline.ts +4 -4
  36. package/internal/src/timeline/add-atom-to-timeline.ts +7 -7
  37. package/internal/src/timeline/create-timeline.ts +29 -21
  38. package/internal/src/timeline/time-travel.ts +19 -45
  39. package/internal/src/transaction/apply-transaction.ts +5 -51
  40. package/internal/src/transaction/build-transaction.ts +9 -2
  41. package/internal/src/transaction/create-transaction.ts +4 -4
  42. package/internal/src/transaction/index.ts +2 -2
  43. package/introspection/dist/index.cjs +9 -9
  44. package/introspection/dist/index.cjs.map +1 -1
  45. package/introspection/dist/index.d.ts +6 -6
  46. package/introspection/dist/index.js +9 -9
  47. package/introspection/dist/index.js.map +1 -1
  48. package/introspection/src/attach-atom-index.ts +4 -4
  49. package/introspection/src/attach-introspection-states.ts +2 -2
  50. package/introspection/src/attach-selector-index.ts +4 -4
  51. package/introspection/src/attach-timeline-family.ts +6 -6
  52. package/introspection/src/attach-timeline-index.ts +6 -4
  53. package/introspection/src/attach-transaction-index.ts +1 -1
  54. package/introspection/src/index.ts +1 -1
  55. package/package.json +11 -12
  56. package/react/dist/index.cjs.map +1 -1
  57. package/react/dist/index.d.ts +4 -4
  58. package/react/dist/index.js.map +1 -1
  59. package/react/src/store-hooks.ts +5 -5
  60. package/react-devtools/dist/index.cjs +7 -9
  61. package/react-devtools/dist/index.cjs.map +1 -1
  62. package/react-devtools/dist/index.d.ts +10 -265
  63. package/react-devtools/dist/index.js +7 -9
  64. package/react-devtools/dist/index.js.map +1 -1
  65. package/react-devtools/src/StateEditor.tsx +3 -3
  66. package/react-devtools/src/StateIndex.tsx +3 -3
  67. package/react-devtools/src/TimelineIndex.tsx +2 -2
  68. package/react-devtools/src/Updates.tsx +1 -1
  69. package/realtime-client/dist/index.cjs +68 -66
  70. package/realtime-client/dist/index.cjs.map +1 -1
  71. package/realtime-client/dist/index.d.ts +8 -7
  72. package/realtime-client/dist/index.js +63 -62
  73. package/realtime-client/dist/index.js.map +1 -1
  74. package/realtime-client/src/pull-family-member.ts +1 -1
  75. package/realtime-client/src/pull.ts +1 -1
  76. package/realtime-client/src/push.ts +2 -3
  77. package/realtime-client/src/realtime-state.ts +11 -3
  78. package/realtime-client/src/server-action.ts +65 -65
  79. package/realtime-react/dist/index.cjs +90 -56
  80. package/realtime-react/dist/index.cjs.map +1 -1
  81. package/realtime-react/dist/index.d.ts +11 -6
  82. package/realtime-react/dist/index.js +89 -55
  83. package/realtime-react/dist/index.js.map +1 -1
  84. package/realtime-react/src/on-mount.ts +23 -0
  85. package/realtime-react/src/realtime-context.tsx +14 -6
  86. package/realtime-react/src/use-pull-family-member.ts +5 -8
  87. package/realtime-react/src/use-pull-mutable-family-member.ts +4 -7
  88. package/realtime-react/src/use-pull-mutable.ts +4 -7
  89. package/realtime-react/src/use-pull.ts +5 -8
  90. package/realtime-react/src/use-push.ts +5 -9
  91. package/realtime-react/src/use-realtime-service.ts +30 -0
  92. package/realtime-react/src/use-server-action.ts +8 -8
  93. package/realtime-server/dist/index.cjs +109 -40
  94. package/realtime-server/dist/index.cjs.map +1 -1
  95. package/realtime-server/dist/index.d.ts +7 -6
  96. package/realtime-server/dist/index.js +90 -39
  97. package/realtime-server/dist/index.js.map +1 -1
  98. package/realtime-server/src/hook-composition/expose-family.ts +2 -2
  99. package/realtime-server/src/hook-composition/expose-mutable-family.ts +1 -1
  100. package/realtime-server/src/hook-composition/expose-single.ts +1 -1
  101. package/realtime-server/src/hook-composition/index.ts +2 -1
  102. package/realtime-server/src/hook-composition/receive-state.ts +2 -2
  103. package/realtime-server/src/hook-composition/receive-transaction.ts +13 -32
  104. package/realtime-server/src/hook-composition/sync-transaction.ts +92 -0
  105. package/realtime-testing/dist/index.cjs +3 -3
  106. package/realtime-testing/dist/index.cjs.map +1 -1
  107. package/realtime-testing/dist/index.js +2 -2
  108. package/realtime-testing/dist/index.js.map +1 -1
  109. package/realtime-testing/src/setup-realtime-test.tsx +4 -3
  110. package/src/atom.ts +30 -7
  111. package/src/dispose.ts +2 -2
  112. package/src/find-state.ts +64 -0
  113. package/src/get-state.ts +2 -2
  114. package/src/index.ts +23 -0
  115. package/src/logger.ts +1 -0
  116. package/src/selector.ts +16 -0
  117. package/src/set-state.ts +2 -2
  118. package/src/silo.ts +2 -2
  119. package/src/subscribe.ts +7 -11
  120. package/src/timeline.ts +20 -12
  121. package/src/transaction.ts +31 -12
  122. package/src/validators.ts +74 -0
  123. package/dist/chunk-K22LR3V6.js +0 -138
  124. package/dist/chunk-K22LR3V6.js.map +0 -1
  125. package/internal/src/set-state/copy-mutable-into-new-store.ts +0 -34
@@ -2,27 +2,7 @@
2
2
 
3
3
  var json = require('atom.io/json');
4
4
  var atom_io = require('atom.io');
5
- var Internal2 = require('atom.io/internal');
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () { return e[k]; }
17
- });
18
- }
19
- });
20
- }
21
- n.default = e;
22
- return Object.freeze(n);
23
- }
24
-
25
- var Internal2__namespace = /*#__PURE__*/_interopNamespace(Internal2);
5
+ var internal = require('atom.io/internal');
26
6
 
27
7
  var __defProp = Object.defineProperty;
28
8
  var __defProps = Object.defineProperties;
@@ -226,7 +206,7 @@ var closeOperation = (store) => {
226
206
  );
227
207
  }
228
208
  store.operation = { open: false };
229
- store.subject.operationStatus.next(store.operation);
209
+ store.on.operationClose.next(store.operation);
230
210
  };
231
211
  var isDone = (key, store) => {
232
212
  if (!store.operation.open) {
@@ -712,13 +692,13 @@ var Store = class {
712
692
  makeContentKey: (...keys) => keys.sort().join(`:`)
713
693
  }
714
694
  );
715
- this.subject = {
695
+ this.on = {
716
696
  atomCreation: new Subject(),
717
697
  selectorCreation: new Subject(),
718
698
  transactionCreation: new Subject(),
719
699
  timelineCreation: new Subject(),
720
700
  transactionApplying: new StatefulSubject(null),
721
- operationStatus: new Subject()
701
+ operationClose: new Subject()
722
702
  };
723
703
  this.operation = { open: false };
724
704
  this.transactionMeta = null;
@@ -953,24 +933,27 @@ var registerSelector = (selectorKey, store) => ({
953
933
  updateSelectorAtoms(selectorKey, dependency, store);
954
934
  return dependencyValue;
955
935
  },
956
- set: (stateToken, newValue) => {
957
- const state = withdraw(stateToken, store);
936
+ set: (WritableToken, newValue) => {
937
+ const state = withdraw(WritableToken, store);
958
938
  if (state === void 0) {
959
939
  throw new Error(
960
- `State "${stateToken.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
940
+ `State "${WritableToken.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
961
941
  );
962
942
  }
963
943
  setAtomOrSelector(state, newValue, store);
964
- }
944
+ },
945
+ find: (token, key) => atom_io.findInStore(token, key, store)
965
946
  });
966
947
 
967
948
  // internal/src/selector/create-read-write-selector.ts
968
949
  var createReadWriteSelector = (options, family, store) => {
969
950
  const target = newest(store);
970
951
  const subject = new Subject();
971
- const { get, set } = registerSelector(options.key, store);
952
+ const transactors = registerSelector(options.key, store);
953
+ const { find, get } = transactors;
954
+ const readonlyTransactors = { find, get };
972
955
  const getSelf = () => {
973
- const value = options.get({ get });
956
+ const value = options.get(readonlyTransactors);
974
957
  cacheValue(options.key, value, subject, newest(store));
975
958
  return value;
976
959
  };
@@ -992,7 +975,7 @@ var createReadWriteSelector = (options, family, store) => {
992
975
  if (target.transactionMeta === null) {
993
976
  subject.next({ newValue, oldValue });
994
977
  }
995
- options.set({ get, set }, newValue);
978
+ options.set(transactors, newValue);
996
979
  };
997
980
  const mySelector = __spreadValues(__spreadProps(__spreadValues({}, options), {
998
981
  subject,
@@ -1011,7 +994,7 @@ var createReadWriteSelector = (options, family, store) => {
1011
994
  if (family) {
1012
995
  token.family = family;
1013
996
  }
1014
- store.subject.selectorCreation.next(token);
997
+ store.on.selectorCreation.next(token);
1015
998
  return token;
1016
999
  };
1017
1000
 
@@ -1019,9 +1002,9 @@ var createReadWriteSelector = (options, family, store) => {
1019
1002
  var createReadonlySelector = (options, family, store) => {
1020
1003
  const target = newest(store);
1021
1004
  const subject = new Subject();
1022
- const { get } = registerSelector(options.key, store);
1005
+ const { get, find } = registerSelector(options.key, store);
1023
1006
  const getSelf = () => {
1024
- const value = options.get({ get });
1007
+ const value = options.get({ get, find });
1025
1008
  cacheValue(options.key, value, subject, store);
1026
1009
  return value;
1027
1010
  };
@@ -1047,7 +1030,7 @@ var createReadonlySelector = (options, family, store) => {
1047
1030
  if (family) {
1048
1031
  token.family = family;
1049
1032
  }
1050
- store.subject.selectorCreation.next(token);
1033
+ store.on.selectorCreation.next(token);
1051
1034
  return token;
1052
1035
  };
1053
1036
 
@@ -1185,7 +1168,7 @@ function subscribeToState(token, handleUpdate, key, store) {
1185
1168
  return unsubscribe;
1186
1169
  }
1187
1170
  var subscribeToTimeline = (token, handleUpdate, key, store) => {
1188
- const tl = Internal2.withdraw(token, store);
1171
+ const tl = internal.withdraw(token, store);
1189
1172
  if (tl === void 0) {
1190
1173
  throw new Error(
1191
1174
  `Cannot subscribe to timeline "${token.key}": timeline not found in store "${store.config.name}".`
@@ -1204,7 +1187,7 @@ var subscribeToTimeline = (token, handleUpdate, key, store) => {
1204
1187
  };
1205
1188
  };
1206
1189
  var subscribeToTransaction = (token, handleUpdate, key, store) => {
1207
- const tx = Internal2.withdraw(token, store);
1190
+ const tx = internal.withdraw(token, store);
1208
1191
  if (tx === void 0) {
1209
1192
  throw new Error(
1210
1193
  `Cannot subscribe to transaction "${token.key}": transaction not found in store "${store.config.name}".`
@@ -1258,7 +1241,7 @@ var Tracker = class {
1258
1241
  `tracker:${store.config.name}:${target.transactionMeta === null ? `main` : target.transactionMeta.update.key}`,
1259
1242
  (update) => {
1260
1243
  if (target.operation.open) {
1261
- const unsubscribe = target.subject.operationStatus.subscribe(
1244
+ const unsubscribe = target.on.operationClose.subscribe(
1262
1245
  mutableState.key,
1263
1246
  () => {
1264
1247
  unsubscribe();
@@ -1281,7 +1264,7 @@ var Tracker = class {
1281
1264
  `tracker:${store.config.name}:${target2.transactionMeta === null ? `main` : target2.transactionMeta.update.key}`,
1282
1265
  (update2) => {
1283
1266
  if (target2.operation.open) {
1284
- const unsubscribe = target2.subject.operationStatus.subscribe(
1267
+ const unsubscribe = target2.on.operationClose.subscribe(
1285
1268
  mutableState.key,
1286
1269
  () => {
1287
1270
  unsubscribe();
@@ -1333,7 +1316,7 @@ var Tracker = class {
1333
1316
  return;
1334
1317
  }
1335
1318
  }
1336
- const unsubscribe = store.subject.operationStatus.subscribe(
1319
+ const unsubscribe = store.on.operationClose.subscribe(
1337
1320
  latestUpdateState.key,
1338
1321
  () => {
1339
1322
  unsubscribe();
@@ -1691,7 +1674,7 @@ function createRegularAtom(options, family, store) {
1691
1674
  }
1692
1675
  };
1693
1676
  }
1694
- store.subject.atomCreation.next(token);
1677
+ store.on.atomCreation.next(token);
1695
1678
  return token;
1696
1679
  }
1697
1680
 
@@ -1704,7 +1687,7 @@ function createAtom(options, family, store) {
1704
1687
  }
1705
1688
 
1706
1689
  // internal/src/atom/delete-atom.ts
1707
- function deleteAtom2(atomToken, store) {
1690
+ function deleteAtom(atomToken, store) {
1708
1691
  var _a, _b;
1709
1692
  const target = newest(store);
1710
1693
  const { key } = atomToken;
@@ -1735,6 +1718,39 @@ function deleteAtom2(atomToken, store) {
1735
1718
  store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
1736
1719
  }
1737
1720
 
1721
+ // internal/src/get-environment-data.ts
1722
+ function getEnvironmentData(store) {
1723
+ return {
1724
+ runtime: typeof window === `undefined` ? typeof global === `object` ? `node` : `unknown` : `browser`,
1725
+ store
1726
+ };
1727
+ }
1728
+ function ingestAtomUpdate(applying, atomUpdate, store) {
1729
+ const { key, newValue, oldValue } = atomUpdate;
1730
+ const value = applying === `newValue` ? newValue : oldValue;
1731
+ atom_io.setState({ key, type: `atom` }, value, store);
1732
+ }
1733
+
1734
+ // internal/src/ingest-updates/ingest-selector-update.ts
1735
+ function ingestSelectorUpdate(applying, selectorUpdate, store) {
1736
+ const updates = applying === `newValue` ? selectorUpdate.atomUpdates : [...selectorUpdate.atomUpdates].reverse();
1737
+ for (const atomUpdate of updates) {
1738
+ ingestAtomUpdate(applying, atomUpdate, store);
1739
+ }
1740
+ }
1741
+
1742
+ // internal/src/ingest-updates/ingest-transaction-update.ts
1743
+ function ingestTransactionUpdate(applying, transactionUpdate, store) {
1744
+ const updates = applying === `newValue` ? transactionUpdate.updates : [...transactionUpdate.updates].reverse();
1745
+ for (const updateFromTransaction of updates) {
1746
+ if (`newValue` in updateFromTransaction) {
1747
+ ingestAtomUpdate(applying, updateFromTransaction, store);
1748
+ } else {
1749
+ ingestTransactionUpdate(applying, updateFromTransaction, store);
1750
+ }
1751
+ }
1752
+ }
1753
+
1738
1754
  // internal/src/lazy-map.ts
1739
1755
  var LazyMap = class extends Map {
1740
1756
  constructor(source) {
@@ -1804,8 +1820,8 @@ var addAtomToTimeline = (atomToken, tl, store) => {
1804
1820
  const target = newest(store);
1805
1821
  const currentSelectorKey = store.operation.open && store.operation.token.type === `selector` ? store.operation.token.key : null;
1806
1822
  const currentSelectorTime = store.operation.open && store.operation.token.type === `selector` ? store.operation.time : null;
1807
- const currentTransactionKey = (_a = target.subject.transactionApplying.state) == null ? void 0 : _a.update.key;
1808
- const currentTransactionTime = (_b = target.subject.transactionApplying.state) == null ? void 0 : _b.time;
1823
+ const currentTransactionKey = (_a = target.on.transactionApplying.state) == null ? void 0 : _a.update.key;
1824
+ const currentTransactionTime = (_b = target.on.transactionApplying.state) == null ? void 0 : _b.time;
1809
1825
  store.logger.info(
1810
1826
  `\u23F3`,
1811
1827
  `timeline`,
@@ -2085,13 +2101,14 @@ function createTimeline(options, store, data) {
2085
2101
  key: timelineKey,
2086
2102
  type: `timeline`
2087
2103
  };
2088
- store.subject.timelineCreation.next(token);
2104
+ store.on.timelineCreation.next(token);
2089
2105
  return token;
2090
2106
  }
2091
- var timeTravel = (direction, token, store) => {
2092
- const action = direction === `forward` ? `redo` : `undo`;
2107
+
2108
+ // internal/src/timeline/time-travel.ts
2109
+ var timeTravel = (action, token, store) => {
2093
2110
  store.logger.info(
2094
- direction === `forward` ? `\u23E9` : `\u23EA`,
2111
+ action === `redo` ? `\u23E9` : `\u23EA`,
2095
2112
  `timeline`,
2096
2113
  token.key,
2097
2114
  action
@@ -2106,53 +2123,36 @@ var timeTravel = (direction, token, store) => {
2106
2123
  );
2107
2124
  return;
2108
2125
  }
2109
- if (direction === `forward` && timelineData.at === timelineData.history.length || direction === `backward` && timelineData.at === 0) {
2126
+ if (action === `redo` && timelineData.at === timelineData.history.length || action === `undo` && timelineData.at === 0) {
2110
2127
  store.logger.warn(
2111
2128
  `\u{1F481}`,
2112
2129
  `timeline`,
2113
2130
  token.key,
2114
- `Failed to ${action} at the ${direction === `forward` ? `end` : `beginning`} of timeline "${token.key}". There is nothing to ${action}.`
2131
+ `Failed to ${action} at the ${action === `redo` ? `end` : `beginning`} of timeline "${token.key}". There is nothing to ${action}.`
2115
2132
  );
2116
2133
  return;
2117
2134
  }
2118
- timelineData.timeTraveling = direction === `forward` ? `into_future` : `into_past`;
2119
- if (direction === `backward`) {
2135
+ timelineData.timeTraveling = action === `redo` ? `into_future` : `into_past`;
2136
+ if (action === `undo`) {
2120
2137
  --timelineData.at;
2121
2138
  }
2122
2139
  const update = timelineData.history[timelineData.at];
2123
- const updateValues = (atomUpdate) => {
2124
- const { key, newValue, oldValue } = atomUpdate;
2125
- const value = direction === `forward` ? newValue : oldValue;
2126
- atom_io.setState({ key, type: `atom` }, value, store);
2127
- };
2128
- const updateValuesFromTransactionUpdate = (transactionUpdate) => {
2129
- const updates = direction === `forward` ? transactionUpdate.updates : [...transactionUpdate.updates].reverse();
2130
- for (const updateFromTransaction of updates) {
2131
- if (`newValue` in updateFromTransaction) {
2132
- updateValues(updateFromTransaction);
2133
- } else {
2134
- updateValuesFromTransactionUpdate(updateFromTransaction);
2135
- }
2136
- }
2137
- };
2140
+ const applying = action === `redo` ? `newValue` : `oldValue`;
2138
2141
  switch (update.type) {
2139
2142
  case `atom_update`: {
2140
- updateValues(update);
2143
+ ingestAtomUpdate(applying, update, store);
2141
2144
  break;
2142
2145
  }
2143
2146
  case `selector_update`: {
2144
- const updates = direction === `forward` ? update.atomUpdates : [...update.atomUpdates].reverse();
2145
- for (const atomUpdate of updates) {
2146
- updateValues(atomUpdate);
2147
- }
2147
+ ingestSelectorUpdate(applying, update, store);
2148
2148
  break;
2149
2149
  }
2150
2150
  case `transaction_update`: {
2151
- updateValuesFromTransactionUpdate(update);
2151
+ ingestTransactionUpdate(applying, update, store);
2152
2152
  break;
2153
2153
  }
2154
2154
  }
2155
- if (direction === `forward`) {
2155
+ if (action === `redo`) {
2156
2156
  ++timelineData.at;
2157
2157
  }
2158
2158
  timelineData.subject.next(action);
@@ -2185,44 +2185,8 @@ var abortTransaction = (store) => {
2185
2185
  );
2186
2186
  target.parent.child = null;
2187
2187
  };
2188
- function ingestAtomUpdate(update, parent, child) {
2189
- var _a, _b, _c;
2190
- const { key, newValue } = update;
2191
- const token = { key, type: `atom` };
2192
- if (!parent.valueMap.has(token.key)) {
2193
- if (token.family) {
2194
- const family = parent.families.get(token.family.key);
2195
- if (family) {
2196
- family(token.family.subKey);
2197
- }
2198
- } else {
2199
- const newAtom = child.atoms.get(token.key);
2200
- if (!newAtom) {
2201
- throw new Error(
2202
- `Absurd Error: Atom "${token.key}" not found while copying updates from transaction "${(_a = child.transactionMeta) == null ? void 0 : _a.update.key}" to store "${parent.config.name}"`
2203
- );
2204
- }
2205
- parent.atoms.set(newAtom.key, newAtom);
2206
- parent.valueMap.set(newAtom.key, newAtom.default);
2207
- parent.logger.info(
2208
- `\u{1F528}`,
2209
- `transaction`,
2210
- (_c = (_b = child.transactionMeta) == null ? void 0 : _b.update.key) != null ? _c : `???`,
2211
- `Adding atom "${newAtom.key}"`
2212
- );
2213
- }
2214
- }
2215
- atom_io.setState(token, newValue, parent);
2216
- }
2217
- function ingestTransactionUpdate(transactionUpdate, parent, child) {
2218
- for (const update of transactionUpdate.updates) {
2219
- if (`newValue` in update) {
2220
- ingestAtomUpdate(update, parent, child);
2221
- } else {
2222
- ingestTransactionUpdate(update, parent, child);
2223
- }
2224
- }
2225
- }
2188
+
2189
+ // internal/src/transaction/apply-transaction.ts
2226
2190
  var applyTransaction = (output, store) => {
2227
2191
  var _a;
2228
2192
  const child = newest(store);
@@ -2239,7 +2203,7 @@ var applyTransaction = (output, store) => {
2239
2203
  child.transactionMeta.phase = `applying`;
2240
2204
  child.transactionMeta.update.output = output;
2241
2205
  parent.child = null;
2242
- parent.subject.transactionApplying.next(child.transactionMeta);
2206
+ parent.on.transactionApplying.next(child.transactionMeta);
2243
2207
  const { updates } = child.transactionMeta.update;
2244
2208
  store.logger.info(
2245
2209
  `\u{1F6C4}`,
@@ -2268,7 +2232,7 @@ var applyTransaction = (output, store) => {
2268
2232
  );
2269
2233
  }
2270
2234
  }
2271
- ingestTransactionUpdate(child.transactionMeta.update, parent, child);
2235
+ ingestTransactionUpdate(`newValue`, child.transactionMeta.update, parent);
2272
2236
  if (parent.transactionMeta === null) {
2273
2237
  const myTransaction = withdraw(
2274
2238
  { key: child.transactionMeta.update.key, type: `transaction` },
@@ -2284,46 +2248,14 @@ var applyTransaction = (output, store) => {
2284
2248
  } else {
2285
2249
  parent.transactionMeta.update.updates.push(child.transactionMeta.update);
2286
2250
  }
2287
- parent.subject.transactionApplying.next(null);
2251
+ parent.on.transactionApplying.next(null);
2288
2252
  };
2289
- function getState2(token, store = Internal2__namespace.IMPLICIT.STORE) {
2290
- var _a;
2291
- const state = (_a = Internal2__namespace.withdraw(token, store)) != null ? _a : Internal2__namespace.withdrawNewFamilyMember(token, store);
2292
- if (state === void 0) {
2293
- throw new Internal2__namespace.NotFoundError(token, store);
2294
- }
2295
- return Internal2__namespace.readOrComputeValue(state, store);
2296
- }
2297
- function setState5(token, value, store = Internal2__namespace.IMPLICIT.STORE) {
2298
- var _a;
2299
- const rejection = Internal2__namespace.openOperation(token, store);
2300
- if (rejection) {
2301
- return;
2302
- }
2303
- const state = (_a = Internal2__namespace.withdraw(token, store)) != null ? _a : Internal2__namespace.withdrawNewFamilyMember(token, store);
2304
- if (state === void 0) {
2305
- throw new Internal2__namespace.NotFoundError(token, store);
2306
- }
2307
- Internal2__namespace.setAtomOrSelector(state, value, store);
2308
- Internal2__namespace.closeOperation(store);
2309
- }
2310
- var runTransaction = (token, store = Internal2.IMPLICIT.STORE) => (...parameters) => {
2311
- const tx = Internal2.withdraw(token, store);
2312
- if (tx) {
2313
- return tx.run(...parameters);
2314
- }
2315
- throw new Error(
2316
- `Cannot run transaction "${token.key}": transaction not found in store "${store.config.name}".`
2317
- );
2318
- };
2319
-
2320
- // internal/src/transaction/build-transaction.ts
2321
- var buildTransaction = (key, params, store) => {
2253
+ var buildTransaction = (key, params, store, id) => {
2322
2254
  const parent = newest(store);
2323
2255
  const child = {
2324
2256
  parent,
2325
2257
  child: null,
2326
- subject: parent.subject,
2258
+ on: parent.on,
2327
2259
  loggers: parent.loggers,
2328
2260
  logger: parent.logger,
2329
2261
  config: parent.config,
@@ -2349,14 +2281,17 @@ var buildTransaction = (key, params, store) => {
2349
2281
  time: Date.now(),
2350
2282
  update: {
2351
2283
  key,
2284
+ id: id != null ? id : Math.random().toString(36).slice(2),
2352
2285
  updates: [],
2353
2286
  params,
2354
2287
  output: void 0
2355
2288
  },
2356
2289
  transactors: {
2357
- get: (token) => getState2(token, child),
2358
- set: (token, value) => setState5(token, value, child),
2359
- run: (token) => runTransaction(token, child)
2290
+ get: (token) => atom_io.getState(token, child),
2291
+ set: (token, value) => atom_io.setState(token, value, child),
2292
+ run: (token) => atom_io.runTransaction(token, child),
2293
+ find: (token, key2) => atom_io.findInStore(token, key2, child),
2294
+ env: () => getEnvironmentData(child)
2360
2295
  }
2361
2296
  };
2362
2297
  parent.child = child;
@@ -2370,12 +2305,12 @@ var buildTransaction = (key, params, store) => {
2370
2305
  };
2371
2306
 
2372
2307
  // internal/src/transaction/create-transaction.ts
2373
- function createTransaction2(options, store) {
2308
+ function createTransaction(options, store) {
2374
2309
  const newTransaction = {
2375
2310
  key: options.key,
2376
2311
  type: `transaction`,
2377
- run: (...params) => {
2378
- buildTransaction(options.key, params, store);
2312
+ run: (params, id) => {
2313
+ buildTransaction(options.key, params, store, id);
2379
2314
  try {
2380
2315
  const target2 = newest(store);
2381
2316
  const { transactors } = target2.transactionMeta;
@@ -2388,13 +2323,13 @@ function createTransaction2(options, store) {
2388
2323
  throw thrown;
2389
2324
  }
2390
2325
  },
2391
- install: (store2) => createTransaction2(options, store2),
2326
+ install: (store2) => createTransaction(options, store2),
2392
2327
  subject: new Subject()
2393
2328
  };
2394
2329
  const target = newest(store);
2395
2330
  target.transactions.set(newTransaction.key, newTransaction);
2396
2331
  const token = deposit(newTransaction);
2397
- store.subject.transactionCreation.next(token);
2332
+ store.on.transactionCreation.next(token);
2398
2333
  return token;
2399
2334
  }
2400
2335
 
@@ -2429,17 +2364,21 @@ exports.createRegularAtomFamily = createRegularAtomFamily;
2429
2364
  exports.createSelector = createSelector;
2430
2365
  exports.createSelectorFamily = createSelectorFamily;
2431
2366
  exports.createTimeline = createTimeline;
2432
- exports.createTransaction = createTransaction2;
2433
- exports.deleteAtom = deleteAtom2;
2367
+ exports.createTransaction = createTransaction;
2368
+ exports.deleteAtom = deleteAtom;
2434
2369
  exports.deleteSelector = deleteSelector;
2435
2370
  exports.deposit = deposit;
2436
2371
  exports.eldest = eldest;
2437
2372
  exports.evictCachedValue = evictCachedValue;
2373
+ exports.getEnvironmentData = getEnvironmentData;
2438
2374
  exports.getJsonFamily = getJsonFamily;
2439
2375
  exports.getJsonToken = getJsonToken;
2440
2376
  exports.getSelectorDependencyKeys = getSelectorDependencyKeys;
2441
2377
  exports.getUpdateFamily = getUpdateFamily;
2442
2378
  exports.getUpdateToken = getUpdateToken;
2379
+ exports.ingestAtomUpdate = ingestAtomUpdate;
2380
+ exports.ingestSelectorUpdate = ingestSelectorUpdate;
2381
+ exports.ingestTransactionUpdate = ingestTransactionUpdate;
2443
2382
  exports.isAtomDefault = isAtomDefault;
2444
2383
  exports.isAtomKey = isAtomKey;
2445
2384
  exports.isDone = isDone;