@ingcreators/annot-playwright 0.3.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 +8 -0
- package/README.md +1 -1
- package/dist/index.js +30 -39
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
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/index.js
CHANGED
|
@@ -1,41 +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
|
-
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;
|
|
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;
|
|
26
22
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
+
};
|
|
32
30
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
A as arrowBetween,
|
|
36
|
-
D as bboxAnnotationsToSvg,
|
|
37
|
-
T as expect,
|
|
38
|
-
O as rectForBoundingBox,
|
|
39
|
-
P as test,
|
|
40
|
-
E as textAt
|
|
41
|
-
};
|
|
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.
|
|
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"
|