Skip to content

docs: fix incorrect API examples and default in camera docs#4030

Merged
mrousavy merged 1 commit into
mrousavy:mainfrom
patrickwehbe:docs/fix-api-examples
Jun 22, 2026
Merged

docs: fix incorrect API examples and default in camera docs#4030
mrousavy merged 1 commit into
mrousavy:mainfrom
patrickwehbe:docs/fix-api-examples

Conversation

@patrickwehbe

Copy link
Copy Markdown
Contributor

While reading the docs I hit three example snippets that don't match the actual API. Each fix below is checked against the source of truth in the repo.

1. startRecording example is a SyntaxError (docs/content/docs/recorder.mdx)

The "Starting a Recording" snippet passes the callbacks inside an object literal:

await recorder.startRecording({
  (path, reason) => ...,
  (error) => ...,
})

Bare arrow functions as object members aren't valid JS, so this throws SyntaxError: Unexpected token '('. startRecording actually takes positional arguments: startRecording(onRecordingFinished, onRecordingError, onRecordingPaused?, onRecordingResumed?) (see Recorder.nitro.ts). The positional form is already used correctly in video-output.mdx, so this just makes recorder.mdx consistent with it.

2. Wrong default JPEG quality (docs/content/docs/photo-quality.mdx)

The page says the default compression is 0.95 (95% quality). The real default is 0.9: usePhotoOutput destructures quality = 0.9 (src/hooks/usePhotoOutput.ts), and the Nitro spec documents @default 0.9 (CameraPhotoOutput.nitro.ts). Updated 0.95 to 0.9 and 95% to 90%.

3. getCameraDevice @example uses the wrong call shape (src/devices/getCameraDevice.ts)

The DeviceFilter.physicalDevices JSDoc @example calls getCameraDevice({ physicalDevices: [...] }) (a single object), but the function signature is getCameraDevice(devices, position, filter). The function-level @example in the same file already shows the correct 3-argument form, so I updated the two physicalDevices example lines to match: getCameraDevice(devices, 'back', { physicalDevices: [...] }).

Docs-only change, no runtime code touched.

Three docs corrections, each verified against the source of truth in
the package:

- recorder.mdx: the `startRecording` example wrapped its callbacks in
  an object literal (`startRecording({ (path, reason) => ..., ... })`),
  which is a SyntaxError. `startRecording` takes positional arguments
  (`onRecordingFinished, onRecordingError, onRecordingPaused?,
  onRecordingResumed?`) per Recorder.nitro.ts; the positional form is
  already used correctly in video-output.mdx. Rewrote the example to the
  positional form.

- photo-quality.mdx: the default JPEG compression was documented as
  `0.95` (95% quality). The actual default is `0.9`
  (usePhotoOutput.ts uses `quality = 0.9`, and CameraPhotoOutput.nitro.ts
  documents `@default 0.9`). Changed `0.95` -> `0.9` and `95%` -> `90%`.

- getCameraDevice.ts: the DeviceFilter.physicalDevices `@example` called
  `getCameraDevice({ physicalDevices: [...] })` (single object), but the
  signature is `getCameraDevice(devices, position, filter)`. The
  function-level `@example` already shows the 3-arg form. Fixed the two
  example lines to `getCameraDevice(devices, 'back', { physicalDevices:
  [...] })`.
@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Margelo Team on Vercel.

A member of the Team first needs to authorize it.

@mrousavy
mrousavy merged commit bd631bc into mrousavy:main Jun 22, 2026
1 check failed
@mrousavy

Copy link
Copy Markdown
Owner

Cool thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants