atom.io 0.14.3 → 0.14.5
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.
- package/data/dist/index.cjs +47 -1416
- package/data/dist/index.cjs.map +1 -1
- package/data/dist/index.d.cts +8 -134
- package/data/dist/index.d.ts +8 -134
- package/data/dist/index.js +4 -6
- package/data/dist/index.js.map +1 -1
- package/dist/chunk-NYTGCPHB.js +261 -0
- package/dist/chunk-NYTGCPHB.js.map +1 -0
- package/dist/chunk-PZLG2HP3.js +36 -0
- package/dist/chunk-PZLG2HP3.js.map +1 -0
- package/dist/chunk-XACXFU3B.js +46 -0
- package/dist/chunk-XACXFU3B.js.map +1 -0
- package/dist/index.cjs +55 -2330
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +152 -1
- package/dist/index.js.map +1 -1
- package/internal/dist/index.cjs +30 -159
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.cts +8 -211
- package/internal/dist/index.d.ts +8 -211
- package/internal/dist/index.js +2027 -1
- package/internal/dist/index.js.map +1 -1
- package/introspection/dist/index.cjs +45 -1565
- package/introspection/dist/index.cjs.map +1 -1
- package/introspection/dist/index.d.cts +2 -129
- package/introspection/dist/index.d.ts +2 -129
- package/introspection/dist/index.js +298 -2
- package/introspection/dist/index.js.map +1 -1
- package/json/dist/index.cjs +5 -1502
- package/json/dist/index.cjs.map +1 -1
- package/json/dist/index.d.cts +5 -131
- package/json/dist/index.d.ts +5 -131
- package/json/dist/index.js +37 -1
- package/json/dist/index.js.map +1 -1
- package/package.json +1 -2
- package/react/dist/index.cjs +30 -1571
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.cts +8 -136
- package/react/dist/index.d.ts +8 -136
- package/react/dist/index.js +62 -2
- package/react/dist/index.js.map +1 -1
- package/react/src/store-hooks.ts +18 -20
- package/react-devtools/dist/index.cjs +135 -2153
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.d.cts +20 -146
- package/react-devtools/dist/index.d.ts +20 -146
- package/react-devtools/dist/index.js +5 -3
- package/react-devtools/dist/index.js.map +1 -1
- package/realtime-client/dist/index.cjs +34 -1529
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.cts +11 -138
- package/realtime-client/dist/index.d.ts +11 -138
- package/realtime-client/dist/index.js +165 -2
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-react/dist/index.cjs +35 -1727
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.cts +7 -35
- package/realtime-react/dist/index.d.ts +7 -35
- package/realtime-react/dist/index.js +66 -4
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-server/dist/index.cjs +57 -1548
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.cts +15 -153
- package/realtime-server/dist/index.d.ts +15 -153
- package/realtime-server/dist/index.js +21 -27
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-testing/dist/index.cjs +15 -2376
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.d.cts +3 -489
- package/realtime-testing/dist/index.d.ts +3 -489
- package/realtime-testing/dist/index.js +10 -9
- package/realtime-testing/dist/index.js.map +1 -1
- package/transceivers/set-rtx/dist/index.cjs +9 -31
- package/transceivers/set-rtx/dist/index.cjs.map +1 -1
- package/transceivers/set-rtx/dist/index.d.cts +7 -7
- package/transceivers/set-rtx/dist/index.d.ts +7 -7
- package/transceivers/set-rtx/dist/index.js +3 -2
- package/transceivers/set-rtx/dist/index.js.map +1 -1
- package/dist/chunk-C4YZZNRH.js +0 -67
- package/dist/chunk-C4YZZNRH.js.map +0 -1
- package/dist/chunk-CWKKQKVQ.js +0 -68
- package/dist/chunk-CWKKQKVQ.js.map +0 -1
- package/dist/chunk-GMN5KH6A.js +0 -309
- package/dist/chunk-GMN5KH6A.js.map +0 -1
- package/dist/chunk-N7ADBQJG.js +0 -176
- package/dist/chunk-N7ADBQJG.js.map +0 -1
- package/dist/chunk-PURABO5G.js +0 -2581
- package/dist/chunk-PURABO5G.js.map +0 -1
- package/dist/index.d.cts +0 -493
- package/dist/index.d.ts +0 -493
- package/dist/metafile-cjs.json +0 -1
- package/dist/metafile-esm.json +0 -1
package/data/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import * as AtomIO from 'atom.io';
|
|
2
|
+
import { FamilyMetadata, ƒn, TransactionUpdate, MutableAtomToken, AtomToken, StateToken, TimelineUpdate, StateUpdate, AtomFamily, ReadonlySelectorFamily, SelectorFamily, ReadonlySelectorToken, SelectorToken, TransactionToken, TimelineToken, AtomIOLogger, Logger } from 'atom.io';
|
|
3
|
+
|
|
1
4
|
declare class Subject<T> {
|
|
2
5
|
Subscriber: (value: T) => void;
|
|
3
6
|
subscribers: Map<string, this[`Subscriber`]>;
|
|
@@ -249,136 +252,7 @@ type Atom<T> = {
|
|
|
249
252
|
cleanup?: () => void;
|
|
250
253
|
};
|
|
251
254
|
|
|
252
|
-
|
|
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<{
|
|
255
|
+
declare function dict<State, Key extends 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<{
|
|
382
256
|
[K in Stringified<Key>]: State;
|
|
383
257
|
}>;
|
|
384
258
|
|
|
@@ -431,9 +305,9 @@ declare function struct<Struct extends {
|
|
|
431
305
|
default: Struct;
|
|
432
306
|
}, store?: Store): [
|
|
433
307
|
{
|
|
434
|
-
[K in keyof Struct as `${Key}${Capitalize<K & string>}State`]: AtomToken<Struct[K]>;
|
|
308
|
+
[K in keyof Struct as `${Key}${Capitalize<K & string>}State`]: AtomIO.AtomToken<Struct[K]>;
|
|
435
309
|
},
|
|
436
|
-
ReadonlySelectorToken<Struct>
|
|
310
|
+
AtomIO.ReadonlySelectorToken<Struct>
|
|
437
311
|
];
|
|
438
312
|
|
|
439
313
|
declare function structFamily<Struct extends object, Key extends string>(options: {
|
|
@@ -441,9 +315,9 @@ declare function structFamily<Struct extends object, Key extends string>(options
|
|
|
441
315
|
default: Struct;
|
|
442
316
|
}): [
|
|
443
317
|
{
|
|
444
|
-
[K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<K & string>}State`]: AtomFamily<Struct[K], string>;
|
|
318
|
+
[K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<K & string>}State`]: AtomIO.AtomFamily<Struct[K], string>;
|
|
445
319
|
},
|
|
446
|
-
ReadonlySelectorFamily<Struct>
|
|
320
|
+
AtomIO.ReadonlySelectorFamily<Struct>
|
|
447
321
|
];
|
|
448
322
|
|
|
449
323
|
type Loadable<T> = Promise<T> | T;
|
package/data/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import * as AtomIO from 'atom.io';
|
|
2
|
+
import { FamilyMetadata, ƒn, TransactionUpdate, MutableAtomToken, AtomToken, StateToken, TimelineUpdate, StateUpdate, AtomFamily, ReadonlySelectorFamily, SelectorFamily, ReadonlySelectorToken, SelectorToken, TransactionToken, TimelineToken, AtomIOLogger, Logger } from 'atom.io';
|
|
3
|
+
|
|
1
4
|
declare class Subject<T> {
|
|
2
5
|
Subscriber: (value: T) => void;
|
|
3
6
|
subscribers: Map<string, this[`Subscriber`]>;
|
|
@@ -249,136 +252,7 @@ type Atom<T> = {
|
|
|
249
252
|
cleanup?: () => void;
|
|
250
253
|
};
|
|
251
254
|
|
|
252
|
-
|
|
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<{
|
|
255
|
+
declare function dict<State, Key extends 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<{
|
|
382
256
|
[K in Stringified<Key>]: State;
|
|
383
257
|
}>;
|
|
384
258
|
|
|
@@ -431,9 +305,9 @@ declare function struct<Struct extends {
|
|
|
431
305
|
default: Struct;
|
|
432
306
|
}, store?: Store): [
|
|
433
307
|
{
|
|
434
|
-
[K in keyof Struct as `${Key}${Capitalize<K & string>}State`]: AtomToken<Struct[K]>;
|
|
308
|
+
[K in keyof Struct as `${Key}${Capitalize<K & string>}State`]: AtomIO.AtomToken<Struct[K]>;
|
|
435
309
|
},
|
|
436
|
-
ReadonlySelectorToken<Struct>
|
|
310
|
+
AtomIO.ReadonlySelectorToken<Struct>
|
|
437
311
|
];
|
|
438
312
|
|
|
439
313
|
declare function structFamily<Struct extends object, Key extends string>(options: {
|
|
@@ -441,9 +315,9 @@ declare function structFamily<Struct extends object, Key extends string>(options
|
|
|
441
315
|
default: Struct;
|
|
442
316
|
}): [
|
|
443
317
|
{
|
|
444
|
-
[K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<K & string>}State`]: AtomFamily<Struct[K], string>;
|
|
318
|
+
[K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<K & string>}State`]: AtomIO.AtomFamily<Struct[K], string>;
|
|
445
319
|
},
|
|
446
|
-
ReadonlySelectorFamily<Struct>
|
|
320
|
+
AtomIO.ReadonlySelectorFamily<Struct>
|
|
447
321
|
];
|
|
448
322
|
|
|
449
323
|
type Loadable<T> = Promise<T> | T;
|
package/data/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
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) {
|
package/data/dist/index.js.map
CHANGED
|
@@ -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;AAAA,IACA;AAAA,EACD;AACD;;;ACZA,SAAS,cAAc;AAYvB,IAAM,cAA2B,EAAE,KAAK,UAAU,KAAK,SAAS;AAEhE,SAAS,WAA6B,QAA0B;AAC/D,SAAQ,OAAO,CAAC,EAAE,YAAY,IAAI,OAAO,MAAM,CAAC;AACjD;AA0GO,SAAS,KAMf,SACA,gBACA,QAAe,SAAS,OAIvB;AACD,QAAM,IAAW,QAAQ,QAAQ,CAAC;AAClC,QAA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,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,CAAC,CAAQ;AAAA,MACb;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;;;ACtBA,SAAS,UAAU,gBAAgB;AAEnC;AAAA,EACC,YAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,SAAS,cAAc;AAYvB,IAAM,cAA2B,EAAE,KAAK,UAAU,KAAK,SAAS;AAEhE,SAAS,WAA6B,QAA0B;AAC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;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"]}
|