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
|
@@ -236,6 +236,7 @@ declare class Store implements Lineage {
|
|
|
236
236
|
type Atom<T> = {
|
|
237
237
|
key: string;
|
|
238
238
|
type: `atom`;
|
|
239
|
+
mutable?: boolean;
|
|
239
240
|
family?: FamilyMetadata;
|
|
240
241
|
install: (store: Store) => void;
|
|
241
242
|
subject: Subject<{
|
|
@@ -250,6 +251,7 @@ type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomTok
|
|
|
250
251
|
key: string;
|
|
251
252
|
type: `atom_family`;
|
|
252
253
|
subject: Subject<AtomToken<T>>;
|
|
254
|
+
mutable?: boolean;
|
|
253
255
|
};
|
|
254
256
|
|
|
255
257
|
declare const LoggerIconDictionary: {
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { Socket } from 'socket.io-client';
|
|
2
|
+
|
|
3
|
+
declare class Subject<T> {
|
|
4
|
+
Subscriber: (value: T) => void;
|
|
5
|
+
subscribers: Map<string, this[`Subscriber`]>;
|
|
6
|
+
subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
|
|
7
|
+
private unsubscribe;
|
|
8
|
+
next(value: T): void;
|
|
9
|
+
}
|
|
10
|
+
declare class StatefulSubject<T> extends Subject<T> {
|
|
11
|
+
state: T;
|
|
12
|
+
constructor(initialState: T);
|
|
13
|
+
next(value: T): void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type Selector<T> = {
|
|
17
|
+
key: string;
|
|
18
|
+
type: `selector`;
|
|
19
|
+
family?: FamilyMetadata;
|
|
20
|
+
install: (store: Store) => void;
|
|
21
|
+
subject: Subject<{
|
|
22
|
+
newValue: T;
|
|
23
|
+
oldValue: T;
|
|
24
|
+
}>;
|
|
25
|
+
get: () => T;
|
|
26
|
+
set: (newValue: T | ((oldValue: T) => T)) => void;
|
|
27
|
+
};
|
|
28
|
+
type ReadonlySelector<T> = {
|
|
29
|
+
key: string;
|
|
30
|
+
type: `readonly_selector`;
|
|
31
|
+
family?: FamilyMetadata;
|
|
32
|
+
install: (store: Store) => void;
|
|
33
|
+
subject: Subject<{
|
|
34
|
+
newValue: T;
|
|
35
|
+
oldValue: T;
|
|
36
|
+
}>;
|
|
37
|
+
get: () => T;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type Transaction<ƒ extends ƒn> = {
|
|
41
|
+
key: string;
|
|
42
|
+
type: `transaction`;
|
|
43
|
+
install: (store: Store) => void;
|
|
44
|
+
subject: Subject<TransactionUpdate<ƒ>>;
|
|
45
|
+
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type TransactionMeta<ƒ extends ƒn> = {
|
|
49
|
+
phase: `applying` | `building`;
|
|
50
|
+
time: number;
|
|
51
|
+
update: TransactionUpdate<ƒ>;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
type primitive = boolean | number | string | null;
|
|
55
|
+
|
|
56
|
+
type Serializable = primitive | Readonly<{
|
|
57
|
+
[key: string]: Serializable;
|
|
58
|
+
}> | ReadonlyArray<Serializable>;
|
|
59
|
+
type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
|
|
60
|
+
|
|
61
|
+
type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
|
|
62
|
+
type Cardinality = `1:1` | `1:n` | `n:n`;
|
|
63
|
+
|
|
64
|
+
interface JunctionEntries<Content extends Object$1 | null> extends Object$1 {
|
|
65
|
+
readonly relations: [string, string[]][];
|
|
66
|
+
readonly contents: [string, Content][];
|
|
67
|
+
}
|
|
68
|
+
interface JunctionSchema<ASide extends string, BSide extends string> extends Object$1 {
|
|
69
|
+
readonly between: [a: ASide, b: BSide];
|
|
70
|
+
readonly cardinality: Cardinality;
|
|
71
|
+
}
|
|
72
|
+
type BaseExternalStoreConfiguration = {
|
|
73
|
+
addRelation: (a: string, b: string) => void;
|
|
74
|
+
deleteRelation: (a: string, b: string) => void;
|
|
75
|
+
replaceRelationsSafely: (a: string, bs: string[]) => void;
|
|
76
|
+
replaceRelationsUnsafely: (a: string, bs: string[]) => void;
|
|
77
|
+
getRelatedKeys: (key: string) => Set<string> | undefined;
|
|
78
|
+
has: (a: string, b?: string) => boolean;
|
|
79
|
+
};
|
|
80
|
+
type ExternalStoreWithContentConfiguration<Content extends Object$1> = {
|
|
81
|
+
getContent: (contentKey: string) => Content | undefined;
|
|
82
|
+
setContent: (contentKey: string, content: Content) => void;
|
|
83
|
+
deleteContent: (contentKey: string) => void;
|
|
84
|
+
};
|
|
85
|
+
type Empty<Obj extends object> = {
|
|
86
|
+
[Key in keyof Obj]?: undefined;
|
|
87
|
+
};
|
|
88
|
+
type ExternalStoreConfiguration<Content extends Object$1 | null> = Content extends Object$1 ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Object$1>>;
|
|
89
|
+
type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
|
|
90
|
+
externalStore?: ExternalStoreConfiguration<Content>;
|
|
91
|
+
isContent?: Refinement<unknown, Content>;
|
|
92
|
+
makeContentKey?: (a: string, b: string) => string;
|
|
93
|
+
};
|
|
94
|
+
type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
|
|
95
|
+
declare class Junction<const ASide extends string, const BSide extends string, const Content extends Object$1 | null = null> {
|
|
96
|
+
readonly a: ASide;
|
|
97
|
+
readonly b: BSide;
|
|
98
|
+
readonly cardinality: Cardinality;
|
|
99
|
+
readonly relations: Map<string, Set<string>>;
|
|
100
|
+
readonly contents: Map<string, Content>;
|
|
101
|
+
isContent: Refinement<unknown, Content> | null;
|
|
102
|
+
makeContentKey: (a: string, b: string) => string;
|
|
103
|
+
getRelatedKeys(key: string): Set<string> | undefined;
|
|
104
|
+
protected addRelation(a: string, b: string): void;
|
|
105
|
+
protected deleteRelation(a: string, b: string): void;
|
|
106
|
+
protected replaceRelationsUnsafely(a: string, bs: string[]): void;
|
|
107
|
+
protected replaceRelationsSafely(a: string, bs: string[]): void;
|
|
108
|
+
protected getContentInternal(contentKey: string): Content | undefined;
|
|
109
|
+
protected setContent(contentKey: string, content: Content): void;
|
|
110
|
+
protected deleteContent(contentKey: string): void;
|
|
111
|
+
constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
|
|
112
|
+
toJSON(): JunctionJSON<ASide, BSide, Content>;
|
|
113
|
+
set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
|
|
114
|
+
set(relation: {
|
|
115
|
+
[Key in ASide | BSide]: string;
|
|
116
|
+
}, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
|
|
117
|
+
delete(a: string, b?: string): this;
|
|
118
|
+
delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
|
|
119
|
+
getRelatedKey(key: string): string | undefined;
|
|
120
|
+
replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
|
|
121
|
+
reckless: boolean;
|
|
122
|
+
}): this;
|
|
123
|
+
getContent(a: string, b: string): Content | undefined;
|
|
124
|
+
getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
|
|
125
|
+
has(a: string, b?: string): boolean;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
interface Lineage {
|
|
129
|
+
parent: typeof this | null;
|
|
130
|
+
child: typeof this | null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
interface Transceiver<Signal extends Serializable> {
|
|
134
|
+
do: (update: Signal) => void;
|
|
135
|
+
undo: (update: Signal) => void;
|
|
136
|
+
subscribe: (key: string, fn: (update: Signal) => void) => () => void;
|
|
137
|
+
cacheUpdateNumber: number;
|
|
138
|
+
getUpdateNumber: (update: Signal) => number;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @internal Give the tracker a transceiver state and a store, and it will
|
|
143
|
+
* subscribe to the transceiver's inner value. When the inner value changes,
|
|
144
|
+
* the tracker will update its own state to reflect the change.
|
|
145
|
+
*/
|
|
146
|
+
declare class Tracker<Mutable extends Transceiver<any>> {
|
|
147
|
+
private Update;
|
|
148
|
+
private initializeState;
|
|
149
|
+
private unsubscribeFromInnerValue;
|
|
150
|
+
private observeCore;
|
|
151
|
+
private updateCore;
|
|
152
|
+
mutableState: MutableAtomToken<Mutable, Serializable>;
|
|
153
|
+
latestUpdateState: AtomToken<typeof this.Update | null>;
|
|
154
|
+
constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
interface MutableAtom<T> extends Atom<T> {
|
|
158
|
+
mutable: true;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
type OperationProgress = {
|
|
162
|
+
open: false;
|
|
163
|
+
} | {
|
|
164
|
+
open: true;
|
|
165
|
+
done: Set<string>;
|
|
166
|
+
prev: Map<string, any>;
|
|
167
|
+
time: number;
|
|
168
|
+
token: StateToken<any>;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
type TimelineAtomUpdate = StateUpdate<unknown> & {
|
|
172
|
+
key: string;
|
|
173
|
+
type: `atom_update`;
|
|
174
|
+
timestamp: number;
|
|
175
|
+
family?: FamilyMetadata;
|
|
176
|
+
};
|
|
177
|
+
type TimelineSelectorUpdate = {
|
|
178
|
+
key: string;
|
|
179
|
+
type: `selector_update`;
|
|
180
|
+
timestamp: number;
|
|
181
|
+
atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
|
|
182
|
+
};
|
|
183
|
+
type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
184
|
+
key: string;
|
|
185
|
+
type: `transaction_update`;
|
|
186
|
+
timestamp: number;
|
|
187
|
+
};
|
|
188
|
+
type Timeline = {
|
|
189
|
+
type: `timeline`;
|
|
190
|
+
key: string;
|
|
191
|
+
at: number;
|
|
192
|
+
shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
|
|
193
|
+
timeTraveling: `into_future` | `into_past` | null;
|
|
194
|
+
history: TimelineUpdate[];
|
|
195
|
+
selectorTime: number | null;
|
|
196
|
+
transactionKey: string | null;
|
|
197
|
+
install: (store: Store) => void;
|
|
198
|
+
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
declare class Store implements Lineage {
|
|
202
|
+
parent: Store | null;
|
|
203
|
+
child: Store | null;
|
|
204
|
+
valueMap: Map<string, any>;
|
|
205
|
+
atoms: Map<string, Atom<any> | MutableAtom<any>>;
|
|
206
|
+
selectors: Map<string, Selector<any>>;
|
|
207
|
+
readonlySelectors: Map<string, ReadonlySelector<any>>;
|
|
208
|
+
trackers: Map<string, Tracker<Transceiver<any>>>;
|
|
209
|
+
families: Map<string, AtomFamily<any, any> | ReadonlySelectorFamily<any, any> | SelectorFamily<any, any>>;
|
|
210
|
+
timelines: Map<string, Timeline>;
|
|
211
|
+
transactions: Map<string, Transaction<ƒn>>;
|
|
212
|
+
atomsThatAreDefault: Set<string>;
|
|
213
|
+
timelineAtoms: Junction<"timelineKey", "atomKey", null>;
|
|
214
|
+
selectorAtoms: Junction<"selectorKey", "atomKey", null>;
|
|
215
|
+
selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
|
|
216
|
+
source: string;
|
|
217
|
+
}>;
|
|
218
|
+
subject: {
|
|
219
|
+
atomCreation: Subject<AtomToken<unknown>>;
|
|
220
|
+
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
221
|
+
transactionCreation: Subject<TransactionToken<ƒn>>;
|
|
222
|
+
timelineCreation: Subject<TimelineToken>;
|
|
223
|
+
transactionApplying: StatefulSubject<TransactionMeta<ƒn> | null>;
|
|
224
|
+
operationStatus: Subject<OperationProgress>;
|
|
225
|
+
};
|
|
226
|
+
operation: OperationProgress;
|
|
227
|
+
transactionMeta: TransactionMeta<ƒn> | null;
|
|
228
|
+
config: {
|
|
229
|
+
name: string;
|
|
230
|
+
};
|
|
231
|
+
loggers: AtomIOLogger[];
|
|
232
|
+
logger: Logger;
|
|
233
|
+
constructor(name: string, store?: Store | null);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
type Atom<T> = {
|
|
237
|
+
key: string;
|
|
238
|
+
type: `atom`;
|
|
239
|
+
mutable?: boolean;
|
|
240
|
+
family?: FamilyMetadata;
|
|
241
|
+
install: (store: Store) => void;
|
|
242
|
+
subject: Subject<{
|
|
243
|
+
newValue: T;
|
|
244
|
+
oldValue: T;
|
|
245
|
+
}>;
|
|
246
|
+
default: T | (() => T);
|
|
247
|
+
cleanup?: () => void;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
|
|
251
|
+
key: string;
|
|
252
|
+
type: `atom_family`;
|
|
253
|
+
subject: Subject<AtomToken<T>>;
|
|
254
|
+
mutable?: boolean;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
declare const LoggerIconDictionary: {
|
|
258
|
+
readonly "\u231B": "Timeline event fully captured";
|
|
259
|
+
readonly "\u23E9": "Timeline redo";
|
|
260
|
+
readonly "\u23EA": "Timeline undo";
|
|
261
|
+
readonly "\u23ED\uFE0F": "Transaction redo";
|
|
262
|
+
readonly "\u23EE\uFE0F": "Transaction undo";
|
|
263
|
+
readonly "\u23F3": "Timeline event partially captured";
|
|
264
|
+
readonly "\u23F9\uFE0F": "Time-travel complete";
|
|
265
|
+
readonly "\uD83D\uDC81": "Notice";
|
|
266
|
+
readonly "\uD83D\uDD04": "Realtime transaction synchronized";
|
|
267
|
+
readonly "\u2705": "Realtime transaction success";
|
|
268
|
+
readonly "\u2728": "Computation complete";
|
|
269
|
+
readonly "\u274C": "Conflict prevents attempted action";
|
|
270
|
+
readonly "\u2B55": "Operation start";
|
|
271
|
+
readonly "\uD83D\uDC1E": "Possible bug in AtomIO";
|
|
272
|
+
readonly "\uD83D\uDC40": "Subscription added";
|
|
273
|
+
readonly "\uD83D\uDC6A": "Family member added";
|
|
274
|
+
readonly "\uD83D\uDCC1": "Stow update";
|
|
275
|
+
readonly "\uD83D\uDCC3": "Copy mutable";
|
|
276
|
+
readonly "\uD83D\uDCD6": "Read state";
|
|
277
|
+
readonly "\uD83D\uDCDD": "Write state";
|
|
278
|
+
readonly "\uD83D\uDCE2": "Notify subscribers";
|
|
279
|
+
readonly "\uD83D\uDD0C": "Register dependency";
|
|
280
|
+
readonly "\uD83D\uDD0D": "Discover root";
|
|
281
|
+
readonly "\uD83D\uDD25": "Delete state";
|
|
282
|
+
readonly "\uD83D\uDD27": "Create mutable atom";
|
|
283
|
+
readonly "\uD83D\uDD28": "Create immutable atom";
|
|
284
|
+
readonly "\uD83D\uDD34": "Operation complete";
|
|
285
|
+
readonly "\uD83D\uDDD1": "Evict cached value";
|
|
286
|
+
readonly "\uD83D\uDCA5": "Caught";
|
|
287
|
+
readonly "\uD83D\uDE48": "Subscription canceled";
|
|
288
|
+
readonly "\uD83D\uDEC4": "Apply transaction";
|
|
289
|
+
readonly "\uD83D\uDEE0\uFE0F": "Install atom into store";
|
|
290
|
+
readonly "\uD83D\uDEEB": "Begin transaction";
|
|
291
|
+
readonly "\uD83D\uDEEC": "Complete transaction";
|
|
292
|
+
readonly "\uD83E\uDDEE": "Computing selector";
|
|
293
|
+
readonly "\uD83E\uDDF9": "Prepare to evict";
|
|
294
|
+
readonly "\uD83E\uDE82": "Abort transaction";
|
|
295
|
+
};
|
|
296
|
+
type LoggerIcon = keyof typeof LoggerIconDictionary;
|
|
297
|
+
declare const LOG_LEVELS: readonly ["info", "warn", "error"];
|
|
298
|
+
type LogLevel = (typeof LOG_LEVELS)[number];
|
|
299
|
+
type LogFn = (icon: LoggerIcon, tokenType: `atom` | `readonly_selector` | `selector` | `state` | `timeline` | `transaction` | `unknown`, tokenKey: string, message: string, ...rest: unknown[]) => void;
|
|
300
|
+
type LogFilter = (...params: Parameters<LogFn>) => boolean;
|
|
301
|
+
type Logger = Record<LogLevel, LogFn>;
|
|
302
|
+
declare class AtomIOLogger implements Logger {
|
|
303
|
+
logLevel: `error` | `info` | `warn` | null;
|
|
304
|
+
private readonly filter?;
|
|
305
|
+
private readonly logger;
|
|
306
|
+
constructor(logLevel: `error` | `info` | `warn` | null, filter?: LogFilter | undefined, logger?: Logger);
|
|
307
|
+
error: LogFn;
|
|
308
|
+
info: LogFn;
|
|
309
|
+
warn: LogFn;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
type TransactionToken<_> = {
|
|
313
|
+
key: string;
|
|
314
|
+
type: `transaction`;
|
|
315
|
+
__brand?: _;
|
|
316
|
+
};
|
|
317
|
+
type TransactionUpdate<ƒ extends ƒn> = {
|
|
318
|
+
key: string;
|
|
319
|
+
updates: (KeyedStateUpdate<unknown> | TransactionUpdate<ƒn>)[];
|
|
320
|
+
params: Parameters<ƒ>;
|
|
321
|
+
output: ReturnType<ƒ>;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
|
|
325
|
+
key: string;
|
|
326
|
+
type: `selector_family`;
|
|
327
|
+
subject: Subject<SelectorToken<T>>;
|
|
328
|
+
};
|
|
329
|
+
type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
330
|
+
key: string;
|
|
331
|
+
type: `readonly_selector_family`;
|
|
332
|
+
subject: Subject<ReadonlySelectorToken<T>>;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
type StateUpdate<T> = {
|
|
336
|
+
newValue: T;
|
|
337
|
+
oldValue: T;
|
|
338
|
+
};
|
|
339
|
+
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
340
|
+
key: string;
|
|
341
|
+
family?: FamilyMetadata;
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
type TimelineToken = {
|
|
345
|
+
key: string;
|
|
346
|
+
type: `timeline`;
|
|
347
|
+
};
|
|
348
|
+
type TimelineUpdate = TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate;
|
|
349
|
+
|
|
350
|
+
type ƒn = (...parameters: any[]) => any;
|
|
351
|
+
type AtomToken<_> = {
|
|
352
|
+
key: string;
|
|
353
|
+
type: `atom`;
|
|
354
|
+
family?: FamilyMetadata;
|
|
355
|
+
__brand?: _;
|
|
356
|
+
};
|
|
357
|
+
interface MutableAtomToken<T extends Transceiver<any>, J extends Serializable> extends AtomToken<T> {
|
|
358
|
+
__asJSON?: J;
|
|
359
|
+
__update?: T extends Transceiver<infer Update> ? Update : never;
|
|
360
|
+
}
|
|
361
|
+
type SelectorToken<_> = {
|
|
362
|
+
key: string;
|
|
363
|
+
type: `selector`;
|
|
364
|
+
family?: FamilyMetadata;
|
|
365
|
+
__brand?: _;
|
|
366
|
+
};
|
|
367
|
+
type StateToken<T> = AtomToken<T> | SelectorToken<T>;
|
|
368
|
+
type ReadonlySelectorToken<_> = {
|
|
369
|
+
key: string;
|
|
370
|
+
type: `readonly_selector`;
|
|
371
|
+
family?: FamilyMetadata;
|
|
372
|
+
__brand?: _;
|
|
373
|
+
};
|
|
374
|
+
type FamilyMetadata = {
|
|
375
|
+
key: string;
|
|
376
|
+
subKey: string;
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
declare const myIdState__INTERNAL: AtomToken<string | null>;
|
|
380
|
+
declare const myIdState: ReadonlySelectorToken<string | null>;
|
|
381
|
+
|
|
382
|
+
declare function pullState<J extends Serializable>(token: StateToken<J>, socket: Socket, store: Store): () => void;
|
|
383
|
+
|
|
384
|
+
declare function pullFamilyMember<J extends Serializable>(token: AtomToken<J>, socket: Socket, store: Store): () => void;
|
|
385
|
+
|
|
386
|
+
declare function pullMutableState<T extends Transceiver<Serializable>, J extends Serializable>(token: MutableAtomToken<T, J>, socket: Socket, store: Store): () => void;
|
|
387
|
+
|
|
388
|
+
declare function pullMutableFamilyMember<T extends Transceiver<Serializable>, J extends Serializable>(token: MutableAtomToken<T, J>, socket: Socket, store: Store): () => void;
|
|
389
|
+
|
|
390
|
+
declare function pushState<J extends Serializable>(token: StateToken<J>, socket: Socket, subscriptionKey: string, store: Store): () => void;
|
|
391
|
+
|
|
392
|
+
declare function synchronizeTransactionResults(token: TransactionToken<any>, socket: Socket, store: Store): () => void;
|
|
393
|
+
|
|
394
|
+
export { myIdState, myIdState__INTERNAL, pullFamilyMember, pullMutableFamilyMember, pullMutableState, pullState, pushState, synchronizeTransactionResults };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { myIdState, myIdState__INTERNAL, pullFamilyMember, pullMutableFamilyMember, pullMutableState, pullState, pushState, synchronizeTransactionResults } from '../../dist/chunk-
|
|
2
|
-
import '../../dist/chunk-
|
|
1
|
+
export { myIdState, myIdState__INTERNAL, pullFamilyMember, pullMutableFamilyMember, pullMutableState, pullState, pushState, synchronizeTransactionResults } from '../../dist/chunk-N7ADBQJG.js';
|
|
2
|
+
import '../../dist/chunk-PURABO5G.js';
|
|
3
3
|
//# sourceMappingURL=out.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -322,7 +322,8 @@ var Subject = class {
|
|
|
322
322
|
this.subscribers.delete(key);
|
|
323
323
|
}
|
|
324
324
|
next(value) {
|
|
325
|
-
|
|
325
|
+
const subscribers = this.subscribers.values();
|
|
326
|
+
for (const subscriber of subscribers) {
|
|
326
327
|
subscriber(value);
|
|
327
328
|
}
|
|
328
329
|
}
|
|
@@ -1129,35 +1130,6 @@ function createSelector(options, family, store) {
|
|
|
1129
1130
|
return createReadonlySelector(options, family, store);
|
|
1130
1131
|
}
|
|
1131
1132
|
|
|
1132
|
-
// internal/src/selector/delete-selector.ts
|
|
1133
|
-
function deleteSelector(selectorToken, store) {
|
|
1134
|
-
const target = newest(store);
|
|
1135
|
-
const { key } = selectorToken;
|
|
1136
|
-
switch (selectorToken.type) {
|
|
1137
|
-
case `selector`:
|
|
1138
|
-
target.selectors.delete(key);
|
|
1139
|
-
break;
|
|
1140
|
-
case `readonly_selector`:
|
|
1141
|
-
target.readonlySelectors.delete(key);
|
|
1142
|
-
break;
|
|
1143
|
-
}
|
|
1144
|
-
target.valueMap.delete(key);
|
|
1145
|
-
target.selectorAtoms.delete(key);
|
|
1146
|
-
const downstreamTokens = target.selectorGraph.getRelationEntries({ upstreamSelectorKey: key }).filter(([_, { source }]) => source === key).map(
|
|
1147
|
-
([downstreamSelectorKey]) => {
|
|
1148
|
-
var _a;
|
|
1149
|
-
return (_a = target.selectors.get(downstreamSelectorKey)) != null ? _a : target.readonlySelectors.get(downstreamSelectorKey);
|
|
1150
|
-
}
|
|
1151
|
-
);
|
|
1152
|
-
for (const downstreamToken of downstreamTokens) {
|
|
1153
|
-
if (downstreamToken) {
|
|
1154
|
-
deleteSelector(downstreamToken, store);
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
target.selectorGraph.delete(key);
|
|
1158
|
-
store.logger.info(`\u{1F525}`, selectorToken.type, `${key}`, `deleted`);
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
1133
|
// internal/src/subscribe/recall-state.ts
|
|
1162
1134
|
var recallState = (state, store) => {
|
|
1163
1135
|
const target = newest(store);
|
|
@@ -1302,7 +1274,8 @@ var Tracker = class {
|
|
|
1302
1274
|
}
|
|
1303
1275
|
initializeState(mutableState, store) {
|
|
1304
1276
|
const latestUpdateStateKey = `*${mutableState.key}`;
|
|
1305
|
-
|
|
1277
|
+
store.atoms.delete(latestUpdateStateKey);
|
|
1278
|
+
store.valueMap.delete(latestUpdateStateKey);
|
|
1306
1279
|
const familyMetaData = mutableState.family ? {
|
|
1307
1280
|
key: `*${mutableState.family.key}`,
|
|
1308
1281
|
subKey: mutableState.family.subKey
|
|
@@ -1315,6 +1288,10 @@ var Tracker = class {
|
|
|
1315
1288
|
familyMetaData,
|
|
1316
1289
|
store
|
|
1317
1290
|
);
|
|
1291
|
+
if (store.parent) {
|
|
1292
|
+
const parentValue = store.parent.valueMap.get(latestUpdateStateKey);
|
|
1293
|
+
store.valueMap.set(latestUpdateStateKey, parentValue);
|
|
1294
|
+
}
|
|
1318
1295
|
return latestUpdateState;
|
|
1319
1296
|
}
|
|
1320
1297
|
observeCore(mutableState, latestUpdateState, store) {
|
|
@@ -1395,7 +1372,7 @@ var Tracker = class {
|
|
|
1395
1372
|
() => {
|
|
1396
1373
|
unsubscribe();
|
|
1397
1374
|
const mutable = getState(mutableState, store);
|
|
1398
|
-
const updateNumber = mutable.getUpdateNumber(newValue);
|
|
1375
|
+
const updateNumber = newValue === null ? -1 : mutable.getUpdateNumber(newValue);
|
|
1399
1376
|
const eventOffset = updateNumber - mutable.cacheUpdateNumber;
|
|
1400
1377
|
if (newValue && eventOffset === 1) {
|
|
1401
1378
|
setState(
|
|
@@ -1550,38 +1527,6 @@ function createAtom(options, family, store) {
|
|
|
1550
1527
|
return token;
|
|
1551
1528
|
}
|
|
1552
1529
|
|
|
1553
|
-
// internal/src/atom/delete-atom.ts
|
|
1554
|
-
function deleteAtom(atomToken, store) {
|
|
1555
|
-
var _a, _b;
|
|
1556
|
-
const target = newest(store);
|
|
1557
|
-
const { key } = atomToken;
|
|
1558
|
-
const atom2 = target.atoms.get(key);
|
|
1559
|
-
if (!atom2) {
|
|
1560
|
-
store.logger.error(
|
|
1561
|
-
`\u274C`,
|
|
1562
|
-
`atom`,
|
|
1563
|
-
`${key}`,
|
|
1564
|
-
`Tried to delete atom, but it does not exist in the store.`
|
|
1565
|
-
);
|
|
1566
|
-
}
|
|
1567
|
-
(_a = atom2 == null ? void 0 : atom2.cleanup) == null ? void 0 : _a.call(atom2);
|
|
1568
|
-
target.atoms.delete(key);
|
|
1569
|
-
target.valueMap.delete(key);
|
|
1570
|
-
const selectorKeys = target.selectorAtoms.getRelatedKeys(key);
|
|
1571
|
-
if (selectorKeys) {
|
|
1572
|
-
for (const selectorKey of selectorKeys) {
|
|
1573
|
-
const token = (_b = target.selectors.get(selectorKey)) != null ? _b : target.readonlySelectors.get(selectorKey);
|
|
1574
|
-
if (token) {
|
|
1575
|
-
deleteSelector(token, store);
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
target.selectorAtoms.delete(key);
|
|
1580
|
-
target.atomsThatAreDefault.delete(key);
|
|
1581
|
-
target.timelineAtoms.delete(key);
|
|
1582
|
-
store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
1530
|
// internal/src/not-found-error.ts
|
|
1586
1531
|
var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
|
|
1587
1532
|
function prettyPrintTokenType(token) {
|