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.
Files changed (83) hide show
  1. package/data/dist/index.cjs +12 -64
  2. package/data/dist/index.cjs.map +1 -1
  3. package/data/dist/index.d.cts +2 -0
  4. package/data/dist/index.d.ts +459 -0
  5. package/data/dist/index.js +1 -1
  6. package/dist/{chunk-KW7RA7IM.js → chunk-C4YZZNRH.js} +4 -4
  7. package/dist/{chunk-LFXB7Y6M.js → chunk-CWKKQKVQ.js} +2 -2
  8. package/dist/{chunk-CK7GNCU5.js → chunk-GMN5KH6A.js} +2 -2
  9. package/dist/{chunk-5VJ77LZE.js → chunk-N7ADBQJG.js} +2 -2
  10. package/dist/{chunk-TE3ZSTQ6.js → chunk-PURABO5G.js} +92 -27
  11. package/dist/chunk-PURABO5G.js.map +1 -0
  12. package/dist/index.cjs +106 -20
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +4 -1
  15. package/dist/index.d.ts +493 -0
  16. package/dist/index.js +1 -1
  17. package/dist/metafile-cjs.json +1 -1
  18. package/dist/metafile-esm.json +1 -0
  19. package/internal/dist/index.cjs +93 -29
  20. package/internal/dist/index.cjs.map +1 -1
  21. package/internal/dist/index.d.cts +6 -4
  22. package/internal/dist/index.d.ts +622 -0
  23. package/internal/dist/index.js +1 -1
  24. package/internal/src/atom/create-atom.ts +3 -1
  25. package/internal/src/families/create-atom-family.ts +3 -4
  26. package/internal/src/mutable/get-update-family.ts +23 -0
  27. package/internal/src/mutable/index.ts +1 -4
  28. package/internal/src/mutable/is-mutable.ts +44 -0
  29. package/internal/src/mutable/tracker.ts +9 -2
  30. package/internal/src/subject.ts +2 -1
  31. package/internal/src/timeline/add-atom-to-timeline.ts +10 -1
  32. package/internal/src/timeline/create-timeline.ts +44 -16
  33. package/introspection/dist/index.cjs +12 -64
  34. package/introspection/dist/index.cjs.map +1 -1
  35. package/introspection/dist/index.d.cts +2 -0
  36. package/introspection/dist/index.d.ts +396 -0
  37. package/introspection/dist/index.js +2 -2
  38. package/json/dist/index.cjs +9 -64
  39. package/json/dist/index.cjs.map +1 -1
  40. package/json/dist/index.d.cts +2 -0
  41. package/json/dist/index.d.ts +417 -0
  42. package/json/dist/index.js +1 -1
  43. package/package.json +3 -2
  44. package/react/dist/index.cjs +9 -64
  45. package/react/dist/index.cjs.map +1 -1
  46. package/react/dist/index.d.cts +2 -0
  47. package/react/dist/index.d.ts +396 -0
  48. package/react/dist/index.js +2 -2
  49. package/react-devtools/dist/index.cjs +12 -64
  50. package/react-devtools/dist/index.cjs.map +1 -1
  51. package/react-devtools/dist/index.d.cts +2 -0
  52. package/react-devtools/dist/index.d.ts +467 -0
  53. package/react-devtools/dist/index.js +3 -3
  54. package/realtime-client/dist/index.cjs +9 -64
  55. package/realtime-client/dist/index.cjs.map +1 -1
  56. package/realtime-client/dist/index.d.cts +2 -0
  57. package/realtime-client/dist/index.d.ts +394 -0
  58. package/realtime-client/dist/index.js +2 -2
  59. package/realtime-react/dist/index.cjs +9 -64
  60. package/realtime-react/dist/index.cjs.map +1 -1
  61. package/realtime-react/dist/index.d.ts +67 -0
  62. package/realtime-react/dist/index.js +4 -4
  63. package/realtime-server/dist/index.cjs +9 -64
  64. package/realtime-server/dist/index.cjs.map +1 -1
  65. package/realtime-server/dist/index.d.cts +4 -1
  66. package/realtime-server/dist/index.d.ts +408 -0
  67. package/realtime-server/dist/index.js +1 -1
  68. package/realtime-testing/dist/index.cjs +104 -79
  69. package/realtime-testing/dist/index.cjs.map +1 -1
  70. package/realtime-testing/dist/index.d.cts +4 -1
  71. package/realtime-testing/dist/index.d.ts +535 -0
  72. package/realtime-testing/dist/index.js +4 -4
  73. package/src/atom.ts +3 -1
  74. package/transceivers/set-rtx/dist/index.cjs +2 -1
  75. package/transceivers/set-rtx/dist/index.cjs.map +1 -1
  76. package/transceivers/set-rtx/dist/index.d.ts +66 -0
  77. package/transceivers/set-rtx/dist/index.js +1 -1
  78. package/dist/chunk-TE3ZSTQ6.js.map +0 -1
  79. package/internal/src/mutable/is-atom-token-mutable.ts +0 -7
  80. /package/dist/{chunk-KW7RA7IM.js.map → chunk-C4YZZNRH.js.map} +0 -0
  81. /package/dist/{chunk-LFXB7Y6M.js.map → chunk-CWKKQKVQ.js.map} +0 -0
  82. /package/dist/{chunk-CK7GNCU5.js.map → chunk-GMN5KH6A.js.map} +0 -0
  83. /package/dist/{chunk-5VJ77LZE.js.map → chunk-N7ADBQJG.js.map} +0 -0
@@ -31,6 +31,7 @@ type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomTok
31
31
  key: string;
32
32
  type: `atom_family`;
33
33
  subject: Subject<AtomToken<T>>;
34
+ mutable?: boolean;
34
35
  };
35
36
 
36
37
  declare const LoggerIconDictionary: {
@@ -384,6 +385,7 @@ declare class Store implements Lineage {
384
385
  type Atom<T> = {
385
386
  key: string;
386
387
  type: `atom`;
388
+ mutable?: boolean;
387
389
  family?: FamilyMetadata;
388
390
  install: (store: Store) => void;
389
391
  subject: Subject<{
@@ -0,0 +1,467 @@
1
+ type ClassSignature = abstract new (...args: any) => any;
2
+
3
+ type RefinementStrategy = ClassSignature | Refinement$1<unknown, any>;
4
+ type Supported<Refine extends RefinementStrategy> = Refine extends Refinement$1<unknown, infer T> ? T : Refine extends ClassSignature ? InstanceType<Refine> : never;
5
+ type RefinementSupport = Record<string, RefinementStrategy>;
6
+ declare class Refinery<SupportedTypes extends RefinementSupport> {
7
+ supported: SupportedTypes;
8
+ constructor(supported: SupportedTypes);
9
+ refine(input: unknown): {
10
+ [K in keyof SupportedTypes]: {
11
+ type: K;
12
+ data: Supported<SupportedTypes[K]>;
13
+ };
14
+ }[keyof SupportedTypes] | null;
15
+ }
16
+
17
+ interface Refinement$1<A, B extends A> {
18
+ (a: A): a is B;
19
+ }
20
+
21
+ type PlainObject = Record<keyof any, unknown>;
22
+
23
+ type primitive = boolean | number | string | null;
24
+
25
+ type Serializable = primitive | Readonly<{
26
+ [key: string]: Serializable;
27
+ }> | ReadonlyArray<Serializable>;
28
+ type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
29
+
30
+ type AtomFamily<T, K extends Serializable = Serializable> = ((key: K) => AtomToken<T>) & {
31
+ key: string;
32
+ type: `atom_family`;
33
+ subject: Subject<AtomToken<T>>;
34
+ mutable?: boolean;
35
+ };
36
+
37
+ declare const LoggerIconDictionary: {
38
+ readonly "\u231B": "Timeline event fully captured";
39
+ readonly "\u23E9": "Timeline redo";
40
+ readonly "\u23EA": "Timeline undo";
41
+ readonly "\u23ED\uFE0F": "Transaction redo";
42
+ readonly "\u23EE\uFE0F": "Transaction undo";
43
+ readonly "\u23F3": "Timeline event partially captured";
44
+ readonly "\u23F9\uFE0F": "Time-travel complete";
45
+ readonly "\uD83D\uDC81": "Notice";
46
+ readonly "\uD83D\uDD04": "Realtime transaction synchronized";
47
+ readonly "\u2705": "Realtime transaction success";
48
+ readonly "\u2728": "Computation complete";
49
+ readonly "\u274C": "Conflict prevents attempted action";
50
+ readonly "\u2B55": "Operation start";
51
+ readonly "\uD83D\uDC1E": "Possible bug in AtomIO";
52
+ readonly "\uD83D\uDC40": "Subscription added";
53
+ readonly "\uD83D\uDC6A": "Family member added";
54
+ readonly "\uD83D\uDCC1": "Stow update";
55
+ readonly "\uD83D\uDCC3": "Copy mutable";
56
+ readonly "\uD83D\uDCD6": "Read state";
57
+ readonly "\uD83D\uDCDD": "Write state";
58
+ readonly "\uD83D\uDCE2": "Notify subscribers";
59
+ readonly "\uD83D\uDD0C": "Register dependency";
60
+ readonly "\uD83D\uDD0D": "Discover root";
61
+ readonly "\uD83D\uDD25": "Delete state";
62
+ readonly "\uD83D\uDD27": "Create mutable atom";
63
+ readonly "\uD83D\uDD28": "Create immutable atom";
64
+ readonly "\uD83D\uDD34": "Operation complete";
65
+ readonly "\uD83D\uDDD1": "Evict cached value";
66
+ readonly "\uD83D\uDCA5": "Caught";
67
+ readonly "\uD83D\uDE48": "Subscription canceled";
68
+ readonly "\uD83D\uDEC4": "Apply transaction";
69
+ readonly "\uD83D\uDEE0\uFE0F": "Install atom into store";
70
+ readonly "\uD83D\uDEEB": "Begin transaction";
71
+ readonly "\uD83D\uDEEC": "Complete transaction";
72
+ readonly "\uD83E\uDDEE": "Computing selector";
73
+ readonly "\uD83E\uDDF9": "Prepare to evict";
74
+ readonly "\uD83E\uDE82": "Abort transaction";
75
+ };
76
+ type LoggerIcon = keyof typeof LoggerIconDictionary;
77
+ declare const LOG_LEVELS: readonly ["info", "warn", "error"];
78
+ type LogLevel = (typeof LOG_LEVELS)[number];
79
+ type LogFn = (icon: LoggerIcon, tokenType: `atom` | `readonly_selector` | `selector` | `state` | `timeline` | `transaction` | `unknown`, tokenKey: string, message: string, ...rest: unknown[]) => void;
80
+ type LogFilter = (...params: Parameters<LogFn>) => boolean;
81
+ type Logger = Record<LogLevel, LogFn>;
82
+ declare class AtomIOLogger implements Logger {
83
+ logLevel: `error` | `info` | `warn` | null;
84
+ private readonly filter?;
85
+ private readonly logger;
86
+ constructor(logLevel: `error` | `info` | `warn` | null, filter?: LogFilter | undefined, logger?: Logger);
87
+ error: LogFn;
88
+ info: LogFn;
89
+ warn: LogFn;
90
+ }
91
+
92
+ type TransactionToken<_> = {
93
+ key: string;
94
+ type: `transaction`;
95
+ __brand?: _;
96
+ };
97
+ type TransactionUpdate<ƒ extends ƒn> = {
98
+ key: string;
99
+ updates: (KeyedStateUpdate<unknown> | TransactionUpdate<ƒn>)[];
100
+ params: Parameters<ƒ>;
101
+ output: ReturnType<ƒ>;
102
+ };
103
+
104
+ type SelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => SelectorToken<T>) & {
105
+ key: string;
106
+ type: `selector_family`;
107
+ subject: Subject<SelectorToken<T>>;
108
+ };
109
+ type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
110
+ key: string;
111
+ type: `readonly_selector_family`;
112
+ subject: Subject<ReadonlySelectorToken<T>>;
113
+ };
114
+
115
+ type StateUpdate<T> = {
116
+ newValue: T;
117
+ oldValue: T;
118
+ };
119
+ type KeyedStateUpdate<T> = StateUpdate<T> & {
120
+ key: string;
121
+ family?: FamilyMetadata;
122
+ };
123
+
124
+ type TimelineToken = {
125
+ key: string;
126
+ type: `timeline`;
127
+ };
128
+ type TimelineUpdate = TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate;
129
+
130
+ type ƒn = (...parameters: any[]) => any;
131
+ type AtomToken<_> = {
132
+ key: string;
133
+ type: `atom`;
134
+ family?: FamilyMetadata;
135
+ __brand?: _;
136
+ };
137
+ interface MutableAtomToken<T extends Transceiver<any>, J extends Serializable> extends AtomToken<T> {
138
+ __asJSON?: J;
139
+ __update?: T extends Transceiver<infer Update> ? Update : never;
140
+ }
141
+ type SelectorToken<_> = {
142
+ key: string;
143
+ type: `selector`;
144
+ family?: FamilyMetadata;
145
+ __brand?: _;
146
+ };
147
+ type StateToken<T> = AtomToken<T> | SelectorToken<T>;
148
+ type ReadonlySelectorToken<_> = {
149
+ key: string;
150
+ type: `readonly_selector`;
151
+ family?: FamilyMetadata;
152
+ __brand?: _;
153
+ };
154
+ type FamilyMetadata = {
155
+ key: string;
156
+ subKey: string;
157
+ };
158
+
159
+ declare class Subject<T> {
160
+ Subscriber: (value: T) => void;
161
+ subscribers: Map<string, this[`Subscriber`]>;
162
+ subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
163
+ private unsubscribe;
164
+ next(value: T): void;
165
+ }
166
+ declare class StatefulSubject<T> extends Subject<T> {
167
+ state: T;
168
+ constructor(initialState: T);
169
+ next(value: T): void;
170
+ }
171
+
172
+ type Selector<T> = {
173
+ key: string;
174
+ type: `selector`;
175
+ family?: FamilyMetadata;
176
+ install: (store: Store) => void;
177
+ subject: Subject<{
178
+ newValue: T;
179
+ oldValue: T;
180
+ }>;
181
+ get: () => T;
182
+ set: (newValue: T | ((oldValue: T) => T)) => void;
183
+ };
184
+ type ReadonlySelector<T> = {
185
+ key: string;
186
+ type: `readonly_selector`;
187
+ family?: FamilyMetadata;
188
+ install: (store: Store) => void;
189
+ subject: Subject<{
190
+ newValue: T;
191
+ oldValue: T;
192
+ }>;
193
+ get: () => T;
194
+ };
195
+
196
+ type Transaction<ƒ extends ƒn> = {
197
+ key: string;
198
+ type: `transaction`;
199
+ install: (store: Store) => void;
200
+ subject: Subject<TransactionUpdate<ƒ>>;
201
+ run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
202
+ };
203
+
204
+ type TransactionMeta<ƒ extends ƒn> = {
205
+ phase: `applying` | `building`;
206
+ time: number;
207
+ update: TransactionUpdate<ƒ>;
208
+ };
209
+
210
+ type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
211
+ type Cardinality = `1:1` | `1:n` | `n:n`;
212
+
213
+ interface JunctionEntries<Content extends Object$1 | null> extends Object$1 {
214
+ readonly relations: [string, string[]][];
215
+ readonly contents: [string, Content][];
216
+ }
217
+ interface JunctionSchema<ASide extends string, BSide extends string> extends Object$1 {
218
+ readonly between: [a: ASide, b: BSide];
219
+ readonly cardinality: Cardinality;
220
+ }
221
+ type BaseExternalStoreConfiguration = {
222
+ addRelation: (a: string, b: string) => void;
223
+ deleteRelation: (a: string, b: string) => void;
224
+ replaceRelationsSafely: (a: string, bs: string[]) => void;
225
+ replaceRelationsUnsafely: (a: string, bs: string[]) => void;
226
+ getRelatedKeys: (key: string) => Set<string> | undefined;
227
+ has: (a: string, b?: string) => boolean;
228
+ };
229
+ type ExternalStoreWithContentConfiguration<Content extends Object$1> = {
230
+ getContent: (contentKey: string) => Content | undefined;
231
+ setContent: (contentKey: string, content: Content) => void;
232
+ deleteContent: (contentKey: string) => void;
233
+ };
234
+ type Empty<Obj extends object> = {
235
+ [Key in keyof Obj]?: undefined;
236
+ };
237
+ type ExternalStoreConfiguration<Content extends Object$1 | null> = Content extends Object$1 ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Object$1>>;
238
+ type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
239
+ externalStore?: ExternalStoreConfiguration<Content>;
240
+ isContent?: Refinement<unknown, Content>;
241
+ makeContentKey?: (a: string, b: string) => string;
242
+ };
243
+ type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
244
+ declare class Junction<const ASide extends string, const BSide extends string, const Content extends Object$1 | null = null> {
245
+ readonly a: ASide;
246
+ readonly b: BSide;
247
+ readonly cardinality: Cardinality;
248
+ readonly relations: Map<string, Set<string>>;
249
+ readonly contents: Map<string, Content>;
250
+ isContent: Refinement<unknown, Content> | null;
251
+ makeContentKey: (a: string, b: string) => string;
252
+ getRelatedKeys(key: string): Set<string> | undefined;
253
+ protected addRelation(a: string, b: string): void;
254
+ protected deleteRelation(a: string, b: string): void;
255
+ protected replaceRelationsUnsafely(a: string, bs: string[]): void;
256
+ protected replaceRelationsSafely(a: string, bs: string[]): void;
257
+ protected getContentInternal(contentKey: string): Content | undefined;
258
+ protected setContent(contentKey: string, content: Content): void;
259
+ protected deleteContent(contentKey: string): void;
260
+ constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
261
+ toJSON(): JunctionJSON<ASide, BSide, Content>;
262
+ set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
263
+ set(relation: {
264
+ [Key in ASide | BSide]: string;
265
+ }, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
266
+ delete(a: string, b?: string): this;
267
+ delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
268
+ getRelatedKey(key: string): string | undefined;
269
+ replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
270
+ reckless: boolean;
271
+ }): this;
272
+ getContent(a: string, b: string): Content | undefined;
273
+ getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
274
+ has(a: string, b?: string): boolean;
275
+ }
276
+
277
+ interface Lineage {
278
+ parent: typeof this | null;
279
+ child: typeof this | null;
280
+ }
281
+
282
+ interface Transceiver<Signal extends Serializable> {
283
+ do: (update: Signal) => void;
284
+ undo: (update: Signal) => void;
285
+ subscribe: (key: string, fn: (update: Signal) => void) => () => void;
286
+ cacheUpdateNumber: number;
287
+ getUpdateNumber: (update: Signal) => number;
288
+ }
289
+
290
+ /**
291
+ * @internal Give the tracker a transceiver state and a store, and it will
292
+ * subscribe to the transceiver's inner value. When the inner value changes,
293
+ * the tracker will update its own state to reflect the change.
294
+ */
295
+ declare class Tracker<Mutable extends Transceiver<any>> {
296
+ private Update;
297
+ private initializeState;
298
+ private unsubscribeFromInnerValue;
299
+ private observeCore;
300
+ private updateCore;
301
+ mutableState: MutableAtomToken<Mutable, Serializable>;
302
+ latestUpdateState: AtomToken<typeof this.Update | null>;
303
+ constructor(mutableState: MutableAtomToken<Mutable, Serializable>, store: Store);
304
+ }
305
+
306
+ interface MutableAtom<T> extends Atom<T> {
307
+ mutable: true;
308
+ }
309
+
310
+ type OperationProgress = {
311
+ open: false;
312
+ } | {
313
+ open: true;
314
+ done: Set<string>;
315
+ prev: Map<string, any>;
316
+ time: number;
317
+ token: StateToken<any>;
318
+ };
319
+
320
+ type TimelineAtomUpdate = StateUpdate<unknown> & {
321
+ key: string;
322
+ type: `atom_update`;
323
+ timestamp: number;
324
+ family?: FamilyMetadata;
325
+ };
326
+ type TimelineSelectorUpdate = {
327
+ key: string;
328
+ type: `selector_update`;
329
+ timestamp: number;
330
+ atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
331
+ };
332
+ type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
333
+ key: string;
334
+ type: `transaction_update`;
335
+ timestamp: number;
336
+ };
337
+ type Timeline = {
338
+ type: `timeline`;
339
+ key: string;
340
+ at: number;
341
+ shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
342
+ timeTraveling: `into_future` | `into_past` | null;
343
+ history: TimelineUpdate[];
344
+ selectorTime: number | null;
345
+ transactionKey: string | null;
346
+ install: (store: Store) => void;
347
+ subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
348
+ };
349
+
350
+ declare class Store implements Lineage {
351
+ parent: Store | null;
352
+ child: Store | null;
353
+ valueMap: Map<string, any>;
354
+ atoms: Map<string, Atom<any> | MutableAtom<any>>;
355
+ selectors: Map<string, Selector<any>>;
356
+ readonlySelectors: Map<string, ReadonlySelector<any>>;
357
+ trackers: Map<string, Tracker<Transceiver<any>>>;
358
+ families: Map<string, AtomFamily<any, any> | ReadonlySelectorFamily<any, any> | SelectorFamily<any, any>>;
359
+ timelines: Map<string, Timeline>;
360
+ transactions: Map<string, Transaction<ƒn>>;
361
+ atomsThatAreDefault: Set<string>;
362
+ timelineAtoms: Junction<"timelineKey", "atomKey", null>;
363
+ selectorAtoms: Junction<"selectorKey", "atomKey", null>;
364
+ selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
365
+ source: string;
366
+ }>;
367
+ subject: {
368
+ atomCreation: Subject<AtomToken<unknown>>;
369
+ selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
370
+ transactionCreation: Subject<TransactionToken<ƒn>>;
371
+ timelineCreation: Subject<TimelineToken>;
372
+ transactionApplying: StatefulSubject<TransactionMeta<ƒn> | null>;
373
+ operationStatus: Subject<OperationProgress>;
374
+ };
375
+ operation: OperationProgress;
376
+ transactionMeta: TransactionMeta<ƒn> | null;
377
+ config: {
378
+ name: string;
379
+ };
380
+ loggers: AtomIOLogger[];
381
+ logger: Logger;
382
+ constructor(name: string, store?: Store | null);
383
+ }
384
+
385
+ type Atom<T> = {
386
+ key: string;
387
+ type: `atom`;
388
+ mutable?: boolean;
389
+ family?: FamilyMetadata;
390
+ install: (store: Store) => void;
391
+ subject: Subject<{
392
+ newValue: T;
393
+ oldValue: T;
394
+ }>;
395
+ default: T | (() => T);
396
+ cleanup?: () => void;
397
+ };
398
+
399
+ type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>;
400
+
401
+ type FamilyNode<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = {
402
+ key: string;
403
+ familyMembers: Record<string, Token>;
404
+ };
405
+ type StateTokenIndex<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = Record<string, FamilyNode<Token> | Token>;
406
+
407
+ type SelectorTokenIndex = StateTokenIndex<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
408
+
409
+ type Delta = {
410
+ summary: string;
411
+ added?: [path: string, addedStringifiedValue: string][];
412
+ removed?: [path: string, removedStringifiedValue: string][];
413
+ changed?: [path: string, delta: Delta][];
414
+ };
415
+ type Diff<T> = (a: T, b: T) => Delta;
416
+ type DiffTree<T> = (a: T, b: T, recurse: Differ<any, any>[`diff`]) => Delta;
417
+ declare class Differ<Leaf extends Record<string, any>, Tree extends Record<string, any>> {
418
+ leafRefinery: Refinery<Leaf>;
419
+ treeRefinery: Refinery<Tree>;
420
+ leafDiffers: {
421
+ [KL in keyof Leaf]: Diff<Supported<Leaf[KL]>>;
422
+ };
423
+ treeDiffers: {
424
+ [KT in keyof Tree]: DiffTree<Supported<Tree[KT]>>;
425
+ };
426
+ constructor(leafRefinery: Refinery<Leaf>, treeRefinery: Refinery<Tree>, diffFunctions: {
427
+ [KT in keyof Tree]: DiffTree<Supported<Tree[KT]>>;
428
+ } & {
429
+ [KL in keyof Leaf]: Diff<Supported<Leaf[KL]>>;
430
+ });
431
+ diff(a: unknown, b: unknown): Delta;
432
+ }
433
+
434
+ declare const AtomIODevtools: () => JSX.Element;
435
+
436
+ declare const atomIndex: ReadonlySelectorToken<AtomTokenIndex>;
437
+ declare const selectorIndex: ReadonlySelectorToken<SelectorTokenIndex>;
438
+ declare const transactionIndex: ReadonlySelectorToken<TransactionToken<ƒn>[]>;
439
+ declare const findTransactionLogState: ReadonlySelectorFamily<TransactionUpdate<ƒn>[]>;
440
+ declare const timelineIndex: ReadonlySelectorToken<TimelineToken[]>;
441
+ declare const findTimelineState: ReadonlySelectorFamily<Timeline>;
442
+ declare const devtoolsAreOpenState: AtomToken<boolean>;
443
+ type DevtoolsView = `atoms` | `selectors` | `timelines` | `transactions`;
444
+ declare const devtoolsViewSelectionState: AtomToken<DevtoolsView>;
445
+ declare const devtoolsViewOptionsState: AtomToken<DevtoolsView[]>;
446
+ declare const findViewIsOpenState: AtomFamily<boolean, string>;
447
+ declare const primitiveRefinery: Refinery<{
448
+ number: (input: unknown) => input is number;
449
+ string: (input: unknown) => input is string;
450
+ boolean: (input: unknown) => input is boolean;
451
+ null: (input: unknown) => input is null;
452
+ }>;
453
+ declare const jsonTreeRefinery: Refinery<{
454
+ object: (input: unknown) => input is PlainObject;
455
+ array: (input: unknown) => input is unknown[];
456
+ }>;
457
+ declare const prettyJson: Differ<{
458
+ number: (input: unknown) => input is number;
459
+ string: (input: unknown) => input is string;
460
+ boolean: (input: unknown) => input is boolean;
461
+ null: (input: unknown) => input is null;
462
+ }, {
463
+ object: (input: unknown) => input is PlainObject;
464
+ array: (input: unknown) => input is unknown[];
465
+ }>;
466
+
467
+ export { AtomIODevtools, atomIndex, devtoolsAreOpenState, devtoolsViewOptionsState, devtoolsViewSelectionState, findTimelineState, findTransactionLogState, findViewIsOpenState, jsonTreeRefinery, prettyJson, primitiveRefinery, selectorIndex, timelineIndex, transactionIndex };
@@ -1,7 +1,7 @@
1
1
  import { treeShake, isEmptyArray, pipe, ifDefined, isArray, isRecord, doesExtend, isModifier, sprawl, isPlainObject, raiseError, recordToEntries, fallback, hasExactProperties, isEmptyObject, doNothing, isOneOf, map, entriesToRecord, comprises, addTo, become, mapObject, delve } from '../../dist/chunk-NYCVSXQB.js';
2
- import { attachIntrospectionStates } from '../../dist/chunk-CK7GNCU5.js';
3
- import { useI, useO } from '../../dist/chunk-LFXB7Y6M.js';
4
- import { __spreadProps, __spreadValues, JSON_TYPE_NAMES, isString, isNumber, isBoolean, selectorFamily, atom, atomFamily, stringifyJson, undo, redo, getState, __objRest, __restKey, JSON_DEFAULTS } from '../../dist/chunk-TE3ZSTQ6.js';
2
+ import { attachIntrospectionStates } from '../../dist/chunk-GMN5KH6A.js';
3
+ import { useI, useO } from '../../dist/chunk-CWKKQKVQ.js';
4
+ import { __spreadProps, __spreadValues, JSON_TYPE_NAMES, isString, isNumber, isBoolean, selectorFamily, atom, atomFamily, stringifyJson, undo, redo, getState, __objRest, __restKey, JSON_DEFAULTS } from '../../dist/chunk-PURABO5G.js';
5
5
  import { motion, spring, LayoutGroup } from 'framer-motion';
6
6
  import * as React from 'react';
7
7
  import { forwardRef, useRef, useState, useImperativeHandle, useLayoutEffect, Fragment as Fragment$1, Component, useId } from 'react';
@@ -214,7 +214,8 @@ var Subject = class {
214
214
  this.subscribers.delete(key);
215
215
  }
216
216
  next(value) {
217
- for (const subscriber of this.subscribers.values()) {
217
+ const subscribers = this.subscribers.values();
218
+ for (const subscriber of subscribers) {
218
219
  subscriber(value);
219
220
  }
220
221
  }
@@ -1021,35 +1022,6 @@ function createSelector(options, family, store) {
1021
1022
  return createReadonlySelector(options, family, store);
1022
1023
  }
1023
1024
 
1024
- // internal/src/selector/delete-selector.ts
1025
- function deleteSelector(selectorToken, store) {
1026
- const target = newest(store);
1027
- const { key } = selectorToken;
1028
- switch (selectorToken.type) {
1029
- case `selector`:
1030
- target.selectors.delete(key);
1031
- break;
1032
- case `readonly_selector`:
1033
- target.readonlySelectors.delete(key);
1034
- break;
1035
- }
1036
- target.valueMap.delete(key);
1037
- target.selectorAtoms.delete(key);
1038
- const downstreamTokens = target.selectorGraph.getRelationEntries({ upstreamSelectorKey: key }).filter(([_, { source }]) => source === key).map(
1039
- ([downstreamSelectorKey]) => {
1040
- var _a;
1041
- return (_a = target.selectors.get(downstreamSelectorKey)) != null ? _a : target.readonlySelectors.get(downstreamSelectorKey);
1042
- }
1043
- );
1044
- for (const downstreamToken of downstreamTokens) {
1045
- if (downstreamToken) {
1046
- deleteSelector(downstreamToken, store);
1047
- }
1048
- }
1049
- target.selectorGraph.delete(key);
1050
- store.logger.info(`\u{1F525}`, selectorToken.type, `${key}`, `deleted`);
1051
- }
1052
-
1053
1025
  // internal/src/subscribe/recall-state.ts
1054
1026
  var recallState = (state, store) => {
1055
1027
  const target = newest(store);
@@ -1194,7 +1166,8 @@ var Tracker = class {
1194
1166
  }
1195
1167
  initializeState(mutableState, store) {
1196
1168
  const latestUpdateStateKey = `*${mutableState.key}`;
1197
- deleteAtom({ type: `atom`, key: latestUpdateStateKey }, store);
1169
+ store.atoms.delete(latestUpdateStateKey);
1170
+ store.valueMap.delete(latestUpdateStateKey);
1198
1171
  const familyMetaData = mutableState.family ? {
1199
1172
  key: `*${mutableState.family.key}`,
1200
1173
  subKey: mutableState.family.subKey
@@ -1207,6 +1180,10 @@ var Tracker = class {
1207
1180
  familyMetaData,
1208
1181
  store
1209
1182
  );
1183
+ if (store.parent) {
1184
+ const parentValue = store.parent.valueMap.get(latestUpdateStateKey);
1185
+ store.valueMap.set(latestUpdateStateKey, parentValue);
1186
+ }
1210
1187
  return latestUpdateState;
1211
1188
  }
1212
1189
  observeCore(mutableState, latestUpdateState, store) {
@@ -1287,7 +1264,7 @@ var Tracker = class {
1287
1264
  () => {
1288
1265
  unsubscribe();
1289
1266
  const mutable = getState(mutableState, store);
1290
- const updateNumber = mutable.getUpdateNumber(newValue);
1267
+ const updateNumber = newValue === null ? -1 : mutable.getUpdateNumber(newValue);
1291
1268
  const eventOffset = updateNumber - mutable.cacheUpdateNumber;
1292
1269
  if (newValue && eventOffset === 1) {
1293
1270
  setState(
@@ -1442,38 +1419,6 @@ function createAtom(options, family, store) {
1442
1419
  return token;
1443
1420
  }
1444
1421
 
1445
- // internal/src/atom/delete-atom.ts
1446
- function deleteAtom(atomToken, store) {
1447
- var _a, _b;
1448
- const target = newest(store);
1449
- const { key } = atomToken;
1450
- const atom2 = target.atoms.get(key);
1451
- if (!atom2) {
1452
- store.logger.error(
1453
- `\u274C`,
1454
- `atom`,
1455
- `${key}`,
1456
- `Tried to delete atom, but it does not exist in the store.`
1457
- );
1458
- }
1459
- (_a = atom2 == null ? void 0 : atom2.cleanup) == null ? void 0 : _a.call(atom2);
1460
- target.atoms.delete(key);
1461
- target.valueMap.delete(key);
1462
- const selectorKeys = target.selectorAtoms.getRelatedKeys(key);
1463
- if (selectorKeys) {
1464
- for (const selectorKey of selectorKeys) {
1465
- const token = (_b = target.selectors.get(selectorKey)) != null ? _b : target.readonlySelectors.get(selectorKey);
1466
- if (token) {
1467
- deleteSelector(token, store);
1468
- }
1469
- }
1470
- }
1471
- target.selectorAtoms.delete(key);
1472
- target.atomsThatAreDefault.delete(key);
1473
- target.timelineAtoms.delete(key);
1474
- store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
1475
- }
1476
-
1477
1422
  // internal/src/not-found-error.ts
1478
1423
  var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
1479
1424
  function prettyPrintTokenType(token) {