mutts 1.0.2 → 1.0.4
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 +14 -6
- package/dist/chunks/{_tslib-C-cuVLvZ.js → _tslib-BgjropY9.js} +9 -1
- package/dist/chunks/_tslib-BgjropY9.js.map +1 -0
- package/dist/chunks/{_tslib-CMEnd0VE.esm.js → _tslib-Mzh1rNsX.esm.js} +9 -2
- package/dist/chunks/_tslib-Mzh1rNsX.esm.js.map +1 -0
- package/dist/chunks/{decorator-D4DU97Zg.js → decorator-DLvrD0UF.js} +42 -19
- package/dist/chunks/decorator-DLvrD0UF.js.map +1 -0
- package/dist/chunks/{decorator-GnHw1Az7.esm.js → decorator-DqiszP7i.esm.js} +42 -19
- package/dist/chunks/decorator-DqiszP7i.esm.js.map +1 -0
- package/dist/chunks/index-79Kk8D6e.esm.js +4857 -0
- package/dist/chunks/index-79Kk8D6e.esm.js.map +1 -0
- package/dist/chunks/index-GRBSx0mB.js +4908 -0
- package/dist/chunks/index-GRBSx0mB.js.map +1 -0
- package/dist/decorator.esm.js +1 -1
- package/dist/decorator.js +1 -1
- package/dist/destroyable.d.ts +1 -1
- package/dist/destroyable.esm.js +1 -1
- package/dist/destroyable.esm.js.map +1 -1
- package/dist/destroyable.js +1 -1
- package/dist/destroyable.js.map +1 -1
- package/dist/devtools/devtools.html +9 -0
- package/dist/devtools/devtools.js +5 -0
- package/dist/devtools/devtools.js.map +1 -0
- package/dist/devtools/manifest.json +8 -0
- package/dist/devtools/panel.css +72 -0
- package/dist/devtools/panel.html +31 -0
- package/dist/devtools/panel.js +13048 -0
- package/dist/devtools/panel.js.map +1 -0
- package/dist/eventful.esm.js +1 -1
- package/dist/eventful.js +1 -1
- package/dist/index.d.ts +18 -63
- package/dist/index.esm.js +4 -4
- package/dist/index.js +37 -11
- package/dist/index.js.map +1 -1
- package/dist/indexable.d.ts +187 -1
- package/dist/indexable.esm.js +197 -3
- package/dist/indexable.esm.js.map +1 -1
- package/dist/indexable.js +198 -2
- package/dist/indexable.js.map +1 -1
- 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/promiseChain.esm.js.map +1 -1
- package/dist/promiseChain.js.map +1 -1
- package/dist/reactive.d.ts +602 -97
- package/dist/reactive.esm.js +3 -3
- package/dist/reactive.js +32 -10
- package/dist/reactive.js.map +1 -1
- package/dist/std-decorators.esm.js +1 -1
- package/dist/std-decorators.js +1 -1
- package/docs/ai/api-reference.md +133 -0
- package/docs/ai/manual.md +105 -0
- package/docs/iterableWeak.md +646 -0
- package/docs/reactive/advanced.md +1280 -0
- package/docs/reactive/collections.md +767 -0
- package/docs/reactive/core.md +973 -0
- package/docs/reactive.md +21 -9545
- package/package.json +18 -5
- package/src/decorator.ts +266 -0
- package/src/destroyable.ts +199 -0
- package/src/eventful.ts +77 -0
- package/src/index.d.ts +9 -0
- package/src/index.ts +9 -0
- package/src/indexable.ts +484 -0
- package/src/introspection.ts +59 -0
- package/src/iterableWeak.ts +233 -0
- package/src/mixins.ts +123 -0
- package/src/promiseChain.ts +110 -0
- package/src/reactive/array.ts +414 -0
- package/src/reactive/change.ts +134 -0
- package/src/reactive/debug.ts +517 -0
- package/src/reactive/deep-touch.ts +268 -0
- package/src/reactive/deep-watch-state.ts +82 -0
- package/src/reactive/deep-watch.ts +168 -0
- package/src/reactive/effect-context.ts +94 -0
- package/src/reactive/effects.ts +1345 -0
- package/src/reactive/index.ts +76 -0
- package/src/reactive/interface.ts +223 -0
- package/src/reactive/map.ts +171 -0
- package/src/reactive/mapped.ts +130 -0
- package/src/reactive/memoize.ts +107 -0
- package/src/reactive/non-reactive-state.ts +49 -0
- package/src/reactive/non-reactive.ts +43 -0
- package/src/reactive/project.project.md +93 -0
- package/src/reactive/project.ts +335 -0
- package/src/reactive/proxy-state.ts +27 -0
- package/src/reactive/proxy.ts +289 -0
- package/src/reactive/record.ts +196 -0
- package/src/reactive/register.ts +421 -0
- package/src/reactive/set.ts +144 -0
- package/src/reactive/tracking.ts +101 -0
- package/src/reactive/types.ts +358 -0
- package/src/reactive/zone.ts +208 -0
- package/src/std-decorators.ts +217 -0
- package/src/utils.ts +117 -0
- package/dist/chunks/_tslib-C-cuVLvZ.js.map +0 -1
- package/dist/chunks/_tslib-CMEnd0VE.esm.js.map +0 -1
- package/dist/chunks/decorator-D4DU97Zg.js.map +0 -1
- package/dist/chunks/decorator-GnHw1Az7.esm.js.map +0 -1
- package/dist/chunks/index-DBScoeCX.esm.js +0 -1960
- package/dist/chunks/index-DBScoeCX.esm.js.map +0 -1
- package/dist/chunks/index-DOTmXL89.js +0 -1983
- package/dist/chunks/index-DOTmXL89.js.map +0 -1
package/dist/reactive.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import './chunks/decorator-
|
|
3
|
-
import './chunks/_tslib-CMEnd0VE.esm.js';
|
|
1
|
+
export { M as ReactiveBase, V as ReactiveError, R as ReadOnlyError, S as Register, j as addBatchCleanup, k as atomic, l as batch, n as biDi, c as buildReactivityGraph, y as cleanedBy, z as cleanup, h as deepWatch, o as defer, A as derived, q as effect, e as enableDevTools, u as getActiveEffect, g as getState, G as immutables, i as isDevtoolsEnabled, H as isNonReactive, L as isReactive, W as isZoneEnabled, D as mapped, F as memoize, P as organize, Q as organized, p as profileInfo, K as project, N as reactive, U as reactiveOptions, E as reduced, T as register, r as registerEffectForDebug, J as registerNativeReactivity, d as registerObjectForDebug, v as root, s as setEffectName, f as setObjectName, X as setZoneEnabled, t as touched, b as touched1, w as trackEffect, B as unreactive, x as untracked, O as unwrap, C as watch } from './chunks/index-79Kk8D6e.esm.js';
|
|
2
|
+
import './chunks/decorator-DqiszP7i.esm.js';
|
|
4
3
|
import './indexable.esm.js';
|
|
4
|
+
import './chunks/_tslib-Mzh1rNsX.esm.js';
|
|
5
5
|
//# sourceMappingURL=reactive.esm.js.map
|
package/dist/reactive.js
CHANGED
|
@@ -1,32 +1,54 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var reactive = require('./chunks/index-
|
|
4
|
-
require('./chunks/decorator-
|
|
5
|
-
require('./chunks/_tslib-C-cuVLvZ.js');
|
|
3
|
+
var reactive = require('./chunks/index-GRBSx0mB.js');
|
|
4
|
+
require('./chunks/decorator-DLvrD0UF.js');
|
|
6
5
|
require('./indexable.js');
|
|
6
|
+
require('./chunks/_tslib-BgjropY9.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
exports.Reactive = reactive.Reactive;
|
|
11
10
|
exports.ReactiveBase = reactive.ReactiveBase;
|
|
12
11
|
exports.ReactiveError = reactive.ReactiveError;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
get: function () { return reactive.activeEffect; }
|
|
16
|
-
});
|
|
12
|
+
exports.ReadOnlyError = reactive.ReadOnlyError;
|
|
13
|
+
exports.Register = reactive.Register;
|
|
17
14
|
exports.addBatchCleanup = reactive.addBatchCleanup;
|
|
18
15
|
exports.atomic = reactive.atomic;
|
|
16
|
+
exports.batch = reactive.batch;
|
|
17
|
+
exports.biDi = reactive.biDi;
|
|
18
|
+
exports.buildReactivityGraph = reactive.buildReactivityGraph;
|
|
19
19
|
exports.cleanedBy = reactive.cleanedBy;
|
|
20
|
-
exports.
|
|
20
|
+
exports.cleanup = reactive.cleanup;
|
|
21
|
+
exports.deepWatch = reactive.deepWatch;
|
|
22
|
+
exports.defer = reactive.defer;
|
|
23
|
+
exports.derived = reactive.derived;
|
|
21
24
|
exports.effect = reactive.effect;
|
|
25
|
+
exports.enableDevTools = reactive.enableDevTools;
|
|
26
|
+
exports.getActiveEffect = reactive.getActiveEffect;
|
|
22
27
|
exports.getState = reactive.getState;
|
|
23
28
|
exports.immutables = reactive.immutables;
|
|
24
|
-
exports.
|
|
29
|
+
exports.isDevtoolsEnabled = reactive.isDevtoolsEnabled;
|
|
25
30
|
exports.isNonReactive = reactive.isNonReactive;
|
|
26
31
|
exports.isReactive = reactive.isReactive;
|
|
32
|
+
exports.isZoneEnabled = reactive.isZoneEnabled;
|
|
33
|
+
exports.mapped = reactive.mapped;
|
|
34
|
+
exports.memoize = reactive.memoize;
|
|
35
|
+
exports.organize = reactive.organize;
|
|
36
|
+
exports.organized = reactive.organized;
|
|
27
37
|
exports.profileInfo = reactive.profileInfo;
|
|
38
|
+
exports.project = reactive.project;
|
|
28
39
|
exports.reactive = reactive.reactive;
|
|
29
40
|
exports.reactiveOptions = reactive.options;
|
|
41
|
+
exports.reduced = reactive.reduced;
|
|
42
|
+
exports.register = reactive.register;
|
|
43
|
+
exports.registerEffectForDebug = reactive.registerEffectForDebug;
|
|
44
|
+
exports.registerNativeReactivity = reactive.registerNativeReactivity;
|
|
45
|
+
exports.registerObjectForDebug = reactive.registerObjectForDebug;
|
|
46
|
+
exports.root = reactive.root;
|
|
47
|
+
exports.setEffectName = reactive.setEffectName;
|
|
48
|
+
exports.setObjectName = reactive.setObjectName;
|
|
49
|
+
exports.setZoneEnabled = reactive.setZoneEnabled;
|
|
50
|
+
exports.touched = reactive.touched;
|
|
51
|
+
exports.touched1 = reactive.touched1;
|
|
30
52
|
exports.trackEffect = reactive.trackEffect;
|
|
31
53
|
exports.unreactive = reactive.unreactive;
|
|
32
54
|
exports.untracked = reactive.untracked;
|
package/dist/reactive.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactive.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reactive.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/std-decorators.js
CHANGED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Mutts API Context
|
|
2
|
+
|
|
3
|
+
This file contains the aggregated type definitions for the Mutts library.
|
|
4
|
+
AI Agents should read this code block to understand correct function signatures and types.
|
|
5
|
+
|
|
6
|
+
```typescript
|
|
7
|
+
/**
|
|
8
|
+
* MUTTS API CONTEXT FILE
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// --------------------------------------------------------------------------------
|
|
12
|
+
// CORE REACTIVITY
|
|
13
|
+
// --------------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
export declare const Effect: unique symbol;
|
|
16
|
+
export declare const cleanup: unique symbol;
|
|
17
|
+
export declare const getAt: unique symbol;
|
|
18
|
+
export declare const setAt: unique symbol;
|
|
19
|
+
/**
|
|
20
|
+
* Symbol to check if an object is reactive
|
|
21
|
+
*/
|
|
22
|
+
export declare const Reactive: unique symbol;
|
|
23
|
+
/**
|
|
24
|
+
* Symbol to map back from a reactive proxy to its original target
|
|
25
|
+
*/
|
|
26
|
+
export declare const Raw: unique symbol;
|
|
27
|
+
export type ScopedCallback = (() => void | (() => void)) & {
|
|
28
|
+
[cleanup]?: () => void;
|
|
29
|
+
};
|
|
30
|
+
export type DependencyFunction = <T>(fn: () => T) => T;
|
|
31
|
+
export type DependencyAccess = {
|
|
32
|
+
tracked: DependencyFunction;
|
|
33
|
+
ascend: DependencyFunction;
|
|
34
|
+
reaction: boolean;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export declare function reactive<T extends object>(target: T): T;
|
|
38
|
+
export declare function effect(fn: (access: DependencyAccess, ...args: any[]) => (ScopedCallback | undefined | void), ...args: any[]): ScopedCallback;
|
|
39
|
+
export declare function unwrap<T>(obj: T): T;
|
|
40
|
+
export declare function isReactive(obj: any): boolean;
|
|
41
|
+
export declare function isNonReactive(obj: any): boolean;
|
|
42
|
+
export declare function untracked<T>(fn: () => T): T;
|
|
43
|
+
|
|
44
|
+
// --------------------------------------------------------------------------------
|
|
45
|
+
// REACTIVE HELPERS
|
|
46
|
+
// --------------------------------------------------------------------------------
|
|
47
|
+
|
|
48
|
+
export declare function atomic<T extends (...args: any[]) => any>(fn: T): T;
|
|
49
|
+
export declare function memoize<Result, Args extends any[]>(fn: (...args: Args) => Result, maxArgs?: number): (...args: Args) => Result;
|
|
50
|
+
export declare function deepWatch(source: any, callback: (path: string[], value: any) => void): () => void;
|
|
51
|
+
export declare function biDi<T>(target: (val: T) => void, source: { get: () => T, set: (v: T) => void }): (val: T) => void;
|
|
52
|
+
|
|
53
|
+
// --------------------------------------------------------------------------------
|
|
54
|
+
// COLLECTIONS
|
|
55
|
+
// --------------------------------------------------------------------------------
|
|
56
|
+
|
|
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
|
+
export declare function mapped<T, U>(inputs: readonly T[], compute: (input: T, index: number, output: U[]) => U): readonly U[];
|
|
72
|
+
export declare function reduced<T, U, R extends object = any>(inputs: readonly T[], compute: (input: T, factor: R) => readonly U[]): readonly U[];
|
|
73
|
+
export declare function project<S, R>(source: S, apply: (access: any, target: any) => any): R;
|
|
74
|
+
export declare function organized<S, T>(source: S, apply: (access: any, target: T) => any, baseTarget?: T): T;
|
|
75
|
+
|
|
76
|
+
// --------------------------------------------------------------------------------
|
|
77
|
+
// DESTROYABLE
|
|
78
|
+
// --------------------------------------------------------------------------------
|
|
79
|
+
|
|
80
|
+
export declare const destructor: unique symbol;
|
|
81
|
+
export declare const allocated: unique symbol;
|
|
82
|
+
export declare function Destroyable<T>(base?: T): any;
|
|
83
|
+
export declare class DestructionError extends Error {}
|
|
84
|
+
|
|
85
|
+
// --------------------------------------------------------------------------------
|
|
86
|
+
// EVENTS
|
|
87
|
+
// --------------------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
export interface EventfulMixin {
|
|
90
|
+
on(event: string, callback: Function): void;
|
|
91
|
+
off(event: string, callback: Function): void;
|
|
92
|
+
emit(event: string, ...args: any[]): void;
|
|
93
|
+
}
|
|
94
|
+
export declare function Eventful<T extends new (...args: any[]) => any>(Base: T): T & (new (...args: any[]) => EventfulMixin);
|
|
95
|
+
|
|
96
|
+
// --------------------------------------------------------------------------------
|
|
97
|
+
// DECORATORS
|
|
98
|
+
// --------------------------------------------------------------------------------
|
|
99
|
+
|
|
100
|
+
export declare function cached(target: any, key: string, descriptor: PropertyDescriptor): void;
|
|
101
|
+
export declare function debounce(delay: number): Function;
|
|
102
|
+
export declare function throttle(delay: number): Function;
|
|
103
|
+
export declare function deprecated(message?: string): Function;
|
|
104
|
+
|
|
105
|
+
// --------------------------------------------------------------------------------
|
|
106
|
+
// INTROSPECTION (AI Debugging)
|
|
107
|
+
// --------------------------------------------------------------------------------
|
|
108
|
+
|
|
109
|
+
export interface ReactivityGraph {
|
|
110
|
+
nodes: { id: string, label: string, type: 'effect'|'object' }[];
|
|
111
|
+
edges: { source: string, target: string, type: string }[];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface MutationRecord {
|
|
115
|
+
type: 'set' | 'add' | 'delete';
|
|
116
|
+
prop: PropertyKey;
|
|
117
|
+
oldValue: any;
|
|
118
|
+
newValue: any;
|
|
119
|
+
objectName?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export declare function getDependencyGraph(): ReactivityGraph;
|
|
123
|
+
export declare function getMutationHistory(): MutationRecord[];
|
|
124
|
+
export declare const options: {
|
|
125
|
+
cycleHandling: 'throw' | 'warn' | 'break' | 'strict';
|
|
126
|
+
introspection: { enableHistory: boolean; historySize: number };
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export enum ReactiveErrorCode {
|
|
130
|
+
CYCLE_DETECTED = 'CYCLE_DETECTED',
|
|
131
|
+
MAX_DEPTH_EXCEEDED = 'MAX_DEPTH_EXCEEDED',
|
|
132
|
+
}
|
|
133
|
+
```
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Mutts AI Agent Manual
|
|
2
|
+
|
|
3
|
+
> [!IMPORTANT]
|
|
4
|
+
> **Identity**: You are an AI Agent. This document is written for **YOU**.
|
|
5
|
+
> **Purpose**: This file defines the protocols, schemas, and capabilities available to you when working with the `mutts` reactivity system.
|
|
6
|
+
>
|
|
7
|
+
> For exact TypeScript signatures of the entire library, consult the **[API Reference for Agents](./api-reference.md)**.
|
|
8
|
+
|
|
9
|
+
## 1. Introspection Capability
|
|
10
|
+
When you encounter reactivity bugs (infinite loops, unexpected updates), **DO NOT GUESS**. Use the introspection API to "see" the system state.
|
|
11
|
+
|
|
12
|
+
### Enabling Introspection
|
|
13
|
+
Introspection is often disabled by default for performance. Enable it before debugging.
|
|
14
|
+
```typescript
|
|
15
|
+
import { enableIntrospection, options } from 'mutts/introspection'
|
|
16
|
+
|
|
17
|
+
// Enable history tracking (memory expensive, use only for debugging)
|
|
18
|
+
enableIntrospection({ historySize: 50 })
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Dependency Graph
|
|
22
|
+
Understanding "Who depends on What".
|
|
23
|
+
```typescript
|
|
24
|
+
import { getDependencyGraph } from 'mutts/introspection'
|
|
25
|
+
|
|
26
|
+
const graph = getDependencyGraph()
|
|
27
|
+
// Returns: { nodes: { id: string, type: 'effect'|'object', label: string }[], edges: { from: string, to: string, type: 'dependency' }[] }
|
|
28
|
+
```
|
|
29
|
+
**Agent Protocol**: If valid code is behaving unexpectedly, inspect the graph to ensure dependencies are actually linked as you expect.
|
|
30
|
+
|
|
31
|
+
### Mutation History
|
|
32
|
+
Understanding "What just happened".
|
|
33
|
+
```typescript
|
|
34
|
+
import { getMutationHistory } from 'mutts/introspection'
|
|
35
|
+
|
|
36
|
+
const history = getMutationHistory()
|
|
37
|
+
/*
|
|
38
|
+
Returns Array<{
|
|
39
|
+
id: number,
|
|
40
|
+
type: 'set' | 'add' | 'delete',
|
|
41
|
+
prop: string | symbol,
|
|
42
|
+
oldValue: any,
|
|
43
|
+
newValue: any,
|
|
44
|
+
objectName: string, // "Human readable name"
|
|
45
|
+
source: string, // "Effect X" or "External"
|
|
46
|
+
timestamp: number
|
|
47
|
+
}>
|
|
48
|
+
*/
|
|
49
|
+
```
|
|
50
|
+
**Agent Protocol**: When diagnosing "why is this value wrong?", check the *last mutation* of that property in history.
|
|
51
|
+
|
|
52
|
+
## 2. Structured Error Handling
|
|
53
|
+
`mutts` throws `ReactiveError` instances. These are designed to be machine-parseable.
|
|
54
|
+
|
|
55
|
+
### ReactiveErrorCode
|
|
56
|
+
Always check `error.debugInfo.code`.
|
|
57
|
+
```typescript
|
|
58
|
+
enum ReactiveErrorCode {
|
|
59
|
+
CycleDetected = 'CYCLE_DETECTED',
|
|
60
|
+
MaxDepthExceeded = 'MAX_DEPTH_EXCEEDED',
|
|
61
|
+
MaxReactionExceeded = 'MAX_REACTION_EXCEEDED',
|
|
62
|
+
WriteInComputed = 'WRITE_IN_COMPUTED',
|
|
63
|
+
TrackingError = 'TRACKING_ERROR'
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Debugging Protocols
|
|
68
|
+
|
|
69
|
+
#### Protocol: Handling `CycleDetected` / `MaxDepthExceeded`
|
|
70
|
+
**Symptom**: `ReactiveError` with code `CycleDetected` or `MaxDepthExceeded`.
|
|
71
|
+
**Action**:
|
|
72
|
+
1. Read `error.debugInfo.cycle` (Array of effect names).
|
|
73
|
+
2. **CRITICAL**: Read `error.debugInfo.causalChain`.
|
|
74
|
+
* It tells you the *logical path*: `Effect A` -> (modifies `x`) -> `Effect B` -> (modifies `y`) -> `Effect A`.
|
|
75
|
+
3. **CRITICAL**: Read `error.debugInfo.creationStack`.
|
|
76
|
+
* This gives you the **File path and Line number** where the problematic effect was defined.
|
|
77
|
+
|
|
78
|
+
**Example Error Object**:
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"message": "[reactive] Max effect chain reached...",
|
|
82
|
+
"debugInfo": {
|
|
83
|
+
"code": "MAX_DEPTH_EXCEEDED",
|
|
84
|
+
"causalChain": [
|
|
85
|
+
"Effect(Anonymous) -> (set 'count') -> Effect(Display)",
|
|
86
|
+
"Effect(Display) -> (set 'dummy') -> Effect(Anonymous)"
|
|
87
|
+
],
|
|
88
|
+
"creationStack": " at tests/my-test.ts:45:10\n at ...",
|
|
89
|
+
"cycle": ["Effect(Anonymous)", "Effect(Display)"]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 3. Strict Mode
|
|
95
|
+
If you are writing new code that might be complex, verify it with "Strict Mode".
|
|
96
|
+
This forces a graph check *before* execution, preventing infinite loops from hanging the runtime.
|
|
97
|
+
```typescript
|
|
98
|
+
import { options } from 'mutts/introspection'
|
|
99
|
+
options.cycleHandling = 'strict'
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## 4. Architecture Constraints for Agents
|
|
103
|
+
1. **Do not** access properties starting with `_mutts_` directly unless instructed. These are internal implementation details.
|
|
104
|
+
2. **Do not** rely on `batchQueue` global state in your reasoning; it is ephemeral.
|
|
105
|
+
3. **Do** name your effects when possible (`effect(() => {}, { name: 'MyEffect' })`) to make your own future debugging easier.
|