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