atom.io 0.26.0 → 0.27.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 (60) hide show
  1. package/data/dist/index.d.ts +3 -3
  2. package/data/src/dict.ts +3 -3
  3. package/dist/chunk-AK23DRMD.js +21 -0
  4. package/dist/index.d.ts +32 -54
  5. package/ephemeral/dist/index.d.ts +7 -7
  6. package/ephemeral/src/find-state.ts +7 -7
  7. package/immortal/dist/index.d.ts +7 -7
  8. package/immortal/src/seek-state.ts +8 -8
  9. package/internal/dist/index.d.ts +56 -59
  10. package/internal/dist/index.js +5 -10
  11. package/internal/src/families/create-atom-family.ts +4 -4
  12. package/internal/src/families/create-readonly-selector-family.ts +2 -2
  13. package/internal/src/families/create-regular-atom-family.ts +2 -2
  14. package/internal/src/families/create-selector-family.ts +4 -4
  15. package/internal/src/families/create-writable-selector-family.ts +2 -2
  16. package/internal/src/families/dispose-from-store.ts +3 -7
  17. package/internal/src/families/find-in-store.ts +9 -9
  18. package/internal/src/families/init-family-member.ts +25 -37
  19. package/internal/src/families/seek-in-store.ts +11 -10
  20. package/internal/src/get-state/get-from-store.ts +3 -3
  21. package/internal/src/molecule/grow-molecule-in-store.ts +9 -9
  22. package/internal/src/mutable/index.ts +0 -1
  23. package/internal/src/mutable/tracker-family.ts +2 -2
  24. package/internal/src/set-state/set-into-store.ts +4 -4
  25. package/internal/src/store/deposit.ts +3 -3
  26. package/internal/src/store/withdraw.ts +10 -9
  27. package/json/dist/index.d.ts +10 -27
  28. package/json/dist/index.js +2 -2
  29. package/json/src/index.ts +8 -3
  30. package/json/src/select-json-family.ts +4 -4
  31. package/package.json +20 -17
  32. package/react/dist/index.d.ts +4 -4
  33. package/react/src/parse-state-overloads.ts +4 -4
  34. package/react/src/use-i.ts +3 -3
  35. package/react/src/use-json.ts +3 -3
  36. package/react/src/use-o.ts +3 -3
  37. package/react-devtools/dist/index.d.ts +1 -1
  38. package/react-devtools/dist/index.js +15 -4
  39. package/react-devtools/src/StateIndex.tsx +5 -4
  40. package/realtime/dist/index.d.ts +3 -3
  41. package/realtime/src/realtime-continuity.ts +2 -2
  42. package/realtime-react/dist/index.d.ts +4 -4
  43. package/realtime-react/src/use-pull-atom-family-member.ts +2 -2
  44. package/realtime-react/src/use-pull-mutable-family-member.ts +2 -2
  45. package/realtime-react/src/use-pull-selector-family-member.ts +2 -2
  46. package/realtime-server/dist/index.d.ts +9 -9
  47. package/realtime-server/src/ipc-sockets/custom-socket.ts +2 -2
  48. package/realtime-server/src/realtime-family-provider.ts +3 -2
  49. package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
  50. package/src/atom.ts +15 -42
  51. package/src/dispose-state.ts +2 -2
  52. package/src/get-state.ts +4 -4
  53. package/src/index.ts +5 -5
  54. package/src/molecule.ts +4 -3
  55. package/src/selector.ts +17 -39
  56. package/src/set-state.ts +3 -2
  57. package/src/silo.ts +4 -4
  58. package/transceivers/set-rtx/src/set-rtx.ts +5 -5
  59. package/dist/chunk-BF4MVQF6.js +0 -44
  60. package/internal/src/mutable/is-mutable.ts +0 -16
package/src/selector.ts CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  createStandaloneSelector,
5
5
  IMPLICIT,
6
6
  } from "atom.io/internal"
7
- import type { Json } from "atom.io/json"
7
+ import type { Canonical } from "atom.io/json"
8
8
 
9
9
  import type { ReadonlySelectorToken, WritableSelectorToken } from "."
10
10
  import type { Read, StateCreation, StateDisposal, Write } from "./transaction"
@@ -31,35 +31,25 @@ export function selector<T>(
31
31
  return createStandaloneSelector(options, IMPLICIT.STORE)
32
32
  }
33
33
 
34
- export type WritableSelectorFamilyOptions<T, K extends Json.Serializable> = {
34
+ export type WritableSelectorFamilyOptions<T, K extends Canonical> = {
35
35
  key: string
36
36
  get: (key: K) => Read<() => T>
37
37
  set: (key: K) => Write<(newValue: T) => void>
38
38
  }
39
- export type ReadonlySelectorFamilyOptions<T, K extends Json.Serializable> = {
39
+ export type ReadonlySelectorFamilyOptions<T, K extends Canonical> = {
40
40
  key: string
41
41
  get: (key: K) => Read<() => T>
42
42
  }
43
43
 
44
- export type WritableSelectorFamilyToken<T, K extends Json.Serializable> = {
44
+ export type WritableSelectorFamilyToken<T, K extends Canonical> = {
45
45
  key: string
46
46
  type: `selector_family`
47
47
  __T?: T
48
48
  __K?: K
49
49
  }
50
+
50
51
  // biome-ignore format: intersection
51
- export type WritableSelectorFamilyTokenWithCall<
52
- T,
53
- K extends Json.Serializable,
54
- > =
55
- & WritableSelectorFamilyToken<T, K>
56
- & {
57
- /** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
58
- /* eslint-disable-next-line @typescript-eslint/prefer-function-type */
59
- (key: K): WritableSelectorToken<T>
60
- }
61
- // biome-ignore format: intersection
62
- export type WritableSelectorFamily<T, K extends Json.Serializable> =
52
+ export type WritableSelectorFamily<T, K extends Canonical> =
63
53
  & WritableSelectorFamilyToken<T, K>
64
54
  & {
65
55
  (key: K): WritableSelectorToken<T>
@@ -67,25 +57,15 @@ export type WritableSelectorFamily<T, K extends Json.Serializable> =
67
57
  install: (store: Store) => void
68
58
  }
69
59
 
70
- export type ReadonlySelectorFamilyToken<T, K extends Json.Serializable> = {
60
+ export type ReadonlySelectorFamilyToken<T, K extends Canonical> = {
71
61
  key: string
72
62
  type: `readonly_selector_family`
73
63
  __T?: T
74
64
  __K?: K
75
65
  }
66
+
76
67
  // biome-ignore format: intersection
77
- export type ReadonlySelectorFamilyTokenWithCall<
78
- T,
79
- K extends Json.Serializable,
80
- > =
81
- & ReadonlySelectorFamilyToken<T, K>
82
- & {
83
- /** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
84
- /* eslint-disable-next-line @typescript-eslint/prefer-function-type */
85
- (key: K): ReadonlySelectorToken<T>
86
- }
87
- // biome-ignore format: intersection
88
- export type ReadonlySelectorFamily<T, K extends Json.Serializable> =
68
+ export type ReadonlySelectorFamily<T, K extends Canonical> =
89
69
  & ((key: K) => ReadonlySelectorToken<T>)
90
70
  & {
91
71
  key: string
@@ -96,25 +76,23 @@ export type ReadonlySelectorFamily<T, K extends Json.Serializable> =
96
76
  __K?: K
97
77
  }
98
78
 
99
- export type SelectorFamily<T, K extends Json.Serializable> =
79
+ export type SelectorFamily<T, K extends Canonical> =
100
80
  | ReadonlySelectorFamily<T, K>
101
81
  | WritableSelectorFamily<T, K>
102
- export type SelectorFamilyToken<T, K extends Json.Serializable> =
82
+ export type SelectorFamilyToken<T, K extends Canonical> =
103
83
  | ReadonlySelectorFamilyToken<T, K>
104
84
  | WritableSelectorFamilyToken<T, K>
105
85
 
106
- export function selectorFamily<T, K extends Json.Serializable>(
86
+ export function selectorFamily<T, K extends Canonical>(
107
87
  options: WritableSelectorFamilyOptions<T, K>,
108
- ): WritableSelectorFamilyTokenWithCall<T, K>
109
- export function selectorFamily<T, K extends Json.Serializable>(
88
+ ): WritableSelectorFamilyToken<T, K>
89
+ export function selectorFamily<T, K extends Canonical>(
110
90
  options: ReadonlySelectorFamilyOptions<T, K>,
111
- ): ReadonlySelectorFamilyTokenWithCall<T, K>
112
- export function selectorFamily<T, K extends Json.Serializable>(
91
+ ): ReadonlySelectorFamilyToken<T, K>
92
+ export function selectorFamily<T, K extends Canonical>(
113
93
  options:
114
94
  | ReadonlySelectorFamilyOptions<T, K>
115
95
  | WritableSelectorFamilyOptions<T, K>,
116
- ):
117
- | ReadonlySelectorFamilyTokenWithCall<T, K>
118
- | WritableSelectorFamilyTokenWithCall<T, K> {
96
+ ): ReadonlySelectorFamilyToken<T, K> | WritableSelectorFamilyToken<T, K> {
119
97
  return createSelectorFamily(options, IMPLICIT.STORE)
120
98
  }
package/src/set-state.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as Internal from "atom.io/internal"
2
+ import type { Canonical } from "atom.io/json"
2
3
  import type { Json } from "rel8"
3
4
 
4
5
  import type { WritableFamilyToken, WritableToken } from "."
@@ -24,14 +25,14 @@ export function setState<T, New extends T>(
24
25
  * @param value - The new value of the state.
25
26
  * @overload Streamlined
26
27
  */
27
- export function setState<T, K extends Json.Serializable, New extends T>(
28
+ export function setState<T, K extends Canonical, New extends T>(
28
29
  token: WritableFamilyToken<T, K>,
29
30
  key: K,
30
31
  value: New | ((oldValue: T) => New),
31
32
  ): void
32
33
 
33
34
  export function setState<T, New extends T>(
34
- token: WritableFamilyToken<T, Json.Serializable> | WritableToken<T>,
35
+ token: WritableFamilyToken<T, Canonical> | WritableToken<T>,
35
36
  p1: Json.Serializable | New | ((oldValue: T) => New),
36
37
  p2?: New | ((oldValue: T) => New),
37
38
  ): void {
package/src/silo.ts CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  Store,
17
17
  timeTravel,
18
18
  } from "atom.io/internal"
19
- import type { Json } from "atom.io/json"
19
+ import type { Canonical, Json } from "atom.io/json"
20
20
 
21
21
  import type {
22
22
  AtomToken,
@@ -73,12 +73,12 @@ export class Silo {
73
73
  function _atomFamily<
74
74
  T extends Transceiver<any>,
75
75
  J extends Json.Serializable,
76
- K extends Json.Serializable,
76
+ K extends Canonical,
77
77
  >(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamily<T, J, K>
78
- function _atomFamily<T, K extends Json.Serializable>(
78
+ function _atomFamily<T, K extends Canonical>(
79
79
  options: RegularAtomFamilyOptions<T, K>,
80
80
  ): RegularAtomFamily<T, K>
81
- function _atomFamily<T, K extends Json.Serializable>(
81
+ function _atomFamily<T, K extends Canonical>(
82
82
  options:
83
83
  | MutableAtomFamilyOptions<any, any, any>
84
84
  | RegularAtomFamilyOptions<T, K>,
@@ -1,6 +1,6 @@
1
1
  import type { Lineage, Transceiver, TransceiverMode } from "atom.io/internal"
2
2
  import { Subject } from "atom.io/internal"
3
- import type { Json, primitive, Stringified } from "atom.io/json"
3
+ import type { Json, primitive, stringified } from "atom.io/json"
4
4
  import { parseJson, stringifyJson } from "atom.io/json"
5
5
 
6
6
  export type SetUpdate =
@@ -145,13 +145,13 @@ export class SetRTX<P extends primitive>
145
145
  const value = update.substring(typeValueBreak + 1)
146
146
  switch (type) {
147
147
  case `add`:
148
- this.add(parseJson(value as Stringified<P>))
148
+ this.add(parseJson(value as stringified<P>))
149
149
  break
150
150
  case `clear`:
151
151
  this.clear()
152
152
  break
153
153
  case `del`:
154
- this.delete(parseJson(value as Stringified<P>))
154
+ this.delete(parseJson(value as stringified<P>))
155
155
  break
156
156
  case `tx`:
157
157
  for (const subUpdate of value.split(`;`)) {
@@ -214,10 +214,10 @@ export class SetRTX<P extends primitive>
214
214
  const value = update.substring(breakpoint + 1)
215
215
  switch (type) {
216
216
  case `add`:
217
- this.delete(parseJson(value as Stringified<P>))
217
+ this.delete(parseJson(value as stringified<P>))
218
218
  break
219
219
  case `del`:
220
- this.add(parseJson(value as Stringified<P>))
220
+ this.add(parseJson(value as stringified<P>))
221
221
  break
222
222
  case `clear`: {
223
223
  const values = JSON.parse(value) as P[]
@@ -1,44 +0,0 @@
1
- // ../anvl/src/json/json-interface.ts
2
- var stringSetJsonInterface = {
3
- toJson: (stringSet) => Array.from(stringSet),
4
- fromJson: (json) => new Set(json)
5
- };
6
-
7
- // ../anvl/src/json/index.ts
8
- var parseJson = (str) => JSON.parse(str);
9
- var stringifyJson = (json) => JSON.stringify(json);
10
- var JSON_TYPE_NAMES = [
11
- `array`,
12
- `boolean`,
13
- `null`,
14
- `number`,
15
- `object`,
16
- `string`
17
- ];
18
- var JSON_DEFAULTS = {
19
- array: [],
20
- boolean: false,
21
- null: null,
22
- number: 0,
23
- object: {},
24
- string: ``
25
- };
26
-
27
- // ../anvl/src/primitive/index.ts
28
- var isString = (input) => {
29
- return typeof input === `string`;
30
- };
31
- var isNumber = (input) => {
32
- return typeof input === `number`;
33
- };
34
- var isBoolean = (input) => {
35
- return typeof input === `boolean`;
36
- };
37
- var isNull = (input) => {
38
- return input === null;
39
- };
40
- var isPrimitive = (input) => {
41
- return isString(input) || isNumber(input) || isBoolean(input) || isNull(input);
42
- };
43
-
44
- export { JSON_DEFAULTS, JSON_TYPE_NAMES, isBoolean, isNull, isNumber, isPrimitive, isString, parseJson, stringSetJsonInterface, stringifyJson };
@@ -1,16 +0,0 @@
1
- import type { AtomFamily, MutableAtomFamily } from "atom.io"
2
-
3
- import type { Atom, MutableAtom } from ".."
4
-
5
- export function isMutable(atom: Atom<any>): atom is MutableAtom<any, any>
6
- export function isMutable(
7
- family: AtomFamily<any, any>,
8
- ): family is MutableAtomFamily<any, any, any>
9
- export function isMutable(
10
- atomOrTokenOrFamily: Atom<any> | AtomFamily<any, any>,
11
- ): boolean {
12
- return (
13
- atomOrTokenOrFamily.type === `mutable_atom` ||
14
- atomOrTokenOrFamily.type === `mutable_atom_family`
15
- )
16
- }