atom.io 0.16.0 → 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 (56) hide show
  1. package/data/dist/index.cjs +60 -29
  2. package/data/dist/index.cjs.map +1 -1
  3. package/data/dist/index.js +60 -29
  4. package/data/dist/index.js.map +1 -1
  5. package/data/src/join.ts +60 -29
  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 +20 -15
  12. package/internal/dist/index.cjs.map +1 -1
  13. package/internal/dist/index.js +20 -15
  14. package/internal/dist/index.js.map +1 -1
  15. package/internal/src/mutable/tracker.ts +13 -11
  16. package/internal/src/selector/create-readonly-selector.ts +2 -2
  17. package/internal/src/selector/create-writable-selector.ts +1 -1
  18. package/internal/src/set-state/copy-mutable-if-needed.ts +0 -2
  19. package/internal/src/set-state/set-atom.ts +7 -4
  20. package/internal/src/store/store.ts +0 -1
  21. package/internal/src/transaction/build-transaction.ts +1 -1
  22. package/package.json +11 -11
  23. package/react-devtools/dist/index.cjs +0 -2
  24. package/react-devtools/dist/index.cjs.map +1 -1
  25. package/react-devtools/dist/index.js +0 -2
  26. package/react-devtools/dist/index.js.map +1 -1
  27. package/realtime-client/dist/index.cjs +1 -0
  28. package/realtime-client/dist/index.cjs.map +1 -1
  29. package/realtime-client/dist/index.js +1 -0
  30. package/realtime-client/dist/index.js.map +1 -1
  31. package/realtime-client/src/sync-server-action.ts +1 -0
  32. package/realtime-react/dist/index.cjs +2 -2
  33. package/realtime-react/dist/index.cjs.map +1 -1
  34. package/realtime-react/dist/index.js +2 -2
  35. package/realtime-react/dist/index.js.map +1 -1
  36. package/realtime-react/src/use-server-action.ts +1 -1
  37. package/realtime-react/src/use-sync-server-action.ts +1 -1
  38. package/realtime-server/dist/index.cjs +19 -8
  39. package/realtime-server/dist/index.cjs.map +1 -1
  40. package/realtime-server/dist/index.d.ts +11 -4
  41. package/realtime-server/dist/index.js +19 -8
  42. package/realtime-server/dist/index.js.map +1 -1
  43. package/realtime-server/src/realtime-action-receiver.ts +4 -3
  44. package/realtime-server/src/realtime-action-synchronizer.ts +13 -1
  45. package/realtime-server/src/realtime-family-provider.ts +8 -4
  46. package/realtime-server/src/realtime-mutable-family-provider.ts +13 -17
  47. package/realtime-server/src/realtime-mutable-provider.ts +1 -0
  48. package/realtime-server/src/realtime-state-provider.ts +1 -0
  49. package/realtime-server/src/realtime-state-receiver.ts +1 -0
  50. package/src/logger.ts +15 -11
  51. package/src/transaction.ts +1 -1
  52. package/transceivers/set-rtx/dist/index.cjs +2 -2
  53. package/transceivers/set-rtx/dist/index.cjs.map +1 -1
  54. package/transceivers/set-rtx/dist/index.js +2 -2
  55. package/transceivers/set-rtx/dist/index.js.map +1 -1
  56. package/transceivers/set-rtx/src/set-rtx.ts +2 -2
@@ -53,6 +53,9 @@ export class Tracker<Mutable extends Transceiver<any>> {
53
53
  latestUpdateState: RegularAtomToken<typeof this.Update | null>,
54
54
  store: Store,
55
55
  ): void {
56
+ const subscriptionKey = `tracker:${store.config.name}:${
57
+ store.transactionMeta === null ? `main` : store.transactionMeta.update.key
58
+ }:${mutableState.key}`
56
59
  const originalInnerValue = getState(mutableState, store)
57
60
  const target = newest(store)
58
61
  this.unsubscribeFromInnerValue = originalInnerValue.subscribe(
@@ -64,7 +67,7 @@ export class Tracker<Mutable extends Transceiver<any>> {
64
67
  (update) => {
65
68
  if (target.operation.open) {
66
69
  const unsubscribe = target.on.operationClose.subscribe(
67
- mutableState.key,
70
+ subscriptionKey,
68
71
  () => {
69
72
  unsubscribe()
70
73
  setState(latestUpdateState, update, target)
@@ -83,15 +86,11 @@ export class Tracker<Mutable extends Transceiver<any>> {
83
86
  this.unsubscribeFromInnerValue()
84
87
  const target = newest(store)
85
88
  this.unsubscribeFromInnerValue = update.newValue.subscribe(
86
- `tracker:${store.config.name}:${
87
- target.transactionMeta === null
88
- ? `main`
89
- : target.transactionMeta.update.key
90
- }`,
89
+ subscriptionKey,
91
90
  (update) => {
92
91
  if (target.operation.open) {
93
92
  const unsubscribe = target.on.operationClose.subscribe(
94
- mutableState.key,
93
+ subscriptionKey,
95
94
  () => {
96
95
  unsubscribe()
97
96
  setState(latestUpdateState, update, target)
@@ -105,7 +104,7 @@ export class Tracker<Mutable extends Transceiver<any>> {
105
104
  )
106
105
  }
107
106
  },
108
- `${store.config.name}: tracker observing inner value`,
107
+ subscriptionKey,
109
108
  store,
110
109
  )
111
110
  }
@@ -115,6 +114,9 @@ export class Tracker<Mutable extends Transceiver<any>> {
115
114
  latestUpdateState: RegularAtomToken<typeof this.Update | null>,
116
115
  store: Store,
117
116
  ): void {
117
+ const subscriptionKey = `tracker:${store.config.name}:${
118
+ store.transactionMeta === null ? `main` : store.transactionMeta.update.key
119
+ }:${mutableState.key}`
118
120
  subscribeToState(
119
121
  latestUpdateState,
120
122
  ({ newValue, oldValue }) => {
@@ -141,7 +143,7 @@ export class Tracker<Mutable extends Transceiver<any>> {
141
143
  store,
142
144
  )
143
145
  },
144
- `${mutableState.key}: tracker observing timeline`,
146
+ subscriptionKey,
145
147
  store,
146
148
  )
147
149
  return
@@ -149,7 +151,7 @@ export class Tracker<Mutable extends Transceiver<any>> {
149
151
  }
150
152
 
151
153
  const unsubscribe = store.on.operationClose.subscribe(
152
- latestUpdateState.key,
154
+ subscriptionKey,
153
155
  () => {
154
156
  unsubscribe()
155
157
  const mutable = getState(mutableState, store)
@@ -168,7 +170,7 @@ export class Tracker<Mutable extends Transceiver<any>> {
168
170
  },
169
171
  )
170
172
  },
171
- `${store.config.name}: tracker observing latest update`,
173
+ subscriptionKey,
172
174
  store,
173
175
  )
174
176
  }
@@ -19,10 +19,10 @@ export const createReadonlySelector = <T>(
19
19
  const target = newest(store)
20
20
  const subject = new Subject<{ newValue: T; oldValue: T }>()
21
21
 
22
- const { get, find } = registerSelector(options.key, store)
22
+ const { get, find } = registerSelector(options.key, target)
23
23
  const getSelf = () => {
24
24
  const value = options.get({ get, find })
25
- cacheValue(options.key, value, subject, store)
25
+ cacheValue(options.key, value, subject, newest(store))
26
26
  return value
27
27
  }
28
28
 
@@ -20,7 +20,7 @@ export const createWritableSelector = <T>(
20
20
  ): WritableSelectorToken<T> => {
21
21
  const target = newest(store)
22
22
  const subject = new Subject<{ newValue: T; oldValue: T }>()
23
- const transactors = registerSelector(options.key, store)
23
+ const transactors = registerSelector(options.key, target)
24
24
  const { find, get } = transactors
25
25
  const readonlyTransactors = { find, get }
26
26
 
@@ -1,5 +1,3 @@
1
- import type { JsonInterface } from "atom.io/json"
2
-
3
1
  import type { MutableAtom, Transceiver } from ".."
4
2
  import { Tracker } from "../mutable"
5
3
  import type { Store } from "../store"
@@ -29,11 +29,14 @@ export const setAtom = <T>(
29
29
  const update = { oldValue, newValue }
30
30
  if (target.transactionMeta === null) {
31
31
  emitUpdate(atom, update, target)
32
- } else if (target.on.transactionApplying && target.parent) {
33
- stowUpdate(atom, update, target)
34
- if (atom.key.startsWith(`*`)) {
32
+ } else if (target.parent) {
33
+ if (target.on.transactionApplying.state === null) {
34
+ stowUpdate(atom, update, target)
35
+ } else if (atom.key.startsWith(`*`)) {
35
36
  const mutableKey = atom.key.slice(1)
36
- const mutable: Transceiver<any> = target.valueMap.get(mutableKey)
37
+ const mutableAtom = target.atoms.get(mutableKey) as Atom<any>
38
+ let mutable: Transceiver<any> = target.valueMap.get(mutableKey)
39
+ mutable = copyMutableIfWithinTransaction(mutable, mutableAtom, target)
37
40
  mutable.do(update.newValue)
38
41
  }
39
42
  }
@@ -6,7 +6,6 @@ import type {
6
6
  ReadonlySelectorFamily,
7
7
  ReadonlySelectorToken,
8
8
  RegularAtomFamily,
9
- RegularAtomToken,
10
9
  TimelineToken,
11
10
  TransactionToken,
12
11
  WritableSelectorFamily,
@@ -52,7 +52,7 @@ export const buildTransaction = (
52
52
  transactors: {
53
53
  get: (token) => getState(token, child),
54
54
  set: (token, value) => setState(token, value, child),
55
- run: (token) => runTransaction(token, child),
55
+ run: (token, id) => runTransaction(token, id, child),
56
56
  find: ((token, key) => findInStore(token, key, child)) as typeof findState,
57
57
  env: () => getEnvironmentData(child),
58
58
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atom.io",
3
- "version": "0.16.0",
3
+ "version": "0.16.2",
4
4
  "description": "Composable and testable reactive data library.",
5
5
  "homepage": "https://atom.io.fyi",
6
6
  "sideEffects": false,
@@ -53,29 +53,29 @@
53
53
  "@types/npmlog": "7.0.0",
54
54
  "@types/react": "18.2.47",
55
55
  "@types/tmp": "0.2.6",
56
- "@vitest/coverage-v8": "1.1.3",
57
- "@vitest/ui": "1.1.3",
56
+ "@vitest/coverage-v8": "1.2.0",
57
+ "@vitest/ui": "1.2.0",
58
58
  "concurrently": "8.2.2",
59
- "drizzle-kit": "0.20.10",
59
+ "drizzle-kit": "0.20.12",
60
60
  "drizzle-orm": "0.29.3",
61
61
  "eslint": "8.56.0",
62
- "framer-motion": "10.17.12",
63
- "happy-dom": "12.10.3",
62
+ "framer-motion": "10.18.0",
63
+ "happy-dom": "13.1.4",
64
64
  "http-proxy": "1.18.1",
65
65
  "npmlog": "7.0.1",
66
66
  "postgres": "3.4.3",
67
67
  "preact": "10.19.3",
68
68
  "react": "18.2.0",
69
69
  "react-dom": "18.2.0",
70
- "react-router-dom": "6.21.1",
71
- "socket.io": "4.7.3",
72
- "socket.io-client": "4.7.3",
70
+ "react-router-dom": "6.21.2",
71
+ "socket.io": "4.7.4",
72
+ "socket.io-client": "4.7.4",
73
73
  "tmp": "0.2.1",
74
74
  "tsup": "8.0.1",
75
75
  "typescript": "5.3.3",
76
76
  "vite": "5.0.11",
77
77
  "vite-tsconfig-paths": "4.2.3",
78
- "vitest": "1.1.3"
78
+ "vitest": "1.2.0"
79
79
  },
80
80
  "main": "dist/index.js",
81
81
  "types": "dist/index.d.ts",
@@ -220,7 +220,7 @@
220
220
  "build:realtime-server": "cd realtime-server && tsup",
221
221
  "build:realtime-testing": "cd realtime-testing && tsup",
222
222
  "build:transceivers:set-rtx": "cd transceivers/set-rtx && tsup",
223
- "lint:biome": "biome check .",
223
+ "lint:biome": "biome check --diagnostic-level=warn -- .",
224
224
  "lint:eslint": "eslint .",
225
225
  "lint": "npm run lint:biome && npm run lint:eslint",
226
226
  "test": "vitest",
@@ -2302,7 +2302,6 @@ var Id = ({ id }) => {
2302
2302
  /* @__PURE__ */ jsxRuntime.jsx(
2303
2303
  "span",
2304
2304
  __spreadProps(__spreadValues({
2305
- role: "content",
2306
2305
  ref: refs.setReference
2307
2306
  }, getReferenceProps()), {
2308
2307
  style: {
@@ -2319,7 +2318,6 @@ var Id = ({ id }) => {
2319
2318
  isOpen && /* @__PURE__ */ jsxRuntime.jsx(react$1.FloatingPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(
2320
2319
  "span",
2321
2320
  __spreadProps(__spreadValues({
2322
- role: "popup",
2323
2321
  ref: refs.setFloating
2324
2322
  }, getFloatingProps()), {
2325
2323
  style: __spreadProps(__spreadValues({}, floatingStyles), {