@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/index.cjs +36 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -9
- package/dist/index.js.map +1 -1
- package/dist/lite.cjs +36 -9
- package/dist/lite.cjs.map +1 -1
- package/dist/lite.js +36 -9
- package/dist/lite.js.map +1 -1
- package/package.json +2 -2
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
|
-
|
|
570
|
-
|
|
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
|
|
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)",
|
|
@@ -1420,11 +1438,20 @@ var CustomSVGStore = class {
|
|
|
1420
1438
|
}
|
|
1421
1439
|
}
|
|
1422
1440
|
persist(all) {
|
|
1423
|
-
if (!this.storage) return;
|
|
1424
1441
|
const json = JSON.stringify(all);
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1442
|
+
if (this.storage) {
|
|
1443
|
+
try {
|
|
1444
|
+
this.storage.setItem(SVG_OVERRIDES_KEY, json);
|
|
1445
|
+
} catch {
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
if (typeof fetch !== "undefined") {
|
|
1449
|
+
fetch("/api/storage/svg-overrides", {
|
|
1450
|
+
method: "PUT",
|
|
1451
|
+
headers: { "Content-Type": "application/json" },
|
|
1452
|
+
body: json
|
|
1453
|
+
}).catch(() => {
|
|
1454
|
+
});
|
|
1428
1455
|
}
|
|
1429
1456
|
}
|
|
1430
1457
|
};
|