atom.io 0.6.5 → 0.6.6

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 (60) hide show
  1. package/README.md +32 -78
  2. package/dist/index.d.mts +4 -35
  3. package/dist/index.d.ts +4 -35
  4. package/dist/index.js +45 -198
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +42 -195
  7. package/dist/index.mjs.map +1 -1
  8. package/introspection/dist/index.js +312 -0
  9. package/introspection/dist/index.js.map +1 -0
  10. package/introspection/dist/index.mjs +289 -0
  11. package/introspection/dist/index.mjs.map +1 -0
  12. package/introspection/package.json +15 -0
  13. package/package.json +16 -6
  14. package/react-devtools/dist/index.css +22 -5
  15. package/react-devtools/dist/index.css.map +1 -1
  16. package/react-devtools/dist/index.d.mts +347 -8
  17. package/react-devtools/dist/index.d.ts +347 -8
  18. package/react-devtools/dist/index.js +2722 -674
  19. package/react-devtools/dist/index.js.map +1 -1
  20. package/react-devtools/dist/index.mjs +2669 -630
  21. package/react-devtools/dist/index.mjs.map +1 -1
  22. package/src/internal/index.ts +0 -1
  23. package/src/internal/operation.ts +1 -0
  24. package/src/internal/store.ts +3 -2
  25. package/src/internal/time-travel-internal.ts +2 -0
  26. package/src/internal/timeline/add-atom-to-timeline.ts +11 -12
  27. package/src/internal/timeline-internal.ts +5 -1
  28. package/src/introspection/attach-atom-index.ts +73 -0
  29. package/src/introspection/attach-introspection-states.ts +42 -0
  30. package/src/introspection/attach-selector-index.ts +77 -0
  31. package/src/introspection/attach-timeline-family.ts +49 -0
  32. package/src/introspection/attach-timeline-index.ts +36 -0
  33. package/src/introspection/attach-transaction-index.ts +38 -0
  34. package/src/introspection/attach-transaction-logs.ts +40 -0
  35. package/src/introspection/index.ts +20 -0
  36. package/src/react-devtools/AtomIODevtools.tsx +97 -96
  37. package/src/react-devtools/Button.tsx +24 -0
  38. package/src/react-devtools/StateEditor.tsx +14 -16
  39. package/src/react-devtools/StateIndex.tsx +153 -0
  40. package/src/react-devtools/TimelineIndex.tsx +92 -0
  41. package/src/react-devtools/TransactionIndex.tsx +70 -0
  42. package/src/react-devtools/Updates.tsx +145 -0
  43. package/src/react-devtools/devtools.scss +196 -15
  44. package/src/react-devtools/index.ts +71 -0
  45. package/src/react-explorer/AtomIOExplorer.tsx +0 -1
  46. package/src/react-explorer/explorer-states.ts +1 -1
  47. package/src/react-explorer/space-states.ts +3 -1
  48. package/src/react-explorer/view-states.ts +0 -2
  49. package/realtime-testing/dist/index.d.mts +0 -49
  50. package/realtime-testing/dist/index.d.ts +0 -49
  51. package/realtime-testing/dist/index.js +0 -165
  52. package/realtime-testing/dist/index.js.map +0 -1
  53. package/realtime-testing/dist/index.mjs +0 -129
  54. package/realtime-testing/dist/index.mjs.map +0 -1
  55. package/src/internal/meta/attach-meta.ts +0 -17
  56. package/src/internal/meta/index.ts +0 -4
  57. package/src/internal/meta/meta-state.ts +0 -135
  58. package/src/internal/meta/meta-timelines.ts +0 -1
  59. package/src/internal/meta/meta-transactions.ts +0 -1
  60. package/src/react-devtools/TokenList.tsx +0 -61
package/dist/index.mjs CHANGED
@@ -41,7 +41,6 @@ var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
41
41
  var internal_exports = {};
42
42
  __export(internal_exports, {
43
43
  IMPLICIT: () => IMPLICIT,
44
- META: () => meta_exports,
45
44
  Subject: () => Subject,
46
45
  TRANSACTION_PHASES: () => TRANSACTION_PHASES,
47
46
  abortTransaction: () => abortTransaction,
@@ -168,62 +167,8 @@ var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing insta
168
167
  ) : nextVersionOfThing;
169
168
  var pass = (...params) => (fn) => fn(...params);
170
169
 
171
- // ../../node_modules/.pnpm/fp-ts@2.16.0/node_modules/fp-ts/es6/function.js
172
- function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
173
- switch (arguments.length) {
174
- case 1:
175
- return a;
176
- case 2:
177
- return ab(a);
178
- case 3:
179
- return bc(ab(a));
180
- case 4:
181
- return cd(bc(ab(a)));
182
- case 5:
183
- return de(cd(bc(ab(a))));
184
- case 6:
185
- return ef(de(cd(bc(ab(a)))));
186
- case 7:
187
- return fg(ef(de(cd(bc(ab(a))))));
188
- case 8:
189
- return gh(fg(ef(de(cd(bc(ab(a)))))));
190
- case 9:
191
- return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
192
- default: {
193
- var ret = arguments[0];
194
- for (var i = 1; i < arguments.length; i++) {
195
- ret = arguments[i](ret);
196
- }
197
- return ret;
198
- }
199
- }
200
- }
201
-
202
- // ../../node_modules/.pnpm/fp-ts@2.16.0/node_modules/fp-ts/es6/string.js
203
- var Eq = {
204
- equals: function(first, second) {
205
- return first === second;
206
- }
207
- };
208
- var Semigroup = {
209
- concat: function(first, second) {
210
- return first + second;
211
- }
212
- };
213
- var empty = "";
214
- var Monoid = {
215
- concat: Semigroup.concat,
216
- empty
217
- };
218
- var Ord = {
219
- equals: Eq.equals,
220
- compare: function(first, second) {
221
- return first < second ? -1 : first > second ? 1 : 0;
222
- }
223
- };
224
- var isString = function(u) {
225
- return typeof u === "string";
226
- };
170
+ // ../anvl/src/join/core-relation-data.ts
171
+ import { isString } from "fp-ts/string";
227
172
 
228
173
  // ../anvl/src/array/venn.ts
229
174
  var includesAll = (items) => (array) => {
@@ -244,6 +189,9 @@ var addTo = (a) => (x) => a.includes(x) ? a : [...a, x];
244
189
  var isEmptyArray = (input) => Array.isArray(input) && input.length === 0;
245
190
  var isOneOf = (...args) => (input) => args.includes(input);
246
191
 
192
+ // ../anvl/src/object/refinement.ts
193
+ import { pipe as pipe2 } from "fp-ts/function";
194
+
247
195
  // ../anvl/src/object/access.ts
248
196
  var access = (k) => Object.assign((obj) => obj[k], {
249
197
  in: (obj) => obj[k]
@@ -254,6 +202,7 @@ var recordToEntries = (obj) => Object.entries(obj);
254
202
  var entriesToRecord = (entries) => Object.fromEntries(entries);
255
203
 
256
204
  // ../anvl/src/object/mapObject.ts
205
+ import { pipe } from "fp-ts/function";
257
206
  var mapObject = (obj, fn) => pipe(
258
207
  obj,
259
208
  recordToEntries,
@@ -276,14 +225,14 @@ var hasProperties = (isValue, options = { allowExtraProperties: false }) => {
276
225
  isValue
277
226
  ).map(([k, v]) => String(k) + `:` + v.name).join(`,`)}}`;
278
227
  const _ = {
279
- [name]: (input) => isPlainObject(input) && pipe(
228
+ [name]: (input) => isPlainObject(input) && pipe2(
280
229
  isValue,
281
230
  Object.entries,
282
231
  every(([key, val]) => key in input || val(void 0))
283
- ) && pipe(
232
+ ) && pipe2(
284
233
  input,
285
234
  mob(
286
- (val, key) => pipe(
235
+ (val, key) => pipe2(
287
236
  isValue,
288
237
  access(key),
289
238
  ifNullish(() => options.allowExtraProperties),
@@ -401,6 +350,9 @@ var makeJsonInterface = (join, ...params) => {
401
350
  };
402
351
  };
403
352
 
353
+ // ../anvl/src/join/relation-contents.ts
354
+ import { pipe as pipe5 } from "fp-ts/function";
355
+
404
356
  // ../anvl/src/join/relation-record.ts
405
357
  var getRelationEntries = (relationMap, idA) => getRelatedIds(relationMap, idA).map((idB) => [
406
358
  idB,
@@ -408,7 +360,12 @@ var getRelationEntries = (relationMap, idA) => getRelatedIds(relationMap, idA).m
408
360
  ]);
409
361
  var getRelationRecord = (relationMap, id) => Object.fromEntries(getRelationEntries(relationMap, id));
410
362
 
363
+ // ../anvl/src/join/remove-relation.ts
364
+ import { pipe as pipe4 } from "fp-ts/function";
365
+ import { isString as isString2 } from "fp-ts/string";
366
+
411
367
  // ../anvl/src/object/index.ts
368
+ import { pipe as pipe3 } from "fp-ts/function";
412
369
  var treeShake = (shouldDiscard = isUndefined) => (obj) => {
413
370
  const newObj = {};
414
371
  const entries = Object.entries(obj);
@@ -425,7 +382,7 @@ var split = (separator) => (str) => str.split(separator);
425
382
  var removeSpecific = (current, idA, idB) => {
426
383
  const isIdForRemoval = isOneOf(idA, idB);
427
384
  return __spreadProps(__spreadValues({}, current), {
428
- relations: pipe(
385
+ relations: pipe4(
429
386
  current.relations,
430
387
  recordToEntries,
431
388
  map(([id, relations]) => [
@@ -435,17 +392,17 @@ var removeSpecific = (current, idA, idB) => {
435
392
  entriesToRecord,
436
393
  treeShake(isEmptyArray)
437
394
  ),
438
- contents: pipe(
395
+ contents: pipe4(
439
396
  current.contents,
440
397
  treeShake(
441
- (_, key) => isString(key) && pipe(key, split(`/`), comprises([idA, idB]))
398
+ (_, key) => isString2(key) && pipe4(key, split(`/`), comprises([idA, idB]))
442
399
  )
443
400
  )
444
401
  });
445
402
  };
446
403
  var removeAll = (current, idToRemove) => {
447
404
  const next = __spreadProps(__spreadValues({}, current), {
448
- relations: pipe(
405
+ relations: pipe4(
449
406
  current.relations,
450
407
  recordToEntries,
451
408
  map(([id, relations]) => [
@@ -455,10 +412,10 @@ var removeAll = (current, idToRemove) => {
455
412
  entriesToRecord,
456
413
  treeShake((val, key) => key === idToRemove || isEmptyArray(val))
457
414
  ),
458
- contents: pipe(
415
+ contents: pipe4(
459
416
  current.contents,
460
417
  treeShake(
461
- (_, key) => isString(key) && key.split(`/`).includes(idToRemove)
418
+ (_, key) => isString2(key) && key.split(`/`).includes(idToRemove)
462
419
  )
463
420
  )
464
421
  });
@@ -540,7 +497,7 @@ var getRelations = (relationMap, id) => getRelationEntries(relationMap, id).map(
540
497
  var setRelations = (current, subject, relations) => {
541
498
  const idA = subject[current.a];
542
499
  const idB = subject[current.b];
543
- return pipe(
500
+ return pipe5(
544
501
  current,
545
502
  (relationData) => {
546
503
  const relatedIds = getRelatedIds(current, idA);
@@ -667,12 +624,13 @@ var createStore = (name, store = null) => {
667
624
  transactions: HAMT2.make(),
668
625
  timelines: HAMT2.make(),
669
626
  timelineAtoms: new Join({ relationType: `1:n` }).from(`timelineKey`).to(`atomKey`),
670
- subject: __spreadValues({
627
+ subject: {
671
628
  atomCreation: new Subject(),
672
629
  selectorCreation: new Subject(),
673
630
  transactionCreation: new Subject(),
674
- timelineCreation: new Subject()
675
- }, store == null ? void 0 : store.subject),
631
+ timelineCreation: new Subject(),
632
+ operationStatus: new Subject()
633
+ },
676
634
  operation: __spreadValues({
677
635
  open: false
678
636
  }, store == null ? void 0 : store.operation),
@@ -745,6 +703,7 @@ var closeOperation = (store) => {
745
703
  const core = target(store);
746
704
  core.operation = { open: false };
747
705
  (_a = store.config.logger) == null ? void 0 : _a.info(`\u{1F534} operation done`);
706
+ store.subject.operationStatus.next(core.operation);
748
707
  };
749
708
  var isDone = (key, store = IMPLICIT.STORE) => {
750
709
  var _a;
@@ -882,6 +841,7 @@ function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
882
841
  }
883
842
 
884
843
  // ../anvl/src/json/index.ts
844
+ import { pipe as pipe6 } from "fp-ts/function";
885
845
  var stringifyJson = (json) => JSON.stringify(json);
886
846
 
887
847
  // src/internal/families-internal.ts
@@ -976,120 +936,6 @@ function selectorFamily__INTERNAL(options, store = IMPLICIT.STORE) {
976
936
  );
977
937
  }
978
938
 
979
- // src/internal/meta/index.ts
980
- var meta_exports = {};
981
- __export(meta_exports, {
982
- attachMetaAtoms: () => attachMetaAtoms,
983
- attachMetaSelectors: () => attachMetaSelectors,
984
- attachMetaState: () => attachMetaState
985
- });
986
-
987
- // src/internal/meta/meta-state.ts
988
- var attachMetaAtoms = (store = IMPLICIT.STORE) => {
989
- const atomTokenIndexState__INTERNAL = atom({
990
- key: `\u{1F441}\u200D\u{1F5E8}_atom_token_index__INTERNAL`,
991
- default: () => [...store.atoms].reduce((acc, [key]) => {
992
- acc[key] = { key, type: `atom` };
993
- return acc;
994
- }, {}),
995
- effects: [
996
- ({ setSelf }) => {
997
- store.subject.atomCreation.subscribe((atomToken) => {
998
- if (store.operation.open) {
999
- return;
1000
- }
1001
- setSelf((state) => {
1002
- const { key, family } = atomToken;
1003
- if (family) {
1004
- const { key: familyKey, subKey } = family;
1005
- const current = state[familyKey];
1006
- if (current === void 0 || `familyMembers` in current) {
1007
- const familyKeyState = current || {
1008
- key: familyKey,
1009
- familyMembers: {}
1010
- };
1011
- return __spreadProps(__spreadValues({}, state), {
1012
- [familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
1013
- familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
1014
- [subKey]: atomToken
1015
- })
1016
- })
1017
- });
1018
- }
1019
- }
1020
- return __spreadProps(__spreadValues({}, state), {
1021
- [key]: atomToken
1022
- });
1023
- });
1024
- });
1025
- }
1026
- ]
1027
- });
1028
- return selector({
1029
- key: `\u{1F441}\u200D\u{1F5E8}_atom_token_index`,
1030
- get: ({ get }) => get(atomTokenIndexState__INTERNAL)
1031
- });
1032
- };
1033
- var attachMetaSelectors = (store = IMPLICIT.STORE) => {
1034
- const readonlySelectorTokenIndexState__INTERNAL = atom({
1035
- key: `\u{1F441}\u200D\u{1F5E8}_selector_token_index__INTERNAL`,
1036
- default: () => Object.assign(
1037
- [...store.readonlySelectors].reduce((acc, [key]) => {
1038
- acc[key] = { key, type: `readonly_selector` };
1039
- return acc;
1040
- }, {}),
1041
- [...store.selectors].reduce((acc, [key]) => {
1042
- acc[key] = { key, type: `selector` };
1043
- return acc;
1044
- }, {})
1045
- ),
1046
- effects: [
1047
- ({ setSelf }) => {
1048
- store.subject.selectorCreation.subscribe((selectorToken) => {
1049
- if (store.operation.open) {
1050
- return;
1051
- }
1052
- setSelf((state) => {
1053
- const { key, family } = selectorToken;
1054
- if (family) {
1055
- const { key: familyKey, subKey } = family;
1056
- const current = state[familyKey];
1057
- if (current === void 0 || `familyMembers` in current) {
1058
- const familyKeyState = current || {
1059
- key: familyKey,
1060
- familyMembers: {}
1061
- };
1062
- return __spreadProps(__spreadValues({}, state), {
1063
- [familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
1064
- familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
1065
- [subKey]: selectorToken
1066
- })
1067
- })
1068
- });
1069
- }
1070
- }
1071
- return __spreadProps(__spreadValues({}, state), {
1072
- [key]: selectorToken
1073
- });
1074
- });
1075
- });
1076
- }
1077
- ]
1078
- });
1079
- return selector({
1080
- key: `\u{1F441}\u200D\u{1F5E8}_selector_token_index`,
1081
- get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL)
1082
- });
1083
- };
1084
-
1085
- // src/internal/meta/attach-meta.ts
1086
- var attachMetaState = (store = IMPLICIT.STORE) => {
1087
- return {
1088
- atomTokenIndexState: attachMetaAtoms(store),
1089
- selectorTokenIndexState: attachMetaSelectors(store)
1090
- };
1091
- };
1092
-
1093
939
  // src/internal/selector-internal.ts
1094
940
  import HAMT9 from "hamt_plus";
1095
941
 
@@ -1472,6 +1318,7 @@ var redo__INTERNAL = (token, store = IMPLICIT.STORE) => {
1472
1318
  }
1473
1319
  }
1474
1320
  ++timelineData.at;
1321
+ timelineData.subject.next(`redo`);
1475
1322
  timelineData.timeTraveling = false;
1476
1323
  (_d = store.config.logger) == null ? void 0 : _d.info(
1477
1324
  `\u23F9\uFE0F "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
@@ -1511,6 +1358,7 @@ var undo__INTERNAL = (token, store = IMPLICIT.STORE) => {
1511
1358
  break;
1512
1359
  }
1513
1360
  }
1361
+ timelineData.subject.next(`undo`);
1514
1362
  timelineData.timeTraveling = false;
1515
1363
  (_d = store.config.logger) == null ? void 0 : _d.info(
1516
1364
  `\u23F9\uFE0F "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
@@ -1549,9 +1397,6 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1549
1397
  `Timeline "${tl.key}" has a selectorTime, but no history. This is most likely a bug in AtomIO.`
1550
1398
  );
1551
1399
  }
1552
- if (mostRecentUpdate.type === `selector_update`) {
1553
- tl.subject.next(mostRecentUpdate);
1554
- }
1555
1400
  }
1556
1401
  if (currentTransactionKey && store.transactionStatus.phase === `applying`) {
1557
1402
  const currentTransaction = withdraw(
@@ -1572,6 +1417,7 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1572
1417
  tl.transactionKey = currentTransactionKey;
1573
1418
  const subscription = currentTransaction.subject.subscribe((update2) => {
1574
1419
  var _a2;
1420
+ subscription.unsubscribe();
1575
1421
  if (tl.timeTraveling === false && currentTransactionTime) {
1576
1422
  if (tl.at !== tl.history.length) {
1577
1423
  tl.history.splice(tl.at);
@@ -1585,10 +1431,9 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1585
1431
  )
1586
1432
  });
1587
1433
  tl.history.push(timelineTransactionUpdate);
1434
+ tl.at = tl.history.length;
1588
1435
  tl.subject.next(timelineTransactionUpdate);
1589
1436
  }
1590
- tl.at = tl.history.length;
1591
- subscription.unsubscribe();
1592
1437
  tl.transactionKey = null;
1593
1438
  (_a2 = store.config.logger) == null ? void 0 : _a2.info(
1594
1439
  `\u231B timeline "${tl.key}" got a transaction_update "${update2.key}"`
@@ -1596,29 +1441,29 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1596
1441
  });
1597
1442
  }
1598
1443
  } else if (currentSelectorKey && currentSelectorTime) {
1444
+ let latestUpdate = tl.history.at(-1);
1599
1445
  if (currentSelectorTime !== tl.selectorTime) {
1600
- const newSelectorUpdate = {
1446
+ latestUpdate = {
1601
1447
  type: `selector_update`,
1602
1448
  timestamp: currentSelectorTime,
1603
1449
  key: currentSelectorKey,
1604
1450
  atomUpdates: []
1605
1451
  };
1606
- newSelectorUpdate.atomUpdates.push(__spreadValues({
1452
+ latestUpdate.atomUpdates.push(__spreadValues({
1607
1453
  key: atom2.key,
1608
1454
  type: `atom_update`
1609
1455
  }, update));
1610
1456
  if (tl.at !== tl.history.length) {
1611
1457
  tl.history.splice(tl.at);
1612
1458
  }
1613
- tl.history.push(newSelectorUpdate);
1459
+ tl.history.push(latestUpdate);
1614
1460
  (_c = store.config.logger) == null ? void 0 : _c.info(
1615
1461
  `\u231B timeline "${tl.key}" got a selector_update "${currentSelectorKey}" with`,
1616
- newSelectorUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key)
1462
+ latestUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key)
1617
1463
  );
1618
1464
  tl.at = tl.history.length;
1619
1465
  tl.selectorTime = currentSelectorTime;
1620
1466
  } else {
1621
- const latestUpdate = tl.history.at(-1);
1622
1467
  if ((latestUpdate == null ? void 0 : latestUpdate.type) === `selector_update`) {
1623
1468
  latestUpdate.atomUpdates.push(__spreadValues({
1624
1469
  key: atom2.key,
@@ -1630,6 +1475,8 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1630
1475
  );
1631
1476
  }
1632
1477
  }
1478
+ if (latestUpdate)
1479
+ tl.subject.next(latestUpdate);
1633
1480
  } else {
1634
1481
  const timestamp = Date.now();
1635
1482
  tl.selectorTime = null;
@@ -1646,7 +1493,7 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1646
1493
  tl.history.push(atomUpdate);
1647
1494
  tl.subject.next(atomUpdate);
1648
1495
  (_e = store.config.logger) == null ? void 0 : _e.info(
1649
- `\u231B timeline "${tl.key}" got a state_update to "${atom2.key}"`
1496
+ `\u231B timeline "${tl.key}" got an atom_update to "${atom2.key}"`
1650
1497
  );
1651
1498
  tl.at = tl.history.length;
1652
1499
  }