atom.io 0.19.0 → 0.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/data/dist/index.cjs +99 -79
  2. package/data/dist/index.js +2 -2
  3. package/data/src/join.ts +91 -74
  4. package/dist/{chunk-YDOGCZ53.js → chunk-ATKDGVTV.js} +29 -29
  5. package/dist/{chunk-CVBEVTM5.js → chunk-CC7IF7QF.js} +5 -42
  6. package/dist/{chunk-WX2NCOZR.js → chunk-FTONNX2R.js} +8 -8
  7. package/dist/{chunk-7ZR244C2.js → chunk-MSCJWACE.js} +92 -72
  8. package/dist/index.cjs +15 -7
  9. package/dist/index.d.ts +24 -35
  10. package/dist/index.js +15 -7
  11. package/internal/dist/index.cjs +56 -44
  12. package/internal/dist/index.d.ts +21 -21
  13. package/internal/dist/index.js +49 -37
  14. package/internal/src/atom/create-regular-atom.ts +7 -5
  15. package/internal/src/atom/delete-atom.ts +2 -2
  16. package/internal/src/families/create-readonly-selector-family.ts +2 -2
  17. package/internal/src/families/create-regular-atom-family.ts +1 -1
  18. package/internal/src/families/create-writable-selector-family.ts +1 -1
  19. package/internal/src/future.ts +4 -2
  20. package/internal/src/lineage.ts +1 -0
  21. package/internal/src/mutable/create-mutable-atom-family.ts +1 -1
  22. package/internal/src/mutable/create-mutable-atom.ts +7 -5
  23. package/internal/src/mutable/tracker.ts +4 -4
  24. package/internal/src/mutable/transceiver.ts +2 -2
  25. package/internal/src/selector/delete-selector.ts +1 -1
  26. package/internal/src/set-state/become.ts +1 -1
  27. package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
  28. package/internal/src/store/deposit.ts +5 -5
  29. package/internal/src/store/store.ts +5 -5
  30. package/internal/src/store/withdraw.ts +4 -5
  31. package/internal/src/subject.ts +3 -1
  32. package/internal/src/subscribe/subscribe-to-state.ts +2 -2
  33. package/internal/src/subscribe/subscribe-to-transaction.ts +4 -4
  34. package/internal/src/timeline/add-atom-to-timeline.ts +16 -11
  35. package/internal/src/timeline/create-timeline.ts +3 -4
  36. package/internal/src/transaction/act-upon-store.ts +5 -5
  37. package/internal/src/transaction/apply-transaction.ts +4 -4
  38. package/internal/src/transaction/build-transaction.ts +10 -7
  39. package/internal/src/transaction/create-transaction.ts +10 -10
  40. package/internal/src/transaction/index.ts +3 -3
  41. package/internal/src/transaction/is-root-store.ts +2 -2
  42. package/introspection/dist/index.cjs +3 -2
  43. package/introspection/dist/index.d.ts +6 -6
  44. package/introspection/dist/index.js +3 -2
  45. package/introspection/src/attach-atom-index.ts +5 -4
  46. package/introspection/src/attach-introspection-states.ts +3 -3
  47. package/introspection/src/attach-transaction-index.ts +4 -4
  48. package/introspection/src/attach-transaction-logs.ts +8 -4
  49. package/introspection/src/index.ts +3 -3
  50. package/json/dist/index.cjs +6 -2
  51. package/json/dist/index.d.ts +1 -1
  52. package/json/dist/index.js +8 -4
  53. package/json/src/select-json-family.ts +3 -2
  54. package/json/src/select-json.ts +3 -1
  55. package/package.json +243 -242
  56. package/react/dist/index.cjs +9 -3
  57. package/react/dist/index.js +9 -3
  58. package/react/src/use-i.ts +3 -1
  59. package/react/src/use-tl.ts +6 -2
  60. package/react-devtools/dist/index.cjs +332 -978
  61. package/react-devtools/dist/index.css +0 -18
  62. package/react-devtools/dist/index.d.ts +7 -9
  63. package/react-devtools/dist/index.js +291 -881
  64. package/react-devtools/src/AtomIODevtools.tsx +5 -2
  65. package/react-devtools/src/Button.tsx +6 -2
  66. package/react-devtools/src/StateEditor.tsx +13 -16
  67. package/react-devtools/src/StateIndex.tsx +28 -21
  68. package/react-devtools/src/TimelineIndex.tsx +17 -6
  69. package/react-devtools/src/TransactionIndex.tsx +13 -6
  70. package/react-devtools/src/Updates.tsx +24 -9
  71. package/realtime/dist/index.cjs +1 -0
  72. package/realtime/dist/index.d.ts +2 -2
  73. package/realtime/dist/index.js +1 -0
  74. package/realtime/src/realtime-continuity.ts +4 -3
  75. package/realtime-client/dist/index.cjs +29 -29
  76. package/realtime-client/dist/index.d.ts +2 -2
  77. package/realtime-client/dist/index.js +1 -1
  78. package/realtime-client/src/server-action.ts +2 -2
  79. package/realtime-client/src/sync-continuity.ts +23 -23
  80. package/realtime-react/dist/index.cjs +30 -30
  81. package/realtime-react/dist/index.d.ts +2 -2
  82. package/realtime-react/dist/index.js +2 -2
  83. package/realtime-react/src/use-server-action.ts +3 -3
  84. package/realtime-react/src/use-single-effect.ts +1 -1
  85. package/realtime-server/dist/index.cjs +54 -44
  86. package/realtime-server/dist/index.d.ts +6 -6
  87. package/realtime-server/dist/index.js +34 -24
  88. package/realtime-server/src/ipc-sockets/child-socket.ts +7 -7
  89. package/realtime-server/src/ipc-sockets/custom-socket.ts +4 -8
  90. package/realtime-server/src/ipc-sockets/parent-socket.ts +13 -7
  91. package/realtime-server/src/realtime-action-receiver.ts +7 -5
  92. package/realtime-server/src/realtime-continuity-synchronizer.ts +3 -3
  93. package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +2 -2
  94. package/realtime-server/src/realtime-state-receiver.ts +3 -1
  95. package/realtime-testing/dist/index.cjs +15 -13
  96. package/realtime-testing/dist/index.js +9 -7
  97. package/realtime-testing/src/setup-realtime-test.tsx +7 -5
  98. package/src/atom.ts +4 -8
  99. package/src/dispose.ts +1 -0
  100. package/src/index.ts +2 -9
  101. package/src/selector.ts +4 -8
  102. package/src/silo.ts +13 -3
  103. package/src/subscribe.ts +6 -6
  104. package/src/timeline.ts +4 -4
  105. package/src/transaction.ts +24 -24
  106. package/src/validators.ts +2 -2
  107. package/transceivers/set-rtx/dist/index.cjs +11 -12
  108. package/transceivers/set-rtx/dist/index.js +11 -12
  109. package/transceivers/set-rtx/src/set-rtx.ts +10 -10
  110. /package/dist/{chunk-VAE5OCKN.js → chunk-BF4MVQF6.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { Junction } from '../../dist/chunk-WX2NCOZR.js';
1
+ import { Junction } from '../../dist/chunk-FTONNX2R.js';
2
2
  import { __spreadValues, __spreadProps } from '../../dist/chunk-U2IICNHQ.js';
3
3
  import { stringifyJson, selectJson, parseJson, selectJsonFamily } from 'atom.io/json';
4
4
  import { AtomIOLogger } from 'atom.io';
@@ -30,7 +30,9 @@ var Subject = class {
30
30
  }
31
31
  subscribe(key, subscriber) {
32
32
  this.subscribers.set(key, subscriber);
33
- const unsubscribe = () => this.unsubscribe(key);
33
+ const unsubscribe = () => {
34
+ this.unsubscribe(key);
35
+ };
34
36
  return unsubscribe;
35
37
  }
36
38
  unsubscribe(key) {
@@ -263,8 +265,12 @@ function withdrawOrCreate(token, store) {
263
265
  var Future = class extends Promise {
264
266
  constructor(executor) {
265
267
  super((resolve, reject) => {
266
- const pass = (value) => this.isCanceled ? reject(`canceled`) : resolve(value);
267
- const fail = (reason) => this.isCanceled ? reject(`canceled`) : reject(reason);
268
+ const pass = (value) => {
269
+ this.isCanceled ? reject(`canceled`) : resolve(value);
270
+ };
271
+ const fail = (reason) => {
272
+ this.isCanceled ? reject(`canceled`) : reject(reason);
273
+ };
268
274
  if (typeof executor === `function`) {
269
275
  executor(pass, fail);
270
276
  } else {
@@ -286,7 +292,7 @@ function copyMutableIfNeeded(atom, origin, target) {
286
292
  if (originValue === void 0) {
287
293
  return typeof atom.default === `function` ? atom.default() : atom.default;
288
294
  }
289
- origin.logger.info(`\u{1F4C3}`, `atom`, `${atom.key}`, `copying`);
295
+ origin.logger.info(`\u{1F4C3}`, `atom`, atom.key, `copying`);
290
296
  const jsonValue = atom.toJson(originValue);
291
297
  const copiedValue = atom.fromJson(jsonValue);
292
298
  target.valueMap.set(atom.key, copiedValue);
@@ -391,7 +397,7 @@ function createRegularAtomFamily(options, store) {
391
397
  key: options.key,
392
398
  type: `atom_family`,
393
399
  subject,
394
- install: (store2) => createRegularAtomFamily(options, store2)
400
+ install: (s) => createRegularAtomFamily(options, s)
395
401
  }
396
402
  );
397
403
  const target = newest(store);
@@ -432,7 +438,7 @@ function createReadonlySelectorFamily(options, store) {
432
438
  key: options.key,
433
439
  type: `readonly_selector_family`,
434
440
  subject,
435
- install: (store2) => createReadonlySelectorFamily(options, store2)
441
+ install: (s) => createReadonlySelectorFamily(options, s)
436
442
  }
437
443
  );
438
444
  store.families.set(options.key, readonlySelectorFamily);
@@ -465,7 +471,7 @@ function createWritableSelectorFamily(options, store) {
465
471
  key: options.key,
466
472
  type: `selector_family`,
467
473
  subject,
468
- install: (store2) => createWritableSelectorFamily(options, store2)
474
+ install: (s) => createWritableSelectorFamily(options, s)
469
475
  }
470
476
  );
471
477
  store.families.set(options.key, selectorFamily);
@@ -974,7 +980,7 @@ function deleteSelector(selectorToken, store) {
974
980
  }
975
981
  }
976
982
  target.selectorGraph.delete(key);
977
- store.logger.info(`\u{1F525}`, selectorToken.type, `${key}`, `deleted`);
983
+ store.logger.info(`\u{1F525}`, selectorToken.type, key, `deleted`);
978
984
  }
979
985
 
980
986
  // internal/src/subscribe/recall-state.ts
@@ -1153,18 +1159,18 @@ var Tracker = class {
1153
1159
  this.unsubscribeFromInnerValue();
1154
1160
  this.unsubscribeFromInnerValue = update.newValue.subscribe(
1155
1161
  subscriptionKey,
1156
- (update2) => {
1162
+ (transceiverUpdate) => {
1157
1163
  if (target.operation.open) {
1158
1164
  const unsubscribe = target.on.operationClose.subscribe(
1159
1165
  subscriptionKey,
1160
1166
  () => {
1161
1167
  unsubscribe();
1162
- setIntoStore(latestUpdateState, update2, target);
1168
+ setIntoStore(latestUpdateState, transceiverUpdate, target);
1163
1169
  }
1164
1170
  );
1165
1171
  } else {
1166
1172
  setIntoStore(mutableState, (current) => current, target);
1167
- setIntoStore(latestUpdateState, update2, target);
1173
+ setIntoStore(latestUpdateState, transceiverUpdate, target);
1168
1174
  }
1169
1175
  }
1170
1176
  );
@@ -1273,14 +1279,14 @@ function createMutableAtom(options, family, store) {
1273
1279
  const subject = new Subject();
1274
1280
  const newAtom = __spreadProps(__spreadValues({}, options), {
1275
1281
  type: `mutable_atom`,
1276
- install: (store2) => {
1277
- store2.logger.info(
1282
+ install: (s) => {
1283
+ s.logger.info(
1278
1284
  `\u{1F6E0}\uFE0F`,
1279
1285
  `atom`,
1280
1286
  options.key,
1281
- `installing in store "${store2.config.name}"`
1287
+ `installing in store "${s.config.name}"`
1282
1288
  );
1283
- return createMutableAtom(options, family, store2);
1289
+ return createMutableAtom(options, family, s);
1284
1290
  },
1285
1291
  subject
1286
1292
  });
@@ -1297,7 +1303,9 @@ function createMutableAtom(options, family, store) {
1297
1303
  const cleanupFunctions = [];
1298
1304
  for (const effect of options.effects) {
1299
1305
  const cleanup = effect({
1300
- setSelf: (next) => setIntoStore(token, next, store),
1306
+ setSelf: (next) => {
1307
+ setIntoStore(token, next, store);
1308
+ },
1301
1309
  onSet: (handle) => subscribeToState(token, handle, `effect[${effectIndex}]`, store)
1302
1310
  });
1303
1311
  if (cleanup) {
@@ -1382,7 +1390,7 @@ function createMutableAtomFamily(options, store) {
1382
1390
  key: options.key,
1383
1391
  type: `mutable_atom_family`,
1384
1392
  subject,
1385
- install: (store2) => createMutableAtomFamily(options, store2),
1393
+ install: (s) => createMutableAtomFamily(options, s),
1386
1394
  toJson: options.toJson,
1387
1395
  fromJson: options.fromJson
1388
1396
  }
@@ -1478,14 +1486,14 @@ function createRegularAtom(options, family, store) {
1478
1486
  const subject = new Subject();
1479
1487
  const newAtom = __spreadProps(__spreadValues({}, options), {
1480
1488
  type: `atom`,
1481
- install: (store2) => {
1482
- store2.logger.info(
1489
+ install: (s) => {
1490
+ s.logger.info(
1483
1491
  `\u{1F6E0}\uFE0F`,
1484
1492
  `atom`,
1485
1493
  options.key,
1486
- `installing in store "${store2.config.name}"`
1494
+ `installing in store "${s.config.name}"`
1487
1495
  );
1488
- return createRegularAtom(options, family, store2);
1496
+ return createRegularAtom(options, family, s);
1489
1497
  },
1490
1498
  subject
1491
1499
  });
@@ -1505,7 +1513,9 @@ function createRegularAtom(options, family, store) {
1505
1513
  const cleanupFunctions = [];
1506
1514
  for (const effect of options.effects) {
1507
1515
  const cleanup = effect({
1508
- setSelf: (next) => setIntoStore(token, next, store),
1516
+ setSelf: (next) => {
1517
+ setIntoStore(token, next, store);
1518
+ },
1509
1519
  onSet: (handle) => subscribeToState(token, handle, `effect[${effectIndex}]`, store)
1510
1520
  });
1511
1521
  if (cleanup) {
@@ -1542,7 +1552,7 @@ function deleteAtom(atomToken, store) {
1542
1552
  store.logger.error(
1543
1553
  `\u274C`,
1544
1554
  `atom`,
1545
- `${key}`,
1555
+ key,
1546
1556
  `Tried to delete atom, but it does not exist in the store.`
1547
1557
  );
1548
1558
  }
@@ -1565,7 +1575,7 @@ function deleteAtom(atomToken, store) {
1565
1575
  const updateToken = getUpdateToken(atomToken);
1566
1576
  deleteAtom(updateToken, store);
1567
1577
  }
1568
- store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
1578
+ store.logger.info(`\u{1F525}`, `atom`, key, `deleted`);
1569
1579
  }
1570
1580
 
1571
1581
  // internal/src/arbitrary.ts
@@ -1709,7 +1719,7 @@ var addAtomToTimeline = (atomToken, tl, store) => {
1709
1719
  tl.transactionKey = currentTransactionKey;
1710
1720
  const unsubscribe = currentTransaction.subject.subscribe(
1711
1721
  `timeline:${tl.key}`,
1712
- (update2) => {
1722
+ (transactionUpdate) => {
1713
1723
  var _a2, _b2;
1714
1724
  unsubscribe();
1715
1725
  if (tl.timeTraveling === null && currentTransactionInstanceId) {
@@ -1717,11 +1727,11 @@ var addAtomToTimeline = (atomToken, tl, store) => {
1717
1727
  tl.history.splice(tl.at);
1718
1728
  }
1719
1729
  const filterUpdates = (updates2) => updates2.filter((updateFromTx) => {
1720
- const target2 = newest(store);
1730
+ const newestStore = newest(store);
1721
1731
  if (`updates` in updateFromTx) {
1722
1732
  return true;
1723
1733
  }
1724
- const atomOrFamilyKeys = target2.timelineAtoms.getRelatedKeys(tl.key);
1734
+ const atomOrFamilyKeys = newestStore.timelineAtoms.getRelatedKeys(tl.key);
1725
1735
  return atomOrFamilyKeys ? [...atomOrFamilyKeys].some(
1726
1736
  (key) => {
1727
1737
  var _a3;
@@ -1736,11 +1746,11 @@ var addAtomToTimeline = (atomToken, tl, store) => {
1736
1746
  }
1737
1747
  return updateFromTx;
1738
1748
  });
1739
- const updates = filterUpdates(update2.updates);
1749
+ const updates = filterUpdates(transactionUpdate.updates);
1740
1750
  const timelineTransactionUpdate = __spreadProps(__spreadValues({
1741
1751
  type: `transaction_update`,
1742
1752
  timestamp: Date.now()
1743
- }, update2), {
1753
+ }, transactionUpdate), {
1744
1754
  updates
1745
1755
  });
1746
1756
  const willCapture = (_b2 = (_a2 = tl.shouldCapture) == null ? void 0 : _a2.call(tl, timelineTransactionUpdate, tl)) != null ? _b2 : true;
@@ -1755,7 +1765,7 @@ var addAtomToTimeline = (atomToken, tl, store) => {
1755
1765
  `\u231B`,
1756
1766
  `timeline`,
1757
1767
  tl.key,
1758
- `got a transaction_update "${update2.key}"`
1768
+ `got a transaction_update "${transactionUpdate.key}"`
1759
1769
  );
1760
1770
  }
1761
1771
  );
@@ -1855,7 +1865,7 @@ function createTimeline(options, store, data) {
1855
1865
  transactionKey: null
1856
1866
  }, data), {
1857
1867
  history: (_a = data == null ? void 0 : data.history.map((update) => __spreadValues({}, update))) != null ? _a : [],
1858
- install: (store2) => createTimeline(options, store2, tl),
1868
+ install: (s) => createTimeline(options, s, tl),
1859
1869
  subject: new Subject()
1860
1870
  });
1861
1871
  if (options.shouldCapture) {
@@ -2146,16 +2156,18 @@ var buildTransaction = (key, params, store, id) => {
2146
2156
  update: {
2147
2157
  key,
2148
2158
  id,
2149
- epoch: epoch === void 0 ? NaN : epoch + 1,
2159
+ epoch: epoch === void 0 ? Number.NaN : epoch + 1,
2150
2160
  updates: [],
2151
2161
  params,
2152
2162
  output: void 0
2153
2163
  },
2154
2164
  transactors: {
2155
2165
  get: (token) => getFromStore(token, child),
2156
- set: (token, value) => setIntoStore(token, value, child),
2157
- run: (token, id2 = arbitrary()) => actUponStore(token, id2, child),
2158
- find: (token, key2) => findInStore(token, key2, child),
2166
+ set: (token, value) => {
2167
+ setIntoStore(token, value, child);
2168
+ },
2169
+ run: (token, identifier = arbitrary()) => actUponStore(token, identifier, child),
2170
+ find: (token, k) => findInStore(token, k, child),
2159
2171
  env: () => getEnvironmentData(child)
2160
2172
  }
2161
2173
  };
@@ -2192,7 +2204,7 @@ function createTransaction(options, store) {
2192
2204
  throw thrown;
2193
2205
  }
2194
2206
  },
2195
- install: (store2) => createTransaction(options, store2),
2207
+ install: (s) => createTransaction(options, s),
2196
2208
  subject: new Subject()
2197
2209
  };
2198
2210
  const target = newest(store);
@@ -41,14 +41,14 @@ export function createRegularAtom<T>(
41
41
  const newAtom: RegularAtom<T> = {
42
42
  ...options,
43
43
  type: `atom`,
44
- install: (store: Store) => {
45
- store.logger.info(
44
+ install: (s: Store) => {
45
+ s.logger.info(
46
46
  `🛠️`,
47
47
  `atom`,
48
48
  options.key,
49
- `installing in store "${store.config.name}"`,
49
+ `installing in store "${s.config.name}"`,
50
50
  )
51
- return createRegularAtom(options, family, store)
51
+ return createRegularAtom(options, family, s)
52
52
  },
53
53
  subject,
54
54
  } as const
@@ -68,7 +68,9 @@ export function createRegularAtom<T>(
68
68
  const cleanupFunctions: (() => void)[] = []
69
69
  for (const effect of options.effects) {
70
70
  const cleanup = effect({
71
- setSelf: (next) => setIntoStore(token, next, store),
71
+ setSelf: (next) => {
72
+ setIntoStore(token, next, store)
73
+ },
72
74
  onSet: (handle: UpdateHandler<T>) =>
73
75
  subscribeToState(token, handle, `effect[${effectIndex}]`, store),
74
76
  })
@@ -11,7 +11,7 @@ export function deleteAtom(atomToken: AtomToken<unknown>, store: Store): void {
11
11
  store.logger.error(
12
12
  `❌`,
13
13
  `atom`,
14
- `${key}`,
14
+ key,
15
15
  `Tried to delete atom, but it does not exist in the store.`,
16
16
  )
17
17
  }
@@ -36,5 +36,5 @@ export function deleteAtom(atomToken: AtomToken<unknown>, store: Store): void {
36
36
  const updateToken = getUpdateToken(atomToken)
37
37
  deleteAtom(updateToken, store)
38
38
  }
39
- store.logger.info(`🔥`, `atom`, `${key}`, `deleted`)
39
+ store.logger.info(`🔥`, `atom`, key, `deleted`)
40
40
  }
@@ -35,13 +35,13 @@ export function createReadonlySelectorFamily<T, K extends Json.Serializable>(
35
35
  },
36
36
  family,
37
37
  store,
38
- ) as ReadonlySelectorToken<T>
38
+ )
39
39
  },
40
40
  {
41
41
  key: options.key,
42
42
  type: `readonly_selector_family`,
43
43
  subject,
44
- install: (store: Store) => createReadonlySelectorFamily(options, store),
44
+ install: (s: Store) => createReadonlySelectorFamily(options, s),
45
45
  } as const,
46
46
  ) as ReadonlySelectorFamily<T, K>
47
47
  store.families.set(options.key, readonlySelectorFamily)
@@ -48,7 +48,7 @@ export function createRegularAtomFamily<T, K extends Json.Serializable>(
48
48
  key: options.key,
49
49
  type: `atom_family`,
50
50
  subject,
51
- install: (store: Store) => createRegularAtomFamily(options, store),
51
+ install: (s: Store) => createRegularAtomFamily(options, s),
52
52
  } as const,
53
53
  )
54
54
  const target = newest(store)
@@ -43,7 +43,7 @@ export function createWritableSelectorFamily<T, K extends Json.Serializable>(
43
43
  key: options.key,
44
44
  type: `selector_family`,
45
45
  subject,
46
- install: (store: Store) => createWritableSelectorFamily(options, store),
46
+ install: (s: Store) => createWritableSelectorFamily(options, s),
47
47
  } as const,
48
48
  ) as WritableSelectorFamily<T, K>
49
49
  store.families.set(options.key, selectorFamily)
@@ -16,10 +16,12 @@ export class Future<T> extends Promise<T> {
16
16
  | ((resolve: (value: T) => void, reject: (reason?: any) => void) => void),
17
17
  ) {
18
18
  super((resolve, reject) => {
19
- const pass = (value: T) =>
19
+ const pass = (value: T) => {
20
20
  this.isCanceled ? reject(`canceled`) : resolve(value)
21
- const fail = (reason: any) =>
21
+ }
22
+ const fail = (reason: any) => {
22
23
  this.isCanceled ? reject(`canceled`) : reject(reason)
24
+ }
23
25
  if (typeof executor === `function`) {
24
26
  executor(pass, fail)
25
27
  } else {
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-redundant-type-constituents */
1
2
  export interface Lineage {
2
3
  parent: typeof this | null
3
4
  child: typeof this | null
@@ -57,7 +57,7 @@ export function createMutableAtomFamily<
57
57
  key: options.key,
58
58
  type: `mutable_atom_family`,
59
59
  subject,
60
- install: (store: Store) => createMutableAtomFamily(options, store),
60
+ install: (s: Store) => createMutableAtomFamily(options, s),
61
61
  toJson: options.toJson,
62
62
  fromJson: options.fromJson,
63
63
  } as const,
@@ -45,14 +45,14 @@ export function createMutableAtom<
45
45
  const newAtom: MutableAtom<T, J> = {
46
46
  ...options,
47
47
  type: `mutable_atom`,
48
- install: (store: Store) => {
49
- store.logger.info(
48
+ install: (s: Store) => {
49
+ s.logger.info(
50
50
  `🛠️`,
51
51
  `atom`,
52
52
  options.key,
53
- `installing in store "${store.config.name}"`,
53
+ `installing in store "${s.config.name}"`,
54
54
  )
55
- return createMutableAtom(options, family, store)
55
+ return createMutableAtom(options, family, s)
56
56
  },
57
57
  subject,
58
58
  } as const
@@ -69,7 +69,9 @@ export function createMutableAtom<
69
69
  const cleanupFunctions: (() => void)[] = []
70
70
  for (const effect of options.effects) {
71
71
  const cleanup = effect({
72
- setSelf: (next) => setIntoStore(token, next, store),
72
+ setSelf: (next) => {
73
+ setIntoStore(token, next, store)
74
+ },
73
75
  onSet: (handle: UpdateHandler<T>) =>
74
76
  subscribeToState(token, handle, `effect[${effectIndex}]`, store),
75
77
  })
@@ -32,7 +32,7 @@ export class Tracker<Mutable extends Transceiver<any>> {
32
32
  ? {
33
33
  key: `*${mutableState.family.key}`,
34
34
  subKey: mutableState.family.subKey,
35
- }
35
+ }
36
36
  : undefined
37
37
  const latestUpdateState = createRegularAtom<
38
38
  (Mutable extends Transceiver<infer Signal> ? Signal : never) | null
@@ -87,18 +87,18 @@ export class Tracker<Mutable extends Transceiver<any>> {
87
87
  this.unsubscribeFromInnerValue()
88
88
  this.unsubscribeFromInnerValue = update.newValue.subscribe(
89
89
  subscriptionKey,
90
- (update) => {
90
+ (transceiverUpdate) => {
91
91
  if (target.operation.open) {
92
92
  const unsubscribe = target.on.operationClose.subscribe(
93
93
  subscriptionKey,
94
94
  () => {
95
95
  unsubscribe()
96
- setIntoStore(latestUpdateState, update, target)
96
+ setIntoStore(latestUpdateState, transceiverUpdate, target)
97
97
  },
98
98
  )
99
99
  } else {
100
100
  setIntoStore(mutableState, (current) => current, target)
101
- setIntoStore(latestUpdateState, update, target)
101
+ setIntoStore(latestUpdateState, transceiverUpdate, target)
102
102
  }
103
103
  },
104
104
  )
@@ -23,9 +23,9 @@ export function isTransceiver(
23
23
  export type TransceiverMode = `playback` | `record` | `transaction`
24
24
 
25
25
  export type Signal<TVR extends Transceiver<any>> = TVR extends Transceiver<
26
- infer Signal
26
+ infer S
27
27
  >
28
- ? Signal
28
+ ? S
29
29
  : never
30
30
 
31
31
  /*
@@ -33,5 +33,5 @@ export function deleteSelector(
33
33
  }
34
34
  }
35
35
  target.selectorGraph.delete(key)
36
- store.logger.info(`🔥`, selectorToken.type, `${key}`, `deleted`)
36
+ store.logger.info(`🔥`, selectorToken.type, key, `deleted`)
37
37
  }
@@ -6,5 +6,5 @@ export const become =
6
6
  nextVersionOfThing instanceof Function
7
7
  ? nextVersionOfThing(
8
8
  originalThing instanceof Function ? originalThing() : originalThing,
9
- )
9
+ )
10
10
  : nextVersionOfThing
@@ -15,7 +15,7 @@ export function copyMutableIfNeeded<T extends Transceiver<any>>(
15
15
  return typeof atom.default === `function` ? atom.default() : atom.default
16
16
  }
17
17
 
18
- origin.logger.info(`📃`, `atom`, `${atom.key}`, `copying`)
18
+ origin.logger.info(`📃`, `atom`, atom.key, `copying`)
19
19
  const jsonValue = atom.toJson(originValue)
20
20
  const copiedValue = atom.fromJson(jsonValue)
21
21
  target.valueMap.set(atom.key, copiedValue)
@@ -7,7 +7,7 @@ import type {
7
7
  TransactionToken,
8
8
  WritableSelectorToken,
9
9
  WritableToken,
10
- ƒn,
10
+ Func,
11
11
  } from "atom.io"
12
12
 
13
13
  import type {
@@ -28,22 +28,22 @@ export function deposit<T extends Transceiver<any>>(
28
28
  export function deposit<T>(state: WritableSelector<T>): WritableSelectorToken<T>
29
29
  export function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>
30
30
  export function deposit<T>(state: WritableState<T>): WritableToken<T>
31
- export function deposit<T>(
32
- state: Transaction<T extends ƒn ? T : never>,
31
+ export function deposit<T extends Func>(
32
+ state: Transaction<T>,
33
33
  ): TransactionToken<T>
34
34
  export function deposit<T>(state: ReadableState<T>): ReadableToken<T>
35
35
  export function deposit<T>(
36
36
  state:
37
37
  | ReadonlySelector<T>
38
38
  | RegularAtom<T>
39
- | Transaction<T extends ƒn ? T : never>
39
+ | Transaction<T extends Func ? T : never>
40
40
  | WritableSelector<T>
41
41
  | (T extends Transceiver<any> ? MutableAtom<T, any> : never),
42
42
  ):
43
43
  | MutableAtomToken<T extends Transceiver<any> ? T : never, any>
44
44
  | RegularAtomToken<T>
45
45
  | SelectorToken<T>
46
- | TransactionToken<T> {
46
+ | TransactionToken<T extends Func ? T : never> {
47
47
  const token = {
48
48
  key: state.key,
49
49
  type: state.type,
@@ -10,7 +10,7 @@ import type {
10
10
  TransactionToken,
11
11
  WritableSelectorFamily,
12
12
  WritableSelectorToken,
13
- ƒn,
13
+ Func,
14
14
  } from "atom.io"
15
15
 
16
16
  import { Junction } from "~/packages/rel8/junction/src"
@@ -54,7 +54,7 @@ export class Store implements Lineage {
54
54
  >()
55
55
 
56
56
  public timelines = new Map<string, Timeline<any>>()
57
- public transactions = new Map<string, Transaction<ƒn>>()
57
+ public transactions = new Map<string, Transaction<Func>>()
58
58
 
59
59
  public atomsThatAreDefault = new Set<string>()
60
60
 
@@ -85,15 +85,15 @@ export class Store implements Lineage {
85
85
  selectorCreation: new Subject<
86
86
  ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>
87
87
  >(),
88
- transactionCreation: new Subject<TransactionToken<ƒn>>(),
88
+ transactionCreation: new Subject<TransactionToken<Func>>(),
89
89
  timelineCreation: new Subject<TimelineToken<unknown>>(),
90
- transactionApplying: new StatefulSubject<TransactionProgress<ƒn> | null>(
90
+ transactionApplying: new StatefulSubject<TransactionProgress<Func> | null>(
91
91
  null,
92
92
  ),
93
93
  operationClose: new Subject<OperationProgress>(),
94
94
  }
95
95
  public operation: OperationProgress = { open: false }
96
- public transactionMeta: TransactionEpoch | TransactionProgress<ƒn> = {
96
+ public transactionMeta: TransactionEpoch | TransactionProgress<Func> = {
97
97
  epoch: new Map<string, number>(),
98
98
  actionContinuities: new Junction({
99
99
  between: [`continuity`, `action`],
@@ -22,7 +22,7 @@ import type {
22
22
  WritableSelectorFamilyToken,
23
23
  WritableSelectorToken,
24
24
  WritableToken,
25
- ƒn,
25
+ Func,
26
26
  } from "atom.io"
27
27
 
28
28
  import type { Json } from "atom.io/json"
@@ -49,7 +49,6 @@ export type Withdrawable =
49
49
  | MutableAtom<any, any>
50
50
  | MutableAtomFamily<any, any, any>
51
51
  | ReadableState<any>
52
- | ReadableState<any>
53
52
  | ReadonlySelector<any>
54
53
  | ReadonlySelectorFamily<any, any>
55
54
  | RegularAtom<any>
@@ -118,10 +117,10 @@ export function withdraw<T, K extends Json.Serializable>(
118
117
  store: Store,
119
118
  ): SelectorFamily<T, any>
120
119
 
121
- export function withdraw<T>(
120
+ export function withdraw<T extends Func>(
122
121
  token: TransactionToken<T>,
123
122
  store: Store,
124
- ): Transaction<T extends ƒn ? T : never>
123
+ ): Transaction<T extends Func ? T : never>
125
124
  export function withdraw<T>(
126
125
  token: TimelineToken<T>,
127
126
  store: Store,
@@ -133,7 +132,7 @@ export function withdraw<T>(
133
132
  | SelectorFamilyToken<T, any>
134
133
  | SelectorToken<T>
135
134
  | TimelineToken<T>
136
- | TransactionToken<T>
135
+ | TransactionToken<T extends Func ? T : never>
137
136
  | (T extends Transceiver<any>
138
137
  ? MutableAtomFamilyToken<T, any, any> | MutableAtomToken<T, any>
139
138
  : never),
@@ -5,7 +5,9 @@ export class Subject<T> {
5
5
 
6
6
  public subscribe(key: string, subscriber: this[`Subscriber`]): () => void {
7
7
  this.subscribers.set(key, subscriber)
8
- const unsubscribe = () => this.unsubscribe(key)
8
+ const unsubscribe = () => {
9
+ this.unsubscribe(key)
10
+ }
9
11
  return unsubscribe
10
12
  }
11
13
 
@@ -32,7 +32,7 @@ export function subscribeToState<T>(
32
32
  `Removing subscription "${key}"`,
33
33
  )
34
34
  unsubFunction()
35
- }
35
+ }
36
36
  : () => {
37
37
  store.logger.info(
38
38
  `🙈`,
@@ -44,7 +44,7 @@ export function subscribeToState<T>(
44
44
  for (const unsubFromDependency of dependencyUnsubFunctions) {
45
45
  unsubFromDependency()
46
46
  }
47
- }
47
+ }
48
48
 
49
49
  return unsubscribe
50
50
  }
@@ -1,10 +1,10 @@
1
- import type { TransactionToken, TransactionUpdateHandler, ƒn } from "atom.io"
1
+ import type { TransactionToken, TransactionUpdateHandler, Func } from "atom.io"
2
2
  import type { Store } from ".."
3
3
  import { withdraw } from ".."
4
4
 
5
- export const subscribeToTransaction = extends ƒn>(
6
- token: TransactionToken<ƒ>,
7
- handleUpdate: TransactionUpdateHandler<ƒ>,
5
+ export const subscribeToTransaction = <F extends Func>(
6
+ token: TransactionToken<F>,
7
+ handleUpdate: TransactionUpdateHandler<F>,
8
8
  key: string,
9
9
  store: Store,
10
10
  ): (() => void) => {