uilint-react 0.1.18 → 0.1.20
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 +49 -92
- package/dist/InspectionPanel-3ML64TAP.js +9 -0
- package/dist/LocatorOverlay-GTTWBRKH.js +11 -0
- package/dist/UILintToolbar-GAOYF7GY.js +9 -0
- package/dist/chunk-DAFFOBEU.js +521 -0
- package/dist/chunk-NOISZ3XP.js +1052 -0
- package/dist/chunk-PBC3J267.js +276 -0
- package/dist/chunk-VYCIUDU7.js +283 -0
- package/dist/index.d.ts +259 -20
- package/dist/index.js +82 -1085
- package/dist/node.js +1 -4
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,267 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import {
|
|
2
|
+
import React$1 from 'react';
|
|
3
|
+
import { GroupedSnapshot, Violation, DOMSnapshot, ExtractedStyles, AnalysisResult } from 'uilint-core';
|
|
4
4
|
export { AnalysisResult, ConsistencyResult, DOMSnapshot, ElementRole, ElementSnapshot, ExtractedStyles, GroupedSnapshot, SerializedStyles, StyleGuide, StyleSnapshot, UILintIssue, Violation, ViolationCategory, ViolationSeverity, createEmptyStyleGuide, createStyleSummary, extractStylesFromDOM, generateStyleGuideFromStyles as generateStyleGuide, mergeStyleGuides, parseStyleGuide, serializeStyles } from 'uilint-core';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Types for UILint Source Visualization
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Source location from React Fiber _debugSource
|
|
11
|
+
*/
|
|
12
|
+
interface SourceLocation {
|
|
13
|
+
fileName: string;
|
|
14
|
+
lineNumber: number;
|
|
15
|
+
columnNumber?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Component information extracted from React Fiber
|
|
19
|
+
*/
|
|
20
|
+
interface ComponentInfo {
|
|
21
|
+
name: string;
|
|
22
|
+
source: SourceLocation | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A scanned DOM element with its React source information
|
|
26
|
+
*/
|
|
27
|
+
interface ScannedElement {
|
|
28
|
+
id: string;
|
|
29
|
+
element: Element;
|
|
30
|
+
tagName: string;
|
|
31
|
+
className: string;
|
|
32
|
+
source: SourceLocation | null;
|
|
33
|
+
componentStack: ComponentInfo[];
|
|
34
|
+
rect: DOMRect;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A source file with all its associated elements
|
|
38
|
+
*/
|
|
39
|
+
interface SourceFile {
|
|
40
|
+
path: string;
|
|
41
|
+
displayName: string;
|
|
42
|
+
color: string;
|
|
43
|
+
elements: ScannedElement[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* User-configurable settings for the overlay
|
|
47
|
+
*/
|
|
48
|
+
interface UILintSettings {
|
|
49
|
+
hideNodeModules: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Element detected under the cursor during Alt-key locator mode
|
|
53
|
+
*/
|
|
54
|
+
interface LocatorTarget {
|
|
55
|
+
element: Element;
|
|
56
|
+
source: SourceLocation | null;
|
|
57
|
+
componentStack: ComponentInfo[];
|
|
58
|
+
rect: DOMRect;
|
|
59
|
+
/** Index in the component stack (0 = current element, higher = parent) */
|
|
60
|
+
stackIndex: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Element being inspected in the sidebar
|
|
64
|
+
*/
|
|
65
|
+
interface InspectedElement {
|
|
66
|
+
element: Element;
|
|
67
|
+
source: SourceLocation | null;
|
|
68
|
+
componentStack: ComponentInfo[];
|
|
69
|
+
rect: DOMRect;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Context value provided by UILintProvider
|
|
73
|
+
*/
|
|
74
|
+
interface UILintContextValue {
|
|
75
|
+
settings: UILintSettings;
|
|
76
|
+
updateSettings: (settings: Partial<UILintSettings>) => void;
|
|
77
|
+
/** True when Alt/Option key is held down */
|
|
78
|
+
altKeyHeld: boolean;
|
|
79
|
+
/** Current element under cursor when Alt is held */
|
|
80
|
+
locatorTarget: LocatorTarget | null;
|
|
81
|
+
/** Navigate to parent component in locator mode */
|
|
82
|
+
locatorGoUp: () => void;
|
|
83
|
+
/** Navigate to child component in locator mode */
|
|
84
|
+
locatorGoDown: () => void;
|
|
85
|
+
/** Element currently being inspected in sidebar */
|
|
86
|
+
inspectedElement: InspectedElement | null;
|
|
87
|
+
/** Set the element to inspect (opens sidebar) */
|
|
88
|
+
setInspectedElement: (element: InspectedElement | null) => void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Props for the UILintProvider component
|
|
92
|
+
*/
|
|
93
|
+
interface UILintProviderProps {
|
|
7
94
|
children: React.ReactNode;
|
|
8
95
|
enabled?: boolean;
|
|
9
|
-
position?: "bottom-left" | "bottom-right" | "top-left" | "top-right";
|
|
10
|
-
autoScan?: boolean;
|
|
11
|
-
apiEndpoint?: string;
|
|
12
96
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Response from the source API
|
|
99
|
+
*/
|
|
100
|
+
interface SourceApiResponse {
|
|
101
|
+
content: string;
|
|
102
|
+
relativePath: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Cached source file content
|
|
106
|
+
*/
|
|
107
|
+
interface CachedSource {
|
|
108
|
+
content: string;
|
|
109
|
+
relativePath: string;
|
|
110
|
+
fetchedAt: number;
|
|
23
111
|
}
|
|
24
|
-
|
|
25
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Color palette for source file differentiation
|
|
114
|
+
*/
|
|
115
|
+
declare const FILE_COLORS: readonly ["#3B82F6", "#8B5CF6", "#EC4899", "#10B981", "#F59E0B", "#06B6D4", "#EF4444", "#84CC16", "#6366F1", "#F97316", "#14B8A6", "#A855F7"];
|
|
116
|
+
/**
|
|
117
|
+
* Default settings
|
|
118
|
+
*/
|
|
119
|
+
declare const DEFAULT_SETTINGS: UILintSettings;
|
|
120
|
+
/**
|
|
121
|
+
* Data attribute used to mark scanned elements
|
|
122
|
+
*/
|
|
123
|
+
declare const DATA_UILINT_ID = "data-ui-lint-id";
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Hook to access UILint context
|
|
127
|
+
*/
|
|
128
|
+
declare function useUILintContext(): UILintContextValue;
|
|
129
|
+
/**
|
|
130
|
+
* UILint Provider Component
|
|
131
|
+
*/
|
|
132
|
+
declare function UILintProvider({ children, enabled, }: UILintProviderProps): react_jsx_runtime.JSX.Element;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* UILint Toolbar - Simple floating button with settings popover
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Main Toolbar Component - Simple floating button with settings popover
|
|
140
|
+
*/
|
|
141
|
+
declare function UILintToolbar(): React$1.ReactPortal | null;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Inspection Panel - Slide-out sidebar showing element details, source preview,
|
|
145
|
+
* and LLM analysis with clipboard-ready fix prompts
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Main Inspection Panel Component
|
|
150
|
+
*/
|
|
151
|
+
declare function InspectionPanel(): React$1.ReactPortal | null;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Locator Overlay - Shows element info when Alt/Option key is held
|
|
155
|
+
* Inspired by LocatorJS for a quick "hover to find source" experience
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Main Locator Overlay Component
|
|
160
|
+
*/
|
|
161
|
+
declare function LocatorOverlay(): React$1.ReactPortal | null;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* React Fiber inspection utilities for source file visualization
|
|
165
|
+
*
|
|
166
|
+
* In development mode, React attaches debug information to Fiber nodes:
|
|
167
|
+
* - _debugSource: { fileName, lineNumber, columnNumber }
|
|
168
|
+
* - _debugOwner: The component that rendered this element
|
|
169
|
+
* - return: Parent fiber in the tree
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
/** React Fiber type (simplified) */
|
|
173
|
+
interface Fiber {
|
|
174
|
+
tag: number;
|
|
175
|
+
type: string | Function | null;
|
|
176
|
+
stateNode: Element | null;
|
|
177
|
+
return: Fiber | null;
|
|
178
|
+
_debugSource?: {
|
|
179
|
+
fileName: string;
|
|
180
|
+
lineNumber: number;
|
|
181
|
+
columnNumber?: number;
|
|
182
|
+
} | null;
|
|
183
|
+
_debugOwner?: Fiber | null;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Get React Fiber from a DOM element
|
|
187
|
+
* React attaches fiber via __reactFiber$xxx key
|
|
188
|
+
*/
|
|
189
|
+
declare function getFiberFromElement(element: Element): Fiber | null;
|
|
190
|
+
/**
|
|
191
|
+
* Extract source location from a fiber's _debugSource
|
|
192
|
+
*/
|
|
193
|
+
declare function getDebugSource(fiber: Fiber): SourceLocation | null;
|
|
194
|
+
/**
|
|
195
|
+
* Get the debug owner fiber (component that rendered this element)
|
|
196
|
+
*/
|
|
197
|
+
declare function getDebugOwner(fiber: Fiber): Fiber | null;
|
|
198
|
+
/**
|
|
199
|
+
* Build a component stack by walking up the fiber tree
|
|
200
|
+
* Returns an array from innermost to outermost component
|
|
201
|
+
*/
|
|
202
|
+
declare function getComponentStack(fiber: Fiber): ComponentInfo[];
|
|
203
|
+
/**
|
|
204
|
+
* Check if a file path is from node_modules
|
|
205
|
+
*/
|
|
206
|
+
declare function isNodeModulesPath(path: string): boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Get display name from a file path (just the filename)
|
|
209
|
+
*/
|
|
210
|
+
declare function getDisplayName(path: string): string;
|
|
211
|
+
/**
|
|
212
|
+
* Scan the DOM tree and extract React source information
|
|
213
|
+
*/
|
|
214
|
+
declare function scanDOMForSources(root?: Element, hideNodeModules?: boolean): ScannedElement[];
|
|
215
|
+
/**
|
|
216
|
+
* Group scanned elements by their source file
|
|
217
|
+
*/
|
|
218
|
+
declare function groupBySourceFile(elements: ScannedElement[]): SourceFile[];
|
|
219
|
+
/**
|
|
220
|
+
* Clean up data attributes from previous scans
|
|
221
|
+
*/
|
|
222
|
+
declare function cleanupDataAttributes(): void;
|
|
223
|
+
/**
|
|
224
|
+
* Get an element by its UILint ID
|
|
225
|
+
*/
|
|
226
|
+
declare function getElementById(id: string): Element | null;
|
|
227
|
+
/**
|
|
228
|
+
* Update element rects (for scroll/resize handling)
|
|
229
|
+
*/
|
|
230
|
+
declare function updateElementRects(elements: ScannedElement[]): ScannedElement[];
|
|
231
|
+
/**
|
|
232
|
+
* Build an "Open in Editor" URL
|
|
233
|
+
*/
|
|
234
|
+
declare function buildEditorUrl(source: SourceLocation, editor?: "cursor" | "vscode"): string;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Client for fetching source code from the dev API
|
|
238
|
+
*/
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Fetch source code for a file
|
|
242
|
+
*/
|
|
243
|
+
declare function fetchSource(filePath: string): Promise<SourceApiResponse | null>;
|
|
244
|
+
/**
|
|
245
|
+
* Fetch source and extract lines around a specific location
|
|
246
|
+
*/
|
|
247
|
+
declare function fetchSourceWithContext(source: SourceLocation, contextLines?: number): Promise<{
|
|
248
|
+
lines: string[];
|
|
249
|
+
startLine: number;
|
|
250
|
+
highlightLine: number;
|
|
251
|
+
relativePath: string;
|
|
252
|
+
} | null>;
|
|
253
|
+
/**
|
|
254
|
+
* Clear the source cache
|
|
255
|
+
*/
|
|
256
|
+
declare function clearSourceCache(): void;
|
|
257
|
+
/**
|
|
258
|
+
* Get cached source without fetching
|
|
259
|
+
*/
|
|
260
|
+
declare function getCachedSource(filePath: string): SourceApiResponse | null;
|
|
261
|
+
/**
|
|
262
|
+
* Prefetch source files for a list of paths
|
|
263
|
+
*/
|
|
264
|
+
declare function prefetchSources(filePaths: string[]): Promise<void>;
|
|
26
265
|
|
|
27
266
|
/**
|
|
28
267
|
* DOM snapshotting for consistency analysis
|
|
@@ -50,7 +289,7 @@ interface ConsistencyHighlighterProps {
|
|
|
50
289
|
* Main consistency highlighter component
|
|
51
290
|
* Renders highlights via Portal to document.body
|
|
52
291
|
*/
|
|
53
|
-
declare function ConsistencyHighlighter({ violations, selectedViolation, lockedViolation, }: ConsistencyHighlighterProps): React.ReactPortal | null;
|
|
292
|
+
declare function ConsistencyHighlighter({ violations, selectedViolation, lockedViolation, }: ConsistencyHighlighterProps): React$1.ReactPortal | null;
|
|
54
293
|
|
|
55
294
|
/**
|
|
56
295
|
* DOM scanner for browser environment
|
|
@@ -104,4 +343,4 @@ declare class LLMClient {
|
|
|
104
343
|
generateStyleGuide(styles: ExtractedStyles): Promise<string | null>;
|
|
105
344
|
}
|
|
106
345
|
|
|
107
|
-
export { ConsistencyHighlighter, LLMClient,
|
|
346
|
+
export { type CachedSource, type ComponentInfo, ConsistencyHighlighter, DATA_UILINT_ID, DEFAULT_SETTINGS, FILE_COLORS, type InspectedElement, InspectionPanel, LLMClient, LocatorOverlay, type LocatorTarget, type ScannedElement, type SourceApiResponse, type SourceFile, type SourceLocation, type UILintContextValue, UILintProvider, type UILintProviderProps, type UILintSettings, UILintToolbar, buildEditorUrl, cleanupDataAttributes, cleanupDataElements, clearSourceCache, createSnapshot, fetchSource, fetchSourceWithContext, getCachedSource, getComponentStack, getDebugOwner, getDebugSource, getDisplayName, getElementById, getElementBySnapshotId, getFiberFromElement, groupBySourceFile, isBrowser, isJSDOM, isNode, isNodeModulesPath, prefetchSources, scanDOM, scanDOMForSources, updateElementRects, useUILintContext };
|