UNPKG

@snap/camera-kit

Version:
110 lines 3.55 kB
import type { ScreenRegionsInput as LensCoreScreenRegionsInput } from "../lens-core-module/generated-types"; /** * Defines the types of screen regions that can be configured for Lens rendering. * * - `roundButton`: Circular UI buttons (e.g., capture button) * - `topBar`: Top navigation or status bar area * - `keyboard`: Virtual keyboard area when shown * - `safeRender`: Safe area for Lens content to avoid UI overlap * - `captureExitButton`: Exit button for capture mode */ export type ScreenRegionType = "roundButton" | "topBar" | "keyboard" | "safeRender" | "captureExitButton"; /** * Represents a screen region with its normalized rectangular bounds. * * All coordinates are normalized values between 0.0 and 1.0 relative to the canvas size. * For example, { x: 0.5, y: 0.5, width: 0.5, height: 0.5 } represents right-bottom quarter of the canvas. */ export interface ScreenRegion { /** * Normalized x-coordinate of the region's top-left corner (0.0 to 1.0). */ x: number; /** * Normalized y-coordinate of the region's top-left corner (0.0 to 1.0). */ y: number; /** * Normalized width of the region (0.0 to 1.0). */ width: number; /** * Normalized height of the region (0.0 to 1.0). */ height: number; } /** * Configuration for screen regions used by Lenses. * * Screen regions help Lenses adapt their content placement based on the host * application's UI layout. All coordinates are normalized (0.0 to 1.0) relative * to the canvas dimensions. * * Only the regions specified in this object will be active - any previously set * regions not included will be automatically removed. * * @example * ```typescript * // Set initial safe rendering area * await session.setScreenRegions({ * safeRender: { * x: 0.1, * y: 0.1, * width: 0.8, * height: 0.8 * } * }); * * // When keyboard appears, update both regions * await session.setScreenRegions({ * safeRender: { * x: 0.1, * y: 0.1, * width: 0.8, * height: 0.5 * }, * keyboard: { * x: 0, * y: 0.5, * width: 1.0, * height: 0.5 * } * }); * * // When keyboard disappears, only specify safeRender * // (keyboard region will be automatically removed) * await session.setScreenRegions({ * safeRender: { * x: 0.1, * y: 0.1, * width: 0.8, * height: 0.8 * } * }); * ``` */ export type ScreenRegions = { [K in ScreenRegionType]?: ScreenRegion; }; /** * Type guard to validate ScreenRegions input. * * - Ensures `value` is a record * - Ensures every key is a known ScreenRegionType (via REGION_TYPE_MAPPING) * - Ensures every value is a normalized rect in [0,1], non-negative size, * and fits within the canvas (with tiny epsilon tolerance) */ export declare function isScreenRegions(value: unknown): value is ScreenRegions; /** * Handles the complete logic for updating screen regions. * * This function implements the "current state" pattern where only the regions * specified in newRegions will be active, and any previously set regions * not included will be automatically removed. * * @param newRegions - The new screen regions to set (public API format) * @param currentRegions - The currently active screen regions (for tracking) * @returns Object containing LensCore input and updated current regions */ export declare function prepareScreenRegionsUpdate(newRegions: ScreenRegions): LensCoreScreenRegionsInput["regions"]; //# sourceMappingURL=screenRegions.d.ts.map