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
package/json/dist/index.d.cts
CHANGED
|
@@ -270,6 +270,7 @@ declare class Store implements Lineage {
|
|
|
270
270
|
type Atom<T> = {
|
|
271
271
|
key: string;
|
|
272
272
|
type: `atom`;
|
|
273
|
+
mutable?: boolean;
|
|
273
274
|
family?: FamilyMetadata;
|
|
274
275
|
install: (store: Store) => void;
|
|
275
276
|
subject: Subject<{
|
|
@@ -284,6 +285,7 @@ type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomTok
|
|
|
284
285
|
key: string;
|
|
285
286
|
type: `atom_family`;
|
|
286
287
|
subject: Subject<AtomToken<T>>;
|
|
288
|
+
mutable?: boolean;
|
|
287
289
|
};
|
|
288
290
|
|
|
289
291
|
declare const LoggerIconDictionary: {
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
type JsonInterface<T, J extends Serializable = Serializable> = {
|
|
2
|
+
toJson: (t: T) => J;
|
|
3
|
+
fromJson: (json: J) => T;
|
|
4
|
+
};
|
|
5
|
+
declare const stringSetJsonInterface: JsonInterface<Set<string>, Array<string>>;
|
|
6
|
+
|
|
7
|
+
type primitive = boolean | number | string | null;
|
|
8
|
+
declare const isString: (input: unknown) => input is string;
|
|
9
|
+
declare const isNumber: (input: unknown) => input is number;
|
|
10
|
+
declare const isBoolean: (input: unknown) => input is boolean;
|
|
11
|
+
declare const isNull: (input: unknown) => input is null;
|
|
12
|
+
declare const isPrimitive: (input: unknown) => input is primitive;
|
|
13
|
+
|
|
14
|
+
type Serializable = primitive | Readonly<{
|
|
15
|
+
[key: string]: Serializable;
|
|
16
|
+
}> | ReadonlyArray<Serializable>;
|
|
17
|
+
type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
|
|
18
|
+
type Array<Element extends Serializable = Serializable> = ReadonlyArray<Element>;
|
|
19
|
+
|
|
20
|
+
type json_Array<Element extends Serializable = Serializable> = Array<Element>;
|
|
21
|
+
type json_Serializable = Serializable;
|
|
22
|
+
declare namespace json {
|
|
23
|
+
export type { json_Array as Array, Object$1 as Object, json_Serializable as Serializable };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare const parseJson: <S extends Stringified<Serializable>>(str: string | S) => S extends Stringified<infer J extends Serializable> ? J : Serializable;
|
|
27
|
+
type Stringified<J extends Serializable> = string & {
|
|
28
|
+
__json: J;
|
|
29
|
+
};
|
|
30
|
+
declare const stringifyJson: <J extends Serializable>(json: J) => Stringified<J>;
|
|
31
|
+
type Empty$1 = Record<string, never>;
|
|
32
|
+
declare const JSON_TYPE_NAMES: readonly ["array", "boolean", "null", "number", "object", "string"];
|
|
33
|
+
type JsonTypeName = (typeof JSON_TYPE_NAMES)[number];
|
|
34
|
+
interface JsonTypes extends Record<JsonTypeName, Serializable> {
|
|
35
|
+
array: Array;
|
|
36
|
+
boolean: boolean;
|
|
37
|
+
null: null;
|
|
38
|
+
number: number;
|
|
39
|
+
object: Object$1;
|
|
40
|
+
string: string;
|
|
41
|
+
}
|
|
42
|
+
declare const JSON_DEFAULTS: JsonTypes;
|
|
43
|
+
|
|
44
|
+
declare class Subject<T> {
|
|
45
|
+
Subscriber: (value: T) => void;
|
|
46
|
+
subscribers: Map<string, this[`Subscriber`]>;
|
|
47
|
+
subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
|
|
48
|
+
private unsubscribe;
|
|
49
|
+
next(value: T): void;
|
|
50
|
+
}
|
|
51
|
+
declare class StatefulSubject<T> extends Subject<T> {
|
|
52
|
+
state: T;
|
|
53
|
+
constructor(initialState: T);
|
|
54
|
+
next(value: T): void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type Selector<T> = {
|
|
58
|
+
key: string;
|
|
59
|
+
type: `selector`;
|
|
60
|
+
family?: FamilyMetadata;
|
|
61
|
+
install: (store: Store) => void;
|
|
62
|
+
subject: Subject<{
|
|
63
|
+
newValue: T;
|
|
64
|
+
oldValue: T;
|
|
65
|
+
}>;
|
|
66
|
+
get: () => T;
|
|
67
|
+
set: (newValue: T | ((oldValue: T) => T)) => void;
|
|
68
|
+
};
|
|
69
|
+
type ReadonlySelector<T> = {
|
|
70
|
+
key: string;
|
|
71
|
+
type: `readonly_selector`;
|
|
72
|
+
family?: FamilyMetadata;
|
|
73
|
+
install: (store: Store) => void;
|
|
74
|
+
subject: Subject<{
|
|
75
|
+
newValue: T;
|
|
76
|
+
oldValue: T;
|
|
77
|
+
}>;
|
|
78
|
+
get: () => T;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
type Transaction<ƒ extends ƒn> = {
|
|
82
|
+
key: string;
|
|
83
|
+
type: `transaction`;
|
|
84
|
+
install: (store: Store) => void;
|
|
85
|
+
subject: Subject<TransactionUpdate<ƒ>>;
|
|
86
|
+
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
type TransactionMeta<ƒ extends ƒn> = {
|
|
90
|
+
phase: `applying` | `building`;
|
|
91
|
+
time: number;
|
|
92
|
+
update: TransactionUpdate<ƒ>;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
|
|
96
|
+
type Cardinality = `1:1` | `1:n` | `n:n`;
|
|
97
|
+
|
|
98
|
+
interface JunctionEntries<Content extends Object$1 | null> extends Object$1 {
|
|
99
|
+
readonly relations: [string, string[]][];
|
|
100
|
+
readonly contents: [string, Content][];
|
|
101
|
+
}
|
|
102
|
+
interface JunctionSchema<ASide extends string, BSide extends string> extends Object$1 {
|
|
103
|
+
readonly between: [a: ASide, b: BSide];
|
|
104
|
+
readonly cardinality: Cardinality;
|
|
105
|
+
}
|
|
106
|
+
type BaseExternalStoreConfiguration = {
|
|
107
|
+
addRelation: (a: string, b: string) => void;
|
|
108
|
+
deleteRelation: (a: string, b: string) => void;
|
|
109
|
+
replaceRelationsSafely: (a: string, bs: string[]) => void;
|
|
110
|
+
replaceRelationsUnsafely: (a: string, bs: string[]) => void;
|
|
111
|
+
getRelatedKeys: (key: string) => Set<string> | undefined;
|
|
112
|
+
has: (a: string, b?: string) => boolean;
|
|
113
|
+
};
|
|
114
|
+
type ExternalStoreWithContentConfiguration<Content extends Object$1> = {
|
|
115
|
+
getContent: (contentKey: string) => Content | undefined;
|
|
116
|
+
setContent: (contentKey: string, content: Content) => void;
|
|
117
|
+
deleteContent: (contentKey: string) => void;
|
|
118
|
+
};
|
|
119
|
+
type Empty<Obj extends object> = {
|
|
120
|
+
[Key in keyof Obj]?: undefined;
|
|
121
|
+
};
|
|
122
|
+
type ExternalStoreConfiguration<Content extends Object$1 | null> = Content extends Object$1 ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Object$1>>;
|
|
123
|
+
type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
|
|
124
|
+
externalStore?: ExternalStoreConfiguration<Content>;
|
|
125
|
+
isContent?: Refinement<unknown, Content>;
|
|
126
|
+
makeContentKey?: (a: string, b: string) => string;
|
|
127
|
+
};
|
|
128
|
+
type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
|
|
129
|
+
declare class Junction<const ASide extends string, const BSide extends string, const Content extends Object$1 | null = null> {
|
|
130
|
+
readonly a: ASide;
|
|
131
|
+
readonly b: BSide;
|
|
132
|
+
readonly cardinality: Cardinality;
|
|
133
|
+
readonly relations: Map<string, Set<string>>;
|
|
134
|
+
readonly contents: Map<string, Content>;
|
|
135
|
+
isContent: Refinement<unknown, Content> | null;
|
|
136
|
+
makeContentKey: (a: string, b: string) => string;
|
|
137
|
+
getRelatedKeys(key: string): Set<string> | undefined;
|
|
138
|
+
protected addRelation(a: string, b: string): void;
|
|
139
|
+
protected deleteRelation(a: string, b: string): void;
|
|
140
|
+
protected replaceRelationsUnsafely(a: string, bs: string[]): void;
|
|
141
|
+
protected replaceRelationsSafely(a: string, bs: string[]): void;
|
|
142
|
+
protected getContentInternal(contentKey: string): Content | undefined;
|
|
143
|
+
protected setContent(contentKey: string, content: Content): void;
|
|
144
|
+
protected deleteContent(contentKey: string): void;
|
|
145
|
+
constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
|
|
146
|
+
toJSON(): JunctionJSON<ASide, BSide, Content>;
|
|
147
|
+
set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
|
|
148
|
+
set(relation: {
|
|
149
|
+
[Key in ASide | BSide]: string;
|
|
150
|
+
}, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
|
|
151
|
+
delete(a: string, b?: string): this;
|
|
152
|
+
delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
|
|
153
|
+
getRelatedKey(key: string): string | undefined;
|
|
154
|
+
replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
|
|
155
|
+
reckless: boolean;
|
|
156
|
+
}): this;
|
|
157
|
+
getContent(a: string, b: string): Content | undefined;
|
|
158
|
+
getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
|
|
159
|
+
has(a: string, b?: string): boolean;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface Lineage {
|
|
163
|
+
parent: typeof this | null;
|
|
164
|
+
child: typeof this | null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
interface Transceiver<Signal extends Serializable> {
|
|
168
|
+
do: (update: Signal) => void;
|
|
169
|
+
undo: (update: Signal) => void;
|
|
170
|
+
subscribe: (key: string, fn: (update: Signal) => void) => () => void;
|
|
171
|
+
cacheUpdateNumber: number;
|
|
172
|
+
getUpdateNumber: (update: Signal) => number;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @internal Give the tracker a transceiver state and a store, and it will
|
|
177
|
+
* subscribe to the transceiver's inner value. When the inner value changes,
|
|
178
|
+
* the tracker will update its own state to reflect the change.
|
|
179
|
+
*/
|
|
180
|
+
declare class Tracker<Mutable extends Transceiver<any>> {
|
|
181
|
+
private Update;
|
|
182
|
+
private initializeState;
|
|
183
|
+
private unsubscribeFromInnerValue;
|
|
184
|
+
private observeCore;
|
|
185
|
+
private updateCore;
|
|
186
|
+
mutableState: MutableAtomToken<Mutable, Serializable>;
|
|
187
|
+
latestUpdateState: AtomToken<typeof this.Update | null>;
|
|
188
|
+
constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
interface MutableAtom<T> extends Atom<T> {
|
|
192
|
+
mutable: true;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
type OperationProgress = {
|
|
196
|
+
open: false;
|
|
197
|
+
} | {
|
|
198
|
+
open: true;
|
|
199
|
+
done: Set<string>;
|
|
200
|
+
prev: Map<string, any>;
|
|
201
|
+
time: number;
|
|
202
|
+
token: StateToken<any>;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
type TimelineAtomUpdate = StateUpdate<unknown> & {
|
|
206
|
+
key: string;
|
|
207
|
+
type: `atom_update`;
|
|
208
|
+
timestamp: number;
|
|
209
|
+
family?: FamilyMetadata;
|
|
210
|
+
};
|
|
211
|
+
type TimelineSelectorUpdate = {
|
|
212
|
+
key: string;
|
|
213
|
+
type: `selector_update`;
|
|
214
|
+
timestamp: number;
|
|
215
|
+
atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
|
|
216
|
+
};
|
|
217
|
+
type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
218
|
+
key: string;
|
|
219
|
+
type: `transaction_update`;
|
|
220
|
+
timestamp: number;
|
|
221
|
+
};
|
|
222
|
+
type Timeline = {
|
|
223
|
+
type: `timeline`;
|
|
224
|
+
key: string;
|
|
225
|
+
at: number;
|
|
226
|
+
shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
|
|
227
|
+
timeTraveling: `into_future` | `into_past` | null;
|
|
228
|
+
history: TimelineUpdate[];
|
|
229
|
+
selectorTime: number | null;
|
|
230
|
+
transactionKey: string | null;
|
|
231
|
+
install: (store: Store) => void;
|
|
232
|
+
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
declare class Store implements Lineage {
|
|
236
|
+
parent: Store | null;
|
|
237
|
+
child: Store | null;
|
|
238
|
+
valueMap: Map<string, any>;
|
|
239
|
+
atoms: Map<string, Atom<any> | MutableAtom<any>>;
|
|
240
|
+
selectors: Map<string, Selector<any>>;
|
|
241
|
+
readonlySelectors: Map<string, ReadonlySelector<any>>;
|
|
242
|
+
trackers: Map<string, Tracker<Transceiver<any>>>;
|
|
243
|
+
families: Map<string, AtomFamily<any, any> | ReadonlySelectorFamily<any, any> | SelectorFamily<any, any>>;
|
|
244
|
+
timelines: Map<string, Timeline>;
|
|
245
|
+
transactions: Map<string, Transaction<ƒn>>;
|
|
246
|
+
atomsThatAreDefault: Set<string>;
|
|
247
|
+
timelineAtoms: Junction<"timelineKey", "atomKey", null>;
|
|
248
|
+
selectorAtoms: Junction<"selectorKey", "atomKey", null>;
|
|
249
|
+
selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
|
|
250
|
+
source: string;
|
|
251
|
+
}>;
|
|
252
|
+
subject: {
|
|
253
|
+
atomCreation: Subject<AtomToken<unknown>>;
|
|
254
|
+
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
255
|
+
transactionCreation: Subject<TransactionToken<ƒn>>;
|
|
256
|
+
timelineCreation: Subject<TimelineToken>;
|
|
257
|
+
transactionApplying: StatefulSubject<TransactionMeta<ƒn> | null>;
|
|
258
|
+
operationStatus: Subject<OperationProgress>;
|
|
259
|
+
};
|
|
260
|
+
operation: OperationProgress;
|
|
261
|
+
transactionMeta: TransactionMeta<ƒn> | null;
|
|
262
|
+
config: {
|
|
263
|
+
name: string;
|
|
264
|
+
};
|
|
265
|
+
loggers: AtomIOLogger[];
|
|
266
|
+
logger: Logger;
|
|
267
|
+
constructor(name: string, store?: Store | null);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
type Atom<T> = {
|
|
271
|
+
key: string;
|
|
272
|
+
type: `atom`;
|
|
273
|
+
mutable?: boolean;
|
|
274
|
+
family?: FamilyMetadata;
|
|
275
|
+
install: (store: Store) => void;
|
|
276
|
+
subject: Subject<{
|
|
277
|
+
newValue: T;
|
|
278
|
+
oldValue: T;
|
|
279
|
+
}>;
|
|
280
|
+
default: T | (() => T);
|
|
281
|
+
cleanup?: () => void;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
|
|
285
|
+
key: string;
|
|
286
|
+
type: `atom_family`;
|
|
287
|
+
subject: Subject<AtomToken<T>>;
|
|
288
|
+
mutable?: boolean;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
declare const LoggerIconDictionary: {
|
|
292
|
+
readonly "\u231B": "Timeline event fully captured";
|
|
293
|
+
readonly "\u23E9": "Timeline redo";
|
|
294
|
+
readonly "\u23EA": "Timeline undo";
|
|
295
|
+
readonly "\u23ED\uFE0F": "Transaction redo";
|
|
296
|
+
readonly "\u23EE\uFE0F": "Transaction undo";
|
|
297
|
+
readonly "\u23F3": "Timeline event partially captured";
|
|
298
|
+
readonly "\u23F9\uFE0F": "Time-travel complete";
|
|
299
|
+
readonly "\uD83D\uDC81": "Notice";
|
|
300
|
+
readonly "\uD83D\uDD04": "Realtime transaction synchronized";
|
|
301
|
+
readonly "\u2705": "Realtime transaction success";
|
|
302
|
+
readonly "\u2728": "Computation complete";
|
|
303
|
+
readonly "\u274C": "Conflict prevents attempted action";
|
|
304
|
+
readonly "\u2B55": "Operation start";
|
|
305
|
+
readonly "\uD83D\uDC1E": "Possible bug in AtomIO";
|
|
306
|
+
readonly "\uD83D\uDC40": "Subscription added";
|
|
307
|
+
readonly "\uD83D\uDC6A": "Family member added";
|
|
308
|
+
readonly "\uD83D\uDCC1": "Stow update";
|
|
309
|
+
readonly "\uD83D\uDCC3": "Copy mutable";
|
|
310
|
+
readonly "\uD83D\uDCD6": "Read state";
|
|
311
|
+
readonly "\uD83D\uDCDD": "Write state";
|
|
312
|
+
readonly "\uD83D\uDCE2": "Notify subscribers";
|
|
313
|
+
readonly "\uD83D\uDD0C": "Register dependency";
|
|
314
|
+
readonly "\uD83D\uDD0D": "Discover root";
|
|
315
|
+
readonly "\uD83D\uDD25": "Delete state";
|
|
316
|
+
readonly "\uD83D\uDD27": "Create mutable atom";
|
|
317
|
+
readonly "\uD83D\uDD28": "Create immutable atom";
|
|
318
|
+
readonly "\uD83D\uDD34": "Operation complete";
|
|
319
|
+
readonly "\uD83D\uDDD1": "Evict cached value";
|
|
320
|
+
readonly "\uD83D\uDCA5": "Caught";
|
|
321
|
+
readonly "\uD83D\uDE48": "Subscription canceled";
|
|
322
|
+
readonly "\uD83D\uDEC4": "Apply transaction";
|
|
323
|
+
readonly "\uD83D\uDEE0\uFE0F": "Install atom into store";
|
|
324
|
+
readonly "\uD83D\uDEEB": "Begin transaction";
|
|
325
|
+
readonly "\uD83D\uDEEC": "Complete transaction";
|
|
326
|
+
readonly "\uD83E\uDDEE": "Computing selector";
|
|
327
|
+
readonly "\uD83E\uDDF9": "Prepare to evict";
|
|
328
|
+
readonly "\uD83E\uDE82": "Abort transaction";
|
|
329
|
+
};
|
|
330
|
+
type LoggerIcon = keyof typeof LoggerIconDictionary;
|
|
331
|
+
declare const LOG_LEVELS: readonly ["info", "warn", "error"];
|
|
332
|
+
type LogLevel = (typeof LOG_LEVELS)[number];
|
|
333
|
+
type LogFn = (icon: LoggerIcon, tokenType: `atom` | `readonly_selector` | `selector` | `state` | `timeline` | `transaction` | `unknown`, tokenKey: string, message: string, ...rest: unknown[]) => void;
|
|
334
|
+
type LogFilter = (...params: Parameters<LogFn>) => boolean;
|
|
335
|
+
type Logger = Record<LogLevel, LogFn>;
|
|
336
|
+
declare class AtomIOLogger implements Logger {
|
|
337
|
+
logLevel: `error` | `info` | `warn` | null;
|
|
338
|
+
private readonly filter?;
|
|
339
|
+
private readonly logger;
|
|
340
|
+
constructor(logLevel: `error` | `info` | `warn` | null, filter?: LogFilter | undefined, logger?: Logger);
|
|
341
|
+
error: LogFn;
|
|
342
|
+
info: LogFn;
|
|
343
|
+
warn: LogFn;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
type TransactionToken<_> = {
|
|
347
|
+
key: string;
|
|
348
|
+
type: `transaction`;
|
|
349
|
+
__brand?: _;
|
|
350
|
+
};
|
|
351
|
+
type TransactionUpdate<ƒ extends ƒn> = {
|
|
352
|
+
key: string;
|
|
353
|
+
updates: (KeyedStateUpdate<unknown> | TransactionUpdate<ƒn>)[];
|
|
354
|
+
params: Parameters<ƒ>;
|
|
355
|
+
output: ReturnType<ƒ>;
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
|
|
359
|
+
key: string;
|
|
360
|
+
type: `selector_family`;
|
|
361
|
+
subject: Subject<SelectorToken<T>>;
|
|
362
|
+
};
|
|
363
|
+
type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
364
|
+
key: string;
|
|
365
|
+
type: `readonly_selector_family`;
|
|
366
|
+
subject: Subject<ReadonlySelectorToken<T>>;
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
type StateUpdate<T> = {
|
|
370
|
+
newValue: T;
|
|
371
|
+
oldValue: T;
|
|
372
|
+
};
|
|
373
|
+
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
374
|
+
key: string;
|
|
375
|
+
family?: FamilyMetadata;
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
type TimelineToken = {
|
|
379
|
+
key: string;
|
|
380
|
+
type: `timeline`;
|
|
381
|
+
};
|
|
382
|
+
type TimelineUpdate = TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate;
|
|
383
|
+
|
|
384
|
+
type ƒn = (...parameters: any[]) => any;
|
|
385
|
+
type AtomToken<_> = {
|
|
386
|
+
key: string;
|
|
387
|
+
type: `atom`;
|
|
388
|
+
family?: FamilyMetadata;
|
|
389
|
+
__brand?: _;
|
|
390
|
+
};
|
|
391
|
+
interface MutableAtomToken<T extends Transceiver<any>, J extends Serializable> extends AtomToken<T> {
|
|
392
|
+
__asJSON?: J;
|
|
393
|
+
__update?: T extends Transceiver<infer Update> ? Update : never;
|
|
394
|
+
}
|
|
395
|
+
type SelectorToken<_> = {
|
|
396
|
+
key: string;
|
|
397
|
+
type: `selector`;
|
|
398
|
+
family?: FamilyMetadata;
|
|
399
|
+
__brand?: _;
|
|
400
|
+
};
|
|
401
|
+
type StateToken<T> = AtomToken<T> | SelectorToken<T>;
|
|
402
|
+
type ReadonlySelectorToken<_> = {
|
|
403
|
+
key: string;
|
|
404
|
+
type: `readonly_selector`;
|
|
405
|
+
family?: FamilyMetadata;
|
|
406
|
+
__brand?: _;
|
|
407
|
+
};
|
|
408
|
+
type FamilyMetadata = {
|
|
409
|
+
key: string;
|
|
410
|
+
subKey: string;
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
declare const selectJson: <T, J extends Serializable>(atom: AtomToken<T>, transform: JsonInterface<T, J>, store?: Store) => SelectorToken<J>;
|
|
414
|
+
|
|
415
|
+
declare const selectJsonFamily: <T, J extends Serializable, K extends Serializable>(atomFamily: AtomFamily<T, K>, transform: JsonInterface<T, J>, store?: Store) => SelectorFamily<J, K>;
|
|
416
|
+
|
|
417
|
+
export { type Empty$1 as Empty, JSON_DEFAULTS, JSON_TYPE_NAMES, json as Json, type JsonInterface, type JsonTypeName, type JsonTypes, type Stringified, isBoolean, isNull, isNumber, isPrimitive, isString, parseJson, type primitive, selectJson, selectJsonFamily, stringSetJsonInterface, stringifyJson };
|
package/json/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { JSON_DEFAULTS, JSON_TYPE_NAMES, isBoolean, isNull, isNumber, isPrimitive, isString, parseJson, selectJson, selectJsonFamily, stringSetJsonInterface, stringifyJson } from '../../dist/chunk-
|
|
1
|
+
export { JSON_DEFAULTS, JSON_TYPE_NAMES, isBoolean, isNull, isNumber, isPrimitive, isString, parseJson, selectJson, selectJsonFamily, stringSetJsonInterface, stringifyJson } from '../../dist/chunk-PURABO5G.js';
|
|
2
2
|
//# sourceMappingURL=out.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atom.io",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.3",
|
|
4
4
|
"description": "Composable and testable reactive data library.",
|
|
5
5
|
"homepage": "https://atom.io.fyi",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -205,7 +205,8 @@
|
|
|
205
205
|
},
|
|
206
206
|
"scripts": {
|
|
207
207
|
"manifest": "tsx __scripts__/manifest-build.node",
|
|
208
|
-
"build": "
|
|
208
|
+
"clean:build": "find . -type d -name 'dist' -not -path '*/node_modules/*' | xargs rm -rf",
|
|
209
|
+
"build": "npm run clean:build && concurrently \"npm:build:*\"",
|
|
209
210
|
"build:main": "tsup",
|
|
210
211
|
"build:types": "tsup --dts",
|
|
211
212
|
"build:data": "cd data && tsup",
|
package/react/dist/index.cjs
CHANGED
|
@@ -302,7 +302,8 @@ var Subject = class {
|
|
|
302
302
|
this.subscribers.delete(key);
|
|
303
303
|
}
|
|
304
304
|
next(value) {
|
|
305
|
-
|
|
305
|
+
const subscribers = this.subscribers.values();
|
|
306
|
+
for (const subscriber of subscribers) {
|
|
306
307
|
subscriber(value);
|
|
307
308
|
}
|
|
308
309
|
}
|
|
@@ -1109,35 +1110,6 @@ function createSelector(options, family, store) {
|
|
|
1109
1110
|
return createReadonlySelector(options, family, store);
|
|
1110
1111
|
}
|
|
1111
1112
|
|
|
1112
|
-
// internal/src/selector/delete-selector.ts
|
|
1113
|
-
function deleteSelector(selectorToken, store) {
|
|
1114
|
-
const target = newest(store);
|
|
1115
|
-
const { key } = selectorToken;
|
|
1116
|
-
switch (selectorToken.type) {
|
|
1117
|
-
case `selector`:
|
|
1118
|
-
target.selectors.delete(key);
|
|
1119
|
-
break;
|
|
1120
|
-
case `readonly_selector`:
|
|
1121
|
-
target.readonlySelectors.delete(key);
|
|
1122
|
-
break;
|
|
1123
|
-
}
|
|
1124
|
-
target.valueMap.delete(key);
|
|
1125
|
-
target.selectorAtoms.delete(key);
|
|
1126
|
-
const downstreamTokens = target.selectorGraph.getRelationEntries({ upstreamSelectorKey: key }).filter(([_, { source }]) => source === key).map(
|
|
1127
|
-
([downstreamSelectorKey]) => {
|
|
1128
|
-
var _a;
|
|
1129
|
-
return (_a = target.selectors.get(downstreamSelectorKey)) != null ? _a : target.readonlySelectors.get(downstreamSelectorKey);
|
|
1130
|
-
}
|
|
1131
|
-
);
|
|
1132
|
-
for (const downstreamToken of downstreamTokens) {
|
|
1133
|
-
if (downstreamToken) {
|
|
1134
|
-
deleteSelector(downstreamToken, store);
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
target.selectorGraph.delete(key);
|
|
1138
|
-
store.logger.info(`\u{1F525}`, selectorToken.type, `${key}`, `deleted`);
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
1113
|
// internal/src/subscribe/recall-state.ts
|
|
1142
1114
|
var recallState = (state, store) => {
|
|
1143
1115
|
const target = newest(store);
|
|
@@ -1256,7 +1228,8 @@ var Tracker = class {
|
|
|
1256
1228
|
}
|
|
1257
1229
|
initializeState(mutableState, store) {
|
|
1258
1230
|
const latestUpdateStateKey = `*${mutableState.key}`;
|
|
1259
|
-
|
|
1231
|
+
store.atoms.delete(latestUpdateStateKey);
|
|
1232
|
+
store.valueMap.delete(latestUpdateStateKey);
|
|
1260
1233
|
const familyMetaData = mutableState.family ? {
|
|
1261
1234
|
key: `*${mutableState.family.key}`,
|
|
1262
1235
|
subKey: mutableState.family.subKey
|
|
@@ -1269,6 +1242,10 @@ var Tracker = class {
|
|
|
1269
1242
|
familyMetaData,
|
|
1270
1243
|
store
|
|
1271
1244
|
);
|
|
1245
|
+
if (store.parent) {
|
|
1246
|
+
const parentValue = store.parent.valueMap.get(latestUpdateStateKey);
|
|
1247
|
+
store.valueMap.set(latestUpdateStateKey, parentValue);
|
|
1248
|
+
}
|
|
1272
1249
|
return latestUpdateState;
|
|
1273
1250
|
}
|
|
1274
1251
|
observeCore(mutableState, latestUpdateState, store) {
|
|
@@ -1349,7 +1326,7 @@ var Tracker = class {
|
|
|
1349
1326
|
() => {
|
|
1350
1327
|
unsubscribe();
|
|
1351
1328
|
const mutable = getState(mutableState, store);
|
|
1352
|
-
const updateNumber = mutable.getUpdateNumber(newValue);
|
|
1329
|
+
const updateNumber = newValue === null ? -1 : mutable.getUpdateNumber(newValue);
|
|
1353
1330
|
const eventOffset = updateNumber - mutable.cacheUpdateNumber;
|
|
1354
1331
|
if (newValue && eventOffset === 1) {
|
|
1355
1332
|
setState(
|
|
@@ -1491,38 +1468,6 @@ function createAtom(options, family, store) {
|
|
|
1491
1468
|
return token;
|
|
1492
1469
|
}
|
|
1493
1470
|
|
|
1494
|
-
// internal/src/atom/delete-atom.ts
|
|
1495
|
-
function deleteAtom(atomToken, store) {
|
|
1496
|
-
var _a, _b;
|
|
1497
|
-
const target = newest(store);
|
|
1498
|
-
const { key } = atomToken;
|
|
1499
|
-
const atom = target.atoms.get(key);
|
|
1500
|
-
if (!atom) {
|
|
1501
|
-
store.logger.error(
|
|
1502
|
-
`\u274C`,
|
|
1503
|
-
`atom`,
|
|
1504
|
-
`${key}`,
|
|
1505
|
-
`Tried to delete atom, but it does not exist in the store.`
|
|
1506
|
-
);
|
|
1507
|
-
}
|
|
1508
|
-
(_a = atom == null ? void 0 : atom.cleanup) == null ? void 0 : _a.call(atom);
|
|
1509
|
-
target.atoms.delete(key);
|
|
1510
|
-
target.valueMap.delete(key);
|
|
1511
|
-
const selectorKeys = target.selectorAtoms.getRelatedKeys(key);
|
|
1512
|
-
if (selectorKeys) {
|
|
1513
|
-
for (const selectorKey of selectorKeys) {
|
|
1514
|
-
const token = (_b = target.selectors.get(selectorKey)) != null ? _b : target.readonlySelectors.get(selectorKey);
|
|
1515
|
-
if (token) {
|
|
1516
|
-
deleteSelector(token, store);
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
}
|
|
1520
|
-
target.selectorAtoms.delete(key);
|
|
1521
|
-
target.atomsThatAreDefault.delete(key);
|
|
1522
|
-
target.timelineAtoms.delete(key);
|
|
1523
|
-
store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
1471
|
// internal/src/not-found-error.ts
|
|
1527
1472
|
var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
|
|
1528
1473
|
function prettyPrintTokenType(token) {
|