atom.io 0.14.4 → 0.14.6

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 (91) hide show
  1. package/data/dist/index.cjs +47 -1416
  2. package/data/dist/index.cjs.map +1 -1
  3. package/data/dist/index.d.cts +16 -317
  4. package/data/dist/index.d.ts +16 -317
  5. package/data/dist/index.js +4 -6
  6. package/data/dist/index.js.map +1 -1
  7. package/dist/chunk-NYTGCPHB.js +261 -0
  8. package/dist/chunk-NYTGCPHB.js.map +1 -0
  9. package/dist/chunk-PZLG2HP3.js +36 -0
  10. package/dist/chunk-PZLG2HP3.js.map +1 -0
  11. package/dist/chunk-XACXFU3B.js +46 -0
  12. package/dist/chunk-XACXFU3B.js.map +1 -0
  13. package/dist/index.cjs +55 -2330
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +21 -269
  16. package/dist/index.d.ts +21 -269
  17. package/dist/index.js +152 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/metafile-cjs.json +1 -1
  20. package/dist/metafile-esm.json +1 -1
  21. package/internal/dist/index.cjs +30 -159
  22. package/internal/dist/index.cjs.map +1 -1
  23. package/internal/dist/index.d.cts +28 -229
  24. package/internal/dist/index.d.ts +28 -229
  25. package/internal/dist/index.js +2027 -1
  26. package/internal/dist/index.js.map +1 -1
  27. package/introspection/dist/index.cjs +45 -1565
  28. package/introspection/dist/index.cjs.map +1 -1
  29. package/introspection/dist/index.d.cts +4 -376
  30. package/introspection/dist/index.d.ts +4 -376
  31. package/introspection/dist/index.js +298 -2
  32. package/introspection/dist/index.js.map +1 -1
  33. package/json/dist/index.cjs +5 -1502
  34. package/json/dist/index.cjs.map +1 -1
  35. package/json/dist/index.d.cts +7 -373
  36. package/json/dist/index.d.ts +7 -373
  37. package/json/dist/index.js +37 -1
  38. package/json/dist/index.js.map +1 -1
  39. package/package.json +1 -1
  40. package/react/dist/index.cjs +14 -1549
  41. package/react/dist/index.cjs.map +1 -1
  42. package/react/dist/index.d.cts +4 -377
  43. package/react/dist/index.d.ts +4 -377
  44. package/react/dist/index.js +62 -2
  45. package/react/dist/index.js.map +1 -1
  46. package/react-devtools/dist/index.cjs +135 -2153
  47. package/react-devtools/dist/index.cjs.map +1 -1
  48. package/react-devtools/dist/index.d.cts +24 -149
  49. package/react-devtools/dist/index.d.ts +24 -149
  50. package/react-devtools/dist/index.js +5 -3
  51. package/react-devtools/dist/index.js.map +1 -1
  52. package/realtime-client/dist/index.cjs +34 -1529
  53. package/realtime-client/dist/index.cjs.map +1 -1
  54. package/realtime-client/dist/index.d.cts +12 -384
  55. package/realtime-client/dist/index.d.ts +12 -384
  56. package/realtime-client/dist/index.js +165 -2
  57. package/realtime-client/dist/index.js.map +1 -1
  58. package/realtime-react/dist/index.cjs +35 -1727
  59. package/realtime-react/dist/index.cjs.map +1 -1
  60. package/realtime-react/dist/index.d.cts +9 -49
  61. package/realtime-react/dist/index.d.ts +9 -49
  62. package/realtime-react/dist/index.js +66 -4
  63. package/realtime-react/dist/index.js.map +1 -1
  64. package/realtime-server/dist/index.cjs +57 -1548
  65. package/realtime-server/dist/index.cjs.map +1 -1
  66. package/realtime-server/dist/index.d.cts +11 -394
  67. package/realtime-server/dist/index.d.ts +11 -394
  68. package/realtime-server/dist/index.js +21 -27
  69. package/realtime-server/dist/index.js.map +1 -1
  70. package/realtime-testing/dist/index.cjs +15 -2376
  71. package/realtime-testing/dist/index.cjs.map +1 -1
  72. package/realtime-testing/dist/index.d.cts +3 -489
  73. package/realtime-testing/dist/index.d.ts +3 -489
  74. package/realtime-testing/dist/index.js +10 -9
  75. package/realtime-testing/dist/index.js.map +1 -1
  76. package/transceivers/set-rtx/dist/index.cjs +9 -31
  77. package/transceivers/set-rtx/dist/index.cjs.map +1 -1
  78. package/transceivers/set-rtx/dist/index.d.cts +3 -29
  79. package/transceivers/set-rtx/dist/index.d.ts +3 -29
  80. package/transceivers/set-rtx/dist/index.js +3 -2
  81. package/transceivers/set-rtx/dist/index.js.map +1 -1
  82. package/dist/chunk-GMN5KH6A.js +0 -309
  83. package/dist/chunk-GMN5KH6A.js.map +0 -1
  84. package/dist/chunk-HQWWV67P.js +0 -62
  85. package/dist/chunk-HQWWV67P.js.map +0 -1
  86. package/dist/chunk-MK4OJD24.js +0 -67
  87. package/dist/chunk-MK4OJD24.js.map +0 -1
  88. package/dist/chunk-N7ADBQJG.js +0 -176
  89. package/dist/chunk-N7ADBQJG.js.map +0 -1
  90. package/dist/chunk-PURABO5G.js +0 -2581
  91. package/dist/chunk-PURABO5G.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,254 +1,6 @@
1
- declare class Subject<T> {
2
- Subscriber: (value: T) => void;
3
- subscribers: Map<string, this[`Subscriber`]>;
4
- subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
5
- private unsubscribe;
6
- next(value: T): void;
7
- }
8
- declare class StatefulSubject<T> extends Subject<T> {
9
- state: T;
10
- constructor(initialState: T);
11
- next(value: T): void;
12
- }
13
-
14
- type Selector<T> = {
15
- key: string;
16
- type: `selector`;
17
- family?: FamilyMetadata;
18
- install: (store: Store) => void;
19
- subject: Subject<{
20
- newValue: T;
21
- oldValue: T;
22
- }>;
23
- get: () => T;
24
- set: (newValue: T | ((oldValue: T) => T)) => void;
25
- };
26
- type ReadonlySelector<T> = {
27
- key: string;
28
- type: `readonly_selector`;
29
- family?: FamilyMetadata;
30
- install: (store: Store) => void;
31
- subject: Subject<{
32
- newValue: T;
33
- oldValue: T;
34
- }>;
35
- get: () => T;
36
- };
37
-
38
- type Transaction<ƒ extends ƒn> = {
39
- key: string;
40
- type: `transaction`;
41
- install: (store: Store) => void;
42
- subject: Subject<TransactionUpdate<ƒ>>;
43
- run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
44
- };
45
-
46
- type TransactionMeta<ƒ extends ƒn> = {
47
- phase: `applying` | `building`;
48
- time: number;
49
- update: TransactionUpdate<ƒ>;
50
- };
51
-
52
- type primitive = boolean | number | string | null;
53
-
54
- type Serializable = primitive | Readonly<{
55
- [key: string]: Serializable;
56
- }> | ReadonlyArray<Serializable>;
57
- type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
58
-
59
- type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
60
- type Cardinality = `1:1` | `1:n` | `n:n`;
61
-
62
- interface JunctionEntries<Content extends Object$1 | null> extends Object$1 {
63
- readonly relations: [string, string[]][];
64
- readonly contents: [string, Content][];
65
- }
66
- interface JunctionSchema<ASide extends string, BSide extends string> extends Object$1 {
67
- readonly between: [a: ASide, b: BSide];
68
- readonly cardinality: Cardinality;
69
- }
70
- type BaseExternalStoreConfiguration = {
71
- addRelation: (a: string, b: string) => void;
72
- deleteRelation: (a: string, b: string) => void;
73
- replaceRelationsSafely: (a: string, bs: string[]) => void;
74
- replaceRelationsUnsafely: (a: string, bs: string[]) => void;
75
- getRelatedKeys: (key: string) => Set<string> | undefined;
76
- has: (a: string, b?: string) => boolean;
77
- };
78
- type ExternalStoreWithContentConfiguration<Content extends Object$1> = {
79
- getContent: (contentKey: string) => Content | undefined;
80
- setContent: (contentKey: string, content: Content) => void;
81
- deleteContent: (contentKey: string) => void;
82
- };
83
- type Empty<Obj extends object> = {
84
- [Key in keyof Obj]?: undefined;
85
- };
86
- type ExternalStoreConfiguration<Content extends Object$1 | null> = Content extends Object$1 ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Object$1>>;
87
- type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
88
- externalStore?: ExternalStoreConfiguration<Content>;
89
- isContent?: Refinement<unknown, Content>;
90
- makeContentKey?: (a: string, b: string) => string;
91
- };
92
- type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
93
- declare class Junction<const ASide extends string, const BSide extends string, const Content extends Object$1 | null = null> {
94
- readonly a: ASide;
95
- readonly b: BSide;
96
- readonly cardinality: Cardinality;
97
- readonly relations: Map<string, Set<string>>;
98
- readonly contents: Map<string, Content>;
99
- isContent: Refinement<unknown, Content> | null;
100
- makeContentKey: (a: string, b: string) => string;
101
- getRelatedKeys(key: string): Set<string> | undefined;
102
- protected addRelation(a: string, b: string): void;
103
- protected deleteRelation(a: string, b: string): void;
104
- protected replaceRelationsUnsafely(a: string, bs: string[]): void;
105
- protected replaceRelationsSafely(a: string, bs: string[]): void;
106
- protected getContentInternal(contentKey: string): Content | undefined;
107
- protected setContent(contentKey: string, content: Content): void;
108
- protected deleteContent(contentKey: string): void;
109
- constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
110
- toJSON(): JunctionJSON<ASide, BSide, Content>;
111
- set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
112
- set(relation: {
113
- [Key in ASide | BSide]: string;
114
- }, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
115
- delete(a: string, b?: string): this;
116
- delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
117
- getRelatedKey(key: string): string | undefined;
118
- replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
119
- reckless: boolean;
120
- }): this;
121
- getContent(a: string, b: string): Content | undefined;
122
- getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
123
- has(a: string, b?: string): boolean;
124
- }
125
-
126
- interface Lineage {
127
- parent: typeof this | null;
128
- child: typeof this | null;
129
- }
130
-
131
- type JsonInterface<T, J extends Serializable = Serializable> = {
132
- toJson: (t: T) => J;
133
- fromJson: (json: J) => T;
134
- };
135
-
136
- interface Transceiver<Signal extends Serializable> {
137
- do: (update: Signal) => void;
138
- undo: (update: Signal) => void;
139
- subscribe: (key: string, fn: (update: Signal) => void) => () => void;
140
- cacheUpdateNumber: number;
141
- getUpdateNumber: (update: Signal) => number;
142
- }
143
-
144
- /**
145
- * @internal Give the tracker a transceiver state and a store, and it will
146
- * subscribe to the transceiver's inner value. When the inner value changes,
147
- * the tracker will update its own state to reflect the change.
148
- */
149
- declare class Tracker<Mutable extends Transceiver<any>> {
150
- private Update;
151
- private initializeState;
152
- private unsubscribeFromInnerValue;
153
- private observeCore;
154
- private updateCore;
155
- mutableState: MutableAtomToken<Mutable, Serializable>;
156
- latestUpdateState: AtomToken<typeof this.Update | null>;
157
- constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
158
- }
159
-
160
- interface MutableAtom<T> extends Atom<T> {
161
- mutable: true;
162
- }
163
-
164
- type OperationProgress = {
165
- open: false;
166
- } | {
167
- open: true;
168
- done: Set<string>;
169
- prev: Map<string, any>;
170
- time: number;
171
- token: StateToken<any>;
172
- };
173
-
174
- type TimelineAtomUpdate = StateUpdate<unknown> & {
175
- key: string;
176
- type: `atom_update`;
177
- timestamp: number;
178
- family?: FamilyMetadata;
179
- };
180
- type TimelineSelectorUpdate = {
181
- key: string;
182
- type: `selector_update`;
183
- timestamp: number;
184
- atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
185
- };
186
- type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
187
- key: string;
188
- type: `transaction_update`;
189
- timestamp: number;
190
- };
191
- type Timeline = {
192
- type: `timeline`;
193
- key: string;
194
- at: number;
195
- shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
196
- timeTraveling: `into_future` | `into_past` | null;
197
- history: TimelineUpdate[];
198
- selectorTime: number | null;
199
- transactionKey: string | null;
200
- install: (store: Store) => void;
201
- subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
202
- };
203
-
204
- declare class Store implements Lineage {
205
- parent: Store | null;
206
- child: Store | null;
207
- valueMap: Map<string, any>;
208
- atoms: Map<string, Atom<any> | MutableAtom<any>>;
209
- selectors: Map<string, Selector<any>>;
210
- readonlySelectors: Map<string, ReadonlySelector<any>>;
211
- trackers: Map<string, Tracker<Transceiver<any>>>;
212
- families: Map<string, AtomFamily<any, any> | ReadonlySelectorFamily<any, any> | SelectorFamily<any, any>>;
213
- timelines: Map<string, Timeline>;
214
- transactions: Map<string, Transaction<ƒn>>;
215
- atomsThatAreDefault: Set<string>;
216
- timelineAtoms: Junction<"timelineKey", "atomKey", null>;
217
- selectorAtoms: Junction<"selectorKey", "atomKey", null>;
218
- selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
219
- source: string;
220
- }>;
221
- subject: {
222
- atomCreation: Subject<AtomToken<unknown>>;
223
- selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
224
- transactionCreation: Subject<TransactionToken<ƒn>>;
225
- timelineCreation: Subject<TimelineToken>;
226
- transactionApplying: StatefulSubject<TransactionMeta<ƒn> | null>;
227
- operationStatus: Subject<OperationProgress>;
228
- };
229
- operation: OperationProgress;
230
- transactionMeta: TransactionMeta<ƒn> | null;
231
- config: {
232
- name: string;
233
- };
234
- loggers: AtomIOLogger[];
235
- logger: Logger;
236
- constructor(name: string, store?: Store | null);
237
- }
238
-
239
- type Atom<T> = {
240
- key: string;
241
- type: `atom`;
242
- mutable?: boolean;
243
- family?: FamilyMetadata;
244
- install: (store: Store) => void;
245
- subject: Subject<{
246
- newValue: T;
247
- oldValue: T;
248
- }>;
249
- default: T | (() => T);
250
- cleanup?: () => void;
251
- };
1
+ import * as Internal from 'atom.io/internal';
2
+ import { Transceiver, Subject, Store, Timeline, TimelineAtomUpdate, TimelineSelectorUpdate, TimelineTransactionUpdate } from 'atom.io/internal';
3
+ import { Json, JsonInterface } from 'atom.io/json';
252
4
 
253
5
  type Effectors<T> = {
254
6
  setSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void;
@@ -263,38 +15,38 @@ type AtomOptions<T> = {
263
15
  default: T | (() => T);
264
16
  effects?: AtomEffect<T>[];
265
17
  };
266
- type MutableAtomOptions<T extends Transceiver<any>, J extends Serializable> = JsonInterface<T, J> & Omit<AtomOptions<T>, `default`> & {
18
+ type MutableAtomOptions<T extends Transceiver<any>, J extends Json.Serializable> = JsonInterface<T, J> & Omit<AtomOptions<T>, `default`> & {
267
19
  default: () => T;
268
20
  mutable: true;
269
21
  };
270
- declare function atom<T extends Transceiver<any>, J extends Serializable>(options: MutableAtomOptions<T, J>): MutableAtomToken<T, J>;
22
+ declare function atom<T extends Transceiver<any>, J extends Json.Serializable>(options: MutableAtomOptions<T, J>): MutableAtomToken<T, J>;
271
23
  declare function atom<T>(options: AtomOptions<T>): AtomToken<T>;
272
- type AtomFamilyOptions<T, K extends Serializable> = {
24
+ type AtomFamilyOptions<T, K extends Json.Serializable> = {
273
25
  key: string;
274
26
  default: T | ((key: K) => T);
275
27
  effects?: (key: K) => AtomEffect<T>[];
276
28
  };
277
- type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
29
+ type AtomFamily<T, K extends Json.Serializable = Json.Serializable> = ((key: K) => AtomToken<T>) & {
278
30
  key: string;
279
31
  type: `atom_family`;
280
32
  subject: Subject<AtomToken<T>>;
281
33
  mutable?: boolean;
282
34
  };
283
- type MutableAtomFamilyOptions<T extends Transceiver<any>, J extends Serializable, K extends Serializable> = AtomFamilyOptions<T, K> & JsonInterface<T, J> & {
35
+ type MutableAtomFamilyOptions<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = AtomFamilyOptions<T, K> & JsonInterface<T, J> & {
284
36
  mutable: true;
285
37
  };
286
- type MutableAtomFamily<Core extends Transceiver<any>, SerializableCore extends Serializable, Key extends Serializable> = JsonInterface<Core, SerializableCore> & ((key: Key) => MutableAtomToken<Core, SerializableCore>) & {
38
+ type MutableAtomFamily<Core extends Transceiver<any>, SerializableCore extends Json.Serializable, Key extends Json.Serializable> = JsonInterface<Core, SerializableCore> & ((key: Key) => MutableAtomToken<Core, SerializableCore>) & {
287
39
  key: `${string}`;
288
40
  type: `atom_family`;
289
41
  subject: Subject<MutableAtomToken<Core, SerializableCore>>;
290
42
  mutable: true;
291
43
  };
292
- declare function atomFamily<T extends Transceiver<any>, J extends Serializable, K extends Serializable>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamily<T, J, K>;
293
- declare function atomFamily<T, K extends Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
44
+ declare function atomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamily<T, J, K>;
45
+ declare function atomFamily<T, K extends Json.Serializable>(options: AtomFamilyOptions<T, K>): AtomFamily<T, K>;
294
46
 
295
- declare function dispose(token: ReadonlySelectorToken<any> | StateToken<any>, store?: Store): void;
47
+ declare function dispose(token: ReadonlySelectorToken<any> | StateToken<any>, store?: Internal.Store): void;
296
48
 
297
- declare function getState<T>(token: ReadonlySelectorToken<T> | StateToken<T>, store?: Store): T;
49
+ declare function getState<T>(token: ReadonlySelectorToken<T> | StateToken<T>, store?: Internal.Store): T;
298
50
 
299
51
  declare const LoggerIconDictionary: {
300
52
  readonly "\u231B": "Timeline event fully captured";
@@ -393,29 +145,29 @@ type ReadonlySelectorOptions<T> = {
393
145
  };
394
146
  declare function selector<T>(options: SelectorOptions<T>): SelectorToken<T>;
395
147
  declare function selector<T>(options: ReadonlySelectorOptions<T>): ReadonlySelectorToken<T>;
396
- type SelectorFamilyOptions<T, K extends Serializable> = {
148
+ type SelectorFamilyOptions<T, K extends Json.Serializable> = {
397
149
  key: string;
398
150
  get: (key: K) => Read<() => T>;
399
151
  set: (key: K) => Write<(newValue: T) => void>;
400
152
  };
401
- type ReadonlySelectorFamilyOptions<T, K extends Serializable> = {
153
+ type ReadonlySelectorFamilyOptions<T, K extends Json.Serializable> = {
402
154
  key: string;
403
155
  get: (key: K) => Read<() => T>;
404
156
  };
405
- type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
157
+ type SelectorFamily<T, K extends Json.Serializable = Json.Serializable> = ((key: K) => SelectorToken<T>) & {
406
158
  key: string;
407
159
  type: `selector_family`;
408
160
  subject: Subject<SelectorToken<T>>;
409
161
  };
410
- type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
162
+ type ReadonlySelectorFamily<T, K extends Json.Serializable = Json.Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
411
163
  key: string;
412
164
  type: `readonly_selector_family`;
413
165
  subject: Subject<ReadonlySelectorToken<T>>;
414
166
  };
415
- declare function selectorFamily<T, K extends Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
416
- declare function selectorFamily<T, K extends Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
167
+ declare function selectorFamily<T, K extends Json.Serializable>(options: SelectorFamilyOptions<T, K>): SelectorFamily<T, K>;
168
+ declare function selectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamily<T, K>;
417
169
 
418
- declare function setState<T, New extends T>(token: StateToken<T>, value: New | ((oldValue: T) => New), store?: Store): void;
170
+ declare function setState<T, New extends T>(token: StateToken<T>, value: New | ((oldValue: T) => New), store?: Internal.Store): void;
419
171
 
420
172
  declare class Silo {
421
173
  store: Store;
@@ -468,7 +220,7 @@ type AtomToken<_> = {
468
220
  family?: FamilyMetadata;
469
221
  __brand?: _;
470
222
  };
471
- interface MutableAtomToken<T extends Transceiver<any>, J extends Serializable> extends AtomToken<T> {
223
+ interface MutableAtomToken<T extends Transceiver<any>, J extends Json.Serializable> extends AtomToken<T> {
472
224
  __asJSON?: J;
473
225
  __update?: T extends Transceiver<infer Update> ? Update : never;
474
226
  }