atom.io 0.20.3 → 0.21.0

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 (42) hide show
  1. package/data/dist/index.cjs +1 -1
  2. package/data/dist/index.js +1 -1
  3. package/data/src/join.ts +2 -2
  4. package/dist/{chunk-SMZRGPN6.js → chunk-KGZGBCYS.js} +2 -2
  5. package/dist/chunk-PNIHPILQ.js +8 -0
  6. package/dist/{chunk-2AIFLP2B.js → chunk-RT43TVKP.js} +2 -2
  7. package/dist/index.cjs +4 -4
  8. package/dist/index.d.ts +2 -2
  9. package/dist/index.js +5 -7
  10. package/internal/dist/index.cjs +31 -26
  11. package/internal/dist/index.d.ts +10 -6
  12. package/internal/dist/index.js +30 -25
  13. package/internal/src/atom/create-regular-atom.ts +1 -1
  14. package/internal/src/atom/dispose-atom.ts +42 -0
  15. package/internal/src/atom/index.ts +1 -1
  16. package/internal/src/selector/{delete-selector.ts → dispose-selector.ts} +3 -2
  17. package/internal/src/selector/index.ts +1 -1
  18. package/internal/src/store/deposit.ts +5 -0
  19. package/internal/src/store/store.ts +5 -1
  20. package/introspection/dist/index.cjs +250 -106
  21. package/introspection/dist/index.d.ts +43 -6
  22. package/introspection/dist/index.js +225 -83
  23. package/introspection/src/attach-atom-index.ts +68 -47
  24. package/introspection/src/attach-selector-index.ts +76 -59
  25. package/introspection/src/auditor.ts +135 -0
  26. package/introspection/src/index.ts +8 -18
  27. package/package.json +9 -9
  28. package/react-devtools/dist/index.cjs +3 -3
  29. package/react-devtools/dist/index.d.ts +5 -5
  30. package/react-devtools/dist/index.js +4 -4
  31. package/react-devtools/src/StateIndex.tsx +8 -27
  32. package/realtime-client/dist/index.cjs +1 -1
  33. package/realtime-client/dist/index.js +1 -1
  34. package/realtime-client/src/sync-continuity.ts +2 -2
  35. package/realtime-react/dist/index.cjs +1 -1
  36. package/realtime-react/dist/index.js +1 -1
  37. package/realtime-server/dist/index.cjs +2 -2
  38. package/realtime-server/dist/index.js +1 -1
  39. package/realtime-testing/dist/index.cjs +4 -4
  40. package/realtime-testing/dist/index.js +1 -1
  41. package/src/dispose.ts +3 -3
  42. package/internal/src/atom/delete-atom.ts +0 -40
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var Internal = require('atom.io/internal');
3
+ var Internal2 = require('atom.io/internal');
4
4
 
5
5
  function _interopNamespace(e) {
6
6
  if (e && e.__esModule) return e;
@@ -20,11 +20,9 @@ function _interopNamespace(e) {
20
20
  return Object.freeze(n);
21
21
  }
22
22
 
23
- var Internal__namespace = /*#__PURE__*/_interopNamespace(Internal);
23
+ var Internal2__namespace = /*#__PURE__*/_interopNamespace(Internal2);
24
24
 
25
25
  var __defProp = Object.defineProperty;
26
- var __defProps = Object.defineProperties;
27
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
28
26
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
29
27
  var __hasOwnProp = Object.prototype.hasOwnProperty;
30
28
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -40,67 +38,90 @@ var __spreadValues = (a, b) => {
40
38
  }
41
39
  return a;
42
40
  };
43
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
44
- var attachAtomIndex = (store = Internal.IMPLICIT.STORE) => {
45
- console.log(store.config);
46
- const atomTokenIndexState__INTERNAL = Internal.createRegularAtom(
41
+ var attachAtomIndex = (store = Internal2.IMPLICIT.STORE) => {
42
+ const atomTokenIndexState__INTERNAL = Internal2.createRegularAtom(
47
43
  {
48
44
  key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index (Internal)`,
49
45
  default: () => {
50
- const defaultAtomIndex = [...store.atoms].filter(([key]) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`)).reduce((acc, [key, atom]) => {
51
- acc[key] = { key, type: atom.type };
52
- return acc;
53
- }, {});
54
- return defaultAtomIndex;
46
+ const base = /* @__PURE__ */ new Map();
47
+ for (const [key, val] of store.atoms) {
48
+ if (!key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
49
+ const token = Internal2.deposit(val);
50
+ if (val.family) {
51
+ let familyNode = base.get(val.family.key);
52
+ if (!familyNode || !(`familyMembers` in familyNode)) {
53
+ familyNode = {
54
+ key: val.family.key,
55
+ familyMembers: /* @__PURE__ */ new Map()
56
+ };
57
+ base.set(val.family.key, familyNode);
58
+ }
59
+ familyNode.familyMembers.set(val.family.subKey, token);
60
+ } else {
61
+ base.set(key, token);
62
+ }
63
+ }
64
+ }
65
+ return base;
55
66
  },
56
67
  effects: [
57
68
  ({ setSelf }) => {
58
- store.on.atomCreation.subscribe(`introspection`, (atomToken) => {
59
- if (atomToken.key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
60
- return;
61
- }
62
- const set = () => setSelf((state) => {
63
- const { key, family } = atomToken;
64
- if (family) {
65
- const { key: familyKey, subKey } = family;
66
- const current = state[familyKey];
67
- if (current === void 0 || `familyMembers` in current) {
68
- const familyKeyState = current || {
69
- key: familyKey,
70
- familyMembers: {}
71
- };
72
- return __spreadProps(__spreadValues({}, state), {
73
- [familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
74
- familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
75
- [subKey]: atomToken
76
- })
77
- })
78
- });
79
- }
69
+ const unsubscribeFromAtomCreation = store.on.atomCreation.subscribe(
70
+ `introspection`,
71
+ (atomToken) => {
72
+ if (atomToken.key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
73
+ return;
80
74
  }
81
- return __spreadProps(__spreadValues({}, state), {
82
- [key]: atomToken
75
+ setSelf((self) => {
76
+ if (atomToken.family) {
77
+ const { key: familyKey, subKey } = atomToken.family;
78
+ let familyNode = self.get(familyKey);
79
+ if (familyNode === void 0 || !(`familyMembers` in familyNode)) {
80
+ familyNode = {
81
+ key: familyKey,
82
+ familyMembers: /* @__PURE__ */ new Map()
83
+ };
84
+ self.set(familyKey, familyNode);
85
+ }
86
+ familyNode.familyMembers.set(subKey, atomToken);
87
+ } else {
88
+ self.set(atomToken.key, atomToken);
89
+ }
90
+ return self;
83
91
  });
84
- });
85
- if (Internal.newest(store).operation.open) {
86
- const unsubscribe = store.on.operationClose.subscribe(
87
- `introspection: waiting to update atom index`,
88
- () => {
89
- unsubscribe();
90
- set();
92
+ }
93
+ );
94
+ const unsubscribeFromAtomDisposal = store.on.atomDisposal.subscribe(
95
+ `introspection`,
96
+ (atomToken) => {
97
+ setSelf((self) => {
98
+ if (atomToken.family) {
99
+ const { key: familyKey, subKey } = atomToken.family;
100
+ const familyNode = self.get(familyKey);
101
+ if (familyNode && `familyMembers` in familyNode) {
102
+ familyNode.familyMembers.delete(subKey);
103
+ if (familyNode.familyMembers.size === 0) {
104
+ self.delete(familyKey);
105
+ }
106
+ }
107
+ } else {
108
+ self.delete(atomToken.key);
91
109
  }
92
- );
93
- } else {
94
- set();
110
+ return self;
111
+ });
95
112
  }
96
- });
113
+ );
114
+ return () => {
115
+ unsubscribeFromAtomCreation();
116
+ unsubscribeFromAtomDisposal();
117
+ };
97
118
  }
98
119
  ]
99
120
  },
100
121
  void 0,
101
122
  store
102
123
  );
103
- return Internal.createStandaloneSelector(
124
+ return Internal2.createStandaloneSelector(
104
125
  {
105
126
  key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index`,
106
127
  get: ({ get }) => get(atomTokenIndexState__INTERNAL)
@@ -108,80 +129,101 @@ var attachAtomIndex = (store = Internal.IMPLICIT.STORE) => {
108
129
  store
109
130
  );
110
131
  };
111
- var attachSelectorIndex = (store = Internal.IMPLICIT.STORE) => {
112
- const readonlySelectorTokenIndexState__INTERNAL = Internal.createRegularAtom(
132
+ var attachSelectorIndex = (store = Internal2.IMPLICIT.STORE) => {
133
+ const readonlySelectorTokenIndexState__INTERNAL = Internal2.createRegularAtom(
113
134
  {
114
135
  key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index (Internal)`,
115
- default: () => Object.assign(
116
- [...store.readonlySelectors].filter(([key]) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`)).reduce((acc, [key]) => {
117
- acc[key] = { key, type: `readonly_selector` };
118
- return acc;
119
- }, {}),
120
- [...store.selectors].reduce((acc, [key]) => {
121
- acc[key] = { key, type: `selector` };
122
- return acc;
123
- }, {})
124
- ),
136
+ default: () => {
137
+ const base = /* @__PURE__ */ new Map();
138
+ for (const map of [store.readonlySelectors, store.selectors]) {
139
+ for (const [key, val] of map) {
140
+ if (!key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
141
+ const token = Internal2.deposit(val);
142
+ if (val.family) {
143
+ let familyNode = base.get(val.family.key);
144
+ if (!familyNode || !(`familyMembers` in familyNode)) {
145
+ familyNode = {
146
+ key: val.family.key,
147
+ familyMembers: /* @__PURE__ */ new Map()
148
+ };
149
+ base.set(val.family.key, familyNode);
150
+ }
151
+ familyNode.familyMembers.set(val.family.subKey, token);
152
+ } else {
153
+ base.set(key, token);
154
+ }
155
+ }
156
+ }
157
+ }
158
+ return base;
159
+ },
125
160
  effects: [
126
161
  ({ setSelf }) => {
127
- store.on.selectorCreation.subscribe(
162
+ const unsubscribeFromSelectorCreation = store.on.selectorCreation.subscribe(
128
163
  `introspection`,
129
164
  (selectorToken) => {
130
165
  if (selectorToken.key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
131
166
  return;
132
167
  }
133
- const set = () => setSelf((state) => {
134
- const { key, family } = selectorToken;
135
- if (family) {
136
- const { key: familyKey, subKey } = family;
137
- const current = state[familyKey];
138
- if (current === void 0 || `familyMembers` in current) {
139
- const familyKeyState = current || {
168
+ setSelf((self) => {
169
+ if (selectorToken.family) {
170
+ const { key: familyKey, subKey } = selectorToken.family;
171
+ let familyNode = self.get(familyKey);
172
+ if (familyNode === void 0 || !(`familyMembers` in familyNode)) {
173
+ familyNode = {
140
174
  key: familyKey,
141
- familyMembers: {}
175
+ familyMembers: /* @__PURE__ */ new Map()
142
176
  };
143
- return __spreadProps(__spreadValues({}, state), {
144
- [familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
145
- familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
146
- [subKey]: selectorToken
147
- })
148
- })
149
- });
177
+ self.set(familyKey, familyNode);
150
178
  }
179
+ familyNode.familyMembers.set(subKey, selectorToken);
180
+ } else {
181
+ self.set(selectorToken.key, selectorToken);
151
182
  }
152
- return __spreadProps(__spreadValues({}, state), {
153
- [key]: selectorToken
154
- });
183
+ return self;
155
184
  });
156
- if (Internal.newest(store).operation.open) {
157
- const unsubscribe = store.on.operationClose.subscribe(
158
- `introspection: waiting to update selector index`,
159
- () => {
160
- unsubscribe();
161
- set();
185
+ }
186
+ );
187
+ const unsubscribeFromSelectorDisposal = store.on.selectorDisposal.subscribe(
188
+ `introspection`,
189
+ (selectorToken) => {
190
+ setSelf((self) => {
191
+ if (selectorToken.family) {
192
+ const { key: familyKey, subKey } = selectorToken.family;
193
+ const familyNode = self.get(familyKey);
194
+ if (familyNode && `familyMembers` in familyNode) {
195
+ familyNode.familyMembers.delete(subKey);
196
+ if (familyNode.familyMembers.size === 0) {
197
+ self.delete(familyKey);
198
+ }
162
199
  }
163
- );
164
- } else {
165
- set();
166
- }
200
+ } else {
201
+ self.delete(selectorToken.key);
202
+ }
203
+ return self;
204
+ });
167
205
  }
168
206
  );
207
+ return () => {
208
+ unsubscribeFromSelectorCreation();
209
+ unsubscribeFromSelectorDisposal();
210
+ };
169
211
  }
170
212
  ]
171
213
  },
172
214
  void 0,
173
215
  store
174
216
  );
175
- return Internal.createStandaloneSelector(
217
+ return Internal2.createStandaloneSelector(
176
218
  {
177
219
  key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index`,
178
220
  get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL)
179
221
  },
180
- Internal.IMPLICIT.STORE
222
+ Internal2.IMPLICIT.STORE
181
223
  );
182
224
  };
183
- var attachTimelineFamily = (store = Internal.IMPLICIT.STORE) => {
184
- const findTimelineLogState__INTERNAL = Internal.createRegularAtomFamily(
225
+ var attachTimelineFamily = (store = Internal2.IMPLICIT.STORE) => {
226
+ const findTimelineLogState__INTERNAL = Internal2.createRegularAtomFamily(
185
227
  {
186
228
  key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log (Internal)`,
187
229
  default: (key) => {
@@ -196,7 +238,7 @@ var attachTimelineFamily = (store = Internal.IMPLICIT.STORE) => {
196
238
  transactionKey: null,
197
239
  install: () => {
198
240
  },
199
- subject: new Internal.Subject()
241
+ subject: new Internal2.Subject()
200
242
  };
201
243
  },
202
244
  effects: (key) => [
@@ -222,7 +264,7 @@ var attachTimelineFamily = (store = Internal.IMPLICIT.STORE) => {
222
264
  },
223
265
  store
224
266
  );
225
- const findTimelineLogState = Internal.createSelectorFamily(
267
+ const findTimelineLogState = Internal2.createSelectorFamily(
226
268
  {
227
269
  key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log`,
228
270
  get: (key) => ({ get }) => get(findTimelineLogState__INTERNAL(key))
@@ -231,8 +273,8 @@ var attachTimelineFamily = (store = Internal.IMPLICIT.STORE) => {
231
273
  );
232
274
  return findTimelineLogState;
233
275
  };
234
- var attachTimelineIndex = (store = Internal.IMPLICIT.STORE) => {
235
- const timelineTokenIndexState__INTERNAL = Internal.createRegularAtom(
276
+ var attachTimelineIndex = (store = Internal2.IMPLICIT.STORE) => {
277
+ const timelineTokenIndexState__INTERNAL = Internal2.createRegularAtom(
236
278
  {
237
279
  key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index (Internal)`,
238
280
  default: () => [...store.timelines].map(([key]) => {
@@ -252,7 +294,7 @@ var attachTimelineIndex = (store = Internal.IMPLICIT.STORE) => {
252
294
  void 0,
253
295
  store
254
296
  );
255
- const timelineTokenIndex = Internal.createStandaloneSelector(
297
+ const timelineTokenIndex = Internal2.createStandaloneSelector(
256
298
  {
257
299
  key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index`,
258
300
  get: ({ get }) => get(timelineTokenIndexState__INTERNAL)
@@ -261,8 +303,8 @@ var attachTimelineIndex = (store = Internal.IMPLICIT.STORE) => {
261
303
  );
262
304
  return timelineTokenIndex;
263
305
  };
264
- var attachTransactionIndex = (store = Internal.IMPLICIT.STORE) => {
265
- const transactionTokenIndexState__INTERNAL = Internal.createRegularAtom(
306
+ var attachTransactionIndex = (store = Internal2.IMPLICIT.STORE) => {
307
+ const transactionTokenIndexState__INTERNAL = Internal2.createRegularAtom(
266
308
  {
267
309
  key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index (Internal)`,
268
310
  default: () => [...store.transactions].map(([key]) => {
@@ -282,7 +324,7 @@ var attachTransactionIndex = (store = Internal.IMPLICIT.STORE) => {
282
324
  void 0,
283
325
  store
284
326
  );
285
- const transactionTokenIndex = Internal.createStandaloneSelector(
327
+ const transactionTokenIndex = Internal2.createStandaloneSelector(
286
328
  {
287
329
  key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index`,
288
330
  get: ({ get }) => get(transactionTokenIndexState__INTERNAL)
@@ -291,8 +333,8 @@ var attachTransactionIndex = (store = Internal.IMPLICIT.STORE) => {
291
333
  );
292
334
  return transactionTokenIndex;
293
335
  };
294
- var attachTransactionLogs = (store = Internal.IMPLICIT.STORE) => {
295
- const findTransactionUpdateLog = Internal.createRegularAtomFamily(
336
+ var attachTransactionLogs = (store = Internal2.IMPLICIT.STORE) => {
337
+ const findTransactionUpdateLog = Internal2.createRegularAtomFamily(
296
338
  {
297
339
  key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log (Internal)`,
298
340
  default: () => [],
@@ -309,7 +351,7 @@ var attachTransactionLogs = (store = Internal.IMPLICIT.STORE) => {
309
351
  },
310
352
  store
311
353
  );
312
- const findTransactionUpdateLogState = Internal.createSelectorFamily(
354
+ const findTransactionUpdateLogState = Internal2.createSelectorFamily(
313
355
  {
314
356
  key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log`,
315
357
  get: (key) => ({ get }) => get(findTransactionUpdateLog(key))
@@ -320,7 +362,7 @@ var attachTransactionLogs = (store = Internal.IMPLICIT.STORE) => {
320
362
  };
321
363
 
322
364
  // introspection/src/attach-introspection-states.ts
323
- var attachIntrospectionStates = (store = Internal__namespace.IMPLICIT.STORE) => {
365
+ var attachIntrospectionStates = (store = Internal2__namespace.IMPLICIT.STORE) => {
324
366
  return {
325
367
  atomIndex: attachAtomIndex(store),
326
368
  selectorIndex: attachSelectorIndex(store),
@@ -330,5 +372,107 @@ var attachIntrospectionStates = (store = Internal__namespace.IMPLICIT.STORE) =>
330
372
  findTimelineState: attachTimelineFamily(store)
331
373
  };
332
374
  };
375
+ function getState(token) {
376
+ return Internal2__namespace.getFromStore(token, Internal2__namespace.IMPLICIT.STORE);
377
+ }
378
+
379
+ // introspection/src/auditor.ts
380
+ var _Auditor = class _Auditor {
381
+ /**
382
+ * @param {Store} store - The store to audit.
383
+ */
384
+ constructor(store = Internal2__namespace.IMPLICIT.STORE) {
385
+ this.store = store;
386
+ this.auditorCreatedAt = performance.now();
387
+ this.statesCreatedAt = /* @__PURE__ */ new Map();
388
+ this.disposed = false;
389
+ this.atomIndex = attachAtomIndex(this.store);
390
+ this.selectorIndex = attachSelectorIndex(this.store);
391
+ this.unsubscribeFromAtomCreation = this.store.on.atomCreation.subscribe(
392
+ `auditor-${this.auditorCreatedAt}`,
393
+ ({ key }) => {
394
+ this.statesCreatedAt.set(key, performance.now() - this.auditorCreatedAt);
395
+ }
396
+ );
397
+ this.unsubscribeFromAtomDisposal = this.store.on.atomDisposal.subscribe(
398
+ `auditor-${this.auditorCreatedAt}`,
399
+ ({ key }) => {
400
+ this.statesCreatedAt.delete(key);
401
+ }
402
+ );
403
+ this.unsubscribeFromSelectorCreation = this.store.on.selectorCreation.subscribe(
404
+ `auditor-${this.auditorCreatedAt}`,
405
+ ({ key }) => {
406
+ this.statesCreatedAt.set(
407
+ key,
408
+ performance.now() - this.auditorCreatedAt
409
+ );
410
+ }
411
+ );
412
+ this.unsubscribeFromSelectorDisposal = this.store.on.selectorDisposal.subscribe(
413
+ `auditor-${this.auditorCreatedAt}`,
414
+ ({ key }) => {
415
+ this.statesCreatedAt.delete(key);
416
+ }
417
+ );
418
+ }
419
+ /**
420
+ * Lists all resources in the store, along with their creation time.
421
+ *
422
+ * @param {ListResourcesParam} [param] - Optional parameters for filtering the list of resources.
423
+ * @returns {readonly [ReadableToken<unknown>, number]}[] - An array of tuples, where each tuple contains a state token belonging to a family in the store and that state's creation time.
424
+ */
425
+ listResources(param = _Auditor.DEFAULT_LIST_RESOURCES_PARAM) {
426
+ if (this.disposed) {
427
+ throw new Error(`This Auditor has been disposed`);
428
+ }
429
+ const atoms = getState(this.atomIndex);
430
+ const selectors = getState(this.selectorIndex);
431
+ const atomFamilyNodes = [...atoms.values()].filter(
432
+ (node) => `familyMembers` in node
433
+ );
434
+ const selectorFamilyNodes = [...selectors.values()].filter(
435
+ (node) => `familyMembers` in node
436
+ );
437
+ const currentTime = performance.now();
438
+ const resources = [];
439
+ if (param.atomFamilies) {
440
+ for (const familyNode of atomFamilyNodes) {
441
+ const tokens = familyNode.familyMembers.values();
442
+ for (const token of tokens) {
443
+ const storedTime = this.statesCreatedAt.get(token.key);
444
+ const creationTime = storedTime != null ? storedTime : this.auditorCreatedAt;
445
+ const age = currentTime - creationTime;
446
+ resources.push([token, age]);
447
+ }
448
+ }
449
+ }
450
+ if (param.selectorFamilies) {
451
+ for (const familyNode of selectorFamilyNodes) {
452
+ const tokens = familyNode.familyMembers.values();
453
+ for (const token of tokens) {
454
+ const storedTime = this.statesCreatedAt.get(token.key);
455
+ const creationTime = storedTime != null ? storedTime : this.auditorCreatedAt;
456
+ const age = currentTime - creationTime;
457
+ resources.push([token, age]);
458
+ }
459
+ }
460
+ }
461
+ return resources;
462
+ }
463
+ [Symbol.dispose]() {
464
+ this.unsubscribeFromAtomCreation();
465
+ this.unsubscribeFromAtomDisposal();
466
+ this.unsubscribeFromSelectorCreation();
467
+ this.unsubscribeFromSelectorDisposal();
468
+ this.disposed = true;
469
+ }
470
+ };
471
+ _Auditor.DEFAULT_LIST_RESOURCES_PARAM = {
472
+ atomFamilies: true,
473
+ selectorFamilies: true
474
+ };
475
+ var Auditor = _Auditor;
333
476
 
477
+ exports.Auditor = Auditor;
334
478
  exports.attachIntrospectionStates = attachIntrospectionStates;
@@ -1,10 +1,10 @@
1
- import { AtomToken, ReadonlySelectorToken, WritableSelectorToken, TransactionToken, Func, ReadonlySelectorFamilyToken, TransactionUpdate, TimelineToken } from 'atom.io';
1
+ import { AtomToken, SelectorToken, ReadonlySelectorToken, TransactionToken, Func, ReadonlySelectorFamilyToken, TransactionUpdate, TimelineToken, ReadableToken } from 'atom.io';
2
2
  import * as Internal from 'atom.io/internal';
3
3
  import { Timeline } from 'atom.io/internal';
4
4
 
5
5
  type AtomTokenIndex = WritableTokenIndex<AtomToken<unknown>>;
6
6
 
7
- type SelectorTokenIndex = WritableTokenIndex<ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>>;
7
+ type SelectorTokenIndex = WritableTokenIndex<SelectorToken<unknown>>;
8
8
 
9
9
  declare const attachIntrospectionStates: (store?: Internal.Store) => {
10
10
  atomIndex: ReadonlySelectorToken<AtomTokenIndex>;
@@ -15,10 +15,47 @@ declare const attachIntrospectionStates: (store?: Internal.Store) => {
15
15
  findTimelineState: ReadonlySelectorFamilyToken<Timeline<any>, string>;
16
16
  };
17
17
 
18
- type FamilyNode<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>> = {
18
+ type ListResourcesParam = {
19
+ atomFamilies: boolean;
20
+ selectorFamilies: boolean;
21
+ };
22
+ /**
23
+ * Auditor is a tool for identifying lingering resources in your store that may result in memory leaks.
24
+ * @experimental
25
+ */
26
+ declare class Auditor {
27
+ readonly store: Internal.Store;
28
+ auditorCreatedAt: number;
29
+ statesCreatedAt: Map<string, number>;
30
+ readonly atomIndex: ReadonlySelectorToken<AtomTokenIndex>;
31
+ readonly selectorIndex: ReadonlySelectorToken<SelectorTokenIndex>;
32
+ disposed: boolean;
33
+ private readonly unsubscribeFromAtomCreation;
34
+ private readonly unsubscribeFromAtomDisposal;
35
+ private readonly unsubscribeFromSelectorCreation;
36
+ private readonly unsubscribeFromSelectorDisposal;
37
+ /**
38
+ * @param {Store} store - The store to audit.
39
+ */
40
+ constructor(store?: Internal.Store);
41
+ static readonly DEFAULT_LIST_RESOURCES_PARAM: {
42
+ atomFamilies: true;
43
+ selectorFamilies: true;
44
+ };
45
+ /**
46
+ * Lists all resources in the store, along with their creation time.
47
+ *
48
+ * @param {ListResourcesParam} [param] - Optional parameters for filtering the list of resources.
49
+ * @returns {readonly [ReadableToken<unknown>, number]}[] - An array of tuples, where each tuple contains a state token belonging to a family in the store and that state's creation time.
50
+ */
51
+ listResources(param?: ListResourcesParam): (readonly [ReadableToken<unknown>, number])[];
52
+ [Symbol.dispose](): void;
53
+ }
54
+
55
+ type FamilyNode<Token extends ReadableToken<unknown>> = {
19
56
  key: string;
20
- familyMembers: Record<string, Token>;
57
+ familyMembers: Map<string, Token>;
21
58
  };
22
- type WritableTokenIndex<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>> = Record<string, FamilyNode<Token> | Token>;
59
+ type WritableTokenIndex<Token extends ReadableToken<unknown>> = Map<string, FamilyNode<Token> | Token>;
23
60
 
24
- export { type FamilyNode, type WritableTokenIndex, attachIntrospectionStates };
61
+ export { Auditor, type FamilyNode, type ListResourcesParam, type WritableTokenIndex, attachIntrospectionStates };