atom.io 0.6.6 → 0.6.8

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 (76) hide show
  1. package/dist/index.d.mts +34 -25
  2. package/dist/index.d.ts +34 -25
  3. package/dist/index.js +94 -115
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +94 -105
  6. package/dist/index.mjs.map +1 -1
  7. package/introspection/dist/index.d.mts +272 -0
  8. package/introspection/dist/index.d.ts +272 -0
  9. package/introspection/dist/index.js +41 -3
  10. package/introspection/dist/index.js.map +1 -1
  11. package/introspection/dist/index.mjs +41 -3
  12. package/introspection/dist/index.mjs.map +1 -1
  13. package/json/dist/index.d.mts +5 -7
  14. package/json/dist/index.d.ts +5 -7
  15. package/json/dist/index.js.map +1 -1
  16. package/json/dist/index.mjs.map +1 -1
  17. package/package.json +22 -14
  18. package/react-devtools/dist/index.css +9 -1
  19. package/react-devtools/dist/index.css.map +1 -1
  20. package/react-devtools/dist/index.d.mts +22 -25
  21. package/react-devtools/dist/index.d.ts +22 -25
  22. package/react-devtools/dist/index.js +845 -326
  23. package/react-devtools/dist/index.js.map +1 -1
  24. package/react-devtools/dist/index.mjs +830 -306
  25. package/react-devtools/dist/index.mjs.map +1 -1
  26. package/realtime/dist/index.d.mts +6 -8
  27. package/realtime/dist/index.d.ts +6 -8
  28. package/realtime/dist/index.js +0 -1
  29. package/realtime/dist/index.js.map +1 -1
  30. package/realtime/dist/index.mjs +0 -1
  31. package/realtime/dist/index.mjs.map +1 -1
  32. package/realtime-react/dist/index.d.mts +11 -13
  33. package/realtime-react/dist/index.d.ts +11 -13
  34. package/realtime-react/dist/index.js.map +1 -1
  35. package/realtime-react/dist/index.mjs.map +1 -1
  36. package/src/atom.ts +4 -4
  37. package/src/index.ts +1 -1
  38. package/src/internal/atom-internal.ts +5 -6
  39. package/src/internal/families-internal.ts +23 -20
  40. package/src/internal/get.ts +7 -9
  41. package/src/internal/index.ts +1 -1
  42. package/src/internal/operation.ts +14 -21
  43. package/src/internal/selector/create-read-write-selector.ts +11 -5
  44. package/src/internal/selector/create-readonly-selector.ts +4 -8
  45. package/src/internal/selector-internal.ts +1 -3
  46. package/src/internal/set.ts +1 -4
  47. package/src/internal/store.ts +19 -22
  48. package/src/internal/subscribe-internal.ts +7 -1
  49. package/src/internal/time-travel-internal.ts +4 -4
  50. package/src/internal/timeline/add-atom-to-timeline.ts +2 -2
  51. package/src/internal/timeline-internal.ts +3 -5
  52. package/src/internal/transaction/apply-transaction.ts +9 -6
  53. package/src/internal/transaction/build-transaction.ts +6 -6
  54. package/src/internal/transaction-internal.ts +1 -7
  55. package/src/introspection/attach-timeline-family.ts +14 -4
  56. package/src/introspection/attach-transaction-logs.ts +1 -1
  57. package/src/json/select-json.ts +1 -1
  58. package/src/react-devtools/AtomIODevtools.tsx +1 -2
  59. package/src/react-devtools/StateEditor.tsx +5 -1
  60. package/src/react-devtools/StateIndex.tsx +4 -1
  61. package/src/react-devtools/devtools.scss +0 -1
  62. package/src/react-explorer/AtomIOExplorer.tsx +3 -3
  63. package/src/realtime/hook-composition/expose-family.ts +2 -2
  64. package/src/realtime/hook-composition/expose-single.ts +1 -1
  65. package/src/realtime/hook-composition/receive-state.ts +1 -1
  66. package/src/realtime-react/realtime-hooks.ts +4 -4
  67. package/src/realtime-react/use-pull-family-member.ts +2 -2
  68. package/src/realtime-react/use-pull-family.ts +2 -2
  69. package/src/realtime-react/use-pull.ts +3 -1
  70. package/src/realtime-react/use-push.ts +3 -1
  71. package/src/selector.ts +14 -12
  72. package/src/subscribe.ts +1 -1
  73. package/src/tracker/index.ts +3 -0
  74. package/src/tracker/tracker.ts +61 -0
  75. package/src/web-effects/storage.ts +1 -1
  76. package/src/internal/subject.ts +0 -24
@@ -0,0 +1,272 @@
1
+ import { AtomToken as AtomToken$1, ReadonlySelectorToken as ReadonlySelectorToken$1, SelectorToken as SelectorToken$1, __INTERNAL__, TransactionToken as TransactionToken$1, ReadonlySelectorFamily, TransactionUpdate as TransactionUpdate$1, TimelineToken as TimelineToken$1 } from 'atom.io';
2
+ import { Refinement } from 'fp-ts/Refinement';
3
+
4
+ type ƒn = (...parameters: any[]) => any;
5
+
6
+ type AtomTokenIndex = StateTokenIndex<AtomToken$1<unknown>>;
7
+
8
+ type SelectorTokenIndex = StateTokenIndex<ReadonlySelectorToken$1<unknown> | SelectorToken$1<unknown>>;
9
+
10
+ type JsonInterface<T, J extends Serializable = Serializable> = {
11
+ toJson: (t: T) => J;
12
+ fromJson: (json: J) => T;
13
+ };
14
+
15
+ type primitive = boolean | number | string | null;
16
+
17
+ type Serializable = primitive | Readonly<{
18
+ [key: string]: Serializable;
19
+ }> | ReadonlyArray<Serializable>;
20
+ type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
21
+
22
+ type Identified = {
23
+ id: string;
24
+ };
25
+
26
+ declare const RELATION_TYPES: readonly ["1:1", "1:n", "n:n"];
27
+ type RelationType = typeof RELATION_TYPES[number];
28
+ type RelationData<CONTENT extends Object$1 | null = null, A extends string = `from`, B extends string = `to`> = {
29
+ contents: Object$1<string, CONTENT>;
30
+ relations: Object$1<string, string[]>;
31
+ relationType: RelationType;
32
+ a: A;
33
+ b: B;
34
+ };
35
+ type IsRelationDataOptions<CONTENT extends Object$1 | null = null, A extends string = `from`, B extends string = `to`> = {
36
+ from?: A;
37
+ to?: B;
38
+ isContent?: (json: Serializable) => json is CONTENT;
39
+ };
40
+
41
+ type NullSafeUnion<Base, Extension> = Extension extends null ? Base : Base & Extension;
42
+ type NullSafeRest<MaybeArg, IfArg = MaybeArg> = MaybeArg extends null ? [] | [undefined] : [IfArg];
43
+
44
+ declare class Join<CONTENT extends Object$1 | null = null, A extends string = `from`, B extends string = `to`> implements RelationData<CONTENT, A, B> {
45
+ readonly relationType: `1:1` | `1:n` | `n:n`;
46
+ readonly a: A;
47
+ readonly b: B;
48
+ readonly relations: Record<string, string[]>;
49
+ readonly contents: Record<string, CONTENT>;
50
+ constructor(json?: Partial<RelationData<CONTENT, A, B>>);
51
+ toJSON(): RelationData<CONTENT, A, B>;
52
+ static fromJSON<CONTENT extends Object$1 | null, A extends string, B extends string>(json: Serializable, options?: IsRelationDataOptions<CONTENT, A, B>): Join<CONTENT, A, B>;
53
+ from<AA extends string>(newA: AA): Join<CONTENT, AA, B>;
54
+ to<BB extends string>(newB: BB): Join<CONTENT, A, BB>;
55
+ makeJsonInterface: (...params: CONTENT extends null ? [
56
+ ] : [Refinement<unknown, CONTENT>]) => JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>>;
57
+ getRelatedId(id: string): string | undefined;
58
+ getRelatedIds(id: string): string[];
59
+ getContent(idA: string, idB: string): CONTENT | undefined;
60
+ getRelationEntries(id: string): [string, CONTENT][];
61
+ getRelationRecord(id: string): Record<string, CONTENT>;
62
+ getRelation(id: string): NullSafeUnion<Identified, CONTENT> | undefined;
63
+ getRelations(id: string): NullSafeUnion<Identified, CONTENT>[];
64
+ setRelations(subject: {
65
+ [from in A]: string;
66
+ } | {
67
+ [to in B]: string;
68
+ }, relations: NullSafeUnion<Identified, CONTENT>[]): Join<CONTENT, A, B>;
69
+ set(relation: {
70
+ [key in A | B]: string;
71
+ }, ...rest: NullSafeRest<CONTENT>): Join<CONTENT, A, B>;
72
+ remove(relation: Partial<Record<A | B, string>>): Join<CONTENT, A, B>;
73
+ }
74
+
75
+ type Logger = Pick<Console, `error` | `info` | `warn`>;
76
+
77
+ type TransactionToken<_> = {
78
+ key: string;
79
+ type: `transaction`;
80
+ __brand?: _;
81
+ };
82
+ type TransactionUpdate<ƒ extends ƒn> = {
83
+ key: string;
84
+ atomUpdates: KeyedStateUpdate<unknown>[];
85
+ params: Parameters<ƒ>;
86
+ output: ReturnType<ƒ>;
87
+ };
88
+
89
+ type StateUpdate<T> = {
90
+ newValue: T;
91
+ oldValue: T;
92
+ };
93
+ type KeyedStateUpdate<T> = StateUpdate<T> & {
94
+ key: string;
95
+ };
96
+
97
+ type TimelineToken = {
98
+ key: string;
99
+ type: `timeline`;
100
+ };
101
+ type TimelineUpdate = TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate;
102
+
103
+ type AtomToken<_> = {
104
+ key: string;
105
+ type: `atom`;
106
+ family?: FamilyMetadata;
107
+ __brand?: _;
108
+ };
109
+ type SelectorToken<_> = {
110
+ key: string;
111
+ type: `selector`;
112
+ family?: FamilyMetadata;
113
+ __brand?: _;
114
+ };
115
+ type StateToken<T> = AtomToken<T> | SelectorToken<T>;
116
+ type ReadonlySelectorToken<_> = {
117
+ key: string;
118
+ type: `readonly_selector`;
119
+ family?: FamilyMetadata;
120
+ __brand?: _;
121
+ };
122
+ type FamilyMetadata = {
123
+ key: string;
124
+ subKey: string;
125
+ };
126
+
127
+ type StoreCore = Pick<Store, `atoms` | `atomsThatAreDefault` | `operation` | `readonlySelectors` | `selectorAtoms` | `selectorGraph` | `selectors` | `timelineAtoms` | `timelines` | `transactions` | `valueMap`>;
128
+ interface Store {
129
+ atoms: Map<string, Atom<any>>;
130
+ atomsThatAreDefault: Set<string>;
131
+ readonlySelectors: Map<string, ReadonlySelector<any>>;
132
+ selectorAtoms: Join<null, `selectorKey`, `atomKey`>;
133
+ selectorGraph: Join<{
134
+ source: string;
135
+ }>;
136
+ selectors: Map<string, Selector<any>>;
137
+ timelineAtoms: Join<null, `timelineKey`, `atomKey`>;
138
+ timelines: Map<string, Timeline>;
139
+ transactions: Map<string, Transaction<any>>;
140
+ valueMap: Map<string, any>;
141
+ subject: {
142
+ atomCreation: Subject<AtomToken<unknown>>;
143
+ selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
144
+ transactionCreation: Subject<TransactionToken<ƒn>>;
145
+ timelineCreation: Subject<TimelineToken>;
146
+ operationStatus: Subject<OperationProgress>;
147
+ };
148
+ operation: OperationProgress;
149
+ transactionStatus: TransactionStatus<ƒn>;
150
+ config: {
151
+ name: string;
152
+ logger: Logger | null;
153
+ logger__INTERNAL: Logger;
154
+ };
155
+ }
156
+
157
+ type Atom<T> = {
158
+ key: string;
159
+ type: `atom`;
160
+ family?: FamilyMetadata;
161
+ subject: Subject<{
162
+ newValue: T;
163
+ oldValue: T;
164
+ }>;
165
+ default: T;
166
+ };
167
+
168
+ type OperationProgress = {
169
+ open: false;
170
+ } | {
171
+ open: true;
172
+ done: Set<string>;
173
+ prev: Map<string, any>;
174
+ time: number;
175
+ token: StateToken<any>;
176
+ };
177
+
178
+ type Selector<T> = {
179
+ key: string;
180
+ type: `selector`;
181
+ family?: FamilyMetadata;
182
+ install: (store: Store) => void;
183
+ subject: Subject<{
184
+ newValue: T;
185
+ oldValue: T;
186
+ }>;
187
+ get: () => T;
188
+ set: (newValue: T | ((oldValue: T) => T)) => void;
189
+ };
190
+ type ReadonlySelector<T> = {
191
+ key: string;
192
+ type: `readonly_selector`;
193
+ family?: FamilyMetadata;
194
+ install: (store: Store) => void;
195
+ subject: Subject<{
196
+ newValue: T;
197
+ oldValue: T;
198
+ }>;
199
+ get: () => T;
200
+ };
201
+
202
+ type Subscriber<T> = (value: T) => void;
203
+ declare class Subject<T> {
204
+ subscribers: Subscriber<T>[];
205
+ subscribe(subscriber: Subscriber<T>): {
206
+ unsubscribe: () => void;
207
+ };
208
+ private unsubscribe;
209
+ next(value: T): void;
210
+ }
211
+
212
+ type TimelineAtomUpdate = StateUpdate<unknown> & {
213
+ key: string;
214
+ type: `atom_update`;
215
+ timestamp: number;
216
+ };
217
+ type TimelineSelectorUpdate = {
218
+ key: string;
219
+ type: `selector_update`;
220
+ timestamp: number;
221
+ atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
222
+ };
223
+ type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
224
+ key: string;
225
+ type: `transaction_update`;
226
+ timestamp: number;
227
+ };
228
+ type Timeline = {
229
+ key: string;
230
+ at: number;
231
+ timeTraveling: `into_future` | `into_past` | null;
232
+ history: TimelineUpdate[];
233
+ selectorTime: number | null;
234
+ transactionKey: string | null;
235
+ install: (store: Store) => void;
236
+ subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
237
+ };
238
+
239
+ type Transaction<ƒ extends ƒn> = {
240
+ key: string;
241
+ type: `transaction`;
242
+ install: (store: Store) => void;
243
+ subject: Subject<TransactionUpdate<ƒ>>;
244
+ run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
245
+ };
246
+
247
+ type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {
248
+ phase: `applying` | `building`;
249
+ time: number;
250
+ core: StoreCore;
251
+ };
252
+ type TransactionIdle = {
253
+ phase: `idle`;
254
+ };
255
+ type TransactionStatus<ƒ extends ƒn> = TransactionIdle | TransactionUpdateInProgress<ƒ>;
256
+
257
+ declare const attachIntrospectionStates: (store?: __INTERNAL__.Store) => {
258
+ atomIndex: ReadonlySelectorToken$1<AtomTokenIndex>;
259
+ selectorIndex: ReadonlySelectorToken$1<SelectorTokenIndex>;
260
+ transactionIndex: ReadonlySelectorToken$1<TransactionToken$1<ƒn>[]>;
261
+ findTransactionLogState: ReadonlySelectorFamily<TransactionUpdate$1<ƒn>[]>;
262
+ timelineIndex: ReadonlySelectorToken$1<TimelineToken$1[]>;
263
+ findTimelineState: ReadonlySelectorFamily<Timeline>;
264
+ };
265
+
266
+ type FamilyNode<Token extends AtomToken$1<unknown> | ReadonlySelectorToken$1<unknown> | SelectorToken$1<unknown>> = {
267
+ key: string;
268
+ familyMembers: Record<string, Token>;
269
+ };
270
+ type StateTokenIndex<Token extends AtomToken$1<unknown> | ReadonlySelectorToken$1<unknown> | SelectorToken$1<unknown>> = Record<string, FamilyNode<Token> | Token>;
271
+
272
+ export { FamilyNode, StateTokenIndex, attachIntrospectionStates };
@@ -0,0 +1,272 @@
1
+ import { AtomToken as AtomToken$1, ReadonlySelectorToken as ReadonlySelectorToken$1, SelectorToken as SelectorToken$1, __INTERNAL__, TransactionToken as TransactionToken$1, ReadonlySelectorFamily, TransactionUpdate as TransactionUpdate$1, TimelineToken as TimelineToken$1 } from 'atom.io';
2
+ import { Refinement } from 'fp-ts/Refinement';
3
+
4
+ type ƒn = (...parameters: any[]) => any;
5
+
6
+ type AtomTokenIndex = StateTokenIndex<AtomToken$1<unknown>>;
7
+
8
+ type SelectorTokenIndex = StateTokenIndex<ReadonlySelectorToken$1<unknown> | SelectorToken$1<unknown>>;
9
+
10
+ type JsonInterface<T, J extends Serializable = Serializable> = {
11
+ toJson: (t: T) => J;
12
+ fromJson: (json: J) => T;
13
+ };
14
+
15
+ type primitive = boolean | number | string | null;
16
+
17
+ type Serializable = primitive | Readonly<{
18
+ [key: string]: Serializable;
19
+ }> | ReadonlyArray<Serializable>;
20
+ type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
21
+
22
+ type Identified = {
23
+ id: string;
24
+ };
25
+
26
+ declare const RELATION_TYPES: readonly ["1:1", "1:n", "n:n"];
27
+ type RelationType = typeof RELATION_TYPES[number];
28
+ type RelationData<CONTENT extends Object$1 | null = null, A extends string = `from`, B extends string = `to`> = {
29
+ contents: Object$1<string, CONTENT>;
30
+ relations: Object$1<string, string[]>;
31
+ relationType: RelationType;
32
+ a: A;
33
+ b: B;
34
+ };
35
+ type IsRelationDataOptions<CONTENT extends Object$1 | null = null, A extends string = `from`, B extends string = `to`> = {
36
+ from?: A;
37
+ to?: B;
38
+ isContent?: (json: Serializable) => json is CONTENT;
39
+ };
40
+
41
+ type NullSafeUnion<Base, Extension> = Extension extends null ? Base : Base & Extension;
42
+ type NullSafeRest<MaybeArg, IfArg = MaybeArg> = MaybeArg extends null ? [] | [undefined] : [IfArg];
43
+
44
+ declare class Join<CONTENT extends Object$1 | null = null, A extends string = `from`, B extends string = `to`> implements RelationData<CONTENT, A, B> {
45
+ readonly relationType: `1:1` | `1:n` | `n:n`;
46
+ readonly a: A;
47
+ readonly b: B;
48
+ readonly relations: Record<string, string[]>;
49
+ readonly contents: Record<string, CONTENT>;
50
+ constructor(json?: Partial<RelationData<CONTENT, A, B>>);
51
+ toJSON(): RelationData<CONTENT, A, B>;
52
+ static fromJSON<CONTENT extends Object$1 | null, A extends string, B extends string>(json: Serializable, options?: IsRelationDataOptions<CONTENT, A, B>): Join<CONTENT, A, B>;
53
+ from<AA extends string>(newA: AA): Join<CONTENT, AA, B>;
54
+ to<BB extends string>(newB: BB): Join<CONTENT, A, BB>;
55
+ makeJsonInterface: (...params: CONTENT extends null ? [
56
+ ] : [Refinement<unknown, CONTENT>]) => JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>>;
57
+ getRelatedId(id: string): string | undefined;
58
+ getRelatedIds(id: string): string[];
59
+ getContent(idA: string, idB: string): CONTENT | undefined;
60
+ getRelationEntries(id: string): [string, CONTENT][];
61
+ getRelationRecord(id: string): Record<string, CONTENT>;
62
+ getRelation(id: string): NullSafeUnion<Identified, CONTENT> | undefined;
63
+ getRelations(id: string): NullSafeUnion<Identified, CONTENT>[];
64
+ setRelations(subject: {
65
+ [from in A]: string;
66
+ } | {
67
+ [to in B]: string;
68
+ }, relations: NullSafeUnion<Identified, CONTENT>[]): Join<CONTENT, A, B>;
69
+ set(relation: {
70
+ [key in A | B]: string;
71
+ }, ...rest: NullSafeRest<CONTENT>): Join<CONTENT, A, B>;
72
+ remove(relation: Partial<Record<A | B, string>>): Join<CONTENT, A, B>;
73
+ }
74
+
75
+ type Logger = Pick<Console, `error` | `info` | `warn`>;
76
+
77
+ type TransactionToken<_> = {
78
+ key: string;
79
+ type: `transaction`;
80
+ __brand?: _;
81
+ };
82
+ type TransactionUpdate<ƒ extends ƒn> = {
83
+ key: string;
84
+ atomUpdates: KeyedStateUpdate<unknown>[];
85
+ params: Parameters<ƒ>;
86
+ output: ReturnType<ƒ>;
87
+ };
88
+
89
+ type StateUpdate<T> = {
90
+ newValue: T;
91
+ oldValue: T;
92
+ };
93
+ type KeyedStateUpdate<T> = StateUpdate<T> & {
94
+ key: string;
95
+ };
96
+
97
+ type TimelineToken = {
98
+ key: string;
99
+ type: `timeline`;
100
+ };
101
+ type TimelineUpdate = TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate;
102
+
103
+ type AtomToken<_> = {
104
+ key: string;
105
+ type: `atom`;
106
+ family?: FamilyMetadata;
107
+ __brand?: _;
108
+ };
109
+ type SelectorToken<_> = {
110
+ key: string;
111
+ type: `selector`;
112
+ family?: FamilyMetadata;
113
+ __brand?: _;
114
+ };
115
+ type StateToken<T> = AtomToken<T> | SelectorToken<T>;
116
+ type ReadonlySelectorToken<_> = {
117
+ key: string;
118
+ type: `readonly_selector`;
119
+ family?: FamilyMetadata;
120
+ __brand?: _;
121
+ };
122
+ type FamilyMetadata = {
123
+ key: string;
124
+ subKey: string;
125
+ };
126
+
127
+ type StoreCore = Pick<Store, `atoms` | `atomsThatAreDefault` | `operation` | `readonlySelectors` | `selectorAtoms` | `selectorGraph` | `selectors` | `timelineAtoms` | `timelines` | `transactions` | `valueMap`>;
128
+ interface Store {
129
+ atoms: Map<string, Atom<any>>;
130
+ atomsThatAreDefault: Set<string>;
131
+ readonlySelectors: Map<string, ReadonlySelector<any>>;
132
+ selectorAtoms: Join<null, `selectorKey`, `atomKey`>;
133
+ selectorGraph: Join<{
134
+ source: string;
135
+ }>;
136
+ selectors: Map<string, Selector<any>>;
137
+ timelineAtoms: Join<null, `timelineKey`, `atomKey`>;
138
+ timelines: Map<string, Timeline>;
139
+ transactions: Map<string, Transaction<any>>;
140
+ valueMap: Map<string, any>;
141
+ subject: {
142
+ atomCreation: Subject<AtomToken<unknown>>;
143
+ selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
144
+ transactionCreation: Subject<TransactionToken<ƒn>>;
145
+ timelineCreation: Subject<TimelineToken>;
146
+ operationStatus: Subject<OperationProgress>;
147
+ };
148
+ operation: OperationProgress;
149
+ transactionStatus: TransactionStatus<ƒn>;
150
+ config: {
151
+ name: string;
152
+ logger: Logger | null;
153
+ logger__INTERNAL: Logger;
154
+ };
155
+ }
156
+
157
+ type Atom<T> = {
158
+ key: string;
159
+ type: `atom`;
160
+ family?: FamilyMetadata;
161
+ subject: Subject<{
162
+ newValue: T;
163
+ oldValue: T;
164
+ }>;
165
+ default: T;
166
+ };
167
+
168
+ type OperationProgress = {
169
+ open: false;
170
+ } | {
171
+ open: true;
172
+ done: Set<string>;
173
+ prev: Map<string, any>;
174
+ time: number;
175
+ token: StateToken<any>;
176
+ };
177
+
178
+ type Selector<T> = {
179
+ key: string;
180
+ type: `selector`;
181
+ family?: FamilyMetadata;
182
+ install: (store: Store) => void;
183
+ subject: Subject<{
184
+ newValue: T;
185
+ oldValue: T;
186
+ }>;
187
+ get: () => T;
188
+ set: (newValue: T | ((oldValue: T) => T)) => void;
189
+ };
190
+ type ReadonlySelector<T> = {
191
+ key: string;
192
+ type: `readonly_selector`;
193
+ family?: FamilyMetadata;
194
+ install: (store: Store) => void;
195
+ subject: Subject<{
196
+ newValue: T;
197
+ oldValue: T;
198
+ }>;
199
+ get: () => T;
200
+ };
201
+
202
+ type Subscriber<T> = (value: T) => void;
203
+ declare class Subject<T> {
204
+ subscribers: Subscriber<T>[];
205
+ subscribe(subscriber: Subscriber<T>): {
206
+ unsubscribe: () => void;
207
+ };
208
+ private unsubscribe;
209
+ next(value: T): void;
210
+ }
211
+
212
+ type TimelineAtomUpdate = StateUpdate<unknown> & {
213
+ key: string;
214
+ type: `atom_update`;
215
+ timestamp: number;
216
+ };
217
+ type TimelineSelectorUpdate = {
218
+ key: string;
219
+ type: `selector_update`;
220
+ timestamp: number;
221
+ atomUpdates: Omit<TimelineAtomUpdate, `timestamp`>[];
222
+ };
223
+ type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
224
+ key: string;
225
+ type: `transaction_update`;
226
+ timestamp: number;
227
+ };
228
+ type Timeline = {
229
+ key: string;
230
+ at: number;
231
+ timeTraveling: `into_future` | `into_past` | null;
232
+ history: TimelineUpdate[];
233
+ selectorTime: number | null;
234
+ transactionKey: string | null;
235
+ install: (store: Store) => void;
236
+ subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
237
+ };
238
+
239
+ type Transaction<ƒ extends ƒn> = {
240
+ key: string;
241
+ type: `transaction`;
242
+ install: (store: Store) => void;
243
+ subject: Subject<TransactionUpdate<ƒ>>;
244
+ run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
245
+ };
246
+
247
+ type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {
248
+ phase: `applying` | `building`;
249
+ time: number;
250
+ core: StoreCore;
251
+ };
252
+ type TransactionIdle = {
253
+ phase: `idle`;
254
+ };
255
+ type TransactionStatus<ƒ extends ƒn> = TransactionIdle | TransactionUpdateInProgress<ƒ>;
256
+
257
+ declare const attachIntrospectionStates: (store?: __INTERNAL__.Store) => {
258
+ atomIndex: ReadonlySelectorToken$1<AtomTokenIndex>;
259
+ selectorIndex: ReadonlySelectorToken$1<SelectorTokenIndex>;
260
+ transactionIndex: ReadonlySelectorToken$1<TransactionToken$1<ƒn>[]>;
261
+ findTransactionLogState: ReadonlySelectorFamily<TransactionUpdate$1<ƒn>[]>;
262
+ timelineIndex: ReadonlySelectorToken$1<TimelineToken$1[]>;
263
+ findTimelineState: ReadonlySelectorFamily<Timeline>;
264
+ };
265
+
266
+ type FamilyNode<Token extends AtomToken$1<unknown> | ReadonlySelectorToken$1<unknown> | SelectorToken$1<unknown>> = {
267
+ key: string;
268
+ familyMembers: Record<string, Token>;
269
+ };
270
+ type StateTokenIndex<Token extends AtomToken$1<unknown> | ReadonlySelectorToken$1<unknown> | SelectorToken$1<unknown>> = Record<string, FamilyNode<Token> | Token>;
271
+
272
+ export { FamilyNode, StateTokenIndex, attachIntrospectionStates };
@@ -165,15 +165,53 @@ var attachSelectorIndex = (store = import_atom2.__INTERNAL__.IMPLICIT.STORE) =>
165
165
 
166
166
  // ../src/introspection/attach-timeline-family.ts
167
167
  var import_atom3 = require("atom.io");
168
+
169
+ // ../../anvl/reactivity/subject.ts
170
+ var Subject = class {
171
+ constructor() {
172
+ this.subscribers = [];
173
+ }
174
+ subscribe(subscriber) {
175
+ this.subscribers.push(subscriber);
176
+ const unsubscribe = () => this.unsubscribe(subscriber);
177
+ return { unsubscribe };
178
+ }
179
+ unsubscribe(subscriber) {
180
+ const subscriberIndex = this.subscribers.indexOf(subscriber);
181
+ if (subscriberIndex !== -1) {
182
+ this.subscribers.splice(subscriberIndex, 1);
183
+ }
184
+ }
185
+ next(value) {
186
+ for (const subscriber of this.subscribers) {
187
+ subscriber(value);
188
+ }
189
+ }
190
+ };
191
+
192
+ // ../src/introspection/attach-timeline-family.ts
168
193
  var attachTimelineFamily = (store = import_atom3.__INTERNAL__.IMPLICIT.STORE) => {
169
194
  const findTimelineLogState__INTERNAL = import_atom3.__INTERNAL__.atomFamily__INTERNAL(
170
195
  {
171
196
  key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log (Internal)`,
172
- default: (key) => store.timelines.get(key),
197
+ default: (key) => {
198
+ var _a;
199
+ return (_a = store.timelines.get(key)) != null ? _a : {
200
+ key: ``,
201
+ at: 0,
202
+ timeTraveling: null,
203
+ history: [],
204
+ selectorTime: null,
205
+ transactionKey: null,
206
+ install: () => {
207
+ },
208
+ subject: new Subject()
209
+ };
210
+ },
173
211
  effects: (key) => [
174
212
  ({ setSelf }) => {
175
213
  const tl = store.timelines.get(key);
176
- tl.subject.subscribe((_) => {
214
+ tl == null ? void 0 : tl.subject.subscribe((_) => {
177
215
  if (store.operation.open === true) {
178
216
  const subscription = store.subject.operationStatus.subscribe(
179
217
  (operationStatus) => {
@@ -274,7 +312,7 @@ var attachTransactionLogs = (store = import_atom6.__INTERNAL__.IMPLICIT.STORE) =
274
312
  effects: (key) => [
275
313
  ({ setSelf }) => {
276
314
  const tx = store.transactions.get(key);
277
- tx.subject.subscribe((transactionUpdate) => {
315
+ tx == null ? void 0 : tx.subject.subscribe((transactionUpdate) => {
278
316
  if (transactionUpdate.key === key) {
279
317
  setSelf((state) => [...state, transactionUpdate]);
280
318
  }