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