uilint-react 0.1.18 → 0.1.19
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/InspectionPanel-6DBGEWWD.js +9 -0
- package/dist/LocatorOverlay-FQEYAMT6.js +9 -0
- package/dist/SourceOverlays-2SEINA2B.js +9 -0
- package/dist/UILintToolbar-7ZYCQC4M.js +9 -0
- package/dist/chunk-3TA6OKS6.js +725 -0
- package/dist/chunk-7WYVWDRU.js +686 -0
- package/dist/chunk-KUFV22FO.js +213 -0
- package/dist/chunk-MEP7WO7U.js +210 -0
- package/dist/chunk-OWX36QE3.js +595 -0
- package/dist/index.d.ts +284 -6
- package/dist/index.js +62 -1
- package/dist/node.js +1 -4
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React$1 from 'react';
|
|
3
3
|
import { Violation, GroupedSnapshot, 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
|
interface UILintProps {
|
|
7
|
-
children: React.ReactNode;
|
|
7
|
+
children: React$1.ReactNode;
|
|
8
8
|
enabled?: boolean;
|
|
9
9
|
position?: "bottom-left" | "bottom-right" | "top-left" | "top-right";
|
|
10
10
|
autoScan?: boolean;
|
|
11
11
|
apiEndpoint?: string;
|
|
12
12
|
}
|
|
13
|
-
interface UILintContextValue {
|
|
13
|
+
interface UILintContextValue$1 {
|
|
14
14
|
violations: Violation[];
|
|
15
15
|
isScanning: boolean;
|
|
16
16
|
elementCount: number;
|
|
@@ -21,9 +21,287 @@ interface UILintContextValue {
|
|
|
21
21
|
lockedViolation: Violation | null;
|
|
22
22
|
setLockedViolation: (violation: Violation | null) => void;
|
|
23
23
|
}
|
|
24
|
-
declare function useUILint(): UILintContextValue;
|
|
24
|
+
declare function useUILint(): UILintContextValue$1;
|
|
25
25
|
declare function UILint({ children, enabled, position, autoScan, apiEndpoint, }: UILintProps): react_jsx_runtime.JSX.Element;
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Types for UILint Source Visualization
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Source location from React Fiber _debugSource
|
|
32
|
+
*/
|
|
33
|
+
interface SourceLocation {
|
|
34
|
+
fileName: string;
|
|
35
|
+
lineNumber: number;
|
|
36
|
+
columnNumber?: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Component information extracted from React Fiber
|
|
40
|
+
*/
|
|
41
|
+
interface ComponentInfo {
|
|
42
|
+
name: string;
|
|
43
|
+
source: SourceLocation | null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A scanned DOM element with its React source information
|
|
47
|
+
*/
|
|
48
|
+
interface ScannedElement {
|
|
49
|
+
id: string;
|
|
50
|
+
element: Element;
|
|
51
|
+
tagName: string;
|
|
52
|
+
className: string;
|
|
53
|
+
source: SourceLocation | null;
|
|
54
|
+
componentStack: ComponentInfo[];
|
|
55
|
+
rect: DOMRect;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A source file with all its associated elements
|
|
59
|
+
*/
|
|
60
|
+
interface SourceFile {
|
|
61
|
+
path: string;
|
|
62
|
+
displayName: string;
|
|
63
|
+
color: string;
|
|
64
|
+
elements: ScannedElement[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* User-configurable settings for the overlay
|
|
68
|
+
*/
|
|
69
|
+
interface UILintSettings {
|
|
70
|
+
showLabels: boolean;
|
|
71
|
+
hideNodeModules: boolean;
|
|
72
|
+
overlayOpacity: number;
|
|
73
|
+
labelPosition: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Operating modes for the UILint overlay
|
|
77
|
+
*/
|
|
78
|
+
type UILintMode = "off" | "sources" | "inspect";
|
|
79
|
+
/**
|
|
80
|
+
* Element detected under the cursor during Alt-key locator mode
|
|
81
|
+
*/
|
|
82
|
+
interface LocatorTarget {
|
|
83
|
+
element: Element;
|
|
84
|
+
source: SourceLocation | null;
|
|
85
|
+
componentStack: ComponentInfo[];
|
|
86
|
+
rect: DOMRect;
|
|
87
|
+
/** Index in the component stack (0 = current element, higher = parent) */
|
|
88
|
+
stackIndex: number;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Context value provided by UILintProvider
|
|
92
|
+
*/
|
|
93
|
+
interface UILintContextValue {
|
|
94
|
+
mode: UILintMode;
|
|
95
|
+
setMode: (mode: UILintMode) => void;
|
|
96
|
+
scannedElements: ScannedElement[];
|
|
97
|
+
sourceFiles: SourceFile[];
|
|
98
|
+
selectedElement: ScannedElement | null;
|
|
99
|
+
setSelectedElement: (element: ScannedElement | null) => void;
|
|
100
|
+
hoveredElement: ScannedElement | null;
|
|
101
|
+
setHoveredElement: (element: ScannedElement | null) => void;
|
|
102
|
+
settings: UILintSettings;
|
|
103
|
+
updateSettings: (settings: Partial<UILintSettings>) => void;
|
|
104
|
+
rescan: () => void;
|
|
105
|
+
isScanning: boolean;
|
|
106
|
+
/** True when Alt/Option key is held down */
|
|
107
|
+
altKeyHeld: boolean;
|
|
108
|
+
/** Current element under cursor when Alt is held */
|
|
109
|
+
locatorTarget: LocatorTarget | null;
|
|
110
|
+
/** Navigate to parent component in locator mode */
|
|
111
|
+
locatorGoUp: () => void;
|
|
112
|
+
/** Navigate to child component in locator mode */
|
|
113
|
+
locatorGoDown: () => void;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Props for the UILintProvider component
|
|
117
|
+
*/
|
|
118
|
+
interface UILintProviderProps {
|
|
119
|
+
children: React.ReactNode;
|
|
120
|
+
enabled?: boolean;
|
|
121
|
+
defaultMode?: UILintMode;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Response from the source API
|
|
125
|
+
*/
|
|
126
|
+
interface SourceApiResponse {
|
|
127
|
+
content: string;
|
|
128
|
+
relativePath: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Cached source file content
|
|
132
|
+
*/
|
|
133
|
+
interface CachedSource {
|
|
134
|
+
content: string;
|
|
135
|
+
relativePath: string;
|
|
136
|
+
fetchedAt: number;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Color palette for source file differentiation
|
|
140
|
+
*/
|
|
141
|
+
declare const FILE_COLORS: readonly ["#3B82F6", "#8B5CF6", "#EC4899", "#10B981", "#F59E0B", "#06B6D4", "#EF4444", "#84CC16", "#6366F1", "#F97316", "#14B8A6", "#A855F7"];
|
|
142
|
+
/**
|
|
143
|
+
* Default settings
|
|
144
|
+
*/
|
|
145
|
+
declare const DEFAULT_SETTINGS: UILintSettings;
|
|
146
|
+
/**
|
|
147
|
+
* Data attribute used to mark scanned elements
|
|
148
|
+
*/
|
|
149
|
+
declare const DATA_UILINT_ID = "data-ui-lint-id";
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Hook to access UILint context
|
|
153
|
+
*/
|
|
154
|
+
declare function useUILintContext(): UILintContextValue;
|
|
155
|
+
/**
|
|
156
|
+
* UILint Provider Component
|
|
157
|
+
*/
|
|
158
|
+
declare function UILintProvider({ children, enabled, defaultMode, }: UILintProviderProps): react_jsx_runtime.JSX.Element;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* UILint Toolbar - Floating pill-shaped toolbar with mode toggles and settings
|
|
162
|
+
*/
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Main Toolbar Component
|
|
166
|
+
*/
|
|
167
|
+
declare function UILintToolbar(): React$1.ReactPortal | null;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Source Overlays - Colored rectangles over components with file labels
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Main Source Overlays Component
|
|
175
|
+
*/
|
|
176
|
+
declare function SourceOverlays(): React$1.ReactPortal | null;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Inspection Panel - Slide-out panel showing element details and source preview
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Main Inspection Panel Component
|
|
184
|
+
*/
|
|
185
|
+
declare function InspectionPanel(): React$1.ReactPortal | null;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* React Fiber inspection utilities for source file visualization
|
|
189
|
+
*
|
|
190
|
+
* In development mode, React attaches debug information to Fiber nodes:
|
|
191
|
+
* - _debugSource: { fileName, lineNumber, columnNumber }
|
|
192
|
+
* - _debugOwner: The component that rendered this element
|
|
193
|
+
* - return: Parent fiber in the tree
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
/** React Fiber type (simplified) */
|
|
197
|
+
interface Fiber {
|
|
198
|
+
tag: number;
|
|
199
|
+
type: string | Function | null;
|
|
200
|
+
stateNode: Element | null;
|
|
201
|
+
return: Fiber | null;
|
|
202
|
+
_debugSource?: {
|
|
203
|
+
fileName: string;
|
|
204
|
+
lineNumber: number;
|
|
205
|
+
columnNumber?: number;
|
|
206
|
+
} | null;
|
|
207
|
+
_debugOwner?: Fiber | null;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Get React Fiber from a DOM element
|
|
211
|
+
* React attaches fiber via __reactFiber$xxx key
|
|
212
|
+
*/
|
|
213
|
+
declare function getFiberFromElement(element: Element): Fiber | null;
|
|
214
|
+
/**
|
|
215
|
+
* Extract source location from a fiber's _debugSource
|
|
216
|
+
*/
|
|
217
|
+
declare function getDebugSource(fiber: Fiber): SourceLocation | null;
|
|
218
|
+
/**
|
|
219
|
+
* Get the debug owner fiber (component that rendered this element)
|
|
220
|
+
*/
|
|
221
|
+
declare function getDebugOwner(fiber: Fiber): Fiber | null;
|
|
222
|
+
/**
|
|
223
|
+
* Build a component stack by walking up the fiber tree
|
|
224
|
+
* Returns an array from innermost to outermost component
|
|
225
|
+
*/
|
|
226
|
+
declare function getComponentStack(fiber: Fiber): ComponentInfo[];
|
|
227
|
+
/**
|
|
228
|
+
* Check if a file path is from node_modules
|
|
229
|
+
*/
|
|
230
|
+
declare function isNodeModulesPath(path: string): boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Get display name from a file path (just the filename)
|
|
233
|
+
*/
|
|
234
|
+
declare function getDisplayName(path: string): string;
|
|
235
|
+
/**
|
|
236
|
+
* Scan the DOM tree and extract React source information
|
|
237
|
+
*/
|
|
238
|
+
declare function scanDOMForSources(root?: Element, hideNodeModules?: boolean): ScannedElement[];
|
|
239
|
+
/**
|
|
240
|
+
* Group scanned elements by their source file
|
|
241
|
+
*/
|
|
242
|
+
declare function groupBySourceFile(elements: ScannedElement[]): SourceFile[];
|
|
243
|
+
/**
|
|
244
|
+
* Clean up data attributes from previous scans
|
|
245
|
+
*/
|
|
246
|
+
declare function cleanupDataAttributes(): void;
|
|
247
|
+
/**
|
|
248
|
+
* Get an element by its UILint ID
|
|
249
|
+
*/
|
|
250
|
+
declare function getElementById(id: string): Element | null;
|
|
251
|
+
/**
|
|
252
|
+
* Update element rects (for scroll/resize handling)
|
|
253
|
+
*/
|
|
254
|
+
declare function updateElementRects(elements: ScannedElement[]): ScannedElement[];
|
|
255
|
+
/**
|
|
256
|
+
* Build an "Open in Editor" URL
|
|
257
|
+
*/
|
|
258
|
+
declare function buildEditorUrl(source: SourceLocation, editor?: "cursor" | "vscode"): string;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Client for fetching source code from the dev API
|
|
262
|
+
*/
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Fetch source code for a file
|
|
266
|
+
*/
|
|
267
|
+
declare function fetchSource(filePath: string): Promise<SourceApiResponse | null>;
|
|
268
|
+
/**
|
|
269
|
+
* Fetch source and extract lines around a specific location
|
|
270
|
+
*/
|
|
271
|
+
declare function fetchSourceWithContext(source: SourceLocation, contextLines?: number): Promise<{
|
|
272
|
+
lines: string[];
|
|
273
|
+
startLine: number;
|
|
274
|
+
highlightLine: number;
|
|
275
|
+
relativePath: string;
|
|
276
|
+
} | null>;
|
|
277
|
+
/**
|
|
278
|
+
* Clear the source cache
|
|
279
|
+
*/
|
|
280
|
+
declare function clearSourceCache(): void;
|
|
281
|
+
/**
|
|
282
|
+
* Get cached source without fetching
|
|
283
|
+
*/
|
|
284
|
+
declare function getCachedSource(filePath: string): SourceApiResponse | null;
|
|
285
|
+
/**
|
|
286
|
+
* Prefetch source files for a list of paths
|
|
287
|
+
*/
|
|
288
|
+
declare function prefetchSources(filePaths: string[]): Promise<void>;
|
|
289
|
+
|
|
290
|
+
interface UseElementScanOptions {
|
|
291
|
+
enabled: boolean;
|
|
292
|
+
settings: UILintSettings;
|
|
293
|
+
}
|
|
294
|
+
interface UseElementScanResult {
|
|
295
|
+
elements: ScannedElement[];
|
|
296
|
+
sourceFiles: SourceFile[];
|
|
297
|
+
isScanning: boolean;
|
|
298
|
+
rescan: () => void;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Hook for managing element scanning
|
|
302
|
+
*/
|
|
303
|
+
declare function useElementScan({ enabled, settings, }: UseElementScanOptions): UseElementScanResult;
|
|
304
|
+
|
|
27
305
|
/**
|
|
28
306
|
* DOM snapshotting for consistency analysis
|
|
29
307
|
*/
|
|
@@ -50,7 +328,7 @@ interface ConsistencyHighlighterProps {
|
|
|
50
328
|
* Main consistency highlighter component
|
|
51
329
|
* Renders highlights via Portal to document.body
|
|
52
330
|
*/
|
|
53
|
-
declare function ConsistencyHighlighter({ violations, selectedViolation, lockedViolation, }: ConsistencyHighlighterProps): React.ReactPortal | null;
|
|
331
|
+
declare function ConsistencyHighlighter({ violations, selectedViolation, lockedViolation, }: ConsistencyHighlighterProps): React$1.ReactPortal | null;
|
|
54
332
|
|
|
55
333
|
/**
|
|
56
334
|
* DOM scanner for browser environment
|
|
@@ -104,4 +382,4 @@ declare class LLMClient {
|
|
|
104
382
|
generateStyleGuide(styles: ExtractedStyles): Promise<string | null>;
|
|
105
383
|
}
|
|
106
384
|
|
|
107
|
-
export { ConsistencyHighlighter, LLMClient, UILint, type UILintProps, cleanupDataElements, createSnapshot, getElementBySnapshotId, isBrowser, isJSDOM, isNode, scanDOM, useUILint };
|
|
385
|
+
export { type CachedSource, type ComponentInfo, ConsistencyHighlighter, DATA_UILINT_ID, DEFAULT_SETTINGS, FILE_COLORS, InspectionPanel, LLMClient, type ScannedElement, type SourceApiResponse, type SourceFile, type SourceLocation, SourceOverlays, UILint, type UILintContextValue, type UILintMode, type UILintProps, 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, useElementScan, useUILint, useUILintContext };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,39 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
UILintToolbar
|
|
4
|
+
} from "./chunk-OWX36QE3.js";
|
|
5
|
+
import {
|
|
6
|
+
SourceOverlays
|
|
7
|
+
} from "./chunk-MEP7WO7U.js";
|
|
8
|
+
import {
|
|
9
|
+
InspectionPanel,
|
|
10
|
+
clearSourceCache,
|
|
11
|
+
fetchSource,
|
|
12
|
+
fetchSourceWithContext,
|
|
13
|
+
getCachedSource,
|
|
14
|
+
prefetchSources
|
|
15
|
+
} from "./chunk-3TA6OKS6.js";
|
|
16
|
+
import "./chunk-KUFV22FO.js";
|
|
17
|
+
import {
|
|
18
|
+
DATA_UILINT_ID,
|
|
19
|
+
DEFAULT_SETTINGS,
|
|
20
|
+
FILE_COLORS,
|
|
21
|
+
UILintProvider,
|
|
22
|
+
buildEditorUrl,
|
|
23
|
+
cleanupDataAttributes,
|
|
24
|
+
getComponentStack,
|
|
25
|
+
getDebugOwner,
|
|
26
|
+
getDebugSource,
|
|
27
|
+
getDisplayName,
|
|
28
|
+
getElementById,
|
|
29
|
+
getFiberFromElement,
|
|
30
|
+
groupBySourceFile,
|
|
31
|
+
isNodeModulesPath,
|
|
32
|
+
scanDOMForSources,
|
|
33
|
+
updateElementRects,
|
|
34
|
+
useElementScan,
|
|
35
|
+
useUILintContext
|
|
36
|
+
} from "./chunk-7WYVWDRU.js";
|
|
2
37
|
|
|
3
38
|
// src/components/UILint.tsx
|
|
4
39
|
import {
|
|
@@ -1549,21 +1584,47 @@ import { generateStyleGuideFromStyles } from "uilint-core";
|
|
|
1549
1584
|
import { createEmptyStyleGuide, mergeStyleGuides } from "uilint-core";
|
|
1550
1585
|
export {
|
|
1551
1586
|
ConsistencyHighlighter,
|
|
1587
|
+
DATA_UILINT_ID,
|
|
1588
|
+
DEFAULT_SETTINGS,
|
|
1589
|
+
FILE_COLORS,
|
|
1590
|
+
InspectionPanel,
|
|
1552
1591
|
LLMClient,
|
|
1592
|
+
SourceOverlays,
|
|
1553
1593
|
UILint,
|
|
1594
|
+
UILintProvider,
|
|
1595
|
+
UILintToolbar,
|
|
1596
|
+
buildEditorUrl,
|
|
1597
|
+
cleanupDataAttributes,
|
|
1554
1598
|
cleanupDataElements,
|
|
1599
|
+
clearSourceCache,
|
|
1555
1600
|
createEmptyStyleGuide,
|
|
1556
1601
|
createSnapshot,
|
|
1557
1602
|
createStyleSummary3 as createStyleSummary,
|
|
1558
1603
|
extractStylesFromDOM2 as extractStylesFromDOM,
|
|
1604
|
+
fetchSource,
|
|
1605
|
+
fetchSourceWithContext,
|
|
1559
1606
|
generateStyleGuideFromStyles as generateStyleGuide,
|
|
1607
|
+
getCachedSource,
|
|
1608
|
+
getComponentStack,
|
|
1609
|
+
getDebugOwner,
|
|
1610
|
+
getDebugSource,
|
|
1611
|
+
getDisplayName,
|
|
1612
|
+
getElementById,
|
|
1560
1613
|
getElementBySnapshotId,
|
|
1614
|
+
getFiberFromElement,
|
|
1615
|
+
groupBySourceFile,
|
|
1561
1616
|
isBrowser,
|
|
1562
1617
|
isJSDOM,
|
|
1563
1618
|
isNode,
|
|
1619
|
+
isNodeModulesPath,
|
|
1564
1620
|
mergeStyleGuides,
|
|
1565
1621
|
parseStyleGuide,
|
|
1622
|
+
prefetchSources,
|
|
1566
1623
|
scanDOM,
|
|
1624
|
+
scanDOMForSources,
|
|
1567
1625
|
serializeStyles2 as serializeStyles,
|
|
1568
|
-
|
|
1626
|
+
updateElementRects,
|
|
1627
|
+
useElementScan,
|
|
1628
|
+
useUILint,
|
|
1629
|
+
useUILintContext
|
|
1569
1630
|
};
|
package/dist/node.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uilint-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "React component for AI-powered UI consistency checking",
|
|
5
5
|
"author": "Peter Suggate",
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"node": ">=20.0.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"uilint-core": "^0.1.
|
|
37
|
+
"uilint-core": "^0.1.19"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": "^19.0.0",
|