The types you pass to Camera: its constructor options, and the options and choices of its methods. This is one of the 5 pages of the types reference, which names every type. A field ending in ? may be absent: Slate leaves out what a camera does not report, and never guesses it.
import type { CameraOptions, TakePhotoOptions } from '@darkgrade/slate'Options
What the methods of Camera take.
FocusDirection
Which way nudgeFocus moves focus: near towards the camera, far away from it.
type FocusDirection = 'near' | 'far'FocusStepSize
A small, medium or large manual-focus step, like the < << <<< buttons in vendor remote apps.
type FocusStepSize = 'small' | 'medium' | 'large'PhotoDestination
Where a photo goes: the camera's card; the card and this computer (its bytes come back); or this computer only, never saved to the card (computerOnly).
type PhotoDestination = 'card' | 'computer' | 'computerOnly'TakePhotoOptions
What takePhoto takes. Every field is optional.
interface TakePhotoOptions {
autofocus?: boolean
destination?: PhotoDestination
download?: boolean
rawCompression?: RawCompression
includeInfo?: boolean
}Show TakePhotoOptions fieldsHide TakePhotoOptions fields
Focus before the shutter. False releases without waiting for focus.
With 'computer' the photo is still saved to the card, and its bytes are returned. With 'computerOnly' the camera sends it to the computer and does not save it to the card, so it has no media id.
See PhotoDestination.
False keeps every byte of the photo on the camera, even the copy some cameras send the computer to name a new file (Sony); the card's own listing confirms it. Only with destination 'card'.
RAW compression for this photo only, put back afterwards, such as 'Lossless'.
See RawCompression.
Also return the camera's own description of the photo (its PTP ObjectInfo) as info.
LiveViewFrameOptions
What getLiveViewFrame takes.
interface LiveViewFrameOptions {
overlay?: boolean
}Show LiveViewFrameOptions fieldsHide LiveViewFrameOptions fields
Also read the camera's on-screen info.
ZoomDirection
Which way startZoom zooms: in towards the long end of the lens, out towards the wide end.
type ZoomDirection = 'in' | 'out'ZoomOptions
What startZoom takes.
interface ZoomOptions {
speed: ZoomSpeed
}Show ZoomOptions fieldsHide ZoomOptions fields
How fast the lens zooms.
See ZoomSpeed.
ZoomSpeed
How fast startZoom moves the lens.
type ZoomSpeed = 'slow' | 'medium' | 'fast'MediaDownloadOptions
Progress and cancel for downloadMedia.
interface MediaDownloadOptions {
onProgress?: (
receivedBytes: number,
totalBytes: number,
) => void
signal?: AbortSignal
}Show MediaDownloadOptions fieldsHide MediaDownloadOptions fields
Called after each chunk with the bytes received so far.
Cancels between chunks; the download rejects with the signal's reason.
MediaPreviewSize
The sizes getMediaPreview returns: thumbnail is the small one, preview a larger one. A file's previews lists which it offers.
type MediaPreviewSize = 'thumbnail' | 'preview'CameraEventHandler
A handler for on: called with no arguments each time the event fires.
type CameraEventHandler = () => voidCameraEventName
settingsChanged: a setting changed on the camera. mediaAdded: a new photo or clip is on the card.
type CameraEventName = 'settingsChanged' | 'mediaAdded'CameraOptions
What new Camera() takes. Every field is optional.
interface CameraOptions {
logger?: Partial<LoggerConfig>
device?: DeviceDescriptor
transport?: TransportInterface
usb?: USB
transactionPolicy?: Partial<TransactionPolicy>
keepAlive?: boolean
vendorId?: number
firstContact?: boolean
}Show CameraOptions fieldsHide CameraOptions fields
Logging. Off unless you turn it on: nothing is drawn in the terminal and the console is left alone.
See LoggerConfig.
Which camera to open, such as a USB filter when several are attached. Without it, Slate opens the one attached camera.
See DeviceDescriptor.
A transport other than the built-in USB one, such as IPTransport from @darkgrade/slate/protocol for PTP/IP.
See TransportInterface.
A WebUSB implementation for the built-in USB transport to use under Node.
Timeouts and DeviceBusy retries for every transaction. A field you leave out keeps its default.
See TransactionPolicy.
Send the advertised Canon session heartbeat without changing saved body settings.
Which vendor's driver to use when the transport cannot tell, as over PTP/IP. On USB the attached camera's own vendor ID decides, and a different vendorId here makes connect() fail with CameraRefusedError.
On Node, a body outside Slate's validated list gets one read-only inventory per model+firmware per installation, shared as a first-contact profile unless telemetry is off.
ConnectOptions
How Camera.connect opens the camera.
interface ConnectOptions {
observeOnly?: boolean
device?: DeviceDescriptor
}Show ConnectOptions fieldsHide ConnectOptions fields
Read without changing any setting. Slate still opens the vendor's control session (Canon's remote and event modes, Sony's authenticated remote session) because nothing can be read without it, but it writes no host preference: Sony keeps its dial priority and saved image destination.
The body to open, when it differs from the device given to the constructor.
See DeviceDescriptor.
Other types
The types Camera hands back: what each method resolves to, what an event carries, and what recover() reports.
The types that say what the connected camera is and can do now: what getCapabilities() returns, what setControl takes, and which model was identified.
One type per setting: the values its getter returns and its setter takes, with the types the typed getters and setters are declared with.
The types around Camera: the workflows built on it, the connection under it, and the host that shares cameras between callers.
Related
The class: constructor, every method, what each returns and throws.
Every setting id with its values, getter, setter and vendor properties.
Every exported type, field by field.
Every error class: when it is thrown and what to do.
Every import path of the package and what it exports.