@nitro-mlkit/digital-ink 0.1.0-beta.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.
- package/LICENSE +21 -0
- package/NitroMLKitDigitalInk.podspec +34 -0
- package/README.md +67 -0
- package/android/CMakeLists.txt +12 -0
- package/android/build.gradle +77 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/cpp/cpp-adapter.cpp +9 -0
- package/android/src/main/kotlin/com/margelo/nitro/nitromlkit/digitalink/HybridDigitalInkRecognizer.kt +84 -0
- package/android/src/main/kotlin/com/nitromlkit/digitalink/NitroMLKitDigitalInkPackage.kt +19 -0
- package/expo-module.config.json +9 -0
- package/ios/HybridDigitalInkRecognizer.swift +156 -0
- package/nitro.json +16 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroMLKitDigitalInk+autolinking.cmake +81 -0
- package/nitrogen/generated/android/NitroMLKitDigitalInk+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroMLKitDigitalInkOnLoad.cpp +54 -0
- package/nitrogen/generated/android/NitroMLKitDigitalInkOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JHybridDigitalInkRecognizerSpec.cpp +149 -0
- package/nitrogen/generated/android/c++/JHybridDigitalInkRecognizerSpec.hpp +67 -0
- package/nitrogen/generated/android/c++/JInkPoint.hpp +65 -0
- package/nitrogen/generated/android/c++/JInkStroke.hpp +78 -0
- package/nitrogen/generated/android/c++/JRecognitionCandidate.hpp +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromlkit/digitalink/HybridDigitalInkRecognizerSpec.kt +71 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromlkit/digitalink/InkPoint.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromlkit/digitalink/InkStroke.kt +51 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromlkit/digitalink/NitroMLKitDigitalInkOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromlkit/digitalink/RecognitionCandidate.kt +56 -0
- package/nitrogen/generated/ios/NitroMLKitDigitalInk+autolinking.rb +62 -0
- package/nitrogen/generated/ios/NitroMLKitDigitalInk-Swift-Cxx-Bridge.cpp +65 -0
- package/nitrogen/generated/ios/NitroMLKitDigitalInk-Swift-Cxx-Bridge.hpp +265 -0
- package/nitrogen/generated/ios/NitroMLKitDigitalInk-Swift-Cxx-Umbrella.hpp +56 -0
- package/nitrogen/generated/ios/NitroMLKitDigitalInkAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroMLKitDigitalInkAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridDigitalInkRecognizerSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridDigitalInkRecognizerSpecSwift.hpp +125 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_RecognitionCandidate_.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridDigitalInkRecognizerSpec.swift +59 -0
- package/nitrogen/generated/ios/swift/HybridDigitalInkRecognizerSpec_cxx.swift +220 -0
- package/nitrogen/generated/ios/swift/InkPoint.swift +52 -0
- package/nitrogen/generated/ios/swift/InkStroke.swift +35 -0
- package/nitrogen/generated/ios/swift/RecognitionCandidate.swift +47 -0
- package/nitrogen/generated/shared/c++/HybridDigitalInkRecognizerSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridDigitalInkRecognizerSpec.hpp +73 -0
- package/nitrogen/generated/shared/c++/InkPoint.hpp +91 -0
- package/nitrogen/generated/shared/c++/InkStroke.hpp +85 -0
- package/nitrogen/generated/shared/c++/RecognitionCandidate.hpp +88 -0
- package/package.json +54 -0
- package/src/index.ts +19 -0
- package/src/specs/DigitalInkRecognizer.nitro.ts +51 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridDigitalInkRecognizerSpecSwift.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
|
+
#include "HybridDigitalInkRecognizerSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridDigitalInkRecognizerSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace NitroMLKitDigitalInk { class HybridDigitalInkRecognizerSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `RecognitionCandidate` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::mlkit::digitalink { struct RecognitionCandidate; }
|
|
17
|
+
// Forward declaration of `InkStroke` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::mlkit::digitalink { struct InkStroke; }
|
|
19
|
+
// Forward declaration of `InkPoint` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::mlkit::digitalink { struct InkPoint; }
|
|
21
|
+
|
|
22
|
+
#include "RecognitionCandidate.hpp"
|
|
23
|
+
#include <vector>
|
|
24
|
+
#include <NitroModules/Promise.hpp>
|
|
25
|
+
#include <string>
|
|
26
|
+
#include <optional>
|
|
27
|
+
#include "InkStroke.hpp"
|
|
28
|
+
#include "InkPoint.hpp"
|
|
29
|
+
|
|
30
|
+
#include "NitroMLKitDigitalInk-Swift-Cxx-Umbrella.hpp"
|
|
31
|
+
|
|
32
|
+
namespace margelo::nitro::mlkit::digitalink {
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The C++ part of HybridDigitalInkRecognizerSpec_cxx.swift.
|
|
36
|
+
*
|
|
37
|
+
* HybridDigitalInkRecognizerSpecSwift (C++) accesses HybridDigitalInkRecognizerSpec_cxx (Swift), and might
|
|
38
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
39
|
+
*
|
|
40
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
41
|
+
* the future, HybridDigitalInkRecognizerSpec_cxx can directly inherit from the C++ class HybridDigitalInkRecognizerSpec
|
|
42
|
+
* to simplify the whole structure and memory management.
|
|
43
|
+
*/
|
|
44
|
+
class HybridDigitalInkRecognizerSpecSwift: public virtual HybridDigitalInkRecognizerSpec {
|
|
45
|
+
public:
|
|
46
|
+
// Constructor from a Swift instance
|
|
47
|
+
explicit HybridDigitalInkRecognizerSpecSwift(const NitroMLKitDigitalInk::HybridDigitalInkRecognizerSpec_cxx& swiftPart):
|
|
48
|
+
HybridObject(HybridDigitalInkRecognizerSpec::TAG),
|
|
49
|
+
_swiftPart(swiftPart) { }
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Get the Swift part
|
|
53
|
+
inline NitroMLKitDigitalInk::HybridDigitalInkRecognizerSpec_cxx& getSwiftPart() noexcept {
|
|
54
|
+
return _swiftPart;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
59
|
+
return _swiftPart.getMemorySize();
|
|
60
|
+
}
|
|
61
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override {
|
|
62
|
+
if (auto otherCast = std::dynamic_pointer_cast<HybridDigitalInkRecognizerSpecSwift>(other)) {
|
|
63
|
+
return _swiftPart.equals(otherCast->_swiftPart);
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
void dispose() noexcept override {
|
|
68
|
+
_swiftPart.dispose();
|
|
69
|
+
}
|
|
70
|
+
std::string toString() override {
|
|
71
|
+
return _swiftPart.toString();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public:
|
|
75
|
+
// Properties
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
public:
|
|
79
|
+
// Methods
|
|
80
|
+
inline std::shared_ptr<Promise<std::vector<RecognitionCandidate>>> recognize(const std::vector<InkStroke>& strokes, const std::string& languageTag) override {
|
|
81
|
+
auto __result = _swiftPart.recognize(strokes, languageTag);
|
|
82
|
+
if (__result.hasError()) [[unlikely]] {
|
|
83
|
+
std::rethrow_exception(__result.error());
|
|
84
|
+
}
|
|
85
|
+
auto __value = std::move(__result.value());
|
|
86
|
+
return __value;
|
|
87
|
+
}
|
|
88
|
+
inline std::shared_ptr<Promise<void>> downloadModel(const std::string& languageTag) override {
|
|
89
|
+
auto __result = _swiftPart.downloadModel(languageTag);
|
|
90
|
+
if (__result.hasError()) [[unlikely]] {
|
|
91
|
+
std::rethrow_exception(__result.error());
|
|
92
|
+
}
|
|
93
|
+
auto __value = std::move(__result.value());
|
|
94
|
+
return __value;
|
|
95
|
+
}
|
|
96
|
+
inline std::shared_ptr<Promise<bool>> isModelDownloaded(const std::string& languageTag) override {
|
|
97
|
+
auto __result = _swiftPart.isModelDownloaded(languageTag);
|
|
98
|
+
if (__result.hasError()) [[unlikely]] {
|
|
99
|
+
std::rethrow_exception(__result.error());
|
|
100
|
+
}
|
|
101
|
+
auto __value = std::move(__result.value());
|
|
102
|
+
return __value;
|
|
103
|
+
}
|
|
104
|
+
inline std::shared_ptr<Promise<void>> deleteModel(const std::string& languageTag) override {
|
|
105
|
+
auto __result = _swiftPart.deleteModel(languageTag);
|
|
106
|
+
if (__result.hasError()) [[unlikely]] {
|
|
107
|
+
std::rethrow_exception(__result.error());
|
|
108
|
+
}
|
|
109
|
+
auto __value = std::move(__result.value());
|
|
110
|
+
return __value;
|
|
111
|
+
}
|
|
112
|
+
inline bool isAvailable() override {
|
|
113
|
+
auto __result = _swiftPart.isAvailable();
|
|
114
|
+
if (__result.hasError()) [[unlikely]] {
|
|
115
|
+
std::rethrow_exception(__result.error());
|
|
116
|
+
}
|
|
117
|
+
auto __value = std::move(__result.value());
|
|
118
|
+
return __value;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private:
|
|
122
|
+
NitroMLKitDigitalInk::HybridDigitalInkRecognizerSpec_cxx _swiftPart;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
} // namespace margelo::nitro::mlkit::digitalink
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void.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
|
+
* Wraps a Swift `() -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void {
|
|
15
|
+
public typealias bridge = margelo.nitro.mlkit.digitalink.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: () -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping () -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call() -> Void {
|
|
25
|
+
self.closure()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void {
|
|
44
|
+
return Unmanaged<Func_void>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_bool.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
|
+
* Wraps a Swift `(_ value: Bool) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_bool {
|
|
15
|
+
public typealias bridge = margelo.nitro.mlkit.digitalink.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ value: Bool) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ value: Bool) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(value: Bool) -> Void {
|
|
25
|
+
self.closure(value)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_bool`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_bool>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_bool {
|
|
44
|
+
return Unmanaged<Func_void_bool>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__exception_ptr.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
|
+
* Wraps a Swift `(_ error: Error) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__exception_ptr {
|
|
15
|
+
public typealias bridge = margelo.nitro.mlkit.digitalink.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ error: Error) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ error: Error) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(error: std.exception_ptr) -> Void {
|
|
25
|
+
self.closure(RuntimeError.from(cppError: error))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
|
|
44
|
+
return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__vector_RecognitionCandidate_.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
|
+
* Wraps a Swift `(_ value: [RecognitionCandidate]) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__vector_RecognitionCandidate_ {
|
|
15
|
+
public typealias bridge = margelo.nitro.mlkit.digitalink.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ value: [RecognitionCandidate]) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ value: [RecognitionCandidate]) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(value: bridge.std__vector_RecognitionCandidate_) -> Void {
|
|
25
|
+
self.closure(value.map({ __item in __item }))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_std__vector_RecognitionCandidate_`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__vector_RecognitionCandidate_>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__vector_RecognitionCandidate_ {
|
|
44
|
+
return Unmanaged<Func_void_std__vector_RecognitionCandidate_>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridDigitalInkRecognizerSpec.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
|
+
/// See ``HybridDigitalInkRecognizerSpec``
|
|
11
|
+
public protocol HybridDigitalInkRecognizerSpec_protocol: HybridObject {
|
|
12
|
+
// Properties
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// Methods
|
|
16
|
+
func recognize(strokes: [InkStroke], languageTag: String) throws -> Promise<[RecognitionCandidate]>
|
|
17
|
+
func downloadModel(languageTag: String) throws -> Promise<Void>
|
|
18
|
+
func isModelDownloaded(languageTag: String) throws -> Promise<Bool>
|
|
19
|
+
func deleteModel(languageTag: String) throws -> Promise<Void>
|
|
20
|
+
func isAvailable() throws -> Bool
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public extension HybridDigitalInkRecognizerSpec_protocol {
|
|
24
|
+
/// Default implementation of ``HybridObject.toString``
|
|
25
|
+
func toString() -> String {
|
|
26
|
+
return "[HybridObject DigitalInkRecognizer]"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/// See ``HybridDigitalInkRecognizerSpec``
|
|
31
|
+
open class HybridDigitalInkRecognizerSpec_base {
|
|
32
|
+
private weak var cxxWrapper: HybridDigitalInkRecognizerSpec_cxx? = nil
|
|
33
|
+
public init() { }
|
|
34
|
+
public func getCxxWrapper() -> HybridDigitalInkRecognizerSpec_cxx {
|
|
35
|
+
#if DEBUG
|
|
36
|
+
guard self is any HybridDigitalInkRecognizerSpec else {
|
|
37
|
+
fatalError("`self` is not a `HybridDigitalInkRecognizerSpec`! Did you accidentally inherit from `HybridDigitalInkRecognizerSpec_base` instead of `HybridDigitalInkRecognizerSpec`?")
|
|
38
|
+
}
|
|
39
|
+
#endif
|
|
40
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
41
|
+
return cxxWrapper
|
|
42
|
+
} else {
|
|
43
|
+
let cxxWrapper = HybridDigitalInkRecognizerSpec_cxx(self as! any HybridDigitalInkRecognizerSpec)
|
|
44
|
+
self.cxxWrapper = cxxWrapper
|
|
45
|
+
return cxxWrapper
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A Swift base-protocol representing the DigitalInkRecognizer HybridObject.
|
|
52
|
+
* Implement this protocol to create Swift-based instances of DigitalInkRecognizer.
|
|
53
|
+
* ```swift
|
|
54
|
+
* class HybridDigitalInkRecognizer : HybridDigitalInkRecognizerSpec {
|
|
55
|
+
* // ...
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
public typealias HybridDigitalInkRecognizerSpec = HybridDigitalInkRecognizerSpec_protocol & HybridDigitalInkRecognizerSpec_base
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridDigitalInkRecognizerSpec_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 HybridDigitalInkRecognizerSpec 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 HybridDigitalInkRecognizerSpec_cxx {
|
|
20
|
+
/**
|
|
21
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::mlkit::digitalink::bridge::swift`)
|
|
22
|
+
* from `NitroMLKitDigitalInk-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.mlkit.digitalink.bridge.swift
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Holds an instance of the `HybridDigitalInkRecognizerSpec` Swift protocol.
|
|
29
|
+
*/
|
|
30
|
+
private var __implementation: any HybridDigitalInkRecognizerSpec
|
|
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_HybridDigitalInkRecognizerSpec_
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a new `HybridDigitalInkRecognizerSpec_cxx` that wraps the given `HybridDigitalInkRecognizerSpec`.
|
|
39
|
+
* All properties and methods bridge to C++ types.
|
|
40
|
+
*/
|
|
41
|
+
public init(_ implementation: any HybridDigitalInkRecognizerSpec) {
|
|
42
|
+
self.__implementation = implementation
|
|
43
|
+
self.__cxxPart = .init()
|
|
44
|
+
/* no base class */
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get the actual `HybridDigitalInkRecognizerSpec` instance this class wraps.
|
|
49
|
+
*/
|
|
50
|
+
@inline(__always)
|
|
51
|
+
public func getHybridDigitalInkRecognizerSpec() -> any HybridDigitalInkRecognizerSpec {
|
|
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 `HybridDigitalInkRecognizerSpec_cxx`.
|
|
65
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridDigitalInkRecognizerSpec_cxx>`.
|
|
66
|
+
* This removes one strong reference from the object!
|
|
67
|
+
*/
|
|
68
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridDigitalInkRecognizerSpec_cxx {
|
|
69
|
+
return Unmanaged<HybridDigitalInkRecognizerSpec_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<HybridDigitalInkRecognizerSpec>`.
|
|
75
|
+
*/
|
|
76
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridDigitalInkRecognizerSpec_ {
|
|
77
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
78
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
79
|
+
return cachedCxxPart
|
|
80
|
+
} else {
|
|
81
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridDigitalInkRecognizerSpec_(self.toUnsafe())
|
|
82
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridDigitalInkRecognizerSpec_(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: HybridDigitalInkRecognizerSpec_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
|
+
|
|
125
|
+
|
|
126
|
+
// Methods
|
|
127
|
+
@inline(__always)
|
|
128
|
+
public final func recognize(strokes: bridge.std__vector_InkStroke_, languageTag: std.string) -> bridge.Result_std__shared_ptr_Promise_std__vector_RecognitionCandidate____ {
|
|
129
|
+
do {
|
|
130
|
+
let __result = try self.__implementation.recognize(strokes: strokes.map({ __item in __item }), languageTag: String(languageTag))
|
|
131
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__vector_RecognitionCandidate___ in
|
|
132
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__vector_RecognitionCandidate___()
|
|
133
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__vector_RecognitionCandidate___(__promise)
|
|
134
|
+
__result
|
|
135
|
+
.then({ __result in __promiseHolder.resolve({ () -> bridge.std__vector_RecognitionCandidate_ in
|
|
136
|
+
var __vector = bridge.create_std__vector_RecognitionCandidate_(__result.count)
|
|
137
|
+
for __item in __result {
|
|
138
|
+
__vector.push_back(__item)
|
|
139
|
+
}
|
|
140
|
+
return __vector
|
|
141
|
+
}()) })
|
|
142
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
143
|
+
return __promise
|
|
144
|
+
}()
|
|
145
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__vector_RecognitionCandidate____(__resultCpp)
|
|
146
|
+
} catch (let __error) {
|
|
147
|
+
let __exceptionPtr = __error.toCpp()
|
|
148
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__vector_RecognitionCandidate____(__exceptionPtr)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@inline(__always)
|
|
153
|
+
public final func downloadModel(languageTag: std.string) -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
154
|
+
do {
|
|
155
|
+
let __result = try self.__implementation.downloadModel(languageTag: String(languageTag))
|
|
156
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
157
|
+
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
158
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
159
|
+
__result
|
|
160
|
+
.then({ __result in __promiseHolder.resolve() })
|
|
161
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
162
|
+
return __promise
|
|
163
|
+
}()
|
|
164
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
165
|
+
} catch (let __error) {
|
|
166
|
+
let __exceptionPtr = __error.toCpp()
|
|
167
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@inline(__always)
|
|
172
|
+
public final func isModelDownloaded(languageTag: std.string) -> bridge.Result_std__shared_ptr_Promise_bool___ {
|
|
173
|
+
do {
|
|
174
|
+
let __result = try self.__implementation.isModelDownloaded(languageTag: String(languageTag))
|
|
175
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
|
|
176
|
+
let __promise = bridge.create_std__shared_ptr_Promise_bool__()
|
|
177
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
|
|
178
|
+
__result
|
|
179
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
180
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
181
|
+
return __promise
|
|
182
|
+
}()
|
|
183
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
|
|
184
|
+
} catch (let __error) {
|
|
185
|
+
let __exceptionPtr = __error.toCpp()
|
|
186
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
@inline(__always)
|
|
191
|
+
public final func deleteModel(languageTag: std.string) -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
192
|
+
do {
|
|
193
|
+
let __result = try self.__implementation.deleteModel(languageTag: String(languageTag))
|
|
194
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
195
|
+
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
196
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
197
|
+
__result
|
|
198
|
+
.then({ __result in __promiseHolder.resolve() })
|
|
199
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
200
|
+
return __promise
|
|
201
|
+
}()
|
|
202
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
203
|
+
} catch (let __error) {
|
|
204
|
+
let __exceptionPtr = __error.toCpp()
|
|
205
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
@inline(__always)
|
|
210
|
+
public final func isAvailable() -> bridge.Result_bool_ {
|
|
211
|
+
do {
|
|
212
|
+
let __result = try self.__implementation.isAvailable()
|
|
213
|
+
let __resultCpp = __result
|
|
214
|
+
return bridge.create_Result_bool_(__resultCpp)
|
|
215
|
+
} catch (let __error) {
|
|
216
|
+
let __exceptionPtr = __error.toCpp()
|
|
217
|
+
return bridge.create_Result_bool_(__exceptionPtr)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// InkPoint.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 `InkPoint`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias InkPoint = margelo.nitro.mlkit.digitalink.InkPoint
|
|
14
|
+
|
|
15
|
+
public extension InkPoint {
|
|
16
|
+
private typealias bridge = margelo.nitro.mlkit.digitalink.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `InkPoint`.
|
|
20
|
+
*/
|
|
21
|
+
init(x: Double, y: Double, t: Double?) {
|
|
22
|
+
self.init(x, y, { () -> bridge.std__optional_double_ in
|
|
23
|
+
if let __unwrappedValue = t {
|
|
24
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}())
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@inline(__always)
|
|
32
|
+
var x: Double {
|
|
33
|
+
return self.__x
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@inline(__always)
|
|
37
|
+
var y: Double {
|
|
38
|
+
return self.__y
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@inline(__always)
|
|
42
|
+
var t: Double? {
|
|
43
|
+
return { () -> Double? in
|
|
44
|
+
if bridge.has_value_std__optional_double_(self.__t) {
|
|
45
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__t)
|
|
46
|
+
return __unwrapped
|
|
47
|
+
} else {
|
|
48
|
+
return nil
|
|
49
|
+
}
|
|
50
|
+
}()
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// InkStroke.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 `InkStroke`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias InkStroke = margelo.nitro.mlkit.digitalink.InkStroke
|
|
14
|
+
|
|
15
|
+
public extension InkStroke {
|
|
16
|
+
private typealias bridge = margelo.nitro.mlkit.digitalink.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `InkStroke`.
|
|
20
|
+
*/
|
|
21
|
+
init(points: [InkPoint]) {
|
|
22
|
+
self.init({ () -> bridge.std__vector_InkPoint_ in
|
|
23
|
+
var __vector = bridge.create_std__vector_InkPoint_(points.count)
|
|
24
|
+
for __item in points {
|
|
25
|
+
__vector.push_back(__item)
|
|
26
|
+
}
|
|
27
|
+
return __vector
|
|
28
|
+
}())
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@inline(__always)
|
|
32
|
+
var points: [InkPoint] {
|
|
33
|
+
return self.__points.map({ __item in __item })
|
|
34
|
+
}
|
|
35
|
+
}
|