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 ADDED
@@ -0,0 +1,105 @@
1
+ # uilint-vision
2
+
3
+ Vision analysis plugin for UILint. Provides AI-powered visual consistency checking using Ollama vision models.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add uilint-vision
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Browser (Client-Side)
14
+
15
+ Import browser utilities for screenshot capture and manifest collection:
16
+
17
+ ```typescript
18
+ import {
19
+ captureScreenshot,
20
+ collectElementManifest,
21
+ getCurrentRoute,
22
+ matchIssuesToManifest,
23
+ } from "uilint-vision";
24
+ ```
25
+
26
+ ### Node.js (Server-Side)
27
+
28
+ Import the VisionAnalyzer for server-side analysis:
29
+
30
+ ```typescript
31
+ import {
32
+ VisionAnalyzer,
33
+ getVisionAnalyzer,
34
+ UILINT_DEFAULT_VISION_MODEL,
35
+ } from "uilint-vision/node";
36
+
37
+ // Create analyzer instance
38
+ const analyzer = new VisionAnalyzer({
39
+ baseUrl: "http://localhost:11434",
40
+ visionModel: UILINT_DEFAULT_VISION_MODEL,
41
+ });
42
+
43
+ // Analyze a screenshot
44
+ const result = await analyzer.analyzeScreenshot(
45
+ imageBase64,
46
+ elementManifest,
47
+ { styleGuide: "..." }
48
+ );
49
+ ```
50
+
51
+ ### Plugin System
52
+
53
+ The vision plugin auto-registers with the UILint plugin registry:
54
+
55
+ ```typescript
56
+ import "uilint-vision"; // Auto-registers plugin
57
+
58
+ import { pluginRegistry } from "uilint-core";
59
+ const visionPlugin = pluginRegistry.get("vision");
60
+ ```
61
+
62
+ ## Features
63
+
64
+ - **Screenshot Capture**: Full page and region-based capture
65
+ - **Element Manifest**: Collects data-loc elements for analysis mapping
66
+ - **Vision Analysis**: AI-powered visual consistency detection
67
+ - **Issue Matching**: Maps detected issues back to source code locations
68
+
69
+ ## Types
70
+
71
+ Key types exported:
72
+
73
+ - `VisionIssue` - Detected visual issue
74
+ - `ElementManifest` - DOM element with data-loc
75
+ - `ScreenshotCapture` - Captured screenshot metadata
76
+ - `VisionAnalysisResult` - Analysis result with issues
77
+
78
+ ## Browser Utilities
79
+
80
+ | Function | Description |
81
+ |----------|-------------|
82
+ | `captureScreenshot()` | Capture full page screenshot |
83
+ | `captureRegion(region)` | Capture specific region |
84
+ | `collectElementManifest()` | Collect data-loc elements |
85
+ | `getCurrentRoute()` | Get current browser route |
86
+ | `matchIssuesToManifest()` | Match issues to elements |
87
+ | `buildVisionAnalysisPayload()` | Build WebSocket message |
88
+
89
+ ## Plugin Definition
90
+
91
+ The vision plugin provides:
92
+
93
+ - **Commands**: Capture full page, capture region, clear screenshots
94
+ - **Panels**: Vision issue inspector, screenshot gallery
95
+ - **Rules**: `semantic-vision` rule for ESLint integration
96
+ - **Toolbar**: Vision capture actions
97
+
98
+ ## Requirements
99
+
100
+ - **Ollama**: Required for vision analysis (server-side)
101
+ - **Recommended Model**: `qwen3-vl:8b-instruct`
102
+
103
+ ## License
104
+
105
+ MIT
@@ -0,0 +1,79 @@
1
+ import { C as CaptureRegion, E as ElementManifest, V as VisionIssue } from '../types-CN_T7-PU.js';
2
+
3
+ /**
4
+ * Element Manifest Collection
5
+ *
6
+ * Collects visible elements with data-loc attributes for vision analysis.
7
+ * Uses DOM APIs - no React.
8
+ */
9
+
10
+ /**
11
+ * Collect element manifest from the DOM
12
+ *
13
+ * @param region - Optional region to filter elements
14
+ * @returns Array of element manifest entries
15
+ */
16
+ declare function collectElementManifest(region?: CaptureRegion | null): ElementManifest[];
17
+
18
+ /**
19
+ * Screenshot Capture
20
+ *
21
+ * Captures screenshots using html-to-image.
22
+ * Browser-only - no React.
23
+ */
24
+
25
+ /**
26
+ * Capture full page screenshot
27
+ *
28
+ * @returns Base64 data URL of the screenshot
29
+ */
30
+ declare function captureScreenshot(): Promise<string>;
31
+ /**
32
+ * Capture a specific region of the page
33
+ *
34
+ * @param region - Region bounds to capture
35
+ * @returns Base64 data URL of the screenshot
36
+ */
37
+ declare function captureRegion(region: CaptureRegion): Promise<string>;
38
+
39
+ /**
40
+ * Vision Browser Utilities
41
+ *
42
+ * Utility functions for vision analysis in the browser.
43
+ */
44
+
45
+ /**
46
+ * Get the current route/URL path
47
+ */
48
+ declare function getCurrentRoute(): string;
49
+ /**
50
+ * Generate a timestamp string
51
+ */
52
+ declare function generateTimestamp(): string;
53
+ /**
54
+ * Match vision issues to manifest elements by their dataLoc
55
+ *
56
+ * @param issues - Vision issues from analysis
57
+ * @param manifest - Element manifest
58
+ * @returns Issues with element references attached
59
+ */
60
+ declare function matchIssuesToManifest(issues: VisionIssue[], manifest: ElementManifest[]): VisionIssue[];
61
+ /**
62
+ * Build vision analysis payload for WebSocket
63
+ */
64
+ declare function buildVisionAnalysisPayload(options: {
65
+ route: string;
66
+ timestamp: number;
67
+ screenshot: string;
68
+ manifest: ElementManifest[];
69
+ requestId?: string;
70
+ }): {
71
+ type: "vision:analyze";
72
+ route: string;
73
+ timestamp: number;
74
+ screenshot: string;
75
+ manifest: ElementManifest[];
76
+ requestId?: string;
77
+ };
78
+
79
+ export { buildVisionAnalysisPayload, captureRegion, captureScreenshot, captureRegion as captureScreenshotRegion, collectElementManifest, generateTimestamp, getCurrentRoute, matchIssuesToManifest };
@@ -0,0 +1,20 @@
1
+ import {
2
+ buildVisionAnalysisPayload,
3
+ captureRegion,
4
+ captureScreenshot,
5
+ collectElementManifest,
6
+ generateTimestamp,
7
+ getCurrentRoute,
8
+ matchIssuesToManifest
9
+ } from "../chunk-IHYJU45M.js";
10
+ export {
11
+ buildVisionAnalysisPayload,
12
+ captureRegion,
13
+ captureScreenshot,
14
+ captureRegion as captureScreenshotRegion,
15
+ collectElementManifest,
16
+ generateTimestamp,
17
+ getCurrentRoute,
18
+ matchIssuesToManifest
19
+ };
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}