atom.io 0.14.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/dist/index.cjs +1473 -52
- package/data/dist/index.cjs.map +1 -1
- package/data/dist/index.d.cts +315 -16
- package/data/dist/index.js +10 -267
- package/data/dist/index.js.map +1 -1
- package/data/package.json +5 -5
- package/data/src/join.ts +3 -3
- package/dist/chunk-5VJ77LZE.js +176 -0
- package/dist/chunk-5VJ77LZE.js.map +1 -0
- package/dist/chunk-CK7GNCU5.js +309 -0
- package/dist/chunk-CK7GNCU5.js.map +1 -0
- package/dist/chunk-KW7RA7IM.js +67 -0
- package/dist/chunk-KW7RA7IM.js.map +1 -0
- package/dist/chunk-LFXB7Y6M.js +68 -0
- package/dist/chunk-LFXB7Y6M.js.map +1 -0
- package/dist/chunk-NYCVSXQB.js +181 -0
- package/dist/chunk-NYCVSXQB.js.map +1 -0
- package/dist/chunk-TE3ZSTQ6.js +2516 -0
- package/dist/chunk-TE3ZSTQ6.js.map +1 -0
- package/dist/index.cjs +2244 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +268 -21
- package/dist/index.js +1 -152
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/internal/dist/index.cjs +208 -79
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.cts +226 -27
- package/internal/dist/index.js +1 -2240
- package/internal/dist/index.js.map +1 -1
- package/internal/package.json +5 -5
- package/introspection/dist/index.cjs +1618 -46
- package/introspection/dist/index.cjs.map +1 -1
- package/introspection/dist/index.d.cts +374 -4
- package/introspection/dist/index.js +2 -316
- package/introspection/dist/index.js.map +1 -1
- package/introspection/package.json +5 -5
- package/json/dist/index.cjs +1560 -8
- package/json/dist/index.cjs.map +1 -1
- package/json/dist/index.d.cts +371 -7
- package/json/dist/index.js +1 -76
- package/json/dist/index.js.map +1 -1
- package/json/package.json +5 -5
- package/package.json +5 -4
- package/react/dist/index.cjs +1604 -14
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.cts +375 -4
- package/react/dist/index.js +2 -68
- package/react/dist/index.js.map +1 -1
- package/react/package.json +5 -5
- package/react-devtools/dist/index.cjs +2268 -198
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.css +2 -2
- package/react-devtools/dist/index.d.cts +148 -24
- package/react-devtools/dist/index.js +57 -297
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/package.json +5 -5
- package/realtime-client/dist/index.cjs +1585 -35
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.cts +382 -12
- package/realtime-client/dist/index.js +2 -165
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-client/package.json +5 -5
- package/realtime-react/dist/index.cjs +1782 -35
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.cts +49 -9
- package/realtime-react/dist/index.js +4 -66
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/package.json +5 -5
- package/realtime-server/dist/index.cjs +1604 -58
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.cts +391 -11
- package/realtime-server/dist/index.js +27 -21
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-server/package.json +6 -6
- package/realtime-testing/dist/index.cjs +2352 -16
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.d.cts +486 -3
- package/realtime-testing/dist/index.js +10 -31
- package/realtime-testing/dist/index.js.map +1 -1
- package/realtime-testing/package.json +5 -5
- package/transceivers/set-rtx/dist/index.cjs +31 -10
- package/transceivers/set-rtx/dist/index.cjs.map +1 -1
- package/transceivers/set-rtx/dist/index.d.cts +29 -3
- package/transceivers/set-rtx/dist/index.js +2 -3
- package/transceivers/set-rtx/dist/index.js.map +1 -1
- package/transceivers/set-rtx/package.json +6 -6
- package/data/dist/index.d.ts +0 -158
- package/data/dist/metafile-cjs.json +0 -1
- package/data/dist/metafile-esm.json +0 -1
- package/dist/index.d.ts +0 -243
- package/dist/metafile-esm.json +0 -1
- package/internal/dist/index.d.ts +0 -421
- package/internal/dist/metafile-cjs.json +0 -1
- package/internal/dist/metafile-esm.json +0 -1
- package/introspection/dist/index.d.ts +0 -24
- package/introspection/dist/metafile-cjs.json +0 -1
- package/introspection/dist/metafile-esm.json +0 -1
- package/json/dist/index.d.ts +0 -51
- package/json/dist/metafile-cjs.json +0 -1
- package/json/dist/metafile-esm.json +0 -1
- package/react/dist/index.d.ts +0 -23
- package/react/dist/metafile-cjs.json +0 -1
- package/react/dist/metafile-esm.json +0 -1
- package/react-devtools/dist/index.d.ts +0 -341
- package/react-devtools/dist/metafile-cjs.json +0 -1
- package/react-devtools/dist/metafile-esm.json +0 -1
- package/realtime-client/dist/index.d.ts +0 -22
- package/realtime-client/dist/metafile-cjs.json +0 -1
- package/realtime-client/dist/metafile-esm.json +0 -1
- package/realtime-react/dist/index.d.ts +0 -27
- package/realtime-react/dist/metafile-cjs.json +0 -1
- package/realtime-react/dist/metafile-esm.json +0 -1
- package/realtime-server/dist/index.d.ts +0 -25
- package/realtime-server/dist/metafile-cjs.json +0 -1
- package/realtime-server/dist/metafile-esm.json +0 -1
- package/realtime-testing/dist/index.d.ts +0 -49
- package/realtime-testing/dist/metafile-cjs.json +0 -1
- package/realtime-testing/dist/metafile-esm.json +0 -1
- package/transceivers/set-rtx/dist/index.d.ts +0 -40
- package/transceivers/set-rtx/dist/metafile-cjs.json +0 -1
- package/transceivers/set-rtx/dist/metafile-esm.json +0 -1
|
@@ -1,12 +1,382 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
declare class Subject<T> {
|
|
2
|
+
Subscriber: (value: T) => void;
|
|
3
|
+
subscribers: Map<string, this[`Subscriber`]>;
|
|
4
|
+
subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
|
|
5
|
+
private unsubscribe;
|
|
6
|
+
next(value: T): void;
|
|
7
|
+
}
|
|
8
|
+
declare class StatefulSubject<T> extends Subject<T> {
|
|
9
|
+
state: T;
|
|
10
|
+
constructor(initialState: T);
|
|
11
|
+
next(value: T): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type Selector<T> = {
|
|
15
|
+
key: string;
|
|
16
|
+
type: `selector`;
|
|
17
|
+
family?: FamilyMetadata;
|
|
18
|
+
install: (store: Store) => void;
|
|
19
|
+
subject: Subject<{
|
|
20
|
+
newValue: T;
|
|
21
|
+
oldValue: T;
|
|
22
|
+
}>;
|
|
23
|
+
get: () => T;
|
|
24
|
+
set: (newValue: T | ((oldValue: T) => T)) => void;
|
|
25
|
+
};
|
|
26
|
+
type ReadonlySelector<T> = {
|
|
27
|
+
key: string;
|
|
28
|
+
type: `readonly_selector`;
|
|
29
|
+
family?: FamilyMetadata;
|
|
30
|
+
install: (store: Store) => void;
|
|
31
|
+
subject: Subject<{
|
|
32
|
+
newValue: T;
|
|
33
|
+
oldValue: T;
|
|
34
|
+
}>;
|
|
35
|
+
get: () => T;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
type Transaction<ƒ extends ƒn> = {
|
|
39
|
+
key: string;
|
|
40
|
+
type: `transaction`;
|
|
41
|
+
install: (store: Store) => void;
|
|
42
|
+
subject: Subject<TransactionUpdate<ƒ>>;
|
|
43
|
+
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type TransactionMeta<ƒ extends ƒn> = {
|
|
47
|
+
phase: `applying` | `building`;
|
|
48
|
+
time: number;
|
|
49
|
+
update: TransactionUpdate<ƒ>;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type primitive = boolean | number | string | null;
|
|
53
|
+
|
|
54
|
+
type Serializable = primitive | Readonly<{
|
|
55
|
+
[key: string]: Serializable;
|
|
56
|
+
}> | ReadonlyArray<Serializable>;
|
|
57
|
+
type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
|
|
58
|
+
|
|
59
|
+
type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
|
|
60
|
+
type Cardinality = `1:1` | `1:n` | `n:n`;
|
|
61
|
+
|
|
62
|
+
interface JunctionEntries<Content extends Object$1 | null> extends Object$1 {
|
|
63
|
+
readonly relations: [string, string[]][];
|
|
64
|
+
readonly contents: [string, Content][];
|
|
65
|
+
}
|
|
66
|
+
interface JunctionSchema<ASide extends string, BSide extends string> extends Object$1 {
|
|
67
|
+
readonly between: [a: ASide, b: BSide];
|
|
68
|
+
readonly cardinality: Cardinality;
|
|
69
|
+
}
|
|
70
|
+
type BaseExternalStoreConfiguration = {
|
|
71
|
+
addRelation: (a: string, b: string) => void;
|
|
72
|
+
deleteRelation: (a: string, b: string) => void;
|
|
73
|
+
replaceRelationsSafely: (a: string, bs: string[]) => void;
|
|
74
|
+
replaceRelationsUnsafely: (a: string, bs: string[]) => void;
|
|
75
|
+
getRelatedKeys: (key: string) => Set<string> | undefined;
|
|
76
|
+
has: (a: string, b?: string) => boolean;
|
|
77
|
+
};
|
|
78
|
+
type ExternalStoreWithContentConfiguration<Content extends Object$1> = {
|
|
79
|
+
getContent: (contentKey: string) => Content | undefined;
|
|
80
|
+
setContent: (contentKey: string, content: Content) => void;
|
|
81
|
+
deleteContent: (contentKey: string) => void;
|
|
82
|
+
};
|
|
83
|
+
type Empty<Obj extends object> = {
|
|
84
|
+
[Key in keyof Obj]?: undefined;
|
|
85
|
+
};
|
|
86
|
+
type ExternalStoreConfiguration<Content extends Object$1 | null> = Content extends Object$1 ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Object$1>>;
|
|
87
|
+
type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
|
|
88
|
+
externalStore?: ExternalStoreConfiguration<Content>;
|
|
89
|
+
isContent?: Refinement<unknown, Content>;
|
|
90
|
+
makeContentKey?: (a: string, b: string) => string;
|
|
91
|
+
};
|
|
92
|
+
type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
|
|
93
|
+
declare class Junction<const ASide extends string, const BSide extends string, const Content extends Object$1 | null = null> {
|
|
94
|
+
readonly a: ASide;
|
|
95
|
+
readonly b: BSide;
|
|
96
|
+
readonly cardinality: Cardinality;
|
|
97
|
+
readonly relations: Map<string, Set<string>>;
|
|
98
|
+
readonly contents: Map<string, Content>;
|
|
99
|
+
isContent: Refinement<unknown, Content> | null;
|
|
100
|
+
makeContentKey: (a: string, b: string) => string;
|
|
101
|
+
getRelatedKeys(key: string): Set<string> | undefined;
|
|
102
|
+
protected addRelation(a: string, b: string): void;
|
|
103
|
+
protected deleteRelation(a: string, b: string): void;
|
|
104
|
+
protected replaceRelationsUnsafely(a: string, bs: string[]): void;
|
|
105
|
+
protected replaceRelationsSafely(a: string, bs: string[]): void;
|
|
106
|
+
protected getContentInternal(contentKey: string): Content | undefined;
|
|
107
|
+
protected setContent(contentKey: string, content: Content): void;
|
|
108
|
+
protected deleteContent(contentKey: string): void;
|
|
109
|
+
constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
|
|
110
|
+
toJSON(): JunctionJSON<ASide, BSide, Content>;
|
|
111
|
+
set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
|
|
112
|
+
set(relation: {
|
|
113
|
+
[Key in ASide | BSide]: string;
|
|
114
|
+
}, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
|
|
115
|
+
delete(a: string, b?: string): this;
|
|
116
|
+
delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
|
|
117
|
+
getRelatedKey(key: string): string | undefined;
|
|
118
|
+
replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
|
|
119
|
+
reckless: boolean;
|
|
120
|
+
}): this;
|
|
121
|
+
getContent(a: string, b: string): Content | undefined;
|
|
122
|
+
getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
|
|
123
|
+
has(a: string, b?: string): boolean;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
interface Lineage {
|
|
127
|
+
parent: typeof this | null;
|
|
128
|
+
child: typeof this | null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface Transceiver<Signal extends Serializable> {
|
|
132
|
+
do: (update: Signal) => void;
|
|
133
|
+
undo: (update: Signal) => void;
|
|
134
|
+
subscribe: (key: string, fn: (update: Signal) => void) => () => void;
|
|
135
|
+
cacheUpdateNumber: number;
|
|
136
|
+
getUpdateNumber: (update: Signal) => number;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @internal Give the tracker a transceiver state and a store, and it will
|
|
141
|
+
* subscribe to the transceiver's inner value. When the inner value changes,
|
|
142
|
+
* the tracker will update its own state to reflect the change.
|
|
143
|
+
*/
|
|
144
|
+
declare class Tracker<Mutable extends Transceiver<any>> {
|
|
145
|
+
private Update;
|
|
146
|
+
private initializeState;
|
|
147
|
+
private unsubscribeFromInnerValue;
|
|
148
|
+
private observeCore;
|
|
149
|
+
private updateCore;
|
|
150
|
+
mutableState: MutableAtomToken<Mutable, Serializable>;
|
|
151
|
+
latestUpdateState: AtomToken<typeof this.Update | null>;
|
|
152
|
+
constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
interface MutableAtom<T> extends Atom<T> {
|
|
156
|
+
mutable: true;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
type OperationProgress = {
|
|
160
|
+
open: false;
|
|
161
|
+
} | {
|
|
162
|
+
open: true;
|
|
163
|
+
done: Set<string>;
|
|
164
|
+
prev: Map<string, any>;
|
|
165
|
+
time: number;
|
|
166
|
+
token: StateToken<any>;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
type TimelineAtomUpdate = StateUpdate<unknown> & {
|
|
170
|
+
key: string;
|
|
171
|
+
type: `atom_update`;
|
|
172
|
+
timestamp: number;
|
|
173
|
+
family?: FamilyMetadata;
|
|
174
|
+
};
|
|
175
|
+
type TimelineSelectorUpdate = {
|
|
176
|
+
key: string;
|
|
177
|
+
type: `selector_update`;
|
|
178
|
+
timestamp: number;
|
|
179
|
+
atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
|
|
180
|
+
};
|
|
181
|
+
type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
182
|
+
key: string;
|
|
183
|
+
type: `transaction_update`;
|
|
184
|
+
timestamp: number;
|
|
185
|
+
};
|
|
186
|
+
type Timeline = {
|
|
187
|
+
type: `timeline`;
|
|
188
|
+
key: string;
|
|
189
|
+
at: number;
|
|
190
|
+
shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
|
|
191
|
+
timeTraveling: `into_future` | `into_past` | null;
|
|
192
|
+
history: TimelineUpdate[];
|
|
193
|
+
selectorTime: number | null;
|
|
194
|
+
transactionKey: string | null;
|
|
195
|
+
install: (store: Store) => void;
|
|
196
|
+
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
declare class Store implements Lineage {
|
|
200
|
+
parent: Store | null;
|
|
201
|
+
child: Store | null;
|
|
202
|
+
valueMap: Map<string, any>;
|
|
203
|
+
atoms: Map<string, Atom<any> | MutableAtom<any>>;
|
|
204
|
+
selectors: Map<string, Selector<any>>;
|
|
205
|
+
readonlySelectors: Map<string, ReadonlySelector<any>>;
|
|
206
|
+
trackers: Map<string, Tracker<Transceiver<any>>>;
|
|
207
|
+
families: Map<string, AtomFamily<any, any> | ReadonlySelectorFamily<any, any> | SelectorFamily<any, any>>;
|
|
208
|
+
timelines: Map<string, Timeline>;
|
|
209
|
+
transactions: Map<string, Transaction<ƒn>>;
|
|
210
|
+
atomsThatAreDefault: Set<string>;
|
|
211
|
+
timelineAtoms: Junction<"timelineKey", "atomKey", null>;
|
|
212
|
+
selectorAtoms: Junction<"selectorKey", "atomKey", null>;
|
|
213
|
+
selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
|
|
214
|
+
source: string;
|
|
215
|
+
}>;
|
|
216
|
+
subject: {
|
|
217
|
+
atomCreation: Subject<AtomToken<unknown>>;
|
|
218
|
+
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
219
|
+
transactionCreation: Subject<TransactionToken<ƒn>>;
|
|
220
|
+
timelineCreation: Subject<TimelineToken>;
|
|
221
|
+
transactionApplying: StatefulSubject<TransactionMeta<ƒn> | null>;
|
|
222
|
+
operationStatus: Subject<OperationProgress>;
|
|
223
|
+
};
|
|
224
|
+
operation: OperationProgress;
|
|
225
|
+
transactionMeta: TransactionMeta<ƒn> | null;
|
|
226
|
+
config: {
|
|
227
|
+
name: string;
|
|
228
|
+
};
|
|
229
|
+
loggers: AtomIOLogger[];
|
|
230
|
+
logger: Logger;
|
|
231
|
+
constructor(name: string, store?: Store | null);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
type Atom<T> = {
|
|
235
|
+
key: string;
|
|
236
|
+
type: `atom`;
|
|
237
|
+
family?: FamilyMetadata;
|
|
238
|
+
install: (store: Store) => void;
|
|
239
|
+
subject: Subject<{
|
|
240
|
+
newValue: T;
|
|
241
|
+
oldValue: T;
|
|
242
|
+
}>;
|
|
243
|
+
default: T | (() => T);
|
|
244
|
+
cleanup?: () => void;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
|
|
248
|
+
key: string;
|
|
249
|
+
type: `atom_family`;
|
|
250
|
+
subject: Subject<AtomToken<T>>;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
declare const LoggerIconDictionary: {
|
|
254
|
+
readonly "\u231B": "Timeline event fully captured";
|
|
255
|
+
readonly "\u23E9": "Timeline redo";
|
|
256
|
+
readonly "\u23EA": "Timeline undo";
|
|
257
|
+
readonly "\u23ED\uFE0F": "Transaction redo";
|
|
258
|
+
readonly "\u23EE\uFE0F": "Transaction undo";
|
|
259
|
+
readonly "\u23F3": "Timeline event partially captured";
|
|
260
|
+
readonly "\u23F9\uFE0F": "Time-travel complete";
|
|
261
|
+
readonly "\uD83D\uDC81": "Notice";
|
|
262
|
+
readonly "\uD83D\uDD04": "Realtime transaction synchronized";
|
|
263
|
+
readonly "\u2705": "Realtime transaction success";
|
|
264
|
+
readonly "\u2728": "Computation complete";
|
|
265
|
+
readonly "\u274C": "Conflict prevents attempted action";
|
|
266
|
+
readonly "\u2B55": "Operation start";
|
|
267
|
+
readonly "\uD83D\uDC1E": "Possible bug in AtomIO";
|
|
268
|
+
readonly "\uD83D\uDC40": "Subscription added";
|
|
269
|
+
readonly "\uD83D\uDC6A": "Family member added";
|
|
270
|
+
readonly "\uD83D\uDCC1": "Stow update";
|
|
271
|
+
readonly "\uD83D\uDCC3": "Copy mutable";
|
|
272
|
+
readonly "\uD83D\uDCD6": "Read state";
|
|
273
|
+
readonly "\uD83D\uDCDD": "Write state";
|
|
274
|
+
readonly "\uD83D\uDCE2": "Notify subscribers";
|
|
275
|
+
readonly "\uD83D\uDD0C": "Register dependency";
|
|
276
|
+
readonly "\uD83D\uDD0D": "Discover root";
|
|
277
|
+
readonly "\uD83D\uDD25": "Delete state";
|
|
278
|
+
readonly "\uD83D\uDD27": "Create mutable atom";
|
|
279
|
+
readonly "\uD83D\uDD28": "Create immutable atom";
|
|
280
|
+
readonly "\uD83D\uDD34": "Operation complete";
|
|
281
|
+
readonly "\uD83D\uDDD1": "Evict cached value";
|
|
282
|
+
readonly "\uD83D\uDCA5": "Caught";
|
|
283
|
+
readonly "\uD83D\uDE48": "Subscription canceled";
|
|
284
|
+
readonly "\uD83D\uDEC4": "Apply transaction";
|
|
285
|
+
readonly "\uD83D\uDEE0\uFE0F": "Install atom into store";
|
|
286
|
+
readonly "\uD83D\uDEEB": "Begin transaction";
|
|
287
|
+
readonly "\uD83D\uDEEC": "Complete transaction";
|
|
288
|
+
readonly "\uD83E\uDDEE": "Computing selector";
|
|
289
|
+
readonly "\uD83E\uDDF9": "Prepare to evict";
|
|
290
|
+
readonly "\uD83E\uDE82": "Abort transaction";
|
|
291
|
+
};
|
|
292
|
+
type LoggerIcon = keyof typeof LoggerIconDictionary;
|
|
293
|
+
declare const LOG_LEVELS: readonly ["info", "warn", "error"];
|
|
294
|
+
type LogLevel = (typeof LOG_LEVELS)[number];
|
|
295
|
+
type LogFn = (icon: LoggerIcon, tokenType: `atom` | `readonly_selector` | `selector` | `state` | `timeline` | `transaction` | `unknown`, tokenKey: string, message: string, ...rest: unknown[]) => void;
|
|
296
|
+
type LogFilter = (...params: Parameters<LogFn>) => boolean;
|
|
297
|
+
type Logger = Record<LogLevel, LogFn>;
|
|
298
|
+
declare class AtomIOLogger implements Logger {
|
|
299
|
+
logLevel: `error` | `info` | `warn` | null;
|
|
300
|
+
private readonly filter?;
|
|
301
|
+
private readonly logger;
|
|
302
|
+
constructor(logLevel: `error` | `info` | `warn` | null, filter?: LogFilter | undefined, logger?: Logger);
|
|
303
|
+
error: LogFn;
|
|
304
|
+
info: LogFn;
|
|
305
|
+
warn: LogFn;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
type TransactionToken<_> = {
|
|
309
|
+
key: string;
|
|
310
|
+
type: `transaction`;
|
|
311
|
+
__brand?: _;
|
|
312
|
+
};
|
|
313
|
+
type TransactionUpdate<ƒ extends ƒn> = {
|
|
314
|
+
key: string;
|
|
315
|
+
updates: (KeyedStateUpdate<unknown> | TransactionUpdate<ƒn>)[];
|
|
316
|
+
params: Parameters<ƒ>;
|
|
317
|
+
output: ReturnType<ƒ>;
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
|
|
321
|
+
key: string;
|
|
322
|
+
type: `selector_family`;
|
|
323
|
+
subject: Subject<SelectorToken<T>>;
|
|
324
|
+
};
|
|
325
|
+
type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
326
|
+
key: string;
|
|
327
|
+
type: `readonly_selector_family`;
|
|
328
|
+
subject: Subject<ReadonlySelectorToken<T>>;
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
type StateUpdate<T> = {
|
|
332
|
+
newValue: T;
|
|
333
|
+
oldValue: T;
|
|
334
|
+
};
|
|
335
|
+
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
336
|
+
key: string;
|
|
337
|
+
family?: FamilyMetadata;
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
type TimelineToken = {
|
|
341
|
+
key: string;
|
|
342
|
+
type: `timeline`;
|
|
343
|
+
};
|
|
344
|
+
type TimelineUpdate = TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate;
|
|
345
|
+
|
|
346
|
+
type ƒn = (...parameters: any[]) => any;
|
|
347
|
+
type AtomToken<_> = {
|
|
348
|
+
key: string;
|
|
349
|
+
type: `atom`;
|
|
350
|
+
family?: FamilyMetadata;
|
|
351
|
+
__brand?: _;
|
|
352
|
+
};
|
|
353
|
+
interface MutableAtomToken<T extends Transceiver<any>, J extends Serializable> extends AtomToken<T> {
|
|
354
|
+
__asJSON?: J;
|
|
355
|
+
__update?: T extends Transceiver<infer Update> ? Update : never;
|
|
356
|
+
}
|
|
357
|
+
type SelectorToken<_> = {
|
|
358
|
+
key: string;
|
|
359
|
+
type: `selector`;
|
|
360
|
+
family?: FamilyMetadata;
|
|
361
|
+
__brand?: _;
|
|
362
|
+
};
|
|
363
|
+
type StateToken<T> = AtomToken<T> | SelectorToken<T>;
|
|
364
|
+
type ReadonlySelectorToken<_> = {
|
|
365
|
+
key: string;
|
|
366
|
+
type: `readonly_selector`;
|
|
367
|
+
family?: FamilyMetadata;
|
|
368
|
+
__brand?: _;
|
|
369
|
+
};
|
|
370
|
+
type FamilyMetadata = {
|
|
371
|
+
key: string;
|
|
372
|
+
subKey: string;
|
|
373
|
+
};
|
|
4
374
|
|
|
5
375
|
type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>;
|
|
6
376
|
|
|
7
377
|
type SelectorTokenIndex = StateTokenIndex<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
8
378
|
|
|
9
|
-
declare const attachIntrospectionStates: (store?:
|
|
379
|
+
declare const attachIntrospectionStates: (store?: Store) => {
|
|
10
380
|
atomIndex: ReadonlySelectorToken<AtomTokenIndex>;
|
|
11
381
|
selectorIndex: ReadonlySelectorToken<SelectorTokenIndex>;
|
|
12
382
|
transactionIndex: ReadonlySelectorToken<TransactionToken<ƒn>[]>;
|
|
@@ -1,318 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __defProps = Object.defineProperties;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
-
var attachAtomIndex = (store = IMPLICIT.STORE) => {
|
|
24
|
-
const atomTokenIndexState__INTERNAL = createAtom(
|
|
25
|
-
{
|
|
26
|
-
key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index (Internal)`,
|
|
27
|
-
default: () => {
|
|
28
|
-
const defaultAtomIndex = [...store.atoms].filter(([key]) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`)).reduce((acc, [key]) => {
|
|
29
|
-
acc[key] = { key, type: `atom` };
|
|
30
|
-
return acc;
|
|
31
|
-
}, {});
|
|
32
|
-
return defaultAtomIndex;
|
|
33
|
-
},
|
|
34
|
-
effects: [
|
|
35
|
-
({ setSelf }) => {
|
|
36
|
-
store.subject.atomCreation.subscribe(`introspection`, (atomToken) => {
|
|
37
|
-
if (atomToken.key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const set = () => setSelf((state) => {
|
|
41
|
-
const { key, family } = atomToken;
|
|
42
|
-
if (family) {
|
|
43
|
-
const { key: familyKey, subKey } = family;
|
|
44
|
-
const current = state[familyKey];
|
|
45
|
-
if (current === void 0 || `familyMembers` in current) {
|
|
46
|
-
const familyKeyState = current || {
|
|
47
|
-
key: familyKey,
|
|
48
|
-
familyMembers: {}
|
|
49
|
-
};
|
|
50
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
51
|
-
[familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
|
|
52
|
-
familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
|
|
53
|
-
[subKey]: atomToken
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
60
|
-
[key]: atomToken
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
if (newest(store).operation.open) {
|
|
64
|
-
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
65
|
-
`introspection: waiting to update atom index`,
|
|
66
|
-
() => {
|
|
67
|
-
unsubscribe();
|
|
68
|
-
set();
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
} else {
|
|
72
|
-
set();
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
]
|
|
77
|
-
},
|
|
78
|
-
void 0,
|
|
79
|
-
store
|
|
80
|
-
);
|
|
81
|
-
return createSelector(
|
|
82
|
-
{
|
|
83
|
-
key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index`,
|
|
84
|
-
get: ({ get }) => get(atomTokenIndexState__INTERNAL)
|
|
85
|
-
},
|
|
86
|
-
void 0,
|
|
87
|
-
store
|
|
88
|
-
);
|
|
89
|
-
};
|
|
90
|
-
var attachSelectorIndex = (store = IMPLICIT.STORE) => {
|
|
91
|
-
const readonlySelectorTokenIndexState__INTERNAL = createAtom(
|
|
92
|
-
{
|
|
93
|
-
key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index (Internal)`,
|
|
94
|
-
default: () => Object.assign(
|
|
95
|
-
[...store.readonlySelectors].filter(([key]) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`)).reduce((acc, [key]) => {
|
|
96
|
-
acc[key] = { key, type: `readonly_selector` };
|
|
97
|
-
return acc;
|
|
98
|
-
}, {}),
|
|
99
|
-
[...store.selectors].reduce((acc, [key]) => {
|
|
100
|
-
acc[key] = { key, type: `selector` };
|
|
101
|
-
return acc;
|
|
102
|
-
}, {})
|
|
103
|
-
),
|
|
104
|
-
effects: [
|
|
105
|
-
({ setSelf }) => {
|
|
106
|
-
store.subject.selectorCreation.subscribe(
|
|
107
|
-
`introspection`,
|
|
108
|
-
(selectorToken) => {
|
|
109
|
-
if (selectorToken.key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
const set = () => setSelf((state) => {
|
|
113
|
-
const { key, family } = selectorToken;
|
|
114
|
-
if (family) {
|
|
115
|
-
const { key: familyKey, subKey } = family;
|
|
116
|
-
const current = state[familyKey];
|
|
117
|
-
if (current === void 0 || `familyMembers` in current) {
|
|
118
|
-
const familyKeyState = current || {
|
|
119
|
-
key: familyKey,
|
|
120
|
-
familyMembers: {}
|
|
121
|
-
};
|
|
122
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
123
|
-
[familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
|
|
124
|
-
familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
|
|
125
|
-
[subKey]: selectorToken
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
132
|
-
[key]: selectorToken
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
if (newest(store).operation.open) {
|
|
136
|
-
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
137
|
-
`introspection: waiting to update selector index`,
|
|
138
|
-
() => {
|
|
139
|
-
unsubscribe();
|
|
140
|
-
set();
|
|
141
|
-
}
|
|
142
|
-
);
|
|
143
|
-
} else {
|
|
144
|
-
set();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
]
|
|
150
|
-
},
|
|
151
|
-
void 0,
|
|
152
|
-
store
|
|
153
|
-
);
|
|
154
|
-
return createSelector(
|
|
155
|
-
{
|
|
156
|
-
key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index`,
|
|
157
|
-
get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL)
|
|
158
|
-
},
|
|
159
|
-
void 0,
|
|
160
|
-
IMPLICIT.STORE
|
|
161
|
-
);
|
|
162
|
-
};
|
|
163
|
-
var attachTimelineFamily = (store = IMPLICIT.STORE) => {
|
|
164
|
-
const findTimelineLogState__INTERNAL = createAtomFamily(
|
|
165
|
-
{
|
|
166
|
-
key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log (Internal)`,
|
|
167
|
-
default: (key) => {
|
|
168
|
-
var _a;
|
|
169
|
-
return (_a = store.timelines.get(key)) != null ? _a : {
|
|
170
|
-
type: `timeline`,
|
|
171
|
-
key: ``,
|
|
172
|
-
at: 0,
|
|
173
|
-
timeTraveling: null,
|
|
174
|
-
history: [],
|
|
175
|
-
selectorTime: null,
|
|
176
|
-
transactionKey: null,
|
|
177
|
-
install: () => {
|
|
178
|
-
},
|
|
179
|
-
subject: new Subject()
|
|
180
|
-
};
|
|
181
|
-
},
|
|
182
|
-
effects: (key) => [
|
|
183
|
-
({ setSelf }) => {
|
|
184
|
-
const tl = store.timelines.get(key);
|
|
185
|
-
tl == null ? void 0 : tl.subject.subscribe(`introspection`, (_) => {
|
|
186
|
-
if (store.operation.open === true) {
|
|
187
|
-
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
188
|
-
`introspection`,
|
|
189
|
-
(operationStatus) => {
|
|
190
|
-
if (operationStatus.open === false) {
|
|
191
|
-
unsubscribe();
|
|
192
|
-
setSelf(__spreadValues({}, tl));
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
);
|
|
196
|
-
} else {
|
|
197
|
-
setSelf(__spreadValues({}, tl));
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
]
|
|
202
|
-
},
|
|
203
|
-
store
|
|
204
|
-
);
|
|
205
|
-
const findTimelineLogState = createSelectorFamily(
|
|
206
|
-
{
|
|
207
|
-
key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log`,
|
|
208
|
-
get: (key) => ({ get }) => get(findTimelineLogState__INTERNAL(key))
|
|
209
|
-
},
|
|
210
|
-
store
|
|
211
|
-
);
|
|
212
|
-
return findTimelineLogState;
|
|
213
|
-
};
|
|
214
|
-
var attachTimelineIndex = (store = IMPLICIT.STORE) => {
|
|
215
|
-
const timelineTokenIndexState__INTERNAL = createAtom(
|
|
216
|
-
{
|
|
217
|
-
key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index (Internal)`,
|
|
218
|
-
default: () => [...store.timelines].map(([key]) => {
|
|
219
|
-
return { key, type: `timeline` };
|
|
220
|
-
}),
|
|
221
|
-
effects: [
|
|
222
|
-
({ setSelf }) => {
|
|
223
|
-
store.subject.timelineCreation.subscribe(
|
|
224
|
-
`introspection`,
|
|
225
|
-
(timelineToken) => {
|
|
226
|
-
setSelf((state) => [...state, timelineToken]);
|
|
227
|
-
}
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
]
|
|
231
|
-
},
|
|
232
|
-
void 0,
|
|
233
|
-
store
|
|
234
|
-
);
|
|
235
|
-
const timelineTokenIndex = createSelector(
|
|
236
|
-
{
|
|
237
|
-
key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index`,
|
|
238
|
-
get: ({ get }) => get(timelineTokenIndexState__INTERNAL)
|
|
239
|
-
},
|
|
240
|
-
void 0,
|
|
241
|
-
store
|
|
242
|
-
);
|
|
243
|
-
return timelineTokenIndex;
|
|
244
|
-
};
|
|
245
|
-
var attachTransactionIndex = (store = IMPLICIT.STORE) => {
|
|
246
|
-
const transactionTokenIndexState__INTERNAL = createAtom(
|
|
247
|
-
{
|
|
248
|
-
key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index (Internal)`,
|
|
249
|
-
default: () => [...store.transactions].map(([key]) => {
|
|
250
|
-
return { key, type: `transaction` };
|
|
251
|
-
}),
|
|
252
|
-
effects: [
|
|
253
|
-
({ setSelf }) => {
|
|
254
|
-
store.subject.transactionCreation.subscribe(
|
|
255
|
-
`introspection`,
|
|
256
|
-
(transactionToken) => {
|
|
257
|
-
setSelf((state) => [...state, transactionToken]);
|
|
258
|
-
}
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
]
|
|
262
|
-
},
|
|
263
|
-
void 0,
|
|
264
|
-
store
|
|
265
|
-
);
|
|
266
|
-
const transactionTokenIndex = createSelector(
|
|
267
|
-
{
|
|
268
|
-
key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index`,
|
|
269
|
-
get: ({ get }) => get(transactionTokenIndexState__INTERNAL)
|
|
270
|
-
},
|
|
271
|
-
void 0,
|
|
272
|
-
store
|
|
273
|
-
);
|
|
274
|
-
return transactionTokenIndex;
|
|
275
|
-
};
|
|
276
|
-
var attachTransactionLogs = (store = IMPLICIT.STORE) => {
|
|
277
|
-
const findTransactionUpdateLog = createAtomFamily(
|
|
278
|
-
{
|
|
279
|
-
key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log (Internal)`,
|
|
280
|
-
default: () => [],
|
|
281
|
-
effects: (key) => [
|
|
282
|
-
({ setSelf }) => {
|
|
283
|
-
const tx = store.transactions.get(key);
|
|
284
|
-
tx == null ? void 0 : tx.subject.subscribe(`introspection`, (transactionUpdate) => {
|
|
285
|
-
if (transactionUpdate.key === key) {
|
|
286
|
-
setSelf((state) => [...state, transactionUpdate]);
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
]
|
|
291
|
-
},
|
|
292
|
-
store
|
|
293
|
-
);
|
|
294
|
-
const findTransactionUpdateLogState = createSelectorFamily(
|
|
295
|
-
{
|
|
296
|
-
key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log`,
|
|
297
|
-
get: (key) => ({ get }) => get(findTransactionUpdateLog(key))
|
|
298
|
-
},
|
|
299
|
-
store
|
|
300
|
-
);
|
|
301
|
-
return findTransactionUpdateLogState;
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
// src/attach-introspection-states.ts
|
|
305
|
-
var attachIntrospectionStates = (store = Internal.IMPLICIT.STORE) => {
|
|
306
|
-
return {
|
|
307
|
-
atomIndex: attachAtomIndex(store),
|
|
308
|
-
selectorIndex: attachSelectorIndex(store),
|
|
309
|
-
transactionIndex: attachTransactionIndex(store),
|
|
310
|
-
findTransactionLogState: attachTransactionLogs(store),
|
|
311
|
-
timelineIndex: attachTimelineIndex(store),
|
|
312
|
-
findTimelineState: attachTimelineFamily(store)
|
|
313
|
-
};
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
export { attachIntrospectionStates };
|
|
1
|
+
export { attachIntrospectionStates } from '../../dist/chunk-CK7GNCU5.js';
|
|
2
|
+
import '../../dist/chunk-TE3ZSTQ6.js';
|
|
317
3
|
//# sourceMappingURL=out.js.map
|
|
318
4
|
//# sourceMappingURL=index.js.map
|