Skip to main content
TypesResult types

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 fields
atLimitboolean

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 fields
destination'card'

Where the photo went.

mediaId?string

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.

namestring

The file name the camera gave the photo, such as DSC01234.JPG.

sizeBytesnumber

The size of the card file, as listMedia() reports it.

info?ObjectInfo

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 fields
destination'computer' | 'computerOnly'

Where the photo went.

dataUint8Array

The photo's bytes.

namestring

The file name the camera gave the photo, such as DSC01234.JPG.

mediaId?string

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.

sizeBytesnumber

The size of the card file, as listMedia() reports it.

info?ObjectInfo

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 | ComputerPhoto

Clip

A finished movie file the camera wrote to its card during one recording.

interface Clip {
    mediaId: string
    name: string
    sizeBytes?: number
}
Show Clip fields
mediaIdstring

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.

namestring

The file name on the card, such as C0001.MP4.

sizeBytes?number

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 fields
kind'focus' | 'face' | 'tracking'

Whether it marks the focus area, a detected face or a tracked subject.

focusedboolean

True once the camera reports this frame in focus.

centerXnumber

The centre's horizontal position, 0 (left) to 1 (right).

centerYnumber

The centre's vertical position, 0 (top) to 1 (bottom).

widthnumber

The width, as a fraction of the picture.

heightnumber

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 fields
jpegUint8Array

The current picture as a JPEG.

focusFramesFocusFrame[]

The camera's focus frames in this picture.

See FocusFrame.

overlay?LiveViewOverlay

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 fields
pngUint8Array

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 fields
slotnumber

1 for the first slot.

state'ready' | 'absent' | 'error' | 'unknown'

ready: a card is in and readable. unknown: the camera did not say.

writable?boolean

Whether the camera says it can record to this card; absent when it does not say.

capacityBytes?number

The card's size.

freeBytes?number

The space left on it.

photosRemaining?number

The photos that still fit, as the camera counts them at its current settings.

recordingSecondsRemaining?number

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 fields
idstring

Opaque; survives a reconnect while the file stays on the card.

namestring

The file name on the card, such as DSC01234.ARW.

kind'photo' | 'clip' | 'other'

Whether the file is a photo, a clip or something else.

slotnumber

The card slot it is on; 1 for the first.

sizeBytes?number

Bytes on the card, when the camera reports the size.

capturedAt?string

The camera's local wall time, ISO 8601 without an offset (2026-11-24T14:05:09).

widthPixels?number

The width of the picture, when the camera reports it.

heightPixels?number

The height of the picture, when the camera reports it.

previewsreadonly MediaPreviewSize[]

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 fields
percent?number

0–100, when the camera reports a percentage.

level?'empty' | 'low' | 'medium' | 'high' | 'full'

The camera's coarse level, when it reports one (Canon reports only this).

minutesRemaining?number

The camera's own estimate for current conditions; never derived from the percentage.

powerSource'battery' | 'usb' | 'dc' | 'poe' | 'unknown'

unknown unless the camera says; a USB cable or an outlet is not evidence.

batteryPresent?boolean

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 fields
manufacturerstring

The make, such as Sony.

modelstring

As the camera names itself, such as ILCE-7M5.

firmwarestring

The firmware version, as the camera reports it.

serialNumber?string

The body's serial number, when it reports one.

lensMount?string

Present only for model families whose mount follows from the name (E, A, Z, F, RF).

connection'usb' | 'wifi' | 'ip'

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 fields
vendorIdnumber

The USB vendor ID, such as 0x054c for Sony.

productIdnumber

The USB product ID of the model.

serialNumber?string

The USB serial number, when the device reports one.

manufacturer?string

The USB manufacturer string, as the device reports it.

model?string

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 = CameraRecoveryReport

Recovery

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 fields
stepTimeoutMilliseconds?numberdefault: 8 s

Upper bound for each transaction and reset during recovery.

waitForDeviceMilliseconds?numberdefault: 20 s

How long to wait for the camera to (re)appear on USB.

allowPortReset?booleandefault: true

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 fields
recoveredboolean

The camera answered GetDeviceInfo after one of the steps.

needsPhysicalActionboolean

Software recovery could not bring the camera back: only now are power or hub cycling warranted.

stepsCameraRecoveryStep[]

Each step tried, in order.

See CameraRecoveryStep.

durationMillisecondsnumber

How long the whole recovery took.

identity?{ manufacturer: string; model: string; firmware: string }

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 fields
step'enumerate' | 'session' | 'device-reset' | 'port-reset'

Which step: finding the device, a fresh session, a PTP Device Reset or a USB port reset.

okboolean

Whether the step succeeded.

durationMillisecondsnumber

How long the step took.

detail?string

What went wrong, when it did.

Other types

⌘I