@biela.dev/core 1.7.5 → 1.7.7
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 +40 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +40 -13
- package/dist/index.js.map +1 -1
- package/dist/lite.cjs +40 -13
- package/dist/lite.cjs.map +1 -1
- package/dist/lite.js +40 -13
- package/dist/lite.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -90,11 +90,14 @@ interface ContainerSize {
|
|
|
90
90
|
/**
|
|
91
91
|
* Observes an element's content box dimensions via ResizeObserver.
|
|
92
92
|
* Foundation of adaptive scaling — same mechanism as Xcode's window resize detection.
|
|
93
|
-
* Uses the actual canvas div, not the window, so it's panel-independent.
|
|
94
93
|
*
|
|
95
|
-
* Safety:
|
|
96
|
-
*
|
|
97
|
-
* cause the device frame to render larger than the screen.
|
|
94
|
+
* Safety features:
|
|
95
|
+
* 1. Clamps reported size to the visual viewport so a mis-sized parent
|
|
96
|
+
* can never cause the device frame to render larger than the screen.
|
|
97
|
+
* 2. When the element has 0 height (common AI-generated code mistake:
|
|
98
|
+
* height: auto or height: 100% without explicit ancestor height),
|
|
99
|
+
* uses a viewport-based fallback so the device still renders.
|
|
100
|
+
* 3. Listens for window resize to stay in sync.
|
|
98
101
|
*/
|
|
99
102
|
declare function useContainerSize(ref: RefObject<HTMLElement | null>): ContainerSize;
|
|
100
103
|
|
package/dist/index.d.ts
CHANGED
|
@@ -90,11 +90,14 @@ interface ContainerSize {
|
|
|
90
90
|
/**
|
|
91
91
|
* Observes an element's content box dimensions via ResizeObserver.
|
|
92
92
|
* Foundation of adaptive scaling — same mechanism as Xcode's window resize detection.
|
|
93
|
-
* Uses the actual canvas div, not the window, so it's panel-independent.
|
|
94
93
|
*
|
|
95
|
-
* Safety:
|
|
96
|
-
*
|
|
97
|
-
* cause the device frame to render larger than the screen.
|
|
94
|
+
* Safety features:
|
|
95
|
+
* 1. Clamps reported size to the visual viewport so a mis-sized parent
|
|
96
|
+
* can never cause the device frame to render larger than the screen.
|
|
97
|
+
* 2. When the element has 0 height (common AI-generated code mistake:
|
|
98
|
+
* height: auto or height: 100% without explicit ancestor height),
|
|
99
|
+
* uses a viewport-based fallback so the device still renders.
|
|
100
|
+
* 3. Listens for window resize to stay in sync.
|
|
98
101
|
*/
|
|
99
102
|
declare function useContainerSize(ref: RefObject<HTMLElement | null>): ContainerSize;
|
|
100
103
|
|
package/dist/index.js
CHANGED
|
@@ -8,10 +8,17 @@ function useContainerSize(ref) {
|
|
|
8
8
|
useEffect(() => {
|
|
9
9
|
const el = ref.current;
|
|
10
10
|
if (!el) return;
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
let
|
|
11
|
+
const update = () => {
|
|
12
|
+
const rect = el.getBoundingClientRect();
|
|
13
|
+
let width = rect.width;
|
|
14
|
+
let height = rect.height;
|
|
14
15
|
if (typeof window !== "undefined") {
|
|
16
|
+
if (height <= 0) {
|
|
17
|
+
height = Math.max(200, window.innerHeight - Math.max(0, rect.top));
|
|
18
|
+
}
|
|
19
|
+
if (width <= 0) {
|
|
20
|
+
width = window.innerWidth;
|
|
21
|
+
}
|
|
15
22
|
width = Math.min(width, window.innerWidth);
|
|
16
23
|
height = Math.min(height, window.innerHeight);
|
|
17
24
|
}
|
|
@@ -19,9 +26,15 @@ function useContainerSize(ref) {
|
|
|
19
26
|
if (prev.width === width && prev.height === height) return prev;
|
|
20
27
|
return { width, height };
|
|
21
28
|
});
|
|
22
|
-
}
|
|
29
|
+
};
|
|
30
|
+
const observer = new ResizeObserver(() => update());
|
|
23
31
|
observer.observe(el);
|
|
24
|
-
|
|
32
|
+
update();
|
|
33
|
+
window.addEventListener("resize", update);
|
|
34
|
+
return () => {
|
|
35
|
+
observer.disconnect();
|
|
36
|
+
window.removeEventListener("resize", update);
|
|
37
|
+
};
|
|
25
38
|
}, [ref]);
|
|
26
39
|
return size;
|
|
27
40
|
}
|
|
@@ -630,9 +643,8 @@ function DeviceFrame({
|
|
|
630
643
|
className: "bielaframe-sentinel",
|
|
631
644
|
style: {
|
|
632
645
|
width: "100%",
|
|
633
|
-
height: "100%",
|
|
646
|
+
height: containerH > 0 ? containerH : "100%",
|
|
634
647
|
minHeight: 0,
|
|
635
|
-
maxHeight: "100%",
|
|
636
648
|
display: "flex",
|
|
637
649
|
flexDirection: "column",
|
|
638
650
|
alignItems: "center",
|
|
@@ -689,10 +701,11 @@ function DeviceFrame({
|
|
|
689
701
|
children: /* @__PURE__ */ jsx(DeviceErrorBoundary, { children })
|
|
690
702
|
}
|
|
691
703
|
),
|
|
692
|
-
DeviceSVGComponent && /* @__PURE__ */
|
|
693
|
-
|
|
704
|
+
DeviceSVGComponent && /* @__PURE__ */ jsxs(
|
|
705
|
+
"div",
|
|
694
706
|
{
|
|
695
|
-
|
|
707
|
+
ref: frameOverlayRef,
|
|
708
|
+
className: "bielaframe-svg-overlay",
|
|
696
709
|
style: {
|
|
697
710
|
position: "absolute",
|
|
698
711
|
top: 0,
|
|
@@ -700,10 +713,24 @@ function DeviceFrame({
|
|
|
700
713
|
width: frameTotalW,
|
|
701
714
|
height: frameTotalH,
|
|
702
715
|
pointerEvents: "none",
|
|
703
|
-
zIndex: 10
|
|
704
|
-
|
|
716
|
+
zIndex: 10,
|
|
717
|
+
overflow: "hidden"
|
|
718
|
+
},
|
|
719
|
+
children: [
|
|
720
|
+
/* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: `.bielaframe-svg-overlay svg { width: 100% !important; height: 100% !important; }` } }),
|
|
721
|
+
/* @__PURE__ */ jsx(
|
|
722
|
+
DeviceSVGComponent,
|
|
723
|
+
{
|
|
724
|
+
colorScheme,
|
|
725
|
+
style: {
|
|
726
|
+
width: "100%",
|
|
727
|
+
height: "100%"
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
)
|
|
731
|
+
]
|
|
705
732
|
}
|
|
706
|
-
)
|
|
733
|
+
),
|
|
707
734
|
showSafeAreaOverlay && /* @__PURE__ */ jsx(
|
|
708
735
|
"div",
|
|
709
736
|
{
|