@capgo/capacitor-document-scanner 8.3.1 → 8.3.3

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.
@@ -86,7 +86,7 @@ class DocScanner: NSObject, VNDocumentCameraViewControllerDelegate {
86
86
  /// Swizzled implementation that enforces document limits
87
87
  @objc dynamic func swizzled_documentCameraController(_ controller: AnyObject, canAddImages count: UInt64) -> Bool {
88
88
  // Check if we have a limit set
89
- if let limit = documentScanLimit, count >= limit {
89
+ if let limit = documentScanLimit, count >= UInt64(limit) {
90
90
  return false
91
91
  }
92
92
  // Call the original implementation (swizzled, so this calls original)
@@ -185,11 +185,15 @@ class DocScanner: NSObject, VNDocumentCameraViewControllerDelegate {
185
185
  }
186
186
  }
187
187
 
188
+ // Clear the global limit before dismissing to avoid race conditions
189
+ documentScanLimit = nil
188
190
  goBackToPreviousView(controller)
189
191
  successHandler(results)
190
192
  }
191
193
 
192
194
  func documentCameraViewControllerDidCancel(_ controller: VNDocumentCameraViewController) {
195
+ // Clear the global limit before dismissing to avoid race conditions
196
+ documentScanLimit = nil
193
197
  goBackToPreviousView(controller)
194
198
  cancelHandler()
195
199
  }
@@ -198,6 +202,8 @@ class DocScanner: NSObject, VNDocumentCameraViewControllerDelegate {
198
202
  _ controller: VNDocumentCameraViewController,
199
203
  didFailWithError error: Error
200
204
  ) {
205
+ // Clear the global limit before dismissing to avoid race conditions
206
+ documentScanLimit = nil
201
207
  goBackToPreviousView(controller)
202
208
  errorHandler(error.localizedDescription)
203
209
  }
@@ -3,7 +3,7 @@ import Foundation
3
3
 
4
4
  @objc(DocumentScannerPlugin)
5
5
  public class DocumentScannerPlugin: CAPPlugin, CAPBridgedPlugin {
6
- private let pluginVersion: String = "8.3.1"
6
+ private let pluginVersion: String = "8.3.3"
7
7
  public let identifier = "DocumentScannerPlugin"
8
8
  public let jsName = "DocumentScanner"
9
9
  public let pluginMethods: [CAPPluginMethod] = [
@@ -42,7 +42,7 @@ public class DocumentScannerPlugin: CAPPlugin, CAPBridgedPlugin {
42
42
  croppedImageQuality: clampQuality(call.getInt("croppedImageQuality")),
43
43
  brightness: clampBrightness(call.getFloat("brightness")),
44
44
  contrast: clampContrast(call.getFloat("contrast")),
45
- maxNumDocuments: call.getInt("maxNumDocuments")
45
+ maxNumDocuments: validateMaxNumDocuments(call.getInt("maxNumDocuments"))
46
46
  )
47
47
 
48
48
  documentScanner?.startScan()
@@ -63,6 +63,14 @@ public class DocumentScannerPlugin: CAPPlugin, CAPBridgedPlugin {
63
63
  return max(0.0, min(10.0, contrast))
64
64
  }
65
65
 
66
+ private func validateMaxNumDocuments(_ value: Int?) -> Int? {
67
+ guard let limit = value else {
68
+ return nil
69
+ }
70
+ // Only return limit if it's positive, otherwise return nil (unlimited)
71
+ return limit > 0 ? limit : nil
72
+ }
73
+
66
74
  @objc func getPluginVersion(_ call: CAPPluginCall) {
67
75
  call.resolve(["version": self.pluginVersion])
68
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-document-scanner",
3
- "version": "8.3.1",
3
+ "version": "8.3.3",
4
4
  "description": "Capacitor plugin to scan document iOS and Android",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",