@a11y-pulse/browser-adaptor 0.1.0 → 0.2.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/dist/clip.d.ts +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/clip.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Rect } from "./adaptor";
|
|
2
|
+
/**
|
|
3
|
+
* A screenshot clip framing `rect` with up to `buffer` pixels of padding on each side, shrunk
|
|
4
|
+
* where the page edges leave less room. The padding allows for indicators drawn just outside
|
|
5
|
+
* the element box (outlines, shadows) and for anti-aliasing.
|
|
6
|
+
*/
|
|
7
|
+
export declare function bufferedClip(rect: Rect, pageWidth: number, pageHeight: number, buffer: number): Rect;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1,20 @@
|
|
|
1
|
+
// src/clip.ts
|
|
2
|
+
function bufferedClip(rect, pageWidth, pageHeight, buffer) {
|
|
3
|
+
const left = Math.max(0, Math.min(buffer, rect.x));
|
|
4
|
+
const top = Math.max(0, Math.min(buffer, rect.y));
|
|
5
|
+
const right = Math.max(0, Math.min(buffer, pageWidth - rect.x - rect.width));
|
|
6
|
+
const bottom = Math.max(
|
|
7
|
+
0,
|
|
8
|
+
Math.min(buffer, pageHeight - rect.y - rect.height)
|
|
9
|
+
);
|
|
10
|
+
return {
|
|
11
|
+
x: Math.max(0, rect.x - left),
|
|
12
|
+
y: Math.max(0, rect.y - top),
|
|
13
|
+
width: rect.width + left + right,
|
|
14
|
+
height: rect.height + top + bottom
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
bufferedClip
|
|
19
|
+
};
|
|
1
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/clip.ts"],"sourcesContent":["import type { Rect } from \"./adaptor\";\n\n/**\n * A screenshot clip framing `rect` with up to `buffer` pixels of padding on each side, shrunk\n * where the page edges leave less room. The padding allows for indicators drawn just outside\n * the element box (outlines, shadows) and for anti-aliasing.\n */\nexport function bufferedClip(\n\trect: Rect,\n\tpageWidth: number,\n\tpageHeight: number,\n\tbuffer: number,\n): Rect {\n\tconst left = Math.max(0, Math.min(buffer, rect.x));\n\tconst top = Math.max(0, Math.min(buffer, rect.y));\n\tconst right = Math.max(0, Math.min(buffer, pageWidth - rect.x - rect.width));\n\tconst bottom = Math.max(\n\t\t0,\n\t\tMath.min(buffer, pageHeight - rect.y - rect.height),\n\t);\n\n\t// Clamp to non-negative origins: an element positioned partially off the top\n\t// or left of the document has a negative page-relative rect, and Puppeteer\n\t// rejects a screenshot clip with negative x/y.\n\treturn {\n\t\tx: Math.max(0, rect.x - left),\n\t\ty: Math.max(0, rect.y - top),\n\t\twidth: rect.width + left + right,\n\t\theight: rect.height + top + bottom,\n\t};\n}\n"],"mappings":";AAOO,SAAS,aACf,MACA,WACA,YACA,QACO;AACP,QAAM,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,QAAQ,KAAK,CAAC,CAAC;AACjD,QAAM,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,QAAQ,KAAK,CAAC,CAAC;AAChD,QAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,QAAQ,YAAY,KAAK,IAAI,KAAK,KAAK,CAAC;AAC3E,QAAM,SAAS,KAAK;AAAA,IACnB;AAAA,IACA,KAAK,IAAI,QAAQ,aAAa,KAAK,IAAI,KAAK,MAAM;AAAA,EACnD;AAKA,SAAO;AAAA,IACN,GAAG,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI;AAAA,IAC5B,GAAG,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG;AAAA,IAC3B,OAAO,KAAK,QAAQ,OAAO;AAAA,IAC3B,QAAQ,KAAK,SAAS,MAAM;AAAA,EAC7B;AACD;","names":[]}
|
package/package.json
CHANGED