@agent-scope/cli 1.0.1 → 1.0.2
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/cli.js +14 -8
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +14 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -8
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -665,13 +665,19 @@ function buildRenderer(filePath, componentName, viewportWidth, viewportHeight) {
|
|
|
665
665
|
`Component "${componentName}" rendered with zero bounding box \u2014 it may be invisible or not mounted`
|
|
666
666
|
);
|
|
667
667
|
}
|
|
668
|
+
const PAD = 24;
|
|
669
|
+
const MIN_W = 320;
|
|
670
|
+
const MIN_H = 200;
|
|
671
|
+
const clipX = Math.max(0, boundingBox.x - PAD);
|
|
672
|
+
const clipY = Math.max(0, boundingBox.y - PAD);
|
|
673
|
+
const rawW = boundingBox.width + PAD * 2;
|
|
674
|
+
const rawH = boundingBox.height + PAD * 2;
|
|
675
|
+
const clipW = Math.max(rawW, MIN_W);
|
|
676
|
+
const clipH = Math.max(rawH, MIN_H);
|
|
677
|
+
const safeW = Math.min(clipW, viewportWidth - clipX);
|
|
678
|
+
const safeH = Math.min(clipH, viewportHeight - clipY);
|
|
668
679
|
const screenshot = await page.screenshot({
|
|
669
|
-
clip: {
|
|
670
|
-
x: boundingBox.x,
|
|
671
|
-
y: boundingBox.y,
|
|
672
|
-
width: boundingBox.width,
|
|
673
|
-
height: boundingBox.height
|
|
674
|
-
},
|
|
680
|
+
clip: { x: clipX, y: clipY, width: safeW, height: safeH },
|
|
675
681
|
type: "png"
|
|
676
682
|
});
|
|
677
683
|
const computedStyles = {};
|
|
@@ -698,8 +704,8 @@ function buildRenderer(filePath, componentName, viewportWidth, viewportHeight) {
|
|
|
698
704
|
computedStyles["[data-reactscope-root] > *"] = styles;
|
|
699
705
|
return {
|
|
700
706
|
screenshot,
|
|
701
|
-
width: Math.round(
|
|
702
|
-
height: Math.round(
|
|
707
|
+
width: Math.round(safeW),
|
|
708
|
+
height: Math.round(safeH),
|
|
703
709
|
renderTimeMs,
|
|
704
710
|
computedStyles
|
|
705
711
|
};
|