atom.io 0.9.9 → 0.10.0

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 (64) hide show
  1. package/dist/index.d.mts +11 -4
  2. package/dist/index.d.ts +11 -4
  3. package/dist/index.js +36 -56
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +34 -55
  6. package/dist/index.mjs.map +1 -1
  7. package/internal/dist/index.d.mts +52 -25
  8. package/internal/dist/index.d.ts +52 -25
  9. package/internal/dist/index.js +352 -385
  10. package/internal/dist/index.js.map +1 -1
  11. package/internal/dist/index.mjs +349 -385
  12. package/internal/dist/index.mjs.map +1 -1
  13. package/internal/src/atom/create-atom.ts +5 -5
  14. package/internal/src/atom/delete-atom.ts +9 -2
  15. package/internal/src/atom/is-default.ts +2 -2
  16. package/internal/src/caching.ts +7 -5
  17. package/internal/src/get-state-internal.ts +4 -4
  18. package/internal/src/index.ts +1 -0
  19. package/internal/src/keys.ts +30 -0
  20. package/internal/src/mutable/create-mutable-atom.ts +2 -2
  21. package/internal/src/mutable/tracker.ts +1 -1
  22. package/internal/src/operation.ts +7 -7
  23. package/internal/src/selector/create-read-write-selector.ts +2 -8
  24. package/internal/src/selector/create-readonly-selector.ts +1 -1
  25. package/internal/src/selector/create-selector.ts +5 -3
  26. package/internal/src/selector/get-selector-dependency-keys.ts +20 -0
  27. package/internal/src/selector/index.ts +1 -1
  28. package/internal/src/selector/register-selector.ts +4 -11
  29. package/internal/src/selector/trace-selector-atoms.ts +26 -26
  30. package/internal/src/selector/update-selector-atoms.ts +14 -14
  31. package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
  32. package/internal/src/set-state/copy-mutable-in-transaction.ts +1 -1
  33. package/internal/src/set-state/emit-update.ts +1 -1
  34. package/internal/src/set-state/evict-downstream.ts +5 -6
  35. package/internal/src/set-state/set-atom.ts +1 -4
  36. package/internal/src/set-state/stow-update.ts +10 -4
  37. package/internal/src/store/index.ts +0 -1
  38. package/internal/src/store/store.ts +27 -10
  39. package/internal/src/store/withdraw-new-family-member.ts +1 -1
  40. package/internal/src/store/withdraw.ts +1 -1
  41. package/internal/src/subscribe/recall-state.ts +2 -2
  42. package/internal/src/subscribe/subscribe-to-root-atoms.ts +7 -8
  43. package/internal/src/timeline/add-atom-to-timeline.ts +8 -8
  44. package/internal/src/timeline/time-travel-internal.ts +12 -12
  45. package/internal/src/timeline/timeline-internal.ts +2 -2
  46. package/internal/src/transaction/abort-transaction.ts +3 -3
  47. package/internal/src/transaction/apply-transaction.ts +6 -6
  48. package/internal/src/transaction/build-transaction.ts +2 -3
  49. package/internal/src/transaction/redo-transaction.ts +1 -1
  50. package/internal/src/transaction/transaction-internal.ts +2 -2
  51. package/internal/src/transaction/undo-transaction.ts +1 -1
  52. package/package.json +3 -3
  53. package/react-devtools/dist/index.d.mts +3 -3
  54. package/react-devtools/dist/index.d.ts +3 -3
  55. package/realtime-client/dist/index.js +6 -9
  56. package/realtime-client/dist/index.js.map +1 -1
  57. package/realtime-client/dist/index.mjs +6 -9
  58. package/realtime-client/dist/index.mjs.map +1 -1
  59. package/realtime-client/src/use-server-action.ts +6 -8
  60. package/src/atom.ts +3 -0
  61. package/src/logger.ts +25 -36
  62. package/src/subscribe.ts +7 -7
  63. package/internal/src/selector/lookup-selector-sources.ts +0 -20
  64. package/internal/src/store/lookup.ts +0 -26
package/src/subscribe.ts CHANGED
@@ -32,18 +32,18 @@ export function subscribe<T>(
32
32
  )
33
33
  }
34
34
  const unsubFunction = state.subject.subscribe(key, handleUpdate)
35
- store.config.logger?.info(`👀 adding subscription "${key}" to "${state.key}"`)
35
+ store.logger.info(`👀 adding subscription "${key}" to "${state.key}"`)
36
36
  const dependencyUnsubFunctions =
37
37
  state.type !== `atom` ? subscribeToRootAtoms(state, store) : null
38
38
 
39
39
  const unsubscribe =
40
40
  dependencyUnsubFunctions === null
41
41
  ? () => {
42
- store.config.logger?.info(`🙈 unsubscribe from "${state.key}"`)
42
+ store.logger.info(`🙈 unsubscribe from "${state.key}"`)
43
43
  unsubFunction()
44
44
  }
45
45
  : () => {
46
- store.config.logger?.info(
46
+ store.logger.info(
47
47
  `🙈 unsubscribe from "${state.key}" and its dependencies`,
48
48
  )
49
49
  unsubFunction()
@@ -71,10 +71,10 @@ export const subscribeToTransaction = <ƒ extends ƒn>(
71
71
  `Cannot subscribe to transaction "${token.key}": transaction not found in store "${store.config.name}".`,
72
72
  )
73
73
  }
74
- store.config.logger?.info(`👀 subscribe to transaction "${token.key}"`)
74
+ store.logger.info(`👀 subscribe to transaction "${token.key}"`)
75
75
  const unsubscribe = tx.subject.subscribe(key, handleUpdate)
76
76
  return () => {
77
- store.config.logger?.info(`🙈 unsubscribe from transaction "${token.key}"`)
77
+ store.logger.info(`🙈 unsubscribe from transaction "${token.key}"`)
78
78
  unsubscribe()
79
79
  }
80
80
  }
@@ -91,10 +91,10 @@ export const subscribeToTimeline = (
91
91
  `Cannot subscribe to timeline "${token.key}": timeline not found in store "${store.config.name}".`,
92
92
  )
93
93
  }
94
- store.config.logger?.info(`👀 subscribe to timeline "${token.key}"`)
94
+ store.logger.info(`👀 subscribe to timeline "${token.key}"`)
95
95
  const unsubscribe = tl.subject.subscribe(key, handleUpdate)
96
96
  return () => {
97
- store.config.logger?.info(`🙈 unsubscribe from timeline "${token.key}"`)
97
+ store.logger.info(`🙈 unsubscribe from timeline "${token.key}"`)
98
98
  unsubscribe()
99
99
  }
100
100
  }
@@ -1,20 +0,0 @@
1
- import type { AtomToken, ReadonlySelectorToken, SelectorToken } from "atom.io"
2
-
3
- import type { Store } from "../store"
4
- import { lookup } from "../store"
5
- import { target } from "../transaction"
6
-
7
- export const lookupSelectorSources = (
8
- key: string,
9
- store: Store,
10
- ): (
11
- | AtomToken<unknown>
12
- | ReadonlySelectorToken<unknown>
13
- | SelectorToken<unknown>
14
- )[] => {
15
- const sources = target(store)
16
- .selectorGraph.getRelationEntries({ downstreamSelectorKey: key })
17
- .filter(([_, { source }]) => source !== key)
18
- .map(([_, { source }]) => lookup(source, store))
19
- return sources
20
- }
@@ -1,26 +0,0 @@
1
- import type { AtomToken, ReadonlySelectorToken, SelectorToken } from "atom.io"
2
-
3
- import { target } from "../transaction"
4
- import type { Store } from "./store"
5
-
6
- export function lookup(
7
- key: string,
8
- store: Store,
9
- ): AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown> {
10
- const core = target(store)
11
- let type: string = core.atoms.has(key)
12
- ? `atom`
13
- : core.selectors.has(key)
14
- ? `selector`
15
- : core.readonlySelectors.has(key)
16
- ? `readonly_selector`
17
- : ``
18
- if (!type) {
19
- const errorId = Math.random().toString(36)
20
- type = `🚨 This state could not be found by lookup! Check the console for "${errorId}"`
21
- store.config.logger?.error(
22
- `${errorId}: Key "${key}" does not exist in the store.`,
23
- )
24
- }
25
- return { key, type } as any
26
- }