@renegades/react-native-tickle 0.1.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.
Files changed (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +352 -0
  3. package/Tickle.podspec +29 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +126 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/tickle/Tickle.kt +71 -0
  10. package/android/src/main/java/com/margelo/nitro/tickle/TicklePackage.kt +22 -0
  11. package/ios/Tickle.swift +185 -0
  12. package/ios/TickleUtils.swift +404 -0
  13. package/lib/module/Tickle.nitro.js +4 -0
  14. package/lib/module/Tickle.nitro.js.map +1 -0
  15. package/lib/module/index.js +254 -0
  16. package/lib/module/index.js.map +1 -0
  17. package/lib/module/package.json +1 -0
  18. package/lib/typescript/package.json +1 -0
  19. package/lib/typescript/src/Tickle.nitro.d.ts +63 -0
  20. package/lib/typescript/src/Tickle.nitro.d.ts.map +1 -0
  21. package/lib/typescript/src/index.d.ts +148 -0
  22. package/lib/typescript/src/index.d.ts.map +1 -0
  23. package/nitro.json +17 -0
  24. package/nitrogen/generated/android/c++/JHapticCurve.hpp +87 -0
  25. package/nitrogen/generated/android/c++/JHapticCurveControlPoint.hpp +61 -0
  26. package/nitrogen/generated/android/c++/JHapticEvent.hpp +94 -0
  27. package/nitrogen/generated/android/c++/JHapticEventParameter.hpp +62 -0
  28. package/nitrogen/generated/android/c++/JHapticEventType.hpp +58 -0
  29. package/nitrogen/generated/android/c++/JHapticImpactStyle.hpp +67 -0
  30. package/nitrogen/generated/android/c++/JHapticNotificationType.hpp +61 -0
  31. package/nitrogen/generated/android/c++/JHapticParameterType.hpp +58 -0
  32. package/nitrogen/generated/android/c++/JHybridTickleSpec.cpp +162 -0
  33. package/nitrogen/generated/android/c++/JHybridTickleSpec.hpp +79 -0
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticCurve.kt +44 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticCurveControlPoint.kt +41 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticEvent.kt +47 -0
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticEventParameter.kt +41 -0
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticEventType.kt +23 -0
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticImpactStyle.kt +26 -0
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticNotificationType.kt +24 -0
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticParameterType.kt +23 -0
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HybridTickleSpec.kt +109 -0
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/tickleOnLoad.kt +35 -0
  44. package/nitrogen/generated/android/tickle+autolinking.cmake +81 -0
  45. package/nitrogen/generated/android/tickle+autolinking.gradle +27 -0
  46. package/nitrogen/generated/android/tickleOnLoad.cpp +44 -0
  47. package/nitrogen/generated/android/tickleOnLoad.hpp +25 -0
  48. package/nitrogen/generated/ios/Tickle+autolinking.rb +60 -0
  49. package/nitrogen/generated/ios/Tickle-Swift-Cxx-Bridge.cpp +33 -0
  50. package/nitrogen/generated/ios/Tickle-Swift-Cxx-Bridge.hpp +139 -0
  51. package/nitrogen/generated/ios/Tickle-Swift-Cxx-Umbrella.hpp +70 -0
  52. package/nitrogen/generated/ios/TickleAutolinking.mm +33 -0
  53. package/nitrogen/generated/ios/TickleAutolinking.swift +25 -0
  54. package/nitrogen/generated/ios/c++/HybridTickleSpecSwift.cpp +11 -0
  55. package/nitrogen/generated/ios/c++/HybridTickleSpecSwift.hpp +185 -0
  56. package/nitrogen/generated/ios/swift/HapticCurve.swift +46 -0
  57. package/nitrogen/generated/ios/swift/HapticCurveControlPoint.swift +35 -0
  58. package/nitrogen/generated/ios/swift/HapticEvent.swift +57 -0
  59. package/nitrogen/generated/ios/swift/HapticEventParameter.swift +35 -0
  60. package/nitrogen/generated/ios/swift/HapticEventType.swift +40 -0
  61. package/nitrogen/generated/ios/swift/HapticImpactStyle.swift +52 -0
  62. package/nitrogen/generated/ios/swift/HapticNotificationType.swift +44 -0
  63. package/nitrogen/generated/ios/swift/HapticParameterType.swift +40 -0
  64. package/nitrogen/generated/ios/swift/HybridTickleSpec.swift +69 -0
  65. package/nitrogen/generated/ios/swift/HybridTickleSpec_cxx.swift +282 -0
  66. package/nitrogen/generated/shared/c++/HapticCurve.hpp +96 -0
  67. package/nitrogen/generated/shared/c++/HapticCurveControlPoint.hpp +87 -0
  68. package/nitrogen/generated/shared/c++/HapticEvent.hpp +101 -0
  69. package/nitrogen/generated/shared/c++/HapticEventParameter.hpp +88 -0
  70. package/nitrogen/generated/shared/c++/HapticEventType.hpp +76 -0
  71. package/nitrogen/generated/shared/c++/HapticImpactStyle.hpp +88 -0
  72. package/nitrogen/generated/shared/c++/HapticNotificationType.hpp +80 -0
  73. package/nitrogen/generated/shared/c++/HapticParameterType.hpp +76 -0
  74. package/nitrogen/generated/shared/c++/HybridTickleSpec.cpp +34 -0
  75. package/nitrogen/generated/shared/c++/HybridTickleSpec.hpp +87 -0
  76. package/package.json +179 -0
  77. package/react-native.config.js +8 -0
  78. package/src/Tickle.nitro.ts +84 -0
  79. package/src/index.tsx +306 -0
@@ -0,0 +1,40 @@
1
+ ///
2
+ /// HapticEventType.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 `HapticEventType`, backed by a C++ enum.
10
+ */
11
+ public typealias HapticEventType = margelo.nitro.tickle.HapticEventType
12
+
13
+ public extension HapticEventType {
14
+ /**
15
+ * Get a HapticEventType 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 "transient":
21
+ self = .transient
22
+ case "continuous":
23
+ self = .continuous
24
+ default:
25
+ return nil
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Get the String value this HapticEventType represents.
31
+ */
32
+ var stringValue: String {
33
+ switch self {
34
+ case .transient:
35
+ return "transient"
36
+ case .continuous:
37
+ return "continuous"
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,52 @@
1
+ ///
2
+ /// HapticImpactStyle.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 `HapticImpactStyle`, backed by a C++ enum.
10
+ */
11
+ public typealias HapticImpactStyle = margelo.nitro.tickle.HapticImpactStyle
12
+
13
+ public extension HapticImpactStyle {
14
+ /**
15
+ * Get a HapticImpactStyle 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 "rigid":
21
+ self = .rigid
22
+ case "heavy":
23
+ self = .heavy
24
+ case "medium":
25
+ self = .medium
26
+ case "light":
27
+ self = .light
28
+ case "soft":
29
+ self = .soft
30
+ default:
31
+ return nil
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Get the String value this HapticImpactStyle represents.
37
+ */
38
+ var stringValue: String {
39
+ switch self {
40
+ case .rigid:
41
+ return "rigid"
42
+ case .heavy:
43
+ return "heavy"
44
+ case .medium:
45
+ return "medium"
46
+ case .light:
47
+ return "light"
48
+ case .soft:
49
+ return "soft"
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// HapticNotificationType.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 `HapticNotificationType`, backed by a C++ enum.
10
+ */
11
+ public typealias HapticNotificationType = margelo.nitro.tickle.HapticNotificationType
12
+
13
+ public extension HapticNotificationType {
14
+ /**
15
+ * Get a HapticNotificationType 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 "error":
21
+ self = .error
22
+ case "success":
23
+ self = .success
24
+ case "warning":
25
+ self = .warning
26
+ default:
27
+ return nil
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Get the String value this HapticNotificationType represents.
33
+ */
34
+ var stringValue: String {
35
+ switch self {
36
+ case .error:
37
+ return "error"
38
+ case .success:
39
+ return "success"
40
+ case .warning:
41
+ return "warning"
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,40 @@
1
+ ///
2
+ /// HapticParameterType.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 `HapticParameterType`, backed by a C++ enum.
10
+ */
11
+ public typealias HapticParameterType = margelo.nitro.tickle.HapticParameterType
12
+
13
+ public extension HapticParameterType {
14
+ /**
15
+ * Get a HapticParameterType 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 "intensity":
21
+ self = .intensity
22
+ case "sharpness":
23
+ self = .sharpness
24
+ default:
25
+ return nil
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Get the String value this HapticParameterType represents.
31
+ */
32
+ var stringValue: String {
33
+ switch self {
34
+ case .intensity:
35
+ return "intensity"
36
+ case .sharpness:
37
+ return "sharpness"
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,69 @@
1
+ ///
2
+ /// HybridTickleSpec.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 Foundation
9
+ import NitroModules
10
+
11
+ /// See ``HybridTickleSpec``
12
+ public protocol HybridTickleSpec_protocol: HybridObject {
13
+ // Properties
14
+
15
+
16
+ // Methods
17
+ func startHaptic(events: [HapticEvent], curves: [HapticCurve]) throws -> Void
18
+ func stopAllHaptics() throws -> Void
19
+ func initializeEngine() throws -> Void
20
+ func destroyEngine() throws -> Void
21
+ func createContinuousPlayer(playerId: String, initialIntensity: Double, initialSharpness: Double) throws -> Void
22
+ func startContinuousPlayer(playerId: String) throws -> Void
23
+ func updateContinuousPlayer(playerId: String, intensityControl: Double, sharpnessControl: Double) throws -> Void
24
+ func stopContinuousPlayer(playerId: String) throws -> Void
25
+ func destroyContinuousPlayer(playerId: String) throws -> Void
26
+ func setHapticsEnabled(enabled: Bool) throws -> Void
27
+ func getHapticsEnabled() throws -> Bool
28
+ func triggerImpact(style: HapticImpactStyle) throws -> Void
29
+ func triggerNotification(type: HapticNotificationType) throws -> Void
30
+ func triggerSelection() throws -> Void
31
+ }
32
+
33
+ public extension HybridTickleSpec_protocol {
34
+ /// Default implementation of ``HybridObject.toString``
35
+ func toString() -> String {
36
+ return "[HybridObject Tickle]"
37
+ }
38
+ }
39
+
40
+ /// See ``HybridTickleSpec``
41
+ open class HybridTickleSpec_base {
42
+ private weak var cxxWrapper: HybridTickleSpec_cxx? = nil
43
+ public init() { }
44
+ public func getCxxWrapper() -> HybridTickleSpec_cxx {
45
+ #if DEBUG
46
+ guard self is HybridTickleSpec else {
47
+ fatalError("`self` is not a `HybridTickleSpec`! Did you accidentally inherit from `HybridTickleSpec_base` instead of `HybridTickleSpec`?")
48
+ }
49
+ #endif
50
+ if let cxxWrapper = self.cxxWrapper {
51
+ return cxxWrapper
52
+ } else {
53
+ let cxxWrapper = HybridTickleSpec_cxx(self as! HybridTickleSpec)
54
+ self.cxxWrapper = cxxWrapper
55
+ return cxxWrapper
56
+ }
57
+ }
58
+ }
59
+
60
+ /**
61
+ * A Swift base-protocol representing the Tickle HybridObject.
62
+ * Implement this protocol to create Swift-based instances of Tickle.
63
+ * ```swift
64
+ * class HybridTickle : HybridTickleSpec {
65
+ * // ...
66
+ * }
67
+ * ```
68
+ */
69
+ public typealias HybridTickleSpec = HybridTickleSpec_protocol & HybridTickleSpec_base
@@ -0,0 +1,282 @@
1
+ ///
2
+ /// HybridTickleSpec_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 Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * A class implementation that bridges HybridTickleSpec over to C++.
13
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14
+ *
15
+ * Also, some Swift types need to be bridged with special handling:
16
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
17
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
19
+ */
20
+ open class HybridTickleSpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::tickle::bridge::swift`)
23
+ * from `Tickle-Swift-Cxx-Bridge.hpp`.
24
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
25
+ */
26
+ public typealias bridge = margelo.nitro.tickle.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridTickleSpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridTickleSpec
32
+
33
+ /**
34
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
35
+ */
36
+ private var __cxxPart: bridge.std__weak_ptr_HybridTickleSpec_
37
+
38
+ /**
39
+ * Create a new `HybridTickleSpec_cxx` that wraps the given `HybridTickleSpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridTickleSpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridTickleSpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridTickleSpec() -> any HybridTickleSpec {
53
+ return __implementation
54
+ }
55
+
56
+ /**
57
+ * Casts this instance to a retained unsafe raw pointer.
58
+ * This acquires one additional strong reference on the object!
59
+ */
60
+ public func toUnsafe() -> UnsafeMutableRawPointer {
61
+ return Unmanaged.passRetained(self).toOpaque()
62
+ }
63
+
64
+ /**
65
+ * Casts an unsafe pointer to a `HybridTickleSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridTickleSpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridTickleSpec_cxx {
70
+ return Unmanaged<HybridTickleSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
71
+ }
72
+
73
+ /**
74
+ * Gets (or creates) the C++ part of this Hybrid Object.
75
+ * The C++ part is a `std::shared_ptr<HybridTickleSpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridTickleSpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if Bool(fromCxx: cachedCxxPart) {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridTickleSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridTickleSpec_(newCxxPart)
84
+ return newCxxPart
85
+ }
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Get the memory size of the Swift class (plus size of any other allocations)
92
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
93
+ */
94
+ @inline(__always)
95
+ public var memorySize: Int {
96
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
+ }
98
+
99
+ /**
100
+ * Compares this object with the given [other] object for reference equality.
101
+ */
102
+ @inline(__always)
103
+ public func equals(other: HybridTickleSpec_cxx) -> Bool {
104
+ return self.__implementation === other.__implementation
105
+ }
106
+
107
+ /**
108
+ * Call dispose() on the Swift class.
109
+ * This _may_ be called manually from JS.
110
+ */
111
+ @inline(__always)
112
+ public func dispose() {
113
+ self.__implementation.dispose()
114
+ }
115
+
116
+ /**
117
+ * Call toString() on the Swift class.
118
+ */
119
+ @inline(__always)
120
+ public func toString() -> String {
121
+ return self.__implementation.toString()
122
+ }
123
+
124
+ // Properties
125
+
126
+
127
+ // Methods
128
+ @inline(__always)
129
+ public final func startHaptic(events: bridge.std__vector_HapticEvent_, curves: bridge.std__vector_HapticCurve_) -> bridge.Result_void_ {
130
+ do {
131
+ try self.__implementation.startHaptic(events: events.map({ __item in __item }), curves: curves.map({ __item in __item }))
132
+ return bridge.create_Result_void_()
133
+ } catch (let __error) {
134
+ let __exceptionPtr = __error.toCpp()
135
+ return bridge.create_Result_void_(__exceptionPtr)
136
+ }
137
+ }
138
+
139
+ @inline(__always)
140
+ public final func stopAllHaptics() -> bridge.Result_void_ {
141
+ do {
142
+ try self.__implementation.stopAllHaptics()
143
+ return bridge.create_Result_void_()
144
+ } catch (let __error) {
145
+ let __exceptionPtr = __error.toCpp()
146
+ return bridge.create_Result_void_(__exceptionPtr)
147
+ }
148
+ }
149
+
150
+ @inline(__always)
151
+ public final func initializeEngine() -> bridge.Result_void_ {
152
+ do {
153
+ try self.__implementation.initializeEngine()
154
+ return bridge.create_Result_void_()
155
+ } catch (let __error) {
156
+ let __exceptionPtr = __error.toCpp()
157
+ return bridge.create_Result_void_(__exceptionPtr)
158
+ }
159
+ }
160
+
161
+ @inline(__always)
162
+ public final func destroyEngine() -> bridge.Result_void_ {
163
+ do {
164
+ try self.__implementation.destroyEngine()
165
+ return bridge.create_Result_void_()
166
+ } catch (let __error) {
167
+ let __exceptionPtr = __error.toCpp()
168
+ return bridge.create_Result_void_(__exceptionPtr)
169
+ }
170
+ }
171
+
172
+ @inline(__always)
173
+ public final func createContinuousPlayer(playerId: std.string, initialIntensity: Double, initialSharpness: Double) -> bridge.Result_void_ {
174
+ do {
175
+ try self.__implementation.createContinuousPlayer(playerId: String(playerId), initialIntensity: initialIntensity, initialSharpness: initialSharpness)
176
+ return bridge.create_Result_void_()
177
+ } catch (let __error) {
178
+ let __exceptionPtr = __error.toCpp()
179
+ return bridge.create_Result_void_(__exceptionPtr)
180
+ }
181
+ }
182
+
183
+ @inline(__always)
184
+ public final func startContinuousPlayer(playerId: std.string) -> bridge.Result_void_ {
185
+ do {
186
+ try self.__implementation.startContinuousPlayer(playerId: String(playerId))
187
+ return bridge.create_Result_void_()
188
+ } catch (let __error) {
189
+ let __exceptionPtr = __error.toCpp()
190
+ return bridge.create_Result_void_(__exceptionPtr)
191
+ }
192
+ }
193
+
194
+ @inline(__always)
195
+ public final func updateContinuousPlayer(playerId: std.string, intensityControl: Double, sharpnessControl: Double) -> bridge.Result_void_ {
196
+ do {
197
+ try self.__implementation.updateContinuousPlayer(playerId: String(playerId), intensityControl: intensityControl, sharpnessControl: sharpnessControl)
198
+ return bridge.create_Result_void_()
199
+ } catch (let __error) {
200
+ let __exceptionPtr = __error.toCpp()
201
+ return bridge.create_Result_void_(__exceptionPtr)
202
+ }
203
+ }
204
+
205
+ @inline(__always)
206
+ public final func stopContinuousPlayer(playerId: std.string) -> bridge.Result_void_ {
207
+ do {
208
+ try self.__implementation.stopContinuousPlayer(playerId: String(playerId))
209
+ return bridge.create_Result_void_()
210
+ } catch (let __error) {
211
+ let __exceptionPtr = __error.toCpp()
212
+ return bridge.create_Result_void_(__exceptionPtr)
213
+ }
214
+ }
215
+
216
+ @inline(__always)
217
+ public final func destroyContinuousPlayer(playerId: std.string) -> bridge.Result_void_ {
218
+ do {
219
+ try self.__implementation.destroyContinuousPlayer(playerId: String(playerId))
220
+ return bridge.create_Result_void_()
221
+ } catch (let __error) {
222
+ let __exceptionPtr = __error.toCpp()
223
+ return bridge.create_Result_void_(__exceptionPtr)
224
+ }
225
+ }
226
+
227
+ @inline(__always)
228
+ public final func setHapticsEnabled(enabled: Bool) -> bridge.Result_void_ {
229
+ do {
230
+ try self.__implementation.setHapticsEnabled(enabled: enabled)
231
+ return bridge.create_Result_void_()
232
+ } catch (let __error) {
233
+ let __exceptionPtr = __error.toCpp()
234
+ return bridge.create_Result_void_(__exceptionPtr)
235
+ }
236
+ }
237
+
238
+ @inline(__always)
239
+ public final func getHapticsEnabled() -> bridge.Result_bool_ {
240
+ do {
241
+ let __result = try self.__implementation.getHapticsEnabled()
242
+ let __resultCpp = __result
243
+ return bridge.create_Result_bool_(__resultCpp)
244
+ } catch (let __error) {
245
+ let __exceptionPtr = __error.toCpp()
246
+ return bridge.create_Result_bool_(__exceptionPtr)
247
+ }
248
+ }
249
+
250
+ @inline(__always)
251
+ public final func triggerImpact(style: Int32) -> bridge.Result_void_ {
252
+ do {
253
+ try self.__implementation.triggerImpact(style: margelo.nitro.tickle.HapticImpactStyle(rawValue: style)!)
254
+ return bridge.create_Result_void_()
255
+ } catch (let __error) {
256
+ let __exceptionPtr = __error.toCpp()
257
+ return bridge.create_Result_void_(__exceptionPtr)
258
+ }
259
+ }
260
+
261
+ @inline(__always)
262
+ public final func triggerNotification(type: Int32) -> bridge.Result_void_ {
263
+ do {
264
+ try self.__implementation.triggerNotification(type: margelo.nitro.tickle.HapticNotificationType(rawValue: type)!)
265
+ return bridge.create_Result_void_()
266
+ } catch (let __error) {
267
+ let __exceptionPtr = __error.toCpp()
268
+ return bridge.create_Result_void_(__exceptionPtr)
269
+ }
270
+ }
271
+
272
+ @inline(__always)
273
+ public final func triggerSelection() -> bridge.Result_void_ {
274
+ do {
275
+ try self.__implementation.triggerSelection()
276
+ return bridge.create_Result_void_()
277
+ } catch (let __error) {
278
+ let __exceptionPtr = __error.toCpp()
279
+ return bridge.create_Result_void_(__exceptionPtr)
280
+ }
281
+ }
282
+ }
@@ -0,0 +1,96 @@
1
+ ///
2
+ /// HapticCurve.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/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+ // Forward declaration of `HapticParameterType` to properly resolve imports.
32
+ namespace margelo::nitro::tickle { enum class HapticParameterType; }
33
+ // Forward declaration of `HapticCurveControlPoint` to properly resolve imports.
34
+ namespace margelo::nitro::tickle { struct HapticCurveControlPoint; }
35
+
36
+ #include "HapticParameterType.hpp"
37
+ #include "HapticCurveControlPoint.hpp"
38
+ #include <vector>
39
+
40
+ namespace margelo::nitro::tickle {
41
+
42
+ /**
43
+ * A struct which can be represented as a JavaScript object (HapticCurve).
44
+ */
45
+ struct HapticCurve final {
46
+ public:
47
+ HapticParameterType type SWIFT_PRIVATE;
48
+ std::vector<HapticCurveControlPoint> controlPoints SWIFT_PRIVATE;
49
+ double relativeTime SWIFT_PRIVATE;
50
+
51
+ public:
52
+ HapticCurve() = default;
53
+ explicit HapticCurve(HapticParameterType type, std::vector<HapticCurveControlPoint> controlPoints, double relativeTime): type(type), controlPoints(controlPoints), relativeTime(relativeTime) {}
54
+
55
+ public:
56
+ friend bool operator==(const HapticCurve& lhs, const HapticCurve& rhs) = default;
57
+ };
58
+
59
+ } // namespace margelo::nitro::tickle
60
+
61
+ namespace margelo::nitro {
62
+
63
+ // C++ HapticCurve <> JS HapticCurve (object)
64
+ template <>
65
+ struct JSIConverter<margelo::nitro::tickle::HapticCurve> final {
66
+ static inline margelo::nitro::tickle::HapticCurve fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
67
+ jsi::Object obj = arg.asObject(runtime);
68
+ return margelo::nitro::tickle::HapticCurve(
69
+ JSIConverter<margelo::nitro::tickle::HapticParameterType>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type"))),
70
+ JSIConverter<std::vector<margelo::nitro::tickle::HapticCurveControlPoint>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "controlPoints"))),
71
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "relativeTime")))
72
+ );
73
+ }
74
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::tickle::HapticCurve& arg) {
75
+ jsi::Object obj(runtime);
76
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "type"), JSIConverter<margelo::nitro::tickle::HapticParameterType>::toJSI(runtime, arg.type));
77
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "controlPoints"), JSIConverter<std::vector<margelo::nitro::tickle::HapticCurveControlPoint>>::toJSI(runtime, arg.controlPoints));
78
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "relativeTime"), JSIConverter<double>::toJSI(runtime, arg.relativeTime));
79
+ return obj;
80
+ }
81
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
82
+ if (!value.isObject()) {
83
+ return false;
84
+ }
85
+ jsi::Object obj = value.getObject(runtime);
86
+ if (!nitro::isPlainObject(runtime, obj)) {
87
+ return false;
88
+ }
89
+ if (!JSIConverter<margelo::nitro::tickle::HapticParameterType>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))) return false;
90
+ if (!JSIConverter<std::vector<margelo::nitro::tickle::HapticCurveControlPoint>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "controlPoints")))) return false;
91
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "relativeTime")))) return false;
92
+ return true;
93
+ }
94
+ };
95
+
96
+ } // namespace margelo::nitro