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;
@@ -1,7 +1,9 @@
1
- import { createSelector, IMPLICIT, createMutableAtomFamily, createAtomFamily, Junction, createAtom, createSelectorFamily, getJsonFamily, getState, setState } from '../../dist/chunk-PURABO5G.js';
1
+ import { Junction } from '../../dist/chunk-NYTGCPHB.js';
2
+ import '../../dist/chunk-PZLG2HP3.js';
3
+ import { createSelector, IMPLICIT, createMutableAtomFamily, createAtomFamily, createAtom, createSelectorFamily, getJsonFamily } from 'atom.io/internal';
4
+ import { getState, setState } from 'atom.io';
2
5
  import { SetRTX } from 'atom.io/transceivers/set-rtx';
3
6
 
4
- // data/src/dict.ts
5
7
  function dict(findState, index, store = IMPLICIT.STORE) {
6
8
  return createSelector(
7
9
  {
@@ -274,8 +276,6 @@ function join(options, defaultContent, store = IMPLICIT.STORE) {
274
276
  throw new Error(`Invalid cardinality: ${options.cardinality}`);
275
277
  }
276
278
  }
277
-
278
- // data/src/struct.ts
279
279
  var capitalize2 = (str) => str[0].toUpperCase() + str.slice(1);
280
280
  function struct(options, store = IMPLICIT.STORE) {
281
281
  const atoms = Object.keys(options.default).reduce((acc, key) => {
@@ -305,8 +305,6 @@ function struct(options, store = IMPLICIT.STORE) {
305
305
  );
306
306
  return [atoms, structState];
307
307
  }
308
-
309
- // data/src/struct-family.ts
310
308
  var capitalize3 = (str) => str[0].toUpperCase() + str.slice(1);
311
309
  var nameFamily = (topKey, subKey) => `find` + capitalize3(topKey) + capitalize3(subKey) + `State`;
312
310
  function structFamily(options) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dict.ts","../src/join.ts","../src/struct.ts","../src/struct-family.ts","../src/until.ts"],"names":["a","b","capitalize"],"mappings":";;;;;;;;;;;;;;AAKO,SAAS,KACf,WAIA,OAIA,QAAe,SAAS,OAC2C;AACnE,SAAO;AAAA,IACN;AAAA,MACC,KAAK,GAAG,UAAU,GAAG;AAAA,MACrB,KAAK,CAAC,EAAE,IAAI,MAAM;AACjB,cAAM,OAAO,IAAI,KAAK;AACtB,eAAO,KAAK,OAAO,CAAC,KAAK,QAAQ;AAChC,cAAI,GAAG,IAAI,IAAI,UAAU,GAAG,CAAC;AAC7B,iBAAO;AAAA,QACR,GAAG,CAAC,CAAQ;AAAA,MACb;AAAA,IACD;AAAA,IACA;AA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;AAAA,MACb,KACC,CAAC,OACD,CAAC,EAAE,IAAI,MAAM;AACZ,eAAO,OAAO,KAAK,QAAQ,OAAO,EAAE,OAAO,CAAC,KAAK,WAAW;AAC3D,cAAI,MAAM,IAAI;AAAA,YACZ,MAAc,WAAW,QAAQ,KAAK,MAAM,CAAC,EAAE,EAAE;AAAA,UACnD;AACA,iBAAO;AAAA,QACR,GAAG,CAAC,CAAQ;AAAA,MACb;AAAA,IACF;AAAA,IACA,SAAS;AAAA,EACV;AACA,SAAO,CAAC,OAAO,eAAe;AAC/B;;;AChDO,SAAS,MAAS,UAAuB,UAAgB;AAC/D,MAAI,oBAAoB,SAAS;AAChC,WAAO;AAAA,EACR;AACA,SAAO;AACR","sourcesContent":["import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createSelector } from \"atom.io/internal\"\nimport type { Json, Stringified } from \"atom.io/json\"\n\nexport function dict<State, Key extends Json.Serializable>(\n\tfindState:\n\t\t| AtomIO.AtomFamily<State, Key>\n\t\t| AtomIO.ReadonlySelectorFamily<State, Key>\n\t\t| AtomIO.SelectorFamily<State, Key>,\n\tindex:\n\t\t| AtomIO.AtomToken<Key[]>\n\t\t| AtomIO.ReadonlySelectorToken<Key[]>\n\t\t| AtomIO.SelectorToken<Key[]>,\n\tstore: Store = IMPLICIT.STORE,\n): AtomIO.ReadonlySelectorToken<{ [K in Stringified<Key>]: State }> {\n\treturn createSelector(\n\t\t{\n\t\t\tkey: `${findState.key}Dict`,\n\t\t\tget: ({ get }) => {\n\t\t\t\tconst keys = get(index)\n\t\t\t\treturn keys.reduce((acc, key) => {\n\t\t\t\t\tacc[key] = get(findState(key))\n\t\t\t\t\treturn acc\n\t\t\t\t}, {} as any)\n\t\t\t},\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n}\n","/* eslint-disable @typescript-eslint/ban-types */\nimport type {\n\tAtomFamily,\n\tRead,\n\tSelectorFamily,\n\tTransactors,\n\tWrite,\n} from \"atom.io\"\nimport { getState, setState } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tcreateAtomFamily,\n\tcreateMutableAtomFamily,\n\tcreateSelectorFamily,\n\tgetJsonFamily,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { SetRTX } from \"atom.io/transceivers/set-rtx\"\n\nimport type {\n\tBaseExternalStoreConfiguration,\n\tExternalStoreConfiguration,\n\tExternalStoreWithContentConfiguration,\n\tJunctionEntries,\n\tJunctionSchema,\n} from \"~/packages/rel8/junction/src\"\nimport { Junction } from \"~/packages/rel8/junction/src\"\nimport type * as Rel8 from \"~/packages/rel8/types/src\"\n\nconst TRANSACTORS: Transactors = { get: getState, set: setState }\n\nfunction capitalize<S extends string>(string: S): Capitalize<S> {\n\treturn (string[0].toUpperCase() + string.slice(1)) as Capitalize<S>\n}\n\nexport interface JoinOptions<\n\tASide extends string,\n\tBSide extends string,\n\tCardinality extends Rel8.Cardinality,\n\tContent extends Json.Object | null,\n> extends Json.Object,\n\t\tJunctionSchema<ASide, BSide>,\n\t\tPartial<JunctionEntries<Content>> {\n\treadonly key: string\n\treadonly cardinality: Cardinality\n}\n\nexport type JoinState<\n\tASide extends string,\n\tBSide extends string,\n\tCardinality extends Rel8.Cardinality,\n\tContent extends Json.Object | null,\n> = Cardinality extends `1:1`\n\t? (Content extends Json.Object\n\t\t\t? {\n\t\t\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t\t\t? `${AB}EntryOf${Capitalize<BSide>}`\n\t\t\t\t\t\t: `${AB}EntryOf${Capitalize<ASide>}`]: SelectorFamily<\n\t\t\t\t\t\t[string, Content] | undefined,\n\t\t\t\t\t\tstring\n\t\t\t\t\t>\n\t\t\t }\n\t\t\t: {}) & {\n\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t? `${AB}KeyOf${Capitalize<BSide>}`\n\t\t\t\t: `${AB}KeyOf${Capitalize<ASide>}`]: SelectorFamily<\n\t\t\t\tstring | undefined,\n\t\t\t\tstring\n\t\t\t>\n\t }\n\t: Cardinality extends `1:n`\n\t ? (Content extends Json.Object\n\t\t\t\t? {\n\t\t\t\t\t\treadonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: SelectorFamily<\n\t\t\t\t\t\t\t[string, Content] | undefined,\n\t\t\t\t\t\t\tstring\n\t\t\t\t\t\t>\n\t\t\t\t } & {\n\t\t\t\t\t\treadonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: SelectorFamily<\n\t\t\t\t\t\t\t[string, Content][],\n\t\t\t\t\t\t\tstring\n\t\t\t\t\t\t>\n\t\t\t\t }\n\t\t\t\t: {}) & {\n\t\t\t\treadonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: SelectorFamily<\n\t\t\t\t\tstring | undefined,\n\t\t\t\t\tstring\n\t\t\t\t>\n\t\t } & {\n\t\t\t\treadonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: SelectorFamily<\n\t\t\t\t\tstring[],\n\t\t\t\t\tstring\n\t\t\t\t>\n\t\t }\n\t : Cardinality extends `n:n`\n\t\t ? (Content extends Json.Object\n\t\t\t\t\t? {\n\t\t\t\t\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t\t\t\t\t? `${AB}EntriesOf${Capitalize<BSide>}`\n\t\t\t\t\t\t\t\t: `${AB}EntriesOf${Capitalize<ASide>}`]: SelectorFamily<\n\t\t\t\t\t\t\t\t[string, Content][],\n\t\t\t\t\t\t\t\tstring\n\t\t\t\t\t\t\t>\n\t\t\t\t\t }\n\t\t\t\t\t: {}) & {\n\t\t\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t\t\t? `${AB}KeysOf${Capitalize<BSide>}`\n\t\t\t\t\t\t: `${AB}KeysOf${Capitalize<ASide>}`]: SelectorFamily<\n\t\t\t\t\t\tstring[],\n\t\t\t\t\t\tstring\n\t\t\t\t\t>\n\t\t\t }\n\t\t : never\n\nexport function join<\n\tconst ASide extends string,\n\tconst BSide extends string,\n\tconst Cardinality extends Rel8.Cardinality,\n>(\n\toptions: JoinOptions<ASide, BSide, Cardinality, null>,\n\tdefaultContent?: undefined,\n\tstore?: Store,\n): {\n\trelations: Junction<ASide, BSide>\n\tfindState: JoinState<ASide, BSide, Cardinality, null>\n}\nexport function join<\n\tconst ASide extends string,\n\tconst Cardinality extends `1:1` | `1:n` | `n:n`,\n\tconst BSide extends string,\n\tconst Content extends Json.Object,\n>(\n\toptions: JoinOptions<ASide, BSide, Cardinality, Content>,\n\tdefaultContent: Content,\n\tstore?: Store,\n): {\n\trelations: Junction<ASide, BSide, Content>\n\tfindState: JoinState<ASide, BSide, Cardinality, Content>\n}\nexport function join<\n\tASide extends string,\n\tBSide extends string,\n\tCardinality extends Rel8.Cardinality,\n\tContent extends Json.Object,\n>(\n\toptions: JoinOptions<ASide, BSide, Cardinality, Content>,\n\tdefaultContent: Content | undefined,\n\tstore: Store = IMPLICIT.STORE,\n): {\n\trelations: Junction<ASide, BSide, Content>\n\tfindState: JoinState<ASide, BSide, Cardinality, Content>\n} {\n\tconst a: ASide = options.between[0]\n\tconst b: BSide = options.between[1]\n\tconst findRelatedKeysState = createMutableAtomFamily<\n\t\tSetRTX<string>,\n\t\tstring[],\n\t\tstring\n\t>(\n\t\t{\n\t\t\tkey: `${options.key}/relatedKeys`,\n\t\t\tdefault: () => new SetRTX(),\n\t\t\tmutable: true,\n\t\t\tfromJson: (json) => new SetRTX(json),\n\t\t\ttoJson: (set) => [...set],\n\t\t},\n\t\tstore,\n\t)\n\tconst getRelatedKeys: Read<(key: string) => Set<string> | undefined> = (\n\t\t{ get },\n\t\tkey,\n\t) => get(findRelatedKeysState(key))\n\tconst addRelation: Write<(a: string, b: string) => void> = (\n\t\ttransactors,\n\t\ta,\n\t\tb,\n\t) => {\n\t\tconst aKeys = getRelatedKeys(transactors, a)\n\t\tconst bKeys = getRelatedKeys(transactors, b)\n\t\tif (aKeys) {\n\t\t\ttransactors.set(findRelatedKeysState(a), aKeys.add(b))\n\t\t} else {\n\t\t\ttransactors.set(findRelatedKeysState(a), new SetRTX([b]))\n\t\t}\n\t\tif (bKeys) {\n\t\t\ttransactors.set(findRelatedKeysState(b), bKeys.add(a))\n\t\t} else {\n\t\t\ttransactors.set(findRelatedKeysState(b), new SetRTX([a]))\n\t\t}\n\t}\n\tconst deleteRelation: Write<(a: string, b: string) => void> = (\n\t\ttransactors,\n\t\ta,\n\t\tb,\n\t) => {\n\t\tconst aKeys = getRelatedKeys(transactors, a)\n\t\tif (aKeys) {\n\t\t\taKeys.delete(b)\n\t\t\tif (aKeys.size === 0) {\n\t\t\t\ttransactors.set(findRelatedKeysState(a), undefined)\n\t\t\t}\n\t\t\tconst bKeys = getRelatedKeys(transactors, b)\n\t\t\tif (bKeys) {\n\t\t\t\tbKeys.delete(a)\n\t\t\t\tif (bKeys.size === 0) {\n\t\t\t\t\ttransactors.set(findRelatedKeysState(b), undefined)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tconst replaceRelationsSafely: Write<(a: string, bs: string[]) => void> = (\n\t\ttransactors,\n\t\ta,\n\t\tbs,\n\t) => {\n\t\tconst aRelations = getRelatedKeys(transactors, a)\n\t\tif (aRelations) {\n\t\t\tfor (const b of aRelations) {\n\t\t\t\tconst bKeys = getRelatedKeys(transactors, b)\n\t\t\t\tif (bKeys) {\n\t\t\t\t\tbKeys.delete(a)\n\t\t\t\t\tif (bKeys.size === 0) {\n\t\t\t\t\t\ttransactors.set(findRelatedKeysState(b), undefined)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttransactors.set(findRelatedKeysState(a), new SetRTX(bs))\n\t\tfor (const b of bs) {\n\t\t\tconst bKeys = getRelatedKeys(transactors, b)\n\t\t\tif (bKeys) {\n\t\t\t\tbKeys.add(a)\n\t\t\t} else {\n\t\t\t\ttransactors.set(findRelatedKeysState(b), new SetRTX([a]))\n\t\t\t}\n\t\t}\n\t}\n\tconst replaceRelationsUnsafely: Write<(a: string, bs: string[]) => void> = (\n\t\ttransactors,\n\t\ta,\n\t\tbs,\n\t) => {\n\t\ttransactors.set(findRelatedKeysState(a), new SetRTX(bs))\n\t\tfor (const b of bs) {\n\t\t\tlet bKeys = getRelatedKeys(transactors, b)\n\t\t\tif (bKeys) {\n\t\t\t\tbKeys.add(a)\n\t\t\t} else {\n\t\t\t\tbKeys = new SetRTX([a])\n\t\t\t\ttransactors.set(findRelatedKeysState(b), bKeys)\n\t\t\t}\n\t\t}\n\t}\n\tconst has: Read<(a: string, b?: string) => boolean> = (transactors, a, b) => {\n\t\tconst aKeys = getRelatedKeys(transactors, a)\n\t\treturn b ? aKeys?.has(b) ?? false : (aKeys?.size ?? 0) > 0 ?? false\n\t}\n\tconst baseExternalStoreConfiguration: BaseExternalStoreConfiguration = {\n\t\tgetRelatedKeys: (key) => getRelatedKeys(TRANSACTORS, key),\n\t\taddRelation: (a, b) => addRelation(TRANSACTORS, a, b),\n\t\tdeleteRelation: (a, b) => deleteRelation(TRANSACTORS, a, b),\n\t\treplaceRelationsSafely: (a, bs) =>\n\t\t\treplaceRelationsSafely(TRANSACTORS, a, bs),\n\t\treplaceRelationsUnsafely: (a, bs) =>\n\t\t\treplaceRelationsUnsafely(TRANSACTORS, a, bs),\n\t\thas: (a, b) => has(TRANSACTORS, a, b),\n\t}\n\tlet externalStore: ExternalStoreConfiguration<Content>\n\tlet findContentState: AtomFamily<Content, string>\n\tif (defaultContent) {\n\t\tfindContentState = createAtomFamily<Content, string>(\n\t\t\t{\n\t\t\t\tkey: `${options.key}/content`,\n\t\t\t\tdefault: defaultContent,\n\t\t\t},\n\t\t\tstore,\n\t\t)\n\t\tconst getContent: Read<(key: string) => Content | undefined> = (\n\t\t\t{ get },\n\t\t\tkey,\n\t\t) => get(findContentState(key))\n\t\tconst setContent: Write<(key: string, content: Content) => void> = (\n\t\t\ttransactors,\n\t\t\tkey,\n\t\t\tcontent,\n\t\t) => transactors.set(findContentState(key), content)\n\t\tconst deleteContent: Write<(key: string) => void> = (transactors, key) =>\n\t\t\ttransactors.set(findContentState(key), undefined)\n\t\tconst externalStoreWithContentConfiguration: ExternalStoreWithContentConfiguration<Content> =\n\t\t\t{\n\t\t\t\tgetContent: (contentKey: string) => {\n\t\t\t\t\tconst content = getContent(TRANSACTORS, contentKey)\n\t\t\t\t\treturn content\n\t\t\t\t},\n\t\t\t\tsetContent: (contentKey: string, content: Content) => {\n\t\t\t\t\tsetContent(TRANSACTORS, contentKey, content)\n\t\t\t\t},\n\t\t\t\tdeleteContent: (contentKey: string) => {\n\t\t\t\t\tdeleteContent(TRANSACTORS, contentKey)\n\t\t\t\t},\n\t\t\t}\n\t\texternalStore = Object.assign(\n\t\t\tbaseExternalStoreConfiguration,\n\t\t\texternalStoreWithContentConfiguration,\n\t\t) as ExternalStoreConfiguration<Content>\n\t} else {\n\t\texternalStore =\n\t\t\tbaseExternalStoreConfiguration as ExternalStoreConfiguration<Content>\n\t}\n\tconst relations = new Junction<ASide, BSide, Content>(options, {\n\t\texternalStore,\n\t\tmakeContentKey: (...args) => args.sort().join(`:`),\n\t})\n\n\tconst createSingleKeyStateFamily = () =>\n\t\tcreateSelectorFamily<string | undefined, string>(\n\t\t\t{\n\t\t\t\tkey: `${options.key}/singleRelatedKey`,\n\t\t\t\tget:\n\t\t\t\t\t(key) =>\n\t\t\t\t\t({ get }) => {\n\t\t\t\t\t\tconst relatedKeys = get(findRelatedKeysState(key))\n\t\t\t\t\t\tfor (const relatedKey of relatedKeys) {\n\t\t\t\t\t\t\treturn relatedKey\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t},\n\t\t\tstore,\n\t\t)\n\tconst getMultipleKeyStateFamily = () =>\n\t\tgetJsonFamily(findRelatedKeysState, store)\n\tconst createSingleEntryStateFamily = () =>\n\t\tcreateSelectorFamily<[string, Content] | undefined, string>(\n\t\t\t{\n\t\t\t\tkey: `${options.key}/singleRelatedEntry`,\n\t\t\t\tget:\n\t\t\t\t\t(key) =>\n\t\t\t\t\t({ get }) => {\n\t\t\t\t\t\tconst relatedKeys = get(findRelatedKeysState(key))\n\t\t\t\t\t\tfor (const relatedKey of relatedKeys) {\n\t\t\t\t\t\t\tconst contentKey = relations.makeContentKey(key, relatedKey)\n\t\t\t\t\t\t\treturn [relatedKey, get(findContentState(contentKey))]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t},\n\t\t\tstore,\n\t\t)\n\tconst getMultipleEntryStateFamily = () =>\n\t\tcreateSelectorFamily<[string, Content][], string>(\n\t\t\t{\n\t\t\t\tkey: `${options.key}/multipleRelatedEntries`,\n\t\t\t\tget:\n\t\t\t\t\t(key) =>\n\t\t\t\t\t({ get }) => {\n\t\t\t\t\t\tconst relatedKeys = get(findRelatedKeysState(key))\n\t\t\t\t\t\treturn [...relatedKeys].map((relatedKey) => {\n\t\t\t\t\t\t\tconst contentKey = relations.makeContentKey(key, relatedKey)\n\t\t\t\t\t\t\treturn [relatedKey, get(findContentState(contentKey))]\n\t\t\t\t\t\t})\n\t\t\t\t\t},\n\t\t\t},\n\t\t\tstore,\n\t\t)\n\n\tswitch (options.cardinality) {\n\t\tcase `1:1`: {\n\t\t\tconst findSingleRelatedKeyState = createSingleKeyStateFamily()\n\t\t\tconst stateKeyA = `${a}KeyOf${capitalize(b)}` as const\n\t\t\tconst stateKeyB = `${b}KeyOf${capitalize(a)}` as const\n\t\t\tconst findStateBase = {\n\t\t\t\t[stateKeyA]: findSingleRelatedKeyState,\n\t\t\t\t[stateKeyB]: findSingleRelatedKeyState,\n\t\t\t} as JoinState<ASide, BSide, Cardinality, Content>\n\t\t\tlet findState: JoinState<ASide, BSide, Cardinality, Content>\n\t\t\tif (defaultContent) {\n\t\t\t\tconst findSingleRelatedEntryState = createSingleEntryStateFamily()\n\t\t\t\tconst entriesStateKeyA = `${a}EntryOf${capitalize(b)}` as const\n\t\t\t\tconst entriesStateKeyB = `${b}EntryOf${capitalize(a)}` as const\n\t\t\t\tconst findStateWithContent = {\n\t\t\t\t\t[entriesStateKeyA]: findSingleRelatedEntryState,\n\t\t\t\t\t[entriesStateKeyB]: findSingleRelatedEntryState,\n\t\t\t\t}\n\t\t\t\tfindState = Object.assign(findStateBase, findStateWithContent)\n\t\t\t} else {\n\t\t\t\tfindState = findStateBase\n\t\t\t}\n\t\t\treturn {\n\t\t\t\trelations,\n\t\t\t\tfindState,\n\t\t\t}\n\t\t}\n\t\tcase `1:n`: {\n\t\t\tconst findSingleRelatedKeyState = createSingleKeyStateFamily()\n\t\t\tconst findMultipleRelatedKeysState = getMultipleKeyStateFamily()\n\t\t\tconst stateKeyA = `${a}KeyOf${capitalize(b)}` as const\n\t\t\tconst stateKeyB = `${b}KeysOf${capitalize(a)}` as const\n\t\t\tconst findStateBase = {\n\t\t\t\t[stateKeyA]: findSingleRelatedKeyState,\n\t\t\t\t[stateKeyB]: findMultipleRelatedKeysState,\n\t\t\t} as JoinState<ASide, BSide, Cardinality, Content>\n\t\t\tlet findState: JoinState<ASide, BSide, Cardinality, Content>\n\t\t\tif (defaultContent) {\n\t\t\t\tconst findSingleRelatedEntryState = createSingleEntryStateFamily()\n\t\t\t\tconst findMultipleRelatedEntriesState = getMultipleEntryStateFamily()\n\t\t\t\tconst entriesStateKeyA = `${a}EntryOf${capitalize(b)}` as const\n\t\t\t\tconst entriesStateKeyB = `${b}EntriesOf${capitalize(a)}` as const\n\t\t\t\tconst findStateWithContent = {\n\t\t\t\t\t[entriesStateKeyA]: findSingleRelatedEntryState,\n\t\t\t\t\t[entriesStateKeyB]: findMultipleRelatedEntriesState,\n\t\t\t\t}\n\t\t\t\tfindState = Object.assign(findStateBase, findStateWithContent)\n\t\t\t} else {\n\t\t\t\tfindState = findStateBase\n\t\t\t}\n\t\t\treturn {\n\t\t\t\trelations,\n\t\t\t\tfindState,\n\t\t\t}\n\t\t}\n\t\tcase `n:n`: {\n\t\t\tconst findMultipleRelatedKeysState = getMultipleKeyStateFamily()\n\t\t\tconst stateKeyA = `${a}KeysOf${capitalize(b)}` as const\n\t\t\tconst stateKeyB = `${b}KeysOf${capitalize(a)}` as const\n\t\t\tconst findStateBase = {\n\t\t\t\t[stateKeyA]: findMultipleRelatedKeysState,\n\t\t\t\t[stateKeyB]: findMultipleRelatedKeysState,\n\t\t\t} as JoinState<ASide, BSide, Cardinality, Content>\n\t\t\tlet findState: JoinState<ASide, BSide, Cardinality, Content>\n\t\t\tif (defaultContent) {\n\t\t\t\tconst findMultipleRelatedEntriesState = getMultipleEntryStateFamily()\n\t\t\t\tconst entriesStateKeyA = `${a}EntriesOf${capitalize(b)}` as const\n\t\t\t\tconst entriesStateKeyB = `${b}EntriesOf${capitalize(a)}` as const\n\t\t\t\tconst findStateWithContent = {\n\t\t\t\t\t[entriesStateKeyA]: findMultipleRelatedEntriesState,\n\t\t\t\t\t[entriesStateKeyB]: findMultipleRelatedEntriesState,\n\t\t\t\t}\n\t\t\t\tfindState = Object.assign(findStateBase, findStateWithContent)\n\t\t\t} else {\n\t\t\t\tfindState = findStateBase\n\t\t\t}\n\t\t\treturn {\n\t\t\t\trelations,\n\t\t\t\tfindState,\n\t\t\t}\n\t\t}\n\t\tdefault:\n\t\t\tthrow new Error(`Invalid cardinality: ${options.cardinality}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT } from \"atom.io/internal\"\n\nimport { createAtom, createSelector } from \"atom.io/internal\"\n\nconst capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)\n\nexport function struct<\n\tStruct extends { [key: string]: unknown },\n\tKey extends string,\n>(\n\toptions: {\n\t\tkey: Key\n\t\tdefault: Struct\n\t},\n\tstore: Store = IMPLICIT.STORE,\n): [\n\t{\n\t\t[K in keyof Struct as `${Key}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.AtomToken<Struct[K]>\n\t},\n\tAtomIO.ReadonlySelectorToken<Struct>,\n] {\n\tconst atoms: {\n\t\t[K in keyof Struct as `${Key}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.AtomToken<Struct[K]>\n\t} = Object.keys(options.default).reduce((acc, key) => {\n\t\tconst atomName = options.key + capitalize(key) + `State`\n\t\tacc[atomName] = createAtom(\n\t\t\t{\n\t\t\t\tkey: `${options.key}.${key}`,\n\t\t\t\tdefault: options.default[key],\n\t\t\t},\n\t\t\tundefined,\n\t\t\tstore,\n\t\t)\n\t\treturn acc\n\t}, {} as any)\n\tconst structState = createSelector(\n\t\t{\n\t\t\tkey: options.key,\n\t\t\tget: ({ get }) => {\n\t\t\t\treturn Object.keys(options.default).reduce((acc, key) => {\n\t\t\t\t\tacc[key] = get(atoms[options.key + capitalize(key) + `State`])\n\t\t\t\t\treturn acc\n\t\t\t\t}, {} as any)\n\t\t\t},\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\treturn [atoms, structState]\n}\n","import type * as AtomIO from \"atom.io\"\nimport {\n\tIMPLICIT,\n\tcreateAtomFamily,\n\tcreateSelectorFamily,\n} from \"atom.io/internal\"\n\nconst capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)\nconst nameFamily = (topKey: string, subKey: string) =>\n\t`find` + capitalize(topKey) + capitalize(subKey) + `State`\n\nexport function structFamily<\n\tStruct extends object,\n\tKey extends string,\n>(options: {\n\tkey: Key\n\tdefault: Struct\n}): [\n\t{\n\t\t[K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.AtomFamily<Struct[K], string>\n\t},\n\tAtomIO.ReadonlySelectorFamily<Struct>,\n] {\n\tconst atoms: {\n\t\t[K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.AtomFamily<Struct[K], string>\n\t} = Object.keys(options.default).reduce((acc, subKey) => {\n\t\tconst atomFamilyName = nameFamily(options.key, subKey)\n\t\tacc[atomFamilyName] = createAtomFamily(\n\t\t\t{\n\t\t\t\tkey: `${options.key}.${subKey}`,\n\t\t\t\tdefault: (options.default as any)[subKey],\n\t\t\t},\n\t\t\tIMPLICIT.STORE,\n\t\t)\n\t\treturn acc\n\t}, {} as any)\n\tconst findStructState = createSelectorFamily(\n\t\t{\n\t\t\tkey: options.key,\n\t\t\tget:\n\t\t\t\t(id) =>\n\t\t\t\t({ get }) => {\n\t\t\t\t\treturn Object.keys(options.default).reduce((acc, subKey) => {\n\t\t\t\t\t\tacc[subKey] = get(\n\t\t\t\t\t\t\t(atoms as any)[nameFamily(options.key, subKey)](id),\n\t\t\t\t\t\t)\n\t\t\t\t\t\treturn acc\n\t\t\t\t\t}, {} as any)\n\t\t\t\t},\n\t\t},\n\t\tIMPLICIT.STORE,\n\t)\n\treturn [atoms, findStructState]\n}\n","export type Loadable<T> = Promise<T> | T\nexport type Fated<T, E extends Error = Error> = Loadable<E | T>\n\n/**\n * Utility for handling loadable values\n * @param loadable Loadable value\n * @param fallback Fallback value until Loadable is resolved\n * @returns Fallback value if your loadable is a promise, otherwise the loadable's resolved value\n */\nexport function until<T>(loadable: Loadable<T>, fallback: T): T {\n\tif (loadable instanceof Promise) {\n\t\treturn fallback\n\t}\n\treturn loadable\n}\n"]}
1
+ {"version":3,"sources":["../src/dict.ts","../src/join.ts","../src/struct.ts","../src/struct-family.ts","../src/until.ts"],"names":["IMPLICIT","a","b","createSelector","capitalize","createAtomFamily","createSelectorFamily"],"mappings":";;;;;;AAEA,SAAS,UAAU,sBAAsB;AAGlC,SAAS,KACf,WAIA,OAIA,QAAe,SAAS,OAC2C;AACnE,SAAO;AAAA,IACN;AAAA,MACC,KAAK,GAAG,UAAU,GAAG;AAAA,MACrB,KAAK,CAAC,EAAE,IAAI,MAAM;AACjB,cAAM,OAAO,IAAI,KAAK;AACtB,eAAO,KAAK,OAAO,CAAC,KAAK,QAAQ;AAChC,cAAI,GAAG,IAAI,IAAI,UAAU,GAAG,CAAC;AAC7B,iBAAO;AAAA,QACR,GAAG,C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,UAAM,iBAAiB,WAAW,QAAQ,KAAK,MAAM;AACrD,QAAI,cAAc,IAAIC;AAAA,MACrB;AAAA,QACC,KAAK,GAAG,QAAQ,GAAG,IAAI,MAAM;AAAA,QAC7B,SAAU,QAAQ,QAAgB,MAAM;AAAA,MACzC;AAAA,MACAL,UAAS;AAAA,IACV;AACA,WAAO;AAAA,EACR,GAAG,CAAC,CAAQ;AACZ,QAAM,kBAAkBM;AAAA,IACvB;AAAA,MACC,KAAK,QAAQ;AAAA,MACb,KACC,CAAC,OACD,CAAC,EAAE,IAAI,MAAM;AACZ,eAAO,OAAO,KAAK,QAAQ,OAAO,EAAE,OAAO,CAAC,KAAK,WAAW;AAC3D,cAAI,MAAM,IAAI;AAAA,YACZ,MAAc,WAAW,QAAQ,KAAK,MAAM,CAAC,EAAE,EAAE;AAAA,UACnD;AACA,iBAAO;AAAA,QACR,GAAG,CAAC,CAAQ;AAAA,MACb;AAAA,IACF;AAAA,IACAN,UAAS;AAAA,EACV;AACA,SAAO,CAAC,OAAO,eAAe;AAC/B;;;AChDO,SAAS,MAAS,UAAuB,UAAgB;AAC/D,MAAI,oBAAoB,SAAS;AAChC,WAAO;AAAA,EACR;AACA,SAAO;AACR","sourcesContent":["import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createSelector } from \"atom.io/internal\"\nimport type { Json, Stringified } from \"atom.io/json\"\n\nexport function dict<State, Key extends Json.Serializable>(\n\tfindState:\n\t\t| AtomIO.AtomFamily<State, Key>\n\t\t| AtomIO.ReadonlySelectorFamily<State, Key>\n\t\t| AtomIO.SelectorFamily<State, Key>,\n\tindex:\n\t\t| AtomIO.AtomToken<Key[]>\n\t\t| AtomIO.ReadonlySelectorToken<Key[]>\n\t\t| AtomIO.SelectorToken<Key[]>,\n\tstore: Store = IMPLICIT.STORE,\n): AtomIO.ReadonlySelectorToken<{ [K in Stringified<Key>]: State }> {\n\treturn createSelector(\n\t\t{\n\t\t\tkey: `${findState.key}Dict`,\n\t\t\tget: ({ get }) => {\n\t\t\t\tconst keys = get(index)\n\t\t\t\treturn keys.reduce((acc, key) => {\n\t\t\t\t\tacc[key] = get(findState(key))\n\t\t\t\t\treturn acc\n\t\t\t\t}, {} as any)\n\t\t\t},\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n}\n","/* eslint-disable @typescript-eslint/ban-types */\nimport type {\n\tAtomFamily,\n\tRead,\n\tSelectorFamily,\n\tTransactors,\n\tWrite,\n} from \"atom.io\"\nimport { getState, setState } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tcreateAtomFamily,\n\tcreateMutableAtomFamily,\n\tcreateSelectorFamily,\n\tgetJsonFamily,\n} from \"atom.io/internal\"\nimport type { Json } from \"atom.io/json\"\nimport { SetRTX } from \"atom.io/transceivers/set-rtx\"\n\nimport type {\n\tBaseExternalStoreConfiguration,\n\tExternalStoreConfiguration,\n\tExternalStoreWithContentConfiguration,\n\tJunctionEntries,\n\tJunctionSchema,\n} from \"~/packages/rel8/junction/src\"\nimport { Junction } from \"~/packages/rel8/junction/src\"\nimport type * as Rel8 from \"~/packages/rel8/types/src\"\n\nconst TRANSACTORS: Transactors = { get: getState, set: setState }\n\nfunction capitalize<S extends string>(string: S): Capitalize<S> {\n\treturn (string[0].toUpperCase() + string.slice(1)) as Capitalize<S>\n}\n\nexport interface JoinOptions<\n\tASide extends string,\n\tBSide extends string,\n\tCardinality extends Rel8.Cardinality,\n\tContent extends Json.Object | null,\n> extends Json.Object,\n\t\tJunctionSchema<ASide, BSide>,\n\t\tPartial<JunctionEntries<Content>> {\n\treadonly key: string\n\treadonly cardinality: Cardinality\n}\n\nexport type JoinState<\n\tASide extends string,\n\tBSide extends string,\n\tCardinality extends Rel8.Cardinality,\n\tContent extends Json.Object | null,\n> = Cardinality extends `1:1`\n\t? (Content extends Json.Object\n\t\t\t? {\n\t\t\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t\t\t? `${AB}EntryOf${Capitalize<BSide>}`\n\t\t\t\t\t\t: `${AB}EntryOf${Capitalize<ASide>}`]: SelectorFamily<\n\t\t\t\t\t\t[string, Content] | undefined,\n\t\t\t\t\t\tstring\n\t\t\t\t\t>\n\t\t\t }\n\t\t\t: {}) & {\n\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t? `${AB}KeyOf${Capitalize<BSide>}`\n\t\t\t\t: `${AB}KeyOf${Capitalize<ASide>}`]: SelectorFamily<\n\t\t\t\tstring | undefined,\n\t\t\t\tstring\n\t\t\t>\n\t }\n\t: Cardinality extends `1:n`\n\t ? (Content extends Json.Object\n\t\t\t\t? {\n\t\t\t\t\t\treadonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: SelectorFamily<\n\t\t\t\t\t\t\t[string, Content] | undefined,\n\t\t\t\t\t\t\tstring\n\t\t\t\t\t\t>\n\t\t\t\t } & {\n\t\t\t\t\t\treadonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: SelectorFamily<\n\t\t\t\t\t\t\t[string, Content][],\n\t\t\t\t\t\t\tstring\n\t\t\t\t\t\t>\n\t\t\t\t }\n\t\t\t\t: {}) & {\n\t\t\t\treadonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: SelectorFamily<\n\t\t\t\t\tstring | undefined,\n\t\t\t\t\tstring\n\t\t\t\t>\n\t\t } & {\n\t\t\t\treadonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: SelectorFamily<\n\t\t\t\t\tstring[],\n\t\t\t\t\tstring\n\t\t\t\t>\n\t\t }\n\t : Cardinality extends `n:n`\n\t\t ? (Content extends Json.Object\n\t\t\t\t\t? {\n\t\t\t\t\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t\t\t\t\t? `${AB}EntriesOf${Capitalize<BSide>}`\n\t\t\t\t\t\t\t\t: `${AB}EntriesOf${Capitalize<ASide>}`]: SelectorFamily<\n\t\t\t\t\t\t\t\t[string, Content][],\n\t\t\t\t\t\t\t\tstring\n\t\t\t\t\t\t\t>\n\t\t\t\t\t }\n\t\t\t\t\t: {}) & {\n\t\t\t\t\treadonly [AB in ASide | BSide as AB extends ASide\n\t\t\t\t\t\t? `${AB}KeysOf${Capitalize<BSide>}`\n\t\t\t\t\t\t: `${AB}KeysOf${Capitalize<ASide>}`]: SelectorFamily<\n\t\t\t\t\t\tstring[],\n\t\t\t\t\t\tstring\n\t\t\t\t\t>\n\t\t\t }\n\t\t : never\n\nexport function join<\n\tconst ASide extends string,\n\tconst BSide extends string,\n\tconst Cardinality extends Rel8.Cardinality,\n>(\n\toptions: JoinOptions<ASide, BSide, Cardinality, null>,\n\tdefaultContent?: undefined,\n\tstore?: Store,\n): {\n\trelations: Junction<ASide, BSide>\n\tfindState: JoinState<ASide, BSide, Cardinality, null>\n}\nexport function join<\n\tconst ASide extends string,\n\tconst Cardinality extends `1:1` | `1:n` | `n:n`,\n\tconst BSide extends string,\n\tconst Content extends Json.Object,\n>(\n\toptions: JoinOptions<ASide, BSide, Cardinality, Content>,\n\tdefaultContent: Content,\n\tstore?: Store,\n): {\n\trelations: Junction<ASide, BSide, Content>\n\tfindState: JoinState<ASide, BSide, Cardinality, Content>\n}\nexport function join<\n\tASide extends string,\n\tBSide extends string,\n\tCardinality extends Rel8.Cardinality,\n\tContent extends Json.Object,\n>(\n\toptions: JoinOptions<ASide, BSide, Cardinality, Content>,\n\tdefaultContent: Content | undefined,\n\tstore: Store = IMPLICIT.STORE,\n): {\n\trelations: Junction<ASide, BSide, Content>\n\tfindState: JoinState<ASide, BSide, Cardinality, Content>\n} {\n\tconst a: ASide = options.between[0]\n\tconst b: BSide = options.between[1]\n\tconst findRelatedKeysState = createMutableAtomFamily<\n\t\tSetRTX<string>,\n\t\tstring[],\n\t\tstring\n\t>(\n\t\t{\n\t\t\tkey: `${options.key}/relatedKeys`,\n\t\t\tdefault: () => new SetRTX(),\n\t\t\tmutable: true,\n\t\t\tfromJson: (json) => new SetRTX(json),\n\t\t\ttoJson: (set) => [...set],\n\t\t},\n\t\tstore,\n\t)\n\tconst getRelatedKeys: Read<(key: string) => Set<string> | undefined> = (\n\t\t{ get },\n\t\tkey,\n\t) => get(findRelatedKeysState(key))\n\tconst addRelation: Write<(a: string, b: string) => void> = (\n\t\ttransactors,\n\t\ta,\n\t\tb,\n\t) => {\n\t\tconst aKeys = getRelatedKeys(transactors, a)\n\t\tconst bKeys = getRelatedKeys(transactors, b)\n\t\tif (aKeys) {\n\t\t\ttransactors.set(findRelatedKeysState(a), aKeys.add(b))\n\t\t} else {\n\t\t\ttransactors.set(findRelatedKeysState(a), new SetRTX([b]))\n\t\t}\n\t\tif (bKeys) {\n\t\t\ttransactors.set(findRelatedKeysState(b), bKeys.add(a))\n\t\t} else {\n\t\t\ttransactors.set(findRelatedKeysState(b), new SetRTX([a]))\n\t\t}\n\t}\n\tconst deleteRelation: Write<(a: string, b: string) => void> = (\n\t\ttransactors,\n\t\ta,\n\t\tb,\n\t) => {\n\t\tconst aKeys = getRelatedKeys(transactors, a)\n\t\tif (aKeys) {\n\t\t\taKeys.delete(b)\n\t\t\tif (aKeys.size === 0) {\n\t\t\t\ttransactors.set(findRelatedKeysState(a), undefined)\n\t\t\t}\n\t\t\tconst bKeys = getRelatedKeys(transactors, b)\n\t\t\tif (bKeys) {\n\t\t\t\tbKeys.delete(a)\n\t\t\t\tif (bKeys.size === 0) {\n\t\t\t\t\ttransactors.set(findRelatedKeysState(b), undefined)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tconst replaceRelationsSafely: Write<(a: string, bs: string[]) => void> = (\n\t\ttransactors,\n\t\ta,\n\t\tbs,\n\t) => {\n\t\tconst aRelations = getRelatedKeys(transactors, a)\n\t\tif (aRelations) {\n\t\t\tfor (const b of aRelations) {\n\t\t\t\tconst bKeys = getRelatedKeys(transactors, b)\n\t\t\t\tif (bKeys) {\n\t\t\t\t\tbKeys.delete(a)\n\t\t\t\t\tif (bKeys.size === 0) {\n\t\t\t\t\t\ttransactors.set(findRelatedKeysState(b), undefined)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttransactors.set(findRelatedKeysState(a), new SetRTX(bs))\n\t\tfor (const b of bs) {\n\t\t\tconst bKeys = getRelatedKeys(transactors, b)\n\t\t\tif (bKeys) {\n\t\t\t\tbKeys.add(a)\n\t\t\t} else {\n\t\t\t\ttransactors.set(findRelatedKeysState(b), new SetRTX([a]))\n\t\t\t}\n\t\t}\n\t}\n\tconst replaceRelationsUnsafely: Write<(a: string, bs: string[]) => void> = (\n\t\ttransactors,\n\t\ta,\n\t\tbs,\n\t) => {\n\t\ttransactors.set(findRelatedKeysState(a), new SetRTX(bs))\n\t\tfor (const b of bs) {\n\t\t\tlet bKeys = getRelatedKeys(transactors, b)\n\t\t\tif (bKeys) {\n\t\t\t\tbKeys.add(a)\n\t\t\t} else {\n\t\t\t\tbKeys = new SetRTX([a])\n\t\t\t\ttransactors.set(findRelatedKeysState(b), bKeys)\n\t\t\t}\n\t\t}\n\t}\n\tconst has: Read<(a: string, b?: string) => boolean> = (transactors, a, b) => {\n\t\tconst aKeys = getRelatedKeys(transactors, a)\n\t\treturn b ? aKeys?.has(b) ?? false : (aKeys?.size ?? 0) > 0 ?? false\n\t}\n\tconst baseExternalStoreConfiguration: BaseExternalStoreConfiguration = {\n\t\tgetRelatedKeys: (key) => getRelatedKeys(TRANSACTORS, key),\n\t\taddRelation: (a, b) => addRelation(TRANSACTORS, a, b),\n\t\tdeleteRelation: (a, b) => deleteRelation(TRANSACTORS, a, b),\n\t\treplaceRelationsSafely: (a, bs) =>\n\t\t\treplaceRelationsSafely(TRANSACTORS, a, bs),\n\t\treplaceRelationsUnsafely: (a, bs) =>\n\t\t\treplaceRelationsUnsafely(TRANSACTORS, a, bs),\n\t\thas: (a, b) => has(TRANSACTORS, a, b),\n\t}\n\tlet externalStore: ExternalStoreConfiguration<Content>\n\tlet findContentState: AtomFamily<Content, string>\n\tif (defaultContent) {\n\t\tfindContentState = createAtomFamily<Content, string>(\n\t\t\t{\n\t\t\t\tkey: `${options.key}/content`,\n\t\t\t\tdefault: defaultContent,\n\t\t\t},\n\t\t\tstore,\n\t\t)\n\t\tconst getContent: Read<(key: string) => Content | undefined> = (\n\t\t\t{ get },\n\t\t\tkey,\n\t\t) => get(findContentState(key))\n\t\tconst setContent: Write<(key: string, content: Content) => void> = (\n\t\t\ttransactors,\n\t\t\tkey,\n\t\t\tcontent,\n\t\t) => transactors.set(findContentState(key), content)\n\t\tconst deleteContent: Write<(key: string) => void> = (transactors, key) =>\n\t\t\ttransactors.set(findContentState(key), undefined)\n\t\tconst externalStoreWithContentConfiguration: ExternalStoreWithContentConfiguration<Content> =\n\t\t\t{\n\t\t\t\tgetContent: (contentKey: string) => {\n\t\t\t\t\tconst content = getContent(TRANSACTORS, contentKey)\n\t\t\t\t\treturn content\n\t\t\t\t},\n\t\t\t\tsetContent: (contentKey: string, content: Content) => {\n\t\t\t\t\tsetContent(TRANSACTORS, contentKey, content)\n\t\t\t\t},\n\t\t\t\tdeleteContent: (contentKey: string) => {\n\t\t\t\t\tdeleteContent(TRANSACTORS, contentKey)\n\t\t\t\t},\n\t\t\t}\n\t\texternalStore = Object.assign(\n\t\t\tbaseExternalStoreConfiguration,\n\t\t\texternalStoreWithContentConfiguration,\n\t\t) as ExternalStoreConfiguration<Content>\n\t} else {\n\t\texternalStore =\n\t\t\tbaseExternalStoreConfiguration as ExternalStoreConfiguration<Content>\n\t}\n\tconst relations = new Junction<ASide, BSide, Content>(options, {\n\t\texternalStore,\n\t\tmakeContentKey: (...args) => args.sort().join(`:`),\n\t})\n\n\tconst createSingleKeyStateFamily = () =>\n\t\tcreateSelectorFamily<string | undefined, string>(\n\t\t\t{\n\t\t\t\tkey: `${options.key}/singleRelatedKey`,\n\t\t\t\tget:\n\t\t\t\t\t(key) =>\n\t\t\t\t\t({ get }) => {\n\t\t\t\t\t\tconst relatedKeys = get(findRelatedKeysState(key))\n\t\t\t\t\t\tfor (const relatedKey of relatedKeys) {\n\t\t\t\t\t\t\treturn relatedKey\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t},\n\t\t\tstore,\n\t\t)\n\tconst getMultipleKeyStateFamily = () =>\n\t\tgetJsonFamily(findRelatedKeysState, store)\n\tconst createSingleEntryStateFamily = () =>\n\t\tcreateSelectorFamily<[string, Content] | undefined, string>(\n\t\t\t{\n\t\t\t\tkey: `${options.key}/singleRelatedEntry`,\n\t\t\t\tget:\n\t\t\t\t\t(key) =>\n\t\t\t\t\t({ get }) => {\n\t\t\t\t\t\tconst relatedKeys = get(findRelatedKeysState(key))\n\t\t\t\t\t\tfor (const relatedKey of relatedKeys) {\n\t\t\t\t\t\t\tconst contentKey = relations.makeContentKey(key, relatedKey)\n\t\t\t\t\t\t\treturn [relatedKey, get(findContentState(contentKey))]\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t},\n\t\t\tstore,\n\t\t)\n\tconst getMultipleEntryStateFamily = () =>\n\t\tcreateSelectorFamily<[string, Content][], string>(\n\t\t\t{\n\t\t\t\tkey: `${options.key}/multipleRelatedEntries`,\n\t\t\t\tget:\n\t\t\t\t\t(key) =>\n\t\t\t\t\t({ get }) => {\n\t\t\t\t\t\tconst relatedKeys = get(findRelatedKeysState(key))\n\t\t\t\t\t\treturn [...relatedKeys].map((relatedKey) => {\n\t\t\t\t\t\t\tconst contentKey = relations.makeContentKey(key, relatedKey)\n\t\t\t\t\t\t\treturn [relatedKey, get(findContentState(contentKey))]\n\t\t\t\t\t\t})\n\t\t\t\t\t},\n\t\t\t},\n\t\t\tstore,\n\t\t)\n\n\tswitch (options.cardinality) {\n\t\tcase `1:1`: {\n\t\t\tconst findSingleRelatedKeyState = createSingleKeyStateFamily()\n\t\t\tconst stateKeyA = `${a}KeyOf${capitalize(b)}` as const\n\t\t\tconst stateKeyB = `${b}KeyOf${capitalize(a)}` as const\n\t\t\tconst findStateBase = {\n\t\t\t\t[stateKeyA]: findSingleRelatedKeyState,\n\t\t\t\t[stateKeyB]: findSingleRelatedKeyState,\n\t\t\t} as JoinState<ASide, BSide, Cardinality, Content>\n\t\t\tlet findState: JoinState<ASide, BSide, Cardinality, Content>\n\t\t\tif (defaultContent) {\n\t\t\t\tconst findSingleRelatedEntryState = createSingleEntryStateFamily()\n\t\t\t\tconst entriesStateKeyA = `${a}EntryOf${capitalize(b)}` as const\n\t\t\t\tconst entriesStateKeyB = `${b}EntryOf${capitalize(a)}` as const\n\t\t\t\tconst findStateWithContent = {\n\t\t\t\t\t[entriesStateKeyA]: findSingleRelatedEntryState,\n\t\t\t\t\t[entriesStateKeyB]: findSingleRelatedEntryState,\n\t\t\t\t}\n\t\t\t\tfindState = Object.assign(findStateBase, findStateWithContent)\n\t\t\t} else {\n\t\t\t\tfindState = findStateBase\n\t\t\t}\n\t\t\treturn {\n\t\t\t\trelations,\n\t\t\t\tfindState,\n\t\t\t}\n\t\t}\n\t\tcase `1:n`: {\n\t\t\tconst findSingleRelatedKeyState = createSingleKeyStateFamily()\n\t\t\tconst findMultipleRelatedKeysState = getMultipleKeyStateFamily()\n\t\t\tconst stateKeyA = `${a}KeyOf${capitalize(b)}` as const\n\t\t\tconst stateKeyB = `${b}KeysOf${capitalize(a)}` as const\n\t\t\tconst findStateBase = {\n\t\t\t\t[stateKeyA]: findSingleRelatedKeyState,\n\t\t\t\t[stateKeyB]: findMultipleRelatedKeysState,\n\t\t\t} as JoinState<ASide, BSide, Cardinality, Content>\n\t\t\tlet findState: JoinState<ASide, BSide, Cardinality, Content>\n\t\t\tif (defaultContent) {\n\t\t\t\tconst findSingleRelatedEntryState = createSingleEntryStateFamily()\n\t\t\t\tconst findMultipleRelatedEntriesState = getMultipleEntryStateFamily()\n\t\t\t\tconst entriesStateKeyA = `${a}EntryOf${capitalize(b)}` as const\n\t\t\t\tconst entriesStateKeyB = `${b}EntriesOf${capitalize(a)}` as const\n\t\t\t\tconst findStateWithContent = {\n\t\t\t\t\t[entriesStateKeyA]: findSingleRelatedEntryState,\n\t\t\t\t\t[entriesStateKeyB]: findMultipleRelatedEntriesState,\n\t\t\t\t}\n\t\t\t\tfindState = Object.assign(findStateBase, findStateWithContent)\n\t\t\t} else {\n\t\t\t\tfindState = findStateBase\n\t\t\t}\n\t\t\treturn {\n\t\t\t\trelations,\n\t\t\t\tfindState,\n\t\t\t}\n\t\t}\n\t\tcase `n:n`: {\n\t\t\tconst findMultipleRelatedKeysState = getMultipleKeyStateFamily()\n\t\t\tconst stateKeyA = `${a}KeysOf${capitalize(b)}` as const\n\t\t\tconst stateKeyB = `${b}KeysOf${capitalize(a)}` as const\n\t\t\tconst findStateBase = {\n\t\t\t\t[stateKeyA]: findMultipleRelatedKeysState,\n\t\t\t\t[stateKeyB]: findMultipleRelatedKeysState,\n\t\t\t} as JoinState<ASide, BSide, Cardinality, Content>\n\t\t\tlet findState: JoinState<ASide, BSide, Cardinality, Content>\n\t\t\tif (defaultContent) {\n\t\t\t\tconst findMultipleRelatedEntriesState = getMultipleEntryStateFamily()\n\t\t\t\tconst entriesStateKeyA = `${a}EntriesOf${capitalize(b)}` as const\n\t\t\t\tconst entriesStateKeyB = `${b}EntriesOf${capitalize(a)}` as const\n\t\t\t\tconst findStateWithContent = {\n\t\t\t\t\t[entriesStateKeyA]: findMultipleRelatedEntriesState,\n\t\t\t\t\t[entriesStateKeyB]: findMultipleRelatedEntriesState,\n\t\t\t\t}\n\t\t\t\tfindState = Object.assign(findStateBase, findStateWithContent)\n\t\t\t} else {\n\t\t\t\tfindState = findStateBase\n\t\t\t}\n\t\t\treturn {\n\t\t\t\trelations,\n\t\t\t\tfindState,\n\t\t\t}\n\t\t}\n\t\tdefault:\n\t\t\tthrow new Error(`Invalid cardinality: ${options.cardinality}`)\n\t}\n}\n","import type * as AtomIO from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT } from \"atom.io/internal\"\n\nimport { createAtom, createSelector } from \"atom.io/internal\"\n\nconst capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)\n\nexport function struct<\n\tStruct extends { [key: string]: unknown },\n\tKey extends string,\n>(\n\toptions: {\n\t\tkey: Key\n\t\tdefault: Struct\n\t},\n\tstore: Store = IMPLICIT.STORE,\n): [\n\t{\n\t\t[K in keyof Struct as `${Key}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.AtomToken<Struct[K]>\n\t},\n\tAtomIO.ReadonlySelectorToken<Struct>,\n] {\n\tconst atoms: {\n\t\t[K in keyof Struct as `${Key}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.AtomToken<Struct[K]>\n\t} = Object.keys(options.default).reduce((acc, key) => {\n\t\tconst atomName = options.key + capitalize(key) + `State`\n\t\tacc[atomName] = createAtom(\n\t\t\t{\n\t\t\t\tkey: `${options.key}.${key}`,\n\t\t\t\tdefault: options.default[key],\n\t\t\t},\n\t\t\tundefined,\n\t\t\tstore,\n\t\t)\n\t\treturn acc\n\t}, {} as any)\n\tconst structState = createSelector(\n\t\t{\n\t\t\tkey: options.key,\n\t\t\tget: ({ get }) => {\n\t\t\t\treturn Object.keys(options.default).reduce((acc, key) => {\n\t\t\t\t\tacc[key] = get(atoms[options.key + capitalize(key) + `State`])\n\t\t\t\t\treturn acc\n\t\t\t\t}, {} as any)\n\t\t\t},\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\treturn [atoms, structState]\n}\n","import type * as AtomIO from \"atom.io\"\nimport {\n\tIMPLICIT,\n\tcreateAtomFamily,\n\tcreateSelectorFamily,\n} from \"atom.io/internal\"\n\nconst capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)\nconst nameFamily = (topKey: string, subKey: string) =>\n\t`find` + capitalize(topKey) + capitalize(subKey) + `State`\n\nexport function structFamily<\n\tStruct extends object,\n\tKey extends string,\n>(options: {\n\tkey: Key\n\tdefault: Struct\n}): [\n\t{\n\t\t[K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.AtomFamily<Struct[K], string>\n\t},\n\tAtomIO.ReadonlySelectorFamily<Struct>,\n] {\n\tconst atoms: {\n\t\t[K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<\n\t\t\tK & string\n\t\t>}State`]: AtomIO.AtomFamily<Struct[K], string>\n\t} = Object.keys(options.default).reduce((acc, subKey) => {\n\t\tconst atomFamilyName = nameFamily(options.key, subKey)\n\t\tacc[atomFamilyName] = createAtomFamily(\n\t\t\t{\n\t\t\t\tkey: `${options.key}.${subKey}`,\n\t\t\t\tdefault: (options.default as any)[subKey],\n\t\t\t},\n\t\t\tIMPLICIT.STORE,\n\t\t)\n\t\treturn acc\n\t}, {} as any)\n\tconst findStructState = createSelectorFamily(\n\t\t{\n\t\t\tkey: options.key,\n\t\t\tget:\n\t\t\t\t(id) =>\n\t\t\t\t({ get }) => {\n\t\t\t\t\treturn Object.keys(options.default).reduce((acc, subKey) => {\n\t\t\t\t\t\tacc[subKey] = get(\n\t\t\t\t\t\t\t(atoms as any)[nameFamily(options.key, subKey)](id),\n\t\t\t\t\t\t)\n\t\t\t\t\t\treturn acc\n\t\t\t\t\t}, {} as any)\n\t\t\t\t},\n\t\t},\n\t\tIMPLICIT.STORE,\n\t)\n\treturn [atoms, findStructState]\n}\n","export type Loadable<T> = Promise<T> | T\nexport type Fated<T, E extends Error = Error> = Loadable<E | T>\n\n/**\n * Utility for handling loadable values\n * @param loadable Loadable value\n * @param fallback Fallback value until Loadable is resolved\n * @returns Fallback value if your loadable is a promise, otherwise the loadable's resolved value\n */\nexport function until<T>(loadable: Loadable<T>, fallback: T): T {\n\tif (loadable instanceof Promise) {\n\t\treturn fallback\n\t}\n\treturn loadable\n}\n"]}