@biela.dev/core 1.7.11 → 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.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
- const xVal = parseFloat(attrs.match(/\bx\s*=\s*["']?(-?\d+\.?\d*)["']?/i)?.[1] ?? "0");
572
- const yVal = parseFloat(attrs.match(/\by\s*=\s*["']?(-?\d+\.?\d*)["']?/i)?.[1] ?? "0");
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 > 0 && hVal > 0 && xVal <= sx + 2 && yVal <= sy + 2 && xVal + wVal >= sx + sw - 2 && yVal + hVal >= sy + sh - 2) {
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)",
@@ -1422,11 +1440,20 @@ var CustomSVGStore = class {
1422
1440
  }
1423
1441
  }
1424
1442
  persist(all) {
1425
- if (!this.storage) return;
1426
1443
  const json = JSON.stringify(all);
1427
- try {
1428
- this.storage.setItem(SVG_OVERRIDES_KEY, json);
1429
- } catch {
1444
+ if (this.storage) {
1445
+ try {
1446
+ this.storage.setItem(SVG_OVERRIDES_KEY, json);
1447
+ } catch {
1448
+ }
1449
+ }
1450
+ if (typeof fetch !== "undefined") {
1451
+ fetch("/api/storage/svg-overrides", {
1452
+ method: "PUT",
1453
+ headers: { "Content-Type": "application/json" },
1454
+ body: json
1455
+ }).catch(() => {
1456
+ });
1430
1457
  }
1431
1458
  }
1432
1459
  };