mutts 1.0.8 → 1.0.10

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 (195) hide show
  1. package/README.md +77 -35
  2. package/dist/browser.cjs +2144 -5355
  3. package/dist/browser.cjs.map +1 -1
  4. package/dist/browser.d.ts +2 -1655
  5. package/dist/browser.dev.cjs +110 -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 +20 -107
  11. package/dist/browser.esm.js.map +1 -1
  12. package/dist/chunks/{async-browser-CA0jPWIi.cjs → async-browser-BU_IfxYD.cjs} +19 -107
  13. package/dist/chunks/async-browser-BU_IfxYD.cjs.map +1 -0
  14. package/dist/chunks/{async-core-UqHzvJ-S.cjs → async-core-CRLKP3l-.cjs} +8 -4
  15. package/dist/chunks/async-core-CRLKP3l-.cjs.map +1 -0
  16. package/dist/chunks/{async-node-BYHuGTni.cjs → async-node-3PrbVAbB.cjs} +7 -12
  17. package/dist/chunks/async-node-3PrbVAbB.cjs.map +1 -0
  18. package/dist/chunks/index-CaaQQlPJ.esm.js +3174 -0
  19. package/dist/chunks/index-CaaQQlPJ.esm.js.map +1 -0
  20. package/dist/chunks/node-nKJBk8iJ.esm.js +96 -0
  21. package/dist/chunks/node-nKJBk8iJ.esm.js.map +1 -0
  22. package/dist/chunks/proxy-Dtg-bJ3T.cjs +3763 -0
  23. package/dist/chunks/proxy-Dtg-bJ3T.cjs.map +1 -0
  24. package/dist/chunks/proxy-r7lARftl.esm.js +3701 -0
  25. package/dist/chunks/proxy-r7lARftl.esm.js.map +1 -0
  26. package/dist/debug.cjs +980 -0
  27. package/dist/debug.cjs.map +1 -0
  28. package/dist/debug.d.ts +208 -0
  29. package/dist/debug.esm.js +950 -0
  30. package/dist/debug.esm.js.map +1 -0
  31. package/dist/devtools/manifest.json +1 -1
  32. package/dist/devtools/panel.html +1 -1
  33. package/dist/devtools/panel.js +107 -94
  34. package/dist/devtools/panel.js.map +1 -1
  35. package/dist/index.d.ts +1447 -13
  36. package/dist/mutts.umd.js +7167 -1
  37. package/dist/mutts.umd.js.map +1 -1
  38. package/dist/mutts.umd.min.js +1 -1
  39. package/dist/mutts.umd.min.js.map +1 -1
  40. package/dist/node.cjs +70 -66
  41. package/dist/node.cjs.map +1 -1
  42. package/dist/node.d.ts +2 -1
  43. package/dist/node.dev.cjs +110 -0
  44. package/dist/node.dev.cjs.map +1 -0
  45. package/dist/node.dev.d.ts +2 -0
  46. package/dist/node.dev.esm.js +6 -0
  47. package/dist/node.dev.esm.js.map +1 -0
  48. package/dist/node.esm.js +4 -103
  49. package/dist/node.esm.js.map +1 -1
  50. package/dist/{reactive/types.d.ts → types-W5vD6m2n.d.ts} +186 -93
  51. package/docs/ai/api-reference.md +12 -19
  52. package/docs/ai/manual.md +521 -17
  53. package/docs/events.md +57 -2
  54. package/docs/flavored.md +210 -0
  55. package/docs/reactive/advanced.md +314 -5
  56. package/docs/reactive/attend.md +142 -0
  57. package/docs/reactive/collections.md +76 -39
  58. package/docs/reactive/core.md +100 -14
  59. package/docs/reactive/debugging.md +123 -18
  60. package/docs/reactive/error-handling.md +121 -0
  61. package/docs/reactive/resource.md +125 -0
  62. package/docs/reactive/scan.md +247 -1
  63. package/docs/reactive.md +4 -1
  64. package/docs/std-decorators.md +102 -51
  65. package/docs/utils.md +70 -0
  66. package/docs/zone.md +3 -7
  67. package/package.json +64 -30
  68. package/dist/async/browser.d.ts +0 -2
  69. package/dist/async/browser.d.ts.map +0 -1
  70. package/dist/async/index.d.ts +0 -18
  71. package/dist/async/index.d.ts.map +0 -1
  72. package/dist/async/node.d.ts +0 -2
  73. package/dist/async/node.d.ts.map +0 -1
  74. package/dist/chunks/async-browser-CA0jPWIi.cjs.map +0 -1
  75. package/dist/chunks/async-core-UqHzvJ-S.cjs.map +0 -1
  76. package/dist/chunks/async-node-BYHuGTni.cjs.map +0 -1
  77. package/dist/chunks/index-DhaOVusv.esm.js +0 -6411
  78. package/dist/chunks/index-DhaOVusv.esm.js.map +0 -1
  79. package/dist/decorator.d.ts +0 -106
  80. package/dist/decorator.d.ts.map +0 -1
  81. package/dist/destroyable.d.ts +0 -87
  82. package/dist/destroyable.d.ts.map +0 -1
  83. package/dist/entry-browser.d.ts +0 -3
  84. package/dist/entry-browser.d.ts.map +0 -1
  85. package/dist/entry-node.d.ts +0 -3
  86. package/dist/entry-node.d.ts.map +0 -1
  87. package/dist/eventful.d.ts +0 -18
  88. package/dist/eventful.d.ts.map +0 -1
  89. package/dist/index.d.ts.map +0 -1
  90. package/dist/indexable.d.ts +0 -243
  91. package/dist/indexable.d.ts.map +0 -1
  92. package/dist/introspection.d.ts +0 -27
  93. package/dist/introspection.d.ts.map +0 -1
  94. package/dist/iterableWeak.d.ts +0 -53
  95. package/dist/iterableWeak.d.ts.map +0 -1
  96. package/dist/mixins.d.ts +0 -25
  97. package/dist/mixins.d.ts.map +0 -1
  98. package/dist/promiseChain.d.ts +0 -20
  99. package/dist/promiseChain.d.ts.map +0 -1
  100. package/dist/reactive/array.d.ts +0 -49
  101. package/dist/reactive/array.d.ts.map +0 -1
  102. package/dist/reactive/buffer.d.ts +0 -44
  103. package/dist/reactive/buffer.d.ts.map +0 -1
  104. package/dist/reactive/change.d.ts +0 -29
  105. package/dist/reactive/change.d.ts.map +0 -1
  106. package/dist/reactive/debug.d.ts +0 -111
  107. package/dist/reactive/debug.d.ts.map +0 -1
  108. package/dist/reactive/deep-touch.d.ts +0 -28
  109. package/dist/reactive/deep-touch.d.ts.map +0 -1
  110. package/dist/reactive/deep-watch-state.d.ts +0 -25
  111. package/dist/reactive/deep-watch-state.d.ts.map +0 -1
  112. package/dist/reactive/deep-watch.d.ts +0 -19
  113. package/dist/reactive/deep-watch.d.ts.map +0 -1
  114. package/dist/reactive/effect-context.d.ts +0 -7
  115. package/dist/reactive/effect-context.d.ts.map +0 -1
  116. package/dist/reactive/effects.d.ts +0 -151
  117. package/dist/reactive/effects.d.ts.map +0 -1
  118. package/dist/reactive/index.d.ts +0 -20
  119. package/dist/reactive/index.d.ts.map +0 -1
  120. package/dist/reactive/interface.d.ts +0 -64
  121. package/dist/reactive/interface.d.ts.map +0 -1
  122. package/dist/reactive/map.d.ts +0 -30
  123. package/dist/reactive/map.d.ts.map +0 -1
  124. package/dist/reactive/memoize.d.ts +0 -5
  125. package/dist/reactive/memoize.d.ts.map +0 -1
  126. package/dist/reactive/non-reactive-state.d.ts +0 -9
  127. package/dist/reactive/non-reactive-state.d.ts.map +0 -1
  128. package/dist/reactive/non-reactive.d.ts +0 -11
  129. package/dist/reactive/non-reactive.d.ts.map +0 -1
  130. package/dist/reactive/project.d.ts +0 -41
  131. package/dist/reactive/project.d.ts.map +0 -1
  132. package/dist/reactive/proxy-state.d.ts +0 -8
  133. package/dist/reactive/proxy-state.d.ts.map +0 -1
  134. package/dist/reactive/proxy.d.ts +0 -23
  135. package/dist/reactive/proxy.d.ts.map +0 -1
  136. package/dist/reactive/record.d.ts +0 -116
  137. package/dist/reactive/record.d.ts.map +0 -1
  138. package/dist/reactive/register.d.ts +0 -64
  139. package/dist/reactive/register.d.ts.map +0 -1
  140. package/dist/reactive/registry.d.ts +0 -20
  141. package/dist/reactive/registry.d.ts.map +0 -1
  142. package/dist/reactive/set.d.ts +0 -28
  143. package/dist/reactive/set.d.ts.map +0 -1
  144. package/dist/reactive/tracking.d.ts +0 -7
  145. package/dist/reactive/tracking.d.ts.map +0 -1
  146. package/dist/reactive/types.d.ts.map +0 -1
  147. package/dist/std-decorators.d.ts +0 -50
  148. package/dist/std-decorators.d.ts.map +0 -1
  149. package/dist/utils.d.ts +0 -49
  150. package/dist/utils.d.ts.map +0 -1
  151. package/dist/zone.d.ts +0 -40
  152. package/dist/zone.d.ts.map +0 -1
  153. package/docs/reactive/project.md +0 -93
  154. package/src/async/browser.ts +0 -319
  155. package/src/async/index.ts +0 -23
  156. package/src/async/node.ts +0 -104
  157. package/src/decorator.ts +0 -272
  158. package/src/destroyable.ts +0 -199
  159. package/src/entry-browser.ts +0 -5
  160. package/src/entry-node.ts +0 -5
  161. package/src/eventful.ts +0 -77
  162. package/src/index.d.ts +0 -12
  163. package/src/index.ts +0 -64
  164. package/src/indexable.ts +0 -526
  165. package/src/introspection.ts +0 -59
  166. package/src/iterableWeak.ts +0 -233
  167. package/src/mixins.ts +0 -123
  168. package/src/promiseChain.ts +0 -110
  169. package/src/reactive/array.ts +0 -507
  170. package/src/reactive/buffer.ts +0 -168
  171. package/src/reactive/change.ts +0 -138
  172. package/src/reactive/debug.ts +0 -517
  173. package/src/reactive/deep-touch.ts +0 -268
  174. package/src/reactive/deep-watch-state.ts +0 -82
  175. package/src/reactive/deep-watch.ts +0 -168
  176. package/src/reactive/effect-context.ts +0 -18
  177. package/src/reactive/effects.ts +0 -1382
  178. package/src/reactive/index.ts +0 -75
  179. package/src/reactive/interface.ts +0 -210
  180. package/src/reactive/map.ts +0 -158
  181. package/src/reactive/memoize.ts +0 -163
  182. package/src/reactive/non-reactive-state.ts +0 -49
  183. package/src/reactive/non-reactive.ts +0 -43
  184. package/src/reactive/project.ts +0 -453
  185. package/src/reactive/proxy-state.ts +0 -27
  186. package/src/reactive/proxy.ts +0 -264
  187. package/src/reactive/record.ts +0 -196
  188. package/src/reactive/register.ts +0 -419
  189. package/src/reactive/registry.ts +0 -59
  190. package/src/reactive/set.ts +0 -130
  191. package/src/reactive/tracking.ts +0 -44
  192. package/src/reactive/types.ts +0 -440
  193. package/src/std-decorators.ts +0 -217
  194. package/src/utils.ts +0 -301
  195. package/src/zone.ts +0 -138
@@ -1,9 +1,47 @@
1
- import { FunctionWrapper } from "../zone";
1
+ declare abstract class AZone<T> {
2
+ abstract active?: T;
3
+ protected enter(value?: T): unknown;
4
+ protected leave(entered: unknown): void;
5
+ with<R>(value: T | undefined, fn: () => R): R;
6
+ root<R>(fn: () => R): R;
7
+ get zoned(): FunctionWrapper;
8
+ }
9
+ type FunctionWrapper = <R>(fn: () => R) => R;
10
+ declare class Zone<T> extends AZone<T> {
11
+ active: T | undefined;
12
+ }
13
+ type HistoryValue<T> = {
14
+ present: T | undefined;
15
+ history: Set<T>;
16
+ };
17
+ declare class ZoneHistory<T> extends AZone<HistoryValue<T>> {
18
+ private controlled;
19
+ private history;
20
+ readonly present: AZone<T>;
21
+ has(value: T): boolean;
22
+ some(predicate: (value: T) => boolean): boolean;
23
+ constructor(controlled?: AZone<T>);
24
+ get active(): HistoryValue<T> | undefined;
25
+ set active(value: HistoryValue<T> | undefined);
26
+ }
27
+ declare class ZoneAggregator extends AZone<Map<AZone<unknown>, unknown>> {
28
+ #private;
29
+ constructor(...zones: AZone<unknown>[]);
30
+ get active(): Map<AZone<unknown>, unknown> | undefined;
31
+ set active(value: Map<AZone<unknown>, unknown> | undefined);
32
+ enter(value?: Map<AZone<unknown>, unknown> | undefined): Map<AZone<unknown>, unknown>;
33
+ leave(entered: Map<AZone<unknown>, unknown>): void;
34
+ add(z: AZone<unknown>): void;
35
+ delete(z: AZone<unknown>): void;
36
+ clear(): void;
37
+ }
38
+ declare const asyncZone: ZoneAggregator;
39
+
2
40
  /**
3
- * Dependency access passed to user callbacks within effects/watch
41
+ * Effect access passed to user callbacks within effects/watch
4
42
  * Provides functions to track dependencies and information about the effect execution
5
43
  */
6
- export interface DependencyAccess {
44
+ interface EffectAccess {
7
45
  /**
8
46
  * Tracks dependencies in the current effect context
9
47
  * Use this for normal dependency tracking within the effect
@@ -36,39 +74,91 @@ export interface DependencyAccess {
36
74
  */
37
75
  ascend: FunctionWrapper;
38
76
  /**
39
- * Indicates whether the effect is running as a reaction (i.e. not the first call)
40
- * - `false`: First execution when the effect is created
41
- * - `true`: Subsequent executions triggered by dependency changes
77
+ * `false` on the first execution, `true` or `CleanupReason` on subsequent runs.
78
+ * `true` means this is a re-run but detailed reason gathering is disabled or unavailable.
79
+ * A `CleanupReason` describes *why* the previous run was torn down.
42
80
  * @example
43
81
  * ```typescript
44
82
  * effect(({ reaction }) => {
45
83
  * if (!reaction) {
46
- * console.log('Effect initialized')
47
- * // Setup code that should only run once
48
- * } else {
49
- * console.log('Effect re-ran due to dependency change')
50
- * // Code that runs on every update
84
+ * // First run — setup
85
+ * } else if (reaction !== true && reaction.type === 'propChange') {
86
+ * // Re-run due to dependency change (with details)
87
+ * for (const { evolution } of reaction.triggers)
88
+ * console.log(`${'prop' in evolution ? evolution.prop : evolution.method}: ${evolution.type}`)
51
89
  * }
52
90
  * })
53
91
  * ```
54
92
  */
55
- reaction: boolean;
93
+ reaction: boolean | CleanupReason;
56
94
  }
57
95
  /**
58
- * Type for effect cleanup functions
96
+ * Base type for effect callbacks - simple function without additional properties
97
+ */
98
+ type ScopedCallback = (reason?: CleanupReason) => void;
99
+ type PropTrigger = {
100
+ obj: object;
101
+ evolution: Evolution;
102
+ dependency?: unknown;
103
+ touch?: unknown;
104
+ };
105
+ /**
106
+ * Reason for an effect cleanup/reaction
107
+ */
108
+ type CleanupReason = {
109
+ type: 'propChange';
110
+ triggers: PropTrigger[];
111
+ } | {
112
+ type: 'invalidate';
113
+ cause: CleanupReason;
114
+ } | {
115
+ type: 'stopped';
116
+ } | {
117
+ type: 'gc';
118
+ } | {
119
+ type: 'lineage';
120
+ parent: CleanupReason;
121
+ } | {
122
+ type: 'error';
123
+ error: unknown;
124
+ } | {
125
+ type: 'multiple';
126
+ reasons: CleanupReason[];
127
+ };
128
+ /**
129
+ * Console-friendly description of a `CleanupReason`.
130
+ * Returns an array of arguments to spread into `console.log` / `console.warn`,
131
+ * mixing strings and raw object references so the console can render them as inspectable values.
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * effect(({ reaction }) => {
136
+ * if (reaction !== true) console.log(...formatCleanupReason(reaction))
137
+ * })
138
+ * ```
59
139
  */
60
- export type ScopedCallback = () => void;
140
+ declare function formatCleanupReason(reason: CleanupReason, depth?: number): unknown[];
141
+ /**
142
+ * Type for effect cleanup functions with stopped state tracking
143
+ */
144
+ type EffectCleanup = ScopedCallback & {
145
+ [stopped]: boolean;
146
+ };
147
+ /**
148
+ * Type for the `runEffect` function of an effect - argument-less function to call to trigger the effect
149
+ */
150
+ type EffectTrigger = ScopedCallback;
61
151
  /**
62
152
  * Async execution mode for effects
63
153
  * - `cancel`: Cancel previous async execution when dependencies change (default)
64
154
  * - `queue`: Queue next execution to run after current completes
65
155
  * - `ignore`: Ignore new executions while async work is running
66
156
  */
67
- export type AsyncExecutionMode = 'cancel' | 'queue' | 'ignore';
157
+ type AsyncExecutionMode = 'cancel' | 'queue' | 'ignore';
68
158
  /**
69
159
  * Options for effect creation
70
160
  */
71
- export interface EffectOptions {
161
+ interface EffectOptions {
72
162
  /**
73
163
  * How to handle async effect executions when dependencies change
74
164
  * @default 'cancel'
@@ -80,103 +170,91 @@ export interface EffectOptions {
80
170
  * Use this for effects that depend on object identity (like memoize).
81
171
  */
82
172
  opaque?: boolean;
173
+ /**
174
+ * Used for debugging purpose. Provides a callback to be called every time a dependency is created.
175
+ */
176
+ dependencyHook?: (obj: any, prop: any) => void;
177
+ /**
178
+ * Used for debugging purpose. Provides a name for the effect.
179
+ */
180
+ name?: string;
83
181
  }
84
182
  /**
85
183
  * Type for property evolution events
86
184
  */
87
- export type PropEvolution = {
185
+ type PropEvolution = {
88
186
  type: 'set' | 'del' | 'add' | 'invalidate';
89
187
  prop: any;
90
188
  };
91
189
  /**
92
190
  * Type for collection operation evolution events
93
191
  */
94
- export type BunchEvolution = {
192
+ type BunchEvolution = {
95
193
  type: 'bunch';
96
194
  method: string;
97
195
  };
98
- export type Evolution = PropEvolution | BunchEvolution;
196
+ type Evolution = PropEvolution | BunchEvolution;
99
197
  type State = {
100
198
  evolution: Evolution;
101
199
  next: State;
102
200
  } | {};
103
- declare const nativeReactive: unique symbol;
104
- /**
105
- * Symbol to mark individual objects as non-reactive
106
- */
107
- export declare const nonReactiveMark: unique symbol;
108
- /**
109
- * Symbol to mark class properties as non-reactive
110
- */
111
- export declare const unreactiveProperties: unique symbol;
112
- /**
113
- * Symbol representing all properties in reactive tracking
114
- */
115
- export declare const allProps: unique symbol;
116
- /**
117
- * Symbol for accessing projection information on reactive objects
118
- */
119
- export declare const projectionInfo: unique symbol;
120
201
  /**
121
202
  * Symbol to check if an effect is stopped
122
203
  */
123
- export declare const stopped: unique symbol;
204
+ declare const stopped: unique symbol;
124
205
  /**
125
206
  * Symbol to access effect cleanup function
126
207
  */
127
- export declare const cleanup: unique symbol;
128
- /**
129
- * Context for a running projection item effect
130
- */
131
- export interface ProjectionContext {
132
- source: any;
133
- key?: any;
134
- target: any;
135
- depth: number;
136
- parent?: ProjectionContext;
137
- }
138
- declare const rootFunction: unique symbol;
208
+ declare const cleanup: unique symbol;
209
+ type EffectCloser = (reason?: CleanupReason) => void;
210
+ type CatchFunction = (error: any) => EffectCloser | undefined | void;
139
211
  /**
140
212
  * Structured error codes for machine-readable diagnosis
141
213
  */
142
- export declare enum ReactiveErrorCode {
143
- CycleDetected = "CYCLE_DETECTED",
144
- MaxDepthExceeded = "MAX_DEPTH_EXCEEDED",
145
- MaxReactionExceeded = "MAX_REACTION_EXCEEDED",
146
- WriteInComputed = "WRITE_IN_COMPUTED",
147
- TrackingError = "TRACKING_ERROR",
148
- BrokenEffects = "BROKEN_EFFECTS"
214
+ declare enum ReactiveErrorCode {
215
+ CycleDetected = "Cycle detected",
216
+ MaxDepthExceeded = "Max depth exceeded",
217
+ MaxReactionExceeded = "Max reaction exceeded",
218
+ WriteInComputed = "Write in computed",
219
+ TrackingError = "Tracking error",
220
+ BrokenEffects = "Broken effects"
149
221
  }
150
- export type CycleDebugInfo = {
222
+ type CycleDebugInfo = {
151
223
  code: ReactiveErrorCode.CycleDetected;
152
224
  cycle: string[];
153
225
  details?: string;
226
+ causalChain?: string[];
227
+ lineage?: unknown;
154
228
  };
155
- export type MaxDepthDebugInfo = {
229
+ type MaxDepthDebugInfo = {
156
230
  code: ReactiveErrorCode.MaxDepthExceeded;
157
- depth: number;
158
- chain: string[];
231
+ effectuatedRoots: any[];
232
+ cycle: any[] | null;
233
+ trace: string;
234
+ maxEffectChain: number;
235
+ queued: string[];
236
+ queuedCount: number;
237
+ causalChain?: string[];
238
+ lineage?: unknown;
159
239
  };
160
- export type MaxReactionDebugInfo = {
240
+ type MaxReactionDebugInfo = {
161
241
  code: ReactiveErrorCode.MaxReactionExceeded;
162
242
  count: number;
163
243
  effect: string;
244
+ causalChain?: string[];
245
+ lineage?: unknown;
164
246
  };
165
- export type BrokenEffectsDebugInfo = {
166
- code: ReactiveErrorCode.BrokenEffects;
167
- cause: any;
168
- };
169
- export type GenericDebugInfo = {
247
+ type GenericDebugInfo = {
170
248
  code: ReactiveErrorCode;
171
249
  causalChain?: string[];
172
- creationStack?: string;
250
+ lineage?: unknown;
173
251
  [key: string]: any;
174
252
  };
175
- export type ReactiveDebugInfo = CycleDebugInfo | MaxDepthDebugInfo | MaxReactionDebugInfo | BrokenEffectsDebugInfo | GenericDebugInfo;
253
+ type ReactiveDebugInfo = CycleDebugInfo | MaxDepthDebugInfo | MaxReactionDebugInfo | GenericDebugInfo;
176
254
  /**
177
255
  * Error class for reactive system errors
178
256
  */
179
- export declare class ReactiveError extends Error {
257
+ declare class ReactiveError extends Error {
180
258
  debugInfo?: ReactiveDebugInfo;
181
259
  constructor(message: string, debugInfo?: ReactiveDebugInfo);
182
260
  get code(): ReactiveErrorCode | undefined;
@@ -185,7 +263,7 @@ export declare class ReactiveError extends Error {
185
263
  /**
186
264
  * Global options for the reactive system
187
265
  */
188
- export declare const options: {
266
+ declare const options: {
189
267
  /**
190
268
  * Debug purpose: called when an effect is entered
191
269
  * @param effect - The effect that is entered
@@ -219,13 +297,13 @@ export declare const options: {
219
297
  * @param props - The properties that changed
220
298
  * @param deps - The dependencies that changed
221
299
  */
222
- touched: (_obj: any, _evolution: Evolution, _props?: any[], _deps?: Set<ScopedCallback>) => void;
300
+ touched: (_obj: any, _evolution: Evolution, _props?: any[], _deps?: EffectTrigger[]) => void;
223
301
  /**
224
302
  * Debug purpose: called when an effect is skipped because it's already running
225
303
  * @param effect - The effect that is already running
226
304
  * @param runningChain - The array of effects from the detected one to the currently running one
227
305
  */
228
- skipRunningEffect: (_effect: ScopedCallback) => void;
306
+ skipRunningEffect: (_effect: EffectTrigger) => void;
229
307
  /**
230
308
  * Debug purpose: maximum effect chain (like call stack max depth)
231
309
  * Used to prevent infinite loops
@@ -267,20 +345,20 @@ export declare const options: {
267
345
  /**
268
346
  * How to handle cycles detected in effect batches.
269
347
  *
270
- * - `'none'` (Default): High-performance mode. Disables dependency graph maintenance and
348
+ * - `'production'` (Default): High-performance mode. Disables dependency graph maintenance and
271
349
  * Topological Sorting in favor of a simple FIFO queue. Use this for trustworthy, acyclic UI code.
272
- * Cycle detection is heuristic (uses execution counts).
350
+ * Cycle detection is heuristic (uses maxEffectChain execution counts).
273
351
  *
274
- * - `'throw'`: Traditional Topological Sorting. Guarantees dependency order and catches
275
- * circular dependencies mathematically before execution.
352
+ * - `'development'`: Maintains direct dependency graph for early cycle detection during edge creation.
353
+ * Catches cycles before effects execute via DFS check when adding edges. Throws immediately with
354
+ * basic path information. Good balance of debugging help with moderate overhead.
276
355
  *
277
- * - `'warn'`: Topological sorting, but logs a warning instead of throwing on cycles.
278
- * - `'break'`: Topological sorting, but silently breaks cycles.
279
- * - `'strict'`: Prevents cycle creation by checking the graph *during* dependency discovery.
356
+ * - `'debug'`: Full diagnostic mode with transitive closures and topological sorting.
357
+ * Provides detailed cycle path reporting. Highest overhead but most informative for bug hunting.
280
358
  *
281
- * @default 'none'
359
+ * @default 'production'
282
360
  */
283
- cycleHandling: "none" | "throw" | "warn" | "break" | "strict";
361
+ cycleHandling: "production" | "development" | "debug";
284
362
  /**
285
363
  * Internal flag used by memoization discrepancy detector to avoid counting calls in tests
286
364
  * @warning Do not modify this flag manually, this flag is given by the engine
@@ -329,20 +407,30 @@ export declare const options: {
329
407
  asyncMode: AsyncExecutionMode | false;
330
408
  warn: (...args: any[]) => void;
331
409
  /**
332
- * Configuration for the introspection system
410
+ * Introspection and debug aids. Set to `null` to disable all debug overhead in production.
411
+ *
412
+ * - `gatherReasons`: collect `PropTrigger[]` for `CleanupReason` on effect re-runs (default `true`)
413
+ * - `lineages`: what lineages to capture in PropTrigger (default `'touch'`)
414
+ * - `logErrors`: log errors with detailed context (default `true`)
415
+ * - `enableHistory`: keep a history of mutations (default `true`)
416
+ * - `historySize`: number of mutations to keep in history (default `50`)
417
+ *
418
+ * `enableDevTools()` sets `logErrors` to `true` automatically.
419
+ *
420
+ * @example
421
+ * ```typescript
422
+ * // Production: disable all introspection
423
+ * reactiveOptions.introspection = null
424
+ * ```
333
425
  */
334
426
  introspection: {
335
- /**
336
- * Whether to keep a history of mutations for debugging
337
- * @default false
338
- */
427
+ gatherReasons: {
428
+ lineages: "none" | "touch" | "dependency" | "both";
429
+ };
430
+ logErrors: boolean;
339
431
  enableHistory: boolean;
340
- /**
341
- * Number of mutations to keep in history
342
- * @default 50
343
- */
344
432
  historySize: number;
345
- };
433
+ } | null;
346
434
  /**
347
435
  * Configuration for zone hooks - control which async APIs are hooked
348
436
  * Each option controls whether the corresponding async API is wrapped to preserve effect context
@@ -372,5 +460,10 @@ export declare const options: {
372
460
  queueMicrotask: boolean;
373
461
  };
374
462
  };
375
- export { type State, nativeReactive, rootFunction };
376
- //# sourceMappingURL=types.d.ts.map
463
+ declare const objectToProxy: WeakMap<object, object>;
464
+ declare const proxyToObject: WeakMap<object, object>;
465
+ declare function unwrap<T>(obj: T): T;
466
+ declare function isReactive(obj: any): boolean;
467
+
468
+ export { AZone as A, ReactiveError as R, ZoneAggregator as Z, cleanup as c, ReactiveErrorCode as i, Zone as j, ZoneHistory as k, asyncZone as l, formatCleanupReason as m, isReactive as n, objectToProxy as o, proxyToObject as p, options as q, stopped as s, unwrap as u };
469
+ export type { CatchFunction as C, EffectTrigger as E, FunctionWrapper as F, PropTrigger as P, ScopedCallback as S, Evolution as a, EffectCleanup as b, EffectCloser as d, EffectAccess as e, State as f, EffectOptions as g, CleanupReason as h };
@@ -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;
@@ -104,28 +105,20 @@ export declare function deprecated(message?: string): Function;
104
105
  // INTROSPECTION (AI Debugging)
105
106
  // --------------------------------------------------------------------------------
106
107
 
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
- }
108
+ // See: 'mutts/debug' for programmatic access
109
+ // buildReactivityGraph, getMutationHistory, getDependents, getDependencies, etc.
119
110
 
120
- export declare function getDependencyGraph(): ReactivityGraph;
121
- export declare function getMutationHistory(): MutationRecord[];
122
- export declare const options: {
123
- cycleHandling: 'throw' | 'warn' | 'break' | 'strict';
124
- introspection: { enableHistory: boolean; historySize: number };
111
+ export declare const reactiveOptions: {
112
+ cycleHandling: 'production' | 'development' | 'debug';
113
+ introspection: { enableHistory: boolean; historySize: number; logErrors: boolean };
125
114
  };
126
115
 
127
116
  export enum ReactiveErrorCode {
128
- CYCLE_DETECTED = 'CYCLE_DETECTED',
129
- MAX_DEPTH_EXCEEDED = 'MAX_DEPTH_EXCEEDED',
117
+ CycleDetected = 'Cycle detected',
118
+ MaxDepthExceeded = 'Max depth exceeded',
119
+ MaxReactionExceeded = 'Max reaction exceeded',
120
+ WriteInComputed = 'Write in computed',
121
+ TrackingError = 'Tracking error',
122
+ BrokenEffects = 'Broken effects',
130
123
  }
131
124
  ```