@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.js CHANGED
@@ -474,6 +474,31 @@ function registerCustomDeviceSVG(deviceId, svgString, frame, cropViewBox, screen
474
474
  });
475
475
  processedSVG = bodySVG.replace(defsPlaceholder, defsContent);
476
476
  }
477
+ let correctedFrame = frame;
478
+ if (screenRect && screenRect.width > 0 && screenRect.height > 0) {
479
+ const finalVBMatch = processedSVG.match(/viewBox\s*=\s*["']([^"']+)["']/i);
480
+ if (finalVBMatch) {
481
+ const vbParts = finalVBMatch[1].split(/[\s,]+/).map(Number);
482
+ if (vbParts.length >= 4) {
483
+ const vbW = vbParts[2];
484
+ const vbH = vbParts[3];
485
+ if (vbW > 0 && vbH > 0) {
486
+ const sx = frame.screenWidth / screenRect.width;
487
+ const sy = frame.screenHeight / screenRect.height;
488
+ const s = Math.min(sx, sy);
489
+ correctedFrame = {
490
+ ...frame,
491
+ bezelLeft: Math.round(screenRect.x * s),
492
+ bezelTop: Math.round(screenRect.y * s),
493
+ bezelRight: Math.round((vbW - screenRect.x - screenRect.width) * s),
494
+ bezelBottom: Math.round((vbH - screenRect.y - screenRect.height) * s),
495
+ totalWidth: Math.round(vbW * s),
496
+ totalHeight: Math.round(vbH * s)
497
+ };
498
+ }
499
+ }
500
+ }
501
+ }
477
502
  const CustomSVGComponent = ({ style }) => /* @__PURE__ */ jsx(
478
503
  "div",
479
504
  {
@@ -481,7 +506,7 @@ function registerCustomDeviceSVG(deviceId, svgString, frame, cropViewBox, screen
481
506
  dangerouslySetInnerHTML: { __html: processedSVG }
482
507
  }
483
508
  );
484
- SVG_REGISTRY[deviceId] = { component: CustomSVGComponent, frame };
509
+ SVG_REGISTRY[deviceId] = { component: CustomSVGComponent, frame: correctedFrame };
485
510
  }
486
511
  function DeviceFrame({
487
512
  device: deviceProp,