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.
- package/README.md +77 -35
- package/dist/browser.cjs +2144 -5355
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +2 -1655
- package/dist/browser.dev.cjs +110 -0
- package/dist/browser.dev.cjs.map +1 -0
- package/dist/browser.dev.d.ts +2 -0
- package/dist/browser.dev.esm.js +5 -0
- package/dist/browser.dev.esm.js.map +1 -0
- package/dist/browser.esm.js +20 -107
- package/dist/browser.esm.js.map +1 -1
- package/dist/chunks/{async-browser-CA0jPWIi.cjs → async-browser-BU_IfxYD.cjs} +19 -107
- package/dist/chunks/async-browser-BU_IfxYD.cjs.map +1 -0
- package/dist/chunks/{async-core-UqHzvJ-S.cjs → async-core-CRLKP3l-.cjs} +8 -4
- package/dist/chunks/async-core-CRLKP3l-.cjs.map +1 -0
- package/dist/chunks/{async-node-BYHuGTni.cjs → async-node-3PrbVAbB.cjs} +7 -12
- package/dist/chunks/async-node-3PrbVAbB.cjs.map +1 -0
- package/dist/chunks/index-CaaQQlPJ.esm.js +3174 -0
- package/dist/chunks/index-CaaQQlPJ.esm.js.map +1 -0
- package/dist/chunks/node-nKJBk8iJ.esm.js +96 -0
- package/dist/chunks/node-nKJBk8iJ.esm.js.map +1 -0
- package/dist/chunks/proxy-Dtg-bJ3T.cjs +3763 -0
- package/dist/chunks/proxy-Dtg-bJ3T.cjs.map +1 -0
- package/dist/chunks/proxy-r7lARftl.esm.js +3701 -0
- package/dist/chunks/proxy-r7lARftl.esm.js.map +1 -0
- package/dist/debug.cjs +980 -0
- package/dist/debug.cjs.map +1 -0
- package/dist/debug.d.ts +208 -0
- package/dist/debug.esm.js +950 -0
- package/dist/debug.esm.js.map +1 -0
- package/dist/devtools/manifest.json +1 -1
- package/dist/devtools/panel.html +1 -1
- package/dist/devtools/panel.js +107 -94
- package/dist/devtools/panel.js.map +1 -1
- package/dist/index.d.ts +1447 -13
- package/dist/mutts.umd.js +7167 -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 +70 -66
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +2 -1
- package/dist/node.dev.cjs +110 -0
- package/dist/node.dev.cjs.map +1 -0
- package/dist/node.dev.d.ts +2 -0
- package/dist/node.dev.esm.js +6 -0
- package/dist/node.dev.esm.js.map +1 -0
- package/dist/node.esm.js +4 -103
- package/dist/node.esm.js.map +1 -1
- package/dist/{reactive/types.d.ts → types-W5vD6m2n.d.ts} +186 -93
- package/docs/ai/api-reference.md +12 -19
- package/docs/ai/manual.md +521 -17
- package/docs/events.md +57 -2
- package/docs/flavored.md +210 -0
- package/docs/reactive/advanced.md +314 -5
- package/docs/reactive/attend.md +142 -0
- package/docs/reactive/collections.md +76 -39
- package/docs/reactive/core.md +100 -14
- package/docs/reactive/debugging.md +123 -18
- package/docs/reactive/error-handling.md +121 -0
- package/docs/reactive/resource.md +125 -0
- package/docs/reactive/scan.md +247 -1
- package/docs/reactive.md +4 -1
- package/docs/std-decorators.md +102 -51
- package/docs/utils.md +70 -0
- package/docs/zone.md +3 -7
- package/package.json +64 -30
- package/dist/async/browser.d.ts +0 -2
- package/dist/async/browser.d.ts.map +0 -1
- package/dist/async/index.d.ts +0 -18
- package/dist/async/index.d.ts.map +0 -1
- package/dist/async/node.d.ts +0 -2
- package/dist/async/node.d.ts.map +0 -1
- package/dist/chunks/async-browser-CA0jPWIi.cjs.map +0 -1
- package/dist/chunks/async-core-UqHzvJ-S.cjs.map +0 -1
- package/dist/chunks/async-node-BYHuGTni.cjs.map +0 -1
- package/dist/chunks/index-DhaOVusv.esm.js +0 -6411
- package/dist/chunks/index-DhaOVusv.esm.js.map +0 -1
- package/dist/decorator.d.ts +0 -106
- package/dist/decorator.d.ts.map +0 -1
- package/dist/destroyable.d.ts +0 -87
- package/dist/destroyable.d.ts.map +0 -1
- package/dist/entry-browser.d.ts +0 -3
- package/dist/entry-browser.d.ts.map +0 -1
- package/dist/entry-node.d.ts +0 -3
- package/dist/entry-node.d.ts.map +0 -1
- package/dist/eventful.d.ts +0 -18
- package/dist/eventful.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/indexable.d.ts +0 -243
- package/dist/indexable.d.ts.map +0 -1
- package/dist/introspection.d.ts +0 -27
- package/dist/introspection.d.ts.map +0 -1
- package/dist/iterableWeak.d.ts +0 -53
- package/dist/iterableWeak.d.ts.map +0 -1
- package/dist/mixins.d.ts +0 -25
- package/dist/mixins.d.ts.map +0 -1
- package/dist/promiseChain.d.ts +0 -20
- package/dist/promiseChain.d.ts.map +0 -1
- package/dist/reactive/array.d.ts +0 -49
- package/dist/reactive/array.d.ts.map +0 -1
- package/dist/reactive/buffer.d.ts +0 -44
- package/dist/reactive/buffer.d.ts.map +0 -1
- package/dist/reactive/change.d.ts +0 -29
- package/dist/reactive/change.d.ts.map +0 -1
- package/dist/reactive/debug.d.ts +0 -111
- package/dist/reactive/debug.d.ts.map +0 -1
- package/dist/reactive/deep-touch.d.ts +0 -28
- package/dist/reactive/deep-touch.d.ts.map +0 -1
- package/dist/reactive/deep-watch-state.d.ts +0 -25
- package/dist/reactive/deep-watch-state.d.ts.map +0 -1
- package/dist/reactive/deep-watch.d.ts +0 -19
- package/dist/reactive/deep-watch.d.ts.map +0 -1
- package/dist/reactive/effect-context.d.ts +0 -7
- package/dist/reactive/effect-context.d.ts.map +0 -1
- package/dist/reactive/effects.d.ts +0 -151
- package/dist/reactive/effects.d.ts.map +0 -1
- package/dist/reactive/index.d.ts +0 -20
- package/dist/reactive/index.d.ts.map +0 -1
- package/dist/reactive/interface.d.ts +0 -64
- package/dist/reactive/interface.d.ts.map +0 -1
- package/dist/reactive/map.d.ts +0 -30
- package/dist/reactive/map.d.ts.map +0 -1
- package/dist/reactive/memoize.d.ts +0 -5
- package/dist/reactive/memoize.d.ts.map +0 -1
- package/dist/reactive/non-reactive-state.d.ts +0 -9
- package/dist/reactive/non-reactive-state.d.ts.map +0 -1
- package/dist/reactive/non-reactive.d.ts +0 -11
- package/dist/reactive/non-reactive.d.ts.map +0 -1
- package/dist/reactive/project.d.ts +0 -41
- package/dist/reactive/project.d.ts.map +0 -1
- package/dist/reactive/proxy-state.d.ts +0 -8
- package/dist/reactive/proxy-state.d.ts.map +0 -1
- package/dist/reactive/proxy.d.ts +0 -23
- package/dist/reactive/proxy.d.ts.map +0 -1
- package/dist/reactive/record.d.ts +0 -116
- package/dist/reactive/record.d.ts.map +0 -1
- package/dist/reactive/register.d.ts +0 -64
- package/dist/reactive/register.d.ts.map +0 -1
- package/dist/reactive/registry.d.ts +0 -20
- package/dist/reactive/registry.d.ts.map +0 -1
- package/dist/reactive/set.d.ts +0 -28
- package/dist/reactive/set.d.ts.map +0 -1
- package/dist/reactive/tracking.d.ts +0 -7
- package/dist/reactive/tracking.d.ts.map +0 -1
- package/dist/reactive/types.d.ts.map +0 -1
- package/dist/std-decorators.d.ts +0 -50
- package/dist/std-decorators.d.ts.map +0 -1
- package/dist/utils.d.ts +0 -49
- package/dist/utils.d.ts.map +0 -1
- package/dist/zone.d.ts +0 -40
- package/dist/zone.d.ts.map +0 -1
- package/docs/reactive/project.md +0 -93
- package/src/async/browser.ts +0 -319
- package/src/async/index.ts +0 -23
- package/src/async/node.ts +0 -104
- package/src/decorator.ts +0 -272
- package/src/destroyable.ts +0 -199
- package/src/entry-browser.ts +0 -5
- package/src/entry-node.ts +0 -5
- package/src/eventful.ts +0 -77
- package/src/index.d.ts +0 -12
- package/src/index.ts +0 -64
- package/src/indexable.ts +0 -526
- package/src/introspection.ts +0 -59
- package/src/iterableWeak.ts +0 -233
- package/src/mixins.ts +0 -123
- package/src/promiseChain.ts +0 -110
- package/src/reactive/array.ts +0 -507
- package/src/reactive/buffer.ts +0 -168
- package/src/reactive/change.ts +0 -138
- package/src/reactive/debug.ts +0 -517
- package/src/reactive/deep-touch.ts +0 -268
- package/src/reactive/deep-watch-state.ts +0 -82
- package/src/reactive/deep-watch.ts +0 -168
- package/src/reactive/effect-context.ts +0 -18
- package/src/reactive/effects.ts +0 -1382
- package/src/reactive/index.ts +0 -75
- package/src/reactive/interface.ts +0 -210
- package/src/reactive/map.ts +0 -158
- package/src/reactive/memoize.ts +0 -163
- package/src/reactive/non-reactive-state.ts +0 -49
- package/src/reactive/non-reactive.ts +0 -43
- package/src/reactive/project.ts +0 -453
- package/src/reactive/proxy-state.ts +0 -27
- package/src/reactive/proxy.ts +0 -264
- package/src/reactive/record.ts +0 -196
- package/src/reactive/register.ts +0 -419
- package/src/reactive/registry.ts +0 -59
- package/src/reactive/set.ts +0 -130
- package/src/reactive/tracking.ts +0 -44
- package/src/reactive/types.ts +0 -440
- package/src/std-decorators.ts +0 -217
- package/src/utils.ts +0 -301
- package/src/zone.ts +0 -138
|
@@ -1,9 +1,47 @@
|
|
|
1
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
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
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
157
|
+
type AsyncExecutionMode = 'cancel' | 'queue' | 'ignore';
|
|
68
158
|
/**
|
|
69
159
|
* Options for effect creation
|
|
70
160
|
*/
|
|
71
|
-
|
|
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
|
-
|
|
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
|
-
|
|
192
|
+
type BunchEvolution = {
|
|
95
193
|
type: 'bunch';
|
|
96
194
|
method: string;
|
|
97
195
|
};
|
|
98
|
-
|
|
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
|
-
|
|
204
|
+
declare const stopped: unique symbol;
|
|
124
205
|
/**
|
|
125
206
|
* Symbol to access effect cleanup function
|
|
126
207
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
143
|
-
CycleDetected = "
|
|
144
|
-
MaxDepthExceeded = "
|
|
145
|
-
MaxReactionExceeded = "
|
|
146
|
-
WriteInComputed = "
|
|
147
|
-
TrackingError = "
|
|
148
|
-
BrokenEffects = "
|
|
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
|
-
|
|
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
|
-
|
|
229
|
+
type MaxDepthDebugInfo = {
|
|
156
230
|
code: ReactiveErrorCode.MaxDepthExceeded;
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
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
|
-
|
|
166
|
-
code: ReactiveErrorCode.BrokenEffects;
|
|
167
|
-
cause: any;
|
|
168
|
-
};
|
|
169
|
-
export type GenericDebugInfo = {
|
|
247
|
+
type GenericDebugInfo = {
|
|
170
248
|
code: ReactiveErrorCode;
|
|
171
249
|
causalChain?: string[];
|
|
172
|
-
|
|
250
|
+
lineage?: unknown;
|
|
173
251
|
[key: string]: any;
|
|
174
252
|
};
|
|
175
|
-
|
|
253
|
+
type ReactiveDebugInfo = CycleDebugInfo | MaxDepthDebugInfo | MaxReactionDebugInfo | GenericDebugInfo;
|
|
176
254
|
/**
|
|
177
255
|
* Error class for reactive system errors
|
|
178
256
|
*/
|
|
179
|
-
|
|
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
|
-
|
|
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?:
|
|
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:
|
|
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
|
-
* - `'
|
|
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
|
-
* - `'
|
|
275
|
-
*
|
|
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
|
-
* - `'
|
|
278
|
-
*
|
|
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 '
|
|
359
|
+
* @default 'production'
|
|
282
360
|
*/
|
|
283
|
-
cycleHandling: "
|
|
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
|
-
*
|
|
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
|
-
|
|
337
|
-
|
|
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
|
-
|
|
376
|
-
|
|
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 };
|
package/docs/ai/api-reference.md
CHANGED
|
@@ -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
|
-
|
|
108
|
-
|
|
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
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
129
|
-
|
|
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
|
```
|