scandit-react-native-datacapture-core 8.0.0 → 8.1.0-beta.1

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.
Files changed (30) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/ScanditDataCaptureCoreModule.kt +35 -16
  3. package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/utils/ReactNativeMethodCall.kt +57 -0
  4. package/dist/core.js +482 -695
  5. package/dist/core.js.map +1 -1
  6. package/dist/dts/DataCaptureView.d.ts +6 -5
  7. package/dist/dts/index.d.ts +1 -0
  8. package/dist/dts/native/CoreNativeCallerProvider.d.ts +4 -0
  9. package/dist/dts/native/RNNativeCaller.d.ts +7 -4
  10. package/dist/dts/native/ScanditNativeModule.d.ts +9 -0
  11. package/dist/index.js +52 -106
  12. package/dist/index.js.map +1 -1
  13. package/dist/tsconfig.tsbuildinfo +1 -1
  14. package/ios/Sources/Extensions/Brush+RNTSDCSerializer.swift +6 -4
  15. package/ios/Sources/Extensions/CGPoint+JSON.swift +2 -2
  16. package/ios/Sources/Extensions/CameraSettings+RNTSDCSerializer.swift +9 -7
  17. package/ios/Sources/Extensions/UIInterfaceOrientation+RNTSDCSerializer.swift +1 -1
  18. package/ios/Sources/Protocols/ScanditReactNativeFactoryContainer.swift +1 -2
  19. package/ios/Sources/ScanditDataCaptureCore.m +9 -4
  20. package/ios/Sources/ScanditDataCaptureCore.swift +174 -75
  21. package/ios/Sources/ScanditDataCaptureViewManager.swift +3 -3
  22. package/ios/Sources/Utils/JSView.swift +3 -2
  23. package/ios/Sources/Utils/ReactNativeEmitter.swift +3 -2
  24. package/ios/Sources/Utils/ReactNativeMethodCall.swift +159 -0
  25. package/ios/Sources/Utils/ReactNativeResult.swift +8 -4
  26. package/package.json +3 -4
  27. package/scandit-react-native-datacapture-core.podspec +1 -1
  28. package/scripts/detect_frameworks.rb +33 -7
  29. package/dist/dts/native/DataCaptureViewProxy.d.ts +0 -24
  30. package/dist/dts/native/FeedbackProxy.d.ts +0 -4
@@ -0,0 +1,159 @@
1
+ /*
2
+ * This file is part of the Scandit Data Capture SDK
3
+ *
4
+ * Copyright (C) 2025- Scandit AG. All rights reserved.
5
+ */
6
+
7
+ import Foundation
8
+ import ScanditFrameworksCore
9
+
10
+ public class ReactNativeMethodCall: FrameworksMethodCall {
11
+
12
+ private let data: [String: Any]
13
+
14
+ public init(_ data: [String: Any]) {
15
+ self.data = data
16
+ }
17
+
18
+ public func argument<T>(key: String) -> T? {
19
+ guard let value = data[key] else {
20
+ return nil
21
+ }
22
+
23
+ if let result = value as? T {
24
+ return result
25
+ }
26
+
27
+ if T.self == Int.self || T.self == Int?.self {
28
+ if let intValue = convertToInt(value) {
29
+ return unsafeBitCast(intValue, to: T.self)
30
+ }
31
+ }
32
+
33
+ if T.self == Int64.self || T.self == Int64?.self {
34
+ if let longValue = convertToLong(value) {
35
+ return unsafeBitCast(longValue, to: T.self)
36
+ }
37
+ }
38
+
39
+ if T.self == Double.self || T.self == Double?.self {
40
+ if let doubleValue = convertToDouble(value) {
41
+ return unsafeBitCast(doubleValue, to: T.self)
42
+ }
43
+ }
44
+
45
+ if T.self == Bool.self || T.self == Bool?.self {
46
+ if let boolValue = convertToBool(value) {
47
+ return unsafeBitCast(boolValue, to: T.self)
48
+ }
49
+ }
50
+
51
+ return value as? T
52
+ }
53
+
54
+ public func arguments() -> [String: Any] {
55
+ data
56
+ }
57
+
58
+ public var method: String {
59
+ data["methodName"] as? String ?? "unknown"
60
+ }
61
+
62
+ public func hasArgument(key: String) -> Bool {
63
+ data.keys.contains(key)
64
+ }
65
+
66
+ public func arguments() -> [String: Any?] {
67
+ data
68
+ }
69
+
70
+ private func convertToInt(_ value: Any) -> Int? {
71
+ switch value {
72
+ case let intValue as Int:
73
+ return intValue
74
+ case let doubleValue as Double:
75
+ if doubleValue.truncatingRemainder(dividingBy: 1.0) == 0.0 && doubleValue >= Double(Int.min)
76
+ && doubleValue <= Double(Int.max)
77
+ {
78
+ return Int(doubleValue)
79
+ }
80
+ return nil
81
+ case let floatValue as Float:
82
+ return Int(floatValue.rounded())
83
+ case let cgFloatValue as CGFloat:
84
+ return Int(cgFloatValue.rounded())
85
+ case let nsNumberValue as NSNumber:
86
+ return nsNumberValue.intValue
87
+ case let stringValue as String:
88
+ return Int(stringValue)
89
+ default:
90
+ return nil
91
+ }
92
+ }
93
+
94
+ private func convertToLong(_ value: Any) -> Int64? {
95
+ switch value {
96
+ case let intValue as Int:
97
+ return Int64(intValue)
98
+ case let int64Value as Int64:
99
+ return int64Value
100
+ case let doubleValue as Double:
101
+ if doubleValue.truncatingRemainder(dividingBy: 1.0) == 0.0 {
102
+ return Int64(doubleValue)
103
+ }
104
+ return nil
105
+ case let floatValue as Float:
106
+ return Int64(floatValue.rounded())
107
+ case let cgFloatValue as CGFloat:
108
+ return Int64(cgFloatValue.rounded())
109
+ case let nsNumberValue as NSNumber:
110
+ return nsNumberValue.int64Value
111
+ case let stringValue as String:
112
+ return Int64(stringValue)
113
+ default:
114
+ return nil
115
+ }
116
+ }
117
+
118
+ private func convertToDouble(_ value: Any) -> Double? {
119
+ switch value {
120
+ case let doubleValue as Double:
121
+ return doubleValue
122
+ case let floatValue as Float:
123
+ return Double(floatValue)
124
+ case let cgFloatValue as CGFloat:
125
+ return Double(cgFloatValue)
126
+ case let intValue as Int:
127
+ return Double(intValue)
128
+ case let int64Value as Int64:
129
+ return Double(int64Value)
130
+ case let nsNumberValue as NSNumber:
131
+ return nsNumberValue.doubleValue
132
+ case let stringValue as String:
133
+ return Double(stringValue)
134
+ default:
135
+ return nil
136
+ }
137
+ }
138
+
139
+ private func convertToBool(_ value: Any) -> Bool? {
140
+ switch value {
141
+ case let boolValue as Bool:
142
+ return boolValue
143
+ case let nsNumberValue as NSNumber:
144
+ return nsNumberValue.boolValue
145
+ case let intValue as Int:
146
+ return intValue != 0
147
+ case let stringValue as String:
148
+ let lowercased = stringValue.lowercased()
149
+ if lowercased == "true" || lowercased == "1" {
150
+ return true
151
+ } else if lowercased == "false" || lowercased == "0" {
152
+ return false
153
+ }
154
+ return nil
155
+ default:
156
+ return nil
157
+ }
158
+ }
159
+ }
@@ -11,8 +11,10 @@ public struct ReactNativeResult: FrameworksResult {
11
11
  private let resolve: RCTPromiseResolveBlock
12
12
  private let rejecter: RCTPromiseRejectBlock
13
13
 
14
- public init(_ resolve: @escaping RCTPromiseResolveBlock,
15
- _ reject: @escaping RCTPromiseRejectBlock) {
14
+ public init(
15
+ _ resolve: @escaping RCTPromiseResolveBlock,
16
+ _ reject: @escaping RCTPromiseRejectBlock
17
+ ) {
16
18
  self.resolve = resolve
17
19
  self.rejecter = reject
18
20
  }
@@ -45,8 +47,10 @@ public struct ReactNativeResult: FrameworksResult {
45
47
  }
46
48
 
47
49
  public extension FrameworksResult where Self == ReactNativeResult {
48
- static func create(_ resolve: @escaping RCTPromiseResolveBlock,
49
- _ reject: @escaping RCTPromiseRejectBlock) -> Self {
50
+ static func create(
51
+ _ resolve: @escaping RCTPromiseResolveBlock,
52
+ _ reject: @escaping RCTPromiseRejectBlock
53
+ ) -> Self {
50
54
  .init(resolve, reject)
51
55
  }
52
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scandit-react-native-datacapture-core",
3
- "version": "8.0.0",
3
+ "version": "8.1.0-beta.1",
4
4
  "description": "Scandit Data Capture SDK for React Native",
5
5
  "homepage": "https://github.com/Scandit/scandit-react-native-datacapture-core",
6
6
  "main": "dist/index.js",
@@ -19,7 +19,7 @@
19
19
  "jest": "jest",
20
20
  "coverage": "jest --coverage",
21
21
  "test": "pnpm run lint",
22
- "lint": "tslint --project .",
22
+ "lint": "eslint --debug ts",
23
23
  "tsc": "tsc",
24
24
  "build": "pnpm run rollup",
25
25
  "rollup": "rollup -c rollup.config.js --bundleConfigAsCjs",
@@ -56,11 +56,10 @@
56
56
  "jest": "^29.7.0",
57
57
  "rollup": "3.22.0",
58
58
  "ts-jest": "^29.3.3",
59
- "tslint": "6.1.2",
60
59
  "typescript": "4.9.5"
61
60
  },
62
61
  "packageManager": "pnpm@10.15.0",
63
62
  "dependencies": {
64
- "scandit-datacapture-frameworks-core": "8.0.0"
63
+ "scandit-datacapture-frameworks-core": "8.1.0-beta.1"
65
64
  }
66
65
  }
@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
18
18
  s.module_name = "ScanditDataCaptureCore"
19
19
  s.header_dir = "ScanditDataCaptureCore"
20
20
 
21
- s.dependency "scandit-datacapture-frameworks-core", '= 8.0.0'
21
+ s.dependency "scandit-datacapture-frameworks-core", '= 8.1.0-beta.1'
22
22
  s.dependency "React"
23
23
 
24
24
  # Check if new architecture is enabled
@@ -1,10 +1,36 @@
1
+ require 'pathname'
2
+
1
3
  def podspec_path_for_pod(pod_name, current_path)
2
- # the current_path will be always the folder of the Podfile where this function is executed
3
- archive_dir = File.expand_path(current_path)
4
- until File.exist?(File.join(archive_dir, 'frameworks'))
5
- parent_dir = File.expand_path('..', archive_dir)
6
- break if parent_dir == archive_dir
7
- archive_dir = parent_dir
4
+ podfile_dir = File.expand_path(current_path)
5
+ current_dir = podfile_dir
6
+
7
+ while current_dir != '/' do
8
+ parent_dir = File.dirname(current_dir)
9
+
10
+ react_native_core_path = File.join(parent_dir, 'scandit-react-native-datacapture-core')
11
+ if Dir.exist?(react_native_core_path)
12
+ frameworks_path = File.join(parent_dir, 'frameworks', 'shared', 'ios', pod_name)
13
+ podspec_file = File.join(frameworks_path, "#{pod_name}.podspec")
14
+
15
+ if File.exist?(podspec_file)
16
+ relative_path = Pathname.new(frameworks_path).relative_path_from(Pathname.new(podfile_dir))
17
+ return relative_path.to_s
18
+ end
19
+
20
+ grandparent_dir = File.dirname(parent_dir)
21
+ if File.basename(parent_dir) == 'react-native'
22
+ frameworks_path = File.join(grandparent_dir, 'shared', 'ios', pod_name)
23
+ podspec_file = File.join(frameworks_path, "#{pod_name}.podspec")
24
+
25
+ if File.exist?(podspec_file)
26
+ relative_path = Pathname.new(frameworks_path).relative_path_from(Pathname.new(podfile_dir))
27
+ return relative_path.to_s
28
+ end
29
+ end
30
+ end
31
+
32
+ current_dir = parent_dir
8
33
  end
9
- File.join(archive_dir, 'frameworks', 'shared', 'ios', pod_name)
34
+
35
+ raise "Could not find podspec for '#{pod_name}'. Searched from: #{podfile_dir}"
10
36
  end
@@ -1,24 +0,0 @@
1
- import { DataCaptureViewProxy, BaseNativeProxy, NativeCallResult } from 'scandit-datacapture-frameworks-core';
2
- export declare class NativeDataCaptureViewProxy extends BaseNativeProxy implements DataCaptureViewProxy {
3
- private nativeListeners;
4
- constructor();
5
- addOverlay(overlayJson: string): Promise<void>;
6
- removeOverlay(overlayJson: string): Promise<void>;
7
- createView(viewJson: string): Promise<void>;
8
- updateView(viewJson: string): Promise<void>;
9
- removeView(viewId: number): Promise<void>;
10
- viewPointForFramePoint({ viewId, pointJson }: {
11
- viewId: number;
12
- pointJson: string;
13
- }): Promise<NativeCallResult>;
14
- viewQuadrilateralForFrameQuadrilateral({ viewId, quadrilateralJson }: {
15
- viewId: number;
16
- quadrilateralJson: string;
17
- }): Promise<NativeCallResult>;
18
- registerListenerForViewEvents(viewId: number): void;
19
- unregisterListenerForViewEvents(viewId: number): void;
20
- subscribeDidChangeSize(): void;
21
- setPositionAndSize(top: number, left: number, width: number, height: number, shouldBeUnderWebView: boolean): Promise<void>;
22
- show(): Promise<void>;
23
- hide(): Promise<void>;
24
- }
@@ -1,4 +0,0 @@
1
- import { Feedback, FeedbackProxy } from 'scandit-datacapture-frameworks-core';
2
- export declare class NativeFeedbackProxy implements FeedbackProxy {
3
- emitFeedback(feedback: Feedback): Promise<void>;
4
- }