atom.io 0.14.5 → 0.14.7
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 +11 -186
- package/dist/index.d.ts +245 -0
- package/internal/dist/index.d.ts +20 -18
- package/introspection/dist/index.d.ts +4 -249
- package/json/dist/index.d.ts +3 -243
- package/package.json +3 -2
- package/react/dist/index.cjs +4 -4
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.ts +4 -249
- package/react/dist/index.js +4 -4
- package/react/dist/index.js.map +1 -1
- package/react/src/store-hooks.ts +4 -4
- package/react-devtools/dist/index.d.ts +4 -3
- package/realtime-client/dist/index.d.ts +9 -254
- package/realtime-react/dist/index.d.ts +7 -19
- package/realtime-server/dist/index.d.ts +9 -254
- package/transceivers/set-rtx/dist/index.d.ts +3 -29
- package/data/dist/index.d.cts +0 -333
- package/internal/dist/index.d.cts +0 -419
- package/introspection/dist/index.d.cts +0 -269
- package/json/dist/index.d.cts +0 -291
- package/react/dist/index.d.cts +0 -268
- package/react-devtools/dist/index.d.cts +0 -341
- package/realtime-client/dist/index.d.cts +0 -267
- package/realtime-react/dist/index.d.cts +0 -39
- package/realtime-server/dist/index.d.cts +0 -270
- package/realtime-testing/dist/index.d.cts +0 -49
- package/transceivers/set-rtx/dist/index.d.cts +0 -66
package/data/dist/index.d.cts
DELETED
|
@@ -1,333 +0,0 @@
|
|
|
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
|
-
|
|
4
|
-
declare class Subject<T> {
|
|
5
|
-
Subscriber: (value: T) => void;
|
|
6
|
-
subscribers: Map<string, this[`Subscriber`]>;
|
|
7
|
-
subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
|
|
8
|
-
private unsubscribe;
|
|
9
|
-
next(value: T): void;
|
|
10
|
-
}
|
|
11
|
-
declare class StatefulSubject<T> extends Subject<T> {
|
|
12
|
-
state: T;
|
|
13
|
-
constructor(initialState: T);
|
|
14
|
-
next(value: T): void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type Selector<T> = {
|
|
18
|
-
key: string;
|
|
19
|
-
type: `selector`;
|
|
20
|
-
family?: FamilyMetadata;
|
|
21
|
-
install: (store: Store) => void;
|
|
22
|
-
subject: Subject<{
|
|
23
|
-
newValue: T;
|
|
24
|
-
oldValue: T;
|
|
25
|
-
}>;
|
|
26
|
-
get: () => T;
|
|
27
|
-
set: (newValue: T | ((oldValue: T) => T)) => void;
|
|
28
|
-
};
|
|
29
|
-
type ReadonlySelector<T> = {
|
|
30
|
-
key: string;
|
|
31
|
-
type: `readonly_selector`;
|
|
32
|
-
family?: FamilyMetadata;
|
|
33
|
-
install: (store: Store) => void;
|
|
34
|
-
subject: Subject<{
|
|
35
|
-
newValue: T;
|
|
36
|
-
oldValue: T;
|
|
37
|
-
}>;
|
|
38
|
-
get: () => T;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
type Transaction<ƒ extends ƒn> = {
|
|
42
|
-
key: string;
|
|
43
|
-
type: `transaction`;
|
|
44
|
-
install: (store: Store) => void;
|
|
45
|
-
subject: Subject<TransactionUpdate<ƒ>>;
|
|
46
|
-
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
type TransactionMeta<ƒ extends ƒn> = {
|
|
50
|
-
phase: `applying` | `building`;
|
|
51
|
-
time: number;
|
|
52
|
-
update: TransactionUpdate<ƒ>;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
type primitive = boolean | number | string | null;
|
|
56
|
-
|
|
57
|
-
type Serializable = primitive | Readonly<{
|
|
58
|
-
[key: string]: Serializable;
|
|
59
|
-
}> | ReadonlyArray<Serializable>;
|
|
60
|
-
type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
|
|
61
|
-
|
|
62
|
-
type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
|
|
63
|
-
type Cardinality = `1:1` | `1:n` | `n:n`;
|
|
64
|
-
|
|
65
|
-
interface JunctionEntries<Content extends Object$1 | null> extends Object$1 {
|
|
66
|
-
readonly relations: [string, string[]][];
|
|
67
|
-
readonly contents: [string, Content][];
|
|
68
|
-
}
|
|
69
|
-
interface JunctionSchema<ASide extends string, BSide extends string> extends Object$1 {
|
|
70
|
-
readonly between: [a: ASide, b: BSide];
|
|
71
|
-
readonly cardinality: Cardinality;
|
|
72
|
-
}
|
|
73
|
-
type BaseExternalStoreConfiguration = {
|
|
74
|
-
addRelation: (a: string, b: string) => void;
|
|
75
|
-
deleteRelation: (a: string, b: string) => void;
|
|
76
|
-
replaceRelationsSafely: (a: string, bs: string[]) => void;
|
|
77
|
-
replaceRelationsUnsafely: (a: string, bs: string[]) => void;
|
|
78
|
-
getRelatedKeys: (key: string) => Set<string> | undefined;
|
|
79
|
-
has: (a: string, b?: string) => boolean;
|
|
80
|
-
};
|
|
81
|
-
type ExternalStoreWithContentConfiguration<Content extends Object$1> = {
|
|
82
|
-
getContent: (contentKey: string) => Content | undefined;
|
|
83
|
-
setContent: (contentKey: string, content: Content) => void;
|
|
84
|
-
deleteContent: (contentKey: string) => void;
|
|
85
|
-
};
|
|
86
|
-
type Empty<Obj extends object> = {
|
|
87
|
-
[Key in keyof Obj]?: undefined;
|
|
88
|
-
};
|
|
89
|
-
type ExternalStoreConfiguration<Content extends Object$1 | null> = Content extends Object$1 ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Object$1>>;
|
|
90
|
-
type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
|
|
91
|
-
externalStore?: ExternalStoreConfiguration<Content>;
|
|
92
|
-
isContent?: Refinement<unknown, Content>;
|
|
93
|
-
makeContentKey?: (a: string, b: string) => string;
|
|
94
|
-
};
|
|
95
|
-
type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
|
|
96
|
-
declare class Junction<const ASide extends string, const BSide extends string, const Content extends Object$1 | null = null> {
|
|
97
|
-
readonly a: ASide;
|
|
98
|
-
readonly b: BSide;
|
|
99
|
-
readonly cardinality: Cardinality;
|
|
100
|
-
readonly relations: Map<string, Set<string>>;
|
|
101
|
-
readonly contents: Map<string, Content>;
|
|
102
|
-
isContent: Refinement<unknown, Content> | null;
|
|
103
|
-
makeContentKey: (a: string, b: string) => string;
|
|
104
|
-
getRelatedKeys(key: string): Set<string> | undefined;
|
|
105
|
-
protected addRelation(a: string, b: string): void;
|
|
106
|
-
protected deleteRelation(a: string, b: string): void;
|
|
107
|
-
protected replaceRelationsUnsafely(a: string, bs: string[]): void;
|
|
108
|
-
protected replaceRelationsSafely(a: string, bs: string[]): 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<Content>>, config?: JunctionAdvancedConfiguration<Content>);
|
|
113
|
-
toJSON(): JunctionJSON<ASide, BSide, Content>;
|
|
114
|
-
set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
|
|
115
|
-
set(relation: {
|
|
116
|
-
[Key in ASide | BSide]: string;
|
|
117
|
-
}, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
|
|
118
|
-
delete(a: string, b?: string): this;
|
|
119
|
-
delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
|
|
120
|
-
getRelatedKey(key: string): string | undefined;
|
|
121
|
-
replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
|
|
122
|
-
reckless: boolean;
|
|
123
|
-
}): this;
|
|
124
|
-
getContent(a: string, b: string): Content | undefined;
|
|
125
|
-
getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
|
|
126
|
-
has(a: string, b?: string): boolean;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
interface Lineage {
|
|
130
|
-
parent: typeof this | null;
|
|
131
|
-
child: typeof this | null;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
type Stringified<J extends Serializable> = string & {
|
|
135
|
-
__json: J;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
interface Transceiver<Signal extends Serializable> {
|
|
139
|
-
do: (update: Signal) => void;
|
|
140
|
-
undo: (update: Signal) => void;
|
|
141
|
-
subscribe: (key: string, fn: (update: Signal) => void) => () => void;
|
|
142
|
-
cacheUpdateNumber: number;
|
|
143
|
-
getUpdateNumber: (update: Signal) => number;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* @internal Give the tracker a transceiver state and a store, and it will
|
|
148
|
-
* subscribe to the transceiver's inner value. When the inner value changes,
|
|
149
|
-
* the tracker will update its own state to reflect the change.
|
|
150
|
-
*/
|
|
151
|
-
declare class Tracker<Mutable extends Transceiver<any>> {
|
|
152
|
-
private Update;
|
|
153
|
-
private initializeState;
|
|
154
|
-
private unsubscribeFromInnerValue;
|
|
155
|
-
private observeCore;
|
|
156
|
-
private updateCore;
|
|
157
|
-
mutableState: MutableAtomToken<Mutable, Serializable>;
|
|
158
|
-
latestUpdateState: AtomToken<typeof this.Update | null>;
|
|
159
|
-
constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
interface MutableAtom<T> extends Atom<T> {
|
|
163
|
-
mutable: true;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
type OperationProgress = {
|
|
167
|
-
open: false;
|
|
168
|
-
} | {
|
|
169
|
-
open: true;
|
|
170
|
-
done: Set<string>;
|
|
171
|
-
prev: Map<string, any>;
|
|
172
|
-
time: number;
|
|
173
|
-
token: StateToken<any>;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
type TimelineAtomUpdate = StateUpdate<unknown> & {
|
|
177
|
-
key: string;
|
|
178
|
-
type: `atom_update`;
|
|
179
|
-
timestamp: number;
|
|
180
|
-
family?: FamilyMetadata;
|
|
181
|
-
};
|
|
182
|
-
type TimelineSelectorUpdate = {
|
|
183
|
-
key: string;
|
|
184
|
-
type: `selector_update`;
|
|
185
|
-
timestamp: number;
|
|
186
|
-
atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
|
|
187
|
-
};
|
|
188
|
-
type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
189
|
-
key: string;
|
|
190
|
-
type: `transaction_update`;
|
|
191
|
-
timestamp: number;
|
|
192
|
-
};
|
|
193
|
-
type Timeline = {
|
|
194
|
-
type: `timeline`;
|
|
195
|
-
key: string;
|
|
196
|
-
at: number;
|
|
197
|
-
shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
|
|
198
|
-
timeTraveling: `into_future` | `into_past` | null;
|
|
199
|
-
history: TimelineUpdate[];
|
|
200
|
-
selectorTime: number | null;
|
|
201
|
-
transactionKey: string | null;
|
|
202
|
-
install: (store: Store) => void;
|
|
203
|
-
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
declare class Store implements Lineage {
|
|
207
|
-
parent: Store | null;
|
|
208
|
-
child: Store | null;
|
|
209
|
-
valueMap: Map<string, any>;
|
|
210
|
-
atoms: Map<string, Atom<any> | MutableAtom<any>>;
|
|
211
|
-
selectors: Map<string, Selector<any>>;
|
|
212
|
-
readonlySelectors: Map<string, ReadonlySelector<any>>;
|
|
213
|
-
trackers: Map<string, Tracker<Transceiver<any>>>;
|
|
214
|
-
families: Map<string, AtomFamily<any, any> | ReadonlySelectorFamily<any, any> | SelectorFamily<any, any>>;
|
|
215
|
-
timelines: Map<string, Timeline>;
|
|
216
|
-
transactions: Map<string, Transaction<ƒn>>;
|
|
217
|
-
atomsThatAreDefault: Set<string>;
|
|
218
|
-
timelineAtoms: Junction<"timelineKey", "atomKey", null>;
|
|
219
|
-
selectorAtoms: Junction<"selectorKey", "atomKey", null>;
|
|
220
|
-
selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
|
|
221
|
-
source: string;
|
|
222
|
-
}>;
|
|
223
|
-
subject: {
|
|
224
|
-
atomCreation: Subject<AtomToken<unknown>>;
|
|
225
|
-
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
226
|
-
transactionCreation: Subject<TransactionToken<ƒn>>;
|
|
227
|
-
timelineCreation: Subject<TimelineToken>;
|
|
228
|
-
transactionApplying: StatefulSubject<TransactionMeta<ƒn> | null>;
|
|
229
|
-
operationStatus: Subject<OperationProgress>;
|
|
230
|
-
};
|
|
231
|
-
operation: OperationProgress;
|
|
232
|
-
transactionMeta: TransactionMeta<ƒn> | null;
|
|
233
|
-
config: {
|
|
234
|
-
name: string;
|
|
235
|
-
};
|
|
236
|
-
loggers: AtomIOLogger[];
|
|
237
|
-
logger: Logger;
|
|
238
|
-
constructor(name: string, store?: Store | null);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
type Atom<T> = {
|
|
242
|
-
key: string;
|
|
243
|
-
type: `atom`;
|
|
244
|
-
mutable?: boolean;
|
|
245
|
-
family?: FamilyMetadata;
|
|
246
|
-
install: (store: Store) => void;
|
|
247
|
-
subject: Subject<{
|
|
248
|
-
newValue: T;
|
|
249
|
-
oldValue: T;
|
|
250
|
-
}>;
|
|
251
|
-
default: T | (() => T);
|
|
252
|
-
cleanup?: () => void;
|
|
253
|
-
};
|
|
254
|
-
|
|
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<{
|
|
256
|
-
[K in Stringified<Key>]: State;
|
|
257
|
-
}>;
|
|
258
|
-
|
|
259
|
-
interface JoinOptions<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Object$1 | null> extends Object$1, JunctionSchema<ASide, BSide>, Partial<JunctionEntries<Content>> {
|
|
260
|
-
readonly key: string;
|
|
261
|
-
readonly cardinality: Cardinality;
|
|
262
|
-
}
|
|
263
|
-
type JoinState<ASide extends string, BSide extends string, Cardinality extends Cardinality, Content extends Object$1 | null> = Cardinality extends `1:1` ? (Content extends Object$1 ? {
|
|
264
|
-
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}EntryOf${Capitalize<BSide>}` : `${AB}EntryOf${Capitalize<ASide>}`]: SelectorFamily<[
|
|
265
|
-
string,
|
|
266
|
-
Content
|
|
267
|
-
] | undefined, string>;
|
|
268
|
-
} : {}) & {
|
|
269
|
-
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}KeyOf${Capitalize<BSide>}` : `${AB}KeyOf${Capitalize<ASide>}`]: SelectorFamily<string | undefined, string>;
|
|
270
|
-
} : Cardinality extends `1:n` ? (Content extends Object$1 ? {
|
|
271
|
-
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: SelectorFamily<[
|
|
272
|
-
string,
|
|
273
|
-
Content
|
|
274
|
-
] | undefined, string>;
|
|
275
|
-
} & {
|
|
276
|
-
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: SelectorFamily<[
|
|
277
|
-
string,
|
|
278
|
-
Content
|
|
279
|
-
][], string>;
|
|
280
|
-
} : {}) & {
|
|
281
|
-
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: SelectorFamily<string | undefined, string>;
|
|
282
|
-
} & {
|
|
283
|
-
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: SelectorFamily<string[], string>;
|
|
284
|
-
} : Cardinality extends `n:n` ? (Content extends Object$1 ? {
|
|
285
|
-
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}EntriesOf${Capitalize<BSide>}` : `${AB}EntriesOf${Capitalize<ASide>}`]: SelectorFamily<[
|
|
286
|
-
string,
|
|
287
|
-
Content
|
|
288
|
-
][], string>;
|
|
289
|
-
} : {}) & {
|
|
290
|
-
readonly [AB in ASide | BSide as AB extends ASide ? `${AB}KeysOf${Capitalize<BSide>}` : `${AB}KeysOf${Capitalize<ASide>}`]: SelectorFamily<string[], string>;
|
|
291
|
-
} : never;
|
|
292
|
-
declare function join<const ASide extends string, const BSide extends string, const Cardinality extends Cardinality>(options: JoinOptions<ASide, BSide, Cardinality, null>, defaultContent?: undefined, store?: Store): {
|
|
293
|
-
relations: Junction<ASide, BSide>;
|
|
294
|
-
findState: JoinState<ASide, BSide, Cardinality, null>;
|
|
295
|
-
};
|
|
296
|
-
declare function join<const ASide extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const BSide extends string, const Content extends Object$1>(options: JoinOptions<ASide, BSide, Cardinality, Content>, defaultContent: Content, store?: Store): {
|
|
297
|
-
relations: Junction<ASide, BSide, Content>;
|
|
298
|
-
findState: JoinState<ASide, BSide, Cardinality, Content>;
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
declare function struct<Struct extends {
|
|
302
|
-
[key: string]: unknown;
|
|
303
|
-
}, Key extends string>(options: {
|
|
304
|
-
key: Key;
|
|
305
|
-
default: Struct;
|
|
306
|
-
}, store?: Store): [
|
|
307
|
-
{
|
|
308
|
-
[K in keyof Struct as `${Key}${Capitalize<K & string>}State`]: AtomIO.AtomToken<Struct[K]>;
|
|
309
|
-
},
|
|
310
|
-
AtomIO.ReadonlySelectorToken<Struct>
|
|
311
|
-
];
|
|
312
|
-
|
|
313
|
-
declare function structFamily<Struct extends object, Key extends string>(options: {
|
|
314
|
-
key: Key;
|
|
315
|
-
default: Struct;
|
|
316
|
-
}): [
|
|
317
|
-
{
|
|
318
|
-
[K in keyof Struct as `find${Capitalize<Key & string>}${Capitalize<K & string>}State`]: AtomIO.AtomFamily<Struct[K], string>;
|
|
319
|
-
},
|
|
320
|
-
AtomIO.ReadonlySelectorFamily<Struct>
|
|
321
|
-
];
|
|
322
|
-
|
|
323
|
-
type Loadable<T> = Promise<T> | T;
|
|
324
|
-
type Fated<T, E extends Error = Error> = Loadable<E | T>;
|
|
325
|
-
/**
|
|
326
|
-
* Utility for handling loadable values
|
|
327
|
-
* @param loadable Loadable value
|
|
328
|
-
* @param fallback Fallback value until Loadable is resolved
|
|
329
|
-
* @returns Fallback value if your loadable is a promise, otherwise the loadable's resolved value
|
|
330
|
-
*/
|
|
331
|
-
declare function until<T>(loadable: Loadable<T>, fallback: T): T;
|
|
332
|
-
|
|
333
|
-
export { type Fated, type JoinOptions, type JoinState, type Loadable, dict, join, struct, structFamily, until };
|