The types Camera hands back: what each method resolves to, what an event carries, and what recover() reports. 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 { Photo, RecoveryReport } from '@darkgrade/slate'Results
What the methods of Camera resolve to, and what its events carry.
FocusNudge
What a focus nudge did.
interface FocusNudge {
atLimit: boolean
}Show FocusNudge fieldsHide FocusNudge fields
The lens stopped at the end of its focus travel that way: it moved less than the step, or not at all when it was already there. Another nudge the same way will not move it.
FocusResult
Whether autofocus confirmed focus.
acquired: the camera reported focus.not-acquired: the camera reported it could not focus (low contrast, too dark, too close).unknown: the camera focused for a while but reports nothing either way (Canon's timed hold, Sony in movie mode).
type FocusResult = 'acquired' | 'not-acquired' | 'unknown'CardPhoto
A photo confirmed on the card.
interface CardPhoto {
destination: 'card'
mediaId?: string
name: string
sizeBytes: number
info?: ObjectInfo
}Show CardPhoto fieldsHide CardPhoto fields
Where the photo went.
The card file's media id, the same id listMedia() gives it, for getMediaPreview() and downloadMedia(). Absent only when the camera offers no card listing over this connection (listMedia is unsupported), so no id can name the file.
The file name the camera gave the photo, such as DSC01234.JPG.
The size of the card file, as listMedia() reports it.
With includeInfo: the ObjectInfo the camera sent for the photo. On Sony it describes the copy the camera sends the computer, whose size can be smaller than the card file's sizeBytes.
See ObjectInfo.
ComputerPhoto
A photo whose bytes reached this computer. With destination 'computer' it is also on the card, and data is the card file. With 'computerOnly' it is not on the card: it has no mediaId.
interface ComputerPhoto extends Omit<CardPhoto, 'destination'> {
destination: 'computer' | 'computerOnly'
data: Uint8Array
name: string
mediaId?: string
sizeBytes: number
info?: ObjectInfo
}Show ComputerPhoto fieldsHide ComputerPhoto fields
Where the photo went.
The photo's bytes.
The file name the camera gave the photo, such as DSC01234.JPG.
The card file's media id, the same id listMedia() gives it, for getMediaPreview() and downloadMedia(). Absent only when the camera offers no card listing over this connection (listMedia is unsupported), so no id can name the file.
The size of the card file, as listMedia() reports it.
With includeInfo: the ObjectInfo the camera sent for the photo. On Sony it describes the copy the camera sends the computer, whose size can be smaller than the card file's sizeBytes.
See ObjectInfo.
Extends CardPhoto.
Photo
What takePhoto resolves to: a CardPhoto for the destination card, a ComputerPhoto for computer and computerOnly.
type Photo = CardPhoto | ComputerPhotoClip
A finished movie file the camera wrote to its card during one recording.
interface Clip {
mediaId: string
name: string
sizeBytes?: number
}Show Clip fieldsHide Clip fields
The clip's media id: the one listMedia() gives it, or its PTP object handle in decimal on a camera that names card files only by handle.
The file name on the card, such as C0001.MP4.
Bytes on the card; absent when the camera reports a size it cannot state (over 4 GiB).
FocusFrame
A frame the camera draws over its picture: its focus area, a detected face or a tracked subject.
interface FocusFrame {
kind: 'focus' | 'face' | 'tracking'
focused: boolean
centerX: number
centerY: number
width: number
height: number
}Show FocusFrame fieldsHide FocusFrame fields
Whether it marks the focus area, a detected face or a tracked subject.
True once the camera reports this frame in focus.
The centre's horizontal position, 0 (left) to 1 (right).
The centre's vertical position, 0 (top) to 1 (bottom).
The width, as a fraction of the picture.
The height, as a fraction of the picture.
LiveViewFrame
What getLiveViewFrame resolves to: one picture and the frames the camera draws over it.
interface LiveViewFrame {
jpeg: Uint8Array
focusFrames: FocusFrame[]
overlay?: LiveViewOverlay
}Show LiveViewFrame fieldsHide LiveViewFrame fields
The current picture as a JPEG.
The camera's focus frames in this picture.
See FocusFrame.
Present when the overlay was requested.
See LiveViewOverlay.
LiveViewOverlay
The camera's own on-screen info (menus, dialogs, shooting info), drawn to lay over the picture.
interface LiveViewOverlay {
png: Uint8Array
}Show LiveViewOverlay fieldsHide LiveViewOverlay fields
A PNG with transparency, the size of the camera's display.
CardStatus
One card slot as the camera reports it now. A field the camera does not report is absent.
interface CardStatus {
slot: number
state: 'ready' | 'absent' | 'error' | 'unknown'
writable?: boolean
capacityBytes?: number
freeBytes?: number
photosRemaining?: number
recordingSecondsRemaining?: number
}Show CardStatus fieldsHide CardStatus fields
1 for the first slot.
ready: a card is in and readable. unknown: the camera did not say.
Whether the camera says it can record to this card; absent when it does not say.
The card's size.
The space left on it.
The photos that still fit, as the camera counts them at its current settings.
The recording time left, as the camera counts it at its current settings.
MediaItem
One file on the card, as listMedia lists it.
interface MediaItem {
id: string
name: string
kind: 'photo' | 'clip' | 'other'
slot: number
sizeBytes?: number
capturedAt?: string
widthPixels?: number
heightPixels?: number
previews: readonly MediaPreviewSize[]
}Show MediaItem fieldsHide MediaItem fields
Opaque; survives a reconnect while the file stays on the card.
The file name on the card, such as DSC01234.ARW.
Whether the file is a photo, a clip or something else.
The card slot it is on; 1 for the first.
Bytes on the card, when the camera reports the size.
The camera's local wall time, ISO 8601 without an offset (2026-11-24T14:05:09).
The width of the picture, when the camera reports it.
The height of the picture, when the camera reports it.
The preview sizes getMediaPreview can return for this file.
See MediaPreviewSize.
Battery
What the camera reports about its power now. A field the camera does not report is absent.
interface Battery {
percent?: number
level?: 'empty' | 'low' | 'medium' | 'high' | 'full'
minutesRemaining?: number
powerSource: 'battery'
| 'usb'
| 'dc'
| 'poe'
| 'unknown'
batteryPresent?: boolean
}Show Battery fieldsHide Battery fields
0–100, when the camera reports a percentage.
The camera's coarse level, when it reports one (Canon reports only this).
The camera's own estimate for current conditions; never derived from the percentage.
unknown unless the camera says; a USB cable or an outlet is not evidence.
Present only when the camera reports it.
CameraInfo
What the body reports about itself. Fields the body does not report are absent, never guessed.
interface CameraInfo {
manufacturer: string
model: string
firmware: string
serialNumber?: string
lensMount?: string
connection: 'usb' | 'wifi' | 'ip'
}Show CameraInfo fieldsHide CameraInfo fields
The make, such as Sony.
As the camera names itself, such as ILCE-7M5.
The firmware version, as the camera reports it.
The body's serial number, when it reports one.
Present only for model families whose mount follows from the name (E, A, Z, F, RF).
ip is PTP/IP, over Wi-Fi or Ethernet; wifi is a vendor's own Wi-Fi session.
DiscoveredCamera
One attached camera found by Camera.discover(), without opening a session.
interface DiscoveredCamera {
vendorId: number
productId: number
serialNumber?: string
manufacturer?: string
model?: string
}Show DiscoveredCamera fieldsHide DiscoveredCamera fields
The USB vendor ID, such as 0x054c for Sony.
The USB product ID of the model.
The USB serial number, when the device reports one.
The USB manufacturer string, as the device reports it.
The USB product string, as the device reports it.
RecoveryReport
What Camera.recover() did: each software step, whether the camera answered GetDeviceInfo afterwards, and whether only power or hub cycling is left. CameraRecoveryReport is the same type.
type RecoveryReport = CameraRecoveryReportRecovery
What recover() takes and reports. Errors and recovery shows when to call it.
CameraRecoveryOptions
Limits for recover.
interface CameraRecoveryOptions {
stepTimeoutMilliseconds?: number
waitForDeviceMilliseconds?: number
allowPortReset?: boolean
}Show CameraRecoveryOptions fieldsHide CameraRecoveryOptions fields
Upper bound for each transaction and reset during recovery.
How long to wait for the camera to (re)appear on USB.
Disable when recovery must preserve USB enumeration and other consumers.
CameraRecoveryReport
What recover did: each software step, whether the camera answered afterwards, and whether only power or hub cycling is left.
interface CameraRecoveryReport {
recovered: boolean
needsPhysicalAction: boolean
steps: CameraRecoveryStep[]
durationMilliseconds: number
identity?: {
manufacturer: string
model: string
firmware: string
}
}Show CameraRecoveryReport fieldsHide CameraRecoveryReport fields
The camera answered GetDeviceInfo after one of the steps.
Software recovery could not bring the camera back: only now are power or hub cycling warranted.
Each step tried, in order.
See CameraRecoveryStep.
How long the whole recovery took.
What the camera answered to GetDeviceInfo, when it recovered.
CameraRecoveryStep
One step of a recovery and how it went.
interface CameraRecoveryStep {
step: 'enumerate'
| 'session'
| 'device-reset'
| 'port-reset'
ok: boolean
durationMilliseconds: number
detail?: string
}Show CameraRecoveryStep fieldsHide CameraRecoveryStep fields
Which step: finding the device, a fresh session, a PTP Device Reset or a USB port reset.
Whether the step succeeded.
How long the step took.
What went wrong, when it did.
Other types
The types you pass to Camera: its constructor options, and the options and choices of its methods.
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.