@devlens/core 1.0.0
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/dist/index.d.mts +139 -0
- package/dist/index.d.ts +139 -0
- package/dist/index.js +651 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +645 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +63 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/** Severity levels for detected issues */
|
|
2
|
+
type Severity = 'error' | 'warn' | 'info';
|
|
3
|
+
/** Categories of detected issues */
|
|
4
|
+
type IssueCategory = 'network' | 'null-access' | 'undefined-data' | 'render-data' | 'unhandled-error' | 'unhandled-rejection' | 'type-mismatch';
|
|
5
|
+
/** A detected issue from any DevLens module */
|
|
6
|
+
interface DetectedIssue {
|
|
7
|
+
/** Unique ID for deduplication */
|
|
8
|
+
id: string;
|
|
9
|
+
/** When the issue was detected */
|
|
10
|
+
timestamp: number;
|
|
11
|
+
/** Severity of the issue */
|
|
12
|
+
severity: Severity;
|
|
13
|
+
/** Category for grouping */
|
|
14
|
+
category: IssueCategory;
|
|
15
|
+
/** Human-readable summary */
|
|
16
|
+
message: string;
|
|
17
|
+
/** Detailed context for debugging */
|
|
18
|
+
details?: Record<string, unknown>;
|
|
19
|
+
/** Property path that was accessed (e.g., "user.profile.avatar") */
|
|
20
|
+
path?: string;
|
|
21
|
+
/** The value that was found (null, undefined, etc.) */
|
|
22
|
+
foundValue?: unknown;
|
|
23
|
+
/** What was expected */
|
|
24
|
+
expectedType?: string;
|
|
25
|
+
/** Stack trace if available */
|
|
26
|
+
stack?: string;
|
|
27
|
+
/** Source component or module */
|
|
28
|
+
source?: string;
|
|
29
|
+
/** Suggested fix */
|
|
30
|
+
suggestion?: string;
|
|
31
|
+
}
|
|
32
|
+
/** Configuration for DevLens */
|
|
33
|
+
interface DevLensConfig {
|
|
34
|
+
/** Enable/disable DevLens entirely (default: true in dev, false in prod) */
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
/** Which modules to activate */
|
|
37
|
+
modules?: {
|
|
38
|
+
network?: boolean | NetworkInterceptorConfig;
|
|
39
|
+
guardian?: boolean | DataGuardianConfig;
|
|
40
|
+
catcher?: boolean | GlobalCatcherConfig;
|
|
41
|
+
};
|
|
42
|
+
/** Severity threshold - only report issues at this level or above */
|
|
43
|
+
minSeverity?: Severity;
|
|
44
|
+
/** Custom reporter (default: console reporter) */
|
|
45
|
+
reporter?: Reporter;
|
|
46
|
+
/** Throttle interval in ms to avoid log spam (default: 1000) */
|
|
47
|
+
throttleMs?: number;
|
|
48
|
+
/** Max issues to keep in memory (default: 100) */
|
|
49
|
+
maxIssues?: number;
|
|
50
|
+
/** Patterns to ignore (URL patterns, property paths, etc.) */
|
|
51
|
+
ignore?: IgnorePatterns;
|
|
52
|
+
}
|
|
53
|
+
interface NetworkInterceptorConfig {
|
|
54
|
+
/** Intercept fetch (default: true) */
|
|
55
|
+
fetch?: boolean;
|
|
56
|
+
/** Intercept XMLHttpRequest (default: true) */
|
|
57
|
+
xhr?: boolean;
|
|
58
|
+
/** URL patterns to ignore */
|
|
59
|
+
ignoreUrls?: (string | RegExp)[];
|
|
60
|
+
/** Log successful responses too (default: false) */
|
|
61
|
+
logSuccess?: boolean;
|
|
62
|
+
/** Custom response validator */
|
|
63
|
+
validateResponse?: (response: NetworkResponse) => DetectedIssue | null;
|
|
64
|
+
}
|
|
65
|
+
interface DataGuardianConfig {
|
|
66
|
+
/** Max depth to track property access (default: 5) */
|
|
67
|
+
maxDepth?: number;
|
|
68
|
+
/** Property paths to ignore */
|
|
69
|
+
ignorePaths?: string[];
|
|
70
|
+
/** Log all property access, not just null/undefined (default: false) */
|
|
71
|
+
verbose?: boolean;
|
|
72
|
+
}
|
|
73
|
+
interface GlobalCatcherConfig {
|
|
74
|
+
/** Catch window.onerror (default: true) */
|
|
75
|
+
windowErrors?: boolean;
|
|
76
|
+
/** Catch unhandled promise rejections (default: true) */
|
|
77
|
+
unhandledRejections?: boolean;
|
|
78
|
+
/** Catch console.error calls (default: false) */
|
|
79
|
+
consoleErrors?: boolean;
|
|
80
|
+
}
|
|
81
|
+
interface IgnorePatterns {
|
|
82
|
+
/** URL patterns to ignore for network interceptor */
|
|
83
|
+
urls?: (string | RegExp)[];
|
|
84
|
+
/** Property paths to ignore for data guardian */
|
|
85
|
+
paths?: (string | RegExp)[];
|
|
86
|
+
/** Error message patterns to ignore */
|
|
87
|
+
messages?: (string | RegExp)[];
|
|
88
|
+
}
|
|
89
|
+
interface NetworkResponse {
|
|
90
|
+
url: string;
|
|
91
|
+
method: string;
|
|
92
|
+
status: number;
|
|
93
|
+
statusText: string;
|
|
94
|
+
headers: Record<string, string>;
|
|
95
|
+
body?: unknown;
|
|
96
|
+
duration: number;
|
|
97
|
+
}
|
|
98
|
+
/** Reporter interface for outputting detected issues */
|
|
99
|
+
interface Reporter {
|
|
100
|
+
report(issue: DetectedIssue): void;
|
|
101
|
+
reportBatch?(issues: DetectedIssue[]): void;
|
|
102
|
+
clear?(): void;
|
|
103
|
+
}
|
|
104
|
+
/** Lifecycle hooks for the DevLens engine */
|
|
105
|
+
interface DevLensPlugin {
|
|
106
|
+
name: string;
|
|
107
|
+
setup(engine: DevLensEngine): void;
|
|
108
|
+
teardown?(): void;
|
|
109
|
+
}
|
|
110
|
+
/** The core engine interface exposed to plugins and adapters */
|
|
111
|
+
interface DevLensEngine {
|
|
112
|
+
report(issue: DetectedIssue): void;
|
|
113
|
+
getConfig(): Readonly<DevLensConfig>;
|
|
114
|
+
getIssues(): readonly DetectedIssue[];
|
|
115
|
+
subscribe(callback: (issue: DetectedIssue) => void): () => void;
|
|
116
|
+
isEnabled(): boolean;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
declare function createNetworkInterceptor(engine: DevLensEngine, config?: NetworkInterceptorConfig | boolean): {
|
|
120
|
+
install: () => void;
|
|
121
|
+
uninstall: () => void;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
declare function createDataGuardian(engine: DevLensEngine, config?: DataGuardianConfig | boolean): {
|
|
125
|
+
guard: <T extends object>(target: T, label?: string) => T;
|
|
126
|
+
guardDeep: <T extends object>(target: T, label?: string) => T;
|
|
127
|
+
unguardAll: () => void;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
declare function createGlobalCatcher(engine: DevLensEngine, config?: GlobalCatcherConfig | boolean): {
|
|
131
|
+
install: () => void;
|
|
132
|
+
uninstall: () => void;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
declare function createDetectionEngine(config?: DevLensConfig): DevLensEngine;
|
|
136
|
+
|
|
137
|
+
declare function createConsoleReporter(): Reporter;
|
|
138
|
+
|
|
139
|
+
export { type DataGuardianConfig, type DetectedIssue, type DevLensConfig, type DevLensEngine, type DevLensPlugin, type GlobalCatcherConfig, type IgnorePatterns, type IssueCategory, type NetworkInterceptorConfig, type NetworkResponse, type Reporter, type Severity, createConsoleReporter, createDataGuardian, createDetectionEngine, createGlobalCatcher, createNetworkInterceptor };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/** Severity levels for detected issues */
|
|
2
|
+
type Severity = 'error' | 'warn' | 'info';
|
|
3
|
+
/** Categories of detected issues */
|
|
4
|
+
type IssueCategory = 'network' | 'null-access' | 'undefined-data' | 'render-data' | 'unhandled-error' | 'unhandled-rejection' | 'type-mismatch';
|
|
5
|
+
/** A detected issue from any DevLens module */
|
|
6
|
+
interface DetectedIssue {
|
|
7
|
+
/** Unique ID for deduplication */
|
|
8
|
+
id: string;
|
|
9
|
+
/** When the issue was detected */
|
|
10
|
+
timestamp: number;
|
|
11
|
+
/** Severity of the issue */
|
|
12
|
+
severity: Severity;
|
|
13
|
+
/** Category for grouping */
|
|
14
|
+
category: IssueCategory;
|
|
15
|
+
/** Human-readable summary */
|
|
16
|
+
message: string;
|
|
17
|
+
/** Detailed context for debugging */
|
|
18
|
+
details?: Record<string, unknown>;
|
|
19
|
+
/** Property path that was accessed (e.g., "user.profile.avatar") */
|
|
20
|
+
path?: string;
|
|
21
|
+
/** The value that was found (null, undefined, etc.) */
|
|
22
|
+
foundValue?: unknown;
|
|
23
|
+
/** What was expected */
|
|
24
|
+
expectedType?: string;
|
|
25
|
+
/** Stack trace if available */
|
|
26
|
+
stack?: string;
|
|
27
|
+
/** Source component or module */
|
|
28
|
+
source?: string;
|
|
29
|
+
/** Suggested fix */
|
|
30
|
+
suggestion?: string;
|
|
31
|
+
}
|
|
32
|
+
/** Configuration for DevLens */
|
|
33
|
+
interface DevLensConfig {
|
|
34
|
+
/** Enable/disable DevLens entirely (default: true in dev, false in prod) */
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
/** Which modules to activate */
|
|
37
|
+
modules?: {
|
|
38
|
+
network?: boolean | NetworkInterceptorConfig;
|
|
39
|
+
guardian?: boolean | DataGuardianConfig;
|
|
40
|
+
catcher?: boolean | GlobalCatcherConfig;
|
|
41
|
+
};
|
|
42
|
+
/** Severity threshold - only report issues at this level or above */
|
|
43
|
+
minSeverity?: Severity;
|
|
44
|
+
/** Custom reporter (default: console reporter) */
|
|
45
|
+
reporter?: Reporter;
|
|
46
|
+
/** Throttle interval in ms to avoid log spam (default: 1000) */
|
|
47
|
+
throttleMs?: number;
|
|
48
|
+
/** Max issues to keep in memory (default: 100) */
|
|
49
|
+
maxIssues?: number;
|
|
50
|
+
/** Patterns to ignore (URL patterns, property paths, etc.) */
|
|
51
|
+
ignore?: IgnorePatterns;
|
|
52
|
+
}
|
|
53
|
+
interface NetworkInterceptorConfig {
|
|
54
|
+
/** Intercept fetch (default: true) */
|
|
55
|
+
fetch?: boolean;
|
|
56
|
+
/** Intercept XMLHttpRequest (default: true) */
|
|
57
|
+
xhr?: boolean;
|
|
58
|
+
/** URL patterns to ignore */
|
|
59
|
+
ignoreUrls?: (string | RegExp)[];
|
|
60
|
+
/** Log successful responses too (default: false) */
|
|
61
|
+
logSuccess?: boolean;
|
|
62
|
+
/** Custom response validator */
|
|
63
|
+
validateResponse?: (response: NetworkResponse) => DetectedIssue | null;
|
|
64
|
+
}
|
|
65
|
+
interface DataGuardianConfig {
|
|
66
|
+
/** Max depth to track property access (default: 5) */
|
|
67
|
+
maxDepth?: number;
|
|
68
|
+
/** Property paths to ignore */
|
|
69
|
+
ignorePaths?: string[];
|
|
70
|
+
/** Log all property access, not just null/undefined (default: false) */
|
|
71
|
+
verbose?: boolean;
|
|
72
|
+
}
|
|
73
|
+
interface GlobalCatcherConfig {
|
|
74
|
+
/** Catch window.onerror (default: true) */
|
|
75
|
+
windowErrors?: boolean;
|
|
76
|
+
/** Catch unhandled promise rejections (default: true) */
|
|
77
|
+
unhandledRejections?: boolean;
|
|
78
|
+
/** Catch console.error calls (default: false) */
|
|
79
|
+
consoleErrors?: boolean;
|
|
80
|
+
}
|
|
81
|
+
interface IgnorePatterns {
|
|
82
|
+
/** URL patterns to ignore for network interceptor */
|
|
83
|
+
urls?: (string | RegExp)[];
|
|
84
|
+
/** Property paths to ignore for data guardian */
|
|
85
|
+
paths?: (string | RegExp)[];
|
|
86
|
+
/** Error message patterns to ignore */
|
|
87
|
+
messages?: (string | RegExp)[];
|
|
88
|
+
}
|
|
89
|
+
interface NetworkResponse {
|
|
90
|
+
url: string;
|
|
91
|
+
method: string;
|
|
92
|
+
status: number;
|
|
93
|
+
statusText: string;
|
|
94
|
+
headers: Record<string, string>;
|
|
95
|
+
body?: unknown;
|
|
96
|
+
duration: number;
|
|
97
|
+
}
|
|
98
|
+
/** Reporter interface for outputting detected issues */
|
|
99
|
+
interface Reporter {
|
|
100
|
+
report(issue: DetectedIssue): void;
|
|
101
|
+
reportBatch?(issues: DetectedIssue[]): void;
|
|
102
|
+
clear?(): void;
|
|
103
|
+
}
|
|
104
|
+
/** Lifecycle hooks for the DevLens engine */
|
|
105
|
+
interface DevLensPlugin {
|
|
106
|
+
name: string;
|
|
107
|
+
setup(engine: DevLensEngine): void;
|
|
108
|
+
teardown?(): void;
|
|
109
|
+
}
|
|
110
|
+
/** The core engine interface exposed to plugins and adapters */
|
|
111
|
+
interface DevLensEngine {
|
|
112
|
+
report(issue: DetectedIssue): void;
|
|
113
|
+
getConfig(): Readonly<DevLensConfig>;
|
|
114
|
+
getIssues(): readonly DetectedIssue[];
|
|
115
|
+
subscribe(callback: (issue: DetectedIssue) => void): () => void;
|
|
116
|
+
isEnabled(): boolean;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
declare function createNetworkInterceptor(engine: DevLensEngine, config?: NetworkInterceptorConfig | boolean): {
|
|
120
|
+
install: () => void;
|
|
121
|
+
uninstall: () => void;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
declare function createDataGuardian(engine: DevLensEngine, config?: DataGuardianConfig | boolean): {
|
|
125
|
+
guard: <T extends object>(target: T, label?: string) => T;
|
|
126
|
+
guardDeep: <T extends object>(target: T, label?: string) => T;
|
|
127
|
+
unguardAll: () => void;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
declare function createGlobalCatcher(engine: DevLensEngine, config?: GlobalCatcherConfig | boolean): {
|
|
131
|
+
install: () => void;
|
|
132
|
+
uninstall: () => void;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
declare function createDetectionEngine(config?: DevLensConfig): DevLensEngine;
|
|
136
|
+
|
|
137
|
+
declare function createConsoleReporter(): Reporter;
|
|
138
|
+
|
|
139
|
+
export { type DataGuardianConfig, type DetectedIssue, type DevLensConfig, type DevLensEngine, type DevLensPlugin, type GlobalCatcherConfig, type IgnorePatterns, type IssueCategory, type NetworkInterceptorConfig, type NetworkResponse, type Reporter, type Severity, createConsoleReporter, createDataGuardian, createDetectionEngine, createGlobalCatcher, createNetworkInterceptor };
|