atom.io 0.16.1 → 0.16.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 (43) hide show
  1. package/data/dist/index.cjs +31 -14
  2. package/data/dist/index.cjs.map +1 -1
  3. package/data/dist/index.js +31 -14
  4. package/data/dist/index.js.map +1 -1
  5. package/data/src/join.ts +31 -14
  6. package/dist/index.cjs +6 -3
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.ts +4 -3
  9. package/dist/index.js +6 -3
  10. package/dist/index.js.map +1 -1
  11. package/internal/dist/index.cjs +17 -12
  12. package/internal/dist/index.cjs.map +1 -1
  13. package/internal/dist/index.js +17 -12
  14. package/internal/dist/index.js.map +1 -1
  15. package/internal/src/mutable/tracker.ts +13 -11
  16. package/internal/src/set-state/set-atom.ts +7 -4
  17. package/internal/src/transaction/build-transaction.ts +1 -1
  18. package/package.json +2 -2
  19. package/realtime-client/dist/index.cjs +1 -0
  20. package/realtime-client/dist/index.cjs.map +1 -1
  21. package/realtime-client/dist/index.js +1 -0
  22. package/realtime-client/dist/index.js.map +1 -1
  23. package/realtime-client/src/sync-server-action.ts +1 -0
  24. package/realtime-react/dist/index.cjs +2 -2
  25. package/realtime-react/dist/index.cjs.map +1 -1
  26. package/realtime-react/dist/index.js +2 -2
  27. package/realtime-react/dist/index.js.map +1 -1
  28. package/realtime-react/src/use-server-action.ts +1 -1
  29. package/realtime-react/src/use-sync-server-action.ts +1 -1
  30. package/realtime-server/dist/index.cjs +19 -8
  31. package/realtime-server/dist/index.cjs.map +1 -1
  32. package/realtime-server/dist/index.d.ts +11 -4
  33. package/realtime-server/dist/index.js +19 -8
  34. package/realtime-server/dist/index.js.map +1 -1
  35. package/realtime-server/src/realtime-action-receiver.ts +4 -3
  36. package/realtime-server/src/realtime-action-synchronizer.ts +13 -1
  37. package/realtime-server/src/realtime-family-provider.ts +8 -4
  38. package/realtime-server/src/realtime-mutable-family-provider.ts +13 -17
  39. package/realtime-server/src/realtime-mutable-provider.ts +1 -0
  40. package/realtime-server/src/realtime-state-provider.ts +1 -0
  41. package/realtime-server/src/realtime-state-receiver.ts +1 -0
  42. package/src/logger.ts +15 -11
  43. package/src/transaction.ts +1 -1
@@ -503,11 +503,14 @@ var setAtom = (atom, next, target) => {
503
503
  const update = { oldValue, newValue };
504
504
  if (target.transactionMeta === null) {
505
505
  emitUpdate(atom, update, target);
506
- } else if (target.on.transactionApplying && target.parent) {
507
- stowUpdate(atom, update, target);
508
- if (atom.key.startsWith(`*`)) {
506
+ } else if (target.parent) {
507
+ if (target.on.transactionApplying.state === null) {
508
+ stowUpdate(atom, update, target);
509
+ } else if (atom.key.startsWith(`*`)) {
509
510
  const mutableKey = atom.key.slice(1);
510
- const mutable = target.valueMap.get(mutableKey);
511
+ const mutableAtom = target.atoms.get(mutableKey);
512
+ let mutable = target.valueMap.get(mutableKey);
513
+ mutable = copyMutableIfWithinTransaction(mutable, mutableAtom, target);
511
514
  mutable.do(update.newValue);
512
515
  }
513
516
  }
@@ -928,6 +931,7 @@ var Tracker = class {
928
931
  return latestUpdateState;
929
932
  }
930
933
  observeCore(mutableState, latestUpdateState, store) {
934
+ const subscriptionKey = `tracker:${store.config.name}:${store.transactionMeta === null ? `main` : store.transactionMeta.update.key}:${mutableState.key}`;
931
935
  const originalInnerValue = getState(mutableState, store);
932
936
  const target = newest(store);
933
937
  this.unsubscribeFromInnerValue = originalInnerValue.subscribe(
@@ -935,7 +939,7 @@ var Tracker = class {
935
939
  (update) => {
936
940
  if (target.operation.open) {
937
941
  const unsubscribe = target.on.operationClose.subscribe(
938
- mutableState.key,
942
+ subscriptionKey,
939
943
  () => {
940
944
  unsubscribe();
941
945
  setState(latestUpdateState, update, target);
@@ -954,11 +958,11 @@ var Tracker = class {
954
958
  this.unsubscribeFromInnerValue();
955
959
  const target2 = newest(store);
956
960
  this.unsubscribeFromInnerValue = update.newValue.subscribe(
957
- `tracker:${store.config.name}:${target2.transactionMeta === null ? `main` : target2.transactionMeta.update.key}`,
961
+ subscriptionKey,
958
962
  (update2) => {
959
963
  if (target2.operation.open) {
960
964
  const unsubscribe = target2.on.operationClose.subscribe(
961
- mutableState.key,
965
+ subscriptionKey,
962
966
  () => {
963
967
  unsubscribe();
964
968
  setState(latestUpdateState, update2, target2);
@@ -972,11 +976,12 @@ var Tracker = class {
972
976
  );
973
977
  }
974
978
  },
975
- `${store.config.name}: tracker observing inner value`,
979
+ subscriptionKey,
976
980
  store
977
981
  );
978
982
  }
979
983
  updateCore(mutableState, latestUpdateState, store) {
984
+ const subscriptionKey = `tracker:${store.config.name}:${store.transactionMeta === null ? `main` : store.transactionMeta.update.key}:${mutableState.key}`;
980
985
  subscribeToState(
981
986
  latestUpdateState,
982
987
  ({ newValue, oldValue }) => {
@@ -1003,14 +1008,14 @@ var Tracker = class {
1003
1008
  store
1004
1009
  );
1005
1010
  },
1006
- `${mutableState.key}: tracker observing timeline`,
1011
+ subscriptionKey,
1007
1012
  store
1008
1013
  );
1009
1014
  return;
1010
1015
  }
1011
1016
  }
1012
1017
  const unsubscribe = store.on.operationClose.subscribe(
1013
- latestUpdateState.key,
1018
+ subscriptionKey,
1014
1019
  () => {
1015
1020
  unsubscribe();
1016
1021
  const mutable = getState(mutableState, store);
@@ -1026,7 +1031,7 @@ var Tracker = class {
1026
1031
  }
1027
1032
  );
1028
1033
  },
1029
- `${store.config.name}: tracker observing latest update`,
1034
+ subscriptionKey,
1030
1035
  store
1031
1036
  );
1032
1037
  }
@@ -2036,7 +2041,7 @@ var buildTransaction = (key, params, store, id) => {
2036
2041
  transactors: {
2037
2042
  get: (token) => getState(token, child),
2038
2043
  set: (token, value) => setState(token, value, child),
2039
- run: (token) => runTransaction(token, child),
2044
+ run: (token, id2) => runTransaction(token, id2, child),
2040
2045
  find: (token, key2) => findInStore(token, key2, child),
2041
2046
  env: () => getEnvironmentData(child)
2042
2047
  }