mutts 1.0.7 → 1.0.9
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.
- package/README.md +72 -17
- package/dist/browser.cjs +3111 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.ts +1391 -1
- package/dist/browser.esm.js +264 -35
- package/dist/browser.esm.js.map +1 -1
- package/dist/chunks/async-browser-lvzLOCgk.cjs +297 -0
- package/dist/chunks/async-browser-lvzLOCgk.cjs.map +1 -0
- package/dist/chunks/async-core-CRLKP3l-.cjs +29 -0
- package/dist/chunks/async-core-CRLKP3l-.cjs.map +1 -0
- package/dist/chunks/async-node-C3DeIb0y.cjs +96 -0
- package/dist/chunks/async-node-C3DeIb0y.cjs.map +1 -0
- package/dist/chunks/index-2vea86wD.esm.js +3011 -0
- package/dist/chunks/index-2vea86wD.esm.js.map +1 -0
- package/dist/chunks/index-CtA2AWl3.esm.js +4376 -0
- package/dist/chunks/index-CtA2AWl3.esm.js.map +1 -0
- package/dist/chunks/index-VTO-b2vR.cjs +4461 -0
- package/dist/chunks/index-VTO-b2vR.cjs.map +1 -0
- package/dist/debug/debug.d.ts +122 -0
- package/dist/debug/debug.d.ts.map +1 -0
- package/dist/debug/index.d.ts +4 -0
- package/dist/debug/index.d.ts.map +1 -0
- package/dist/debug/lineage-panel.d.ts +5 -0
- package/dist/debug/lineage-panel.d.ts.map +1 -0
- package/dist/debug/lineage.d.ts +79 -0
- package/dist/debug/lineage.d.ts.map +1 -0
- package/dist/debug.cjs +35 -0
- package/dist/debug.cjs.map +1 -0
- package/dist/debug.d.ts +209 -0
- package/dist/debug.esm.js +2 -0
- package/dist/debug.esm.js.map +1 -0
- package/dist/devtools/devtool/devtools.d.ts +1 -0
- package/dist/devtools/devtool/devtools.d.ts.map +1 -0
- package/dist/devtools/devtool/panel.d.ts +2 -0
- package/dist/devtools/devtool/panel.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/mutts.umd.js +1 -1
- package/dist/mutts.umd.js.map +1 -1
- package/dist/mutts.umd.min.js +1 -1
- package/dist/mutts.umd.min.js.map +1 -1
- package/dist/node.cjs +107 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.ts +2 -2
- package/dist/node.esm.js +86 -33
- package/dist/node.esm.js.map +1 -1
- package/dist/src/async/browser.d.ts +2 -0
- package/dist/src/async/browser.d.ts.map +1 -0
- package/dist/src/async/index.d.ts +19 -0
- package/dist/src/async/index.d.ts.map +1 -0
- package/dist/src/async/node.d.ts +2 -0
- package/dist/src/async/node.d.ts.map +1 -0
- package/dist/src/decorator.d.ts +106 -0
- package/dist/src/decorator.d.ts.map +1 -0
- package/dist/src/destroyable.d.ts +87 -0
- package/dist/src/destroyable.d.ts.map +1 -0
- package/dist/src/entry-browser.d.ts +3 -0
- package/dist/src/entry-browser.d.ts.map +1 -0
- package/dist/src/entry-node.d.ts +3 -0
- package/dist/src/entry-node.d.ts.map +1 -0
- package/dist/src/eventful.d.ts +20 -0
- package/dist/src/eventful.d.ts.map +1 -0
- package/dist/src/flavored.d.ts +33 -0
- package/dist/src/flavored.d.ts.map +1 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/indexable.d.ts +243 -0
- package/dist/src/indexable.d.ts.map +1 -0
- package/dist/src/introspection.d.ts +27 -0
- package/dist/src/introspection.d.ts.map +1 -0
- package/dist/src/iterableWeak.d.ts +53 -0
- package/dist/src/iterableWeak.d.ts.map +1 -0
- package/dist/src/mixins.d.ts +25 -0
- package/dist/src/mixins.d.ts.map +1 -0
- package/dist/src/promiseChain.d.ts +20 -0
- package/dist/src/promiseChain.d.ts.map +1 -0
- package/dist/src/reactive/array.d.ts +48 -0
- package/dist/src/reactive/array.d.ts.map +1 -0
- package/dist/src/reactive/buffer.d.ts +120 -0
- package/dist/src/reactive/buffer.d.ts.map +1 -0
- package/dist/src/reactive/change.d.ts +29 -0
- package/dist/src/reactive/change.d.ts.map +1 -0
- package/dist/src/reactive/deep-touch.d.ts +28 -0
- package/dist/src/reactive/deep-touch.d.ts.map +1 -0
- package/dist/src/reactive/deep-watch-state.d.ts +25 -0
- package/dist/src/reactive/deep-watch-state.d.ts.map +1 -0
- package/dist/src/reactive/deep-watch.d.ts +20 -0
- package/dist/src/reactive/deep-watch.d.ts.map +1 -0
- package/dist/src/reactive/describe.d.ts +12 -0
- package/dist/src/reactive/describe.d.ts.map +1 -0
- package/dist/src/reactive/effect-context.d.ts +34 -0
- package/dist/src/reactive/effect-context.d.ts.map +1 -0
- package/dist/src/reactive/effects.d.ts +164 -0
- package/dist/src/reactive/effects.d.ts.map +1 -0
- package/dist/src/reactive/index.d.ts +19 -0
- package/dist/src/reactive/index.d.ts.map +1 -0
- package/dist/src/reactive/map.d.ts +28 -0
- package/dist/src/reactive/map.d.ts.map +1 -0
- package/dist/src/reactive/memoize.d.ts +28 -0
- package/dist/src/reactive/memoize.d.ts.map +1 -0
- package/dist/src/reactive/non-reactive-state.d.ts +9 -0
- package/dist/src/reactive/non-reactive-state.d.ts.map +1 -0
- package/dist/src/reactive/non-reactive.d.ts +11 -0
- package/dist/src/reactive/non-reactive.d.ts.map +1 -0
- package/dist/src/reactive/project.d.ts +40 -0
- package/dist/src/reactive/project.d.ts.map +1 -0
- package/dist/src/reactive/proxy-state.d.ts +8 -0
- package/dist/src/reactive/proxy-state.d.ts.map +1 -0
- package/dist/src/reactive/proxy.d.ts +23 -0
- package/dist/src/reactive/proxy.d.ts.map +1 -0
- package/dist/src/reactive/record.d.ts +115 -0
- package/dist/src/reactive/record.d.ts.map +1 -0
- package/dist/src/reactive/register.d.ts +125 -0
- package/dist/src/reactive/register.d.ts.map +1 -0
- package/dist/src/reactive/registry.d.ts +21 -0
- package/dist/src/reactive/registry.d.ts.map +1 -0
- package/dist/src/reactive/set.d.ts +26 -0
- package/dist/src/reactive/set.d.ts.map +1 -0
- package/dist/src/reactive/tracking.d.ts +7 -0
- package/dist/src/reactive/tracking.d.ts.map +1 -0
- package/dist/src/reactive/types.d.ts +424 -0
- package/dist/src/reactive/types.d.ts.map +1 -0
- package/dist/src/reactive/watch.d.ts +48 -0
- package/dist/src/reactive/watch.d.ts.map +1 -0
- package/dist/src/std-decorators.d.ts +45 -0
- package/dist/src/std-decorators.d.ts.map +1 -0
- package/dist/src/utils.d.ts +49 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/zone.d.ts +40 -0
- package/dist/src/zone.d.ts.map +1 -0
- package/dist/types-DaHFfhlN.d.ts +414 -0
- package/docs/ai/api-reference.md +1 -1
- package/docs/ai/manual.md +443 -17
- package/docs/events.md +57 -2
- package/docs/flavored.md +210 -0
- package/docs/reactive/advanced.md +2 -3
- package/docs/reactive/attend.md +143 -0
- package/docs/reactive/collections.md +55 -0
- package/docs/reactive/core.md +120 -4
- package/docs/reactive/debugging.md +8 -10
- package/docs/reactive/describe.md +85 -0
- package/docs/reactive/error-handling.md +121 -0
- package/docs/reactive/project.md +1 -1
- package/docs/reactive/scan.md +215 -0
- package/docs/reactive.md +2 -0
- package/docs/std-decorators.md +171 -52
- package/docs/zone.md +9 -6
- package/package.json +44 -27
- package/src/async/browser.ts +277 -41
- package/src/async/index.ts +23 -4
- package/src/async/node.ts +78 -32
- package/src/entry-browser.ts +5 -0
- package/src/entry-node.ts +5 -0
- package/src/eventful.ts +82 -49
- package/src/flavored.ts +106 -0
- package/src/index.d.ts +12 -9
- package/src/index.ts +2 -1
- package/src/introspection.ts +1 -1
- package/src/reactive/array.ts +160 -80
- package/src/reactive/buffer.ts +187 -27
- package/src/reactive/change.ts +16 -23
- package/src/reactive/deep-touch.ts +19 -14
- package/src/reactive/deep-watch-state.ts +3 -3
- package/src/reactive/deep-watch.ts +7 -4
- package/src/reactive/describe.ts +39 -0
- package/src/reactive/effect-context.ts +71 -6
- package/src/reactive/effects.ts +445 -393
- package/src/reactive/index.ts +12 -14
- package/src/reactive/map.ts +8 -24
- package/src/reactive/memoize.ts +26 -3
- package/src/reactive/project.md +107 -0
- package/src/reactive/project.ts +48 -71
- package/src/reactive/proxy.ts +21 -3
- package/src/reactive/record.ts +30 -45
- package/src/reactive/register.ts +138 -19
- package/src/reactive/registry.ts +22 -9
- package/src/reactive/set.ts +7 -20
- package/src/reactive/tracking.ts +9 -12
- package/src/reactive/types.ts +104 -24
- package/src/reactive/{interface.ts → watch.ts} +29 -59
- package/src/std-decorators.ts +56 -17
- package/src/utils.ts +3 -4
- package/src/zone.ts +43 -28
- package/dist/browser.js +0 -161
- package/dist/browser.js.map +0 -1
- package/dist/chunks/index-BFYK02LG.js +0 -6378
- package/dist/chunks/index-BFYK02LG.js.map +0 -1
- package/dist/chunks/index-CNR6QRUl.esm.js +0 -6291
- package/dist/chunks/index-CNR6QRUl.esm.js.map +0 -1
- package/dist/node.js +0 -136
- package/dist/node.js.map +0 -1
- package/src/reactive/debug.ts +0 -517
|
@@ -0,0 +1,414 @@
|
|
|
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
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Effect access passed to user callbacks within effects/watch
|
|
42
|
+
* Provides functions to track dependencies and information about the effect execution
|
|
43
|
+
*/
|
|
44
|
+
interface EffectAccess {
|
|
45
|
+
/**
|
|
46
|
+
* Tracks dependencies in the current effect context
|
|
47
|
+
* Use this for normal dependency tracking within the effect
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* effect(({ tracked }) => {
|
|
51
|
+
* // In async context, use tracked to restore dependency tracking
|
|
52
|
+
* await someAsyncOperation()
|
|
53
|
+
* const value = tracked(() => state.count) // Tracks state.count in this effect
|
|
54
|
+
* })
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
tracked: FunctionWrapper;
|
|
58
|
+
/**
|
|
59
|
+
* Tracks dependencies in the parent effect context
|
|
60
|
+
* Use this when child effects should track dependencies in the parent,
|
|
61
|
+
* allowing parent cleanup to manage child effects while dependencies trigger the parent
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* effect(({ ascend }) => {
|
|
65
|
+
* const length = inputs.length
|
|
66
|
+
* if (length > 0) {
|
|
67
|
+
* ascend(() => {
|
|
68
|
+
* // Dependencies here are tracked in the parent effect
|
|
69
|
+
* inputs.forEach(item => console.log(item))
|
|
70
|
+
* })
|
|
71
|
+
* }
|
|
72
|
+
* })
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
ascend: FunctionWrapper;
|
|
76
|
+
/**
|
|
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
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* effect(({ reaction }) => {
|
|
83
|
+
* 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
|
|
89
|
+
* }
|
|
90
|
+
* })
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
reaction: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Base type for effect callbacks - simple function without additional properties
|
|
97
|
+
*/
|
|
98
|
+
type ScopedCallback = () => void;
|
|
99
|
+
/**
|
|
100
|
+
* Type for effect cleanup functions with stopped state tracking
|
|
101
|
+
*/
|
|
102
|
+
type EffectCleanup = ScopedCallback & {
|
|
103
|
+
[stopped]: boolean;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Type for the `runEffect` function of an effect - argument-less function to call to trigger the effect
|
|
107
|
+
*/
|
|
108
|
+
type EffectTrigger = ScopedCallback;
|
|
109
|
+
/**
|
|
110
|
+
* Async execution mode for effects
|
|
111
|
+
* - `cancel`: Cancel previous async execution when dependencies change (default)
|
|
112
|
+
* - `queue`: Queue next execution to run after current completes
|
|
113
|
+
* - `ignore`: Ignore new executions while async work is running
|
|
114
|
+
*/
|
|
115
|
+
type AsyncExecutionMode = 'cancel' | 'queue' | 'ignore';
|
|
116
|
+
/**
|
|
117
|
+
* Options for effect creation
|
|
118
|
+
*/
|
|
119
|
+
interface EffectOptions {
|
|
120
|
+
/**
|
|
121
|
+
* How to handle async effect executions when dependencies change
|
|
122
|
+
* @default 'cancel'
|
|
123
|
+
*/
|
|
124
|
+
asyncMode?: AsyncExecutionMode;
|
|
125
|
+
/**
|
|
126
|
+
* If true, this effect is "opaque" to deep optimizations: it sees the object reference itself
|
|
127
|
+
* and must be notified when it changes, regardless of deep content similarity.
|
|
128
|
+
* Use this for effects that depend on object identity (like memoize).
|
|
129
|
+
*/
|
|
130
|
+
opaque?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Used for debugging purpose. Provides a callback to be called every time a dependency is created.
|
|
133
|
+
*/
|
|
134
|
+
dependencyHook?: (obj: any, prop: any) => void;
|
|
135
|
+
/**
|
|
136
|
+
* Used for debugging purpose. Provides a name for the effect.
|
|
137
|
+
*/
|
|
138
|
+
name?: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Type for property evolution events
|
|
142
|
+
*/
|
|
143
|
+
type PropEvolution = {
|
|
144
|
+
type: 'set' | 'del' | 'add' | 'invalidate';
|
|
145
|
+
prop: any;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Type for collection operation evolution events
|
|
149
|
+
*/
|
|
150
|
+
type BunchEvolution = {
|
|
151
|
+
type: 'bunch';
|
|
152
|
+
method: string;
|
|
153
|
+
};
|
|
154
|
+
type Evolution = PropEvolution | BunchEvolution;
|
|
155
|
+
type State = {
|
|
156
|
+
evolution: Evolution;
|
|
157
|
+
next: State;
|
|
158
|
+
} | {};
|
|
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
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Structured error codes for machine-readable diagnosis
|
|
181
|
+
*/
|
|
182
|
+
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"
|
|
189
|
+
}
|
|
190
|
+
type CycleDebugInfo = {
|
|
191
|
+
code: ReactiveErrorCode.CycleDetected;
|
|
192
|
+
cycle: string[];
|
|
193
|
+
details?: string;
|
|
194
|
+
};
|
|
195
|
+
type MaxDepthDebugInfo = {
|
|
196
|
+
code: ReactiveErrorCode.MaxDepthExceeded;
|
|
197
|
+
depth: number;
|
|
198
|
+
chain: string[];
|
|
199
|
+
};
|
|
200
|
+
type MaxReactionDebugInfo = {
|
|
201
|
+
code: ReactiveErrorCode.MaxReactionExceeded;
|
|
202
|
+
count: number;
|
|
203
|
+
effect: string;
|
|
204
|
+
};
|
|
205
|
+
type GenericDebugInfo = {
|
|
206
|
+
code: ReactiveErrorCode;
|
|
207
|
+
causalChain?: string[];
|
|
208
|
+
creationStack?: string | any[];
|
|
209
|
+
lineage?: any[];
|
|
210
|
+
[key: string]: any;
|
|
211
|
+
};
|
|
212
|
+
type ReactiveDebugInfo = CycleDebugInfo | MaxDepthDebugInfo | MaxReactionDebugInfo | GenericDebugInfo;
|
|
213
|
+
/**
|
|
214
|
+
* Error class for reactive system errors
|
|
215
|
+
*/
|
|
216
|
+
declare class ReactiveError extends Error {
|
|
217
|
+
debugInfo?: ReactiveDebugInfo;
|
|
218
|
+
constructor(message: string, debugInfo?: ReactiveDebugInfo);
|
|
219
|
+
get code(): ReactiveErrorCode | undefined;
|
|
220
|
+
get cause(): any;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Global options for the reactive system
|
|
224
|
+
*/
|
|
225
|
+
declare const options: {
|
|
226
|
+
/**
|
|
227
|
+
* Debug purpose: called when an effect is entered
|
|
228
|
+
* @param effect - The effect that is entered
|
|
229
|
+
*/
|
|
230
|
+
enter: (_effect: Function) => void;
|
|
231
|
+
/**
|
|
232
|
+
* Debug purpose: called when an effect is left
|
|
233
|
+
* @param effect - The effect that is left
|
|
234
|
+
*/
|
|
235
|
+
leave: (_effect: Function) => void;
|
|
236
|
+
/**
|
|
237
|
+
* Debug purpose: called when an effect is chained
|
|
238
|
+
* @param target - The effect that is being triggered
|
|
239
|
+
* @param caller - The effect that is calling the target
|
|
240
|
+
*/
|
|
241
|
+
chain: (_targets: Function[], _caller?: Function) => void;
|
|
242
|
+
/**
|
|
243
|
+
* Debug purpose: called when an effect chain is started
|
|
244
|
+
* @param target - The effect that is being triggered
|
|
245
|
+
*/
|
|
246
|
+
beginChain: (_targets: Function[]) => void;
|
|
247
|
+
/**
|
|
248
|
+
* Debug purpose: called when an effect chain is ended
|
|
249
|
+
*/
|
|
250
|
+
endChain: () => void;
|
|
251
|
+
garbageCollected: (_fn: Function) => void;
|
|
252
|
+
/**
|
|
253
|
+
* Debug purpose: called when an object is touched
|
|
254
|
+
* @param obj - The object that is touched
|
|
255
|
+
* @param evolution - The type of change
|
|
256
|
+
* @param props - The properties that changed
|
|
257
|
+
* @param deps - The dependencies that changed
|
|
258
|
+
*/
|
|
259
|
+
touched: (_obj: any, _evolution: Evolution, _props?: any[], _deps?: Set<EffectTrigger>) => void;
|
|
260
|
+
/**
|
|
261
|
+
* Debug purpose: called when an effect is skipped because it's already running
|
|
262
|
+
* @param effect - The effect that is already running
|
|
263
|
+
* @param runningChain - The array of effects from the detected one to the currently running one
|
|
264
|
+
*/
|
|
265
|
+
skipRunningEffect: (_effect: EffectTrigger) => void;
|
|
266
|
+
/**
|
|
267
|
+
* Debug purpose: maximum effect chain (like call stack max depth)
|
|
268
|
+
* Used to prevent infinite loops
|
|
269
|
+
* @default 100
|
|
270
|
+
*/
|
|
271
|
+
maxEffectChain: number;
|
|
272
|
+
/**
|
|
273
|
+
* Maximum number of times an effect can be triggered by the same cause in a single batch
|
|
274
|
+
* Used to detect aggressive re-computation or infinite loops
|
|
275
|
+
* @default 10
|
|
276
|
+
*/
|
|
277
|
+
maxTriggerPerBatch: number;
|
|
278
|
+
/**
|
|
279
|
+
* Debug purpose: maximum effect reaction (like call stack max depth)
|
|
280
|
+
* Used to prevent infinite loops
|
|
281
|
+
* @default 'throw'
|
|
282
|
+
*/
|
|
283
|
+
maxEffectReaction: "throw" | "debug" | "warn";
|
|
284
|
+
/**
|
|
285
|
+
* Callback called when a memoization discrepancy is detected (debug only)
|
|
286
|
+
* When defined, memoized functions will run a second time (untracked) to verify consistency.
|
|
287
|
+
* If the untracked run returns a different value than the cached one, this callback is triggered.
|
|
288
|
+
*
|
|
289
|
+
* This is the primary tool for detecting missing reactive dependencies in computed values.
|
|
290
|
+
*
|
|
291
|
+
* @param cached - The value currently in the memoization cache
|
|
292
|
+
* @param fresh - The value obtained by re-running the function untracked
|
|
293
|
+
* @param fn - The memoized function itself
|
|
294
|
+
* @param args - Arguments passed to the function
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* reactiveOptions.onMemoizationDiscrepancy = (cached, fresh, fn, args) => {
|
|
299
|
+
* throw new Error(`Memoization discrepancy in ${fn.name}!`);
|
|
300
|
+
* };
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
onMemoizationDiscrepancy: ((cached: any, fresh: any, fn: Function, args: any[], cause: "calculation" | "comparison") => void) | undefined;
|
|
304
|
+
/**
|
|
305
|
+
* How to handle cycles detected in effect batches.
|
|
306
|
+
*
|
|
307
|
+
* - `'production'` (Default): High-performance mode. Disables dependency graph maintenance and
|
|
308
|
+
* Topological Sorting in favor of a simple FIFO queue. Use this for trustworthy, acyclic UI code.
|
|
309
|
+
* Cycle detection is heuristic (uses maxEffectChain execution counts).
|
|
310
|
+
*
|
|
311
|
+
* - `'development'`: Maintains direct dependency graph for early cycle detection during edge creation.
|
|
312
|
+
* Catches cycles before effects execute via DFS check when adding edges. Throws immediately with
|
|
313
|
+
* basic path information. Good balance of debugging help with moderate overhead.
|
|
314
|
+
*
|
|
315
|
+
* - `'debug'`: Full diagnostic mode with transitive closures and topological sorting.
|
|
316
|
+
* Provides detailed cycle path reporting. Highest overhead but most informative for bug hunting.
|
|
317
|
+
*
|
|
318
|
+
* @default 'production'
|
|
319
|
+
*/
|
|
320
|
+
cycleHandling: "production" | "development" | "debug";
|
|
321
|
+
/**
|
|
322
|
+
* Internal flag used by memoization discrepancy detector to avoid counting calls in tests
|
|
323
|
+
* @warning Do not modify this flag manually, this flag is given by the engine
|
|
324
|
+
*/
|
|
325
|
+
isVerificationRun: boolean;
|
|
326
|
+
/**
|
|
327
|
+
* Maximum depth for deep watching traversal
|
|
328
|
+
* Used to prevent infinite recursion in circular references
|
|
329
|
+
* @default 100
|
|
330
|
+
*/
|
|
331
|
+
maxDeepWatchDepth: number;
|
|
332
|
+
/**
|
|
333
|
+
* Only react on instance members modification (not inherited properties)
|
|
334
|
+
* For instance, do not track class methods
|
|
335
|
+
* @default true
|
|
336
|
+
*/
|
|
337
|
+
instanceMembers: boolean;
|
|
338
|
+
/**
|
|
339
|
+
* Ignore accessors (getters and setters) and only track direct properties
|
|
340
|
+
* @default true
|
|
341
|
+
*/
|
|
342
|
+
ignoreAccessors: boolean;
|
|
343
|
+
/**
|
|
344
|
+
* Enable recursive touching when objects with the same prototype are replaced
|
|
345
|
+
* When enabled, replacing an object with another of the same prototype triggers
|
|
346
|
+
* recursive diffing instead of notifying parent effects
|
|
347
|
+
* @default true
|
|
348
|
+
*/
|
|
349
|
+
recursiveTouching: boolean;
|
|
350
|
+
/**
|
|
351
|
+
* Default async execution mode for effects that return Promises
|
|
352
|
+
* - 'cancel': Cancel previous async execution when dependencies change (default, enables async zone)
|
|
353
|
+
* - 'queue': Queue next execution to run after current completes (enables async zone)
|
|
354
|
+
* - 'ignore': Ignore new executions while async work is running (enables async zone)
|
|
355
|
+
* - false: Disable async zone and async mode handling (effects run concurrently)
|
|
356
|
+
*
|
|
357
|
+
* **When truthy:** Enables async zone (Promise.prototype wrapping) for automatic context
|
|
358
|
+
* preservation in Promise callbacks. Warning: This modifies Promise.prototype globally.
|
|
359
|
+
* Only enable if no other library modifies Promise.prototype.
|
|
360
|
+
*
|
|
361
|
+
* **When false:** Async zone is disabled. Use `tracked()` manually in Promise callbacks.
|
|
362
|
+
*
|
|
363
|
+
* Can be overridden per-effect via EffectOptions
|
|
364
|
+
* @default 'cancel'
|
|
365
|
+
*/
|
|
366
|
+
asyncMode: AsyncExecutionMode | false;
|
|
367
|
+
warn: (...args: any[]) => void;
|
|
368
|
+
/**
|
|
369
|
+
* Configuration for the introspection system
|
|
370
|
+
*/
|
|
371
|
+
introspection: {
|
|
372
|
+
/**
|
|
373
|
+
* Whether to keep a history of mutations for debugging
|
|
374
|
+
* @default false
|
|
375
|
+
*/
|
|
376
|
+
enableHistory: boolean;
|
|
377
|
+
/**
|
|
378
|
+
* Number of mutations to keep in history
|
|
379
|
+
* @default 50
|
|
380
|
+
*/
|
|
381
|
+
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
|
+
};
|
|
411
|
+
};
|
|
412
|
+
|
|
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 };
|
package/docs/ai/api-reference.md
CHANGED
|
@@ -120,7 +120,7 @@ export interface MutationRecord {
|
|
|
120
120
|
export declare function getDependencyGraph(): ReactivityGraph;
|
|
121
121
|
export declare function getMutationHistory(): MutationRecord[];
|
|
122
122
|
export declare const options: {
|
|
123
|
-
cycleHandling: '
|
|
123
|
+
cycleHandling: 'production' | 'development' | 'debug';
|
|
124
124
|
introspection: { enableHistory: boolean; historySize: number };
|
|
125
125
|
};
|
|
126
126
|
|