atomirx 0.0.8 → 0.1.1

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 (138) hide show
  1. package/README.md +198 -2234
  2. package/bin/cli.js +90 -0
  3. package/dist/core/derived.d.ts +2 -2
  4. package/dist/core/effect.d.ts +3 -2
  5. package/dist/core/onCreateHook.d.ts +15 -2
  6. package/dist/core/onErrorHook.d.ts +4 -1
  7. package/dist/core/pool.d.ts +78 -0
  8. package/dist/core/pool.test.d.ts +1 -0
  9. package/dist/core/select-boolean.test.d.ts +1 -0
  10. package/dist/core/select-pool.test.d.ts +1 -0
  11. package/dist/core/select.d.ts +278 -86
  12. package/dist/core/types.d.ts +233 -1
  13. package/dist/core/withAbort.d.ts +95 -0
  14. package/dist/core/withReady.d.ts +3 -3
  15. package/dist/devtools/constants.d.ts +41 -0
  16. package/dist/devtools/index.cjs +1 -0
  17. package/dist/devtools/index.d.ts +29 -0
  18. package/dist/devtools/index.js +429 -0
  19. package/dist/devtools/registry.d.ts +98 -0
  20. package/dist/devtools/registry.test.d.ts +1 -0
  21. package/dist/devtools/setup.d.ts +61 -0
  22. package/dist/devtools/types.d.ts +311 -0
  23. package/dist/index-BZEnfIcB.cjs +1 -0
  24. package/dist/index-BbPZhsDl.js +1653 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.d.ts +4 -3
  27. package/dist/index.js +18 -14
  28. package/dist/onDispatchHook-C8yLzr-o.cjs +1 -0
  29. package/dist/onDispatchHook-SKbiIUaJ.js +5 -0
  30. package/dist/onErrorHook-BGGy3tqK.js +38 -0
  31. package/dist/onErrorHook-DHBASmYw.cjs +1 -0
  32. package/dist/react/index.cjs +1 -1
  33. package/dist/react/index.js +191 -151
  34. package/dist/react/onDispatchHook.d.ts +106 -0
  35. package/dist/react/useAction.d.ts +4 -1
  36. package/dist/react-devtools/DevToolsPanel.d.ts +93 -0
  37. package/dist/react-devtools/EntityDetails.d.ts +10 -0
  38. package/dist/react-devtools/EntityList.d.ts +15 -0
  39. package/dist/react-devtools/LogList.d.ts +12 -0
  40. package/dist/react-devtools/hooks.d.ts +50 -0
  41. package/dist/react-devtools/index.cjs +1 -0
  42. package/dist/react-devtools/index.d.ts +31 -0
  43. package/dist/react-devtools/index.js +1589 -0
  44. package/dist/react-devtools/styles.d.ts +148 -0
  45. package/package.json +26 -2
  46. package/skills/atomirx/SKILL.md +456 -0
  47. package/skills/atomirx/references/async-patterns.md +188 -0
  48. package/skills/atomirx/references/atom-patterns.md +238 -0
  49. package/skills/atomirx/references/deferred-loading.md +191 -0
  50. package/skills/atomirx/references/derived-patterns.md +428 -0
  51. package/skills/atomirx/references/effect-patterns.md +426 -0
  52. package/skills/atomirx/references/error-handling.md +140 -0
  53. package/skills/atomirx/references/hooks.md +322 -0
  54. package/skills/atomirx/references/pool-patterns.md +229 -0
  55. package/skills/atomirx/references/react-integration.md +411 -0
  56. package/skills/atomirx/references/rules.md +407 -0
  57. package/skills/atomirx/references/select-context.md +309 -0
  58. package/skills/atomirx/references/service-template.md +172 -0
  59. package/skills/atomirx/references/store-template.md +205 -0
  60. package/skills/atomirx/references/testing-patterns.md +431 -0
  61. package/coverage/base.css +0 -224
  62. package/coverage/block-navigation.js +0 -87
  63. package/coverage/clover.xml +0 -1440
  64. package/coverage/coverage-final.json +0 -14
  65. package/coverage/favicon.png +0 -0
  66. package/coverage/index.html +0 -131
  67. package/coverage/prettify.css +0 -1
  68. package/coverage/prettify.js +0 -2
  69. package/coverage/sort-arrow-sprite.png +0 -0
  70. package/coverage/sorter.js +0 -210
  71. package/coverage/src/core/atom.ts.html +0 -889
  72. package/coverage/src/core/batch.ts.html +0 -223
  73. package/coverage/src/core/define.ts.html +0 -805
  74. package/coverage/src/core/emitter.ts.html +0 -919
  75. package/coverage/src/core/equality.ts.html +0 -631
  76. package/coverage/src/core/hook.ts.html +0 -460
  77. package/coverage/src/core/index.html +0 -281
  78. package/coverage/src/core/isAtom.ts.html +0 -100
  79. package/coverage/src/core/isPromiseLike.ts.html +0 -133
  80. package/coverage/src/core/onCreateHook.ts.html +0 -138
  81. package/coverage/src/core/scheduleNotifyHook.ts.html +0 -94
  82. package/coverage/src/core/types.ts.html +0 -523
  83. package/coverage/src/core/withUse.ts.html +0 -253
  84. package/coverage/src/index.html +0 -116
  85. package/coverage/src/index.ts.html +0 -106
  86. package/dist/index-CBVj1kSj.js +0 -1350
  87. package/dist/index-Cxk9v0um.cjs +0 -1
  88. package/scripts/publish.js +0 -198
  89. package/src/core/atom.test.ts +0 -633
  90. package/src/core/atom.ts +0 -311
  91. package/src/core/atomState.test.ts +0 -342
  92. package/src/core/atomState.ts +0 -256
  93. package/src/core/batch.test.ts +0 -257
  94. package/src/core/batch.ts +0 -172
  95. package/src/core/define.test.ts +0 -343
  96. package/src/core/define.ts +0 -243
  97. package/src/core/derived.test.ts +0 -1215
  98. package/src/core/derived.ts +0 -450
  99. package/src/core/effect.test.ts +0 -802
  100. package/src/core/effect.ts +0 -188
  101. package/src/core/emitter.test.ts +0 -364
  102. package/src/core/emitter.ts +0 -392
  103. package/src/core/equality.test.ts +0 -392
  104. package/src/core/equality.ts +0 -182
  105. package/src/core/getAtomState.ts +0 -69
  106. package/src/core/hook.test.ts +0 -227
  107. package/src/core/hook.ts +0 -177
  108. package/src/core/isAtom.ts +0 -27
  109. package/src/core/isPromiseLike.test.ts +0 -72
  110. package/src/core/isPromiseLike.ts +0 -16
  111. package/src/core/onCreateHook.ts +0 -107
  112. package/src/core/onErrorHook.test.ts +0 -350
  113. package/src/core/onErrorHook.ts +0 -52
  114. package/src/core/promiseCache.test.ts +0 -241
  115. package/src/core/promiseCache.ts +0 -284
  116. package/src/core/scheduleNotifyHook.ts +0 -53
  117. package/src/core/select.ts +0 -729
  118. package/src/core/selector.test.ts +0 -799
  119. package/src/core/types.ts +0 -389
  120. package/src/core/withReady.test.ts +0 -534
  121. package/src/core/withReady.ts +0 -191
  122. package/src/core/withUse.test.ts +0 -249
  123. package/src/core/withUse.ts +0 -56
  124. package/src/index.test.ts +0 -80
  125. package/src/index.ts +0 -65
  126. package/src/react/index.ts +0 -21
  127. package/src/react/rx.test.tsx +0 -571
  128. package/src/react/rx.tsx +0 -531
  129. package/src/react/strictModeTest.tsx +0 -71
  130. package/src/react/useAction.test.ts +0 -987
  131. package/src/react/useAction.ts +0 -607
  132. package/src/react/useSelector.test.ts +0 -182
  133. package/src/react/useSelector.ts +0 -292
  134. package/src/react/useStable.test.ts +0 -553
  135. package/src/react/useStable.ts +0 -288
  136. package/tsconfig.json +0 -9
  137. package/v2.md +0 -725
  138. package/vite.config.ts +0 -42
@@ -0,0 +1,429 @@
1
+ var k = Object.defineProperty;
2
+ var b = (r, t, n) => t in r ? k(r, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[t] = n;
3
+ var a = (r, t, n) => b(r, typeof t != "symbol" ? t + "" : t, n);
4
+ import { o as y, a as g } from "../onErrorHook-BGGy3tqK.js";
5
+ import { o as p } from "../onDispatchHook-SKbiIUaJ.js";
6
+ const N = "atomirx-devtools-preferences", m = 50, L = "atomirx", z = 1, T = 999999, O = 200, V = 800, M = 300, U = 48, v = 200;
7
+ let S = 0;
8
+ function f(r) {
9
+ return `${L}-${r}-${++S}`;
10
+ }
11
+ class w {
12
+ constructor(t = m) {
13
+ a(this, "_entities", /* @__PURE__ */ new Map());
14
+ a(this, "_logs", []);
15
+ a(this, "_listeners", /* @__PURE__ */ new Set());
16
+ a(this, "_maxHistorySize");
17
+ a(this, "_maxLogSize", 200);
18
+ a(this, "_logIdCounter", 0);
19
+ a(this, "_version", 0);
20
+ a(this, "_cachedEntities", null);
21
+ a(this, "_cachedLogs", null);
22
+ a(this, "_notifyScheduled", !1);
23
+ this._maxHistorySize = t;
24
+ }
25
+ get entities() {
26
+ return this._cachedEntities || (this._cachedEntities = new Map(this._entities)), this._cachedEntities;
27
+ }
28
+ get logs() {
29
+ return this._cachedLogs || (this._cachedLogs = [...this._logs]), this._cachedLogs;
30
+ }
31
+ get version() {
32
+ return this._version;
33
+ }
34
+ addLog(t) {
35
+ const n = {
36
+ ...t,
37
+ id: `log-${++this._logIdCounter}`
38
+ };
39
+ this._logs = [n, ...this._logs].slice(0, this._maxLogSize), this._notifyListeners();
40
+ }
41
+ clearLogs() {
42
+ this._logs = [], this._notifyListeners();
43
+ }
44
+ /**
45
+ * Register a mutable atom.
46
+ */
47
+ registerMutable(t, n) {
48
+ const i = f("mutable"), e = Date.now(), s = {
49
+ id: i,
50
+ type: "mutable",
51
+ key: n,
52
+ createdAt: e,
53
+ lastUpdatedAt: e,
54
+ changeCount: 0,
55
+ instanceRef: new WeakRef(t),
56
+ subscriberCount: 0,
57
+ history: []
58
+ };
59
+ return this._entities.set(i, s), this._notifyListeners(), this._trackMutableChanges(i, t), i;
60
+ }
61
+ /**
62
+ * Register a derived atom.
63
+ */
64
+ registerDerived(t, n, i = []) {
65
+ const e = f("derived"), s = Date.now(), o = {
66
+ id: e,
67
+ type: "derived",
68
+ key: n,
69
+ createdAt: s,
70
+ lastUpdatedAt: s,
71
+ changeCount: 0,
72
+ instanceRef: new WeakRef(t),
73
+ dependencyIds: i,
74
+ subscriberCount: 0,
75
+ history: []
76
+ };
77
+ return this._entities.set(e, o), this._notifyListeners(), this._trackDerivedChanges(e, t), e;
78
+ }
79
+ /**
80
+ * Register an effect.
81
+ */
82
+ registerEffect(t, n, i = []) {
83
+ const e = f("effect"), s = Date.now(), o = {
84
+ id: e,
85
+ type: "effect",
86
+ key: n,
87
+ createdAt: s,
88
+ lastUpdatedAt: s,
89
+ changeCount: 0,
90
+ instanceRef: new WeakRef(t),
91
+ dependencyIds: i,
92
+ runCount: 0,
93
+ isActive: !0
94
+ };
95
+ return this._entities.set(e, o), this._notifyListeners(), e;
96
+ }
97
+ /**
98
+ * Register a pool.
99
+ */
100
+ registerPool(t, n, i) {
101
+ const e = f("pool"), s = Date.now(), o = {
102
+ id: e,
103
+ type: "pool",
104
+ key: n,
105
+ createdAt: s,
106
+ lastUpdatedAt: s,
107
+ changeCount: 0,
108
+ instanceRef: new WeakRef(t),
109
+ entryCount: 0,
110
+ gcTime: i
111
+ };
112
+ return this._entities.set(e, o), this._notifyListeners(), this._trackPoolChanges(e, t), e;
113
+ }
114
+ /**
115
+ * Register a module.
116
+ */
117
+ registerModule(t, n) {
118
+ const i = f("module"), e = Date.now(), s = {
119
+ id: i,
120
+ type: "module",
121
+ key: n,
122
+ createdAt: e,
123
+ lastUpdatedAt: e,
124
+ changeCount: 0,
125
+ instanceRef: new WeakRef(t)
126
+ };
127
+ return this._entities.set(i, s), this._notifyListeners(), i;
128
+ }
129
+ /**
130
+ * Track changes to a mutable atom.
131
+ */
132
+ _trackMutableChanges(t, n) {
133
+ let i = this._serializeValue(n.get());
134
+ n.on(() => {
135
+ var _;
136
+ const e = this._entities.get(t);
137
+ if (!e) return;
138
+ const s = this._serializeValue(n.get()), o = Date.now(), h = {
139
+ timestamp: o,
140
+ previousValue: i,
141
+ newValue: s
142
+ };
143
+ e.history = [h, ...e.history].slice(
144
+ 0,
145
+ this._maxHistorySize
146
+ ), e.changeCount++, e.lastUpdatedAt = o, i = s, this._notifyListeners();
147
+ const u = (_ = n.meta) == null ? void 0 : _.key;
148
+ u && this.addLog({
149
+ type: "mutable.change",
150
+ timestamp: o,
151
+ atomKey: u
152
+ });
153
+ });
154
+ }
155
+ /**
156
+ * Track changes to a derived atom.
157
+ */
158
+ _trackDerivedChanges(t, n) {
159
+ let i = this._serializeValue(n.staleValue);
160
+ n.on(() => {
161
+ var _;
162
+ const e = this._entities.get(t);
163
+ if (!e) return;
164
+ const s = this._serializeValue(n.staleValue), o = Date.now(), h = {
165
+ timestamp: o,
166
+ previousValue: i,
167
+ newValue: s
168
+ };
169
+ e.history = [h, ...e.history].slice(
170
+ 0,
171
+ this._maxHistorySize
172
+ ), e.changeCount++, e.lastUpdatedAt = o, i = s, this._notifyListeners();
173
+ const u = (_ = n.meta) == null ? void 0 : _.key;
174
+ u && this.addLog({
175
+ type: "derived.change",
176
+ timestamp: o,
177
+ atomKey: u
178
+ });
179
+ });
180
+ }
181
+ /**
182
+ * Track changes to a pool and log events.
183
+ */
184
+ _trackPoolChanges(t, n) {
185
+ n.on((i) => {
186
+ var o;
187
+ const e = this._entities.get(t);
188
+ if (!e) return;
189
+ (i.type === "create" || i.type === "change") && (e.changeCount++, e.lastUpdatedAt = Date.now()), this._updatePoolEntryCount(t, n), this._notifyListeners();
190
+ const s = (o = n.meta) == null ? void 0 : o.key;
191
+ if (s) {
192
+ const h = {
193
+ create: "pool.create",
194
+ change: "pool.set",
195
+ // "change" maps to "set" for logging
196
+ remove: "pool.remove"
197
+ }, u = this._serializeParams(i.params);
198
+ this.addLog({
199
+ type: h[i.type],
200
+ timestamp: Date.now(),
201
+ poolKey: s,
202
+ params: u.slice(0, 50)
203
+ // Truncate long params
204
+ });
205
+ }
206
+ });
207
+ }
208
+ /**
209
+ * Serialize params for logging.
210
+ */
211
+ _serializeParams(t) {
212
+ try {
213
+ return JSON.stringify(t);
214
+ } catch {
215
+ return String(t);
216
+ }
217
+ }
218
+ /**
219
+ * Update pool entry count.
220
+ */
221
+ _updatePoolEntryCount(t, n) {
222
+ const i = this._entities.get(t);
223
+ i && (i.entryCount = n.size());
224
+ }
225
+ /**
226
+ * Serialize a value for history storage.
227
+ */
228
+ _serializeValue(t) {
229
+ if (t === void 0) return "undefined";
230
+ if (t === null) return "null";
231
+ try {
232
+ const n = /* @__PURE__ */ new WeakSet();
233
+ return JSON.stringify(
234
+ t,
235
+ (i, e) => {
236
+ if (typeof e == "object" && e !== null) {
237
+ if (n.has(e)) return "[Circular]";
238
+ n.add(e);
239
+ }
240
+ return typeof e == "function" ? "[Function]" : typeof e == "symbol" ? e.toString() : e instanceof Error ? `[Error: ${e.message}]` : e instanceof Promise ? "[Promise]" : e;
241
+ },
242
+ 2
243
+ );
244
+ } catch {
245
+ return "[unserializable]";
246
+ }
247
+ }
248
+ getByType(t) {
249
+ const n = [];
250
+ for (const i of this._entities.values())
251
+ i.type === t && n.push(i);
252
+ return n;
253
+ }
254
+ get(t) {
255
+ return this._entities.get(t);
256
+ }
257
+ subscribe(t) {
258
+ return this._listeners.add(t), () => {
259
+ this._listeners.delete(t);
260
+ };
261
+ }
262
+ getStats() {
263
+ let t = 0, n = 0, i = 0, e = 0, s = 0;
264
+ for (const o of this._entities.values())
265
+ switch (o.type) {
266
+ case "mutable":
267
+ t++;
268
+ break;
269
+ case "derived":
270
+ n++;
271
+ break;
272
+ case "effect":
273
+ i++;
274
+ break;
275
+ case "pool":
276
+ e++;
277
+ break;
278
+ case "module":
279
+ s++;
280
+ break;
281
+ }
282
+ return {
283
+ mutableCount: t,
284
+ derivedCount: n,
285
+ effectCount: i,
286
+ poolCount: e,
287
+ moduleCount: s,
288
+ totalCount: t + n + i + e + s
289
+ };
290
+ }
291
+ clear() {
292
+ this._entities.clear(), this._notifyListeners();
293
+ }
294
+ /**
295
+ * Schedule listener notifications.
296
+ * Uses queueMicrotask to defer notifications and avoid updating React state during render.
297
+ * Multiple calls within the same microtask are batched into a single notification.
298
+ */
299
+ _notifyListeners() {
300
+ this._version++, this._cachedEntities = null, this._cachedLogs = null, !this._notifyScheduled && (this._notifyScheduled = !0, queueMicrotask(() => {
301
+ this._notifyScheduled = !1;
302
+ for (const t of this._listeners)
303
+ try {
304
+ t();
305
+ } catch {
306
+ }
307
+ }));
308
+ }
309
+ }
310
+ let l = null;
311
+ function E(r) {
312
+ return l || (l = new w(r)), l;
313
+ }
314
+ function x() {
315
+ l == null || l.clear(), l = null;
316
+ }
317
+ function C() {
318
+ l = null;
319
+ }
320
+ const D = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
321
+ function A() {
322
+ try {
323
+ if (typeof process < "u" && process.env)
324
+ return process.env.NODE_ENV === "production";
325
+ } catch {
326
+ }
327
+ try {
328
+ if (typeof import.meta < "u" && D)
329
+ return !0;
330
+ } catch {
331
+ }
332
+ return !1;
333
+ }
334
+ let d = !1, c = null;
335
+ function F(r = {}) {
336
+ const {
337
+ maxHistorySize: t = m,
338
+ enableInProduction: n = !1
339
+ } = r;
340
+ if (A() && !n)
341
+ return console.warn(
342
+ "[atomirx-devtools] Devtools disabled in production. Use { enableInProduction: true } to enable."
343
+ ), () => {
344
+ };
345
+ if (d && c)
346
+ return c;
347
+ const i = E(t);
348
+ return y.override((e) => (s) => {
349
+ switch (e == null || e(s), s.type) {
350
+ case "mutable":
351
+ i.registerMutable(s.instance, s.key);
352
+ break;
353
+ case "derived":
354
+ i.registerDerived(s.instance, s.key);
355
+ break;
356
+ case "effect":
357
+ i.registerEffect(s.instance, s.key);
358
+ break;
359
+ case "pool":
360
+ i.registerPool(s.instance, s.key, 0);
361
+ break;
362
+ case "module":
363
+ typeof s.instance == "object" && s.instance !== null && i.registerModule(s.instance, s.key);
364
+ break;
365
+ }
366
+ }), p.override((e) => (s) => {
367
+ var o;
368
+ e == null || e(s), (o = s.meta) != null && o.key && i.addLog({
369
+ type: "action.dispatch",
370
+ timestamp: Date.now(),
371
+ actionKey: s.meta.key,
372
+ deps: JSON.stringify(s.deps).slice(0, 100)
373
+ });
374
+ }), g.override((e) => (s) => {
375
+ e == null || e(s), i.addLog({
376
+ type: "error",
377
+ timestamp: Date.now(),
378
+ sourceType: s.source.type,
379
+ sourceKey: s.source.key,
380
+ error: String(s.error).slice(0, 200)
381
+ });
382
+ }), d = !0, c = () => {
383
+ y.reset(), p.reset(), g.reset(), i.clear(), i.clearLogs(), d = !1, c = null;
384
+ }, c;
385
+ }
386
+ function H() {
387
+ return d ? E() : null;
388
+ }
389
+ function K() {
390
+ return d;
391
+ }
392
+ function W() {
393
+ c && c(), C(), d = !1, c = null;
394
+ }
395
+ const Z = {
396
+ isOpen: !1,
397
+ position: "bottom",
398
+ activeTab: "atoms",
399
+ panelSize: 300,
400
+ searchText: {
401
+ atoms: "",
402
+ effects: "",
403
+ pools: "",
404
+ modules: "",
405
+ logs: ""
406
+ },
407
+ atomFilter: "all",
408
+ selectedEntityId: null,
409
+ showAtomValues: !1
410
+ };
411
+ export {
412
+ v as ANIMATION_DURATION,
413
+ m as DEFAULT_MAX_HISTORY_SIZE,
414
+ M as DEFAULT_PANEL_SIZE,
415
+ Z as DEFAULT_PREFERENCES,
416
+ T as DEVTOOLS_Z_INDEX,
417
+ L as ENTITY_ID_PREFIX,
418
+ U as FLOATING_BUTTON_SIZE,
419
+ V as MAX_PANEL_SIZE,
420
+ O as MIN_PANEL_SIZE,
421
+ N as STORAGE_KEY_PREFERENCES,
422
+ z as STORAGE_VERSION,
423
+ W as _resetDevtools,
424
+ H as getDevtoolsRegistry,
425
+ E as getRegistry,
426
+ K as isDevtoolsEnabled,
427
+ x as resetRegistry,
428
+ F as setupDevtools
429
+ };
@@ -0,0 +1,98 @@
1
+ import { EntityInfo, EntityType, DevtoolsRegistry, DevtoolsStats, LogEntry, NewLogEntry } from './types';
2
+ import { MutableAtom, DerivedAtom, Pool } from '../core/types';
3
+ import { Effect } from '../core/effect';
4
+ /**
5
+ * Generate a unique entity ID.
6
+ */
7
+ export declare function generateEntityId(type: EntityType): string;
8
+ /**
9
+ * Internal registry implementation.
10
+ */
11
+ declare class DevtoolsRegistryImpl implements DevtoolsRegistry {
12
+ private _entities;
13
+ private _logs;
14
+ private _listeners;
15
+ private _maxHistorySize;
16
+ private _maxLogSize;
17
+ private _logIdCounter;
18
+ constructor(maxHistorySize?: number);
19
+ private _version;
20
+ private _cachedEntities;
21
+ private _cachedLogs;
22
+ private _notifyScheduled;
23
+ get entities(): ReadonlyMap<string, EntityInfo>;
24
+ get logs(): readonly LogEntry[];
25
+ get version(): number;
26
+ addLog(entry: NewLogEntry): void;
27
+ clearLogs(): void;
28
+ /**
29
+ * Register a mutable atom.
30
+ */
31
+ registerMutable(instance: MutableAtom<unknown>, key: string | undefined): string;
32
+ /**
33
+ * Register a derived atom.
34
+ */
35
+ registerDerived(instance: DerivedAtom<unknown, boolean>, key: string | undefined, dependencyIds?: string[]): string;
36
+ /**
37
+ * Register an effect.
38
+ */
39
+ registerEffect(instance: Effect, key: string | undefined, dependencyIds?: string[]): string;
40
+ /**
41
+ * Register a pool.
42
+ */
43
+ registerPool(instance: Pool<unknown, unknown>, key: string | undefined, gcTime: number): string;
44
+ /**
45
+ * Register a module.
46
+ */
47
+ registerModule(instance: object, key: string | undefined): string;
48
+ /**
49
+ * Track changes to a mutable atom.
50
+ */
51
+ private _trackMutableChanges;
52
+ /**
53
+ * Track changes to a derived atom.
54
+ */
55
+ private _trackDerivedChanges;
56
+ /**
57
+ * Track changes to a pool and log events.
58
+ */
59
+ private _trackPoolChanges;
60
+ /**
61
+ * Serialize params for logging.
62
+ */
63
+ private _serializeParams;
64
+ /**
65
+ * Update pool entry count.
66
+ */
67
+ private _updatePoolEntryCount;
68
+ /**
69
+ * Serialize a value for history storage.
70
+ */
71
+ private _serializeValue;
72
+ getByType<T extends EntityType>(type: T): EntityInfo[];
73
+ get(id: string): EntityInfo | undefined;
74
+ subscribe(listener: () => void): () => void;
75
+ getStats(): DevtoolsStats;
76
+ clear(): void;
77
+ /**
78
+ * Schedule listener notifications.
79
+ * Uses queueMicrotask to defer notifications and avoid updating React state during render.
80
+ * Multiple calls within the same microtask are batched into a single notification.
81
+ */
82
+ private _notifyListeners;
83
+ }
84
+ /**
85
+ * Get or create the global devtools registry.
86
+ */
87
+ export declare function getRegistry(maxHistorySize?: number): DevtoolsRegistryImpl;
88
+ /**
89
+ * Reset the global registry (for testing).
90
+ * Note: This also resets the isEnabled state in setup.ts
91
+ */
92
+ export declare function resetRegistry(): void;
93
+ /**
94
+ * Force set the global registry to null (for testing).
95
+ * @internal
96
+ */
97
+ export declare function _forceResetRegistry(): void;
98
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,61 @@
1
+ import { DevtoolsOptions, DevtoolsRegistry } from './types';
2
+ /**
3
+ * Set up devtools to track all atomirx entities.
4
+ *
5
+ * This function hooks into the entity creation system and registers
6
+ * all atoms, derived atoms, effects, pools, and modules with the
7
+ * devtools registry for inspection.
8
+ *
9
+ * @param options - Configuration options
10
+ * @returns Cleanup function to disable devtools
11
+ *
12
+ * @example Basic setup
13
+ * ```ts
14
+ * import { setupDevtools } from 'atomirx/devtools';
15
+ *
16
+ * // Enable devtools (disabled in production by default)
17
+ * const cleanup = setupDevtools();
18
+ *
19
+ * // Later: disable devtools
20
+ * cleanup();
21
+ * ```
22
+ *
23
+ * @example Enable in production
24
+ * ```ts
25
+ * setupDevtools({ enableInProduction: true });
26
+ * ```
27
+ *
28
+ * @example Custom history size
29
+ * ```ts
30
+ * setupDevtools({ maxHistorySize: 100 });
31
+ * ```
32
+ */
33
+ export declare function setupDevtools(options?: DevtoolsOptions): () => void;
34
+ /**
35
+ * Get the devtools registry.
36
+ *
37
+ * Returns the registry instance if devtools is enabled,
38
+ * otherwise returns null.
39
+ *
40
+ * @returns The registry or null if devtools not enabled
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * import { getDevtoolsRegistry } from 'atomirx/devtools';
45
+ *
46
+ * const registry = getDevtoolsRegistry();
47
+ * if (registry) {
48
+ * console.log('Stats:', registry.getStats());
49
+ * }
50
+ * ```
51
+ */
52
+ export declare function getDevtoolsRegistry(): DevtoolsRegistry | null;
53
+ /**
54
+ * Check if devtools is currently enabled.
55
+ */
56
+ export declare function isDevtoolsEnabled(): boolean;
57
+ /**
58
+ * Reset devtools state (for testing).
59
+ * @internal
60
+ */
61
+ export declare function _resetDevtools(): void;