inspectra-engine 0.0.0-stage → 1.0.3

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/CHANGELOG.md ADDED
@@ -0,0 +1,67 @@
1
+ # Changelog
2
+
3
+ All notable changes to Inspectra will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.3] - 2026-10-30
9
+
10
+ ### Changed
11
+
12
+ - Pin Shivax to version `1.0.2`.
13
+ - Update Playwright and its test runner to `^1.64.1`, axe-core's Playwright
14
+ integration to `^4.14.0`, CSpell to `^10.4.0` and Lighthouse to `^13.6.0`.
15
+
16
+ ## [1.0.2] - 2026-10-28
17
+
18
+ ### Added
19
+
20
+ - Project attribution NOTICE file, included in the published npm package.
21
+ - npm package description, source and issue links, and feature-specific discovery keywords.
22
+ - README use cases and FAQs covering UI testing, accessibility, design baselines
23
+ and supported execution environments.
24
+ - Include this changelog in the published npm package.
25
+
26
+ ### Changed
27
+
28
+ - Replace outdated phase notes and repository boilerplate in the README with a
29
+ feature overview, installation requirements, basic imports and function examples.
30
+ - Correct documented imports to use the published `inspectra-engine` package name.
31
+
32
+ ## [1.0.1] - 2026-10-27
33
+
34
+ ### Added
35
+
36
+ - This changelog, including the published version history and contribution conventions.
37
+
38
+ ### Changed
39
+
40
+ - Increase the local runner's default bootstrap token lifetime from 5 to 15 minutes.
41
+ Explicit shorter lifetimes remain supported; the maximum stays at 15 minutes.
42
+ Tokens still expire and do not renew automatically.
43
+
44
+ ## [1.0.0] - 2026-10-03
45
+
46
+ ### Added
47
+
48
+ - Local Playwright capture of baseline and target pages, including semantic nodes,
49
+ typography, layout, hierarchy, screenshots and viewport metadata.
50
+ - Shivax-compatible UI snapshots with measurement provenance and confidence.
51
+ - URL comparisons using Shivax, with JSON reports and screenshot artifacts.
52
+ - Structured Figma baselines and PNG baselines with OCR-assisted observations.
53
+ - Accessibility checks and optional UI styling, layout and spelling checks.
54
+ - A local HTTP runner with scan sessions, streamed events, previews, cancellation
55
+ and report retrieval.
56
+ - Node.js APIs, a browser client, TypeScript declarations and the `inspectra` CLI.
57
+ - Explicit company/personal scopes and separate output directories for captures.
58
+ - Apache-2.0 licensing.
59
+
60
+ ## [0.0.0-stage] - 2026-10-26
61
+
62
+ ### Added
63
+
64
+ - Initial staging publication of `inspectra-engine` on npm, preceding version 1.0.0.
65
+
66
+ [1.0.3]: https://www.npmjs.com/package/inspectra-engine/v/1.0.3
67
+ [1.0.2]: https://www.npmjs.com/package/inspectra-engine/v/1.0.2
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Urvesh Gohil
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,11 @@
1
+ Inspectra (inspectra-engine)
2
+ Copyright 2026 Urvesh Gohil
3
+
4
+ Inspectra is distributed under the Apache License, Version 2.0.
5
+ See the LICENSE file for the full license text.
6
+
7
+ Project: https://gitlab.com/urveshgohil.developer/inspectra
8
+
9
+ Third-party dependencies retain their respective copyright notices and
10
+ licenses. Refer to the license and notice files distributed with each
11
+ dependency for its attribution and licensing terms.
package/README.md CHANGED
@@ -1,3 +1,133 @@
1
- # Temporary Holding Version
1
+ # Inspectra: Playwright UI Testing and Accessibility for Node.js
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Inspectra (`inspectra-engine`) is a Node.js package for UI testing, visual regression testing, design QA and automated accessibility checks. Developers and QA teams can compare a live website against a URL, Figma design or PNG baseline, inspect rendered layout and typography, and export JSON reports with screenshot evidence. Inspectra captures pages with Playwright and uses Shivax to compare structured UI snapshots.
4
+
5
+ Published on npm as **`inspectra-engine`**. Requires **Node.js 22.15+**. ESM imports and TypeScript declarations are included.
6
+
7
+ [npm package](https://www.npmjs.com/package/inspectra-engine) · [Source code](https://gitlab.com/urveshgohil.developer/inspectra) · [Report an issue](https://gitlab.com/urveshgohil.developer/inspectra/-/issues) · [Changelog](CHANGELOG.md)
8
+
9
+ ## Features
10
+
11
+ - Baseline and target capture with consistent viewport and device-pixel-ratio settings.
12
+ - Semantic content, typography, spacing, dimensions, hierarchy and layout extraction.
13
+ - UI comparison through Shivax using structured measurements, with screenshots as supporting evidence.
14
+ - URL, Figma and PNG baselines. Inferred measurements carry provenance and confidence.
15
+ - Accessibility checks powered by axe-core, plus optional UI styling, layout and spelling checks.
16
+ - JSON reports, screenshots, scan events, cancellation and a local HTTP runner.
17
+ - Explicit company and personal scopes for organizing scan data.
18
+
19
+ ## Use cases
20
+
21
+ | Task | Inspectra capability |
22
+ | --- | --- |
23
+ | Visual regression testing | Compare baseline and target UI snapshots to identify measured design differences. |
24
+ | Figma design QA | Compare structured Figma design data against a rendered website. |
25
+ | Frontend layout testing | Inspect dimensions, padding, margins, gaps, typography and element relationships. |
26
+ | Responsive UI testing | Capture pages at specified viewports and device pixel ratios. |
27
+ | Accessibility testing | Run axe-core checks and include findings alongside UI comparison reports. |
28
+ | Screenshot baseline review | Compare a PNG baseline with a website using OCR-assisted observations and confidence annotations. |
29
+
30
+ ## Installation
31
+
32
+ ```sh
33
+ npm install inspectra-engine
34
+ npx playwright install chromium
35
+ ```
36
+
37
+ Figma capture needs a Figma token supplied to the Node.js process. PNG text extraction needs local Tesseract OCR or a supplied OCR provider.
38
+
39
+ ## Basic usage
40
+
41
+ ### Compare two pages
42
+
43
+ ```js
44
+ import { compare } from 'inspectra-engine';
45
+
46
+ const result = await compare({
47
+ baseline: 'https://example.com',
48
+ target: 'https://example.org',
49
+ viewport: { width: 1440, height: 900 },
50
+ scope: { kind: 'company', id: 'my-company' },
51
+ output: `./reports/scan-${Date.now()}`,
52
+ });
53
+
54
+ console.log(result.issues);
55
+ console.log(result.artifacts.report);
56
+ ```
57
+
58
+ The output directory must be new. A completed comparison writes `report.json`, `baseline.png` and `target.png`. Accessibility checks are enabled by default; use `accessibility: false` to disable them. For URL comparisons, use `uiChecks: true` to include additional UI checks, and `spelling: true` alongside it for spelling checks.
59
+
60
+ ### Capture a snapshot and check accessibility
61
+
62
+ ```js
63
+ import { chromium } from 'playwright';
64
+ import { captureUISnapshot, scanAccessibility } from 'inspectra-engine';
65
+
66
+ const browser = await chromium.launch();
67
+ try {
68
+ const page = await browser.newPage({
69
+ viewport: { width: 1440, height: 900 },
70
+ deviceScaleFactor: 1,
71
+ });
72
+ await page.goto('https://example.com', { waitUntil: 'load' });
73
+
74
+ const snapshot = await captureUISnapshot(page, {
75
+ scope: { kind: 'personal', id: 'local-user' },
76
+ });
77
+ const accessibility = await scanAccessibility(page);
78
+
79
+ console.log(snapshot.nodes);
80
+ console.log(accessibility.violations);
81
+ } finally {
82
+ await browser.close();
83
+ }
84
+ ```
85
+
86
+ ## Main functions
87
+
88
+ Import these from `inspectra-engine` or `inspectra-engine/node`.
89
+
90
+ | Function | Purpose |
91
+ | --- | --- |
92
+ | `compare(options)` | Compare a URL, Figma or PNG baseline against a target page and save artifacts. |
93
+ | `captureUISnapshot(page, options)` | Convert an existing Playwright page into a Shivax UI snapshot. |
94
+ | `captureUIPage(page, options)` | Capture a snapshot, extraction metadata and an optional screenshot. |
95
+ | `captureUISnapshotPair(options)` | Capture baseline and target URLs using matching browser settings. |
96
+ | `scanAccessibility(page, options)` | Run axe-core accessibility checks on an existing page. |
97
+ | `captureFigmaBaseline(source, options)` | Capture structured Figma data and its preview. |
98
+ | `capturePNGBaseline(source, options)` | Convert a PNG baseline into an evidence-tagged snapshot. |
99
+ | `startLocalRunner(options)` | Start the loopback HTTP runner for an application integration. |
100
+
101
+ Node APIs execute outside the browser. Browser applications can import report types and `COMPARISON_VERSION` from `inspectra-engine/client`; this entry does not run scans. Application UI, login and licensing belong to the consuming application. Scope metadata does not replace authentication or storage access controls.
102
+
103
+ The HTTP runner's bootstrap token lasts 15 minutes by default and does not renew automatically.
104
+
105
+ ## Frequently asked questions
106
+
107
+ ### Is Inspectra a standalone application or a Playwright package?
108
+
109
+ Inspectra is an npm package that uses Playwright for browser capture. Import its functions into a Node.js application or use the included `inspectra` CLI. Visynq Workstation is a separate application that consumes Inspectra.
110
+
111
+ ### Can Inspectra compare Figma designs or screenshots with a website?
112
+
113
+ Yes. `compare()` accepts a URL string, a structured Figma baseline or a PNG baseline. Figma capture requires a token, and PNG capture requires viewport metadata and an OCR provider. PNG-derived observations are inferred and require review.
114
+
115
+ ### Does Inspectra primarily compare screenshots pixel by pixel?
116
+
117
+ No. The main comparison flow uses structured snapshots and Shivax analysis. Browser captures expose rendered geometry and computed styles; screenshots provide visual evidence. Measurements inferred from PNGs retain confidence and provenance rather than being presented as original CSS values.
118
+
119
+ ### Can Inspectra run inside a React application in the browser?
120
+
121
+ The scanner requires Node.js and Playwright outside the browser. The `inspectra-engine/client` entry provides browser-safe report contracts and a version constant, but does not execute scans. React applications need a separate execution environment for the scanner.
122
+
123
+ ### Does Inspectra require a hosted scanning service?
124
+
125
+ No. Its Node.js APIs run in the environment supplied by the consuming application, including a local development process or an application-owned worker. Inspectra does not require an Inspectra-hosted scanner backend.
126
+
127
+ ## Changelog
128
+
129
+ See [CHANGELOG.md](CHANGELOG.md) for version history.
130
+
131
+ ## License
132
+
133
+ [Apache-2.0](LICENSE). Copyright 2026 Urvesh Gohil. Third-party dependencies retain their own licenses.
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ import { parseArgs, parseEnv } from 'node:util';
3
+ import { readFileSync } from 'node:fs';
4
+
5
+ const help = `Usage:
6
+ inspectra compare --baseline <URL> --target <URL> --viewport <WIDTHxHEIGHT>
7
+ --output <new-directory> --scope-kind <company|personal> --scope-id <id>
8
+ # Figma baseline: add --figma-node <node-id> [--figma-scale <design-units-per-css-px>]
9
+ # PNG baseline: --baseline <image.png> --png-metadata <metadata.json>
10
+ inspectra dev [--env <.env>] [--port <4317>] [--origin <http://localhost:5173>]
11
+ inspectra help
12
+
13
+ Runs Chromium locally, compares measured snapshots with Shivax, and writes
14
+ report.json, baseline.png and target.png. Output must not already exist.
15
+ Dev reads .env in the current directory; shell variables and flags take precedence.
16
+ Viewport defaults to 1440x900. Accessibility checks use WCAG A/AA.
17
+ Exit codes: 0 success (including findings), 1 error, 130 cancelled.
18
+ `;
19
+ const controller = new AbortController();
20
+ const abort = () => controller.abort();
21
+ process.once('SIGINT', abort);
22
+ process.once('SIGTERM', abort);
23
+ try {
24
+ const [command, ...args] = process.argv.slice(2);
25
+ if (!command || command === 'help' || command === '--help') {
26
+ process.stdout.write(help);
27
+ } else if (command === 'dev') {
28
+ const { values } = parseArgs({ args, options: { env: { type: 'string' }, port: { type: 'string' }, origin: { type: 'string', multiple: true } } });
29
+ try {
30
+ const env = parseEnv(readFileSync(values['env'] ?? '.env', 'utf8'));
31
+ for (const [name, value] of Object.entries(env)) if (process.env[name] === undefined) process.env[name] = value;
32
+ }
33
+ catch (error) { if (values['env'] || error.code !== 'ENOENT') throw error; }
34
+ const { devOptions } = await import('../node/dev-config.mjs');
35
+ const { startLocalRunner } = await import('../node/index.mjs');
36
+ const runner = await startLocalRunner({ ...devOptions(values), signal: controller.signal });
37
+ process.stdout.write(JSON.stringify({ origin: runner.origin, token: runner.token, expiresAt: runner.expiresAt }) + '\n');
38
+ await new Promise(resolve => {
39
+ if (controller.signal.aborted) resolve();
40
+ else controller.signal.addEventListener('abort', resolve, { once: true });
41
+ });
42
+ await runner.close();
43
+ } else if (command === 'compare') {
44
+ const { values } = parseArgs({ args, options: Object.fromEntries(
45
+ ['baseline', 'target', 'viewport', 'output', 'scope-kind', 'scope-id', 'figma-node', 'figma-scale', 'png-metadata'].map(name => [name, { type: 'string' }])) });
46
+ const match = values.viewport === undefined ? undefined : /^(\d+)x(\d+)$/.exec(values.viewport);
47
+ if (values.viewport !== undefined && !match) throw new TypeError('viewport must be WIDTHxHEIGHT');
48
+ const { compare } = await import('../node/index.mjs');
49
+ const figma = values['figma-node'] !== undefined || /^https:\/\/(?:www\.)?figma\.com\//.test(values.baseline ?? '');
50
+ if (values['figma-scale'] !== undefined && !figma) throw new TypeError('figma-scale requires a Figma baseline');
51
+ const png = values['png-metadata'] !== undefined || (!/^[a-z]+:\/\//i.test(values.baseline ?? '') && /\.png$/i.test(values.baseline ?? ''));
52
+ if (png && figma) throw new TypeError('Choose one baseline source type');
53
+ if (png && !values['png-metadata']) throw new TypeError('PNG requires --png-metadata with screenshot viewport metadata');
54
+ const baseline = png ? { ...JSON.parse(readFileSync(values['png-metadata'], 'utf8')), type: 'png', path: values.baseline } : figma ? { type: 'figma', url: values.baseline, ...(values['figma-node'] ? { nodeId: values['figma-node'] } : {}), unitsPerCssPixel: Number(values['figma-scale'] ?? 1) } : values.baseline;
55
+ const result = await compare({ baseline, target: values.target, output: values.output,
56
+ viewport: match ? { width: Number(match[1]), height: Number(match[2]) } : undefined,
57
+ scope: { kind: values['scope-kind'], id: values['scope-id'] }, signal: controller.signal });
58
+ process.stdout.write(JSON.stringify({ issues: result.issues.length, artifacts: result.artifacts }) + '\n');
59
+ } else {
60
+ throw new TypeError(`Unknown command: ${command}. Run inspectra help.`);
61
+ }
62
+ } catch (error) {
63
+ process.stderr.write(`inspectra: ${error.message}\n`);
64
+ process.exitCode = controller.signal.aborted ? 130 : 1;
65
+ } finally {
66
+ process.removeListener('SIGINT', abort);
67
+ process.removeListener('SIGTERM', abort);
68
+ }
@@ -0,0 +1,85 @@
1
+ import type { UISnapshot, UIAnalysisResult } from 'shivax';
2
+ export type { UISnapshot, UIAnalysisOptions, UIAnalysisResult, UIIssue, Measurement, SourceProvenance } from 'shivax';
3
+ export declare const COMPARISON_VERSION: 1;
4
+ export interface UIHighlightRect { x: number; y: number; width: number; height: number }
5
+ export interface UICheckFinding {
6
+ severity: 'high' | 'medium' | 'low' | 'info';
7
+ type: string; detail: string; elements?: string[]; text?: string;
8
+ refRects?: UIHighlightRect[]; tgtRects?: UIHighlightRect[]; rects?: UIHighlightRect[];
9
+ diffs?: { prop: string; ref: string; act: string }[];
10
+ }
11
+ export interface SpellingFinding { word: string; suggestions: string[]; tag: string; context: string; rects: UIHighlightRect[] }
12
+ export interface UICheckResult {
13
+ completeness: UICheckFinding[]; layout: UICheckFinding[]; styling: UICheckFinding[];
14
+ spelling: SpellingFinding[]; spellingRan: boolean;
15
+ provenance: { method: 'inspectra-ui-check'; kind: 'inferred'; confidence: null };
16
+ }
17
+ export interface ComparisonResult {
18
+ /** Optional existing Inspectra UI-check results, measured on the same captured pages. */
19
+ uiCheck?: UICheckResult;
20
+ version: 1;
21
+ scope: UISnapshot['scope'];
22
+ baseline: UISnapshot;
23
+ target: UISnapshot;
24
+ analysis: UIAnalysisResult;
25
+ issues: UIAnalysisResult['issues'];
26
+ evidence: { baseline: unknown; target: unknown };
27
+ accessibility: { baseline: unknown; target: unknown } | null;
28
+ artifacts: { report: string; baselineScreenshot: string; targetScreenshot: string; baselineHighlights?: string; targetHighlights?: string };
29
+ review?: { status: 'needs_review'; issues: { id: string; status: 'needs_review' }[]; uncertain: UIAnalysisResult['matching']['uncertain']; uncertainTarget: UIAnalysisResult['matching']['uncertainTarget'] };
30
+ matches?: { id: string; baselineNodeId: string; targetNodeId: string; baseline: UIHighlightRect; target: UIHighlightRect; confidence: UIAnalysisResult['matching']['matches'][number]['confidence']; status: 'needs_review' }[];
31
+ }
32
+
33
+ export type ScanState = 'queued' | 'loading' | 'extracting' | 'matching' | 'comparing' | 'completed' | 'failed' | 'cancelled';
34
+ export interface FigmaBaseline {
35
+ type: 'figma';
36
+ url: string;
37
+ /** Canonical colon node ID or copied URL-style hyphen node ID. */
38
+ nodeId?: string;
39
+ /** Explicit design units per CSS pixel; never inferred from viewport or DPR. */
40
+ unitsPerCssPixel?: number;
41
+ /** Optional explicit presentation/ARIA roles keyed by Figma node ID. */
42
+ roleMappings?: Record<string, string>;
43
+ }
44
+ export interface PngBaseline {
45
+ type: 'png';
46
+ /** Raw base64 or data:image/png;base64,...; local HTTP runner rejects file paths. */
47
+ data: string;
48
+ viewport: { width: number; height: number; devicePixelRatio: number };
49
+ fullPage?: boolean;
50
+ /** CSS-pixel scroll offset of a viewport screenshot; full-page screenshots use zero. */
51
+ scroll?: { x: number; y: number };
52
+ }
53
+ export interface ScanRequest {
54
+ baseline: string | FigmaBaseline | PngBaseline;
55
+ target: string;
56
+ scope: UISnapshot['scope'];
57
+ viewport?: { width: number; height: number };
58
+ timeout?: number;
59
+ maxNodes?: number;
60
+ includeText?: boolean;
61
+ ignoreSelectors?: string[];
62
+ requiredAssets?: string[];
63
+ analysisOptions?: import('shivax').UIAnalysisOptions;
64
+ accessibility?: boolean;
65
+ uiChecks?: boolean;
66
+ spelling?: boolean;
67
+ }
68
+ export interface ScanStatus {
69
+ id: string;
70
+ state: ScanState;
71
+ scope: UISnapshot['scope'];
72
+ expiresAt: number;
73
+ error: { name: string; message: string } | null;
74
+ lastEventId: number;
75
+ }
76
+ export interface ScanSession extends ScanStatus { token: string }
77
+ export type ScanEvent = { id: number; sessionId: string; timestamp: string } & (
78
+ { type: 'state'; state: ScanState; side?: 'baseline' | 'target'; error?: ScanStatus['error'] } |
79
+ { type: 'page'; name: 'domcontentloaded' | 'requestfailed'; side: 'baseline' | 'target'; error?: string } |
80
+ { type: 'snapshot'; side: 'baseline' | 'target'; nodes: number } |
81
+ { type: 'preview'; side: 'baseline' | 'target'; bytes: number } |
82
+ { type: 'preview-error'; side: 'baseline' | 'target'; message: string } |
83
+ { type: 'issue'; issue: UIAnalysisResult['issues'][number]; status?: 'needs_review' } |
84
+ { type: 'analysis'; diagnostics: UIAnalysisResult['diagnostics']; work: number }
85
+ );
@@ -0,0 +1,2 @@
1
+ /** Browser-safe wire-contract version. Runtime scanning lives in inspectra/node. */
2
+ export const COMPARISON_VERSION = 1;