@thehoneyjar/sigil-diagnostics 0.1.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/LICENSE.md +660 -0
- package/README.md +128 -0
- package/dist/index.d.ts +312 -0
- package/dist/index.js +931 -0
- package/package.json +59 -0
- package/src/compliance.ts +250 -0
- package/src/detection.ts +373 -0
- package/src/index.ts +48 -0
- package/src/patterns.ts +327 -0
- package/src/service.ts +330 -0
- package/src/types.ts +243 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sigil/diagnostics
|
|
3
|
+
*
|
|
4
|
+
* Types for physics compliance checking and issue detection.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Effect types that determine physics behavior
|
|
9
|
+
*/
|
|
10
|
+
export type EffectType =
|
|
11
|
+
| 'financial'
|
|
12
|
+
| 'destructive'
|
|
13
|
+
| 'soft-delete'
|
|
14
|
+
| 'standard'
|
|
15
|
+
| 'local'
|
|
16
|
+
| 'navigation'
|
|
17
|
+
| 'query'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Issue severity levels
|
|
21
|
+
*/
|
|
22
|
+
export type Severity = 'error' | 'warning' | 'info'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Pattern categories for diagnostics
|
|
26
|
+
*/
|
|
27
|
+
export type PatternCategory =
|
|
28
|
+
| 'hydration'
|
|
29
|
+
| 'dialog'
|
|
30
|
+
| 'performance'
|
|
31
|
+
| 'layout'
|
|
32
|
+
| 'server-component'
|
|
33
|
+
| 'react-19'
|
|
34
|
+
| 'physics'
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A diagnostic issue found during analysis
|
|
38
|
+
*/
|
|
39
|
+
export interface DiagnosticIssue {
|
|
40
|
+
/** Severity level */
|
|
41
|
+
severity: Severity
|
|
42
|
+
/** Unique code for this issue type */
|
|
43
|
+
code: string
|
|
44
|
+
/** Human-readable message */
|
|
45
|
+
message: string
|
|
46
|
+
/** Source location if available */
|
|
47
|
+
location?: {
|
|
48
|
+
file?: string
|
|
49
|
+
line?: number
|
|
50
|
+
column?: number
|
|
51
|
+
}
|
|
52
|
+
/** Suggested fix */
|
|
53
|
+
suggestion?: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Behavioral physics compliance check result
|
|
58
|
+
*/
|
|
59
|
+
export interface BehavioralCompliance {
|
|
60
|
+
/** Sync strategy: optimistic, pessimistic, or immediate */
|
|
61
|
+
sync: 'optimistic' | 'pessimistic' | 'immediate'
|
|
62
|
+
/** Expected timing in ms */
|
|
63
|
+
timing: number
|
|
64
|
+
/** Whether confirmation is required */
|
|
65
|
+
confirmation: boolean
|
|
66
|
+
/** Whether current implementation is compliant */
|
|
67
|
+
compliant: boolean
|
|
68
|
+
/** Reason for non-compliance */
|
|
69
|
+
reason?: string
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Animation physics compliance check result
|
|
74
|
+
*/
|
|
75
|
+
export interface AnimationCompliance {
|
|
76
|
+
/** Easing function used */
|
|
77
|
+
easing: string
|
|
78
|
+
/** Duration in ms */
|
|
79
|
+
duration: number
|
|
80
|
+
/** Whether current implementation is compliant */
|
|
81
|
+
compliant: boolean
|
|
82
|
+
/** Reason for non-compliance */
|
|
83
|
+
reason?: string
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Material physics compliance check result
|
|
88
|
+
*/
|
|
89
|
+
export interface MaterialCompliance {
|
|
90
|
+
/** Surface type */
|
|
91
|
+
surface: string
|
|
92
|
+
/** Shadow style */
|
|
93
|
+
shadow: string
|
|
94
|
+
/** Border radius */
|
|
95
|
+
radius?: string
|
|
96
|
+
/** Whether current implementation is compliant */
|
|
97
|
+
compliant: boolean
|
|
98
|
+
/** Reason for non-compliance */
|
|
99
|
+
reason?: string
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Complete compliance result across all physics layers
|
|
104
|
+
*/
|
|
105
|
+
export interface ComplianceResult {
|
|
106
|
+
/** Behavioral physics compliance */
|
|
107
|
+
behavioral: BehavioralCompliance
|
|
108
|
+
/** Animation physics compliance */
|
|
109
|
+
animation: AnimationCompliance
|
|
110
|
+
/** Material physics compliance */
|
|
111
|
+
material: MaterialCompliance
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Full diagnostic result for a component
|
|
116
|
+
*/
|
|
117
|
+
export interface DiagnosticResult {
|
|
118
|
+
/** Component name or identifier */
|
|
119
|
+
component: string
|
|
120
|
+
/** Detected effect type */
|
|
121
|
+
effect: EffectType
|
|
122
|
+
/** Issues found during analysis */
|
|
123
|
+
issues: DiagnosticIssue[]
|
|
124
|
+
/** Physics compliance results */
|
|
125
|
+
compliance: ComplianceResult
|
|
126
|
+
/** Improvement suggestions */
|
|
127
|
+
suggestions: string[]
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Pattern cause for matching symptoms
|
|
132
|
+
*/
|
|
133
|
+
export interface PatternCause {
|
|
134
|
+
/** Cause name */
|
|
135
|
+
name: string
|
|
136
|
+
/** Signature/pattern to look for */
|
|
137
|
+
signature: string
|
|
138
|
+
/** Example of problematic code */
|
|
139
|
+
codeSmell?: string
|
|
140
|
+
/** Solution code or explanation */
|
|
141
|
+
solution: string
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Diagnostic pattern for matching known issues
|
|
146
|
+
*/
|
|
147
|
+
export interface DiagnosticPattern {
|
|
148
|
+
/** Unique pattern ID */
|
|
149
|
+
id: string
|
|
150
|
+
/** Human-readable name */
|
|
151
|
+
name: string
|
|
152
|
+
/** Category of issue */
|
|
153
|
+
category: PatternCategory
|
|
154
|
+
/** Severity level */
|
|
155
|
+
severity: Severity
|
|
156
|
+
/** Symptoms that indicate this pattern */
|
|
157
|
+
symptoms: string[]
|
|
158
|
+
/** Keywords to match against */
|
|
159
|
+
keywords: string[]
|
|
160
|
+
/** Possible causes and solutions */
|
|
161
|
+
causes: PatternCause[]
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Result of pattern matching
|
|
166
|
+
*/
|
|
167
|
+
export interface PatternMatchResult {
|
|
168
|
+
/** Matched pattern */
|
|
169
|
+
pattern: DiagnosticPattern
|
|
170
|
+
/** Most likely cause */
|
|
171
|
+
matchedCause: PatternCause
|
|
172
|
+
/** Confidence score 0-1 */
|
|
173
|
+
confidence: number
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Configuration for the diagnostics service
|
|
178
|
+
*/
|
|
179
|
+
export interface DiagnosticsConfig {
|
|
180
|
+
/** Enable strict mode (more warnings) */
|
|
181
|
+
strict?: boolean
|
|
182
|
+
/** Custom patterns to include */
|
|
183
|
+
customPatterns?: DiagnosticPattern[]
|
|
184
|
+
/** Pattern categories to check */
|
|
185
|
+
categories?: PatternCategory[]
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Diagnostics service interface
|
|
190
|
+
*/
|
|
191
|
+
export interface DiagnosticsService {
|
|
192
|
+
/**
|
|
193
|
+
* Analyze a component for physics compliance and issues
|
|
194
|
+
*/
|
|
195
|
+
analyze(component: string, code?: string): Promise<DiagnosticResult>
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Check if physics settings comply with effect type
|
|
199
|
+
*/
|
|
200
|
+
checkCompliance(
|
|
201
|
+
effect: EffectType,
|
|
202
|
+
physics: Partial<ComplianceResult>
|
|
203
|
+
): boolean
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Detect effect type from keywords and types
|
|
207
|
+
*/
|
|
208
|
+
detectEffect(keywords: string[], types?: string[]): EffectType
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Match symptoms to known patterns
|
|
212
|
+
*/
|
|
213
|
+
matchPatterns(symptoms: string): PatternMatchResult[]
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Get quick diagnosis from symptom description
|
|
217
|
+
*/
|
|
218
|
+
diagnose(symptom: string): string
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Error codes for diagnostics package
|
|
223
|
+
*/
|
|
224
|
+
export const DiagnosticsErrorCodes = {
|
|
225
|
+
ANALYSIS_FAILED: 'ANALYSIS_FAILED',
|
|
226
|
+
PATTERN_NOT_FOUND: 'PATTERN_NOT_FOUND',
|
|
227
|
+
INVALID_EFFECT: 'INVALID_EFFECT',
|
|
228
|
+
ANCHOR_NOT_AVAILABLE: 'ANCHOR_NOT_AVAILABLE',
|
|
229
|
+
} as const
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Diagnostics error class
|
|
233
|
+
*/
|
|
234
|
+
export class DiagnosticsError extends Error {
|
|
235
|
+
constructor(
|
|
236
|
+
message: string,
|
|
237
|
+
public code: keyof typeof DiagnosticsErrorCodes,
|
|
238
|
+
public recoverable: boolean = true
|
|
239
|
+
) {
|
|
240
|
+
super(message)
|
|
241
|
+
this.name = 'DiagnosticsError'
|
|
242
|
+
}
|
|
243
|
+
}
|