@afixt/screenshot-utils 0.9.0 → 1.0.0
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 +2 -5
- package/README.md +20 -20
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -1
- package/dist/types/adapters/cdp.d.ts +28 -0
- package/dist/types/adapters/cdp.d.ts.map +1 -0
- package/dist/types/adapters/index.d.ts +5 -0
- package/dist/types/adapters/index.d.ts.map +1 -0
- package/dist/types/adapters/playwright.d.ts +28 -0
- package/dist/types/adapters/playwright.d.ts.map +1 -0
- package/dist/types/adapters/puppeteer.d.ts +20 -0
- package/dist/types/adapters/puppeteer.d.ts.map +1 -0
- package/dist/types/capture/element.d.ts +20 -0
- package/dist/types/capture/element.d.ts.map +1 -0
- package/dist/types/capture/index.d.ts +8 -0
- package/dist/types/capture/index.d.ts.map +1 -0
- package/dist/types/capture/long-page.d.ts +16 -0
- package/dist/types/capture/long-page.d.ts.map +1 -0
- package/dist/types/capture/page.d.ts +14 -0
- package/dist/types/capture/page.d.ts.map +1 -0
- package/dist/types/capture/responsive.d.ts +20 -0
- package/dist/types/capture/responsive.d.ts.map +1 -0
- package/dist/types/capture/settle.d.ts +14 -0
- package/dist/types/capture/settle.d.ts.map +1 -0
- package/dist/types/capture/viewport.d.ts +14 -0
- package/dist/types/capture/viewport.d.ts.map +1 -0
- package/dist/types/cli/index.d.ts +10 -0
- package/dist/types/cli/index.d.ts.map +1 -0
- package/dist/types/compose/annotate.d.ts +16 -0
- package/dist/types/compose/annotate.d.ts.map +1 -0
- package/dist/types/compose/diff.d.ts +15 -0
- package/dist/types/compose/diff.d.ts.map +1 -0
- package/dist/types/compose/heatmap.d.ts +17 -0
- package/dist/types/compose/heatmap.d.ts.map +1 -0
- package/dist/types/compose/index.d.ts +6 -0
- package/dist/types/compose/index.d.ts.map +1 -0
- package/dist/types/compose/theme.d.ts +17 -0
- package/dist/types/compose/theme.d.ts.map +1 -0
- package/dist/types/errors/adapter.d.ts +33 -0
- package/dist/types/errors/adapter.d.ts.map +1 -0
- package/dist/types/errors/base.d.ts +37 -0
- package/dist/types/errors/base.d.ts.map +1 -0
- package/dist/types/errors/capture.d.ts +109 -0
- package/dist/types/errors/capture.d.ts.map +1 -0
- package/dist/types/errors/compose.d.ts +35 -0
- package/dist/types/errors/compose.d.ts.map +1 -0
- package/dist/types/errors/index.d.ts +29 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/errors/optional.d.ts +23 -0
- package/dist/types/errors/optional.d.ts.map +1 -0
- package/dist/types/errors/redaction.d.ts +21 -0
- package/dist/types/errors/redaction.d.ts.map +1 -0
- package/dist/types/errors/tile.d.ts +29 -0
- package/dist/types/errors/tile.d.ts.map +1 -0
- package/dist/types/errors/transform.d.ts +35 -0
- package/dist/types/errors/transform.d.ts.map +1 -0
- package/dist/types/index.d.ts +58 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/redact/index.d.ts +5 -0
- package/dist/types/redact/index.d.ts.map +1 -0
- package/dist/types/redact/policy.d.ts +29 -0
- package/dist/types/redact/policy.d.ts.map +1 -0
- package/dist/types/redact/redact.d.ts +29 -0
- package/dist/types/redact/redact.d.ts.map +1 -0
- package/dist/types/tile/dzi.d.ts +18 -0
- package/dist/types/tile/dzi.d.ts.map +1 -0
- package/dist/types/tile/index.d.ts +3 -0
- package/dist/types/tile/index.d.ts.map +1 -0
- package/dist/types/transform/convert.d.ts +13 -0
- package/dist/types/transform/convert.d.ts.map +1 -0
- package/dist/types/transform/crop.d.ts +33 -0
- package/dist/types/transform/crop.d.ts.map +1 -0
- package/dist/types/transform/index.d.ts +7 -0
- package/dist/types/transform/index.d.ts.map +1 -0
- package/dist/types/transform/normalize.d.ts +14 -0
- package/dist/types/transform/normalize.d.ts.map +1 -0
- package/dist/types/transform/resize.d.ts +14 -0
- package/dist/types/transform/resize.d.ts.map +1 -0
- package/package.json +4 -3
- package/src/capture/element.js +3 -4
- package/src/capture/settle.js +3 -3
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrap a CDP (Chrome DevTools Protocol) session + Puppeteer page in the
|
|
3
|
+
* package's `PageAdapter` interface.
|
|
4
|
+
*
|
|
5
|
+
* Use this adapter when the consumer already holds a CDP session (e.g.
|
|
6
|
+
* the engine's CDP-attached runtime path described in spec § 10). The
|
|
7
|
+
* adapter routes `screenshot()` through CDP's `Page.captureScreenshot`
|
|
8
|
+
* — which avoids the page.screenshot() round-trip overhead — while
|
|
9
|
+
* delegating every other method to the supplied Puppeteer page.
|
|
10
|
+
*
|
|
11
|
+
* The Puppeteer page is required because CDP does not expose
|
|
12
|
+
* `Page.setViewport`, document scrollWidth/Height, or page reloads in a
|
|
13
|
+
* single coherent API; falling back to the Puppeteer page for those
|
|
14
|
+
* keeps the contract identical to `fromPuppeteerPage`.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
* @param {object} session A CDP session (e.g. from `page.target().createCDPSession()`).
|
|
18
|
+
* @param {object} page The same Puppeteer Page the session is attached to.
|
|
19
|
+
* @param {object} [options]
|
|
20
|
+
* @param {string} [options.label]
|
|
21
|
+
* @param {number} [options.screenshotMaxHeight] Override Chromium's 16384 limit.
|
|
22
|
+
* @returns {import('../types/index.d.ts').PageAdapter}
|
|
23
|
+
*/
|
|
24
|
+
export function fromCDPSession(session: object, page: object, options?: {
|
|
25
|
+
label?: string | undefined;
|
|
26
|
+
screenshotMaxHeight?: number | undefined;
|
|
27
|
+
}): import("../types/index.d.ts").PageAdapter;
|
|
28
|
+
//# sourceMappingURL=cdp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cdp.d.ts","sourceRoot":"","sources":["../../../src/adapters/cdp.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wCAPW,MAAM,QACN,MAAM,YAEd;IAAyB,KAAK;IACL,mBAAmB;CAC5C,GAAU,OAAO,qBAAqB,EAAE,WAAW,CAyCrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrap a Playwright `Page` object in the package's `PageAdapter` interface.
|
|
3
|
+
*
|
|
4
|
+
* Like `fromPuppeteerPage`, this adapter never imports `playwright` itself —
|
|
5
|
+
* the caller passes the `page` they already created. `playwright` remains
|
|
6
|
+
* an optional peer at the package level (spec § 10).
|
|
7
|
+
*
|
|
8
|
+
* Differences from Puppeteer's API (handled here so consumers don't have to):
|
|
9
|
+
* - Playwright uses `page.setViewportSize({ width, height })` instead of
|
|
10
|
+
* `page.setViewport(...)`. The deviceScaleFactor on the Viewport type is
|
|
11
|
+
* not settable post-hoc in Playwright — pass it at browser context
|
|
12
|
+
* creation time.
|
|
13
|
+
* - Playwright's `page.screenshot()` accepts `type: 'png' | 'jpeg'` (no
|
|
14
|
+
* webp). The adapter passes the type through; webp re-encode happens
|
|
15
|
+
* one level up in capture functions.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
* @param {object} page A Playwright Page instance (or compatible shim).
|
|
19
|
+
* @param {object} [options]
|
|
20
|
+
* @param {string} [options.label] Identifier for log lines.
|
|
21
|
+
* @param {number} [options.screenshotMaxHeight] Override Chromium's 16384 limit.
|
|
22
|
+
* @returns {import('../types/index.d.ts').PageAdapter}
|
|
23
|
+
*/
|
|
24
|
+
export function fromPlaywrightPage(page: object, options?: {
|
|
25
|
+
label?: string | undefined;
|
|
26
|
+
screenshotMaxHeight?: number | undefined;
|
|
27
|
+
}): import("../types/index.d.ts").PageAdapter;
|
|
28
|
+
//# sourceMappingURL=playwright.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwright.d.ts","sourceRoot":"","sources":["../../../src/adapters/playwright.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,yCANW,MAAM,YAEd;IAAyB,KAAK;IACL,mBAAmB;CAC5C,GAAU,OAAO,qBAAqB,EAAE,WAAW,CAgFrD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrap a Puppeteer `Page` object in the package's `PageAdapter` interface.
|
|
3
|
+
*
|
|
4
|
+
* The adapter never imports `puppeteer` itself — the caller passes in the
|
|
5
|
+
* `page` they already created. This keeps `puppeteer` an optional peer
|
|
6
|
+
* dependency at the package level (per `spec.md` § 10) and means the same
|
|
7
|
+
* adapter works against any Puppeteer 23.x+ release without re-pinning.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
* @param {object} page A Puppeteer Page instance (or compatible shim).
|
|
11
|
+
* @param {object} [options]
|
|
12
|
+
* @param {string} [options.label] Identifier for log lines (e.g. context id).
|
|
13
|
+
* @param {number} [options.screenshotMaxHeight] Override Chromium's 16384 limit.
|
|
14
|
+
* @returns {import('../types/index.d.ts').PageAdapter}
|
|
15
|
+
*/
|
|
16
|
+
export function fromPuppeteerPage(page: object, options?: {
|
|
17
|
+
label?: string | undefined;
|
|
18
|
+
screenshotMaxHeight?: number | undefined;
|
|
19
|
+
}): import("../types/index.d.ts").PageAdapter;
|
|
20
|
+
//# sourceMappingURL=puppeteer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"puppeteer.d.ts","sourceRoot":"","sources":["../../../src/adapters/puppeteer.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,wCANW,MAAM,YAEd;IAAyB,KAAK;IACL,mBAAmB;CAC5C,GAAU,OAAO,qBAAqB,EAAE,WAAW,CAgErD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture a single element by selector or xpath.
|
|
3
|
+
*
|
|
4
|
+
* Implements `spec.md` § 8.1.3. **Deprecated as the engine's primary path**
|
|
5
|
+
* — prefer `capturePage` + `cropMany`. Retained because (a) the engine
|
|
6
|
+
* needs a like-for-like replacement during the Phase 3 migration and
|
|
7
|
+
* (b) direct callers (Investigator, ad-hoc tooling) still want it.
|
|
8
|
+
*
|
|
9
|
+
* Failure modes return an ElementCaptureResult with `bytes === null` and
|
|
10
|
+
* `reason` populated rather than throwing. This matches the engine's
|
|
11
|
+
* current `{ screenshot, reason }` contract so consumers can swap
|
|
12
|
+
* implementations without changing control flow.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
* @param {import('../types/index.d.ts').PageAdapter} adapter
|
|
16
|
+
* @param {import('../types/index.d.ts').ElementCaptureOptions} [options]
|
|
17
|
+
* @returns {Promise<import('../types/index.d.ts').ElementCaptureResult>}
|
|
18
|
+
*/
|
|
19
|
+
export function captureElement(adapter: import("../types/index.d.ts").PageAdapter, options?: import("../types/index.d.ts").ElementCaptureOptions): Promise<import("../types/index.d.ts").ElementCaptureResult>;
|
|
20
|
+
//# sourceMappingURL=element.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../../src/capture/element.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;GAiBG;AACH,wCAJW,OAAO,qBAAqB,EAAE,WAAW,YACzC,OAAO,qBAAqB,EAAE,qBAAqB,GACjD,OAAO,CAAC,OAAO,qBAAqB,EAAE,oBAAoB,CAAC,CA+GvE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { capturePage } from "./page.js";
|
|
2
|
+
import { waitForStable } from "./settle.js";
|
|
3
|
+
import { captureLongPage } from "./long-page.js";
|
|
4
|
+
import { captureElement } from "./element.js";
|
|
5
|
+
import { captureViewport } from "./viewport.js";
|
|
6
|
+
import { captureResponsive } from "./responsive.js";
|
|
7
|
+
export { capturePage, waitForStable, captureLongPage, captureElement, captureViewport, captureResponsive };
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/capture/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture a page taller than the browser's single-screenshot height limit
|
|
3
|
+
* by scrolling, capturing strips, and stitching them via `sharp`.
|
|
4
|
+
*
|
|
5
|
+
* Implements `spec.md` § 8.1.4. If the document height fits within the
|
|
6
|
+
* adapter's `screenshotMaxHeight` capability, delegates to the regular
|
|
7
|
+
* `adapter.screenshot({ fullPage: true })`. Otherwise iterates over
|
|
8
|
+
* viewport-height strips, scrolling between captures.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
* @param {import('../types/index.d.ts').PageAdapter} adapter
|
|
12
|
+
* @param {import('../types/index.d.ts').LongPageCaptureOptions} [options]
|
|
13
|
+
* @returns {Promise<import('../types/index.d.ts').CaptureResult>}
|
|
14
|
+
*/
|
|
15
|
+
export function captureLongPage(adapter: import("../types/index.d.ts").PageAdapter, options?: import("../types/index.d.ts").LongPageCaptureOptions): Promise<import("../types/index.d.ts").CaptureResult>;
|
|
16
|
+
//# sourceMappingURL=long-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"long-page.d.ts","sourceRoot":"","sources":["../../../src/capture/long-page.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AACH,yCAJW,OAAO,qBAAqB,EAAE,WAAW,YACzC,OAAO,qBAAqB,EAAE,sBAAsB,GAClD,OAAO,CAAC,OAAO,qBAAqB,EAAE,aAAa,CAAC,CA8DhE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture a full page (or just the viewport) via a `PageAdapter`.
|
|
3
|
+
*
|
|
4
|
+
* Implements `spec.md` § 8.1.1. Lazy-loads `sharp` only when the requested
|
|
5
|
+
* output format is one the browser can't produce directly (today: webp;
|
|
6
|
+
* Chromium emits png/jpeg natively).
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @param {import('../types/index.d.ts').PageAdapter} adapter
|
|
10
|
+
* @param {import('../types/index.d.ts').CaptureOptions} [options]
|
|
11
|
+
* @returns {Promise<import('../types/index.d.ts').CaptureResult>}
|
|
12
|
+
*/
|
|
13
|
+
export function capturePage(adapter: import("../types/index.d.ts").PageAdapter, options?: import("../types/index.d.ts").CaptureOptions): Promise<import("../types/index.d.ts").CaptureResult>;
|
|
14
|
+
//# sourceMappingURL=page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/capture/page.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,qCAJW,OAAO,qBAAqB,EAAE,WAAW,YACzC,OAAO,qBAAqB,EAAE,cAAc,GAC1C,OAAO,CAAC,OAAO,qBAAqB,EAAE,aAAa,CAAC,CAkFhE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture the same page at multiple viewport sizes in one orchestrated
|
|
3
|
+
* call. Useful for responsive accessibility audits.
|
|
4
|
+
*
|
|
5
|
+
* Implements `spec.md` § 8.1.5.
|
|
6
|
+
*
|
|
7
|
+
* - `parallelism: 1` (default) is the safe choice — driving viewport
|
|
8
|
+
* changes against a single page in parallel produces non-deterministic
|
|
9
|
+
* results. Consumers can bump it above 1 only if they hand over
|
|
10
|
+
* distinct adapters via the (Phase 4) per-context capture API.
|
|
11
|
+
* - `reloadBetween: true` (default) reloads the page between viewport
|
|
12
|
+
* changes so media queries and layout re-evaluate cleanly.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
* @param {import('../types/index.d.ts').PageAdapter} adapter
|
|
16
|
+
* @param {import('../types/index.d.ts').ResponsiveCaptureOptions} options
|
|
17
|
+
* @returns {Promise<import('../types/index.d.ts').ResponsiveCaptureResult>}
|
|
18
|
+
*/
|
|
19
|
+
export function captureResponsive(adapter: import("../types/index.d.ts").PageAdapter, options: import("../types/index.d.ts").ResponsiveCaptureOptions): Promise<import("../types/index.d.ts").ResponsiveCaptureResult>;
|
|
20
|
+
//# sourceMappingURL=responsive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responsive.d.ts","sourceRoot":"","sources":["../../../src/capture/responsive.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;GAiBG;AACH,2CAJW,OAAO,qBAAqB,EAAE,WAAW,WACzC,OAAO,qBAAqB,EAAE,wBAAwB,GACpD,OAAO,CAAC,OAAO,qBAAqB,EAAE,uBAAuB,CAAC,CA6C1E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wait for the page to reach a render-stable state before capture.
|
|
3
|
+
*
|
|
4
|
+
* Implements `spec.md` § 8.1.6. The whole settle logic runs inside the
|
|
5
|
+
* page context via a single `adapter.evaluate()` call to avoid Node ↔
|
|
6
|
+
* browser round-trips for each sub-check.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @param {import('../types/index.d.ts').PageAdapter} adapter
|
|
10
|
+
* @param {import('../types/index.d.ts').WaitForStableOptions} [options]
|
|
11
|
+
* @returns {Promise<import('../types/index.d.ts').StabilityReport>}
|
|
12
|
+
*/
|
|
13
|
+
export function waitForStable(adapter: import("../types/index.d.ts").PageAdapter, options?: import("../types/index.d.ts").WaitForStableOptions): Promise<import("../types/index.d.ts").StabilityReport>;
|
|
14
|
+
//# sourceMappingURL=settle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settle.d.ts","sourceRoot":"","sources":["../../../src/capture/settle.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,uCAJW,OAAO,qBAAqB,EAAE,WAAW,YACzC,OAAO,qBAAqB,EAAE,oBAAoB,GAChD,OAAO,CAAC,OAAO,qBAAqB,EAAE,eAAe,CAAC,CAqBlE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture only what is currently scrolled into view (no full-page scroll
|
|
3
|
+
* or stitching). Useful for AI evidence and above-the-fold checks.
|
|
4
|
+
*
|
|
5
|
+
* Implements `spec.md` § 8.1.2. Thin wrapper around `capturePage` that
|
|
6
|
+
* forces `fullPage: false` regardless of caller options.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @param {import('../types/index.d.ts').PageAdapter} adapter
|
|
10
|
+
* @param {import('../types/index.d.ts').CaptureOptions} [options]
|
|
11
|
+
* @returns {Promise<import('../types/index.d.ts').CaptureResult>}
|
|
12
|
+
*/
|
|
13
|
+
export function captureViewport(adapter: import("../types/index.d.ts").PageAdapter, options?: import("../types/index.d.ts").CaptureOptions): Promise<import("../types/index.d.ts").CaptureResult>;
|
|
14
|
+
//# sourceMappingURL=viewport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../../src/capture/viewport.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,yCAJW,OAAO,qBAAqB,EAAE,WAAW,YACzC,OAAO,qBAAqB,EAAE,cAAc,GAC1C,OAAO,CAAC,OAAO,qBAAqB,EAAE,aAAa,CAAC,CAIhE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI entry. Returns the process exit code (0 = success).
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
* @param {string[]} argv The argv array minus the node binary + script path
|
|
6
|
+
* (i.e. process.argv.slice(2)).
|
|
7
|
+
* @returns {Promise<number>}
|
|
8
|
+
*/
|
|
9
|
+
export function main(argv: string[]): Promise<number>;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/index.js"],"names":[],"mappings":"AA2BA;;;;;;;GAOG;AACH,2BAJW,MAAM,EAAE,GAEN,OAAO,CAAC,MAAM,CAAC,CAoB3B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render annotation overlays onto a screenshot buffer.
|
|
3
|
+
*
|
|
4
|
+
* Implements `spec.md` § 8.3.1 with pure-sharp rendering — annotations are
|
|
5
|
+
* serialized to an SVG layer and composited onto the source image. No
|
|
6
|
+
* `@napi-rs/canvas` dep in v1.0 (deferred to v1.1 per spec § 22).
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @param {Buffer} input
|
|
10
|
+
* @param {Array<import('../types/index.d.ts').Annotation>} annotations
|
|
11
|
+
* @param {import('../types/index.d.ts').AnnotateOptions} [options]
|
|
12
|
+
* @returns {Promise<Buffer>}
|
|
13
|
+
*/
|
|
14
|
+
export function annotate(input: Buffer, annotations: Array<import("../types/index.d.ts").Annotation>, options?: import("../types/index.d.ts").AnnotateOptions): Promise<Buffer>;
|
|
15
|
+
export const MAX_ANNOTATIONS: 5000;
|
|
16
|
+
//# sourceMappingURL=annotate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotate.d.ts","sourceRoot":"","sources":["../../../src/compose/annotate.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;GAYG;AACH,gCALW,MAAM,eACN,KAAK,CAAC,OAAO,qBAAqB,EAAE,UAAU,CAAC,YAC/C,OAAO,qBAAqB,EAAE,eAAe,GAC3C,OAAO,CAAC,MAAM,CAAC,CA+C3B;AAnED,8BAAwB,IAAI,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Perceptual visual diff between two image buffers.
|
|
3
|
+
*
|
|
4
|
+
* Implements `spec.md` § 8.3.4. Requires the optional peer
|
|
5
|
+
* `pixelmatch` (≥ v7); throws `OptionalDependencyMissingError` if it
|
|
6
|
+
* isn't installed.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @param {Buffer} bufferA
|
|
10
|
+
* @param {Buffer} bufferB
|
|
11
|
+
* @param {import('../types/index.d.ts').DiffOptions} [options]
|
|
12
|
+
* @returns {Promise<import('../types/index.d.ts').DiffResult>}
|
|
13
|
+
*/
|
|
14
|
+
export function diff(bufferA: Buffer, bufferB: Buffer, options?: import("../types/index.d.ts").DiffOptions): Promise<import("../types/index.d.ts").DiffResult>;
|
|
15
|
+
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/compose/diff.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;GAYG;AACH,8BALW,MAAM,WACN,MAAM,YACN,OAAO,qBAAqB,EAAE,WAAW,GACvC,OAAO,CAAC,OAAO,qBAAqB,EAAE,UAAU,CAAC,CA2D7D"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render a kernel-density heatmap over a screenshot.
|
|
3
|
+
*
|
|
4
|
+
* Implements `spec.md` § 8.3.3 with a simple SVG-circles + blur approach.
|
|
5
|
+
* Each point gets a circle whose radius scales with weight; the
|
|
6
|
+
* collection is then blurred to produce a smooth heatmap surface and
|
|
7
|
+
* composited onto the source using the requested blend mode.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
* @param {Buffer} input
|
|
11
|
+
* @param {Array<import('../types/index.d.ts').HeatmapPoint>} points
|
|
12
|
+
* @param {import('../types/index.d.ts').HeatmapOptions} [options]
|
|
13
|
+
* @returns {Promise<Buffer>}
|
|
14
|
+
*/
|
|
15
|
+
export function heatmap(input: Buffer, points: Array<import("../types/index.d.ts").HeatmapPoint>, options?: import("../types/index.d.ts").HeatmapOptions): Promise<Buffer>;
|
|
16
|
+
export const MAX_POINTS: 100000;
|
|
17
|
+
//# sourceMappingURL=heatmap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heatmap.d.ts","sourceRoot":"","sources":["../../../src/compose/heatmap.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;GAaG;AACH,+BALW,MAAM,UACN,KAAK,CAAC,OAAO,qBAAqB,EAAE,YAAY,CAAC,YACjD,OAAO,qBAAqB,EAAE,cAAc,GAC1C,OAAO,CAAC,MAAM,CAAC,CA0D3B;AAzED,yBAAmB,MAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/compose/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default annotation theme shipped with the package.
|
|
3
|
+
*
|
|
4
|
+
* Implements `spec.md` § 8.3.2. The four severity keys cover the standard
|
|
5
|
+
* accessibility-issue grading. Consumers can replace any subset by passing
|
|
6
|
+
* their own theme object to `annotate()`; the function shallow-merges over
|
|
7
|
+
* this default.
|
|
8
|
+
*
|
|
9
|
+
* Color choices target WCAG 2.2 AA when rendered against typical light or
|
|
10
|
+
* dark page backgrounds. Stroke widths are in CSS px and scale with the
|
|
11
|
+
* captured image's pixel space.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
* @type {Readonly<import('../types/index.d.ts').AnnotationTheme>}
|
|
15
|
+
*/
|
|
16
|
+
export const defaultTheme: Readonly<import("../types/index.d.ts").AnnotationTheme>;
|
|
17
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/compose/theme.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,2BAFU,QAAQ,CAAC,OAAO,qBAAqB,EAAE,eAAe,CAAC,CA2B9D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base for errors arising at the `PageAdapter` boundary
|
|
3
|
+
* (third-party browser object integration).
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export class AdapterError extends ScreenshotUtilsError {
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} message
|
|
10
|
+
* @param {object} [options]
|
|
11
|
+
*/
|
|
12
|
+
constructor(message: string, options?: object);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The wrapped third-party page object is missing a method required by the
|
|
16
|
+
* `PageAdapter` contract (spec § 10). Deterministic — the caller passed the
|
|
17
|
+
* wrong kind of object.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export class AdapterContractError extends AdapterError {
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The underlying puppeteer / playwright / CDP call threw. Wrapped so consumers
|
|
25
|
+
* can rely on the package's error shape without sniffing browser-library
|
|
26
|
+
* internals. Retriable because most browser-API errors are transient.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export class BrowserApiError extends AdapterError {
|
|
31
|
+
}
|
|
32
|
+
import { ScreenshotUtilsError } from "./base.js";
|
|
33
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/errors/adapter.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH;IACI;;;OAGG;IACH,qBAHW,MAAM,YACN,MAAM,EAMhB;CACJ;AAED;;;;;;GAMG;AACH;CAUC;AAED;;;;;;GAMG;AACH;CAUC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract base class for all errors thrown by `@afixt/screenshot-utils`.
|
|
3
|
+
*
|
|
4
|
+
* Concrete subclasses must:
|
|
5
|
+
* - set a stable `code` string (machine-readable; never localized)
|
|
6
|
+
* - set `retriable: true` only when a consumer-side retry has a chance of succeeding
|
|
7
|
+
* without operator intervention (transient browser timeouts, transport blips, etc.)
|
|
8
|
+
* - never include PII in `context`. The platform privacy rules in
|
|
9
|
+
* the parent CLAUDE.md forbid logging user data; the same applies to
|
|
10
|
+
* error payloads since they are commonly logged verbatim.
|
|
11
|
+
*
|
|
12
|
+
* See `spec.md` § 14 for the full error model.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export class ScreenshotUtilsError extends Error {
|
|
17
|
+
/**
|
|
18
|
+
* Construct an error. Subclasses set `code` and `retriable`; callers may
|
|
19
|
+
* supply `reason`, `cause`, and `context`.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} message Human-readable summary. Should not include PII.
|
|
22
|
+
* @param {object} [options]
|
|
23
|
+
* @param {string} [options.reason] Sub-classification (enum string) — see spec § 14.3.
|
|
24
|
+
* @param {Error} [options.cause] Underlying error being wrapped, preserved for stack traces.
|
|
25
|
+
* @param {Record<string, unknown>} [options.context] Structured debug data. NO PII.
|
|
26
|
+
*/
|
|
27
|
+
constructor(message: string, { reason, cause, context }?: {
|
|
28
|
+
reason?: string | undefined;
|
|
29
|
+
cause?: Error | undefined;
|
|
30
|
+
context?: Record<string, unknown> | undefined;
|
|
31
|
+
});
|
|
32
|
+
code: string;
|
|
33
|
+
retriable: boolean;
|
|
34
|
+
reason: string | undefined;
|
|
35
|
+
context: Record<string, unknown> | undefined;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/errors/base.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH;IACI;;;;;;;;;OASG;IACH,qBANW,MAAM,+BAEd;QAAyB,MAAM;QACN,KAAK;QACY,OAAO;KACnD,EAiBA;IAXG,aAAoC;IACpC,mBAAsB;IAElB,2BAAoB;IAGpB,6CAAsB;CAMjC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base for any error arising during the capture phase
|
|
3
|
+
* (browser interaction, scroll, settle, screenshot).
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export class CaptureError extends ScreenshotUtilsError {
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The browser context is unreachable (process crashed, pool exhausted, etc.).
|
|
11
|
+
* Retriable because the consumer may obtain a fresh browser context.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export class BrowserUnavailableError extends CaptureError {
|
|
16
|
+
/**
|
|
17
|
+
* @param {string} message
|
|
18
|
+
* @param {object} [options]
|
|
19
|
+
*/
|
|
20
|
+
constructor(message: string, options?: object);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Document scrollHeight exceeds the configured `maxHeight` ceiling.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export class PageTooTallError extends CaptureError {
|
|
28
|
+
/**
|
|
29
|
+
* @param {string} message
|
|
30
|
+
* @param {object} [options]
|
|
31
|
+
*/
|
|
32
|
+
constructor(message: string, options?: object);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The requested selector / xpath returned no DOM node.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export class ElementNotFoundError extends CaptureError {
|
|
40
|
+
/**
|
|
41
|
+
* @param {string} message
|
|
42
|
+
* @param {object} [options]
|
|
43
|
+
*/
|
|
44
|
+
constructor(message: string, options?: object);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The element exists but has zero size or is hidden from layout.
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export class ElementNotVisibleError extends CaptureError {
|
|
52
|
+
/**
|
|
53
|
+
* @param {string} message
|
|
54
|
+
* @param {object} [options]
|
|
55
|
+
*/
|
|
56
|
+
constructor(message: string, options?: object);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A verification snippet was provided but the live DOM did not match.
|
|
60
|
+
*
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
export class ElementMismatchError extends CaptureError {
|
|
64
|
+
/**
|
|
65
|
+
* @param {string} message
|
|
66
|
+
* @param {object} [options]
|
|
67
|
+
*/
|
|
68
|
+
constructor(message: string, options?: object);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Element dimensions exceed `maxDimensions` (default 4000×4000 CSS px).
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
export class ElementTooLargeError extends CaptureError {
|
|
76
|
+
/**
|
|
77
|
+
* @param {string} message
|
|
78
|
+
* @param {object} [options]
|
|
79
|
+
*/
|
|
80
|
+
constructor(message: string, options?: object);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* `waitForStable` exceeded its `maxWait`. The page was still settling.
|
|
84
|
+
* Retriable because subsequent calls may catch a stable frame.
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
export class StabilityTimeoutError extends CaptureError {
|
|
89
|
+
/**
|
|
90
|
+
* @param {string} message
|
|
91
|
+
* @param {object} [options]
|
|
92
|
+
*/
|
|
93
|
+
constructor(message: string, options?: object);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The underlying browser screenshot call exceeded the configured `timeout`.
|
|
97
|
+
* Retriable for the same reasons as StabilityTimeoutError.
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
export class CaptureTimeoutError extends CaptureError {
|
|
102
|
+
/**
|
|
103
|
+
* @param {string} message
|
|
104
|
+
* @param {object} [options]
|
|
105
|
+
*/
|
|
106
|
+
constructor(message: string, options?: object);
|
|
107
|
+
}
|
|
108
|
+
import { ScreenshotUtilsError } from "./base.js";
|
|
109
|
+
//# sourceMappingURL=capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../../src/errors/capture.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH;CAaC;AAED;;;;;GAKG;AACH;IACI;;;OAGG;IACH,qBAHW,MAAM,YACN,MAAM,EAMhB;CACJ;AAED;;;;GAIG;AACH;IACI;;;OAGG;IACH,qBAHW,MAAM,YACN,MAAM,EAMhB;CACJ;AAED;;;;GAIG;AACH;IACI;;;OAGG;IACH,qBAHW,MAAM,YACN,MAAM,EAMhB;CACJ;AAED;;;;GAIG;AACH;IACI;;;OAGG;IACH,qBAHW,MAAM,YACN,MAAM,EAMhB;CACJ;AAED;;;;GAIG;AACH;IACI;;;OAGG;IACH,qBAHW,MAAM,YACN,MAAM,EAMhB;CACJ;AAED;;;;GAIG;AACH;IACI;;;OAGG;IACH,qBAHW,MAAM,YACN,MAAM,EAMhB;CACJ;AAED;;;;;GAKG;AACH;IACI;;;OAGG;IACH,qBAHW,MAAM,YACN,MAAM,EAMhB;CACJ;AAED;;;;;GAKG;AACH;IACI;;;OAGG;IACH,qBAHW,MAAM,YACN,MAAM,EAMhB;CACJ"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base for errors arising during composition (annotate, heatmap, diff, composite).
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export class ComposeError extends ScreenshotUtilsError {
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} message
|
|
9
|
+
* @param {object} [options]
|
|
10
|
+
*/
|
|
11
|
+
constructor(message: string, options?: object);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* `diff()` was called with two images whose dimensions don't match.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export class DimensionMismatchError extends ComposeError {
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* An annotation theme is missing a required key or has invalid values.
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export class ThemeError extends ComposeError {
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A heatmap point is malformed (e.g., missing x/y, negative weight, NaN).
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export class HeatmapPointError extends ComposeError {
|
|
33
|
+
}
|
|
34
|
+
import { ScreenshotUtilsError } from "./base.js";
|
|
35
|
+
//# sourceMappingURL=compose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../../src/errors/compose.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH;IACI;;;OAGG;IACH,qBAHW,MAAM,YACN,MAAM,EAMhB;CACJ;AAED;;;;GAIG;AACH;CAUC;AAED;;;;GAIG;AACH;CAUC;AAED;;;;GAIG;AACH;CAUC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ScreenshotUtilsError } from "./base.js";
|
|
2
|
+
import { CaptureError } from "./capture.js";
|
|
3
|
+
import { BrowserUnavailableError } from "./capture.js";
|
|
4
|
+
import { PageTooTallError } from "./capture.js";
|
|
5
|
+
import { ElementNotFoundError } from "./capture.js";
|
|
6
|
+
import { ElementNotVisibleError } from "./capture.js";
|
|
7
|
+
import { ElementMismatchError } from "./capture.js";
|
|
8
|
+
import { ElementTooLargeError } from "./capture.js";
|
|
9
|
+
import { StabilityTimeoutError } from "./capture.js";
|
|
10
|
+
import { CaptureTimeoutError } from "./capture.js";
|
|
11
|
+
import { TransformError } from "./transform.js";
|
|
12
|
+
import { InvalidRectError } from "./transform.js";
|
|
13
|
+
import { UnsupportedFormatError } from "./transform.js";
|
|
14
|
+
import { BufferCorruptError } from "./transform.js";
|
|
15
|
+
import { ComposeError } from "./compose.js";
|
|
16
|
+
import { DimensionMismatchError } from "./compose.js";
|
|
17
|
+
import { ThemeError } from "./compose.js";
|
|
18
|
+
import { HeatmapPointError } from "./compose.js";
|
|
19
|
+
import { TileError } from "./tile.js";
|
|
20
|
+
import { TileSizeError } from "./tile.js";
|
|
21
|
+
import { TileWriteError } from "./tile.js";
|
|
22
|
+
import { RedactionError } from "./redaction.js";
|
|
23
|
+
import { PolicyError } from "./redaction.js";
|
|
24
|
+
import { AdapterError } from "./adapter.js";
|
|
25
|
+
import { AdapterContractError } from "./adapter.js";
|
|
26
|
+
import { BrowserApiError } from "./adapter.js";
|
|
27
|
+
import { OptionalDependencyMissingError } from "./optional.js";
|
|
28
|
+
export { ScreenshotUtilsError, CaptureError, BrowserUnavailableError, PageTooTallError, ElementNotFoundError, ElementNotVisibleError, ElementMismatchError, ElementTooLargeError, StabilityTimeoutError, CaptureTimeoutError, TransformError, InvalidRectError, UnsupportedFormatError, BufferCorruptError, ComposeError, DimensionMismatchError, ThemeError, HeatmapPointError, TileError, TileSizeError, TileWriteError, RedactionError, PolicyError, AdapterError, AdapterContractError, BrowserApiError, OptionalDependencyMissingError };
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/errors/index.js"],"names":[],"mappings":""}
|