@onekeyfe/react-native-qr-scanner 0.0.0-stage → 6.8.0-alpha.545
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/LICENSE +21 -0
- package/QrScanner.podspec +42 -0
- package/README.md +74 -2
- package/android/CMakeLists.txt +23 -0
- package/android/build.gradle +147 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/cpp/cpp-adapter.cpp +8 -0
- package/android/src/main/java/com/margelo/nitro/qrscanner/HybridQrImageDecoder.kt +66 -0
- package/android/src/main/java/com/margelo/nitro/qrscanner/QrCameraZoom.kt +15 -0
- package/android/src/main/java/com/margelo/nitro/qrscanner/QrEngines.kt +53 -0
- package/android/src/main/java/com/margelo/nitro/qrscanner/QrFrameTextGate.kt +44 -0
- package/android/src/main/java/com/margelo/nitro/qrscanner/QrImageDecodingPipeline.kt +169 -0
- package/android/src/main/java/com/margelo/nitro/qrscanner/QrScanner.kt +318 -0
- package/android/src/main/java/com/margelo/nitro/qrscanner/QrScannerPackage.kt +31 -0
- package/android/src/test/java/com/margelo/nitro/qrscanner/QrCameraZoomTest.kt +24 -0
- package/android/src/test/java/com/margelo/nitro/qrscanner/QrFrameTextGateTest.kt +69 -0
- package/android/src/test/java/com/margelo/nitro/qrscanner/QrImageDecodingPipelineTest.kt +97 -0
- package/ios/HybridQrImageDecoder.swift +58 -0
- package/ios/QrCameraControl.swift +57 -0
- package/ios/QrFrameTextGate.swift +66 -0
- package/ios/QrImageDecodingPipeline.swift +159 -0
- package/ios/QrScanner.swift +372 -0
- package/ios/QrZXingReader.h +15 -0
- package/ios/QrZXingReader.mm +46 -0
- package/lib/module/QrImageDecoder.nitro.js +4 -0
- package/lib/module/QrImageDecoder.nitro.js.map +1 -0
- package/lib/module/QrScanner.js +84 -0
- package/lib/module/QrScanner.js.map +1 -0
- package/lib/module/QrScanner.nitro.js +4 -0
- package/lib/module/QrScanner.nitro.js.map +1 -0
- package/lib/module/decodeQrImage.constants.js +5 -0
- package/lib/module/decodeQrImage.constants.js.map +1 -0
- package/lib/module/decodeQrImage.js +27 -0
- package/lib/module/decodeQrImage.js.map +1 -0
- package/lib/module/errors.js +31 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/ur/assembler.js +152 -0
- package/lib/module/ur/assembler.js.map +1 -0
- package/lib/module/ur/index.js +6 -0
- package/lib/module/ur/index.js.map +1 -0
- package/lib/module/ur/limits.js +207 -0
- package/lib/module/ur/limits.js.map +1 -0
- package/lib/module/ur/session.js +74 -0
- package/lib/module/ur/session.js.map +1 -0
- package/lib/module/ur/types.js +2 -0
- package/lib/module/ur/types.js.map +1 -0
- package/lib/module/web/decodeQrImage.js +62 -0
- package/lib/module/web/decodeQrImage.js.map +1 -0
- package/lib/module/web/engines.js +154 -0
- package/lib/module/web/engines.js.map +1 -0
- package/lib/module/web/imageOps.js +81 -0
- package/lib/module/web/imageOps.js.map +1 -0
- package/lib/module/web/index.js +11 -0
- package/lib/module/web/index.js.map +1 -0
- package/lib/module/web/scanner.js +230 -0
- package/lib/module/web/scanner.js.map +1 -0
- package/lib/module/web/zxing.worker.js +11 -0
- package/lib/module/web/zxing.worker.js.map +1 -0
- package/lib/module/web/zxingWorkerProtocol.js +67 -0
- package/lib/module/web/zxingWorkerProtocol.js.map +1 -0
- package/lib/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/lib/nitrogen/generated/android/c++/JFunc_void_std__string_double.hpp +76 -0
- package/lib/nitrogen/generated/android/c++/JFunc_void_std__string_std__string_double.hpp +76 -0
- package/lib/nitrogen/generated/android/c++/JHybridQrImageDecoderSpec.cpp +78 -0
- package/lib/nitrogen/generated/android/c++/JHybridQrImageDecoderSpec.hpp +63 -0
- package/lib/nitrogen/generated/android/c++/JHybridQrScannerSpec.cpp +114 -0
- package/lib/nitrogen/generated/android/c++/JHybridQrScannerSpec.hpp +70 -0
- package/lib/nitrogen/generated/android/c++/JQrDecodeEngine.hpp +61 -0
- package/lib/nitrogen/generated/android/c++/JQrDecodePass.hpp +64 -0
- package/lib/nitrogen/generated/android/c++/JQrImageDecodeResult.hpp +70 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridQrScannerStateUpdater.cpp +89 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridQrScannerStateUpdater.hpp +54 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/Func_void_double.kt +78 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/Func_void_std__string_double.kt +78 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/Func_void_std__string_std__string_double.kt +78 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/HybridQrImageDecoderSpec.kt +57 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/HybridQrScannerSpec.kt +101 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/QrDecodeEngine.kt +24 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/QrDecodePass.kt +25 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/QrImageDecodeResult.kt +61 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/qrscannerOnLoad.kt +35 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/views/HybridQrScannerManager.kt +96 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/views/HybridQrScannerStateUpdater.kt +23 -0
- package/lib/nitrogen/generated/android/qrscanner+autolinking.cmake +85 -0
- package/lib/nitrogen/generated/android/qrscanner+autolinking.gradle +27 -0
- package/lib/nitrogen/generated/android/qrscannerOnLoad.cpp +78 -0
- package/lib/nitrogen/generated/android/qrscannerOnLoad.hpp +34 -0
- package/lib/nitrogen/generated/ios/QrScanner+autolinking.rb +62 -0
- package/lib/nitrogen/generated/ios/QrScanner-Swift-Cxx-Bridge.cpp +90 -0
- package/lib/nitrogen/generated/ios/QrScanner-Swift-Cxx-Bridge.hpp +294 -0
- package/lib/nitrogen/generated/ios/QrScanner-Swift-Cxx-Umbrella.hpp +61 -0
- package/lib/nitrogen/generated/ios/QrScannerAutolinking.mm +41 -0
- package/lib/nitrogen/generated/ios/QrScannerAutolinking.swift +38 -0
- package/lib/nitrogen/generated/ios/c++/HybridQrImageDecoderSpecSwift.cpp +11 -0
- package/lib/nitrogen/generated/ios/c++/HybridQrImageDecoderSpecSwift.hpp +92 -0
- package/lib/nitrogen/generated/ios/c++/HybridQrScannerSpecSwift.cpp +11 -0
- package/lib/nitrogen/generated/ios/c++/HybridQrScannerSpecSwift.hpp +103 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridQrScannerComponent.mm +162 -0
- package/lib/nitrogen/generated/ios/swift/Func_void_QrImageDecodeResult.swift +46 -0
- package/lib/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
- package/lib/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/lib/nitrogen/generated/ios/swift/Func_void_std__string_double.swift +46 -0
- package/lib/nitrogen/generated/ios/swift/Func_void_std__string_std__string_double.swift +46 -0
- package/lib/nitrogen/generated/ios/swift/HybridQrImageDecoderSpec.swift +55 -0
- package/lib/nitrogen/generated/ios/swift/HybridQrImageDecoderSpec_cxx.swift +145 -0
- package/lib/nitrogen/generated/ios/swift/HybridQrScannerSpec.swift +58 -0
- package/lib/nitrogen/generated/ios/swift/HybridQrScannerSpec_cxx.swift +252 -0
- package/lib/nitrogen/generated/ios/swift/QrDecodeEngine.swift +44 -0
- package/lib/nitrogen/generated/ios/swift/QrDecodePass.swift +48 -0
- package/lib/nitrogen/generated/ios/swift/QrImageDecodeResult.swift +64 -0
- package/lib/nitrogen/generated/shared/c++/HybridQrImageDecoderSpec.cpp +21 -0
- package/lib/nitrogen/generated/shared/c++/HybridQrImageDecoderSpec.hpp +65 -0
- package/lib/nitrogen/generated/shared/c++/HybridQrScannerSpec.cpp +28 -0
- package/lib/nitrogen/generated/shared/c++/HybridQrScannerSpec.hpp +71 -0
- package/lib/nitrogen/generated/shared/c++/QrDecodeEngine.hpp +80 -0
- package/lib/nitrogen/generated/shared/c++/QrDecodePass.hpp +84 -0
- package/lib/nitrogen/generated/shared/c++/QrImageDecodeResult.hpp +97 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridQrScannerComponent.cpp +40 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridQrScannerComponent.hpp +94 -0
- package/lib/nitrogen/generated/shared/json/QrScannerConfig.json +13 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/QrImageDecoder.nitro.d.ts +26 -0
- package/lib/typescript/src/QrImageDecoder.nitro.d.ts.map +1 -0
- package/lib/typescript/src/QrScanner.d.ts +31 -0
- package/lib/typescript/src/QrScanner.d.ts.map +1 -0
- package/lib/typescript/src/QrScanner.nitro.d.ts +29 -0
- package/lib/typescript/src/QrScanner.nitro.d.ts.map +1 -0
- package/lib/typescript/src/decodeQrImage.constants.d.ts +3 -0
- package/lib/typescript/src/decodeQrImage.constants.d.ts.map +1 -0
- package/lib/typescript/src/decodeQrImage.d.ts +13 -0
- package/lib/typescript/src/decodeQrImage.d.ts.map +1 -0
- package/lib/typescript/src/errors.d.ts +13 -0
- package/lib/typescript/src/errors.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/ur/assembler.d.ts +5 -0
- package/lib/typescript/src/ur/assembler.d.ts.map +1 -0
- package/lib/typescript/src/ur/index.d.ts +5 -0
- package/lib/typescript/src/ur/index.d.ts.map +1 -0
- package/lib/typescript/src/ur/limits.d.ts +40 -0
- package/lib/typescript/src/ur/limits.d.ts.map +1 -0
- package/lib/typescript/src/ur/session.d.ts +11 -0
- package/lib/typescript/src/ur/session.d.ts.map +1 -0
- package/lib/typescript/src/ur/types.d.ts +61 -0
- package/lib/typescript/src/ur/types.d.ts.map +1 -0
- package/lib/typescript/src/web/decodeQrImage.d.ts +8 -0
- package/lib/typescript/src/web/decodeQrImage.d.ts.map +1 -0
- package/lib/typescript/src/web/engines.d.ts +32 -0
- package/lib/typescript/src/web/engines.d.ts.map +1 -0
- package/lib/typescript/src/web/imageOps.d.ts +37 -0
- package/lib/typescript/src/web/imageOps.d.ts.map +1 -0
- package/lib/typescript/src/web/index.d.ts +11 -0
- package/lib/typescript/src/web/index.d.ts.map +1 -0
- package/lib/typescript/src/web/scanner.d.ts +43 -0
- package/lib/typescript/src/web/scanner.d.ts.map +1 -0
- package/lib/typescript/src/web/zxing.worker.d.ts +2 -0
- package/lib/typescript/src/web/zxing.worker.d.ts.map +1 -0
- package/lib/typescript/src/web/zxingWorkerProtocol.d.ts +36 -0
- package/lib/typescript/src/web/zxingWorkerProtocol.d.ts.map +1 -0
- package/nitro.json +27 -0
- package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string_double.hpp +76 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string_std__string_double.hpp +76 -0
- package/nitrogen/generated/android/c++/JHybridQrImageDecoderSpec.cpp +78 -0
- package/nitrogen/generated/android/c++/JHybridQrImageDecoderSpec.hpp +63 -0
- package/nitrogen/generated/android/c++/JHybridQrScannerSpec.cpp +114 -0
- package/nitrogen/generated/android/c++/JHybridQrScannerSpec.hpp +70 -0
- package/nitrogen/generated/android/c++/JQrDecodeEngine.hpp +61 -0
- package/nitrogen/generated/android/c++/JQrDecodePass.hpp +64 -0
- package/nitrogen/generated/android/c++/JQrImageDecodeResult.hpp +70 -0
- package/nitrogen/generated/android/c++/views/JHybridQrScannerStateUpdater.cpp +89 -0
- package/nitrogen/generated/android/c++/views/JHybridQrScannerStateUpdater.hpp +54 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/Func_void_double.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/Func_void_std__string_double.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/Func_void_std__string_std__string_double.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/HybridQrImageDecoderSpec.kt +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/HybridQrScannerSpec.kt +101 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/QrDecodeEngine.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/QrDecodePass.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/QrImageDecodeResult.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/qrscannerOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/views/HybridQrScannerManager.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qrscanner/views/HybridQrScannerStateUpdater.kt +23 -0
- package/nitrogen/generated/android/qrscanner+autolinking.cmake +85 -0
- package/nitrogen/generated/android/qrscanner+autolinking.gradle +27 -0
- package/nitrogen/generated/android/qrscannerOnLoad.cpp +78 -0
- package/nitrogen/generated/android/qrscannerOnLoad.hpp +34 -0
- package/nitrogen/generated/ios/QrScanner+autolinking.rb +62 -0
- package/nitrogen/generated/ios/QrScanner-Swift-Cxx-Bridge.cpp +90 -0
- package/nitrogen/generated/ios/QrScanner-Swift-Cxx-Bridge.hpp +294 -0
- package/nitrogen/generated/ios/QrScanner-Swift-Cxx-Umbrella.hpp +61 -0
- package/nitrogen/generated/ios/QrScannerAutolinking.mm +41 -0
- package/nitrogen/generated/ios/QrScannerAutolinking.swift +38 -0
- package/nitrogen/generated/ios/c++/HybridQrImageDecoderSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridQrImageDecoderSpecSwift.hpp +92 -0
- package/nitrogen/generated/ios/c++/HybridQrScannerSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridQrScannerSpecSwift.hpp +103 -0
- package/nitrogen/generated/ios/c++/views/HybridQrScannerComponent.mm +162 -0
- package/nitrogen/generated/ios/swift/Func_void_QrImageDecodeResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string_std__string_double.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridQrImageDecoderSpec.swift +55 -0
- package/nitrogen/generated/ios/swift/HybridQrImageDecoderSpec_cxx.swift +145 -0
- package/nitrogen/generated/ios/swift/HybridQrScannerSpec.swift +58 -0
- package/nitrogen/generated/ios/swift/HybridQrScannerSpec_cxx.swift +252 -0
- package/nitrogen/generated/ios/swift/QrDecodeEngine.swift +44 -0
- package/nitrogen/generated/ios/swift/QrDecodePass.swift +48 -0
- package/nitrogen/generated/ios/swift/QrImageDecodeResult.swift +64 -0
- package/nitrogen/generated/shared/c++/HybridQrImageDecoderSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridQrImageDecoderSpec.hpp +65 -0
- package/nitrogen/generated/shared/c++/HybridQrScannerSpec.cpp +28 -0
- package/nitrogen/generated/shared/c++/HybridQrScannerSpec.hpp +71 -0
- package/nitrogen/generated/shared/c++/QrDecodeEngine.hpp +80 -0
- package/nitrogen/generated/shared/c++/QrDecodePass.hpp +84 -0
- package/nitrogen/generated/shared/c++/QrImageDecodeResult.hpp +97 -0
- package/nitrogen/generated/shared/c++/views/HybridQrScannerComponent.cpp +40 -0
- package/nitrogen/generated/shared/c++/views/HybridQrScannerComponent.hpp +94 -0
- package/nitrogen/generated/shared/json/QrScannerConfig.json +13 -0
- package/package.json +191 -4
- package/src/QrImageDecoder.nitro.ts +27 -0
- package/src/QrScanner.nitro.ts +34 -0
- package/src/QrScanner.tsx +109 -0
- package/src/decodeQrImage.constants.ts +2 -0
- package/src/decodeQrImage.ts +39 -0
- package/src/errors.ts +52 -0
- package/src/index.tsx +15 -0
- package/src/ur/assembler.ts +174 -0
- package/src/ur/index.ts +15 -0
- package/src/ur/limits.ts +214 -0
- package/src/ur/session.ts +57 -0
- package/src/ur/types.ts +64 -0
- package/src/web/decodeQrImage.ts +59 -0
- package/src/web/engines.ts +192 -0
- package/src/web/imageOps.ts +102 -0
- package/src/web/index.ts +12 -0
- package/src/web/scanner.ts +271 -0
- package/src/web/zxing.worker.ts +17 -0
- package/src/web/zxingWorkerProtocol.ts +79 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridQrScannerSpec_cxx.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A class implementation that bridges HybridQrScannerSpec over to C++.
|
|
12
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
13
|
+
*
|
|
14
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
15
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
16
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
17
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
18
|
+
*/
|
|
19
|
+
open class HybridQrScannerSpec_cxx {
|
|
20
|
+
/**
|
|
21
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::qrscanner::bridge::swift`)
|
|
22
|
+
* from `QrScanner-Swift-Cxx-Bridge.hpp`.
|
|
23
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
24
|
+
*/
|
|
25
|
+
public typealias bridge = margelo.nitro.qrscanner.bridge.swift
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Holds an instance of the `HybridQrScannerSpec` Swift protocol.
|
|
29
|
+
*/
|
|
30
|
+
private var __implementation: any HybridQrScannerSpec
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
34
|
+
*/
|
|
35
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridQrScannerSpec_
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a new `HybridQrScannerSpec_cxx` that wraps the given `HybridQrScannerSpec`.
|
|
39
|
+
* All properties and methods bridge to C++ types.
|
|
40
|
+
*/
|
|
41
|
+
public init(_ implementation: any HybridQrScannerSpec) {
|
|
42
|
+
self.__implementation = implementation
|
|
43
|
+
self.__cxxPart = .init()
|
|
44
|
+
/* no base class */
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get the actual `HybridQrScannerSpec` instance this class wraps.
|
|
49
|
+
*/
|
|
50
|
+
@inline(__always)
|
|
51
|
+
public func getHybridQrScannerSpec() -> any HybridQrScannerSpec {
|
|
52
|
+
return __implementation
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
57
|
+
* This acquires one additional strong reference on the object!
|
|
58
|
+
*/
|
|
59
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
60
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Casts an unsafe pointer to a `HybridQrScannerSpec_cxx`.
|
|
65
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridQrScannerSpec_cxx>`.
|
|
66
|
+
* This removes one strong reference from the object!
|
|
67
|
+
*/
|
|
68
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridQrScannerSpec_cxx {
|
|
69
|
+
return Unmanaged<HybridQrScannerSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
74
|
+
* The C++ part is a `std::shared_ptr<HybridQrScannerSpec>`.
|
|
75
|
+
*/
|
|
76
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridQrScannerSpec_ {
|
|
77
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
78
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
79
|
+
return cachedCxxPart
|
|
80
|
+
} else {
|
|
81
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridQrScannerSpec_(self.toUnsafe())
|
|
82
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridQrScannerSpec_(newCxxPart)
|
|
83
|
+
return newCxxPart
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
91
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
92
|
+
*/
|
|
93
|
+
@inline(__always)
|
|
94
|
+
public var memorySize: Int {
|
|
95
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Compares this object with the given [other] object for reference equality.
|
|
100
|
+
*/
|
|
101
|
+
@inline(__always)
|
|
102
|
+
public func equals(other: HybridQrScannerSpec_cxx) -> Bool {
|
|
103
|
+
return self.__implementation === other.__implementation
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Call dispose() on the Swift class.
|
|
108
|
+
* This _may_ be called manually from JS.
|
|
109
|
+
*/
|
|
110
|
+
@inline(__always)
|
|
111
|
+
public func dispose() {
|
|
112
|
+
self.__implementation.dispose()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Call toString() on the Swift class.
|
|
117
|
+
*/
|
|
118
|
+
@inline(__always)
|
|
119
|
+
public func toString() -> String {
|
|
120
|
+
return self.__implementation.toString()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Properties
|
|
124
|
+
public final var active: Bool {
|
|
125
|
+
@inline(__always)
|
|
126
|
+
get {
|
|
127
|
+
return self.__implementation.active
|
|
128
|
+
}
|
|
129
|
+
@inline(__always)
|
|
130
|
+
set {
|
|
131
|
+
self.__implementation.active = newValue
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public final var onReady: bridge.std__optional_std__function_void_double____generation______ {
|
|
136
|
+
@inline(__always)
|
|
137
|
+
get {
|
|
138
|
+
return { () -> bridge.std__optional_std__function_void_double____generation______ in
|
|
139
|
+
if let __unwrappedValue = self.__implementation.onReady {
|
|
140
|
+
return bridge.create_std__optional_std__function_void_double____generation______({ () -> bridge.Func_void_double in
|
|
141
|
+
let __closureWrapper = Func_void_double(__unwrappedValue)
|
|
142
|
+
return bridge.create_Func_void_double(__closureWrapper.toUnsafe())
|
|
143
|
+
}())
|
|
144
|
+
} else {
|
|
145
|
+
return .init()
|
|
146
|
+
}
|
|
147
|
+
}()
|
|
148
|
+
}
|
|
149
|
+
@inline(__always)
|
|
150
|
+
set {
|
|
151
|
+
self.__implementation.onReady = { () -> ((_ generation: Double) -> Void)? in
|
|
152
|
+
if bridge.has_value_std__optional_std__function_void_double____generation______(newValue) {
|
|
153
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_double____generation______(newValue)
|
|
154
|
+
return { () -> (Double) -> Void in
|
|
155
|
+
let __wrappedFunction = bridge.wrap_Func_void_double(__unwrapped)
|
|
156
|
+
return { (__generation: Double) -> Void in
|
|
157
|
+
__wrappedFunction.call(__generation)
|
|
158
|
+
}
|
|
159
|
+
}()
|
|
160
|
+
} else {
|
|
161
|
+
return nil
|
|
162
|
+
}
|
|
163
|
+
}()
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
public final var onFrameText: bridge.std__optional_std__function_void_const_std__string_____text_____double____generation______ {
|
|
168
|
+
@inline(__always)
|
|
169
|
+
get {
|
|
170
|
+
return { () -> bridge.std__optional_std__function_void_const_std__string_____text_____double____generation______ in
|
|
171
|
+
if let __unwrappedValue = self.__implementation.onFrameText {
|
|
172
|
+
return bridge.create_std__optional_std__function_void_const_std__string_____text_____double____generation______({ () -> bridge.Func_void_std__string_double in
|
|
173
|
+
let __closureWrapper = Func_void_std__string_double(__unwrappedValue)
|
|
174
|
+
return bridge.create_Func_void_std__string_double(__closureWrapper.toUnsafe())
|
|
175
|
+
}())
|
|
176
|
+
} else {
|
|
177
|
+
return .init()
|
|
178
|
+
}
|
|
179
|
+
}()
|
|
180
|
+
}
|
|
181
|
+
@inline(__always)
|
|
182
|
+
set {
|
|
183
|
+
self.__implementation.onFrameText = { () -> ((_ text: String, _ generation: Double) -> Void)? in
|
|
184
|
+
if bridge.has_value_std__optional_std__function_void_const_std__string_____text_____double____generation______(newValue) {
|
|
185
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_const_std__string_____text_____double____generation______(newValue)
|
|
186
|
+
return { () -> (String, Double) -> Void in
|
|
187
|
+
let __wrappedFunction = bridge.wrap_Func_void_std__string_double(__unwrapped)
|
|
188
|
+
return { (__text: String, __generation: Double) -> Void in
|
|
189
|
+
__wrappedFunction.call(std.string(__text), __generation)
|
|
190
|
+
}
|
|
191
|
+
}()
|
|
192
|
+
} else {
|
|
193
|
+
return nil
|
|
194
|
+
}
|
|
195
|
+
}()
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
public final var onError: bridge.std__optional_std__function_void_const_std__string_____code_____const_std__string_____message_____double____generation______ {
|
|
200
|
+
@inline(__always)
|
|
201
|
+
get {
|
|
202
|
+
return { () -> bridge.std__optional_std__function_void_const_std__string_____code_____const_std__string_____message_____double____generation______ in
|
|
203
|
+
if let __unwrappedValue = self.__implementation.onError {
|
|
204
|
+
return bridge.create_std__optional_std__function_void_const_std__string_____code_____const_std__string_____message_____double____generation______({ () -> bridge.Func_void_std__string_std__string_double in
|
|
205
|
+
let __closureWrapper = Func_void_std__string_std__string_double(__unwrappedValue)
|
|
206
|
+
return bridge.create_Func_void_std__string_std__string_double(__closureWrapper.toUnsafe())
|
|
207
|
+
}())
|
|
208
|
+
} else {
|
|
209
|
+
return .init()
|
|
210
|
+
}
|
|
211
|
+
}()
|
|
212
|
+
}
|
|
213
|
+
@inline(__always)
|
|
214
|
+
set {
|
|
215
|
+
self.__implementation.onError = { () -> ((_ code: String, _ message: String, _ generation: Double) -> Void)? in
|
|
216
|
+
if bridge.has_value_std__optional_std__function_void_const_std__string_____code_____const_std__string_____message_____double____generation______(newValue) {
|
|
217
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_const_std__string_____code_____const_std__string_____message_____double____generation______(newValue)
|
|
218
|
+
return { () -> (String, String, Double) -> Void in
|
|
219
|
+
let __wrappedFunction = bridge.wrap_Func_void_std__string_std__string_double(__unwrapped)
|
|
220
|
+
return { (__code: String, __message: String, __generation: Double) -> Void in
|
|
221
|
+
__wrappedFunction.call(std.string(__code), std.string(__message), __generation)
|
|
222
|
+
}
|
|
223
|
+
}()
|
|
224
|
+
} else {
|
|
225
|
+
return nil
|
|
226
|
+
}
|
|
227
|
+
}()
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Methods
|
|
232
|
+
public final func getView() -> UnsafeMutableRawPointer {
|
|
233
|
+
return Unmanaged.passRetained(__implementation.view).toOpaque()
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
public final func beforeUpdate() {
|
|
237
|
+
__implementation.beforeUpdate()
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public final func afterUpdate() {
|
|
241
|
+
__implementation.afterUpdate()
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
public final func maybePrepareForRecycle() {
|
|
245
|
+
guard let recyclable = __implementation as? any RecyclableView else { return }
|
|
246
|
+
recyclable.prepareForRecycle()
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
public final func onDropView() {
|
|
250
|
+
__implementation.onDropView()
|
|
251
|
+
}
|
|
252
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// QrDecodeEngine.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents the JS union `QrDecodeEngine`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias QrDecodeEngine = margelo.nitro.qrscanner.QrDecodeEngine
|
|
12
|
+
|
|
13
|
+
public extension QrDecodeEngine {
|
|
14
|
+
/**
|
|
15
|
+
* Get a QrDecodeEngine for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "vision":
|
|
21
|
+
self = .vision
|
|
22
|
+
case "mlkit":
|
|
23
|
+
self = .mlkit
|
|
24
|
+
case "zxing":
|
|
25
|
+
self = .zxing
|
|
26
|
+
default:
|
|
27
|
+
return nil
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the String value this QrDecodeEngine represents.
|
|
33
|
+
*/
|
|
34
|
+
var stringValue: String {
|
|
35
|
+
switch self {
|
|
36
|
+
case .vision:
|
|
37
|
+
return "vision"
|
|
38
|
+
case .mlkit:
|
|
39
|
+
return "mlkit"
|
|
40
|
+
case .zxing:
|
|
41
|
+
return "zxing"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// QrDecodePass.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents the JS union `QrDecodePass`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias QrDecodePass = margelo.nitro.qrscanner.QrDecodePass
|
|
12
|
+
|
|
13
|
+
public extension QrDecodePass {
|
|
14
|
+
/**
|
|
15
|
+
* Get a QrDecodePass for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "original":
|
|
21
|
+
self = .original
|
|
22
|
+
case "padded":
|
|
23
|
+
self = .padded
|
|
24
|
+
case "grayscale":
|
|
25
|
+
self = .grayscale
|
|
26
|
+
case "inverted":
|
|
27
|
+
self = .inverted
|
|
28
|
+
default:
|
|
29
|
+
return nil
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get the String value this QrDecodePass represents.
|
|
35
|
+
*/
|
|
36
|
+
var stringValue: String {
|
|
37
|
+
switch self {
|
|
38
|
+
case .original:
|
|
39
|
+
return "original"
|
|
40
|
+
case .padded:
|
|
41
|
+
return "padded"
|
|
42
|
+
case .grayscale:
|
|
43
|
+
return "grayscale"
|
|
44
|
+
case .inverted:
|
|
45
|
+
return "inverted"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// QrImageDecodeResult.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `QrImageDecodeResult`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias QrImageDecodeResult = margelo.nitro.qrscanner.QrImageDecodeResult
|
|
14
|
+
|
|
15
|
+
public extension QrImageDecodeResult {
|
|
16
|
+
private typealias bridge = margelo.nitro.qrscanner.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `QrImageDecodeResult`.
|
|
20
|
+
*/
|
|
21
|
+
init(text: String?, engine: QrDecodeEngine?, pass: QrDecodePass?) {
|
|
22
|
+
self.init({ () -> bridge.std__optional_std__string_ in
|
|
23
|
+
if let __unwrappedValue = text {
|
|
24
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}(), { () -> bridge.std__optional_QrDecodeEngine_ in
|
|
29
|
+
if let __unwrappedValue = engine {
|
|
30
|
+
return bridge.create_std__optional_QrDecodeEngine_(__unwrappedValue)
|
|
31
|
+
} else {
|
|
32
|
+
return .init()
|
|
33
|
+
}
|
|
34
|
+
}(), { () -> bridge.std__optional_QrDecodePass_ in
|
|
35
|
+
if let __unwrappedValue = pass {
|
|
36
|
+
return bridge.create_std__optional_QrDecodePass_(__unwrappedValue)
|
|
37
|
+
} else {
|
|
38
|
+
return .init()
|
|
39
|
+
}
|
|
40
|
+
}())
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@inline(__always)
|
|
44
|
+
var text: String? {
|
|
45
|
+
return { () -> String? in
|
|
46
|
+
if bridge.has_value_std__optional_std__string_(self.__text) {
|
|
47
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__text)
|
|
48
|
+
return String(__unwrapped)
|
|
49
|
+
} else {
|
|
50
|
+
return nil
|
|
51
|
+
}
|
|
52
|
+
}()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@inline(__always)
|
|
56
|
+
var engine: QrDecodeEngine? {
|
|
57
|
+
return self.__engine.value
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@inline(__always)
|
|
61
|
+
var pass: QrDecodePass? {
|
|
62
|
+
return self.__pass.value
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridQrImageDecoderSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridQrImageDecoderSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::qrscanner {
|
|
11
|
+
|
|
12
|
+
void HybridQrImageDecoderSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("decodeImage", &HybridQrImageDecoderSpec::decodeImage);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
} // namespace margelo::nitro::qrscanner
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridQrImageDecoderSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
// Forward declaration of `QrImageDecodeResult` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::qrscanner { struct QrImageDecodeResult; }
|
|
18
|
+
|
|
19
|
+
#include "QrImageDecodeResult.hpp"
|
|
20
|
+
#include <NitroModules/Promise.hpp>
|
|
21
|
+
#include <string>
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::qrscanner {
|
|
24
|
+
|
|
25
|
+
using namespace margelo::nitro;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* An abstract base class for `QrImageDecoder`
|
|
29
|
+
* Inherit this class to create instances of `HybridQrImageDecoderSpec` in C++.
|
|
30
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
31
|
+
* @example
|
|
32
|
+
* ```cpp
|
|
33
|
+
* class HybridQrImageDecoder: public HybridQrImageDecoderSpec {
|
|
34
|
+
* public:
|
|
35
|
+
* HybridQrImageDecoder(...): HybridObject(TAG) { ... }
|
|
36
|
+
* // ...
|
|
37
|
+
* };
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
class HybridQrImageDecoderSpec: public virtual HybridObject {
|
|
41
|
+
public:
|
|
42
|
+
// Constructor
|
|
43
|
+
explicit HybridQrImageDecoderSpec(): HybridObject(TAG) { }
|
|
44
|
+
|
|
45
|
+
// Destructor
|
|
46
|
+
~HybridQrImageDecoderSpec() override = default;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
// Properties
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
// Methods
|
|
54
|
+
virtual std::shared_ptr<Promise<QrImageDecodeResult>> decodeImage(const std::string& uri, double maxPixels) = 0;
|
|
55
|
+
|
|
56
|
+
protected:
|
|
57
|
+
// Hybrid Setup
|
|
58
|
+
void loadHybridMethods() override;
|
|
59
|
+
|
|
60
|
+
protected:
|
|
61
|
+
// Tag for logging
|
|
62
|
+
static constexpr auto TAG = "QrImageDecoder";
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
} // namespace margelo::nitro::qrscanner
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridQrScannerSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridQrScannerSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::qrscanner {
|
|
11
|
+
|
|
12
|
+
void HybridQrScannerSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridGetter("active", &HybridQrScannerSpec::getActive);
|
|
18
|
+
prototype.registerHybridSetter("active", &HybridQrScannerSpec::setActive);
|
|
19
|
+
prototype.registerHybridGetter("onReady", &HybridQrScannerSpec::getOnReady);
|
|
20
|
+
prototype.registerHybridSetter("onReady", &HybridQrScannerSpec::setOnReady);
|
|
21
|
+
prototype.registerHybridGetter("onFrameText", &HybridQrScannerSpec::getOnFrameText);
|
|
22
|
+
prototype.registerHybridSetter("onFrameText", &HybridQrScannerSpec::setOnFrameText);
|
|
23
|
+
prototype.registerHybridGetter("onError", &HybridQrScannerSpec::getOnError);
|
|
24
|
+
prototype.registerHybridSetter("onError", &HybridQrScannerSpec::setOnError);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
} // namespace margelo::nitro::qrscanner
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridQrScannerSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
#include <functional>
|
|
19
|
+
#include <optional>
|
|
20
|
+
#include <string>
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::qrscanner {
|
|
23
|
+
|
|
24
|
+
using namespace margelo::nitro;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* An abstract base class for `QrScanner`
|
|
28
|
+
* Inherit this class to create instances of `HybridQrScannerSpec` in C++.
|
|
29
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
30
|
+
* @example
|
|
31
|
+
* ```cpp
|
|
32
|
+
* class HybridQrScanner: public HybridQrScannerSpec {
|
|
33
|
+
* public:
|
|
34
|
+
* HybridQrScanner(...): HybridObject(TAG) { ... }
|
|
35
|
+
* // ...
|
|
36
|
+
* };
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
class HybridQrScannerSpec: public virtual HybridObject {
|
|
40
|
+
public:
|
|
41
|
+
// Constructor
|
|
42
|
+
explicit HybridQrScannerSpec(): HybridObject(TAG) { }
|
|
43
|
+
|
|
44
|
+
// Destructor
|
|
45
|
+
~HybridQrScannerSpec() override = default;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
// Properties
|
|
49
|
+
virtual bool getActive() = 0;
|
|
50
|
+
virtual void setActive(bool active) = 0;
|
|
51
|
+
virtual std::optional<std::function<void(double /* generation */)>> getOnReady() = 0;
|
|
52
|
+
virtual void setOnReady(const std::optional<std::function<void(double /* generation */)>>& onReady) = 0;
|
|
53
|
+
virtual std::optional<std::function<void(const std::string& /* text */, double /* generation */)>> getOnFrameText() = 0;
|
|
54
|
+
virtual void setOnFrameText(const std::optional<std::function<void(const std::string& /* text */, double /* generation */)>>& onFrameText) = 0;
|
|
55
|
+
virtual std::optional<std::function<void(const std::string& /* code */, const std::string& /* message */, double /* generation */)>> getOnError() = 0;
|
|
56
|
+
virtual void setOnError(const std::optional<std::function<void(const std::string& /* code */, const std::string& /* message */, double /* generation */)>>& onError) = 0;
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
// Methods
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
protected:
|
|
63
|
+
// Hybrid Setup
|
|
64
|
+
void loadHybridMethods() override;
|
|
65
|
+
|
|
66
|
+
protected:
|
|
67
|
+
// Tag for logging
|
|
68
|
+
static constexpr auto TAG = "QrScanner";
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
} // namespace margelo::nitro::qrscanner
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// QrDecodeEngine.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::qrscanner {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (QrDecodeEngine).
|
|
30
|
+
*/
|
|
31
|
+
enum class QrDecodeEngine {
|
|
32
|
+
VISION SWIFT_NAME(vision) = 0,
|
|
33
|
+
MLKIT SWIFT_NAME(mlkit) = 1,
|
|
34
|
+
ZXING SWIFT_NAME(zxing) = 2,
|
|
35
|
+
} CLOSED_ENUM;
|
|
36
|
+
|
|
37
|
+
} // namespace margelo::nitro::qrscanner
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro {
|
|
40
|
+
|
|
41
|
+
// C++ QrDecodeEngine <> JS QrDecodeEngine (union)
|
|
42
|
+
template <>
|
|
43
|
+
struct JSIConverter<margelo::nitro::qrscanner::QrDecodeEngine> final {
|
|
44
|
+
static inline margelo::nitro::qrscanner::QrDecodeEngine fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
45
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
46
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
47
|
+
case hashString("vision"): return margelo::nitro::qrscanner::QrDecodeEngine::VISION;
|
|
48
|
+
case hashString("mlkit"): return margelo::nitro::qrscanner::QrDecodeEngine::MLKIT;
|
|
49
|
+
case hashString("zxing"): return margelo::nitro::qrscanner::QrDecodeEngine::ZXING;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum QrDecodeEngine - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::qrscanner::QrDecodeEngine arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case margelo::nitro::qrscanner::QrDecodeEngine::VISION: return JSIConverter<std::string>::toJSI(runtime, "vision");
|
|
57
|
+
case margelo::nitro::qrscanner::QrDecodeEngine::MLKIT: return JSIConverter<std::string>::toJSI(runtime, "mlkit");
|
|
58
|
+
case margelo::nitro::qrscanner::QrDecodeEngine::ZXING: return JSIConverter<std::string>::toJSI(runtime, "zxing");
|
|
59
|
+
default: [[unlikely]]
|
|
60
|
+
throw std::invalid_argument("Cannot convert QrDecodeEngine to JS - invalid value: "
|
|
61
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
65
|
+
if (!value.isString()) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
69
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
70
|
+
case hashString("vision"):
|
|
71
|
+
case hashString("mlkit"):
|
|
72
|
+
case hashString("zxing"):
|
|
73
|
+
return true;
|
|
74
|
+
default:
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|