atom.io 0.27.4 → 0.28.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 (134) hide show
  1. package/data/dist/index.d.ts +31 -29
  2. package/data/dist/index.js +65 -81
  3. package/data/src/dict.ts +9 -12
  4. package/data/src/join.ts +30 -33
  5. package/data/src/struct-family.ts +17 -23
  6. package/data/src/struct.ts +9 -12
  7. package/dist/{chunk-JRENM6KL.js → chunk-BX3MTH2Z.js} +482 -385
  8. package/dist/chunk-D52JNVER.js +721 -0
  9. package/dist/chunk-EUVKUTW3.js +89 -0
  10. package/dist/index.d.ts +4 -3
  11. package/dist/index.js +35 -53
  12. package/ephemeral/dist/index.js +1 -1
  13. package/ephemeral/src/find-state.ts +1 -1
  14. package/immortal/dist/index.js +2 -2
  15. package/immortal/src/seek-state.ts +2 -2
  16. package/internal/dist/index.d.ts +141 -87
  17. package/internal/dist/index.js +1 -1
  18. package/internal/src/atom/create-regular-atom.ts +3 -3
  19. package/internal/src/atom/create-standalone-atom.ts +7 -5
  20. package/internal/src/atom/dispose-atom.ts +2 -9
  21. package/internal/src/families/create-atom-family.ts +5 -5
  22. package/internal/src/families/create-readonly-selector-family.ts +20 -9
  23. package/internal/src/families/create-regular-atom-family.ts +15 -6
  24. package/internal/src/families/create-selector-family.ts +5 -5
  25. package/internal/src/families/create-writable-selector-family.ts +20 -10
  26. package/internal/src/families/dispose-from-store.ts +43 -29
  27. package/internal/src/families/find-in-store.ts +28 -18
  28. package/internal/src/families/init-family-member.ts +9 -9
  29. package/internal/src/families/seek-in-store.ts +10 -10
  30. package/internal/src/get-state/get-from-store.ts +70 -47
  31. package/internal/src/ingest-updates/ingest-atom-update.ts +1 -1
  32. package/internal/src/ingest-updates/ingest-creation-disposal.ts +15 -6
  33. package/internal/src/molecule/create-molecule-family.ts +1 -1
  34. package/internal/src/molecule/dispose-molecule.ts +7 -18
  35. package/internal/src/molecule/grow-molecule-in-store.ts +1 -1
  36. package/internal/src/molecule/make-molecule-in-store.ts +5 -5
  37. package/internal/src/mutable/create-mutable-atom-family.ts +15 -6
  38. package/internal/src/mutable/create-mutable-atom.ts +3 -3
  39. package/internal/src/mutable/get-json-token.ts +2 -2
  40. package/internal/src/mutable/tracker-family.ts +3 -3
  41. package/internal/src/mutable/tracker.ts +14 -18
  42. package/internal/src/pretty-print.ts +1 -16
  43. package/internal/src/selector/create-readonly-selector.ts +2 -2
  44. package/internal/src/selector/create-standalone-selector.ts +5 -5
  45. package/internal/src/selector/create-writable-selector.ts +2 -2
  46. package/internal/src/selector/dispose-selector.ts +2 -9
  47. package/internal/src/selector/register-selector.ts +9 -9
  48. package/internal/src/set-state/set-into-store.ts +23 -33
  49. package/internal/src/store/circular-buffer.ts +34 -0
  50. package/internal/src/store/counterfeit.ts +109 -0
  51. package/internal/src/store/deposit.ts +67 -13
  52. package/internal/src/store/index.ts +1 -0
  53. package/internal/src/store/store.ts +4 -1
  54. package/internal/src/store/withdraw.ts +15 -10
  55. package/internal/src/subscribe/index.ts +2 -0
  56. package/internal/src/subscribe/subscribe-in-store.ts +62 -0
  57. package/internal/src/timeline/time-travel.ts +1 -1
  58. package/internal/src/transaction/build-transaction.ts +7 -6
  59. package/introspection/dist/index.d.ts +84 -4
  60. package/introspection/dist/index.js +1 -413
  61. package/introspection/src/attach-atom-index.ts +5 -8
  62. package/introspection/src/attach-introspection-states.ts +7 -4
  63. package/introspection/src/attach-selector-index.ts +6 -8
  64. package/introspection/src/attach-timeline-family.ts +25 -28
  65. package/introspection/src/attach-timeline-index.ts +5 -8
  66. package/introspection/src/attach-transaction-index.ts +5 -8
  67. package/introspection/src/attach-transaction-logs.ts +21 -27
  68. package/introspection/src/attach-type-selectors.ts +26 -0
  69. package/introspection/src/differ.ts +167 -0
  70. package/introspection/src/index.ts +2 -0
  71. package/introspection/src/refinery.ts +100 -0
  72. package/json/dist/index.d.ts +31 -30
  73. package/json/dist/index.js +2 -80
  74. package/json/src/entries.ts +6 -0
  75. package/json/src/index.ts +47 -6
  76. package/json/src/select-json-family.ts +4 -4
  77. package/json/src/select-json.ts +6 -9
  78. package/package.json +17 -8
  79. package/react/dist/index.js +7 -7
  80. package/react/src/parse-state-overloads.ts +2 -2
  81. package/react/src/use-i.ts +1 -1
  82. package/react/src/use-json.ts +2 -2
  83. package/react/src/use-o.ts +2 -2
  84. package/react-devtools/dist/index.d.ts +1 -91
  85. package/react-devtools/dist/index.js +285 -414
  86. package/react-devtools/src/AtomIODevtools.tsx +2 -2
  87. package/react-devtools/src/StateEditor.tsx +20 -12
  88. package/react-devtools/src/StateIndex.tsx +8 -26
  89. package/react-devtools/src/TimelineIndex.tsx +3 -3
  90. package/react-devtools/src/TransactionIndex.tsx +6 -6
  91. package/react-devtools/src/Updates.tsx +1 -4
  92. package/react-devtools/src/index.ts +0 -71
  93. package/react-devtools/src/store.ts +51 -0
  94. package/realtime/dist/index.d.ts +7 -7
  95. package/realtime/dist/index.js +18 -22
  96. package/realtime/src/realtime-continuity.ts +27 -35
  97. package/realtime-client/dist/index.js +59 -65
  98. package/realtime-client/src/pull-atom-family-member.ts +1 -1
  99. package/realtime-client/src/pull-atom.ts +1 -1
  100. package/realtime-client/src/pull-mutable-atom-family-member.ts +3 -3
  101. package/realtime-client/src/pull-mutable-atom.ts +3 -3
  102. package/realtime-client/src/realtime-client-stores/client-main-store.ts +6 -6
  103. package/realtime-client/src/sync-continuity.ts +55 -53
  104. package/realtime-react/dist/index.js +3 -3
  105. package/realtime-react/src/use-pull-atom-family-member.ts +1 -1
  106. package/realtime-react/src/use-pull-mutable-family-member.ts +1 -1
  107. package/realtime-react/src/use-pull-selector-family-member.ts +1 -1
  108. package/realtime-server/dist/index.js +72 -36
  109. package/realtime-server/src/realtime-continuity-synchronizer.ts +57 -93
  110. package/realtime-server/src/realtime-family-provider.ts +3 -3
  111. package/realtime-server/src/realtime-mutable-family-provider.ts +5 -5
  112. package/realtime-server/src/realtime-mutable-provider.ts +2 -2
  113. package/realtime-server/src/realtime-state-provider.ts +1 -1
  114. package/realtime-server/src/realtime-state-receiver.ts +1 -1
  115. package/realtime-testing/dist/index.d.ts +2 -0
  116. package/realtime-testing/dist/index.js +57 -15
  117. package/realtime-testing/src/setup-realtime-test.tsx +66 -16
  118. package/src/atom.ts +2 -2
  119. package/src/dispose-state.ts +2 -2
  120. package/src/get-state.ts +9 -13
  121. package/src/molecule.ts +1 -1
  122. package/src/selector.ts +2 -2
  123. package/src/set-state.ts +10 -7
  124. package/src/silo.ts +29 -55
  125. package/src/subscribe.ts +3 -23
  126. package/src/timeline.ts +2 -2
  127. package/web/dist/index.d.ts +9 -0
  128. package/{dist/chunk-H6EDLPKH.js → web/dist/index.js} +5 -4
  129. package/web/package.json +13 -0
  130. package/web/src/index.ts +1 -0
  131. package/web/src/persist-sync.ts +25 -0
  132. package/dist/chunk-AK23DRMD.js +0 -21
  133. package/dist/chunk-IW6WYRS7.js +0 -140
  134. package/internal/src/families/throw-in-case-of-conflicting-family.ts +0 -18
@@ -4,14 +4,14 @@ import { useI, useO } from "atom.io/react"
4
4
  import { LayoutGroup, motion, spring } from "framer-motion"
5
5
  import { useRef } from "react"
6
6
 
7
+ import { StateIndex } from "./StateIndex"
7
8
  import {
8
9
  atomIndex,
9
10
  devtoolsAreOpenState,
10
11
  devtoolsViewOptionsState,
11
12
  devtoolsViewSelectionState,
12
13
  selectorIndex,
13
- } from "."
14
- import { StateIndex } from "./StateIndex"
14
+ } from "./store"
15
15
  import { TimelineIndex } from "./TimelineIndex"
16
16
  import { TransactionIndex } from "./TransactionIndex"
17
17
 
@@ -1,12 +1,19 @@
1
1
  import type { ReadonlySelectorToken, WritableToken } from "atom.io"
2
+ import { isJson } from "atom.io/json"
2
3
  import { useI, useO } from "atom.io/react"
3
4
  import type { FC } from "react"
4
5
 
5
- import { fallback } from "~/packages/anvl/src/function"
6
- import { isJson } from "~/packages/anvl/src/refinement"
7
6
  import { ElasticInput } from "~/packages/hamr/react-elastic-input/src"
8
7
  import { JsonEditor } from "~/packages/hamr/react-json-editor/src"
9
8
 
9
+ export const fallback = <T,>(fn: () => T, fallbackValue: T): T => {
10
+ try {
11
+ return fn()
12
+ } catch (_) {
13
+ return fallbackValue
14
+ }
15
+ }
16
+
10
17
  export const StateEditor: FC<{
11
18
  token: WritableToken<unknown>
12
19
  }> = ({ token }) => {
@@ -18,16 +25,17 @@ export const StateEditor: FC<{
18
25
  <div className="json_editor">
19
26
  <ElasticInput
20
27
  value={
21
- data !== null &&
22
- typeof data === `object` &&
23
- `toJson` in data &&
24
- typeof data.toJson === `function`
25
- ? JSON.stringify(data.toJson())
26
- : data instanceof Set
27
- ? `Set { ${JSON.stringify([...data]).slice(1, -1)} }`
28
- : Object.getPrototypeOf(data).constructor.name +
29
- ` ` +
30
- fallback(() => JSON.stringify(data), `?`)
28
+ data === undefined || data === null
29
+ ? ``
30
+ : typeof data === `object` &&
31
+ `toJson` in data &&
32
+ typeof data.toJson === `function`
33
+ ? JSON.stringify(data.toJson())
34
+ : data instanceof Set
35
+ ? `Set { ${JSON.stringify([...data]).slice(1, -1)} }`
36
+ : Object.getPrototypeOf(data).constructor.name +
37
+ ` ` +
38
+ fallback(() => JSON.stringify(data), `?`)
31
39
  }
32
40
  disabled={true}
33
41
  />
@@ -6,32 +6,14 @@ import type {
6
6
  import { getState, selectorFamily } from "atom.io"
7
7
  import { findState } from "atom.io/ephemeral"
8
8
  import type { FamilyNode, WritableTokenIndex } from "atom.io/introspection"
9
+ import { primitiveRefinery } from "atom.io/introspection"
9
10
  import type { Canonical } from "atom.io/json"
10
11
  import { useI, useO } from "atom.io/react"
11
12
  import type { FC } from "react"
12
13
 
13
- import { isJson, refineJsonType } from "~/packages/anvl/src/refinement"
14
-
15
- import { findViewIsOpenState, primitiveRefinery } from "."
16
14
  import { button } from "./Button"
17
15
  import { StoreEditor } from "./StateEditor"
18
-
19
- const findStateTypeState = selectorFamily<string, Canonical>({
20
- key: `👁‍🗨 State Type`,
21
- get:
22
- (token) =>
23
- ({ get }) => {
24
- let state: unknown
25
- try {
26
- state = get(token as any)
27
- } catch (error) {
28
- return `error`
29
- }
30
- if (state === undefined) return `undefined`
31
- if (isJson(state)) return refineJsonType(state).type
32
- return Object.getPrototypeOf(state).constructor.name
33
- },
34
- })
16
+ import { typeSelectors, viewIsOpenAtoms } from "./store"
35
17
 
36
18
  export const StateIndexLeafNode: FC<{
37
19
  node: ReadableToken<unknown>
@@ -83,8 +65,8 @@ export const StateIndexTreeNode: FC<{
83
65
  const setIsOpen = useI(isOpenState)
84
66
  const isOpen = useO(isOpenState)
85
67
  for (const [key, childNode] of node.familyMembers) {
86
- findState(findViewIsOpenState, key)
87
- findState(findStateTypeState, childNode.key)
68
+ findState(viewIsOpenAtoms, key)
69
+ findState(typeSelectors, childNode.key)
88
70
  }
89
71
  return (
90
72
  <>
@@ -104,8 +86,8 @@ export const StateIndexTreeNode: FC<{
104
86
  <StateIndexNode
105
87
  key={key}
106
88
  node={childNode}
107
- isOpenState={findState(findViewIsOpenState, childNode.key)}
108
- typeState={findState(findStateTypeState, childNode.key)}
89
+ isOpenState={findState(viewIsOpenAtoms, childNode.key)}
90
+ typeState={findState(typeSelectors, childNode.key)}
109
91
  />
110
92
  ))
111
93
  : null}
@@ -147,8 +129,8 @@ export const StateIndex: FC<{
147
129
  <StateIndexNode
148
130
  key={key}
149
131
  node={node}
150
- isOpenState={findState(findViewIsOpenState, node.key)}
151
- typeState={findState(findStateTypeState, node.key)}
132
+ isOpenState={findState(viewIsOpenAtoms, node.key)}
133
+ typeState={findState(typeSelectors, node.key)}
152
134
  />
153
135
  )
154
136
  })}
@@ -9,8 +9,8 @@ import type { Timeline } from "atom.io/internal"
9
9
  import { useI, useO } from "atom.io/react"
10
10
  import { type FC, Fragment } from "react"
11
11
 
12
- import { findTimelineState, findViewIsOpenState, timelineIndex } from "."
13
12
  import { button } from "./Button"
13
+ import { timelineIndex, timelineSelectors, viewIsOpenAtoms } from "./store"
14
14
  import { article } from "./Updates"
15
15
 
16
16
  export const YouAreHere: FC = () => {
@@ -96,8 +96,8 @@ export const TimelineIndex: FC = () => {
96
96
  <TimelineLog
97
97
  key={token.key}
98
98
  token={token}
99
- isOpenState={findState(findViewIsOpenState, token.key)}
100
- timelineState={findState(findTimelineState, token.key)}
99
+ isOpenState={findState(viewIsOpenAtoms, token.key)}
100
+ timelineState={findState(timelineSelectors, token.key)}
101
101
  />
102
102
  )
103
103
  })}
@@ -9,12 +9,12 @@ import type { Func } from "atom.io/internal"
9
9
  import { useI, useO } from "atom.io/react"
10
10
  import type { FC } from "react"
11
11
 
12
+ import { button } from "./Button"
12
13
  import {
13
- findTransactionLogState,
14
- findViewIsOpenState,
15
14
  transactionIndex,
16
- } from "."
17
- import { button } from "./Button"
15
+ transactionLogSelectors,
16
+ viewIsOpenAtoms,
17
+ } from "./store"
18
18
  import { article } from "./Updates"
19
19
 
20
20
  export const TransactionLog: FC<{
@@ -68,8 +68,8 @@ export const TransactionIndex: FC = () => {
68
68
  <TransactionLog
69
69
  key={token.key}
70
70
  token={token}
71
- isOpenState={findState(findViewIsOpenState, token.key)}
72
- logState={findState(findTransactionLogState, token.key)}
71
+ isOpenState={findState(viewIsOpenAtoms, token.key)}
72
+ logState={findState(transactionLogSelectors, token.key)}
73
73
  />
74
74
  )
75
75
  })}
@@ -4,12 +4,9 @@ import type {
4
4
  TransactionUpdate,
5
5
  } from "atom.io"
6
6
  import type { Func } from "atom.io/internal"
7
+ import { discoverType, prettyJson } from "atom.io/introspection"
7
8
  import * as React from "react"
8
9
 
9
- import { discoverType } from "~/packages/anvl/src/refinement/refinery"
10
-
11
- import { prettyJson } from "."
12
-
13
10
  const AtomUpdateFC: React.FC<{
14
11
  serialNumber: number
15
12
  atomUpdate: KeyedStateUpdate<unknown>
@@ -1,72 +1 @@
1
- import { atom, atomFamily } from "atom.io"
2
- import { attachIntrospectionStates } from "atom.io/introspection"
3
-
4
- import { isPlainObject } from "~/packages/anvl/src/object"
5
- import { Refinery } from "~/packages/anvl/src/refinement"
6
- import {
7
- diffArray,
8
- diffBoolean,
9
- Differ,
10
- diffNumber,
11
- diffObject,
12
- diffString,
13
- } from "~/packages/anvl/src/tree/differ"
14
- import { lazyLocalStorageEffect } from "~/packages/atom.io/__unstable__/web-effects/src"
15
-
16
1
  export * from "./AtomIODevtools"
17
-
18
- export const {
19
- atomIndex,
20
- selectorIndex,
21
- transactionIndex,
22
- findTransactionLogState,
23
- timelineIndex,
24
- findTimelineState,
25
- } = attachIntrospectionStates()
26
-
27
- export const devtoolsAreOpenState = atom<boolean>({
28
- key: `👁‍🗨 Devtools Are Open`,
29
- default: true,
30
- effects: [lazyLocalStorageEffect(`👁‍🗨 Devtools Are Open`)],
31
- })
32
-
33
- type DevtoolsView = `atoms` | `selectors` | `timelines` | `transactions`
34
-
35
- export const devtoolsViewSelectionState = atom<DevtoolsView>({
36
- key: `👁‍🗨 Devtools View Selection`,
37
- default: `atoms`,
38
- effects: [lazyLocalStorageEffect(`👁‍🗨 Devtools View`)],
39
- })
40
-
41
- export const devtoolsViewOptionsState = atom<DevtoolsView[]>({
42
- key: `👁‍🗨 Devtools View Options`,
43
- default: [`atoms`, `selectors`, `transactions`, `timelines`],
44
- effects: [lazyLocalStorageEffect(`👁‍🗨 Devtools View Options`)],
45
- })
46
-
47
- export const findViewIsOpenState = atomFamily<boolean, string>({
48
- key: `👁‍🗨 Devtools View Is Open`,
49
- default: false,
50
- effects: (key) => [lazyLocalStorageEffect(key + `:view-is-open`)],
51
- })
52
-
53
- export const primitiveRefinery = new Refinery({
54
- number: (input: unknown): input is number => typeof input === `number`,
55
- string: (input: unknown): input is string => typeof input === `string`,
56
- boolean: (input: unknown): input is boolean => typeof input === `boolean`,
57
- null: (input: unknown): input is null => input === null,
58
- })
59
-
60
- export const jsonTreeRefinery = new Refinery({
61
- object: isPlainObject,
62
- array: (input: unknown): input is unknown[] => Array.isArray(input),
63
- })
64
-
65
- export const prettyJson = new Differ(primitiveRefinery, jsonTreeRefinery, {
66
- number: diffNumber,
67
- string: diffString,
68
- boolean: diffBoolean,
69
- null: () => ({ summary: `No Change` }),
70
- object: diffObject,
71
- array: diffArray,
72
- })
@@ -0,0 +1,51 @@
1
+ import { atom, atomFamily } from "atom.io"
2
+ import { attachIntrospectionStates } from "atom.io/introspection"
3
+ import { persistSync } from "atom.io/web"
4
+
5
+ export const {
6
+ atomIndex,
7
+ selectorIndex,
8
+ transactionIndex,
9
+ transactionLogSelectors,
10
+ timelineIndex,
11
+ timelineSelectors,
12
+ typeSelectors,
13
+ } = attachIntrospectionStates()
14
+
15
+ export const devtoolsAreOpenState = atom<boolean>({
16
+ key: `👁‍🗨 Devtools Are Open`,
17
+ default: true,
18
+ effects:
19
+ typeof window === `undefined`
20
+ ? []
21
+ : [persistSync(window.localStorage, JSON, `👁‍🗨 Devtools Are Open`)],
22
+ })
23
+
24
+ type DevtoolsView = `atoms` | `selectors` | `timelines` | `transactions`
25
+
26
+ export const devtoolsViewSelectionState = atom<DevtoolsView>({
27
+ key: `👁‍🗨 Devtools View Selection`,
28
+ default: `atoms`,
29
+ effects:
30
+ typeof window === `undefined`
31
+ ? []
32
+ : [persistSync(window.localStorage, JSON, `👁‍🗨 Devtools View`)],
33
+ })
34
+
35
+ export const devtoolsViewOptionsState = atom<DevtoolsView[]>({
36
+ key: `👁‍🗨 Devtools View Options`,
37
+ default: [`atoms`, `selectors`, `transactions`, `timelines`],
38
+ effects:
39
+ typeof window === `undefined`
40
+ ? []
41
+ : [persistSync(window.localStorage, JSON, `👁‍🗨 Devtools View Options`)],
42
+ })
43
+
44
+ export const viewIsOpenAtoms = atomFamily<boolean, string>({
45
+ key: `👁‍🗨 Devtools View Is Open`,
46
+ default: false,
47
+ effects: (key) =>
48
+ typeof window === `undefined`
49
+ ? []
50
+ : [persistSync(window.localStorage, JSON, key + `:view-is-open`)],
51
+ })
@@ -1,6 +1,6 @@
1
1
  import * as atom_io from 'atom.io';
2
- import { AtomFamilyToken, ReadableFamilyToken, ReadableToken, AtomToken, TransactionToken, MutableAtomToken } from 'atom.io';
3
- import { Canonical, Json } from 'atom.io/json';
2
+ import { AtomFamilyToken, ReadableFamilyToken, ReadableToken, TokenType, AtomToken, TransactionToken, MutableAtomToken } from 'atom.io';
3
+ import { Canonical } from 'atom.io/json';
4
4
  import * as atom_io_data from 'atom.io/data';
5
5
  import { SetRTX, SetRTXJson } from 'atom.io/transceivers/set-rtx';
6
6
 
@@ -8,24 +8,24 @@ declare class InvariantMap<K, V> extends Map<K, V> {
8
8
  set(key: K, value: V): this;
9
9
  clear(): void;
10
10
  }
11
- type PerspectiveToken<F extends AtomFamilyToken<any>, T extends F extends AtomFamilyToken<infer U, any> ? U : never> = {
11
+ type PerspectiveToken<F extends AtomFamilyToken<any>> = {
12
12
  type: `realtime_perspective`;
13
13
  resourceAtoms: F;
14
- viewAtoms: ReadableFamilyToken<ReadableToken<T>[], string>;
14
+ viewAtoms: ReadableFamilyToken<ReadableToken<TokenType<F>>[], string>;
15
15
  };
16
16
  type ContinuityToken = {
17
17
  readonly type: `continuity`;
18
18
  readonly key: string;
19
19
  readonly globals: AtomToken<any>[];
20
20
  readonly actions: TransactionToken<any>[];
21
- readonly perspectives: PerspectiveToken<AtomFamilyToken<any, Canonical>, Json.Serializable>[];
21
+ readonly perspectives: PerspectiveToken<AtomFamilyToken<any, Canonical>>[];
22
22
  };
23
23
  declare class SyncGroup {
24
24
  protected readonly key: string;
25
- protected type: "continuity";
25
+ type: "continuity";
26
26
  protected globals: AtomToken<any>[];
27
27
  protected actions: TransactionToken<any>[];
28
- protected perspectives: PerspectiveToken<any, any>[];
28
+ protected perspectives: PerspectiveToken<any>[];
29
29
  protected constructor(key: string);
30
30
  static existing: InvariantMap<string, ContinuityToken>;
31
31
  static create(key: string, builder: (group: SyncGroup) => SyncGroup): ContinuityToken;
@@ -1,5 +1,5 @@
1
1
  import '../../dist/chunk-XWL6SNVU.js';
2
- import { getUpdateToken, assignTransactionToContinuity, IMPLICIT, setEpochNumberOfContinuity } from 'atom.io/internal';
2
+ import { assignTransactionToContinuity, IMPLICIT, setEpochNumberOfContinuity } from 'atom.io/internal';
3
3
  import { atom, selectorFamily } from 'atom.io';
4
4
  import { join, getInternalRelations } from 'atom.io/data';
5
5
  import { SetRTX } from 'atom.io/transceivers/set-rtx';
@@ -37,28 +37,24 @@ var SyncGroup = class _SyncGroup {
37
37
  }
38
38
  add(...args) {
39
39
  const zeroth = args[0];
40
- if (zeroth.type === `atom` || zeroth.type === `mutable_atom`) {
41
- const globals = args;
42
- for (const global of globals) {
43
- switch (global.type) {
44
- case `atom`:
45
- this.globals.push(global);
46
- break;
47
- case `mutable_atom`:
48
- this.globals.push(getUpdateToken(global));
49
- break;
40
+ switch (zeroth.type) {
41
+ case `atom`:
42
+ case `mutable_atom`:
43
+ this.globals.push(...args);
44
+ break;
45
+ case `transaction`:
46
+ this.actions.push(...args);
47
+ break;
48
+ case `atom_family`:
49
+ {
50
+ const [family, index] = args;
51
+ this.perspectives.push({
52
+ type: `realtime_perspective`,
53
+ resourceAtoms: family,
54
+ viewAtoms: index
55
+ });
50
56
  }
51
- }
52
- } else if (zeroth.type === `transaction`) {
53
- const actions = args;
54
- this.actions.push(...actions);
55
- } else {
56
- const [family, index] = args;
57
- this.perspectives.push({
58
- type: `realtime_perspective`,
59
- resourceAtoms: family,
60
- viewAtoms: index
61
- });
57
+ break;
62
58
  }
63
59
  return this;
64
60
  }
@@ -3,6 +3,7 @@ import type {
3
3
  AtomToken,
4
4
  ReadableFamilyToken,
5
5
  ReadableToken,
6
+ TokenType,
6
7
  TransactionToken,
7
8
  } from "atom.io"
8
9
  import {
@@ -30,13 +31,10 @@ export class InvariantMap<K, V> extends Map<K, V> {
30
31
  }
31
32
  }
32
33
 
33
- export type PerspectiveToken<
34
- F extends AtomFamilyToken<any>,
35
- T extends F extends AtomFamilyToken<infer U, any> ? U : never,
36
- > = {
34
+ export type PerspectiveToken<F extends AtomFamilyToken<any>> = {
37
35
  type: `realtime_perspective`
38
36
  resourceAtoms: F
39
- viewAtoms: ReadableFamilyToken<ReadableToken<T>[], string>
37
+ viewAtoms: ReadableFamilyToken<ReadableToken<TokenType<F>>[], string>
40
38
  }
41
39
 
42
40
  export type ContinuityToken = {
@@ -44,18 +42,15 @@ export type ContinuityToken = {
44
42
  readonly key: string
45
43
  readonly globals: AtomToken<any>[]
46
44
  readonly actions: TransactionToken<any>[]
47
- readonly perspectives: PerspectiveToken<
48
- AtomFamilyToken<any, Canonical>,
49
- Json.Serializable
50
- >[]
45
+ readonly perspectives: PerspectiveToken<AtomFamilyToken<any, Canonical>>[]
51
46
  }
52
47
 
53
48
  export class SyncGroup {
54
- protected type = `continuity` as const
49
+ public type = `continuity` as const
55
50
 
56
51
  protected globals: AtomToken<any>[] = []
57
52
  protected actions: TransactionToken<any>[] = []
58
- protected perspectives: PerspectiveToken<any, any>[] = []
53
+ protected perspectives: PerspectiveToken<any>[] = []
59
54
 
60
55
  protected constructor(protected readonly key: string) {}
61
56
 
@@ -88,32 +83,29 @@ export class SyncGroup {
88
83
  | [AtomFamilyToken<any, any>, ReadableFamilyToken<Iterable<any>, string>]
89
84
  ): this {
90
85
  const zeroth = args[0]
91
- if (zeroth.type === `atom` || zeroth.type === `mutable_atom`) {
92
- const globals = args as AtomToken<any>[]
93
- for (const global of globals) {
94
- switch (global.type) {
95
- case `atom`:
96
- this.globals.push(global)
97
- break
98
- case `mutable_atom`:
99
- this.globals.push(getUpdateToken(global))
100
- break
86
+ switch (zeroth.type) {
87
+ case `atom`:
88
+ case `mutable_atom`:
89
+ this.globals.push(...(args as AtomToken<any>[]))
90
+ break
91
+ case `transaction`:
92
+ this.actions.push(...(args as TransactionToken<any>[]))
93
+ break
94
+ case `atom_family`:
95
+ {
96
+ const [family, index] = args as [
97
+ AtomFamilyToken<any, any>,
98
+ ReadableFamilyToken<ReadableToken<any>[], string>,
99
+ ]
100
+ this.perspectives.push({
101
+ type: `realtime_perspective`,
102
+ resourceAtoms: family,
103
+ viewAtoms: index,
104
+ })
101
105
  }
102
- }
103
- } else if (zeroth.type === `transaction`) {
104
- const actions = args as TransactionToken<any>[]
105
- this.actions.push(...actions)
106
- } else {
107
- const [family, index] = args as [
108
- AtomFamilyToken<any, any>,
109
- ReadableFamilyToken<ReadableToken<any>[], string>,
110
- ]
111
- this.perspectives.push({
112
- type: `realtime_perspective`,
113
- resourceAtoms: family,
114
- viewAtoms: index,
115
- })
106
+ break
116
107
  }
108
+
117
109
  return this
118
110
  }
119
111
  }