atom.io 0.14.1 → 0.14.3
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 +12 -64
- package/data/dist/index.cjs.map +1 -1
- package/data/dist/index.d.cts +2 -0
- package/data/dist/index.d.ts +459 -0
- package/data/dist/index.js +1 -1
- package/dist/{chunk-KW7RA7IM.js → chunk-C4YZZNRH.js} +4 -4
- package/dist/{chunk-LFXB7Y6M.js → chunk-CWKKQKVQ.js} +2 -2
- package/dist/{chunk-CK7GNCU5.js → chunk-GMN5KH6A.js} +2 -2
- package/dist/{chunk-5VJ77LZE.js → chunk-N7ADBQJG.js} +2 -2
- package/dist/{chunk-TE3ZSTQ6.js → chunk-PURABO5G.js} +92 -27
- package/dist/chunk-PURABO5G.js.map +1 -0
- package/dist/index.cjs +106 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +493 -0
- package/dist/index.js +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -0
- package/internal/dist/index.cjs +93 -29
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.cts +6 -4
- package/internal/dist/index.d.ts +622 -0
- package/internal/dist/index.js +1 -1
- package/internal/src/atom/create-atom.ts +3 -1
- package/internal/src/families/create-atom-family.ts +3 -4
- package/internal/src/mutable/get-update-family.ts +23 -0
- package/internal/src/mutable/index.ts +1 -4
- package/internal/src/mutable/is-mutable.ts +44 -0
- package/internal/src/mutable/tracker.ts +9 -2
- package/internal/src/subject.ts +2 -1
- package/internal/src/timeline/add-atom-to-timeline.ts +10 -1
- package/internal/src/timeline/create-timeline.ts +44 -16
- package/introspection/dist/index.cjs +12 -64
- package/introspection/dist/index.cjs.map +1 -1
- package/introspection/dist/index.d.cts +2 -0
- package/introspection/dist/index.d.ts +396 -0
- package/introspection/dist/index.js +2 -2
- package/json/dist/index.cjs +9 -64
- package/json/dist/index.cjs.map +1 -1
- package/json/dist/index.d.cts +2 -0
- package/json/dist/index.d.ts +417 -0
- package/json/dist/index.js +1 -1
- package/package.json +3 -2
- package/react/dist/index.cjs +9 -64
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.cts +2 -0
- package/react/dist/index.d.ts +396 -0
- package/react/dist/index.js +2 -2
- package/react-devtools/dist/index.cjs +12 -64
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.d.cts +2 -0
- package/react-devtools/dist/index.d.ts +467 -0
- package/react-devtools/dist/index.js +3 -3
- package/realtime-client/dist/index.cjs +9 -64
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.cts +2 -0
- package/realtime-client/dist/index.d.ts +394 -0
- package/realtime-client/dist/index.js +2 -2
- package/realtime-react/dist/index.cjs +9 -64
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.ts +67 -0
- package/realtime-react/dist/index.js +4 -4
- package/realtime-server/dist/index.cjs +9 -64
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.cts +4 -1
- package/realtime-server/dist/index.d.ts +408 -0
- package/realtime-server/dist/index.js +1 -1
- package/realtime-testing/dist/index.cjs +104 -79
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.d.cts +4 -1
- package/realtime-testing/dist/index.d.ts +535 -0
- package/realtime-testing/dist/index.js +4 -4
- package/src/atom.ts +3 -1
- package/transceivers/set-rtx/dist/index.cjs +2 -1
- package/transceivers/set-rtx/dist/index.cjs.map +1 -1
- package/transceivers/set-rtx/dist/index.d.ts +66 -0
- package/transceivers/set-rtx/dist/index.js +1 -1
- package/dist/chunk-TE3ZSTQ6.js.map +0 -1
- package/internal/src/mutable/is-atom-token-mutable.ts +0 -7
- /package/dist/{chunk-KW7RA7IM.js.map → chunk-C4YZZNRH.js.map} +0 -0
- /package/dist/{chunk-LFXB7Y6M.js.map → chunk-CWKKQKVQ.js.map} +0 -0
- /package/dist/{chunk-CK7GNCU5.js.map → chunk-GMN5KH6A.js.map} +0 -0
- /package/dist/{chunk-5VJ77LZE.js.map → chunk-N7ADBQJG.js.map} +0 -0
|
@@ -234,6 +234,7 @@ declare class Store implements Lineage {
|
|
|
234
234
|
type Atom<T> = {
|
|
235
235
|
key: string;
|
|
236
236
|
type: `atom`;
|
|
237
|
+
mutable?: boolean;
|
|
237
238
|
family?: FamilyMetadata;
|
|
238
239
|
install: (store: Store) => void;
|
|
239
240
|
subject: Subject<{
|
|
@@ -248,6 +249,7 @@ type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomTok
|
|
|
248
249
|
key: string;
|
|
249
250
|
type: `atom_family`;
|
|
250
251
|
subject: Subject<AtomToken<T>>;
|
|
252
|
+
mutable?: boolean;
|
|
251
253
|
};
|
|
252
254
|
|
|
253
255
|
declare const LoggerIconDictionary: {
|
|
@@ -0,0 +1,396 @@
|
|
|
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
|
+
mutable?: boolean;
|
|
238
|
+
family?: FamilyMetadata;
|
|
239
|
+
install: (store: Store) => void;
|
|
240
|
+
subject: Subject<{
|
|
241
|
+
newValue: T;
|
|
242
|
+
oldValue: T;
|
|
243
|
+
}>;
|
|
244
|
+
default: T | (() => T);
|
|
245
|
+
cleanup?: () => void;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
|
|
249
|
+
key: string;
|
|
250
|
+
type: `atom_family`;
|
|
251
|
+
subject: Subject<AtomToken<T>>;
|
|
252
|
+
mutable?: boolean;
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
declare const LoggerIconDictionary: {
|
|
256
|
+
readonly "\u231B": "Timeline event fully captured";
|
|
257
|
+
readonly "\u23E9": "Timeline redo";
|
|
258
|
+
readonly "\u23EA": "Timeline undo";
|
|
259
|
+
readonly "\u23ED\uFE0F": "Transaction redo";
|
|
260
|
+
readonly "\u23EE\uFE0F": "Transaction undo";
|
|
261
|
+
readonly "\u23F3": "Timeline event partially captured";
|
|
262
|
+
readonly "\u23F9\uFE0F": "Time-travel complete";
|
|
263
|
+
readonly "\uD83D\uDC81": "Notice";
|
|
264
|
+
readonly "\uD83D\uDD04": "Realtime transaction synchronized";
|
|
265
|
+
readonly "\u2705": "Realtime transaction success";
|
|
266
|
+
readonly "\u2728": "Computation complete";
|
|
267
|
+
readonly "\u274C": "Conflict prevents attempted action";
|
|
268
|
+
readonly "\u2B55": "Operation start";
|
|
269
|
+
readonly "\uD83D\uDC1E": "Possible bug in AtomIO";
|
|
270
|
+
readonly "\uD83D\uDC40": "Subscription added";
|
|
271
|
+
readonly "\uD83D\uDC6A": "Family member added";
|
|
272
|
+
readonly "\uD83D\uDCC1": "Stow update";
|
|
273
|
+
readonly "\uD83D\uDCC3": "Copy mutable";
|
|
274
|
+
readonly "\uD83D\uDCD6": "Read state";
|
|
275
|
+
readonly "\uD83D\uDCDD": "Write state";
|
|
276
|
+
readonly "\uD83D\uDCE2": "Notify subscribers";
|
|
277
|
+
readonly "\uD83D\uDD0C": "Register dependency";
|
|
278
|
+
readonly "\uD83D\uDD0D": "Discover root";
|
|
279
|
+
readonly "\uD83D\uDD25": "Delete state";
|
|
280
|
+
readonly "\uD83D\uDD27": "Create mutable atom";
|
|
281
|
+
readonly "\uD83D\uDD28": "Create immutable atom";
|
|
282
|
+
readonly "\uD83D\uDD34": "Operation complete";
|
|
283
|
+
readonly "\uD83D\uDDD1": "Evict cached value";
|
|
284
|
+
readonly "\uD83D\uDCA5": "Caught";
|
|
285
|
+
readonly "\uD83D\uDE48": "Subscription canceled";
|
|
286
|
+
readonly "\uD83D\uDEC4": "Apply transaction";
|
|
287
|
+
readonly "\uD83D\uDEE0\uFE0F": "Install atom into store";
|
|
288
|
+
readonly "\uD83D\uDEEB": "Begin transaction";
|
|
289
|
+
readonly "\uD83D\uDEEC": "Complete transaction";
|
|
290
|
+
readonly "\uD83E\uDDEE": "Computing selector";
|
|
291
|
+
readonly "\uD83E\uDDF9": "Prepare to evict";
|
|
292
|
+
readonly "\uD83E\uDE82": "Abort transaction";
|
|
293
|
+
};
|
|
294
|
+
type LoggerIcon = keyof typeof LoggerIconDictionary;
|
|
295
|
+
declare const LOG_LEVELS: readonly ["info", "warn", "error"];
|
|
296
|
+
type LogLevel = (typeof LOG_LEVELS)[number];
|
|
297
|
+
type LogFn = (icon: LoggerIcon, tokenType: `atom` | `readonly_selector` | `selector` | `state` | `timeline` | `transaction` | `unknown`, tokenKey: string, message: string, ...rest: unknown[]) => void;
|
|
298
|
+
type LogFilter = (...params: Parameters<LogFn>) => boolean;
|
|
299
|
+
type Logger = Record<LogLevel, LogFn>;
|
|
300
|
+
declare class AtomIOLogger implements Logger {
|
|
301
|
+
logLevel: `error` | `info` | `warn` | null;
|
|
302
|
+
private readonly filter?;
|
|
303
|
+
private readonly logger;
|
|
304
|
+
constructor(logLevel: `error` | `info` | `warn` | null, filter?: LogFilter | undefined, logger?: Logger);
|
|
305
|
+
error: LogFn;
|
|
306
|
+
info: LogFn;
|
|
307
|
+
warn: LogFn;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
type TransactionToken<_> = {
|
|
311
|
+
key: string;
|
|
312
|
+
type: `transaction`;
|
|
313
|
+
__brand?: _;
|
|
314
|
+
};
|
|
315
|
+
type TransactionUpdate<ƒ extends ƒn> = {
|
|
316
|
+
key: string;
|
|
317
|
+
updates: (KeyedStateUpdate<unknown> | TransactionUpdate<ƒn>)[];
|
|
318
|
+
params: Parameters<ƒ>;
|
|
319
|
+
output: ReturnType<ƒ>;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
|
|
323
|
+
key: string;
|
|
324
|
+
type: `selector_family`;
|
|
325
|
+
subject: Subject<SelectorToken<T>>;
|
|
326
|
+
};
|
|
327
|
+
type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
328
|
+
key: string;
|
|
329
|
+
type: `readonly_selector_family`;
|
|
330
|
+
subject: Subject<ReadonlySelectorToken<T>>;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
type StateUpdate<T> = {
|
|
334
|
+
newValue: T;
|
|
335
|
+
oldValue: T;
|
|
336
|
+
};
|
|
337
|
+
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
338
|
+
key: string;
|
|
339
|
+
family?: FamilyMetadata;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
type TimelineToken = {
|
|
343
|
+
key: string;
|
|
344
|
+
type: `timeline`;
|
|
345
|
+
};
|
|
346
|
+
type TimelineUpdate = TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate;
|
|
347
|
+
|
|
348
|
+
type ƒn = (...parameters: any[]) => any;
|
|
349
|
+
type AtomToken<_> = {
|
|
350
|
+
key: string;
|
|
351
|
+
type: `atom`;
|
|
352
|
+
family?: FamilyMetadata;
|
|
353
|
+
__brand?: _;
|
|
354
|
+
};
|
|
355
|
+
interface MutableAtomToken<T extends Transceiver<any>, J extends Serializable> extends AtomToken<T> {
|
|
356
|
+
__asJSON?: J;
|
|
357
|
+
__update?: T extends Transceiver<infer Update> ? Update : never;
|
|
358
|
+
}
|
|
359
|
+
type SelectorToken<_> = {
|
|
360
|
+
key: string;
|
|
361
|
+
type: `selector`;
|
|
362
|
+
family?: FamilyMetadata;
|
|
363
|
+
__brand?: _;
|
|
364
|
+
};
|
|
365
|
+
type StateToken<T> = AtomToken<T> | SelectorToken<T>;
|
|
366
|
+
type ReadonlySelectorToken<_> = {
|
|
367
|
+
key: string;
|
|
368
|
+
type: `readonly_selector`;
|
|
369
|
+
family?: FamilyMetadata;
|
|
370
|
+
__brand?: _;
|
|
371
|
+
};
|
|
372
|
+
type FamilyMetadata = {
|
|
373
|
+
key: string;
|
|
374
|
+
subKey: string;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>;
|
|
378
|
+
|
|
379
|
+
type SelectorTokenIndex = StateTokenIndex<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
380
|
+
|
|
381
|
+
declare const attachIntrospectionStates: (store?: Store) => {
|
|
382
|
+
atomIndex: ReadonlySelectorToken<AtomTokenIndex>;
|
|
383
|
+
selectorIndex: ReadonlySelectorToken<SelectorTokenIndex>;
|
|
384
|
+
transactionIndex: ReadonlySelectorToken<TransactionToken<ƒn>[]>;
|
|
385
|
+
findTransactionLogState: ReadonlySelectorFamily<TransactionUpdate<ƒn>[]>;
|
|
386
|
+
timelineIndex: ReadonlySelectorToken<TimelineToken[]>;
|
|
387
|
+
findTimelineState: ReadonlySelectorFamily<Timeline>;
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
type FamilyNode<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = {
|
|
391
|
+
key: string;
|
|
392
|
+
familyMembers: Record<string, Token>;
|
|
393
|
+
};
|
|
394
|
+
type StateTokenIndex<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = Record<string, FamilyNode<Token> | Token>;
|
|
395
|
+
|
|
396
|
+
export { type FamilyNode, type StateTokenIndex, attachIntrospectionStates };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { attachIntrospectionStates } from '../../dist/chunk-
|
|
2
|
-
import '../../dist/chunk-
|
|
1
|
+
export { attachIntrospectionStates } from '../../dist/chunk-GMN5KH6A.js';
|
|
2
|
+
import '../../dist/chunk-PURABO5G.js';
|
|
3
3
|
//# sourceMappingURL=out.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/json/dist/index.cjs
CHANGED
|
@@ -301,7 +301,8 @@ var Subject = class {
|
|
|
301
301
|
this.subscribers.delete(key);
|
|
302
302
|
}
|
|
303
303
|
next(value) {
|
|
304
|
-
|
|
304
|
+
const subscribers = this.subscribers.values();
|
|
305
|
+
for (const subscriber of subscribers) {
|
|
305
306
|
subscriber(value);
|
|
306
307
|
}
|
|
307
308
|
}
|
|
@@ -1108,35 +1109,6 @@ function createSelector(options, family, store) {
|
|
|
1108
1109
|
return createReadonlySelector(options, family, store);
|
|
1109
1110
|
}
|
|
1110
1111
|
|
|
1111
|
-
// internal/src/selector/delete-selector.ts
|
|
1112
|
-
function deleteSelector(selectorToken, store) {
|
|
1113
|
-
const target = newest(store);
|
|
1114
|
-
const { key } = selectorToken;
|
|
1115
|
-
switch (selectorToken.type) {
|
|
1116
|
-
case `selector`:
|
|
1117
|
-
target.selectors.delete(key);
|
|
1118
|
-
break;
|
|
1119
|
-
case `readonly_selector`:
|
|
1120
|
-
target.readonlySelectors.delete(key);
|
|
1121
|
-
break;
|
|
1122
|
-
}
|
|
1123
|
-
target.valueMap.delete(key);
|
|
1124
|
-
target.selectorAtoms.delete(key);
|
|
1125
|
-
const downstreamTokens = target.selectorGraph.getRelationEntries({ upstreamSelectorKey: key }).filter(([_, { source }]) => source === key).map(
|
|
1126
|
-
([downstreamSelectorKey]) => {
|
|
1127
|
-
var _a;
|
|
1128
|
-
return (_a = target.selectors.get(downstreamSelectorKey)) != null ? _a : target.readonlySelectors.get(downstreamSelectorKey);
|
|
1129
|
-
}
|
|
1130
|
-
);
|
|
1131
|
-
for (const downstreamToken of downstreamTokens) {
|
|
1132
|
-
if (downstreamToken) {
|
|
1133
|
-
deleteSelector(downstreamToken, store);
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
target.selectorGraph.delete(key);
|
|
1137
|
-
store.logger.info(`\u{1F525}`, selectorToken.type, `${key}`, `deleted`);
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
1112
|
// internal/src/subscribe/recall-state.ts
|
|
1141
1113
|
var recallState = (state, store) => {
|
|
1142
1114
|
const target = newest(store);
|
|
@@ -1255,7 +1227,8 @@ var Tracker = class {
|
|
|
1255
1227
|
}
|
|
1256
1228
|
initializeState(mutableState, store) {
|
|
1257
1229
|
const latestUpdateStateKey = `*${mutableState.key}`;
|
|
1258
|
-
|
|
1230
|
+
store.atoms.delete(latestUpdateStateKey);
|
|
1231
|
+
store.valueMap.delete(latestUpdateStateKey);
|
|
1259
1232
|
const familyMetaData = mutableState.family ? {
|
|
1260
1233
|
key: `*${mutableState.family.key}`,
|
|
1261
1234
|
subKey: mutableState.family.subKey
|
|
@@ -1268,6 +1241,10 @@ var Tracker = class {
|
|
|
1268
1241
|
familyMetaData,
|
|
1269
1242
|
store
|
|
1270
1243
|
);
|
|
1244
|
+
if (store.parent) {
|
|
1245
|
+
const parentValue = store.parent.valueMap.get(latestUpdateStateKey);
|
|
1246
|
+
store.valueMap.set(latestUpdateStateKey, parentValue);
|
|
1247
|
+
}
|
|
1271
1248
|
return latestUpdateState;
|
|
1272
1249
|
}
|
|
1273
1250
|
observeCore(mutableState, latestUpdateState, store) {
|
|
@@ -1348,7 +1325,7 @@ var Tracker = class {
|
|
|
1348
1325
|
() => {
|
|
1349
1326
|
unsubscribe();
|
|
1350
1327
|
const mutable = getState(mutableState, store);
|
|
1351
|
-
const updateNumber = mutable.getUpdateNumber(newValue);
|
|
1328
|
+
const updateNumber = newValue === null ? -1 : mutable.getUpdateNumber(newValue);
|
|
1352
1329
|
const eventOffset = updateNumber - mutable.cacheUpdateNumber;
|
|
1353
1330
|
if (newValue && eventOffset === 1) {
|
|
1354
1331
|
setState(
|
|
@@ -1545,38 +1522,6 @@ function createAtom(options, family, store) {
|
|
|
1545
1522
|
return token;
|
|
1546
1523
|
}
|
|
1547
1524
|
|
|
1548
|
-
// internal/src/atom/delete-atom.ts
|
|
1549
|
-
function deleteAtom(atomToken, store) {
|
|
1550
|
-
var _a, _b;
|
|
1551
|
-
const target = newest(store);
|
|
1552
|
-
const { key } = atomToken;
|
|
1553
|
-
const atom = target.atoms.get(key);
|
|
1554
|
-
if (!atom) {
|
|
1555
|
-
store.logger.error(
|
|
1556
|
-
`\u274C`,
|
|
1557
|
-
`atom`,
|
|
1558
|
-
`${key}`,
|
|
1559
|
-
`Tried to delete atom, but it does not exist in the store.`
|
|
1560
|
-
);
|
|
1561
|
-
}
|
|
1562
|
-
(_a = atom == null ? void 0 : atom.cleanup) == null ? void 0 : _a.call(atom);
|
|
1563
|
-
target.atoms.delete(key);
|
|
1564
|
-
target.valueMap.delete(key);
|
|
1565
|
-
const selectorKeys = target.selectorAtoms.getRelatedKeys(key);
|
|
1566
|
-
if (selectorKeys) {
|
|
1567
|
-
for (const selectorKey of selectorKeys) {
|
|
1568
|
-
const token = (_b = target.selectors.get(selectorKey)) != null ? _b : target.readonlySelectors.get(selectorKey);
|
|
1569
|
-
if (token) {
|
|
1570
|
-
deleteSelector(token, store);
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
target.selectorAtoms.delete(key);
|
|
1575
|
-
target.atomsThatAreDefault.delete(key);
|
|
1576
|
-
target.timelineAtoms.delete(key);
|
|
1577
|
-
store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
|
|
1578
|
-
}
|
|
1579
|
-
|
|
1580
1525
|
// internal/src/not-found-error.ts
|
|
1581
1526
|
var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
|
|
1582
1527
|
function prettyPrintTokenType(token) {
|