Skip to content

Commit

Permalink
add support for v3.0.0 for iOS
Browse files Browse the repository at this point in the history
See: mrousavy/react-native-vision-camera#1754
for Android. We need this to be able to pass in the types array.
  • Loading branch information
rkmackinnon committed Sep 2, 2023
1 parent dedefa6 commit f2933a7
Show file tree
Hide file tree
Showing 27 changed files with 5,175 additions and 6,330 deletions.
27 changes: 0 additions & 27 deletions .yarn/patches/react-native-vision-camera-https-167742576d.patch

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
diff --git a/ios/Frame Processor/FrameProcessorPluginHostObject.mm b/ios/Frame Processor/FrameProcessorPluginHostObject.mm
index c21e7765da1205264063650f84e86a4a45f9f263..8fb580472bd391b9b02685e83c55af2920125445 100644
--- a/ios/Frame Processor/FrameProcessorPluginHostObject.mm
+++ b/ios/Frame Processor/FrameProcessorPluginHostObject.mm
@@ -39,7 +39,7 @@
}

// Call actual Frame Processor Plugin
- id result = [_plugin callback:frame withArguments:nil];
+ id result = [_plugin callback:frame withArguments:options];

// Convert result value to jsi::Value (possibly undefined)
return JSINSObjectConversion::convertObjCObjectToJSIValue(runtime, result);
diff --git a/src/FrameProcessorPlugins.ts b/src/FrameProcessorPlugins.ts
index cb5366f5cbebb6472b77b4450c50f9ca8e965ef2..d49f709e26a8e7970501826f0ca86f70e44b0628 100644
--- a/src/FrameProcessorPlugins.ts
+++ b/src/FrameProcessorPlugins.ts
@@ -7,17 +7,16 @@ import type TWorklets from 'react-native-worklets-core';
import { CameraModule } from './NativeCameraModule';
import { assertJSIAvailable } from './JSIHelper';

-type BasicParameterType = string | number | boolean | undefined;
-type ParameterType = BasicParameterType | BasicParameterType[] | Record<string, BasicParameterType | undefined>;
+type ParameterType = string | number | boolean | undefined | ParameterType[] | { [key: string]: ParameterType };

-interface FrameProcessorPlugin {
+interface FrameProcessorPlugin<T extends ParameterType> {
/**
* Call the native Frame Processor Plugin with the given Frame and options.
* @param frame The Frame from the Frame Processor.
* @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<string, ParameterType>) => ParameterType;
+ call: (frame: Frame, options?: Record<string, ParameterType>) => T;
}

interface TVisionCameraProxy {
@@ -27,7 +26,7 @@ interface TVisionCameraProxy {
* Creates a new instance of a Frame Processor Plugin.
* The Plugin has to be registered on the native side, otherwise this returns `undefined`
*/
- getFrameProcessorPlugin: (name: string) => FrameProcessorPlugin | undefined;
+ getFrameProcessorPlugin: <T extends ParameterType>(name: string) => FrameProcessorPlugin<T> | undefined;
}

let hasWorklets = false;
Loading

2 comments on commit f2933a7

@Nanle21
Copy link

@Nanle21 Nanle21 commented on f2933a7 Sep 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello
i have been having this error

node_modules/react-native-vision-camera/src/CameraDevice.ts:30:5 - error TS2578: Unused '@ts-expect-error' directive.

30 // @ts-expect-error for very obvious reasons
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error in node_modules/react-native-vision-camera/src/CameraDevice.ts:30

@rkmackinnon
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, thanks! That can be fixed by just uncommenting the @ts-expect-error line. I had been uncommenting it in previous commits' patch files but missed carrying it forward with this release. I'll put it back in for the next update once a new release of react-native-vision-camera is out that lets me add Android support.

Please sign in to comment.