atom.io 0.4.1 → 0.5.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 (58) hide show
  1. package/README.md +38 -10
  2. package/dist/index.d.mts +598 -0
  3. package/dist/index.d.ts +51 -14
  4. package/dist/index.js +143 -28
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +142 -28
  7. package/dist/index.mjs.map +1 -1
  8. package/json/dist/index.d.mts +18 -0
  9. package/json/dist/index.d.ts +18 -0
  10. package/json/dist/index.js +51 -0
  11. package/json/dist/index.js.map +1 -0
  12. package/json/dist/index.mjs +15 -0
  13. package/json/dist/index.mjs.map +1 -0
  14. package/json/package.json +15 -0
  15. package/package.json +34 -7
  16. package/react/dist/index.d.mts +17 -0
  17. package/react-devtools/dist/index.d.mts +15 -0
  18. package/react-devtools/dist/index.js +1 -1
  19. package/react-devtools/dist/index.js.map +1 -1
  20. package/react-devtools/dist/index.mjs +1 -1
  21. package/react-devtools/dist/index.mjs.map +1 -1
  22. package/realtime/dist/index.d.mts +25 -0
  23. package/realtime/dist/index.d.ts +25 -0
  24. package/realtime/dist/index.js +168 -0
  25. package/realtime/dist/index.js.map +1 -0
  26. package/realtime/dist/index.mjs +130 -0
  27. package/realtime/dist/index.mjs.map +1 -0
  28. package/realtime/package.json +15 -0
  29. package/src/index.ts +22 -0
  30. package/src/internal/atom-internal.ts +1 -1
  31. package/src/internal/families-internal.ts +3 -3
  32. package/src/internal/get.ts +22 -12
  33. package/src/internal/selector-internal.ts +10 -0
  34. package/src/internal/set.ts +1 -1
  35. package/src/internal/store.ts +1 -1
  36. package/src/internal/subscribe-internal.ts +5 -0
  37. package/src/internal/timeline-internal.ts +13 -1
  38. package/src/internal/transaction-internal.ts +24 -9
  39. package/src/json/index.ts +1 -0
  40. package/src/json/select-json.ts +18 -0
  41. package/src/react-explorer/explorer-states.ts +5 -5
  42. package/src/react-explorer/index.ts +1 -1
  43. package/src/react-explorer/space-states.ts +6 -7
  44. package/src/realtime/hook-composition/expose-family.ts +101 -0
  45. package/src/realtime/hook-composition/expose-single.ts +38 -0
  46. package/src/realtime/hook-composition/index.ts +11 -0
  47. package/src/realtime/hook-composition/receive-transaction.ts +19 -0
  48. package/src/realtime/index.ts +1 -0
  49. package/src/realtime-client/hook-composition/compose-realtime-hooks.ts +62 -0
  50. package/src/realtime-client/hook-composition/realtime-client-family-member.ts +28 -0
  51. package/src/realtime-client/hook-composition/realtime-client-family.ts +26 -0
  52. package/src/realtime-client/hook-composition/realtime-client-single.ts +24 -0
  53. package/src/realtime-client/hook-composition/realtime-client-transaction.ts +35 -0
  54. package/src/realtime-client/index.ts +1 -0
  55. package/src/selector.ts +9 -6
  56. package/src/silo.ts +45 -0
  57. package/src/subscribe.ts +13 -1
  58. package/src/transaction.ts +11 -4
package/src/subscribe.ts CHANGED
@@ -1,4 +1,6 @@
1
- import type { ReadonlySelectorToken, StateToken, TransactionToken, ƒn } from "."
1
+ import type { ƒn } from "~/packages/anvl/src/function"
2
+
3
+ import type { ReadonlySelectorToken, StateToken, TransactionToken } from "."
2
4
  import type { Store, TransactionUpdate } from "./internal"
3
5
  import { IMPLICIT, subscribeToRootAtoms, withdraw } from "./internal"
4
6
 
@@ -11,6 +13,11 @@ export const subscribe = <T>(
11
13
  store: Store = IMPLICIT.STORE
12
14
  ): (() => void) => {
13
15
  const state = withdraw<T>(token, store)
16
+ if (state === null) {
17
+ throw new Error(
18
+ `State "${token.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
19
+ )
20
+ }
14
21
  const subscription = state.subject.subscribe(handleUpdate)
15
22
  store.config.logger?.info(`👀 subscribe to "${state.key}"`)
16
23
  const dependencySubscriptions =
@@ -45,6 +52,11 @@ export const subscribeToTransaction = <ƒ extends ƒn>(
45
52
  store = IMPLICIT.STORE
46
53
  ): (() => void) => {
47
54
  const tx = withdraw(token, store)
55
+ if (tx === null) {
56
+ throw new Error(
57
+ `Cannot subscribe to transaction "${token.key}": transaction not found in store "${store.config.name}".`
58
+ )
59
+ }
48
60
  store.config.logger?.info(`👀 subscribe to transaction "${token.key}"`)
49
61
  const subscription = tx.subject.subscribe(handleUpdate)
50
62
  const unsubscribe = () => {
@@ -1,11 +1,11 @@
1
1
  import type * as Rx from "rxjs"
2
2
 
3
+ import type { ƒn } from "~/packages/anvl/src/function"
4
+
3
5
  import type { ReadonlySelectorToken, StateToken, TransactionToken } from "."
4
6
  import type { Store, TransactionUpdate } from "./internal"
5
7
  import { IMPLICIT, transaction__INTERNAL, withdraw } from "./internal"
6
8
 
7
- export type ƒn = (...parameters: any[]) => any
8
-
9
9
  export type Transactors = {
10
10
  get: <S>(state: ReadonlySelectorToken<S> | StateToken<S>) => S
11
11
  set: <S>(state: StateToken<S>, newValue: S | ((oldValue: S) => S)) => void
@@ -44,5 +44,12 @@ export function transaction<ƒ extends ƒn>(
44
44
 
45
45
  export const runTransaction =
46
46
  <ƒ extends ƒn>(token: TransactionToken<ƒ>, store: Store = IMPLICIT.STORE) =>
47
- (...parameters: Parameters<ƒ>): ReturnType<ƒ> =>
48
- withdraw(token, store).run(...parameters)
47
+ (...parameters: Parameters<ƒ>): ReturnType<ƒ> => {
48
+ const tx = withdraw(token, store)
49
+ if (tx) {
50
+ return tx.run(...parameters)
51
+ }
52
+ throw new Error(
53
+ `Cannot run transaction "${token.key}": transaction not found in store "${store.config.name}".`
54
+ )
55
+ }