Update code example languages

This commit is contained in:
Marc Rousavy 2021-03-09 12:02:10 +01:00
parent cd55596ebd
commit e8a4e9f6b5
4 changed files with 20 additions and 15 deletions

View File

@ -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. * 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 * @example
* ```js * ```tsx
* const devices = useCameraDevices('wide-angle-camera') * const devices = useCameraDevices('wide-angle-camera')
* const device = devices.back * const device = devices.back
* *
@ -89,7 +89,6 @@ export interface CameraDeviceProps {
* style={StyleSheet.absoluteFill} * style={StyleSheet.absoluteFill}
* /> * />
* ) * )
*
* ``` * ```
*/ */
device: CameraDevice; device: CameraDevice;
@ -208,7 +207,7 @@ type RefType = React.Component<CameraProps> & Readonly<NativeMethods>;
* * {@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 `<Camera>` component instead of using `isActive={false}`, the Camera will take a bit longer to start again. * * {@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 `<Camera>` component instead of using `isActive={false}`, the Camera will take a bit longer to start again.
* *
* @example * @example
* ```jsx * ```tsx
* function App() { * function App() {
* const devices = useCameraDevices('wide-angle-camera') * const devices = useCameraDevices('wide-angle-camera')
* const device = devices.back * const device = devices.back
@ -263,7 +262,7 @@ export class Camera extends React.PureComponent<CameraProps, CameraState> {
* *
* @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 * @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 * @example
* ```js * ```ts
* const photo = await camera.current.takePhoto({ * const photo = await camera.current.takePhoto({
* qualityPrioritization: 'quality', * qualityPrioritization: 'quality',
* flash: 'on', * flash: 'on',
@ -288,7 +287,7 @@ export class Camera extends React.PureComponent<CameraProps, CameraState> {
* *
* @platform Android * @platform Android
* @example * @example
* ```js * ```ts
* const photo = await camera.current.takeSnapshot({ * const photo = await camera.current.takeSnapshot({
* quality: 85, * quality: 85,
* skipMetadata: true * skipMetadata: true
@ -318,7 +317,7 @@ export class Camera extends React.PureComponent<CameraProps, CameraState> {
* @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 * @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 * @example
* ```js * ```ts
* camera.current.startRecording({ * camera.current.startRecording({
* onRecordingFinished: (video) => console.log(video), * onRecordingFinished: (video) => console.log(video),
* onRecordingError: (error) => console.error(error), * onRecordingError: (error) => console.error(error),
@ -350,7 +349,7 @@ export class Camera extends React.PureComponent<CameraProps, CameraState> {
* @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 * @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 * @example
* ```js * ```ts
* await camera.current.startRecording() * await camera.current.startRecording()
* setTimeout(async () => { * setTimeout(async () => {
* const video = await camera.current.stopRecording() * const video = await camera.current.stopRecording()
@ -376,7 +375,7 @@ export class Camera extends React.PureComponent<CameraProps, CameraState> {
* *
* @throws {@linkcode CameraRuntimeError} When any kind of error occured while focussing. Use the {@linkcode CameraRuntimeError.code | code} property to get the actual error * @throws {@linkcode CameraRuntimeError} When any kind of error occured while focussing. Use the {@linkcode CameraRuntimeError.code | code} property to get the actual error
* @example * @example
* ```js * ```ts
* await camera.current.focus({ * await camera.current.focus({
* x: tapEvent.x, * x: tapEvent.x,
* y: tapEvent.y * y: tapEvent.y
@ -431,7 +430,7 @@ export class Camera extends React.PureComponent<CameraProps, CameraState> {
* *
* @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 * @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 * @example
* ```js * ```ts
* const devices = await Camera.getAvailableCameraDevices() * const devices = await Camera.getAvailableCameraDevices()
* const filtered = devices.filter((d) => matchesMyExpectations(d)) * const filtered = devices.filter((d) => matchesMyExpectations(d))
* const sorted = devices.sort(sortDevicesByAmountOfCameras) * const sorted = devices.sort(sortDevicesByAmountOfCameras)

View File

@ -73,6 +73,12 @@ export interface PhotoFile extends TemporaryFile {
height: number; height: number;
isRawPhoto: boolean; isRawPhoto: boolean;
thumbnail?: Record<string, unknown>; thumbnail?: Record<string, unknown>;
/**
* 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: { metadata: {
Orientation: number; Orientation: number;
/** /**

View File

@ -20,7 +20,7 @@ const DefaultCameraDevices: CameraDevices = {
* @returns The best matching {@linkcode CameraDevice}. * @returns The best matching {@linkcode CameraDevice}.
* @throws {@linkcode CameraRuntimeError} if no device was found. * @throws {@linkcode CameraRuntimeError} if no device was found.
* @example * @example
* ```jsx * ```tsx
* const device = useCameraDevice() * const device = useCameraDevice()
* // ... * // ...
* return <Camera device={device} /> * return <Camera device={device} />
@ -35,7 +35,7 @@ export function useCameraDevices(): CameraDevices;
* @returns A {@linkcode CameraDevice} for the requested device type. * @returns A {@linkcode CameraDevice} for the requested device type.
* @throws {@linkcode CameraRuntimeError} if no device was found. * @throws {@linkcode CameraRuntimeError} if no device was found.
* @example * @example
* ```jsx * ```tsx
* const device = useCameraDevice('wide-angle-camera') * const device = useCameraDevice('wide-angle-camera')
* // ... * // ...
* return <Camera device={device} /> * return <Camera device={device} />

View File

@ -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. * > Note that this makes the `sort()` function descending, so the first element (`[0]`) is the "best" device.
* *
* @example * @example
* ```js * ```ts
* const devices = camera.devices.sort(sortDevices) * const devices = camera.devices.sort(sortDevices)
* const bestDevice = devices[0] * 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_. * @returns A list of Camera Device Formats that match the given `viewSize`' aspect ratio _as close as possible_.
* *
* @example * @example
* ```js * ```ts
* const formats = useMemo(() => filterFormatsByAspectRatio(device.formats, CAMERA_VIEW_SIZE), [device.formats]) * const formats = useMemo(() => filterFormatsByAspectRatio(device.formats, CAMERA_VIEW_SIZE), [device.formats])
* ``` * ```
* @method * @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. * Sorts Camera Device Formats by highest photo-capture resolution, descending. Use this in a `.sort` function.
* *
* @example * @example
* ```js * ```ts
* const formats = useMemo(() => device.formats.sort(sortFormatsByResolution), [device.formats]) * const formats = useMemo(() => device.formats.sort(sortFormatsByResolution), [device.formats])
* const bestFormat = formats[0] * 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 {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. * @param {number} fps The FPS to check if the given `range` supports.
* @example * @example
* ```js * ```ts
* // get all formats that support 60 FPS * // get all formats that support 60 FPS
* const formatsWithHighFps = useMemo(() => device.formats.filter((f) => f.frameRateRanges.some((r) => frameRateIncluded(r, 60))), [device.formats]) * const formatsWithHighFps = useMemo(() => device.formats.filter((f) => f.frameRateRanges.some((r) => frameRateIncluded(r, 60))), [device.formats])
* ``` * ```