fix: Make Frame properties readonly in Types (#2397)

This commit is contained in:
Marc Rousavy 2024-01-16 18:00:13 +01:00 committed by GitHub
parent 64207ac1bf
commit e825e21e1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 14 deletions

View File

@ -18,42 +18,42 @@ export interface Frame {
* Whether the underlying buffer is still valid or not. * Whether the underlying buffer is still valid or not.
* A Frame is valid as long as your Frame Processor (or a `runAsync(..)` operation) is still running * A Frame is valid as long as your Frame Processor (or a `runAsync(..)` operation) is still running
*/ */
isValid: boolean readonly isValid: boolean
/** /**
* Returns the width of the frame, in pixels. * Returns the width of the frame, in pixels.
*/ */
width: number readonly width: number
/** /**
* Returns the height of the frame, in pixels. * Returns the height of the frame, in pixels.
*/ */
height: number readonly height: number
/** /**
* Returns the amount of bytes per row. * Returns the amount of bytes per row.
*/ */
bytesPerRow: number readonly bytesPerRow: number
/** /**
* Returns the number of planes this frame contains. * Returns the number of planes this frame contains.
*/ */
planesCount: number readonly planesCount: number
/** /**
* Returns whether the Frame is mirrored (selfie camera) or not. * Returns whether the Frame is mirrored (selfie camera) or not.
*/ */
isMirrored: boolean readonly isMirrored: boolean
/** /**
* Returns the timestamp of the Frame relative to the host sytem's clock. * Returns the timestamp of the Frame relative to the host sytem's clock.
*/ */
timestamp: number readonly timestamp: number
/** /**
* Represents the orientation of the Frame. * Represents the orientation of the Frame.
* *
* Some ML Models are trained for specific orientations, so they need to be taken into * Some ML Models are trained for specific orientations, so they need to be taken into
* consideration when running a frame processor. See also: {@linkcode isMirrored} * consideration when running a frame processor. See also: {@linkcode isMirrored}
*/ */
orientation: Orientation readonly orientation: Orientation
/** /**
* Represents the pixel-format of the Frame. * Represents the pixel-format of the Frame.
*/ */
pixelFormat: PixelFormat readonly pixelFormat: PixelFormat
/** /**
* Get the underlying data of the Frame as a uint8 array buffer. * Get the underlying data of the Frame as a uint8 array buffer.

View File

@ -17,12 +17,12 @@ interface FrameProcessorPlugin {
* @param options (optional) Additional options. Options will be converted to a native dictionary * @param options (optional) Additional options. Options will be converted to a native dictionary
* @returns (optional) A value returned from the native Frame Processor Plugin (or undefined) * @returns (optional) A value returned from the native Frame Processor Plugin (or undefined)
*/ */
call: (frame: Frame, options?: Record<string, ParameterType>) => ParameterType call(frame: Frame, options?: Record<string, ParameterType>): ParameterType
} }
interface TVisionCameraProxy { interface TVisionCameraProxy {
setFrameProcessor: (viewTag: number, frameProcessor: FrameProcessor) => void setFrameProcessor(viewTag: number, frameProcessor: FrameProcessor): void
removeFrameProcessor: (viewTag: number) => void removeFrameProcessor(viewTag: number): void
/** /**
* Creates a new instance of a native Frame Processor Plugin. * Creates a new instance of a native Frame Processor Plugin.
* The Plugin has to be registered on the native side, otherwise this returns `undefined`. * The Plugin has to be registered on the native side, otherwise this returns `undefined`.
@ -34,11 +34,11 @@ interface TVisionCameraProxy {
* if (plugin == null) throw new Error("Failed to load scanFaces plugin!") * if (plugin == null) throw new Error("Failed to load scanFaces plugin!")
* ``` * ```
*/ */
initFrameProcessorPlugin: (name: string, options?: Record<string, ParameterType>) => FrameProcessorPlugin | undefined initFrameProcessorPlugin(name: string, options?: Record<string, ParameterType>): FrameProcessorPlugin | undefined
/** /**
* Throws the given error. * Throws the given error.
*/ */
throwJSError: (error: unknown) => void throwJSError(error: unknown): void
} }
const errorMessage = 'Frame Processors are not available, react-native-worklets-core is not installed!' const errorMessage = 'Frame Processors are not available, react-native-worklets-core is not installed!'