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
@@ -1,53 +1,11 @@
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
- };
1
+ import * as AtomIO from 'atom.io';
2
+ import { SelectorFamily } from 'atom.io';
3
+ import { Store } from 'atom.io/internal';
4
+ import { Json, Stringified } from 'atom.io/json';
45
5
 
46
- type TransactionMeta<ƒ extends ƒn> = {
47
- phase: `applying` | `building`;
48
- time: number;
49
- update: TransactionUpdate<ƒ>;
50
- };
6
+ declare function dict<State, Key extends Json.Serializable>(findState: AtomIO.AtomFamily<State, Key> | AtomIO.ReadonlySelectorFamily<State, Key> | AtomIO.SelectorFamily<State, Key>, index: AtomIO.AtomToken<Key[]> | AtomIO.ReadonlySelectorToken<Key[]> | AtomIO.SelectorToken<Key[]>, store?: Store): AtomIO.ReadonlySelectorToken<{
7
+ [K in Stringified<Key>]: State;
8
+ }>;
51
9
 
52
10
  type primitive = boolean | number | string | null;
53
11
 
@@ -123,277 +81,18 @@ declare class Junction<const ASide extends string, const BSide extends string, c
123
81
  has(a: string, b?: string): boolean;
124
82
  }
125
83
 
126
- interface Lineage {
127
- parent: typeof this | null;
128
- child: typeof this | null;
129
- }
130
-
131
- type Stringified<J extends Serializable> = string & {
132
- __json: J;
133
- };
134
-
135
- interface Transceiver<Signal extends Serializable> {
136
- do: (update: Signal) => void;
137
- undo: (update: Signal) => void;
138
- subscribe: (key: string, fn: (update: Signal) => void) => () => void;
139
- cacheUpdateNumber: number;
140
- getUpdateNumber: (update: Signal) => number;
141
- }
142
-
143
- /**
144
- * @internal Give the tracker a transceiver state and a store, and it will
145
- * subscribe to the transceiver's inner value. When the inner value changes,
146
- * the tracker will update its own state to reflect the change.
147
- */
148
- declare class Tracker<Mutable extends Transceiver<any>> {
149
- private Update;
150
- private initializeState;
151
- private unsubscribeFromInnerValue;
152
- private observeCore;
153
- private updateCore;
154
- mutableState: MutableAtomToken<Mutable, Serializable>;
155
- latestUpdateState: AtomToken<typeof this.Update | null>;
156
- constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
157
- }
158
-
159
- interface MutableAtom<T> extends Atom<T> {
160
- mutable: true;
161
- }
162
-
163
- type OperationProgress = {
164
- open: false;
165
- } | {
166
- open: true;
167
- done: Set<string>;
168
- prev: Map<string, any>;
169
- time: number;
170
- token: StateToken<any>;
171
- };
172
-
173
- type TimelineAtomUpdate = StateUpdate<unknown> & {
174
- key: string;
175
- type: `atom_update`;
176
- timestamp: number;
177
- family?: FamilyMetadata;
178
- };
179
- type TimelineSelectorUpdate = {
180
- key: string;
181
- type: `selector_update`;
182
- timestamp: number;
183
- atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
184
- };
185
- type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
186
- key: string;
187
- type: `transaction_update`;
188
- timestamp: number;
189
- };
190
- type Timeline = {
191
- type: `timeline`;
192
- key: string;
193
- at: number;
194
- shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
195
- timeTraveling: `into_future` | `into_past` | null;
196
- history: TimelineUpdate[];
197
- selectorTime: number | null;
198
- transactionKey: string | null;
199
- install: (store: Store) => void;
200
- subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
201
- };
202
-
203
- declare class Store implements Lineage {
204
- parent: Store | null;
205
- child: Store | null;
206
- valueMap: Map<string, any>;
207
- atoms: Map<string, Atom<any> | MutableAtom<any>>;
208
- selectors: Map<string, Selector<any>>;
209
- readonlySelectors: Map<string, ReadonlySelector<any>>;
210
- trackers: Map<string, Tracker<Transceiver<any>>>;
211
- families: Map<string, AtomFamily<any, any> | ReadonlySelectorFamily<any, any> | SelectorFamily<any, any>>;
212
- timelines: Map<string, Timeline>;
213
- transactions: Map<string, Transaction<ƒn>>;
214
- atomsThatAreDefault: Set<string>;
215
- timelineAtoms: Junction<"timelineKey", "atomKey", null>;
216
- selectorAtoms: Junction<"selectorKey", "atomKey", null>;
217
- selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
218
- source: string;
219
- }>;
220
- subject: {
221
- atomCreation: Subject<AtomToken<unknown>>;
222
- selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
223
- transactionCreation: Subject<TransactionToken<ƒn>>;
224
- timelineCreation: Subject<TimelineToken>;
225
- transactionApplying: StatefulSubject<TransactionMeta<ƒn> | null>;
226
- operationStatus: Subject<OperationProgress>;
227
- };
228
- operation: OperationProgress;
229
- transactionMeta: TransactionMeta<ƒn> | null;
230
- config: {
231
- name: string;
232
- };
233
- loggers: AtomIOLogger[];
234
- logger: Logger;
235
- constructor(name: string, store?: Store | null);
236
- }
237
-
238
- type Atom<T> = {
239
- key: string;
240
- type: `atom`;
241
- mutable?: boolean;
242
- family?: FamilyMetadata;
243
- install: (store: Store) => void;
244
- subject: Subject<{
245
- newValue: T;
246
- oldValue: T;
247
- }>;
248
- default: T | (() => T);
249
- cleanup?: () => void;
250
- };
251
-
252
- type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
253
- key: string;
254
- type: `atom_family`;
255
- subject: Subject<AtomToken<T>>;
256
- mutable?: boolean;
257
- };
258
-
259
- declare const LoggerIconDictionary: {
260
- readonly "\u231B": "Timeline event fully captured";
261
- readonly "\u23E9": "Timeline redo";
262
- readonly "\u23EA": "Timeline undo";
263
- readonly "\u23ED\uFE0F": "Transaction redo";
264
- readonly "\u23EE\uFE0F": "Transaction undo";
265
- readonly "\u23F3": "Timeline event partially captured";
266
- readonly "\u23F9\uFE0F": "Time-travel complete";
267
- readonly "\uD83D\uDC81": "Notice";
268
- readonly "\uD83D\uDD04": "Realtime transaction synchronized";
269
- readonly "\u2705": "Realtime transaction success";
270
- readonly "\u2728": "Computation complete";
271
- readonly "\u274C": "Conflict prevents attempted action";
272
- readonly "\u2B55": "Operation start";
273
- readonly "\uD83D\uDC1E": "Possible bug in AtomIO";
274
- readonly "\uD83D\uDC40": "Subscription added";
275
- readonly "\uD83D\uDC6A": "Family member added";
276
- readonly "\uD83D\uDCC1": "Stow update";
277
- readonly "\uD83D\uDCC3": "Copy mutable";
278
- readonly "\uD83D\uDCD6": "Read state";
279
- readonly "\uD83D\uDCDD": "Write state";
280
- readonly "\uD83D\uDCE2": "Notify subscribers";
281
- readonly "\uD83D\uDD0C": "Register dependency";
282
- readonly "\uD83D\uDD0D": "Discover root";
283
- readonly "\uD83D\uDD25": "Delete state";
284
- readonly "\uD83D\uDD27": "Create mutable atom";
285
- readonly "\uD83D\uDD28": "Create immutable atom";
286
- readonly "\uD83D\uDD34": "Operation complete";
287
- readonly "\uD83D\uDDD1": "Evict cached value";
288
- readonly "\uD83D\uDCA5": "Caught";
289
- readonly "\uD83D\uDE48": "Subscription canceled";
290
- readonly "\uD83D\uDEC4": "Apply transaction";
291
- readonly "\uD83D\uDEE0\uFE0F": "Install atom into store";
292
- readonly "\uD83D\uDEEB": "Begin transaction";
293
- readonly "\uD83D\uDEEC": "Complete transaction";
294
- readonly "\uD83E\uDDEE": "Computing selector";
295
- readonly "\uD83E\uDDF9": "Prepare to evict";
296
- readonly "\uD83E\uDE82": "Abort transaction";
297
- };
298
- type LoggerIcon = keyof typeof LoggerIconDictionary;
299
- declare const LOG_LEVELS: readonly ["info", "warn", "error"];
300
- type LogLevel = (typeof LOG_LEVELS)[number];
301
- type LogFn = (icon: LoggerIcon, tokenType: `atom` | `readonly_selector` | `selector` | `state` | `timeline` | `transaction` | `unknown`, tokenKey: string, message: string, ...rest: unknown[]) => void;
302
- type LogFilter = (...params: Parameters<LogFn>) => boolean;
303
- type Logger = Record<LogLevel, LogFn>;
304
- declare class AtomIOLogger implements Logger {
305
- logLevel: `error` | `info` | `warn` | null;
306
- private readonly filter?;
307
- private readonly logger;
308
- constructor(logLevel: `error` | `info` | `warn` | null, filter?: LogFilter | undefined, logger?: Logger);
309
- error: LogFn;
310
- info: LogFn;
311
- warn: LogFn;
312
- }
313
-
314
- type TransactionToken<_> = {
315
- key: string;
316
- type: `transaction`;
317
- __brand?: _;
318
- };
319
- type TransactionUpdate<ƒ extends ƒn> = {
320
- key: string;
321
- updates: (KeyedStateUpdate<unknown> | TransactionUpdate<ƒn>)[];
322
- params: Parameters<ƒ>;
323
- output: ReturnType<ƒ>;
324
- };
325
-
326
- type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
327
- key: string;
328
- type: `selector_family`;
329
- subject: Subject<SelectorToken<T>>;
330
- };
331
- type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
332
- key: string;
333
- type: `readonly_selector_family`;
334
- subject: Subject<ReadonlySelectorToken<T>>;
335
- };
336
-
337
- type StateUpdate<T> = {
338
- newValue: T;
339
- oldValue: T;
340
- };
341
- type KeyedStateUpdate<T> = StateUpdate<T> & {
342
- key: string;
343
- family?: FamilyMetadata;
344
- };
345
-
346
- type TimelineToken = {
347
- key: string;
348
- type: `timeline`;
349
- };
350
- type TimelineUpdate = TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate;
351
-
352
- type ƒn = (...parameters: any[]) => any;
353
- type AtomToken<_> = {
354
- key: string;
355
- type: `atom`;
356
- family?: FamilyMetadata;
357
- __brand?: _;
358
- };
359
- interface MutableAtomToken<T extends Transceiver<any>, J extends Serializable> extends AtomToken<T> {
360
- __asJSON?: J;
361
- __update?: T extends Transceiver<infer Update> ? Update : never;
362
- }
363
- type SelectorToken<_> = {
364
- key: string;
365
- type: `selector`;
366
- family?: FamilyMetadata;
367
- __brand?: _;
368
- };
369
- type StateToken<T> = AtomToken<T> | SelectorToken<T>;
370
- type ReadonlySelectorToken<_> = {
371
- key: string;
372
- type: `readonly_selector`;
373
- family?: FamilyMetadata;
374
- __brand?: _;
375
- };
376
- type FamilyMetadata = {
377
- key: string;
378
- subKey: string;
379
- };
380
-
381
- declare function dict<State, Key extends Serializable>(findState: AtomFamily<State, Key> | ReadonlySelectorFamily<State, Key> | SelectorFamily<State, Key>, index: AtomToken<Key[]> | ReadonlySelectorToken<Key[]> | SelectorToken<Key[]>, store?: Store): ReadonlySelectorToken<{
382
- [K in Stringified<Key>]: State;
383
- }>;
384
-
385
- interface JoinOptions<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Object$1 | null> extends Object$1, JunctionSchema<ASide, BSide>, Partial<JunctionEntries<Content>> {
84
+ interface JoinOptions<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Json.Object | null> extends Json.Object, JunctionSchema<ASide, BSide>, Partial<JunctionEntries<Content>> {
386
85
  readonly key: string;
387
86
  readonly cardinality: Cardinality;
388
87
  }
389
- type JoinState<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Object$1 | null> = Cardinality extends `1:1` ? (Content extends Object$1 ? {
88
+ type JoinState<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Json.Object | null> = Cardinality extends `1:1` ? (Content extends Json.Object ? {
390
89
  readonly [AB in ASide | BSide as AB extends ASide ? `${AB}EntryOf${Capitalize<BSide>}` : `${AB}EntryOf${Capitalize<ASide>}`]: SelectorFamily<[
391
90
  string,
392
91
  Content
393
92
  ] | undefined, string>;
394
93
  } : {}) & {
395
94
  readonly [AB in ASide | BSide as AB extends ASide ? `${AB}KeyOf${Capitalize<BSide>}` : `${AB}KeyOf${Capitalize<ASide>}`]: SelectorFamily<string | undefined, string>;
396
- } : Cardinality extends `1:n` ? (Content extends Object$1 ? {
95
+ } : Cardinality extends `1:n` ? (Content extends Json.Object ? {
397
96
  readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: SelectorFamily<[
398
97
  string,
399
98
  Content
@@ -407,7 +106,7 @@ type JoinState<ASide extends string, BSide extends string, Cardinality extends C
407
106
  readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: SelectorFamily<string | undefined, string>;
408
107
  } & {
409
108
  readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: SelectorFamily<string[], string>;
410
- } : Cardinality extends `n:n` ? (Content extends Object$1 ? {
109
+ } : Cardinality extends `n:n` ? (Content extends Json.Object ? {
411
110
  readonly [AB in ASide | BSide as AB extends ASide ? `${AB}EntriesOf${Capitalize<BSide>}` : `${AB}EntriesOf${Capitalize<ASide>}`]: SelectorFamily<[
412
111
  string,
413
112
  Content
@@ -419,7 +118,7 @@ declare function join<const ASide extends string, const BSide extends string, co
419
118
  relations: Junction<ASide, BSide>;
420
119
  findState: JoinState<ASide, BSide, Cardinality, null>;
421
120
  };
422
- declare function join<const ASide extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const BSide extends string, const Content extends Object$1>(options: JoinOptions<ASide, BSide, Cardinality, Content>, defaultContent: Content, store?: Store): {
121
+ declare function join<const ASide extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const BSide extends string, const Content extends Json.Object>(options: JoinOptions<ASide, BSide, Cardinality, Content>, defaultContent: Content, store?: Store): {
423
122
  relations: Junction<ASide, BSide, Content>;
424
123
  findState: JoinState<ASide, BSide, Cardinality, Content>;
425
124
  };
@@ -431,9 +130,9 @@ declare function struct<Struct extends {
431
130
  default: Struct;
432
131
  }, store?: Store): [
433
132
  {
434
- [K in keyof Struct as `${Key}${Capitalize<K & string>}State`]: AtomToken<Struct[K]>;
133
+ [K in keyof Struct as `${Key}${Capitalize<K & string>}State`]: AtomIO.AtomToken<Struct[K]>;
435
134
  },
436
- ReadonlySelectorToken<Struct>
135
+ AtomIO.ReadonlySelectorToken<Struct>
437
136
  ];
438
137
 
439
138
  declare function structFamily<Struct extends object, Key extends string>(options: {
@@ -441,9 +140,9 @@ declare function structFamily<Struct extends object, Key extends string>(options
441
140
  default: Struct;
442
141
  }): [
443
142
  {
444
- [K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<K & string>}State`]: AtomFamily<Struct[K], string>;
143
+ [K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<K & string>}State`]: AtomIO.AtomFamily<Struct[K], string>;
445
144
  },
446
- ReadonlySelectorFamily<Struct>
145
+ AtomIO.ReadonlySelectorFamily<Struct>
447
146
  ];
448
147
 
449
148
  type Loadable<T> = Promise<T> | T;