@biela.dev/core 1.7.2 → 1.7.3
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 +26 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/dist/lite.cjs +26 -1
- package/dist/lite.cjs.map +1 -1
- package/dist/lite.js +26 -1
- package/dist/lite.js.map +1 -1
- package/package.json +1 -1
package/dist/lite.cjs
CHANGED
|
@@ -566,6 +566,31 @@ function registerCustomDeviceSVG(deviceId, svgString, frame, cropViewBox, screen
|
|
|
566
566
|
});
|
|
567
567
|
processedSVG = bodySVG.replace(defsPlaceholder, defsContent);
|
|
568
568
|
}
|
|
569
|
+
let correctedFrame = frame;
|
|
570
|
+
if (screenRect && screenRect.width > 0 && screenRect.height > 0) {
|
|
571
|
+
const finalVBMatch = processedSVG.match(/viewBox\s*=\s*["']([^"']+)["']/i);
|
|
572
|
+
if (finalVBMatch) {
|
|
573
|
+
const vbParts = finalVBMatch[1].split(/[\s,]+/).map(Number);
|
|
574
|
+
if (vbParts.length >= 4) {
|
|
575
|
+
const vbW = vbParts[2];
|
|
576
|
+
const vbH = vbParts[3];
|
|
577
|
+
if (vbW > 0 && vbH > 0) {
|
|
578
|
+
const sx = frame.screenWidth / screenRect.width;
|
|
579
|
+
const sy = frame.screenHeight / screenRect.height;
|
|
580
|
+
const s = Math.min(sx, sy);
|
|
581
|
+
correctedFrame = {
|
|
582
|
+
...frame,
|
|
583
|
+
bezelLeft: Math.round(screenRect.x * s),
|
|
584
|
+
bezelTop: Math.round(screenRect.y * s),
|
|
585
|
+
bezelRight: Math.round((vbW - screenRect.x - screenRect.width) * s),
|
|
586
|
+
bezelBottom: Math.round((vbH - screenRect.y - screenRect.height) * s),
|
|
587
|
+
totalWidth: Math.round(vbW * s),
|
|
588
|
+
totalHeight: Math.round(vbH * s)
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
569
594
|
const CustomSVGComponent = ({ style }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
570
595
|
"div",
|
|
571
596
|
{
|
|
@@ -573,7 +598,7 @@ function registerCustomDeviceSVG(deviceId, svgString, frame, cropViewBox, screen
|
|
|
573
598
|
dangerouslySetInnerHTML: { __html: processedSVG }
|
|
574
599
|
}
|
|
575
600
|
);
|
|
576
|
-
SVG_REGISTRY[deviceId] = { component: CustomSVGComponent, frame };
|
|
601
|
+
SVG_REGISTRY[deviceId] = { component: CustomSVGComponent, frame: correctedFrame };
|
|
577
602
|
}
|
|
578
603
|
function DeviceFrame({
|
|
579
604
|
device: deviceProp,
|