From e825e21e1d35700a15c83efedd8e8bffb5bb4152 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Tue, 16 Jan 2024 18:00:13 +0100 Subject: [PATCH] fix: Make `Frame` properties readonly in Types (#2397) --- package/src/Frame.ts | 18 +++++++++--------- package/src/FrameProcessorPlugins.ts | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package/src/Frame.ts b/package/src/Frame.ts index 3a50c80..61594bd 100644 --- a/package/src/Frame.ts +++ b/package/src/Frame.ts @@ -18,42 +18,42 @@ export interface Frame { * 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 */ - isValid: boolean + readonly isValid: boolean /** * Returns the width of the frame, in pixels. */ - width: number + readonly width: number /** * Returns the height of the frame, in pixels. */ - height: number + readonly height: number /** * Returns the amount of bytes per row. */ - bytesPerRow: number + readonly bytesPerRow: number /** * Returns the number of planes this frame contains. */ - planesCount: number + readonly planesCount: number /** * 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. */ - timestamp: number + readonly timestamp: number /** * Represents the orientation of the Frame. * * 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} */ - orientation: Orientation + readonly orientation: Orientation /** * Represents the pixel-format of the Frame. */ - pixelFormat: PixelFormat + readonly pixelFormat: PixelFormat /** * Get the underlying data of the Frame as a uint8 array buffer. diff --git a/package/src/FrameProcessorPlugins.ts b/package/src/FrameProcessorPlugins.ts index bf94d3d..80d6e16 100644 --- a/package/src/FrameProcessorPlugins.ts +++ b/package/src/FrameProcessorPlugins.ts @@ -17,12 +17,12 @@ interface FrameProcessorPlugin { * @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) */ - call: (frame: Frame, options?: Record) => ParameterType + call(frame: Frame, options?: Record): ParameterType } interface TVisionCameraProxy { - setFrameProcessor: (viewTag: number, frameProcessor: FrameProcessor) => void - removeFrameProcessor: (viewTag: number) => void + setFrameProcessor(viewTag: number, frameProcessor: FrameProcessor): void + removeFrameProcessor(viewTag: number): void /** * Creates a new instance of a native Frame Processor Plugin. * 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!") * ``` */ - initFrameProcessorPlugin: (name: string, options?: Record) => FrameProcessorPlugin | undefined + initFrameProcessorPlugin(name: string, options?: Record): FrameProcessorPlugin | undefined /** * 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!'