atom.io 0.13.0 → 0.14.1

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 (141) hide show
  1. package/data/dist/index.cjs +1473 -52
  2. package/data/dist/index.cjs.map +1 -1
  3. package/data/dist/index.d.cts +315 -16
  4. package/data/dist/index.js +10 -267
  5. package/data/dist/index.js.map +1 -1
  6. package/data/package.json +5 -5
  7. package/data/src/join.ts +3 -3
  8. package/dist/chunk-5VJ77LZE.js +176 -0
  9. package/dist/chunk-5VJ77LZE.js.map +1 -0
  10. package/dist/chunk-CK7GNCU5.js +309 -0
  11. package/dist/chunk-CK7GNCU5.js.map +1 -0
  12. package/dist/chunk-KW7RA7IM.js +67 -0
  13. package/dist/chunk-KW7RA7IM.js.map +1 -0
  14. package/dist/chunk-LFXB7Y6M.js +68 -0
  15. package/dist/chunk-LFXB7Y6M.js.map +1 -0
  16. package/dist/chunk-NYCVSXQB.js +181 -0
  17. package/dist/chunk-NYCVSXQB.js.map +1 -0
  18. package/dist/chunk-TE3ZSTQ6.js +2516 -0
  19. package/dist/chunk-TE3ZSTQ6.js.map +1 -0
  20. package/dist/index.cjs +2250 -126
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +272 -25
  23. package/dist/index.js +1 -215
  24. package/dist/index.js.map +1 -1
  25. package/dist/metafile-cjs.json +1 -1
  26. package/internal/dist/index.cjs +885 -684
  27. package/internal/dist/index.cjs.map +1 -1
  28. package/internal/dist/index.d.cts +230 -24
  29. package/internal/dist/index.js +1 -2171
  30. package/internal/dist/index.js.map +1 -1
  31. package/internal/package.json +5 -5
  32. package/internal/src/atom/create-atom.ts +3 -2
  33. package/internal/src/mutable/create-mutable-atom.ts +3 -2
  34. package/internal/src/mutable/tracker.ts +6 -4
  35. package/internal/src/selector/register-selector.ts +1 -1
  36. package/internal/src/selector/update-selector-atoms.ts +3 -3
  37. package/internal/src/subscribe/index.ts +3 -0
  38. package/internal/src/subscribe/recall-state.ts +0 -6
  39. package/internal/src/subscribe/subscribe-to-state.ts +47 -0
  40. package/internal/src/subscribe/subscribe-to-timeline.ts +28 -0
  41. package/internal/src/subscribe/subscribe-to-transaction.ts +33 -0
  42. package/introspection/dist/index.cjs +1618 -46
  43. package/introspection/dist/index.cjs.map +1 -1
  44. package/introspection/dist/index.d.cts +374 -4
  45. package/introspection/dist/index.js +2 -316
  46. package/introspection/dist/index.js.map +1 -1
  47. package/introspection/package.json +5 -5
  48. package/json/dist/index.cjs +1560 -8
  49. package/json/dist/index.cjs.map +1 -1
  50. package/json/dist/index.d.cts +371 -7
  51. package/json/dist/index.js +1 -76
  52. package/json/dist/index.js.map +1 -1
  53. package/json/package.json +5 -5
  54. package/package.json +10 -9
  55. package/react/dist/index.cjs +1638 -10
  56. package/react/dist/index.cjs.map +1 -1
  57. package/react/dist/index.d.cts +383 -5
  58. package/react/dist/index.js +2 -31
  59. package/react/dist/index.js.map +1 -1
  60. package/react/package.json +5 -5
  61. package/react/src/store-hooks.ts +52 -3
  62. package/react-devtools/dist/index.cjs +2268 -198
  63. package/react-devtools/dist/index.cjs.map +1 -1
  64. package/react-devtools/dist/index.css +2 -2
  65. package/react-devtools/dist/index.d.cts +148 -24
  66. package/react-devtools/dist/index.js +57 -297
  67. package/react-devtools/dist/index.js.map +1 -1
  68. package/react-devtools/package.json +5 -5
  69. package/realtime-client/dist/index.cjs +1585 -34
  70. package/realtime-client/dist/index.cjs.map +1 -1
  71. package/realtime-client/dist/index.d.cts +382 -11
  72. package/realtime-client/dist/index.js +2 -164
  73. package/realtime-client/dist/index.js.map +1 -1
  74. package/realtime-client/package.json +5 -5
  75. package/realtime-client/src/use-push.ts +4 -4
  76. package/realtime-client/src/use-server-action.ts +4 -4
  77. package/realtime-react/dist/index.cjs +1782 -35
  78. package/realtime-react/dist/index.cjs.map +1 -1
  79. package/realtime-react/dist/index.d.cts +49 -9
  80. package/realtime-react/dist/index.js +4 -66
  81. package/realtime-react/dist/index.js.map +1 -1
  82. package/realtime-react/package.json +5 -5
  83. package/realtime-server/dist/index.cjs +1627 -60
  84. package/realtime-server/dist/index.cjs.map +1 -1
  85. package/realtime-server/dist/index.d.cts +391 -11
  86. package/realtime-server/dist/index.js +59 -32
  87. package/realtime-server/dist/index.js.map +1 -1
  88. package/realtime-server/package.json +6 -6
  89. package/realtime-server/src/hook-composition/expose-family.ts +7 -3
  90. package/realtime-server/src/hook-composition/expose-mutable-family.ts +13 -5
  91. package/realtime-server/src/hook-composition/expose-mutable.ts +11 -3
  92. package/realtime-server/src/hook-composition/expose-single.ts +6 -2
  93. package/realtime-server/src/hook-composition/receive-transaction.ts +14 -5
  94. package/realtime-testing/dist/index.cjs +2352 -16
  95. package/realtime-testing/dist/index.cjs.map +1 -1
  96. package/realtime-testing/dist/index.d.cts +486 -3
  97. package/realtime-testing/dist/index.js +10 -31
  98. package/realtime-testing/dist/index.js.map +1 -1
  99. package/realtime-testing/package.json +5 -5
  100. package/src/subscribe.ts +37 -91
  101. package/transceivers/set-rtx/dist/index.cjs +31 -10
  102. package/transceivers/set-rtx/dist/index.cjs.map +1 -1
  103. package/transceivers/set-rtx/dist/index.d.cts +29 -3
  104. package/transceivers/set-rtx/dist/index.js +2 -3
  105. package/transceivers/set-rtx/dist/index.js.map +1 -1
  106. package/transceivers/set-rtx/package.json +6 -6
  107. package/data/dist/index.d.ts +0 -158
  108. package/data/dist/metafile-cjs.json +0 -1
  109. package/data/dist/metafile-esm.json +0 -1
  110. package/dist/index.d.ts +0 -243
  111. package/dist/metafile-esm.json +0 -1
  112. package/internal/dist/index.d.ts +0 -414
  113. package/internal/dist/metafile-cjs.json +0 -1
  114. package/internal/dist/metafile-esm.json +0 -1
  115. package/introspection/dist/index.d.ts +0 -24
  116. package/introspection/dist/metafile-cjs.json +0 -1
  117. package/introspection/dist/metafile-esm.json +0 -1
  118. package/json/dist/index.d.ts +0 -51
  119. package/json/dist/metafile-cjs.json +0 -1
  120. package/json/dist/metafile-esm.json +0 -1
  121. package/react/dist/index.d.ts +0 -16
  122. package/react/dist/metafile-cjs.json +0 -1
  123. package/react/dist/metafile-esm.json +0 -1
  124. package/react-devtools/dist/index.d.ts +0 -341
  125. package/react-devtools/dist/metafile-cjs.json +0 -1
  126. package/react-devtools/dist/metafile-esm.json +0 -1
  127. package/realtime-client/dist/index.d.ts +0 -21
  128. package/realtime-client/dist/metafile-cjs.json +0 -1
  129. package/realtime-client/dist/metafile-esm.json +0 -1
  130. package/realtime-react/dist/index.d.ts +0 -27
  131. package/realtime-react/dist/metafile-cjs.json +0 -1
  132. package/realtime-react/dist/metafile-esm.json +0 -1
  133. package/realtime-server/dist/index.d.ts +0 -25
  134. package/realtime-server/dist/metafile-cjs.json +0 -1
  135. package/realtime-server/dist/metafile-esm.json +0 -1
  136. package/realtime-testing/dist/index.d.ts +0 -49
  137. package/realtime-testing/dist/metafile-cjs.json +0 -1
  138. package/realtime-testing/dist/metafile-esm.json +0 -1
  139. package/transceivers/set-rtx/dist/index.d.ts +0 -40
  140. package/transceivers/set-rtx/dist/metafile-cjs.json +0 -1
  141. package/transceivers/set-rtx/dist/metafile-esm.json +0 -1
@@ -1,11 +1,53 @@
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';
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
+ }
5
13
 
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
- }>;
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
+ };
9
51
 
10
52
  type primitive = boolean | number | string | null;
11
53
 
@@ -81,18 +123,275 @@ declare class Junction<const ASide extends string, const BSide extends string, c
81
123
  has(a: string, b?: string): boolean;
82
124
  }
83
125
 
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>> {
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
+ family?: FamilyMetadata;
242
+ install: (store: Store) => void;
243
+ subject: Subject<{
244
+ newValue: T;
245
+ oldValue: T;
246
+ }>;
247
+ default: T | (() => T);
248
+ cleanup?: () => void;
249
+ };
250
+
251
+ type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
252
+ key: string;
253
+ type: `atom_family`;
254
+ subject: Subject<AtomToken<T>>;
255
+ };
256
+
257
+ declare const LoggerIconDictionary: {
258
+ readonly "\u231B": "Timeline event fully captured";
259
+ readonly "\u23E9": "Timeline redo";
260
+ readonly "\u23EA": "Timeline undo";
261
+ readonly "\u23ED\uFE0F": "Transaction redo";
262
+ readonly "\u23EE\uFE0F": "Transaction undo";
263
+ readonly "\u23F3": "Timeline event partially captured";
264
+ readonly "\u23F9\uFE0F": "Time-travel complete";
265
+ readonly "\uD83D\uDC81": "Notice";
266
+ readonly "\uD83D\uDD04": "Realtime transaction synchronized";
267
+ readonly "\u2705": "Realtime transaction success";
268
+ readonly "\u2728": "Computation complete";
269
+ readonly "\u274C": "Conflict prevents attempted action";
270
+ readonly "\u2B55": "Operation start";
271
+ readonly "\uD83D\uDC1E": "Possible bug in AtomIO";
272
+ readonly "\uD83D\uDC40": "Subscription added";
273
+ readonly "\uD83D\uDC6A": "Family member added";
274
+ readonly "\uD83D\uDCC1": "Stow update";
275
+ readonly "\uD83D\uDCC3": "Copy mutable";
276
+ readonly "\uD83D\uDCD6": "Read state";
277
+ readonly "\uD83D\uDCDD": "Write state";
278
+ readonly "\uD83D\uDCE2": "Notify subscribers";
279
+ readonly "\uD83D\uDD0C": "Register dependency";
280
+ readonly "\uD83D\uDD0D": "Discover root";
281
+ readonly "\uD83D\uDD25": "Delete state";
282
+ readonly "\uD83D\uDD27": "Create mutable atom";
283
+ readonly "\uD83D\uDD28": "Create immutable atom";
284
+ readonly "\uD83D\uDD34": "Operation complete";
285
+ readonly "\uD83D\uDDD1": "Evict cached value";
286
+ readonly "\uD83D\uDCA5": "Caught";
287
+ readonly "\uD83D\uDE48": "Subscription canceled";
288
+ readonly "\uD83D\uDEC4": "Apply transaction";
289
+ readonly "\uD83D\uDEE0\uFE0F": "Install atom into store";
290
+ readonly "\uD83D\uDEEB": "Begin transaction";
291
+ readonly "\uD83D\uDEEC": "Complete transaction";
292
+ readonly "\uD83E\uDDEE": "Computing selector";
293
+ readonly "\uD83E\uDDF9": "Prepare to evict";
294
+ readonly "\uD83E\uDE82": "Abort transaction";
295
+ };
296
+ type LoggerIcon = keyof typeof LoggerIconDictionary;
297
+ declare const LOG_LEVELS: readonly ["info", "warn", "error"];
298
+ type LogLevel = (typeof LOG_LEVELS)[number];
299
+ type LogFn = (icon: LoggerIcon, tokenType: `atom` | `readonly_selector` | `selector` | `state` | `timeline` | `transaction` | `unknown`, tokenKey: string, message: string, ...rest: unknown[]) => void;
300
+ type LogFilter = (...params: Parameters<LogFn>) => boolean;
301
+ type Logger = Record<LogLevel, LogFn>;
302
+ declare class AtomIOLogger implements Logger {
303
+ logLevel: `error` | `info` | `warn` | null;
304
+ private readonly filter?;
305
+ private readonly logger;
306
+ constructor(logLevel: `error` | `info` | `warn` | null, filter?: LogFilter | undefined, logger?: Logger);
307
+ error: LogFn;
308
+ info: LogFn;
309
+ warn: LogFn;
310
+ }
311
+
312
+ type TransactionToken<_> = {
313
+ key: string;
314
+ type: `transaction`;
315
+ __brand?: _;
316
+ };
317
+ type TransactionUpdate<ƒ extends ƒn> = {
318
+ key: string;
319
+ updates: (KeyedStateUpdate<unknown> | TransactionUpdate<ƒn>)[];
320
+ params: Parameters<ƒ>;
321
+ output: ReturnType<ƒ>;
322
+ };
323
+
324
+ type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
325
+ key: string;
326
+ type: `selector_family`;
327
+ subject: Subject<SelectorToken<T>>;
328
+ };
329
+ type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
330
+ key: string;
331
+ type: `readonly_selector_family`;
332
+ subject: Subject<ReadonlySelectorToken<T>>;
333
+ };
334
+
335
+ type StateUpdate<T> = {
336
+ newValue: T;
337
+ oldValue: T;
338
+ };
339
+ type KeyedStateUpdate<T> = StateUpdate<T> & {
340
+ key: string;
341
+ family?: FamilyMetadata;
342
+ };
343
+
344
+ type TimelineToken = {
345
+ key: string;
346
+ type: `timeline`;
347
+ };
348
+ type TimelineUpdate = TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate;
349
+
350
+ type ƒn = (...parameters: any[]) => any;
351
+ type AtomToken<_> = {
352
+ key: string;
353
+ type: `atom`;
354
+ family?: FamilyMetadata;
355
+ __brand?: _;
356
+ };
357
+ interface MutableAtomToken<T extends Transceiver<any>, J extends Serializable> extends AtomToken<T> {
358
+ __asJSON?: J;
359
+ __update?: T extends Transceiver<infer Update> ? Update : never;
360
+ }
361
+ type SelectorToken<_> = {
362
+ key: string;
363
+ type: `selector`;
364
+ family?: FamilyMetadata;
365
+ __brand?: _;
366
+ };
367
+ type StateToken<T> = AtomToken<T> | SelectorToken<T>;
368
+ type ReadonlySelectorToken<_> = {
369
+ key: string;
370
+ type: `readonly_selector`;
371
+ family?: FamilyMetadata;
372
+ __brand?: _;
373
+ };
374
+ type FamilyMetadata = {
375
+ key: string;
376
+ subKey: string;
377
+ };
378
+
379
+ 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<{
380
+ [K in Stringified<Key>]: State;
381
+ }>;
382
+
383
+ 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>> {
85
384
  readonly key: string;
86
385
  readonly cardinality: Cardinality;
87
386
  }
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 ? {
387
+ type JoinState<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Object$1 | null> = Cardinality extends `1:1` ? (Content extends Object$1 ? {
89
388
  readonly [AB in ASide | BSide as AB extends ASide ? `${AB}EntryOf${Capitalize<BSide>}` : `${AB}EntryOf${Capitalize<ASide>}`]: SelectorFamily<[
90
389
  string,
91
390
  Content
92
391
  ] | undefined, string>;
93
392
  } : {}) & {
94
393
  readonly [AB in ASide | BSide as AB extends ASide ? `${AB}KeyOf${Capitalize<BSide>}` : `${AB}KeyOf${Capitalize<ASide>}`]: SelectorFamily<string | undefined, string>;
95
- } : Cardinality extends `1:n` ? (Content extends Json.Object ? {
394
+ } : Cardinality extends `1:n` ? (Content extends Object$1 ? {
96
395
  readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: SelectorFamily<[
97
396
  string,
98
397
  Content
@@ -106,7 +405,7 @@ type JoinState<ASide extends string, BSide extends string, Cardinality extends C
106
405
  readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: SelectorFamily<string | undefined, string>;
107
406
  } & {
108
407
  readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: SelectorFamily<string[], string>;
109
- } : Cardinality extends `n:n` ? (Content extends Json.Object ? {
408
+ } : Cardinality extends `n:n` ? (Content extends Object$1 ? {
110
409
  readonly [AB in ASide | BSide as AB extends ASide ? `${AB}EntriesOf${Capitalize<BSide>}` : `${AB}EntriesOf${Capitalize<ASide>}`]: SelectorFamily<[
111
410
  string,
112
411
  Content
@@ -118,7 +417,7 @@ declare function join<const ASide extends string, const BSide extends string, co
118
417
  relations: Junction<ASide, BSide>;
119
418
  findState: JoinState<ASide, BSide, Cardinality, null>;
120
419
  };
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): {
420
+ 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): {
122
421
  relations: Junction<ASide, BSide, Content>;
123
422
  findState: JoinState<ASide, BSide, Cardinality, Content>;
124
423
  };
@@ -130,9 +429,9 @@ declare function struct<Struct extends {
130
429
  default: Struct;
131
430
  }, store?: Store): [
132
431
  {
133
- [K in keyof Struct as `${Key}${Capitalize<K & string>}State`]: AtomIO.AtomToken<Struct[K]>;
432
+ [K in keyof Struct as `${Key}${Capitalize<K & string>}State`]: AtomToken<Struct[K]>;
134
433
  },
135
- AtomIO.ReadonlySelectorToken<Struct>
434
+ ReadonlySelectorToken<Struct>
136
435
  ];
137
436
 
138
437
  declare function structFamily<Struct extends object, Key extends string>(options: {
@@ -140,9 +439,9 @@ declare function structFamily<Struct extends object, Key extends string>(options
140
439
  default: Struct;
141
440
  }): [
142
441
  {
143
- [K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<K & string>}State`]: AtomIO.AtomFamily<Struct[K], string>;
442
+ [K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<K & string>}State`]: AtomFamily<Struct[K], string>;
144
443
  },
145
- AtomIO.ReadonlySelectorFamily<Struct>
444
+ ReadonlySelectorFamily<Struct>
146
445
  ];
147
446
 
148
447
  type Loadable<T> = Promise<T> | T;
@@ -1,8 +1,7 @@
1
- import { createSelector, IMPLICIT, createMutableAtomFamily, createAtomFamily, createAtom, createSelectorFamily, getJsonFamily } from 'atom.io/internal';
2
- import { getState, setState } from 'atom.io';
1
+ import { createSelector, IMPLICIT, createMutableAtomFamily, createAtomFamily, Junction, createAtom, createSelectorFamily, getJsonFamily, getState, setState } from '../../dist/chunk-TE3ZSTQ6.js';
3
2
  import { SetRTX } from 'atom.io/transceivers/set-rtx';
4
3
 
5
- // src/dict.ts
4
+ // data/src/dict.ts
6
5
  function dict(findState, index, store = IMPLICIT.STORE) {
7
6
  return createSelector(
8
7
  {
@@ -19,266 +18,6 @@ function dict(findState, index, store = IMPLICIT.STORE) {
19
18
  store
20
19
  );
21
20
  }
22
-
23
- // ../../rel8/junction/src/junction.ts
24
- var Junction = class {
25
- constructor(data, config) {
26
- this.relations = /* @__PURE__ */ new Map();
27
- this.contents = /* @__PURE__ */ new Map();
28
- this.makeContentKey = (a, b) => `${a}:${b}`;
29
- var _a, _b, _c, _d;
30
- this.a = data.between[0];
31
- this.b = data.between[1];
32
- this.cardinality = data.cardinality;
33
- if (!(config == null ? void 0 : config.externalStore)) {
34
- this.relations = new Map((_a = data.relations) == null ? void 0 : _a.map(([a, b]) => [a, new Set(b)]));
35
- this.contents = new Map(data.contents);
36
- }
37
- this.isContent = (_b = config == null ? void 0 : config.isContent) != null ? _b : null;
38
- if (config == null ? void 0 : config.makeContentKey) {
39
- this.makeContentKey = config.makeContentKey;
40
- }
41
- if (config == null ? void 0 : config.externalStore) {
42
- const externalStore = config.externalStore;
43
- this.has = (a, b) => externalStore.has(a, b);
44
- this.addRelation = (a, b) => {
45
- externalStore.addRelation(a, b);
46
- };
47
- this.deleteRelation = (a, b) => {
48
- externalStore.deleteRelation(a, b);
49
- };
50
- this.replaceRelationsSafely = (a, bs) => {
51
- externalStore.replaceRelationsSafely(a, bs);
52
- };
53
- this.replaceRelationsUnsafely = (a, bs) => {
54
- externalStore.replaceRelationsUnsafely(a, bs);
55
- };
56
- this.getRelatedKeys = (key) => externalStore.getRelatedKeys(key);
57
- if (externalStore.getContent) {
58
- this.getContentInternal = (contentKey) => {
59
- return externalStore.getContent(contentKey);
60
- };
61
- this.setContent = (contentKey, content) => {
62
- externalStore.setContent(contentKey, content);
63
- };
64
- this.deleteContent = (contentKey) => {
65
- externalStore.deleteContent(contentKey);
66
- };
67
- }
68
- for (const [x, ys] of (_c = data.relations) != null ? _c : []) {
69
- for (const y of ys)
70
- this.addRelation(x, y);
71
- }
72
- for (const [contentKey, content] of (_d = data.contents) != null ? _d : []) {
73
- this.setContent(contentKey, content);
74
- }
75
- }
76
- }
77
- getRelatedKeys(key) {
78
- return this.relations.get(key);
79
- }
80
- addRelation(a, b) {
81
- let aRelations = this.relations.get(a);
82
- let bRelations = this.relations.get(b);
83
- if (aRelations) {
84
- aRelations.add(b);
85
- } else {
86
- aRelations = /* @__PURE__ */ new Set([b]);
87
- this.relations.set(a, aRelations);
88
- }
89
- if (bRelations) {
90
- bRelations.add(a);
91
- } else {
92
- bRelations = /* @__PURE__ */ new Set([a]);
93
- this.relations.set(b, bRelations);
94
- }
95
- }
96
- deleteRelation(a, b) {
97
- const aRelations = this.relations.get(a);
98
- if (aRelations) {
99
- aRelations.delete(b);
100
- if (aRelations.size === 0) {
101
- this.relations.delete(a);
102
- }
103
- const bRelations = this.relations.get(b);
104
- if (bRelations) {
105
- bRelations.delete(a);
106
- if (bRelations.size === 0) {
107
- this.relations.delete(b);
108
- }
109
- }
110
- }
111
- }
112
- replaceRelationsUnsafely(a, bs) {
113
- this.relations.set(a, new Set(bs));
114
- for (const b of bs) {
115
- const bRelations = /* @__PURE__ */ new Set([a]);
116
- this.relations.set(b, bRelations);
117
- }
118
- }
119
- replaceRelationsSafely(a, bs) {
120
- const aRelationsPrev = this.relations.get(a);
121
- if (aRelationsPrev) {
122
- for (const b of aRelationsPrev) {
123
- const bRelations = this.relations.get(b);
124
- if (bRelations) {
125
- if (bRelations.size === 1) {
126
- this.relations.delete(b);
127
- } else {
128
- bRelations.delete(a);
129
- }
130
- this.contents.delete(this.makeContentKey(a, b));
131
- }
132
- }
133
- }
134
- this.relations.set(a, new Set(bs));
135
- for (const b of bs) {
136
- let bRelations = this.relations.get(b);
137
- if (bRelations) {
138
- bRelations.add(a);
139
- } else {
140
- bRelations = /* @__PURE__ */ new Set([a]);
141
- this.relations.set(b, bRelations);
142
- }
143
- }
144
- }
145
- getContentInternal(contentKey) {
146
- return this.contents.get(contentKey);
147
- }
148
- setContent(contentKey, content) {
149
- this.contents.set(contentKey, content);
150
- }
151
- deleteContent(contentKey) {
152
- this.contents.delete(contentKey);
153
- }
154
- toJSON() {
155
- return {
156
- between: [this.a, this.b],
157
- cardinality: this.cardinality,
158
- relations: [...this.relations.entries()].map(([a, b]) => [a, [...b]]),
159
- contents: [...this.contents.entries()]
160
- };
161
- }
162
- set(a, ...rest) {
163
- var _a;
164
- const b = typeof rest[0] === `string` ? rest[0] : a[this.b];
165
- const content = ((_a = rest[1]) != null ? _a : typeof rest[0] === `string`) ? void 0 : rest[0];
166
- a = typeof a === `string` ? a : a[this.a];
167
- switch (this.cardinality) {
168
- case `1:1`: {
169
- const bPrev = this.getRelatedKey(a);
170
- if (bPrev && bPrev !== b)
171
- this.delete(bPrev, a);
172
- }
173
- case `1:n`: {
174
- const aPrev = this.getRelatedKey(b);
175
- if (aPrev && aPrev !== a)
176
- this.delete(aPrev, b);
177
- }
178
- }
179
- if (content) {
180
- const contentKey = this.makeContentKey(a, b);
181
- this.setContent(contentKey, content);
182
- }
183
- this.addRelation(a, b);
184
- return this;
185
- }
186
- delete(x, b) {
187
- b = typeof b === `string` ? b : x[this.b];
188
- const a = typeof x === `string` ? x : x[this.a];
189
- if (a === void 0 && typeof b === `string`) {
190
- const bRelations = this.getRelatedKeys(b);
191
- if (bRelations) {
192
- for (const a2 of bRelations) {
193
- this.delete(a2, b);
194
- }
195
- }
196
- }
197
- if (typeof a === `string` && b === void 0) {
198
- const aRelations = this.getRelatedKeys(a);
199
- if (aRelations) {
200
- for (const b2 of aRelations) {
201
- this.delete(a, b2);
202
- }
203
- }
204
- }
205
- if (typeof a === `string` && typeof b === `string`) {
206
- this.deleteRelation(a, b);
207
- const contentKey = this.makeContentKey(a, b);
208
- this.deleteContent(contentKey);
209
- }
210
- return this;
211
- }
212
- getRelatedKey(key) {
213
- const relations = this.getRelatedKeys(key);
214
- if (relations) {
215
- if (relations.size > 1) {
216
- console.warn(
217
- `${relations.size} related keys were found for key "${key}": (${[
218
- ...relations
219
- ].map((k) => `"${k}"`).join(`, `)}). Only one related key was expected.`
220
- );
221
- }
222
- for (const relation of relations) {
223
- return relation;
224
- }
225
- }
226
- }
227
- replaceRelations(a, relations, config) {
228
- const hasContent = !Array.isArray(relations);
229
- const bs = hasContent ? Object.keys(relations) : relations;
230
- if (config == null ? void 0 : config.reckless) {
231
- this.replaceRelationsUnsafely(a, bs);
232
- } else {
233
- this.replaceRelationsSafely(a, bs);
234
- }
235
- if (hasContent) {
236
- for (const b of bs) {
237
- const contentKey = this.makeContentKey(a, b);
238
- const content = relations[b];
239
- this.setContent(contentKey, content);
240
- }
241
- }
242
- return this;
243
- }
244
- getContent(a, b) {
245
- const contentKey = this.makeContentKey(a, b);
246
- return this.getContentInternal(contentKey);
247
- }
248
- getRelationEntries(input) {
249
- const a = input[this.a];
250
- const b = input[this.b];
251
- if (a !== void 0 && b === void 0) {
252
- const aRelations = this.getRelatedKeys(a);
253
- if (aRelations) {
254
- return [...aRelations].map((b2) => {
255
- var _a;
256
- return [b2, (_a = this.getContent(a, b2)) != null ? _a : null];
257
- });
258
- }
259
- }
260
- if (a === void 0 && b !== void 0) {
261
- const bRelations = this.getRelatedKeys(b);
262
- if (bRelations) {
263
- return [...bRelations].map((a2) => {
264
- var _a;
265
- return [a2, (_a = this.getContent(a2, b)) != null ? _a : null];
266
- });
267
- }
268
- }
269
- return [];
270
- }
271
- has(a, b) {
272
- var _a;
273
- if (b) {
274
- const setA = this.getRelatedKeys(a);
275
- return (_a = setA == null ? void 0 : setA.has(b)) != null ? _a : false;
276
- }
277
- return this.relations.has(a);
278
- }
279
- };
280
-
281
- // src/join.ts
282
21
  var TRANSACTORS = { get: getState, set: setState };
283
22
  function capitalize(string) {
284
23
  return string[0].toUpperCase() + string.slice(1);
@@ -328,9 +67,9 @@ function join(options, defaultContent, store = IMPLICIT.STORE) {
328
67
  }
329
68
  };
330
69
  const replaceRelationsSafely = (transactors, a2, bs) => {
331
- const aKeys = getRelatedKeys(transactors, a2);
332
- if (aKeys) {
333
- for (const b2 of aKeys) {
70
+ const aRelations = getRelatedKeys(transactors, a2);
71
+ if (aRelations) {
72
+ for (const b2 of aRelations) {
334
73
  const bKeys = getRelatedKeys(transactors, b2);
335
74
  if (bKeys) {
336
75
  bKeys.delete(a2);
@@ -535,6 +274,8 @@ function join(options, defaultContent, store = IMPLICIT.STORE) {
535
274
  throw new Error(`Invalid cardinality: ${options.cardinality}`);
536
275
  }
537
276
  }
277
+
278
+ // data/src/struct.ts
538
279
  var capitalize2 = (str) => str[0].toUpperCase() + str.slice(1);
539
280
  function struct(options, store = IMPLICIT.STORE) {
540
281
  const atoms = Object.keys(options.default).reduce((acc, key) => {
@@ -564,6 +305,8 @@ function struct(options, store = IMPLICIT.STORE) {
564
305
  );
565
306
  return [atoms, structState];
566
307
  }
308
+
309
+ // data/src/struct-family.ts
567
310
  var capitalize3 = (str) => str[0].toUpperCase() + str.slice(1);
568
311
  var nameFamily = (topKey, subKey) => `find` + capitalize3(topKey) + capitalize3(subKey) + `State`;
569
312
  function structFamily(options) {
@@ -595,7 +338,7 @@ function structFamily(options) {
595
338
  return [atoms, findStructState];
596
339
  }
597
340
 
598
- // src/until.ts
341
+ // data/src/until.ts
599
342
  function until(loadable, fallback) {
600
343
  if (loadable instanceof Promise) {
601
344
  return fallback;