API reference
Everything the package exports: opening it, actions on a take, scripts, and their types.
Opening it
install(options?)
Opens and closes Closeup on a shortcut, ⌥⇧C unless told otherwise. Returns what removes it.
function install(options?: { shortcut?: string }): () => void;open(options?), close(), toggle()
Opens Closeup, on pick when given an element, ready to film; closes it; or one or the other.
function open(options?: { pick?: Element | null }): void;
function close(): void;
function toggle(): void;DEFAULT_SHORTCUT
"Alt+Shift+C".
supportsCapture()
Whether this browser can share a tab and crop it to an element.
Takes
addAction(action)
Offers a button of your own on every take from now on. Returns what takes it away.
function addAction(action: TakeAction): () => void;
type TakeAction = {
label: string;
icon?: string; // paths on a 24-unit grid
when?: (take: Take) => boolean;
run: (
take: Take,
context: { progress: (done: number) => void },
) => Promise<string | void>;
};
type Take = {
kind: "photo" | "video";
blob: Blob;
type: string;
width: number;
height: number;
seconds?: number;
script?: Script; // the script a video played
};Scripts
parseScript(value)
A script, checked, from JSON already parsed: null if it isn't one.
loadScript(path?), saveScript(script, path?)
The script kept in this browser for a page, by its path (the current page's unless said); saving null forgets it.
function parseScript(value: unknown): Script | null;
function loadScript(path?: string): Script | null;
function saveScript(script: Script | null, path?: string): void;
type Script = {
version: 1 | 2;
start: Target;
out?: { x: number; y: number };
steps: Step[];
};
type Step = {
to: Target;
in?: { x: number; y: number };
out?: { x: number; y: number };
action: "move" | "click" | "type" | "scroll";
text?: string;
scroll?: number;
hover?: number;
duration?: number;
wait: number;
};
type Target = {
x: number;
y: number;
on?: { selector: string; u: number; v: number };
};Settings
Settings is the type of what the options keep in the browser, exported for anyone reading them:
type Settings = {
mode: "photo" | "video";
pick: "element" | "region";
shape: "16:9" | "1:1" | "4:5" | "9:16" | "free"; // free: the pick's own
padding: number; // room round the pick, a share of its size
background: "none" | "color" | "gradient" | "image";
color: string;
gradient: number;
inset: number;
radius: number;
shadow: boolean;
cursor: boolean;
cursorSize: number;
ring: boolean;
moves: "yours" | "script";
zoom: number; // 1, 1.5 or 2
countdown: number; // seconds before a video by hand
timer: number; // seconds before a photo
clicks: boolean;
tabAudio: boolean;
quality: "standard" | "high";
};