@biela.dev/core 1.7.1 → 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/lite.cjs CHANGED
@@ -78,7 +78,11 @@ function useContainerSize(ref) {
78
78
  if (!el) return;
79
79
  const observer = new ResizeObserver(([entry]) => {
80
80
  if (!entry) return;
81
- const { width, height } = entry.contentRect;
81
+ let { width, height } = entry.contentRect;
82
+ if (typeof window !== "undefined") {
83
+ width = Math.min(width, window.innerWidth);
84
+ height = Math.min(height, window.innerHeight);
85
+ }
82
86
  setSize((prev) => {
83
87
  if (prev.width === width && prev.height === height) return prev;
84
88
  return { width, height };
@@ -562,6 +566,31 @@ function registerCustomDeviceSVG(deviceId, svgString, frame, cropViewBox, screen
562
566
  });
563
567
  processedSVG = bodySVG.replace(defsPlaceholder, defsContent);
564
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
+ }
565
594
  const CustomSVGComponent = ({ style }) => /* @__PURE__ */ jsxRuntime.jsx(
566
595
  "div",
567
596
  {
@@ -569,7 +598,7 @@ function registerCustomDeviceSVG(deviceId, svgString, frame, cropViewBox, screen
569
598
  dangerouslySetInnerHTML: { __html: processedSVG }
570
599
  }
571
600
  );
572
- SVG_REGISTRY[deviceId] = { component: CustomSVGComponent, frame };
601
+ SVG_REGISTRY[deviceId] = { component: CustomSVGComponent, frame: correctedFrame };
573
602
  }
574
603
  function DeviceFrame({
575
604
  device: deviceProp,