@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/index.cjs
CHANGED
|
@@ -476,6 +476,31 @@ function registerCustomDeviceSVG(deviceId, svgString, frame, cropViewBox, screen
|
|
|
476
476
|
});
|
|
477
477
|
processedSVG = bodySVG.replace(defsPlaceholder, defsContent);
|
|
478
478
|
}
|
|
479
|
+
let correctedFrame = frame;
|
|
480
|
+
if (screenRect && screenRect.width > 0 && screenRect.height > 0) {
|
|
481
|
+
const finalVBMatch = processedSVG.match(/viewBox\s*=\s*["']([^"']+)["']/i);
|
|
482
|
+
if (finalVBMatch) {
|
|
483
|
+
const vbParts = finalVBMatch[1].split(/[\s,]+/).map(Number);
|
|
484
|
+
if (vbParts.length >= 4) {
|
|
485
|
+
const vbW = vbParts[2];
|
|
486
|
+
const vbH = vbParts[3];
|
|
487
|
+
if (vbW > 0 && vbH > 0) {
|
|
488
|
+
const sx = frame.screenWidth / screenRect.width;
|
|
489
|
+
const sy = frame.screenHeight / screenRect.height;
|
|
490
|
+
const s = Math.min(sx, sy);
|
|
491
|
+
correctedFrame = {
|
|
492
|
+
...frame,
|
|
493
|
+
bezelLeft: Math.round(screenRect.x * s),
|
|
494
|
+
bezelTop: Math.round(screenRect.y * s),
|
|
495
|
+
bezelRight: Math.round((vbW - screenRect.x - screenRect.width) * s),
|
|
496
|
+
bezelBottom: Math.round((vbH - screenRect.y - screenRect.height) * s),
|
|
497
|
+
totalWidth: Math.round(vbW * s),
|
|
498
|
+
totalHeight: Math.round(vbH * s)
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
479
504
|
const CustomSVGComponent = ({ style }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
480
505
|
"div",
|
|
481
506
|
{
|
|
@@ -483,7 +508,7 @@ function registerCustomDeviceSVG(deviceId, svgString, frame, cropViewBox, screen
|
|
|
483
508
|
dangerouslySetInnerHTML: { __html: processedSVG }
|
|
484
509
|
}
|
|
485
510
|
);
|
|
486
|
-
SVG_REGISTRY[deviceId] = { component: CustomSVGComponent, frame };
|
|
511
|
+
SVG_REGISTRY[deviceId] = { component: CustomSVGComponent, frame: correctedFrame };
|
|
487
512
|
}
|
|
488
513
|
function DeviceFrame({
|
|
489
514
|
device: deviceProp,
|
|
@@ -608,6 +633,8 @@ function DeviceFrame({
|
|
|
608
633
|
style: {
|
|
609
634
|
width: "100%",
|
|
610
635
|
height: "100%",
|
|
636
|
+
minHeight: 0,
|
|
637
|
+
maxHeight: "100%",
|
|
611
638
|
display: "flex",
|
|
612
639
|
flexDirection: "column",
|
|
613
640
|
alignItems: "center",
|