@ingcreators/annot-playwright 0.2.0 → 0.3.1
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 +54 -0
- package/README.md +1 -1
- package/dist/fixture.d.ts +8 -1
- package/dist/index.js +30 -36
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
# @ingcreators/annot-playwright
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [806badc]
|
|
8
|
+
- Updated dependencies [df1a429]
|
|
9
|
+
- @ingcreators/annot-annotator@0.5.0
|
|
10
|
+
|
|
11
|
+
## 0.3.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 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.
|
|
16
|
+
|
|
17
|
+
## `annot-playwright`
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
await annotator.annotateScreenshot(page, {
|
|
21
|
+
annotations: [...],
|
|
22
|
+
encode: { format: "smart", saveSizePreset: "standard" },
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
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).
|
|
27
|
+
|
|
28
|
+
## `annot-mcp`
|
|
29
|
+
|
|
30
|
+
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:
|
|
31
|
+
|
|
32
|
+
```jsonc
|
|
33
|
+
{
|
|
34
|
+
"url": "https://...",
|
|
35
|
+
"annotations": [...],
|
|
36
|
+
"encode": {
|
|
37
|
+
"format": "smart",
|
|
38
|
+
"saveSizePreset": "light",
|
|
39
|
+
"smartFallback": "jpeg"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`format`: `"smart"` (default — PNG-8 for UI / PNG / JPEG for photos) / `"png"` / `"jpeg"`.
|
|
45
|
+
`saveSizePreset`: `"light"` 1280px / `"standard"` 1920px / `"highQuality"` 2560px / `"original"` no resize.
|
|
46
|
+
`smartFallback`, `smartColorThreshold`, `jpegPercent` all configurable.
|
|
47
|
+
|
|
48
|
+
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.
|
|
49
|
+
|
|
50
|
+
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).
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- Updated dependencies [86d0853]
|
|
55
|
+
- @ingcreators/annot-annotator@0.3.0
|
|
56
|
+
|
|
3
57
|
## 0.2.0
|
|
4
58
|
|
|
5
59
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -161,7 +161,7 @@ const annotator = createAnnotator({
|
|
|
161
161
|
— Phase 0 feasibility report.
|
|
162
162
|
- [`docs/plans/_done/annot-annotator-package.md`](../../docs/plans/_done/annot-annotator-package.md)
|
|
163
163
|
— Phase 1 annotator design.
|
|
164
|
-
- [`docs/plans/annot-playwright-fixture.md`](../../docs/plans/annot-playwright-fixture.md)
|
|
164
|
+
- [`docs/plans/_done/annot-playwright-fixture.md`](../../docs/plans/_done/annot-playwright-fixture.md)
|
|
165
165
|
— Phase 2 design (this package).
|
|
166
166
|
- [`PRODUCT_DIRECTION.md`](../../PRODUCT_DIRECTION.md) — strategic
|
|
167
167
|
context.
|
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,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
1
|
+
import { DEFAULT_ENCODE_OPTIONS as e, arrowBetween as t, bboxAnnotationsToSvg as n, bboxAnnotationsToSvg as r, createAnnotator as i, decodeAndEncodeImage as a, rectForBoundingBox as o, textAt as s } from "@ingcreators/annot-annotator";
|
|
2
|
+
import { expect as c, test as l } from "@playwright/test";
|
|
3
|
+
//#region src/fixture.ts
|
|
4
|
+
var u = l.extend({ annotator: async ({}, e) => {
|
|
5
|
+
let t = i();
|
|
6
|
+
await e({
|
|
7
|
+
raw: t,
|
|
8
|
+
annotateScreenshot: (e, n) => d(t, e, n)
|
|
9
|
+
});
|
|
10
|
+
} });
|
|
11
|
+
async function d(t, n, i) {
|
|
12
|
+
let o = await n.screenshot({ fullPage: i.fullPage }), { width: s, height: c } = f(o), l = `data:image/png;base64,${o.toString("base64")}`, u = "annotations" in i && i.annotations !== void 0 ? r(i.annotations) : i.annotationsSvg ?? "", d = t.toPng({
|
|
13
|
+
originalDataUrl: l,
|
|
14
|
+
annotationsSvg: u,
|
|
15
|
+
width: s,
|
|
16
|
+
height: c
|
|
17
|
+
});
|
|
18
|
+
return !i.encode || Object.keys(i.encode).length === 0 ? d : (await a(d, {
|
|
19
|
+
...e,
|
|
20
|
+
...i.encode
|
|
21
|
+
})).bytes;
|
|
23
22
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
function f(e) {
|
|
24
|
+
if (e.length < 24) throw Error("PNG too short to contain IHDR chunk");
|
|
25
|
+
let t = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
26
|
+
return {
|
|
27
|
+
width: t.getUint32(16, !1),
|
|
28
|
+
height: t.getUint32(20, !1)
|
|
29
|
+
};
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
m as arrowBetween,
|
|
33
|
-
S as bboxAnnotationsToSvg,
|
|
34
|
-
A as expect,
|
|
35
|
-
v as rectForBoundingBox,
|
|
36
|
-
u as test,
|
|
37
|
-
P as textAt
|
|
38
|
-
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { d as annotateScreenshot, t as arrowBetween, n as bboxAnnotationsToSvg, c as expect, o as rectForBoundingBox, u as test, s as textAt };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ingcreators/annot-playwright",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
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",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@playwright/test": "^1.50.0",
|
|
46
46
|
"typescript": "^6.0.3",
|
|
47
|
-
"vite": "^
|
|
48
|
-
"vite-plugin-dts": "^5.0.
|
|
47
|
+
"vite": "^8.0.13",
|
|
48
|
+
"vite-plugin-dts": "^5.0.1"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@ingcreators/annot-annotator": "0.
|
|
51
|
+
"@ingcreators/annot-annotator": "0.5.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@playwright/test": "^1.40.0"
|