import { Genome } from "../types.js"; import { PlateCell } from "../plate.js"; import { Keyframe, Orientation, POSE_NAMES, Pose, PoseName, definePose, poseAt, poses, resolvePose } from "../poses.js"; import { FaceOptions, PlateOptions, faceSVG, pickFace, plateSVG, pointerToCanvas } from "../integrations/core.js"; import { ImageFileOptions, ImageFormat, PlateFileOptions, VideoFileOptions, canRecordVideo, faceFile, faceVideoFile, pickVideoMime, plateFile } from "../integrations/export.js"; import { CSSProperties, PointerEvent, ReactElement } from "react"; //#region src/react/index.d.ts interface UseFaceResult { svg: string; genome: Genome; /** A one-line summary -- good alt text. */ description: string; } /** One face as SVG, recomputed only when something about it actually changes. */ declare function useFace(options?: FaceOptions): UseFaceResult; interface UsePlateResult { svg: string; faces: PlateCell[]; } /** A grid of faces as SVG, plus where each face landed. */ declare function usePlate(options?: PlateOptions): UsePlateResult; interface Turntable { yaw: number; pitch: number; setYaw: (v: number) => void; setPitch: (v: number) => void; reset: () => void; dragging: boolean; /** Spread onto the element that should respond to dragging. */ bind: { onPointerDown: (e: PointerEvent) => void; onPointerMove: (e: PointerEvent) => void; onPointerUp: (e: PointerEvent) => void; onPointerCancel: (e: PointerEvent) => void; style: CSSProperties; }; } interface TurntableOptions { yaw?: number; pitch?: number; /** Degrees of turn per pixel dragged. */ sensitivity?: number; maxYaw?: number; maxPitch?: number; } /** Drag-to-turn, in the units `` takes. */ declare function useTurntable(options?: TurntableOptions): Turntable; interface FaceProps extends FaceOptions { /** * `svg` inlines a vector drawing and works during server rendering; * `canvas` paints, which is cheaper to re-run every frame. */ as?: 'svg' | 'canvas'; className?: string; style?: CSSProperties; /** Overrides the generated description used as the accessible label. */ label?: string; onGenome?: (genome: Genome) => void; } /** * One doodle face. * * * */ declare function Face(props: FaceProps): ReactElement; interface PlateProps extends PlateOptions { as?: 'svg' | 'canvas'; className?: string; style?: CSSProperties; label?: string; /** Fires with the face that was clicked, or nothing if it was a gutter. */ onSelect?: (cell: PlateCell) => void; onFaces?: (faces: PlateCell[]) => void; } /** * A sheet of faces. * * setSeed(f.seed)} /> */ declare function Plate(props: PlateProps): ReactElement; interface FileState { /** Build the file. Pass overrides to tweak this one call. */ create: (overrides?: Partial) => Promise; /** Build it and hand it straight to the browser as a download. */ download: (overrides?: Partial) => Promise; /** The most recent result, and an object URL for previewing it. */ file: File | null; url: string | null; pending: boolean; error: Error | null; reset: () => void; } /** * A face as a downloadable `File` -- png, jpeg, webp or svg. * * const { create, download, url, pending } = useFaceFile({ seed, format: 'webp' }) * */ declare function useFaceFile(options?: ImageFileOptions): FileState; /** A whole plate as a downloadable `File`. */ declare function usePlateFile(options?: PlateFileOptions): FileState; interface VideoState extends FileState { /** 0 -> 1 while recording. Recording runs in real time. */ progress: number; /** Stop early. The clip so far is discarded. */ cancel: () => void; /** False when the browser has no webm recorder. */ supported: boolean; } /** * A looping webm of the face moving through a pose. * * const { create, progress, supported } = useFaceVideo({ seed, pose: 'nod', duration: 10 }) * * Recording is real time, so a ten second clip takes ten seconds; `progress` * and `pending` are there to say so. */ declare function useFaceVideo(options?: VideoFileOptions): VideoState; //#endregion export { Face, type FaceOptions, FaceProps, FileState, type ImageFileOptions, type ImageFormat, type Keyframe, type Orientation, POSE_NAMES, Plate, type PlateFileOptions, type PlateOptions, PlateProps, type Pose, type PoseName, Turntable, TurntableOptions, UseFaceResult, UsePlateResult, type VideoFileOptions, VideoState, canRecordVideo, definePose, faceFile, faceSVG, faceVideoFile, pickFace, pickVideoMime, plateFile, plateSVG, pointerToCanvas, poseAt, poses, resolvePose, useFace, useFaceFile, useFaceVideo, usePlate, usePlateFile, useTurntable };