@biela.dev/core 1.7.2 → 1.7.4
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 +28 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -1
- package/dist/lite.cjs +28 -1
- package/dist/lite.cjs.map +1 -1
- package/dist/lite.js +28 -1
- package/dist/lite.js.map +1 -1
- package/package.json +11 -11
package/dist/lite.js
CHANGED
|
@@ -564,6 +564,31 @@ function registerCustomDeviceSVG(deviceId, svgString, frame, cropViewBox, screen
|
|
|
564
564
|
});
|
|
565
565
|
processedSVG = bodySVG.replace(defsPlaceholder, defsContent);
|
|
566
566
|
}
|
|
567
|
+
let correctedFrame = frame;
|
|
568
|
+
if (screenRect && screenRect.width > 0 && screenRect.height > 0) {
|
|
569
|
+
const finalVBMatch = processedSVG.match(/viewBox\s*=\s*["']([^"']+)["']/i);
|
|
570
|
+
if (finalVBMatch) {
|
|
571
|
+
const vbParts = finalVBMatch[1].split(/[\s,]+/).map(Number);
|
|
572
|
+
if (vbParts.length >= 4) {
|
|
573
|
+
const vbW = vbParts[2];
|
|
574
|
+
const vbH = vbParts[3];
|
|
575
|
+
if (vbW > 0 && vbH > 0) {
|
|
576
|
+
const sx = frame.screenWidth / screenRect.width;
|
|
577
|
+
const sy = frame.screenHeight / screenRect.height;
|
|
578
|
+
const s = Math.min(sx, sy);
|
|
579
|
+
correctedFrame = {
|
|
580
|
+
...frame,
|
|
581
|
+
bezelLeft: Math.round(screenRect.x * s),
|
|
582
|
+
bezelTop: Math.round(screenRect.y * s),
|
|
583
|
+
bezelRight: Math.round((vbW - screenRect.x - screenRect.width) * s),
|
|
584
|
+
bezelBottom: Math.round((vbH - screenRect.y - screenRect.height) * s),
|
|
585
|
+
totalWidth: Math.round(vbW * s),
|
|
586
|
+
totalHeight: Math.round(vbH * s)
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
567
592
|
const CustomSVGComponent = ({ style }) => /* @__PURE__ */ jsx(
|
|
568
593
|
"div",
|
|
569
594
|
{
|
|
@@ -571,7 +596,7 @@ function registerCustomDeviceSVG(deviceId, svgString, frame, cropViewBox, screen
|
|
|
571
596
|
dangerouslySetInnerHTML: { __html: processedSVG }
|
|
572
597
|
}
|
|
573
598
|
);
|
|
574
|
-
SVG_REGISTRY[deviceId] = { component: CustomSVGComponent, frame };
|
|
599
|
+
SVG_REGISTRY[deviceId] = { component: CustomSVGComponent, frame: correctedFrame };
|
|
575
600
|
}
|
|
576
601
|
function DeviceFrame({
|
|
577
602
|
device: deviceProp,
|
|
@@ -696,6 +721,8 @@ function DeviceFrame({
|
|
|
696
721
|
style: {
|
|
697
722
|
width: "100%",
|
|
698
723
|
height: "100%",
|
|
724
|
+
minHeight: 0,
|
|
725
|
+
maxHeight: "100%",
|
|
699
726
|
display: "flex",
|
|
700
727
|
flexDirection: "column",
|
|
701
728
|
alignItems: "center",
|