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.
- package/README.md +60 -35
- package/dist/browser.cjs +1333 -1760
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +2 -1392
- package/dist/browser.dev.cjs +114 -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 +18 -97
- package/dist/browser.esm.js.map +1 -1
- package/dist/chunks/{async-browser-lvzLOCgk.cjs → async-browser-Dgr5CreQ.cjs} +16 -95
- package/dist/chunks/async-browser-Dgr5CreQ.cjs.map +1 -0
- package/dist/chunks/{async-node-C3DeIb0y.cjs → async-node-3PrbVAbB.cjs} +3 -1
- package/dist/chunks/async-node-3PrbVAbB.cjs.map +1 -0
- package/dist/chunks/index-Sf74wXTV.esm.js +2577 -0
- package/dist/chunks/index-Sf74wXTV.esm.js.map +1 -0
- package/dist/chunks/node-Bo7WU5S2.esm.js +96 -0
- package/dist/chunks/node-Bo7WU5S2.esm.js.map +1 -0
- package/dist/chunks/{index-VTO-b2vR.cjs → proxy-Cc79Lrzj.cjs} +2593 -3216
- package/dist/chunks/proxy-Cc79Lrzj.cjs.map +1 -0
- package/dist/chunks/{index-CtA2AWl3.esm.js → proxy-D2C49sXH.esm.js} +2570 -3174
- package/dist/chunks/proxy-D2C49sXH.esm.js.map +1 -0
- package/dist/debug.cjs +987 -28
- package/dist/debug.cjs.map +1 -1
- package/dist/debug.d.ts +37 -38
- package/dist/debug.esm.js +963 -1
- package/dist/debug.esm.js.map +1 -1
- 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 +1322 -1
- package/dist/mutts.umd.js +6647 -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 +69 -63
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.dev.cjs +114 -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 -97
- package/dist/node.esm.js.map +1 -1
- package/dist/{types-DaHFfhlN.d.ts → types-Bx2PhORg.d.ts} +134 -88
- package/docs/ai/api-reference.md +11 -32
- package/docs/ai/manual.md +297 -239
- package/docs/reactive/advanced.md +318 -9
- package/docs/reactive/attend.md +2 -4
- package/docs/reactive/collections.md +22 -187
- package/docs/reactive/core.md +223 -131
- package/docs/reactive/debugging.md +119 -12
- package/docs/reactive/error-handling.md +10 -10
- package/docs/reactive/resource.md +125 -0
- package/docs/reactive.md +3 -4
- package/docs/utils.md +70 -0
- package/docs/zone.md +1 -1
- package/package.json +76 -38
- package/dist/chunks/async-browser-lvzLOCgk.cjs.map +0 -1
- package/dist/chunks/async-node-C3DeIb0y.cjs.map +0 -1
- package/dist/chunks/index-2vea86wD.esm.js +0 -3011
- package/dist/chunks/index-2vea86wD.esm.js.map +0 -1
- package/dist/chunks/index-CtA2AWl3.esm.js.map +0 -1
- package/dist/chunks/index-VTO-b2vR.cjs.map +0 -1
- package/dist/debug/debug.d.ts +0 -122
- package/dist/debug/debug.d.ts.map +0 -1
- package/dist/debug/index.d.ts +0 -4
- package/dist/debug/index.d.ts.map +0 -1
- package/dist/debug/lineage-panel.d.ts +0 -5
- package/dist/debug/lineage-panel.d.ts.map +0 -1
- package/dist/debug/lineage.d.ts +0 -79
- package/dist/debug/lineage.d.ts.map +0 -1
- package/dist/src/async/browser.d.ts +0 -2
- package/dist/src/async/browser.d.ts.map +0 -1
- package/dist/src/async/index.d.ts +0 -19
- package/dist/src/async/index.d.ts.map +0 -1
- package/dist/src/async/node.d.ts +0 -2
- package/dist/src/async/node.d.ts.map +0 -1
- package/dist/src/decorator.d.ts +0 -106
- package/dist/src/decorator.d.ts.map +0 -1
- package/dist/src/destroyable.d.ts +0 -87
- package/dist/src/destroyable.d.ts.map +0 -1
- package/dist/src/entry-browser.d.ts +0 -3
- package/dist/src/entry-browser.d.ts.map +0 -1
- package/dist/src/entry-node.d.ts +0 -3
- package/dist/src/entry-node.d.ts.map +0 -1
- package/dist/src/eventful.d.ts +0 -20
- package/dist/src/eventful.d.ts.map +0 -1
- package/dist/src/flavored.d.ts +0 -33
- package/dist/src/flavored.d.ts.map +0 -1
- package/dist/src/index.d.ts +0 -14
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/indexable.d.ts +0 -243
- package/dist/src/indexable.d.ts.map +0 -1
- package/dist/src/introspection.d.ts +0 -27
- package/dist/src/introspection.d.ts.map +0 -1
- package/dist/src/iterableWeak.d.ts +0 -53
- package/dist/src/iterableWeak.d.ts.map +0 -1
- package/dist/src/mixins.d.ts +0 -25
- package/dist/src/mixins.d.ts.map +0 -1
- package/dist/src/promiseChain.d.ts +0 -20
- package/dist/src/promiseChain.d.ts.map +0 -1
- package/dist/src/reactive/array.d.ts +0 -48
- package/dist/src/reactive/array.d.ts.map +0 -1
- package/dist/src/reactive/buffer.d.ts +0 -120
- package/dist/src/reactive/buffer.d.ts.map +0 -1
- package/dist/src/reactive/change.d.ts +0 -29
- package/dist/src/reactive/change.d.ts.map +0 -1
- package/dist/src/reactive/deep-touch.d.ts +0 -28
- package/dist/src/reactive/deep-touch.d.ts.map +0 -1
- package/dist/src/reactive/deep-watch-state.d.ts +0 -25
- package/dist/src/reactive/deep-watch-state.d.ts.map +0 -1
- package/dist/src/reactive/deep-watch.d.ts +0 -20
- package/dist/src/reactive/deep-watch.d.ts.map +0 -1
- package/dist/src/reactive/describe.d.ts +0 -12
- package/dist/src/reactive/describe.d.ts.map +0 -1
- package/dist/src/reactive/effect-context.d.ts +0 -34
- package/dist/src/reactive/effect-context.d.ts.map +0 -1
- package/dist/src/reactive/effects.d.ts +0 -164
- package/dist/src/reactive/effects.d.ts.map +0 -1
- package/dist/src/reactive/index.d.ts +0 -19
- package/dist/src/reactive/index.d.ts.map +0 -1
- package/dist/src/reactive/map.d.ts +0 -28
- package/dist/src/reactive/map.d.ts.map +0 -1
- package/dist/src/reactive/memoize.d.ts +0 -28
- package/dist/src/reactive/memoize.d.ts.map +0 -1
- package/dist/src/reactive/non-reactive-state.d.ts +0 -9
- package/dist/src/reactive/non-reactive-state.d.ts.map +0 -1
- package/dist/src/reactive/non-reactive.d.ts +0 -11
- package/dist/src/reactive/non-reactive.d.ts.map +0 -1
- package/dist/src/reactive/project.d.ts +0 -40
- package/dist/src/reactive/project.d.ts.map +0 -1
- package/dist/src/reactive/proxy-state.d.ts +0 -8
- package/dist/src/reactive/proxy-state.d.ts.map +0 -1
- package/dist/src/reactive/proxy.d.ts +0 -23
- package/dist/src/reactive/proxy.d.ts.map +0 -1
- package/dist/src/reactive/record.d.ts +0 -115
- package/dist/src/reactive/record.d.ts.map +0 -1
- package/dist/src/reactive/register.d.ts +0 -125
- package/dist/src/reactive/register.d.ts.map +0 -1
- package/dist/src/reactive/registry.d.ts +0 -21
- package/dist/src/reactive/registry.d.ts.map +0 -1
- package/dist/src/reactive/set.d.ts +0 -26
- package/dist/src/reactive/set.d.ts.map +0 -1
- package/dist/src/reactive/tracking.d.ts +0 -7
- package/dist/src/reactive/tracking.d.ts.map +0 -1
- package/dist/src/reactive/types.d.ts +0 -424
- package/dist/src/reactive/types.d.ts.map +0 -1
- package/dist/src/reactive/watch.d.ts +0 -48
- package/dist/src/reactive/watch.d.ts.map +0 -1
- package/dist/src/std-decorators.d.ts +0 -45
- package/dist/src/std-decorators.d.ts.map +0 -1
- package/dist/src/utils.d.ts +0 -49
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/zone.d.ts +0 -40
- package/dist/src/zone.d.ts.map +0 -1
- package/docs/reactive/describe.md +0 -85
- package/docs/reactive/project.md +0 -93
- package/docs/reactive/scan.md +0 -293
- package/src/async/browser.ts +0 -323
- package/src/async/index.ts +0 -27
- package/src/async/node.ts +0 -92
- 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 -110
- package/src/flavored.ts +0 -106
- 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 -500
- package/src/reactive/buffer.ts +0 -328
- package/src/reactive/change.ts +0 -131
- package/src/reactive/deep-touch.ts +0 -273
- package/src/reactive/deep-watch-state.ts +0 -82
- package/src/reactive/deep-watch.ts +0 -171
- package/src/reactive/describe.ts +0 -39
- package/src/reactive/effect-context.ts +0 -83
- package/src/reactive/effects.ts +0 -1434
- package/src/reactive/index.ts +0 -72
- package/src/reactive/map.ts +0 -142
- package/src/reactive/memoize.ts +0 -186
- package/src/reactive/non-reactive-state.ts +0 -49
- package/src/reactive/non-reactive.ts +0 -43
- package/src/reactive/project.md +0 -107
- package/src/reactive/project.ts +0 -430
- package/src/reactive/proxy-state.ts +0 -27
- package/src/reactive/proxy.ts +0 -282
- package/src/reactive/record.ts +0 -181
- package/src/reactive/register.ts +0 -538
- package/src/reactive/registry.ts +0 -72
- package/src/reactive/set.ts +0 -117
- package/src/reactive/tracking.ts +0 -41
- package/src/reactive/types.ts +0 -520
- package/src/reactive/watch.ts +0 -180
- package/src/std-decorators.ts +0 -256
- package/src/utils.ts +0 -300
- 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():
|
|
7
|
+
get zoned(): GetterWrapper;
|
|
8
8
|
}
|
|
9
|
-
type
|
|
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:
|
|
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:
|
|
86
|
+
ascend: GetterWrapper;
|
|
76
87
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
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
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
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
|
-
*
|
|
122
|
+
* Reason for an effect cleanup/reaction
|
|
101
123
|
*/
|
|
102
|
-
type
|
|
103
|
-
|
|
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
|
-
|
|
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 = "
|
|
184
|
-
MaxDepthExceeded = "
|
|
185
|
-
MaxReactionExceeded = "
|
|
186
|
-
WriteInComputed = "
|
|
187
|
-
TrackingError = "
|
|
188
|
-
BrokenEffects = "
|
|
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
|
-
|
|
198
|
-
|
|
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
|
-
|
|
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?:
|
|
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
|
-
*
|
|
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
|
-
|
|
374
|
-
|
|
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,
|
|
414
|
-
export type {
|
|
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 };
|
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;
|
|
@@ -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
|
-
|
|
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
|
-
}
|
|
94
|
+
// See: 'mutts/debug' for programmatic access
|
|
95
|
+
// buildReactivityGraph, getMutationHistory, getDependents, getDependencies, etc.
|
|
119
96
|
|
|
120
|
-
export declare
|
|
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
|
-
|
|
129
|
-
|
|
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
|
```
|