atom.io 0.6.1 → 0.6.3

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 (90) hide show
  1. package/dist/index.d.mts +3 -3
  2. package/dist/index.d.ts +3 -3
  3. package/dist/index.js +7 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +7 -2
  6. package/dist/index.mjs.map +1 -1
  7. package/json/dist/index.js.map +1 -1
  8. package/json/dist/index.mjs.map +1 -1
  9. package/package.json +13 -3
  10. package/react/dist/index.js.map +1 -1
  11. package/react/dist/index.mjs.map +1 -1
  12. package/react-devtools/dist/index.js +32 -18
  13. package/react-devtools/dist/index.js.map +1 -1
  14. package/react-devtools/dist/index.mjs +32 -18
  15. package/react-devtools/dist/index.mjs.map +1 -1
  16. package/realtime/dist/index.js.map +1 -1
  17. package/realtime/dist/index.mjs.map +1 -1
  18. package/realtime-react/dist/index.js.map +1 -1
  19. package/realtime-react/dist/index.mjs.map +1 -1
  20. package/realtime-testing/dist/index.d.mts +49 -0
  21. package/realtime-testing/dist/index.d.ts +49 -0
  22. package/realtime-testing/dist/index.js +153 -0
  23. package/realtime-testing/dist/index.js.map +1 -0
  24. package/realtime-testing/dist/index.mjs +117 -0
  25. package/realtime-testing/dist/index.mjs.map +1 -0
  26. package/realtime-testing/package.json +15 -0
  27. package/src/atom.ts +15 -15
  28. package/src/index.ts +59 -59
  29. package/src/internal/atom-internal.ts +36 -36
  30. package/src/internal/families-internal.ts +114 -114
  31. package/src/internal/get.ts +83 -83
  32. package/src/internal/is-default.ts +17 -17
  33. package/src/internal/meta/attach-meta.ts +7 -7
  34. package/src/internal/meta/meta-state.ts +115 -115
  35. package/src/internal/operation.ts +93 -93
  36. package/src/internal/selector/create-read-write-selector.ts +46 -46
  37. package/src/internal/selector/create-readonly-selector.ts +37 -37
  38. package/src/internal/selector/lookup-selector-sources.ts +9 -9
  39. package/src/internal/selector/register-selector.ts +44 -44
  40. package/src/internal/selector/trace-selector-atoms.ts +30 -30
  41. package/src/internal/selector/update-selector-atoms.ts +25 -25
  42. package/src/internal/selector-internal.ts +37 -37
  43. package/src/internal/set.ts +78 -78
  44. package/src/internal/store.ts +118 -118
  45. package/src/internal/subscribe-internal.ts +62 -62
  46. package/src/internal/time-travel-internal.ts +76 -76
  47. package/src/internal/timeline/add-atom-to-timeline.ts +158 -153
  48. package/src/internal/timeline-internal.ts +80 -80
  49. package/src/internal/transaction/abort-transaction.ts +8 -8
  50. package/src/internal/transaction/apply-transaction.ts +41 -41
  51. package/src/internal/transaction/build-transaction.ts +28 -28
  52. package/src/internal/transaction/index.ts +7 -7
  53. package/src/internal/transaction/redo-transaction.ts +13 -13
  54. package/src/internal/transaction/undo-transaction.ts +13 -13
  55. package/src/internal/transaction-internal.ts +48 -48
  56. package/src/json/select-json.ts +12 -12
  57. package/src/logger.ts +30 -30
  58. package/src/react/store-context.tsx +4 -4
  59. package/src/react/store-hooks.ts +18 -18
  60. package/src/react-devtools/AtomIODevtools.tsx +83 -82
  61. package/src/react-devtools/StateEditor.tsx +53 -53
  62. package/src/react-devtools/TokenList.tsx +47 -42
  63. package/src/react-explorer/AtomIOExplorer.tsx +197 -185
  64. package/src/react-explorer/explorer-effects.ts +11 -11
  65. package/src/react-explorer/explorer-states.ts +186 -193
  66. package/src/react-explorer/index.ts +11 -11
  67. package/src/react-explorer/space-states.ts +48 -50
  68. package/src/react-explorer/view-states.ts +25 -25
  69. package/src/realtime/hook-composition/expose-family.ts +81 -81
  70. package/src/realtime/hook-composition/expose-single.ts +26 -26
  71. package/src/realtime/hook-composition/expose-timeline.ts +60 -0
  72. package/src/realtime/hook-composition/index.ts +2 -2
  73. package/src/realtime/hook-composition/receive-state.ts +18 -18
  74. package/src/realtime/hook-composition/receive-transaction.ts +8 -8
  75. package/src/realtime-react/realtime-context.tsx +17 -17
  76. package/src/realtime-react/realtime-hooks.ts +17 -17
  77. package/src/realtime-react/realtime-state.ts +4 -4
  78. package/src/realtime-react/use-pull-family-member.ts +15 -15
  79. package/src/realtime-react/use-pull-family.ts +13 -13
  80. package/src/realtime-react/use-pull.ts +12 -12
  81. package/src/realtime-react/use-push.ts +15 -15
  82. package/src/realtime-react/use-server-action.ts +21 -21
  83. package/src/realtime-testing/index.ts +1 -0
  84. package/src/realtime-testing/setup-realtime-test.tsx +160 -0
  85. package/src/selector.ts +25 -25
  86. package/src/silo.ts +38 -38
  87. package/src/subscribe.ts +68 -68
  88. package/src/timeline.ts +13 -13
  89. package/src/transaction.ts +28 -28
  90. package/src/web-effects/storage.ts +17 -17
@@ -5,56 +5,56 @@ import type { Store } from "./internal"
5
5
  import { IMPLICIT, transaction__INTERNAL, withdraw } from "./internal"
6
6
 
7
7
  export type TransactionToken<_> = {
8
- key: string
9
- type: `transaction`
10
- __brand?: _
8
+ key: string
9
+ type: `transaction`
10
+ __brand?: _
11
11
  }
12
12
 
13
13
  export type TransactionUpdate<ƒ extends ƒn> = {
14
- key: string
15
- atomUpdates: KeyedStateUpdate<unknown>[]
16
- params: Parameters<ƒ>
17
- output: ReturnType<ƒ>
14
+ key: string
15
+ atomUpdates: KeyedStateUpdate<unknown>[]
16
+ params: Parameters<ƒ>
17
+ output: ReturnType<ƒ>
18
18
  }
19
19
 
20
20
  export type Transactors = {
21
- get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S
22
- set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void
21
+ get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S
22
+ set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void
23
23
  }
24
24
  export type ReadonlyTransactors = Pick<Transactors, `get`>
25
25
 
26
26
  export type Read<ƒ extends ƒn> = (
27
- transactors: ReadonlyTransactors,
28
- ...parameters: Parameters<ƒ>
27
+ transactors: ReadonlyTransactors,
28
+ ...parameters: Parameters<ƒ>
29
29
  ) => ReturnType<ƒ>
30
30
 
31
31
  export type Write<ƒ extends ƒn> = (
32
- transactors: Transactors,
33
- ...parameters: Parameters<ƒ>
32
+ transactors: Transactors,
33
+ ...parameters: Parameters<ƒ>
34
34
  ) => ReturnType<ƒ>
35
35
 
36
36
  export type TransactionOptions<ƒ extends ƒn> = {
37
- key: string
38
- do: Write<ƒ>
37
+ key: string
38
+ do: Write<ƒ>
39
39
  }
40
40
 
41
41
  export type TransactionIO<Token extends TransactionToken<any>> =
42
- Token extends TransactionToken<infer ƒ> ? ƒ : never
42
+ Token extends TransactionToken<infer ƒ> ? ƒ : never
43
43
 
44
44
  export function transaction<ƒ extends ƒn>(
45
- options: TransactionOptions<ƒ>
45
+ options: TransactionOptions<ƒ>,
46
46
  ): TransactionToken<ƒ> {
47
- return transaction__INTERNAL(options)
47
+ return transaction__INTERNAL(options)
48
48
  }
49
49
 
50
50
  export const runTransaction =
51
- <ƒ extends ƒn>(token: TransactionToken<ƒ>, store: Store = IMPLICIT.STORE) =>
52
- (...parameters: Parameters<ƒ>): ReturnType<ƒ> => {
53
- const tx = withdraw(token, store)
54
- if (tx) {
55
- return tx.run(...parameters)
56
- }
57
- throw new Error(
58
- `Cannot run transaction "${token.key}": transaction not found in store "${store.config.name}".`
59
- )
60
- }
51
+ <ƒ extends ƒn>(token: TransactionToken<ƒ>, store: Store = IMPLICIT.STORE) =>
52
+ (...parameters: Parameters<ƒ>): ReturnType<ƒ> => {
53
+ const tx = withdraw(token, store)
54
+ if (tx) {
55
+ return tx.run(...parameters)
56
+ }
57
+ throw new Error(
58
+ `Cannot run transaction "${token.key}": transaction not found in store "${store.config.name}".`,
59
+ )
60
+ }
@@ -3,28 +3,28 @@ import type { Json } from "~/packages/anvl/src/json"
3
3
  import type { AtomEffect } from "../index"
4
4
 
5
5
  export type StringInterface<T> = {
6
- stringify: (t: T) => string
7
- parse: (s: string) => T
6
+ stringify: (t: T) => string
7
+ parse: (s: string) => T
8
8
  }
9
9
 
10
10
  export const persistAtom =
11
- <T>(storage: Storage) =>
12
- ({ stringify, parse }: StringInterface<T>) =>
13
- (key: string): AtomEffect<T> =>
14
- ({ setSelf, onSet }) => {
15
- const savedValue = storage.getItem(key)
11
+ <T>(storage: Storage) =>
12
+ ({ stringify, parse }: StringInterface<T>) =>
13
+ (key: string): AtomEffect<T> =>
14
+ ({ setSelf, onSet }) => {
15
+ const savedValue = storage.getItem(key)
16
16
 
17
- if (savedValue != null) setSelf(parse(savedValue))
17
+ if (savedValue != null) setSelf(parse(savedValue))
18
18
 
19
- onSet(({ newValue }) => {
20
- if (newValue == null) {
21
- storage.removeItem(key)
22
- return
23
- }
24
- storage.setItem(key, stringify(newValue))
25
- })
26
- }
19
+ onSet(({ newValue }) => {
20
+ if (newValue == null) {
21
+ storage.removeItem(key)
22
+ return
23
+ }
24
+ storage.setItem(key, stringify(newValue))
25
+ })
26
+ }
27
27
 
28
28
  export const lazyLocalStorageEffect: <J extends Json>(
29
- key: string
29
+ key: string,
30
30
  ) => AtomEffect<J> = persistAtom(localStorage)(JSON)