@ingcreators/annot-playwright 0.2.0 → 0.3.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 +46 -0
- package/dist/fixture.d.ts +8 -1
- package/dist/index.js +28 -25
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @ingcreators/annot-playwright
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b3e8e53: Both packages now accept an optional `encode` option that flows through to `@ingcreators/annot-annotator@0.3.0`'s `toEncoded()` / `decodeAndEncodeImage()` pipeline. Achieves feature parity with the Chrome extension's "Save size" + "Format smart" capture settings for AI-agent (`annot-mcp`) and Playwright-test (`annot-playwright`) flows.
|
|
8
|
+
|
|
9
|
+
## `annot-playwright`
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
await annotator.annotateScreenshot(page, {
|
|
13
|
+
annotations: [...],
|
|
14
|
+
encode: { format: "smart", saveSizePreset: "standard" },
|
|
15
|
+
});
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Returned bytes shrink to PNG-8 / JPEG / resized PNG-32 per the smart heuristic; default behaviour when `encode` is omitted matches v0.2.x (raw PNG-32 from the annotator).
|
|
19
|
+
|
|
20
|
+
## `annot-mcp`
|
|
21
|
+
|
|
22
|
+
All five tools (`annot_annotate_screenshot`, `annot_annotate_url`, `annot_redact_screenshot`, `annot_redact_url`, `annot_compare_screenshots`) accept the same `encode` shape on their MCP `inputSchema`. Agents can specify any subset:
|
|
23
|
+
|
|
24
|
+
```jsonc
|
|
25
|
+
{
|
|
26
|
+
"url": "https://...",
|
|
27
|
+
"annotations": [...],
|
|
28
|
+
"encode": {
|
|
29
|
+
"format": "smart",
|
|
30
|
+
"saveSizePreset": "light",
|
|
31
|
+
"smartFallback": "jpeg"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`format`: `"smart"` (default — PNG-8 for UI / PNG / JPEG for photos) / `"png"` / `"jpeg"`.
|
|
37
|
+
`saveSizePreset`: `"light"` 1280px / `"standard"` 1920px / `"highQuality"` 2560px / `"original"` no resize.
|
|
38
|
+
`smartFallback`, `smartColorThreshold`, `jpegPercent` all configurable.
|
|
39
|
+
|
|
40
|
+
Output `mimeType` flips to `image/jpeg` when the chosen path emits JPEG, so MCP clients render inline correctly. The text confirmation when `output` is set now includes the chosen format and any `reason` (`png-8` / `photo-fallback-jpeg` / `imagequant-missing` / …) for observability.
|
|
41
|
+
|
|
42
|
+
Backwards-compatible: when `encode` is omitted, all tools emit PNG-32 bytes verbatim (no decode/encode round-trip, same as v0.1.x / v0.2.x).
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [86d0853]
|
|
47
|
+
- @ingcreators/annot-annotator@0.3.0
|
|
48
|
+
|
|
3
49
|
## 0.2.0
|
|
4
50
|
|
|
5
51
|
### Minor Changes
|
package/dist/fixture.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Annotator, BboxAnnotation } from '@ingcreators/annot-annotator';
|
|
1
|
+
import { Annotator, BboxAnnotation, EncodeOptions } from '@ingcreators/annot-annotator';
|
|
2
2
|
/**
|
|
3
3
|
* Minimal Playwright `Page` surface the fixture relies on. The full
|
|
4
4
|
* `@playwright/test` `Page` type is much wider, but importing it
|
|
@@ -37,10 +37,17 @@ export type AnnotateScreenshotOptions = {
|
|
|
37
37
|
annotationsSvg: string;
|
|
38
38
|
annotations?: never;
|
|
39
39
|
fullPage?: boolean;
|
|
40
|
+
/** Optional encoder settings (since 0.3.0). When omitted the
|
|
41
|
+
* fixture emits PNG-32 verbatim (matches 0.1.x / 0.2.x
|
|
42
|
+
* behaviour). When set, the annotated bytes go through
|
|
43
|
+
* `decodeAndEncodeImage()` for `format` / `saveSizePreset`
|
|
44
|
+
* application. */
|
|
45
|
+
encode?: Partial<EncodeOptions>;
|
|
40
46
|
} | {
|
|
41
47
|
annotations: readonly BboxAnnotation[];
|
|
42
48
|
annotationsSvg?: never;
|
|
43
49
|
fullPage?: boolean;
|
|
50
|
+
encode?: Partial<EncodeOptions>;
|
|
44
51
|
};
|
|
45
52
|
export interface PlaywrightAnnotator {
|
|
46
53
|
raw: Annotator;
|
package/dist/index.js
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
import { createAnnotator as
|
|
2
|
-
import { arrowBetween as
|
|
3
|
-
import { test as
|
|
4
|
-
import { expect as
|
|
5
|
-
const
|
|
1
|
+
import { createAnnotator as d, bboxAnnotationsToSvg as f, DEFAULT_ENCODE_OPTIONS as h, decodeAndEncodeImage as l } from "@ingcreators/annot-annotator";
|
|
2
|
+
import { arrowBetween as A, bboxAnnotationsToSvg as D, rectForBoundingBox as O, textAt as E } from "@ingcreators/annot-annotator";
|
|
3
|
+
import { test as w } from "@playwright/test";
|
|
4
|
+
import { expect as T } from "@playwright/test";
|
|
5
|
+
const P = w.extend({
|
|
6
6
|
// biome-ignore lint/correctness/noEmptyPattern: Playwright fixture signature requires the empty destructure.
|
|
7
7
|
annotator: async ({}, n) => {
|
|
8
|
-
const
|
|
8
|
+
const e = d();
|
|
9
9
|
await n({
|
|
10
|
-
raw:
|
|
11
|
-
annotateScreenshot: (t,
|
|
10
|
+
raw: e,
|
|
11
|
+
annotateScreenshot: (t, o) => u(e, t, o)
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
async function
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
height: r
|
|
15
|
+
async function u(n, e, t) {
|
|
16
|
+
const o = await e.screenshot({ fullPage: t.fullPage }), { width: r, height: i } = b(o), s = `data:image/png;base64,${o.toString("base64")}`, c = "annotations" in t && t.annotations !== void 0 ? f(t.annotations) : t.annotationsSvg ?? "", a = n.toPng({
|
|
17
|
+
originalDataUrl: s,
|
|
18
|
+
annotationsSvg: c,
|
|
19
|
+
width: r,
|
|
20
|
+
height: i
|
|
22
21
|
});
|
|
22
|
+
if (!t.encode || Object.keys(t.encode).length === 0)
|
|
23
|
+
return a;
|
|
24
|
+
const g = { ...h, ...t.encode };
|
|
25
|
+
return (await l(a, g)).bytes;
|
|
23
26
|
}
|
|
24
|
-
function
|
|
27
|
+
function b(n) {
|
|
25
28
|
if (n.length < 24)
|
|
26
29
|
throw new Error("PNG too short to contain IHDR chunk");
|
|
27
|
-
const
|
|
28
|
-
return { width: t, height:
|
|
30
|
+
const e = new DataView(n.buffer, n.byteOffset, n.byteLength), t = e.getUint32(16, !1), o = e.getUint32(20, !1);
|
|
31
|
+
return { width: t, height: o };
|
|
29
32
|
}
|
|
30
33
|
export {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
u as annotateScreenshot,
|
|
35
|
+
A as arrowBetween,
|
|
36
|
+
D as bboxAnnotationsToSvg,
|
|
37
|
+
T as expect,
|
|
38
|
+
O as rectForBoundingBox,
|
|
39
|
+
P as test,
|
|
40
|
+
E as textAt
|
|
38
41
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ingcreators/annot-playwright",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Playwright fixture for annotated screenshots — emit annotated PNGs from failing tests without leaving the test file. Pairs `test.extend({ annotator })` with the headless renderer from @ingcreators/annot-annotator.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "ingcreators",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"vite-plugin-dts": "^5.0.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@ingcreators/annot-annotator": "0.
|
|
51
|
+
"@ingcreators/annot-annotator": "0.3.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@playwright/test": "^1.40.0"
|