atom.io 0.31.1 → 0.32.0
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.d.ts +867 -101
- package/data/dist/index.js +10 -558
- package/data/src/index.ts +0 -2
- package/data/src/struct-family.ts +1 -1
- package/data/src/struct.ts +1 -2
- package/dist/chunk-354XQWHH.js +153 -0
- package/dist/chunk-4LWKCEW3.js +14 -0
- package/dist/chunk-5F2V7S3B.js +83 -0
- package/dist/chunk-ECOMOMUN.js +631 -0
- package/dist/{chunk-Y5MBNTVU.js → chunk-GY2XQYZY.js} +1791 -703
- package/dist/chunk-NF7FJKJD.js +107 -0
- package/dist/chunk-R3ZUK5EH.js +1024 -0
- package/dist/chunk-Z2UJW4NQ.js +523 -0
- package/dist/index.d.ts +622 -26
- package/dist/index.js +1 -228
- package/eslint-plugin/dist/index.d.ts +1 -30
- package/eslint-plugin/dist/index.js +0 -146
- package/eslint-plugin/src/index.ts +0 -1
- package/eslint-plugin/src/rules/index.ts +0 -1
- package/internal/dist/index.d.ts +783 -64
- package/internal/dist/index.js +1 -1
- package/internal/src/atom/create-regular-atom.ts +3 -3
- package/internal/src/atom/dispose-atom.ts +4 -13
- package/internal/src/atom/is-default.ts +3 -3
- package/internal/src/caching.ts +5 -5
- package/internal/src/capitalize.ts +3 -0
- package/internal/src/families/create-readonly-selector-family.ts +5 -6
- package/internal/src/families/create-writable-selector-family.ts +1 -4
- package/internal/src/families/dispose-from-store.ts +3 -13
- package/internal/src/get-state/get-from-store.ts +2 -2
- package/internal/src/get-state/read-or-compute-value.ts +1 -1
- package/internal/src/index.ts +2 -0
- package/internal/src/install-into-store.ts +1 -1
- package/internal/src/join/edit-relations-in-store.ts +32 -0
- package/internal/src/join/find-relations-in-store.ts +124 -0
- package/internal/src/join/get-internal-relations-from-store.ts +14 -0
- package/internal/src/join/get-join.ts +31 -0
- package/internal/src/join/index.ts +5 -0
- package/{data/src/join.ts → internal/src/join/join-internal.ts} +20 -429
- package/internal/src/keys.ts +7 -7
- package/internal/src/mutable/create-mutable-atom-family.ts +1 -1
- package/internal/src/mutable/create-mutable-atom.ts +3 -3
- package/internal/src/mutable/get-json-token.ts +1 -1
- package/internal/src/mutable/tracker-family.ts +19 -17
- package/internal/src/mutable/tracker.ts +8 -8
- package/internal/src/pretty-print.ts +1 -1
- package/internal/src/selector/create-readonly-selector.ts +3 -7
- package/internal/src/selector/create-writable-selector.ts +4 -4
- package/internal/src/selector/dispose-selector.ts +20 -11
- package/internal/src/selector/get-selector-dependency-keys.ts +1 -1
- package/internal/src/selector/register-selector.ts +6 -9
- package/internal/src/selector/trace-selector-atoms.ts +2 -2
- package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
- package/internal/src/set-state/emit-update.ts +1 -1
- package/internal/src/set-state/evict-downstream.ts +1 -1
- package/internal/src/set-state/set-atom-or-selector.ts +1 -1
- package/internal/src/set-state/set-atom.ts +10 -10
- package/internal/src/set-state/set-into-store.ts +2 -2
- package/internal/src/set-state/stow-update.ts +1 -1
- package/internal/src/store/store.ts +1 -1
- package/internal/src/store/withdraw.ts +22 -22
- package/internal/src/subscribe/recall-state.ts +1 -1
- package/internal/src/subscribe/subscribe-in-store.ts +3 -3
- package/internal/src/subscribe/subscribe-to-root-atoms.ts +3 -3
- package/internal/src/subscribe/subscribe-to-state.ts +5 -5
- package/internal/src/subscribe/subscribe-to-timeline.ts +3 -3
- package/internal/src/subscribe/subscribe-to-transaction.ts +3 -3
- package/internal/src/timeline/create-timeline.ts +17 -37
- package/internal/src/transaction/act-upon-store.ts +2 -2
- package/internal/src/transaction/apply-transaction.ts +5 -5
- package/internal/src/transaction/assign-transaction-to-continuity.ts +1 -1
- package/internal/src/transaction/build-transaction.ts +5 -8
- package/internal/src/transaction/create-transaction.ts +3 -3
- package/internal/src/transaction/get-epoch-number.ts +3 -3
- package/internal/src/transaction/set-epoch-number.ts +2 -2
- package/introspection/dist/index.d.ts +922 -6
- package/introspection/dist/index.js +2 -620
- package/json/dist/index.d.ts +899 -5
- package/json/dist/index.js +1 -80
- package/json/src/select-json-family.ts +3 -14
- package/package.json +24 -42
- package/react/dist/index.d.ts +921 -3
- package/react/dist/index.js +2 -82
- package/react/src/use-o.ts +1 -1
- package/react/src/use-tl.ts +2 -2
- package/react-devtools/dist/index.css +16 -14
- package/react-devtools/dist/index.d.ts +26 -1
- package/react-devtools/dist/index.js +6 -6
- package/react-devtools/src/devtools.scss +16 -14
- package/realtime/dist/index.d.ts +202 -8
- package/realtime/dist/index.js +2 -107
- package/realtime/src/realtime-continuity.ts +2 -2
- package/realtime/src/shared-room-store.ts +1 -2
- package/realtime-client/dist/index.d.ts +960 -22
- package/realtime-client/dist/index.js +3 -509
- package/realtime-client/src/continuity/register-and-attempt-confirmed-update.ts +3 -3
- package/realtime-client/src/continuity/use-conceal-state.ts +1 -1
- package/realtime-client/src/pull-atom-family-member.ts +2 -2
- package/realtime-client/src/pull-atom.ts +2 -2
- package/realtime-client/src/pull-mutable-atom-family-member.ts +2 -2
- package/realtime-client/src/pull-mutable-atom.ts +2 -2
- package/realtime-client/src/pull-selector-family-member.ts +4 -4
- package/realtime-client/src/pull-selector.ts +4 -4
- package/realtime-client/src/push-state.ts +5 -10
- package/realtime-client/src/server-action.ts +4 -4
- package/realtime-client/src/sync-continuity.ts +6 -6
- package/realtime-react/dist/index.d.ts +166 -12
- package/realtime-react/dist/index.js +5 -154
- package/realtime-react/src/use-pull-atom-family-member.ts +1 -1
- package/realtime-react/src/use-pull-atom.ts +1 -1
- package/realtime-react/src/use-pull-mutable-atom.ts +1 -1
- package/realtime-react/src/use-pull-mutable-family-member.ts +1 -1
- package/realtime-react/src/use-pull-selector-family-member.ts +1 -1
- package/realtime-react/src/use-pull-selector.ts +1 -1
- package/realtime-react/src/use-push.ts +1 -1
- package/realtime-react/src/use-server-action.ts +2 -2
- package/realtime-react/src/use-sync-continuity.ts +1 -1
- package/realtime-server/dist/index.d.ts +971 -28
- package/realtime-server/dist/index.js +3 -1001
- package/realtime-server/src/continuity/prepare-to-serve-transaction-request.ts +1 -1
- package/realtime-server/src/continuity/prepare-to-sync-realtime-continuity.ts +3 -3
- package/realtime-server/src/continuity/subscribe-to-continuity-actions.ts +2 -2
- package/realtime-server/src/continuity/subscribe-to-continuity-perpectives.ts +2 -2
- package/realtime-server/src/realtime-action-receiver.ts +1 -1
- package/realtime-server/src/realtime-family-provider.ts +2 -2
- package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
- package/realtime-server/src/realtime-mutable-provider.ts +2 -2
- package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +2 -1
- package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +1 -1
- package/realtime-server/src/realtime-server-stores/server-user-store.ts +1 -2
- package/realtime-server/src/realtime-state-provider.ts +2 -2
- package/realtime-testing/dist/index.d.ts +1091 -3
- package/realtime-testing/dist/index.js +20 -22
- package/realtime-testing/src/setup-realtime-test.tsx +2 -1
- package/src/index.ts +4 -0
- package/src/join.ts +218 -0
- package/src/silo.ts +4 -4
- package/src/timeline.ts +1 -1
- package/src/transaction.ts +4 -8
- package/transceivers/set-rtx/dist/index.d.ts +37 -2
- package/transceivers/set-rtx/dist/index.js +1 -215
- package/web/dist/index.d.ts +30 -1
- package/web/dist/index.js +1 -15
- package/data/src/until.ts +0 -15
- package/ephemeral/dist/index.d.ts +0 -67
- package/ephemeral/dist/index.js +0 -9
- package/ephemeral/package.json +0 -13
- package/ephemeral/src/index.ts +0 -1
- package/eslint-plugin/src/rules/lifespan.ts +0 -203
- package/immortal/dist/index.d.ts +0 -12
- package/immortal/dist/index.js +0 -9
- package/immortal/package.json +0 -13
- package/immortal/src/index.ts +0 -1
- package/immortal/src/seek-state.ts +0 -60
- /package/{ephemeral/src → src}/find-state.ts +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,478 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
type primitive = boolean | number | string | null;
|
|
2
|
+
declare namespace Json {
|
|
3
|
+
namespace Tree {
|
|
4
|
+
type Array<Element = unknown> = ReadonlyArray<Element>;
|
|
5
|
+
type Object<K extends string = string, V = unknown> = Record<K, V>;
|
|
6
|
+
type Fork = Array | Object;
|
|
7
|
+
type Leaf = primitive;
|
|
8
|
+
type Node = Fork | Leaf;
|
|
9
|
+
}
|
|
10
|
+
type Serializable = primitive | Readonly<{
|
|
11
|
+
[key: string]: Serializable;
|
|
12
|
+
}> | ReadonlyArray<Serializable>;
|
|
13
|
+
type Object<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
|
|
14
|
+
type Array<Element extends Serializable = Serializable> = ReadonlyArray<Element>;
|
|
15
|
+
}
|
|
16
|
+
type stringified<J extends Json.Serializable> = J extends string ? `"${J}"` : J extends number ? `${J}` : J extends true ? `true` : J extends false ? `false` : J extends boolean ? `false` | `true` : J extends null ? `null` : string & {
|
|
17
|
+
__json?: J;
|
|
18
|
+
};
|
|
19
|
+
type Canonical = primitive | ReadonlyArray<Canonical>;
|
|
20
|
+
type JsonInterface<T, J extends Json.Serializable = Json.Serializable> = {
|
|
21
|
+
toJson: (t: T) => J;
|
|
22
|
+
fromJson: (json: J) => T;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
declare class CircularBuffer<T> {
|
|
26
|
+
protected _buffer: T[];
|
|
27
|
+
protected _index: number;
|
|
28
|
+
constructor(array: T[]);
|
|
29
|
+
constructor(length: number);
|
|
30
|
+
get buffer(): ReadonlyArray<T | undefined>;
|
|
31
|
+
get index(): number;
|
|
32
|
+
add(item: T): void;
|
|
33
|
+
copy(): CircularBuffer<T>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type Func = (...parameters: any[]) => any;
|
|
37
|
+
type Flat<R extends {
|
|
38
|
+
[K in PropertyKey]: any;
|
|
39
|
+
}> = {
|
|
40
|
+
[K in keyof R]: R[K];
|
|
41
|
+
};
|
|
42
|
+
type Count<N extends number, A extends any[] = []> = [
|
|
43
|
+
...A,
|
|
44
|
+
any
|
|
45
|
+
][`length`] extends N ? A[`length`] : A[`length`] | Count<N, [...A, any]>;
|
|
46
|
+
type Each<E extends any[]> = {
|
|
47
|
+
[P in Count<E[`length`]>]: E[P];
|
|
48
|
+
};
|
|
49
|
+
type Refinement<A, B extends A> = (a: A) => a is B;
|
|
50
|
+
|
|
51
|
+
type JunctionEntriesBase<AType extends string, BType extends string, Content extends Json.Object | null> = {
|
|
52
|
+
readonly relations: ([AType, BType[]] | [BType, AType[]])[];
|
|
53
|
+
readonly contents: [string, Content][];
|
|
54
|
+
};
|
|
55
|
+
interface JunctionEntries<AType extends string, BType extends string, Content extends Json.Object | null> extends Json.Object, JunctionEntriesBase<AType, BType, Content> {
|
|
56
|
+
}
|
|
57
|
+
type JunctionSchemaBase<ASide extends string, BSide extends string> = {
|
|
58
|
+
readonly between: [a: ASide, b: BSide];
|
|
59
|
+
readonly cardinality: `1:1` | `1:n` | `n:n`;
|
|
60
|
+
};
|
|
61
|
+
interface JunctionSchema<ASide extends string, BSide extends string> extends Json.Object, JunctionSchemaBase<ASide, BSide> {
|
|
62
|
+
}
|
|
63
|
+
type BaseExternalStoreConfiguration = {
|
|
64
|
+
addRelation: (a: string, b: string) => void;
|
|
65
|
+
deleteRelation: (a: string, b: string) => void;
|
|
66
|
+
replaceRelationsSafely: (a: string, bs: string[]) => void;
|
|
67
|
+
replaceRelationsUnsafely: (a: string, bs: string[]) => void;
|
|
68
|
+
getRelatedKeys(key: string): Set<string> | undefined;
|
|
69
|
+
has: (a: string, b?: string) => boolean;
|
|
70
|
+
};
|
|
71
|
+
type ExternalStoreWithContentConfiguration<Content extends Json.Object> = {
|
|
72
|
+
getContent: (contentKey: string) => Content | undefined;
|
|
73
|
+
setContent: (contentKey: string, content: Content) => void;
|
|
74
|
+
deleteContent: (contentKey: string) => void;
|
|
75
|
+
};
|
|
76
|
+
type Empty<Obj extends object> = {
|
|
77
|
+
[Key in keyof Obj]?: undefined;
|
|
78
|
+
};
|
|
79
|
+
type ExternalStoreConfiguration<Content extends Json.Object | null> = Content extends Json.Object ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Json.Object>>;
|
|
80
|
+
type JunctionAdvancedConfiguration<AType extends string, BType extends string, Content extends Json.Object | null> = {
|
|
81
|
+
warn?: (...args: any[]) => void;
|
|
82
|
+
externalStore?: ExternalStoreConfiguration<Content>;
|
|
83
|
+
isAType?: Refinement<string, AType>;
|
|
84
|
+
isBType?: Refinement<string, BType>;
|
|
85
|
+
isContent?: Refinement<unknown, Content>;
|
|
86
|
+
makeContentKey?: (a: AType, b: BType) => string;
|
|
87
|
+
};
|
|
88
|
+
type JunctionJSON<ASide extends string, AType extends string, BSide extends string, BType extends string, Content extends Json.Object | null> = JunctionEntries<AType, BType, Content> & JunctionSchema<ASide, BSide>;
|
|
89
|
+
declare class Junction<const ASide extends string, const AType extends string, const BSide extends string, const BType extends string, const Content extends Json.Object | null = null> {
|
|
90
|
+
readonly a: ASide;
|
|
91
|
+
readonly b: BSide;
|
|
92
|
+
readonly cardinality: `1:1` | `1:n` | `n:n`;
|
|
93
|
+
readonly relations: Map<AType | BType, Set<AType> | Set<BType>>;
|
|
94
|
+
readonly contents: Map<string, Content>;
|
|
95
|
+
isAType?: Refinement<string, AType> | null;
|
|
96
|
+
isBType?: Refinement<string, BType> | null;
|
|
97
|
+
isContent: Refinement<unknown, Content> | null;
|
|
98
|
+
makeContentKey: (a: AType, b: BType) => string;
|
|
99
|
+
warn?: (...args: any[]) => void;
|
|
100
|
+
getRelatedKeys(key: AType): Set<BType> | undefined;
|
|
101
|
+
getRelatedKeys(key: BType): Set<AType> | undefined;
|
|
102
|
+
getRelatedKeys(key: AType | BType): Set<AType> | Set<BType> | undefined;
|
|
103
|
+
protected addRelation(a: AType, b: BType): void;
|
|
104
|
+
protected deleteRelation(a: AType, b: BType): void;
|
|
105
|
+
protected replaceRelationsUnsafely(a: AType, bs: BType[]): void;
|
|
106
|
+
protected replaceRelationsUnsafely(b: BType, as: AType[]): void;
|
|
107
|
+
protected replaceRelationsSafely(a: AType, bs: BType[]): void;
|
|
108
|
+
protected replaceRelationsSafely(b: BType, as: AType[]): void;
|
|
109
|
+
protected getContentInternal(contentKey: string): Content | undefined;
|
|
110
|
+
protected setContent(contentKey: string, content: Content): void;
|
|
111
|
+
protected deleteContent(contentKey: string): void;
|
|
112
|
+
constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<NoInfer<AType>, NoInfer<BType>, Content>>, config?: JunctionAdvancedConfiguration<AType, BType, Content>);
|
|
113
|
+
toJSON(): JunctionJSON<ASide, AType, BSide, BType, Content>;
|
|
114
|
+
set(a: AType, ...rest: Content extends null ? [b: BType] : [b: BType, content: Content]): this;
|
|
115
|
+
set(relation: {
|
|
116
|
+
[Key in ASide]: AType;
|
|
117
|
+
} & {
|
|
118
|
+
[Key in BSide]: BType;
|
|
119
|
+
}, ...rest: Content extends null ? [] | [void?: undefined] : [content: Content]): this;
|
|
120
|
+
delete(a: AType, b?: BType): this;
|
|
121
|
+
delete(b: BType, a?: AType): this;
|
|
122
|
+
delete(relation: {
|
|
123
|
+
[Key in ASide]: AType;
|
|
124
|
+
} | {
|
|
125
|
+
[Key in BSide]: BType;
|
|
126
|
+
} | ({
|
|
127
|
+
[Key in ASide]: AType;
|
|
128
|
+
} & {
|
|
129
|
+
[Key in BSide]: BType;
|
|
130
|
+
}), b?: undefined): this;
|
|
131
|
+
getRelatedKey(key: AType): BType | undefined;
|
|
132
|
+
getRelatedKey(key: BType): AType | undefined;
|
|
133
|
+
replaceRelations(a: AType, relations: Content extends null ? BType[] : Record<BType, Content>, config?: {
|
|
134
|
+
reckless: boolean;
|
|
135
|
+
}): this;
|
|
136
|
+
replaceRelations(b: BType, relations: Content extends null ? AType[] : Record<AType, Content>, config?: {
|
|
137
|
+
reckless: boolean;
|
|
138
|
+
}): this;
|
|
139
|
+
getContent(a: AType, b: BType): Content | undefined;
|
|
140
|
+
getRelationEntries(input: Record<ASide, AType>): [BType, Content][];
|
|
141
|
+
getRelationEntries(input: Record<BSide, BType>): [AType, Content][];
|
|
142
|
+
has(a: AType, b?: BType): boolean;
|
|
143
|
+
has(b: BType, a?: AType): boolean;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare class Subject<T> {
|
|
147
|
+
Subscriber: (value: T) => void;
|
|
148
|
+
subscribers: Map<string, this[`Subscriber`]>;
|
|
149
|
+
subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
|
|
150
|
+
private unsubscribe;
|
|
151
|
+
next(value: T): void;
|
|
152
|
+
}
|
|
153
|
+
declare class StatefulSubject<T> extends Subject<T> {
|
|
154
|
+
state: T;
|
|
155
|
+
constructor(initialState: T);
|
|
156
|
+
next(value: T): void;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
type Transaction<F extends Func> = {
|
|
160
|
+
key: string;
|
|
161
|
+
type: `transaction`;
|
|
162
|
+
install: (store: Store) => void;
|
|
163
|
+
subject: Subject<TransactionUpdate<F>>;
|
|
164
|
+
run: (parameters: Parameters<F>, id?: string) => ReturnType<F>;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
type TransactionProgress<F extends Func> = {
|
|
168
|
+
phase: `applying` | `building`;
|
|
169
|
+
update: TransactionUpdate<F>;
|
|
170
|
+
toolkit: ActorToolkit;
|
|
171
|
+
};
|
|
172
|
+
type TransactionEpoch = {
|
|
173
|
+
epoch: Map<string, number>;
|
|
174
|
+
actionContinuities: Junction<`continuity`, string, `action`, string>;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
type SetUpdate = `add:${string}` | `clear:${string}` | `del:${string}` | `tx:${string}`;
|
|
178
|
+
type NumberedSetUpdate = `${number}=${SetUpdate}`;
|
|
179
|
+
interface SetRTXJson<P extends primitive> extends Json.Object {
|
|
180
|
+
members: P[];
|
|
181
|
+
cache: (NumberedSetUpdate | null)[];
|
|
182
|
+
cacheLimit: number;
|
|
183
|
+
cacheIdx: number;
|
|
184
|
+
cacheUpdateNumber: number;
|
|
185
|
+
}
|
|
186
|
+
declare class SetRTX<P extends primitive> extends Set<P> implements Transceiver<NumberedSetUpdate>, Lineage {
|
|
187
|
+
mode: TransceiverMode;
|
|
188
|
+
readonly subject: Subject<SetUpdate>;
|
|
189
|
+
cacheLimit: number;
|
|
190
|
+
cache: (NumberedSetUpdate | null)[];
|
|
191
|
+
cacheIdx: number;
|
|
192
|
+
cacheUpdateNumber: number;
|
|
193
|
+
constructor(values?: Iterable<P>, cacheLimit?: number);
|
|
194
|
+
toJSON(): SetRTXJson<P>;
|
|
195
|
+
static fromJSON<P extends primitive>(json: SetRTXJson<P>): SetRTX<P>;
|
|
196
|
+
add(value: P): this;
|
|
197
|
+
clear(): void;
|
|
198
|
+
delete(value: P): boolean;
|
|
199
|
+
readonly parent: SetRTX<P> | null;
|
|
200
|
+
child: SetRTX<P> | null;
|
|
201
|
+
transactionUpdates: SetUpdate[] | null;
|
|
202
|
+
transaction(run: (child: SetRTX<P>) => boolean): void;
|
|
203
|
+
protected _subscribe(key: string, fn: (update: SetUpdate) => void): () => void;
|
|
204
|
+
subscribe(key: string, fn: (update: NumberedSetUpdate) => void): () => void;
|
|
205
|
+
emit(update: SetUpdate): void;
|
|
206
|
+
private doStep;
|
|
207
|
+
getUpdateNumber(update: NumberedSetUpdate): number;
|
|
208
|
+
do(update: NumberedSetUpdate): number | `OUT_OF_RANGE` | null;
|
|
209
|
+
undoStep(update: SetUpdate): void;
|
|
210
|
+
undo(update: NumberedSetUpdate): number | null;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
type Molecule<K extends Canonical> = {
|
|
214
|
+
readonly key: K;
|
|
215
|
+
readonly stringKey: stringified<K>;
|
|
216
|
+
readonly dependsOn: `all` | `any`;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
type JoinStateFamilies<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null> = Cardinality extends `1:1` ? (Content extends Json.Object ? {
|
|
220
|
+
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<[
|
|
221
|
+
AType,
|
|
222
|
+
Content
|
|
223
|
+
] | null, BType>;
|
|
224
|
+
} & {
|
|
225
|
+
readonly [B in BSide as `${B}EntryOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<[
|
|
226
|
+
BType,
|
|
227
|
+
Content
|
|
228
|
+
] | null, AType>;
|
|
229
|
+
} : {}) & {
|
|
230
|
+
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<AType | null, BType>;
|
|
231
|
+
} & {
|
|
232
|
+
readonly [B in BSide as `${B}KeyOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<BType | null, AType>;
|
|
233
|
+
} : Cardinality extends `1:n` ? (Content extends Json.Object ? {
|
|
234
|
+
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<[
|
|
235
|
+
AType,
|
|
236
|
+
Content
|
|
237
|
+
] | null, BType>;
|
|
238
|
+
} & {
|
|
239
|
+
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<[
|
|
240
|
+
BType,
|
|
241
|
+
Content
|
|
242
|
+
][], AType>;
|
|
243
|
+
} : {}) & {
|
|
244
|
+
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<AType | null, BType>;
|
|
245
|
+
} & {
|
|
246
|
+
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<BType[], AType>;
|
|
247
|
+
} : Cardinality extends `n:n` ? (Content extends Json.Object ? {
|
|
248
|
+
readonly [A in ASide as `${A}EntriesOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<[
|
|
249
|
+
AType,
|
|
250
|
+
Content
|
|
251
|
+
][], BType>;
|
|
252
|
+
} & {
|
|
253
|
+
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<[
|
|
254
|
+
BType,
|
|
255
|
+
Content
|
|
256
|
+
][], AType>;
|
|
257
|
+
} : {}) & {
|
|
258
|
+
readonly [A in ASide as `${A}KeysOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<AType[], BType>;
|
|
259
|
+
} & {
|
|
260
|
+
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<BType[], AType>;
|
|
261
|
+
} : never;
|
|
262
|
+
declare class Join<const ASide extends string, const AType extends string, const BSide extends string, const BType extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const Content extends Json.Object | null = null, const ContentKey extends CompoundTypedKey<`content`, ASide, BSide> = CompoundTypedKey<`content`, ASide, BSide>> {
|
|
263
|
+
private toolkit;
|
|
264
|
+
options: JoinOptions<ASide, AType, BSide, BType, Cardinality, Content>;
|
|
265
|
+
defaultContent: Content | undefined;
|
|
266
|
+
molecules: Map<string, Molecule<any>>;
|
|
267
|
+
relations: Junction<ASide, AType, BSide, BType, Content>;
|
|
268
|
+
states: JoinStateFamilies<ASide, AType, BSide, BType, Cardinality, Content>;
|
|
269
|
+
core: {
|
|
270
|
+
relatedKeysAtoms: MutableAtomFamilyToken<SetRTX<string>, SetRTXJson<string>, string>;
|
|
271
|
+
};
|
|
272
|
+
transact(toolkit: SetterToolkit, run: (join: Join<ASide, AType, BSide, BType, Cardinality, Content>) => void): void;
|
|
273
|
+
store: Store;
|
|
274
|
+
realm: Anarchy;
|
|
275
|
+
[Symbol.dispose](): void;
|
|
276
|
+
constructor(options: JoinOptions<ASide, AType, BSide, BType, Cardinality, Content>, defaultContent: Content | undefined, store?: Store);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
interface Lineage {
|
|
280
|
+
parent: typeof this | null;
|
|
281
|
+
child: typeof this | null;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
type OperationProgress = {
|
|
285
|
+
open: false;
|
|
286
|
+
} | {
|
|
287
|
+
open: true;
|
|
288
|
+
done: Set<string>;
|
|
289
|
+
prev: Map<string, any>;
|
|
290
|
+
time: number;
|
|
291
|
+
token: WritableToken<any>;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
type TimelineAtomUpdate<ManagedAtom extends TimelineManageable> = Flat<StateUpdate<TokenType<ManagedAtom>> & {
|
|
295
|
+
key: string;
|
|
296
|
+
type: `atom_update`;
|
|
297
|
+
timestamp: number;
|
|
298
|
+
family?: FamilyMetadata;
|
|
299
|
+
}>;
|
|
300
|
+
type TimelineSelectorUpdate<ManagedAtom extends TimelineManageable> = {
|
|
301
|
+
key: string;
|
|
302
|
+
type: `selector_update`;
|
|
303
|
+
timestamp: number;
|
|
304
|
+
atomUpdates: Omit<TimelineAtomUpdate<ManagedAtom>, `timestamp`>[];
|
|
305
|
+
};
|
|
306
|
+
type TimelineTransactionUpdate = Flat<TransactionUpdate<Func> & {
|
|
307
|
+
key: string;
|
|
308
|
+
type: `transaction_update`;
|
|
309
|
+
timestamp: number;
|
|
310
|
+
}>;
|
|
311
|
+
type TimelineStateCreation<T extends ReadableToken<any>> = Flat<StateCreation<T> & {
|
|
312
|
+
timestamp: number;
|
|
313
|
+
}>;
|
|
314
|
+
type TimelineStateDisposal<T extends ReadableToken<any>> = Flat<StateDisposal<T> & {
|
|
315
|
+
timestamp: number;
|
|
316
|
+
}>;
|
|
317
|
+
type TimelineMoleculeCreation = Flat<MoleculeCreation & {
|
|
318
|
+
timestamp: number;
|
|
319
|
+
}>;
|
|
320
|
+
type TimelineMoleculeDisposal = Flat<MoleculeDisposal & {
|
|
321
|
+
timestamp: number;
|
|
322
|
+
}>;
|
|
323
|
+
type Timeline<ManagedAtom extends TimelineManageable> = {
|
|
324
|
+
type: `timeline`;
|
|
325
|
+
key: string;
|
|
326
|
+
at: number;
|
|
327
|
+
shouldCapture?: (update: TimelineUpdate<ManagedAtom>, timeline: Timeline<ManagedAtom>) => boolean;
|
|
328
|
+
timeTraveling: `into_future` | `into_past` | null;
|
|
329
|
+
history: TimelineUpdate<ManagedAtom>[];
|
|
330
|
+
selectorTime: number | null;
|
|
331
|
+
transactionKey: string | null;
|
|
332
|
+
install: (store: Store) => void;
|
|
333
|
+
subject: Subject<TimelineUpdate<ManagedAtom> | `redo` | `undo`>;
|
|
334
|
+
subscriptions: Map<string, () => void>;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
declare class Store implements Lineage {
|
|
338
|
+
parent: Store | null;
|
|
339
|
+
child: Store | null;
|
|
340
|
+
valueMap: Map<string, any>;
|
|
341
|
+
defaults: Map<string, any>;
|
|
342
|
+
atoms: Map<string, Atom<any>>;
|
|
343
|
+
selectors: Map<string, WritableSelector<any>>;
|
|
344
|
+
readonlySelectors: Map<string, ReadonlySelector<any>>;
|
|
345
|
+
atomsThatAreDefault: Set<string>;
|
|
346
|
+
selectorAtoms: Junction<"selectorKey", string, "atomKey", string, null>;
|
|
347
|
+
selectorGraph: Junction<"upstreamSelectorKey", string, "downstreamSelectorKey", string, {
|
|
348
|
+
source: string;
|
|
349
|
+
}>;
|
|
350
|
+
trackers: Map<string, Tracker<Transceiver<any>>>;
|
|
351
|
+
families: Map<string, MutableAtomFamily<any, any, any> | ReadonlySelectorFamily<any, any> | RegularAtomFamily<any, any> | WritableSelectorFamily<any, any>>;
|
|
352
|
+
joins: Map<string, Join<any, any, any, any, any, any, `T$--content==${any}::${string}++${any}::${string}`>>;
|
|
353
|
+
transactions: Map<string, Transaction<Func>>;
|
|
354
|
+
transactionMeta: TransactionEpoch | TransactionProgress<Func>;
|
|
355
|
+
timelines: Map<string, Timeline<any>>;
|
|
356
|
+
timelineTopics: Junction<"timelineKey", string, "topicKey", string, {
|
|
357
|
+
topicType: `atom_family` | `atom` | `molecule_family` | `molecule`;
|
|
358
|
+
}>;
|
|
359
|
+
disposalTraces: CircularBuffer<{
|
|
360
|
+
key: string;
|
|
361
|
+
trace: string;
|
|
362
|
+
}>;
|
|
363
|
+
molecules: Map<string, Molecule<Canonical>>;
|
|
364
|
+
moleculeJoins: Junction<"moleculeKey", stringified<Canonical>, "joinKey", string, null>;
|
|
365
|
+
moleculeGraph: Junction<"upstreamMoleculeKey", stringified<Canonical> | "root", "downstreamMoleculeKey", stringified<Canonical>, {
|
|
366
|
+
source: stringified<Canonical>;
|
|
367
|
+
}>;
|
|
368
|
+
moleculeData: Junction<"moleculeKey", stringified<Canonical>, "stateFamilyKey", string, null>;
|
|
369
|
+
miscResources: Map<string, Disposable>;
|
|
370
|
+
on: {
|
|
371
|
+
atomCreation: Subject<AtomToken<unknown>>;
|
|
372
|
+
atomDisposal: Subject<AtomToken<unknown>>;
|
|
373
|
+
selectorCreation: Subject<ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>>;
|
|
374
|
+
selectorDisposal: Subject<ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>>;
|
|
375
|
+
timelineCreation: Subject<TimelineToken<unknown>>;
|
|
376
|
+
transactionCreation: Subject<TransactionToken<Func>>;
|
|
377
|
+
transactionApplying: StatefulSubject<TransactionProgress<Func> | null>;
|
|
378
|
+
operationClose: Subject<OperationProgress>;
|
|
379
|
+
moleculeCreation: Subject<MoleculeCreation>;
|
|
380
|
+
moleculeDisposal: Subject<MoleculeDisposal>;
|
|
381
|
+
};
|
|
382
|
+
operation: OperationProgress;
|
|
383
|
+
config: {
|
|
384
|
+
name: string;
|
|
385
|
+
lifespan: `ephemeral` | `immortal`;
|
|
386
|
+
};
|
|
387
|
+
loggers: AtomIOLogger[];
|
|
388
|
+
logger: Logger;
|
|
389
|
+
constructor(config: Store[`config`], store?: Store | null);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
interface Transceiver<S extends Json.Serializable> {
|
|
393
|
+
do: (update: S) => number | `OUT_OF_RANGE` | null;
|
|
394
|
+
undo: (update: S) => void;
|
|
395
|
+
subscribe: (key: string, fn: (update: S) => void) => () => void;
|
|
396
|
+
cacheUpdateNumber: number;
|
|
397
|
+
getUpdateNumber: (update: S) => number;
|
|
398
|
+
}
|
|
399
|
+
type TransceiverMode = `playback` | `record` | `transaction`;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* @internal Give the tracker a transceiver state and a store, and it will
|
|
403
|
+
* subscribe to the transceiver's inner value. When the inner value changes,
|
|
404
|
+
* the tracker will update its own state to reflect the change.
|
|
405
|
+
*/
|
|
406
|
+
declare class Tracker<Mutable extends Transceiver<any>> {
|
|
407
|
+
private Update;
|
|
408
|
+
private initializeState;
|
|
409
|
+
private unsubscribeFromInnerValue;
|
|
410
|
+
private unsubscribeFromState;
|
|
411
|
+
private observeCore;
|
|
412
|
+
private updateCore;
|
|
413
|
+
mutableState: MutableAtomToken<Mutable, Json.Serializable>;
|
|
414
|
+
latestUpdateState: RegularAtomToken<typeof this.Update | null>;
|
|
415
|
+
[Symbol.dispose]: () => void;
|
|
416
|
+
constructor(mutableState: MutableAtomToken<Mutable, Json.Serializable>, store: Store);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
type EnvironmentData = {
|
|
420
|
+
store: Store;
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
type AtomIOState = {
|
|
424
|
+
key: string;
|
|
425
|
+
family?: FamilyMetadata;
|
|
426
|
+
install: (store: Store) => void;
|
|
427
|
+
subject: Subject<{
|
|
428
|
+
newValue: any;
|
|
429
|
+
oldValue: any;
|
|
430
|
+
}>;
|
|
431
|
+
};
|
|
432
|
+
type RegularAtom<T> = AtomIOState & {
|
|
433
|
+
type: `atom`;
|
|
434
|
+
default: T | (() => T);
|
|
435
|
+
cleanup?: () => void;
|
|
436
|
+
};
|
|
437
|
+
type MutableAtom<T extends Transceiver<any>, J extends Json.Serializable> = AtomIOState & JsonInterface<T, J> & {
|
|
438
|
+
type: `mutable_atom`;
|
|
439
|
+
default: T | (() => T);
|
|
440
|
+
cleanup?: () => void;
|
|
441
|
+
};
|
|
442
|
+
type Atom<T> = RegularAtom<T> | (T extends Transceiver<any> ? MutableAtom<T, any> : never);
|
|
443
|
+
type WritableSelector<T> = AtomIOState & {
|
|
444
|
+
type: `selector`;
|
|
445
|
+
get: () => T;
|
|
446
|
+
set: (newValue: T | ((oldValue: T) => T)) => void;
|
|
447
|
+
};
|
|
448
|
+
type ReadonlySelector<T> = AtomIOState & {
|
|
449
|
+
type: `readonly_selector`;
|
|
450
|
+
get: () => T;
|
|
451
|
+
};
|
|
452
|
+
type RegularAtomFamily<T, K extends Canonical> = RegularAtomFamilyToken<T, K> & {
|
|
453
|
+
(key: K): RegularAtomToken<T>;
|
|
454
|
+
subject: Subject<StateCreation<AtomToken<T>> | StateDisposal<AtomToken<T>>>;
|
|
455
|
+
install: (store: Store) => void;
|
|
456
|
+
internalRoles: string[] | undefined;
|
|
457
|
+
};
|
|
458
|
+
type MutableAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical> = JsonInterface<T, J> & MutableAtomFamilyToken<T, J, K> & {
|
|
459
|
+
(key: K): MutableAtomToken<T, J>;
|
|
460
|
+
subject: Subject<StateCreation<MutableAtomToken<T, J>> | StateDisposal<MutableAtomToken<T, J>>>;
|
|
461
|
+
install: (store: Store) => void;
|
|
462
|
+
internalRoles: string[] | undefined;
|
|
463
|
+
};
|
|
464
|
+
type WritableSelectorFamily<T, K extends Canonical> = WritableSelectorFamilyToken<T, K> & ((key: K) => WritableSelectorToken<T>) & {
|
|
465
|
+
default: (key: K) => T;
|
|
466
|
+
subject: Subject<StateCreation<WritableSelectorToken<T>> | StateDisposal<WritableSelectorToken<T>>>;
|
|
467
|
+
install: (store: Store) => void;
|
|
468
|
+
internalRoles: string[] | undefined;
|
|
469
|
+
};
|
|
470
|
+
type ReadonlySelectorFamily<T, K extends Canonical> = ReadonlySelectorFamilyToken<T, K> & ((key: K) => ReadonlySelectorToken<T>) & {
|
|
471
|
+
default: (key: K) => T;
|
|
472
|
+
subject: Subject<StateCreation<ReadonlySelectorToken<T>> | StateDisposal<ReadonlySelectorToken<T>>>;
|
|
473
|
+
install: (store: Store) => void;
|
|
474
|
+
internalRoles: string[] | undefined;
|
|
475
|
+
};
|
|
6
476
|
|
|
7
477
|
/**
|
|
8
478
|
* @public
|
|
@@ -139,19 +609,17 @@ type TransactionUpdate<F extends Func> = {
|
|
|
139
609
|
params: Parameters<F>;
|
|
140
610
|
output: ReturnType<F>;
|
|
141
611
|
};
|
|
142
|
-
type GetterToolkit = Pick<SetterToolkit, `find` | `get` | `json
|
|
612
|
+
type GetterToolkit = Pick<SetterToolkit, `find` | `get` | `json`>;
|
|
143
613
|
type SetterToolkit = Readonly<{
|
|
144
|
-
get: typeof getState
|
|
145
|
-
set: typeof setState
|
|
614
|
+
get: typeof getState;
|
|
615
|
+
set: typeof setState;
|
|
146
616
|
find: typeof findState;
|
|
147
|
-
seek: typeof seekState;
|
|
148
617
|
json: <T extends Transceiver<any>, J extends Json.Serializable>(state: MutableAtomToken<T, J>) => WritableSelectorToken<J>;
|
|
149
618
|
}>;
|
|
150
619
|
type ActorToolkit = Readonly<{
|
|
151
|
-
get: typeof getState
|
|
152
|
-
set: typeof setState
|
|
620
|
+
get: typeof getState;
|
|
621
|
+
set: typeof setState;
|
|
153
622
|
find: typeof findState;
|
|
154
|
-
seek: typeof seekState;
|
|
155
623
|
json: <T extends Transceiver<any>, J extends Json.Serializable>(state: MutableAtomToken<T, J>) => WritableSelectorToken<J>;
|
|
156
624
|
dispose: typeof disposeState;
|
|
157
625
|
run: typeof runTransaction;
|
|
@@ -255,6 +723,68 @@ declare function disposeState(token: ReadableToken<any>): void;
|
|
|
255
723
|
*/
|
|
256
724
|
declare function disposeState<K extends Canonical>(token: ReadableFamilyToken<any, K>, key: K): void;
|
|
257
725
|
|
|
726
|
+
/**
|
|
727
|
+
* @public
|
|
728
|
+
* Finds a {@link MutableAtomToken} in the store
|
|
729
|
+
* @param token - A {@link MutableAtomFamilyToken}
|
|
730
|
+
* @param key - The key of the state
|
|
731
|
+
* @returns
|
|
732
|
+
* The current value of the state
|
|
733
|
+
* @overload Mutable Atom
|
|
734
|
+
*/
|
|
735
|
+
declare function findState<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical, Key extends K>(token: MutableAtomFamilyToken<T, J, K>, key: Key): MutableAtomToken<T, J, K>;
|
|
736
|
+
/**
|
|
737
|
+
* @public
|
|
738
|
+
* Finds a state in the store
|
|
739
|
+
* @param token - The token of the state family
|
|
740
|
+
* @param key - The key of the state
|
|
741
|
+
* @returns
|
|
742
|
+
* The current value of the state
|
|
743
|
+
* @overload Regular Atom
|
|
744
|
+
*/
|
|
745
|
+
declare function findState<T, K extends Canonical, Key extends K>(token: RegularAtomFamilyToken<T, K>, key: Key): RegularAtomToken<T, K>;
|
|
746
|
+
/**
|
|
747
|
+
* @public
|
|
748
|
+
* Finds a state in the store
|
|
749
|
+
* @param token - The token of the state family
|
|
750
|
+
* @param key - The key of the state
|
|
751
|
+
* @returns
|
|
752
|
+
* The current value of the state
|
|
753
|
+
* @overload Writable Selector
|
|
754
|
+
*/
|
|
755
|
+
declare function findState<T, K extends Canonical, Key extends K>(token: WritableSelectorFamilyToken<T, K>, key: Key): WritableSelectorToken<T, K>;
|
|
756
|
+
/**
|
|
757
|
+
* @public
|
|
758
|
+
* Finds a state in the store
|
|
759
|
+
* @param token - The token of the state family
|
|
760
|
+
* @param key - The key of the state
|
|
761
|
+
* @returns
|
|
762
|
+
* The current value of the state
|
|
763
|
+
* @overload Readonly Selector
|
|
764
|
+
*/
|
|
765
|
+
declare function findState<T, K extends Canonical, Key extends K>(token: ReadonlySelectorFamilyToken<T, K>, key: Key): ReadonlySelectorToken<T, K>;
|
|
766
|
+
/**
|
|
767
|
+
* @public
|
|
768
|
+
* Finds a state in the store
|
|
769
|
+
* @param token - The token of the state family
|
|
770
|
+
* @param key - The key of the state
|
|
771
|
+
* @returns
|
|
772
|
+
* The current value of the state
|
|
773
|
+
* @overload Writable State
|
|
774
|
+
*/
|
|
775
|
+
declare function findState<T, K extends Canonical, Key extends K>(token: WritableFamilyToken<T, K>, key: Key): WritableToken<T, K>;
|
|
776
|
+
/**
|
|
777
|
+
* @public
|
|
778
|
+
* Finds a {@link ReadableToken} in the store
|
|
779
|
+
* @param token - A {@link ReadableFamilyToken}
|
|
780
|
+
* @param key - The key of the state
|
|
781
|
+
* @returns
|
|
782
|
+
* The current value of the state
|
|
783
|
+
* @overload Unknown
|
|
784
|
+
* @default
|
|
785
|
+
*/
|
|
786
|
+
declare function findState<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): ReadableToken<T, K>;
|
|
787
|
+
|
|
258
788
|
/**
|
|
259
789
|
* @public
|
|
260
790
|
* Get the current value of a state
|
|
@@ -274,6 +804,71 @@ declare function getState<T>(token: ReadableToken<T>): T;
|
|
|
274
804
|
*/
|
|
275
805
|
declare function getState<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): T;
|
|
276
806
|
|
|
807
|
+
interface JoinOptions<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null> extends JunctionSchemaBase<ASide, BSide>, Partial<JunctionEntriesBase<AType, BType, Content>> {
|
|
808
|
+
readonly key: string;
|
|
809
|
+
readonly cardinality: Cardinality;
|
|
810
|
+
readonly isAType: Refinement<string, AType>;
|
|
811
|
+
readonly isBType: Refinement<string, BType>;
|
|
812
|
+
}
|
|
813
|
+
type JoinToken<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null = null> = {
|
|
814
|
+
key: string;
|
|
815
|
+
type: `join`;
|
|
816
|
+
cardinality: Cardinality;
|
|
817
|
+
a: ASide;
|
|
818
|
+
b: BSide;
|
|
819
|
+
__aType?: AType;
|
|
820
|
+
__bType?: BType;
|
|
821
|
+
__content?: Content;
|
|
822
|
+
};
|
|
823
|
+
declare function join<const ASide extends string, const AType extends string, const BSide extends string, const BType extends string, const Cardinality extends `1:1` | `1:n` | `n:n`>(options: JoinOptions<ASide, AType, BSide, BType, Cardinality, null>, defaultContent?: undefined, store?: Store): JoinToken<ASide, AType, BSide, BType, Cardinality, null>;
|
|
824
|
+
declare function join<const ASide extends string, const AType extends string, const BSide extends string, const BType extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const Content extends Json.Object>(options: JoinOptions<ASide, AType, BSide, BType, Cardinality, Content>, defaultContent: Content, store?: Store): JoinToken<ASide, AType, BSide, BType, Cardinality, Content>;
|
|
825
|
+
type JoinStates<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null> = Cardinality extends `1:1` ? (Content extends Json.Object ? {
|
|
826
|
+
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorToken<[
|
|
827
|
+
AType,
|
|
828
|
+
Content
|
|
829
|
+
] | null, BType>;
|
|
830
|
+
} & {
|
|
831
|
+
readonly [B in BSide as `${B}EntryOf${Capitalize<ASide>}`]: ReadonlySelectorToken<[
|
|
832
|
+
BType,
|
|
833
|
+
Content
|
|
834
|
+
] | null, AType>;
|
|
835
|
+
} : {}) & {
|
|
836
|
+
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorToken<AType | null, BType>;
|
|
837
|
+
} & {
|
|
838
|
+
readonly [B in BSide as `${B}KeyOf${Capitalize<ASide>}`]: ReadonlySelectorToken<BType | null, AType>;
|
|
839
|
+
} : Cardinality extends `1:n` ? (Content extends Json.Object ? {
|
|
840
|
+
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorToken<[
|
|
841
|
+
AType,
|
|
842
|
+
Content
|
|
843
|
+
] | null, BType>;
|
|
844
|
+
} & {
|
|
845
|
+
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorToken<[
|
|
846
|
+
BType,
|
|
847
|
+
Content
|
|
848
|
+
][], AType>;
|
|
849
|
+
} : {}) & {
|
|
850
|
+
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorToken<AType | null, BType>;
|
|
851
|
+
} & {
|
|
852
|
+
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorToken<BType[], AType>;
|
|
853
|
+
} : Cardinality extends `n:n` ? (Content extends Json.Object ? {
|
|
854
|
+
readonly [A in ASide as `${A}EntriesOf${Capitalize<BSide>}`]: ReadonlySelectorToken<[
|
|
855
|
+
AType,
|
|
856
|
+
Content
|
|
857
|
+
][], BType>;
|
|
858
|
+
} & {
|
|
859
|
+
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorToken<[
|
|
860
|
+
BType,
|
|
861
|
+
Content
|
|
862
|
+
][], AType>;
|
|
863
|
+
} : {}) & {
|
|
864
|
+
readonly [A in ASide as `${A}KeysOf${Capitalize<BSide>}`]: ReadonlySelectorToken<AType[], BType>;
|
|
865
|
+
} & {
|
|
866
|
+
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorToken<BType[], AType>;
|
|
867
|
+
} : never;
|
|
868
|
+
declare function findRelations<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>, key: AType | BType): JoinStates<ASide, AType, BSide, BType, Cardinality, Content>;
|
|
869
|
+
declare function editRelations<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>, change: (relations: Junction<ASide, AType, BSide, BType, Content>) => void): void;
|
|
870
|
+
declare function getInternalRelations<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>): MutableAtomFamilyToken<SetRTX<string>, SetRTXJson<string>, string>;
|
|
871
|
+
|
|
277
872
|
declare const LoggerIconDictionary: {
|
|
278
873
|
readonly "\u231B": "Timeline event fully captured";
|
|
279
874
|
readonly "\u23E9": "Timeline redo";
|
|
@@ -465,19 +1060,19 @@ declare function subscribe<T>(token: ReadableToken<T>, handleUpdate: UpdateHandl
|
|
|
465
1060
|
declare function subscribe<F extends Func>(token: TransactionToken<F>, handleUpdate: TransactionUpdateHandler<F>, key?: string): () => void;
|
|
466
1061
|
declare function subscribe<M extends TimelineManageable>(token: TimelineToken<M>, handleUpdate: (update: TimelineUpdate<M> | `redo` | `undo`) => void, key?: string): () => void;
|
|
467
1062
|
|
|
468
|
-
type TokenType<Comparison extends ReadableFamilyToken
|
|
469
|
-
declare function isToken<KnownToken extends RegularAtomToken
|
|
470
|
-
declare function isToken<KnownToken extends MutableAtomToken
|
|
471
|
-
declare function isToken<KnownToken extends WritableSelectorToken
|
|
472
|
-
declare function isToken<KnownToken extends ReadonlySelectorToken
|
|
473
|
-
declare function isToken<KnownToken extends WritableToken
|
|
474
|
-
declare function isToken<KnownToken extends ReadableToken
|
|
475
|
-
declare function belongsTo<Family extends RegularAtomFamilyToken
|
|
476
|
-
declare function belongsTo<Family extends MutableAtomFamilyToken
|
|
477
|
-
declare function belongsTo<Family extends WritableSelectorFamilyToken
|
|
478
|
-
declare function belongsTo<Family extends ReadonlySelectorFamilyToken
|
|
479
|
-
declare function belongsTo<Family extends WritableFamilyToken
|
|
480
|
-
declare function belongsTo<Family extends ReadableFamilyToken
|
|
1063
|
+
type TokenType<Comparison extends ReadableFamilyToken<any, any> | ReadableToken<any>> = Comparison extends ReadableToken<infer RepresentedValue> ? RepresentedValue : Comparison extends ReadableFamilyToken<infer RepresentedValue, any> ? RepresentedValue : never;
|
|
1064
|
+
declare function isToken<KnownToken extends RegularAtomToken<any>>(knownToken: KnownToken, unknownToken: ReadableToken<any>): unknownToken is RegularAtomToken<TokenType<KnownToken>>;
|
|
1065
|
+
declare function isToken<KnownToken extends MutableAtomToken<any, any>>(knownToken: KnownToken, unknownToken: ReadableToken<any>): unknownToken is MutableAtomToken<TokenType<KnownToken>, any>;
|
|
1066
|
+
declare function isToken<KnownToken extends WritableSelectorToken<any>>(knownToken: KnownToken, unknownToken: ReadableToken<any>): unknownToken is WritableSelectorToken<TokenType<KnownToken>>;
|
|
1067
|
+
declare function isToken<KnownToken extends ReadonlySelectorToken<any>>(knownToken: KnownToken, unknownToken: ReadableToken<any>): unknownToken is ReadonlySelectorToken<TokenType<KnownToken>>;
|
|
1068
|
+
declare function isToken<KnownToken extends WritableToken<any>>(knownToken: KnownToken, unknownToken: ReadableToken<any>): unknownToken is WritableToken<TokenType<KnownToken>>;
|
|
1069
|
+
declare function isToken<KnownToken extends ReadableToken<any>>(knownToken: KnownToken, unknownToken: ReadableToken<any>): unknownToken is ReadableToken<TokenType<KnownToken>>;
|
|
1070
|
+
declare function belongsTo<Family extends RegularAtomFamilyToken<any, any>>(family: Family, unknownToken: ReadableToken<any>): unknownToken is RegularAtomToken<TokenType<Family>>;
|
|
1071
|
+
declare function belongsTo<Family extends MutableAtomFamilyToken<any, any, any>>(family: Family, unknownToken: ReadableToken<any>): unknownToken is MutableAtomToken<TokenType<Family>, any>;
|
|
1072
|
+
declare function belongsTo<Family extends WritableSelectorFamilyToken<any, any>>(family: Family, unknownToken: ReadableToken<any>): unknownToken is WritableSelectorToken<TokenType<Family>>;
|
|
1073
|
+
declare function belongsTo<Family extends ReadonlySelectorFamilyToken<any, any>>(family: Family, unknownToken: ReadableToken<any>): unknownToken is ReadonlySelectorToken<TokenType<Family>>;
|
|
1074
|
+
declare function belongsTo<Family extends WritableFamilyToken<any, any>>(family: Family, unknownToken: ReadableToken<any>): unknownToken is WritableToken<TokenType<Family>>;
|
|
1075
|
+
declare function belongsTo<Family extends ReadableFamilyToken<any, any>>(family: Family, unknownToken: ReadableToken<any>): unknownToken is ReadableToken<TokenType<Family>>;
|
|
481
1076
|
|
|
482
1077
|
/**
|
|
483
1078
|
* @public
|
|
@@ -572,5 +1167,6 @@ type FamilyMetadata<K extends Canonical = any> = {
|
|
|
572
1167
|
/** The family member's unique identifier, in the form of a string. */
|
|
573
1168
|
subKey: stringified<K>;
|
|
574
1169
|
};
|
|
1170
|
+
type Loadable<T> = Promise<T> | T;
|
|
575
1171
|
|
|
576
|
-
export { $claim, type Above, type ActorToolkit, Anarchy, type AtomDisposal, type AtomEffect, type AtomFamilyToken, AtomIOLogger, type AtomIOToken, type AtomOnly, type AtomToken, type Below, type Claim, type CompoundFrom, type CompoundTypedKey, type Effectors, type FamilyMetadata, type GetterToolkit, type Hierarchy, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MoleculeCreation, type MoleculeDisposal, type MoleculeTransfer, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomOptions, type MutableAtomToken, type Mutuals, type Read, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorOptions, type ReadonlySelectorToken, Realm, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomOptions, type RegularAtomToken, type SelectorDisposal, type SelectorFamilyToken, type SelectorToken, type Setter, type SetterToolkit, Silo, type SingularTypedKey, type StateCreation, type StateDisposal, type StateUpdate, T$, type TimelineManageable, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TokenDenomination, type TokenType, type Transact, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateContent, type TransactionUpdateHandler, type TypeTag, type TypedKey, type UpdateHandler, type Vassal, type WritableFamilyToken, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, atom, atomFamily, belongsTo, disposeState, getState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
|
|
1172
|
+
export { $claim, type Above, type ActorToolkit, Anarchy, type AtomDisposal, type AtomEffect, type AtomFamilyToken, AtomIOLogger, type AtomIOToken, type AtomOnly, type AtomToken, type Below, type Claim, type CompoundFrom, type CompoundTypedKey, type Effectors, type FamilyMetadata, type GetterToolkit, type Hierarchy, type JoinOptions, type JoinStates, type JoinToken, type KeyedStateUpdate, LOG_LEVELS, type Loadable, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MoleculeCreation, type MoleculeDisposal, type MoleculeTransfer, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomOptions, type MutableAtomToken, type Mutuals, type Read, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorOptions, type ReadonlySelectorToken, Realm, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomOptions, type RegularAtomToken, type SelectorDisposal, type SelectorFamilyToken, type SelectorToken, type Setter, type SetterToolkit, Silo, type SingularTypedKey, type StateCreation, type StateDisposal, type StateUpdate, T$, type TimelineManageable, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TokenDenomination, type TokenType, type Transact, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateContent, type TransactionUpdateHandler, type TypeTag, type TypedKey, type UpdateHandler, type Vassal, type WritableFamilyToken, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, atom, atomFamily, belongsTo, disposeState, editRelations, findRelations, findState, getInternalRelations, getState, isToken, join, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
|