mutts 1.0.9 → 1.0.11

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 (206) hide show
  1. package/README.md +60 -35
  2. package/dist/browser.cjs +1333 -1760
  3. package/dist/browser.cjs.map +1 -1
  4. package/dist/browser.d.ts +2 -1392
  5. package/dist/browser.dev.cjs +114 -0
  6. package/dist/browser.dev.cjs.map +1 -0
  7. package/dist/browser.dev.d.ts +2 -0
  8. package/dist/browser.dev.esm.js +5 -0
  9. package/dist/browser.dev.esm.js.map +1 -0
  10. package/dist/browser.esm.js +18 -97
  11. package/dist/browser.esm.js.map +1 -1
  12. package/dist/chunks/{async-browser-lvzLOCgk.cjs → async-browser-Dgr5CreQ.cjs} +16 -95
  13. package/dist/chunks/async-browser-Dgr5CreQ.cjs.map +1 -0
  14. package/dist/chunks/{async-node-C3DeIb0y.cjs → async-node-3PrbVAbB.cjs} +3 -1
  15. package/dist/chunks/async-node-3PrbVAbB.cjs.map +1 -0
  16. package/dist/chunks/index-Sf74wXTV.esm.js +2577 -0
  17. package/dist/chunks/index-Sf74wXTV.esm.js.map +1 -0
  18. package/dist/chunks/node-Bo7WU5S2.esm.js +96 -0
  19. package/dist/chunks/node-Bo7WU5S2.esm.js.map +1 -0
  20. package/dist/chunks/{index-VTO-b2vR.cjs → proxy-Cc79Lrzj.cjs} +2593 -3216
  21. package/dist/chunks/proxy-Cc79Lrzj.cjs.map +1 -0
  22. package/dist/chunks/{index-CtA2AWl3.esm.js → proxy-D2C49sXH.esm.js} +2570 -3174
  23. package/dist/chunks/proxy-D2C49sXH.esm.js.map +1 -0
  24. package/dist/debug.cjs +987 -28
  25. package/dist/debug.cjs.map +1 -1
  26. package/dist/debug.d.ts +37 -38
  27. package/dist/debug.esm.js +963 -1
  28. package/dist/debug.esm.js.map +1 -1
  29. package/dist/devtools/manifest.json +1 -1
  30. package/dist/devtools/panel.html +1 -1
  31. package/dist/devtools/panel.js +107 -94
  32. package/dist/devtools/panel.js.map +1 -1
  33. package/dist/index.d.ts +1322 -1
  34. package/dist/mutts.umd.js +6647 -1
  35. package/dist/mutts.umd.js.map +1 -1
  36. package/dist/mutts.umd.min.js +1 -1
  37. package/dist/mutts.umd.min.js.map +1 -1
  38. package/dist/node.cjs +69 -63
  39. package/dist/node.cjs.map +1 -1
  40. package/dist/node.d.ts +2 -2
  41. package/dist/node.dev.cjs +114 -0
  42. package/dist/node.dev.cjs.map +1 -0
  43. package/dist/node.dev.d.ts +2 -0
  44. package/dist/node.dev.esm.js +6 -0
  45. package/dist/node.dev.esm.js.map +1 -0
  46. package/dist/node.esm.js +4 -97
  47. package/dist/node.esm.js.map +1 -1
  48. package/dist/{types-DaHFfhlN.d.ts → types-Bx2PhORg.d.ts} +134 -88
  49. package/docs/ai/api-reference.md +11 -32
  50. package/docs/ai/manual.md +297 -239
  51. package/docs/reactive/advanced.md +318 -9
  52. package/docs/reactive/attend.md +2 -4
  53. package/docs/reactive/collections.md +22 -187
  54. package/docs/reactive/core.md +223 -131
  55. package/docs/reactive/debugging.md +119 -12
  56. package/docs/reactive/error-handling.md +10 -10
  57. package/docs/reactive/resource.md +125 -0
  58. package/docs/reactive.md +3 -4
  59. package/docs/utils.md +70 -0
  60. package/docs/zone.md +1 -1
  61. package/package.json +76 -38
  62. package/dist/chunks/async-browser-lvzLOCgk.cjs.map +0 -1
  63. package/dist/chunks/async-node-C3DeIb0y.cjs.map +0 -1
  64. package/dist/chunks/index-2vea86wD.esm.js +0 -3011
  65. package/dist/chunks/index-2vea86wD.esm.js.map +0 -1
  66. package/dist/chunks/index-CtA2AWl3.esm.js.map +0 -1
  67. package/dist/chunks/index-VTO-b2vR.cjs.map +0 -1
  68. package/dist/debug/debug.d.ts +0 -122
  69. package/dist/debug/debug.d.ts.map +0 -1
  70. package/dist/debug/index.d.ts +0 -4
  71. package/dist/debug/index.d.ts.map +0 -1
  72. package/dist/debug/lineage-panel.d.ts +0 -5
  73. package/dist/debug/lineage-panel.d.ts.map +0 -1
  74. package/dist/debug/lineage.d.ts +0 -79
  75. package/dist/debug/lineage.d.ts.map +0 -1
  76. package/dist/src/async/browser.d.ts +0 -2
  77. package/dist/src/async/browser.d.ts.map +0 -1
  78. package/dist/src/async/index.d.ts +0 -19
  79. package/dist/src/async/index.d.ts.map +0 -1
  80. package/dist/src/async/node.d.ts +0 -2
  81. package/dist/src/async/node.d.ts.map +0 -1
  82. package/dist/src/decorator.d.ts +0 -106
  83. package/dist/src/decorator.d.ts.map +0 -1
  84. package/dist/src/destroyable.d.ts +0 -87
  85. package/dist/src/destroyable.d.ts.map +0 -1
  86. package/dist/src/entry-browser.d.ts +0 -3
  87. package/dist/src/entry-browser.d.ts.map +0 -1
  88. package/dist/src/entry-node.d.ts +0 -3
  89. package/dist/src/entry-node.d.ts.map +0 -1
  90. package/dist/src/eventful.d.ts +0 -20
  91. package/dist/src/eventful.d.ts.map +0 -1
  92. package/dist/src/flavored.d.ts +0 -33
  93. package/dist/src/flavored.d.ts.map +0 -1
  94. package/dist/src/index.d.ts +0 -14
  95. package/dist/src/index.d.ts.map +0 -1
  96. package/dist/src/indexable.d.ts +0 -243
  97. package/dist/src/indexable.d.ts.map +0 -1
  98. package/dist/src/introspection.d.ts +0 -27
  99. package/dist/src/introspection.d.ts.map +0 -1
  100. package/dist/src/iterableWeak.d.ts +0 -53
  101. package/dist/src/iterableWeak.d.ts.map +0 -1
  102. package/dist/src/mixins.d.ts +0 -25
  103. package/dist/src/mixins.d.ts.map +0 -1
  104. package/dist/src/promiseChain.d.ts +0 -20
  105. package/dist/src/promiseChain.d.ts.map +0 -1
  106. package/dist/src/reactive/array.d.ts +0 -48
  107. package/dist/src/reactive/array.d.ts.map +0 -1
  108. package/dist/src/reactive/buffer.d.ts +0 -120
  109. package/dist/src/reactive/buffer.d.ts.map +0 -1
  110. package/dist/src/reactive/change.d.ts +0 -29
  111. package/dist/src/reactive/change.d.ts.map +0 -1
  112. package/dist/src/reactive/deep-touch.d.ts +0 -28
  113. package/dist/src/reactive/deep-touch.d.ts.map +0 -1
  114. package/dist/src/reactive/deep-watch-state.d.ts +0 -25
  115. package/dist/src/reactive/deep-watch-state.d.ts.map +0 -1
  116. package/dist/src/reactive/deep-watch.d.ts +0 -20
  117. package/dist/src/reactive/deep-watch.d.ts.map +0 -1
  118. package/dist/src/reactive/describe.d.ts +0 -12
  119. package/dist/src/reactive/describe.d.ts.map +0 -1
  120. package/dist/src/reactive/effect-context.d.ts +0 -34
  121. package/dist/src/reactive/effect-context.d.ts.map +0 -1
  122. package/dist/src/reactive/effects.d.ts +0 -164
  123. package/dist/src/reactive/effects.d.ts.map +0 -1
  124. package/dist/src/reactive/index.d.ts +0 -19
  125. package/dist/src/reactive/index.d.ts.map +0 -1
  126. package/dist/src/reactive/map.d.ts +0 -28
  127. package/dist/src/reactive/map.d.ts.map +0 -1
  128. package/dist/src/reactive/memoize.d.ts +0 -28
  129. package/dist/src/reactive/memoize.d.ts.map +0 -1
  130. package/dist/src/reactive/non-reactive-state.d.ts +0 -9
  131. package/dist/src/reactive/non-reactive-state.d.ts.map +0 -1
  132. package/dist/src/reactive/non-reactive.d.ts +0 -11
  133. package/dist/src/reactive/non-reactive.d.ts.map +0 -1
  134. package/dist/src/reactive/project.d.ts +0 -40
  135. package/dist/src/reactive/project.d.ts.map +0 -1
  136. package/dist/src/reactive/proxy-state.d.ts +0 -8
  137. package/dist/src/reactive/proxy-state.d.ts.map +0 -1
  138. package/dist/src/reactive/proxy.d.ts +0 -23
  139. package/dist/src/reactive/proxy.d.ts.map +0 -1
  140. package/dist/src/reactive/record.d.ts +0 -115
  141. package/dist/src/reactive/record.d.ts.map +0 -1
  142. package/dist/src/reactive/register.d.ts +0 -125
  143. package/dist/src/reactive/register.d.ts.map +0 -1
  144. package/dist/src/reactive/registry.d.ts +0 -21
  145. package/dist/src/reactive/registry.d.ts.map +0 -1
  146. package/dist/src/reactive/set.d.ts +0 -26
  147. package/dist/src/reactive/set.d.ts.map +0 -1
  148. package/dist/src/reactive/tracking.d.ts +0 -7
  149. package/dist/src/reactive/tracking.d.ts.map +0 -1
  150. package/dist/src/reactive/types.d.ts +0 -424
  151. package/dist/src/reactive/types.d.ts.map +0 -1
  152. package/dist/src/reactive/watch.d.ts +0 -48
  153. package/dist/src/reactive/watch.d.ts.map +0 -1
  154. package/dist/src/std-decorators.d.ts +0 -45
  155. package/dist/src/std-decorators.d.ts.map +0 -1
  156. package/dist/src/utils.d.ts +0 -49
  157. package/dist/src/utils.d.ts.map +0 -1
  158. package/dist/src/zone.d.ts +0 -40
  159. package/dist/src/zone.d.ts.map +0 -1
  160. package/docs/reactive/describe.md +0 -85
  161. package/docs/reactive/project.md +0 -93
  162. package/docs/reactive/scan.md +0 -293
  163. package/src/async/browser.ts +0 -323
  164. package/src/async/index.ts +0 -27
  165. package/src/async/node.ts +0 -92
  166. package/src/decorator.ts +0 -272
  167. package/src/destroyable.ts +0 -199
  168. package/src/entry-browser.ts +0 -5
  169. package/src/entry-node.ts +0 -5
  170. package/src/eventful.ts +0 -110
  171. package/src/flavored.ts +0 -106
  172. package/src/index.d.ts +0 -12
  173. package/src/index.ts +0 -64
  174. package/src/indexable.ts +0 -526
  175. package/src/introspection.ts +0 -59
  176. package/src/iterableWeak.ts +0 -233
  177. package/src/mixins.ts +0 -123
  178. package/src/promiseChain.ts +0 -110
  179. package/src/reactive/array.ts +0 -500
  180. package/src/reactive/buffer.ts +0 -328
  181. package/src/reactive/change.ts +0 -131
  182. package/src/reactive/deep-touch.ts +0 -273
  183. package/src/reactive/deep-watch-state.ts +0 -82
  184. package/src/reactive/deep-watch.ts +0 -171
  185. package/src/reactive/describe.ts +0 -39
  186. package/src/reactive/effect-context.ts +0 -83
  187. package/src/reactive/effects.ts +0 -1434
  188. package/src/reactive/index.ts +0 -72
  189. package/src/reactive/map.ts +0 -142
  190. package/src/reactive/memoize.ts +0 -186
  191. package/src/reactive/non-reactive-state.ts +0 -49
  192. package/src/reactive/non-reactive.ts +0 -43
  193. package/src/reactive/project.md +0 -107
  194. package/src/reactive/project.ts +0 -430
  195. package/src/reactive/proxy-state.ts +0 -27
  196. package/src/reactive/proxy.ts +0 -282
  197. package/src/reactive/record.ts +0 -181
  198. package/src/reactive/register.ts +0 -538
  199. package/src/reactive/registry.ts +0 -72
  200. package/src/reactive/set.ts +0 -117
  201. package/src/reactive/tracking.ts +0 -41
  202. package/src/reactive/types.ts +0 -520
  203. package/src/reactive/watch.ts +0 -180
  204. package/src/std-decorators.ts +0 -256
  205. package/src/utils.ts +0 -300
  206. package/src/zone.ts +0 -142
@@ -4,9 +4,9 @@ declare abstract class AZone<T> {
4
4
  protected leave(entered: unknown): void;
5
5
  with<R>(value: T | undefined, fn: () => R): R;
6
6
  root<R>(fn: () => R): R;
7
- get zoned(): FunctionWrapper;
7
+ get zoned(): GetterWrapper;
8
8
  }
9
- type FunctionWrapper = <R>(fn: () => R) => R;
9
+ type GetterWrapper = <R>(fn: () => R) => R;
10
10
  declare class Zone<T> extends AZone<T> {
11
11
  active: T | undefined;
12
12
  }
@@ -35,6 +35,17 @@ declare class ZoneAggregator extends AZone<Map<AZone<unknown>, unknown>> {
35
35
  delete(z: AZone<unknown>): void;
36
36
  clear(): void;
37
37
  }
38
+ /**
39
+ * Aggregator of zones that should be preserved across async boundaries.
40
+ * If you add a zone here, it will be preserved across async boundaries.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * import { Zone, asyncZone } from 'mutts'
45
+ * const userZone = new Zone<User>()
46
+ * asyncZone.add(userZone)
47
+ * ```
48
+ */
38
49
  declare const asyncZone: ZoneAggregator;
39
50
 
40
51
  /**
@@ -54,7 +65,7 @@ interface EffectAccess {
54
65
  * })
55
66
  * ```
56
67
  */
57
- tracked: FunctionWrapper;
68
+ tracked: GetterWrapper;
58
69
  /**
59
70
  * Tracks dependencies in the parent effect context
60
71
  * Use this when child effects should track dependencies in the parent,
@@ -72,36 +83,82 @@ interface EffectAccess {
72
83
  * })
73
84
  * ```
74
85
  */
75
- ascend: FunctionWrapper;
86
+ ascend: GetterWrapper;
76
87
  /**
77
- * Indicates whether the effect is running as a reaction (i.e. not the first call)
78
- * - `false`: First execution when the effect is created
79
- * - `true`: Subsequent executions triggered by dependency changes
88
+ * `false` on the first execution, `true` or `CleanupReason` on subsequent runs.
89
+ * `true` means this is a re-run but detailed reason gathering is disabled or unavailable.
90
+ * A `CleanupReason` describes *why* the previous run was torn down.
80
91
  * @example
81
92
  * ```typescript
82
93
  * effect(({ reaction }) => {
83
94
  * if (!reaction) {
84
- * console.log('Effect initialized')
85
- * // Setup code that should only run once
86
- * } else {
87
- * console.log('Effect re-ran due to dependency change')
88
- * // Code that runs on every update
95
+ * // First run — setup
96
+ * } else if (reaction !== true && reaction.type === 'propChange') {
97
+ * // Re-run due to dependency change (with details)
98
+ * for (const { evolution } of reaction.triggers)
99
+ * console.log(`${'prop' in evolution ? evolution.prop : evolution.method}: ${evolution.type}`)
89
100
  * }
90
101
  * })
91
102
  * ```
92
103
  */
93
- reaction: boolean;
104
+ reaction: boolean | CleanupReason;
105
+ /**
106
+ * AbortSignal that is aborted when the effect is cleaned up or re-runs.
107
+ * Use this to cancel async operations (like fetch) when the effect is no longer valid.
108
+ */
109
+ signal: AbortSignal;
94
110
  }
95
111
  /**
96
112
  * Base type for effect callbacks - simple function without additional properties
97
113
  */
98
- type ScopedCallback = () => void;
114
+ type ScopedCallback = (reason?: CleanupReason) => void;
115
+ type PropTrigger = {
116
+ obj: object;
117
+ evolution: Evolution;
118
+ dependency?: unknown;
119
+ touch?: unknown;
120
+ };
99
121
  /**
100
- * Type for effect cleanup functions with stopped state tracking
122
+ * Reason for an effect cleanup/reaction
101
123
  */
102
- type EffectCleanup = ScopedCallback & {
103
- [stopped]: boolean;
124
+ type CleanupReason = {
125
+ type: 'propChange';
126
+ triggers: PropTrigger[];
127
+ } | {
128
+ type: 'invalidate';
129
+ cause: CleanupReason;
130
+ } | {
131
+ type: 'stopped';
132
+ detail?: string;
133
+ } | {
134
+ type: 'gc';
135
+ } | {
136
+ type: 'lineage';
137
+ parent: CleanupReason;
138
+ } | {
139
+ type: 'error';
140
+ error: unknown;
141
+ } | {
142
+ type: 'multiple';
143
+ reasons: CleanupReason[];
104
144
  };
145
+ /**
146
+ * Console-friendly description of a `CleanupReason`.
147
+ * Returns an array of arguments to spread into `console.log` / `console.warn`,
148
+ * mixing strings and raw object references so the console can render them as inspectable values.
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * effect(({ reaction }) => {
153
+ * if (reaction !== true) console.log(...formatCleanupReason(reaction))
154
+ * })
155
+ * ```
156
+ */
157
+ declare function formatCleanupReason(reason: CleanupReason, depth?: number): unknown[];
158
+ /**
159
+ * Type for effect cleanup functions.
160
+ */
161
+ type EffectCleanup = ScopedCallback;
105
162
  /**
106
163
  * Type for the `runEffect` function of an effect - argument-less function to call to trigger the effect
107
164
  */
@@ -156,57 +213,48 @@ type State = {
156
213
  evolution: Evolution;
157
214
  next: State;
158
215
  } | {};
159
- /**
160
- * Symbol to check if an effect is stopped
161
- */
162
- declare const stopped: unique symbol;
163
- /**
164
- * Symbol to access effect cleanup function
165
- */
166
- declare const cleanup: unique symbol;
167
- type EffectCloser = (error?: any) => void;
168
- type CatchFunction = (error: any) => EffectCloser | undefined | void;
169
- /**
170
- * Context for a running projection item effect
171
- */
172
- interface ProjectionContext {
173
- source: any;
174
- key?: any;
175
- target: any;
176
- depth: number;
177
- parent?: ProjectionContext;
178
- }
216
+ type EffectCloser = (reason?: CleanupReason) => void;
217
+ type CatchFunction = (error: unknown) => EffectCloser | undefined | void;
179
218
  /**
180
219
  * Structured error codes for machine-readable diagnosis
181
220
  */
182
221
  declare enum ReactiveErrorCode {
183
- CycleDetected = "CYCLE_DETECTED",
184
- MaxDepthExceeded = "MAX_DEPTH_EXCEEDED",
185
- MaxReactionExceeded = "MAX_REACTION_EXCEEDED",
186
- WriteInComputed = "WRITE_IN_COMPUTED",
187
- TrackingError = "TRACKING_ERROR",
188
- BrokenEffects = "BROKEN_EFFECTS"
222
+ CycleDetected = "Cycle detected",
223
+ MaxDepthExceeded = "Max depth exceeded",
224
+ MaxReactionExceeded = "Max reaction exceeded",
225
+ WriteInComputed = "Write in computed",
226
+ TrackingError = "Tracking error",
227
+ BrokenEffects = "Broken effects"
189
228
  }
190
229
  type CycleDebugInfo = {
191
230
  code: ReactiveErrorCode.CycleDetected;
192
231
  cycle: string[];
193
232
  details?: string;
233
+ causalChain?: string[];
234
+ lineage?: unknown;
194
235
  };
195
236
  type MaxDepthDebugInfo = {
196
237
  code: ReactiveErrorCode.MaxDepthExceeded;
197
- depth: number;
198
- chain: string[];
238
+ effectuatedRoots: any[];
239
+ cycle: any[] | null;
240
+ trace: string;
241
+ maxEffectChain: number;
242
+ queued: string[];
243
+ queuedCount: number;
244
+ causalChain?: string[];
245
+ lineage?: unknown;
199
246
  };
200
247
  type MaxReactionDebugInfo = {
201
248
  code: ReactiveErrorCode.MaxReactionExceeded;
202
249
  count: number;
203
250
  effect: string;
251
+ causalChain?: string[];
252
+ lineage?: unknown;
204
253
  };
205
254
  type GenericDebugInfo = {
206
255
  code: ReactiveErrorCode;
207
256
  causalChain?: string[];
208
- creationStack?: string | any[];
209
- lineage?: any[];
257
+ lineage?: unknown;
210
258
  [key: string]: any;
211
259
  };
212
260
  type ReactiveDebugInfo = CycleDebugInfo | MaxDepthDebugInfo | MaxReactionDebugInfo | GenericDebugInfo;
@@ -256,13 +304,19 @@ declare const options: {
256
304
  * @param props - The properties that changed
257
305
  * @param deps - The dependencies that changed
258
306
  */
259
- touched: (_obj: any, _evolution: Evolution, _props?: any[], _deps?: Set<EffectTrigger>) => void;
307
+ touched: (_obj: any, _evolution: Evolution, _props?: any[], _deps?: EffectTrigger[]) => void;
260
308
  /**
261
309
  * Debug purpose: called when an effect is skipped because it's already running
262
310
  * @param effect - The effect that is already running
263
311
  * @param runningChain - The array of effects from the detected one to the currently running one
264
312
  */
265
313
  skipRunningEffect: (_effect: EffectTrigger) => void;
314
+ /**
315
+ * Debug purpose: called when an effect starts executing.
316
+ * @param effect - The effect being executed (root function)
317
+ * @param reaction - false for initial creation, true/CleanupReason for subsequent runs
318
+ */
319
+ effectRun: (_effect: Function, _reaction: boolean | CleanupReason) => void;
266
320
  /**
267
321
  * Debug purpose: maximum effect chain (like call stack max depth)
268
322
  * Used to prevent infinite loops
@@ -366,49 +420,41 @@ declare const options: {
366
420
  asyncMode: AsyncExecutionMode | false;
367
421
  warn: (...args: any[]) => void;
368
422
  /**
369
- * Configuration for the introspection system
423
+ * Introspection and debug aids. Set to `null` to disable all debug overhead in production.
424
+ *
425
+ * - `gatherReasons`: collect `PropTrigger[]` for `CleanupReason` on effect re-runs (default `true`)
426
+ * - `lineages`: what lineages to capture in PropTrigger (default `'touch'`)
427
+ * - `logErrors`: log errors with detailed context (default `true`)
428
+ * - `enableHistory`: keep a history of mutations (default `true`)
429
+ * - `historySize`: number of mutations to keep in history (default `50`)
430
+ *
431
+ * `enableDevTools()` sets `logErrors` to `true` automatically.
432
+ *
433
+ * @example
434
+ * ```typescript
435
+ * // Production: disable all introspection
436
+ * reactiveOptions.introspection = null
437
+ * ```
370
438
  */
371
439
  introspection: {
372
- /**
373
- * Whether to keep a history of mutations for debugging
374
- * @default false
375
- */
440
+ gatherReasons: {
441
+ lineages: "none" | "touch" | "dependency" | "both";
442
+ };
443
+ logErrors: boolean;
376
444
  enableHistory: boolean;
377
- /**
378
- * Number of mutations to keep in history
379
- * @default 50
380
- */
381
445
  historySize: number;
382
- };
383
- /**
384
- * Configuration for zone hooks - control which async APIs are hooked
385
- * Each option controls whether the corresponding async API is wrapped to preserve effect context
386
- * Only applies when asyncMode is enabled (truthy)
387
- * @deprecated Should take all when we made sure PIXI.create, Game.create, ... are -> .root()
388
- */
389
- zones: {
390
- /**
391
- * Hook setTimeout to preserve effect context
392
- * @default true
393
- */
394
- setTimeout: boolean;
395
- /**
396
- * Hook setInterval to preserve effect context
397
- * @default true
398
- */
399
- setInterval: boolean;
400
- /**
401
- * Hook requestAnimationFrame (runs in untracked context when hooked)
402
- * @default true
403
- */
404
- requestAnimationFrame: boolean;
405
- /**
406
- * Hook queueMicrotask to preserve effect context
407
- * @default true
408
- */
409
- queueMicrotask: boolean;
410
- };
446
+ } | null;
411
447
  };
448
+ /** Production preset: no introspection, heuristic cycle detection, minimal overhead */
449
+ declare const prodPreset: Partial<typeof options>;
450
+ /** Development preset (default): introspection on, early cycle detection, warnings */
451
+ declare const devPreset: Partial<typeof options>;
452
+ /** Debug preset: full diagnostics, throws on violations, rich lineage capture */
453
+ declare const debugPreset: Partial<typeof options>;
454
+ declare const objectToProxy: WeakMap<object, object>;
455
+ declare const proxyToObject: WeakMap<object, object>;
456
+ declare function unwrap<T>(obj: T): T;
457
+ declare function isReactive(obj: any): boolean;
412
458
 
413
- export { AZone as A, ReactiveError as R, ZoneAggregator as Z, cleanup as c, ReactiveErrorCode as h, Zone as i, ZoneHistory as j, asyncZone as k, options as o };
414
- export type { CatchFunction as C, EffectTrigger as E, FunctionWrapper as F, ProjectionContext as P, ScopedCallback as S, Evolution as a, EffectCleanup as b, EffectCloser as d, EffectAccess as e, State as f, EffectOptions as g };
459
+ export { AZone as A, ReactiveError as R, ZoneAggregator as Z, ReactiveErrorCode as h, Zone as i, ZoneHistory as j, asyncZone as k, debugPreset as l, devPreset as m, formatCleanupReason as n, isReactive as o, objectToProxy as p, prodPreset as q, proxyToObject as r, options as s, unwrap as u };
460
+ export type { CleanupReason as C, EffectTrigger as E, GetterWrapper as G, HistoryValue as H, PropTrigger as P, ScopedCallback as S, Evolution as a, EffectCleanup as b, EffectAccess as c, EffectCloser as d, State as e, CatchFunction as f, EffectOptions as g };
@@ -46,6 +46,7 @@ export declare function untracked<T>(fn: () => T): T;
46
46
  // --------------------------------------------------------------------------------
47
47
 
48
48
  export declare function atomic<T extends (...args: any[]) => any>(fn: T): T;
49
+ export declare function atom<T>(fn: () => T): T;
49
50
  export declare function memoize<Result, Args extends any[]>(fn: (...args: Args) => Result, maxArgs?: number): (...args: Args) => Result;
50
51
  export declare function deepWatch(source: any, callback: (path: string[], value: any) => void): () => void;
51
52
  export declare function biDi<T>(target: (val: T) => void, source: { get: () => T, set: (v: T) => void }): (val: T) => void;
@@ -54,20 +55,6 @@ export declare function biDi<T>(target: (val: T) => void, source: { get: () => T
54
55
  // COLLECTIONS
55
56
  // --------------------------------------------------------------------------------
56
57
 
57
- export interface Register<T, K extends PropertyKey = PropertyKey> extends Iterable<T> {
58
- length: number;
59
- [index: number]: T;
60
- get(key: K): T | undefined;
61
- set(key: K, value: T): void;
62
- hasKey(key: K): boolean;
63
- indexOfKey(key: K): number;
64
- remove(key: K): void;
65
- removeAt(index: number): T | undefined;
66
- push(...items: T[]): number;
67
- // ... complete array methods are supported
68
- }
69
-
70
- export declare function register<T, K extends PropertyKey = PropertyKey>(keyFn: (item: T) => K, initial?: Iterable<T>): Register<T, K>;
71
58
  export declare function project<S, R>(source: S, apply: (access: any, target: any) => any): R;
72
59
  export declare function organized<S, T>(source: S, apply: (access: any, target: T) => any, baseTarget?: T): T;
73
60
 
@@ -104,28 +91,20 @@ export declare function deprecated(message?: string): Function;
104
91
  // INTROSPECTION (AI Debugging)
105
92
  // --------------------------------------------------------------------------------
106
93
 
107
- export interface ReactivityGraph {
108
- nodes: { id: string, label: string, type: 'effect'|'object' }[];
109
- edges: { source: string, target: string, type: string }[];
110
- }
111
-
112
- export interface MutationRecord {
113
- type: 'set' | 'add' | 'delete';
114
- prop: PropertyKey;
115
- oldValue: any;
116
- newValue: any;
117
- objectName?: string;
118
- }
94
+ // See: 'mutts/debug' for programmatic access
95
+ // buildReactivityGraph, getMutationHistory, getDependents, getDependencies, etc.
119
96
 
120
- export declare function getDependencyGraph(): ReactivityGraph;
121
- export declare function getMutationHistory(): MutationRecord[];
122
- export declare const options: {
97
+ export declare const reactiveOptions: {
123
98
  cycleHandling: 'production' | 'development' | 'debug';
124
- introspection: { enableHistory: boolean; historySize: number };
99
+ introspection: { enableHistory: boolean; historySize: number; logErrors: boolean };
125
100
  };
126
101
 
127
102
  export enum ReactiveErrorCode {
128
- CYCLE_DETECTED = 'CYCLE_DETECTED',
129
- MAX_DEPTH_EXCEEDED = 'MAX_DEPTH_EXCEEDED',
103
+ CycleDetected = 'Cycle detected',
104
+ MaxDepthExceeded = 'Max depth exceeded',
105
+ MaxReactionExceeded = 'Max reaction exceeded',
106
+ WriteInComputed = 'Write in computed',
107
+ TrackingError = 'Tracking error',
108
+ BrokenEffects = 'Broken effects',
130
109
  }
131
110
  ```