react-native-vision-camera-spoof-detector 1.0.24 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -1,2 +1,2 @@
1
- #Wed Sep 02 15:02:00 IST 2026
1
+ #Thu Sep 03 10:53:58 IST 2026
2
2
  gradle.version=9.2.0
package/index.js CHANGED
@@ -3,9 +3,15 @@ import { VisionCameraProxy } from 'react-native-vision-camera';
3
3
 
4
4
  const { FaceAntiSpoof } = NativeModules;
5
5
 
6
- // Lazily initialize the frame processor plugin after native initialize() succeeds.
6
+ // Initialize the plugin before any worklet captures this module.
7
7
  let _faceAntiSpoofPlugin = null;
8
8
 
9
+ try {
10
+ _faceAntiSpoofPlugin = VisionCameraProxy.initFrameProcessorPlugin('faceAntiSpoof', {});
11
+ } catch (e) {
12
+ console.warn('[FaceAntiSpoof] Failed to init frame processor plugin:', e);
13
+ }
14
+
9
15
  function ensurePluginInitialized() {
10
16
  if (!_faceAntiSpoofPlugin) {
11
17
  try {
@@ -15,6 +21,7 @@ function ensurePluginInitialized() {
15
21
  _faceAntiSpoofPlugin = null;
16
22
  }
17
23
  }
24
+ return !!_faceAntiSpoofPlugin;
18
25
  }
19
26
 
20
27
  // Worklet called by VisionCamera
@@ -80,11 +87,10 @@ export const initializeFaceAntiSpoof = async () => {
80
87
 
81
88
  const isSuccess = result && status.pluginAvailable;
82
89
  // If native initialization succeeded, register the frame processor plugin for worklets
83
- if (isSuccess) {
84
- ensurePluginInitialized();
85
- }
86
- console.log('[FaceAntiSpoof] Initialization result:', isSuccess);
87
- return isSuccess;
90
+ const pluginInitialized = isSuccess ? ensurePluginInitialized() : false;
91
+ const initialized = isSuccess && pluginInitialized;
92
+ console.log('[FaceAntiSpoof] Initialization result:', initialized);
93
+ return initialized;
88
94
  } catch (error) {
89
95
  console.error('[FaceAntiSpoof] Initialization failed:', error);
90
96
  throw error;
@@ -13,6 +13,8 @@
13
13
  #import "RCTBridge.h"
14
14
  #endif
15
15
 
16
+ extern void FaceAntiSpoofRegisterPlugin(void);
17
+
16
18
  @interface FaceAntiSpoofModule : NSObject <RCTBridgeModule>
17
19
  @end
18
20
 
@@ -33,6 +35,7 @@ RCT_REMAP_METHOD(initialize,
33
35
  initializeWithResolver:(RCTPromiseResolveBlock)resolve
34
36
  rejecter:(RCTPromiseRejectBlock)reject)
35
37
  {
38
+ FaceAntiSpoofRegisterPlugin();
36
39
 
37
40
  BOOL pluginAvailable = (NSClassFromString(@"FaceAntiSpoofFrameProcessor") != Nil);
38
41
 
@@ -66,6 +69,7 @@ RCT_REMAP_METHOD(checkModelStatus,
66
69
  checkModelStatusWithResolver:(RCTPromiseResolveBlock)resolve
67
70
  rejecter:(RCTPromiseRejectBlock)reject)
68
71
  {
72
+ FaceAntiSpoofRegisterPlugin();
69
73
  BOOL pluginAvailable = (NSClassFromString(@"FaceAntiSpoofFrameProcessor") != Nil);
70
74
  NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"FaceAntiSpoofing" ofType:@"tflite"];
71
75
  if (!modelPath) {
@@ -107,6 +111,7 @@ RCT_REMAP_METHOD(install,
107
111
  installWithResolver:(RCTPromiseResolveBlock)resolve
108
112
  rejecter:(RCTPromiseRejectBlock)reject)
109
113
  {
114
+ FaceAntiSpoofRegisterPlugin();
110
115
  // Attempt to initialize shared model resources via FaceAntiSpoofManager
111
116
  BOOL managerInitialized = NO;
112
117
  Class managerClass = NSClassFromString(@"FaceAntiSpoofManager");
@@ -1,18 +1,53 @@
1
1
  #import <Foundation/Foundation.h>
2
+ #if __has_include(<VisionCamera/FrameProcessorPluginRegistry.h>)
3
+ #import <VisionCamera/FrameProcessorPluginRegistry.h>
4
+ #import <VisionCamera/FrameProcessorPlugin.h>
5
+ #import <VisionCamera/VisionCameraProxyHolder.h>
6
+ #define FACE_ANTISPOOF_HAS_VISION_CAMERA_HEADERS 1
7
+ #elif __has_include("FrameProcessorPluginRegistry.h")
8
+ #import "FrameProcessorPluginRegistry.h"
9
+ #import "FrameProcessorPlugin.h"
10
+ #import "VisionCameraProxyHolder.h"
11
+ #define FACE_ANTISPOOF_HAS_VISION_CAMERA_HEADERS 1
12
+ #endif
2
13
  #import <objc/runtime.h>
3
14
  #import <objc/message.h>
4
15
 
5
- // At load time, attempt to register the Swift FrameProcessor plugin with VisionCamera
6
- __attribute__((constructor)) static void register_face_anti_spoof_plugin(void) {
16
+ // Register after VisionCamera has loaded so its registry is available.
17
+ void FaceAntiSpoofRegisterPlugin(void) {
7
18
  @autoreleasepool {
19
+ static BOOL registered = NO;
20
+ if (registered) {
21
+ return;
22
+ }
23
+
24
+ #if FACE_ANTISPOOF_HAS_VISION_CAMERA_HEADERS
25
+ // Use a direct reference so the registry is linked in device builds.
26
+ [FrameProcessorPluginRegistry addFrameProcessorPlugin:@"faceAntiSpoof"
27
+ withInitializer:^FrameProcessorPlugin*(VisionCameraProxyHolder *proxy, NSDictionary *options) {
28
+ Class dynClass = NSClassFromString(@"FaceAntiSpoofFrameProcessor");
29
+ if (dynClass == Nil) {
30
+ return nil;
31
+ }
32
+ id alloced = ((id (*)(id, SEL))objc_msgSend)((id)dynClass, sel_registerName("alloc"));
33
+ SEL initSel = sel_registerName("initWithProxy:withOptions:");
34
+ if (![alloced respondsToSelector:initSel]) {
35
+ return nil;
36
+ }
37
+ return ((id (*)(id, SEL, id, id))objc_msgSend)(alloced, initSel, proxy, options);
38
+ }];
39
+ registered = YES;
40
+ #else
8
41
  Class registry = NSClassFromString(@"FrameProcessorPluginRegistry");
9
42
 
10
43
  if (registry == Nil) {
11
- return; // VisionCamera not available yet
44
+ NSLog(@"[FaceAntiSpoof] VisionCamera registry is not loaded");
45
+ return;
12
46
  }
13
47
 
14
48
  SEL selector = NSSelectorFromString(@"addFrameProcessorPlugin:withInitializer:");
15
49
  if (![registry respondsToSelector:selector]) {
50
+ NSLog(@"[FaceAntiSpoof] VisionCamera registry API is unavailable");
16
51
  return;
17
52
  }
18
53
 
@@ -25,8 +60,8 @@ __attribute__((constructor)) static void register_face_anti_spoof_plugin(void) {
25
60
  SEL allocSel = sel_registerName("alloc");
26
61
  id alloced = ((id (*)(id, SEL))objc_msgSend)((id)dynClass, allocSel);
27
62
 
28
- // Swift's exported Objective-C initializer name is `initWithProxy:options:`
29
- SEL initSel = sel_registerName("initWithProxy:options:");
63
+ // VisionCamera's Objective-C initializer is `initWithProxy:withOptions:`.
64
+ SEL initSel = sel_registerName("initWithProxy:withOptions:");
30
65
  if (![alloced respondsToSelector:initSel]) {
31
66
  return nil;
32
67
  }
@@ -38,5 +73,12 @@ __attribute__((constructor)) static void register_face_anti_spoof_plugin(void) {
38
73
  // We use objc_msgSend to avoid compile-time dependency on the header signature
39
74
  void (*msgSend)(id, SEL, id, id) = (void (*)(id, SEL, id, id))objc_msgSend;
40
75
  msgSend((id)registry, selector, @"faceAntiSpoof", initializer);
76
+ registered = YES;
77
+ #endif
41
78
  }
42
79
  }
80
+
81
+ // Keep the old startup hook for apps where VisionCamera is already loaded.
82
+ __attribute__((constructor)) static void register_face_anti_spoof_plugin_at_load(void) {
83
+ FaceAntiSpoofRegisterPlugin();
84
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-vision-camera-spoof-detector",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "High-performance face anti-spoofing and liveness detection module for React Native Vision Camera. Uses TensorFlow Lite with GPU acceleration and optimized YUV processing.",
5
5
  "homepage": "https://github.com/dpraful/react-native-vision-camera-spoof-detector",
6
6
  "repository": {
@@ -37,7 +37,8 @@
37
37
  "index.js",
38
38
  "index.d.ts",
39
39
  "README.md",
40
- "LICENSE"
40
+ "LICENSE",
41
+ "react-native-vision-camera-spoof-detector.podspec"
41
42
  ],
42
43
  "keywords": [
43
44
  "react-native",
@@ -0,0 +1,22 @@
1
+ Pod::Spec.new do |s|
2
+ s.name = 'react-native-vision-camera-spoof-detector'
3
+ s.version = '0.1.0'
4
+ s.summary = 'Face anti-spoof detector for VisionCamera (iOS)'
5
+ s.homepage = 'https://example.com'
6
+ s.license = { :type => 'MIT' }
7
+ s.authors = { 'You' => 'you@example.com' }
8
+ s.platform = :ios, '11.0'
9
+ s.source = { :path => '.' }
10
+
11
+ s.swift_version = '5.0'
12
+
13
+ s.source_files = 'ios/**/*.{h,m,mm,swift,mm,cpp,c,cc}'
14
+ s.resources = ['ios/models/*']
15
+
16
+ # Dependencies
17
+ s.dependency 'TensorFlowLiteSwift'
18
+ s.dependency 'VisionCamera'
19
+
20
+ # Keep default deployment target and static linkage consistent with RN
21
+ s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
22
+ end