uilint-vision 0.2.136
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 +105 -0
- package/dist/browser/index.d.ts +79 -0
- package/dist/browser/index.js +20 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/chunk-CM75UYJ5.js +631 -0
- package/dist/chunk-CM75UYJ5.js.map +1 -0
- package/dist/chunk-IHYJU45M.js +254 -0
- package/dist/chunk-IHYJU45M.js.map +1 -0
- package/dist/chunk-ZMNCURDE.js +1 -0
- package/dist/chunk-ZMNCURDE.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/node.d.ts +120 -0
- package/dist/node.js +438 -0
- package/dist/node.js.map +1 -0
- package/dist/plugin/index.d.ts +54 -0
- package/dist/plugin/index.js +9 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/types-CN_T7-PU.d.ts +230 -0
- package/package.json +56 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vision Plugin Types
|
|
3
|
+
*
|
|
4
|
+
* All types for vision-based UI consistency analysis.
|
|
5
|
+
* Consolidated from uilint-core and uilint-react.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Vision issue category
|
|
9
|
+
*/
|
|
10
|
+
type VisionIssueCategory = "spacing" | "alignment" | "color" | "typography" | "layout" | "contrast" | "visual-hierarchy" | "other";
|
|
11
|
+
/**
|
|
12
|
+
* Vision issue severity
|
|
13
|
+
*/
|
|
14
|
+
type VisionIssueSeverity = "error" | "warning" | "info";
|
|
15
|
+
/**
|
|
16
|
+
* Vision analysis issue from the LLM
|
|
17
|
+
*/
|
|
18
|
+
interface VisionIssue {
|
|
19
|
+
/** Text of the element this issue refers to */
|
|
20
|
+
elementText: string;
|
|
21
|
+
/** Issue description */
|
|
22
|
+
message: string;
|
|
23
|
+
/** Issue category */
|
|
24
|
+
category: VisionIssueCategory;
|
|
25
|
+
/** Severity level */
|
|
26
|
+
severity: VisionIssueSeverity;
|
|
27
|
+
/** Matched dataLoc from manifest (filled in after text matching) */
|
|
28
|
+
dataLoc?: string;
|
|
29
|
+
/** Matched element ID (filled in after text matching) */
|
|
30
|
+
elementId?: string;
|
|
31
|
+
/** Suggested fix (optional) */
|
|
32
|
+
suggestion?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Element manifest entry for vision analysis.
|
|
36
|
+
* Maps visible elements to their source locations.
|
|
37
|
+
*/
|
|
38
|
+
interface ElementManifest {
|
|
39
|
+
/** Unique ID (data-loc if present, otherwise generated) */
|
|
40
|
+
id: string;
|
|
41
|
+
/** Visible text content (truncated to 100 chars) */
|
|
42
|
+
text: string;
|
|
43
|
+
/** data-loc value: "path:line:column" */
|
|
44
|
+
dataLoc: string;
|
|
45
|
+
/** Bounding rectangle */
|
|
46
|
+
rect: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
};
|
|
52
|
+
/** HTML tag name */
|
|
53
|
+
tagName: string;
|
|
54
|
+
/** Inferred semantic role (button, heading, link, etc.) */
|
|
55
|
+
role?: string;
|
|
56
|
+
/** Total instances with same dataLoc (if deduplicated) */
|
|
57
|
+
instanceCount?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Region bounds for partial screenshot capture
|
|
61
|
+
*/
|
|
62
|
+
interface CaptureRegion {
|
|
63
|
+
x: number;
|
|
64
|
+
y: number;
|
|
65
|
+
width: number;
|
|
66
|
+
height: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Capture mode for vision analysis
|
|
70
|
+
*/
|
|
71
|
+
type CaptureMode = "full" | "region";
|
|
72
|
+
/**
|
|
73
|
+
* Screenshot capture entry for the gallery
|
|
74
|
+
*/
|
|
75
|
+
interface ScreenshotCapture {
|
|
76
|
+
/** Unique ID for this capture */
|
|
77
|
+
id: string;
|
|
78
|
+
/** Route where the capture was taken */
|
|
79
|
+
route: string;
|
|
80
|
+
/** Base64 data URL of the screenshot (for in-memory captures) */
|
|
81
|
+
dataUrl?: string;
|
|
82
|
+
/** Filename for persisted screenshots (used to fetch from API) */
|
|
83
|
+
filename?: string;
|
|
84
|
+
/** Unix timestamp when captured */
|
|
85
|
+
timestamp: number;
|
|
86
|
+
/** Type of capture */
|
|
87
|
+
type: CaptureMode;
|
|
88
|
+
/** Region bounds if type is 'region' */
|
|
89
|
+
region?: CaptureRegion;
|
|
90
|
+
/** Whether this is a persisted screenshot loaded from disk */
|
|
91
|
+
persisted?: boolean;
|
|
92
|
+
/** Vision issues specific to this capture */
|
|
93
|
+
issues?: VisionIssue[];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Vision analysis result from the analyzer
|
|
97
|
+
*/
|
|
98
|
+
interface VisionAnalysisResult {
|
|
99
|
+
/** Route/path that was analyzed */
|
|
100
|
+
route: string;
|
|
101
|
+
/** Timestamp of capture */
|
|
102
|
+
timestamp: number;
|
|
103
|
+
/** Screenshot as base64 data URL */
|
|
104
|
+
screenshotDataUrl?: string;
|
|
105
|
+
/** Element manifest */
|
|
106
|
+
manifest: ElementManifest[];
|
|
107
|
+
/** Issues found by vision analysis */
|
|
108
|
+
issues: VisionIssue[];
|
|
109
|
+
/** Analysis duration in ms */
|
|
110
|
+
analysisTime: number;
|
|
111
|
+
/** Error message if analysis failed */
|
|
112
|
+
error?: string;
|
|
113
|
+
/** Full prompt sent to the model (for debugging) */
|
|
114
|
+
prompt?: string;
|
|
115
|
+
/** Raw LLM response (for debugging) */
|
|
116
|
+
rawResponse?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Auto-scan settings for Vision analysis.
|
|
120
|
+
* Persisted to localStorage.
|
|
121
|
+
*/
|
|
122
|
+
interface VisionAutoScanSettings {
|
|
123
|
+
/** Auto-capture and analyze on route change */
|
|
124
|
+
onRouteChange: boolean;
|
|
125
|
+
/** Auto-capture and analyze on initial page load */
|
|
126
|
+
onInitialLoad: boolean;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Default vision auto-scan settings
|
|
130
|
+
*/
|
|
131
|
+
declare const DEFAULT_VISION_AUTO_SCAN_SETTINGS: VisionAutoScanSettings;
|
|
132
|
+
/**
|
|
133
|
+
* Vision pipeline stage (for error tracking)
|
|
134
|
+
*/
|
|
135
|
+
type VisionStage = "capture" | "manifest" | "ws" | "vision";
|
|
136
|
+
/**
|
|
137
|
+
* Vision error information with stage context
|
|
138
|
+
*/
|
|
139
|
+
interface VisionErrorInfo {
|
|
140
|
+
/** The stage where the error occurred */
|
|
141
|
+
stage: VisionStage;
|
|
142
|
+
/** Human-readable error message */
|
|
143
|
+
message: string;
|
|
144
|
+
/** Route that was being analyzed */
|
|
145
|
+
route: string;
|
|
146
|
+
/** Timestamp of the error */
|
|
147
|
+
timestamp: number;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Persisted screenshot metadata from the API
|
|
151
|
+
*/
|
|
152
|
+
interface PersistedScreenshotMetadata {
|
|
153
|
+
filename: string;
|
|
154
|
+
timestamp: number;
|
|
155
|
+
screenshotFile: string;
|
|
156
|
+
route: string | null;
|
|
157
|
+
issues: VisionIssue[] | null;
|
|
158
|
+
manifest: ElementManifest[] | null;
|
|
159
|
+
analysisResult: {
|
|
160
|
+
route: string;
|
|
161
|
+
timestamp: number;
|
|
162
|
+
issues: VisionIssue[];
|
|
163
|
+
analysisTime: number;
|
|
164
|
+
error?: string;
|
|
165
|
+
} | null;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* API response for listing screenshots
|
|
169
|
+
*/
|
|
170
|
+
interface ScreenshotListResponse {
|
|
171
|
+
screenshots: Array<{
|
|
172
|
+
filename: string;
|
|
173
|
+
metadata: PersistedScreenshotMetadata | null;
|
|
174
|
+
}>;
|
|
175
|
+
projectRoot: string;
|
|
176
|
+
screenshotsDir: string;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Client -> Server: Request vision analysis
|
|
180
|
+
*/
|
|
181
|
+
interface VisionAnalyzeMessage {
|
|
182
|
+
type: "vision:analyze";
|
|
183
|
+
route: string;
|
|
184
|
+
timestamp: number;
|
|
185
|
+
screenshot: string;
|
|
186
|
+
manifest: ElementManifest[];
|
|
187
|
+
requestId?: string;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Server -> Client: Vision analysis result
|
|
191
|
+
*/
|
|
192
|
+
interface VisionResultMessage {
|
|
193
|
+
type: "vision:result";
|
|
194
|
+
route: string;
|
|
195
|
+
issues: VisionIssue[];
|
|
196
|
+
analysisTime: number;
|
|
197
|
+
error?: string;
|
|
198
|
+
requestId?: string;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Server -> Client: Vision analysis progress
|
|
202
|
+
*/
|
|
203
|
+
interface VisionProgressMessage {
|
|
204
|
+
type: "vision:progress";
|
|
205
|
+
route: string;
|
|
206
|
+
phase: string;
|
|
207
|
+
requestId?: string;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Client -> Server: Check vision availability
|
|
211
|
+
*/
|
|
212
|
+
interface VisionCheckMessage {
|
|
213
|
+
type: "vision:check";
|
|
214
|
+
requestId?: string;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Server -> Client: Vision availability status
|
|
218
|
+
*/
|
|
219
|
+
interface VisionStatusMessage {
|
|
220
|
+
type: "vision:status";
|
|
221
|
+
available: boolean;
|
|
222
|
+
model?: string;
|
|
223
|
+
requestId?: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Union of all vision WebSocket messages
|
|
227
|
+
*/
|
|
228
|
+
type VisionMessage = VisionAnalyzeMessage | VisionResultMessage | VisionProgressMessage | VisionCheckMessage | VisionStatusMessage;
|
|
229
|
+
|
|
230
|
+
export { type CaptureRegion as C, DEFAULT_VISION_AUTO_SCAN_SETTINGS as D, type ElementManifest as E, type PersistedScreenshotMetadata as P, type ScreenshotCapture as S, type VisionIssue as V, type VisionIssueCategory as a, type VisionIssueSeverity as b, type CaptureMode as c, type VisionAnalysisResult as d, type VisionAutoScanSettings as e, type VisionStage as f, type VisionErrorInfo as g, type ScreenshotListResponse as h, type VisionAnalyzeMessage as i, type VisionResultMessage as j, type VisionProgressMessage as k, type VisionCheckMessage as l, type VisionStatusMessage as m, type VisionMessage as n };
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "uilint-vision",
|
|
3
|
+
"version": "0.2.136",
|
|
4
|
+
"description": "Vision-based UI consistency analysis for UILint",
|
|
5
|
+
"author": "Peter Suggate",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/peter-suggate/uilint.git",
|
|
9
|
+
"directory": "packages/uilint-vision"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./node": {
|
|
21
|
+
"types": "./dist/node.d.ts",
|
|
22
|
+
"import": "./dist/node.js"
|
|
23
|
+
},
|
|
24
|
+
"./browser": {
|
|
25
|
+
"types": "./dist/browser/index.d.ts",
|
|
26
|
+
"import": "./dist/browser/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./plugin": {
|
|
29
|
+
"types": "./dist/plugin/index.d.ts",
|
|
30
|
+
"import": "./dist/plugin/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"uilint-core": "0.2.136"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"html-to-image": "^1.11.13"
|
|
41
|
+
},
|
|
42
|
+
"optionalDependencies": {
|
|
43
|
+
"ollama": "^0.6.3"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"typescript": "^5.7.0",
|
|
47
|
+
"tsup": "^8.0.0",
|
|
48
|
+
"vitest": "^2.0.0"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsup",
|
|
52
|
+
"dev": "tsup --watch",
|
|
53
|
+
"test": "vitest",
|
|
54
|
+
"typecheck": "tsc --noEmit"
|
|
55
|
+
}
|
|
56
|
+
}
|