@biela.dev/core 1.7.1 → 1.7.2

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.d.cts CHANGED
@@ -91,6 +91,10 @@ interface ContainerSize {
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
93
  * Uses the actual canvas div, not the window, so it's panel-independent.
94
+ *
95
+ * Safety: clamps reported size to the visual viewport so that a mis-sized
96
+ * parent (e.g. height: auto or height: 100% with no fixed ancestor) can never
97
+ * cause the device frame to render larger than the screen.
94
98
  */
95
99
  declare function useContainerSize(ref: RefObject<HTMLElement | null>): ContainerSize;
96
100
 
package/dist/index.d.ts CHANGED
@@ -91,6 +91,10 @@ interface ContainerSize {
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
93
  * Uses the actual canvas div, not the window, so it's panel-independent.
94
+ *
95
+ * Safety: clamps reported size to the visual viewport so that a mis-sized
96
+ * parent (e.g. height: auto or height: 100% with no fixed ancestor) can never
97
+ * cause the device frame to render larger than the screen.
94
98
  */
95
99
  declare function useContainerSize(ref: RefObject<HTMLElement | null>): ContainerSize;
96
100
 
package/dist/index.js CHANGED
@@ -10,7 +10,11 @@ function useContainerSize(ref) {
10
10
  if (!el) return;
11
11
  const observer = new ResizeObserver(([entry]) => {
12
12
  if (!entry) return;
13
- const { width, height } = entry.contentRect;
13
+ let { width, height } = entry.contentRect;
14
+ if (typeof window !== "undefined") {
15
+ width = Math.min(width, window.innerWidth);
16
+ height = Math.min(height, window.innerHeight);
17
+ }
14
18
  setSize((prev) => {
15
19
  if (prev.width === width && prev.height === height) return prev;
16
20
  return { width, height };