@capgo/capacitor-document-scanner 8.4.8 → 8.4.10
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.
- package/ios/Sources/DocumentScannerPlugin/DocScanner.swift +30 -7
- package/ios/Sources/DocumentScannerPlugin/DocumentScannerPlugin.swift +1 -1
- package/ios/Sources/DocumentScannerPlugin/VisionKitPrivateConstants.swift +10 -0
- package/ios/Tests/DocumentScannerPluginTests/DocumentScannerPluginTests.swift +11 -0
- package/package.json +3 -1
|
@@ -291,14 +291,16 @@ class DocScanner: NSObject {
|
|
|
291
291
|
return
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
|
|
294
|
+
// appstore-2.5.2-allow: resolve VisionKit in-process document camera class for page-limit hook
|
|
295
|
+
guard let inProcessClass = NSClassFromString(VisionKitPrivateConstants.inProcessViewControllerClassName) else {
|
|
295
296
|
return
|
|
296
297
|
}
|
|
297
298
|
|
|
298
|
-
let originalSelector =
|
|
299
|
+
let originalSelector = VisionKitPrivateConstants.documentCameraCanAddImagesSelector
|
|
299
300
|
let swizzledSelector = #selector(DocScanner.swizzled_documentCameraController(_:canAddImages:))
|
|
300
301
|
|
|
301
302
|
guard
|
|
303
|
+
// appstore-2.5.2-allow: read private canAddImages implementation before swizzle
|
|
302
304
|
let originalMethod = class_getInstanceMethod(inProcessClass, originalSelector),
|
|
303
305
|
let swizzledMethod = class_getInstanceMethod(DocScanner.self, swizzledSelector)
|
|
304
306
|
else {
|
|
@@ -306,6 +308,7 @@ class DocScanner: NSObject {
|
|
|
306
308
|
}
|
|
307
309
|
|
|
308
310
|
swizzled = true
|
|
311
|
+
// appstore-2.5.2-allow: install swizzled canAddImages handler on in-process VisionKit class
|
|
309
312
|
let didAddMethod = class_addMethod(
|
|
310
313
|
inProcessClass,
|
|
311
314
|
swizzledSelector,
|
|
@@ -315,10 +318,12 @@ class DocScanner: NSObject {
|
|
|
315
318
|
|
|
316
319
|
if didAddMethod,
|
|
317
320
|
let installedSwizzledMethod = class_getInstanceMethod(inProcessClass, swizzledSelector) {
|
|
321
|
+
// appstore-2.5.2-allow: exchange canAddImages implementations for scan limit enforcement
|
|
318
322
|
method_exchangeImplementations(originalMethod, installedSwizzledMethod)
|
|
319
323
|
return
|
|
320
324
|
}
|
|
321
325
|
|
|
326
|
+
// appstore-2.5.2-allow: exchange canAddImages implementations for scan limit enforcement
|
|
322
327
|
method_exchangeImplementations(originalMethod, swizzledMethod)
|
|
323
328
|
}
|
|
324
329
|
|
|
@@ -414,7 +419,10 @@ class DocScanner: NSObject {
|
|
|
414
419
|
}
|
|
415
420
|
|
|
416
421
|
let previewWasTriggered: Bool
|
|
417
|
-
if let previewView = findFirstView(
|
|
422
|
+
if let previewView = findFirstView(
|
|
423
|
+
namedLike: [VisionKitPrivateConstants.thumbnailContainerViewClassFragment],
|
|
424
|
+
in: rootView
|
|
425
|
+
) {
|
|
418
426
|
previewWasTriggered = triggerInteraction(around: previewView, in: rootView)
|
|
419
427
|
} else {
|
|
420
428
|
let previewPoint = CGPoint(
|
|
@@ -519,7 +527,10 @@ class DocScanner: NSObject {
|
|
|
519
527
|
}
|
|
520
528
|
|
|
521
529
|
for gestureRecognizer in gestureRecognizers where gestureRecognizer.isEnabled {
|
|
522
|
-
|
|
530
|
+
// appstore-2.5.2-allow: read UIKit gesture recognizer target list to trigger preview navigation
|
|
531
|
+
guard let internalTargets = gestureRecognizer.value(
|
|
532
|
+
forKey: VisionKitPrivateConstants.gestureRecognizerTargetsKey
|
|
533
|
+
) as? [NSObject] else {
|
|
523
534
|
continue
|
|
524
535
|
}
|
|
525
536
|
|
|
@@ -542,15 +553,27 @@ class DocScanner: NSObject {
|
|
|
542
553
|
}
|
|
543
554
|
|
|
544
555
|
private static func gestureRecognizerInvocation(from internalTarget: NSObject) -> (target: AnyObject, selector: Selector)? {
|
|
556
|
+
guard let targetClass: AnyClass = object_getClass(internalTarget) else {
|
|
557
|
+
return nil
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// appstore-2.5.2-allow: read UIKit gesture target/action ivars to forward preview taps
|
|
545
561
|
guard
|
|
546
|
-
let
|
|
547
|
-
|
|
548
|
-
|
|
562
|
+
let targetIvar = class_getInstanceVariable(
|
|
563
|
+
targetClass,
|
|
564
|
+
VisionKitPrivateConstants.gestureTargetIvarName
|
|
565
|
+
),
|
|
566
|
+
let actionIvar = class_getInstanceVariable(
|
|
567
|
+
targetClass,
|
|
568
|
+
VisionKitPrivateConstants.gestureActionIvarName
|
|
569
|
+
),
|
|
570
|
+
// appstore-2.5.2-allow: read gesture target object from UIKit internal target entry
|
|
549
571
|
let target = object_getIvar(internalTarget, targetIvar) as AnyObject?
|
|
550
572
|
else {
|
|
551
573
|
return nil
|
|
552
574
|
}
|
|
553
575
|
|
|
576
|
+
// appstore-2.5.2-allow: read gesture action selector offset from UIKit internal target entry
|
|
554
577
|
let actionOffset = ivar_getOffset(actionIvar)
|
|
555
578
|
let actionPointer = Unmanaged.passUnretained(internalTarget).toOpaque().advanced(by: actionOffset)
|
|
556
579
|
let selector = actionPointer.load(as: Selector.self)
|
|
@@ -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.4.
|
|
6
|
+
private let pluginVersion: String = "8.4.10"
|
|
7
7
|
public let identifier = "DocumentScannerPlugin"
|
|
8
8
|
public let jsName = "DocumentScanner"
|
|
9
9
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
enum VisionKitPrivateConstants {
|
|
4
|
+
static let inProcessViewControllerClassName = "VNDocumentCameraViewController_InProcess"
|
|
5
|
+
static let documentCameraCanAddImagesSelector = Selector("documentCameraController:canAddImages:")
|
|
6
|
+
static let gestureRecognizerTargetsKey = "_targets"
|
|
7
|
+
static let gestureTargetIvarName = "_target"
|
|
8
|
+
static let gestureActionIvarName = "_action"
|
|
9
|
+
static let thumbnailContainerViewClassFragment = "ICDocCamThumbnailContainerView"
|
|
10
|
+
}
|
|
@@ -6,4 +6,15 @@ final class DocumentScannerTests: XCTestCase {
|
|
|
6
6
|
XCTAssertEqual(ResponseType.base64, "base64")
|
|
7
7
|
XCTAssertEqual(ResponseType.imageFilePath, "imageFilePath")
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
func testVisionKitPrivateConstantsAreStatic() {
|
|
11
|
+
XCTAssertEqual(
|
|
12
|
+
VisionKitPrivateConstants.inProcessViewControllerClassName,
|
|
13
|
+
"VNDocumentCameraViewController_InProcess"
|
|
14
|
+
)
|
|
15
|
+
XCTAssertEqual(
|
|
16
|
+
VisionKitPrivateConstants.documentCameraCanAddImagesSelector,
|
|
17
|
+
Selector("documentCameraController:canAddImages:")
|
|
18
|
+
)
|
|
19
|
+
}
|
|
9
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-document-scanner",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.10",
|
|
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",
|
|
@@ -49,6 +49,8 @@
|
|
|
49
49
|
"prepublishOnly": "bun run build",
|
|
50
50
|
"check:wiring": "node scripts/check-capacitor-plugin-wiring.mjs",
|
|
51
51
|
"check:cap9-deprecated": "node scripts/check-cap9-deprecated.mjs",
|
|
52
|
+
"check:ios-app-store": "node scripts/check-ios-app-store-dynamic-code.mjs",
|
|
53
|
+
"test:ios-app-store-check": "node --test scripts/check-ios-app-store-dynamic-code.test.mjs",
|
|
52
54
|
"example:install": "cd example-app && bun install --frozen-lockfile",
|
|
53
55
|
"example:build": "bun run build && cd example-app && bun install --frozen-lockfile && bun run build",
|
|
54
56
|
"changelog:ai": "node scripts/generate-ai-changelog.mjs"
|