@biela.dev/core 1.7.12 → 1.7.13
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/index.cjs +23 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -5
- package/dist/index.js.map +1 -1
- package/dist/lite.cjs +23 -5
- package/dist/lite.cjs.map +1 -1
- package/dist/lite.js +23 -5
- package/dist/lite.js.map +1 -1
- package/package.json +2 -2
package/dist/lite.cjs
CHANGED
|
@@ -568,11 +568,25 @@ function registerCustomDeviceSVG(deviceId, svgString, frame, cropViewBox, screen
|
|
|
568
568
|
let bodySVG = defsMatch ? processedSVG.replace(defsContent, defsPlaceholder) : processedSVG;
|
|
569
569
|
bodySVG = bodySVG.replace(/<rect\b([^>]*?)\/?>/gi, (fullMatch, attrs) => {
|
|
570
570
|
if (/\bmask\s*=/i.test(fullMatch)) return fullMatch;
|
|
571
|
-
|
|
572
|
-
|
|
571
|
+
let xVal = parseFloat(attrs.match(/\bx\s*=\s*["']?(-?\d+\.?\d*)["']?/i)?.[1] ?? "0");
|
|
572
|
+
let yVal = parseFloat(attrs.match(/\by\s*=\s*["']?(-?\d+\.?\d*)["']?/i)?.[1] ?? "0");
|
|
573
573
|
const wVal = parseFloat(attrs.match(/\bwidth\s*=\s*["']?(\d+\.?\d*)["']?/i)?.[1] ?? "0");
|
|
574
574
|
const hVal = parseFloat(attrs.match(/\bheight\s*=\s*["']?(\d+\.?\d*)["']?/i)?.[1] ?? "0");
|
|
575
|
-
if (wVal
|
|
575
|
+
if (wVal <= 0 || hVal <= 0) return fullMatch;
|
|
576
|
+
const translateMatch = attrs.match(/transform\s*=\s*["'][^"']*translate\(\s*(-?[\d.]+)[\s,]+(-?[\d.]+)/i);
|
|
577
|
+
if (translateMatch) {
|
|
578
|
+
xVal += parseFloat(translateMatch[1]);
|
|
579
|
+
yVal += parseFloat(translateMatch[2]);
|
|
580
|
+
}
|
|
581
|
+
const fullyCovering = xVal <= sx + 2 && yVal <= sy + 2 && xVal + wVal >= sx + sw - 2 && yVal + hVal >= sy + sh - 2;
|
|
582
|
+
const overlapLeft = Math.max(xVal, sx);
|
|
583
|
+
const overlapTop = Math.max(yVal, sy);
|
|
584
|
+
const overlapRight = Math.min(xVal + wVal, sx + sw);
|
|
585
|
+
const overlapBottom = Math.min(yVal + hVal, sy + sh);
|
|
586
|
+
const overlapArea = Math.max(0, overlapRight - overlapLeft) * Math.max(0, overlapBottom - overlapTop);
|
|
587
|
+
const screenArea = sw * sh;
|
|
588
|
+
const significantOverlap = overlapArea > screenArea * 0.15 && wVal * hVal > screenArea * 0.25;
|
|
589
|
+
if (fullyCovering || significantOverlap) {
|
|
576
590
|
return fullMatch.replace(/(\/?>)$/, ` mask="url(#${maskId})"$1`);
|
|
577
591
|
}
|
|
578
592
|
return fullMatch;
|
|
@@ -598,7 +612,11 @@ function registerCustomDeviceSVG(deviceId, svgString, frame, cropViewBox, screen
|
|
|
598
612
|
bezelRight: Math.round((vbW - screenRect.x - screenRect.width) * s),
|
|
599
613
|
bezelBottom: Math.round((vbH - screenRect.y - screenRect.height) * s),
|
|
600
614
|
totalWidth: Math.round(vbW * s),
|
|
601
|
-
totalHeight: Math.round(vbH * s)
|
|
615
|
+
totalHeight: Math.round(vbH * s),
|
|
616
|
+
// Derive screen corner radius from the SVG's screen rect rx,
|
|
617
|
+
// scaled to CSS pixels, so the content clipPath matches the
|
|
618
|
+
// SVG mask hole exactly (no corner gap mismatch).
|
|
619
|
+
screenRadius: screenRect.rx ? Math.round(screenRect.rx * s) : frame.screenRadius
|
|
602
620
|
};
|
|
603
621
|
}
|
|
604
622
|
}
|
|
@@ -798,7 +816,7 @@ function DeviceFrame({
|
|
|
798
816
|
top: frameBezelTop,
|
|
799
817
|
width: deviceMeta.screen.width,
|
|
800
818
|
height: deviceMeta.screen.height,
|
|
801
|
-
clipPath: `inset(0 round ${contract.screen.cornerRadius}px)`,
|
|
819
|
+
clipPath: `inset(0 round ${frameInfo?.screenRadius ?? contract.screen.cornerRadius}px)`,
|
|
802
820
|
overflow: "hidden",
|
|
803
821
|
backfaceVisibility: "hidden",
|
|
804
822
|
transform: "translateZ(0)",
|