atom.io 0.14.5 → 0.14.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/dist/index.d.cts +11 -186
- package/data/dist/index.d.ts +11 -186
- package/dist/index.d.cts +245 -0
- package/dist/index.d.ts +245 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/internal/dist/index.d.cts +20 -18
- package/internal/dist/index.d.ts +20 -18
- package/introspection/dist/index.d.cts +4 -249
- package/introspection/dist/index.d.ts +4 -249
- package/json/dist/index.d.cts +3 -243
- package/json/dist/index.d.ts +3 -243
- package/package.json +2 -1
- package/react/dist/index.d.cts +4 -249
- package/react/dist/index.d.ts +4 -249
- package/react-devtools/dist/index.d.cts +4 -3
- package/react-devtools/dist/index.d.ts +4 -3
- package/realtime-client/dist/index.d.cts +9 -254
- package/realtime-client/dist/index.d.ts +9 -254
- package/realtime-react/dist/index.d.cts +7 -19
- package/realtime-react/dist/index.d.ts +7 -19
- package/realtime-server/dist/index.d.cts +9 -254
- package/realtime-server/dist/index.d.ts +9 -254
- package/transceivers/set-rtx/dist/index.d.cts +3 -29
- package/transceivers/set-rtx/dist/index.d.ts +3 -29
package/react/dist/index.d.cts
CHANGED
|
@@ -1,252 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Store } from 'atom.io/internal';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
interface Transceiver<Signal extends Serializable> {
|
|
135
|
-
do: (update: Signal) => void;
|
|
136
|
-
undo: (update: Signal) => void;
|
|
137
|
-
subscribe: (key: string, fn: (update: Signal) => void) => () => void;
|
|
138
|
-
cacheUpdateNumber: number;
|
|
139
|
-
getUpdateNumber: (update: Signal) => number;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* @internal Give the tracker a transceiver state and a store, and it will
|
|
144
|
-
* subscribe to the transceiver's inner value. When the inner value changes,
|
|
145
|
-
* the tracker will update its own state to reflect the change.
|
|
146
|
-
*/
|
|
147
|
-
declare class Tracker<Mutable extends Transceiver<any>> {
|
|
148
|
-
private Update;
|
|
149
|
-
private initializeState;
|
|
150
|
-
private unsubscribeFromInnerValue;
|
|
151
|
-
private observeCore;
|
|
152
|
-
private updateCore;
|
|
153
|
-
mutableState: MutableAtomToken<Mutable, Serializable>;
|
|
154
|
-
latestUpdateState: AtomToken<typeof this.Update | null>;
|
|
155
|
-
constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
interface MutableAtom<T> extends Atom<T> {
|
|
159
|
-
mutable: true;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
type OperationProgress = {
|
|
163
|
-
open: false;
|
|
164
|
-
} | {
|
|
165
|
-
open: true;
|
|
166
|
-
done: Set<string>;
|
|
167
|
-
prev: Map<string, any>;
|
|
168
|
-
time: number;
|
|
169
|
-
token: StateToken<any>;
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
type TimelineAtomUpdate = StateUpdate<unknown> & {
|
|
173
|
-
key: string;
|
|
174
|
-
type: `atom_update`;
|
|
175
|
-
timestamp: number;
|
|
176
|
-
family?: FamilyMetadata;
|
|
177
|
-
};
|
|
178
|
-
type TimelineSelectorUpdate = {
|
|
179
|
-
key: string;
|
|
180
|
-
type: `selector_update`;
|
|
181
|
-
timestamp: number;
|
|
182
|
-
atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
|
|
183
|
-
};
|
|
184
|
-
type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
185
|
-
key: string;
|
|
186
|
-
type: `transaction_update`;
|
|
187
|
-
timestamp: number;
|
|
188
|
-
};
|
|
189
|
-
type Timeline = {
|
|
190
|
-
type: `timeline`;
|
|
191
|
-
key: string;
|
|
192
|
-
at: number;
|
|
193
|
-
shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
|
|
194
|
-
timeTraveling: `into_future` | `into_past` | null;
|
|
195
|
-
history: TimelineUpdate[];
|
|
196
|
-
selectorTime: number | null;
|
|
197
|
-
transactionKey: string | null;
|
|
198
|
-
install: (store: Store) => void;
|
|
199
|
-
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
declare class Store implements Lineage {
|
|
203
|
-
parent: Store | null;
|
|
204
|
-
child: Store | null;
|
|
205
|
-
valueMap: Map<string, any>;
|
|
206
|
-
atoms: Map<string, Atom<any> | MutableAtom<any>>;
|
|
207
|
-
selectors: Map<string, Selector<any>>;
|
|
208
|
-
readonlySelectors: Map<string, ReadonlySelector<any>>;
|
|
209
|
-
trackers: Map<string, Tracker<Transceiver<any>>>;
|
|
210
|
-
families: Map<string, AtomFamily<any, any> | ReadonlySelectorFamily<any, any> | SelectorFamily<any, any>>;
|
|
211
|
-
timelines: Map<string, Timeline>;
|
|
212
|
-
transactions: Map<string, Transaction<ƒn>>;
|
|
213
|
-
atomsThatAreDefault: Set<string>;
|
|
214
|
-
timelineAtoms: Junction<"timelineKey", "atomKey", null>;
|
|
215
|
-
selectorAtoms: Junction<"selectorKey", "atomKey", null>;
|
|
216
|
-
selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
|
|
217
|
-
source: string;
|
|
218
|
-
}>;
|
|
219
|
-
subject: {
|
|
220
|
-
atomCreation: Subject<AtomToken<unknown>>;
|
|
221
|
-
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
222
|
-
transactionCreation: Subject<TransactionToken<ƒn>>;
|
|
223
|
-
timelineCreation: Subject<TimelineToken>;
|
|
224
|
-
transactionApplying: StatefulSubject<TransactionMeta<ƒn> | null>;
|
|
225
|
-
operationStatus: Subject<OperationProgress>;
|
|
226
|
-
};
|
|
227
|
-
operation: OperationProgress;
|
|
228
|
-
transactionMeta: TransactionMeta<ƒn> | null;
|
|
229
|
-
config: {
|
|
230
|
-
name: string;
|
|
231
|
-
};
|
|
232
|
-
loggers: AtomIOLogger[];
|
|
233
|
-
logger: Logger;
|
|
234
|
-
constructor(name: string, store?: Store | null);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
type Atom<T> = {
|
|
238
|
-
key: string;
|
|
239
|
-
type: `atom`;
|
|
240
|
-
mutable?: boolean;
|
|
241
|
-
family?: FamilyMetadata;
|
|
242
|
-
install: (store: Store) => void;
|
|
243
|
-
subject: Subject<{
|
|
244
|
-
newValue: T;
|
|
245
|
-
oldValue: T;
|
|
246
|
-
}>;
|
|
247
|
-
default: T | (() => T);
|
|
248
|
-
cleanup?: () => void;
|
|
249
|
-
};
|
|
3
|
+
import { StateToken, ReadonlySelectorToken, MutableAtomToken, TimelineToken } from 'atom.io';
|
|
4
|
+
import { Json } from 'atom.io/json';
|
|
250
5
|
|
|
251
6
|
declare const StoreContext: React.Context<Store>;
|
|
252
7
|
declare const StoreProvider: React.FC<{
|
|
@@ -256,7 +11,7 @@ declare const StoreProvider: React.FC<{
|
|
|
256
11
|
|
|
257
12
|
declare function useI<T>(token: StateToken<T>): <New extends T>(next: New | ((old: T) => New)) => void;
|
|
258
13
|
declare function useO<T>(token: ReadonlySelectorToken<T> | StateToken<T>): T;
|
|
259
|
-
declare function useJSON<Serializable extends Serializable>(token: MutableAtomToken<any, Serializable>): Serializable;
|
|
14
|
+
declare function useJSON<Serializable extends Json.Serializable>(token: MutableAtomToken<any, Serializable>): Serializable;
|
|
260
15
|
type TimelineMeta = {
|
|
261
16
|
at: number;
|
|
262
17
|
length: number;
|
package/react/dist/index.d.ts
CHANGED
|
@@ -1,252 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Store } from 'atom.io/internal';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
interface Transceiver<Signal extends Serializable> {
|
|
135
|
-
do: (update: Signal) => void;
|
|
136
|
-
undo: (update: Signal) => void;
|
|
137
|
-
subscribe: (key: string, fn: (update: Signal) => void) => () => void;
|
|
138
|
-
cacheUpdateNumber: number;
|
|
139
|
-
getUpdateNumber: (update: Signal) => number;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* @internal Give the tracker a transceiver state and a store, and it will
|
|
144
|
-
* subscribe to the transceiver's inner value. When the inner value changes,
|
|
145
|
-
* the tracker will update its own state to reflect the change.
|
|
146
|
-
*/
|
|
147
|
-
declare class Tracker<Mutable extends Transceiver<any>> {
|
|
148
|
-
private Update;
|
|
149
|
-
private initializeState;
|
|
150
|
-
private unsubscribeFromInnerValue;
|
|
151
|
-
private observeCore;
|
|
152
|
-
private updateCore;
|
|
153
|
-
mutableState: MutableAtomToken<Mutable, Serializable>;
|
|
154
|
-
latestUpdateState: AtomToken<typeof this.Update | null>;
|
|
155
|
-
constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
interface MutableAtom<T> extends Atom<T> {
|
|
159
|
-
mutable: true;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
type OperationProgress = {
|
|
163
|
-
open: false;
|
|
164
|
-
} | {
|
|
165
|
-
open: true;
|
|
166
|
-
done: Set<string>;
|
|
167
|
-
prev: Map<string, any>;
|
|
168
|
-
time: number;
|
|
169
|
-
token: StateToken<any>;
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
type TimelineAtomUpdate = StateUpdate<unknown> & {
|
|
173
|
-
key: string;
|
|
174
|
-
type: `atom_update`;
|
|
175
|
-
timestamp: number;
|
|
176
|
-
family?: FamilyMetadata;
|
|
177
|
-
};
|
|
178
|
-
type TimelineSelectorUpdate = {
|
|
179
|
-
key: string;
|
|
180
|
-
type: `selector_update`;
|
|
181
|
-
timestamp: number;
|
|
182
|
-
atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
|
|
183
|
-
};
|
|
184
|
-
type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
185
|
-
key: string;
|
|
186
|
-
type: `transaction_update`;
|
|
187
|
-
timestamp: number;
|
|
188
|
-
};
|
|
189
|
-
type Timeline = {
|
|
190
|
-
type: `timeline`;
|
|
191
|
-
key: string;
|
|
192
|
-
at: number;
|
|
193
|
-
shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
|
|
194
|
-
timeTraveling: `into_future` | `into_past` | null;
|
|
195
|
-
history: TimelineUpdate[];
|
|
196
|
-
selectorTime: number | null;
|
|
197
|
-
transactionKey: string | null;
|
|
198
|
-
install: (store: Store) => void;
|
|
199
|
-
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
declare class Store implements Lineage {
|
|
203
|
-
parent: Store | null;
|
|
204
|
-
child: Store | null;
|
|
205
|
-
valueMap: Map<string, any>;
|
|
206
|
-
atoms: Map<string, Atom<any> | MutableAtom<any>>;
|
|
207
|
-
selectors: Map<string, Selector<any>>;
|
|
208
|
-
readonlySelectors: Map<string, ReadonlySelector<any>>;
|
|
209
|
-
trackers: Map<string, Tracker<Transceiver<any>>>;
|
|
210
|
-
families: Map<string, AtomFamily<any, any> | ReadonlySelectorFamily<any, any> | SelectorFamily<any, any>>;
|
|
211
|
-
timelines: Map<string, Timeline>;
|
|
212
|
-
transactions: Map<string, Transaction<ƒn>>;
|
|
213
|
-
atomsThatAreDefault: Set<string>;
|
|
214
|
-
timelineAtoms: Junction<"timelineKey", "atomKey", null>;
|
|
215
|
-
selectorAtoms: Junction<"selectorKey", "atomKey", null>;
|
|
216
|
-
selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
|
|
217
|
-
source: string;
|
|
218
|
-
}>;
|
|
219
|
-
subject: {
|
|
220
|
-
atomCreation: Subject<AtomToken<unknown>>;
|
|
221
|
-
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
222
|
-
transactionCreation: Subject<TransactionToken<ƒn>>;
|
|
223
|
-
timelineCreation: Subject<TimelineToken>;
|
|
224
|
-
transactionApplying: StatefulSubject<TransactionMeta<ƒn> | null>;
|
|
225
|
-
operationStatus: Subject<OperationProgress>;
|
|
226
|
-
};
|
|
227
|
-
operation: OperationProgress;
|
|
228
|
-
transactionMeta: TransactionMeta<ƒn> | null;
|
|
229
|
-
config: {
|
|
230
|
-
name: string;
|
|
231
|
-
};
|
|
232
|
-
loggers: AtomIOLogger[];
|
|
233
|
-
logger: Logger;
|
|
234
|
-
constructor(name: string, store?: Store | null);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
type Atom<T> = {
|
|
238
|
-
key: string;
|
|
239
|
-
type: `atom`;
|
|
240
|
-
mutable?: boolean;
|
|
241
|
-
family?: FamilyMetadata;
|
|
242
|
-
install: (store: Store) => void;
|
|
243
|
-
subject: Subject<{
|
|
244
|
-
newValue: T;
|
|
245
|
-
oldValue: T;
|
|
246
|
-
}>;
|
|
247
|
-
default: T | (() => T);
|
|
248
|
-
cleanup?: () => void;
|
|
249
|
-
};
|
|
3
|
+
import { StateToken, ReadonlySelectorToken, MutableAtomToken, TimelineToken } from 'atom.io';
|
|
4
|
+
import { Json } from 'atom.io/json';
|
|
250
5
|
|
|
251
6
|
declare const StoreContext: React.Context<Store>;
|
|
252
7
|
declare const StoreProvider: React.FC<{
|
|
@@ -256,7 +11,7 @@ declare const StoreProvider: React.FC<{
|
|
|
256
11
|
|
|
257
12
|
declare function useI<T>(token: StateToken<T>): <New extends T>(next: New | ((old: T) => New)) => void;
|
|
258
13
|
declare function useO<T>(token: ReadonlySelectorToken<T> | StateToken<T>): T;
|
|
259
|
-
declare function useJSON<Serializable extends Serializable>(token: MutableAtomToken<any, Serializable>): Serializable;
|
|
14
|
+
declare function useJSON<Serializable extends Json.Serializable>(token: MutableAtomToken<any, Serializable>): Serializable;
|
|
260
15
|
type TimelineMeta = {
|
|
261
16
|
at: number;
|
|
262
17
|
length: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as atom_io from 'atom.io';
|
|
2
2
|
import { FamilyMetadata, ƒn, TransactionUpdate, MutableAtomToken, AtomToken, StateToken, TimelineUpdate, StateUpdate, AtomFamily, ReadonlySelectorFamily, SelectorFamily, ReadonlySelectorToken, SelectorToken, TransactionToken, TimelineToken, AtomIOLogger, Logger } from 'atom.io';
|
|
3
|
+
import { Json } from 'atom.io/json';
|
|
3
4
|
|
|
4
5
|
type ClassSignature = abstract new (...args: any) => any;
|
|
5
6
|
|
|
@@ -153,7 +154,7 @@ interface Lineage {
|
|
|
153
154
|
child: typeof this | null;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
interface Transceiver<Signal extends Serializable> {
|
|
157
|
+
interface Transceiver<Signal extends Json.Serializable> {
|
|
157
158
|
do: (update: Signal) => void;
|
|
158
159
|
undo: (update: Signal) => void;
|
|
159
160
|
subscribe: (key: string, fn: (update: Signal) => void) => () => void;
|
|
@@ -172,9 +173,9 @@ declare class Tracker<Mutable extends Transceiver<any>> {
|
|
|
172
173
|
private unsubscribeFromInnerValue;
|
|
173
174
|
private observeCore;
|
|
174
175
|
private updateCore;
|
|
175
|
-
mutableState: MutableAtomToken<Mutable, Serializable>;
|
|
176
|
+
mutableState: MutableAtomToken<Mutable, Json.Serializable>;
|
|
176
177
|
latestUpdateState: AtomToken<typeof this.Update | null>;
|
|
177
|
-
constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
|
|
178
|
+
constructor(mutableState: MutableAtomToken<Mutable, Json.Serializable>, store: Store);
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
interface MutableAtom<T> extends Atom<T> {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as atom_io from 'atom.io';
|
|
2
2
|
import { FamilyMetadata, ƒn, TransactionUpdate, MutableAtomToken, AtomToken, StateToken, TimelineUpdate, StateUpdate, AtomFamily, ReadonlySelectorFamily, SelectorFamily, ReadonlySelectorToken, SelectorToken, TransactionToken, TimelineToken, AtomIOLogger, Logger } from 'atom.io';
|
|
3
|
+
import { Json } from 'atom.io/json';
|
|
3
4
|
|
|
4
5
|
type ClassSignature = abstract new (...args: any) => any;
|
|
5
6
|
|
|
@@ -153,7 +154,7 @@ interface Lineage {
|
|
|
153
154
|
child: typeof this | null;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
interface Transceiver<Signal extends Serializable> {
|
|
157
|
+
interface Transceiver<Signal extends Json.Serializable> {
|
|
157
158
|
do: (update: Signal) => void;
|
|
158
159
|
undo: (update: Signal) => void;
|
|
159
160
|
subscribe: (key: string, fn: (update: Signal) => void) => () => void;
|
|
@@ -172,9 +173,9 @@ declare class Tracker<Mutable extends Transceiver<any>> {
|
|
|
172
173
|
private unsubscribeFromInnerValue;
|
|
173
174
|
private observeCore;
|
|
174
175
|
private updateCore;
|
|
175
|
-
mutableState: MutableAtomToken<Mutable, Serializable>;
|
|
176
|
+
mutableState: MutableAtomToken<Mutable, Json.Serializable>;
|
|
176
177
|
latestUpdateState: AtomToken<typeof this.Update | null>;
|
|
177
|
-
constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
|
|
178
|
+
constructor(mutableState: MutableAtomToken<Mutable, Json.Serializable>, store: Store);
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
interface MutableAtom<T> extends Atom<T> {
|