atom.io 0.31.0 → 0.32.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 (171) hide show
  1. package/data/dist/index.d.ts +867 -101
  2. package/data/dist/index.js +10 -558
  3. package/data/src/index.ts +0 -2
  4. package/data/src/struct-family.ts +1 -1
  5. package/data/src/struct.ts +1 -2
  6. package/dist/chunk-354XQWHH.js +153 -0
  7. package/dist/chunk-4LWKCEW3.js +14 -0
  8. package/dist/chunk-5F2V7S3B.js +83 -0
  9. package/dist/chunk-ECOMOMUN.js +631 -0
  10. package/dist/{chunk-42UH5F5Q.js → chunk-GY2XQYZY.js} +2051 -755
  11. package/dist/chunk-NF7FJKJD.js +107 -0
  12. package/dist/chunk-R3ZUK5EH.js +1024 -0
  13. package/dist/chunk-Z2UJW4NQ.js +523 -0
  14. package/dist/index.d.ts +855 -127
  15. package/dist/index.js +1 -143
  16. package/eslint-plugin/dist/index.d.ts +1 -30
  17. package/eslint-plugin/dist/index.js +0 -146
  18. package/eslint-plugin/src/index.ts +0 -1
  19. package/eslint-plugin/src/rules/index.ts +0 -1
  20. package/internal/dist/index.d.ts +794 -70
  21. package/internal/dist/index.js +1 -2
  22. package/internal/src/atom/create-regular-atom.ts +3 -3
  23. package/internal/src/atom/dispose-atom.ts +4 -13
  24. package/internal/src/atom/is-default.ts +3 -3
  25. package/internal/src/caching.ts +5 -5
  26. package/internal/src/capitalize.ts +3 -0
  27. package/internal/src/families/create-readonly-selector-family.ts +5 -6
  28. package/internal/src/families/create-writable-selector-family.ts +1 -4
  29. package/internal/src/families/dispose-from-store.ts +3 -13
  30. package/internal/src/families/find-in-store.ts +1 -6
  31. package/internal/src/get-state/get-from-store.ts +2 -2
  32. package/internal/src/get-state/read-or-compute-value.ts +1 -1
  33. package/internal/src/index.ts +19 -9
  34. package/internal/src/ingest-updates/ingest-creation-disposal.ts +2 -3
  35. package/internal/src/install-into-store.ts +48 -0
  36. package/internal/src/join/edit-relations-in-store.ts +32 -0
  37. package/internal/src/join/find-relations-in-store.ts +124 -0
  38. package/internal/src/join/get-internal-relations-from-store.ts +14 -0
  39. package/internal/src/join/get-join.ts +31 -0
  40. package/internal/src/join/index.ts +5 -0
  41. package/{data/src/join.ts → internal/src/join/join-internal.ts} +20 -429
  42. package/internal/src/keys.ts +7 -7
  43. package/internal/src/molecule.ts +299 -0
  44. package/internal/src/mutable/create-mutable-atom-family.ts +1 -1
  45. package/internal/src/mutable/create-mutable-atom.ts +3 -3
  46. package/internal/src/mutable/get-json-token.ts +1 -1
  47. package/internal/src/mutable/tracker-family.ts +19 -17
  48. package/internal/src/mutable/tracker.ts +8 -8
  49. package/internal/src/not-found-error.ts +8 -30
  50. package/internal/src/pretty-print.ts +2 -13
  51. package/internal/src/selector/create-readonly-selector.ts +3 -7
  52. package/internal/src/selector/create-writable-selector.ts +4 -4
  53. package/internal/src/selector/dispose-selector.ts +20 -11
  54. package/internal/src/selector/get-selector-dependency-keys.ts +1 -1
  55. package/internal/src/selector/register-selector.ts +7 -17
  56. package/internal/src/selector/trace-selector-atoms.ts +2 -2
  57. package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
  58. package/internal/src/set-state/emit-update.ts +1 -1
  59. package/internal/src/set-state/evict-downstream.ts +1 -1
  60. package/internal/src/set-state/set-atom-or-selector.ts +1 -1
  61. package/internal/src/set-state/set-atom.ts +10 -10
  62. package/internal/src/set-state/set-into-store.ts +2 -2
  63. package/internal/src/set-state/stow-update.ts +1 -1
  64. package/internal/src/store/deposit.ts +10 -8
  65. package/internal/src/store/store.ts +1 -1
  66. package/internal/src/store/withdraw.ts +34 -53
  67. package/internal/src/subscribe/recall-state.ts +1 -1
  68. package/internal/src/subscribe/subscribe-in-store.ts +3 -3
  69. package/internal/src/subscribe/subscribe-to-root-atoms.ts +3 -3
  70. package/internal/src/subscribe/subscribe-to-state.ts +5 -5
  71. package/internal/src/subscribe/subscribe-to-timeline.ts +3 -3
  72. package/internal/src/subscribe/subscribe-to-transaction.ts +3 -3
  73. package/internal/src/timeline/create-timeline.ts +17 -37
  74. package/internal/src/transaction/act-upon-store.ts +2 -2
  75. package/internal/src/transaction/apply-transaction.ts +5 -5
  76. package/internal/src/transaction/assign-transaction-to-continuity.ts +1 -1
  77. package/internal/src/transaction/build-transaction.ts +5 -8
  78. package/internal/src/transaction/create-transaction.ts +3 -3
  79. package/internal/src/transaction/get-epoch-number.ts +3 -3
  80. package/internal/src/transaction/set-epoch-number.ts +2 -2
  81. package/introspection/dist/index.d.ts +922 -6
  82. package/introspection/dist/index.js +2 -620
  83. package/json/dist/index.d.ts +899 -5
  84. package/json/dist/index.js +1 -81
  85. package/json/src/select-json-family.ts +3 -14
  86. package/package.json +27 -45
  87. package/react/dist/index.d.ts +921 -3
  88. package/react/dist/index.js +2 -82
  89. package/react/src/use-o.ts +1 -1
  90. package/react/src/use-tl.ts +2 -2
  91. package/react-devtools/dist/index.css +16 -14
  92. package/react-devtools/dist/index.d.ts +26 -1
  93. package/react-devtools/dist/index.js +6 -6
  94. package/react-devtools/src/devtools.scss +16 -14
  95. package/realtime/dist/index.d.ts +202 -8
  96. package/realtime/dist/index.js +2 -107
  97. package/realtime/src/realtime-continuity.ts +2 -2
  98. package/realtime/src/shared-room-store.ts +1 -2
  99. package/realtime-client/dist/index.d.ts +960 -22
  100. package/realtime-client/dist/index.js +3 -509
  101. package/realtime-client/src/continuity/register-and-attempt-confirmed-update.ts +3 -3
  102. package/realtime-client/src/continuity/use-conceal-state.ts +1 -1
  103. package/realtime-client/src/pull-atom-family-member.ts +2 -2
  104. package/realtime-client/src/pull-atom.ts +2 -2
  105. package/realtime-client/src/pull-mutable-atom-family-member.ts +2 -2
  106. package/realtime-client/src/pull-mutable-atom.ts +2 -2
  107. package/realtime-client/src/pull-selector-family-member.ts +4 -4
  108. package/realtime-client/src/pull-selector.ts +4 -4
  109. package/realtime-client/src/push-state.ts +5 -10
  110. package/realtime-client/src/server-action.ts +4 -4
  111. package/realtime-client/src/sync-continuity.ts +6 -6
  112. package/realtime-react/dist/index.d.ts +166 -12
  113. package/realtime-react/dist/index.js +5 -154
  114. package/realtime-react/src/use-pull-atom-family-member.ts +1 -1
  115. package/realtime-react/src/use-pull-atom.ts +1 -1
  116. package/realtime-react/src/use-pull-mutable-atom.ts +1 -1
  117. package/realtime-react/src/use-pull-mutable-family-member.ts +1 -1
  118. package/realtime-react/src/use-pull-selector-family-member.ts +1 -1
  119. package/realtime-react/src/use-pull-selector.ts +1 -1
  120. package/realtime-react/src/use-push.ts +1 -1
  121. package/realtime-react/src/use-server-action.ts +2 -2
  122. package/realtime-react/src/use-sync-continuity.ts +1 -1
  123. package/realtime-server/dist/index.d.ts +971 -28
  124. package/realtime-server/dist/index.js +3 -1001
  125. package/realtime-server/src/continuity/prepare-to-serve-transaction-request.ts +1 -1
  126. package/realtime-server/src/continuity/prepare-to-sync-realtime-continuity.ts +3 -3
  127. package/realtime-server/src/continuity/subscribe-to-continuity-actions.ts +2 -2
  128. package/realtime-server/src/continuity/subscribe-to-continuity-perpectives.ts +2 -2
  129. package/realtime-server/src/ipc-sockets/child-socket.ts +0 -1
  130. package/realtime-server/src/realtime-action-receiver.ts +1 -1
  131. package/realtime-server/src/realtime-family-provider.ts +2 -2
  132. package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
  133. package/realtime-server/src/realtime-mutable-provider.ts +2 -2
  134. package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +2 -1
  135. package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +1 -1
  136. package/realtime-server/src/realtime-server-stores/server-user-store.ts +1 -2
  137. package/realtime-server/src/realtime-state-provider.ts +2 -2
  138. package/realtime-testing/dist/index.d.ts +1091 -3
  139. package/realtime-testing/dist/index.js +23 -26
  140. package/realtime-testing/src/setup-realtime-test.tsx +6 -5
  141. package/src/atom.ts +53 -29
  142. package/src/dispose-state.ts +12 -2
  143. package/{ephemeral/src → src}/find-state.ts +35 -25
  144. package/src/get-state.ts +16 -0
  145. package/src/index.ts +77 -3
  146. package/src/join.ts +218 -0
  147. package/src/realm.ts +169 -0
  148. package/src/selector.ts +20 -0
  149. package/src/set-state.ts +16 -8
  150. package/src/silo.ts +13 -7
  151. package/src/timeline.ts +1 -1
  152. package/src/transaction.ts +4 -8
  153. package/transceivers/set-rtx/dist/index.d.ts +37 -2
  154. package/transceivers/set-rtx/dist/index.js +1 -212
  155. package/transceivers/set-rtx/src/set-rtx.ts +4 -1
  156. package/web/dist/index.d.ts +30 -1
  157. package/web/dist/index.js +1 -15
  158. package/data/src/until.ts +0 -15
  159. package/dist/chunk-ICGFFQ3H.js +0 -272
  160. package/ephemeral/dist/index.d.ts +0 -57
  161. package/ephemeral/dist/index.js +0 -9
  162. package/ephemeral/package.json +0 -13
  163. package/ephemeral/src/index.ts +0 -1
  164. package/eslint-plugin/src/rules/lifespan.ts +0 -203
  165. package/immortal/dist/index.d.ts +0 -12
  166. package/immortal/dist/index.js +0 -9
  167. package/immortal/package.json +0 -13
  168. package/immortal/src/index.ts +0 -1
  169. package/immortal/src/seek-state.ts +0 -60
  170. package/src/allocate.ts +0 -443
  171. package/src/molecule.ts +0 -16
@@ -1,83 +1,3 @@
1
+ export { StoreContext, StoreProvider, useI, useJSON, useO, useTL } from '../../dist/chunk-5F2V7S3B.js';
2
+ import '../../dist/chunk-GY2XQYZY.js';
1
3
  import '../../dist/chunk-XWL6SNVU.js';
2
- import { IMPLICIT, setIntoStore, subscribeToState, getFromStore, findInStore, getJsonToken, withdraw, subscribeToTimeline } from 'atom.io/internal';
3
- import * as React5 from 'react';
4
- import { jsx } from 'react/jsx-runtime';
5
- import { undo, redo } from 'atom.io';
6
-
7
- var StoreContext = React5.createContext(IMPLICIT.STORE);
8
- var StoreProvider = ({ children, store = IMPLICIT.STORE }) => /* @__PURE__ */ jsx(StoreContext.Provider, { value: store, children });
9
- function parseStateOverloads(store, ...rest) {
10
- let token;
11
- if (rest.length === 2) {
12
- const family = rest[0];
13
- const key = rest[1];
14
- token = findInStore(store, family, key);
15
- } else {
16
- token = rest[0];
17
- }
18
- return token;
19
- }
20
-
21
- // react/src/use-i.ts
22
- function useI(...params) {
23
- const store = React5.useContext(StoreContext);
24
- const token = parseStateOverloads(store, ...params);
25
- const setter = React5.useRef(null);
26
- if (setter.current === null) {
27
- setter.current = (next) => {
28
- setIntoStore(store, token, next);
29
- };
30
- }
31
- return setter.current;
32
- }
33
- function useO(...params) {
34
- const store = React5.useContext(StoreContext);
35
- const token = parseStateOverloads(store, ...params);
36
- const id = React5.useId();
37
- return React5.useSyncExternalStore(
38
- (dispatch) => subscribeToState(token, dispatch, `use-o:${id}`, store),
39
- () => getFromStore(store, token),
40
- () => getFromStore(store, token)
41
- );
42
- }
43
-
44
- // react/src/use-json.ts
45
- function useJSON(token, key) {
46
- const store = React5.useContext(StoreContext);
47
- const stateToken = token.type === `mutable_atom_family` ? findInStore(store, token, key) : token;
48
- const jsonToken = getJsonToken(store, stateToken);
49
- return useO(jsonToken);
50
- }
51
- function useTL(token) {
52
- const store = React5.useContext(StoreContext);
53
- const id = React5.useId();
54
- const timeline = withdraw(token, store);
55
- const tokenRef = React5.useRef(token);
56
- const rebuildMeta = () => {
57
- return {
58
- at: timeline.at,
59
- length: timeline.history.length,
60
- undo: () => {
61
- undo(token);
62
- },
63
- redo: () => {
64
- redo(token);
65
- }
66
- };
67
- };
68
- const meta = React5.useRef(rebuildMeta());
69
- const retrieve = () => {
70
- if (meta.current.at !== timeline?.at || meta.current.length !== timeline?.history.length || tokenRef.current !== token) {
71
- tokenRef.current = token;
72
- meta.current = rebuildMeta();
73
- }
74
- return meta.current;
75
- };
76
- return React5.useSyncExternalStore(
77
- (dispatch) => subscribeToTimeline(token, dispatch, `use-tl:${id}`, store),
78
- retrieve,
79
- retrieve
80
- );
81
- }
82
-
83
- export { StoreContext, StoreProvider, useI, useJSON, useO, useTL };
@@ -20,7 +20,7 @@ export function useO<T, K extends Canonical>(
20
20
  const token = parseStateOverloads(store, ...params)
21
21
  const id = React.useId()
22
22
  return React.useSyncExternalStore<T>(
23
- (dispatch) => subscribeToState(token, dispatch, `use-o:${id}`, store),
23
+ (dispatch) => subscribeToState(store, token, `use-o:${id}`, dispatch),
24
24
  () => getFromStore(store, token),
25
25
  () => getFromStore(store, token),
26
26
  )
@@ -15,7 +15,7 @@ export type TimelineMeta = {
15
15
  export function useTL(token: TimelineToken<any>): TimelineMeta {
16
16
  const store = React.useContext(StoreContext)
17
17
  const id = React.useId()
18
- const timeline = withdraw(token, store)
18
+ const timeline = withdraw(store, token)
19
19
  const tokenRef = React.useRef(token)
20
20
  const rebuildMeta = () => {
21
21
  return {
@@ -42,7 +42,7 @@ export function useTL(token: TimelineToken<any>): TimelineMeta {
42
42
  return meta.current
43
43
  }
44
44
  return React.useSyncExternalStore<TimelineMeta>(
45
- (dispatch) => subscribeToTimeline(token, dispatch, `use-tl:${id}`, store),
45
+ (dispatch) => subscribeToTimeline(store, token, `use-tl:${id}`, dispatch),
46
46
  retrieve,
47
47
  retrieve,
48
48
  )
@@ -9,20 +9,22 @@ main[data-css=atom_io_devtools] {
9
9
  --bg-color: #ddd;
10
10
  --bg-tint1: #e3e3e3;
11
11
  }
12
- box-sizing: border-box;
13
- color: var(--fg-color);
14
- background-color: var(--bg-color);
15
- border: 2px solid var(--fg-color);
16
- position: fixed;
17
- right: 0;
18
- bottom: 0;
19
- height: 100%;
20
- display: flex;
21
- flex-flow: column;
22
- max-height: 800px;
23
- width: 100%;
24
- max-width: 500px;
25
- overflow-y: scroll;
12
+ & {
13
+ box-sizing: border-box;
14
+ color: var(--fg-color);
15
+ background-color: var(--bg-color);
16
+ border: 2px solid var(--fg-color);
17
+ position: fixed;
18
+ right: 0;
19
+ bottom: 0;
20
+ height: 100%;
21
+ display: flex;
22
+ flex-flow: column;
23
+ max-height: 800px;
24
+ width: 100%;
25
+ max-width: 500px;
26
+ overflow-y: scroll;
27
+ }
26
28
  * {
27
29
  font-size: 16px;
28
30
  font-family: theia, monospace;
@@ -1,5 +1,4 @@
1
1
  import { DetailedHTMLProps, InputHTMLAttributes, ForwardRefExoticComponent, FC, ErrorInfo, ReactNode, Component, CSSProperties, ReactElement } from 'react';
2
- import { JsonTypes, Json } from 'atom.io/json';
3
2
 
4
3
  declare const AtomIODevtools: React.FC;
5
4
 
@@ -76,6 +75,32 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryS
76
75
  render(): ReactNode;
77
76
  }
78
77
 
78
+ type primitive = boolean | number | string | null;
79
+ declare namespace Json {
80
+ namespace Tree {
81
+ type Array<Element = unknown> = ReadonlyArray<Element>;
82
+ type Object<K extends string = string, V = unknown> = Record<K, V>;
83
+ type Fork = Array | Object;
84
+ type Leaf = primitive;
85
+ type Node = Fork | Leaf;
86
+ }
87
+ type Serializable = primitive | Readonly<{
88
+ [key: string]: Serializable;
89
+ }> | ReadonlyArray<Serializable>;
90
+ type Object<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
91
+ type Array<Element extends Serializable = Serializable> = ReadonlyArray<Element>;
92
+ }
93
+ declare const JSON_TYPE_NAMES: readonly ["array", "boolean", "null", "number", "object", "string"];
94
+ type JsonTypeName = (typeof JSON_TYPE_NAMES)[number];
95
+ interface JsonTypes extends Record<JsonTypeName, Json.Serializable> {
96
+ array: Json.Array;
97
+ boolean: boolean;
98
+ null: null;
99
+ number: number;
100
+ object: Json.Object;
101
+ string: string;
102
+ }
103
+
79
104
  type Dict<T> = Record<string, T>;
80
105
  type WrapperComponent<T extends Dict<unknown> = Dict<unknown>> = FC<T & {
81
106
  children: ReactNode;
@@ -1,13 +1,11 @@
1
+ import { persistSync } from '../../dist/chunk-4LWKCEW3.js';
2
+ import { jsonRefinery, attachIntrospectionStates, primitiveRefinery, prettyJson, discoverType } from '../../dist/chunk-ECOMOMUN.js';
3
+ import { StoreContext, useI, useO } from '../../dist/chunk-5F2V7S3B.js';
4
+ import { IMPLICIT, createStandaloneAtom, createAtomFamily, isJson, findInStore, become, fromEntries, toEntries, undo, redo, JSON_DEFAULTS, getState, stringifyJson } from '../../dist/chunk-GY2XQYZY.js';
1
5
  import '../../dist/chunk-XWL6SNVU.js';
2
- import { StoreContext, useI, useO } from 'atom.io/react';
3
6
  import { motion, spring, LayoutGroup } from 'motion/react';
4
7
  import { forwardRef, useRef, useState, useImperativeHandle, useLayoutEffect, createContext, useId, Component, useContext, Fragment as Fragment$1 } from 'react';
5
- import { undo, redo, getState } from 'atom.io';
6
- import { IMPLICIT, createStandaloneAtom, createAtomFamily, findInStore, become } from 'atom.io/internal';
7
- import { jsonRefinery, attachIntrospectionStates, primitiveRefinery, prettyJson, discoverType } from 'atom.io/introspection';
8
8
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
9
- import { isJson, fromEntries, toEntries, JSON_DEFAULTS, stringifyJson } from 'atom.io/json';
10
- import { persistSync } from 'atom.io/web';
11
9
 
12
10
  var OpenClose = ({ isOpen, setIsOpen, disabled, testid }) => {
13
11
  return /* @__PURE__ */ jsx(
@@ -353,6 +351,8 @@ var JsonEditor_INTERNAL = ({
353
351
  }
354
352
  ) });
355
353
  };
354
+
355
+ // react-devtools/src/json-editor/editors-by-type/utilities/array-elements.ts
356
356
  var makeElementSetters = (data, set) => data.map((value, index) => (newValue) => {
357
357
  set(() => {
358
358
  const newData = [...data];
@@ -8,20 +8,22 @@ main[data-css="atom_io_devtools"] {
8
8
  --bg-color: #ddd;
9
9
  --bg-tint1: #e3e3e3;
10
10
  }
11
- box-sizing: border-box;
12
- color: var(--fg-color);
13
- background-color: var(--bg-color);
14
- border: 2px solid var(--fg-color);
15
- position: fixed;
16
- right: 0;
17
- bottom: 0;
18
- height: 100%;
19
- display: flex;
20
- flex-flow: column;
21
- max-height: 800px;
22
- width: 100%;
23
- max-width: 500px;
24
- overflow-y: scroll;
11
+ & {
12
+ box-sizing: border-box;
13
+ color: var(--fg-color);
14
+ background-color: var(--bg-color);
15
+ border: 2px solid var(--fg-color);
16
+ position: fixed;
17
+ right: 0;
18
+ bottom: 0;
19
+ height: 100%;
20
+ display: flex;
21
+ flex-flow: column;
22
+ max-height: 800px;
23
+ width: 100%;
24
+ max-width: 500px;
25
+ overflow-y: scroll;
26
+ }
25
27
  * {
26
28
  font-size: 16px;
27
29
  font-family: theia, monospace;
@@ -1,9 +1,203 @@
1
- import * as atom_io from 'atom.io';
2
- import { AtomFamilyToken, ReadableFamilyToken, ReadableToken, TokenType, AtomToken, TransactionToken, MutableAtomToken } from 'atom.io';
3
- import { Canonical } from 'atom.io/json';
4
- import { UserKey } from 'atom.io/realtime-server';
5
- import * as atom_io_data from 'atom.io/data';
6
- import { SetRTX, SetRTXJson } from 'atom.io/transceivers/set-rtx';
1
+ type primitive = boolean | number | string | null;
2
+ declare namespace Json {
3
+ namespace Tree {
4
+ type Array<Element = unknown> = ReadonlyArray<Element>;
5
+ type Object<K extends string = string, V = unknown> = Record<K, V>;
6
+ type Fork = Array | Object;
7
+ type Leaf = primitive;
8
+ type Node = Fork | Leaf;
9
+ }
10
+ type Serializable = primitive | Readonly<{
11
+ [key: string]: Serializable;
12
+ }> | ReadonlyArray<Serializable>;
13
+ type Object<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
14
+ type Array<Element extends Serializable = Serializable> = ReadonlyArray<Element>;
15
+ }
16
+ type stringified<J extends Json.Serializable> = J extends string ? `"${J}"` : J extends number ? `${J}` : J extends true ? `true` : J extends false ? `false` : J extends boolean ? `false` | `true` : J extends null ? `null` : string & {
17
+ __json?: J;
18
+ };
19
+ type Canonical = primitive | ReadonlyArray<Canonical>;
20
+
21
+ type Func = (...parameters: any[]) => any;
22
+
23
+ declare class Subject<T> {
24
+ Subscriber: (value: T) => void;
25
+ subscribers: Map<string, this[`Subscriber`]>;
26
+ subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
27
+ private unsubscribe;
28
+ next(value: T): void;
29
+ }
30
+
31
+ type SetUpdate = `add:${string}` | `clear:${string}` | `del:${string}` | `tx:${string}`;
32
+ type NumberedSetUpdate = `${number}=${SetUpdate}`;
33
+ interface SetRTXJson<P extends primitive> extends Json.Object {
34
+ members: P[];
35
+ cache: (NumberedSetUpdate | null)[];
36
+ cacheLimit: number;
37
+ cacheIdx: number;
38
+ cacheUpdateNumber: number;
39
+ }
40
+ declare class SetRTX<P extends primitive> extends Set<P> implements Transceiver<NumberedSetUpdate>, Lineage {
41
+ mode: TransceiverMode;
42
+ readonly subject: Subject<SetUpdate>;
43
+ cacheLimit: number;
44
+ cache: (NumberedSetUpdate | null)[];
45
+ cacheIdx: number;
46
+ cacheUpdateNumber: number;
47
+ constructor(values?: Iterable<P>, cacheLimit?: number);
48
+ toJSON(): SetRTXJson<P>;
49
+ static fromJSON<P extends primitive>(json: SetRTXJson<P>): SetRTX<P>;
50
+ add(value: P): this;
51
+ clear(): void;
52
+ delete(value: P): boolean;
53
+ readonly parent: SetRTX<P> | null;
54
+ child: SetRTX<P> | null;
55
+ transactionUpdates: SetUpdate[] | null;
56
+ transaction(run: (child: SetRTX<P>) => boolean): void;
57
+ protected _subscribe(key: string, fn: (update: SetUpdate) => void): () => void;
58
+ subscribe(key: string, fn: (update: NumberedSetUpdate) => void): () => void;
59
+ emit(update: SetUpdate): void;
60
+ private doStep;
61
+ getUpdateNumber(update: NumberedSetUpdate): number;
62
+ do(update: NumberedSetUpdate): number | `OUT_OF_RANGE` | null;
63
+ undoStep(update: SetUpdate): void;
64
+ undo(update: NumberedSetUpdate): number | null;
65
+ }
66
+
67
+ interface Lineage {
68
+ parent: typeof this | null;
69
+ child: typeof this | null;
70
+ }
71
+
72
+ interface Transceiver<S extends Json.Serializable> {
73
+ do: (update: S) => number | `OUT_OF_RANGE` | null;
74
+ undo: (update: S) => void;
75
+ subscribe: (key: string, fn: (update: S) => void) => () => void;
76
+ cacheUpdateNumber: number;
77
+ getUpdateNumber: (update: S) => number;
78
+ }
79
+ type TransceiverMode = `playback` | `record` | `transaction`;
80
+
81
+ type RegularAtomFamilyToken<T, K extends Canonical> = {
82
+ key: string;
83
+ type: `atom_family`;
84
+ __T?: T;
85
+ __K?: K;
86
+ };
87
+ type MutableAtomFamilyToken<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical> = {
88
+ key: string;
89
+ type: `mutable_atom_family`;
90
+ __T?: T;
91
+ __J?: J;
92
+ __K?: K;
93
+ };
94
+ type AtomFamilyToken<T, K extends Canonical = Canonical> = MutableAtomFamilyToken<T extends Transceiver<any> ? T : never, any, K> | RegularAtomFamilyToken<T, K>;
95
+
96
+ type TransactionToken<F extends Func> = {
97
+ key: string;
98
+ type: `transaction`;
99
+ __F?: F;
100
+ };
101
+
102
+ type WritableSelectorFamilyToken<T, K extends Canonical> = {
103
+ key: string;
104
+ type: `selector_family`;
105
+ __T?: T;
106
+ __K?: K;
107
+ };
108
+ type ReadonlySelectorFamilyToken<T, K extends Canonical> = {
109
+ key: string;
110
+ type: `readonly_selector_family`;
111
+ __T?: T;
112
+ __K?: K;
113
+ };
114
+ type SelectorFamilyToken<T, K extends Canonical> = ReadonlySelectorFamilyToken<T, K> | WritableSelectorFamilyToken<T, K>;
115
+
116
+ type JoinToken<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null = null> = {
117
+ key: string;
118
+ type: `join`;
119
+ cardinality: Cardinality;
120
+ a: ASide;
121
+ b: BSide;
122
+ __aType?: AType;
123
+ __bType?: BType;
124
+ __content?: Content;
125
+ };
126
+
127
+ type TokenType<Comparison extends ReadableFamilyToken<any, any> | ReadableToken<any>> = Comparison extends ReadableToken<infer RepresentedValue> ? RepresentedValue : Comparison extends ReadableFamilyToken<infer RepresentedValue, any> ? RepresentedValue : never;
128
+
129
+ /** @public */
130
+ type RegularAtomToken<T, K extends Canonical = any> = {
131
+ /** The unique identifier of the atom. */
132
+ key: string;
133
+ /** Discriminator. */
134
+ type: `atom`;
135
+ /** Present if the atom belongs to a family. */
136
+ family?: FamilyMetadata<K>;
137
+ /** Never present. This is a marker that preserves the type of the atom's value. */
138
+ __T?: T;
139
+ };
140
+ /** @public */
141
+ type MutableAtomToken<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical = any> = {
142
+ /** The unique identifier of the atom. */
143
+ key: string;
144
+ /** Discriminator. */
145
+ type: `mutable_atom`;
146
+ /** Present if the atom belongs to a family. */
147
+ family?: FamilyMetadata<K>;
148
+ /** Never present. This is a marker that preserves the JSON form of the atom's transceiver value. */
149
+ __J?: J;
150
+ /** Never present. This is a marker that preserves the type of the atom's transceiver value. */
151
+ __U?: T extends Transceiver<infer Update> ? Update : never;
152
+ };
153
+ /** @public */
154
+ type AtomToken<T, K extends Canonical = any> = MutableAtomToken<T extends Transceiver<any> ? T : never, any, K> | RegularAtomToken<T, K>;
155
+ /** @public */
156
+ type WritableSelectorToken<T, K extends Canonical = any> = {
157
+ /** The unique identifier of the selector. */
158
+ key: string;
159
+ /** Discriminator. */
160
+ type: `selector`;
161
+ /** Present if the selector belongs to a family. */
162
+ family?: FamilyMetadata<K>;
163
+ /** Never present. This is a marker that preserves the type of the selector's value. */
164
+ __T?: T;
165
+ };
166
+ /** @public */
167
+ type ReadonlySelectorToken<T, K extends Canonical = any> = {
168
+ /** The unique identifier of the selector. */
169
+ key: string;
170
+ /** Discriminator. */
171
+ type: `readonly_selector`;
172
+ /** Present if the selector belongs to a family. */
173
+ family?: FamilyMetadata<K>;
174
+ /** Never present. This is a marker that preserves the type of the selector's value. */
175
+ __T?: T;
176
+ };
177
+ /** @public */
178
+ type SelectorToken<T, K extends Canonical = any> = ReadonlySelectorToken<T, K> | WritableSelectorToken<T, K>;
179
+ /**
180
+ * @public
181
+ * These states cannot be set.
182
+ */
183
+ type ReadableToken<T, K extends Canonical = any> = AtomToken<T, K> | SelectorToken<T, K>;
184
+ /**
185
+ * @public
186
+ * States belonging to this family cannot be set.
187
+ */
188
+ type ReadableFamilyToken<T, K extends Canonical> = AtomFamilyToken<T, K> | SelectorFamilyToken<T, K>;
189
+ /**
190
+ * @public
191
+ * Identifies a state's connection to its family.
192
+ */
193
+ type FamilyMetadata<K extends Canonical = any> = {
194
+ /** The family's unique key. */
195
+ key: string;
196
+ /** The family member's unique identifier, in the form of a string. */
197
+ subKey: stringified<K>;
198
+ };
199
+
200
+ type UserKey = `user::${string}`;
7
201
 
8
202
  declare class InvariantMap<K, V> extends Map<K, V> {
9
203
  set(key: K, value: V): this;
@@ -46,7 +240,7 @@ type UserInRoomMeta = {
46
240
  enteredAtEpoch: number;
47
241
  };
48
242
  declare const DEFAULT_USER_IN_ROOM_META: UserInRoomMeta;
49
- declare const usersInRooms: atom_io_data.JoinToken<"room", string, "user", string, "1:n", UserInRoomMeta>;
50
- declare const usersInMyRoomView: atom_io.ReadonlySelectorFamilyToken<MutableAtomToken<SetRTX<string>, SetRTXJson<string>>[], string>;
243
+ declare const usersInRooms: JoinToken<"room", string, "user", string, "1:n", UserInRoomMeta>;
244
+ declare const usersInMyRoomView: ReadonlySelectorFamilyToken<MutableAtomToken<SetRTX<string>, SetRTXJson<string>>[], string>;
51
245
 
52
246
  export { type ContinuityOptions, type ContinuityToken, DEFAULT_USER_IN_ROOM_META, InvariantMap, type PerspectiveToken, SyncGroup, type UserInRoomMeta, continuity, roomIndex, usersInMyRoomView, usersInRooms, usersInThisRoomIndex };
@@ -1,108 +1,3 @@
1
+ export { DEFAULT_USER_IN_ROOM_META, InvariantMap, SyncGroup, continuity, roomIndex, usersInMyRoomView, usersInRooms, usersInThisRoomIndex } from '../../dist/chunk-NF7FJKJD.js';
2
+ import '../../dist/chunk-GY2XQYZY.js';
1
3
  import '../../dist/chunk-XWL6SNVU.js';
2
- import { assignTransactionToContinuity, IMPLICIT, setEpochNumberOfContinuity } from 'atom.io/internal';
3
- import { atom, selectorFamily } from 'atom.io';
4
- import { join, getInternalRelations } from 'atom.io/data';
5
- import { SetRTX } from 'atom.io/transceivers/set-rtx';
6
-
7
- var InvariantMap = class extends Map {
8
- set(key, value) {
9
- if (this.has(key)) {
10
- console.warn(`Tried to set a key that already exists in an InvariantMap`, {
11
- key,
12
- value
13
- });
14
- return this;
15
- }
16
- return super.set(key, value);
17
- }
18
- clear() {
19
- throw new Error(`Cannot clear an InvariantMap`);
20
- }
21
- };
22
- var SyncGroup = class _SyncGroup {
23
- constructor(key) {
24
- this.key = key;
25
- }
26
- type = `continuity`;
27
- globals = [];
28
- actions = [];
29
- perspectives = [];
30
- static existing = new InvariantMap();
31
- static create(key, builder) {
32
- const group = new _SyncGroup(key);
33
- const { type, globals, actions, perspectives } = builder(group);
34
- const token = { type, key, globals, actions, perspectives };
35
- _SyncGroup.existing.set(key, token);
36
- return token;
37
- }
38
- add(...args) {
39
- const zeroth = args[0];
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
- });
56
- }
57
- break;
58
- }
59
- return this;
60
- }
61
- };
62
- function continuity(options) {
63
- const { key, config } = options;
64
- const token = SyncGroup.create(key, config);
65
- const { actions } = token;
66
- for (const action of actions) {
67
- assignTransactionToContinuity(key, action.key, IMPLICIT.STORE);
68
- }
69
- setEpochNumberOfContinuity(key, -1, IMPLICIT.STORE);
70
- return token;
71
- }
72
- var usersInThisRoomIndex = atom({
73
- key: `usersInRoomIndex`,
74
- mutable: true,
75
- default: () => new SetRTX(),
76
- toJson: (set) => set.toJSON(),
77
- fromJson: (json) => SetRTX.fromJSON(json)
78
- });
79
- var roomIndex = atom({
80
- key: `roomIndex`,
81
- default: () => new SetRTX(),
82
- mutable: true,
83
- toJson: (set) => set.toJSON(),
84
- fromJson: (json) => SetRTX.fromJSON(json)
85
- });
86
- var DEFAULT_USER_IN_ROOM_META = {
87
- enteredAtEpoch: 0
88
- };
89
- var usersInRooms = join(
90
- {
91
- key: `usersInRooms`,
92
- between: [`room`, `user`],
93
- cardinality: `1:n`,
94
- isAType: (input) => typeof input === `string`,
95
- isBType: (input) => typeof input === `string`
96
- },
97
- DEFAULT_USER_IN_ROOM_META
98
- );
99
- var usersInMyRoomView = selectorFamily({
100
- key: `usersInMyRoomView`,
101
- get: (myUsername) => ({ find }) => {
102
- const usersInRoomsAtoms = getInternalRelations(usersInRooms);
103
- const myRoomIndex = find(usersInRoomsAtoms, myUsername);
104
- return [myRoomIndex];
105
- }
106
- });
107
-
108
- export { DEFAULT_USER_IN_ROOM_META, InvariantMap, SyncGroup, continuity, roomIndex, usersInMyRoomView, usersInRooms, usersInThisRoomIndex };
@@ -122,9 +122,9 @@ export function continuity(options: ContinuityOptions): ContinuityToken {
122
122
  const token = SyncGroup.create(key, config)
123
123
  const { actions } = token
124
124
  for (const action of actions) {
125
- assignTransactionToContinuity(key, action.key, IMPLICIT.STORE)
125
+ assignTransactionToContinuity(IMPLICIT.STORE, key, action.key)
126
126
  }
127
- setEpochNumberOfContinuity(key, -1, IMPLICIT.STORE)
127
+ setEpochNumberOfContinuity(IMPLICIT.STORE, key, -1)
128
128
  return token
129
129
  }
130
130
 
@@ -1,6 +1,5 @@
1
1
  import type { MutableAtomToken } from "atom.io"
2
- import { atom, selectorFamily } from "atom.io"
3
- import { getInternalRelations, join } from "atom.io/data"
2
+ import { atom, getInternalRelations, join, selectorFamily } from "atom.io"
4
3
  import type { SetRTXJson } from "atom.io/transceivers/set-rtx"
5
4
  import { SetRTX } from "atom.io/transceivers/set-rtx"
6
5