atom.io 0.14.1 → 0.14.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 (70) hide show
  1. package/data/dist/index.cjs +12 -64
  2. package/data/dist/index.cjs.map +1 -1
  3. package/data/dist/index.d.cts +2 -0
  4. package/data/dist/index.js +1 -1
  5. package/dist/{chunk-KW7RA7IM.js → chunk-C4YZZNRH.js} +4 -4
  6. package/dist/{chunk-LFXB7Y6M.js → chunk-CWKKQKVQ.js} +2 -2
  7. package/dist/{chunk-CK7GNCU5.js → chunk-GMN5KH6A.js} +2 -2
  8. package/dist/{chunk-5VJ77LZE.js → chunk-N7ADBQJG.js} +2 -2
  9. package/dist/{chunk-TE3ZSTQ6.js → chunk-PURABO5G.js} +92 -27
  10. package/dist/chunk-PURABO5G.js.map +1 -0
  11. package/dist/index.cjs +106 -20
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +4 -1
  14. package/dist/index.js +1 -1
  15. package/dist/metafile-cjs.json +1 -1
  16. package/internal/dist/index.cjs +93 -29
  17. package/internal/dist/index.cjs.map +1 -1
  18. package/internal/dist/index.d.cts +6 -4
  19. package/internal/dist/index.js +1 -1
  20. package/internal/src/atom/create-atom.ts +3 -1
  21. package/internal/src/families/create-atom-family.ts +3 -4
  22. package/internal/src/mutable/get-update-family.ts +23 -0
  23. package/internal/src/mutable/index.ts +1 -4
  24. package/internal/src/mutable/is-mutable.ts +44 -0
  25. package/internal/src/mutable/tracker.ts +9 -2
  26. package/internal/src/subject.ts +2 -1
  27. package/internal/src/timeline/add-atom-to-timeline.ts +10 -1
  28. package/internal/src/timeline/create-timeline.ts +44 -16
  29. package/introspection/dist/index.cjs +12 -64
  30. package/introspection/dist/index.cjs.map +1 -1
  31. package/introspection/dist/index.d.cts +2 -0
  32. package/introspection/dist/index.js +2 -2
  33. package/json/dist/index.cjs +9 -64
  34. package/json/dist/index.cjs.map +1 -1
  35. package/json/dist/index.d.cts +2 -0
  36. package/json/dist/index.js +1 -1
  37. package/package.json +1 -1
  38. package/react/dist/index.cjs +9 -64
  39. package/react/dist/index.cjs.map +1 -1
  40. package/react/dist/index.d.cts +2 -0
  41. package/react/dist/index.js +2 -2
  42. package/react-devtools/dist/index.cjs +12 -64
  43. package/react-devtools/dist/index.cjs.map +1 -1
  44. package/react-devtools/dist/index.d.cts +2 -0
  45. package/react-devtools/dist/index.js +3 -3
  46. package/realtime-client/dist/index.cjs +9 -64
  47. package/realtime-client/dist/index.cjs.map +1 -1
  48. package/realtime-client/dist/index.d.cts +2 -0
  49. package/realtime-client/dist/index.js +2 -2
  50. package/realtime-react/dist/index.cjs +9 -64
  51. package/realtime-react/dist/index.cjs.map +1 -1
  52. package/realtime-react/dist/index.js +4 -4
  53. package/realtime-server/dist/index.cjs +9 -64
  54. package/realtime-server/dist/index.cjs.map +1 -1
  55. package/realtime-server/dist/index.d.cts +4 -1
  56. package/realtime-server/dist/index.js +1 -1
  57. package/realtime-testing/dist/index.cjs +104 -79
  58. package/realtime-testing/dist/index.cjs.map +1 -1
  59. package/realtime-testing/dist/index.d.cts +4 -1
  60. package/realtime-testing/dist/index.js +4 -4
  61. package/src/atom.ts +3 -1
  62. package/transceivers/set-rtx/dist/index.cjs +2 -1
  63. package/transceivers/set-rtx/dist/index.cjs.map +1 -1
  64. package/transceivers/set-rtx/dist/index.js +1 -1
  65. package/dist/chunk-TE3ZSTQ6.js.map +0 -1
  66. package/internal/src/mutable/is-atom-token-mutable.ts +0 -7
  67. /package/dist/{chunk-KW7RA7IM.js.map → chunk-C4YZZNRH.js.map} +0 -0
  68. /package/dist/{chunk-LFXB7Y6M.js.map → chunk-CWKKQKVQ.js.map} +0 -0
  69. /package/dist/{chunk-CK7GNCU5.js.map → chunk-GMN5KH6A.js.map} +0 -0
  70. /package/dist/{chunk-5VJ77LZE.js.map → chunk-N7ADBQJG.js.map} +0 -0
@@ -11,6 +11,7 @@ type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomTok
11
11
  key: string;
12
12
  type: `atom_family`;
13
13
  subject: Subject<AtomToken<T>>;
14
+ mutable?: boolean;
14
15
  };
15
16
 
16
17
  declare const LoggerIconDictionary: {
@@ -364,6 +365,7 @@ declare class Store implements Lineage {
364
365
  type Atom<T> = {
365
366
  key: string;
366
367
  type: `atom`;
368
+ mutable?: boolean;
367
369
  family?: FamilyMetadata;
368
370
  install: (store: Store) => void;
369
371
  subject: Subject<{
@@ -1,4 +1,4 @@
1
- export { StoreContext, StoreProvider, useI, useJSON, useO, useTL } from '../../dist/chunk-LFXB7Y6M.js';
2
- import '../../dist/chunk-TE3ZSTQ6.js';
1
+ export { StoreContext, StoreProvider, useI, useJSON, useO, useTL } from '../../dist/chunk-CWKKQKVQ.js';
2
+ import '../../dist/chunk-PURABO5G.js';
3
3
  //# sourceMappingURL=out.js.map
4
4
  //# sourceMappingURL=index.js.map
@@ -301,7 +301,8 @@ var Subject = class {
301
301
  this.subscribers.delete(key);
302
302
  }
303
303
  next(value) {
304
- for (const subscriber of this.subscribers.values()) {
304
+ const subscribers = this.subscribers.values();
305
+ for (const subscriber of subscribers) {
305
306
  subscriber(value);
306
307
  }
307
308
  }
@@ -1108,35 +1109,6 @@ function createSelector(options, family, store) {
1108
1109
  return createReadonlySelector(options, family, store);
1109
1110
  }
1110
1111
 
1111
- // internal/src/selector/delete-selector.ts
1112
- function deleteSelector(selectorToken, store) {
1113
- const target = newest(store);
1114
- const { key } = selectorToken;
1115
- switch (selectorToken.type) {
1116
- case `selector`:
1117
- target.selectors.delete(key);
1118
- break;
1119
- case `readonly_selector`:
1120
- target.readonlySelectors.delete(key);
1121
- break;
1122
- }
1123
- target.valueMap.delete(key);
1124
- target.selectorAtoms.delete(key);
1125
- const downstreamTokens = target.selectorGraph.getRelationEntries({ upstreamSelectorKey: key }).filter(([_, { source }]) => source === key).map(
1126
- ([downstreamSelectorKey]) => {
1127
- var _a2;
1128
- return (_a2 = target.selectors.get(downstreamSelectorKey)) != null ? _a2 : target.readonlySelectors.get(downstreamSelectorKey);
1129
- }
1130
- );
1131
- for (const downstreamToken of downstreamTokens) {
1132
- if (downstreamToken) {
1133
- deleteSelector(downstreamToken, store);
1134
- }
1135
- }
1136
- target.selectorGraph.delete(key);
1137
- store.logger.info(`\u{1F525}`, selectorToken.type, `${key}`, `deleted`);
1138
- }
1139
-
1140
1112
  // internal/src/subscribe/recall-state.ts
1141
1113
  var recallState = (state, store) => {
1142
1114
  const target = newest(store);
@@ -1255,7 +1227,8 @@ var Tracker = class {
1255
1227
  }
1256
1228
  initializeState(mutableState, store) {
1257
1229
  const latestUpdateStateKey = `*${mutableState.key}`;
1258
- deleteAtom({ type: `atom`, key: latestUpdateStateKey }, store);
1230
+ store.atoms.delete(latestUpdateStateKey);
1231
+ store.valueMap.delete(latestUpdateStateKey);
1259
1232
  const familyMetaData = mutableState.family ? {
1260
1233
  key: `*${mutableState.family.key}`,
1261
1234
  subKey: mutableState.family.subKey
@@ -1268,6 +1241,10 @@ var Tracker = class {
1268
1241
  familyMetaData,
1269
1242
  store
1270
1243
  );
1244
+ if (store.parent) {
1245
+ const parentValue = store.parent.valueMap.get(latestUpdateStateKey);
1246
+ store.valueMap.set(latestUpdateStateKey, parentValue);
1247
+ }
1271
1248
  return latestUpdateState;
1272
1249
  }
1273
1250
  observeCore(mutableState, latestUpdateState, store) {
@@ -1348,7 +1325,7 @@ var Tracker = class {
1348
1325
  () => {
1349
1326
  unsubscribe();
1350
1327
  const mutable = getState(mutableState, store);
1351
- const updateNumber = mutable.getUpdateNumber(newValue);
1328
+ const updateNumber = newValue === null ? -1 : mutable.getUpdateNumber(newValue);
1352
1329
  const eventOffset = updateNumber - mutable.cacheUpdateNumber;
1353
1330
  if (newValue && eventOffset === 1) {
1354
1331
  setState(
@@ -1423,6 +1400,9 @@ function createAtomFamily(options, store) {
1423
1400
  subject
1424
1401
  }
1425
1402
  );
1403
+ if (`mutable` in options && typeof options.mutable === `boolean`) {
1404
+ Object.assign(atomFamily2, { mutable: options.mutable });
1405
+ }
1426
1406
  const target = newest(store);
1427
1407
  target.families.set(options.key, atomFamily2);
1428
1408
  return atomFamily2;
@@ -1626,38 +1606,6 @@ function createAtom(options, family, store) {
1626
1606
  return token;
1627
1607
  }
1628
1608
 
1629
- // internal/src/atom/delete-atom.ts
1630
- function deleteAtom(atomToken, store) {
1631
- var _a2, _b;
1632
- const target = newest(store);
1633
- const { key } = atomToken;
1634
- const atom2 = target.atoms.get(key);
1635
- if (!atom2) {
1636
- store.logger.error(
1637
- `\u274C`,
1638
- `atom`,
1639
- `${key}`,
1640
- `Tried to delete atom, but it does not exist in the store.`
1641
- );
1642
- }
1643
- (_a2 = atom2 == null ? void 0 : atom2.cleanup) == null ? void 0 : _a2.call(atom2);
1644
- target.atoms.delete(key);
1645
- target.valueMap.delete(key);
1646
- const selectorKeys = target.selectorAtoms.getRelatedKeys(key);
1647
- if (selectorKeys) {
1648
- for (const selectorKey of selectorKeys) {
1649
- const token = (_b = target.selectors.get(selectorKey)) != null ? _b : target.readonlySelectors.get(selectorKey);
1650
- if (token) {
1651
- deleteSelector(token, store);
1652
- }
1653
- }
1654
- }
1655
- target.selectorAtoms.delete(key);
1656
- target.atomsThatAreDefault.delete(key);
1657
- target.timelineAtoms.delete(key);
1658
- store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
1659
- }
1660
-
1661
1609
  // internal/src/not-found-error.ts
1662
1610
  var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
1663
1611
  function prettyPrintTokenType(token) {