atom.io 0.6.4 → 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 (61) 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 +17 -129
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +17 -129
  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 +17 -8
  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-effects.ts +3 -3
  47. package/src/react-explorer/explorer-states.ts +1 -1
  48. package/src/react-explorer/space-states.ts +6 -4
  49. package/src/react-explorer/view-states.ts +0 -2
  50. package/realtime-testing/dist/index.d.mts +0 -49
  51. package/realtime-testing/dist/index.d.ts +0 -49
  52. package/realtime-testing/dist/index.js +0 -165
  53. package/realtime-testing/dist/index.js.map +0 -1
  54. package/realtime-testing/dist/index.mjs +0 -129
  55. package/realtime-testing/dist/index.mjs.map +0 -1
  56. package/src/internal/meta/attach-meta.ts +0 -17
  57. package/src/internal/meta/index.ts +0 -4
  58. package/src/internal/meta/meta-state.ts +0 -135
  59. package/src/internal/meta/meta-timelines.ts +0 -1
  60. package/src/internal/meta/meta-transactions.ts +0 -1
  61. 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,
@@ -625,12 +624,13 @@ var createStore = (name, store = null) => {
625
624
  transactions: HAMT2.make(),
626
625
  timelines: HAMT2.make(),
627
626
  timelineAtoms: new Join({ relationType: `1:n` }).from(`timelineKey`).to(`atomKey`),
628
- subject: __spreadValues({
627
+ subject: {
629
628
  atomCreation: new Subject(),
630
629
  selectorCreation: new Subject(),
631
630
  transactionCreation: new Subject(),
632
- timelineCreation: new Subject()
633
- }, store == null ? void 0 : store.subject),
631
+ timelineCreation: new Subject(),
632
+ operationStatus: new Subject()
633
+ },
634
634
  operation: __spreadValues({
635
635
  open: false
636
636
  }, store == null ? void 0 : store.operation),
@@ -703,6 +703,7 @@ var closeOperation = (store) => {
703
703
  const core = target(store);
704
704
  core.operation = { open: false };
705
705
  (_a = store.config.logger) == null ? void 0 : _a.info(`\u{1F534} operation done`);
706
+ store.subject.operationStatus.next(core.operation);
706
707
  };
707
708
  var isDone = (key, store = IMPLICIT.STORE) => {
708
709
  var _a;
@@ -935,120 +936,6 @@ function selectorFamily__INTERNAL(options, store = IMPLICIT.STORE) {
935
936
  );
936
937
  }
937
938
 
938
- // src/internal/meta/index.ts
939
- var meta_exports = {};
940
- __export(meta_exports, {
941
- attachMetaAtoms: () => attachMetaAtoms,
942
- attachMetaSelectors: () => attachMetaSelectors,
943
- attachMetaState: () => attachMetaState
944
- });
945
-
946
- // src/internal/meta/meta-state.ts
947
- var attachMetaAtoms = (store = IMPLICIT.STORE) => {
948
- const atomTokenIndexState__INTERNAL = atom({
949
- key: `\u{1F441}\u200D\u{1F5E8}_atom_token_index__INTERNAL`,
950
- default: () => [...store.atoms].reduce((acc, [key]) => {
951
- acc[key] = { key, type: `atom` };
952
- return acc;
953
- }, {}),
954
- effects: [
955
- ({ setSelf }) => {
956
- store.subject.atomCreation.subscribe((atomToken) => {
957
- if (store.operation.open) {
958
- return;
959
- }
960
- setSelf((state) => {
961
- const { key, family } = atomToken;
962
- if (family) {
963
- const { key: familyKey, subKey } = family;
964
- const current = state[familyKey];
965
- if (current === void 0 || `familyMembers` in current) {
966
- const familyKeyState = current || {
967
- key: familyKey,
968
- familyMembers: {}
969
- };
970
- return __spreadProps(__spreadValues({}, state), {
971
- [familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
972
- familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
973
- [subKey]: atomToken
974
- })
975
- })
976
- });
977
- }
978
- }
979
- return __spreadProps(__spreadValues({}, state), {
980
- [key]: atomToken
981
- });
982
- });
983
- });
984
- }
985
- ]
986
- });
987
- return selector({
988
- key: `\u{1F441}\u200D\u{1F5E8}_atom_token_index`,
989
- get: ({ get }) => get(atomTokenIndexState__INTERNAL)
990
- });
991
- };
992
- var attachMetaSelectors = (store = IMPLICIT.STORE) => {
993
- const readonlySelectorTokenIndexState__INTERNAL = atom({
994
- key: `\u{1F441}\u200D\u{1F5E8}_selector_token_index__INTERNAL`,
995
- default: () => Object.assign(
996
- [...store.readonlySelectors].reduce((acc, [key]) => {
997
- acc[key] = { key, type: `readonly_selector` };
998
- return acc;
999
- }, {}),
1000
- [...store.selectors].reduce((acc, [key]) => {
1001
- acc[key] = { key, type: `selector` };
1002
- return acc;
1003
- }, {})
1004
- ),
1005
- effects: [
1006
- ({ setSelf }) => {
1007
- store.subject.selectorCreation.subscribe((selectorToken) => {
1008
- if (store.operation.open) {
1009
- return;
1010
- }
1011
- setSelf((state) => {
1012
- const { key, family } = selectorToken;
1013
- if (family) {
1014
- const { key: familyKey, subKey } = family;
1015
- const current = state[familyKey];
1016
- if (current === void 0 || `familyMembers` in current) {
1017
- const familyKeyState = current || {
1018
- key: familyKey,
1019
- familyMembers: {}
1020
- };
1021
- return __spreadProps(__spreadValues({}, state), {
1022
- [familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
1023
- familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
1024
- [subKey]: selectorToken
1025
- })
1026
- })
1027
- });
1028
- }
1029
- }
1030
- return __spreadProps(__spreadValues({}, state), {
1031
- [key]: selectorToken
1032
- });
1033
- });
1034
- });
1035
- }
1036
- ]
1037
- });
1038
- return selector({
1039
- key: `\u{1F441}\u200D\u{1F5E8}_selector_token_index`,
1040
- get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL)
1041
- });
1042
- };
1043
-
1044
- // src/internal/meta/attach-meta.ts
1045
- var attachMetaState = (store = IMPLICIT.STORE) => {
1046
- return {
1047
- atomTokenIndexState: attachMetaAtoms(store),
1048
- selectorTokenIndexState: attachMetaSelectors(store)
1049
- };
1050
- };
1051
-
1052
939
  // src/internal/selector-internal.ts
1053
940
  import HAMT9 from "hamt_plus";
1054
941
 
@@ -1431,6 +1318,7 @@ var redo__INTERNAL = (token, store = IMPLICIT.STORE) => {
1431
1318
  }
1432
1319
  }
1433
1320
  ++timelineData.at;
1321
+ timelineData.subject.next(`redo`);
1434
1322
  timelineData.timeTraveling = false;
1435
1323
  (_d = store.config.logger) == null ? void 0 : _d.info(
1436
1324
  `\u23F9\uFE0F "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
@@ -1470,6 +1358,7 @@ var undo__INTERNAL = (token, store = IMPLICIT.STORE) => {
1470
1358
  break;
1471
1359
  }
1472
1360
  }
1361
+ timelineData.subject.next(`undo`);
1473
1362
  timelineData.timeTraveling = false;
1474
1363
  (_d = store.config.logger) == null ? void 0 : _d.info(
1475
1364
  `\u23F9\uFE0F "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
@@ -1508,9 +1397,6 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1508
1397
  `Timeline "${tl.key}" has a selectorTime, but no history. This is most likely a bug in AtomIO.`
1509
1398
  );
1510
1399
  }
1511
- if (mostRecentUpdate.type === `selector_update`) {
1512
- tl.subject.next(mostRecentUpdate);
1513
- }
1514
1400
  }
1515
1401
  if (currentTransactionKey && store.transactionStatus.phase === `applying`) {
1516
1402
  const currentTransaction = withdraw(
@@ -1531,6 +1417,7 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1531
1417
  tl.transactionKey = currentTransactionKey;
1532
1418
  const subscription = currentTransaction.subject.subscribe((update2) => {
1533
1419
  var _a2;
1420
+ subscription.unsubscribe();
1534
1421
  if (tl.timeTraveling === false && currentTransactionTime) {
1535
1422
  if (tl.at !== tl.history.length) {
1536
1423
  tl.history.splice(tl.at);
@@ -1544,10 +1431,9 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1544
1431
  )
1545
1432
  });
1546
1433
  tl.history.push(timelineTransactionUpdate);
1434
+ tl.at = tl.history.length;
1547
1435
  tl.subject.next(timelineTransactionUpdate);
1548
1436
  }
1549
- tl.at = tl.history.length;
1550
- subscription.unsubscribe();
1551
1437
  tl.transactionKey = null;
1552
1438
  (_a2 = store.config.logger) == null ? void 0 : _a2.info(
1553
1439
  `\u231B timeline "${tl.key}" got a transaction_update "${update2.key}"`
@@ -1555,29 +1441,29 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1555
1441
  });
1556
1442
  }
1557
1443
  } else if (currentSelectorKey && currentSelectorTime) {
1444
+ let latestUpdate = tl.history.at(-1);
1558
1445
  if (currentSelectorTime !== tl.selectorTime) {
1559
- const newSelectorUpdate = {
1446
+ latestUpdate = {
1560
1447
  type: `selector_update`,
1561
1448
  timestamp: currentSelectorTime,
1562
1449
  key: currentSelectorKey,
1563
1450
  atomUpdates: []
1564
1451
  };
1565
- newSelectorUpdate.atomUpdates.push(__spreadValues({
1452
+ latestUpdate.atomUpdates.push(__spreadValues({
1566
1453
  key: atom2.key,
1567
1454
  type: `atom_update`
1568
1455
  }, update));
1569
1456
  if (tl.at !== tl.history.length) {
1570
1457
  tl.history.splice(tl.at);
1571
1458
  }
1572
- tl.history.push(newSelectorUpdate);
1459
+ tl.history.push(latestUpdate);
1573
1460
  (_c = store.config.logger) == null ? void 0 : _c.info(
1574
1461
  `\u231B timeline "${tl.key}" got a selector_update "${currentSelectorKey}" with`,
1575
- newSelectorUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key)
1462
+ latestUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key)
1576
1463
  );
1577
1464
  tl.at = tl.history.length;
1578
1465
  tl.selectorTime = currentSelectorTime;
1579
1466
  } else {
1580
- const latestUpdate = tl.history.at(-1);
1581
1467
  if ((latestUpdate == null ? void 0 : latestUpdate.type) === `selector_update`) {
1582
1468
  latestUpdate.atomUpdates.push(__spreadValues({
1583
1469
  key: atom2.key,
@@ -1589,6 +1475,8 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1589
1475
  );
1590
1476
  }
1591
1477
  }
1478
+ if (latestUpdate)
1479
+ tl.subject.next(latestUpdate);
1592
1480
  } else {
1593
1481
  const timestamp = Date.now();
1594
1482
  tl.selectorTime = null;
@@ -1605,7 +1493,7 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
1605
1493
  tl.history.push(atomUpdate);
1606
1494
  tl.subject.next(atomUpdate);
1607
1495
  (_e = store.config.logger) == null ? void 0 : _e.info(
1608
- `\u231B timeline "${tl.key}" got a state_update to "${atom2.key}"`
1496
+ `\u231B timeline "${tl.key}" got an atom_update to "${atom2.key}"`
1609
1497
  );
1610
1498
  tl.at = tl.history.length;
1611
1499
  }