atom.io 0.29.0 → 0.29.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 (37) hide show
  1. package/dist/{chunk-XPYU2HY2.js → chunk-J4B56MM5.js} +36 -9
  2. package/dist/index.d.ts +15 -15
  3. package/ephemeral/dist/index.d.ts +6 -6
  4. package/ephemeral/src/find-state.ts +6 -6
  5. package/immortal/dist/index.d.ts +6 -6
  6. package/immortal/src/seek-state.ts +6 -6
  7. package/internal/dist/index.d.ts +27 -26
  8. package/internal/dist/index.js +1 -1
  9. package/internal/src/families/dispose-from-store.ts +1 -1
  10. package/internal/src/families/find-in-store.ts +8 -8
  11. package/internal/src/families/get-family-of-token.ts +64 -0
  12. package/internal/src/families/init-family-member.ts +9 -10
  13. package/internal/src/families/seek-in-store.ts +8 -8
  14. package/internal/src/future.ts +4 -0
  15. package/internal/src/get-state/get-from-store.ts +17 -4
  16. package/internal/src/set-state/set-into-store.ts +13 -5
  17. package/json/dist/index.d.ts +3 -3
  18. package/json/dist/index.js +1 -1
  19. package/json/src/entries.ts +1 -1
  20. package/json/src/index.ts +13 -1
  21. package/package.json +15 -15
  22. package/react-devtools/dist/index.css +2 -2
  23. package/react-devtools/dist/index.js +14 -11
  24. package/react-devtools/src/StateIndex.tsx +4 -4
  25. package/react-devtools/src/TimelineIndex.tsx +2 -2
  26. package/react-devtools/src/TransactionIndex.tsx +2 -2
  27. package/react-devtools/src/devtools.scss +2 -2
  28. package/react-devtools/src/elastic-input/NumberInput.tsx +8 -7
  29. package/react-devtools/src/elastic-input/TextInput.tsx +6 -2
  30. package/realtime-server/dist/index.d.ts +8 -10
  31. package/realtime-server/src/ipc-sockets/child-socket.ts +1 -5
  32. package/realtime-server/src/ipc-sockets/custom-socket.ts +7 -7
  33. package/realtime-server/src/ipc-sockets/parent-socket.ts +4 -4
  34. package/realtime-server/src/realtime-continuity-synchronizer.ts +1 -1
  35. package/src/index.ts +25 -17
  36. package/transceivers/set-rtx/dist/index.js +5 -5
  37. package/transceivers/set-rtx/src/set-rtx.ts +6 -6
@@ -37,6 +37,9 @@ export class SubjectSocket<
37
37
 
38
38
  export class ParentSocket<
39
39
  I extends Events & {
40
+ [id in string as `relay:${id}`]: [string, ...Json.Serializable[]]
41
+ },
42
+ O extends Events & {
40
43
  [id in string as `user:${id}`]: [string, ...Json.Serializable[]]
41
44
  } & {
42
45
  /* eslint-disable quotes */
@@ -44,9 +47,6 @@ export class ParentSocket<
44
47
  "user-leaves": [string]
45
48
  /* eslint-enable quotes */
46
49
  },
47
- O extends Events & {
48
- [id in string as `relay:${id}`]: [string, ...Json.Serializable[]]
49
- },
50
50
  > extends CustomSocket<I, O> {
51
51
  protected incompleteData = ``
52
52
  protected unprocessedEvents: string[] = []
@@ -167,7 +167,7 @@ export class ParentSocket<
167
167
  relay.in.next(data)
168
168
  })
169
169
  relay.out.subscribe(`socket`, (data) => {
170
- this.emit(...(data as [string, ...O[keyof O]]))
170
+ this.emit(...(data as [string, ...I[keyof I]]))
171
171
  })
172
172
  })
173
173
 
@@ -174,7 +174,7 @@ export function realtimeContinuitySynchronizer({
174
174
  }
175
175
 
176
176
  const epoch = isRootStore(store)
177
- ? store.transactionMeta.epoch.get(continuityKey) ?? null
177
+ ? (store.transactionMeta.epoch.get(continuityKey) ?? null)
178
178
  : null
179
179
 
180
180
  socket?.emit(`continuity-init:${continuityKey}`, epoch, initialPayload)
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Transceiver } from "atom.io/internal"
2
- import type { Canonical, Json } from "atom.io/json"
2
+ import type { Canonical, Json, stringified } from "atom.io/json"
3
3
 
4
4
  import type { AtomFamilyToken } from "./atom"
5
5
  import type {
@@ -20,44 +20,49 @@ export * from "./timeline"
20
20
  export * from "./transaction"
21
21
  export * from "./validators"
22
22
 
23
- export type RegularAtomToken<T> = {
23
+ export type RegularAtomToken<T, K extends Canonical = any> = {
24
24
  key: string
25
25
  type: `atom`
26
- family?: FamilyMetadata
26
+ family?: FamilyMetadata<K>
27
27
  __T?: T
28
28
  }
29
29
  export type MutableAtomToken<
30
30
  T extends Transceiver<any>,
31
31
  J extends Json.Serializable,
32
+ K extends Canonical = any,
32
33
  > = {
33
34
  key: string
34
35
  type: `mutable_atom`
35
- family?: FamilyMetadata
36
+ family?: FamilyMetadata<K>
36
37
  __J?: J
37
38
  __U?: T extends Transceiver<infer Update> ? Update : never
38
39
  }
39
- export type AtomToken<T> =
40
- | MutableAtomToken<T extends Transceiver<any> ? T : never, any>
41
- | RegularAtomToken<T>
40
+ export type AtomToken<T, K extends Canonical = any> =
41
+ | MutableAtomToken<T extends Transceiver<any> ? T : never, any, K>
42
+ | RegularAtomToken<T, K>
42
43
 
43
- export type WritableSelectorToken<T> = {
44
+ export type WritableSelectorToken<T, K extends Canonical = any> = {
44
45
  key: string
45
46
  type: `selector`
46
- family?: FamilyMetadata
47
+ family?: FamilyMetadata<K>
47
48
  __T?: T
48
49
  }
49
- export type ReadonlySelectorToken<T> = {
50
+ export type ReadonlySelectorToken<T, K extends Canonical = any> = {
50
51
  key: string
51
52
  type: `readonly_selector`
52
- family?: FamilyMetadata
53
+ family?: FamilyMetadata<K>
53
54
  __T?: T
54
55
  }
55
- export type SelectorToken<T> =
56
- | ReadonlySelectorToken<T>
57
- | WritableSelectorToken<T>
56
+ export type SelectorToken<T, K extends Canonical = any> =
57
+ | ReadonlySelectorToken<T, K>
58
+ | WritableSelectorToken<T, K>
58
59
 
59
- export type WritableToken<T> = AtomToken<T> | WritableSelectorToken<T>
60
- export type ReadableToken<T> = AtomToken<T> | SelectorToken<T>
60
+ export type WritableToken<T, K extends Canonical = any> =
61
+ | AtomToken<T, K>
62
+ | WritableSelectorToken<T, K>
63
+ export type ReadableToken<T, K extends Canonical = any> =
64
+ | AtomToken<T, K>
65
+ | SelectorToken<T, K>
61
66
 
62
67
  export type WritableFamilyToken<T, K extends Canonical> =
63
68
  | AtomFamilyToken<T, K>
@@ -66,4 +71,7 @@ export type ReadableFamilyToken<T, K extends Canonical> =
66
71
  | AtomFamilyToken<T, K>
67
72
  | SelectorFamilyToken<T, K>
68
73
 
69
- export type FamilyMetadata = { key: string; subKey: string }
74
+ export type FamilyMetadata<K extends Canonical = any> = {
75
+ key: string
76
+ subKey: stringified<K>
77
+ }
@@ -1,6 +1,6 @@
1
1
  import '../../../dist/chunk-XWL6SNVU.js';
2
2
  import { Subject } from 'atom.io/internal';
3
- import { stringifyJson, parseJson } from 'atom.io/json';
3
+ import { stringifyJson } from 'atom.io/json';
4
4
 
5
5
  var SetRTX = class _SetRTX extends Set {
6
6
  mode = `record`;
@@ -111,13 +111,13 @@ var SetRTX = class _SetRTX extends Set {
111
111
  const value = update.substring(typeValueBreak + 1);
112
112
  switch (type) {
113
113
  case `add`:
114
- this.add(parseJson(value));
114
+ this.add(JSON.parse(value));
115
115
  break;
116
116
  case `clear`:
117
117
  this.clear();
118
118
  break;
119
119
  case `del`:
120
- this.delete(parseJson(value));
120
+ this.delete(JSON.parse(value));
121
121
  break;
122
122
  case `tx`:
123
123
  for (const subUpdate of value.split(`;`)) {
@@ -177,10 +177,10 @@ var SetRTX = class _SetRTX extends Set {
177
177
  const value = update.substring(breakpoint + 1);
178
178
  switch (type) {
179
179
  case `add`:
180
- this.delete(parseJson(value));
180
+ this.delete(JSON.parse(value));
181
181
  break;
182
182
  case `del`:
183
- this.add(parseJson(value));
183
+ this.add(JSON.parse(value));
184
184
  break;
185
185
  case `clear`: {
186
186
  const values = JSON.parse(value);
@@ -1,7 +1,7 @@
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"
4
- import { parseJson, stringifyJson } from "atom.io/json"
3
+ import type { Json, primitive } from "atom.io/json"
4
+ import { stringifyJson } from "atom.io/json"
5
5
 
6
6
  export type SetUpdate =
7
7
  | `add:${string}`
@@ -146,13 +146,13 @@ export class SetRTX<P extends primitive>
146
146
  const value = update.substring(typeValueBreak + 1)
147
147
  switch (type) {
148
148
  case `add`:
149
- this.add(parseJson(value as stringified<P>))
149
+ this.add(JSON.parse(value))
150
150
  break
151
151
  case `clear`:
152
152
  this.clear()
153
153
  break
154
154
  case `del`:
155
- this.delete(parseJson(value as stringified<P>))
155
+ this.delete(JSON.parse(value))
156
156
  break
157
157
  case `tx`:
158
158
  for (const subUpdate of value.split(`;`)) {
@@ -215,10 +215,10 @@ export class SetRTX<P extends primitive>
215
215
  const value = update.substring(breakpoint + 1)
216
216
  switch (type) {
217
217
  case `add`:
218
- this.delete(parseJson(value as stringified<P>))
218
+ this.delete(JSON.parse(value))
219
219
  break
220
220
  case `del`:
221
- this.add(parseJson(value as stringified<P>))
221
+ this.add(JSON.parse(value))
222
222
  break
223
223
  case `clear`: {
224
224
  const values = JSON.parse(value) as P[]