From e8a4e9f6b5207096c42af4fc605b869bac4541b0 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Tue, 9 Mar 2021 12:02:10 +0100 Subject: [PATCH] Update code example languages --- src/Camera.tsx | 17 ++++++++--------- src/PhotoFile.ts | 6 ++++++ src/hooks/useCameraDevices.ts | 4 ++-- src/utils/FormatFilter.ts | 8 ++++---- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/Camera.tsx b/src/Camera.tsx index b7c91f6..dbc8d8f 100644 --- a/src/Camera.tsx +++ b/src/Camera.tsx @@ -78,7 +78,7 @@ export interface CameraDeviceProps { * See the [Camera Devices](https://cuvent.github.io/react-native-vision-camera/docs/devices) section in the documentation for more information about Camera Devices. * * @example - * ```js + * ```tsx * const devices = useCameraDevices('wide-angle-camera') * const device = devices.back * @@ -89,7 +89,6 @@ export interface CameraDeviceProps { * style={StyleSheet.absoluteFill} * /> * ) - * * ``` */ device: CameraDevice; @@ -208,7 +207,7 @@ type RefType = React.Component & Readonly; * * {@linkcode CameraDynamicProps.isActive | isActive}: A boolean value that specifies whether the Camera should actively stream video frames or not. This can be compared to a Video component, where `isActive` specifies whether the video is paused or not. If you fully unmount the `` component instead of using `isActive={false}`, the Camera will take a bit longer to start again. * * @example - * ```jsx + * ```tsx * function App() { * const devices = useCameraDevices('wide-angle-camera') * const device = devices.back @@ -263,7 +262,7 @@ export class Camera extends React.PureComponent { * * @throws {@linkcode CameraCaptureError} When any kind of error occured while capturing the photo. Use the {@linkcode CameraCaptureError.code | code} property to get the actual error * @example - * ```js + * ```ts * const photo = await camera.current.takePhoto({ * qualityPrioritization: 'quality', * flash: 'on', @@ -288,7 +287,7 @@ export class Camera extends React.PureComponent { * * @platform Android * @example - * ```js + * ```ts * const photo = await camera.current.takeSnapshot({ * quality: 85, * skipMetadata: true @@ -318,7 +317,7 @@ export class Camera extends React.PureComponent { * @throws {@linkcode CameraCaptureError} When any kind of error occured while starting the video recording. Use the {@linkcode CameraCaptureError.code | code} property to get the actual error * * @example - * ```js + * ```ts * camera.current.startRecording({ * onRecordingFinished: (video) => console.log(video), * onRecordingError: (error) => console.error(error), @@ -350,7 +349,7 @@ export class Camera extends React.PureComponent { * @throws {@linkcode CameraCaptureError} When any kind of error occured while stopping the video recording. Use the {@linkcode CameraCaptureError.code | code} property to get the actual error * * @example - * ```js + * ```ts * await camera.current.startRecording() * setTimeout(async () => { * const video = await camera.current.stopRecording() @@ -376,7 +375,7 @@ export class Camera extends React.PureComponent { * * @throws {@linkcode CameraRuntimeError} When any kind of error occured while focussing. Use the {@linkcode CameraRuntimeError.code | code} property to get the actual error * @example - * ```js + * ```ts * await camera.current.focus({ * x: tapEvent.x, * y: tapEvent.y @@ -431,7 +430,7 @@ export class Camera extends React.PureComponent { * * @throws {@linkcode CameraRuntimeError} When any kind of error occured while getting all available camera devices. Use the {@linkcode CameraRuntimeError.code | code} property to get the actual error * @example - * ```js + * ```ts * const devices = await Camera.getAvailableCameraDevices() * const filtered = devices.filter((d) => matchesMyExpectations(d)) * const sorted = devices.sort(sortDevicesByAmountOfCameras) diff --git a/src/PhotoFile.ts b/src/PhotoFile.ts index be54a9e..bbcf537 100644 --- a/src/PhotoFile.ts +++ b/src/PhotoFile.ts @@ -73,6 +73,12 @@ export interface PhotoFile extends TemporaryFile { height: number; isRawPhoto: boolean; thumbnail?: Record; + /** + * Metadata information describing the captured image. + * + * @see [AVCapturePhoto.metadata](https://developer.apple.com/documentation/avfoundation/avcapturephoto/2873982-metadata) + * @see [AndroidX ExifInterface](https://developer.android.com/reference/androidx/exifinterface/media/ExifInterface) + */ metadata: { Orientation: number; /** diff --git a/src/hooks/useCameraDevices.ts b/src/hooks/useCameraDevices.ts index 1ec0992..d440c07 100644 --- a/src/hooks/useCameraDevices.ts +++ b/src/hooks/useCameraDevices.ts @@ -20,7 +20,7 @@ const DefaultCameraDevices: CameraDevices = { * @returns The best matching {@linkcode CameraDevice}. * @throws {@linkcode CameraRuntimeError} if no device was found. * @example - * ```jsx + * ```tsx * const device = useCameraDevice() * // ... * return @@ -35,7 +35,7 @@ export function useCameraDevices(): CameraDevices; * @returns A {@linkcode CameraDevice} for the requested device type. * @throws {@linkcode CameraRuntimeError} if no device was found. * @example - * ```jsx + * ```tsx * const device = useCameraDevice('wide-angle-camera') * // ... * return diff --git a/src/utils/FormatFilter.ts b/src/utils/FormatFilter.ts index effd39a..91132b1 100644 --- a/src/utils/FormatFilter.ts +++ b/src/utils/FormatFilter.ts @@ -9,7 +9,7 @@ import type { CameraDevice, CameraDeviceFormat, FrameRateRange } from 'react-nat * > Note that this makes the `sort()` function descending, so the first element (`[0]`) is the "best" device. * * @example - * ```js + * ```ts * const devices = camera.devices.sort(sortDevices) * const bestDevice = devices[0] * ``` @@ -84,7 +84,7 @@ const getFormatAspectRatioOverflow = (format: CameraDeviceFormat, size: Size): n * @returns A list of Camera Device Formats that match the given `viewSize`' aspect ratio _as close as possible_. * * @example - * ```js + * ```ts * const formats = useMemo(() => filterFormatsByAspectRatio(device.formats, CAMERA_VIEW_SIZE), [device.formats]) * ``` * @method @@ -103,7 +103,7 @@ export const filterFormatsByAspectRatio = (formats: CameraDeviceFormat[], viewSi * Sorts Camera Device Formats by highest photo-capture resolution, descending. Use this in a `.sort` function. * * @example - * ```js + * ```ts * const formats = useMemo(() => device.formats.sort(sortFormatsByResolution), [device.formats]) * const bestFormat = formats[0] * ``` @@ -128,7 +128,7 @@ export const sortFormatsByResolution = (left: CameraDeviceFormat, right: CameraD * @param {FrameRateRange} range The range to check if the given `fps` are included in * @param {number} fps The FPS to check if the given `range` supports. * @example - * ```js + * ```ts * // get all formats that support 60 FPS * const formatsWithHighFps = useMemo(() => device.formats.filter((f) => f.frameRateRanges.some((r) => frameRateIncluded(r, 60))), [device.formats]) * ```