anyline-ocr-react-native-module 55.7.1 → 55.9.0

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.
@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
18
18
  s.source = { :git => "https://github.com/Anyline/anyline-ocr-react-native-module.git", :tag => "#{s.version}" }
19
19
 
20
20
  s.source_files = 'ios/**/*.{h,m,swift}'
21
- s.dependency "Anyline", "55.7.0"
21
+ s.dependency "Anyline", "55.9.0"
22
22
  s.dependency "React"
23
23
 
24
24
  end
package/LICENSE.md ADDED
@@ -0,0 +1,11 @@
1
+ # Copyright © 2026 Anyline GmbH. All rights reserved.
2
+
3
+ ## License
4
+
5
+ The contents of this repository are the intellectual property of Anyline GmbH.
6
+
7
+ The use of the SDK and this app is subject to the most recent Master Subscription Terms of Anyline GmbH (or one of its subsidiaries), Terms of Use for the Anyline App and Anyline's Privacy Policies, available under Imprint & Legal of Anyline GmbH & Anyline Inc. | Anyline (or to a "Master Partner Agreement" if you are a partner of Anyline), and is only allowed if you have received a "Trial Access" (as defined in the Master Subscription Terms) or a license according to the Master Subscription Terms (or Master Partner Agreement).
8
+
9
+ ## Contact
10
+
11
+ For more information about the software development kit and licensing options, please contact Anyline GmbH at [anyline.com](https://anyline.com).
@@ -61,6 +61,6 @@ repositories {
61
61
 
62
62
  dependencies {
63
63
  implementation fileTree(dir: "libs", include: ["*.jar"])
64
- implementation 'io.anyline:anylinesdk:55.7.1'
64
+ implementation 'io.anyline:anylinesdk:55.9.0'
65
65
  implementation "com.facebook.react:react-native:+"
66
66
  }
@@ -1,5 +1,8 @@
1
1
  package com.anyline.reactnative;
2
2
 
3
+ import androidx.annotation.NonNull;
4
+
5
+ import com.anyline.reactnative.nativeview.AnylineNativeViewManager;
3
6
  import com.facebook.react.ReactPackage;
4
7
  import com.facebook.react.bridge.JavaScriptModule;
5
8
  import com.facebook.react.bridge.NativeModule;
@@ -12,17 +15,24 @@ import java.util.List;
12
15
 
13
16
  public class AnylinePackage implements ReactPackage {
14
17
 
18
+ private AnylineNativeViewManager viewManager = null;
19
+
15
20
  public List<Class<? extends JavaScriptModule>> createJSModules() {
16
21
  return Collections.emptyList();
17
22
  }
18
23
 
24
+ @NonNull
19
25
  @Override
20
- public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
21
- return Collections.emptyList();
26
+ public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
27
+ if (viewManager == null) {
28
+ viewManager = new AnylineNativeViewManager();
29
+ }
30
+ return List.of(viewManager);
22
31
  }
23
32
 
33
+ @NonNull
24
34
  @Override
25
- public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
35
+ public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
26
36
  List<NativeModule> modules = new ArrayList<>();
27
37
  modules.add(new AnylineSDKPlugin(reactContext));
28
38
  return modules;
@@ -5,8 +5,12 @@ package com.anyline.reactnative;
5
5
  */
6
6
 
7
7
  import android.content.Context;
8
+ import android.view.ViewGroup;
8
9
 
9
10
  import androidx.annotation.NonNull;
11
+ import androidx.annotation.Nullable;
12
+
13
+ import com.anyline.reactnative.nativeview.NativeViewRegistry;
10
14
 
11
15
  import com.facebook.react.bridge.Callback;
12
16
  import com.facebook.react.bridge.Promise;
@@ -14,6 +18,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
14
18
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
15
19
  import com.facebook.react.bridge.ReactMethod;
16
20
  import com.facebook.react.bridge.Arguments;
21
+ import com.facebook.react.bridge.UiThreadUtil;
17
22
  import com.facebook.react.modules.core.DeviceEventManagerModule;
18
23
 
19
24
  import org.jetbrains.annotations.NotNull;
@@ -168,6 +173,16 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule
168
173
  wrapperSessionSdkInitializationRequestJson.toString());
169
174
  }
170
175
 
176
+ @ReactMethod
177
+ public void setDefaultScanStartPlatformOptions(String scanStartPlatformOptionsString, final Promise promise) {
178
+ try {
179
+ WrapperSessionProvider.setDefaultScanStartPlatformOptions(scanStartPlatformOptionsString);
180
+ promise.resolve("");
181
+ } catch (Exception e) {
182
+ promise.reject(E_ERROR, e.getMessage());
183
+ }
184
+ }
185
+
171
186
  @ReactMethod
172
187
  public void setup(String config, String scanMode, Callback onResultReact, Callback onErrorReact) {
173
188
  setupWithInitializationParameters(null, config, scanMode, onResultReact, onErrorReact);
@@ -224,7 +239,13 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule
224
239
  JSONObject wrapperSessionScanStartRequestJson
225
240
  = WrapperSessionScanStartRequestExtensionKt.toJsonObject(wrapperSessionScanRequest);
226
241
 
227
- WrapperSessionProvider.requestScanStart(wrapperSessionScanStartRequestJson.toString());
242
+ UiThreadUtil.runOnUiThread(() -> {
243
+ try {
244
+ WrapperSessionProvider.requestScanStart(wrapperSessionScanStartRequestJson.toString());
245
+ } catch (Exception e) {
246
+ returnError("Unable to request ScanStart: " + e.getMessage());
247
+ }
248
+ });
228
249
 
229
250
  ResultReporter.setListener(this);
230
251
  }
@@ -248,6 +269,11 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule
248
269
  WrapperSessionProvider.requestExportCachedEvents();
249
270
  }
250
271
 
272
+ @ReactMethod
273
+ public void trySwitchScan(String scanViewConfigContent) {
274
+ WrapperSessionProvider.requestScanSwitchWithScanViewConfigContentString(scanViewConfigContent);
275
+ }
276
+
251
277
  @ReactMethod
252
278
  public void tryStopScan(String scanStopRequestParams) {
253
279
  WrapperSessionProvider.requestScanStop(scanStopRequestParams);
@@ -315,6 +341,11 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule
315
341
  return this.reactContext;
316
342
  }
317
343
 
344
+ @Override
345
+ public @Nullable ViewGroup getContainerView() {
346
+ return (ViewGroup) NativeViewRegistry.getLastOrNull();
347
+ }
348
+
318
349
  @Override
319
350
  public void onSdkInitializationResponse(@NotNull WrapperSessionSdkInitializationResponse initializationResponse) {
320
351
  JSONObject json =
@@ -0,0 +1,26 @@
1
+ package com.anyline.reactnative.nativeview;
2
+
3
+ import android.widget.FrameLayout;
4
+ import com.facebook.react.uimanager.SimpleViewManager;
5
+ import com.facebook.react.uimanager.ThemedReactContext;
6
+
7
+ public class AnylineNativeViewManager extends SimpleViewManager<FrameLayout> {
8
+ public static final String REACT_CLASS = "AnylineNativeView";
9
+
10
+ @Override
11
+ public String getName() {
12
+ return REACT_CLASS;
13
+ }
14
+
15
+ @Override
16
+ protected FrameLayout createViewInstance(ThemedReactContext reactContext) {
17
+ return new NativeFragmentContainerView(reactContext);
18
+ }
19
+
20
+ @Override
21
+ public void onDropViewInstance(FrameLayout view) {
22
+ // Remove view from registry
23
+ NativeViewRegistry.remove(view);
24
+ super.onDropViewInstance(view);
25
+ }
26
+ }
@@ -0,0 +1,44 @@
1
+
2
+ package com.anyline.reactnative.nativeview;
3
+
4
+ import android.content.Context;
5
+ import android.graphics.PixelFormat;
6
+ import android.view.View;
7
+ import android.view.ViewGroup;
8
+ import android.view.WindowManager;
9
+ import android.widget.FrameLayout;
10
+
11
+ public class NativeFragmentContainerView extends FrameLayout {
12
+ NativeFragmentContainerView(Context context) {
13
+ super(context);
14
+ setLayoutParams(
15
+ new WindowManager.LayoutParams(
16
+ ViewGroup.LayoutParams.MATCH_PARENT,
17
+ ViewGroup.LayoutParams.MATCH_PARENT,
18
+ WindowManager.LayoutParams.TYPE_APPLICATION,
19
+ WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
20
+ PixelFormat.TRANSLUCENT
21
+ ));
22
+
23
+ isHardwareAccelerated();
24
+
25
+ // Generate a unique ID for the container
26
+ int containerId = View.generateViewId();
27
+
28
+ setId(containerId);
29
+
30
+ NativeViewRegistry.register(String.valueOf(containerId), this);
31
+ }
32
+
33
+ @Override
34
+ public void requestLayout() {
35
+ super.requestLayout();
36
+ post(measureAndLayoutRunnable);
37
+ }
38
+
39
+ private final Runnable measureAndLayoutRunnable = () -> {
40
+ measure(MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
41
+ MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
42
+ layout(getLeft(), getTop(), getRight(), getBottom());
43
+ };
44
+ }
@@ -0,0 +1,38 @@
1
+ package com.anyline.reactnative.nativeview;
2
+
3
+ import android.view.View;
4
+
5
+ import java.util.HashMap;
6
+ import java.util.Map;
7
+
8
+ public class NativeViewRegistry {
9
+ private static final Map<String, View> registry = new HashMap<>();
10
+
11
+ private NativeViewRegistry() {
12
+
13
+ }
14
+
15
+ public static void register(String id, View view) {
16
+ registry.put(id, view);
17
+ }
18
+
19
+ public static View get(String id) {
20
+ return registry.get(id);
21
+ }
22
+
23
+ public static View getLastOrNull() {
24
+ if (registry.isEmpty()) {
25
+ return null;
26
+ } else {
27
+ return (View) registry.values().toArray()[registry.size() - 1];
28
+ }
29
+ }
30
+
31
+ public static void remove(String id) {
32
+ registry.remove(id);
33
+ }
34
+
35
+ public static void remove(View view) {
36
+ registry.values().removeIf(value -> (value == view));
37
+ }
38
+ }
@@ -2,6 +2,7 @@
2
2
  #import <React/RCTEventEmitter.h>
3
3
  #import <React/RCTBridge.h>
4
4
  #import "AnylineSDKPlugin.h"
5
+ #import "NativeView/NativeViewRegistry.h"
5
6
  #import "RCTUtils.h"
6
7
 
7
8
  // Static instance to retain the ALWrapperSessionProvider instance
@@ -116,6 +117,18 @@ RCT_EXPORT_METHOD(licenseKeyExpiryDate:(RCTPromiseResolveBlock)resolve rejecter:
116
117
  return;
117
118
  }
118
119
 
120
+ RCT_EXPORT_METHOD(setDefaultScanStartPlatformOptions:(nullable NSString *)scanStartPlatformOptionsString
121
+ resolver:(RCTPromiseResolveBlock)resolve
122
+ rejecter:(RCTPromiseRejectBlock)reject) {
123
+ @try {
124
+ [ALWrapperSessionProvider setDefaultScanStartPlatformOptionsWithString:scanStartPlatformOptionsString];
125
+ resolve(@"");
126
+ }
127
+ @catch (NSException *exception) {
128
+ reject(@"ANYLINE_ERROR", exception.reason, nil);
129
+ }
130
+ }
131
+
119
132
  // Deprecated
120
133
  RCT_EXPORT_METHOD(setupScanViewWithConfigJson:(NSString *)config scanMode:(NSString *)scanMode onResultCallback:(RCTResponseSenderBlock)onResult onErrorCallback:(RCTResponseSenderBlock)onError) {
121
134
  [self setupWithInitializationParameters:nil config:config scanMode:scanMode onResultCallback:onResult onErrorCallback:onError];
@@ -181,6 +194,10 @@ RCT_EXPORT_METHOD(setupPromiseWithInitializationParametersAndScanCallbackConfig:
181
194
  scanCallbackConfigString:scanCallbackConfigString];
182
195
  }
183
196
 
197
+ RCT_EXPORT_METHOD(trySwitchScan:(NSString *)scanViewConfigContent) {
198
+ [ALWrapperSessionProvider requestScanSwitchWithScanViewConfigContentString:scanViewConfigContent];
199
+ }
200
+
184
201
  RCT_EXPORT_METHOD(tryStopScan:(NSString * _Nullable)scanStopRequestParams) {
185
202
  [ALWrapperSessionProvider requestScanStopWithScanStopRequestParamsString:scanStopRequestParams];
186
203
  }
@@ -336,6 +353,10 @@ RCT_EXPORT_METHOD(exportCachedEvents:(RCTPromiseResolveBlock)resolve rejecter:(R
336
353
  return nil;
337
354
  }
338
355
 
356
+ - (nullable UIView *)getContainerView {
357
+ return [[NativeViewRegistry shared] getLastOrNull];
358
+ }
359
+
339
360
  - (void)onSdkInitializationResponse:(nonnull ALWrapperSessionSDKInitializationResponse *)initializationResponse {
340
361
  if ([initializationResponse.initialized isEqualToNumber:@YES]) {
341
362
  self.wrapperSessionSdkInitializationResponsePromiseResolve(@"success");
@@ -0,0 +1,4 @@
1
+ #import <React/RCTViewManager.h>
2
+
3
+ @interface AnylineNativeViewManager : RCTViewManager
4
+ @end
@@ -0,0 +1,27 @@
1
+ #import "AnylineNativeViewManager.h"
2
+ #import "NativeViewRegistry.h"
3
+ #import <UIKit/UIKit.h>
4
+
5
+ @implementation AnylineNativeViewManager
6
+
7
+ RCT_EXPORT_MODULE()
8
+
9
+ - (UIView *)view {
10
+ UIView *containerView = [[UIView alloc] init];
11
+
12
+ NSString *containerId = [NSString stringWithFormat:@"%d", 0];
13
+ [[NativeViewRegistry shared] registerView:containerView withId:containerId];
14
+
15
+ UIViewController *vc = [[UIViewController alloc] init];
16
+ vc.view.frame = containerView.bounds;
17
+ vc.view.backgroundColor = [UIColor lightGrayColor];
18
+
19
+ UIViewController *rootVC = UIApplication.sharedApplication.delegate.window.rootViewController;
20
+ [rootVC addChildViewController:vc];
21
+ [containerView addSubview:vc.view];
22
+ [vc didMoveToParentViewController:rootVC];
23
+
24
+ return containerView;
25
+ }
26
+
27
+ @end
@@ -0,0 +1,11 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <UIKit/UIKit.h>
3
+
4
+ @interface NativeViewRegistry : NSObject
5
+
6
+ + (instancetype)shared;
7
+ - (void)registerView:(UIView *)view withId:(NSString *)viewId;
8
+ - (UIView *)getViewById:(NSString *)viewId;
9
+ - (UIView *)getLastOrNull;
10
+
11
+ @end
@@ -0,0 +1,37 @@
1
+ #import "NativeViewRegistry.h"
2
+
3
+ @interface NativeViewRegistry ()
4
+ @property(nonatomic, strong) NSMapTable<NSString *, UIView *> *views;
5
+ @end
6
+
7
+ @implementation NativeViewRegistry
8
+
9
+ + (instancetype)shared {
10
+ static NativeViewRegistry *instance;
11
+ static dispatch_once_t onceToken;
12
+ dispatch_once(&onceToken, ^{
13
+ instance = [[NativeViewRegistry alloc] init];
14
+ instance.views = [NSMapTable strongToWeakObjectsMapTable];
15
+ });
16
+ return instance;
17
+ }
18
+
19
+ - (void)registerView:(UIView *)view withId:(NSString *)viewId {
20
+ [self.views setObject:view forKey:viewId];
21
+ }
22
+
23
+ - (UIView *)getViewById:(NSString *)viewId {
24
+ return [self.views objectForKey:viewId];
25
+ }
26
+
27
+ - (UIView *)getLastOrNull {
28
+ NSArray *allKeys = self.views.keyEnumerator.allObjects;
29
+ if (allKeys.count > 0) {
30
+ NSString *lastKey = [allKeys lastObject];
31
+ return [self.views objectForKey:lastKey];
32
+ } else {
33
+ return nil;
34
+ }
35
+ }
36
+
37
+ @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anyline-ocr-react-native-module",
3
- "version": "55.7.1",
3
+ "version": "55.9.0",
4
4
  "description": "A Plugin for connecting Anyline with React-Native",
5
5
  "keywords": [
6
6
  "reactnative",