Provides functions for handling CoreGraphics rectangles, viewport snapshots, containment checks, area calculations, and visibility logic. Reuse for any UI layout or graphics calculations requiring robust rect handling.
// Source: https://github.com/callstack/agent-device | License: MIT | Copyright 2026 Callstack
// Provided via justclaw.it.com; keep this notice with the code.
import type { Rect, SnapshotViewportSize } from './snapshot.ts';
/**
* CoreGraphics' `CGRectInfinite`, spelled in the four doubles Apple builds it from. This is what a
* failed viewport or frame read looks like once it has crossed a JSON wire: every component of it
* is finite, and so is every extent, and its center is `(0, 0)` (#2891).
*/
const CG_RECT_INFINITE: Rect = {
x: -Number.MAX_VALUE / 2,
y: -Number.MAX_VALUE / 2,
width: Number.MAX_VALUE,
height: Number.MAX_VALUE,
};
function isCGRectInfinite(rect: Rect): boolean {
return (
rect.x === CG_RECT_INFINITE.x &&
rect.y === CG_RECT_INFINITE.y &&
rect.wi
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key